Version: v0.0.7 Latest Latest

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 0




View Source
const (
	// MessageTypeHeader is the unique id of a tlv header.
	MessageTypeHeader message.Type = 0

	// HeaderTypeBytesLength defines the amount of bytes dedicated for the message type in the packet header.
	HeaderTypeBytesLength = 1

	// HeaderLengthByteLength defines the amount of bytes dedicated for the message length denotation in the packet header.
	HeaderLengthByteLength = 2

	// HeaderBytesLength defines the amount of bytes making up the protocol TLV packet header.
	HeaderBytesLength = HeaderLengthByteLength + HeaderTypeBytesLength


View Source
var (
	// ErrInvalidMessageLength is returned when a packet advertises a message length which
	// is invalid for the given message type.
	ErrInvalidMessageLength = errors.New("invalid message length")
View Source
var (
	// HeaderMessageDefinition is the message header sent in each message denoting the TLV fields.
	HeaderMessageDefinition = &message.Definition{
		ID:             MessageTypeHeader,
		MaxBytesLength: HeaderBytesLength,
		VariableLength: false,


func WriteHeader

func WriteHeader(buf io.Writer, msgType message.Type, msgBytesLength uint16) error

WriteHeader writes a TLV header into the given Writer.


type Header struct {
	// The definition of the message.
	Definition *message.Definition
	// The length in bytes of the message.
	MessageBytesLength uint16

Header includes the definition of the message and its bytes length.

func ParseHeader

func ParseHeader(buf []byte, r *message.Registry) (*Header, error)

ParseHeader parses the given buffer to a Header.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL