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 ¶
- type Endpoint
- func (*Endpoint) ARPHardwareType() header.ARPHardwareType
- func (*Endpoint) AddHeader(tcpip.LinkAddress, tcpip.LinkAddress, tcpip.NetworkProtocolNumber, ...)
- func (e *Endpoint) AddNotify(notify Notification) *NotificationHandle
- func (e *Endpoint) Attach(dispatcher stack.NetworkDispatcher)
- func (e *Endpoint) Capabilities() stack.LinkEndpointCapabilities
- func (e *Endpoint) Close()
- func (e *Endpoint) Drain() int
- func (*Endpoint) GSOMaxSize() uint32
- func (e *Endpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer)
- func (e *Endpoint) InjectLinkAddr(protocol tcpip.NetworkProtocolNumber, remote tcpip.LinkAddress, ...)
- func (e *Endpoint) IsAttached() bool
- func (e *Endpoint) LinkAddress() tcpip.LinkAddress
- func (e *Endpoint) MTU() uint32
- func (*Endpoint) MaxHeaderLength() uint16
- func (e *Endpoint) NumQueued() int
- func (e *Endpoint) Read() *stack.PacketBuffer
- func (e *Endpoint) ReadContext(ctx context.Context) *stack.PacketBuffer
- func (e *Endpoint) RemoveNotify(handle *NotificationHandle)
- func (e *Endpoint) SupportedGSO() stack.SupportedGSO
- func (*Endpoint) Wait()
- func (e *Endpoint) WritePackets(_ stack.RouteInfo, pkts stack.PacketBufferList, _ tcpip.NetworkProtocolNumber) (int, tcpip.Error)
- func (e *Endpoint) WriteRawPacket(pkt *stack.PacketBuffer) tcpip.Error
- type Notification
- type NotificationHandle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct { LinkEPCapabilities stack.LinkEndpointCapabilities SupportedGSOKind stack.SupportedGSO // 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) ARPHardwareType ¶
func (*Endpoint) ARPHardwareType() header.ARPHardwareType
ARPHardwareType implements stack.LinkEndpoint.ARPHardwareType.
func (*Endpoint) AddHeader ¶
func (*Endpoint) AddHeader(tcpip.LinkAddress, tcpip.LinkAddress, tcpip.NetworkProtocolNumber, *stack.PacketBuffer)
AddHeader implements stack.LinkEndpoint.AddHeader.
func (*Endpoint) AddNotify ¶
func (e *Endpoint) AddNotify(notify Notification) *NotificationHandle
AddNotify adds a notification target for receiving event about outgoing packets.
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) Close ¶
func (e *Endpoint) Close()
Close closes e. Further packet injections will panic. Reads continue to succeed until all packets are read.
func (*Endpoint) GSOMaxSize ¶
GSOMaxSize implements stack.GSOEndpoint.
func (*Endpoint) InjectInbound ¶
func (e *Endpoint) InjectInbound(protocol tcpip.NetworkProtocolNumber, pkt *stack.PacketBuffer)
InjectInbound injects an inbound packet.
func (*Endpoint) InjectLinkAddr ¶
func (e *Endpoint) InjectLinkAddr(protocol tcpip.NetworkProtocolNumber, remote tcpip.LinkAddress, pkt *stack.PacketBuffer)
InjectLinkAddr injects an inbound packet with a remote link address.
func (*Endpoint) IsAttached ¶
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 ¶
MTU implements stack.LinkEndpoint.MTU. It returns the value initialized during construction.
func (*Endpoint) MaxHeaderLength ¶
MaxHeaderLength returns the maximum size of the link layer header. Given it doesn't have a header, it just returns 0.
func (*Endpoint) Read ¶
func (e *Endpoint) Read() *stack.PacketBuffer
Read does non-blocking read one packet from the outbound packet queue.
func (*Endpoint) ReadContext ¶
func (e *Endpoint) ReadContext(ctx context.Context) *stack.PacketBuffer
ReadContext does blocking read for one packet from the outbound packet queue. It can be cancelled by ctx, and in this case, it returns false.
func (*Endpoint) RemoveNotify ¶
func (e *Endpoint) RemoveNotify(handle *NotificationHandle)
RemoveNotify removes handle from the list of notification targets.
func (*Endpoint) SupportedGSO ¶
func (e *Endpoint) SupportedGSO() stack.SupportedGSO
SupportedGSO implements stack.GSOEndpoint.
func (*Endpoint) WritePackets ¶
func (e *Endpoint) WritePackets(_ stack.RouteInfo, pkts stack.PacketBufferList, _ tcpip.NetworkProtocolNumber) (int, tcpip.Error)
WritePackets stores outbound packets into the channel.
func (*Endpoint) WriteRawPacket ¶
func (e *Endpoint) WriteRawPacket(pkt *stack.PacketBuffer) tcpip.Error
WriteRawPacket implements stack.LinkEndpoint.
type Notification ¶
type Notification interface {
// WriteNotify will be called when a write happens to the queue.
WriteNotify()
}
Notification is the interface for receiving notification from the packet queue.
type NotificationHandle ¶
type NotificationHandle struct {
// contains filtered or unexported fields
}
NotificationHandle is an opaque handle to the registered notification target. It can be used to unregister the notification when no longer interested.
+stateify savable