import "github.com/google/netstack/tcpip/link/fdbased"
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().
BufConfig defines the shape of the vectorised view used to read packets from the NIC.
func New(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.
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(fd int, mtu uint32) (tcpip.LinkEndpointID, *InjectableEndpoint)
NewInjectable creates a new fd-based InjectableEndpoint.
func (e *InjectableEndpoint) Attach(dispatcher stack.NetworkDispatcher)
Attach saves the stack network-layer dispatcher for use later when packets are injected.
func (e *InjectableEndpoint) Capabilities() stack.LinkEndpointCapabilities
Capabilities implements stack.LinkEndpoint.Capabilities.
func (e *InjectableEndpoint) Inject(protocol tcpip.NetworkProtocolNumber, vv buffer.VectorisedView)
Inject injects an inbound packet.
IsAttached implements stack.LinkEndpoint.IsAttached.
func (e *InjectableEndpoint) LinkAddress() tcpip.LinkAddress
LinkAddress returns the link address of this endpoint.
MTU implements stack.LinkEndpoint.MTU. It returns the value initialized during construction.
MaxHeaderLength returns the maximum size of the link-layer header.
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 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.
Package fdbased imports 6 packages (graph) and is imported by 2 packages. Updated 2018-09-21. Refresh now. Tools for package owners.