|
24 | 24 | extern "C" { |
25 | 25 | #endif |
26 | 26 |
|
| 27 | +/** @cond INTERNAL_HIDDEN */ |
| 28 | + |
27 | 29 | #define LLDP_TLV_GET_LENGTH(type_length) (type_length & BIT_MASK(9)) |
28 | 30 | #define LLDP_TLV_GET_TYPE(type_length) ((u8_t)(type_length >> 9)) |
29 | 31 |
|
@@ -101,46 +103,59 @@ extern "C" { |
101 | 103 |
|
102 | 104 | struct net_if; |
103 | 105 |
|
104 | | -/* TLV Types. Please refer to table 8-1 from IEEE 802.1AB standard. */ |
| 106 | +/** @endcond */ |
| 107 | + |
| 108 | +/** TLV Types. Please refer to table 8-1 from IEEE 802.1AB standard. */ |
105 | 109 | enum net_lldp_tlv_type { |
106 | | - LLDP_TLV_END_LLDPDU = 0, |
107 | | - LLDP_TLV_CHASSIS_ID, |
108 | | - LLDP_TLV_PORT_ID, |
109 | | - LLDP_TLV_TTL, |
110 | | - LLDP_TLV_PORT_DESC, |
111 | | - LLDP_TLV_SYSTEM_NAME, |
112 | | - LLDP_TLV_SYSTEM_DESC, |
113 | | - LLDP_TLV_SYSTEM_CAPABILITIES, |
114 | | - LLDP_TLV_MANAGEMENT_ADDR, |
| 110 | + LLDP_TLV_END_LLDPDU = 0, /**< End Of LLDPDU (optional) */ |
| 111 | + LLDP_TLV_CHASSIS_ID = 1, /**< Chassis ID (mandatory) */ |
| 112 | + LLDP_TLV_PORT_ID = 2, /**< Port ID (mandatory) */ |
| 113 | + LLDP_TLV_TTL = 3, /**< Time To Live (mandatory) */ |
| 114 | + LLDP_TLV_PORT_DESC = 4, /**< Port Description (optional) */ |
| 115 | + LLDP_TLV_SYSTEM_NAME = 5, /**< System Name (optional) */ |
| 116 | + LLDP_TLV_SYSTEM_DESC = 6, /**< System Description (optional) */ |
| 117 | + LLDP_TLV_SYSTEM_CAPABILITIES = 7, /**< System Capability (optional) */ |
| 118 | + LLDP_TLV_MANAGEMENT_ADDR = 8, /**< Management Address (optional) */ |
115 | 119 | /* Types 9 - 126 are reserved. */ |
116 | | - LLDP_TLV_ORG_SPECIFIC = 127 |
| 120 | + LLDP_TLV_ORG_SPECIFIC = 127, /**< Org specific TLVs (optional) */ |
117 | 121 | }; |
118 | 122 |
|
| 123 | +/** Chassis ID TLV, see chapter 8.5.2 in IEEE 802.1AB */ |
119 | 124 | struct net_lldp_chassis_tlv { |
120 | | - uint16_t type_length; /* 7 bits for type, 9 bits for length */ |
121 | | - uint8_t subtype; /* ID subtype. */ |
| 125 | + /** 7 bits for type, 9 bits for length */ |
| 126 | + uint16_t type_length; |
| 127 | + /** ID subtype */ |
| 128 | + uint8_t subtype; |
| 129 | + /** Chassis ID value */ |
122 | 130 | uint8_t value[NET_LLDP_CHASSIS_ID_VALUE_LEN]; |
123 | 131 | } __packed; |
124 | 132 |
|
| 133 | +/** Port ID TLV, see chapter 8.5.3 in IEEE 802.1AB */ |
125 | 134 | struct net_lldp_port_tlv { |
126 | | - uint16_t type_length; /* 7 bits for type, 9 bits for length */ |
127 | | - uint8_t subtype; /* ID subtype. */ |
| 135 | + /** 7 bits for type, 9 bits for length */ |
| 136 | + uint16_t type_length; |
| 137 | + /** ID subtype */ |
| 138 | + uint8_t subtype; |
| 139 | + /** Port ID value */ |
128 | 140 | uint8_t value[NET_LLDP_PORT_ID_VALUE_LEN]; |
129 | 141 | } __packed; |
130 | 142 |
|
| 143 | +/** Time To Live TLV, see chapter 8.5.4 in IEEE 802.1AB */ |
131 | 144 | struct net_lldp_time_to_live_tlv { |
132 | | - uint16_t type_length; /* 7 bits for type, 9 bits for length */ |
133 | | - uint16_t ttl; /* Time to live */ |
| 145 | + /** 7 bits for type, 9 bits for length */ |
| 146 | + uint16_t type_length; |
| 147 | + /** Time To Live (TTL) value */ |
| 148 | + uint16_t ttl; |
134 | 149 | } __packed; |
135 | 150 |
|
136 | | -/* |
| 151 | +/** |
137 | 152 | * LLDP Data Unit (LLDPDU) shall contain the following ordered TLVs |
138 | | - * as stated in "8.2 LLDPDU format" from the Spec. |
| 153 | + * as stated in "8.2 LLDPDU format" from the IEEE 802.1AB |
139 | 154 | */ |
140 | 155 | struct net_lldpdu { |
141 | | - struct net_lldp_chassis_tlv chassis_id; /* Mandatory TLV */ |
142 | | - struct net_lldp_port_tlv port_id; /* Mandatory TLV */ |
143 | | - struct net_lldp_time_to_live_tlv ttl; /* Mandatory TLV */ |
| 156 | + struct net_lldp_chassis_tlv chassis_id; /**< Mandatory Chassis TLV */ |
| 157 | + struct net_lldp_port_tlv port_id; /**< Mandatory Port TLV */ |
| 158 | + struct net_lldp_time_to_live_tlv ttl; /**< Mandatory TTL TLV */ |
144 | 159 | } __packed; |
145 | 160 |
|
146 | 161 | /** |
@@ -205,25 +220,25 @@ int net_lldp_register_callback(struct net_if *iface, net_lldp_recv_cb_t cb); |
205 | 220 | */ |
206 | 221 | enum net_verdict net_lldp_recv(struct net_if *iface, struct net_pkt *pkt); |
207 | 222 |
|
208 | | -#if defined(CONFIG_NET_LLDP) |
209 | 223 | /** |
210 | 224 | * @brief Set LLDP protocol data unit (LLDPDU) for the network interface. |
211 | 225 | * |
212 | 226 | * @param iface Network interface |
213 | 227 | * |
214 | 228 | * @return <0 if error, index in lldp array if iface is found there |
215 | 229 | */ |
| 230 | +#if defined(CONFIG_NET_LLDP) |
216 | 231 | int net_lldp_set_lldpdu(struct net_if *iface); |
217 | 232 | #else |
218 | 233 | #define net_lldp_set_lldpdu(iface) |
219 | 234 | #endif |
220 | 235 |
|
221 | | -#if defined(CONFIG_NET_LLDP) |
222 | 236 | /** |
223 | 237 | * @brief Unset LLDP protocol data unit (LLDPDU) for the network interface. |
224 | 238 | * |
225 | 239 | * @param iface Network interface |
226 | 240 | */ |
| 241 | +#if defined(CONFIG_NET_LLDP) |
227 | 242 | void net_lldp_unset_lldpdu(struct net_if *iface); |
228 | 243 | #else |
229 | 244 | #define net_lldp_unset_lldpdu(iface) |
|
0 commit comments