2 * Routines for BPDU (Spanning Tree Protocol) disassembly
4 * Copyright 1999 Christophe Tronche <ch.tronche@computer.org>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
16 #include <epan/llcsaps.h>
17 #include <epan/chdlctypes.h>
18 #include <epan/etypes.h>
19 #include <epan/addr_resolv.h>
20 #include <epan/prefs.h>
21 #include <epan/expert.h>
22 #include <epan/cisco_pid.h>
25 /* Offsets of fields within a BPDU */
27 #define BPDU_IDENTIFIER 0
28 #define BPDU_VERSION_IDENTIFIER 2
31 #define BPDU_ROOT_IDENTIFIER 5
32 #define BPDU_ROOT_PATH_COST 13
33 #define BPDU_BRIDGE_IDENTIFIER 17
34 #define BPDU_PORT_IDENTIFIER 25
35 #define BPDU_MESSAGE_AGE 27
36 #define BPDU_MAX_AGE 29
37 #define BPDU_HELLO_TIME 31
38 #define BPDU_FORWARD_DELAY 33
39 #define BPDU_VERSION_1_LENGTH 35
40 #define BPDU_VERSION_3_LENGTH 36
41 #define BPDU_MST_CONFIG_FORMAT_SELECTOR 38
42 #define BPDU_MST_CONFIG_NAME 39
43 #define BPDU_MST_CONFIG_REVISION_LEVEL 71
44 #define BPDU_MST_CONFIG_DIGEST 73
45 #define BPDU_CIST_INTERNAL_ROOT_PATH_COST 89
46 #define BPDU_CIST_BRIDGE_IDENTIFIER 93
47 #define BPDU_CIST_REMAINING_HOPS 101
50 #define BPDU_PVST_TLV 36
53 #define MSTI_REGIONAL_ROOT 1
54 #define MSTI_INTERNAL_ROOT_PATH_COST 9
55 #define MSTI_BRIDGE_IDENTIFIER_PRIORITY 13
56 #define MSTI_PORT_IDENTIFIER_PRIORITY 14
57 #define MSTI_REMAINING_HOPS 15
60 #define CONF_BPDU_SIZE 35
61 #define TC_BPDU_SIZE 4
62 #define MST_BPDU_SIZE 38
63 #define VERSION_3_STATIC_LENGTH 64
64 #define MSTI_MESSAGE_SIZE 16
66 /* Values for the Alternative MSTI format */
68 #define ALT_BPDU_CIST_BRIDGE_IDENTIFIER 89
69 #define ALT_BPDU_CIST_INTERNAL_ROOT_PATH_COST 97
71 #define ALT_MSTI_MSTID 0
72 #define ALT_MSTI_FLAGS 2
73 #define ALT_MSTI_REGIONAL_ROOT 3
74 #define ALT_MSTI_INTERNAL_ROOT_PATH_COST 11
75 #define ALT_MSTI_BRIDGE_IDENTIFIER 15
76 #define ALT_MSTI_PORT_IDENTIFIER 23
77 #define ALT_MSTI_REMAINING_HOPS 25
79 #define ALT_MSTI_MESSAGE_SIZE 26
83 #define BPDU_FLAGS_TCACK 0x80
84 #define BPDU_FLAGS_AGREEMENT 0x40
85 #define BPDU_FLAGS_FORWARDING 0x20
86 #define BPDU_FLAGS_LEARNING 0x10
87 #define BPDU_FLAGS_PORT_ROLE_MASK 0x0C
88 #define BPDU_FLAGS_PORT_ROLE_SHIFT 2
89 #define BPDU_FLAGS_PROPOSAL 0x02
90 #define BPDU_FLAGS_TC 0x01
92 void proto_register_bpdu(void);
93 void proto_reg_handoff_bpdu(void);
95 static int proto_bpdu
;
96 static int hf_bpdu_proto_id
;
97 static int hf_bpdu_version_id
;
98 static int hf_bpdu_type
;
99 static int hf_bpdu_flags
;
100 static int hf_bpdu_flags_tcack
;
101 static int hf_bpdu_flags_agreement
;
102 static int hf_bpdu_flags_forwarding
;
103 static int hf_bpdu_flags_learning
;
104 static int hf_bpdu_flags_port_role
;
105 static int hf_bpdu_flags_proposal
;
106 static int hf_bpdu_flags_tc
;
107 static int hf_bpdu_root_prio
;
108 static int hf_bpdu_root_sys_id_ext
;
109 static int hf_bpdu_root_mac
;
110 static int hf_bpdu_root_cost
;
111 static int hf_bpdu_bridge_prio
;
112 static int hf_bpdu_bridge_sys_id_ext
;
113 static int hf_bpdu_bridge_mac
;
114 static int hf_bpdu_port_id
;
115 static int hf_bpdu_msg_age
;
116 static int hf_bpdu_max_age
;
117 static int hf_bpdu_hello_time
;
118 static int hf_bpdu_forward_delay
;
119 static int hf_bpdu_version_1_length
;
120 static int hf_bpdu_version_3_length
;
121 static int hf_bpdu_mst_config_format_selector
;
122 static int hf_bpdu_mst_config_name
;
123 static int hf_bpdu_mst_config_revision_level
;
124 static int hf_bpdu_mst_config_digest
;
125 static int hf_bpdu_cist_internal_root_path_cost
;
126 static int hf_bpdu_cist_bridge_prio
;
127 static int hf_bpdu_cist_bridge_sys_id_ext
;
128 static int hf_bpdu_cist_bridge_mac
;
129 static int hf_bpdu_cist_remaining_hops
;
130 static int hf_bpdu_msti_flags
;
131 static int hf_bpdu_msti_id
;
132 static int hf_bpdu_msti_id_FFF
;
133 static int hf_bpdu_mst_priority
;
134 static int hf_bpdu_msti_regional_root_id
;
135 static int hf_bpdu_msti_regional_root_mac
;
136 static int hf_bpdu_msti_internal_root_path_cost
;
137 static int hf_bpdu_msti_bridge_identifier_priority
;
138 static int hf_bpdu_msti_port_identifier_priority
;
139 static int hf_bpdu_msti_port_id
;
140 static int hf_bpdu_msti_bridge_id
;
141 static int hf_bpdu_msti_bridge_id_priority
;
142 static int hf_bpdu_msti_bridge_id_mac
;
143 static int hf_bpdu_msti_remaining_hops
;
144 static int hf_bpdu_version_4_length
;
145 static int hf_bpdu_spt_config_format_selector
;
146 static int hf_bpdu_spt_config_name
;
147 static int hf_bpdu_spt_config_revision_level
;
148 static int hf_bpdu_spt_config_digest
;
149 static int hf_bpdu_flags_agree_num
;
150 static int hf_bpdu_flags_dagree_num
;
151 static int hf_bpdu_flags_agree_valid
;
152 static int hf_bpdu_flags_restricted_role
;
153 static int hf_bpdu_spt_agreement_digest
;
154 static int hf_bpdu_agreement_digest_format_id
;
155 static int hf_bpdu_agreement_digest_format_capabilities
;
156 static int hf_bpdu_agreement_digest_convention_id
;
157 static int hf_bpdu_agreement_digest_convention_capabilities
;
158 static int hf_bpdu_agreement_digest_edge_count
;
160 static int hf_bpdu_pvst_tlvtype
;
161 static int hf_bpdu_pvst_tlvlength
;
162 static int hf_bpdu_pvst_tlvvalue
;
163 static int hf_bpdu_pvst_tlv_origvlan
;
166 static int ett_bpdu_flags
;
167 static int ett_root_id
;
168 static int ett_bridge_id
;
171 static int ett_cist_bridge_id
;
173 static int ett_aux_mcid
;
174 static int ett_agreement
;
175 static int ett_bpdu_pvst_tlv
;
177 static expert_field ei_pvst_tlv_length_invalid
;
178 static expert_field ei_pvst_tlv_origvlan_missing
;
179 static expert_field ei_pvst_tlv_truncated
;
180 static expert_field ei_pvst_tlv_unknown
;
181 static expert_field ei_bpdu_type
;
182 static expert_field ei_bpdu_version_support
;
185 static bool bpdu_use_system_id_extensions
= true;
187 static dissector_handle_t gvrp_handle
;
188 static dissector_handle_t gmrp_handle
;
190 static dissector_handle_t bpdu_handle
;
191 static dissector_handle_t bpdu_cisco_handle
;
193 static const value_string protocol_id_vals
[] = {
194 { 0, "Spanning Tree Protocol" },
198 #define BPDU_PVST_TLV_ORIGVLAN 0 /* Originating VLAN TLV in Cisco (R)PVST+ BPDUs */
200 static const value_string bpdu_pvst_tlv_vals
[] = {
201 { BPDU_PVST_TLV_ORIGVLAN
, "Originating VLAN" },
206 #define BPDU_TYPE_CONF 0x00 /* STP Configuration BPDU */
207 #define BPDU_TYPE_RST 0x02 /* RST BPDU (or MST) */
208 #define BPDU_TYPE_TOPOLOGY_CHANGE 0x80 /* STP TCN (Topology change notify) BPDU */
210 static const value_string bpdu_type_vals
[] = {
211 { BPDU_TYPE_CONF
, "Configuration" },
212 { BPDU_TYPE_RST
, "Rapid/Multiple Spanning Tree" },
213 { BPDU_TYPE_TOPOLOGY_CHANGE
, "Topology Change Notification" },
217 #define PROTO_VERSION_STP 0
218 #define PROTO_VERSION_RSTP 2
219 #define PROTO_VERSION_MSTP 3
220 #define PROTO_VERSION_SPB 4
222 #define MSTI_FORMAT_UNKNOWN 0
223 #define MSTI_FORMAT_IEEE_8021S 1
224 #define MSTI_FORMAT_ALTERNATIVE 2
226 static const value_string version_id_vals
[] = {
227 { PROTO_VERSION_STP
, "Spanning Tree" },
228 { PROTO_VERSION_RSTP
, "Rapid Spanning Tree" },
229 { PROTO_VERSION_MSTP
, "Multiple Spanning Tree" },
230 { PROTO_VERSION_SPB
, "Shortest Path Tree" },
233 static const value_string role_vals
[] = {
234 { 1, "Alternate or Backup" },
240 static const char initial_sep
[] = " (";
241 static const char cont_sep
[] = ", ";
244 dissect_bpdu_pvst_tlv(packet_info
*pinfo
, proto_tree
*tree
, tvbuff_t
*tvb
) {
245 bool pvst_tlv_origvlan_present
= false;
246 uint16_t tlv_type
, tlv_length
;
247 int offset
= BPDU_PVST_TLV
;
248 proto_item
* ti
= NULL
;
249 proto_item
* tlv_length_item
= NULL
;
250 proto_tree
* tlv_tree
= NULL
;
252 if (tvb_reported_length_remaining(tvb
, offset
) < 4) /* TLV Type and Length fields occupy 4 bytes in total */
253 expert_add_info(pinfo
, tree
, &ei_pvst_tlv_truncated
);
255 while (tvb_reported_length_remaining(tvb
, offset
) >= 4) { /* TLV Type and Length fields occupy 4 bytes in total */
256 tlv_type
= tvb_get_ntohs(tvb
, offset
);
257 tlv_length
= tvb_get_ntohs(tvb
, offset
+ 2);
259 tlv_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, 4 + tlv_length
,
260 ett_bpdu_pvst_tlv
, &ti
,
261 val_to_str(tlv_type
, bpdu_pvst_tlv_vals
, "Unknown TLV type: 0x%04x"));
263 proto_tree_add_item(tlv_tree
, hf_bpdu_pvst_tlvtype
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
264 tlv_length_item
= proto_tree_add_item(tlv_tree
, hf_bpdu_pvst_tlvlength
,
265 tvb
, offset
+ 2, 2, ENC_BIG_ENDIAN
);
267 if (tvb_reported_length_remaining(tvb
, offset
+ 4) < tlv_length
) {
268 expert_add_info(pinfo
, tlv_length_item
, &ei_pvst_tlv_truncated
);
275 case BPDU_PVST_TLV_ORIGVLAN
:
276 if (tlv_length
== 2) { /* Originating VLAN ID must be 2 bytes long */
277 proto_item_append_text(ti
, " (PVID): %u", tvb_get_ntohs(tvb
, offset
));
278 proto_tree_add_item(tlv_tree
, hf_bpdu_pvst_tlv_origvlan
, tvb
, offset
, tlv_length
, ENC_BIG_ENDIAN
);
279 pvst_tlv_origvlan_present
= true;
282 expert_add_info(pinfo
, tlv_length_item
, &ei_pvst_tlv_length_invalid
);
286 proto_tree_add_item(tlv_tree
, hf_bpdu_pvst_tlvvalue
, tvb
, offset
, tlv_length
, ENC_NA
);
287 expert_add_info(pinfo
, tlv_tree
, &ei_pvst_tlv_unknown
);
291 offset
+= tlv_length
;
294 if (pvst_tlv_origvlan_present
== false) /* If a (R)PVST+ BPDU lacks the Originating VLAN TLV, it is malformed */
295 expert_add_info(pinfo
, tree
, &ei_pvst_tlv_origvlan_missing
);
299 dissect_bpdu(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, bool is_bpdu_pvst
)
301 uint16_t protocol_identifier
;
302 uint8_t protocol_version_identifier
;
305 uint16_t root_identifier_bridge_priority
;
306 uint16_t root_identifier_system_id_extension
= 0;
307 const char *root_identifier_mac_str
;
308 uint32_t root_path_cost
;
309 uint16_t bridge_identifier_bridge_priority
;
310 uint16_t bridge_identifier_system_id_extension
= 0;
311 const char *bridge_identifier_mac_str
;
312 uint16_t port_identifier
;
316 double forward_delay
;
317 uint8_t version_1_length
;
318 uint16_t version_3_length
;
319 uint16_t version_4_length
= 0;
320 uint16_t bpdu_version_4_length
= 0;
321 uint8_t config_format_selector
;
322 uint16_t cist_bridge_identifier_bridge_priority
;
323 uint16_t cist_bridge_identifier_system_id_extension
= 0;
324 const char *cist_bridge_identifier_mac_str
;
325 uint32_t msti_regional_root_mstid
, msti_regional_root_priority
;
326 const char *msti_regional_root_mac_str
;
327 uint16_t msti_bridge_identifier_priority
, msti_port_identifier_priority
;
328 int total_msti_length
, offset
, msti_format
;
329 int msti_length_remaining
;
334 uint8_t spt_agree_data
= 0;
336 proto_tree
*bpdu_tree
;
337 proto_tree
*mstp_tree
, *msti_tree
, *spt_tree
= NULL
, *aux_mcid_tree
= NULL
, *agreement_tree
= NULL
;
338 proto_item
*bpdu_item
;
339 proto_item
*agreement_item
, *proto_id_item
, *type_item
;
340 proto_tree
*root_id_tree
;
341 proto_tree
*bridge_id_tree
;
342 proto_tree
*cist_bridge_id_tree
;
345 static int * const bpdu_flags
[] = {
346 &hf_bpdu_flags_tcack
,
351 static int * const rst_flags
[] = {
352 &hf_bpdu_flags_tcack
,
353 &hf_bpdu_flags_agreement
,
354 &hf_bpdu_flags_forwarding
,
355 &hf_bpdu_flags_learning
,
356 &hf_bpdu_flags_port_role
,
357 &hf_bpdu_flags_proposal
,
362 /* GARP application frames require special interpretation of the
363 destination address field; otherwise, they will be mistaken as
365 Fortunately, they can be recognized by checking the first 6 octets
366 of the destination address, which are in the range from
367 01-80-C2-00-00-20 to 01-80-C2-00-00-2F.
369 Yes - we *do* need to check the destination address type;
370 on Linux cooked captures, there *is* no destination address,
372 if (pinfo
->dl_dst
.type
== AT_ETHER
) {
373 const uint8_t *dstaddr
;
375 dstaddr
= (const uint8_t *)pinfo
->dl_dst
.data
;
376 if(dstaddr
[0] == 0x01 && dstaddr
[1] == 0x80 &&
377 dstaddr
[2] == 0xC2 && dstaddr
[3] == 0x00 &&
378 dstaddr
[4] == 0x00 && ((dstaddr
[5] == 0x0D) || ((dstaddr
[5] & 0xF0) == 0x20))) {
380 switch (dstaddr
[5]) {
384 call_dissector(gmrp_handle
, tvb
, pinfo
, tree
);
390 call_dissector(gvrp_handle
, tvb
, pinfo
, tree
);
393 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "GARP");
394 /* Generic Attribute Registration Protocol */
396 col_add_fstr(pinfo
->cinfo
, COL_INFO
,
397 "Unknown GARP application (0x%02X)",
404 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "STP"); /* Spanning Tree Protocol */
405 col_clear(pinfo
->cinfo
, COL_INFO
);
407 bpdu_type
= tvb_get_uint8(tvb
, BPDU_TYPE
);
409 protocol_version_identifier
= tvb_get_uint8(tvb
, BPDU_VERSION_IDENTIFIER
);
415 flags
= tvb_get_uint8(tvb
, BPDU_FLAGS
);
416 root_identifier_bridge_priority
= tvb_get_ntohs(tvb
,BPDU_ROOT_IDENTIFIER
);
417 if (bpdu_use_system_id_extensions
) {
418 root_identifier_system_id_extension
= root_identifier_bridge_priority
& 0x0fff;
419 root_identifier_bridge_priority
&= 0xf000;
421 root_identifier_mac_str
= tvb_ether_to_str(pinfo
->pool
, tvb
, BPDU_ROOT_IDENTIFIER
+ 2);
422 root_path_cost
= tvb_get_ntohl(tvb
, BPDU_ROOT_PATH_COST
);
423 port_identifier
= tvb_get_ntohs(tvb
, BPDU_PORT_IDENTIFIER
);
427 /* Squelch GCC complaints. */
429 root_identifier_bridge_priority
= 0;
430 root_identifier_mac_str
= NULL
;
439 if (bpdu_use_system_id_extensions
) {
440 col_add_fstr(pinfo
->cinfo
, COL_INFO
,
441 "Conf. %sRoot = %d/%d/%s Cost = %d Port = 0x%04x",
442 flags
& 0x1 ? "TC + " : "",
443 root_identifier_bridge_priority
,
444 root_identifier_system_id_extension
,
445 root_identifier_mac_str
,
446 root_path_cost
, port_identifier
);
448 col_add_fstr(pinfo
->cinfo
, COL_INFO
,
449 "Conf. %sRoot = %d/%s Cost = %d Port = 0x%04x",
450 flags
& 0x1 ? "TC + " : "",
451 root_identifier_bridge_priority
, root_identifier_mac_str
,
452 root_path_cost
, port_identifier
);
456 case BPDU_TYPE_TOPOLOGY_CHANGE
:
457 col_set_str(pinfo
->cinfo
, COL_INFO
, "Topology Change Notification");
461 if (bpdu_use_system_id_extensions
) {
462 col_add_fstr(pinfo
->cinfo
, COL_INFO
,
463 "%sT. %sRoot = %d/%d/%s Cost = %d Port = 0x%04x",
464 protocol_version_identifier
== 3 ? "MS":
465 (protocol_version_identifier
== 4 ? "SP":"RS"),
466 flags
& 0x1 ? "TC + " : "",
467 root_identifier_bridge_priority
,
468 root_identifier_system_id_extension
,
469 root_identifier_mac_str
,
470 root_path_cost
, port_identifier
);
472 col_add_fstr(pinfo
->cinfo
, COL_INFO
,
473 "%sT. %sRoot = %d/%s Cost = %d Port = 0x%04x",
474 protocol_version_identifier
== 3 ? "MS":
475 (protocol_version_identifier
== 4 ? "SP":"RS"),
476 flags
& 0x1 ? "TC + " : "",
477 root_identifier_bridge_priority
, root_identifier_mac_str
,
478 root_path_cost
, port_identifier
);
483 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unknown BPDU type (%u)", bpdu_type
);
487 bpdu_item
= proto_tree_add_protocol_format(tree
, proto_bpdu
, tvb
, 0, -1,
488 "Spanning Tree Protocol");
489 bpdu_tree
= proto_item_add_subtree(bpdu_item
, ett_bpdu
);
491 protocol_identifier
= tvb_get_ntohs(tvb
, BPDU_IDENTIFIER
);
492 proto_tree_add_uint(bpdu_tree
, hf_bpdu_proto_id
, tvb
, BPDU_IDENTIFIER
, 2,
493 protocol_identifier
);
495 proto_id_item
= proto_tree_add_uint(bpdu_tree
, hf_bpdu_version_id
, tvb
,
496 BPDU_VERSION_IDENTIFIER
, 1,
497 protocol_version_identifier
);
498 switch (protocol_version_identifier
) {
509 expert_add_info(pinfo
, proto_id_item
, &ei_bpdu_version_support
);
512 type_item
= proto_tree_add_uint(bpdu_tree
, hf_bpdu_type
, tvb
, BPDU_TYPE
, 1, bpdu_type
);
514 if (bpdu_type
== BPDU_TYPE_TOPOLOGY_CHANGE
) {
515 set_actual_length(tvb
, TC_BPDU_SIZE
);
519 if (bpdu_type
!= BPDU_TYPE_CONF
&& bpdu_type
!= BPDU_TYPE_RST
) {
520 /* Unknown BPDU type - just display the rest of the PDU as data */
521 expert_add_info(pinfo
, type_item
, &ei_bpdu_type
);
525 bridge_identifier_bridge_priority
= tvb_get_ntohs(tvb
, BPDU_BRIDGE_IDENTIFIER
);
526 if (bpdu_use_system_id_extensions
) {
527 bridge_identifier_system_id_extension
= bridge_identifier_bridge_priority
& 0x0fff;
528 bridge_identifier_bridge_priority
&= 0xf000;
530 bridge_identifier_mac_str
= tvb_ether_to_str(pinfo
->pool
, tvb
, BPDU_BRIDGE_IDENTIFIER
+ 2);
532 if (bpdu_type
== BPDU_TYPE_RST
) {
533 proto_tree_add_bitmask_value_with_flags(bpdu_tree
, tvb
, BPDU_FLAGS
, hf_bpdu_flags
, ett_bpdu_flags
, rst_flags
, flags
, BMT_NO_FALSE
|BMT_NO_TFS
);
535 proto_tree_add_bitmask_value_with_flags(bpdu_tree
, tvb
, BPDU_FLAGS
, hf_bpdu_flags
, ett_bpdu_flags
, bpdu_flags
, flags
, BMT_NO_FALSE
|BMT_NO_TFS
);
538 /* add Identifier with format based on preference value
539 * bpdu_use_system_id_extensions
541 if (bpdu_use_system_id_extensions
) {
542 root_id_tree
= proto_tree_add_subtree_format(bpdu_tree
, tvb
,
543 BPDU_ROOT_IDENTIFIER
, 8,
545 "Root Identifier: %d / %d / %s",
546 root_identifier_bridge_priority
,
547 root_identifier_system_id_extension
,
548 root_identifier_mac_str
);
549 proto_tree_add_uint(root_id_tree
, hf_bpdu_root_prio
, tvb
,
550 BPDU_ROOT_IDENTIFIER
, 1,
551 root_identifier_bridge_priority
);
552 proto_tree_add_uint(root_id_tree
, hf_bpdu_root_sys_id_ext
, tvb
,
553 BPDU_ROOT_IDENTIFIER
, 2,
554 root_identifier_system_id_extension
);
555 proto_tree_add_item(root_id_tree
, hf_bpdu_root_mac
, tvb
,
556 BPDU_ROOT_IDENTIFIER
+ 2, 6, ENC_NA
);
559 root_id_tree
= proto_tree_add_subtree_format(bpdu_tree
, tvb
,
560 BPDU_ROOT_IDENTIFIER
, 8,
562 "Root Identifier: %d / %s",
563 root_identifier_bridge_priority
,
564 root_identifier_mac_str
);
565 proto_tree_add_uint(root_id_tree
, hf_bpdu_root_prio
, tvb
,
566 BPDU_ROOT_IDENTIFIER
, 2,
567 root_identifier_bridge_priority
);
568 proto_tree_add_item(root_id_tree
, hf_bpdu_root_mac
, tvb
,
569 BPDU_ROOT_IDENTIFIER
+ 2, 6, ENC_NA
);
571 /* end of Identifier formatting */
573 proto_tree_add_uint(bpdu_tree
, hf_bpdu_root_cost
, tvb
,
574 BPDU_ROOT_PATH_COST
, 4, root_path_cost
);
576 /* add Identifier with format based on preference value
577 * bpdu_use_system_id_extensions
579 if (bpdu_use_system_id_extensions
) {
580 bridge_id_tree
= proto_tree_add_subtree_format(bpdu_tree
, tvb
,
581 BPDU_BRIDGE_IDENTIFIER
, 8,
583 "Bridge Identifier: %d / %d / %s",
584 bridge_identifier_bridge_priority
,
585 bridge_identifier_system_id_extension
,
586 bridge_identifier_mac_str
);
587 proto_tree_add_uint(bridge_id_tree
, hf_bpdu_bridge_prio
, tvb
,
588 BPDU_BRIDGE_IDENTIFIER
, 1,
589 bridge_identifier_bridge_priority
);
590 proto_tree_add_uint(bridge_id_tree
, hf_bpdu_bridge_sys_id_ext
, tvb
,
591 BPDU_BRIDGE_IDENTIFIER
, 2,
592 bridge_identifier_system_id_extension
);
593 proto_tree_add_item(bridge_id_tree
, hf_bpdu_bridge_mac
, tvb
,
594 BPDU_BRIDGE_IDENTIFIER
+ 2, 6, ENC_NA
);
596 bridge_id_tree
= proto_tree_add_subtree_format(bpdu_tree
, tvb
,
597 BPDU_BRIDGE_IDENTIFIER
, 8,
599 "Bridge Identifier: %d / %s",
600 bridge_identifier_bridge_priority
,
601 bridge_identifier_mac_str
);
602 proto_tree_add_uint(bridge_id_tree
, hf_bpdu_bridge_prio
, tvb
,
603 BPDU_BRIDGE_IDENTIFIER
, 2,
604 bridge_identifier_bridge_priority
);
605 proto_tree_add_item(bridge_id_tree
, hf_bpdu_bridge_mac
, tvb
,
606 BPDU_BRIDGE_IDENTIFIER
+ 2, 6, ENC_NA
);
608 /* end of Identifier formatting */
610 proto_tree_add_uint(bpdu_tree
, hf_bpdu_port_id
, tvb
,
611 BPDU_PORT_IDENTIFIER
, 2, port_identifier
);
612 message_age
= tvb_get_ntohs(tvb
, BPDU_MESSAGE_AGE
) / 256.0;
613 proto_tree_add_double(bpdu_tree
, hf_bpdu_msg_age
, tvb
, BPDU_MESSAGE_AGE
, 2,
615 max_age
= tvb_get_ntohs(tvb
, BPDU_MAX_AGE
) / 256.0;
616 proto_tree_add_double(bpdu_tree
, hf_bpdu_max_age
, tvb
, BPDU_MAX_AGE
, 2,
618 hello_time
= tvb_get_ntohs(tvb
, BPDU_HELLO_TIME
) / 256.0;
619 proto_tree_add_double(bpdu_tree
, hf_bpdu_hello_time
, tvb
,
620 BPDU_HELLO_TIME
, 2, hello_time
);
621 forward_delay
= tvb_get_ntohs(tvb
, BPDU_FORWARD_DELAY
) / 256.0;
622 proto_tree_add_double(bpdu_tree
, hf_bpdu_forward_delay
, tvb
,
623 BPDU_FORWARD_DELAY
, 2, forward_delay
);
625 if (bpdu_type
== BPDU_TYPE_CONF
) {
627 dissect_bpdu_pvst_tlv(pinfo
, bpdu_tree
, tvb
);
629 /* Nothing more in this BPDU */
630 set_actual_length(tvb
, CONF_BPDU_SIZE
);
634 /* RST or MST BPDU */
635 version_1_length
= tvb_get_uint8(tvb
, BPDU_VERSION_1_LENGTH
);
636 proto_tree_add_uint(bpdu_tree
, hf_bpdu_version_1_length
, tvb
,
637 BPDU_VERSION_1_LENGTH
, 1, version_1_length
);
638 /* Is this an MST BPDU? */
639 if (protocol_version_identifier
>= 3 && version_1_length
== 0 &&
640 tvb_reported_length(tvb
) >= 102) {
642 * OK, it passes the "Protocol Identifier is 0000 0000
643 * 0000 0000", "Protocol Version Identifier is 3 or
644 * greater", "BPDU Type is 0000 0010", "contains 102 or
645 * more octets", and "a Version 1 Length of 0" tests.
647 version_3_length
= tvb_get_ntohs(tvb
, BPDU_VERSION_3_LENGTH
);
648 proto_tree_add_uint(bpdu_tree
, hf_bpdu_version_3_length
, tvb
,
649 BPDU_VERSION_3_LENGTH
, 2, version_3_length
);
652 * Check the Version 3 Length, and see whether it's a
653 * multiple of the MSTI Configuration Message length. Also
654 * check the config_format_selector because some MST BPDU's
655 * have BPDU_VERSION_3_LENGTH set to 0 and use the
656 * field BPDU_MST_CONFIG_FORMAT_SELECTOR as a length-field
659 config_format_selector
= tvb_get_uint8(tvb
, BPDU_MST_CONFIG_FORMAT_SELECTOR
);
660 if (version_3_length
!= 0) {
661 msti_format
= MSTI_FORMAT_IEEE_8021S
;
662 if (version_3_length
>= VERSION_3_STATIC_LENGTH
) {
663 total_msti_length
= version_3_length
- VERSION_3_STATIC_LENGTH
;
666 * XXX - there appears to be an ambiguity in the 802.3Q-2003
667 * standard and at least some of the 802.3s drafts.
669 * The "Version 3 Length" field is defined to be "the number of
670 * octets taken by the parameters that follow in the BPDU", but
671 * it's spoken of as "representing an integral number, from 0 to
672 * 64 inclusive, of MSTI Configuration Messages".
674 * According to mail from a member of the stds-802-1@ieee.org list,
675 * the latter of those is just saying that the length must not have
676 * a value that implies that there's a partial MSTI message in the
677 * packet; it's still in units of octets, not messages.
679 * However, it appears that Cisco's C3550 software (C3550-I5Q3L2-M,
680 * Version 12.1(12c)EA1) might be sending out lengths in units of
683 * This length can't be the number of octets taken by the parameters
684 * that follow in the BPDU, because it's less than the fixed-length
685 * portion of those parameters, so we assume the length is a count of
688 total_msti_length
= version_3_length
* MSTI_MESSAGE_SIZE
;
691 if (tvb_reported_length(tvb
) == (unsigned)config_format_selector
+ MST_BPDU_SIZE
+ 1 ) {
692 msti_format
= MSTI_FORMAT_ALTERNATIVE
;
693 total_msti_length
= config_format_selector
- VERSION_3_STATIC_LENGTH
;
696 * XXX - Unknown MSTI format, since version_3_length is 0
697 * lets assume there are no msti instances in the packet.
699 msti_format
= MSTI_FORMAT_UNKNOWN
;
700 total_msti_length
= 0;
703 if (protocol_version_identifier
== 3) {
704 set_actual_length(tvb
, BPDU_MSTI
+ total_msti_length
);
707 mstp_tree
= proto_tree_add_subtree(bpdu_tree
, tvb
, BPDU_VERSION_3_LENGTH
,
708 -1, ett_mstp
, NULL
, "MST Extension");
710 proto_tree_add_item(mstp_tree
, hf_bpdu_mst_config_format_selector
, tvb
,
711 BPDU_MST_CONFIG_FORMAT_SELECTOR
, 1, ENC_BIG_ENDIAN
);
712 proto_tree_add_item(mstp_tree
, hf_bpdu_mst_config_name
, tvb
,
713 BPDU_MST_CONFIG_NAME
, 32, ENC_ASCII
|ENC_NA
);
715 proto_tree_add_item(mstp_tree
, hf_bpdu_mst_config_revision_level
, tvb
,
716 BPDU_MST_CONFIG_REVISION_LEVEL
, 2, ENC_BIG_ENDIAN
);
717 proto_tree_add_item(mstp_tree
, hf_bpdu_mst_config_digest
, tvb
,
718 BPDU_MST_CONFIG_DIGEST
, 16, ENC_NA
);
720 switch(msti_format
) {
722 case MSTI_FORMAT_IEEE_8021S
:
723 proto_tree_add_item(mstp_tree
, hf_bpdu_cist_internal_root_path_cost
, tvb
,
724 BPDU_CIST_INTERNAL_ROOT_PATH_COST
, 4, ENC_BIG_ENDIAN
);
726 cist_bridge_identifier_bridge_priority
= tvb_get_ntohs(tvb
,BPDU_CIST_BRIDGE_IDENTIFIER
);
727 cist_bridge_identifier_mac_str
= tvb_ether_to_str(pinfo
->pool
, tvb
, BPDU_CIST_BRIDGE_IDENTIFIER
+ 2);
729 /* add Identifier with format based on preference value
730 * bpdu_use_system_id_extensions
732 if (bpdu_use_system_id_extensions
) {
733 cist_bridge_identifier_system_id_extension
= cist_bridge_identifier_bridge_priority
& 0x0fff;
734 cist_bridge_identifier_bridge_priority
&= 0xf000;
736 cist_bridge_id_tree
= proto_tree_add_subtree_format(mstp_tree
, tvb
,
737 BPDU_CIST_BRIDGE_IDENTIFIER
, 8,
738 ett_cist_bridge_id
, NULL
,
739 "CIST Bridge Identifier: %d / %d / %s",
740 cist_bridge_identifier_bridge_priority
,
741 cist_bridge_identifier_system_id_extension
,
742 cist_bridge_identifier_mac_str
);
743 proto_tree_add_uint(cist_bridge_id_tree
, hf_bpdu_cist_bridge_prio
, tvb
,
744 BPDU_CIST_BRIDGE_IDENTIFIER
, 1,
745 cist_bridge_identifier_bridge_priority
);
746 proto_tree_add_uint(cist_bridge_id_tree
, hf_bpdu_cist_bridge_sys_id_ext
, tvb
,
747 BPDU_CIST_BRIDGE_IDENTIFIER
, 2,
748 cist_bridge_identifier_system_id_extension
);
749 proto_tree_add_item(cist_bridge_id_tree
, hf_bpdu_cist_bridge_mac
, tvb
,
750 BPDU_CIST_BRIDGE_IDENTIFIER
+ 2, 6, ENC_NA
);
753 cist_bridge_id_tree
= proto_tree_add_subtree_format(mstp_tree
, tvb
,
754 BPDU_CIST_BRIDGE_IDENTIFIER
, 8,
755 ett_cist_bridge_id
, NULL
,
756 "CIST Bridge Identifier: %d / %s",
757 cist_bridge_identifier_bridge_priority
,
758 cist_bridge_identifier_mac_str
);
759 proto_tree_add_uint(cist_bridge_id_tree
, hf_bpdu_cist_bridge_prio
, tvb
,
760 BPDU_CIST_BRIDGE_IDENTIFIER
, 2,
761 cist_bridge_identifier_bridge_priority
);
762 proto_tree_add_item(cist_bridge_id_tree
, hf_bpdu_cist_bridge_mac
, tvb
,
763 BPDU_CIST_BRIDGE_IDENTIFIER
+ 2, 6, ENC_NA
);
765 /* end of Identifier formatting */
769 case MSTI_FORMAT_ALTERNATIVE
:
770 cist_bridge_identifier_bridge_priority
= tvb_get_ntohs(tvb
,ALT_BPDU_CIST_BRIDGE_IDENTIFIER
);
771 cist_bridge_identifier_mac_str
= tvb_ether_to_str(pinfo
->pool
, tvb
, ALT_BPDU_CIST_BRIDGE_IDENTIFIER
+ 2);
773 /* add Identifier with format based on preference value
774 * bpdu_use_system_id_extensions
776 if (bpdu_use_system_id_extensions
) {
777 cist_bridge_identifier_system_id_extension
= cist_bridge_identifier_bridge_priority
& 0x0fff;
778 cist_bridge_identifier_bridge_priority
&= 0xf000;
780 cist_bridge_id_tree
= proto_tree_add_subtree_format(mstp_tree
, tvb
,
781 ALT_BPDU_CIST_BRIDGE_IDENTIFIER
, 8,
782 ett_cist_bridge_id
, NULL
,
783 "CIST Bridge Identifier: %d / %d / %s",
784 cist_bridge_identifier_bridge_priority
,
785 cist_bridge_identifier_system_id_extension
,
786 cist_bridge_identifier_mac_str
);
787 proto_tree_add_uint(cist_bridge_id_tree
, hf_bpdu_cist_bridge_prio
, tvb
,
788 ALT_BPDU_CIST_BRIDGE_IDENTIFIER
, 1,
789 cist_bridge_identifier_bridge_priority
);
790 proto_tree_add_uint(cist_bridge_id_tree
, hf_bpdu_cist_bridge_sys_id_ext
, tvb
,
791 ALT_BPDU_CIST_BRIDGE_IDENTIFIER
, 2,
792 cist_bridge_identifier_system_id_extension
);
793 proto_tree_add_item(cist_bridge_id_tree
, hf_bpdu_cist_bridge_mac
, tvb
,
794 ALT_BPDU_CIST_BRIDGE_IDENTIFIER
+ 2, 6, ENC_NA
);
796 cist_bridge_id_tree
= proto_tree_add_subtree_format(mstp_tree
, tvb
,
797 ALT_BPDU_CIST_BRIDGE_IDENTIFIER
, 8,
798 ett_cist_bridge_id
, NULL
,
799 "CIST Bridge Identifier: %d / %s",
800 cist_bridge_identifier_bridge_priority
,
801 cist_bridge_identifier_mac_str
);
802 proto_tree_add_uint(cist_bridge_id_tree
, hf_bpdu_cist_bridge_prio
, tvb
,
803 ALT_BPDU_CIST_BRIDGE_IDENTIFIER
, 2,
804 cist_bridge_identifier_bridge_priority
);
805 proto_tree_add_item(cist_bridge_id_tree
, hf_bpdu_cist_bridge_mac
, tvb
,
806 ALT_BPDU_CIST_BRIDGE_IDENTIFIER
+ 2, 6, ENC_NA
);
808 /* end of Identifier formatting */
810 proto_tree_add_item(mstp_tree
, hf_bpdu_cist_internal_root_path_cost
, tvb
,
811 ALT_BPDU_CIST_INTERNAL_ROOT_PATH_COST
, 4, ENC_BIG_ENDIAN
);
816 proto_tree_add_item(mstp_tree
, hf_bpdu_cist_remaining_hops
, tvb
,
817 BPDU_CIST_REMAINING_HOPS
, 1, ENC_BIG_ENDIAN
);
820 msti_length_remaining
= total_msti_length
;
821 while (msti_length_remaining
> 0) {
822 switch(msti_format
) {
824 case MSTI_FORMAT_IEEE_8021S
:
825 msti_regional_root_mstid
= tvb_get_uint8(tvb
, offset
+ MSTI_REGIONAL_ROOT
);
826 msti_regional_root_priority
= (msti_regional_root_mstid
&0xf0) << 8;
827 msti_regional_root_mstid
= ((msti_regional_root_mstid
& 0x0f) << 8) +
828 tvb_get_uint8(tvb
, offset
+ MSTI_REGIONAL_ROOT
+1);
829 msti_regional_root_mac_str
= tvb_ether_to_str(pinfo
->pool
, tvb
, offset
+ MSTI_REGIONAL_ROOT
+ 2);
831 msti_tree
= proto_tree_add_subtree_format(mstp_tree
, tvb
, offset
, 16, ett_msti
, NULL
,
832 "MSTID %d, Regional Root Identifier %d / %s",
833 msti_regional_root_mstid
,
834 msti_regional_root_priority
,
835 msti_regional_root_mac_str
);
838 proto_tree_add_bitmask_with_flags(msti_tree
, tvb
, offset
+MSTI_FLAGS
, hf_bpdu_msti_flags
, ett_bpdu_flags
, rst_flags
, ENC_NA
, BMT_NO_FALSE
|BMT_NO_TFS
);
840 /* pri, MSTID, Regional root */
841 proto_tree_add_item(msti_tree
, hf_bpdu_mst_priority
, tvb
, offset
+ MSTI_REGIONAL_ROOT
, 1, ENC_BIG_ENDIAN
);
842 proto_tree_add_item(msti_tree
, hf_bpdu_msti_id_FFF
, tvb
, offset
+ MSTI_REGIONAL_ROOT
, 2, ENC_BIG_ENDIAN
);
843 proto_tree_add_item(msti_tree
, hf_bpdu_msti_regional_root_mac
, tvb
,
844 offset
+ MSTI_REGIONAL_ROOT
+ 2, 6, ENC_NA
);
846 proto_tree_add_item(msti_tree
, hf_bpdu_msti_internal_root_path_cost
, tvb
,
847 offset
+MSTI_INTERNAL_ROOT_PATH_COST
, 4, ENC_BIG_ENDIAN
);
849 msti_bridge_identifier_priority
= tvb_get_uint8(tvb
, offset
+MSTI_BRIDGE_IDENTIFIER_PRIORITY
) >> 4;
850 msti_port_identifier_priority
= tvb_get_uint8(tvb
, offset
+MSTI_PORT_IDENTIFIER_PRIORITY
) >> 4;
852 proto_tree_add_uint(msti_tree
, hf_bpdu_msti_bridge_identifier_priority
, tvb
,
853 offset
+MSTI_BRIDGE_IDENTIFIER_PRIORITY
, 1,
854 msti_bridge_identifier_priority
);
855 proto_tree_add_uint(msti_tree
, hf_bpdu_msti_port_identifier_priority
, tvb
,
856 offset
+MSTI_PORT_IDENTIFIER_PRIORITY
, 1,
857 msti_port_identifier_priority
);
859 proto_tree_add_item(msti_tree
, hf_bpdu_msti_remaining_hops
, tvb
,
860 offset
+ MSTI_REMAINING_HOPS
, 1, ENC_BIG_ENDIAN
);
862 msti_length_remaining
-= MSTI_MESSAGE_SIZE
;
863 offset
+= MSTI_MESSAGE_SIZE
;
866 case MSTI_FORMAT_ALTERNATIVE
:
867 msti_regional_root_mstid
= tvb_get_uint8(tvb
, offset
+ ALT_MSTI_REGIONAL_ROOT
);
868 msti_regional_root_priority
= (msti_regional_root_mstid
&0xf0) << 8;
869 msti_regional_root_mstid
= ((msti_regional_root_mstid
& 0x0f) << 8) +
870 tvb_get_uint8(tvb
, offset
+ ALT_MSTI_REGIONAL_ROOT
+1);
871 msti_regional_root_mac_str
= tvb_ether_to_str(pinfo
->pool
, tvb
, offset
+ ALT_MSTI_REGIONAL_ROOT
+ 2);
873 msti_tree
= proto_tree_add_subtree_format(mstp_tree
, tvb
, offset
, 16, ett_msti
, NULL
,
874 "MSTID %d, Regional Root Identifier %d / %s",
875 msti_regional_root_mstid
,
876 msti_regional_root_priority
,
877 msti_regional_root_mac_str
);
879 proto_tree_add_item(msti_tree
, hf_bpdu_msti_id
, tvb
, offset
+ALT_MSTI_MSTID
, 2, ENC_BIG_ENDIAN
);
882 proto_tree_add_bitmask_with_flags(msti_tree
, tvb
, offset
+ALT_MSTI_FLAGS
, hf_bpdu_msti_flags
, ett_bpdu_flags
, rst_flags
, ENC_NA
, BMT_NO_FALSE
|BMT_NO_TFS
);
884 /* pri, MSTID, Regional root */
885 proto_tree_add_item(msti_tree
, hf_bpdu_mst_priority
, tvb
, offset
+ ALT_MSTI_REGIONAL_ROOT
, 1, ENC_BIG_ENDIAN
);
886 proto_tree_add_item(msti_tree
, hf_bpdu_msti_regional_root_id
, tvb
, offset
+ ALT_MSTI_REGIONAL_ROOT
, 2, ENC_BIG_ENDIAN
);
887 proto_tree_add_item(msti_tree
, hf_bpdu_msti_regional_root_mac
, tvb
,
888 offset
+ ALT_MSTI_REGIONAL_ROOT
+ 2, 6, ENC_NA
);
890 proto_tree_add_item(msti_tree
, hf_bpdu_msti_internal_root_path_cost
, tvb
,
891 offset
+ALT_MSTI_INTERNAL_ROOT_PATH_COST
, 4, ENC_BIG_ENDIAN
);
893 proto_tree_add_item(msti_tree
, hf_bpdu_msti_bridge_id
, tvb
, offset
+ ALT_MSTI_BRIDGE_IDENTIFIER
, 2, ENC_BIG_ENDIAN
);
894 proto_tree_add_item(msti_tree
, hf_bpdu_msti_bridge_id_priority
, tvb
, offset
+ ALT_MSTI_BRIDGE_IDENTIFIER
, 2, ENC_BIG_ENDIAN
);
895 proto_tree_add_item(msti_tree
, hf_bpdu_msti_bridge_id_mac
, tvb
,
896 offset
+ ALT_MSTI_BRIDGE_IDENTIFIER
+ 2, 6, ENC_NA
);
898 proto_tree_add_item(msti_tree
, hf_bpdu_msti_port_id
, tvb
, offset
+ALT_MSTI_PORT_IDENTIFIER
, 2, ENC_BIG_ENDIAN
);
900 proto_tree_add_item(msti_tree
, hf_bpdu_msti_remaining_hops
, tvb
,
901 offset
+ ALT_MSTI_REMAINING_HOPS
, 1, ENC_BIG_ENDIAN
);
903 msti_length_remaining
-= ALT_MSTI_MESSAGE_SIZE
;
904 offset
+= ALT_MSTI_MESSAGE_SIZE
;
909 if (protocol_version_identifier
>= 4 && version_1_length
== 0
910 && tvb_reported_length(tvb
) >= 106) {
912 * OK, it passes the "Protocol Identifier is 0000 0000
913 * 0000 0000", "Protocol Version Identifier is 4 or
914 * greater", "BPDU Type is 0000 0010", "contains 106 or
915 * more octets", and "a Version 1 Length of 0" tests.
917 bpdu_version_4_length
= BPDU_MSTI
+ total_msti_length
;
918 version_4_length
= tvb_get_ntohs(tvb
, bpdu_version_4_length
);
920 proto_tree_add_uint(bpdu_tree
, hf_bpdu_version_4_length
, tvb
,
921 bpdu_version_4_length
, 2, version_4_length
);
923 /* version 4 length is 55 or more.
925 if (version_4_length
>= 53) {
926 static int * const agreements
[] = {
927 &hf_bpdu_flags_agree_num
,
928 &hf_bpdu_flags_dagree_num
,
929 &hf_bpdu_flags_agree_valid
,
930 &hf_bpdu_flags_restricted_role
,
934 spt_tree
= proto_tree_add_subtree(bpdu_tree
, tvb
, bpdu_version_4_length
, -1,
935 ett_spt
, NULL
, "SPT Extension");
937 spt_offset
= (bpdu_version_4_length
+ 2);
941 aux_mcid_tree
= proto_tree_add_subtree(spt_tree
, tvb
, spt_offset
,
942 MCID_LEN
, ett_aux_mcid
, NULL
, "MCID Data");
944 proto_tree_add_item(aux_mcid_tree
,
945 hf_bpdu_spt_config_format_selector
, tvb
, spt_offset
, 1,
947 proto_tree_add_item(aux_mcid_tree
, hf_bpdu_spt_config_name
, tvb
,
948 spt_offset
+ 1, 32, ENC_ASCII
| ENC_NA
);
950 proto_tree_add_item(aux_mcid_tree
,
951 hf_bpdu_spt_config_revision_level
, tvb
, spt_offset
+ 33,
953 proto_tree_add_item(aux_mcid_tree
, hf_bpdu_spt_config_digest
,
954 tvb
, spt_offset
+ 35, 16, ENC_NA
);
955 spt_offset
+= MCID_LEN
;
958 agreement_tree
= proto_tree_add_subtree(spt_tree
, tvb
, spt_offset
,
959 -1, ett_agreement
, &agreement_item
, "Agreement Data");
961 spt_agree_data
= tvb_get_uint8(tvb
, spt_offset
);
964 proto_item_append_text(agreement_item
, "%sAN: %d", sep
, (spt_agree_data
& 0x03));
966 proto_tree_add_bitmask_list_value(agreement_tree
, tvb
, spt_offset
, 1, agreements
, spt_agree_data
);
969 proto_item_append_text(agreement_item
, "%sDAN: %d", sep
, ((spt_agree_data
& 0x0C) >> 2));
971 if (sep
!= initial_sep
) {
972 proto_item_append_text(agreement_item
, ")");
976 proto_tree_add_item(agreement_tree
, hf_bpdu_agreement_digest_format_id
, tvb
, spt_offset
, 1, ENC_NA
);
977 proto_tree_add_item(agreement_tree
, hf_bpdu_agreement_digest_format_capabilities
, tvb
, spt_offset
, 1, ENC_NA
);
980 proto_tree_add_item(agreement_tree
, hf_bpdu_agreement_digest_convention_id
, tvb
, spt_offset
, 1, ENC_NA
);
981 proto_tree_add_item(agreement_tree
, hf_bpdu_agreement_digest_convention_capabilities
, tvb
, spt_offset
, 1, ENC_NA
);
984 proto_tree_add_item(agreement_tree
, hf_bpdu_agreement_digest_edge_count
, tvb
, spt_offset
, 2, ENC_BIG_ENDIAN
);
987 proto_tree_add_item(agreement_tree
, hf_bpdu_spt_agreement_digest
,
988 tvb
, spt_offset
, 20, ENC_NA
);
989 /*spt_offset += 20;*/
991 if (protocol_version_identifier
== 4) {
992 set_actual_length(tvb
, (bpdu_version_4_length
+ version_4_length
+ 2));
996 } else { /* It is RSTP BPDU and may still be Rapid PVST+ */
998 dissect_bpdu_pvst_tlv(pinfo
, bpdu_tree
, tvb
);
1003 dissect_bpdu_cisco(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
1005 dissect_bpdu(tvb
, pinfo
, tree
, true);
1006 return tvb_captured_length(tvb
);
1010 dissect_bpdu_generic(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
1012 dissect_bpdu(tvb
, pinfo
, tree
, false);
1013 return tvb_captured_length(tvb
);
1017 proto_register_bpdu(void)
1020 static hf_register_info hf
[] = {
1021 { &hf_bpdu_proto_id
,
1022 { "Protocol Identifier", "stp.protocol",
1023 FT_UINT16
, BASE_HEX
, VALS(protocol_id_vals
), 0x0,
1025 { &hf_bpdu_version_id
,
1026 { "Protocol Version Identifier", "stp.version",
1027 FT_UINT8
, BASE_DEC
, VALS(version_id_vals
), 0x0,
1030 { "BPDU Type", "stp.type",
1031 FT_UINT8
, BASE_HEX
, VALS(bpdu_type_vals
), 0x0,
1034 { "BPDU flags", "stp.flags",
1035 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1037 { &hf_bpdu_flags_tcack
,
1038 { "Topology Change Acknowledgment", "stp.flags.tcack",
1039 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), BPDU_FLAGS_TCACK
,
1041 { &hf_bpdu_flags_agreement
,
1042 { "Agreement", "stp.flags.agreement",
1043 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), BPDU_FLAGS_AGREEMENT
,
1045 { &hf_bpdu_flags_forwarding
,
1046 { "Forwarding", "stp.flags.forwarding",
1047 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), BPDU_FLAGS_FORWARDING
,
1049 { &hf_bpdu_flags_learning
,
1050 { "Learning", "stp.flags.learning",
1051 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), BPDU_FLAGS_LEARNING
,
1053 { &hf_bpdu_flags_port_role
,
1054 { "Port Role", "stp.flags.port_role",
1055 FT_UINT8
, BASE_DEC
, VALS(role_vals
), BPDU_FLAGS_PORT_ROLE_MASK
,
1057 { &hf_bpdu_flags_proposal
,
1058 { "Proposal", "stp.flags.proposal",
1059 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), BPDU_FLAGS_PROPOSAL
,
1061 { &hf_bpdu_flags_tc
,
1062 { "Topology Change", "stp.flags.tc",
1063 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), BPDU_FLAGS_TC
,
1065 { &hf_bpdu_root_prio
,
1066 { "Root Bridge Priority", "stp.root.prio",
1067 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1069 { &hf_bpdu_root_sys_id_ext
,
1070 { "Root Bridge System ID Extension", "stp.root.ext",
1071 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1073 { &hf_bpdu_root_mac
,
1074 { "Root Bridge System ID", "stp.root.hw",
1075 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
1077 { &hf_bpdu_root_cost
,
1078 { "Root Path Cost", "stp.root.cost",
1079 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1081 { &hf_bpdu_bridge_prio
,
1082 { "Bridge Priority", "stp.bridge.prio",
1083 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1085 { &hf_bpdu_bridge_sys_id_ext
,
1086 { "Bridge System ID Extension", "stp.bridge.ext",
1087 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1089 { &hf_bpdu_bridge_mac
,
1090 { "Bridge System ID", "stp.bridge.hw",
1091 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
1094 { "Port identifier", "stp.port",
1095 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
1098 { "Message Age", "stp.msg_age",
1099 FT_DOUBLE
, BASE_NONE
, NULL
, 0x0,
1102 { "Max Age", "stp.max_age",
1103 FT_DOUBLE
, BASE_NONE
, NULL
, 0x0,
1105 { &hf_bpdu_hello_time
,
1106 { "Hello Time", "stp.hello",
1107 FT_DOUBLE
, BASE_NONE
, NULL
, 0x0,
1109 { &hf_bpdu_forward_delay
,
1110 { "Forward Delay", "stp.forward",
1111 FT_DOUBLE
, BASE_NONE
, NULL
, 0x0,
1113 { &hf_bpdu_version_1_length
,
1114 { "Version 1 Length", "stp.version_1_length",
1115 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1117 { &hf_bpdu_pvst_tlvtype
,
1118 { "Type", "stp.pvst.tlvtype",
1119 FT_UINT16
, BASE_HEX
, VALS(bpdu_pvst_tlv_vals
), 0x0,
1121 { &hf_bpdu_pvst_tlvlength
,
1122 { "Length", "stp.pvst.tlvlen",
1123 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1125 { &hf_bpdu_pvst_tlv_origvlan
,
1126 { "Originating VLAN", "stp.pvst.origvlan",
1127 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1129 { &hf_bpdu_pvst_tlvvalue
,
1130 { "Value", "stp.pvst.tlvval",
1131 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1133 { &hf_bpdu_version_3_length
,
1134 { "Version 3 Length", "mstp.version_3_length",
1135 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1137 { &hf_bpdu_mst_config_format_selector
,
1138 { "MST Config ID format selector", "mstp.config_format_selector",
1139 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1141 { &hf_bpdu_mst_config_name
,
1142 { "MST Config name", "mstp.config_name",
1143 FT_STRINGZPAD
, BASE_NONE
, NULL
, 0x0,
1145 { &hf_bpdu_mst_config_revision_level
,
1146 { "MST Config revision", "mstp.config_revision_level",
1147 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1149 { &hf_bpdu_mst_config_digest
,
1150 { "MST Config digest", "mstp.config_digest",
1151 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1153 { &hf_bpdu_cist_internal_root_path_cost
,
1154 { "CIST Internal Root Path Cost", "mstp.cist_internal_root_path_cost",
1155 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1157 { &hf_bpdu_cist_bridge_prio
,
1158 { "CIST Bridge Priority", "mstp.cist_bridge.prio",
1159 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1161 { &hf_bpdu_cist_bridge_sys_id_ext
,
1162 { "CIST Bridge Identifier System ID Extension", "mstp.cist_bridge.ext",
1163 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1165 { &hf_bpdu_cist_bridge_mac
,
1166 { "CIST Bridge Identifier System ID", "mstp.cist_bridge.hw",
1167 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
1169 { &hf_bpdu_cist_remaining_hops
,
1170 { "CIST Remaining hops", "mstp.cist_remaining_hops",
1171 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1173 { &hf_bpdu_msti_flags
,
1174 { "MSTI flags", "mstp.msti.flags",
1175 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1177 { &hf_bpdu_mst_priority
,
1178 { "Priority", "mstp.msti.priority",
1179 FT_UINT8
, BASE_HEX
, NULL
, 0xF0,
1181 { &hf_bpdu_msti_id_FFF
,
1182 { "MSTID", "mstp.msti.msti_id",
1183 FT_UINT16
, BASE_DEC
, NULL
, 0x0FFF,
1186 { "MSTID", "mstp.msti.msti_id",
1187 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1189 { &hf_bpdu_msti_regional_root_id
,
1190 { "MSTI Regional Root Identifier", "mstp.msti.regional_root_id",
1191 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1193 { &hf_bpdu_msti_regional_root_mac
,
1194 { "Regional Root", "mstp.msti.root.hw",
1195 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
1197 { &hf_bpdu_msti_internal_root_path_cost
,
1198 { "Internal root path cost", "mstp.msti.root_cost",
1199 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1201 { &hf_bpdu_msti_bridge_id
,
1202 { "MSTI Bridge Identifier", "mstp.msti.bridge_id",
1203 FT_UINT16
, BASE_DEC
, NULL
, 0x0FFF,
1205 { &hf_bpdu_msti_bridge_id_priority
,
1206 { "MSTI Bridge Priority", "mstp.msti.bridge_id_priority",
1207 FT_UINT16
, BASE_DEC
, NULL
, 0xF000,
1209 { &hf_bpdu_msti_bridge_id_mac
,
1210 { "MSTI Bridge MAC", "mstp.msti.bridge_id_mac",
1211 FT_ETHER
, BASE_NONE
, NULL
, 0x0,
1213 { &hf_bpdu_msti_bridge_identifier_priority
,
1214 { "Bridge Identifier Priority", "mstp.msti.bridge_priority",
1215 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1217 { &hf_bpdu_msti_port_identifier_priority
,
1218 { "Port identifier priority", "mstp.msti.port_priority",
1219 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1221 { &hf_bpdu_msti_port_id
,
1222 { "Port identifier", "mstp.msti.port",
1223 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
1225 { &hf_bpdu_msti_remaining_hops
,
1226 { "Remaining hops", "mstp.msti.remaining_hops",
1227 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1229 { &hf_bpdu_version_4_length
,
1230 { "Version 4 Length", "mstp.version_4_length",
1231 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1233 { &hf_bpdu_spt_config_format_selector
,
1234 { "SPT Config ID format selector", "mstp.config_format_selector",
1235 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1237 { &hf_bpdu_spt_config_name
,
1238 {"SPT Config name", "mstp.config_name",
1239 FT_STRINGZPAD
, BASE_NONE
, NULL
, 0x0,
1241 { &hf_bpdu_spt_config_revision_level
,
1242 { "SPT Config revision", "mstp.config_revision_level",
1243 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1245 { &hf_bpdu_spt_config_digest
,
1246 { "SPT Config digest", "mstp.config_digest",
1247 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1249 { &hf_bpdu_flags_agree_num
,
1250 { "Agreement Number", "mstp.agree_flags.agreement_num",
1251 FT_UINT8
, BASE_DEC
, NULL
, 0x03,
1253 { &hf_bpdu_flags_dagree_num
,
1254 { "Disagreement Number", "mstp.agree_flags.dagreement_num",
1255 FT_UINT8
, BASE_DEC
, NULL
, 0x0C,
1257 { &hf_bpdu_flags_agree_valid
,
1258 { "Agreement Valid Flag", "mstp.agree_flags.agreement_valid",
1259 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), 0x10,
1261 { &hf_bpdu_flags_restricted_role
,
1262 { "Restricted Role", "mstp.agree_flags.rest_role",
1263 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
), 0x20,
1265 { &hf_bpdu_spt_agreement_digest
,
1266 { "Agreement Digest", "mstp.agreement_digest",
1267 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1269 { &hf_bpdu_agreement_digest_format_id
,
1270 { "Agreement Digest Format Id", "bpdu.agreement_digest_format_id",
1271 FT_UINT8
, BASE_DEC
, NULL
, 0xF0,
1273 { &hf_bpdu_agreement_digest_format_capabilities
,
1274 { "Agreement Digest Format Capabilities", "bpdu.agreement_digest_format_capabilities",
1275 FT_UINT8
, BASE_DEC
, NULL
, 0x0F,
1277 { &hf_bpdu_agreement_digest_convention_id
,
1278 { "Agreement Digest Convention Id", "bpdu.agreement_digest_convention_id",
1279 FT_UINT8
, BASE_DEC
, NULL
, 0xF0,
1281 { &hf_bpdu_agreement_digest_convention_capabilities
,
1282 { "Agreement Digest Convention Capabilities", "bpdu.agreement_digest_convention_capabilities",
1283 FT_UINT8
, BASE_DEC
, NULL
, 0x0F,
1285 { &hf_bpdu_agreement_digest_edge_count
,
1286 { "Agreement Digest Edge Count", "bpdu.agreement_digest_edge_count",
1287 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1290 static int *ett
[] = {
1297 &ett_cist_bridge_id
,
1304 static ei_register_info ei
[] = {
1305 { &ei_pvst_tlv_length_invalid
,
1306 { "stp.pvst.tlvlen.invalid", PI_MALFORMED
, PI_ERROR
,
1307 "Indicated length is not valid for this record type", EXPFILL
}},
1309 { &ei_pvst_tlv_origvlan_missing
,
1310 { "stp.pvst.origvlan.missing", PI_MALFORMED
, PI_ERROR
,
1311 "Originating (PVID) VLAN TLV is missing or corrupt", EXPFILL
}},
1313 { &ei_pvst_tlv_truncated
,
1314 { "stp.pvst.tlv.truncated", PI_MALFORMED
, PI_ERROR
,
1315 "TLV record is truncated prematurely", EXPFILL
}},
1317 { &ei_pvst_tlv_unknown
,
1318 { "stp.pvst.tlv.unknown", PI_UNDECODED
, PI_COMMENT
,
1319 "TLV type is unknown", EXPFILL
}},
1321 { &ei_bpdu_version_support
,
1322 { "bpdu.version_support", PI_PROTOCOL
, PI_WARN
,
1323 "This version of Wireshark only knows about versions 0, 2, 3 & 4", EXPFILL
}},
1326 { "stp.type.unknown", PI_PROTOCOL
, PI_WARN
,
1327 "Unknown BPDU type data", EXPFILL
}},
1330 module_t
*bpdu_module
;
1331 expert_module_t
*expert_bpdu
;
1333 proto_bpdu
= proto_register_protocol("Spanning Tree Protocol", "STP", "stp");
1334 proto_register_field_array(proto_bpdu
, hf
, array_length(hf
));
1335 proto_register_subtree_array(ett
, array_length(ett
));
1337 bpdu_handle
= register_dissector("bpdu", dissect_bpdu_generic
, proto_bpdu
);
1338 bpdu_cisco_handle
= register_dissector("bpdu_cisco", dissect_bpdu_cisco
, proto_bpdu
);
1340 expert_bpdu
= expert_register_protocol(proto_bpdu
);
1341 expert_register_field_array(expert_bpdu
, ei
, array_length(ei
));
1343 bpdu_module
= prefs_register_protocol(proto_bpdu
, NULL
);
1344 prefs_register_bool_preference(bpdu_module
, "use_system_id_extension",
1345 "Use 802.1t System ID Extensions",
1346 "Whether the BPDU dissector should use 802.1t System ID Extensions when dissecting the Bridge Identifier",
1347 &bpdu_use_system_id_extensions
);
1351 proto_reg_handoff_bpdu(void)
1354 * Get handle for the GVRP dissector.
1356 gvrp_handle
= find_dissector("gvrp");
1359 * Get handle for the GMRP dissector.
1361 gmrp_handle
= find_dissector_add_dependency("gmrp", proto_bpdu
);
1363 dissector_add_uint("llc.dsap", SAP_BPDU
, bpdu_handle
);
1364 dissector_add_uint("chdlc.protocol", CHDLCTYPE_BPDU
, bpdu_handle
);
1365 dissector_add_uint("ethertype", ETHERTYPE_STP
, bpdu_handle
);
1366 dissector_add_uint("llc.cisco_pid", CISCO_PID_RLQ_REQ
, bpdu_handle
); /* Cisco's RLQ is just plain STP */
1367 dissector_add_uint("llc.cisco_pid", CISCO_PID_RLQ_RESP
, bpdu_handle
); /* Cisco's RLQ is just plain STP */
1368 dissector_add_uint("llc.cisco_pid", CISCO_PID_VLAN_BRIDGE
, bpdu_handle
); /* Cisco's VLAN-bridge STP is just plain STP */
1369 dissector_add_uint("llc.cisco_pid", CISCO_PID_PVSTPP
, bpdu_cisco_handle
); /* Handle Cisco's (R)PVST+ TLV extensions */
1373 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1378 * indent-tabs-mode: nil
1381 * ex: set shiftwidth=2 tabstop=8 expandtab:
1382 * :indentSize=2:tabSize=8:noTabs=true: