fdbased

package
v0.0.0-...-d4e65c6 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package fdbased provides the implemention of data-link layer endpoints backed by boundary-preserving file descriptors (e.g., TUN devices, seqpacket/datagram sockets).

FD based endpoints can be used in the networking stack by calling New() to create a new endpoint, and then passing it as an argument to Stack.CreateNIC().

Index

Constants

This section is empty.

Variables

View Source
var BufConfig = []int{128, 256, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768}

BufConfig defines the shape of the vectorised view used to read packets from the NIC.

Functions

func New

func New(ifce *water.Interface, opts *Options) tcpip.LinkEndpointID

New creates a new fd-based endpoint.

Makes fd non-blocking, but does not take ownership of fd, which must remain open for the lifetime of the returned endpoint.

Types

type InjectableEndpoint

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

InjectableEndpoint is an injectable fd-based endpoint. The endpoint writes to the FD, but does not read from it. All reads come from injected packets.

func NewInjectable

func NewInjectable(fd int, mtu uint32) (tcpip.LinkEndpointID, *InjectableEndpoint)

NewInjectable creates a new fd-based InjectableEndpoint.

func (*InjectableEndpoint) Attach

func (e *InjectableEndpoint) Attach(dispatcher stack.NetworkDispatcher)

Attach saves the stack network-layer dispatcher for use later when packets are injected.

func (*InjectableEndpoint) Capabilities

func (e *InjectableEndpoint) Capabilities() stack.LinkEndpointCapabilities

Capabilities implements stack.LinkEndpoint.Capabilities.

func (*InjectableEndpoint) Inject

Inject injects an inbound packet.

func (*InjectableEndpoint) IsAttached

func (e *InjectableEndpoint) IsAttached() bool

IsAttached implements stack.LinkEndpoint.IsAttached.

func (*InjectableEndpoint) LinkAddress

func (e *InjectableEndpoint) LinkAddress() tcpip.LinkAddress

LinkAddress returns the link address of this endpoint.

func (*InjectableEndpoint) MTU

func (e *InjectableEndpoint) MTU() uint32

MTU implements stack.LinkEndpoint.MTU. It returns the value initialized during construction.

func (*InjectableEndpoint) MaxHeaderLength

func (e *InjectableEndpoint) MaxHeaderLength() uint16

MaxHeaderLength returns the maximum size of the link-layer header.

func (*InjectableEndpoint) WritePacket

func (e *InjectableEndpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload buffer.VectorisedView, protocol tcpip.NetworkProtocolNumber) *tcpip.Error

WritePacket writes outbound packets to the file descriptor. If it is not currently writable, the packet is dropped.

type Options

type Options struct {
	FD              int
	MTU             uint32
	EthernetHeader  bool
	ChecksumOffload bool
	ClosedFunc      func(*tcpip.Error)
	Address         tcpip.LinkAddress
	SaveRestore     bool
	DisconnectOk    bool
	HandleLocal     bool
}

Options specify the details about the fd-based endpoint to be created.

Jump to

Keyboard shortcuts

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