lldp

package
v0.0.0-...-b25b90c Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package lldp captures and emits IEEE 802.1AB Link Layer Discovery Protocol frames. RX gives cloud-boot-init visibility into the upstream switch (chassis, port, system name) so plans can make rack/port-aware decisions. TX advertises the booting host to the network for inventory purposes.

All wire-level I/O lives in the Linux build (AF_PACKET); other platforms get a no-op stub so the package can still be imported from host tools.

Index

Constants

View Source
const EtherType uint16 = 0x88CC

EtherType is the IEEE-assigned LLDP EtherType.

Variables

This section is empty.

Functions

func Send

func Send(ifaceName, systemName, systemDesc string) error

Send emits a single LLDP frame from ifaceName announcing this host. The kernel prepends the Ethernet header from sockaddr_ll so the caller need only construct the LLDPDU TLV stream.

Types

type Facts

type Facts struct {
	ChassisType  uint8  // LLDP "chassis ID subtype"
	ChassisID    string // human form of the chassis ID (MAC if subtype 4)
	PortType     uint8  // LLDP "port ID subtype"
	PortID       string // human form of the port ID (iface name if subtype 5)
	TTL          uint16 // advertised TTL seconds
	SystemName   string // sysName MIB
	SystemDesc   string // sysDescr MIB
	PortDesc     string // ifDescr MIB
	Capabilities uint16 // see 802.1AB §8.5.8
	MgmtAddr     string // first management address (v4 or v6)
}

Facts is the decoded subset of a single LLDPDU we care about.

func Listen

func Listen(ifaceName string, timeout time.Duration) (*Facts, error)

Listen opens an AF_PACKET socket on ifaceName, blocks for up to timeout waiting for a single LLDP frame, then returns the decoded Facts.

SOCK_DGRAM strips the Ethernet header on RX so the caller gets just the LLDPDU TLV stream.

Jump to

Keyboard shortcuts

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