lldp_tlv.c File Reference

TLV parsing and formatting. More...

#include "core/net.h"
#include "lldp/lldp.h"
#include "lldp/lldp_tlv.h"
#include "lldp/lldp_debug.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   LLDP_TRACE_LEVEL
 

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...
 

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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file lldp_tlv.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   LLDP_TRACE_LEVEL

Definition at line 32 of file lldp_tlv.c.

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]valuePointer to the TLV value to decode
[in]lengthLength of the TLV value, in bytes
[out]mgmtAddr1First part of the Management Address TLV
[out]mgmtAddr2Second 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]lldpduPointer to the LLDP data unit
[in]ouiOrganizationally unique identifier
[in]subtypeOrganizationally defined subtype
[in]indexTLV 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]lldpduPointer to the LLDP data unit
[in]typeTLV type
[in]indexTLV 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]lldpduPointer to the LLDP data unit
[out]tlvNext 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]lldpduPointer to the LLDP data unit
[out]tlvNext 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]lldpduPointer to the LLDP data unit
[in]ouiOrganizationally unique identifier
[in]subtypeOrganizationally defined subtype
[in]indexTLV occurrence index
[out]valueOrganizationally defined information string
[out]lengthLength 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]lldpduPointer to the LLDP data unit
[in]typeTLV type
[in]indexTLV occurrence index
[out]valueTLV information string
[out]lengthLength 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]lldpduPointer to the LLDP data unit
[in]ouiOrganizationally unique identifier
[in]subtypeOrganizationally defined subtype
[in]indexTLV occurrence index
[in]valueOrganizationally defined information string
[in]lengthLength of the information string, in bytes
[in]replaceReplace 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]lldpduPointer to the LLDP data unit
[in]typeTLV type
[in]indexTLV occurrence index
[in]valueTLV information string
[in]lengthLength of the information string, in bytes
[in]replaceReplace the existing TLV if a match is found
Returns
Error code

Definition at line 56 of file lldp_tlv.c.