Documentation
¶
Index ¶
Constants ¶
const ( // IPLayerOffsetEthernet denotes the ethernet header offset IPLayerOffsetEthernet = 14 // IPLayerOffsetLinuxSLL2 denotes the Linux SLL2 header offset IPLayerOffsetLinuxSLL2 = 20 // LayerOffsetPPPOE denotes the additional offset for PPPOE (session) packets LayerOffsetPPPOE = 8 )
Variables ¶
var ( // ErrNotExist denotes that the interface in question does not exist ErrNotExist = errors.New("interface does not exist") // ErrNotUp denotes that the interface in question is not up ErrNotUp = errors.New("interface is currently not up") )
var EmptyEthernetLink = Link{ Type: TypeEthernet, }
EmptyEthernetLink provides a quick access to a plain / empty ethernet-type link
var ( // ErrIndexOutOfBounds denotes the (unlikely) case of an invalid index being outside the range of an int ErrIndexOutOfBounds = errors.New("interface index out of bounds") )
Functions ¶
This section is empty.
Types ¶
type Link ¶
Link is the low-level representation of a network interface
func New ¶
New instantiates a new link / interface It will return an error if the interface does not exist or is not up
func (*Link) IPs ¶
IPs retrieves all IPv4 and IPv6 addresses assigned to the interface using a minimal netlink RTM_GETADDR dump to avoid the higher-level net package. Mostly extracted from the net package internals (net.Interface.Addrs()).
type Links ¶
type Links []*Link
Links is a slice of Link pointers
type Type ¶
type Type int
Type denotes the linux interface type
const ( // TypeInvalid denotes an invalid link type TypeInvalid Type = iota // TypeEthernet denotes a link of type ARPHRD_ETHER TypeEthernet Type = 1 // TypeLoopback denotes a link of type ARPHRD_LOOPBACK TypeLoopback Type = 772 // TypePPP denotes a link of type ARPHRD_PPP TypePPP Type = 512 // TypeIP6IP6 denotes a link of type ARPHRD_TUNNEL6 TypeIP6IP6 Type = 769 // TypeGRE denotes a link of type ARPHRD_IPGRE TypeGRE Type = 778 // TypeGRE6 denotes a link of type ARPHRD_IP6GRE TypeGRE6 Type = 823 // TypeLinuxSLL2 denotes a link of type LINUX_SLL2 TypeLinuxSLL2 Type = 276 // TypeNone denotes a link of type ARPHRD_NONE: // Tunnel / anything else (confirmed: Wireguard, OpenVPN) TypeNone Type = 65534 )
func (Type) IPHeaderOffset ¶
IPHeaderOffset returns the link / interface specific payload offset for the IP header c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/if_arp.h