mikroSDK Reference Manual
lldp_tlv.h
Go to the documentation of this file.
1
31#ifndef _LLDP_TLV_H
32#define _LLDP_TLV_H
33
34//Dependencies
35#include "core/net.h"
36#include "lldp/lldp.h"
37
38//Size of organizationally unique identifiers
39#define LLDP_OUI_SIZE 3
40
41//Maximum length of TLV information string
42#define LLDP_MAX_TLV_INFO_LEN 511
43//Maximum length of organizationally defined information string
44#define LLDP_MAX_ORG_SPECIFIC_INFO_LEN 507
45
46//Minimum length of chassis ID
47#define LLDP_MIN_CHASSIS_ID_LEN 1
48//Maximum length of chassis ID
49#define LLDP_MAX_CHASSIS_ID_LEN 255
50
51//Minimum length of port ID
52#define LLDP_MIN_PORT_ID_LEN 1
53//Maximum length of port ID
54#define LLDP_MAX_PORT_ID_LEN 255
55
56//Minimum length of port description
57#define LLDP_MIN_PORT_DESC_LEN 1
58//Maximum length of port description
59#define LLDP_MAX_PORT_DESC_LEN 255
60
61//Minimum length of system name
62#define LLDP_MIN_SYS_NAME_LEN 1
63//Maximum length of system name
64#define LLDP_MAX_SYS_NAME_LEN 255
65
66//Minimum length of system description
67#define LLDP_MIN_SYS_DESC_LEN 1
68//Maximum length of system description
69#define LLDP_MAX_SYS_DESC_LEN 255
70
71//Minimum length of management address
72#define LLDP_MIN_MGMT_ADDR_LEN 1
73//Maximum length of management address
74#define LLDP_MAX_MGMT_ADDR_LEN 31
75
76//Minimum length of object identifier
77#define LLDP_MIN_OID_LEN 0
78//Maximum length of object identifier
79#define LLDP_MAX_OID_LEN 128
80
81//C++ guard
82#ifdef __cplusplus
83extern "C" {
84#endif
85
86
104
105
121
122
138
139
155
156
168
169
180
181
186typedef enum
187{
188 LLDP_DOT1_OUI = 0x0080C2,
189 LLDP_DOT3_OUI = 0x00120F,
190 LLDP_MED_OUI = 0x0012BB,
191 LLDP_PNO_OUI = 0x000ECF
193
194
199typedef struct
200{
201 size_t pos;
202 uint8_t type;
203 size_t length;
204 uint8_t *value;
205} LldpTlv;
206
207
208//CodeWarrior or Win32 compiler?
209#if defined(__CWCC__) || defined(_WIN32)
210 #pragma pack(push, 1)
211#endif
212
213
219{
220#if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
221 uint8_t type : 7; //0
222 uint8_t lengthH : 1;
223 uint8_t lengthL; //1
224 uint8_t value[]; //2
225#else
226 uint8_t lengthH : 1; //0
227 uint8_t type : 7;
228 uint8_t lengthL; //1
229 uint8_t value[]; //2
230#endif
231} LldpTlvHeader;
232
233
238typedef __packed_struct
239{
240 uint8_t chassisIdSubtype; //0
241 uint8_t chassisId[]; //1
242} LldpChassisIdTlv;
243
244
249typedef __packed_struct
250{
251 uint8_t portIdSubtype; //0
252 uint8_t portId[]; //1
253} LldpPortIdTlv;
254
255
260typedef __packed_struct
261{
262 uint16_t ttl; //0-1
263} LldpTimeToLiveTlv;
264
265
270typedef __packed_struct
271{
272 uint16_t supportedCap; //0-1
273 uint16_t enabledCap; //2-3
274} LldpSysCapTlv;
275
276
281typedef __packed_struct
282{
283 uint8_t mgmtAddrLen; //0
284 uint8_t mgmtAddrSubtype; //1
285 uint8_t mgmtAddr[]; //2
286} LldpMgmtAddrTlv1;
287
288
293typedef __packed_struct
294{
295 uint8_t ifNumSubtype; //0
296 uint32_t ifNum; //1-4
297 uint8_t oidLen; //5
298 uint8_t oid[]; //6
299} LldpMgmtAddrTlv2;
300
301
306typedef __packed_struct
307{
308 uint8_t oui[LLDP_OUI_SIZE]; //0-2
309 uint8_t subtype; //3
310 uint8_t value[]; //4
311} LldpOrgDefTlv;
312
313
314//CodeWarrior or Win32 compiler?
315#if defined(__CWCC__) || defined(_WIN32)
316 #pragma pack(pop)
317#endif
318
319//LLDP related functions
320error_t lldpSetTlv(LldpDataUnit *lldpdu, uint8_t type, uint_t index,
321 const uint8_t *value, size_t length, bool_t replace);
322
323error_t lldpGetTlv(LldpDataUnit *lldpdu, uint8_t type, uint_t index,
324 const uint8_t **value, size_t *length);
325
326error_t lldpGetFirstTlv(LldpDataUnit *lldpdu, LldpTlv *tlv);
327error_t lldpGetNextTlv(LldpDataUnit *lldpdu, LldpTlv *tlv);
328
329error_t lldpDeleteTlv(LldpDataUnit *lldpdu, uint8_t type, uint_t index);
330
331error_t lldpDecodeMgmtAddrTlv(const uint8_t *value, size_t length,
332 const LldpMgmtAddrTlv1 **mgmtAddr1, const LldpMgmtAddrTlv2 **mgmtAddr2);
333
334error_t lldpSetOrgDefTlv(LldpDataUnit *lldpdu, uint32_t oui, uint8_t subtype,
335 uint_t index, const uint8_t *value, size_t length, bool_t replace);
336
337error_t lldpGetOrgDefTlv(LldpDataUnit *lldpdu, uint32_t oui, uint8_t subtype,
338 uint_t index, const uint8_t **value, size_t *length);
339
340error_t lldpDeleteOrgDefTlv(LldpDataUnit *lldpdu, uint32_t oui, uint8_t subtype,
341 uint_t index);
342
343//C++ guard
344#ifdef __cplusplus
345}
346#endif
347
348#endif
error_t
Error codes.
Definition error.h:43
LLDP (Link Layer Discovery Protocol)
LldpMgmtAddrSubtype
Management address subtypes.
Definition lldp_tlv.h:162
@ LLDP_MGMT_ADDR_SUBTYPE_OTHER
Other.
Definition lldp_tlv.h:163
@ LLDP_MGMT_ADDR_SUBTYPE_IPV6
IPv6 address.
Definition lldp_tlv.h:165
@ LLDP_MGMT_ADDR_SUBTYPE_IPV4
IPv4 address.
Definition lldp_tlv.h:164
@ LLDP_MGMT_ADDR_SUBTYPE_ALL_802
MAC address.
Definition lldp_tlv.h:166
LldpPortIdSubtype
Port ID subtypes.
Definition lldp_tlv.h:128
@ LLDP_PORT_ID_SUBTYPE_INTERFACE_NAME
Interface name.
Definition lldp_tlv.h:134
@ LLDP_PORT_ID_SUBTYPE_PORT_COMPONENT
Port component.
Definition lldp_tlv.h:131
@ LLDP_PORT_ID_SUBTYPE_MAC_ADDR
MAC address.
Definition lldp_tlv.h:132
@ LLDP_PORT_ID_SUBTYPE_AGENT_CIRCUIT_ID
Agent circuit ID.
Definition lldp_tlv.h:135
@ LLDP_PORT_ID_SUBTYPE_NETWORK_ADDR
Network address.
Definition lldp_tlv.h:133
@ LLDP_PORT_ID_SUBTYPE_INTERFACE_ALIAS
Interface alias.
Definition lldp_tlv.h:130
@ LLDP_PORT_ID_SUBTYPE_RESERVED
Reserved.
Definition lldp_tlv.h:129
@ LLDP_PORT_ID_SUBTYPE_LOCALLY_ASSIGNED
Locally assigned.
Definition lldp_tlv.h:136
LldpOui
Organizationally unique identifiers.
Definition lldp_tlv.h:187
@ LLDP_DOT3_OUI
IEEE 802.3.
Definition lldp_tlv.h:189
@ LLDP_PNO_OUI
PROFIBUS.
Definition lldp_tlv.h:191
@ LLDP_DOT1_OUI
IEEE 802.1.
Definition lldp_tlv.h:188
@ LLDP_MED_OUI
LLDP-MED.
Definition lldp_tlv.h:190
LldpChassisIdSubtype
Chassis ID subtypes.
Definition lldp_tlv.h:111
@ LLDP_CHASSIS_ID_SUBTYPE_PORT_COMPONENT
Port component.
Definition lldp_tlv.h:115
@ LLDP_CHASSIS_ID_SUBTYPE_RESERVED
Reserved.
Definition lldp_tlv.h:112
@ LLDP_CHASSIS_ID_SUBTYPE_INTERFACE_ALIAS
Interface alias.
Definition lldp_tlv.h:114
@ LLDP_CHASSIS_ID_SUBTYPE_INTERFACE_NAME
Interface name.
Definition lldp_tlv.h:118
@ LLDP_CHASSIS_ID_SUBTYPE_MAC_ADDR
MAC address.
Definition lldp_tlv.h:116
@ LLDP_CHASSIS_ID_SUBTYPE_LOCALLY_ASSIGNED
Locally assigned.
Definition lldp_tlv.h:119
@ LLDP_CHASSIS_ID_SUBTYPE_CHASSIS_COMPONENT
Chassis component.
Definition lldp_tlv.h:113
@ LLDP_CHASSIS_ID_SUBTYPE_NETWORK_ADDR
Network address.
Definition lldp_tlv.h:117
LldpIfNumSubtype
Interface numbering subtypes.
Definition lldp_tlv.h:175
@ LLDP_IF_NUM_SUBTYPE_UNKNOWN
Unknown.
Definition lldp_tlv.h:176
@ LLDP_IF_NUM_SUBTYPE_IF_INDEX
Interface index.
Definition lldp_tlv.h:177
@ LLDP_IF_NUM_SUBTYPE_SYS_PORT_NUM
System port number.
Definition lldp_tlv.h:178
typedef __packed_struct
TLV header.
Definition lldp_tlv.h:219
LldpSysCap
System capabilities.
Definition lldp_tlv.h:145
@ LLDP_SYS_CAP_REPEATER
Repeater.
Definition lldp_tlv.h:147
@ LLDP_SYS_CAP_DOCSIS_CABLE_DEVICE
DOCSIS cable device.
Definition lldp_tlv.h:152
@ LLDP_SYS_CAP_OTHER
Other.
Definition lldp_tlv.h:146
@ LLDP_SYS_CAP_BRIDGE
Bridge.
Definition lldp_tlv.h:148
@ LLDP_SYS_CAP_WLAN_ACCESS_POINT
WLAN Access Point.
Definition lldp_tlv.h:149
@ LLDP_SYS_CAP_STATION_ONLY
Station Only.
Definition lldp_tlv.h:153
@ LLDP_SYS_CAP_TELEPHONE
Telephone.
Definition lldp_tlv.h:151
@ LLDP_SYS_CAP_ROUTER
Router.
Definition lldp_tlv.h:150
LldpTlvType
TLV type values.
Definition lldp_tlv.h:92
@ LLDP_TLV_TYPE_CHASSIS_ID
Chassis ID.
Definition lldp_tlv.h:94
@ LLDP_TLV_TYPE_MGMT_ADDR
Management Address.
Definition lldp_tlv.h:101
@ LLDP_TLV_TYPE_SYS_NAME
System Name.
Definition lldp_tlv.h:98
@ LLDP_TLV_TYPE_SYS_CAP
System Capabilities.
Definition lldp_tlv.h:100
@ LLDP_TLV_TYPE_END_OF_LLDPDU
End Of LLDPDU.
Definition lldp_tlv.h:93
@ LLDP_TLV_TYPE_SYS_DESC
System Description.
Definition lldp_tlv.h:99
@ LLDP_TLV_TYPE_TIME_TO_LIVE
Time To Live.
Definition lldp_tlv.h:96
@ LLDP_TLV_TYPE_PORT_ID
Port ID.
Definition lldp_tlv.h:95
@ LLDP_TLV_TYPE_PORT_DESC
Port Description.
Definition lldp_tlv.h:97
@ LLDP_TLV_TYPE_ORG_DEFINED
Organizationally Specific TLVs.
Definition lldp_tlv.h:102
TCP/IP stack core.
TLV structure.
Definition lldp_tlv.h:200