Documentation ¶
Overview ¶
Package network provides facilities to support tcpip.Endpoints that operate at the network layer or above.
Index ¶
- type Endpoint
- func (e *Endpoint) AcquireContextForWrite(opts tcpip.WriteOptions) (WriteContext, tcpip.Error)
- func (e *Endpoint) Bind(addr tcpip.FullAddress) tcpip.Error
- func (e *Endpoint) BindAndThen(addr tcpip.FullAddress, ...) tcpip.Error
- func (e *Endpoint) Close()
- func (e *Endpoint) Connect(addr tcpip.FullAddress) tcpip.Error
- func (e *Endpoint) ConnectAndThen(addr tcpip.FullAddress, ...) tcpip.Error
- func (e *Endpoint) Disconnect()
- func (e *Endpoint) GetLocalAddress() tcpip.FullAddress
- func (e *Endpoint) GetRemoteAddress() (tcpip.FullAddress, bool)
- func (e *Endpoint) GetSockOpt(opt tcpip.GettableSocketOption) tcpip.Error
- func (e *Endpoint) GetSockOptInt(opt tcpip.SockOptInt) (int, tcpip.Error)
- func (e *Endpoint) HasSendSpace() bool
- func (e *Endpoint) Info() stack.TransportEndpointInfo
- func (e *Endpoint) Init(s *stack.Stack, netProto tcpip.NetworkProtocolNumber, ...)
- func (e *Endpoint) MaybeSignalWritable()
- func (e *Endpoint) NetProto() tcpip.NetworkProtocolNumber
- func (e *Endpoint) Resume(s *stack.Stack)
- func (e *Endpoint) SetOwner(owner tcpip.PacketOwner)
- func (e *Endpoint) SetSockOpt(opt tcpip.SettableSocketOption) tcpip.Error
- func (e *Endpoint) SetSockOptInt(opt tcpip.SockOptInt, v int) tcpip.Error
- func (e *Endpoint) Shutdown() tcpip.Error
- func (e *Endpoint) State() transport.DatagramEndpointState
- func (e *Endpoint) StateFields() []string
- func (e *Endpoint) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (e *Endpoint) StateSave(stateSinkObject state.Sink)
- func (e *Endpoint) StateTypeName() string
- func (e *Endpoint) WasBound() bool
- type WriteContext
- func (c *WriteContext) MTU() uint32
- func (c *WriteContext) PacketInfo() WritePacketInfo
- func (c *WriteContext) Release()
- func (c *WriteContext) TryNewPacketBuffer(reserveHdrBytes int, data buffer.Buffer) *stack.PacketBuffer
- func (c *WriteContext) TryNewPacketBufferFromPayloader(reserveHdrBytes int, payloader tcpip.Payloader) *stack.PacketBuffer
- func (c *WriteContext) WritePacket(pkt *stack.PacketBuffer, headerIncluded bool) tcpip.Error
- type WritePacketInfo
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 ¶
func (e *Endpoint) BindAndThen(addr tcpip.FullAddress, f func(tcpip.NetworkProtocolNumber, tcpip.Address) tcpip.Error) tcpip.Error
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 ¶
GetSockOptInt returns the socket option.
func (*Endpoint) HasSendSpace ¶
HasSendSpace returns whether or not the send buffer has space.
func (*Endpoint) Info ¶
func (e *Endpoint) Info() stack.TransportEndpointInfo
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) 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 ¶
SetSockOptInt sets the socket option.
func (*Endpoint) State ¶
func (e *Endpoint) State() transport.DatagramEndpointState
State returns the state of the endpoint.
func (*Endpoint) StateFields ¶
func (*Endpoint) StateTypeName ¶
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) TryNewPacketBuffer ¶
func (c *WriteContext) TryNewPacketBuffer(reserveHdrBytes int, data buffer.Buffer) *stack.PacketBuffer
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) TryNewPacketBufferFromPayloader ¶
func (c *WriteContext) TryNewPacketBufferFromPayloader(reserveHdrBytes int, payloader tcpip.Payloader) *stack.PacketBuffer
TryNewPacketBufferFromPayloader returns a new packet buffer iff the endpoint's send buffer is not full. Otherwise, data from `payloader` isn't read.
If this method returns nil, the caller should wait for the endpoint to become writable.
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.