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