lldp_ext_dot1.h
Go to the documentation of this file.
1 /**
2  * @file lldp_ext_dot1.h
3  * @brief IEEE 802.1 LLDP extension
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _LLDP_EXT_DOT1_H
32 #define _LLDP_EXT_DOT1_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "lldp/lldp.h"
37 
38 //Minimum length of VLAN name
39 #define LLDP_DOT1_MIN_VLAN_NAME_LEN 1
40 //Maximum length of VLAN name
41 #define LLDP_DOT1_MAX_VLAN_NAME_LEN 31
42 
43 //Minimum length of protocol identity
44 #define LLDP_DOT1_MIN_PROTOCOL_ID_LEN 1
45 //Maximum length of protocol identity
46 #define LLDP_DOT1_MAX_PROTOCOL_ID_LEN 255
47 
48 //C++ guard
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 
54 /**
55  * @brief IEEE 802.1 subtypes
56  **/
57 
58 typedef enum
59 {
60  LLDP_DOT1_SUBTYPE_RESERVED = 0, ///<Reserved
61  LLDP_DOT1_SUBTYPE_PORT_VLAN_ID = 1, ///<Port VLAN ID
62  LLDP_DOT1_SUBTYPE_PORT_PROTO_VLAN_ID = 2, ///<Port And Protocol VLAN ID
63  LLDP_DOT1_SUBTYPE_VLAN_NAME = 3, ///<VLAN Name
64  LLDP_DOT1_SUBTYPE_PROTOCOL_ID = 4 ///<Protocol Identity
66 
67 
68 /**
69  * @brief Port and protocol capability/status flags
70  **/
71 
72 typedef enum
73 {
75  LLDP_DOT1_PORT_PROTO_FLAG_SUPPORTED = 0x02, ///<Port and protocol VLAN supported
76  LLDP_DOT1_PORT_PROTO_FLAG_ENABLED = 0x04, ///<Port and protocol VLAN enabled
78 
79 
80 //CC-RX, CodeWarrior or Win32 compiler?
81 #if defined(__CCRX__)
82  #pragma pack
83 #elif defined(__CWCC__) || defined(_WIN32)
84  #pragma pack(push, 1)
85 #endif
86 
87 
88 /**
89  * @brief Port VLAN ID TLV
90  **/
91 
93 {
94  uint16_t pvid; //0-2
96 
97 
98 /**
99  * @brief Port And Protocol VLAN ID TLV
100  **/
101 
102 typedef __packed_struct
103 {
104  uint8_t flags; //0
105  uint16_t ppvid; //1-2
107 
108 
109 /**
110  * @brief VLAN Name TLV
111  **/
112 
113 typedef __packed_struct
114 {
115  uint16_t vlanId; //0
116  uint8_t vlanNameLen; //1
119 
120 
121 /**
122  * @brief Protocol Identity TLV
123  **/
124 
125 typedef __packed_struct
126 {
127  uint8_t protocolIdLen; //0
128  uint8_t protocolId[]; //1
130 
131 
132 //CC-RX, CodeWarrior or Win32 compiler?
133 #if defined(__CCRX__)
134  #pragma unpack
135 #elif defined(__CWCC__) || defined(_WIN32)
136  #pragma pack(pop)
137 #endif
138 
139 //IEEE 802.1 related functions
141  uint_t portIndex, uint16_t pvid);
142 
144  uint_t portIndex, uint8_t flags, uint16_t ppvid);
145 
147  uint_t portIndex, uint16_t vlanId, const char_t *vlanName);
148 
150  uint_t portIndex, const uint8_t *protocolId, size_t protocolIdLen);
151 
154 
155 //C++ guard
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif
unsigned int uint_t
Definition: compiler_port.h:50
char char_t
Definition: compiler_port.h:48
error_t
Error codes.
Definition: error.h:43
LLDP (Link Layer Discovery Protocol)
#define LldpAgentContext
Definition: lldp.h:40
uint8_t protocolId[]
uint16_t ppvid
error_t lldpDot1SetLocalPortProtoVlanId(LldpAgentContext *context, uint_t portIndex, uint8_t flags, uint16_t ppvid)
Set port and protocol VLAN ID.
char_t vlanName[]
error_t lldpDot1SetLocalVlanName(LldpAgentContext *context, uint_t portIndex, uint16_t vlanId, const char_t *vlanName)
Set VLAN name.
LldpDot1PortVlanIdTlv
Definition: lldp_ext_dot1.h:95
LldpDot1ProtocolIdTlv
LldpDot1VlanNameTlv
LldpDot1PortProtoFlags
Port and protocol capability/status flags.
Definition: lldp_ext_dot1.h:73
@ LLDP_DOT1_PORT_PROTO_FLAG_RESERVED
Reserved.
Definition: lldp_ext_dot1.h:74
@ LLDP_DOT1_PORT_PROTO_FLAG_ENABLED
Port and protocol VLAN enabled.
Definition: lldp_ext_dot1.h:76
@ LLDP_DOT1_PORT_PROTO_FLAG_SUPPORTED
Port and protocol VLAN supported.
Definition: lldp_ext_dot1.h:75
LldpDot1Subtype
IEEE 802.1 subtypes.
Definition: lldp_ext_dot1.h:59
@ LLDP_DOT1_SUBTYPE_PROTOCOL_ID
Protocol Identity.
Definition: lldp_ext_dot1.h:64
@ LLDP_DOT1_SUBTYPE_VLAN_NAME
VLAN Name.
Definition: lldp_ext_dot1.h:63
@ LLDP_DOT1_SUBTYPE_RESERVED
Reserved.
Definition: lldp_ext_dot1.h:60
@ LLDP_DOT1_SUBTYPE_PORT_PROTO_VLAN_ID
Port And Protocol VLAN ID.
Definition: lldp_ext_dot1.h:62
@ LLDP_DOT1_SUBTYPE_PORT_VLAN_ID
Port VLAN ID.
Definition: lldp_ext_dot1.h:61
uint8_t vlanNameLen
LldpDot1PortProtoVlanIdTlv
error_t lldpDot1SetLocalPortVlanId(LldpAgentContext *context, uint_t portIndex, uint16_t pvid)
Set port VLAN ID.
Definition: lldp_ext_dot1.c:54
typedef __packed_struct
Port VLAN ID TLV.
Definition: lldp_ext_dot1.h:93
error_t lldpDot1SetLocalProtocolId(LldpAgentContext *context, uint_t portIndex, const uint8_t *protocolId, size_t protocolIdLen)
Set protocol identity.
error_t lldpDot1DeleteLocalTlv(LldpAgentContext *context, LldpDot1Subtype subtype)
Remove all IEEE 802.1 specific TLVs with specified subtype.
uint8_t subtype
Definition: lldp_tlv.h:311
TCP/IP stack core.
uint8_t flags
Definition: tcp.h:351