udp

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package udp contains the implementation of the UDP transport protocol. To use it in the networking stack, this package must be added to the project, and activated on the stack by passing udp.NewProtocol() as one of the transport protocols when calling stack.New(). Then endpoints can be created by passing udp.ProtocolNumber as the transport protocol number when calling Stack.NewEndpoint().

Index

Constants

View Source
const (
	// ProtocolNumber is the udp protocol number.
	ProtocolNumber = header.UDPProtocolNumber
)

Variables

This section is empty.

Functions

func NewProtocol

func NewProtocol() stack.TransportProtocol

NewProtocol returns a UDP transport protocol.

Types

type EndpointState

type EndpointState uint32

EndpointState represents the state of a UDP endpoint.

const (
	StateInitial EndpointState = iota
	StateBound
	StateConnected
	StateClosed
)

Endpoint states. Note that are represented in a netstack-specific manner and may not be meaningful externally. Specifically, they need to be translated to Linux's representation for these states if presented to userspace.

func (EndpointState) String

func (s EndpointState) String() string

String implements fmt.Stringer.String.

type Forwarder

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

Forwarder is a session request forwarder, which allows clients to decide what to do with a session request, for example: ignore it, or process it.

The canonical way of using it is to pass the Forwarder.HandlePacket function to stack.SetTransportProtocolHandler.

func NewForwarder

func NewForwarder(s *stack.Stack, handler func(*ForwarderRequest)) *Forwarder

NewForwarder allocates and initializes a new forwarder.

func (*Forwarder) HandlePacket

func (f *Forwarder) HandlePacket(r *stack.Route, id stack.TransportEndpointID, pkt tcpip.PacketBuffer) bool

HandlePacket handles all packets.

This function is expected to be passed as an argument to the stack.SetTransportProtocolHandler function.

type ForwarderRequest

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

ForwarderRequest represents a session request received by the forwarder and passed to the client. Clients may optionally create an endpoint to represent it via CreateEndpoint.

func (*ForwarderRequest) CreateEndpoint

func (r *ForwarderRequest) CreateEndpoint(queue *waiter.Queue) (tcpip.Endpoint, *tcpip.Error)

CreateEndpoint creates a connected UDP endpoint for the session request.

func (*ForwarderRequest) ID

ID returns the 4-tuple (src address, src port, dst address, dst port) that represents the session request.

Jump to

Keyboard shortcuts

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