Data Structures | Macros | Functions | Variables
lldp.h File Reference

Link Layer Discovery Protocol. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  lldp_tlv
 An LLDP TLV header. More...


#define LLDP_TLV_TYPE(type_len)   ( (type_len) >> 9 )
 Extract LLDP TLV type. More...
#define LLDP_TLV_LEN(type_len)   ( (type_len) & 0x01ff )
 Extract LLDP TLV length. More...
#define LLDP_TYPE_END   0x00
 End of LLDP data unit. More...
#define LLDP_SETTINGS_NAME   "lldp"
 LLDP settings block name. More...
#define LLDP_TAG(prefix, type, index, offset, length)
 Construct LLDP setting tag. More...


struct lldp_tlv __attribute__ ((packed))


uint16_t type_len
 Type and length. More...
uint8_t data [0]
 Data. More...

Detailed Description

Link Layer Discovery Protocol.

Definition in file lldp.h.

Macro Definition Documentation


#define LLDP_TLV_TYPE (   type_len)    ( (type_len) >> 9 )

Extract LLDP TLV type.

type_lenType and length
Return values

Definition at line 28 of file lldp.h.


#define LLDP_TLV_LEN (   type_len)    ( (type_len) & 0x01ff )

Extract LLDP TLV length.

type_lenType and length
Return values

Definition at line 36 of file lldp.h.


#define LLDP_TYPE_END   0x00

End of LLDP data unit.

Definition at line 39 of file lldp.h.


#define LLDP_SETTINGS_NAME   "lldp"

LLDP settings block name.

Definition at line 42 of file lldp.h.


#define LLDP_TAG (   prefix,
( ( ( ( uint64_t ) (prefix) ) << 32 ) | \
( (type) << 24 ) | ( (index) << 16 ) | \
( (offset) << 8 ) | ( (length) << 0 ) )
u16 length
Definition: sky2.h:9
unsigned long long uint64_t
Definition: stdint.h:13
char prefix[4]
Definition: vmconsole.c:53
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
uint32_t type
Operating system type.
Definition: ena.h:12
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

Construct LLDP setting tag.

LLDP settings are encoded as



<type> is the TLV type

<offset> is the starting offset within the TLV value

<length> is the length (or zero to read the from <offset> to the end)

<prefix>, if it has a non-zero value, is the subtype byte string of length <offset> to match at the start of the TLV value, up to a maximum matched length of 4 bytes

<index> is the index of the entry matching <type> and <prefix> to be accessed, with zero indicating the first matching entry

The <prefix> is designed to accommodate both matching of the OUI within an organization-specific TLV (e.g. 0x0080c2 for IEEE 802.1 TLVs) and of a subtype byte as found within many TLVs.

This encoding allows most LLDP values to be extracted easily. For example

System name: ${netX.lldp/}

System description: ${netX.lldp/}

Port description: ${netX.lldp/}

Port interface name: ${netX.lldp/}

Chassis MAC address: ${netX.lldp/}

Management IPv4 address: ${netX.lldp/}

Port VLAN ID: ${netX.lldp/0x0080c2.}

Port VLAN name: ${netX.lldp/0x0080c2.}

Maximum frame size: ${netX.lldp/0x00120f.}

Definition at line 92 of file lldp.h.

Function Documentation



◆ __attribute__()

struct lldp_tlv __attribute__ ( (packed)  )

Variable Documentation

◆ type_len

uint16_t type_len

Type and length.

Definition at line 12 of file lldp.h.

◆ data

uint8_t data[0]


Definition at line 14 of file lldp.h.