lldp

Module for LLDP (Link Layer Discovery Protocol).

This module is in BETA. APIs that we expose here are subject to change in future minor and patch releases. Feedback is greatly appreciated.

LLDP is a link layer protocol that sends “TLVs” across the link, allowing devices to advertise their identities and properties over a network. The protocol is uni-directional (no acks).

This module provides access to information learned from neighbors directly connected via Ethernet interfaces. It can also provide proprietary information to those neighbors via “Organizationally defined TLVs”. The mandatory info exchanged over the link are the interface’s name, the chassis ID, the system name and the management port address (over which more information can be gleaned via protocols such as SNMP). The protocol has to be enabled per interface and per direction. On EOS, LLDP is disabled by default, but once enabled (cli: “lldp run”), all interfaces are enabled bi-directionally by default.

The type of an LLDP TLV is composed of a 24 bit organization (vendor/manufacturer) number assigned by IEEE (also called OUI: organizationally unique identifier), and a subtype which is managed by that organization. That’s the lldp_tlv_type_t. When you add the payload (of 0-507 octets) you get a TLV.

When enabled, EOS transmits these TLVS on an interface (if they apply)

  • Chassis ID & Port ID (mandatory)
  • Port Description
  • System Name
  • System Description
  • System Capabilities (bridge and router)
  • Management Address
  • Port Vlan ID (802.1; vlan ID of untagged frames: default/native vlan)
  • Maximum Frame Size (802.3)
  • Link Aggregation (802.3)
  • MAC/Phy config/status info (802.3; speed auto-negotiation)

namespace eos
class lldp_handler
#include <lldp.h>

Handler class to notify of changes in LLDP. In the handler context, “tlv” means received tlv.

Public Functions

lldp_handler(lldp_mgr *)
lldp_mgr * get_lldp_mgr() const

Returns the associated lldp_mgr.

virtual void on_lldp_intf_set(lldp_neighbor_t const & peer)

Called when a neighbor starts sending LLDP information. intf refers to the local interface that this information was received on.

virtual void on_lldp_intf_del(lldp_neighbor_t const & peer)

Called when a neighbor’s LLDP information ages out (or is disconnected).

virtual void on_lldp_intf_change(lldp_neighbor_t const & peer)

Called when the remote information has changed and all has been updated; this can be used as an alternative to reacting to each single callback provided below.

virtual void on_lldp_chassis_id(lldp_neighbor_t const & peer, lldp_chassis_id_t name)

Called when the remote’s “chassis ID” changed (mandatory TLV).

virtual void on_lldp_intf_id(lldp_neighbor_t const & peer, lldp_intf_id_t name)

Called when the remote’s “interface ID” changed (mandatory TLV).

virtual void on_lldp_system_name(lldp_neighbor_t const & peer, std::string const & name)

Called when the remote’s “system name” changed.

virtual void on_lldp_system_description(lldp_neighbor_t const & peer, std::string const & desc)

Called when the remote’s “system description” changed.

virtual void on_lldp_intf_description(lldp_neighbor_t const & peer, std::string const & descr)

Called when the remote’s “interface description” changed.

virtual void on_lldp_default_vlan(lldp_neighbor_t const & peer, vlan_id_t vlan)

Called when the remote’s “default vlan” changed.

virtual void on_lldp_management_vlan(lldp_neighbor_t const & peer, vlan_id_t vlan)

Called when the remote’s “management vlan” changed.

virtual void on_lldp_max_frame_size(lldp_neighbor_t const & peer, uint32_t size)

Called when the remote’s “maximum transmission unit” changed.

virtual void on_lldp_management_address(lldp_neighbor_t const & peer, std::list< lldp_management_address_t > const & info)

Called when the remote’s “management address” changed.

virtual void on_lldp_lacp(lldp_neighbor_t const & peer, lldp_lacp_t const & info)

Called when the remote’s “link aggregation config/status” changed.

virtual void on_lldp_phy(lldp_neighbor_t const & peer, lldp_phy_t const & info)

Called when the remote’s “phy negotiation config/status” changed.

virtual void on_lldp_tlv_set(lldp_neighbor_t const & peer, lldp_tlv_type_t type, std::string const & data)

Called when a new TLV type is received, or its content has changed.

virtual void on_lldp_tlv_del(lldp_neighbor_t const & peer, lldp_tlv_type_t type)

Called when a TLV type previously received is now absent from advertisements.

virtual void on_lldp_tx_timer(uint32_t seconds)

Called when a transmission timer value change became effective.

virtual void on_lldp_hold_time(uint32_t seconds)

Called when a hold timer value change became effective.

virtual void on_lldp_intf_enabled(intf_id_t intf, lldp_intf_enabled_t status)

Called when an LLDP interface status change became effective.

class lldp_intf_iter_t
#include <lldp.h>

An iterator that yields a intf_id_t for each interface with lldp config.

Private Functions

lldp_intf_iter_t(lldp_intf_iter_impl * const)

Friends

friend class lldp_intf_iter_impl
class lldp_remote_system_iter_t
#include <lldp.h>

An iterator that yields a lldp_remote_system_t for each neighbor on an interface.

Private Functions

lldp_remote_system_iter_t(lldp_remote_system_iter_impl * const)

Friends

friend class lldp_remote_system_iter_impl
class lldp_neighbor_iter_t
#include <lldp.h>

An iterator that yields a lldp_neighbor_t for each neighbor (remote system) A combination of the lldp-remote-system and lldp-intf iterators.

Private Functions

lldp_neighbor_iter_t(lldp_neighbor_iter_impl * const)

Friends

friend class lldp_neighbor_iter_impl
class lldp_mgr
#include <lldp.h>

A manager for LLDP information.

Create one of these via sdk.get_lldp_mgr() prior to starting the agent main loop. When your eos::agent_handler::on_initialized virtual function is called, the manager is valid for use. In manager context, “tlv” means received tlv. What is sent it called tx_tlv.

Public Functions

virtual ~lldp_mgr()
virtual lldp_intf_iter_t lldp_intf_iter() const = 0
virtual lldp_remote_system_iter_t lldp_remote_system_iter(intf_id_t) const = 0
virtual lldp_neighbor_iter_t lldp_neighbor_iter() const = 0
virtual lldp_neighbor_iter_t lldp_neighbor_iter(intf_id_t local_intf) const = 0
virtual void enabled_is(bool) = 0
virtual bool enabled() const = 0
virtual void intf_enabled_is(intf_id_t intf, lldp_intf_enabled_t enable) = 0

Enable LLDP on an interface on by default. LLDP is unidirectional, so enablement can be split by direction.

virtual lldp_intf_enabled_t intf_enabled(intf_id_t intf) const = 0
virtual void tx_timer_is(uint32_t seconds) = 0

The LLDP transmit timer specifies how often TLVs are sent (aka “refreshed”), in seconds, default 30s, range 5-32768

virtual int tx_timer() const = 0
virtual int hold_time() const = 0

The LLDP holding time determines how long the recipient of our TLVs should keep them un-refreshed, in seconds, default 120s, range 10-65535. This is sent to the neighbor as the “ttl” value (this holding time limit is imposed on our neighbor, has no effect locally).

virtual void hold_time_is(uint32_t seconds) = 0
virtual lldp_chassis_id_t chassis_id(lldp_neighbor_t const & peer) const = 0

Get the chassisID of the remote interface (< 255 octets)

virtual lldp_intf_id_t intf_id(lldp_neighbor_t const & peer) const = 0

Get the port ID of the remote interface (< 255 octets)

virtual std::string intf_description(lldp_neighbor_t const & peer) const = 0

interface description: max string size 255, empty if not rx-ed

virtual std::string system_name(lldp_neighbor_t const & peer) const = 0

sysname: max string size 255, empty if not rx-ed

virtual std::string system_description(lldp_neighbor_t const & peer) const = 0

sysdescr: max string size 255, empty if not rx-ed

virtual lldp_syscap_t system_capabilities(lldp_neighbor_t const & peer) const = 0

system capabilities bitmap, ‘other’ if not rx-ed

virtual vlan_id_t default_vlan(lldp_neighbor_t const & peer) const = 0

The default vlan ID (vlan-id for untagged packets); 0 if none or not rx-ed.

virtual vlan_id_t management_vlan(lldp_neighbor_t const & peer) const = 0

The vlan-id on which the managment interface is available; 0 if none.

virtual uint32_t max_frame_size(lldp_neighbor_t const & peer) const = 0

The max frame size on the link; 0 if not rx-ed.

virtual lldp_lacp_t lacp(lldp_neighbor_t const & peer) const = 0

Port-channel this interface is member of (and capability/status) !value returns false if this tlv was not received.

virtual std::list< lldp_management_address_t > management_address(lldp_neighbor_t const & peer) const = 0

management info (address, snmp-ifindex, sysDescr-oid) !value returns false if this tlv was not received. The type of address (and its encoding) is described using IANA’s AddressFamilyNumbers, which is available here: http://www.iana.org/assignments/ianaaddressfamilynumbers-mib/ ianaaddressfamilynumbers-mib. In EOS’s case, the address family is an IPV4 address.

virtual lldp_phy_t phy(lldp_neighbor_t const & peer) const = 0

The mac phy config status info (auto-negotiation) !value returns false if this tlv was not received.

virtual void tx_tlv_set(lldp_neighbor_t const & peer, lldp_tlv_type_t type, std::string const & data) = 0

Send a/multiple application defined TLV on a interface. Transmission will occur every tx_timer until revoked.

virtual void tx_tlv_del(lldp_neighbor_t const & peer, lldp_tlv_type_t type) = 0
virtual std::string tlv(lldp_neighbor_t const & peer, lldp_tlv_type_t type) const = 0
virtual bool tlv_exists(lldp_neighbor_t const & peer, lldp_tlv_type_t type) const = 0
virtual std::map< lldp_tlv_type_t, std::string > tlvs(lldp_neighbor_t const & peer) const = 0

Get en-block (there is no iterator, cannot be many given mtu limit this includes all “organizationnally defined TLVs” (owned by this app or not)

Protected Functions

lldp_mgr()

Private Members

lldp_mgr

Friends

friend class lldp_handler

Type definitions in lldp

namespace eos

Enums

lldp_std_tlv_type_bit_t enum

Set of standard TLVs (as a bitmask).

Values:

  • LLDP_TLV_NONE -
  • LLDP_TLV_CHASSIS_ID = = 1 -
  • LLDP_TLV_INTF_ID = = 2 -
  • LLDP_TLV_INTF_DESCR = = 4 -
  • LLDP_TLV_SYSTEM_CAP = = 8 -
  • LLDP_TLV_MANAGEMENT = = 16 -
  • LLDP_TLV_VLAN = = 32 -
  • LLDP_TLV_MANAGMENT_VLAN = = 64 -
  • LLDP_TLV_MAX_FRAME_SIZE = = 128 -
  • LLDP_TLV_LACP = = 256 -
  • LLDP_TLV_PHY = = 512 -
lldp_syscap_bits_t enum

Set of system capabilities.

Values:

  • LLDP_SYSCAP_OTHER -
  • LLDP_SYSCAP_REPEATER = = 1 -
  • LLDP_SYSCAP_BRIDGE = = 2 -
  • LLDP_SYSCAP_VLAN_AP = = 4 -
  • LLDP_SYSCAP_ROUTER = = 8 -
  • LLDP_SYSCAP_TELEPONE = = 16 -
  • LLDP_SYSCAP_DOCSIS = = 32 -
  • LLDP_SYSCAP_STATION = = 64 -
lldp_intf_enabled_t enum

The lldp administrative status of an interface.

Values:

  • LLDP_INTF_STATUS_NULL -
  • LLDP_INTF_ENABLE_TX = = 1 -
  • LLDP_INTF_ENABLE_RX = = 2 -
  • LLDP_INTF_ENABLE_BIDIR = = 3 -
  • LLDP_INTF_DISABLE = = 4 -
lldp_chassis_id_encoding_t enum

encoding format of the chassis name.

Values:

  • LLDP_CHASSIS_RESERVED -
  • LLDP_CHASSIS_COMPONENT = = 1 -
  • LLDP_CHASSIS_INTF_ALIAS = = 2 -
  • LLDP_CHASSIS_PORT_COMPONENT = = 3 -
  • LLDP_CHASSIS_MAC_ADDR = = 4 -
  • LLDP_CHASSIS_NET_ADDR = = 5 -
  • LLDP_CHASSIS_INTF_NAME = = 6 -
  • LLDP_CHASSIS_LOCAL = = 7 -
  • LLDP_CHASSIS_NULL = = 255 -
lldp_intf_id_encoding_t enum

encoding format of the chassis name.

Values:

  • LLDP_INTF_RESERVED -
  • LLDP_INTF_ALIAS = = 1 -
  • LLDP_INTF_COMPONENT = = 2 -
  • LLDP_INTF_MAC_ADDR = = 3 -
  • LLDP_INTF_NET_ADDR = = 4 -
  • LLDP_INTF_NAME = = 5 -
  • LLDP_INTF_CIRCUIT = = 6 -
  • LLDP_INTF_LOCAL = = 7 -
  • LLDP_INTF_NULL = = 255 -
class lldp_tlv_type_t
#include <lldp.h>

An LLDP organizationally defined TLV type.

Public Functions

lldp_tlv_type_t()
lldp_tlv_type_t(uint32_t organization, uint8_t subtype)
uint32_t organization() const

Getter for ‘organization’: IEEE assigned Organizationally Unique Identifier (OUI), 24 bits.

void organization_is(uint32_t organization)

Setter for ‘organization’.

uint8_t subtype() const

Getter for ‘subtype’: Subtype under OUI (managed by org.), 8 bits.

void subtype_is(uint8_t subtype)

Setter for ‘subtype’.

bool operator==(lldp_tlv_type_t const & other) const
bool operator!=(lldp_tlv_type_t const & other) const
bool operator<(lldp_tlv_type_t const & other) const
uint32_t hash() const

The hash function for type lldp_tlv_type_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

uint32_t organization_
uint8_t subtype_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_tlv_type_t to the ostream.

class lldp_std_tlv_type_t
#include <lldp.h>

Defines a set of remote TLVs (for which we have a value for).

Public Functions

lldp_std_tlv_type_t()
void chassis_id_is(bool enabled)
void intf_id_is(bool enabled)
void intf_description_is(bool enabled)
void system_capabilities_is(bool enabled)
void management_address_is(bool enabled)
void default_vlan_is(bool enabled)
void management_vlan_is(bool enabled)
void max_frame_size_is(bool enabled)
void lacp_is(bool enabled)
void phy_is(bool enabled)
bool chassis_id() const
bool intf_id() const
bool intf_description() const
bool system_capabilities() const
bool management_address() const
bool default_vlan() const
bool management_vlan() const
bool max_frame_size() const
bool lacp() const
bool phy() const
uint32_t hash() const

The hash function for type lldp_std_tlv_type_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

lldp_std_tlv_type_bit_t bitset_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_std_tlv_type_t to the ostream.

class lldp_syscap_t
#include <lldp.h>

Defines a set of remote system capabilities.

Public Functions

lldp_syscap_t()
lldp_syscap_t(lldp_syscap_bits_t bitset)
bool other() const
bool repeater() const
bool bridge() const
bool vlan_ap() const
bool router() const
bool telephone() const
bool docsis() const
bool station() const
uint32_t hash() const

The hash function for type lldp_syscap_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

lldp_syscap_bits_t bitset_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_syscap_t to the ostream.

class lldp_management_address_t
#include <lldp.h>

Management information of the switch across the link.

Public Functions

lldp_management_address_t()
lldp_management_address_t(uint32_t address_family, std::string address, uint32_t snmp_ifindex, std::string oid)
uint32_t address_family() const

Getter for ‘address_family’: Type of address encoded in address field (see IANA Address Family Numbers MIB).

std::string address() const

Getter for ‘address’: The address, max size 31 octets (ipv4 or ipv6 most likely).

uint32_t snmp_ifindex() const

Getter for ‘snmp_ifindex’: The SNMP interface index of the management interface.

std::string oid() const

Getter for ‘oid’: The SNMP OID that describes the hardware the management interface is part of.

uint32_t hash() const

The hash function for type lldp_management_address_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

uint32_t address_family_
std::string address_
uint32_t snmp_ifindex_
std::string oid_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_management_address_t to the ostream.

class lldp_lacp_t
#include <lldp.h>

LACP information from the peer.

Public Functions

lldp_lacp_t()
lldp_lacp_t(bool capable, bool enabled, uint32_t id, bool valid)
bool capable() const

Getter for ‘capable’: if port can become a member of a port-channel.

bool enabled() const

Getter for ‘enabled’: if port is a member of a port-channel.

uint32_t id() const

Getter for ‘id’: which port-channel number this interface is part of, (if enabled=true).

bool valid() const

Getter for ‘valid’: true if such tlv was received, else other fields are bogus.

bool operator!() const

invalid lacp_t returned if no such tlv received.

uint32_t hash() const

The hash function for type lldp_lacp_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

bool capable_
bool enabled_
uint32_t id_
bool valid_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_lacp_t to the ostream.

class lldp_phy_t
#include <lldp.h>

PHY information from the peer (related to speed auto-negotiation).

Public Functions

lldp_phy_t()
lldp_phy_t(bool autonegSupported, bool autonegEnabled, uint16_t autonegCapabilitiesBm, bool valid)
bool autonegSupported() const

Getter for ‘autonegSupported’: if auto-negotiation supported.

bool autonegEnabled() const

Getter for ‘autonegEnabled’: if auto-negatiation enabled.

uint16_t autonegCapabilitiesBm() const

Getter for ‘autonegCapabilitiesBm’: capabilities bitmask.

bool valid() const

Getter for ‘valid’: if phy-info tlv received from remote.

uint32_t hash() const

The hash function for type lldp_phy_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

bool autonegSupported_
bool autonegEnabled_
uint16_t autonegCapabilitiesBm_
bool valid_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_phy_t to the ostream.

class lldp_chassis_id_t
#include <lldp.h>

The chassis name, as an encoding plus payload.

Public Functions

lldp_chassis_id_t()
lldp_chassis_id_t(lldp_chassis_id_encoding_t encoding, std::string value)
lldp_chassis_id_encoding_t encoding() const
std::string value() const
std::string repr() const

String representation of a chassisId.

bool operator==(lldp_chassis_id_t const & other) const
bool operator!=(lldp_chassis_id_t const & other) const
bool operator<(lldp_chassis_id_t const & other) const
uint32_t hash() const

The hash function for type lldp_chassis_id_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

lldp_chassis_id_encoding_t encoding_
std::string value_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_chassis_id_t to the ostream.

class lldp_intf_id_t
#include <lldp.h>

The interface name, as an encoding plus payload.

Public Functions

lldp_intf_id_t()
lldp_intf_id_t(lldp_intf_id_encoding_t encoding, std::string value)
lldp_intf_id_encoding_t encoding() const
std::string value() const
std::string repr() const

String representation of a chassisId.

bool operator==(lldp_intf_id_t const & other) const
bool operator!=(lldp_intf_id_t const & other) const
bool operator<(lldp_intf_id_t const & other) const
uint32_t hash() const

The hash function for type lldp_intf_id_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

lldp_intf_id_encoding_t encoding_
std::string value_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_intf_id_t to the ostream.

class lldp_remote_system_t
#include <lldp.h>

Identifies a remote system as seen across an LLDP interface.

Public Functions

lldp_remote_system_t()
lldp_remote_system_t(lldp_chassis_id_t chassis, lldp_intf_id_t port)
lldp_chassis_id_t chassis() const

Getter for ‘chassis’: The chassis-id of the remote system.

void chassis_is(lldp_chassis_id_t chassis)

Setter for ‘chassis’.

lldp_intf_id_t port() const

Getter for ‘port’: The port-id of the remote system.

void port_is(lldp_intf_id_t port)

Setter for ‘port’.

std::string repr() const

String representation of a chassisId.

bool operator==(lldp_remote_system_t const & other) const
bool operator!=(lldp_remote_system_t const & other) const
bool operator<(lldp_remote_system_t const & other) const
uint32_t hash() const

The hash function for type lldp_remote_system_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

lldp_chassis_id_t chassis_
lldp_intf_id_t port_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_remote_system_t to the ostream.

class lldp_neighbor_t
#include <lldp.h>

Identifies a remote system seen from the local switch.

Public Functions

lldp_neighbor_t()
lldp_neighbor_t(intf_id_t intf)
lldp_neighbor_t(intf_id_t intf, lldp_remote_system_t remote_system)
intf_id_t intf() const

Getter for ‘intf’: The local interface that sees this neighbor.

void intf_is(intf_id_t intf)

Setter for ‘intf’.

lldp_remote_system_t remote_system() const

Getter for ‘remote_system’: The id of the remote system (an interface can see more than one).

void remote_system_is(lldp_remote_system_t remote_system)

Setter for ‘remote_system’.

std::string repr() const

String representation of a chassisId.

bool operator==(lldp_neighbor_t const & other) const
bool operator!=(lldp_neighbor_t const & other) const
bool operator<(lldp_neighbor_t const & other) const
uint32_t hash() const

The hash function for type lldp_neighbor_t.

std::string to_string() const

Returns a string representation of the current object’s values.

Private Members

intf_id_t intf_
lldp_remote_system_t remote_system_

Friends

friend std::ostream & operator<<

A utility stream operator that adds a string representation of lldp_neighbor_t to the ostream.

Table Of Contents

Previous topic

iterator

Next topic

mac_table