socket_oob

package module
v0.0.0-...-bc3885d Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 7 Imported by: 1

README

Socket OOB Control Message Utils for Go

Experimental

Planned features

  • append, read, modify, remove
    • generic socket OOB control messages
    • ECN flags
    • GSO size
    • IPv6 destination options

Supported Systems

Currently only Linux is supported.

References

Documentation

Index

Constants

View Source
const (
	DestOptTypePad0 byte = 0
	DestOptTypePadN      = 1
)
View Source
const DstOptsHdrLen = 2
View Source
const MaxGSOBufSize = math.MaxUint16 - 8

Variables

View Source
var CmsgHdrSpace int

Functions

func DstOptsLen

func DstOptsLen(datalen int) int

func EnableGRO

func EnableGRO(conn *net.UDPConn) error

func IsGROEnabled

func IsGROEnabled(conn *net.UDPConn) bool

IsGROEnabled tests if GSO is enabled on this socket. Sending with GRO might still fail later on, if the interface doesn't support it.

func IsGROSupported

func IsGROSupported(conn *net.UDPConn) bool

IsGROSupported tests if the kernel supports GRO. Sending with GRO might still fail later on, if the interface doesn't support it.

func IsGSOSupported

func IsGSOSupported(conn *net.UDPConn) bool

IsGSOSupported tests if the kernel supports GSO. Sending with GSO might still fail later on, if the interface doesn't support it.

func WriteGSO

func WriteGSO(conn *net.UDPConn, b []byte, size uint16, addr netip.AddrPort, oob []byte) (n int, oobn int, err error)

WriteGSO uses generic segmentation offload

Types

type Cmsg

type Cmsg struct {
	Hdr  *unix.Cmsghdr
	Data []byte
}

type DstOptsHdr

type DstOptsHdr struct {
	NextHeader            uint8
	HeaderExtensionLength uint8
}

type ECN

type ECN uint8
const (
	ECNUnsupported ECN = iota
	ECNNon             // 00
	ECT1               // 01
	ECT0               // 10
	ECNCE              // 11
)

func (ECN) ToHeaderBits

func (e ECN) ToHeaderBits() byte

type Iterator

type Iterator[T any] interface {
	HasNext() bool
	Next() T
}

type Segments

type Segments struct {
	Buf            []byte
	MaxSegmentSize int
}

Segments represents a series of network packets in one byte array. all segments have MaxSegmentSize except the last one might be smaller.

func ReadGRO

func ReadGRO(conn *net.UDPConn, b []byte, oob []byte) (Segments, []byte, int, netip.AddrPort, error)

ReadGRO uses generic receive offload

func (*Segments) First

func (s *Segments) First() []byte

func (*Segments) Iterator

func (s *Segments) Iterator() Iterator[[]byte]

func (*Segments) Len

func (s *Segments) Len() int

func (*Segments) Split

func (s *Segments) Split(left func(segment []byte) bool) (Segments, Segments)

Jump to

Keyboard shortcuts

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