inet

package
v0.0.0-...-522126a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package inet defines semantics for IP stacks.

Index

Constants

View Source
const (
	// CtxStack is a Context.Value key for a network stack.
	CtxStack contextID = iota
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface struct {
	// DeviceType is the device type, a Linux ARPHRD_* constant.
	DeviceType uint16

	// Flags is the device flags; see netdevice(7), under "Ioctls",
	// "SIOCGIFFLAGS, SIOCSIFFLAGS".
	Flags uint32

	// Name is the device name.
	Name string

	// Addr is the hardware device address.
	Addr []byte

	// MTU is the maximum transmission unit.
	MTU uint32
}

Interface contains information about a network interface.

type InterfaceAddr

type InterfaceAddr struct {
	// Family is the address family, a Linux AF_* constant.
	Family uint8

	// PrefixLen is the address prefix length.
	PrefixLen uint8

	// Flags is the address flags.
	Flags uint8

	// Addr is the actual address.
	Addr []byte
}

InterfaceAddr contains information about a network interface address.

type Route

type Route struct {
	// Family is the address family, a Linux AF_* constant.
	Family uint8

	// DstLen is the length of the destination address.
	DstLen uint8

	// SrcLen is the length of the source address.
	SrcLen uint8

	// TOS is the Type of Service filter.
	TOS uint8

	// Table is the routing table ID.
	Table uint8

	// Protocol is the route origin, a Linux RTPROT_* constant.
	Protocol uint8

	// Scope is the distance to destination, a Linux RT_SCOPE_* constant.
	Scope uint8

	// Type is the route origin, a Linux RTN_* constant.
	Type uint8

	// Flags are route flags. See rtnetlink(7) under "rtm_flags".
	Flags uint32

	// DstAddr is the route destination address (RTA_DST).
	DstAddr []byte

	// SrcAddr is the route source address (RTA_SRC).
	SrcAddr []byte

	// OutputInterface is the output interface index (RTA_OIF).
	OutputInterface int32

	// GatewayAddr is the route gateway address (RTA_GATEWAY).
	GatewayAddr []byte
}

Route contains information about a network route.

type Stack

type Stack interface {
	// Interfaces returns all network interfaces as a mapping from interface
	// indexes to interface properties. Interface indices are strictly positive
	// integers.
	Interfaces() map[int32]Interface

	// InterfaceAddrs returns all network interface addresses as a mapping from
	// interface indexes to a slice of associated interface address properties.
	InterfaceAddrs() map[int32][]InterfaceAddr

	// SupportsIPv6 returns true if the stack supports IPv6 connectivity.
	SupportsIPv6() bool

	// TCPReceiveBufferSize returns TCP receive buffer size settings.
	TCPReceiveBufferSize() (TCPBufferSize, error)

	// SetTCPReceiveBufferSize attempts to change TCP receive buffer size
	// settings.
	SetTCPReceiveBufferSize(size TCPBufferSize) error

	// TCPSendBufferSize returns TCP send buffer size settings.
	TCPSendBufferSize() (TCPBufferSize, error)

	// SetTCPSendBufferSize attempts to change TCP send buffer size settings.
	SetTCPSendBufferSize(size TCPBufferSize) error

	// TCPSACKEnabled returns true if RFC 2018 TCP Selective Acknowledgements
	// are enabled.
	TCPSACKEnabled() (bool, error)

	// SetTCPSACKEnabled attempts to change TCP selective acknowledgement
	// settings.
	SetTCPSACKEnabled(enabled bool) error

	// Statistics reports stack statistics.
	Statistics(stat interface{}, arg string) error

	// RouteTable returns the network stack's route table.
	RouteTable() []Route

	// Resume restarts the network stack after restore.
	Resume()

	// RegisteredEndpoints returns all endpoints which are currently registered.
	RegisteredEndpoints() []stack.TransportEndpoint

	// CleanupEndpoints returns endpoints currently in the cleanup state.
	CleanupEndpoints() []stack.TransportEndpoint

	// RestoreCleanupEndpoints adds endpoints to cleanup tracking. This is useful
	// for restoring a stack after a save.
	RestoreCleanupEndpoints([]stack.TransportEndpoint)
}

Stack represents a TCP/IP stack.

func StackFromContext

func StackFromContext(ctx context.Context) Stack

StackFromContext returns the network stack associated with ctx.

type StatDev

type StatDev [16]uint64

StatDev describes one line of /proc/net/dev, i.e., stats for one network interface.

type StatSNMPICMP

type StatSNMPICMP [27]uint64

StatSNMPICMP describes Icmp line of /proc/net/snmp.

type StatSNMPICMPMSG

type StatSNMPICMPMSG [512]uint64

StatSNMPICMPMSG describes IcmpMsg line of /proc/net/snmp.

type StatSNMPIP

type StatSNMPIP [19]uint64

StatSNMPIP describes Ip line of /proc/net/snmp.

type StatSNMPTCP

type StatSNMPTCP [15]uint64

StatSNMPTCP describes Tcp line of /proc/net/snmp.

type StatSNMPUDP

type StatSNMPUDP [8]uint64

StatSNMPUDP describes Udp line of /proc/net/snmp.

type StatSNMPUDPLite

type StatSNMPUDPLite [8]uint64

StatSNMPUDPLite describes UdpLite line of /proc/net/snmp.

type TCPBufferSize

type TCPBufferSize struct {
	// Min is the minimum size.
	Min int

	// Default is the default size.
	Default int

	// Max is the maximum size.
	Max int
}

TCPBufferSize contains settings controlling TCP buffer sizing.

+stateify savable

type TestStack

type TestStack struct {
	InterfacesMap     map[int32]Interface
	InterfaceAddrsMap map[int32][]InterfaceAddr
	RouteList         []Route
	SupportsIPv6Flag  bool
	TCPRecvBufSize    TCPBufferSize
	TCPSendBufSize    TCPBufferSize
	TCPSACKFlag       bool
}

TestStack is a dummy implementation of Stack for tests.

func NewTestStack

func NewTestStack() *TestStack

NewTestStack returns a TestStack with no network interfaces. The value of all other options is unspecified; tests that rely on specific values must set them explicitly.

func (*TestStack) CleanupEndpoints

func (s *TestStack) CleanupEndpoints() []stack.TransportEndpoint

CleanupEndpoints implements inet.Stack.CleanupEndpoints.

func (*TestStack) InterfaceAddrs

func (s *TestStack) InterfaceAddrs() map[int32][]InterfaceAddr

InterfaceAddrs implements Stack.InterfaceAddrs.

func (*TestStack) Interfaces

func (s *TestStack) Interfaces() map[int32]Interface

Interfaces implements Stack.Interfaces.

func (*TestStack) RegisteredEndpoints

func (s *TestStack) RegisteredEndpoints() []stack.TransportEndpoint

RegisteredEndpoints implements inet.Stack.RegisteredEndpoints.

func (*TestStack) RestoreCleanupEndpoints

func (s *TestStack) RestoreCleanupEndpoints([]stack.TransportEndpoint)

RestoreCleanupEndpoints implements inet.Stack.RestoreCleanupEndpoints.

func (*TestStack) Resume

func (s *TestStack) Resume()

Resume implements Stack.Resume.

func (*TestStack) RouteTable

func (s *TestStack) RouteTable() []Route

RouteTable implements Stack.RouteTable.

func (*TestStack) SetTCPReceiveBufferSize

func (s *TestStack) SetTCPReceiveBufferSize(size TCPBufferSize) error

SetTCPReceiveBufferSize implements Stack.SetTCPReceiveBufferSize.

func (*TestStack) SetTCPSACKEnabled

func (s *TestStack) SetTCPSACKEnabled(enabled bool) error

SetTCPSACKEnabled implements Stack.SetTCPSACKEnabled.

func (*TestStack) SetTCPSendBufferSize

func (s *TestStack) SetTCPSendBufferSize(size TCPBufferSize) error

SetTCPSendBufferSize implements Stack.SetTCPSendBufferSize.

func (*TestStack) Statistics

func (s *TestStack) Statistics(stat interface{}, arg string) error

Statistics implements inet.Stack.Statistics.

func (*TestStack) SupportsIPv6

func (s *TestStack) SupportsIPv6() bool

SupportsIPv6 implements Stack.SupportsIPv6.

func (*TestStack) TCPReceiveBufferSize

func (s *TestStack) TCPReceiveBufferSize() (TCPBufferSize, error)

TCPReceiveBufferSize implements Stack.TCPReceiveBufferSize.

func (*TestStack) TCPSACKEnabled

func (s *TestStack) TCPSACKEnabled() (bool, error)

TCPSACKEnabled implements Stack.TCPSACKEnabled.

func (*TestStack) TCPSendBufferSize

func (s *TestStack) TCPSendBufferSize() (TCPBufferSize, error)

TCPSendBufferSize implements Stack.TCPSendBufferSize.

Jump to

Keyboard shortcuts

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