iPXE
lldp.h
Go to the documentation of this file.
1#ifndef _IPXE_LLDP_H
2#define _IPXE_LLDP_H
4/** @file
5 *
6 * Link Layer Discovery Protocol
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14
15/** An LLDP TLV header */
16struct lldp_tlv {
17 /** Type and length */
19 /** Data */
21} __attribute__ (( packed ));
22
23/**
24 * Extract LLDP TLV type
25 *
26 * @v type_len Type and length
27 * @ret type Type
28 */
29#define LLDP_TLV_TYPE( type_len ) ( (type_len) >> 9 )
30
31/**
32 * Extract LLDP TLV length
33 *
34 * @v type_len Type and length
35 * @ret len Length
36 */
37#define LLDP_TLV_LEN( type_len ) ( (type_len) & 0x01ff )
38
39/** End of LLDP data unit */
40#define LLDP_TYPE_END 0x00
41
42/** LLDP settings block name */
43#define LLDP_SETTINGS_NAME "lldp"
44
45/**
46 * Construct LLDP setting tag
47 *
48 * LLDP settings are encoded as
49 *
50 * ${netX.lldp/<prefix>.<type>.<index>.<offset>.<length>}
51 *
52 * where
53 *
54 * <type> is the TLV type
55 *
56 * <offset> is the starting offset within the TLV value
57 *
58 * <length> is the length (or zero to read the from <offset> to the end)
59 *
60 * <prefix>, if it has a non-zero value, is the subtype byte string
61 * of length <offset> to match at the start of the TLV value, up to
62 * a maximum matched length of 4 bytes
63 *
64 * <index> is the index of the entry matching <type> and <prefix> to
65 * be accessed, with zero indicating the first matching entry
66 *
67 * The <prefix> is designed to accommodate both matching of the OUI
68 * within an organization-specific TLV (e.g. 0x0080c2 for IEEE 802.1
69 * TLVs) and of a subtype byte as found within many TLVs.
70 *
71 * This encoding allows most LLDP values to be extracted easily. For
72 * example
73 *
74 * System name: ${netX.lldp/5.0.0.0:string}
75 *
76 * System description: ${netX.lldp/6.0.0.0:string}
77 *
78 * Port description: ${netX.lldp/4.0.0.0:string}
79 *
80 * Port interface name: ${netX.lldp/5.2.0.1.0:string}
81 *
82 * Chassis MAC address: ${netX.lldp/4.1.0.1.0:hex}
83 *
84 * Management IPv4 address: ${netX.lldp/5.1.8.0.2.4:ipv4}
85 *
86 * Port VLAN ID: ${netX.lldp/0x0080c2.1.127.0.4.2:int16}
87 *
88 * Port VLAN name: ${netX.lldp/0x0080c2.3.127.0.7.0:string}
89 *
90 * Maximum frame size: ${netX.lldp/0x00120f.4.127.0.4.2:uint16}
91 *
92 */
93#define LLDP_TAG( prefix, type, index, offset, length ) \
94 ( ( ( ( uint64_t ) (prefix) ) << 32 ) | \
95 ( (type) << 24 ) | ( (index) << 16 ) | \
96 ( (offset) << 8 ) | ( (length) << 0 ) )
97
98#endif /* _IPXE_LLDP_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned char uint8_t
Definition stdint.h:10
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
An LLDP TLV header.
Definition lldp.h:16
uint16_t type_len
Type and length.
Definition lldp.h:18
uint8_t data[0]
Data.
Definition lldp.h:20