handshake

package
v0.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The amount of bytes used for the coo address sent in a handshake packet.
	ByteEncodedCooAddressBytesLength = 49
)
View Source
const (
	MessageTypeHandshake message.Type = 1
)

Variables

View Source
var (
	ErrVersionNotSupported = errors.New("version not supported")
)
View Source
var (
	// HandshakeMessageFormat defines a handshake message's format.
	// Made up of:
	// - own server socket port (2 bytes)
	// - time at which the packet was sent (8 bytes)
	// - own used byte encoded coordinator address (49 bytes)
	// - own used MWM (1 byte)
	// - supported protocol versions. we need up to 32 bytes to represent 256 possible protocol
	//   versions. only up to N bytes are used to communicate the highest supported version.
	HandshakeMessageDefinition = &message.Definition{
		ID:             MessageTypeHandshake,
		MaxBytesLength: 92,
		VariableLength: true,
	}
)

Functions

func NewHandshakeMessage

func NewHandshakeMessage(ownSupportedMessagesBitset *bitset.BitSet, ownSourcePort uint16, ownByteEncodedCooAddress []byte, ownUsedMWM byte) ([]byte, error)

NewHandshakeMessage creates a new handshake message.

Types

type Handshake

type Handshake struct {
	ServerSocketPort      uint16
	SentTimestamp         uint64
	ByteEncodedCooAddress []byte
	MWM                   byte
	SupportedVersions     []byte
}

Handshake defines information exchanged during the handshake phase between two peers.

func ParseHandshake

func ParseHandshake(msg []byte) (*Handshake, error)

ParseHandshake parses the given message into a Handshake.

func (Handshake) SupportedVersion

func (hs Handshake) SupportedVersion(ownSupportedMessagesBitset *bitset.BitSet) (version int, err error)

SupportedVersion returns the highest supported protocol version.

type HeaderState

type HeaderState int32

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL