Documentation
¶
Index ¶
- Constants
- func IPChecksum(hdr []byte) uint16
- func IPv6Checksum(src, dst [16]byte, protocol uint8, upperLayerPacketLength uint32, data []byte) uint16
- func RandUint32() uint32
- func SeqAfter(a, b uint32) bool
- func TCPChecksum(src, dst []byte, tcp []byte, payload []byte) uint16
- func UDPChecksum(src, dst []byte, udp []byte, payload []byte) uint16
- type Listener
- type Listener6
- type Stack
- func (s *Stack) Addr() netip.Prefix
- func (s *Stack) Close() error
- func (s *Stack) ConnectL3(dev pktkit.L3Device) (func() error, error)
- func (s *Stack) Listen(network, address string) (net.Listener, error)
- func (s *Stack) Send(pkt pktkit.Packet) error
- func (s *Stack) SetAddr(p netip.Prefix) error
- func (s *Stack) SetHandler(h func(pktkit.Packet) error)
Constants ¶
const ( ICMPv6TypeEchoRequest = 128 ICMPv6TypeEchoReply = 129 ICMPv6TypeRouterSolicitation = 133 ICMPv6TypeRouterAdvertisement = 134 ICMPv6TypeNeighborSolicitation = 135 ICMPv6TypeNeighborAdvertisement = 136 )
ICMPv6 Type codes
Variables ¶
This section is empty.
Functions ¶
func IPChecksum ¶
Utilities shared by TCP/UDP IPChecksum computes the Internet checksum (RFC 1071) over the given header bytes.
func IPv6Checksum ¶
func IPv6Checksum(src, dst [16]byte, protocol uint8, upperLayerPacketLength uint32, data []byte) uint16
IPv6Checksum calculates the pseudo-header checksum for IPv6 TCP/UDP.
func SeqAfter ¶
SeqAfter reports whether TCP sequence number a is after b, handling 32-bit wraparound via signed comparison.
func TCPChecksum ¶
TCPChecksum computes the TCP checksum including the IPv4 pseudo-header.
Types ¶
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is a virtual network listener for TCP connections within the slirp stack.
type Listener6 ¶
type Listener6 struct {
// contains filtered or unexported fields
}
Listener6 is a virtual network listener for IPv6 TCP connections within the slirp stack.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack is a NAT/routing stack that implements pktkit.L3Device. Packets received via Send are routed to real network connections (NAT) or to virtual listeners. Responses are sent via the handler set with SetHandler.
For multi-tenant use, call Stack.ConnectL3 to create namespace-isolated inside L3Devices. Each namespace's connections are tracked independently, allowing overlapping inside IPs.
func (*Stack) Close ¶
Close shuts down the stack, stopping the maintenance goroutine and closing all active connections.
func (*Stack) ConnectL3 ¶
ConnectL3 implements pktkit.L3Connector. It creates a namespace-isolated L3Device on this stack. Packets from the device are tracked with a unique namespace ID, so multiple devices can use overlapping IPs without conflict.
func (*Stack) Listen ¶
Listen announces on the virtual network address. The network must be "tcp", "tcp4", or "tcp6". The address is the virtual IP:port to listen on within the slirp stack.
func (*Stack) Send ¶
Send delivers an IP packet to the stack for processing. Implements pktkit.L3Device.