udp

package
v0.0.0-...-a24973a Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 9 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.ProtocolName (or "udp") 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 (
	// ProtocolName is the string representation of the udp protocol name.
	ProtocolName = "udp"

	// ProtocolNumber is the udp protocol number.
	ProtocolNumber = header.UDPProtocolNumber
)

Variables

This section is empty.

Functions

This section is empty.

Types

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, netHeader buffer.View, vv buffer.VectorisedView) 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