2 * Copyright (c) 1998-2007 The TCPDUMP project
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that: (1) source code
6 * distributions retain the above copyright notice and this paragraph
7 * in its entirety, and (2) distributions including binary code include
8 * the above copyright notice and this paragraph in its entirety in
9 * the documentation or other materials provided with the distribution.
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13 * FOR A PARTICULAR PURPOSE.
15 * support for the IEEE Link Discovery Protocol as per 802.1AB
17 * Original code by Hannes Gredler (hannes@juniper.net)
18 * IEEE and TIA extensions by Carles Kishimoto <carles.kishimoto@gmail.com>
19 * DCBX extensions by Kaladhar Musunuru <kaladharm@sourceforge.net>
23 static const char rcsid
[] _U_
=
24 "@(#) $Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.10 2008-03-20 09:30:56 hannes Exp $";
31 #include <tcpdump-stdinc.h>
37 #include "interface.h"
39 #include "addrtoname.h"
43 #define LLDP_EXTRACT_TYPE(x) (((x)&0xfe00)>>9)
44 #define LLDP_EXTRACT_LEN(x) ((x)&0x01ff)
49 #define LLDP_END_TLV 0
50 #define LLDP_CHASSIS_ID_TLV 1
51 #define LLDP_PORT_ID_TLV 2
52 #define LLDP_TTL_TLV 3
53 #define LLDP_PORT_DESCR_TLV 4
54 #define LLDP_SYSTEM_NAME_TLV 5
55 #define LLDP_SYSTEM_DESCR_TLV 6
56 #define LLDP_SYSTEM_CAP_TLV 7
57 #define LLDP_MGMT_ADDR_TLV 8
58 #define LLDP_PRIVATE_TLV 127
60 static const struct tok lldp_tlv_values
[] = {
61 { LLDP_END_TLV
, "End" },
62 { LLDP_CHASSIS_ID_TLV
, "Chassis ID" },
63 { LLDP_PORT_ID_TLV
, "Port ID" },
64 { LLDP_TTL_TLV
, "Time to Live" },
65 { LLDP_PORT_DESCR_TLV
, "Port Description" },
66 { LLDP_SYSTEM_NAME_TLV
, "System Name" },
67 { LLDP_SYSTEM_DESCR_TLV
, "System Description" },
68 { LLDP_SYSTEM_CAP_TLV
, "System Capabilities" },
69 { LLDP_MGMT_ADDR_TLV
, "Management Address" },
70 { LLDP_PRIVATE_TLV
, "Organization specific" },
77 #define LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE 1
78 #define LLDP_CHASSIS_INTF_ALIAS_SUBTYPE 2
79 #define LLDP_CHASSIS_PORT_COMP_SUBTYPE 3
80 #define LLDP_CHASSIS_MAC_ADDR_SUBTYPE 4
81 #define LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE 5
82 #define LLDP_CHASSIS_INTF_NAME_SUBTYPE 6
83 #define LLDP_CHASSIS_LOCAL_SUBTYPE 7
85 static const struct tok lldp_chassis_subtype_values
[] = {
86 { LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE
, "Chassis component"},
87 { LLDP_CHASSIS_INTF_ALIAS_SUBTYPE
, "Interface alias"},
88 { LLDP_CHASSIS_PORT_COMP_SUBTYPE
, "Port component"},
89 { LLDP_CHASSIS_MAC_ADDR_SUBTYPE
, "MAC address"},
90 { LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE
, "Network address"},
91 { LLDP_CHASSIS_INTF_NAME_SUBTYPE
, "Interface name"},
92 { LLDP_CHASSIS_LOCAL_SUBTYPE
, "Local"},
99 #define LLDP_PORT_INTF_ALIAS_SUBTYPE 1
100 #define LLDP_PORT_PORT_COMP_SUBTYPE 2
101 #define LLDP_PORT_MAC_ADDR_SUBTYPE 3
102 #define LLDP_PORT_NETWORK_ADDR_SUBTYPE 4
103 #define LLDP_PORT_INTF_NAME_SUBTYPE 5
104 #define LLDP_PORT_AGENT_CIRC_ID_SUBTYPE 6
105 #define LLDP_PORT_LOCAL_SUBTYPE 7
107 static const struct tok lldp_port_subtype_values
[] = {
108 { LLDP_PORT_INTF_ALIAS_SUBTYPE
, "Interface alias"},
109 { LLDP_PORT_PORT_COMP_SUBTYPE
, "Port component"},
110 { LLDP_PORT_MAC_ADDR_SUBTYPE
, "MAC address"},
111 { LLDP_PORT_NETWORK_ADDR_SUBTYPE
, "Network Address"},
112 { LLDP_PORT_INTF_NAME_SUBTYPE
, "Interface Name"},
113 { LLDP_PORT_AGENT_CIRC_ID_SUBTYPE
, "Agent circuit ID"},
114 { LLDP_PORT_LOCAL_SUBTYPE
, "Local"},
119 * System Capabilities
121 #define LLDP_CAP_OTHER (1 << 0)
122 #define LLDP_CAP_REPEATER (1 << 1)
123 #define LLDP_CAP_BRIDGE (1 << 2)
124 #define LLDP_CAP_WLAN_AP (1 << 3)
125 #define LLDP_CAP_ROUTER (1 << 4)
126 #define LLDP_CAP_PHONE (1 << 5)
127 #define LLDP_CAP_DOCSIS (1 << 6)
128 #define LLDP_CAP_STATION_ONLY (1 << 7)
130 static const struct tok lldp_cap_values
[] = {
131 { LLDP_CAP_OTHER
, "Other"},
132 { LLDP_CAP_REPEATER
, "Repeater"},
133 { LLDP_CAP_BRIDGE
, "Bridge"},
134 { LLDP_CAP_WLAN_AP
, "WLAN AP"},
135 { LLDP_CAP_ROUTER
, "Router"},
136 { LLDP_CAP_PHONE
, "Telephone"},
137 { LLDP_CAP_DOCSIS
, "Docsis"},
138 { LLDP_CAP_STATION_ONLY
, "Station Only"},
142 #define LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID 1
143 #define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID 2
144 #define LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME 3
145 #define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY 4
146 #define LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION 8
147 #define LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION 9
148 #define LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION 10
149 #define LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION 11
150 #define LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY 12
151 #define LLDP_PRIVATE_8021_SUBTYPE_EVB 13
152 #define LLDP_PRIVATE_8021_SUBTYPE_CDCP 14
154 static const struct tok lldp_8021_subtype_values
[] = {
155 { LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID
, "Port VLAN Id"},
156 { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID
, "Port and Protocol VLAN ID"},
157 { LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME
, "VLAN name"},
158 { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY
, "Protocol Identity"},
159 { LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION
, "Congestion Notification"},
160 { LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION
, "ETS Configuration"},
161 { LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION
, "ETS Recommendation"},
162 { LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION
, "Priority Flow Control Configuration"},
163 { LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY
, "Application Priority"},
164 { LLDP_PRIVATE_8021_SUBTYPE_EVB
, "EVB"},
165 { LLDP_PRIVATE_8021_SUBTYPE_CDCP
,"CDCP"},
169 #define LLDP_8021_PORT_PROTOCOL_VLAN_SUPPORT (1 << 1)
170 #define LLDP_8021_PORT_PROTOCOL_VLAN_STATUS (1 << 2)
172 static const struct tok lldp_8021_port_protocol_id_values
[] = {
173 { LLDP_8021_PORT_PROTOCOL_VLAN_SUPPORT
, "supported"},
174 { LLDP_8021_PORT_PROTOCOL_VLAN_STATUS
, "enabled"},
178 #define LLDP_PRIVATE_8023_SUBTYPE_MACPHY 1
179 #define LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER 2
180 #define LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR 3
181 #define LLDP_PRIVATE_8023_SUBTYPE_MTU 4
183 static const struct tok lldp_8023_subtype_values
[] = {
184 { LLDP_PRIVATE_8023_SUBTYPE_MACPHY
, "MAC/PHY configuration/status"},
185 { LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER
, "Power via MDI"},
186 { LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR
, "Link aggregation"},
187 { LLDP_PRIVATE_8023_SUBTYPE_MTU
, "Max frame size"},
191 #define LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES 1
192 #define LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY 2
193 #define LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID 3
194 #define LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI 4
195 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV 5
196 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV 6
197 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV 7
198 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER 8
199 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME 9
200 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME 10
201 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID 11
203 static const struct tok lldp_tia_subtype_values
[] = {
204 { LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES
, "LLDP-MED Capabilities" },
205 { LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY
, "Network policy" },
206 { LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID
, "Location identification" },
207 { LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI
, "Extended power-via-MDI" },
208 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV
, "Inventory - hardware revision" },
209 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV
, "Inventory - firmware revision" },
210 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV
, "Inventory - software revision" },
211 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER
, "Inventory - serial number" },
212 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME
, "Inventory - manufacturer name" },
213 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME
, "Inventory - model name" },
214 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID
, "Inventory - asset ID" },
218 #define LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_METERS 1
219 #define LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_FLOORS 2
221 static const struct tok lldp_tia_location_altitude_type_values
[] = {
222 { LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_METERS
, "meters"},
223 { LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_FLOORS
, "floors"},
227 /* ANSI/TIA-1057 - Annex B */
228 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A1 1
229 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A2 2
230 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A3 3
231 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A4 4
232 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A5 5
233 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A6 6
235 static const struct tok lldp_tia_location_lci_catype_values
[] = {
236 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A1
, "national subdivisions (state,canton,region,province,prefecture)"},
237 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A2
, "county, parish, gun, district"},
238 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A3
, "city, township, shi"},
239 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A4
, "city division, borough, city district, ward chou"},
240 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A5
, "neighborhood, block"},
241 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A6
, "street"},
245 static const struct tok lldp_tia_location_lci_what_values
[] = {
246 { 0, "location of DHCP server"},
247 { 1, "location of the network element believed to be closest to the client"},
248 { 2, "location of the client"},
253 * From RFC 3636 - dot3MauType
255 #define LLDP_MAU_TYPE_UNKNOWN 0
256 #define LLDP_MAU_TYPE_AUI 1
257 #define LLDP_MAU_TYPE_10BASE_5 2
258 #define LLDP_MAU_TYPE_FOIRL 3
259 #define LLDP_MAU_TYPE_10BASE_2 4
260 #define LLDP_MAU_TYPE_10BASE_T 5
261 #define LLDP_MAU_TYPE_10BASE_FP 6
262 #define LLDP_MAU_TYPE_10BASE_FB 7
263 #define LLDP_MAU_TYPE_10BASE_FL 8
264 #define LLDP_MAU_TYPE_10BROAD36 9
265 #define LLDP_MAU_TYPE_10BASE_T_HD 10
266 #define LLDP_MAU_TYPE_10BASE_T_FD 11
267 #define LLDP_MAU_TYPE_10BASE_FL_HD 12
268 #define LLDP_MAU_TYPE_10BASE_FL_FD 13
269 #define LLDP_MAU_TYPE_100BASE_T4 14
270 #define LLDP_MAU_TYPE_100BASE_TX_HD 15
271 #define LLDP_MAU_TYPE_100BASE_TX_FD 16
272 #define LLDP_MAU_TYPE_100BASE_FX_HD 17
273 #define LLDP_MAU_TYPE_100BASE_FX_FD 18
274 #define LLDP_MAU_TYPE_100BASE_T2_HD 19
275 #define LLDP_MAU_TYPE_100BASE_T2_FD 20
276 #define LLDP_MAU_TYPE_1000BASE_X_HD 21
277 #define LLDP_MAU_TYPE_1000BASE_X_FD 22
278 #define LLDP_MAU_TYPE_1000BASE_LX_HD 23
279 #define LLDP_MAU_TYPE_1000BASE_LX_FD 24
280 #define LLDP_MAU_TYPE_1000BASE_SX_HD 25
281 #define LLDP_MAU_TYPE_1000BASE_SX_FD 26
282 #define LLDP_MAU_TYPE_1000BASE_CX_HD 27
283 #define LLDP_MAU_TYPE_1000BASE_CX_FD 28
284 #define LLDP_MAU_TYPE_1000BASE_T_HD 29
285 #define LLDP_MAU_TYPE_1000BASE_T_FD 30
286 #define LLDP_MAU_TYPE_10GBASE_X 31
287 #define LLDP_MAU_TYPE_10GBASE_LX4 32
288 #define LLDP_MAU_TYPE_10GBASE_R 33
289 #define LLDP_MAU_TYPE_10GBASE_ER 34
290 #define LLDP_MAU_TYPE_10GBASE_LR 35
291 #define LLDP_MAU_TYPE_10GBASE_SR 36
292 #define LLDP_MAU_TYPE_10GBASE_W 37
293 #define LLDP_MAU_TYPE_10GBASE_EW 38
294 #define LLDP_MAU_TYPE_10GBASE_LW 39
295 #define LLDP_MAU_TYPE_10GBASE_SW 40
297 static const struct tok lldp_mau_types_values
[] = {
298 { LLDP_MAU_TYPE_UNKNOWN
, "Unknown"},
299 { LLDP_MAU_TYPE_AUI
, "AUI"},
300 { LLDP_MAU_TYPE_10BASE_5
, "10BASE_5"},
301 { LLDP_MAU_TYPE_FOIRL
, "FOIRL"},
302 { LLDP_MAU_TYPE_10BASE_2
, "10BASE2"},
303 { LLDP_MAU_TYPE_10BASE_T
, "10BASET duplex mode unknown"},
304 { LLDP_MAU_TYPE_10BASE_FP
, "10BASEFP"},
305 { LLDP_MAU_TYPE_10BASE_FB
, "10BASEFB"},
306 { LLDP_MAU_TYPE_10BASE_FL
, "10BASEFL duplex mode unknown"},
307 { LLDP_MAU_TYPE_10BROAD36
, "10BROAD36"},
308 { LLDP_MAU_TYPE_10BASE_T_HD
, "10BASET hdx"},
309 { LLDP_MAU_TYPE_10BASE_T_FD
, "10BASET fdx"},
310 { LLDP_MAU_TYPE_10BASE_FL_HD
, "10BASEFL hdx"},
311 { LLDP_MAU_TYPE_10BASE_FL_FD
, "10BASEFL fdx"},
312 { LLDP_MAU_TYPE_100BASE_T4
, "100BASET4"},
313 { LLDP_MAU_TYPE_100BASE_TX_HD
, "100BASETX hdx"},
314 { LLDP_MAU_TYPE_100BASE_TX_FD
, "100BASETX fdx"},
315 { LLDP_MAU_TYPE_100BASE_FX_HD
, "100BASEFX hdx"},
316 { LLDP_MAU_TYPE_100BASE_FX_FD
, "100BASEFX fdx"},
317 { LLDP_MAU_TYPE_100BASE_T2_HD
, "100BASET2 hdx"},
318 { LLDP_MAU_TYPE_100BASE_T2_FD
, "100BASET2 fdx"},
319 { LLDP_MAU_TYPE_1000BASE_X_HD
, "1000BASEX hdx"},
320 { LLDP_MAU_TYPE_1000BASE_X_FD
, "1000BASEX fdx"},
321 { LLDP_MAU_TYPE_1000BASE_LX_HD
, "1000BASELX hdx"},
322 { LLDP_MAU_TYPE_1000BASE_LX_FD
, "1000BASELX fdx"},
323 { LLDP_MAU_TYPE_1000BASE_SX_HD
, "1000BASESX hdx"},
324 { LLDP_MAU_TYPE_1000BASE_SX_FD
, "1000BASESX fdx"},
325 { LLDP_MAU_TYPE_1000BASE_CX_HD
, "1000BASECX hdx"},
326 { LLDP_MAU_TYPE_1000BASE_CX_FD
, "1000BASECX fdx"},
327 { LLDP_MAU_TYPE_1000BASE_T_HD
, "1000BASET hdx"},
328 { LLDP_MAU_TYPE_1000BASE_T_FD
, "1000BASET fdx"},
329 { LLDP_MAU_TYPE_10GBASE_X
, "10GBASEX"},
330 { LLDP_MAU_TYPE_10GBASE_LX4
, "10GBASELX4"},
331 { LLDP_MAU_TYPE_10GBASE_R
, "10GBASER"},
332 { LLDP_MAU_TYPE_10GBASE_ER
, "10GBASEER"},
333 { LLDP_MAU_TYPE_10GBASE_LR
, "10GBASELR"},
334 { LLDP_MAU_TYPE_10GBASE_SR
, "10GBASESR"},
335 { LLDP_MAU_TYPE_10GBASE_W
, "10GBASEW"},
336 { LLDP_MAU_TYPE_10GBASE_EW
, "10GBASEEW"},
337 { LLDP_MAU_TYPE_10GBASE_LW
, "10GBASELW"},
338 { LLDP_MAU_TYPE_10GBASE_SW
, "10GBASESW"},
342 #define LLDP_8023_AUTONEGOTIATION_SUPPORT (1 << 0)
343 #define LLDP_8023_AUTONEGOTIATION_STATUS (1 << 1)
345 static const struct tok lldp_8023_autonegotiation_values
[] = {
346 { LLDP_8023_AUTONEGOTIATION_SUPPORT
, "supported"},
347 { LLDP_8023_AUTONEGOTIATION_STATUS
, "enabled"},
351 #define LLDP_TIA_CAPABILITY_MED (1 << 0)
352 #define LLDP_TIA_CAPABILITY_NETWORK_POLICY (1 << 1)
353 #define LLDP_TIA_CAPABILITY_LOCATION_IDENTIFICATION (1 << 2)
354 #define LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PSE (1 << 3)
355 #define LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PD (1 << 4)
356 #define LLDP_TIA_CAPABILITY_INVENTORY (1 << 5)
358 static const struct tok lldp_tia_capabilities_values
[] = {
359 { LLDP_TIA_CAPABILITY_MED
, "LLDP-MED capabilities"},
360 { LLDP_TIA_CAPABILITY_NETWORK_POLICY
, "network policy"},
361 { LLDP_TIA_CAPABILITY_LOCATION_IDENTIFICATION
, "location identification"},
362 { LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PSE
, "extended power via MDI-PSE"},
363 { LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PD
, "extended power via MDI-PD"},
364 { LLDP_TIA_CAPABILITY_INVENTORY
, "Inventory"},
368 #define LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_1 1
369 #define LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_2 2
370 #define LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_3 3
371 #define LLDP_TIA_DEVICE_TYPE_NETWORK_CONNECTIVITY 4
373 static const struct tok lldp_tia_device_type_values
[] = {
374 { LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_1
, "endpoint class 1"},
375 { LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_2
, "endpoint class 2"},
376 { LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_3
, "endpoint class 3"},
377 { LLDP_TIA_DEVICE_TYPE_NETWORK_CONNECTIVITY
, "network connectivity"},
381 #define LLDP_TIA_APPLICATION_TYPE_VOICE 1
382 #define LLDP_TIA_APPLICATION_TYPE_VOICE_SIGNALING 2
383 #define LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE 3
384 #define LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE_SIGNALING 4
385 #define LLDP_TIA_APPLICATION_TYPE_SOFTPHONE_VOICE 5
386 #define LLDP_TIA_APPLICATION_TYPE_VIDEO_CONFERENCING 6
387 #define LLDP_TIA_APPLICATION_TYPE_STREAMING_VIDEO 7
388 #define LLDP_TIA_APPLICATION_TYPE_VIDEO_SIGNALING 8
390 static const struct tok lldp_tia_application_type_values
[] = {
391 { LLDP_TIA_APPLICATION_TYPE_VOICE
, "voice"},
392 { LLDP_TIA_APPLICATION_TYPE_VOICE_SIGNALING
, "voice signaling"},
393 { LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE
, "guest voice"},
394 { LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE_SIGNALING
, "guest voice signaling"},
395 { LLDP_TIA_APPLICATION_TYPE_SOFTPHONE_VOICE
, "softphone voice"},
396 { LLDP_TIA_APPLICATION_TYPE_VIDEO_CONFERENCING
, "video conferencing"},
397 { LLDP_TIA_APPLICATION_TYPE_STREAMING_VIDEO
, "streaming video"},
398 { LLDP_TIA_APPLICATION_TYPE_VIDEO_SIGNALING
, "video signaling"},
402 #define LLDP_TIA_NETWORK_POLICY_X_BIT (1 << 5)
403 #define LLDP_TIA_NETWORK_POLICY_T_BIT (1 << 6)
404 #define LLDP_TIA_NETWORK_POLICY_U_BIT (1 << 7)
406 static const struct tok lldp_tia_network_policy_bits_values
[] = {
407 { LLDP_TIA_NETWORK_POLICY_U_BIT
, "Unknown"},
408 { LLDP_TIA_NETWORK_POLICY_T_BIT
, "Tagged"},
409 { LLDP_TIA_NETWORK_POLICY_X_BIT
, "reserved"},
413 #define LLDP_EXTRACT_NETWORK_POLICY_VLAN(x) (((x)&0x1ffe)>>1)
414 #define LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(x) (((x)&0x01ff)>>6)
415 #define LLDP_EXTRACT_NETWORK_POLICY_DSCP(x) ((x)&0x003f)
417 #define LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED 1
418 #define LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS 2
419 #define LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN 3
421 static const struct tok lldp_tia_location_data_format_values
[] = {
422 { LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED
, "coordinate-based LCI"},
423 { LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS
, "civic address LCI"},
424 { LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN
, "ECS ELIN"},
428 #define LLDP_TIA_LOCATION_DATUM_WGS_84 1
429 #define LLDP_TIA_LOCATION_DATUM_NAD_83_NAVD_88 2
430 #define LLDP_TIA_LOCATION_DATUM_NAD_83_MLLW 3
432 static const struct tok lldp_tia_location_datum_type_values
[] = {
433 { LLDP_TIA_LOCATION_DATUM_WGS_84
, "World Geodesic System 1984"},
434 { LLDP_TIA_LOCATION_DATUM_NAD_83_NAVD_88
, "North American Datum 1983 (NAVD88)"},
435 { LLDP_TIA_LOCATION_DATUM_NAD_83_MLLW
, "North American Datum 1983 (MLLW)"},
439 #define LLDP_TIA_POWER_SOURCE_PSE 1
440 #define LLDP_TIA_POWER_SOURCE_LOCAL 2
441 #define LLDP_TIA_POWER_SOURCE_PSE_AND_LOCAL 3
443 static const struct tok lldp_tia_power_source_values
[] = {
444 { LLDP_TIA_POWER_SOURCE_PSE
, "PSE - primary power source"},
445 { LLDP_TIA_POWER_SOURCE_LOCAL
, "local - backup power source"},
446 { LLDP_TIA_POWER_SOURCE_PSE_AND_LOCAL
, "PSE+local - reserved"},
450 #define LLDP_TIA_POWER_PRIORITY_CRITICAL 1
451 #define LLDP_TIA_POWER_PRIORITY_HIGH 2
452 #define LLDP_TIA_POWER_PRIORITY_LOW 3
454 static const struct tok lldp_tia_power_priority_values
[] = {
455 { LLDP_TIA_POWER_PRIORITY_CRITICAL
, "critical"},
456 { LLDP_TIA_POWER_PRIORITY_HIGH
, "high"},
457 { LLDP_TIA_POWER_PRIORITY_LOW
, "low"},
461 #define LLDP_TIA_POWER_VAL_MAX 1024
463 static const struct tok lldp_tia_inventory_values
[] = {
464 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV
, "Hardware revision" },
465 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV
, "Firmware revision" },
466 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV
, "Software revision" },
467 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER
, "Serial number" },
468 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME
, "Manufacturer name" },
469 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME
, "Model name" },
470 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID
, "Asset ID" },
475 * From RFC 3636 - ifMauAutoNegCapAdvertisedBits
477 #define LLDP_MAU_PMD_OTHER (1 << 15)
478 #define LLDP_MAU_PMD_10BASE_T (1 << 14)
479 #define LLDP_MAU_PMD_10BASE_T_FD (1 << 13)
480 #define LLDP_MAU_PMD_100BASE_T4 (1 << 12)
481 #define LLDP_MAU_PMD_100BASE_TX (1 << 11)
482 #define LLDP_MAU_PMD_100BASE_TX_FD (1 << 10)
483 #define LLDP_MAU_PMD_100BASE_T2 (1 << 9)
484 #define LLDP_MAU_PMD_100BASE_T2_FD (1 << 8)
485 #define LLDP_MAU_PMD_FDXPAUSE (1 << 7)
486 #define LLDP_MAU_PMD_FDXAPAUSE (1 << 6)
487 #define LLDP_MAU_PMD_FDXSPAUSE (1 << 5)
488 #define LLDP_MAU_PMD_FDXBPAUSE (1 << 4)
489 #define LLDP_MAU_PMD_1000BASE_X (1 << 3)
490 #define LLDP_MAU_PMD_1000BASE_X_FD (1 << 2)
491 #define LLDP_MAU_PMD_1000BASE_T (1 << 1)
492 #define LLDP_MAU_PMD_1000BASE_T_FD (1 << 0)
494 static const struct tok lldp_pmd_capability_values
[] = {
495 { LLDP_MAU_PMD_10BASE_T
, "10BASE-T hdx"},
496 { LLDP_MAU_PMD_10BASE_T_FD
, "10BASE-T fdx"},
497 { LLDP_MAU_PMD_100BASE_T4
, "100BASE-T4"},
498 { LLDP_MAU_PMD_100BASE_TX
, "100BASE-TX hdx"},
499 { LLDP_MAU_PMD_100BASE_TX_FD
, "100BASE-TX fdx"},
500 { LLDP_MAU_PMD_100BASE_T2
, "100BASE-T2 hdx"},
501 { LLDP_MAU_PMD_100BASE_T2_FD
, "100BASE-T2 fdx"},
502 { LLDP_MAU_PMD_FDXPAUSE
, "Pause for fdx links"},
503 { LLDP_MAU_PMD_FDXAPAUSE
, "Asym PAUSE for fdx"},
504 { LLDP_MAU_PMD_FDXSPAUSE
, "Sym PAUSE for fdx"},
505 { LLDP_MAU_PMD_FDXBPAUSE
, "Asym and Sym PAUSE for fdx"},
506 { LLDP_MAU_PMD_1000BASE_X
, "1000BASE-{X LX SX CX} hdx"},
507 { LLDP_MAU_PMD_1000BASE_X_FD
, "1000BASE-{X LX SX CX} fdx"},
508 { LLDP_MAU_PMD_1000BASE_T
, "1000BASE-T hdx"},
509 { LLDP_MAU_PMD_1000BASE_T_FD
, "1000BASE-T fdx"},
513 #define LLDP_MDI_PORT_CLASS (1 << 0)
514 #define LLDP_MDI_POWER_SUPPORT (1 << 1)
515 #define LLDP_MDI_POWER_STATE (1 << 2)
516 #define LLDP_MDI_PAIR_CONTROL_ABILITY (1 << 3)
518 static const struct tok lldp_mdi_values
[] = {
519 { LLDP_MDI_PORT_CLASS
, "PSE"},
520 { LLDP_MDI_POWER_SUPPORT
, "supported"},
521 { LLDP_MDI_POWER_STATE
, "enabled"},
522 { LLDP_MDI_PAIR_CONTROL_ABILITY
, "can be controlled"},
526 #define LLDP_MDI_PSE_PORT_POWER_PAIRS_SIGNAL 1
527 #define LLDP_MDI_PSE_PORT_POWER_PAIRS_SPARE 2
529 static const struct tok lldp_mdi_power_pairs_values
[] = {
530 { LLDP_MDI_PSE_PORT_POWER_PAIRS_SIGNAL
, "signal"},
531 { LLDP_MDI_PSE_PORT_POWER_PAIRS_SPARE
, "spare"},
535 #define LLDP_MDI_POWER_CLASS0 1
536 #define LLDP_MDI_POWER_CLASS1 2
537 #define LLDP_MDI_POWER_CLASS2 3
538 #define LLDP_MDI_POWER_CLASS3 4
539 #define LLDP_MDI_POWER_CLASS4 5
541 static const struct tok lldp_mdi_power_class_values
[] = {
542 { LLDP_MDI_POWER_CLASS0
, "class0"},
543 { LLDP_MDI_POWER_CLASS1
, "class1"},
544 { LLDP_MDI_POWER_CLASS2
, "class2"},
545 { LLDP_MDI_POWER_CLASS3
, "class3"},
546 { LLDP_MDI_POWER_CLASS4
, "class4"},
550 #define LLDP_AGGREGATION_CAPABILTIY (1 << 0)
551 #define LLDP_AGGREGATION_STATUS (1 << 1)
553 static const struct tok lldp_aggregation_values
[] = {
554 { LLDP_AGGREGATION_CAPABILTIY
, "supported"},
555 { LLDP_AGGREGATION_STATUS
, "enabled"},
560 * DCBX protocol subtypes.
562 #define LLDP_DCBX_SUBTYPE_1 1
563 #define LLDP_DCBX_SUBTYPE_2 2
565 static const struct tok lldp_dcbx_subtype_values
[] = {
566 { LLDP_DCBX_SUBTYPE_1
, "DCB Capability Exchange Protocol Rev 1" },
567 { LLDP_DCBX_SUBTYPE_2
, "DCB Capability Exchange Protocol Rev 1.01" },
571 #define LLDP_DCBX_CONTROL_TLV 1
572 #define LLDP_DCBX_PRIORITY_GROUPS_TLV 2
573 #define LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV 3
574 #define LLDP_DCBX_APPLICATION_TLV 4
577 * Interface numbering subtypes.
579 #define LLDP_INTF_NUMB_IFX_SUBTYPE 2
580 #define LLDP_INTF_NUMB_SYSPORT_SUBTYPE 3
582 static const struct tok lldp_intf_numb_subtype_values
[] = {
583 { LLDP_INTF_NUMB_IFX_SUBTYPE
, "Interface Index" },
584 { LLDP_INTF_NUMB_SYSPORT_SUBTYPE
, "System Port Number" },
588 #define LLDP_INTF_NUM_LEN 5
590 #define LLDP_EVB_MODE_NOT_SUPPORTED 0
591 #define LLDP_EVB_MODE_EVB_BRIDGE 1
592 #define LLDP_EVB_MODE_EVB_STATION 2
593 #define LLDP_EVB_MODE_RESERVED 3
595 static const struct tok lldp_evb_mode_values
[]={
596 { LLDP_EVB_MODE_NOT_SUPPORTED
, "Not Supported"},
597 { LLDP_EVB_MODE_EVB_BRIDGE
, "EVB Bridge"},
598 { LLDP_EVB_MODE_EVB_STATION
, "EVB Staion"},
599 { LLDP_EVB_MODE_RESERVED
, "Reserved for future Standardization"},
603 #define LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH 6
604 #define LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION_LENGTH 25
605 #define LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION_LENGTH 25
606 #define LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION_LENGTH 6
607 #define LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH 5
608 #define LLDP_PRIVATE_8021_SUBTYPE_EVB_LENGTH 9
609 #define LLDP_PRIVATE_8021_SUBTYPE_CDCP_MIN_LENGTH 8
611 static void print_ets_priority_assignment_table(const u_char
*ptr
)
613 printf("\n\t Priority Assignment Table");
614 printf("\n\t Priority : 0 1 2 3 4 5 6 7");
615 printf("\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
616 ptr
[0]>>4,ptr
[0]&0x0f,ptr
[1]>>4,ptr
[1]&0x0f,ptr
[2]>>4,
617 ptr
[2]&0x0f,ptr
[3]>>4,ptr
[3]&0x0f);
620 static void print_tc_bandwidth_table(const u_char
*ptr
)
622 printf("\n\t TC Bandwidth Table");
623 printf("\n\t TC%% : 0 1 2 3 4 5 6 7");
624 printf("\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
625 ptr
[0],ptr
[1],ptr
[2],ptr
[3],ptr
[4],ptr
[5],ptr
[6],ptr
[7]);
628 static void print_tsa_assignment_table(const u_char
*ptr
)
630 printf("\n\t TSA Assignment Table");
631 printf("\n\t Traffic Class: 0 1 2 3 4 5 6 7");
632 printf("\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
633 ptr
[0],ptr
[1],ptr
[2],ptr
[3],ptr
[4],ptr
[5],ptr
[6],ptr
[7]);
637 * Print IEEE 802.1 private extensions. (802.1AB annex E)
640 lldp_private_8021_print(const u_char
*tptr
, u_int tlv_len
)
642 int subtype
, hexdump
= FALSE
;
652 printf("\n\t %s Subtype (%u)",
653 tok2str(lldp_8021_subtype_values
, "unknown", subtype
),
657 case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID
:
661 printf("\n\t port vlan id (PVID): %u",
662 EXTRACT_16BITS(tptr
+4));
664 case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID
:
668 printf("\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
669 EXTRACT_16BITS(tptr
+5),
670 bittok2str(lldp_8021_port_protocol_id_values
, "none", *(tptr
+4)),
673 case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME
:
677 printf("\n\t vlan id (VID): %u",
678 EXTRACT_16BITS(tptr
+4));
683 if (tlv_len
< 7+sublen
) {
686 printf("\n\t vlan name: ");
687 safeputs((const char *)tptr
+7, sublen
);
689 case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY
:
694 if (tlv_len
< 5+sublen
) {
697 printf("\n\t protocol identity: ");
698 safeputs((const char *)tptr
+5, sublen
);
700 case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION
:
701 if(tlv_len
<LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH
){
705 printf("\n\t Pre-Priority CNPV Indicator");
706 printf("\n\t Priority : 0 1 2 3 4 5 6 7");
707 printf("\n\t Value : ");
708 for(i
=0;i
<NO_OF_BITS
;i
++)
709 printf("%-2d ",(tval
>>i
)&0x01);
711 printf("\n\t Pre-Priority Ready Indicator");
712 printf("\n\t Priority : 0 1 2 3 4 5 6 7");
713 printf("\n\t Value : ");
714 for(i
=0;i
<NO_OF_BITS
;i
++)
715 printf("%-2d ",(tval
>>i
)&0x01);
718 case LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION
:
719 if(tlv_len
<LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION_LENGTH
) {
723 printf("\n\t Willing:%d, CBS:%d, RES:%d, Max TCs:%d",
724 tval
>>7, (tval
>>6) & 0x02, (tval
>>3) & 0x07, tval
& 0x07);
726 /*Print Priority Assignment Table*/
727 print_ets_priority_assignment_table(tptr
+5);
729 /*Print TC Bandwidth Table*/
730 print_tc_bandwidth_table(tptr
+9);
732 /* Print TSA Assignment Table */
733 print_tsa_assignment_table(tptr
+17);
737 case LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION
:
738 if(tlv_len
<LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION_LENGTH
) {
741 printf("\n\t RES: %d",*(tptr
+4));
742 /*Print Priority Assignment Table */
743 print_ets_priority_assignment_table(tptr
+5);
744 /*Print TC Bandwidth Table */
745 print_tc_bandwidth_table(tptr
+9);
746 /* Print TSA Assignment Table */
747 print_tsa_assignment_table(tptr
+17);
750 case LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION
:
751 if(tlv_len
<LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION_LENGTH
) {
755 printf("\n\t Willing: %d, MBC: %d, RES: %d, PFC cap:%d ",
756 tval
>>7, (tval
>>6)&0x01, (tval
>>4)&0x03, (tval
& 0x0f));
757 printf("\n\t PFC Enable");
759 printf("\n\t Priority : 0 1 2 3 4 5 6 7");
760 printf("\n\t Value : ");
761 for(i
=0;i
<NO_OF_BITS
;i
++)
762 printf("%-2d ",(tval
>>i
)&0x01);
765 case LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY
:
766 if(tlv_len
<LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH
) {
769 printf("\n\t RES: %d",*(tptr
+4));
770 if(tlv_len
<=LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH
){
773 /* Length of Application Priority Table */
779 printf("\n\t Application Priority Table");
782 printf("\n\t Priority: %d, RES: %d, Sel: %d",
783 tval
>>5, (tval
>>3)&0x03, (tval
& 0x07));
784 printf("Protocol ID: %d",EXTRACT_16BITS(tptr
+i
+5));
788 case LLDP_PRIVATE_8021_SUBTYPE_EVB
:
789 if(tlv_len
<LLDP_PRIVATE_8021_SUBTYPE_EVB_LENGTH
){
792 printf("\n\t EVB Bridge Status");
794 printf("\n\t RES: %d, BGID: %d, RRCAP: %d, RRCTR: %d",
795 tval
>>3, (tval
>>2)&0x01, (tval
>>1)&0x01,tval
&0x01);
796 printf("\n\t EVB Station Status");
798 printf("\n\t RES: %d, SGID: %d, RRREQ: %d,RRSTAT: %d",
799 tval
>>4, (tval
>>3)&0x01, (tval
>>2)&0x01, tval
&0x03);
801 printf("\n\t R: %d, RTE: %d, ",tval
>>5, tval
&0x1f);
803 printf("EVB Mode: %s [%d]",
804 tok2str(lldp_evb_mode_values
,"unknown",tval
>>6),tval
>>6);
805 printf("\n\t ROL: %d, RWD: %d, ", (tval
>>5)&0x01,tval
&0x1f);
807 printf("RES: %d, ROL: %d, RKA: %d", tval
>>6,(tval
>>5)&0x01, tval
&0x1f);
810 case LLDP_PRIVATE_8021_SUBTYPE_CDCP
:
811 if(tlv_len
<LLDP_PRIVATE_8021_SUBTYPE_CDCP_MIN_LENGTH
){
815 printf("\n\t Role: %d, RES: %d, Scomp: %d ",
816 tval
>>7, (tval
>>4)&0x07,(tval
>>3)&0x01);
817 printf("ChnCap: %d",EXTRACT_16BITS(tptr
+6)&0x0fff);
824 tval
=EXTRACT_24BITS(tptr
+i
+8);
825 printf("\n\t SCID: %d, SVID: %d",
826 tval
>>12, tval
&0x000fff);
840 * Print IEEE 802.3 private extensions. (802.3bc)
843 lldp_private_8023_print(const u_char
*tptr
, u_int tlv_len
)
845 int subtype
, hexdump
= FALSE
;
852 printf("\n\t %s Subtype (%u)",
853 tok2str(lldp_8023_subtype_values
, "unknown", subtype
),
857 case LLDP_PRIVATE_8023_SUBTYPE_MACPHY
:
861 printf("\n\t autonegotiation [%s] (0x%02x)",
862 bittok2str(lldp_8023_autonegotiation_values
, "none", *(tptr
+4)),
864 printf("\n\t PMD autoneg capability [%s] (0x%04x)",
865 bittok2str(lldp_pmd_capability_values
,"unknown", EXTRACT_16BITS(tptr
+5)),
866 EXTRACT_16BITS(tptr
+5));
867 printf("\n\t MAU type %s (0x%04x)",
868 tok2str(lldp_mau_types_values
, "unknown", EXTRACT_16BITS(tptr
+7)),
869 EXTRACT_16BITS(tptr
+7));
872 case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER
:
876 printf("\n\t MDI power support [%s], power pair %s, power class %s",
877 bittok2str(lldp_mdi_values
, "none", *(tptr
+4)),
878 tok2str(lldp_mdi_power_pairs_values
, "unknown", *(tptr
+5)),
879 tok2str(lldp_mdi_power_class_values
, "unknown", *(tptr
+6)));
882 case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR
:
886 printf("\n\t aggregation status [%s], aggregation port ID %u",
887 bittok2str(lldp_aggregation_values
, "none", *(tptr
+4)),
888 EXTRACT_32BITS(tptr
+5));
891 case LLDP_PRIVATE_8023_SUBTYPE_MTU
:
892 printf("\n\t MTU size %u", EXTRACT_16BITS(tptr
+4));
904 * Extract 34bits of latitude/longitude coordinates.
907 lldp_extract_latlon(const u_char
*tptr
)
911 latlon
= *tptr
& 0x3;
912 latlon
= (latlon
<< 32) | EXTRACT_32BITS(tptr
+1);
918 * Print private TIA extensions.
921 lldp_private_tia_print(const u_char
*tptr
, u_int tlv_len
)
923 int subtype
, hexdump
= FALSE
;
924 u_int8_t location_format
;
927 u_int8_t ca_type
, ca_len
;
934 printf("\n\t %s Subtype (%u)",
935 tok2str(lldp_tia_subtype_values
, "unknown", subtype
),
939 case LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES
:
943 printf("\n\t Media capabilities [%s] (0x%04x)",
944 bittok2str(lldp_tia_capabilities_values
, "none",
945 EXTRACT_16BITS(tptr
+4)), EXTRACT_16BITS(tptr
+4));
946 printf("\n\t Device type [%s] (0x%02x)",
947 tok2str(lldp_tia_device_type_values
, "unknown", *(tptr
+6)),
951 case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY
:
955 printf("\n\t Application type [%s] (0x%02x)",
956 tok2str(lldp_tia_application_type_values
, "none", *(tptr
+4)),
958 printf(", Flags [%s]", bittok2str(
959 lldp_tia_network_policy_bits_values
, "none", *(tptr
+5)));
960 printf("\n\t Vlan id %u",
961 LLDP_EXTRACT_NETWORK_POLICY_VLAN(EXTRACT_16BITS(tptr
+5)));
962 printf(", L2 priority %u",
963 LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(EXTRACT_16BITS(tptr
+6)));
964 printf(", DSCP value %u",
965 LLDP_EXTRACT_NETWORK_POLICY_DSCP(EXTRACT_16BITS(tptr
+6)));
968 case LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID
:
972 location_format
= *(tptr
+4);
973 printf("\n\t Location data format %s (0x%02x)",
974 tok2str(lldp_tia_location_data_format_values
, "unknown", location_format
),
977 switch (location_format
) {
978 case LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED
:
982 printf("\n\t Latitude resolution %u, latitude value %" PRIu64
,
983 (*(tptr
+5)>>2), lldp_extract_latlon(tptr
+5));
984 printf("\n\t Longitude resolution %u, longitude value %" PRIu64
,
985 (*(tptr
+10)>>2), lldp_extract_latlon(tptr
+10));
986 printf("\n\t Altitude type %s (%u)",
987 tok2str(lldp_tia_location_altitude_type_values
, "unknown",(*(tptr
+15)>>4)),
989 printf("\n\t Altitude resolution %u, altitude value 0x%x",
990 (EXTRACT_16BITS(tptr
+15)>>6)&0x3f,
991 ((EXTRACT_32BITS(tptr
+16)&0x3fffffff)));
992 printf("\n\t Datum %s (0x%02x)",
993 tok2str(lldp_tia_location_datum_type_values
, "unknown", *(tptr
+20)),
997 case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS
:
1001 lci_len
= *(tptr
+5);
1005 if (tlv_len
< 7+lci_len
) {
1008 printf("\n\t LCI length %u, LCI what %s (0x%02x), Country-code ",
1010 tok2str(lldp_tia_location_lci_what_values
, "unknown", *(tptr
+6)),
1014 safeputs((const char *)(tptr
+7), 2);
1016 lci_len
= lci_len
-3;
1019 /* Decode each civic address element */
1020 while (lci_len
> 0) {
1030 printf("\n\t CA type \'%s\' (%u), length %u: ",
1031 tok2str(lldp_tia_location_lci_catype_values
, "unknown", ca_type
),
1034 /* basic sanity check */
1035 if ( ca_type
== 0 || ca_len
== 0) {
1038 if (lci_len
< ca_len
) {
1042 safeputs((const char *)tptr
, ca_len
);
1048 case LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN
:
1049 printf("\n\t ECS ELIN id ");
1050 safeputs((const char *)tptr
+5, tlv_len
-5);
1054 printf("\n\t Location ID ");
1055 print_unknown_data(gndo
,tptr
+5, "\n\t ", tlv_len
-5);
1059 case LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI
:
1063 printf("\n\t Power type [%s]",
1064 (*(tptr
+4)&0xC0>>6) ? "PD device" : "PSE device");
1065 printf(", Power source [%s]",
1066 tok2str(lldp_tia_power_source_values
, "none", (*(tptr
+4)&0x30)>>4));
1067 printf("\n\t Power priority [%s] (0x%02x)",
1068 tok2str(lldp_tia_power_priority_values
, "none", *(tptr
+4)&0x0f),
1070 power_val
= EXTRACT_16BITS(tptr
+5);
1071 if (power_val
< LLDP_TIA_POWER_VAL_MAX
) {
1072 printf(", Power %.1f Watts", ((float)power_val
)/10);
1074 printf(", Power %u (Reserved)", power_val
);
1078 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV
:
1079 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV
:
1080 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV
:
1081 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER
:
1082 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME
:
1083 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME
:
1084 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID
:
1086 tok2str(lldp_tia_inventory_values
, "unknown", subtype
));
1087 safeputs((const char *)tptr
+4, tlv_len
-4);
1099 * Print DCBX Protocol fields (V 1.01).
1102 lldp_private_dcbx_print(const u_char
*pptr
, u_int len
)
1104 int subtype
, hexdump
= FALSE
;
1107 u_int32_t i
, pgval
, uval
;
1108 u_int tlen
, tlv_type
, tlv_len
;
1109 const u_char
*tptr
, *mptr
;
1114 subtype
= *(pptr
+3);
1116 printf("\n\t %s Subtype (%u)",
1117 tok2str(lldp_dcbx_subtype_values
, "unknown", subtype
),
1120 /* by passing old version */
1121 if (subtype
== LLDP_DCBX_SUBTYPE_1
)
1127 while (tlen
>= sizeof(tlv
)) {
1129 TCHECK2(*tptr
, sizeof(tlv
));
1131 tlv
= EXTRACT_16BITS(tptr
);
1133 tlv_type
= LLDP_EXTRACT_TYPE(tlv
);
1134 tlv_len
= LLDP_EXTRACT_LEN(tlv
);
1137 tlen
-= sizeof(tlv
);
1138 tptr
+= sizeof(tlv
);
1141 if (!tlv_type
|| !tlv_len
) {
1145 TCHECK2(*tptr
, tlv_len
);
1146 if (tlen
< tlv_len
) {
1150 /* decode every tlv */
1152 case LLDP_DCBX_CONTROL_TLV
:
1156 printf("\n\t Control - Protocol Control (type 0x%x, length %d)",
1157 LLDP_DCBX_CONTROL_TLV
, tlv_len
);
1158 printf("\n\t Oper_Version: %d", *tptr
);
1159 printf("\n\t Max_Version: %d", *(tptr
+1));
1160 printf("\n\t Sequence Number: %d", EXTRACT_32BITS(tptr
+2));
1161 printf("\n\t Acknowledgement Number: %d",
1162 EXTRACT_32BITS(tptr
+6));
1164 case LLDP_DCBX_PRIORITY_GROUPS_TLV
:
1168 printf("\n\t Feature - Priority Group (type 0x%x, length %d)",
1169 LLDP_DCBX_PRIORITY_GROUPS_TLV
, tlv_len
);
1170 printf("\n\t Oper_Version: %d", *tptr
);
1171 printf("\n\t Max_Version: %d", *(tptr
+1));
1172 printf("\n\t Info block(0x%02X): ", *(tptr
+2));
1174 printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
1175 (tval
& 0x80) ? 1 : 0, (tval
& 0x40) ? 1 : 0,
1176 (tval
& 0x20) ? 1 : 0);
1177 printf("\n\t SubType: %d", *(tptr
+3));
1178 printf("\n\t Priority Allocation");
1180 pgval
= EXTRACT_32BITS(tptr
+4);
1181 for (i
= 0; i
<= 7; i
++) {
1182 tval
= *(tptr
+4+(i
/2));
1183 printf("\n\t PgId_%d: %d",
1184 i
, (pgval
>> (28-4*i
)) & 0xF);
1186 printf("\n\t Priority Group Allocation");
1187 for (i
= 0; i
<= 7; i
++)
1188 printf("\n\t Pg percentage[%d]: %d", i
, *(tptr
+8+i
));
1189 printf("\n\t NumTCsSupported: %d", *(tptr
+8+8));
1191 case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV
:
1195 printf("\n\t Feature - Priority Flow Control");
1196 printf(" (type 0x%x, length %d)",
1197 LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV
, tlv_len
);
1198 printf("\n\t Oper_Version: %d", *tptr
);
1199 printf("\n\t Max_Version: %d", *(tptr
+1));
1200 printf("\n\t Info block(0x%02X): ", *(tptr
+2));
1202 printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
1203 (tval
& 0x80) ? 1 : 0, (tval
& 0x40) ? 1 : 0,
1204 (tval
& 0x20) ? 1 : 0);
1205 printf("\n\t SubType: %d", *(tptr
+3));
1207 printf("\n\t PFC Config (0x%02X)", *(tptr
+4));
1208 for (i
= 0; i
<= 7; i
++)
1209 printf("\n\t Priority Bit %d: %s",
1210 i
, (tval
& (1 << i
)) ? "Enabled" : "Disabled");
1211 printf("\n\t NumTCPFCSupported: %d", *(tptr
+5));
1213 case LLDP_DCBX_APPLICATION_TLV
:
1217 printf("\n\t Feature - Application (type 0x%x, length %d)",
1218 LLDP_DCBX_APPLICATION_TLV
, tlv_len
);
1219 printf("\n\t Oper_Version: %d", *tptr
);
1220 printf("\n\t Max_Version: %d", *(tptr
+1));
1221 printf("\n\t Info block(0x%02X): ", *(tptr
+2));
1223 printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
1224 (tval
& 0x80) ? 1 : 0, (tval
& 0x40) ? 1 : 0,
1225 (tval
& 0x20) ? 1 : 0);
1226 printf("\n\t SubType: %d", *(tptr
+3));
1230 printf("\n\t Application Value");
1231 printf("\n\t Application Protocol ID: 0x%04x",
1232 EXTRACT_16BITS(mptr
));
1233 uval
= EXTRACT_24BITS(mptr
+2);
1234 printf("\n\t SF (0x%x) Application Protocol ID is %s",
1236 (uval
>> 22) ? "Socket Number" : "L2 EtherType");
1237 printf("\n\t OUI: 0x%06x", uval
& 0x3fffff);
1238 printf("\n\t User Priority Map: 0x%02x", *(mptr
+5));
1248 /* do we also want to see a hex dump ? */
1249 if (vflag
> 1 || (vflag
&& hexdump
)) {
1250 print_unknown_data(gndo
,tptr
,"\n\t ", tlv_len
);
1262 lldp_network_addr_print(const u_char
*tptr
, u_int len
) {
1265 static char buf
[BUFSIZE
];
1266 const char * (*pfunc
)(const u_char
*);
1288 pfunc
= etheraddr_string
;
1296 snprintf(buf
, sizeof(buf
), "AFI %s (%u), no AF printer !",
1297 tok2str(af_values
, "Unknown", af
), af
);
1299 snprintf(buf
, sizeof(buf
), "AFI %s (%u): %s",
1300 tok2str(af_values
, "Unknown", af
), af
, (*pfunc
)(tptr
+1));
1307 lldp_mgmt_addr_tlv_print(const u_char
*pptr
, u_int len
) {
1309 u_int8_t mgmt_addr_len
, intf_num_subtype
, oid_len
;
1320 mgmt_addr_len
= *tptr
++;
1323 if (tlen
< mgmt_addr_len
) {
1327 mgmt_addr
= lldp_network_addr_print(tptr
, mgmt_addr_len
);
1328 if (mgmt_addr
== NULL
) {
1331 printf("\n\t Management Address length %u, %s",
1332 mgmt_addr_len
, mgmt_addr
);
1333 tptr
+= mgmt_addr_len
;
1334 tlen
-= mgmt_addr_len
;
1336 if (tlen
< LLDP_INTF_NUM_LEN
) {
1340 intf_num_subtype
= *tptr
;
1341 printf("\n\t %s Interface Numbering (%u): %u",
1342 tok2str(lldp_intf_numb_subtype_values
, "Unknown", intf_num_subtype
),
1344 EXTRACT_32BITS(tptr
+1));
1346 tptr
+= LLDP_INTF_NUM_LEN
;
1347 tlen
-= LLDP_INTF_NUM_LEN
;
1350 * The OID is optional.
1355 if (tlen
< oid_len
) {
1359 printf("\n\t OID length %u", oid_len
);
1360 safeputs((const char *)tptr
+1, oid_len
);
1368 lldp_print(register const u_char
*pptr
, register u_int len
) {
1371 u_int16_t tlv
, cap
, ena_cap
;
1372 u_int oui
, tlen
, hexdump
, tlv_type
, tlv_len
;
1379 printf("LLDP, length %u", len
);
1381 while (tlen
>= sizeof(tlv
)) {
1383 TCHECK2(*tptr
, sizeof(tlv
));
1385 tlv
= EXTRACT_16BITS(tptr
);
1387 tlv_type
= LLDP_EXTRACT_TYPE(tlv
);
1388 tlv_len
= LLDP_EXTRACT_LEN(tlv
);
1391 tlen
-= sizeof(tlv
);
1392 tptr
+= sizeof(tlv
);
1395 printf("\n\t%s TLV (%u), length %u",
1396 tok2str(lldp_tlv_values
, "Unknown", tlv_type
),
1400 /* infinite loop check */
1401 if (!tlv_type
|| !tlv_len
) {
1405 TCHECK2(*tptr
, tlv_len
);
1406 if (tlen
< tlv_len
) {
1412 case LLDP_CHASSIS_ID_TLV
:
1418 printf("\n\t Subtype %s (%u): ",
1419 tok2str(lldp_chassis_subtype_values
, "Unknown", subtype
),
1423 case LLDP_CHASSIS_MAC_ADDR_SUBTYPE
:
1424 if (tlv_len
< 1+6) {
1427 printf("%s", etheraddr_string(tptr
+1));
1430 case LLDP_CHASSIS_INTF_NAME_SUBTYPE
: /* fall through */
1431 case LLDP_CHASSIS_LOCAL_SUBTYPE
:
1432 case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE
:
1433 case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE
:
1434 case LLDP_CHASSIS_PORT_COMP_SUBTYPE
:
1435 safeputs((const char *)tptr
+1, tlv_len
-1);
1438 case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE
:
1439 network_addr
= lldp_network_addr_print(tptr
+1, tlv_len
-1);
1440 if (network_addr
== NULL
) {
1443 printf("%s", network_addr
);
1453 case LLDP_PORT_ID_TLV
:
1459 printf("\n\t Subtype %s (%u): ",
1460 tok2str(lldp_port_subtype_values
, "Unknown", subtype
),
1464 case LLDP_PORT_MAC_ADDR_SUBTYPE
:
1465 if (tlv_len
< 1+6) {
1468 printf("%s", etheraddr_string(tptr
+1));
1471 case LLDP_PORT_INTF_NAME_SUBTYPE
: /* fall through */
1472 case LLDP_PORT_LOCAL_SUBTYPE
:
1473 case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE
:
1474 case LLDP_PORT_INTF_ALIAS_SUBTYPE
:
1475 case LLDP_PORT_PORT_COMP_SUBTYPE
:
1476 safeputs((const char *)tptr
+1, tlv_len
-1);
1479 case LLDP_PORT_NETWORK_ADDR_SUBTYPE
:
1480 network_addr
= lldp_network_addr_print(tptr
+1, tlv_len
-1);
1481 if (network_addr
== NULL
) {
1484 printf("%s", network_addr
);
1499 printf(": TTL %us", EXTRACT_16BITS(tptr
));
1503 case LLDP_PORT_DESCR_TLV
:
1506 safeputs((const char *)tptr
, tlv_len
);
1510 case LLDP_SYSTEM_NAME_TLV
:
1512 * The system name is also print in non-verbose mode
1513 * similar to the CDP printer.
1516 safeputs((const char *)tptr
, tlv_len
);
1519 case LLDP_SYSTEM_DESCR_TLV
:
1522 safeputs((const char *)tptr
, tlv_len
);
1526 case LLDP_SYSTEM_CAP_TLV
:
1529 * XXX - IEEE Std 802.1AB-2009 says the first octet
1530 * if a chassis ID subtype, with the system
1531 * capabilities and enabled capabilities following
1537 cap
= EXTRACT_16BITS(tptr
);
1538 ena_cap
= EXTRACT_16BITS(tptr
+2);
1539 printf("\n\t System Capabilities [%s] (0x%04x)",
1540 bittok2str(lldp_cap_values
, "none", cap
), cap
);
1541 printf("\n\t Enabled Capabilities [%s] (0x%04x)",
1542 bittok2str(lldp_cap_values
, "none", ena_cap
), ena_cap
);
1546 case LLDP_MGMT_ADDR_TLV
:
1548 if (!lldp_mgmt_addr_tlv_print(tptr
, tlv_len
)) {
1554 case LLDP_PRIVATE_TLV
:
1559 oui
= EXTRACT_24BITS(tptr
);
1560 printf(": OUI %s (0x%06x)", tok2str(oui_values
, "Unknown", oui
), oui
);
1563 case OUI_IEEE_8021_PRIVATE
:
1564 hexdump
= lldp_private_8021_print(tptr
, tlv_len
);
1566 case OUI_IEEE_8023_PRIVATE
:
1567 hexdump
= lldp_private_8023_print(tptr
, tlv_len
);
1570 hexdump
= lldp_private_tia_print(tptr
, tlv_len
);
1573 hexdump
= lldp_private_dcbx_print(tptr
, tlv_len
);
1587 /* do we also want to see a hex dump ? */
1588 if (vflag
> 1 || (vflag
&& hexdump
)) {
1589 print_unknown_data(gndo
,tptr
,"\n\t ", tlv_len
);
1597 printf("\n\t[|LLDP]");
1602 * c-style: whitesmith