netutils

package
v4.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const TCPAOMaxKeyLen = 80

TCPAOMaxKeyLen defines maximum TCP-AO key length, matching Linux TCP_AO_MAXKEYLEN: https://github.com/torvalds/linux/blob/v6.7/include/uapi/linux/tcp.h#L369

Variables

View Source
var ErrTCPAONotSupported = errors.New("TCP-AO is not supported on this platform")

ErrTCPAONotSupported is returned when TCP-AO is requested on a platform for which GoBGP does not provide support.

Functions

func AddTCPAOKeysSockopt added in v4.8.0

func AddTCPAOKeysSockopt(sc syscall.RawConn, peer netip.Prefix, interfaceName string, config TCPAOConfig) error

AddTCPAOKeysSockopt installs all provided keys on a TCP socket. A nil PreferredSendID leaves the existing CurrentKey and RNextKey selection unchanged, as required when installing keys on a listening socket. A non-nil value selects the matching key.

func DeleteTCPAOKeysSockopt added in v4.8.0

func DeleteTCPAOKeysSockopt(sc syscall.RawConn, peer netip.Prefix, interfaceName string, config TCPAOConfig) error

DeleteTCPAOKeysSockopt removes all configured keys from a TCP socket.

func DialerControl

func DialerControl(logger *slog.Logger, network, address string, c syscall.RawConn, ttl, minTtl uint8, mss uint16, password string, bindInterface string, tos uint8) error

func SetBindToDevSockopt

func SetBindToDevSockopt(sc syscall.RawConn, device string) error

func SetIPTOSSockopt added in v4.3.0

func SetIPTOSSockopt(conn net.Conn, tos uint8) error

func SetReuseAddrSockopt added in v4.5.0

func SetReuseAddrSockopt(sc syscall.RawConn) error

func SetTCPAOKeySockopt added in v4.8.0

func SetTCPAOKeySockopt(sc syscall.RawConn, config TCPAOConfig, setRNext, setCurrent bool) error

SetTCPAOKeySockopt sets CurrentKey and/or RNextKey to the key selected by PreferredSendID on a connected TCP-AO socket.

func SetTCPMD5SigSockopt

func SetTCPMD5SigSockopt(l *net.TCPListener, bindInterface string, address string, key string) error

func SetTCPMSSSockopt

func SetTCPMSSSockopt(conn net.Conn, mss uint16) error

func SetTCPMinTTLSockopt

func SetTCPMinTTLSockopt(conn net.Conn, ttl int) error

func SetTCPTTLSockopt

func SetTCPTTLSockopt(conn net.Conn, ttl int) error

func SetUDPTTLSockopt added in v4.5.0

func SetUDPTTLSockopt(conn net.Conn, ttl int) error

func ValidateTCPAOKeys added in v4.9.0

func ValidateTCPAOKeys(keys []TCPAOKey) error

ValidateTCPAOKeys checks a complete set of keys that is about to be installed on a socket. Callers that build a key set from user input should use it so that the same rules apply everywhere.

Types

type TCPAOAlgorithm added in v4.8.0

type TCPAOAlgorithm uint8

TCPAOAlgorithm identifies a TCP-AO algorithm profile.

const (
	TCPAOAlgorithmUnspecified TCPAOAlgorithm = iota
	TCPAOAlgorithmHMACSHA1
	TCPAOAlgorithmAES128CMAC
	TCPAOAlgorithmHMACSHA256MAC96
	TCPAOAlgorithmHMACSHA256MAC128
)

type TCPAOConfig added in v4.8.0

type TCPAOConfig struct {
	Keys            []TCPAOKey
	PreferredSendID *uint8
}

TCPAOConfig contains all keys used by a TCP-AO socket operation. PreferredSendID optionally selects a key from Keys.

type TCPAOKey added in v4.8.0

type TCPAOKey struct {
	SendID            uint8
	ReceiveID         uint8
	Algorithm         TCPAOAlgorithm
	MasterKey         []byte
	ExcludeTCPOptions bool
}

TCPAOKey contains socket-level properties of one TCP-AO key.

type TCPAOKeyState added in v4.8.0

type TCPAOKeyState struct {
	Peer           netip.Prefix
	InterfaceIndex int32
	SendID         uint8
	ReceiveID      uint8
	Current        bool
	ReceiveNext    bool
	PacketsGood    uint64
	PacketsBad     uint64
}

TCPAOKeyState contains the operational state for one TCP-AO key installed on a socket.

func GetTCPAOKeyStateSockopt added in v4.8.0

func GetTCPAOKeyStateSockopt(sc syscall.RawConn) ([]TCPAOKeyState, error)

GetTCPAOKeyStateSockopt returns the keys installed on a TCP-AO socket and their kernel-maintained operational state.

type TCPAOSocketCounters added in v4.8.0

type TCPAOSocketCounters struct {
	PacketsKeyNotFound uint64
	PacketsAORequired  uint64
	PacketsDroppedICMP uint64
}

TCPAOSocketCounters contains operational counters maintained for a TCP-AO socket.

func GetTCPAOSocketCountersSockopt added in v4.8.0

func GetTCPAOSocketCountersSockopt(sc syscall.RawConn) (TCPAOSocketCounters, error)

GetTCPAOSocketCountersSockopt returns the operational counters maintained for a TCP-AO socket.

type TCPConn

type TCPConn struct {
	*net.TCPConn
	// contains filtered or unexported fields
}

func (*TCPConn) Close

func (c *TCPConn) Close() error

func (*TCPConn) Key

func (c *TCPConn) Key() string

type TCPListener

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

func NewTCPListener

func NewTCPListener(logger *slog.Logger, address string, port uint32, bindToDev string, connChan chan net.Conn) (*TCPListener, error)

avoid mapped IPv6 address

func (*TCPListener) Addr

func (l *TCPListener) Addr() net.Addr

func (*TCPListener) Close

func (l *TCPListener) Close()

func (*TCPListener) Listener

func (l *TCPListener) Listener() *net.TCPListener

Jump to

Keyboard shortcuts

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