channel

package
v0.0.0-...-55fcc16 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: Apache-2.0 Imports: 3 Imported by: 8

Documentation

Overview

Package channel provides the implemention of channel-based data-link layer endpoints. Such endpoints allow injection of inbound packets and store outbound packets in a channel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	GSO bool

	// C is where outbound packets are queued.
	C chan PacketInfo
	// contains filtered or unexported fields
}

Endpoint is link layer endpoint that stores outbound packets in a channel and allows injection of inbound packets.

func New

func New(size int, mtu uint32, linkAddr tcpip.LinkAddress) *Endpoint

New creates a new channel endpoint.

func (*Endpoint) Attach

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

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

func (*Endpoint) Capabilities

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

Capabilities implements stack.LinkEndpoint.Capabilities.

func (*Endpoint) Drain

func (e *Endpoint) Drain() int

Drain removes all outbound packets from the channel and counts them.

func (*Endpoint) GSOMaxSize

func (*Endpoint) GSOMaxSize() uint32

GSOMaxSize returns the maximum GSO packet size.

func (*Endpoint) InjectInbound

func (e *Endpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber, pkt tcpip.PacketBuffer)

InjectInbound injects an inbound packet.

func (*Endpoint) InjectLinkAddr

func (e *Endpoint) InjectLinkAddr(protocol tcpip.NetworkProtocolNumber, remote tcpip.LinkAddress, pkt tcpip.PacketBuffer)

InjectLinkAddr injects an inbound packet with a remote link address.

func (*Endpoint) IsAttached

func (e *Endpoint) IsAttached() bool

IsAttached implements stack.LinkEndpoint.IsAttached.

func (*Endpoint) LinkAddress

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

LinkAddress returns the link address of this endpoint.

func (*Endpoint) MTU

func (e *Endpoint) MTU() uint32

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

func (*Endpoint) MaxHeaderLength

func (*Endpoint) MaxHeaderLength() uint16

MaxHeaderLength returns the maximum size of the link layer header. Given it doesn't have a header, it just returns 0.

func (*Endpoint) Wait

func (*Endpoint) Wait()

Wait implements stack.LinkEndpoint.Wait.

func (*Endpoint) WritePacket

func (e *Endpoint) WritePacket(_ *stack.Route, gso *stack.GSO, protocol tcpip.NetworkProtocolNumber, pkt tcpip.PacketBuffer) *tcpip.Error

WritePacket stores outbound packets into the channel.

func (*Endpoint) WritePackets

func (e *Endpoint) WritePackets(_ *stack.Route, gso *stack.GSO, hdrs []stack.PacketDescriptor, payload buffer.VectorisedView, protocol tcpip.NetworkProtocolNumber) (int, *tcpip.Error)

WritePackets stores outbound packets into the channel.

func (*Endpoint) WriteRawPacket

func (e *Endpoint) WriteRawPacket(vv buffer.VectorisedView) *tcpip.Error

WriteRawPacket implements stack.LinkEndpoint.WriteRawPacket.

type PacketInfo

type PacketInfo struct {
	Pkt   tcpip.PacketBuffer
	Proto tcpip.NetworkProtocolNumber
	GSO   *stack.GSO
}

PacketInfo holds all the information about an outbound packet.

Jump to

Keyboard shortcuts

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