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
147 static const struct tok lldp_8021_subtype_values
[] = {
148 { LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID
, "Port VLAN Id"},
149 { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID
, "Port and Protocol VLAN ID"},
150 { LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME
, "VLAN name"},
151 { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY
, "Protocol Identity"},
155 #define LLDP_8021_PORT_PROTOCOL_VLAN_SUPPORT (1 << 1)
156 #define LLDP_8021_PORT_PROTOCOL_VLAN_STATUS (1 << 2)
158 static const struct tok lldp_8021_port_protocol_id_values
[] = {
159 { LLDP_8021_PORT_PROTOCOL_VLAN_SUPPORT
, "supported"},
160 { LLDP_8021_PORT_PROTOCOL_VLAN_STATUS
, "enabled"},
164 #define LLDP_PRIVATE_8023_SUBTYPE_MACPHY 1
165 #define LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER 2
166 #define LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR 3
167 #define LLDP_PRIVATE_8023_SUBTYPE_MTU 4
169 static const struct tok lldp_8023_subtype_values
[] = {
170 { LLDP_PRIVATE_8023_SUBTYPE_MACPHY
, "MAC/PHY configuration/status"},
171 { LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER
, "Power via MDI"},
172 { LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR
, "Link aggregation"},
173 { LLDP_PRIVATE_8023_SUBTYPE_MTU
, "Max frame size"},
177 #define LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES 1
178 #define LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY 2
179 #define LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID 3
180 #define LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI 4
181 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV 5
182 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV 6
183 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV 7
184 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER 8
185 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME 9
186 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME 10
187 #define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID 11
189 static const struct tok lldp_tia_subtype_values
[] = {
190 { LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES
, "LLDP-MED Capabilities" },
191 { LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY
, "Network policy" },
192 { LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID
, "Location identification" },
193 { LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI
, "Extended power-via-MDI" },
194 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV
, "Inventory - hardware revision" },
195 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV
, "Inventory - firmware revision" },
196 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV
, "Inventory - software revision" },
197 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER
, "Inventory - serial number" },
198 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME
, "Inventory - manufacturer name" },
199 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME
, "Inventory - model name" },
200 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID
, "Inventory - asset ID" },
204 #define LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_METERS 1
205 #define LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_FLOORS 2
207 static const struct tok lldp_tia_location_altitude_type_values
[] = {
208 { LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_METERS
, "meters"},
209 { LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_FLOORS
, "floors"},
213 /* ANSI/TIA-1057 - Annex B */
214 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A1 1
215 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A2 2
216 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A3 3
217 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A4 4
218 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A5 5
219 #define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A6 6
221 static const struct tok lldp_tia_location_lci_catype_values
[] = {
222 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A1
, "national subdivisions (state,canton,region,province,prefecture)"},
223 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A2
, "county, parish, gun, district"},
224 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A3
, "city, township, shi"},
225 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A4
, "city division, borough, city district, ward chou"},
226 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A5
, "neighborhood, block"},
227 { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A6
, "street"},
231 static const struct tok lldp_tia_location_lci_what_values
[] = {
232 { 0, "location of DHCP server"},
233 { 1, "location of the network element believed to be closest to the client"},
234 { 2, "location of the client"},
239 * From RFC 3636 - dot3MauType
241 #define LLDP_MAU_TYPE_UNKNOWN 0
242 #define LLDP_MAU_TYPE_AUI 1
243 #define LLDP_MAU_TYPE_10BASE_5 2
244 #define LLDP_MAU_TYPE_FOIRL 3
245 #define LLDP_MAU_TYPE_10BASE_2 4
246 #define LLDP_MAU_TYPE_10BASE_T 5
247 #define LLDP_MAU_TYPE_10BASE_FP 6
248 #define LLDP_MAU_TYPE_10BASE_FB 7
249 #define LLDP_MAU_TYPE_10BASE_FL 8
250 #define LLDP_MAU_TYPE_10BROAD36 9
251 #define LLDP_MAU_TYPE_10BASE_T_HD 10
252 #define LLDP_MAU_TYPE_10BASE_T_FD 11
253 #define LLDP_MAU_TYPE_10BASE_FL_HD 12
254 #define LLDP_MAU_TYPE_10BASE_FL_FD 13
255 #define LLDP_MAU_TYPE_100BASE_T4 14
256 #define LLDP_MAU_TYPE_100BASE_TX_HD 15
257 #define LLDP_MAU_TYPE_100BASE_TX_FD 16
258 #define LLDP_MAU_TYPE_100BASE_FX_HD 17
259 #define LLDP_MAU_TYPE_100BASE_FX_FD 18
260 #define LLDP_MAU_TYPE_100BASE_T2_HD 19
261 #define LLDP_MAU_TYPE_100BASE_T2_FD 20
262 #define LLDP_MAU_TYPE_1000BASE_X_HD 21
263 #define LLDP_MAU_TYPE_1000BASE_X_FD 22
264 #define LLDP_MAU_TYPE_1000BASE_LX_HD 23
265 #define LLDP_MAU_TYPE_1000BASE_LX_FD 24
266 #define LLDP_MAU_TYPE_1000BASE_SX_HD 25
267 #define LLDP_MAU_TYPE_1000BASE_SX_FD 26
268 #define LLDP_MAU_TYPE_1000BASE_CX_HD 27
269 #define LLDP_MAU_TYPE_1000BASE_CX_FD 28
270 #define LLDP_MAU_TYPE_1000BASE_T_HD 29
271 #define LLDP_MAU_TYPE_1000BASE_T_FD 30
272 #define LLDP_MAU_TYPE_10GBASE_X 31
273 #define LLDP_MAU_TYPE_10GBASE_LX4 32
274 #define LLDP_MAU_TYPE_10GBASE_R 33
275 #define LLDP_MAU_TYPE_10GBASE_ER 34
276 #define LLDP_MAU_TYPE_10GBASE_LR 35
277 #define LLDP_MAU_TYPE_10GBASE_SR 36
278 #define LLDP_MAU_TYPE_10GBASE_W 37
279 #define LLDP_MAU_TYPE_10GBASE_EW 38
280 #define LLDP_MAU_TYPE_10GBASE_LW 39
281 #define LLDP_MAU_TYPE_10GBASE_SW 40
283 static const struct tok lldp_mau_types_values
[] = {
284 { LLDP_MAU_TYPE_UNKNOWN
, "Unknown"},
285 { LLDP_MAU_TYPE_AUI
, "AUI"},
286 { LLDP_MAU_TYPE_10BASE_5
, "10BASE_5"},
287 { LLDP_MAU_TYPE_FOIRL
, "FOIRL"},
288 { LLDP_MAU_TYPE_10BASE_2
, "10BASE2"},
289 { LLDP_MAU_TYPE_10BASE_T
, "10BASET duplex mode unknown"},
290 { LLDP_MAU_TYPE_10BASE_FP
, "10BASEFP"},
291 { LLDP_MAU_TYPE_10BASE_FB
, "10BASEFB"},
292 { LLDP_MAU_TYPE_10BASE_FL
, "10BASEFL duplex mode unknown"},
293 { LLDP_MAU_TYPE_10BROAD36
, "10BROAD36"},
294 { LLDP_MAU_TYPE_10BASE_T_HD
, "10BASET hdx"},
295 { LLDP_MAU_TYPE_10BASE_T_FD
, "10BASET fdx"},
296 { LLDP_MAU_TYPE_10BASE_FL_HD
, "10BASEFL hdx"},
297 { LLDP_MAU_TYPE_10BASE_FL_FD
, "10BASEFL fdx"},
298 { LLDP_MAU_TYPE_100BASE_T4
, "100BASET4"},
299 { LLDP_MAU_TYPE_100BASE_TX_HD
, "100BASETX hdx"},
300 { LLDP_MAU_TYPE_100BASE_TX_FD
, "100BASETX fdx"},
301 { LLDP_MAU_TYPE_100BASE_FX_HD
, "100BASEFX hdx"},
302 { LLDP_MAU_TYPE_100BASE_FX_FD
, "100BASEFX fdx"},
303 { LLDP_MAU_TYPE_100BASE_T2_HD
, "100BASET2 hdx"},
304 { LLDP_MAU_TYPE_100BASE_T2_FD
, "100BASET2 fdx"},
305 { LLDP_MAU_TYPE_1000BASE_X_HD
, "1000BASEX hdx"},
306 { LLDP_MAU_TYPE_1000BASE_X_FD
, "1000BASEX fdx"},
307 { LLDP_MAU_TYPE_1000BASE_LX_HD
, "1000BASELX hdx"},
308 { LLDP_MAU_TYPE_1000BASE_LX_FD
, "1000BASELX fdx"},
309 { LLDP_MAU_TYPE_1000BASE_SX_HD
, "1000BASESX hdx"},
310 { LLDP_MAU_TYPE_1000BASE_SX_FD
, "1000BASESX fdx"},
311 { LLDP_MAU_TYPE_1000BASE_CX_HD
, "1000BASECX hdx"},
312 { LLDP_MAU_TYPE_1000BASE_CX_FD
, "1000BASECX fdx"},
313 { LLDP_MAU_TYPE_1000BASE_T_HD
, "1000BASET hdx"},
314 { LLDP_MAU_TYPE_1000BASE_T_FD
, "1000BASET fdx"},
315 { LLDP_MAU_TYPE_10GBASE_X
, "10GBASEX"},
316 { LLDP_MAU_TYPE_10GBASE_LX4
, "10GBASELX4"},
317 { LLDP_MAU_TYPE_10GBASE_R
, "10GBASER"},
318 { LLDP_MAU_TYPE_10GBASE_ER
, "10GBASEER"},
319 { LLDP_MAU_TYPE_10GBASE_LR
, "10GBASELR"},
320 { LLDP_MAU_TYPE_10GBASE_SR
, "10GBASESR"},
321 { LLDP_MAU_TYPE_10GBASE_W
, "10GBASEW"},
322 { LLDP_MAU_TYPE_10GBASE_EW
, "10GBASEEW"},
323 { LLDP_MAU_TYPE_10GBASE_LW
, "10GBASELW"},
324 { LLDP_MAU_TYPE_10GBASE_SW
, "10GBASESW"},
328 #define LLDP_8023_AUTONEGOTIATION_SUPPORT (1 << 0)
329 #define LLDP_8023_AUTONEGOTIATION_STATUS (1 << 1)
331 static const struct tok lldp_8023_autonegotiation_values
[] = {
332 { LLDP_8023_AUTONEGOTIATION_SUPPORT
, "supported"},
333 { LLDP_8023_AUTONEGOTIATION_STATUS
, "enabled"},
337 #define LLDP_TIA_CAPABILITY_MED (1 << 0)
338 #define LLDP_TIA_CAPABILITY_NETWORK_POLICY (1 << 1)
339 #define LLDP_TIA_CAPABILITY_LOCATION_IDENTIFICATION (1 << 2)
340 #define LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PSE (1 << 3)
341 #define LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PD (1 << 4)
342 #define LLDP_TIA_CAPABILITY_INVENTORY (1 << 5)
344 static const struct tok lldp_tia_capabilities_values
[] = {
345 { LLDP_TIA_CAPABILITY_MED
, "LLDP-MED capabilities"},
346 { LLDP_TIA_CAPABILITY_NETWORK_POLICY
, "network policy"},
347 { LLDP_TIA_CAPABILITY_LOCATION_IDENTIFICATION
, "location identification"},
348 { LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PSE
, "extended power via MDI-PSE"},
349 { LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PD
, "extended power via MDI-PD"},
350 { LLDP_TIA_CAPABILITY_INVENTORY
, "Inventory"},
354 #define LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_1 1
355 #define LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_2 2
356 #define LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_3 3
357 #define LLDP_TIA_DEVICE_TYPE_NETWORK_CONNECTIVITY 4
359 static const struct tok lldp_tia_device_type_values
[] = {
360 { LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_1
, "endpoint class 1"},
361 { LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_2
, "endpoint class 2"},
362 { LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_3
, "endpoint class 3"},
363 { LLDP_TIA_DEVICE_TYPE_NETWORK_CONNECTIVITY
, "network connectivity"},
367 #define LLDP_TIA_APPLICATION_TYPE_VOICE 1
368 #define LLDP_TIA_APPLICATION_TYPE_VOICE_SIGNALING 2
369 #define LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE 3
370 #define LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE_SIGNALING 4
371 #define LLDP_TIA_APPLICATION_TYPE_SOFTPHONE_VOICE 5
372 #define LLDP_TIA_APPLICATION_TYPE_VIDEO_CONFERENCING 6
373 #define LLDP_TIA_APPLICATION_TYPE_STREAMING_VIDEO 7
374 #define LLDP_TIA_APPLICATION_TYPE_VIDEO_SIGNALING 8
376 static const struct tok lldp_tia_application_type_values
[] = {
377 { LLDP_TIA_APPLICATION_TYPE_VOICE
, "voice"},
378 { LLDP_TIA_APPLICATION_TYPE_VOICE_SIGNALING
, "voice signaling"},
379 { LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE
, "guest voice"},
380 { LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE_SIGNALING
, "guest voice signaling"},
381 { LLDP_TIA_APPLICATION_TYPE_SOFTPHONE_VOICE
, "softphone voice"},
382 { LLDP_TIA_APPLICATION_TYPE_VIDEO_CONFERENCING
, "video conferencing"},
383 { LLDP_TIA_APPLICATION_TYPE_STREAMING_VIDEO
, "streaming video"},
384 { LLDP_TIA_APPLICATION_TYPE_VIDEO_SIGNALING
, "video signaling"},
388 #define LLDP_TIA_NETWORK_POLICY_X_BIT (1 << 5)
389 #define LLDP_TIA_NETWORK_POLICY_T_BIT (1 << 6)
390 #define LLDP_TIA_NETWORK_POLICY_U_BIT (1 << 7)
392 static const struct tok lldp_tia_network_policy_bits_values
[] = {
393 { LLDP_TIA_NETWORK_POLICY_U_BIT
, "Unknown"},
394 { LLDP_TIA_NETWORK_POLICY_T_BIT
, "Tagged"},
395 { LLDP_TIA_NETWORK_POLICY_X_BIT
, "reserved"},
399 #define LLDP_EXTRACT_NETWORK_POLICY_VLAN(x) (((x)&0x1ffe)>>1)
400 #define LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(x) (((x)&0x01ff)>>6)
401 #define LLDP_EXTRACT_NETWORK_POLICY_DSCP(x) ((x)&0x003f)
403 #define LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED 1
404 #define LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS 2
405 #define LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN 3
407 static const struct tok lldp_tia_location_data_format_values
[] = {
408 { LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED
, "coordinate-based LCI"},
409 { LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS
, "civic address LCI"},
410 { LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN
, "ECS ELIN"},
414 #define LLDP_TIA_LOCATION_DATUM_WGS_84 1
415 #define LLDP_TIA_LOCATION_DATUM_NAD_83_NAVD_88 2
416 #define LLDP_TIA_LOCATION_DATUM_NAD_83_MLLW 3
418 static const struct tok lldp_tia_location_datum_type_values
[] = {
419 { LLDP_TIA_LOCATION_DATUM_WGS_84
, "World Geodesic System 1984"},
420 { LLDP_TIA_LOCATION_DATUM_NAD_83_NAVD_88
, "North American Datum 1983 (NAVD88)"},
421 { LLDP_TIA_LOCATION_DATUM_NAD_83_MLLW
, "North American Datum 1983 (MLLW)"},
425 #define LLDP_TIA_POWER_SOURCE_PSE 1
426 #define LLDP_TIA_POWER_SOURCE_LOCAL 2
427 #define LLDP_TIA_POWER_SOURCE_PSE_AND_LOCAL 3
429 static const struct tok lldp_tia_power_source_values
[] = {
430 { LLDP_TIA_POWER_SOURCE_PSE
, "PSE - primary power source"},
431 { LLDP_TIA_POWER_SOURCE_LOCAL
, "local - backup power source"},
432 { LLDP_TIA_POWER_SOURCE_PSE_AND_LOCAL
, "PSE+local - reserved"},
436 #define LLDP_TIA_POWER_PRIORITY_CRITICAL 1
437 #define LLDP_TIA_POWER_PRIORITY_HIGH 2
438 #define LLDP_TIA_POWER_PRIORITY_LOW 3
440 static const struct tok lldp_tia_power_priority_values
[] = {
441 { LLDP_TIA_POWER_PRIORITY_CRITICAL
, "critical"},
442 { LLDP_TIA_POWER_PRIORITY_HIGH
, "high"},
443 { LLDP_TIA_POWER_PRIORITY_LOW
, "low"},
447 #define LLDP_TIA_POWER_VAL_MAX 1024
449 static const struct tok lldp_tia_inventory_values
[] = {
450 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV
, "Hardware revision" },
451 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV
, "Firmware revision" },
452 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV
, "Software revision" },
453 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER
, "Serial number" },
454 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME
, "Manufacturer name" },
455 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME
, "Model name" },
456 { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID
, "Asset ID" },
461 * From RFC 3636 - ifMauAutoNegCapAdvertisedBits
463 #define LLDP_MAU_PMD_OTHER (1 << 15)
464 #define LLDP_MAU_PMD_10BASE_T (1 << 14)
465 #define LLDP_MAU_PMD_10BASE_T_FD (1 << 13)
466 #define LLDP_MAU_PMD_100BASE_T4 (1 << 12)
467 #define LLDP_MAU_PMD_100BASE_TX (1 << 11)
468 #define LLDP_MAU_PMD_100BASE_TX_FD (1 << 10)
469 #define LLDP_MAU_PMD_100BASE_T2 (1 << 9)
470 #define LLDP_MAU_PMD_100BASE_T2_FD (1 << 8)
471 #define LLDP_MAU_PMD_FDXPAUSE (1 << 7)
472 #define LLDP_MAU_PMD_FDXAPAUSE (1 << 6)
473 #define LLDP_MAU_PMD_FDXSPAUSE (1 << 5)
474 #define LLDP_MAU_PMD_FDXBPAUSE (1 << 4)
475 #define LLDP_MAU_PMD_1000BASE_X (1 << 3)
476 #define LLDP_MAU_PMD_1000BASE_X_FD (1 << 2)
477 #define LLDP_MAU_PMD_1000BASE_T (1 << 1)
478 #define LLDP_MAU_PMD_1000BASE_T_FD (1 << 0)
480 static const struct tok lldp_pmd_capability_values
[] = {
481 { LLDP_MAU_PMD_10BASE_T
, "10BASE-T hdx"},
482 { LLDP_MAU_PMD_10BASE_T_FD
, "10BASE-T fdx"},
483 { LLDP_MAU_PMD_100BASE_T4
, "100BASE-T4"},
484 { LLDP_MAU_PMD_100BASE_TX
, "100BASE-TX hdx"},
485 { LLDP_MAU_PMD_100BASE_TX_FD
, "100BASE-TX fdx"},
486 { LLDP_MAU_PMD_100BASE_T2
, "100BASE-T2 hdx"},
487 { LLDP_MAU_PMD_100BASE_T2_FD
, "100BASE-T2 fdx"},
488 { LLDP_MAU_PMD_FDXPAUSE
, "Pause for fdx links"},
489 { LLDP_MAU_PMD_FDXAPAUSE
, "Asym PAUSE for fdx"},
490 { LLDP_MAU_PMD_FDXSPAUSE
, "Sym PAUSE for fdx"},
491 { LLDP_MAU_PMD_FDXBPAUSE
, "Asym and Sym PAUSE for fdx"},
492 { LLDP_MAU_PMD_1000BASE_X
, "1000BASE-{X LX SX CX} hdx"},
493 { LLDP_MAU_PMD_1000BASE_X_FD
, "1000BASE-{X LX SX CX} fdx"},
494 { LLDP_MAU_PMD_1000BASE_T
, "1000BASE-T hdx"},
495 { LLDP_MAU_PMD_1000BASE_T_FD
, "1000BASE-T fdx"},
499 #define LLDP_MDI_PORT_CLASS (1 << 0)
500 #define LLDP_MDI_POWER_SUPPORT (1 << 1)
501 #define LLDP_MDI_POWER_STATE (1 << 2)
502 #define LLDP_MDI_PAIR_CONTROL_ABILITY (1 << 3)
504 static const struct tok lldp_mdi_values
[] = {
505 { LLDP_MDI_PORT_CLASS
, "PSE"},
506 { LLDP_MDI_POWER_SUPPORT
, "supported"},
507 { LLDP_MDI_POWER_STATE
, "enabled"},
508 { LLDP_MDI_PAIR_CONTROL_ABILITY
, "can be controlled"},
512 #define LLDP_MDI_PSE_PORT_POWER_PAIRS_SIGNAL 1
513 #define LLDP_MDI_PSE_PORT_POWER_PAIRS_SPARE 2
515 static const struct tok lldp_mdi_power_pairs_values
[] = {
516 { LLDP_MDI_PSE_PORT_POWER_PAIRS_SIGNAL
, "signal"},
517 { LLDP_MDI_PSE_PORT_POWER_PAIRS_SPARE
, "spare"},
521 #define LLDP_MDI_POWER_CLASS0 1
522 #define LLDP_MDI_POWER_CLASS1 2
523 #define LLDP_MDI_POWER_CLASS2 3
524 #define LLDP_MDI_POWER_CLASS3 4
525 #define LLDP_MDI_POWER_CLASS4 5
527 static const struct tok lldp_mdi_power_class_values
[] = {
528 { LLDP_MDI_POWER_CLASS0
, "class0"},
529 { LLDP_MDI_POWER_CLASS1
, "class1"},
530 { LLDP_MDI_POWER_CLASS2
, "class2"},
531 { LLDP_MDI_POWER_CLASS3
, "class3"},
532 { LLDP_MDI_POWER_CLASS4
, "class4"},
536 #define LLDP_AGGREGATION_CAPABILTIY (1 << 0)
537 #define LLDP_AGGREGATION_STATUS (1 << 1)
539 static const struct tok lldp_aggregation_values
[] = {
540 { LLDP_AGGREGATION_CAPABILTIY
, "supported"},
541 { LLDP_AGGREGATION_STATUS
, "enabled"},
546 * DCBX protocol subtypes.
548 #define LLDP_DCBX_SUBTYPE_1 1
549 #define LLDP_DCBX_SUBTYPE_2 2
551 static const struct tok lldp_dcbx_subtype_values
[] = {
552 { LLDP_DCBX_SUBTYPE_1
, "DCB Capability Exchange Protocol Rev 1" },
553 { LLDP_DCBX_SUBTYPE_2
, "DCB Capability Exchange Protocol Rev 1.01" },
557 #define LLDP_DCBX_CONTROL_TLV 1
558 #define LLDP_DCBX_PRIORITY_GROUPS_TLV 2
559 #define LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV 3
560 #define LLDP_DCBX_APPLICATION_TLV 4
563 * Interface numbering subtypes.
565 #define LLDP_INTF_NUMB_IFX_SUBTYPE 2
566 #define LLDP_INTF_NUMB_SYSPORT_SUBTYPE 3
568 static const struct tok lldp_intf_numb_subtype_values
[] = {
569 { LLDP_INTF_NUMB_IFX_SUBTYPE
, "Interface Index" },
570 { LLDP_INTF_NUMB_SYSPORT_SUBTYPE
, "System Port Number" },
574 #define LLDP_INTF_NUM_LEN 5
577 * Print IEEE 802.1 private extensions. (802.1AB annex E)
580 lldp_private_8021_print(const u_char
*tptr
, u_int tlv_len
)
582 int subtype
, hexdump
= FALSE
;
590 printf("\n\t %s Subtype (%u)",
591 tok2str(lldp_8021_subtype_values
, "unknown", subtype
),
595 case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID
:
599 printf("\n\t port vlan id (PVID): %u",
600 EXTRACT_16BITS(tptr
+4));
602 case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID
:
606 printf("\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
607 EXTRACT_16BITS(tptr
+5),
608 bittok2str(lldp_8021_port_protocol_id_values
, "none", *(tptr
+4)),
611 case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME
:
615 printf("\n\t vlan id (VID): %u",
616 EXTRACT_16BITS(tptr
+4));
621 if (tlv_len
< 7+sublen
) {
624 printf("\n\t vlan name: ");
625 safeputs((const char *)tptr
+7, sublen
);
627 case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY
:
632 if (tlv_len
< 5+sublen
) {
635 printf("\n\t protocol identity: ");
636 safeputs((const char *)tptr
+5, sublen
);
648 * Print IEEE 802.3 private extensions. (802.3bc)
651 lldp_private_8023_print(const u_char
*tptr
, u_int tlv_len
)
653 int subtype
, hexdump
= FALSE
;
660 printf("\n\t %s Subtype (%u)",
661 tok2str(lldp_8023_subtype_values
, "unknown", subtype
),
665 case LLDP_PRIVATE_8023_SUBTYPE_MACPHY
:
669 printf("\n\t autonegotiation [%s] (0x%02x)",
670 bittok2str(lldp_8023_autonegotiation_values
, "none", *(tptr
+4)),
672 printf("\n\t PMD autoneg capability [%s] (0x%04x)",
673 bittok2str(lldp_pmd_capability_values
,"unknown", EXTRACT_16BITS(tptr
+5)),
674 EXTRACT_16BITS(tptr
+5));
675 printf("\n\t MAU type %s (0x%04x)",
676 tok2str(lldp_mau_types_values
, "unknown", EXTRACT_16BITS(tptr
+7)),
677 EXTRACT_16BITS(tptr
+7));
680 case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER
:
684 printf("\n\t MDI power support [%s], power pair %s, power class %s",
685 bittok2str(lldp_mdi_values
, "none", *(tptr
+4)),
686 tok2str(lldp_mdi_power_pairs_values
, "unknown", *(tptr
+5)),
687 tok2str(lldp_mdi_power_class_values
, "unknown", *(tptr
+6)));
690 case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR
:
694 printf("\n\t aggregation status [%s], aggregation port ID %u",
695 bittok2str(lldp_aggregation_values
, "none", *(tptr
+4)),
696 EXTRACT_32BITS(tptr
+5));
699 case LLDP_PRIVATE_8023_SUBTYPE_MTU
:
700 printf("\n\t MTU size %u", EXTRACT_16BITS(tptr
+4));
712 * Extract 34bits of latitude/longitude coordinates.
715 lldp_extract_latlon(const u_char
*tptr
)
719 latlon
= *tptr
& 0x3;
720 latlon
= (latlon
<< 32) | EXTRACT_32BITS(tptr
+1);
726 * Print private TIA extensions.
729 lldp_private_tia_print(const u_char
*tptr
, u_int tlv_len
)
731 int subtype
, hexdump
= FALSE
;
732 u_int8_t location_format
;
735 u_int8_t ca_type
, ca_len
;
742 printf("\n\t %s Subtype (%u)",
743 tok2str(lldp_tia_subtype_values
, "unknown", subtype
),
747 case LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES
:
751 printf("\n\t Media capabilities [%s] (0x%04x)",
752 bittok2str(lldp_tia_capabilities_values
, "none",
753 EXTRACT_16BITS(tptr
+4)), EXTRACT_16BITS(tptr
+4));
754 printf("\n\t Device type [%s] (0x%02x)",
755 tok2str(lldp_tia_device_type_values
, "unknown", *(tptr
+6)),
759 case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY
:
763 printf("\n\t Application type [%s] (0x%02x)",
764 tok2str(lldp_tia_application_type_values
, "none", *(tptr
+4)),
766 printf(", Flags [%s]", bittok2str(
767 lldp_tia_network_policy_bits_values
, "none", *(tptr
+5)));
768 printf("\n\t Vlan id %u",
769 LLDP_EXTRACT_NETWORK_POLICY_VLAN(EXTRACT_16BITS(tptr
+5)));
770 printf(", L2 priority %u",
771 LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(EXTRACT_16BITS(tptr
+6)));
772 printf(", DSCP value %u",
773 LLDP_EXTRACT_NETWORK_POLICY_DSCP(EXTRACT_16BITS(tptr
+6)));
776 case LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID
:
780 location_format
= *(tptr
+4);
781 printf("\n\t Location data format %s (0x%02x)",
782 tok2str(lldp_tia_location_data_format_values
, "unknown", location_format
),
785 switch (location_format
) {
786 case LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED
:
790 printf("\n\t Latitude resolution %u, latitude value %" PRIu64
,
791 (*(tptr
+5)>>2), lldp_extract_latlon(tptr
+5));
792 printf("\n\t Longitude resolution %u, longitude value %" PRIu64
,
793 (*(tptr
+10)>>2), lldp_extract_latlon(tptr
+10));
794 printf("\n\t Altitude type %s (%u)",
795 tok2str(lldp_tia_location_altitude_type_values
, "unknown",(*(tptr
+15)>>4)),
797 printf("\n\t Altitude resolution %u, altitude value 0x%x",
798 (EXTRACT_16BITS(tptr
+15)>>6)&0x3f,
799 ((EXTRACT_32BITS(tptr
+16)&0x3fffffff)));
800 printf("\n\t Datum %s (0x%02x)",
801 tok2str(lldp_tia_location_datum_type_values
, "unknown", *(tptr
+20)),
805 case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS
:
813 if (tlv_len
< 7+lci_len
) {
816 printf("\n\t LCI length %u, LCI what %s (0x%02x), Country-code ",
818 tok2str(lldp_tia_location_lci_what_values
, "unknown", *(tptr
+6)),
822 safeputs((const char *)(tptr
+7), 2);
827 /* Decode each civic address element */
828 while (lci_len
> 0) {
838 printf("\n\t CA type \'%s\' (%u), length %u: ",
839 tok2str(lldp_tia_location_lci_catype_values
, "unknown", ca_type
),
842 /* basic sanity check */
843 if ( ca_type
== 0 || ca_len
== 0) {
846 if (lci_len
< ca_len
) {
850 safeputs((const char *)tptr
, ca_len
);
856 case LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN
:
857 printf("\n\t ECS ELIN id ");
858 safeputs((const char *)tptr
+5, tlv_len
-5);
862 printf("\n\t Location ID ");
863 print_unknown_data(tptr
+5, "\n\t ", tlv_len
-5);
867 case LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI
:
871 printf("\n\t Power type [%s]",
872 (*(tptr
+4)&0xC0>>6) ? "PD device" : "PSE device");
873 printf(", Power source [%s]",
874 tok2str(lldp_tia_power_source_values
, "none", (*(tptr
+4)&0x30)>>4));
875 printf("\n\t Power priority [%s] (0x%02x)",
876 tok2str(lldp_tia_power_priority_values
, "none", *(tptr
+4)&0x0f),
878 power_val
= EXTRACT_16BITS(tptr
+5);
879 if (power_val
< LLDP_TIA_POWER_VAL_MAX
) {
880 printf(", Power %.1f Watts", ((float)power_val
)/10);
882 printf(", Power %u (Reserved)", power_val
);
886 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV
:
887 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV
:
888 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV
:
889 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER
:
890 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME
:
891 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME
:
892 case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID
:
894 tok2str(lldp_tia_inventory_values
, "unknown", subtype
));
895 safeputs((const char *)tptr
+4, tlv_len
-4);
907 * Print DCBX Protocol fields (V 1.01).
910 lldp_private_dcbx_print(const u_char
*pptr
, u_int len
)
912 int subtype
, hexdump
= FALSE
;
915 u_int32_t i
, pgval
, uval
;
916 u_int tlen
, tlv_type
, tlv_len
;
917 const u_char
*tptr
, *mptr
;
924 printf("\n\t %s Subtype (%u)",
925 tok2str(lldp_dcbx_subtype_values
, "unknown", subtype
),
928 /* by passing old version */
929 if (subtype
== LLDP_DCBX_SUBTYPE_1
)
935 while (tlen
>= sizeof(tlv
)) {
937 TCHECK2(*tptr
, sizeof(tlv
));
939 tlv
= EXTRACT_16BITS(tptr
);
941 tlv_type
= LLDP_EXTRACT_TYPE(tlv
);
942 tlv_len
= LLDP_EXTRACT_LEN(tlv
);
949 if (!tlv_type
|| !tlv_len
) {
953 TCHECK2(*tptr
, tlv_len
);
954 if (tlen
< tlv_len
) {
958 /* decode every tlv */
960 case LLDP_DCBX_CONTROL_TLV
:
964 printf("\n\t Control - Protocol Control (type 0x%x, length %d)",
965 LLDP_DCBX_CONTROL_TLV
, tlv_len
);
966 printf("\n\t Oper_Version: %d", *tptr
);
967 printf("\n\t Max_Version: %d", *(tptr
+1));
968 printf("\n\t Sequence Number: %d", EXTRACT_32BITS(tptr
+2));
969 printf("\n\t Acknowledgement Number: %d",
970 EXTRACT_32BITS(tptr
+6));
972 case LLDP_DCBX_PRIORITY_GROUPS_TLV
:
976 printf("\n\t Feature - Priority Group (type 0x%x, length %d)",
977 LLDP_DCBX_PRIORITY_GROUPS_TLV
, tlv_len
);
978 printf("\n\t Oper_Version: %d", *tptr
);
979 printf("\n\t Max_Version: %d", *(tptr
+1));
980 printf("\n\t Info block(0x%02X): ", *(tptr
+2));
982 printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
983 (tval
& 0x80) ? 1 : 0, (tval
& 0x40) ? 1 : 0,
984 (tval
& 0x20) ? 1 : 0);
985 printf("\n\t SubType: %d", *(tptr
+3));
986 printf("\n\t Priority Allocation");
988 pgval
= EXTRACT_32BITS(tptr
+4);
989 for (i
= 0; i
<= 7; i
++) {
990 tval
= *(tptr
+4+(i
/2));
991 printf("\n\t PgId_%d: %d",
992 i
, (pgval
>> (28-4*i
)) & 0xF);
994 printf("\n\t Priority Group Allocation");
995 for (i
= 0; i
<= 7; i
++)
996 printf("\n\t Pg percentage[%d]: %d", i
, *(tptr
+8+i
));
997 printf("\n\t NumTCsSupported: %d", *(tptr
+8+8));
999 case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV
:
1003 printf("\n\t Feature - Priority Flow Control");
1004 printf(" (type 0x%x, length %d)",
1005 LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV
, tlv_len
);
1006 printf("\n\t Oper_Version: %d", *tptr
);
1007 printf("\n\t Max_Version: %d", *(tptr
+1));
1008 printf("\n\t Info block(0x%02X): ", *(tptr
+2));
1010 printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
1011 (tval
& 0x80) ? 1 : 0, (tval
& 0x40) ? 1 : 0,
1012 (tval
& 0x20) ? 1 : 0);
1013 printf("\n\t SubType: %d", *(tptr
+3));
1015 printf("\n\t PFC Config (0x%02X)", *(tptr
+4));
1016 for (i
= 0; i
<= 7; i
++)
1017 printf("\n\t Priority Bit %d: %s",
1018 i
, (tval
& (1 << i
)) ? "Enabled" : "Disabled");
1019 printf("\n\t NumTCPFCSupported: %d", *(tptr
+5));
1021 case LLDP_DCBX_APPLICATION_TLV
:
1025 printf("\n\t Feature - Application (type 0x%x, length %d)",
1026 LLDP_DCBX_APPLICATION_TLV
, tlv_len
);
1027 printf("\n\t Oper_Version: %d", *tptr
);
1028 printf("\n\t Max_Version: %d", *(tptr
+1));
1029 printf("\n\t Info block(0x%02X): ", *(tptr
+2));
1031 printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
1032 (tval
& 0x80) ? 1 : 0, (tval
& 0x40) ? 1 : 0,
1033 (tval
& 0x20) ? 1 : 0);
1034 printf("\n\t SubType: %d", *(tptr
+3));
1038 printf("\n\t Application Value");
1039 printf("\n\t Application Protocol ID: 0x%04x",
1040 EXTRACT_16BITS(mptr
));
1041 uval
= EXTRACT_24BITS(mptr
+2);
1042 printf("\n\t SF (0x%x) Application Protocol ID is %s",
1044 (uval
>> 22) ? "Socket Number" : "L2 EtherType");
1045 printf("\n\t OUI: 0x%06x", uval
& 0x3fffff);
1046 printf("\n\t User Priority Map: 0x%02x", *(mptr
+5));
1056 /* do we also want to see a hex dump ? */
1057 if (vflag
> 1 || (vflag
&& hexdump
)) {
1058 print_unknown_data(tptr
,"\n\t ", tlv_len
);
1070 lldp_network_addr_print(const u_char
*tptr
, u_int len
) {
1073 static char buf
[BUFSIZE
];
1074 const char * (*pfunc
)(const u_char
*);
1096 pfunc
= etheraddr_string
;
1104 snprintf(buf
, sizeof(buf
), "AFI %s (%u), no AF printer !",
1105 tok2str(af_values
, "Unknown", af
), af
);
1107 snprintf(buf
, sizeof(buf
), "AFI %s (%u): %s",
1108 tok2str(af_values
, "Unknown", af
), af
, (*pfunc
)(tptr
+1));
1115 lldp_mgmt_addr_tlv_print(const u_char
*pptr
, u_int len
) {
1117 u_int8_t mgmt_addr_len
, intf_num_subtype
, oid_len
;
1128 mgmt_addr_len
= *tptr
++;
1131 if (tlen
< mgmt_addr_len
) {
1135 mgmt_addr
= lldp_network_addr_print(tptr
, mgmt_addr_len
);
1136 if (mgmt_addr
== NULL
) {
1139 printf("\n\t Management Address length %u, %s",
1140 mgmt_addr_len
, mgmt_addr
);
1141 tptr
+= mgmt_addr_len
;
1142 tlen
-= mgmt_addr_len
;
1144 if (tlen
< LLDP_INTF_NUM_LEN
) {
1148 intf_num_subtype
= *tptr
;
1149 printf("\n\t %s Interface Numbering (%u): %u",
1150 tok2str(lldp_intf_numb_subtype_values
, "Unknown", intf_num_subtype
),
1152 EXTRACT_32BITS(tptr
+1));
1154 tptr
+= LLDP_INTF_NUM_LEN
;
1155 tlen
-= LLDP_INTF_NUM_LEN
;
1158 * The OID is optional.
1163 if (tlen
< oid_len
) {
1167 printf("\n\t OID length %u", oid_len
);
1168 safeputs((const char *)tptr
+1, oid_len
);
1176 lldp_print(register const u_char
*pptr
, register u_int len
) {
1179 u_int16_t tlv
, cap
, ena_cap
;
1180 u_int oui
, tlen
, hexdump
, tlv_type
, tlv_len
;
1188 printf("LLDP, length %u", len
);
1191 while (tlen
>= sizeof(tlv
)) {
1193 TCHECK2(*tptr
, sizeof(tlv
));
1195 tlv
= EXTRACT_16BITS(tptr
);
1197 tlv_type
= LLDP_EXTRACT_TYPE(tlv
);
1198 tlv_len
= LLDP_EXTRACT_LEN(tlv
);
1201 tlen
-= sizeof(tlv
);
1202 tptr
+= sizeof(tlv
);
1205 printf("\n\t%s TLV (%u), length %u",
1206 tok2str(lldp_tlv_values
, "Unknown", tlv_type
),
1210 /* infinite loop check */
1211 if (!tlv_type
|| !tlv_len
) {
1215 TCHECK2(*tptr
, tlv_len
);
1216 if (tlen
< tlv_len
) {
1222 case LLDP_CHASSIS_ID_TLV
:
1228 printf("\n\t Subtype %s (%u): ",
1229 tok2str(lldp_chassis_subtype_values
, "Unknown", subtype
),
1233 case LLDP_CHASSIS_MAC_ADDR_SUBTYPE
:
1234 if (tlv_len
< 1+6) {
1237 printf("%s", etheraddr_string(tptr
+1));
1240 case LLDP_CHASSIS_INTF_NAME_SUBTYPE
: /* fall through */
1241 case LLDP_CHASSIS_LOCAL_SUBTYPE
:
1242 case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE
:
1243 case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE
:
1244 case LLDP_CHASSIS_PORT_COMP_SUBTYPE
:
1245 safeputs((const char *)tptr
+1, tlv_len
-1);
1248 case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE
:
1249 network_addr
= lldp_network_addr_print(tptr
+1, tlv_len
-1);
1250 if (network_addr
== NULL
) {
1253 printf("%s", network_addr
);
1263 case LLDP_PORT_ID_TLV
:
1269 printf("\n\t Subtype %s (%u): ",
1270 tok2str(lldp_port_subtype_values
, "Unknown", subtype
),
1274 case LLDP_PORT_MAC_ADDR_SUBTYPE
:
1275 if (tlv_len
< 1+6) {
1278 printf("%s", etheraddr_string(tptr
+1));
1281 case LLDP_PORT_INTF_NAME_SUBTYPE
: /* fall through */
1282 case LLDP_PORT_LOCAL_SUBTYPE
:
1283 case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE
:
1284 case LLDP_PORT_INTF_ALIAS_SUBTYPE
:
1285 case LLDP_PORT_PORT_COMP_SUBTYPE
:
1286 safeputs((const char *)tptr
+1, tlv_len
-1);
1289 case LLDP_PORT_NETWORK_ADDR_SUBTYPE
:
1290 network_addr
= lldp_network_addr_print(tptr
+1, tlv_len
-1);
1291 if (network_addr
== NULL
) {
1294 printf("%s", network_addr
);
1309 printf(": TTL %us", EXTRACT_16BITS(tptr
));
1313 case LLDP_PORT_DESCR_TLV
:
1316 safeputs((const char *)tptr
, tlv_len
);
1320 case LLDP_SYSTEM_NAME_TLV
:
1322 * The system name is also print in non-verbose mode
1323 * similar to the CDP printer.
1327 safeputs((const char *)tptr
, tlv_len
);
1329 printf("LLDP, name ");
1330 safeputs((const char *)tptr
, tlv_len
);
1331 printf(", length %u", len
);
1335 case LLDP_SYSTEM_DESCR_TLV
:
1338 safeputs((const char *)tptr
, tlv_len
);
1342 case LLDP_SYSTEM_CAP_TLV
:
1345 * XXX - IEEE Std 802.1AB-2009 says the first octet
1346 * if a chassis ID subtype, with the system
1347 * capabilities and enabled capabilities following
1353 cap
= EXTRACT_16BITS(tptr
);
1354 ena_cap
= EXTRACT_16BITS(tptr
+2);
1355 printf("\n\t System Capabilities [%s] (0x%04x)",
1356 bittok2str(lldp_cap_values
, "none", cap
), cap
);
1357 printf("\n\t Enabled Capabilities [%s] (0x%04x)",
1358 bittok2str(lldp_cap_values
, "none", ena_cap
), ena_cap
);
1362 case LLDP_MGMT_ADDR_TLV
:
1364 if (!lldp_mgmt_addr_tlv_print(tptr
, tlv_len
)) {
1370 case LLDP_PRIVATE_TLV
:
1375 oui
= EXTRACT_24BITS(tptr
);
1376 printf(": OUI %s (0x%06x)", tok2str(oui_values
, "Unknown", oui
), oui
);
1379 case OUI_IEEE_8021_PRIVATE
:
1380 hexdump
= lldp_private_8021_print(tptr
, tlv_len
);
1382 case OUI_IEEE_8023_PRIVATE
:
1383 hexdump
= lldp_private_8023_print(tptr
, tlv_len
);
1386 hexdump
= lldp_private_tia_print(tptr
, tlv_len
);
1389 hexdump
= lldp_private_dcbx_print(tptr
, tlv_len
);
1403 /* do we also want to see a hex dump ? */
1404 if (vflag
> 1 || (vflag
&& hexdump
)) {
1405 print_unknown_data(tptr
,"\n\t ", tlv_len
);
1413 printf("\n\t[|LLDP]");
1418 * c-style: whitesmith