2 * Routines for DEC BPDU (DEC Spanning Tree Protocol) disassembly
4 * $Id: packet-dec-bpdu.c,v 1.9 2001/12/10 00:25:27 guy Exp $
6 * Copyright 2001 Paul Ionescu <paul@acorp.ro>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
35 #ifdef HAVE_NETINET_IN_H
36 # include <netinet/in.h>
47 /* Offsets of fields within a BPDU */
49 #define BPDU_DEC_CODE 0
51 #define BPDU_VERSION 2
53 #define BPDU_ROOT_PRI 4
54 #define BPDU_ROOT_MAC 6
55 #define BPDU_ROOT_PATH_COST 12
56 #define BPDU_BRIDGE_PRI 14
57 #define BPDU_BRIDGE_MAC 16
58 #define BPDU_PORT_IDENTIFIER 22
59 #define BPDU_MESSAGE_AGE 23
60 #define BPDU_HELLO_TIME 24
61 #define BPDU_MAX_AGE 25
62 #define BPDU_FORWARD_DELAY 26
64 #define DEC_BPDU_SIZE 27
67 static int proto_dec_bpdu = -1;
69 static gint ett_dec_bpdu = -1;
72 dissect_dec_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
73 guint8 protocol_identifier;
74 guint8 protocol_version;
77 proto_tree *bpdu_tree;
80 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
81 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DEC_STP");
83 if (check_col(pinfo->cinfo, COL_INFO)) {
84 col_clear(pinfo->cinfo, COL_INFO);
87 bpdu_type = tvb_get_guint8(tvb, BPDU_TYPE);
88 flags=tvb_get_guint8(tvb,BPDU_FLAGS);
90 if (check_col(pinfo->cinfo, COL_INFO)) {
92 col_add_fstr(pinfo->cinfo, COL_INFO, "Hello Packet");
93 else if (bpdu_type == 0x02)
94 col_add_fstr(pinfo->cinfo, COL_INFO, "Topology Change Notification");
97 tvb_set_reported_length(tvb, DEC_BPDU_SIZE);
100 protocol_identifier = tvb_get_guint8(tvb, BPDU_DEC_CODE);
102 protocol_version = tvb_get_guint8(tvb, BPDU_VERSION);
104 ti = proto_tree_add_protocol_format(tree, proto_dec_bpdu, tvb, 0, DEC_BPDU_SIZE,
105 "DEC Spanning Tree Protocol");
106 bpdu_tree = proto_item_add_subtree(ti, ett_dec_bpdu);
108 proto_tree_add_text(bpdu_tree, tvb, BPDU_DEC_CODE, 1, "Protocol ID: 0x%02x (%s)",
110 protocol_identifier==0xe1?"DEC Spanning Tree Protocol":
111 "Unknown protocol, the dissection may be wrong");
113 proto_tree_add_text(bpdu_tree, tvb, BPDU_TYPE,1, "BPDU Type: %u (%s)", bpdu_type,
114 (bpdu_type==25?"Hello Packet":(bpdu_type==2?"Topology change notice":"Unknown")));
116 proto_tree_add_text(bpdu_tree, tvb, BPDU_VERSION,1, "BPDU Version: %u (%s)",
117 protocol_version,protocol_version==1?"DEC STP Version 1":"Unknown Version");
119 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS,1, "Flags: 0x%02x",flags);
122 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS, 1, " 1... .... Use short timers");
124 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS, 1, " .... ..1. Topology Change Acknowledgment");
126 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS, 1, " .... ...1 Topology Change");
128 proto_tree_add_text(bpdu_tree, tvb, BPDU_ROOT_PRI,2, "Root priority: %u",
129 tvb_get_ntohs(tvb,BPDU_ROOT_PRI));
130 proto_tree_add_text(bpdu_tree, tvb, BPDU_ROOT_MAC,6, "Root MAC: %s",
131 ether_to_str(tvb_get_ptr(tvb,BPDU_ROOT_MAC,6)));
132 proto_tree_add_text(bpdu_tree, tvb, BPDU_ROOT_PATH_COST,2, "Root path cost: %u",
133 tvb_get_ntohs(tvb,BPDU_ROOT_PATH_COST));
134 proto_tree_add_text(bpdu_tree, tvb, BPDU_BRIDGE_PRI,2, "Root priority: %u",
135 tvb_get_ntohs(tvb,BPDU_BRIDGE_PRI));
136 proto_tree_add_text(bpdu_tree, tvb, BPDU_BRIDGE_MAC,6, "Root MAC: %s",
137 ether_to_str(tvb_get_ptr(tvb,BPDU_BRIDGE_MAC,6)));
138 proto_tree_add_text(bpdu_tree, tvb, BPDU_PORT_IDENTIFIER,1, "Port identifier: %u",
139 tvb_get_guint8(tvb,BPDU_PORT_IDENTIFIER));
140 proto_tree_add_text(bpdu_tree, tvb, BPDU_MESSAGE_AGE,1, "Age: %u",
141 tvb_get_guint8(tvb,BPDU_MESSAGE_AGE));
142 proto_tree_add_text(bpdu_tree, tvb, BPDU_HELLO_TIME,1, "Hello time: %u",
143 tvb_get_guint8(tvb,BPDU_HELLO_TIME));
144 proto_tree_add_text(bpdu_tree, tvb, BPDU_MAX_AGE,1, "Max Age: %u",
145 tvb_get_guint8(tvb,BPDU_MAX_AGE));
146 proto_tree_add_text(bpdu_tree, tvb, BPDU_FORWARD_DELAY,1, "Forward Delay: %u",
147 tvb_get_guint8(tvb,BPDU_FORWARD_DELAY));
153 proto_register_dec_bpdu(void)
155 static gint *ett[] = {
159 proto_dec_bpdu = proto_register_protocol("DEC Spanning Tree Protocol",
160 "DEC_STP", "dec_stp");
161 proto_register_subtree_array(ett, array_length(ett));
165 proto_reg_handoff_dec_bpdu(void)
167 dissector_handle_t dec_bpdu_handle;
169 dec_bpdu_handle = create_dissector_handle(dissect_dec_bpdu,
171 dissector_add("ethertype", ETHERTYPE_DEC_LB, dec_bpdu_handle);
172 dissector_add("chdlctype", ETHERTYPE_DEC_LB, dec_bpdu_handle);
173 dissector_add("ppp.protocol", PPP_DEC_LB, dec_bpdu_handle);