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-2023 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.2.4
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 //CodeWarrior or Win32 compiler?
81 #if defined(__CWCC__) || defined(_WIN32)
82  #pragma pack(push, 1)
83 #endif
84 
85 
86 /**
87  * @brief Port VLAN ID TLV
88  **/
89 
90 typedef __start_packed struct
91 {
92  uint16_t pvid; //0-2
94 
95 
96 /**
97  * @brief Port And Protocol VLAN ID TLV
98  **/
99 
100 typedef __start_packed struct
101 {
102  uint8_t flags; //0
103  uint16_t ppvid; //1-2
105 
106 
107 /**
108  * @brief VLAN Name TLV
109  **/
110 
111 typedef __start_packed struct
112 {
113  uint16_t vlanId; //0
114  uint8_t vlanNameLen; //1
117 
118 
119 /**
120  * @brief Protocol Identity TLV
121  **/
122 
123 typedef __start_packed struct
124 {
125  uint8_t protocolIdLen; //0
126  uint8_t protocolId[]; //1
128 
129 
130 //CodeWarrior or Win32 compiler?
131 #if defined(__CWCC__) || defined(_WIN32)
132  #pragma pack(pop)
133 #endif
134 
135 //IEEE 802.1 related functions
137  uint_t portIndex, uint16_t pvid);
138 
140  uint_t portIndex, uint8_t flags, uint16_t ppvid);
141 
143  uint_t portIndex, uint16_t vlanId, const char_t *vlanName);
144 
146  uint_t portIndex, const uint8_t *protocolId, size_t protocolIdLen);
147 
150 
151 //C++ guard
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif
uint8_t protocolId[]
error_t lldpDot1SetLocalPortVlanId(LldpAgentContext *context, uint_t portIndex, uint16_t pvid)
Set port VLAN ID.
Definition: lldp_ext_dot1.c:54
uint16_t vlanId
@ LLDP_DOT1_SUBTYPE_PORT_PROTO_VLAN_ID
Port And Protocol VLAN ID.
Definition: lldp_ext_dot1.h:62
__start_packed struct @1 LldpDot1PortProtoVlanIdTlv
Port And Protocol VLAN ID TLV.
char_t vlanName[]
@ LLDP_DOT1_SUBTYPE_RESERVED
Reserved.
Definition: lldp_ext_dot1.h:60
error_t lldpDot1SetLocalPortProtoVlanId(LldpAgentContext *context, uint_t portIndex, uint8_t flags, uint16_t ppvid)
Set port and protocol VLAN ID.
@ LLDP_DOT1_PORT_PROTO_FLAG_SUPPORTED
Port and protocol VLAN supported.
Definition: lldp_ext_dot1.h:75
error_t
Error codes.
Definition: error.h:43
uint8_t protocolIdLen
@ LLDP_DOT1_SUBTYPE_PORT_VLAN_ID
Port VLAN ID.
Definition: lldp_ext_dot1.h:61
@ LLDP_DOT1_PORT_PROTO_FLAG_RESERVED
Reserved.
Definition: lldp_ext_dot1.h:74
__start_packed struct @2 LldpDot1VlanNameTlv
VLAN Name TLV.
__start_packed struct _Ipv4Header __end_packed
__start_packed struct @3 LldpDot1ProtocolIdTlv
Protocol Identity TLV.
LldpDot1Subtype
IEEE 802.1 subtypes.
Definition: lldp_ext_dot1.h:59
uint8_t subtype
Definition: lldp_tlv.h:309
char char_t
Definition: compiler_port.h:48
uint16_t ppvid
LldpDot1PortProtoFlags
Port and protocol capability/status flags.
Definition: lldp_ext_dot1.h:73
#define LldpAgentContext
Definition: lldp.h:40
@ LLDP_DOT1_SUBTYPE_VLAN_NAME
VLAN Name.
Definition: lldp_ext_dot1.h:63
uint8_t vlanNameLen
__start_packed struct @0 LldpDot1PortVlanIdTlv
Port VLAN ID TLV.
error_t lldpDot1SetLocalProtocolId(LldpAgentContext *context, uint_t portIndex, const uint8_t *protocolId, size_t protocolIdLen)
Set protocol identity.
@ LLDP_DOT1_PORT_PROTO_FLAG_ENABLED
Port and protocol VLAN enabled.
Definition: lldp_ext_dot1.h:76
@ LLDP_DOT1_SUBTYPE_PROTOCOL_ID
Protocol Identity.
Definition: lldp_ext_dot1.h:64
error_t lldpDot1SetLocalVlanName(LldpAgentContext *context, uint_t portIndex, uint16_t vlanId, const char_t *vlanName)
Set VLAN name.
LLDP (Link Layer Discovery Protocol)
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
uint8_t flags
uint16_t pvid
Definition: lldp_ext_dot1.h:92
error_t lldpDot1DeleteLocalTlv(LldpAgentContext *context, LldpDot1Subtype subtype)
Remove all IEEE 802.1 specific TLVs with specified subtype.