36#define LldpDataUnit struct _LldpDataUnit
40#define LldpAgentContext struct _LldpAgentContext
44#define LldpPortEntry struct _LldpPortEntry
54 #define LLDP_SUPPORT DISABLED
55#elif (LLDP_SUPPORT != ENABLED && LLDP_SUPPORT != DISABLED)
56 #error LLDP_SUPPORT parameter is not valid
60#ifndef LLDP_TX_MODE_SUPPORT
61 #define LLDP_TX_MODE_SUPPORT ENABLED
62#elif (LLDP_TX_MODE_SUPPORT != ENABLED && LLDP_TX_MODE_SUPPORT != DISABLED)
63 #error LLDP_TX_MODE_SUPPORT parameter is not valid
67#ifndef LLDP_RX_MODE_SUPPORT
68 #define LLDP_RX_MODE_SUPPORT ENABLED
69#elif (LLDP_RX_MODE_SUPPORT != ENABLED && LLDP_RX_MODE_SUPPORT != DISABLED)
70 #error LLDP_RX_MODE_SUPPORT parameter is not valid
74#ifndef LLDP_TASK_STACK_SIZE
75 #define LLDP_TASK_STACK_SIZE 500
76#elif (LLDP_TASK_STACK_SIZE < 1)
77 #error LLDP_TASK_STACK_SIZE parameter is not valid
81#ifndef LLDP_TASK_PRIORITY
82 #define LLDP_TASK_PRIORITY OS_TASK_PRIORITY_NORMAL
86#ifndef LLDP_TICK_INTERVAL
87 #define LLDP_TICK_INTERVAL 1000
88#elif (LLDP_TICK_INTERVAL < 10)
89 #error LLDP_TICK_INTERVAL parameter is not valid
93#ifndef LLDP_MAX_LLDPDU_SIZE
94 #define LLDP_MAX_LLDPDU_SIZE 500
95#elif (LLDP_MAX_LLDPDU_SIZE < 100 || LLDP_MAX_LLDPDU_SIZE > 1500)
96 #error LLDP_MAX_LLDPDU_SIZE parameter is not valid
100#ifndef LLDP_MAX_MGMT_ADDRS
101 #define LLDP_MAX_MGMT_ADDRS 10
102#elif (LLDP_MAX_MGMT_ADDRS < 1 || LLDP_MAX_MGMT_ADDRS > 32)
103 #error LLDP_MAX_MGMT_ADDRS parameter is not valid
107#define LLDP_MIN_MSG_TX_INTERVAL 1
109#define LLDP_DEFAULT_MSG_TX_INTERVAL 30
111#define LLDP_MAX_MSG_TX_INTERVAL 3600
114#define LLDP_MIN_MSG_TX_HOLD 1
116#define LLDP_DEFAULT_MSG_TX_HOLD 4
118#define LLDP_MAX_MSG_TX_HOLD 100
121#define LLDP_MIN_REINIT_DELAY 1
123#define LLDP_DEFAULT_REINIT_DELAY 2
125#define LLDP_MAX_REINIT_DELAY 10
128#define LLDP_MIN_TX_DELAY 1
130#define LLDP_DEFAULT_TX_DELAY 2
132#define LLDP_MAX_TX_DELAY 900
135#define LLDP_MIN_NOTIFICATION_INTERVAL 5
137#define LLDP_DEFAULT_NOTIFICATION_INTERVAL 5
139#define LLDP_MAX_NOTIFICATION_INTERVAL 3600
142#define LLDP_MGMT_ADDR_FILTER_0 0x00000001
143#define LLDP_MGMT_ADDR_FILTER_1 0x00000002
144#define LLDP_MGMT_ADDR_FILTER_2 0x00000004
145#define LLDP_MGMT_ADDR_FILTER_3 0x00000008
146#define LLDP_MGMT_ADDR_FILTER_4 0x00000010
147#define LLDP_MGMT_ADDR_FILTER_5 0x00000020
148#define LLDP_MGMT_ADDR_FILTER_6 0x00000040
149#define LLDP_MGMT_ADDR_FILTER_7 0x00000080
150#define LLDP_MGMT_ADDR_FILTER_8 0x00000100
151#define LLDP_MGMT_ADDR_FILTER_9 0x00000200
152#define LLDP_MGMT_ADDR_FILTER_10 0x00000400
153#define LLDP_MGMT_ADDR_FILTER_11 0x00000800
154#define LLDP_MGMT_ADDR_FILTER_12 0x00001000
155#define LLDP_MGMT_ADDR_FILTER_13 0x00002000
156#define LLDP_MGMT_ADDR_FILTER_14 0x00004000
157#define LLDP_MGMT_ADDR_FILTER_15 0x00008000
158#define LLDP_MGMT_ADDR_FILTER_16 0x00010000
159#define LLDP_MGMT_ADDR_FILTER_17 0x00020000
160#define LLDP_MGMT_ADDR_FILTER_18 0x00040000
161#define LLDP_MGMT_ADDR_FILTER_19 0x00080000
162#define LLDP_MGMT_ADDR_FILTER_20 0x00100000
163#define LLDP_MGMT_ADDR_FILTER_21 0x00200000
164#define LLDP_MGMT_ADDR_FILTER_22 0x00400000
165#define LLDP_MGMT_ADDR_FILTER_23 0x00800000
166#define LLDP_MGMT_ADDR_FILTER_24 0x01000000
167#define LLDP_MGMT_ADDR_FILTER_25 0x02000000
168#define LLDP_MGMT_ADDR_FILTER_26 0x04000000
169#define LLDP_MGMT_ADDR_FILTER_27 0x08000000
170#define LLDP_MGMT_ADDR_FILTER_28 0x10000000
171#define LLDP_MGMT_ADDR_FILTER_29 0x20000000
172#define LLDP_MGMT_ADDR_FILTER_30 0x40000000
173#define LLDP_MGMT_ADDR_FILTER_31 0x80000000
174#define LLDP_MGMT_ADDR_FILTER_ALL 0xFFFFFFFF
191 LLDP_ADMIN_STATUS_ENABLED_TX_RX = 3,
236 uint8_t data[LLDP_MAX_LLDPDU_SIZE];
280#if (LLDP_TX_MODE_SUPPORT == ENABLED)
295#if (LLDP_RX_MODE_SUPPORT == ENABLED)
347#if (OS_STATIC_TASK_SUPPORT == ENABLED)
355#if (LLDP_TX_MODE_SUPPORT == ENABLED)
364#if (LLDP_RX_MODE_SUPPORT == ENABLED)
373 uint32_t statsRemTablesLastChangeTime;
374 uint32_t statsRemTablesInserts;
375 uint32_t statsRemTablesDeletes;
376 uint32_t statsRemTablesDrops;
377 uint32_t statsRemTablesAgeouts;
387error_t lldpInit(LldpAgentContext *context,
390error_t lldpStart(LldpAgentContext *context);
391error_t lldpStop(LldpAgentContext *context);
393error_t lldpSetPortAddr(LldpAgentContext *context, uint_t portIndex,
394 const MacAddr *macAddr);
396error_t lldpSetAdminStatus(LldpAgentContext *context, uint_t portIndex,
399error_t lldpSetBasicTlvFilter(LldpAgentContext *context, uint_t portIndex,
402error_t lldpSetMgmtAddrFilter(LldpAgentContext *context, uint_t portIndex,
405error_t lldpSetMsgTxInterval(LldpAgentContext *context, uint_t msgTxInterval);
406error_t lldpSetMsgTxHold(LldpAgentContext *context, uint_t msgTxHold);
407error_t lldpSetReinitDelay(LldpAgentContext *context, uint_t reinitDelay);
408error_t lldpSetTxDelay(LldpAgentContext *context, uint_t txDelay);
410error_t lldpSetLocalChassisId(LldpAgentContext *context,
412 size_t chassisIdLen);
414error_t lldpSetLocalPortId(LldpAgentContext *context, uint_t portIndex,
417error_t lldpSetLocalPortDesc(LldpAgentContext *context, uint_t portIndex,
418 const char_t *portDesc);
420error_t lldpSetLocalSysName(LldpAgentContext *context,
const char_t *sysName);
421error_t lldpSetLocalSysDesc(LldpAgentContext *context,
const char_t *sysDesc);
423error_t lldpSetLocalSysCap(LldpAgentContext *context, uint16_t supportedCap,
424 uint16_t enabledCap);
426error_t lldpSetLocalMgmtAddr(LldpAgentContext *context, uint_t index,
429 const uint8_t *oid,
size_t oidLen);
433void lldpTask(LldpAgentContext *context);
435void lldpDeinit(LldpAgentContext *context);
error_t
Error codes.
Definition error.h:43
void(* LldpSendCallback)(LldpPortEntry *port, LldpDataUnit *lldpdu)
LLDP frame transmission callback function.
Definition lldp.h:213
void(* LldpReceiveCallback)(LldpPortEntry *port, LldpDataUnit *lldpdu)
LLDP frame reception callback function.
Definition lldp.h:220
LldpAdminStatus
Administrative status.
Definition lldp.h:187
@ LLDP_ADMIN_STATUS_ENABLED_RX_ONLY
The local LLDP agent can only receive LLDP frames.
Definition lldp.h:190
@ LLDP_ADMIN_STATUS_DISABLED
The local LLDP agent can neither transmit or receive LLDP frames.
Definition lldp.h:188
@ LLDP_ADMIN_STATUS_ENABLED_TX_ONLY
The local LLDP agent can only transmit LLDP frames.
Definition lldp.h:189
LldpBasicTlvFilter
Basic TLV filter.
Definition lldp.h:200
@ LLDP_BASIC_TLV_FILTER_SYS_NAME
System Name TLV.
Definition lldp.h:202
@ LLDP_BASIC_TLV_FILTER_SYS_DESC
System Description TLV.
Definition lldp.h:203
@ LLDP_BASIC_TLV_FILTER_ALL
All Basic TLVs.
Definition lldp.h:205
@ LLDP_BASIC_TLV_FILTER_SYS_CAP
System Capabilities TLV.
Definition lldp.h:204
@ LLDP_BASIC_TLV_FILTER_PORT_DESC
Port Description TLV.
Definition lldp.h:201
void(* LldpTickCallback)(LldpAgentContext *context)
Tick callback function.
Definition lldp.h:227
LLDP receive state machine.
LldpRxState
LLDP receive states.
Definition lldp_rx_fsm.h:49
TLV parsing and formatting.
LldpMgmtAddrSubtype
Management address subtypes.
Definition lldp_tlv.h:162
LldpPortIdSubtype
Port ID subtypes.
Definition lldp_tlv.h:128
LldpChassisIdSubtype
Chassis ID subtypes.
Definition lldp_tlv.h:111
LldpIfNumSubtype
Interface numbering subtypes.
Definition lldp_tlv.h:175
LldpTlvType
TLV type values.
Definition lldp_tlv.h:92
LLDP transmit state machine.
LldpTxState
LLDP transmit states.
Definition lldp_tx_fsm.h:49
uint_t OsMutex
Mutex object.
Definition os_port_none.h:118
uint_t OsEvent
Event object.
Definition os_port_none.h:104
uint_t OsTaskId
Task identifier.
Definition os_port_none.h:97
uint32_t systime_t
System time.
Definition os_port_none.h:90
LLDP agent settings.
Definition lldp.h:315
LldpSendCallback sendCallback
LLDP frame transmission callback function.
Definition lldp.h:321
NetInterface * interface
Network interface to configure.
Definition lldp.h:316
LldpPortEntry * ports
Port table.
Definition lldp.h:318
uint_t numNeighbors
Maximum number of entries in the neighbor table.
Definition lldp.h:319
uint_t numPorts
Number of ports.
Definition lldp.h:317
LldpTickCallback tickCallback
Tick callback function.
Definition lldp.h:323
LldpNeighborEntry * neighbors
Neighbor table.
Definition lldp.h:320
LldpReceiveCallback receiveCallback
LLDP frame reception callback function.
Definition lldp.h:322
MSAP identifier.
Definition lldp.h:247
size_t chassisIdLen
Length of the chassis identifier, in bytes.
Definition lldp.h:249
const uint8_t * chassisId
Chassis identifier.
Definition lldp.h:248
const uint8_t * portId
Port identifier.
Definition lldp.h:250
size_t portIdLen
Length of the port identifier, in bytes.
Definition lldp.h:251
LLDP neighbor entry.
Definition lldp.h:260
uint_t rxInfoTTL
Time remaining until the information is no longer valid.
Definition lldp.h:264
LldpDataUnit rxInfo
Remote system information.
Definition lldp.h:265
uint_t portIndex
Port on which the LLDPDU was received.
Definition lldp.h:263
uint32_t index
Arbitrary local integer value used to identify the entry.
Definition lldp.h:261
uint32_t timeMark
Timestamp used to implement time-filtered rows.
Definition lldp.h:262
LLDP agent context.
Definition lldp.h:332
LldpTickCallback tickCallback
Tick callback function.
Definition lldp.h:340
OsStackType taskStack[LLDP_TASK_STACK_SIZE]
Task stack.
Definition lldp.h:349
bool_t rxChanges
The incoming LLDPDU has been received with different TLV values.
Definition lldp.h:369
OsTaskId taskId
Task identifier.
Definition lldp.h:346
bool_t busy
Busy flag.
Definition lldp.h:380
OsTaskTcb taskTcb
Task control block.
Definition lldp.h:348
bool_t tooManyNeighbors
Insufficient space to store information from all neighbors.
Definition lldp.h:372
bool_t running
This flag tells whether the LLDP agent is running or not.
Definition lldp.h:342
NetInterface * interface
Underlying network interface.
Definition lldp.h:333
LldpDataUnit txInfo
Local system information.
Definition lldp.h:356
bool_t stop
Stop request.
Definition lldp.h:343
bool_t somethingChangedRemote
Per-MSAP variable set after all the information has been updated.
Definition lldp.h:371
LldpSendCallback sendCallback
LLDP frame transmission callback function.
Definition lldp.h:338
systime_t timestamp
Timestamp to manage timeout.
Definition lldp.h:352
uint_t rxTTL
The TTL extracted from the received LLDPDU.
Definition lldp.h:370
bool_t badFrame
Incoming failed validation and was discarded.
Definition lldp.h:368
LldpDataUnit lldpdu
Incoming/outgoing LLDP data unit.
Definition lldp.h:353
OsMutex mutex
Mutex preventing simultaneous access to LLDP agent context.
Definition lldp.h:344
LldpReceiveCallback receiveCallback
LLDP frame reception callback function.
Definition lldp.h:339
uint_t numPorts
Number of ports.
Definition lldp.h:334
uint32_t index
Monotonically increasing index used to identify entries.
Definition lldp.h:365
uint_t txDelay
Delay between successive LLDP frame transmissions.
Definition lldp.h:360
uint_t msgTxInterval
Interval at which LLDP frames are transmitted.
Definition lldp.h:357
uint_t msgTxHold
Transmit hold multiplier.
Definition lldp.h:358
LldpPortEntry * ports
Port table.
Definition lldp.h:335
uint32_t mgmtAddrMap
Bit-map indicating the management addresses that are configured.
Definition lldp.h:361
uint_t tooManyNeighborsTimer
Too many neighbors timer.
Definition lldp.h:367
LldpNeighborEntry * neighbors
Neighbor table.
Definition lldp.h:337
uint_t reinitDelay
Delay before re-initialization will be attempted.
Definition lldp.h:359
Socket * socket
Underlying socket.
Definition lldp.h:351
uint_t numNeighbors
Maximum number of entries in the neighbor table.
Definition lldp.h:336
OsEvent event
Event object used to poll the underlying socket.
Definition lldp.h:345
uint_t notificationInterval
Notification interval.
Definition lldp.h:366
LLDP data unit.
Definition lldp.h:235
LLDP port entry.
Definition lldp.h:274
uint32_t statsFramesInTotal
Count of all LLDP frames received.
Definition lldp.h:302
uint_t txTTR
Transmit time to refresh timer.
Definition lldp.h:288
uint8_t basicTlvFilter
Bit-map indicating the basic TLVs enabled for transmission.
Definition lldp.h:283
bool_t rcvFrame
An LLDP frame has been recognized by the LLDP LSAP function.
Definition lldp.h:298
uint_t txDelayWhile
Minimum delay between transmission of successive LLDP frames.
Definition lldp.h:287
uint32_t mgmtAddrFilter
Bit-map indicating the management addresses enabled for transmission.
Definition lldp.h:284
bool_t notificationEnable
Enable or disable notifications.
Definition lldp.h:297
uint32_t statsTLVsDiscardedTotal
Count of all TLVs received and then discarded for any reason.
Definition lldp.h:303
uint32_t statsFramesDiscardedTotal
Count of all LLDPDUs received and then discarded.
Definition lldp.h:300
LldpRxState rxState
LLDP receive state.
Definition lldp.h:296
bool_t portEnabled
Operational state of the MAC service supporting the port.
Definition lldp.h:278
uint32_t lldpduLengthErrors
The number of LLDPDU length errors recorded for the port.
Definition lldp.h:292
LldpDataUnit txInfo
Local system information.
Definition lldp.h:282
LldpAdminStatus adminStatus
Indicates whether the local LLDP agent is enabled.
Definition lldp.h:277
uint32_t statsTLVsUnrecognizedTotal
Count of all TLVs received on the port that are not recognized.
Definition lldp.h:304
LldpAgentContext * context
LLDP agent context.
Definition lldp.h:275
bool_t somethingChangedLocal
Status/value of one or more objects in the LLDP local system MIB has changed.
Definition lldp.h:289
uint_t txTTL
Time remaining before information in the outgoing LLDPDU will no longer be valid.
Definition lldp.h:290
uint_t txShutdownWhile
Number of seconds remaining until LLDP re-initialization can occur.
Definition lldp.h:286
uint_t rxInfoAge
The rxInfoTTL timing counter has expired.
Definition lldp.h:299
LldpTxState txState
LLDP transmit state.
Definition lldp.h:285
uint8_t portIndex
Port index.
Definition lldp.h:276
uint32_t statsFramesInErrorsTotal
Count of all LLDPDUs received with one or more detectable errors.
Definition lldp.h:301
MacAddr macAddr
MAC address of the port.
Definition lldp.h:281
uint32_t statsFramesOutTotal
Count of all LLDP frames transmitted.
Definition lldp.h:291
uint32_t statsAgeoutsTotal
Count of the times that a neighbor's information has been aged out.
Definition lldp.h:305