tlv

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeHeader message.Type = 0

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

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

	// 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 (
	// 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) (*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