iPXE
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...

Macros

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

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
struct lldp_tlv __attribute__ ((packed))

Variables

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

Detailed Description

Link Layer Discovery Protocol.

Definition in file lldp.h.

Macro Definition Documentation

◆ LLDP_TLV_TYPE

#define LLDP_TLV_TYPE ( type_len)
Value:
( (type_len) >> 9 )
uint16_t type_len
Type and length.
Definition lldp.h:1

Extract LLDP TLV type.

Parameters
type_lenType and length
Return values
typeType

Definition at line 29 of file lldp.h.

Referenced by lldp_fetch().

◆ LLDP_TLV_LEN

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

Extract LLDP TLV length.

Parameters
type_lenType and length
Return values
lenLength

Definition at line 37 of file lldp.h.

Referenced by lldp_fetch().

◆ LLDP_TYPE_END

#define LLDP_TYPE_END   0x00

End of LLDP data unit.

Definition at line 40 of file lldp.h.

Referenced by lldp_fetch().

◆ LLDP_SETTINGS_NAME

#define LLDP_SETTINGS_NAME   "lldp"

LLDP settings block name.

Definition at line 43 of file lldp.h.

Referenced by lldp_probe().

◆ LLDP_TAG

#define LLDP_TAG ( prefix,
type,
index,
offset,
length )
Value:
( ( ( ( uint64_t ) (prefix) ) << 32 ) | \
( (type) << 24 ) | ( (index) << 16 ) | \
( (offset) << 8 ) | ( (length) << 0 ) )
unsigned long long uint64_t
Definition stdint.h:13
long index
Definition bigint.h:65
uint16_t offset
Offset to command line.
Definition bzimage.h:3
uint32_t type
Operating system type.
Definition ena.h:1
u16 length
Definition sky2.h:1
char prefix[4]
Definition vmconsole.c:53

Construct LLDP setting tag.

LLDP settings are encoded as

${netX.lldp/<prefix>.<type>.<index>.<offset>.<length>}

where

<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/5.0.0.0:string}

System description: ${netX.lldp/6.0.0.0:string}

Port description: ${netX.lldp/4.0.0.0:string}

Port interface name: ${netX.lldp/5.2.0.1.0:string}

Chassis MAC address: ${netX.lldp/4.1.0.1.0:hex}

Management IPv4 address: ${netX.lldp/5.1.8.0.2.4:ipv4}

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

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

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

Definition at line 93 of file lldp.h.

93#define LLDP_TAG( prefix, type, index, offset, length ) \
94 ( ( ( ( uint64_t ) (prefix) ) << 32 ) | \
95 ( (type) << 24 ) | ( (index) << 16 ) | \
96 ( (offset) << 8 ) | ( (length) << 0 ) )

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ __attribute__()

struct lldp_tlv __attribute__ ( (packed) )

Variable Documentation

◆ type_len

uint16_t type_len

Type and length.

Definition at line 1 of file lldp.h.

◆ data

uint8_t data[0]

Data.

Definition at line 3 of file lldp.h.