Go to the documentation of this file.
32 #define TRACE_LEVEL LLDP_TRACE_LEVEL
43 #if (LLDP_SUPPORT == ENABLED)
66 interface = context->interface;
69 for(i = 0; i < context->numPorts; i++)
72 port = &context->ports[i];
74 #if (LLDP_TX_MODE_SUPPORT == ENABLED)
85 if(!
port->portEnabled && linkState && interface->linkState)
94 #if (LLDP_TX_MODE_SUPPORT == ENABLED)
102 else if(
port->portEnabled && !linkState)
105 TRACE_INFO(
"Port %" PRIu8
": Link is down...\r\n",
port->portIndex);
117 #if (LLDP_RX_MODE_SUPPORT == ENABLED)
122 for(i = 0; i < context->numNeighbors; i++)
127 entry = &context->neighbors[i];
130 if(entry->
rxInfo.length > 0)
157 if(context->tickCallback != NULL)
160 context->tickCallback(context);
179 msg.
data = context->lldpdu.data;
189 context->lldpdu.length = msg.
length;
191 #if (ETH_PORT_TAGGING_SUPPORT == ENABLED)
201 portIndex, context->lldpdu.length);
204 if(portIndex <= context->numPorts)
213 port = &context->ports[portIndex - 1];
216 if(context->receiveCallback != NULL)
219 context->receiveCallback(
port, &context->lldpdu);
222 #if (LLDP_RX_MODE_SUPPORT == ENABLED)
244 #if (LLDP_RX_MODE_SUPPORT == ENABLED)
254 context =
port->context;
337 if(context->rxTTL == 0)
383 port->statsTLVsUnrecognizedTotal++;
411 port->statsTLVsDiscardedTotal++;
412 port->statsFramesInErrorsTotal++;
422 port->statsFramesDiscardedTotal++;
423 port->statsFramesInErrorsTotal++;
426 context->badFrame =
TRUE;
453 for(i = 0; i < context->numNeighbors; i++)
456 if(context->neighbors[i].rxInfo.length == 0)
459 entry = &context->neighbors[i];
495 for(i = 0; i < context->numNeighbors; i++)
498 if(context->neighbors[i].rxInfo.length > 0)
501 error =
lldpGetMsapId(&context->neighbors[i].rxInfo, &msapId2);
510 entry = &context->neighbors[i];
550 interface = context->interface;
553 if(context->numPorts > 1 && interface->switchDriver != NULL &&
554 interface->switchDriver->getLinkState != NULL)
559 linkState = interface->switchDriver->getLinkState(interface, portIndex);
566 linkState = interface->linkState;
582 #if (LLDP_RX_MODE_SUPPORT == ENABLED)
591 interface = context->interface;
597 if(interface->switchDriver != NULL &&
598 interface->switchDriver->addStaticFdbEntry != NULL)
607 error = interface->switchDriver->addStaticFdbEntry(interface, &entry);
637 #if (LLDP_RX_MODE_SUPPORT == ENABLED)
646 interface = context->interface;
652 if(interface->switchDriver != NULL &&
653 interface->switchDriver->deleteStaticFdbEntry != NULL)
662 error = interface->switchDriver->deleteStaticFdbEntry(interface, &entry);
697 context =
port->context;
700 if(context->numPorts > 1)
703 macAddr = &context->interface->macAddr;
709 for(i = 5; i >= 0; i--)
712 port->macAddr.b[i] = macAddr->b[i] +
c;
715 if(
port->macAddr.b[i] < macAddr->b[i])
728 port->macAddr = context->interface->macAddr;
808 #if (LLDP_TX_MODE_SUPPORT == ENABLED)
812 for(i = 0; i < context->numPorts; i++)
814 context->ports[i].somethingChangedLocal =
TRUE;
void lldpFsm(LldpAgentContext *context)
LLDP state machine implementation.
error_t lldpGetFirstTlv(LldpDataUnit *lldpdu, LldpTlv *tlv)
Extract the first TLV from an LLDPDU.
error_t ethAcceptMacAddr(NetInterface *interface, const MacAddr *macAddr)
Add a unicast/multicast address to the MAC filter table.
error_t lldpDropMulticastAddr(LldpAgentContext *context)
Remove the LLDP multicast address from the static MAC table.
@ LLDP_TLV_TYPE_SYS_CAP
System Capabilities.
void lldpProcessFrame(LldpAgentContext *context)
Process incoming LLDP frame.
Message and ancillary data.
@ LLDP_TLV_TYPE_MGMT_ADDR
Management Address.
error_t lldpGetNextTlv(LldpDataUnit *lldpdu, LldpTlv *tlv)
Extract the next TLV from an LLDPDU.
#define LLDP_MAX_PORT_ID_LEN
void * data
Pointer to the payload.
@ LLDP_TLV_TYPE_ORG_DEFINED
Organizationally Specific TLVs.
#define osMemcmp(p1, p2, length)
const MacAddr LLDP_MULTICAST_ADDR
#define LLDP_MAX_LLDPDU_SIZE
error_t ethDropMacAddr(NetInterface *interface, const MacAddr *macAddr)
Remove a unicast/multicast address from the MAC filter table.
@ LLDP_TLV_TYPE_END_OF_LLDPDU
End Of LLDPDU.
uint16_t ethType
Ethernet type field.
const uint8_t * portId
Port identifier.
Data logging functions for debugging purpose (LLDP)
const SocketMsg SOCKET_DEFAULT_MSG
size_t length
Actual length of the payload, in bytes.
size_t portIdLen
Length of the port identifier, in bytes.
#define LLDP_MIN_CHASSIS_ID_LEN
LldpNeighborEntry * lldpCreateNeighborEntry(LldpAgentContext *context)
Create a new entry in the remote systems MIB.
error_t lldpCheckDataUnit(LldpPortEntry *port, LldpDataUnit *lldpdu)
LLDP data unit validation.
#define LLDP_MAX_CHASSIS_ID_LEN
const uint8_t * chassisId
Chassis identifier.
void lldpDeleteNeighborEntry(LldpNeighborEntry *entry)
Remove an entry from the remote systems MIB.
uint_t rxInfoTTL
Time remaining until the information is no longer valid.
bool_t lldpCompareMsapId(const LldpMsapId *msapId1, const LldpMsapId *msapId2)
Compare MSAP identifiers.
uint8_t switchPort
Switch port identifier.
error_t socketReceiveMsg(Socket *socket, SocketMsg *message, uint_t flags)
Receive a message from a connectionless socket.
Helper functions for LLDP.
error_t lldpGetTlv(LldpDataUnit *lldpdu, uint8_t type, uint_t index, const uint8_t **value, size_t *length)
Search a LLDPDU for a given TLV.
void lldpTick(LldpAgentContext *context)
LLDP agent timer handler.
bool_t lldpGetLinkState(LldpAgentContext *context, uint_t portIndex)
Get link state.
@ LLDP_TLV_TYPE_CHASSIS_ID
Chassis ID.
MacAddr destMacAddr
Destination MAC address.
uint_t portIndex
Port on which the LLDPDU was received.
void lldpSomethingChangedLocal(LldpAgentContext *context)
Notify LLDP that an object in the LLDP local system MIB has changed.
size_t chassisIdLen
Length of the chassis identifier, in bytes.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
LldpNeighborEntry * lldpFindNeighborEntry(LldpAgentContext *context, LldpDataUnit *lldpdu)
Search the remote systems MIB for a matching MSAP identifier.
#define macCompAddr(macAddr1, macAddr2)
size_t size
Size of the payload, in bytes.
void lldpDecrementTimer(uint_t *x)
Decrement timer value.
error_t lldpAcceptMulticastAddr(LldpAgentContext *context)
Add the LLDP multicast address to the static MAC table.
@ LLDP_TLV_TYPE_PORT_ID
Port ID.
void lldpGeneratePortAddr(LldpPortEntry *port)
Port's MAC address generation.
#define SWITCH_CPU_PORT_MASK
LLDP (Link Layer Discovery Protocol)
@ LLDP_TLV_TYPE_TIME_TO_LIVE
Time To Live.
error_t lldpGetMsapId(LldpDataUnit *lldpdu, LldpMsapId *msapId)
Extract MSAP identifier.
@ LLDP_TLV_TYPE_PORT_DESC
Port Description.
Forwarding database entry.
#define LLDP_MIN_PORT_ID_LEN
LldpDataUnit rxInfo
Remote system information.