packet

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: 0BSD Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MTU constants
	EncryptedMDU = 383 // Maximum size of payload data in encrypted packet
	PlainMDU     = 464 // Maximum size of payload data in unencrypted packet

	// Propagation Types
	PropagationBroadcast = 0
	PropagationTransport = 1

	// Destination Types
	DestinationSingle = 0
	DestinationGroup  = 1
	DestinationPlain  = 2
	DestinationLink   = 3

	// Minimum packet sizes
	MinAnnounceSize = 170 // header(2) + desthash(16) + context(1) + enckey(32) + signkey(32) +

)
View Source
const (
	// Packet Types
	PacketTypeData     = 0x00
	PacketTypeAnnounce = 0x01
	PacketTypeLinkReq  = 0x02
	PacketTypeProof    = 0x03

	// Header Types
	HeaderType1 = 0x00
	HeaderType2 = 0x01

	// Context Types
	ContextNone         = 0x00
	ContextResource     = 0x01
	ContextResourceAdv  = 0x02
	ContextResourceReq  = 0x03
	ContextResourceHMU  = 0x04
	ContextResourcePRF  = 0x05
	ContextResourceICL  = 0x06
	ContextResourceRCL  = 0x07
	ContextCacheReq     = 0x08
	ContextRequest      = 0x09
	ContextResponse     = 0x0A
	ContextPathResponse = 0x0B
	ContextCommand      = 0x0C
	ContextCmdStatus    = 0x0D
	ContextChannel      = 0x0E
	ContextKeepalive    = 0xFA
	ContextLinkIdentify = 0xFB
	ContextLinkClose    = 0xFC
	ContextLinkProof    = 0xFD
	ContextLRRTT        = 0xFE
	ContextLRProof      = 0xFF

	// Flag Values
	FlagSet   = 0x01
	FlagUnset = 0x00

	// Header sizes
	HeaderMaxSize = 64
	MTU           = 500

	AddressSize = 32 // Size of address/hash fields in bytes
)
View Source
const (
	RECEIPT_FAILED    = 0x00
	RECEIPT_SENT      = 0x01
	RECEIPT_DELIVERED = 0x02
	RECEIPT_CULLED    = 0xFF

	EXPL_LENGTH = (identity.HASHLENGTH + identity.SIGLENGTH) / 8
	IMPL_LENGTH = identity.SIGLENGTH / 8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Packet

type Packet struct {
	HeaderType    byte
	PacketType    byte
	TransportType byte
	Context       byte
	ContextFlag   byte
	Hops          byte

	DestinationType byte
	DestinationHash []byte
	Destination     interface{}
	TransportID     []byte
	Data            []byte

	Raw           []byte
	Packed        bool
	Sent          bool
	CreateReceipt bool
	FromPacked    bool

	SentAt     time.Time
	PacketHash []byte
	RatchetID  []byte

	RSSI *float64
	SNR  *float64
	Q    *float64

	Addresses []byte
	Link      interface{}
	// contains filtered or unexported fields
}

func NewAnnouncePacket

func NewAnnouncePacket(destHash []byte, identity *identity.Identity, appData []byte, transportID []byte) (*Packet, error)

func NewPacket

func NewPacket(destType byte, data []byte, packetType byte, context byte,
	transportType byte, headerType byte, transportID []byte, createReceipt bool,
	contextFlag byte) *Packet

func (*Packet) GetHash

func (p *Packet) GetHash() []byte

func (*Packet) Hash

func (p *Packet) Hash() []byte

func (*Packet) Pack

func (p *Packet) Pack() error

func (*Packet) Serialize

func (p *Packet) Serialize() ([]byte, error)

func (*Packet) TruncatedHash

func (p *Packet) TruncatedHash() []byte

func (*Packet) Unpack

func (p *Packet) Unpack() error

type PacketConfig

type PacketConfig struct {
	DestType      byte
	Data          []byte
	PacketType    byte
	Context       byte
	TransportType byte
	HeaderType    byte
	TransportID   []byte
	CreateReceipt bool
	ContextFlag   byte
}

type PacketReceipt

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

func NewPacketReceipt

func NewPacketReceipt(pkt *Packet) *PacketReceipt

func (*PacketReceipt) Cancel

func (pr *PacketReceipt) Cancel()

func (*PacketReceipt) GetHash

func (pr *PacketReceipt) GetHash() []byte

func (*PacketReceipt) GetRTT

func (pr *PacketReceipt) GetRTT() time.Duration

func (*PacketReceipt) GetStatus

func (pr *PacketReceipt) GetStatus() byte

func (*PacketReceipt) IsDelivered

func (pr *PacketReceipt) IsDelivered() bool

func (*PacketReceipt) IsFailed

func (pr *PacketReceipt) IsFailed() bool

func (*PacketReceipt) IsTimedOut

func (pr *PacketReceipt) IsTimedOut() bool

func (*PacketReceipt) SetDeliveryCallback

func (pr *PacketReceipt) SetDeliveryCallback(callback func(*PacketReceipt))

func (*PacketReceipt) SetDestinationIdentity

func (pr *PacketReceipt) SetDestinationIdentity(ident *identity.Identity)
func (pr *PacketReceipt) SetLink(link interface{})

func (*PacketReceipt) SetTimeout

func (pr *PacketReceipt) SetTimeout(timeout time.Duration)

func (*PacketReceipt) SetTimeoutCallback

func (pr *PacketReceipt) SetTimeoutCallback(callback func(*PacketReceipt))

func (*PacketReceipt) ValidateLinkProof

func (pr *PacketReceipt) ValidateLinkProof(proof []byte, link interface{}, proofPacket *Packet) bool

func (*PacketReceipt) ValidateProof

func (pr *PacketReceipt) ValidateProof(proof []byte, proofPacket *Packet) bool

func (*PacketReceipt) ValidateProofPacket

func (pr *PacketReceipt) ValidateProofPacket(proofPacket *Packet) bool

Jump to

Keyboard shortcuts

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