common

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: GPL-2.0 Imports: 4 Imported by: 7

README

Common Utilities for IPREF

This package contains common utilities between the various IPREF Go packages (gw, dns-agent, etc.).

Documentation

Index

Constants

View Source
const (
	V1_SIG      = 0x11 // v1 signature
	V1_HDR_LEN  = 8
	V1_MARK_LEN = 4 + 4 // oid + mark
	// v1 header offsets
	V1_VER      = 0 // must be 0x11
	V1_CMD      = 1
	V1_PKTID    = 2
	V1_IPVER    = 4 // high nibble is the ea IP ver, low nibble is gw IP ver
	V1_RESERVED = 5
	V1_PKTLEN   = 6
	// v1 mark offsets
	V1_OID  = 0
	V1_MARK = 4
	// v1 host data offsets
	V1_HOST_DATA_BATCHID = 0
	V1_HOST_DATA_COUNT   = 0
	V1_HOST_DATA_HASH    = 4
	V1_HOST_DATA_SOURCE  = 12
	// v1 save dnssource offsets
	V1_DNSSOURCE_MARK   = 4
	V1_DNSSOURCE_XMARK  = 4
	V1_DNSSOURCE_HASH   = 8
	V1_DNSSOURCE_SOURCE = 16
)
View Source
const (
	V1_NOOP           = 0
	V1_SET_AREC       = 1
	V1_SET_MARK       = 2
	V1_GET_REF        = 4
	V1_GET_EA         = 6
	V1_MC_GET_EA      = 7
	V1_SAVE_OID       = 8
	V1_SAVE_TIME_BASE = 9
	V1_RECOVER_EA     = 10
	V1_RECOVER_REF    = 11

	V1_MC_HOST_DATA      = 14
	V1_MC_HOST_DATA_HASH = 15
	V1_SAVE_DNSSOURCE    = 16
)
View Source
const (
	V1_DATA = 0x00
	V1_REQ  = 0x40
	V1_ACK  = 0x80
	V1_NACK = 0xC0
)
View Source
const (

	//V1_TYPE_NONE   = 0
	//V1_TYPE_AREC   = 1
	//V1_TYPE_IPV4   = 3
	V1_TYPE_STRING = 4
)

Variables

This section is empty.

Functions

func AddrRecEncodedLen added in v1.1.0

func AddrRecEncodedLen(ea_iplen, gw_iplen int) int

func AddrRecSlices added in v1.1.0

func AddrRecSlices(ea_iplen, gw_iplen int, arec []byte) (ea, ip, gw, refh, refl []byte)

Types

type AddrRec added in v1.1.0

type AddrRec struct {
	EA  IP
	IP  IP
	GW  IP
	Ref rff.Ref
}

func AddrRecDecode added in v1.1.0

func AddrRecDecode(ea_iplen, gw_iplen int, arecb []byte) (arec AddrRec)

func (AddrRec) Encode added in v1.1.0

func (arec AddrRec) Encode(arecb []byte)

func (AddrRec) EncodedLen added in v1.1.0

func (arec AddrRec) EncodedLen() int

type IP

type IP netip.Addr // IPv4 or IPv6 address; Zone() must be ""

func IPBits

func IPBits(l, n int) IP

func IPFromSlice

func IPFromSlice(ip []byte) IP

The slice must be 4 or 16 bytes

func IPFromUint32

func IPFromUint32(ip uint32) IP

func IPNum

func IPNum(l int, n uint32) IP

func MustParseIP

func MustParseIP(s string) IP

func ParseIP

func ParseIP(s string) (IP, error)

func (IP) Add

func (a IP) Add(b IP) IP

func (IP) And

func (a IP) And(b IP) IP

func (IP) AsSlice

func (ip IP) AsSlice() []byte

func (IP) AsSlice4

func (ip IP) AsSlice4() []byte

func (IP) AsSlice6

func (ip IP) AsSlice6() []byte

func (IP) AsUint32

func (ip IP) AsUint32() uint32

func (IP) ByteFromEnd

func (ip IP) ByteFromEnd(i int) byte

func (IP) Is4

func (ip IP) Is4() bool

func (IP) Is6

func (ip IP) Is6() bool

func (IP) IsLinkLocal

func (ip IP) IsLinkLocal() bool

func (IP) IsZero

func (ip IP) IsZero() bool

Tests if the IP is equal to the zero-initialized value. This is distinct from the zero IP address (eg. 0.0.0.0 or ::).

func (IP) IsZeroAddr

func (ip IP) IsZeroAddr() bool

func (IP) Len

func (ip IP) Len() int

func (IP) Not

func (a IP) Not() IP

func (IP) Or

func (a IP) Or(b IP) IP

func (IP) String

func (ip IP) String() string

func (IP) Ver

func (ip IP) Ver() int

func (IP) XOr

func (a IP) XOr(b IP) IP

type IpRef added in v1.1.0

type IpRef struct {
	IP  IP
	Ref rff.Ref
}

func (IpRef) String added in v1.1.0

func (ipref IpRef) String() string

Jump to

Keyboard shortcuts

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