netstack

package
v1.4.4-beta3 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: AGPL-3.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultStack

func NewDefaultStack(ipAddr string, macAddress string, networkIfaceGateway string, endpoint stack.LinkEndpoint, opts ...Option) (*stack.Stack, error)

Types

type Option

type Option func(*stack.Stack) error

func WithCreatingNIC

func WithCreatingNIC(nicId tcpip.NICID, ep stack.LinkEndpoint) Option

func WithDefault

func WithDefault() Option

WithDefault sets all default values for stack.

func WithDefaultTTL

func WithDefaultTTL(ttl uint8) Option

WithDefaultTTL sets the default TTL used by stack.

func WithForwarding

func WithForwarding(v bool) Option

WithForwarding sets packet forwarding between NICs for IPv4 & IPv6.

func WithICMPBurst

func WithICMPBurst(burst int) Option

WithICMPBurst sets the number of ICMP messages that can be sent in a single burst.

func WithICMPLimit

func WithICMPLimit(limit rate.Limit) Option

WithICMPLimit sets the maximum number of ICMP messages permitted by rate limiter.

func WithIPv4RouteTableDefaultGateway

func WithIPv4RouteTableDefaultGateway(nicID tcpip.NICID, gateway netip.Addr) Option

func WithMainNICIP

func WithMainNICIP(nicID tcpip.NICID, ip tcpip.Address, mac net.HardwareAddr) Option

func WithMulticastGroups

func WithMulticastGroups(nicID tcpip.NICID, multicastGroups []netip.Addr) Option

withMulticastGroups adds a NIC to the given multicast groups.

func WithPromiscuousMode

func WithPromiscuousMode(nicID tcpip.NICID, v bool) Option

WithPromiscuousMode sets promiscuous mode in the given NICs.

func WithRouteTable

func WithRouteTable(nicID tcpip.NICID) Option

func WithSpoofing

func WithSpoofing(nicID tcpip.NICID, v bool) Option

WithSpoofing sets address spoofing in the given NICs, allowing endpoints to bind to any address in the NIC.

func WithTCPCongestionControl

func WithTCPCongestionControl(cc string) Option

WithTCPCongestionControl sets the current congestion control algorithm.

func WithTCPDelay

func WithTCPDelay(v bool) Option

WithTCPDelay enables or disables Nagle's algorithm in TCP.

func WithTCPHandler

func WithTCPHandler(handle func(TCPConn)) Option

func WithTCPModerateReceiveBuffer

func WithTCPModerateReceiveBuffer(v bool) Option

WithTCPModerateReceiveBuffer sets receive buffer moderation for TCP.

func WithTCPReceiveBufferSize

func WithTCPReceiveBufferSize(size int) Option

WithTCPReceiveBufferSize sets the default receive buffer size for TCP.

func WithTCPReceiveBufferSizeRange

func WithTCPReceiveBufferSizeRange(a, b, c int) Option

WithTCPReceiveBufferSizeRange sets the receive buffer size range for TCP.

func WithTCPRecovery

func WithTCPRecovery(v tcpip.TCPRecovery) Option

WithTCPRecovery sets the recovery option for TCP.

func WithTCPSACKEnabled

func WithTCPSACKEnabled(v bool) Option

WithTCPSACKEnabled sets the SACK option for TCP.

func WithTCPSendBufferSize

func WithTCPSendBufferSize(size int) Option

WithTCPSendBufferSize sets default the send buffer size for TCP.

func WithTCPSendBufferSizeRange

func WithTCPSendBufferSizeRange(a, b, c int) Option

WithTCPSendBufferSizeRange sets the send buffer size range for TCP.

func WithUDPHandler

func WithUDPHandler(handle func(UDPConn)) Option

type TCPConn

type TCPConn interface {
	net.Conn

	// ID returns the transport endpoint id of TCPConn.
	ID() *stack.TransportEndpointID
}

TCPConn implements the net.Conn interface.

type TransportHandler

type TransportHandler interface {
	HandleTCP(TCPConn)
	HandleUDP(UDPConn)
}

TransportHandler is a TCP/UDP connection handler that implements HandleTCP and HandleUDP methods.

type UDPConn

type UDPConn interface {
	net.Conn
	net.PacketConn

	// ID returns the transport endpoint id of UDPConn.
	ID() *stack.TransportEndpointID
}

UDPConn implements net.Conn and net.PacketConn.

Directories

Path Synopsis
gvisor
pkg/atomicbitops
Package atomicbitops provides extensions to the sync/atomic package.
Package atomicbitops provides extensions to the sync/atomic package.
pkg/bits
Package bits includes all bit related types and operations.
Package bits includes all bit related types and operations.
pkg/buffer
Package buffer provides the implementation of a non-contiguous buffer that is reference counted, pooled, and copy-on-write.
Package buffer provides the implementation of a non-contiguous buffer that is reference counted, pooled, and copy-on-write.
pkg/context
Package context defines an internal context type.
Package context defines an internal context type.
pkg/cpuid
Package cpuid provides basic functionality for creating and adjusting CPU feature sets.
Package cpuid provides basic functionality for creating and adjusting CPU feature sets.
pkg/gohacks
Package gohacks contains utilities for subverting the Go compiler.
Package gohacks contains utilities for subverting the Go compiler.
pkg/goid
Package goid provides the Get function.
Package goid provides the Get function.
pkg/linewriter
Package linewriter provides an io.Writer which calls an emitter on each line.
Package linewriter provides an io.Writer which calls an emitter on each line.
pkg/rand
Package rand implements a cryptographically secure pseudorandom number generator.
Package rand implements a cryptographically secure pseudorandom number generator.
pkg/refs
Package refs defines an interface for reference counted objects.
Package refs defines an interface for reference counted objects.
pkg/sleep
Package sleep allows goroutines to efficiently sleep on multiple sources of notifications (wakers).
Package sleep allows goroutines to efficiently sleep on multiple sources of notifications (wakers).
pkg/state
Package state provides functionality related to saving and loading object graphs.
Package state provides functionality related to saving and loading object graphs.
pkg/state/wire
Package wire contains a few basic types that can be composed to serialize graph information for the state package.
Package wire contains a few basic types that can be composed to serialize graph information for the state package.
pkg/sync
Package sync provides synchronization primitives.
Package sync provides synchronization primitives.
pkg/sync/locking
Package locking implements lock primitives with the correctness validator.
Package locking implements lock primitives with the correctness validator.
pkg/tcpip
Package tcpip provides the interfaces and related types that users of the tcpip stack will use in order to create endpoints used to send and receive data over the network stack.
Package tcpip provides the interfaces and related types that users of the tcpip stack will use in order to create endpoints used to send and receive data over the network stack.
pkg/tcpip/adapters/gonet
Package gonet provides a Go net package compatible wrapper for a tcpip stack.
Package gonet provides a Go net package compatible wrapper for a tcpip stack.
pkg/tcpip/checksum
Package checksum provides the implementation of the encoding and decoding of network protocol headers.
Package checksum provides the implementation of the encoding and decoding of network protocol headers.
pkg/tcpip/hash/jenkins
Package jenkins implements Jenkins's one_at_a_time, non-cryptographic hash functions created by by Bob Jenkins.
Package jenkins implements Jenkins's one_at_a_time, non-cryptographic hash functions created by by Bob Jenkins.
pkg/tcpip/header
Package header provides the implementation of the encoding and decoding of network protocol headers.
Package header provides the implementation of the encoding and decoding of network protocol headers.
pkg/tcpip/header/parse
Package parse provides utilities to parse packets.
Package parse provides utilities to parse packets.
pkg/tcpip/internal/tcp
Package tcp contains internal type definitions that are not expected to be used by anyone else outside pkg/tcpip.
Package tcp contains internal type definitions that are not expected to be used by anyone else outside pkg/tcpip.
pkg/tcpip/link/channel
Package channel provides the implementation of channel-based data-link layer endpoints.
Package channel provides the implementation of channel-based data-link layer endpoints.
pkg/tcpip/network/arp
Package arp implements the ARP network protocol.
Package arp implements the ARP network protocol.
pkg/tcpip/network/hash
Package hash contains utility functions for hashing.
Package hash contains utility functions for hashing.
pkg/tcpip/network/internal/fragmentation
Package fragmentation contains the implementation of IP fragmentation.
Package fragmentation contains the implementation of IP fragmentation.
pkg/tcpip/network/internal/ip
Package ip holds IPv4/IPv6 common utilities.
Package ip holds IPv4/IPv6 common utilities.
pkg/tcpip/network/internal/multicast
Package multicast contains utilities for supporting multicast routing.
Package multicast contains utilities for supporting multicast routing.
pkg/tcpip/network/ipv4
Package ipv4 contains the implementation of the ipv4 network protocol.
Package ipv4 contains the implementation of the ipv4 network protocol.
pkg/tcpip/network/ipv6
Package ipv6 contains the implementation of the ipv6 network protocol.
Package ipv6 contains the implementation of the ipv6 network protocol.
pkg/tcpip/ports
Package ports provides PortManager that manages allocating, reserving and releasing ports.
Package ports provides PortManager that manages allocating, reserving and releasing ports.
pkg/tcpip/seqnum
Package seqnum defines the types and methods for TCP sequence numbers such that they fit in 32-bit words and work properly when overflows occur.
Package seqnum defines the types and methods for TCP sequence numbers such that they fit in 32-bit words and work properly when overflows occur.
pkg/tcpip/stack
Package stack provides the glue between networking protocols and the consumers of the networking stack.
Package stack provides the glue between networking protocols and the consumers of the networking stack.
pkg/tcpip/transport
Package transport supports transport protocols.
Package transport supports transport protocols.
pkg/tcpip/transport/icmp
Package icmp contains the implementation of the ICMP and IPv6-ICMP transport protocols for use in ping.
Package icmp contains the implementation of the ICMP and IPv6-ICMP transport protocols for use in ping.
pkg/tcpip/transport/internal/network
Package network provides facilities to support tcpip.Endpoints that operate at the network layer or above.
Package network provides facilities to support tcpip.Endpoints that operate at the network layer or above.
pkg/tcpip/transport/internal/noop
Package noop contains an endpoint that implements all tcpip.Endpoint functions as noops.
Package noop contains an endpoint that implements all tcpip.Endpoint functions as noops.
pkg/tcpip/transport/packet
Package packet provides the implementation of packet sockets (see packet(7)).
Package packet provides the implementation of packet sockets (see packet(7)).
pkg/tcpip/transport/raw
Package raw provides the implementation of raw sockets (see raw(7)).
Package raw provides the implementation of raw sockets (see raw(7)).
pkg/tcpip/transport/tcp
Package tcp contains the implementation of the TCP transport protocol.
Package tcp contains the implementation of the TCP transport protocol.
pkg/tcpip/transport/tcpconntrack
Package tcpconntrack implements a TCP connection tracking object.
Package tcpconntrack implements a TCP connection tracking object.
pkg/tcpip/transport/udp
Package udp contains the implementation of the UDP transport protocol.
Package udp contains the implementation of the UDP transport protocol.
pkg/waiter
Package waiter provides the implementation of a wait queue, where waiters can be enqueued to be notified when an event of interest happens.
Package waiter provides the implementation of a wait queue, where waiters can be enqueued to be notified when an event of interest happens.

Jump to

Keyboard shortcuts

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