Documentation ¶
Overview ¶
Package tcpip provides the interfaces and related types that users of the tcpip stack will use in order to create endpoints used to send and receive data over the network stack.
The starting point is the creation and configuration of a stack. A stack can be created by calling the New() function of the tcpip/stack/stack package; configuring a stack involves creating NICs (via calls to Stack.CreateNIC()), adding network addresses (via calls to Stack.AddAddress()), and setting a route table (via a call to Stack.SetRouteTable()).
Once a stack is configured, endpoints can be created by calling Stack.NewEndpoint(). Such endpoints can be used to send/receive data, connect to peers, listen for connections, accept connections, etc., depending on the transport protocol selected.
Index ¶
- Constants
- Variables
- func AddDanglingEndpoint(e Endpoint)
- func DeleteDanglingEndpoint(e Endpoint)
- func InitStatCounters(v reflect.Value)
- type ARPStats
- type AddMembershipOption
- type Address
- type AddressMask
- type AddressWithPrefix
- type Clock
- type CongestionControlOption
- type ControlMessages
- type DefaultSocketOptionsHandler
- func (*DefaultSocketOptionsHandler) HasNIC(int32) bool
- func (*DefaultSocketOptionsHandler) LastError() *Error
- func (*DefaultSocketOptionsHandler) OnCorkOptionSet(bool)
- func (*DefaultSocketOptionsHandler) OnDelayOptionSet(bool)
- func (*DefaultSocketOptionsHandler) OnKeepAliveSet(bool)
- func (*DefaultSocketOptionsHandler) OnReuseAddressSet(bool)
- func (*DefaultSocketOptionsHandler) OnReusePortSet(bool)
- func (*DefaultSocketOptionsHandler) UpdateLastError(*Error)
- type DefaultTTLOption
- type Endpoint
- type EndpointInfo
- type EndpointStats
- type ErrSaveRejection
- type Error
- type FullAddress
- type GettableNetworkProtocolOption
- type GettableSocketOption
- type GettableTransportProtocolOption
- type ICMPStats
- type ICMPv4PacketStats
- type ICMPv4ReceivedPacketStats
- type ICMPv4SentPacketStats
- type ICMPv4Stats
- type ICMPv6PacketStats
- type ICMPv6ReceivedPacketStats
- type ICMPv6SentPacketStats
- type ICMPv6Stats
- type IGMPPacketStats
- type IGMPReceivedPacketStats
- type IGMPSentPacketStats
- type IGMPStats
- type IPPacketInfo
- type IPStats
- type Job
- type KeepaliveIdleOption
- type KeepaliveIntervalOption
- type LimitedWriter
- type LingerOption
- type LinkAddress
- type LinkPacketInfo
- type MembershipOption
- type MultiCounterStat
- type MulticastInterfaceOption
- type NICID
- type NetworkProtocolNumber
- type OriginalDestinationOption
- type PacketOwner
- type PacketType
- type Payloader
- type ProtocolAddress
- type ReadErrors
- type ReadOptions
- type ReadResult
- type ReceiveErrors
- type RemoveMembershipOption
- type Route
- type SendErrors
- type SettableNetworkProtocolOption
- type SettableSocketOption
- type SettableTransportProtocolOption
- type ShutdownFlags
- type SliceWriter
- type SockErrOrigin
- type SockError
- func (e *SockError) Next() *SockError
- func (e *SockError) Prev() *SockError
- func (e *SockError) SetNext(elem *SockError)
- func (e *SockError) SetPrev(elem *SockError)
- func (s *SockError) StateFields() []string
- func (s *SockError) StateLoad(stateSourceObject state.Source)
- func (s *SockError) StateSave(stateSinkObject state.Sink)
- func (s *SockError) StateTypeName() string
- type SockOptInt
- type SocketDetachFilterOption
- type SocketOptions
- func (so *SocketOptions) DequeueErr() *SockError
- func (so *SocketOptions) GetBindToDevice() int32
- func (so *SocketOptions) GetBroadcast() bool
- func (so *SocketOptions) GetCorkOption() bool
- func (so *SocketOptions) GetDelayOption() bool
- func (so *SocketOptions) GetHeaderIncluded() bool
- func (so *SocketOptions) GetKeepAlive() bool
- func (so *SocketOptions) GetLastError() *Error
- func (so *SocketOptions) GetLinger() LingerOption
- func (so *SocketOptions) GetMulticastLoop() bool
- func (so *SocketOptions) GetNoChecksum() bool
- func (*SocketOptions) GetOutOfBandInline() bool
- func (so *SocketOptions) GetPassCred() bool
- func (so *SocketOptions) GetQuickAck() bool
- func (so *SocketOptions) GetReceiveOriginalDstAddress() bool
- func (so *SocketOptions) GetReceivePacketInfo() bool
- func (so *SocketOptions) GetReceiveTClass() bool
- func (so *SocketOptions) GetReceiveTOS() bool
- func (so *SocketOptions) GetRecvError() bool
- func (so *SocketOptions) GetReuseAddress() bool
- func (so *SocketOptions) GetReusePort() bool
- func (so *SocketOptions) GetV6Only() bool
- func (so *SocketOptions) InitHandler(handler SocketOptionsHandler)
- func (so *SocketOptions) PeekErr() *SockError
- func (so *SocketOptions) QueueErr(err *SockError)
- func (so *SocketOptions) QueueLocalErr(err *Error, net NetworkProtocolNumber, info uint32, dst FullAddress, ...)
- func (so *SocketOptions) SetBindToDevice(bindToDevice int32) *Error
- func (so *SocketOptions) SetBroadcast(v bool)
- func (so *SocketOptions) SetCorkOption(v bool)
- func (so *SocketOptions) SetDelayOption(v bool)
- func (so *SocketOptions) SetHeaderIncluded(v bool)
- func (so *SocketOptions) SetKeepAlive(v bool)
- func (so *SocketOptions) SetLastError(err *Error)
- func (so *SocketOptions) SetLinger(linger LingerOption)
- func (so *SocketOptions) SetMulticastLoop(v bool)
- func (so *SocketOptions) SetNoChecksum(v bool)
- func (*SocketOptions) SetOutOfBandInline(bool)
- func (so *SocketOptions) SetPassCred(v bool)
- func (so *SocketOptions) SetQuickAck(v bool)
- func (so *SocketOptions) SetReceiveOriginalDstAddress(v bool)
- func (so *SocketOptions) SetReceivePacketInfo(v bool)
- func (so *SocketOptions) SetReceiveTClass(v bool)
- func (so *SocketOptions) SetReceiveTOS(v bool)
- func (so *SocketOptions) SetRecvError(v bool)
- func (so *SocketOptions) SetReuseAddress(v bool)
- func (so *SocketOptions) SetReusePort(v bool)
- func (so *SocketOptions) SetV6Only(v bool)
- func (so *SocketOptions) StateFields() []string
- func (so *SocketOptions) StateLoad(stateSourceObject state.Source)
- func (so *SocketOptions) StateSave(stateSinkObject state.Sink)
- func (so *SocketOptions) StateTypeName() string
- type SocketOptionsHandler
- type StatCounter
- type Stats
- type StdClock
- func (*StdClock) AfterFunc(d time.Duration, f func()) Timer
- func (*StdClock) NowMonotonic() int64
- func (*StdClock) NowNanoseconds() int64
- func (s *StdClock) StateFields() []string
- func (s *StdClock) StateLoad(stateSourceObject state.Source)
- func (s *StdClock) StateSave(stateSinkObject state.Sink)
- func (s *StdClock) StateTypeName() string
- type Subnet
- func (s *Subnet) Bits() (ones int, zeros int)
- func (s *Subnet) Broadcast() Address
- func (s *Subnet) Contains(a Address) bool
- func (s Subnet) Equal(o Subnet) bool
- func (s *Subnet) ID() Address
- func (s *Subnet) IsBroadcast(address Address) bool
- func (s *Subnet) Mask() AddressMask
- func (s *Subnet) Prefix() int
- func (s Subnet) String() string
- type TCPAvailableCongestionControlOption
- type TCPDeferAcceptOption
- type TCPDelayEnabled
- type TCPInfoOption
- type TCPLingerTimeoutOption
- type TCPMaxRTOOption
- type TCPMaxRetriesOption
- type TCPMinRTOOption
- type TCPModerateReceiveBufferOption
- type TCPReceiveBufferSizeRangeOption
- type TCPRecovery
- type TCPSACKEnabled
- type TCPSendBufferSizeRangeOption
- type TCPStats
- type TCPSynRcvdCountThresholdOption
- type TCPSynRetriesOption
- type TCPTimeWaitReuseOption
- type TCPTimeWaitTimeoutOption
- type TCPUserTimeoutOption
- type Timer
- type TransportEndpointStats
- type TransportProtocolNumber
- type UDPStats
- type WriteErrors
- type WriteOptions
Constants ¶
const ( // PMTUDiscoveryWant is a setting of the MTUDiscoverOption to use // per-route settings. PMTUDiscoveryWant int = iota // PMTUDiscoveryDont is a setting of the MTUDiscoverOption to disable // path MTU discovery. PMTUDiscoveryDont // PMTUDiscoveryDo is a setting of the MTUDiscoverOption to always do // path MTU discovery. PMTUDiscoveryDo // PMTUDiscoveryProbe is a setting of the MTUDiscoverOption to set DF // but ignore path MTU. PMTUDiscoveryProbe )
Variables ¶
var ( ErrUnknownProtocol = &Error{msg: "unknown protocol"} ErrUnknownNICID = &Error{msg: "unknown nic id"} ErrUnknownDevice = &Error{msg: "unknown device"} ErrUnknownProtocolOption = &Error{msg: "unknown option for protocol"} ErrDuplicateNICID = &Error{msg: "duplicate nic id"} ErrDuplicateAddress = &Error{msg: "duplicate address"} ErrNoRoute = &Error{msg: "no route"} ErrBadLinkEndpoint = &Error{msg: "bad link layer endpoint"} ErrAlreadyBound = &Error{msg: "endpoint already bound", ignoreStats: true} ErrInvalidEndpointState = &Error{msg: "endpoint is in invalid state"} ErrAlreadyConnecting = &Error{msg: "endpoint is already connecting", ignoreStats: true} ErrAlreadyConnected = &Error{msg: "endpoint is already connected", ignoreStats: true} ErrNoPortAvailable = &Error{msg: "no ports are available"} ErrPortInUse = &Error{msg: "port is in use"} ErrBadLocalAddress = &Error{msg: "bad local address"} ErrClosedForSend = &Error{msg: "endpoint is closed for send"} ErrClosedForReceive = &Error{msg: "endpoint is closed for receive"} ErrWouldBlock = &Error{msg: "operation would block", ignoreStats: true} ErrConnectionRefused = &Error{msg: "connection was refused"} ErrTimeout = &Error{msg: "operation timed out"} ErrAborted = &Error{msg: "operation aborted"} ErrConnectStarted = &Error{msg: "connection attempt started", ignoreStats: true} ErrDestinationRequired = &Error{msg: "destination address is required"} ErrNotSupported = &Error{msg: "operation not supported"} ErrQueueSizeNotSupported = &Error{msg: "queue size querying not supported"} ErrNotConnected = &Error{msg: "endpoint not connected"} ErrConnectionReset = &Error{msg: "connection reset by peer"} ErrConnectionAborted = &Error{msg: "connection aborted"} ErrNoSuchFile = &Error{msg: "no such file"} ErrInvalidOptionValue = &Error{msg: "invalid option value specified"} ErrBadAddress = &Error{msg: "bad address"} ErrNetworkUnreachable = &Error{msg: "network is unreachable"} ErrMessageTooLong = &Error{msg: "message too long"} ErrNoBufferSpace = &Error{msg: "no buffer space available"} ErrBroadcastDisabled = &Error{msg: "broadcast socket option disabled"} ErrNotPermitted = &Error{msg: "operation not permitted"} ErrAddressFamilyNotSupported = &Error{msg: "address family not supported by protocol"} ErrMalformedHeader = &Error{msg: "header is malformed"} ErrBadBuffer = &Error{msg: "bad buffer"} )
Errors that can be returned by the network stack.
var AsyncLoading sync.WaitGroup
AsyncLoading is the global barrier for asynchronous endpoint loading activities.
Functions ¶
func AddDanglingEndpoint ¶
func AddDanglingEndpoint(e Endpoint)
AddDanglingEndpoint adds a dangling endpoint.
func DeleteDanglingEndpoint ¶
func DeleteDanglingEndpoint(e Endpoint)
DeleteDanglingEndpoint removes a dangling endpoint.
func InitStatCounters ¶
InitStatCounters initializes v's fields with nil StatCounter fields to new StatCounters.
Types ¶
type ARPStats ¶
type ARPStats struct { // PacketsReceived is the number of ARP packets received from the link layer. PacketsReceived *StatCounter // DisabledPacketsReceived is the number of ARP packets received from the link // layer when the ARP layer is disabled. DisabledPacketsReceived *StatCounter // MalformedPacketsReceived is the number of ARP packets that were dropped due // to being malformed. MalformedPacketsReceived *StatCounter // RequestsReceived is the number of ARP requests received. RequestsReceived *StatCounter // RequestsReceivedUnknownTargetAddress is the number of ARP requests that // were targeted to an interface different from the one it was received on. RequestsReceivedUnknownTargetAddress *StatCounter // OutgoingRequestInterfaceHasNoLocalAddressErrors is the number of failures // to send an ARP request because the interface has no network address // assigned to it. OutgoingRequestInterfaceHasNoLocalAddressErrors *StatCounter // OutgoingRequestBadLocalAddressErrors is the number of failures to send an // ARP request with a bad local address. OutgoingRequestBadLocalAddressErrors *StatCounter // OutgoingRequestNetworkUnreachableErrors is the number of failures to send // an ARP request with a network unreachable error. OutgoingRequestNetworkUnreachableErrors *StatCounter // OutgoingRequestsDropped is the number of ARP requests which failed to write // to a link-layer endpoint. OutgoingRequestsDropped *StatCounter // OutgoingRequestSent is the number of ARP requests successfully written to a // link-layer endpoint. OutgoingRequestsSent *StatCounter // RepliesReceived is the number of ARP replies received. RepliesReceived *StatCounter // OutgoingRepliesDropped is the number of ARP replies which failed to write // to a link-layer endpoint. OutgoingRepliesDropped *StatCounter // OutgoingRepliesSent is the number of ARP replies successfully written to a // link-layer endpoint. OutgoingRepliesSent *StatCounter }
ARPStats collects ARP-specific stats.
type AddMembershipOption ¶
type AddMembershipOption MembershipOption
AddMembershipOption identifies a multicast group to join on some interface.
type Address ¶
type Address string
Address is a byte slice cast as a string that represents the address of a network node. Or, in the case of unix endpoints, it may represent a path.
func (Address) MatchingPrefix ¶
MatchingPrefix returns the matching prefix length in bits.
Panics if b and a have different lengths.
func (Address) To4 ¶
To4 converts the IPv4 address to a 4-byte representation. If the address is not an IPv4 address, To4 returns "".
func (Address) Unspecified ¶
Unspecified returns true if the address is unspecified.
func (Address) WithPrefix ¶
func (a Address) WithPrefix() AddressWithPrefix
WithPrefix returns the address with a prefix that represents a point subnet.
type AddressMask ¶
type AddressMask string
AddressMask is a bitmask for an address.
func (AddressMask) Prefix ¶
func (m AddressMask) Prefix() int
Prefix returns the number of bits before the first host bit.
type AddressWithPrefix ¶
type AddressWithPrefix struct { // Address is a network address. Address Address // PrefixLen is the subnet prefix length. PrefixLen int }
AddressWithPrefix is an address with its subnet prefix length.
func (AddressWithPrefix) String ¶
func (a AddressWithPrefix) String() string
String implements the fmt.Stringer interface.
func (AddressWithPrefix) Subnet ¶
func (a AddressWithPrefix) Subnet() Subnet
Subnet converts the address and prefix into a Subnet value and returns it.
type Clock ¶
type Clock interface { // NowNanoseconds returns the current real time as a number of // nanoseconds since the Unix epoch. NowNanoseconds() int64 // NowMonotonic returns a monotonic time value. NowMonotonic() int64 // AfterFunc waits for the duration to elapse and then calls f in its own // goroutine. It returns a Timer that can be used to cancel the call using // its Stop method. AfterFunc(d time.Duration, f func()) Timer }
A Clock provides the current time and schedules work for execution.
Times returned by a Clock should always be used for application-visible time. Only monotonic times should be used for netstack internal timekeeping.
type CongestionControlOption ¶
type CongestionControlOption string
CongestionControlOption is used by SetSockOpt/GetSockOpt to set/get the current congestion control algorithm.
type ControlMessages ¶
type ControlMessages struct { // HasTimestamp indicates whether Timestamp is valid/set. HasTimestamp bool // Timestamp is the time (in ns) that the last packet used to create // the read data was received. Timestamp int64 // HasInq indicates whether Inq is valid/set. HasInq bool // Inq is the number of bytes ready to be received. Inq int32 // HasTOS indicates whether Tos is valid/set. HasTOS bool // TOS is the IPv4 type of service of the associated packet. TOS uint8 // HasTClass indicates whether TClass is valid/set. HasTClass bool // TClass is the IPv6 traffic class of the associated packet. TClass uint32 // HasIPPacketInfo indicates whether PacketInfo is set. HasIPPacketInfo bool // PacketInfo holds interface and address data on an incoming packet. PacketInfo IPPacketInfo // HasOriginalDestinationAddress indicates whether OriginalDstAddress is // set. HasOriginalDstAddress bool // OriginalDestinationAddress holds the original destination address // and port of the incoming packet. OriginalDstAddress FullAddress // SockErr is the dequeued socket error on recvmsg(MSG_ERRQUEUE). SockErr *SockError }
A ControlMessages contains socket control messages for IP sockets.
+stateify savable
func (*ControlMessages) StateFields ¶
func (c *ControlMessages) StateFields() []string
func (*ControlMessages) StateLoad ¶
func (c *ControlMessages) StateLoad(stateSourceObject state.Source)
func (*ControlMessages) StateSave ¶
func (c *ControlMessages) StateSave(stateSinkObject state.Sink)
func (*ControlMessages) StateTypeName ¶
func (c *ControlMessages) StateTypeName() string
type DefaultSocketOptionsHandler ¶
type DefaultSocketOptionsHandler struct{}
DefaultSocketOptionsHandler is an embeddable type that implements no-op implementations for SocketOptionsHandler methods.
func (*DefaultSocketOptionsHandler) HasNIC ¶
func (*DefaultSocketOptionsHandler) HasNIC(int32) bool
HasNIC implements SocketOptionsHandler.HasNIC.
func (*DefaultSocketOptionsHandler) LastError ¶
func (*DefaultSocketOptionsHandler) LastError() *Error
LastError implements SocketOptionsHandler.LastError.
func (*DefaultSocketOptionsHandler) OnCorkOptionSet ¶
func (*DefaultSocketOptionsHandler) OnCorkOptionSet(bool)
OnCorkOptionSet implements SocketOptionsHandler.OnCorkOptionSet.
func (*DefaultSocketOptionsHandler) OnDelayOptionSet ¶
func (*DefaultSocketOptionsHandler) OnDelayOptionSet(bool)
OnDelayOptionSet implements SocketOptionsHandler.OnDelayOptionSet.
func (*DefaultSocketOptionsHandler) OnKeepAliveSet ¶
func (*DefaultSocketOptionsHandler) OnKeepAliveSet(bool)
OnKeepAliveSet implements SocketOptionsHandler.OnKeepAliveSet.
func (*DefaultSocketOptionsHandler) OnReuseAddressSet ¶
func (*DefaultSocketOptionsHandler) OnReuseAddressSet(bool)
OnReuseAddressSet implements SocketOptionsHandler.OnReuseAddressSet.
func (*DefaultSocketOptionsHandler) OnReusePortSet ¶
func (*DefaultSocketOptionsHandler) OnReusePortSet(bool)
OnReusePortSet implements SocketOptionsHandler.OnReusePortSet.
func (*DefaultSocketOptionsHandler) UpdateLastError ¶
func (*DefaultSocketOptionsHandler) UpdateLastError(*Error)
UpdateLastError implements SocketOptionsHandler.UpdateLastError.
type DefaultTTLOption ¶
type DefaultTTLOption uint8
DefaultTTLOption is used by stack.(*Stack).NetworkProtocolOption to specify a default TTL.
type Endpoint ¶
type Endpoint interface { // Close puts the endpoint in a closed state and frees all resources // associated with it. Close initiates the teardown process, the // Endpoint may not be fully closed when Close returns. Close() // Abort initiates an expedited endpoint teardown. As compared to // Close, Abort prioritizes closing the Endpoint quickly over cleanly. // Abort is best effort; implementing Abort with Close is acceptable. Abort() // Read reads data from the endpoint and optionally writes to dst. // // This method does not block if there is no data pending; in this case, // ErrWouldBlock is returned. // // If non-zero number of bytes are successfully read and written to dst, err // must be nil. Otherwise, if dst failed to write anything, ErrBadBuffer // should be returned. Read(dst io.Writer, opts ReadOptions) (res ReadResult, err *Error) // Write writes data to the endpoint's peer. This method does not block if // the data cannot be written. // // Unlike io.Writer.Write, Endpoint.Write transfers ownership of any bytes // successfully written to the Endpoint. That is, if a call to // Write(SlicePayload{data}) returns (n, err), it may retain data[:n], and // the caller should not use data[:n] after Write returns. // // Note that unlike io.Writer.Write, it is not an error for Write to // perform a partial write (if n > 0, no error may be returned). Only // stream (TCP) Endpoints may return partial writes, and even then only // in the case where writing additional data would block. Other Endpoints // will either write the entire message or return an error. Write(Payloader, WriteOptions) (int64, *Error) // Connect connects the endpoint to its peer. Specifying a NIC is // optional. // // There are three classes of return values: // nil -- the attempt to connect succeeded. // ErrConnectStarted/ErrAlreadyConnecting -- the connect attempt started // but hasn't completed yet. In this case, the caller must call Connect // or GetSockOpt(ErrorOption) when the endpoint becomes writable to // get the actual result. The first call to Connect after the socket has // connected returns nil. Calling connect again results in ErrAlreadyConnected. // Anything else -- the attempt to connect failed. // // If address.Addr is empty, this means that Enpoint has to be // disconnected if this is supported, otherwise // ErrAddressFamilyNotSupported must be returned. Connect(address FullAddress) *Error // Disconnect disconnects the endpoint from its peer. Disconnect() *Error // Shutdown closes the read and/or write end of the endpoint connection // to its peer. Shutdown(flags ShutdownFlags) *Error // Listen puts the endpoint in "listen" mode, which allows it to accept // new connections. Listen(backlog int) *Error // Accept returns a new endpoint if a peer has established a connection // to an endpoint previously set to listen mode. This method does not // block if no new connections are available. // // The returned Queue is the wait queue for the newly created endpoint. // // If peerAddr is not nil then it is populated with the peer address of the // returned endpoint. Accept(peerAddr *FullAddress) (Endpoint, *waiter.Queue, *Error) // Bind binds the endpoint to a specific local address and port. // Specifying a NIC is optional. Bind(address FullAddress) *Error // GetLocalAddress returns the address to which the endpoint is bound. GetLocalAddress() (FullAddress, *Error) // GetRemoteAddress returns the address to which the endpoint is // connected. GetRemoteAddress() (FullAddress, *Error) // Readiness returns the current readiness of the endpoint. For example, // if waiter.EventIn is set, the endpoint is immediately readable. Readiness(mask waiter.EventMask) waiter.EventMask // SetSockOpt sets a socket option. SetSockOpt(opt SettableSocketOption) *Error // SetSockOptInt sets a socket option, for simple cases where a value // has the int type. SetSockOptInt(opt SockOptInt, v int) *Error // GetSockOpt gets a socket option. GetSockOpt(opt GettableSocketOption) *Error // GetSockOptInt gets a socket option for simple cases where a return // value has the int type. GetSockOptInt(SockOptInt) (int, *Error) // State returns a socket's lifecycle state. The returned value is // protocol-specific and is primarily used for diagnostics. State() uint32 // ModerateRecvBuf should be called everytime data is copied to the user // space. This allows for dynamic tuning of recv buffer space for a // given socket. // // NOTE: This method is a no-op for sockets other than TCP. ModerateRecvBuf(copied int) // Info returns a copy to the transport endpoint info. Info() EndpointInfo // Stats returns a reference to the endpoint stats. Stats() EndpointStats // SetOwner sets the task owner to the endpoint owner. SetOwner(owner PacketOwner) // LastError clears and returns the last error reported by the endpoint. LastError() *Error // SocketOptions returns the structure which contains all the socket // level options. SocketOptions() *SocketOptions }
Endpoint is the interface implemented by transport protocols (e.g., tcp, udp) that exposes functionality like read, write, connect, etc. to users of the networking stack.
func GetDanglingEndpoints ¶
func GetDanglingEndpoints() []Endpoint
GetDanglingEndpoints returns all dangling endpoints.
type EndpointInfo ¶
type EndpointInfo interface { // IsEndpointInfo is an empty method to implement the tcpip.EndpointInfo // marker interface. IsEndpointInfo() }
EndpointInfo is the interface implemented by each endpoint info struct.
type EndpointStats ¶
type EndpointStats interface { // IsEndpointStats is an empty method to implement the tcpip.EndpointStats // marker interface. IsEndpointStats() }
EndpointStats is the interface implemented by each endpoint stats struct.
type ErrSaveRejection ¶
type ErrSaveRejection struct {
Err error
}
ErrSaveRejection indicates a failed save due to unsupported networking state. This type of errors is only used for save logic.
func (ErrSaveRejection) Error ¶
func (e ErrSaveRejection) Error() string
Error returns a sensible description of the save rejection error.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an error in the netstack error space. Using a special type ensures that errors outside of this space are not accidentally introduced.
All errors must have unique msg strings.
+stateify savable
func StringToError ¶
StringToError converts an error message to the error.
func (*Error) IgnoreStats ¶
IgnoreStats indicates whether this error type should be included in failure counts in tcpip.Stats structs.
func (*Error) StateFields ¶
func (*Error) StateTypeName ¶
type FullAddress ¶
type FullAddress struct { // NIC is the ID of the NIC this address refers to. // // This may not be used by all endpoint types. NIC NICID // Addr is the network or link layer address. Addr Address // Port is the transport port. // // This may not be used by all endpoint types. Port uint16 }
FullAddress represents a full transport node address, as required by the Connect() and Bind() methods.
+stateify savable
func (*FullAddress) StateFields ¶
func (f *FullAddress) StateFields() []string
func (*FullAddress) StateLoad ¶
func (f *FullAddress) StateLoad(stateSourceObject state.Source)
func (*FullAddress) StateSave ¶
func (f *FullAddress) StateSave(stateSinkObject state.Sink)
func (*FullAddress) StateTypeName ¶
func (f *FullAddress) StateTypeName() string
type GettableNetworkProtocolOption ¶
type GettableNetworkProtocolOption interface {
// contains filtered or unexported methods
}
GettableNetworkProtocolOption is a marker interface for network protocol options that may be queried.
type GettableSocketOption ¶
type GettableSocketOption interface {
// contains filtered or unexported methods
}
GettableSocketOption is a marker interface for socket options that may be queried.
type GettableTransportProtocolOption ¶
type GettableTransportProtocolOption interface {
// contains filtered or unexported methods
}
GettableTransportProtocolOption is a marker interface for transport protocol options that may be queried.
type ICMPStats ¶
type ICMPStats struct { // V4 contains the ICMPv4-specifics stats. V4 ICMPv4Stats // V6 contains the ICMPv4-specifics stats. V6 ICMPv6Stats }
ICMPStats collects ICMP-specific stats (both v4 and v6).
type ICMPv4PacketStats ¶
type ICMPv4PacketStats struct { // Echo is the total number of ICMPv4 echo packets counted. Echo *StatCounter // EchoReply is the total number of ICMPv4 echo reply packets counted. EchoReply *StatCounter // DstUnreachable is the total number of ICMPv4 destination unreachable // packets counted. DstUnreachable *StatCounter // SrcQuench is the total number of ICMPv4 source quench packets // counted. SrcQuench *StatCounter // Redirect is the total number of ICMPv4 redirect packets counted. Redirect *StatCounter // TimeExceeded is the total number of ICMPv4 time exceeded packets // counted. TimeExceeded *StatCounter // ParamProblem is the total number of ICMPv4 parameter problem packets // counted. ParamProblem *StatCounter // Timestamp is the total number of ICMPv4 timestamp packets counted. Timestamp *StatCounter // TimestampReply is the total number of ICMPv4 timestamp reply packets // counted. TimestampReply *StatCounter // InfoRequest is the total number of ICMPv4 information request // packets counted. InfoRequest *StatCounter // InfoReply is the total number of ICMPv4 information reply packets // counted. InfoReply *StatCounter }
ICMPv4PacketStats enumerates counts for all ICMPv4 packet types.
type ICMPv4ReceivedPacketStats ¶
type ICMPv4ReceivedPacketStats struct { ICMPv4PacketStats // Invalid is the total number of invalid ICMPv4 packets received. Invalid *StatCounter }
ICMPv4ReceivedPacketStats collects inbound ICMPv4-specific stats.
type ICMPv4SentPacketStats ¶
type ICMPv4SentPacketStats struct { ICMPv4PacketStats // Dropped is the total number of ICMPv4 packets dropped due to link // layer errors. Dropped *StatCounter // RateLimited is the total number of ICMPv4 packets dropped due to // rate limit being exceeded. RateLimited *StatCounter }
ICMPv4SentPacketStats collects outbound ICMPv4-specific stats.
type ICMPv4Stats ¶
type ICMPv4Stats struct { // PacketsSent contains statistics about sent packets. PacketsSent ICMPv4SentPacketStats // PacketsReceived contains statistics about received packets. PacketsReceived ICMPv4ReceivedPacketStats }
ICMPv4Stats collects ICMPv4-specific stats.
type ICMPv6PacketStats ¶
type ICMPv6PacketStats struct { // EchoRequest is the total number of ICMPv6 echo request packets // counted. EchoRequest *StatCounter // EchoReply is the total number of ICMPv6 echo reply packets counted. EchoReply *StatCounter // DstUnreachable is the total number of ICMPv6 destination unreachable // packets counted. DstUnreachable *StatCounter // PacketTooBig is the total number of ICMPv6 packet too big packets // counted. PacketTooBig *StatCounter // TimeExceeded is the total number of ICMPv6 time exceeded packets // counted. TimeExceeded *StatCounter // ParamProblem is the total number of ICMPv6 parameter problem packets // counted. ParamProblem *StatCounter // RouterSolicit is the total number of ICMPv6 router solicit packets // counted. RouterSolicit *StatCounter // RouterAdvert is the total number of ICMPv6 router advert packets // counted. RouterAdvert *StatCounter // NeighborSolicit is the total number of ICMPv6 neighbor solicit // packets counted. NeighborSolicit *StatCounter // NeighborAdvert is the total number of ICMPv6 neighbor advert packets // counted. NeighborAdvert *StatCounter // RedirectMsg is the total number of ICMPv6 redirect message packets // counted. RedirectMsg *StatCounter // MulticastListenerQuery is the total number of Multicast Listener Query // messages counted. MulticastListenerQuery *StatCounter // MulticastListenerReport is the total number of Multicast Listener Report // messages counted. MulticastListenerReport *StatCounter // MulticastListenerDone is the total number of Multicast Listener Done // messages counted. MulticastListenerDone *StatCounter }
ICMPv6PacketStats enumerates counts for all ICMPv6 packet types.
type ICMPv6ReceivedPacketStats ¶
type ICMPv6ReceivedPacketStats struct { ICMPv6PacketStats // Unrecognized is the total number of ICMPv6 packets received that the // transport layer does not know how to parse. Unrecognized *StatCounter // Invalid is the total number of invalid ICMPv6 packets received. Invalid *StatCounter // RouterOnlyPacketsDroppedByHost is the total number of ICMPv6 packets // dropped due to being router-specific packets. RouterOnlyPacketsDroppedByHost *StatCounter }
ICMPv6ReceivedPacketStats collects inbound ICMPv6-specific stats.
type ICMPv6SentPacketStats ¶
type ICMPv6SentPacketStats struct { ICMPv6PacketStats // Dropped is the total number of ICMPv6 packets dropped due to link // layer errors. Dropped *StatCounter // RateLimited is the total number of ICMPv6 packets dropped due to // rate limit being exceeded. RateLimited *StatCounter }
ICMPv6SentPacketStats collects outbound ICMPv6-specific stats.
type ICMPv6Stats ¶
type ICMPv6Stats struct { // PacketsSent contains statistics about sent packets. PacketsSent ICMPv6SentPacketStats // PacketsReceived contains statistics about received packets. PacketsReceived ICMPv6ReceivedPacketStats }
ICMPv6Stats collects ICMPv6-specific stats.
type IGMPPacketStats ¶
type IGMPPacketStats struct { // MembershipQuery is the total number of Membership Query messages counted. MembershipQuery *StatCounter // V1MembershipReport is the total number of Version 1 Membership Report // messages counted. V1MembershipReport *StatCounter // V2MembershipReport is the total number of Version 2 Membership Report // messages counted. V2MembershipReport *StatCounter // LeaveGroup is the total number of Leave Group messages counted. LeaveGroup *StatCounter }
IGMPPacketStats enumerates counts for all IGMP packet types.
type IGMPReceivedPacketStats ¶
type IGMPReceivedPacketStats struct { IGMPPacketStats // Invalid is the total number of invalid IGMP packets received. Invalid *StatCounter // ChecksumErrors is the total number of IGMP packets dropped due to bad // checksums. ChecksumErrors *StatCounter // Unrecognized is the total number of unrecognized messages counted, these // are silently ignored for forward-compatibilty. Unrecognized *StatCounter }
IGMPReceivedPacketStats collects inbound IGMP-specific stats.
type IGMPSentPacketStats ¶
type IGMPSentPacketStats struct { IGMPPacketStats // Dropped is the total number of IGMP packets dropped. Dropped *StatCounter }
IGMPSentPacketStats collects outbound IGMP-specific stats.
type IGMPStats ¶
type IGMPStats struct { // PacketsSent contains statistics about sent packets. PacketsSent IGMPSentPacketStats // PacketsReceived contains statistics about received packets. PacketsReceived IGMPReceivedPacketStats }
IGMPStats collects IGMP-specific stats.
type IPPacketInfo ¶
type IPPacketInfo struct { // NIC is the ID of the NIC to be used. NIC NICID // LocalAddr is the local address. LocalAddr Address // DestinationAddr is the destination address found in the IP header. DestinationAddr Address }
IPPacketInfo is the message structure for IP_PKTINFO.
+stateify savable
func (*IPPacketInfo) StateFields ¶
func (i *IPPacketInfo) StateFields() []string
func (*IPPacketInfo) StateLoad ¶
func (i *IPPacketInfo) StateLoad(stateSourceObject state.Source)
func (*IPPacketInfo) StateSave ¶
func (i *IPPacketInfo) StateSave(stateSinkObject state.Sink)
func (*IPPacketInfo) StateTypeName ¶
func (i *IPPacketInfo) StateTypeName() string
type IPStats ¶
type IPStats struct { // PacketsReceived is the total number of IP packets received from the // link layer. PacketsReceived *StatCounter // DisabledPacketsReceived is the total number of IP packets received from the // link layer when the IP layer is disabled. DisabledPacketsReceived *StatCounter // InvalidDestinationAddressesReceived is the total number of IP packets // received with an unknown or invalid destination address. InvalidDestinationAddressesReceived *StatCounter // InvalidSourceAddressesReceived is the total number of IP packets received // with a source address that should never have been received on the wire. InvalidSourceAddressesReceived *StatCounter // PacketsDelivered is the total number of incoming IP packets that // are successfully delivered to the transport layer. PacketsDelivered *StatCounter // PacketsSent is the total number of IP packets sent via WritePacket. PacketsSent *StatCounter // OutgoingPacketErrors is the total number of IP packets which failed // to write to a link-layer endpoint. OutgoingPacketErrors *StatCounter // MalformedPacketsReceived is the total number of IP Packets that were // dropped due to the IP packet header failing validation checks. MalformedPacketsReceived *StatCounter // MalformedFragmentsReceived is the total number of IP Fragments that were // dropped due to the fragment failing validation checks. MalformedFragmentsReceived *StatCounter // IPTablesPreroutingDropped is the total number of IP packets dropped // in the Prerouting chain. IPTablesPreroutingDropped *StatCounter // IPTablesInputDropped is the total number of IP packets dropped in // the Input chain. IPTablesInputDropped *StatCounter // IPTablesOutputDropped is the total number of IP packets dropped in // the Output chain. IPTablesOutputDropped *StatCounter // OptionTSReceived is the number of Timestamp options seen. OptionTSReceived *StatCounter // OptionRRReceived is the number of Record Route options seen. OptionRRReceived *StatCounter // OptionUnknownReceived is the number of unknown IP options seen. OptionUnknownReceived *StatCounter }
IPStats collects IP-specific stats (both v4 and v6).
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job represents some work that can be scheduled for execution. The work can be safely cancelled when it fires at the same time some "related work" is being done.
The term "related work" is defined as some work that needs to be done while holding some lock that the timer must also hold while doing some work.
Note, it is not safe to copy a Job as its timer instance creates a closure over the address of the Job.
func NewJob ¶
NewJob returns a new Job that can be used to schedule f to run in its own gorountine. l will be locked before calling f then unlocked after f returns.
var clock tcpip.StdClock var mu sync.Mutex message := "foo" job := tcpip.NewJob(&clock, &mu, func() { fmt.Println(message) }) job.Schedule(time.Second) mu.Lock() message = "bar" mu.Unlock() // Output: bar
f MUST NOT attempt to lock l.
l MUST be locked prior to calling the returned job's Cancel().
var clock tcpip.StdClock var mu sync.Mutex message := "foo" job := tcpip.NewJob(&clock, &mu, func() { fmt.Println(message) }) job.Schedule(time.Second) mu.Lock() job.Cancel() mu.Unlock()
func (*Job) Cancel ¶
func (j *Job) Cancel()
Cancel prevents the Job from executing if it has not executed already.
Cancel requires appropriate locking to be in place for any resources managed by the Job. If the Job is blocked on obtaining the lock when Cancel is called, it will early return.
Note, t will be modified.
j.locker MUST be locked.
func (*Job) Schedule ¶
Schedule schedules the Job for execution after duration d. This can be called on cancelled or completed Jobs to schedule them again.
Schedule should be invoked only on unscheduled, cancelled, or completed Jobs. To be safe, callers should always call Cancel before calling Schedule.
Note, j will be modified.
type KeepaliveIdleOption ¶
KeepaliveIdleOption is used by SetSockOpt/GetSockOpt to specify the time a connection must remain idle before the first TCP keepalive packet is sent. Once this time is reached, KeepaliveIntervalOption is used instead.
type KeepaliveIntervalOption ¶
KeepaliveIntervalOption is used by SetSockOpt/GetSockOpt to specify the interval between sending TCP keepalive packets.
type LimitedWriter ¶
A LimitedWriter writes to W but limits the amount of data copied to just N bytes. Each call to Write updates N to reflect the new amount remaining.
type LingerOption ¶
LingerOption is used by SetSockOpt/GetSockOpt to set/get the duration for which a socket lingers before returning from Close.
+stateify savable
func (*LingerOption) StateFields ¶
func (l *LingerOption) StateFields() []string
func (*LingerOption) StateLoad ¶
func (l *LingerOption) StateLoad(stateSourceObject state.Source)
func (*LingerOption) StateSave ¶
func (l *LingerOption) StateSave(stateSinkObject state.Sink)
func (*LingerOption) StateTypeName ¶
func (l *LingerOption) StateTypeName() string
type LinkAddress ¶
type LinkAddress string
LinkAddress is a byte slice cast as a string that represents a link address. It is typically a 6-byte MAC address.
func ParseMACAddress ¶
func ParseMACAddress(s string) (LinkAddress, error)
ParseMACAddress parses an IEEE 802 address.
It must be in the format aa:bb:cc:dd:ee:ff or aa-bb-cc-dd-ee-ff.
func (LinkAddress) String ¶
func (a LinkAddress) String() string
String implements the fmt.Stringer interface.
type LinkPacketInfo ¶
type LinkPacketInfo struct { // Protocol is the NetworkProtocolNumber for the packet. Protocol NetworkProtocolNumber // PktType is used to indicate the destination of the packet. PktType PacketType }
LinkPacketInfo holds Link layer information for a received packet.
+stateify savable
func (*LinkPacketInfo) StateFields ¶
func (l *LinkPacketInfo) StateFields() []string
func (*LinkPacketInfo) StateLoad ¶
func (l *LinkPacketInfo) StateLoad(stateSourceObject state.Source)
func (*LinkPacketInfo) StateSave ¶
func (l *LinkPacketInfo) StateSave(stateSinkObject state.Sink)
func (*LinkPacketInfo) StateTypeName ¶
func (l *LinkPacketInfo) StateTypeName() string
type MembershipOption ¶
MembershipOption is used to identify a multicast membership on an interface.
type MultiCounterStat ¶
type MultiCounterStat struct {
// contains filtered or unexported fields
}
A MultiCounterStat keeps track of two counters at once.
func (*MultiCounterStat) Increment ¶
func (m *MultiCounterStat) Increment()
Increment adds one to the counters.
func (*MultiCounterStat) IncrementBy ¶
func (m *MultiCounterStat) IncrementBy(v uint64)
IncrementBy increments the counters by v.
func (*MultiCounterStat) Init ¶
func (m *MultiCounterStat) Init(a, b *StatCounter)
Init sets both internal counters to point to a and b.
type MulticastInterfaceOption ¶
MulticastInterfaceOption is used by SetSockOpt/GetSockOpt to specify a default interface for multicast.
type NetworkProtocolNumber ¶
type NetworkProtocolNumber uint32
NetworkProtocolNumber is the EtherType of a network protocol in an Ethernet frame.
See: https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml
type OriginalDestinationOption ¶
type OriginalDestinationOption FullAddress
OriginalDestinationOption is used to get the original destination address and port of a redirected packet.
type PacketOwner ¶
type PacketOwner interface { // UID returns UID of the packet. UID() uint32 // GID returns GID of the packet. GID() uint32 }
PacketOwner is used to get UID and GID of the packet.
type PacketType ¶
type PacketType uint8
PacketType is used to indicate the destination of the packet.
const ( // PacketHost indicates a packet addressed to the local host. PacketHost PacketType = iota // PacketOtherHost indicates an outgoing packet addressed to // another host caught by a NIC in promiscuous mode. PacketOtherHost // PacketOutgoing for a packet originating from the local host // that is looped back to a packet socket. PacketOutgoing // PacketBroadcast indicates a link layer broadcast packet. PacketBroadcast // PacketMulticast indicates a link layer multicast packet. PacketMulticast )
type Payloader ¶
type Payloader interface { io.Reader // Len returns the number of bytes of the unread portion of the // Reader. Len() int }
Payloader is an interface that provides data.
This interface allows the endpoint to request the amount of data it needs based on internal buffers without exposing them.
type ProtocolAddress ¶
type ProtocolAddress struct { // Protocol is the protocol of the address. Protocol NetworkProtocolNumber // AddressWithPrefix is a network address with its subnet prefix length. AddressWithPrefix AddressWithPrefix }
ProtocolAddress is an address and the network protocol it is associated with.
type ReadErrors ¶
type ReadErrors struct { // ReadClosed is the number of received packet drops because the endpoint // was shutdown for read. ReadClosed StatCounter // InvalidEndpointState is the number of times we found the endpoint state // to be unexpected. InvalidEndpointState StatCounter // NotConnected is the number of times we tried to read but found that the // endpoint was not connected. NotConnected StatCounter }
ReadErrors collects segment read errors from an endpoint read call.
type ReadOptions ¶
type ReadOptions struct { // Peek indicates whether this read is a peek. Peek bool // NeedRemoteAddr indicates whether to return the remote address, if // supported. NeedRemoteAddr bool // NeedLinkPacketInfo indicates whether to return the link-layer information, // if supported. NeedLinkPacketInfo bool }
ReadOptions contains options for Endpoint.Read.
type ReadResult ¶
type ReadResult struct { // Count is the number of bytes received and written to the buffer. Count int // Total is the number of bytes of the received packet. This can be used to // determine whether the read is truncated. Total int // ControlMessages is the control messages received. ControlMessages ControlMessages // RemoteAddr is the remote address if ReadOptions.NeedAddr is true. RemoteAddr FullAddress // LinkPacketInfo is the link-layer information of the received packet if // ReadOptions.NeedLinkPacketInfo is true. LinkPacketInfo LinkPacketInfo }
ReadResult represents result for a successful Endpoint.Read.
type ReceiveErrors ¶
type ReceiveErrors struct { // ReceiveBufferOverflow is the number of received packets dropped // due to the receive buffer being full. ReceiveBufferOverflow StatCounter // MalformedPacketsReceived is the number of incoming packets // dropped due to the packet header being in a malformed state. MalformedPacketsReceived StatCounter // ClosedReceiver is the number of received packets dropped because // of receiving endpoint state being closed. ClosedReceiver StatCounter // ChecksumErrors is the number of packets dropped due to bad checksums. ChecksumErrors StatCounter }
ReceiveErrors collects packet receive errors within transport endpoint.
type RemoveMembershipOption ¶
type RemoveMembershipOption MembershipOption
RemoveMembershipOption identifies a multicast group to leave on some interface.
type Route ¶
type Route struct { // Destination must contain the target address for this row to be viable. Destination Subnet // Gateway is the gateway to be used if this row is viable. Gateway Address // NIC is the id of the nic to be used if this row is viable. NIC NICID }
Route is a row in the routing table. It specifies through which NIC (and gateway) sets of packets should be routed. A row is considered viable if the masked target address matches the destination address in the row.
type SendErrors ¶
type SendErrors struct { // SendToNetworkFailed is the number of packets failed to be written to // the network endpoint. SendToNetworkFailed StatCounter // NoRoute is the number of times we failed to resolve IP route. NoRoute StatCounter }
SendErrors collects packet send errors within the transport layer for an endpoint.
type SettableNetworkProtocolOption ¶
type SettableNetworkProtocolOption interface {
// contains filtered or unexported methods
}
SettableNetworkProtocolOption is a marker interface for network protocol options that may be set.
type SettableSocketOption ¶
type SettableSocketOption interface {
// contains filtered or unexported methods
}
SettableSocketOption is a marker interface for socket options that may be configured.
type SettableTransportProtocolOption ¶
type SettableTransportProtocolOption interface {
// contains filtered or unexported methods
}
SettableTransportProtocolOption is a marker interface for transport protocol options that may be set.
type ShutdownFlags ¶
type ShutdownFlags int
ShutdownFlags represents flags that can be passed to the Shutdown() method of the Endpoint interface.
const ( ShutdownRead ShutdownFlags = 1 << iota ShutdownWrite )
Values of the flags that can be passed to the Shutdown() method. They can be OR'ed together.
type SockErrOrigin ¶
type SockErrOrigin uint8
SockErrOrigin represents the constants for error origin.
const ( // SockExtErrorOriginNone represents an unknown error origin. SockExtErrorOriginNone SockErrOrigin = iota // SockExtErrorOriginLocal indicates a local error. SockExtErrorOriginLocal // SockExtErrorOriginICMP indicates an IPv4 ICMP error. SockExtErrorOriginICMP // SockExtErrorOriginICMP6 indicates an IPv6 ICMP error. SockExtErrorOriginICMP6 )
func (SockErrOrigin) IsICMPErr ¶
func (origin SockErrOrigin) IsICMPErr() bool
IsICMPErr indicates if the error originated from an ICMP error.
type SockError ¶
type SockError struct { // Err is the error caused by the errant packet. Err *Error // ErrOrigin indicates the error origin. ErrOrigin SockErrOrigin // ErrType is the type in the ICMP header. ErrType uint8 // ErrCode is the code in the ICMP header. ErrCode uint8 // ErrInfo is additional info about the error. ErrInfo uint32 // Payload is the errant packet's payload. Payload []byte // Dst is the original destination address of the errant packet. Dst FullAddress // Offender is the original sender address of the errant packet. Offender FullAddress // NetProto is the network protocol being used to transmit the packet. NetProto NetworkProtocolNumber // contains filtered or unexported fields }
SockError represents a queue entry in the per-socket error queue.
+stateify savable
func (*SockError) Next ¶
func (e *SockError) Next() *SockError
Next returns the entry that follows e in the list.
func (*SockError) Prev ¶
func (e *SockError) Prev() *SockError
Prev returns the entry that precedes e in the list.
func (*SockError) SetNext ¶
func (e *SockError) SetNext(elem *SockError)
SetNext assigns 'entry' as the entry that follows e in the list.
func (*SockError) SetPrev ¶
func (e *SockError) SetPrev(elem *SockError)
SetPrev assigns 'entry' as the entry that precedes e in the list.
func (*SockError) StateFields ¶
func (*SockError) StateTypeName ¶
type SockOptInt ¶
type SockOptInt int
SockOptInt represents socket options which values have the int type.
const ( // KeepaliveCountOption is used by SetSockOptInt/GetSockOptInt to // specify the number of un-ACKed TCP keepalives that will be sent // before the connection is closed. KeepaliveCountOption SockOptInt = iota // IPv4TOSOption is used by SetSockOptInt/GetSockOptInt to specify TOS // for all subsequent outgoing IPv4 packets from the endpoint. IPv4TOSOption // IPv6TrafficClassOption is used by SetSockOptInt/GetSockOptInt to // specify TOS for all subsequent outgoing IPv6 packets from the // endpoint. IPv6TrafficClassOption // MaxSegOption is used by SetSockOptInt/GetSockOptInt to set/get the // current Maximum Segment Size(MSS) value as specified using the // TCP_MAXSEG option. MaxSegOption // MTUDiscoverOption is used to set/get the path MTU discovery setting. // // NOTE: Setting this option to any other value than PMTUDiscoveryDont // is not supported and will fail as such, and getting this option will // always return PMTUDiscoveryDont. MTUDiscoverOption // MulticastTTLOption is used by SetSockOptInt/GetSockOptInt to control // the default TTL value for multicast messages. The default is 1. MulticastTTLOption // ReceiveQueueSizeOption is used in GetSockOptInt to specify that the // number of unread bytes in the input buffer should be returned. ReceiveQueueSizeOption // SendBufferSizeOption is used by SetSockOptInt/GetSockOptInt to // specify the send buffer size option. SendBufferSizeOption // ReceiveBufferSizeOption is used by SetSockOptInt/GetSockOptInt to // specify the receive buffer size option. ReceiveBufferSizeOption // SendQueueSizeOption is used in GetSockOptInt to specify that the // number of unread bytes in the output buffer should be returned. SendQueueSizeOption // TTLOption is used by SetSockOptInt/GetSockOptInt to control the // default TTL/hop limit value for unicast messages. The default is // protocol specific. // // A zero value indicates the default. TTLOption // TCPSynCountOption is used by SetSockOptInt/GetSockOptInt to specify // the number of SYN retransmits that TCP should send before aborting // the attempt to connect. It cannot exceed 255. // // NOTE: This option is currently only stubbed out and is no-op. TCPSynCountOption // TCPWindowClampOption is used by SetSockOptInt/GetSockOptInt to bound // the size of the advertised window to this value. // // NOTE: This option is currently only stubed out and is a no-op TCPWindowClampOption )
type SocketDetachFilterOption ¶
type SocketDetachFilterOption int
SocketDetachFilterOption is used by SetSockOpt to detach a previously attached classic BPF filter on a given endpoint.
type SocketOptions ¶
type SocketOptions struct {
// contains filtered or unexported fields
}
SocketOptions contains all the variables which store values for SOL_SOCKET, SOL_IP, SOL_IPV6 and SOL_TCP level options.
+stateify savable
func (*SocketOptions) DequeueErr ¶
func (so *SocketOptions) DequeueErr() *SockError
DequeueErr dequeues a socket extended error from the error queue and returns it. Returns nil if queue is empty.
func (*SocketOptions) GetBindToDevice ¶
func (so *SocketOptions) GetBindToDevice() int32
GetBindToDevice gets value for SO_BINDTODEVICE option.
func (*SocketOptions) GetBroadcast ¶
func (so *SocketOptions) GetBroadcast() bool
GetBroadcast gets value for SO_BROADCAST option.
func (*SocketOptions) GetCorkOption ¶
func (so *SocketOptions) GetCorkOption() bool
GetCorkOption gets value for TCP_CORK option.
func (*SocketOptions) GetDelayOption ¶
func (so *SocketOptions) GetDelayOption() bool
GetDelayOption gets inverted value for TCP_NODELAY option.
func (*SocketOptions) GetHeaderIncluded ¶
func (so *SocketOptions) GetHeaderIncluded() bool
GetHeaderIncluded gets value for IP_HDRINCL option.
func (*SocketOptions) GetKeepAlive ¶
func (so *SocketOptions) GetKeepAlive() bool
GetKeepAlive gets value for SO_KEEPALIVE option.
func (*SocketOptions) GetLastError ¶
func (so *SocketOptions) GetLastError() *Error
GetLastError gets value for SO_ERROR option.
func (*SocketOptions) GetLinger ¶
func (so *SocketOptions) GetLinger() LingerOption
GetLinger gets value for SO_LINGER option.
func (*SocketOptions) GetMulticastLoop ¶
func (so *SocketOptions) GetMulticastLoop() bool
GetMulticastLoop gets value for IP_MULTICAST_LOOP option.
func (*SocketOptions) GetNoChecksum ¶
func (so *SocketOptions) GetNoChecksum() bool
GetNoChecksum gets value for SO_NO_CHECK option.
func (*SocketOptions) GetOutOfBandInline ¶
func (*SocketOptions) GetOutOfBandInline() bool
GetOutOfBandInline gets value for SO_OOBINLINE option.
func (*SocketOptions) GetPassCred ¶
func (so *SocketOptions) GetPassCred() bool
GetPassCred gets value for SO_PASSCRED option.
func (*SocketOptions) GetQuickAck ¶
func (so *SocketOptions) GetQuickAck() bool
GetQuickAck gets value for TCP_QUICKACK option.
func (*SocketOptions) GetReceiveOriginalDstAddress ¶
func (so *SocketOptions) GetReceiveOriginalDstAddress() bool
GetReceiveOriginalDstAddress gets value for IP(V6)_RECVORIGDSTADDR option.
func (*SocketOptions) GetReceivePacketInfo ¶
func (so *SocketOptions) GetReceivePacketInfo() bool
GetReceivePacketInfo gets value for IP_PKTINFO option.
func (*SocketOptions) GetReceiveTClass ¶
func (so *SocketOptions) GetReceiveTClass() bool
GetReceiveTClass gets value for IPV6_RECVTCLASS option.
func (*SocketOptions) GetReceiveTOS ¶
func (so *SocketOptions) GetReceiveTOS() bool
GetReceiveTOS gets value for IP_RECVTOS option.
func (*SocketOptions) GetRecvError ¶
func (so *SocketOptions) GetRecvError() bool
GetRecvError gets value for IP*_RECVERR option.
func (*SocketOptions) GetReuseAddress ¶
func (so *SocketOptions) GetReuseAddress() bool
GetReuseAddress gets value for SO_REUSEADDR option.
func (*SocketOptions) GetReusePort ¶
func (so *SocketOptions) GetReusePort() bool
GetReusePort gets value for SO_REUSEPORT option.
func (*SocketOptions) GetV6Only ¶
func (so *SocketOptions) GetV6Only() bool
GetV6Only gets value for IPV6_V6ONLY option.
func (*SocketOptions) InitHandler ¶
func (so *SocketOptions) InitHandler(handler SocketOptionsHandler)
InitHandler initializes the handler. This must be called before using the socket options utility.
func (*SocketOptions) PeekErr ¶
func (so *SocketOptions) PeekErr() *SockError
PeekErr returns the error in the front of the error queue. Returns nil if the error queue is empty.
func (*SocketOptions) QueueErr ¶
func (so *SocketOptions) QueueErr(err *SockError)
QueueErr inserts the error at the back of the error queue.
Preconditions: so.GetRecvError() == true.
func (*SocketOptions) QueueLocalErr ¶
func (so *SocketOptions) QueueLocalErr(err *Error, net NetworkProtocolNumber, info uint32, dst FullAddress, payload []byte)
QueueLocalErr queues a local error onto the local queue.
func (*SocketOptions) SetBindToDevice ¶
func (so *SocketOptions) SetBindToDevice(bindToDevice int32) *Error
SetBindToDevice sets value for SO_BINDTODEVICE option.
func (*SocketOptions) SetBroadcast ¶
func (so *SocketOptions) SetBroadcast(v bool)
SetBroadcast sets value for SO_BROADCAST option.
func (*SocketOptions) SetCorkOption ¶
func (so *SocketOptions) SetCorkOption(v bool)
SetCorkOption sets value for TCP_CORK option.
func (*SocketOptions) SetDelayOption ¶
func (so *SocketOptions) SetDelayOption(v bool)
SetDelayOption sets inverted value for TCP_NODELAY option.
func (*SocketOptions) SetHeaderIncluded ¶
func (so *SocketOptions) SetHeaderIncluded(v bool)
SetHeaderIncluded sets value for IP_HDRINCL option.
func (*SocketOptions) SetKeepAlive ¶
func (so *SocketOptions) SetKeepAlive(v bool)
SetKeepAlive sets value for SO_KEEPALIVE option.
func (*SocketOptions) SetLastError ¶
func (so *SocketOptions) SetLastError(err *Error)
SetLastError sets the last error for a socket.
func (*SocketOptions) SetLinger ¶
func (so *SocketOptions) SetLinger(linger LingerOption)
SetLinger sets value for SO_LINGER option.
func (*SocketOptions) SetMulticastLoop ¶
func (so *SocketOptions) SetMulticastLoop(v bool)
SetMulticastLoop sets value for IP_MULTICAST_LOOP option.
func (*SocketOptions) SetNoChecksum ¶
func (so *SocketOptions) SetNoChecksum(v bool)
SetNoChecksum sets value for SO_NO_CHECK option.
func (*SocketOptions) SetOutOfBandInline ¶
func (*SocketOptions) SetOutOfBandInline(bool)
SetOutOfBandInline sets value for SO_OOBINLINE option. We currently do not support disabling this option.
func (*SocketOptions) SetPassCred ¶
func (so *SocketOptions) SetPassCred(v bool)
SetPassCred sets value for SO_PASSCRED option.
func (*SocketOptions) SetQuickAck ¶
func (so *SocketOptions) SetQuickAck(v bool)
SetQuickAck sets value for TCP_QUICKACK option.
func (*SocketOptions) SetReceiveOriginalDstAddress ¶
func (so *SocketOptions) SetReceiveOriginalDstAddress(v bool)
SetReceiveOriginalDstAddress sets value for IP(V6)_RECVORIGDSTADDR option.
func (*SocketOptions) SetReceivePacketInfo ¶
func (so *SocketOptions) SetReceivePacketInfo(v bool)
SetReceivePacketInfo sets value for IP_PKTINFO option.
func (*SocketOptions) SetReceiveTClass ¶
func (so *SocketOptions) SetReceiveTClass(v bool)
SetReceiveTClass sets value for IPV6_RECVTCLASS option.
func (*SocketOptions) SetReceiveTOS ¶
func (so *SocketOptions) SetReceiveTOS(v bool)
SetReceiveTOS sets value for IP_RECVTOS option.
func (*SocketOptions) SetRecvError ¶
func (so *SocketOptions) SetRecvError(v bool)
SetRecvError sets value for IP*_RECVERR option.
func (*SocketOptions) SetReuseAddress ¶
func (so *SocketOptions) SetReuseAddress(v bool)
SetReuseAddress sets value for SO_REUSEADDR option.
func (*SocketOptions) SetReusePort ¶
func (so *SocketOptions) SetReusePort(v bool)
SetReusePort sets value for SO_REUSEPORT option.
func (*SocketOptions) SetV6Only ¶
func (so *SocketOptions) SetV6Only(v bool)
SetV6Only sets value for IPV6_V6ONLY option.
Preconditions: the backing TCP or UDP endpoint must be in initial state.
func (*SocketOptions) StateFields ¶
func (so *SocketOptions) StateFields() []string
func (*SocketOptions) StateLoad ¶
func (so *SocketOptions) StateLoad(stateSourceObject state.Source)
func (*SocketOptions) StateSave ¶
func (so *SocketOptions) StateSave(stateSinkObject state.Sink)
func (*SocketOptions) StateTypeName ¶
func (so *SocketOptions) StateTypeName() string
type SocketOptionsHandler ¶
type SocketOptionsHandler interface { // OnReuseAddressSet is invoked when SO_REUSEADDR is set for an endpoint. OnReuseAddressSet(v bool) // OnReusePortSet is invoked when SO_REUSEPORT is set for an endpoint. OnReusePortSet(v bool) // OnKeepAliveSet is invoked when SO_KEEPALIVE is set for an endpoint. OnKeepAliveSet(v bool) // OnDelayOptionSet is invoked when TCP_NODELAY is set for an endpoint. // Note that v will be the inverse of TCP_NODELAY option. OnDelayOptionSet(v bool) // OnCorkOptionSet is invoked when TCP_CORK is set for an endpoint. OnCorkOptionSet(v bool) // LastError is invoked when SO_ERROR is read for an endpoint. LastError() *Error // UpdateLastError updates the endpoint specific last error field. UpdateLastError(err *Error) // HasNIC is invoked to check if the NIC is valid for SO_BINDTODEVICE. HasNIC(v int32) bool }
SocketOptionsHandler holds methods that help define endpoint specific behavior for socket level socket options. These must be implemented by endpoints to get notified when socket level options are set.
type StatCounter ¶
type StatCounter struct {
// contains filtered or unexported fields
}
A StatCounter keeps track of a statistic.
func (*StatCounter) Decrement ¶
func (s *StatCounter) Decrement()
Decrement minuses one to the counter.
func (*StatCounter) Increment ¶
func (s *StatCounter) Increment()
Increment adds one to the counter.
func (*StatCounter) IncrementBy ¶
func (s *StatCounter) IncrementBy(v uint64)
IncrementBy increments the counter by v.
func (*StatCounter) String ¶
func (s *StatCounter) String() string
func (*StatCounter) Value ¶
func (s *StatCounter) Value() uint64
Value returns the current value of the counter.
type Stats ¶
type Stats struct { // UnknownProtocolRcvdPackets is the number of packets received by the // stack that were for an unknown or unsupported protocol. UnknownProtocolRcvdPackets *StatCounter // MalformedRcvdPackets is the number of packets received by the stack // that were deemed malformed. MalformedRcvdPackets *StatCounter // DroppedPackets is the number of packets dropped due to full queues. DroppedPackets *StatCounter // ICMP breaks out ICMP-specific stats (both v4 and v6). ICMP ICMPStats // IGMP breaks out IGMP-specific stats. IGMP IGMPStats // IP breaks out IP-specific stats (both v4 and v6). IP IPStats // ARP breaks out ARP-specific stats. ARP ARPStats // TCP breaks out TCP-specific stats. TCP TCPStats // UDP breaks out UDP-specific stats. UDP UDPStats }
Stats holds statistics about the networking stack.
All fields are optional.
type StdClock ¶
type StdClock struct{}
StdClock implements Clock with the time package.
+stateify savable
func (*StdClock) NowMonotonic ¶
NowMonotonic implements Clock.NowMonotonic.
func (*StdClock) NowNanoseconds ¶
NowNanoseconds implements Clock.NowNanoseconds.
func (*StdClock) StateFields ¶
func (*StdClock) StateTypeName ¶
type Subnet ¶
type Subnet struct {
// contains filtered or unexported fields
}
Subnet is a subnet defined by its address and mask.
func NewSubnet ¶
func NewSubnet(a Address, m AddressMask) (Subnet, error)
NewSubnet creates a new Subnet, checking that the address and mask are the same length.
func (*Subnet) Bits ¶
Bits returns the number of ones (network bits) and zeros (host bits) in the subnet mask.
func (*Subnet) Contains ¶
Contains returns true iff the address is of the same length and matches the subnet address and mask.
func (*Subnet) IsBroadcast ¶
IsBroadcast returns true if the address is considered a broadcast address.
type TCPAvailableCongestionControlOption ¶
type TCPAvailableCongestionControlOption string
TCPAvailableCongestionControlOption is the supported congestion control algorithms for TCP
type TCPDeferAcceptOption ¶
TCPDeferAcceptOption is used by SetSockOpt/GetSockOpt to allow a accept to return a completed connection only when there is data to be read. This usually means the listening socket will drop the final ACK for a handshake till the specified timeout until a segment with data arrives.
type TCPDelayEnabled ¶
type TCPDelayEnabled bool
TCPDelayEnabled enables/disables Nagle's algorithm in TCP.
type TCPInfoOption ¶
TCPInfoOption is used by GetSockOpt to expose TCP statistics.
TODO(b/64800844): Add and populate stat fields.
type TCPLingerTimeoutOption ¶
TCPLingerTimeoutOption is used by SetSockOpt/GetSockOpt to set/get the maximum duration for which a socket lingers in the TCP_FIN_WAIT_2 state before being marked closed.
type TCPMaxRTOOption ¶
TCPMaxRTOOption is use by SetSockOpt/GetSockOpt to allow overriding default MaxRTO used by the Stack.
type TCPMaxRetriesOption ¶
type TCPMaxRetriesOption uint64
TCPMaxRetriesOption is used by SetSockOpt/GetSockOpt to set/get the maximum number of retransmits after which we time out the connection.
type TCPMinRTOOption ¶
TCPMinRTOOption is use by SetSockOpt/GetSockOpt to allow overriding default MinRTO used by the Stack.
type TCPModerateReceiveBufferOption ¶
type TCPModerateReceiveBufferOption bool
TCPModerateReceiveBufferOption enables/disables receive buffer moderation for TCP.
type TCPReceiveBufferSizeRangeOption ¶
TCPReceiveBufferSizeRangeOption is the receive buffer size range for TCP.
type TCPRecovery ¶
type TCPRecovery int32
TCPRecovery is the loss deteoction algorithm used by TCP.
const ( // TCPRACKLossDetection indicates RACK is used for loss detection and // recovery. TCPRACKLossDetection TCPRecovery = 1 << iota // TCPRACKStaticReoWnd indicates the reordering window should not be // adjusted when DSACK is received. TCPRACKStaticReoWnd // TCPRACKNoDupTh indicates RACK should not consider the classic three // duplicate acknowledgements rule to mark the segments as lost. This // is used when reordering is not detected. TCPRACKNoDupTh )
type TCPSendBufferSizeRangeOption ¶
TCPSendBufferSizeRangeOption is the send buffer size range for TCP.
type TCPStats ¶
type TCPStats struct { // ActiveConnectionOpenings is the number of connections opened // successfully via Connect. ActiveConnectionOpenings *StatCounter // PassiveConnectionOpenings is the number of connections opened // successfully via Listen. PassiveConnectionOpenings *StatCounter // CurrentEstablished is the number of TCP connections for which the // current state is ESTABLISHED. CurrentEstablished *StatCounter // CurrentConnected is the number of TCP connections that // are in connected state. CurrentConnected *StatCounter // EstablishedResets is the number of times TCP connections have made // a direct transition to the CLOSED state from either the // ESTABLISHED state or the CLOSE-WAIT state. EstablishedResets *StatCounter // EstablishedClosed is the number of times established TCP connections // made a transition to CLOSED state. EstablishedClosed *StatCounter // EstablishedTimedout is the number of times an established connection // was reset because of keep-alive time out. EstablishedTimedout *StatCounter // ListenOverflowSynDrop is the number of times the listen queue overflowed // and a SYN was dropped. ListenOverflowSynDrop *StatCounter // ListenOverflowAckDrop is the number of times the final ACK // in the handshake was dropped due to overflow. ListenOverflowAckDrop *StatCounter // ListenOverflowCookieSent is the number of times a SYN cookie was sent. ListenOverflowSynCookieSent *StatCounter // ListenOverflowSynCookieRcvd is the number of times a valid SYN // cookie was received. ListenOverflowSynCookieRcvd *StatCounter // ListenOverflowInvalidSynCookieRcvd is the number of times an invalid SYN cookie // was received. ListenOverflowInvalidSynCookieRcvd *StatCounter // FailedConnectionAttempts is the number of calls to Connect or Listen // (active and passive openings, respectively) that end in an error. FailedConnectionAttempts *StatCounter // ValidSegmentsReceived is the number of TCP segments received that // the transport layer successfully parsed. ValidSegmentsReceived *StatCounter // InvalidSegmentsReceived is the number of TCP segments received that // the transport layer could not parse. InvalidSegmentsReceived *StatCounter // SegmentsSent is the number of TCP segments sent. SegmentsSent *StatCounter // SegmentSendErrors is the number of TCP segments failed to be sent. SegmentSendErrors *StatCounter // ResetsSent is the number of TCP resets sent. ResetsSent *StatCounter // ResetsReceived is the number of TCP resets received. ResetsReceived *StatCounter // Retransmits is the number of TCP segments retransmitted. Retransmits *StatCounter // FastRecovery is the number of times Fast Recovery was used to // recover from packet loss. FastRecovery *StatCounter // SACKRecovery is the number of times SACK Recovery was used to // recover from packet loss. SACKRecovery *StatCounter // SlowStartRetransmits is the number of segments retransmitted in slow // start. SlowStartRetransmits *StatCounter // FastRetransmit is the number of segments retransmitted in fast // recovery. FastRetransmit *StatCounter // Timeouts is the number of times the RTO expired. Timeouts *StatCounter // ChecksumErrors is the number of segments dropped due to bad checksums. ChecksumErrors *StatCounter }
TCPStats collects TCP-specific stats.
type TCPSynRcvdCountThresholdOption ¶
type TCPSynRcvdCountThresholdOption uint64
TCPSynRcvdCountThresholdOption is used by SetSockOpt/GetSockOpt to specify the number of endpoints that can be in SYN-RCVD state before the stack switches to using SYN cookies.
type TCPSynRetriesOption ¶
type TCPSynRetriesOption uint8
TCPSynRetriesOption is used by SetSockOpt/GetSockOpt to specify stack-wide default for number of times SYN is retransmitted before aborting a connect.
type TCPTimeWaitReuseOption ¶
type TCPTimeWaitReuseOption uint8
TCPTimeWaitReuseOption is used stack.(*Stack).TransportProtocolOption to specify if the stack can reuse the port bound by an endpoint in TIME-WAIT for new connections when it is safe from protocol viewpoint.
const ( // TCPTimeWaitReuseDisabled indicates reuse of port bound by endponts in TIME-WAIT cannot // be reused for new connections. TCPTimeWaitReuseDisabled TCPTimeWaitReuseOption = iota // TCPTimeWaitReuseGlobal indicates reuse of port bound by endponts in TIME-WAIT can // be reused for new connections irrespective of the src/dest addresses. TCPTimeWaitReuseGlobal // TCPTimeWaitReuseLoopbackOnly indicates reuse of port bound by endpoint in TIME-WAIT can // only be reused if the connection was a connection over loopback. i.e src/dest adddresses // are loopback addresses. TCPTimeWaitReuseLoopbackOnly )
type TCPTimeWaitTimeoutOption ¶
TCPTimeWaitTimeoutOption is used by SetSockOpt/GetSockOpt to set/get the maximum duration for which a socket lingers in the TIME_WAIT state before being marked closed.
type TCPUserTimeoutOption ¶
TCPUserTimeoutOption is used by SetSockOpt/GetSockOpt to specify a user specified timeout for a given TCP connection. See: RFC5482 for details.
type Timer ¶
type Timer interface { // Stop prevents the Timer from firing. It returns true if the call stops the // timer, false if the timer has already expired or been stopped. // // If Stop returns false, then the timer has already expired and the function // f of Clock.AfterFunc(d, f) has been started in its own goroutine; Stop // does not wait for f to complete before returning. If the caller needs to // know whether f is completed, it must coordinate with f explicitly. Stop() bool // Reset changes the timer to expire after duration d. // // Reset should be invoked only on stopped or expired timers. If the timer is // known to have expired, Reset can be used directly. Otherwise, the caller // must coordinate with the function f of Clock.AfterFunc(d, f). Reset(d time.Duration) }
Timer represents a single event. A Timer must be created with Clock.AfterFunc.
func NewStdTimer ¶
NewStdTimer returns a Timer implemented with the time package.
type TransportEndpointStats ¶
type TransportEndpointStats struct { // PacketsReceived is the number of successful packet receives. PacketsReceived StatCounter // PacketsSent is the number of successful packet sends. PacketsSent StatCounter // ReceiveErrors collects packet receive errors within transport layer. ReceiveErrors ReceiveErrors // ReadErrors collects packet read errors from an endpoint read call. ReadErrors ReadErrors // SendErrors collects packet send errors within the transport layer. SendErrors SendErrors // WriteErrors collects packet write errors from an endpoint write call. WriteErrors WriteErrors }
TransportEndpointStats collects statistics about the endpoint.
func (*TransportEndpointStats) Clone ¶
func (src *TransportEndpointStats) Clone() TransportEndpointStats
Clone returns a copy of the TransportEndpointStats by atomically reading each field.
func (*TransportEndpointStats) IsEndpointStats ¶
func (*TransportEndpointStats) IsEndpointStats()
IsEndpointStats is an empty method to implement the tcpip.EndpointStats marker interface.
type TransportProtocolNumber ¶
type TransportProtocolNumber uint32
TransportProtocolNumber is the number of a transport protocol.
type UDPStats ¶
type UDPStats struct { // PacketsReceived is the number of UDP datagrams received via // HandlePacket. PacketsReceived *StatCounter // UnknownPortErrors is the number of incoming UDP datagrams dropped // because they did not have a known destination port. UnknownPortErrors *StatCounter // ReceiveBufferErrors is the number of incoming UDP datagrams dropped // due to the receiving buffer being in an invalid state. ReceiveBufferErrors *StatCounter // MalformedPacketsReceived is the number of incoming UDP datagrams // dropped due to the UDP header being in a malformed state. MalformedPacketsReceived *StatCounter // PacketsSent is the number of UDP datagrams sent via sendUDP. PacketsSent *StatCounter // PacketSendErrors is the number of datagrams failed to be sent. PacketSendErrors *StatCounter // ChecksumErrors is the number of datagrams dropped due to bad checksums. ChecksumErrors *StatCounter }
UDPStats collects UDP-specific stats.
type WriteErrors ¶
type WriteErrors struct { // WriteClosed is the number of packet drops because the endpoint // was shutdown for write. WriteClosed StatCounter // InvalidEndpointState is the number of times we found the endpoint state // to be unexpected. InvalidEndpointState StatCounter // InvalidArgs is the number of times invalid input arguments were // provided for endpoint Write call. InvalidArgs StatCounter }
WriteErrors collects packet write errors from an endpoint write call.
type WriteOptions ¶
type WriteOptions struct { // If To is not nil, write to the given address instead of the endpoint's // peer. To *FullAddress // More has the same semantics as Linux's MSG_MORE. More bool // EndOfRecord has the same semantics as Linux's MSG_EOR. EndOfRecord bool // Atomic means that all data fetched from Payloader must be written to the // endpoint. If Atomic is false, then data fetched from the Payloader may be // discarded if available endpoint buffer space is unsufficient. Atomic bool }
WriteOptions contains options for Endpoint.Write.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
adapters
|
|
gonet
Package gonet provides a Go net package compatible wrapper for a tcpip stack.
|
Package gonet provides a Go net package compatible wrapper for a tcpip stack. |
Package buffer provides the implementation of a buffer view.
|
Package buffer provides the implementation of a buffer view. |
hash
|
|
jenkins
Package jenkins implements Jenkins's one_at_a_time, non-cryptographic hash functions created by by Bob Jenkins.
|
Package jenkins implements Jenkins's one_at_a_time, non-cryptographic hash functions created by by Bob Jenkins. |
Package header provides the implementation of the encoding and decoding of network protocol headers.
|
Package header provides the implementation of the encoding and decoding of network protocol headers. |
parse
Package parse provides utilities to parse packets.
|
Package parse provides utilities to parse packets. |
link
|
|
channel
Package channel provides the implemention of channel-based data-link layer endpoints.
|
Package channel provides the implemention of channel-based data-link layer endpoints. |
ethernet
Package ethernet provides an implementation of an ethernet link endpoint that wraps an inner link endpoint.
|
Package ethernet provides an implementation of an ethernet link endpoint that wraps an inner link endpoint. |
fdbased
Package fdbased provides the implemention of data-link layer endpoints backed by boundary-preserving file descriptors (e.g., TUN devices, seqpacket/datagram sockets).
|
Package fdbased provides the implemention of data-link layer endpoints backed by boundary-preserving file descriptors (e.g., TUN devices, seqpacket/datagram sockets). |
loopback
Package loopback provides the implemention of loopback data-link layer endpoints.
|
Package loopback provides the implemention of loopback data-link layer endpoints. |
muxed
Package muxed provides a muxed link endpoints.
|
Package muxed provides a muxed link endpoints. |
nested
Package nested provides helpers to implement the pattern of nested stack.LinkEndpoints.
|
Package nested provides helpers to implement the pattern of nested stack.LinkEndpoints. |
packetsocket
Package packetsocket provides a link layer endpoint that provides the ability to loop outbound packets to any AF_PACKET sockets that may be interested in the outgoing packet.
|
Package packetsocket provides a link layer endpoint that provides the ability to loop outbound packets to any AF_PACKET sockets that may be interested in the outgoing packet. |
pipe
Package pipe provides the implementation of pipe-like data-link layer endpoints.
|
Package pipe provides the implementation of pipe-like data-link layer endpoints. |
qdisc/fifo
Package fifo provides the implementation of data-link layer endpoints that wrap another endpoint and queues all outbound packets and asynchronously dispatches them to the lower endpoint.
|
Package fifo provides the implementation of data-link layer endpoints that wrap another endpoint and queues all outbound packets and asynchronously dispatches them to the lower endpoint. |
rawfile
Package rawfile contains utilities for using the netstack with raw host files on Linux hosts.
|
Package rawfile contains utilities for using the netstack with raw host files on Linux hosts. |
sharedmem
Package sharedmem provides the implemention of data-link layer endpoints backed by shared memory.
|
Package sharedmem provides the implemention of data-link layer endpoints backed by shared memory. |
sharedmem/pipe
Package pipe implements a shared memory ring buffer on which a single reader and a single writer can operate (read/write) concurrently.
|
Package pipe implements a shared memory ring buffer on which a single reader and a single writer can operate (read/write) concurrently. |
sharedmem/queue
Package queue provides the implementation of transmit and receive queues based on shared memory ring buffers.
|
Package queue provides the implementation of transmit and receive queues based on shared memory ring buffers. |
sniffer
Package sniffer provides the implementation of data-link layer endpoints that wrap another endpoint and logs inbound and outbound packets.
|
Package sniffer provides the implementation of data-link layer endpoints that wrap another endpoint and logs inbound and outbound packets. |
tun
Package tun contains methods to open TAP and TUN devices.
|
Package tun contains methods to open TAP and TUN devices. |
waitable
Package waitable provides the implementation of data-link layer endpoints that wrap other endpoints, and can wait for inflight calls to WritePacket or DeliverNetworkPacket to finish (and new ones to be prevented).
|
Package waitable provides the implementation of data-link layer endpoints that wrap other endpoints, and can wait for inflight calls to WritePacket or DeliverNetworkPacket to finish (and new ones to be prevented). |
network
|
|
arp
Package arp implements the ARP network protocol.
|
Package arp implements the ARP network protocol. |
fragmentation
Package fragmentation contains the implementation of IP fragmentation.
|
Package fragmentation contains the implementation of IP fragmentation. |
hash
Package hash contains utility functions for hashing.
|
Package hash contains utility functions for hashing. |
ip
Package ip holds IPv4/IPv6 common utilities.
|
Package ip holds IPv4/IPv6 common utilities. |
ipv4
Package ipv4 contains the implementation of the ipv4 network protocol.
|
Package ipv4 contains the implementation of the ipv4 network protocol. |
ipv6
Package ipv6 contains the implementation of the ipv6 network protocol.
|
Package ipv6 contains the implementation of the ipv6 network protocol. |
Package ports provides PortManager that manages allocating, reserving and releasing ports.
|
Package ports provides PortManager that manages allocating, reserving and releasing ports. |
Package seqnum defines the types and methods for TCP sequence numbers such that they fit in 32-bit words and work properly when overflows occur.
|
Package seqnum defines the types and methods for TCP sequence numbers such that they fit in 32-bit words and work properly when overflows occur. |
Package stack provides the glue between networking protocols and the consumers of the networking stack.
|
Package stack provides the glue between networking protocols and the consumers of the networking stack. |
transport
|
|
icmp
Package icmp contains the implementation of the ICMP and IPv6-ICMP transport protocols for use in ping.
|
Package icmp contains the implementation of the ICMP and IPv6-ICMP transport protocols for use in ping. |
packet
Package packet provides the implementation of packet sockets (see packet(7)).
|
Package packet provides the implementation of packet sockets (see packet(7)). |
raw
Package raw provides the implementation of raw sockets (see raw(7)).
|
Package raw provides the implementation of raw sockets (see raw(7)). |
tcp
Package tcp contains the implementation of the TCP transport protocol.
|
Package tcp contains the implementation of the TCP transport protocol. |
tcpconntrack
Package tcpconntrack implements a TCP connection tracking object.
|
Package tcpconntrack implements a TCP connection tracking object. |
udp
Package udp contains the implementation of the UDP transport protocol.
|
Package udp contains the implementation of the UDP transport protocol. |