network

package
v0.0.0-...-ba09d25 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: Apache-2.0, MIT Imports: 7 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) Info

Info returns a copy of the endpoint info.

func (*Endpoint) Init

Init initializes the endpoint.

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) 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) WritePacket

func (c *WriteContext) WritePacket(pkt *stack.PacketBuffer, 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