network

package
v0.0.0-...-9ec6d29 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Overview

Package network provides facilities to support tcpip.Endpoints that operate at the network layer or above.

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 datagram-based endpoint. It only supports sending datagrams to a peer.

+stateify savable

func (*Endpoint) AcquireContextForWrite

func (e *Endpoint) AcquireContextForWrite(opts tcpip.WriteOptions) (WriteContext, tcpip.Error)

AcquireContextForWrite acquires a WriteContext.

func (*Endpoint) Bind

func (e *Endpoint) Bind(addr tcpip.FullAddress) tcpip.Error

Bind binds the endpoint to the address.

func (*Endpoint) BindAndThen

BindAndThen binds the endpoint to the address and then calls the provided function.

If the function returns an error, the endpoint's state does not change. The function will be called with the bound network protocol and address.

func (*Endpoint) Close

func (e *Endpoint) Close()

Close cleans the endpoint's resources and leaves the endpoint in a closed state.

func (*Endpoint) Connect

func (e *Endpoint) Connect(addr tcpip.FullAddress) tcpip.Error

Connect connects the endpoint to the address.

func (*Endpoint) ConnectAndThen

func (e *Endpoint) ConnectAndThen(addr tcpip.FullAddress, f func(netProto tcpip.NetworkProtocolNumber, previousID, nextID stack.TransportEndpointID) tcpip.Error) tcpip.Error

ConnectAndThen connects the endpoint to the address and then calls the provided function.

If the function returns an error, the endpoint's state does not change. The function will be called with the network protocol used to connect to the peer and the source and destination addresses that will be used to send traffic to the peer.

func (*Endpoint) Disconnect

func (e *Endpoint) Disconnect()

Disconnect disconnects the endpoint from its peer.

func (*Endpoint) GetLocalAddress

func (e *Endpoint) GetLocalAddress() tcpip.FullAddress

GetLocalAddress returns the address that the endpoint is bound to.

func (*Endpoint) GetRemoteAddress

func (e *Endpoint) GetRemoteAddress() (tcpip.FullAddress, bool)

GetRemoteAddress returns the address that the endpoint is connected to.

func (*Endpoint) GetSockOpt

func (e *Endpoint) GetSockOpt(opt tcpip.GettableSocketOption) tcpip.Error

GetSockOpt returns the socket option.

func (*Endpoint) GetSockOptInt

func (e *Endpoint) GetSockOptInt(opt tcpip.SockOptInt) (int, tcpip.Error)

GetSockOptInt returns the socket option.

func (*Endpoint) HasSendSpace

func (e *Endpoint) HasSendSpace() bool

HasSendSpace returns whether or not the send buffer has space.

func (*Endpoint) Info

Info returns a copy of the endpoint info.

func (*Endpoint) Init

func (e *Endpoint) Init(s *stack.Stack, netProto tcpip.NetworkProtocolNumber, transProto tcpip.TransportProtocolNumber, ops *tcpip.SocketOptions, waiterQueue *waiter.Queue)

Init initializes the endpoint.

func (*Endpoint) MaybeSignalWritable

func (e *Endpoint) MaybeSignalWritable()

MaybeSignalWritable signals waiters with writable events if the send buffer has space.

func (*Endpoint) NetProto

func (e *Endpoint) NetProto() tcpip.NetworkProtocolNumber

NetProto returns the network protocol the endpoint was initialized with.

func (*Endpoint) Resume

func (e *Endpoint) Resume(s *stack.Stack)

Resume implements tcpip.ResumableEndpoint.Resume.

func (*Endpoint) SetOwner

func (e *Endpoint) SetOwner(owner tcpip.PacketOwner)

SetOwner sets the owner of transmitted packets.

func (*Endpoint) SetSockOpt

func (e *Endpoint) SetSockOpt(opt tcpip.SettableSocketOption) tcpip.Error

SetSockOpt sets the socket option.

func (*Endpoint) SetSockOptInt

func (e *Endpoint) SetSockOptInt(opt tcpip.SockOptInt, v int) tcpip.Error

SetSockOptInt sets the socket option.

func (*Endpoint) Shutdown

func (e *Endpoint) Shutdown() tcpip.Error

Shutdown shutsdown the endpoint.

func (*Endpoint) State

State returns the state of the endpoint.

func (*Endpoint) WasBound

func (e *Endpoint) WasBound() bool

WasBound returns true iff the endpoint was ever bound.

type WriteContext

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

WriteContext holds the context for a write.

func (*WriteContext) MTU

func (c *WriteContext) MTU() uint32

func (*WriteContext) PacketInfo

func (c *WriteContext) PacketInfo() WritePacketInfo

PacketInfo returns the properties of a packet that will be written.

func (*WriteContext) Release

func (c *WriteContext) Release()

Release releases held resources.

func (*WriteContext) TryNewPacketBuffer

func (c *WriteContext) TryNewPacketBuffer(reserveHdrBytes int, data bufferv2.Buffer) stack.PacketBufferPtr

TryNewPacketBuffer returns a new packet buffer iff the endpoint's send buffer is not full.

If this method returns nil, the caller should wait for the endpoint to become writable.

func (*WriteContext) WritePacket

func (c *WriteContext) WritePacket(pkt stack.PacketBufferPtr, headerIncluded bool) tcpip.Error

WritePacket attempts to write the packet.

type WritePacketInfo

type WritePacketInfo struct {
	NetProto                    tcpip.NetworkProtocolNumber
	LocalAddress, RemoteAddress tcpip.Address
	MaxHeaderLength             uint16
	RequiresTXTransportChecksum bool
}

WritePacketInfo is the properties of a packet that may be written.

Jump to

Keyboard shortcuts

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