waitable

package
v0.0.0-...-2b55090 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package waitable provides the implementation of data-link layer endpoints that wrap other endpoints, and can wait for inflight calls to WritePacket or DeliverNetworkPacket to finish (and new ones to be prevented).

Waitable endpoints can be used in the networking stack by calling New(eID) to create a new endpoint, where eID is the ID of the endpoint being wrapped, and then passing it as an argument to Stack.CreateNIC().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

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

Endpoint is a waitable link-layer endpoint.

+stateify savable

func New

func New(lower stack.LinkEndpoint) *Endpoint

New creates a new waitable link-layer endpoint. It wraps around another endpoint and allows the caller to block new write/dispatch calls and wait for the inflight ones to finish before returning.

func (*Endpoint) ARPHardwareType

func (e *Endpoint) ARPHardwareType() header.ARPHardwareType

ARPHardwareType implements stack.LinkEndpoint.ARPHardwareType.

func (*Endpoint) AddHeader

func (e *Endpoint) AddHeader(pkt *stack.PacketBuffer)

AddHeader implements stack.LinkEndpoint.AddHeader.

func (*Endpoint) Attach

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

Attach implements stack.LinkEndpoint.Attach. It saves the dispatcher and registers with the lower endpoint as its dispatcher so that "e" is called for inbound packets.

func (*Endpoint) Capabilities

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

Capabilities implements stack.LinkEndpoint.Capabilities. It just forwards the request to the lower endpoint.

func (*Endpoint) Close

func (e *Endpoint) Close()

Close implements stack.LinkEndpoint.

func (*Endpoint) DeliverLinkPacket

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

DeliverLinkPacket implements stack.NetworkDispatcher.

func (*Endpoint) DeliverNetworkPacket

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

DeliverNetworkPacket implements stack.NetworkDispatcher.DeliverNetworkPacket. It is called by the link-layer endpoint being wrapped when a packet arrives, and only forwards to the actual dispatcher if Wait or WaitDispatch haven't been called.

func (*Endpoint) IsAttached

func (e *Endpoint) IsAttached() bool

IsAttached implements stack.LinkEndpoint.IsAttached.

func (*Endpoint) LinkAddress

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

LinkAddress implements stack.LinkEndpoint.LinkAddress. It just forwards the request to the lower endpoint.

func (*Endpoint) MTU

func (e *Endpoint) MTU() uint32

MTU implements stack.LinkEndpoint.MTU. It just forwards the request to the lower endpoint.

func (*Endpoint) MaxHeaderLength

func (e *Endpoint) MaxHeaderLength() uint16

MaxHeaderLength implements stack.LinkEndpoint.MaxHeaderLength. It just forwards the request to the lower endpoint.

func (*Endpoint) ParseHeader

func (e *Endpoint) ParseHeader(pkt *stack.PacketBuffer) bool

ParseHeader implements stack.LinkEndpoint.ParseHeader.

func (*Endpoint) SetLinkAddress

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

SetLinkAddress implements stack.LinkEndpoint.SetLinkAddress. It forwards the request to the lower endpoint.

func (*Endpoint) SetMTU

func (e *Endpoint) SetMTU(mtu uint32)

SetMTU implements stack.LinkEndpoint.SetMTU. It just forwards the request to the lower endpoint.

func (*Endpoint) SetOnCloseAction

func (e *Endpoint) SetOnCloseAction(action func())

SetOnCloseAction implements stack.LinkEndpoint.SetOnCloseAction.

func (*Endpoint) Wait

func (e *Endpoint) Wait()

Wait implements stack.LinkEndpoint.Wait.

func (*Endpoint) WaitDispatch

func (e *Endpoint) WaitDispatch()

WaitDispatch prevents new calls to DeliverNetworkPacket from reaching the actual dispatcher, and waits for inflight ones to finish before returning.

func (*Endpoint) WaitWrite

func (e *Endpoint) WaitWrite()

WaitWrite prevents new calls to WritePacket from reaching the lower endpoint, and waits for inflight ones to finish before returning.

func (*Endpoint) WritePackets

func (e *Endpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error)

WritePackets implements stack.LinkEndpoint.WritePackets. It is called by higher-level protocols to write packets. It only forwards packets to the lower endpoint if Wait or WaitWrite haven't been called.

Jump to

Keyboard shortcuts

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