lldp_ext_med.h
Go to the documentation of this file.
1 /**
2  * @file lldp_ext_med.h
3  * @brief LLDP-MED extension (LLDP for Media Endpoint Devices)
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_MED_H
32 #define _LLDP_EXT_MED_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "lldp/lldp.h"
37 
38 //Minimum length of hardware revision
39 #define LLDP_MED_MIN_INVENTORY_STRING_LEN 0
40 //Maximum length of hardware revision
41 #define LLDP_MED_MAX_INVENTORY_STRING_LEN 32
42 
43 //C++ guard
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 
49 /**
50  * @brief LLDP-MED subtypes
51  **/
52 
53 typedef enum
54 {
55  LLDP_MED_SUBTYPE_RESERVED = 0, ///<Reserved
56  LLDP_MED_SUBTYPE_LLDP_MED_CAP = 1, ///<LLDP-MED Capabilities
57  LLDP_MED_SUBTYPE_NETWORK_POLICY = 2, ///<Network Policy
58  LLDP_MED_SUBTYPE_LOCATION_ID = 3, ///<Location Identification
59  LLDP_MED_SUBTYPE_EXT_POWER_VIA_MDI = 4, ///<Extended Power-via-MDI
60  LLDP_MED_SUBTYPE_HARDWARE_REVISION = 5, ///<Inventory - Hardware Revision
61  LLDP_MED_SUBTYPE_FIRMWARE_REVISION = 6, ///<Inventory - Firmware Revision
62  LLDP_MED_SUBTYPE_SOFTWARE_REVISION = 7, ///<Inventory - Software Revision
63  LLDP_MED_SUBTYPE_SERIAL_NUMBER = 8, ///<Inventory - Serial Number
64  LLDP_MED_SUBTYPE_MANUFACTURER_NAME = 9, ///<Inventory - Manufacturer Name
65  LLDP_MED_SUBTYPE_MODEL_NAME = 10, ///<Inventory - Model Name
66  LLDP_MED_SUBTYPE_ASSET_ID = 11 ///<Inventory - Asset ID
68 
69 
70 /**
71  * @brief LLDP-MED capabilities
72  **/
73 
74 typedef enum
75 {
76  LLDP_MED_CAP = 0x0001, ///<LLDP-MED capabilities
77  LLDP_MED_CAP_NETWORK_POLICY = 0x0002, ///<Network policy
78  LLDP_MED_CAP_LOCATION = 0x0004, ///<Location identification
79  LLDP_MED_CAP_EXTENDED_PSE = 0x0008, ///<Extended power via MDI - PSE
80  LLDP_MED_CAP_EXTENDED_PD = 0x0010, ///<Extended power via MDI - PD
81  LLDP_MED_CAP_INVENTORY = 0x0020 ///<Inventory
83 
84 
85 /**
86  * @brief LLDP-MED device type
87  **/
88 
89 typedef enum
90 {
91  LLDP_MED_DEVICE_TYPE_NOT_DEFINED = 0, ///<Type not defined
92  LLDP_MED_DEVICE_TYPE_ENDPOINT_CLASS_1 = 1, ///<Endpoint class I
93  LLDP_MED_DEVICE_TYPE_ENDPOINT_CLASS_2 = 2, ///<Endpoint class II
94  LLDP_MED_DEVICE_TYPE_ENDPOINT_CLASS_3 = 3, ///<Endpoint class III
95  LLDP_MED_DEVICE_TYPE_NETWORK_CONNECTIVITY = 4 ///<Network connectivity
97 
98 
99 /**
100  * @brief Application type
101  **/
102 
103 typedef enum
104 {
105  LLDP_MED_APP_TYPE_RESERVED = 0, ///<Reserved
106  LLDP_MED_APP_TYPE_VOICE = 1, ///<Voice
107  LLDP_MED_APP_TYPE_VOICE_SIGNALING = 2, ///<Voice signaling
108  LLDP_MED_APP_TYPE_GUEST_VOICE = 3, ///<Guest Voice
109  LLDP_MED_APP_TYPE_GUEST_VOICE_SIGNALING = 4, ///<Guest Voice Signaling
110  LLDP_MED_APP_TYPE_SOFTPHONE_VOICE = 5, ///<Softphone Voice
111  LLDP_MED_APP_TYPE_VIDEO_CONFERENCING = 6, ///<Video Conferencing
112  LLDP_MED_APP_TYPE_STREAMING_VIDEO = 7, ///<Streaming Video
113  LLDP_MED_APP_TYPE_VIDEO_SIGNALING = 8 ///<Video signaling
115 
116 
117 /**
118  * @brief Location data format
119  **/
120 
121 typedef enum
122 {
124  LLDP_MED_LOCATION_DATA_FORMAT_COORD_BASED_LCI = 1, ///<Coordinate-based LCI
128 
129 
130 /**
131  * @brief Power type
132  **/
133 
134 typedef enum
135 {
136  LLDP_MED_POWER_TYPE_PSE_DEVICE = 0, ///<PSE Device
137  LLDP_MED_POWER_TYPE_PD_DEVICE = 1, ///<PD Device
139  LLDP_MED_POWER_TYPE_RESERVED_2 = 3 ///<Reserved
141 
142 
143 /**
144  * @brief Power source
145  **/
146 
147 typedef enum
148 {
149  LLDP_MED_PD_POWER_SOURCE_UNKNOWN = 0, ///<Unknown (PD device type)
150  LLDP_MED_PD_POWER_SOURCE_PSE = 1, ///<PSE (PD device type)
151  LLDP_MED_PD_POWER_SOURCE_LOCAL = 2, ///<Local (PD device type)
152  LLDP_MED_PD_POWER_SOURCE_PSE_AND_LOCAL = 3, ///<PSE and local (PD device type)
153  LLDP_MED_PSE_POWER_SOURCE_UNKNOWN = 0, ///<Unknown (PSE device type)
154  LLDP_MED_PSE_POWER_SOURCE_PRIMARY = 1, ///<Primary Power Source (PSE device type)
155  LLDP_MED_PSE_POWER_SOURCE_BACKUP = 2, ///<Backup Power Source (PSE device type)
156  LLDP_MED_PSE_POWER_SOURCE_RESERVED = 3 ///<Reserved (PSE device type)
158 
159 
160 /**
161  * @brief Power priority
162  **/
163 
164 typedef enum
165 {
169  LLDP_MED_POWER_PRIORITY_LOW = 3 ///<Low
171 
172 
173 //CC-RX, CodeWarrior or Win32 compiler?
174 #if defined(__CCRX__)
175  #pragma pack
176 #elif defined(__CWCC__) || defined(_WIN32)
177  #pragma pack(push, 1)
178 #endif
179 
180 
181 /**
182  * @brief LLDP-MED Capabilities TLV
183  **/
184 
186 {
187  uint16_t capabilities; //0-1
188  uint8_t deviceType; //2
190 
191 
192 /**
193  * @brief Network Policy TLV
194  **/
195 
196 typedef __packed_struct
197 {
198 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
199  uint8_t appType; //0
200  uint8_t u : 1; //1
201  uint8_t t : 1;
202  uint8_t x : 1;
203  uint8_t vlanIdH : 5;
204  uint8_t vlanIdL : 7; //2
205  uint8_t l2PriorityH : 1;
206  uint8_t l2PriorityL : 2; //3
207  uint8_t dscpValue : 6;
208 #else
209  uint8_t appType; //0
210  uint8_t vlanIdH : 5; //1
211  uint8_t x : 1;
212  uint8_t t : 1;
213  uint8_t u : 1;
214  uint8_t l2PriorityH : 1; //2
215  uint8_t vlanIdL : 7;
216  uint8_t dscpValue : 6; //3
217  uint8_t l2PriorityL : 2;
218 #endif
220 
221 
222 /**
223  * @brief Location Identification TLV
224  **/
225 
226 typedef __packed_struct
227 {
228  uint8_t locationDataFormat; //0-1
229  uint8_t locationId[]; //2
231 
232 
233 /**
234  * @brief Extended Power-Via-MDI TLV
235  **/
236 
237 typedef __packed_struct
238 {
239 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
240  uint8_t powerType : 2; //0
241  uint8_t powerSource : 2;
242  uint8_t powerPriority : 4;
243  uint16_t powerValue; //1-2
244 #else
245  uint8_t powerPriority : 4; //0
246  uint8_t powerSource : 2;
247  uint8_t powerType : 2;
248  uint16_t powerValue; //1-2
249 #endif
251 
252 
253 //CC-RX, CodeWarrior or Win32 compiler?
254 #if defined(__CCRX__)
255  #pragma unpack
256 #elif defined(__CWCC__) || defined(_WIN32)
257  #pragma pack(pop)
258 #endif
259 
260 //LLDP-MED related functions
261 error_t lldpMedSetLocalCap(LldpAgentContext *context, uint16_t capabilities,
263 
265  uint_t portIndex, LldpMedAppType appType, bool_t u, bool_t t,
266  uint16_t vlanId, uint8_t l2Priority, uint8_t dscpValue);
267 
269  uint_t portIndex, LldpMedLocationDataFormat locationDataFormat,
270  const void *locationId, size_t locationIdLen);
271 
274  LldpMedPowerPriority powerPriority, uint16_t powerValue);
275 
277  const char_t *hardwareRevision);
278 
280  const char_t *firmwareRevision);
281 
283  const char_t *softwareRevision);
284 
286  const char_t *serialNumber);
287 
289  const char_t *manufacturerName);
290 
292  const char_t *modelName);
293 
295  const char_t *assetId);
296 
299 
300 //C++ guard
301 #ifdef __cplusplus
302 }
303 #endif
304 
305 #endif
unsigned int uint_t
Definition: compiler_port.h:50
char char_t
Definition: compiler_port.h:48
int bool_t
Definition: compiler_port.h:53
error_t
Error codes.
Definition: error.h:43
LLDP (Link Layer Discovery Protocol)
#define LldpAgentContext
Definition: lldp.h:40
uint8_t u
Definition: lldp_ext_med.h:213
uint8_t x
Definition: lldp_ext_med.h:211
error_t lldpMedSetLocalHardwareRevision(LldpAgentContext *context, const char_t *hardwareRevision)
Set hardware revision.
Definition: lldp_ext_med.c:464
uint8_t vlanIdL
Definition: lldp_ext_med.h:215
LldpMedCap
LLDP-MED capabilities.
Definition: lldp_ext_med.h:75
@ LLDP_MED_CAP_NETWORK_POLICY
Network policy.
Definition: lldp_ext_med.h:77
@ LLDP_MED_CAP
LLDP-MED capabilities.
Definition: lldp_ext_med.h:76
@ LLDP_MED_CAP_INVENTORY
Inventory.
Definition: lldp_ext_med.h:81
@ LLDP_MED_CAP_EXTENDED_PSE
Extended power via MDI - PSE.
Definition: lldp_ext_med.h:79
@ LLDP_MED_CAP_EXTENDED_PD
Extended power via MDI - PD.
Definition: lldp_ext_med.h:80
@ LLDP_MED_CAP_LOCATION
Location identification.
Definition: lldp_ext_med.h:78
uint8_t t
Definition: lldp_ext_med.h:212
error_t lldpMedSetLocalCap(LldpAgentContext *context, uint16_t capabilities, LldpMedDeviceType deviceType)
Set LLDP-MED capabilities.
Definition: lldp_ext_med.c:54
uint8_t powerSource
Definition: lldp_ext_med.h:246
LldpMedAppType
Application type.
Definition: lldp_ext_med.h:104
@ LLDP_MED_APP_TYPE_VOICE_SIGNALING
Voice signaling.
Definition: lldp_ext_med.h:107
@ LLDP_MED_APP_TYPE_GUEST_VOICE_SIGNALING
Guest Voice Signaling.
Definition: lldp_ext_med.h:109
@ LLDP_MED_APP_TYPE_STREAMING_VIDEO
Streaming Video.
Definition: lldp_ext_med.h:112
@ LLDP_MED_APP_TYPE_RESERVED
Reserved.
Definition: lldp_ext_med.h:105
@ LLDP_MED_APP_TYPE_GUEST_VOICE
Guest Voice.
Definition: lldp_ext_med.h:108
@ LLDP_MED_APP_TYPE_VIDEO_CONFERENCING
Video Conferencing.
Definition: lldp_ext_med.h:111
@ LLDP_MED_APP_TYPE_SOFTPHONE_VOICE
Softphone Voice.
Definition: lldp_ext_med.h:110
@ LLDP_MED_APP_TYPE_VOICE
Voice.
Definition: lldp_ext_med.h:106
@ LLDP_MED_APP_TYPE_VIDEO_SIGNALING
Video signaling.
Definition: lldp_ext_med.h:113
LldpMedNetworkPolicyTlv
Definition: lldp_ext_med.h:219
LldpMedPowerPriority
Power priority.
Definition: lldp_ext_med.h:165
@ LLDP_MED_POWER_PRIORITY_HIGH
High.
Definition: lldp_ext_med.h:168
@ LLDP_MED_POWER_PRIORITY_CRITICAL
Critical.
Definition: lldp_ext_med.h:167
@ LLDP_MED_POWER_PRIORITY_UNKNOWN
Unknown.
Definition: lldp_ext_med.h:166
@ LLDP_MED_POWER_PRIORITY_LOW
Low.
Definition: lldp_ext_med.h:169
uint8_t l2PriorityL
Definition: lldp_ext_med.h:217
error_t lldpMedSetLocalFirmwareRevision(LldpAgentContext *context, const char_t *firmwareRevision)
Set firmware revision.
Definition: lldp_ext_med.c:518
error_t lldpMedSetLocalManufacturerName(LldpAgentContext *context, const char_t *manufacturerName)
Set manufacturer name.
Definition: lldp_ext_med.c:679
uint8_t l2PriorityH
Definition: lldp_ext_med.h:214
LldpMedLocationIdTlv
Definition: lldp_ext_med.h:230
uint8_t vlanIdH
Definition: lldp_ext_med.h:210
uint8_t deviceType
Definition: lldp_ext_med.h:188
uint16_t powerValue
Definition: lldp_ext_med.h:248
error_t lldpMedSetLocalSerialNumber(LldpAgentContext *context, const char_t *serialNumber)
Set serial number.
Definition: lldp_ext_med.c:626
LldpMedSubtype
LLDP-MED subtypes.
Definition: lldp_ext_med.h:54
@ LLDP_MED_SUBTYPE_FIRMWARE_REVISION
Inventory - Firmware Revision.
Definition: lldp_ext_med.h:61
@ LLDP_MED_SUBTYPE_HARDWARE_REVISION
Inventory - Hardware Revision.
Definition: lldp_ext_med.h:60
@ LLDP_MED_SUBTYPE_ASSET_ID
Inventory - Asset ID.
Definition: lldp_ext_med.h:66
@ LLDP_MED_SUBTYPE_SOFTWARE_REVISION
Inventory - Software Revision.
Definition: lldp_ext_med.h:62
@ LLDP_MED_SUBTYPE_NETWORK_POLICY
Network Policy.
Definition: lldp_ext_med.h:57
@ LLDP_MED_SUBTYPE_SERIAL_NUMBER
Inventory - Serial Number.
Definition: lldp_ext_med.h:63
@ LLDP_MED_SUBTYPE_LLDP_MED_CAP
LLDP-MED Capabilities.
Definition: lldp_ext_med.h:56
@ LLDP_MED_SUBTYPE_EXT_POWER_VIA_MDI
Extended Power-via-MDI.
Definition: lldp_ext_med.h:59
@ LLDP_MED_SUBTYPE_MODEL_NAME
Inventory - Model Name.
Definition: lldp_ext_med.h:65
@ LLDP_MED_SUBTYPE_LOCATION_ID
Location Identification.
Definition: lldp_ext_med.h:58
@ LLDP_MED_SUBTYPE_RESERVED
Reserved.
Definition: lldp_ext_med.h:55
@ LLDP_MED_SUBTYPE_MANUFACTURER_NAME
Inventory - Manufacturer Name.
Definition: lldp_ext_med.h:64
error_t lldpMedSetLocalLocationId(LldpAgentContext *context, uint_t portIndex, LldpMedLocationDataFormat locationDataFormat, const void *locationId, size_t locationIdLen)
Set location identification.
Definition: lldp_ext_med.c:243
error_t lldpMedSetLocalModelName(LldpAgentContext *context, const char_t *modelName)
Set model name.
Definition: lldp_ext_med.c:733
LldpMedLocationDataFormat
Location data format.
Definition: lldp_ext_med.h:122
@ LLDP_MED_LOCATION_DATA_FORMAT_COORD_BASED_LCI
Coordinate-based LCI.
Definition: lldp_ext_med.h:124
@ LLDP_MED_LOCATION_DATA_FORMAT_ECS_ELIN
ECS ELIN.
Definition: lldp_ext_med.h:126
@ LLDP_MED_LOCATION_DATA_FORMAT_CIVIC_ADDR_LCI
Civic Address LCI.
Definition: lldp_ext_med.h:125
@ LLDP_MED_LOCATION_DATA_FORMAT_INVALID
Invalid.
Definition: lldp_ext_med.h:123
error_t lldpMedDeleteLocalTlv(LldpAgentContext *context, LldpMedSubtype subtype)
Remove all LLDP-MED specific TLVs with specified subtype.
Definition: lldp_ext_med.c:838
error_t lldpMedSetLocalExtPowerViaMdi(LldpAgentContext *context, uint_t portIndex, LldpMedPowerType powerType, LldpMedPowerSource powerSource, LldpMedPowerPriority powerPriority, uint16_t powerValue)
Set extended power-via-MDI.
Definition: lldp_ext_med.c:393
uint8_t locationId[]
Definition: lldp_ext_med.h:229
LldpMedCapTlv
Definition: lldp_ext_med.h:189
error_t lldpMedSetLocalAssetId(LldpAgentContext *context, const char_t *assetId)
Set asset identifier.
Definition: lldp_ext_med.c:786
LldpMedPowerType
Power type.
Definition: lldp_ext_med.h:135
@ LLDP_MED_POWER_TYPE_RESERVED_2
Reserved.
Definition: lldp_ext_med.h:139
@ LLDP_MED_POWER_TYPE_RESERVED_1
Reserved.
Definition: lldp_ext_med.h:138
@ LLDP_MED_POWER_TYPE_PSE_DEVICE
PSE Device.
Definition: lldp_ext_med.h:136
@ LLDP_MED_POWER_TYPE_PD_DEVICE
PD Device.
Definition: lldp_ext_med.h:137
LldpMedDeviceType
LLDP-MED device type.
Definition: lldp_ext_med.h:90
@ LLDP_MED_DEVICE_TYPE_ENDPOINT_CLASS_2
Endpoint class II.
Definition: lldp_ext_med.h:93
@ LLDP_MED_DEVICE_TYPE_NETWORK_CONNECTIVITY
Network connectivity.
Definition: lldp_ext_med.h:95
@ LLDP_MED_DEVICE_TYPE_NOT_DEFINED
Type not defined.
Definition: lldp_ext_med.h:91
@ LLDP_MED_DEVICE_TYPE_ENDPOINT_CLASS_1
Endpoint class I.
Definition: lldp_ext_med.h:92
@ LLDP_MED_DEVICE_TYPE_ENDPOINT_CLASS_3
Endpoint class III.
Definition: lldp_ext_med.h:94
LldpMedPowerSource
Power source.
Definition: lldp_ext_med.h:148
@ LLDP_MED_PSE_POWER_SOURCE_RESERVED
Reserved (PSE device type)
Definition: lldp_ext_med.h:156
@ LLDP_MED_PD_POWER_SOURCE_UNKNOWN
Unknown (PD device type)
Definition: lldp_ext_med.h:149
@ LLDP_MED_PD_POWER_SOURCE_LOCAL
Local (PD device type)
Definition: lldp_ext_med.h:151
@ LLDP_MED_PSE_POWER_SOURCE_PRIMARY
Primary Power Source (PSE device type)
Definition: lldp_ext_med.h:154
@ LLDP_MED_PSE_POWER_SOURCE_UNKNOWN
Unknown (PSE device type)
Definition: lldp_ext_med.h:153
@ LLDP_MED_PD_POWER_SOURCE_PSE_AND_LOCAL
PSE and local (PD device type)
Definition: lldp_ext_med.h:152
@ LLDP_MED_PSE_POWER_SOURCE_BACKUP
Backup Power Source (PSE device type)
Definition: lldp_ext_med.h:155
@ LLDP_MED_PD_POWER_SOURCE_PSE
PSE (PD device type)
Definition: lldp_ext_med.h:150
typedef __packed_struct
LLDP-MED Capabilities TLV.
Definition: lldp_ext_med.h:186
uint8_t dscpValue
Definition: lldp_ext_med.h:216
LldpMedExtPowerViaMdiTlv
Definition: lldp_ext_med.h:250
error_t lldpMedSetLocalSoftwareRevision(LldpAgentContext *context, const char_t *softwareRevision)
Set software revision.
Definition: lldp_ext_med.c:572
error_t lldpMedSetLocalNetworkPolicy(LldpAgentContext *context, uint_t portIndex, LldpMedAppType appType, bool_t u, bool_t t, uint16_t vlanId, uint8_t l2Priority, uint8_t dscpValue)
Set network policy.
Definition: lldp_ext_med.c:116
uint8_t powerType
Definition: lldp_ext_med.h:247
uint8_t subtype
Definition: lldp_tlv.h:311
TCP/IP stack core.