tlv

package
v0.0.0-...-25ef478 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 3

Documentation

Index

Constants

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
)

Variables

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,
	}
)

Functions

func WriteHeader

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

WriteHeader writes a TLV header into the given Writer.

Types

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.

Jump to

Keyboard shortcuts

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