Documentation
¶
Index ¶
- type StackEthernet
- func (ls *StackEthernet) Configure(cfg StackEthernetConfig) error
- func (ls *StackEthernet) ConnectionID() *uint64
- func (ls *StackEthernet) Demux(carrierData []byte, frameOffset int) (err error)
- func (ls *StackEthernet) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (n int, err error)
- func (ls *StackEthernet) Gateway6() (gw [6]byte)
- func (ls *StackEthernet) HardwareAddr6() [6]byte
- func (ls *StackEthernet) LocalPort() uint16
- func (ls *StackEthernet) MTU() int
- func (ls *StackEthernet) MaxFrameLength() int
- func (ls *StackEthernet) Protocol() uint64
- func (ls *StackEthernet) Register(h lneto.StackNode) error
- func (ls *StackEthernet) Reset6(mac, gateway [6]byte, mtu, maxNodes int) errordeprecated
- func (ls *StackEthernet) SetAcceptMulticast(accept bool)
- func (ls *StackEthernet) SetGateway6(gw [6]byte)
- func (ls *StackEthernet) SetHardwareAddr6(mac [6]byte)
- type StackEthernetConfig
- type StackIP
- func (sb *StackIP) Addr() netip.Addr
- func (sb *StackIP) ConnectionID() *uint64
- func (sb *StackIP) Demux(carrierData []byte, offset int) error
- func (sb *StackIP) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (int, error)
- func (sb *StackIP) IsRegistered(proto lneto.IPProto) bool
- func (sb *StackIP) LocalPort() uint16
- func (sb *StackIP) Protocol() uint64
- func (sb *StackIP) Register(h lneto.StackNode) error
- func (sb *StackIP) Reset(addr netip.Addr, maxNodes int) error
- func (sb *StackIP) SetAcceptMulticast(accept bool)
- func (sb *StackIP) SetAddr(addr netip.Addr) error
- func (sb *StackIP) SetLogger(logger *slog.Logger)
- type StackPorts
- func (ps *StackPorts) ConnectionID() *uint64
- func (ps *StackPorts) Demux(b []byte, offset int) (err error)
- func (ps *StackPorts) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (n int, err error)
- func (ps *StackPorts) LocalPort() uint16
- func (ps *StackPorts) Protocol() uint64
- func (ps *StackPorts) Register(h lneto.StackNode) error
- func (ps *StackPorts) Reset(protocol uint64, dstPortOffset, maxNodes uint16) error
- func (ps *StackPorts) ResetTCP(maxNodes uint16) error
- func (ps *StackPorts) ResetUDP(maxNodes uint16) error
- type StackPortsMACFiltered
- func (ps *StackPortsMACFiltered) ConnectionID() *uint64
- func (ps *StackPortsMACFiltered) Demux(b []byte, offset int) (err error)
- func (ps *StackPortsMACFiltered) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (n int, err error)
- func (ps *StackPortsMACFiltered) LocalPort() uint16
- func (ps *StackPortsMACFiltered) Protocol() uint64
- func (mfsp *StackPortsMACFiltered) Register(h lneto.StackNode, addr []byte) error
- func (ps *StackPortsMACFiltered) Reset(protocol uint64, dstPortOffset, maxNodes uint16) error
- func (ps *StackPortsMACFiltered) ResetTCP(maxNodes uint16) error
- func (ps *StackPortsMACFiltered) ResetUDP(maxNodes uint16) error
- type StackUDPPort
- func (sudp *StackUDPPort) ConnectionID() *uint64
- func (sudp *StackUDPPort) Demux(carrierData []byte, frameOffset int) error
- func (sudp *StackUDPPort) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (int, error)
- func (sudp *StackUDPPort) LocalPort() uint16
- func (sudp *StackUDPPort) Protocol() uint64
- func (sudp *StackUDPPort) SetStackNode(node lneto.StackNode, raddr []byte, rmport uint16)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StackEthernet ¶
type StackEthernet struct {
// contains filtered or unexported fields
}
func (*StackEthernet) Configure ¶
func (ls *StackEthernet) Configure(cfg StackEthernetConfig) error
Configure resets and configures the ethernet stack with the given configuration. It validates the configuration parameters and resets internal state. The connection ID is incremented on each call to invalidate existing connections.
func (*StackEthernet) ConnectionID ¶
func (ls *StackEthernet) ConnectionID() *uint64
func (*StackEthernet) Demux ¶
func (ls *StackEthernet) Demux(carrierData []byte, frameOffset int) (err error)
func (*StackEthernet) Encapsulate ¶
func (ls *StackEthernet) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (n int, err error)
func (*StackEthernet) Gateway6 ¶
func (ls *StackEthernet) Gateway6() (gw [6]byte)
func (*StackEthernet) HardwareAddr6 ¶
func (ls *StackEthernet) HardwareAddr6() [6]byte
func (*StackEthernet) LocalPort ¶
func (ls *StackEthernet) LocalPort() uint16
func (*StackEthernet) MTU ¶
func (ls *StackEthernet) MTU() int
MTU is the Maximum Transmission Unit of the stack corresponding to the maximum payload size of an ethernet frame that can be sent through the stack. Important to note that the actual ethernet frame size is MTU + Ethernet header (14) + CRC (4 if enabled), this is known as the Maximum Frame Length.
func (*StackEthernet) MaxFrameLength ¶
func (ls *StackEthernet) MaxFrameLength() int
MaxFrameLength returns the maximum ethernet frame length in bytes, which is the MTU plus the Ethernet header (14 bytes) and CRC (4 bytes if enabled). This is the maximum size of an Ethernet frame that can be sent from the stack.
func (*StackEthernet) Protocol ¶
func (ls *StackEthernet) Protocol() uint64
func (*StackEthernet) Reset6
deprecated
func (ls *StackEthernet) Reset6(mac, gateway [6]byte, mtu, maxNodes int) error
Reset6 resets the stack with the given parameters.
Deprecated: Use StackEthernet.Configure instead.
func (*StackEthernet) SetAcceptMulticast ¶
func (ls *StackEthernet) SetAcceptMulticast(accept bool)
func (*StackEthernet) SetGateway6 ¶
func (ls *StackEthernet) SetGateway6(gw [6]byte)
func (*StackEthernet) SetHardwareAddr6 ¶
func (ls *StackEthernet) SetHardwareAddr6(mac [6]byte)
type StackEthernetConfig ¶
type StackEthernetConfig struct {
// MTU is the Maximum Transmission Unit, representing the maximum ethernet
// payload size in bytes (excluding the 14-byte ethernet header).
// Standard ethernet MTU is 1500. Must be between 256 and 65535.
MTU int
// MaxNodes is the maximum number of protocol handlers (e.g., IP, ARP)
// that can be registered with the stack. Must be greater than 0.
MaxNodes int
// MAC is the local hardware (MAC) address for this ethernet interface.
MAC [6]byte
// Gateway is the hardware (MAC) address of the default gateway.
// Outgoing frames will be addressed to this MAC.
Gateway [6]byte
// AppendCRC32, if true, appends a 32-bit CRC to outgoing frames.
// Only needed if the PHY does not handle CRC generation.
AppendCRC32 bool
// CRC32Update is a IEEE CRC32 implementation that should be provided if AppendCRC32 is set.
CRC32Update func(crc uint32, p []byte) uint32
}
StackEthernetConfig contains configuration parameters for StackEthernet.
type StackIP ¶
type StackIP struct {
// contains filtered or unexported fields
}
func (*StackIP) ConnectionID ¶
func (*StackIP) Encapsulate ¶
func (*StackIP) SetAcceptMulticast ¶
type StackPorts ¶
type StackPorts struct {
// contains filtered or unexported fields
}
func (*StackPorts) ConnectionID ¶
func (ps *StackPorts) ConnectionID() *uint64
func (*StackPorts) Encapsulate ¶
func (ps *StackPorts) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (n int, err error)
func (*StackPorts) LocalPort ¶
func (ps *StackPorts) LocalPort() uint16
func (*StackPorts) Protocol ¶
func (ps *StackPorts) Protocol() uint64
func (*StackPorts) Register ¶
func (ps *StackPorts) Register(h lneto.StackNode) error
Register registers a port StackNode on StackPorts. If dstMAC is set to non-nil, length six buffer then
func (*StackPorts) Reset ¶
func (ps *StackPorts) Reset(protocol uint64, dstPortOffset, maxNodes uint16) error
func (*StackPorts) ResetTCP ¶
func (ps *StackPorts) ResetTCP(maxNodes uint16) error
func (*StackPorts) ResetUDP ¶
func (ps *StackPorts) ResetUDP(maxNodes uint16) error
type StackPortsMACFiltered ¶
type StackPortsMACFiltered struct {
// contains filtered or unexported fields
}
StackPortsMACFiltered is a StackPorts implementation but that avoids calling encapsulate on nodes with a non-nil MAC address registered via Register method that is set to all zero values. If the address is set to nil no filtering occurs. MAC Address is set automatically on the ethernet frame by StackPortsMACFiltered when non-nil.
func (*StackPortsMACFiltered) ConnectionID ¶
func (ps *StackPortsMACFiltered) ConnectionID() *uint64
func (*StackPortsMACFiltered) Demux ¶
func (ps *StackPortsMACFiltered) Demux(b []byte, offset int) (err error)
func (*StackPortsMACFiltered) Encapsulate ¶
func (ps *StackPortsMACFiltered) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (n int, err error)
func (*StackPortsMACFiltered) LocalPort ¶
func (ps *StackPortsMACFiltered) LocalPort() uint16
func (*StackPortsMACFiltered) Protocol ¶
func (ps *StackPortsMACFiltered) Protocol() uint64
func (*StackPortsMACFiltered) Register ¶
func (mfsp *StackPortsMACFiltered) Register(h lneto.StackNode, addr []byte) error
func (*StackPortsMACFiltered) Reset ¶
func (ps *StackPortsMACFiltered) Reset(protocol uint64, dstPortOffset, maxNodes uint16) error
func (*StackPortsMACFiltered) ResetTCP ¶
func (ps *StackPortsMACFiltered) ResetTCP(maxNodes uint16) error
func (*StackPortsMACFiltered) ResetUDP ¶
func (ps *StackPortsMACFiltered) ResetUDP(maxNodes uint16) error
type StackUDPPort ¶
type StackUDPPort struct {
// contains filtered or unexported fields
}
func (*StackUDPPort) ConnectionID ¶
func (sudp *StackUDPPort) ConnectionID() *uint64
func (*StackUDPPort) Demux ¶
func (sudp *StackUDPPort) Demux(carrierData []byte, frameOffset int) error
func (*StackUDPPort) Encapsulate ¶
func (sudp *StackUDPPort) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (int, error)
func (*StackUDPPort) LocalPort ¶
func (sudp *StackUDPPort) LocalPort() uint16
func (*StackUDPPort) Protocol ¶
func (sudp *StackUDPPort) Protocol() uint64
func (*StackUDPPort) SetStackNode ¶
func (sudp *StackUDPPort) SetStackNode(node lneto.StackNode, raddr []byte, rmport uint16)