TLV parsing and formatting. More...
Go to the source code of this file.
Data Structures | |
struct | LldpTlv |
TLV structure. More... | |
Macros | |
#define | LLDP_OUI_SIZE 3 |
#define | LLDP_MAX_TLV_INFO_LEN 511 |
#define | LLDP_MAX_ORG_SPECIFIC_INFO_LEN 507 |
#define | LLDP_MIN_CHASSIS_ID_LEN 1 |
#define | LLDP_MAX_CHASSIS_ID_LEN 255 |
#define | LLDP_MIN_PORT_ID_LEN 1 |
#define | LLDP_MAX_PORT_ID_LEN 255 |
#define | LLDP_MIN_PORT_DESC_LEN 1 |
#define | LLDP_MAX_PORT_DESC_LEN 255 |
#define | LLDP_MIN_SYS_NAME_LEN 1 |
#define | LLDP_MAX_SYS_NAME_LEN 255 |
#define | LLDP_MIN_SYS_DESC_LEN 1 |
#define | LLDP_MAX_SYS_DESC_LEN 255 |
#define | LLDP_MIN_MGMT_ADDR_LEN 1 |
#define | LLDP_MAX_MGMT_ADDR_LEN 31 |
#define | LLDP_MIN_OID_LEN 0 |
#define | LLDP_MAX_OID_LEN 128 |
Functions | |
error_t | lldpSetTlv (LldpDataUnit *lldpdu, uint8_t type, uint_t index, const uint8_t *value, size_t length, bool_t replace) |
Add or replace a TLV. More... | |
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. More... | |
error_t | lldpGetFirstTlv (LldpDataUnit *lldpdu, LldpTlv *tlv) |
Extract the first TLV from an LLDPDU. More... | |
error_t | lldpGetNextTlv (LldpDataUnit *lldpdu, LldpTlv *tlv) |
Extract the next TLV from an LLDPDU. More... | |
error_t | lldpDeleteTlv (LldpDataUnit *lldpdu, uint8_t type, uint_t index) |
Remove a TLV from a LLDPDU. More... | |
error_t | lldpDecodeMgmtAddrTlv (const uint8_t *value, size_t length, const LldpMgmtAddrTlv1 **mgmtAddr1, const LldpMgmtAddrTlv2 **mgmtAddr2) |
Decode the contents of a Management Address TLV. More... | |
error_t | lldpSetOrgDefTlv (LldpDataUnit *lldpdu, uint32_t oui, uint8_t subtype, uint_t index, const uint8_t *value, size_t length, bool_t replace) |
Add or replace an organizationally specific TLV. More... | |
error_t | lldpGetOrgDefTlv (LldpDataUnit *lldpdu, uint32_t oui, uint8_t subtype, uint_t index, const uint8_t **value, size_t *length) |
Search an LLDPDU for an organizationally specific TLV. More... | |
error_t | lldpDeleteOrgDefTlv (LldpDataUnit *lldpdu, uint32_t oui, uint8_t subtype, uint_t index) |
Remove an organizationally specific TLV from a LLDPDU. More... | |
Variables | |
typedef | __packed_struct |
TLV header. More... | |
uint8_t | type |
uint8_t | lengthL |
uint8_t | value [] |
LldpTlvHeader | |
uint8_t | chassisId [] |
LldpChassisIdTlv | |
uint8_t | portId [] |
LldpPortIdTlv | |
LldpTimeToLiveTlv | |
uint16_t | enabledCap |
LldpSysCapTlv | |
uint8_t | mgmtAddrSubtype |
uint8_t | mgmtAddr [] |
LldpMgmtAddrTlv1 | |
uint32_t | ifNum |
uint8_t | oidLen |
uint8_t | oid [] |
LldpMgmtAddrTlv2 | |
uint8_t | subtype |
LldpOrgDefTlv | |
Detailed Description
TLV parsing and formatting.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.4.4
Definition in file lldp_tlv.h.
Macro Definition Documentation
◆ LLDP_MAX_CHASSIS_ID_LEN
#define LLDP_MAX_CHASSIS_ID_LEN 255 |
Definition at line 49 of file lldp_tlv.h.
◆ LLDP_MAX_MGMT_ADDR_LEN
#define LLDP_MAX_MGMT_ADDR_LEN 31 |
Definition at line 74 of file lldp_tlv.h.
◆ LLDP_MAX_OID_LEN
#define LLDP_MAX_OID_LEN 128 |
Definition at line 79 of file lldp_tlv.h.
◆ LLDP_MAX_ORG_SPECIFIC_INFO_LEN
#define LLDP_MAX_ORG_SPECIFIC_INFO_LEN 507 |
Definition at line 44 of file lldp_tlv.h.
◆ LLDP_MAX_PORT_DESC_LEN
#define LLDP_MAX_PORT_DESC_LEN 255 |
Definition at line 59 of file lldp_tlv.h.
◆ LLDP_MAX_PORT_ID_LEN
#define LLDP_MAX_PORT_ID_LEN 255 |
Definition at line 54 of file lldp_tlv.h.
◆ LLDP_MAX_SYS_DESC_LEN
#define LLDP_MAX_SYS_DESC_LEN 255 |
Definition at line 69 of file lldp_tlv.h.
◆ LLDP_MAX_SYS_NAME_LEN
#define LLDP_MAX_SYS_NAME_LEN 255 |
Definition at line 64 of file lldp_tlv.h.
◆ LLDP_MAX_TLV_INFO_LEN
#define LLDP_MAX_TLV_INFO_LEN 511 |
Definition at line 42 of file lldp_tlv.h.
◆ LLDP_MIN_CHASSIS_ID_LEN
#define LLDP_MIN_CHASSIS_ID_LEN 1 |
Definition at line 47 of file lldp_tlv.h.
◆ LLDP_MIN_MGMT_ADDR_LEN
#define LLDP_MIN_MGMT_ADDR_LEN 1 |
Definition at line 72 of file lldp_tlv.h.
◆ LLDP_MIN_OID_LEN
#define LLDP_MIN_OID_LEN 0 |
Definition at line 77 of file lldp_tlv.h.
◆ LLDP_MIN_PORT_DESC_LEN
#define LLDP_MIN_PORT_DESC_LEN 1 |
Definition at line 57 of file lldp_tlv.h.
◆ LLDP_MIN_PORT_ID_LEN
#define LLDP_MIN_PORT_ID_LEN 1 |
Definition at line 52 of file lldp_tlv.h.
◆ LLDP_MIN_SYS_DESC_LEN
#define LLDP_MIN_SYS_DESC_LEN 1 |
Definition at line 67 of file lldp_tlv.h.
◆ LLDP_MIN_SYS_NAME_LEN
#define LLDP_MIN_SYS_NAME_LEN 1 |
Definition at line 62 of file lldp_tlv.h.
◆ LLDP_OUI_SIZE
#define LLDP_OUI_SIZE 3 |
Definition at line 39 of file lldp_tlv.h.
Enumeration Type Documentation
◆ LldpChassisIdSubtype
enum LldpChassisIdSubtype |
Chassis ID subtypes.
Definition at line 110 of file lldp_tlv.h.
◆ LldpIfNumSubtype
enum LldpIfNumSubtype |
Interface numbering subtypes.
Enumerator | |
---|---|
LLDP_IF_NUM_SUBTYPE_UNKNOWN | Unknown. |
LLDP_IF_NUM_SUBTYPE_IF_INDEX | Interface index. |
LLDP_IF_NUM_SUBTYPE_SYS_PORT_NUM | System port number. |
Definition at line 174 of file lldp_tlv.h.
◆ LldpMgmtAddrSubtype
enum LldpMgmtAddrSubtype |
Management address subtypes.
Enumerator | |
---|---|
LLDP_MGMT_ADDR_SUBTYPE_OTHER | Other. |
LLDP_MGMT_ADDR_SUBTYPE_IPV4 | IPv4 address. |
LLDP_MGMT_ADDR_SUBTYPE_IPV6 | IPv6 address. |
LLDP_MGMT_ADDR_SUBTYPE_ALL_802 | MAC address. |
Definition at line 161 of file lldp_tlv.h.
◆ LldpOui
enum LldpOui |
Organizationally unique identifiers.
Enumerator | |
---|---|
LLDP_DOT1_OUI | IEEE 802.1. |
LLDP_DOT3_OUI | IEEE 802.3. |
LLDP_MED_OUI | LLDP-MED. |
LLDP_PNO_OUI | PROFIBUS. |
Definition at line 186 of file lldp_tlv.h.
◆ LldpPortIdSubtype
enum LldpPortIdSubtype |
Port ID subtypes.
Definition at line 127 of file lldp_tlv.h.
◆ LldpSysCap
enum LldpSysCap |
System capabilities.
Definition at line 144 of file lldp_tlv.h.
◆ LldpTlvType
enum LldpTlvType |
TLV type values.
Definition at line 91 of file lldp_tlv.h.
Function Documentation
◆ lldpDecodeMgmtAddrTlv()
error_t lldpDecodeMgmtAddrTlv | ( | const uint8_t * | value, |
size_t | length, | ||
const LldpMgmtAddrTlv1 ** | mgmtAddr1, | ||
const LldpMgmtAddrTlv2 ** | mgmtAddr2 | ||
) |
Decode the contents of a Management Address TLV.
- Parameters
-
[in] value Pointer to the TLV value to decode [in] length Length of the TLV value, in bytes [out] mgmtAddr1 First part of the Management Address TLV [out] mgmtAddr2 Second part of the Management Address TLV
- Returns
- Error code
Definition at line 380 of file lldp_tlv.c.
◆ lldpDeleteOrgDefTlv()
error_t lldpDeleteOrgDefTlv | ( | LldpDataUnit * | lldpdu, |
uint32_t | oui, | ||
uint8_t | subtype, | ||
uint_t | index | ||
) |
Remove an organizationally specific TLV from a LLDPDU.
- Parameters
-
[in] lldpdu Pointer to the LLDP data unit [in] oui Organizationally unique identifier [in] subtype Organizationally defined subtype [in] index TLV occurrence index
- Returns
- Error code
Definition at line 719 of file lldp_tlv.c.
◆ lldpDeleteTlv()
error_t lldpDeleteTlv | ( | LldpDataUnit * | lldpdu, |
uint8_t | type, | ||
uint_t | index | ||
) |
Remove a TLV from a LLDPDU.
- Parameters
-
[in] lldpdu Pointer to the LLDP data unit [in] type TLV type [in] index TLV occurrence index
- Returns
- Error code
Definition at line 320 of file lldp_tlv.c.
◆ lldpGetFirstTlv()
error_t lldpGetFirstTlv | ( | LldpDataUnit * | lldpdu, |
LldpTlv * | tlv | ||
) |
Extract the first TLV from an LLDPDU.
- Parameters
-
[in] lldpdu Pointer to the LLDP data unit [out] tlv Next TLV
- Returns
- Error code
Definition at line 247 of file lldp_tlv.c.
◆ lldpGetNextTlv()
error_t lldpGetNextTlv | ( | LldpDataUnit * | lldpdu, |
LldpTlv * | tlv | ||
) |
Extract the next TLV from an LLDPDU.
- Parameters
-
[in] lldpdu Pointer to the LLDP data unit [out] tlv Next TLV
- Returns
- Error code
Definition at line 264 of file lldp_tlv.c.
◆ lldpGetOrgDefTlv()
error_t lldpGetOrgDefTlv | ( | LldpDataUnit * | lldpdu, |
uint32_t | oui, | ||
uint8_t | subtype, | ||
uint_t | index, | ||
const uint8_t ** | value, | ||
size_t * | length | ||
) |
Search an LLDPDU for an organizationally specific TLV.
- Parameters
-
[in] lldpdu Pointer to the LLDP data unit [in] oui Organizationally unique identifier [in] subtype Organizationally defined subtype [in] index TLV occurrence index [out] value Organizationally defined information string [out] length Length of the information string, in bytes
- Returns
- Error code
Definition at line 651 of file lldp_tlv.c.
◆ lldpGetTlv()
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.
- Parameters
-
[in] lldpdu Pointer to the LLDP data unit [in] type TLV type [in] index TLV occurrence index [out] value TLV information string [out] length Length of the information string, in bytes
- Returns
- Error code
Definition at line 200 of file lldp_tlv.c.
◆ lldpSetOrgDefTlv()
error_t lldpSetOrgDefTlv | ( | LldpDataUnit * | lldpdu, |
uint32_t | oui, | ||
uint8_t | subtype, | ||
uint_t | index, | ||
const uint8_t * | value, | ||
size_t | length, | ||
bool_t | replace | ||
) |
Add or replace an organizationally specific TLV.
- Parameters
-
[in] lldpdu Pointer to the LLDP data unit [in] oui Organizationally unique identifier [in] subtype Organizationally defined subtype [in] index TLV occurrence index [in] value Organizationally defined information string [in] length Length of the information string, in bytes [in] replace Replace the existing TLV if a match is found
- Returns
- Error code
Definition at line 452 of file lldp_tlv.c.
◆ lldpSetTlv()
error_t lldpSetTlv | ( | LldpDataUnit * | lldpdu, |
uint8_t | type, | ||
uint_t | index, | ||
const uint8_t * | value, | ||
size_t | length, | ||
bool_t | replace | ||
) |
Add or replace a TLV.
- Parameters
-
[in] lldpdu Pointer to the LLDP data unit [in] type TLV type [in] index TLV occurrence index [in] value TLV information string [in] length Length of the information string, in bytes [in] replace Replace the existing TLV if a match is found
- Returns
- Error code
Definition at line 56 of file lldp_tlv.c.
Variable Documentation
◆ __packed_struct
typedef __packed_struct |
TLV header.
Organizationally Specific TLV.
Management Address TLV (part 2)
Management Address TLV (part 1)
System Capabilities TLV.
Time To Live TLV.
Port ID TLV.
Chassis ID TLV.
Definition at line 220 of file lldp_tlv.h.
◆ chassisId
uint8_t chassisId[] |
Definition at line 243 of file lldp_tlv.h.
◆ enabledCap
uint16_t enabledCap |
Definition at line 275 of file lldp_tlv.h.
◆ ifNum
uint32_t ifNum |
Definition at line 298 of file lldp_tlv.h.
◆ lengthL
uint8_t lengthL |
Definition at line 230 of file lldp_tlv.h.
◆ LldpChassisIdTlv
LldpChassisIdTlv |
Definition at line 244 of file lldp_tlv.h.
◆ LldpMgmtAddrTlv1
LldpMgmtAddrTlv1 |
Definition at line 288 of file lldp_tlv.h.
◆ LldpMgmtAddrTlv2
LldpMgmtAddrTlv2 |
Definition at line 301 of file lldp_tlv.h.
◆ LldpOrgDefTlv
LldpOrgDefTlv |
Definition at line 313 of file lldp_tlv.h.
◆ LldpPortIdTlv
LldpPortIdTlv |
Definition at line 255 of file lldp_tlv.h.
◆ LldpSysCapTlv
LldpSysCapTlv |
Definition at line 276 of file lldp_tlv.h.
◆ LldpTimeToLiveTlv
LldpTimeToLiveTlv |
Definition at line 265 of file lldp_tlv.h.
◆ LldpTlvHeader
LldpTlvHeader |
Definition at line 233 of file lldp_tlv.h.
◆ mgmtAddr
uint8_t mgmtAddr[] |
Definition at line 287 of file lldp_tlv.h.
◆ mgmtAddrSubtype
uint8_t mgmtAddrSubtype |
Definition at line 286 of file lldp_tlv.h.
◆ oid
uint8_t oid[] |
Definition at line 300 of file lldp_tlv.h.
◆ oidLen
uint8_t oidLen |
Definition at line 299 of file lldp_tlv.h.
◆ portId
uint8_t portId[] |
Definition at line 254 of file lldp_tlv.h.
◆ subtype
uint8_t subtype |
Definition at line 311 of file lldp_tlv.h.
◆ type
uint8_t type |
Definition at line 229 of file lldp_tlv.h.
◆ value
uint8_t value[] |
Definition at line 231 of file lldp_tlv.h.