packet_layer

package
v0.0.0-...-8e980cd Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PacketDecoder

type PacketDecoder struct {
	// contains filtered or unexported fields
}

func NewPacketDecoder

func NewPacketDecoder() *PacketDecoder

func (*PacketDecoder) AppendPacket

func (decoder *PacketDecoder) AppendPacket(packet []byte) error

AppendPacket adds a packet to the end of the decoder

func (*PacketDecoder) HasMessage

func (decoder *PacketDecoder) HasMessage() (bool, error)

HasMessage returns true if there are messages to be decoded

func (*PacketDecoder) PacketCount

func (decoder *PacketDecoder) PacketCount() int

func (*PacketDecoder) ReadMessage

func (decoder *PacketDecoder) ReadMessage() ([]byte, error)

ReadMessage decodes and removes the first message in the decoder

type PacketEncoder

type PacketEncoder struct {
	// contains filtered or unexported fields
}

func NewPacketEncoder

func NewPacketEncoder(packetSize int) *PacketEncoder

func (*PacketEncoder) EncodeMessage

func (encoder *PacketEncoder) EncodeMessage(message []byte) error

EncodeMessage encodes the given message to the last packet in the encoder potentially creating a new packet if it does not fit.

func (*PacketEncoder) PacketCount

func (encoder *PacketEncoder) PacketCount() int

func (*PacketEncoder) PacketSize

func (encoder *PacketEncoder) PacketSize() int

func (*PacketEncoder) PopPacket

func (encoder *PacketEncoder) PopPacket() []byte

PopPacket removes and returns the first packet in encoder

type PacketLayer

type PacketLayer struct {
	// contains filtered or unexported fields
}

func NewLinkLayer

func NewLinkLayer(dev device.Device, options device.ProtocolOptions) *PacketLayer

func (*PacketLayer) BroadcastBytes

func (link *PacketLayer) BroadcastBytes(data []byte)

func (*PacketLayer) BroadcastBytesExcept

func (link *PacketLayer) BroadcastBytesExcept(data []byte, exceptAddress device.DeviceAddress)

Broadcasts bytes to some of the neighbours, except for exceptAddress

func (*PacketLayer) OnConnection

func (link *PacketLayer) OnConnection(address device.DeviceAddress)

func (*PacketLayer) OnDisconnection

func (link *PacketLayer) OnDisconnection(address device.DeviceAddress)

func (*PacketLayer) ReceivePacket

func (link *PacketLayer) ReceivePacket(sender device.DeviceAddress, packet []byte) [][]byte

func (*PacketLayer) SendBytes

func (link *PacketLayer) SendBytes(address device.DeviceAddress, data []byte) bool

Jump to

Keyboard shortcuts

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