2 * Routines for DEC BPDU (DEC Spanning Tree Protocol) disassembly
4 * $Id: packet-dec-bpdu.c,v 1.1 2001/01/05 19:00:37 guy Exp $
6 * Copyright 2001 Paul Ionescu <paul@acorp.ro>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@zing.org>
10 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
36 #ifdef HAVE_NETINET_IN_H
37 # 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 static int proto_dec_bpdu = -1;
66 static gint ett_dec_bpdu = -1;
69 dissect_dec_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
70 guint8 protocol_identifier;
71 guint8 protocol_version;
74 proto_tree *bpdu_tree;
77 CHECK_DISPLAY_AS_DATA(proto_dec_bpdu, tvb, pinfo, tree);
79 pinfo->current_proto = "DEC_STP";
81 if (check_col(pinfo->fd, COL_PROTOCOL)) {
82 col_set_str(pinfo->fd, COL_PROTOCOL, "DEC_STP");
85 bpdu_type = tvb_get_guint8(tvb, BPDU_TYPE);
86 flags=tvb_get_guint8(tvb,BPDU_FLAGS);
88 if (check_col(pinfo->fd, COL_INFO)) {
90 col_add_fstr(pinfo->fd, COL_INFO, "Hello Packet");
91 else if (bpdu_type == 0x02)
92 col_add_fstr(pinfo->fd, COL_INFO, "Topology Change Notification");
96 protocol_identifier = tvb_get_guint8(tvb, BPDU_DEC_CODE);
98 protocol_version = tvb_get_guint8(tvb, BPDU_VERSION);
100 ti = proto_tree_add_protocol_format(tree, proto_dec_bpdu, tvb, 0, 27,
101 "DEC Spanning Tree Protocol");
102 bpdu_tree = proto_item_add_subtree(ti, ett_dec_bpdu);
104 proto_tree_add_text(bpdu_tree, tvb, BPDU_DEC_CODE, 1, "Protocol ID: %d (%s)",
106 protocol_identifier==0xe1?"DEC Spanning Tree Protocol":
107 "Unknown protocol, the dissection may be wrong");
109 proto_tree_add_text(bpdu_tree, tvb, BPDU_TYPE,1, "BPDU Type: %d (%s)", bpdu_type,
110 (bpdu_type==25?"Hello Packet":(bpdu_type==2?"Topology change notice":"Unknown")));
112 proto_tree_add_text(bpdu_tree, tvb, BPDU_VERSION,1, "BPDU Version: %d (%s)",
113 protocol_version,protocol_version==1?"DEC STP Version 1":"Unknown Version");
115 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS,1, "Flags: %d",flags);
118 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS, 1, " 1... .... Use short timers");
120 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS, 1, " .... ..1. Topology Change Acknowledgment");
122 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS, 1, " .... ...1 Topology Change");
124 proto_tree_add_text(bpdu_tree, tvb, BPDU_ROOT_PRI,2, "Root priority: %d",
125 tvb_get_ntohs(tvb,BPDU_ROOT_PRI));
126 proto_tree_add_text(bpdu_tree, tvb, BPDU_ROOT_MAC,6, "Root MAC: %s",
127 ether_to_str(tvb_get_ptr(tvb,BPDU_ROOT_MAC,6)));
128 proto_tree_add_text(bpdu_tree, tvb, BPDU_ROOT_PATH_COST,2, "Root path cost: %d",
129 tvb_get_ntohs(tvb,BPDU_ROOT_PATH_COST));
130 proto_tree_add_text(bpdu_tree, tvb, BPDU_BRIDGE_PRI,2, "Root priority: %d",
131 tvb_get_ntohs(tvb,BPDU_BRIDGE_PRI));
132 proto_tree_add_text(bpdu_tree, tvb, BPDU_BRIDGE_MAC,6, "Root MAC: %s",
133 ether_to_str(tvb_get_ptr(tvb,BPDU_BRIDGE_MAC,6)));
134 proto_tree_add_text(bpdu_tree, tvb, BPDU_PORT_IDENTIFIER,1, "Port identifier: %d",
135 tvb_get_guint8(tvb,BPDU_PORT_IDENTIFIER));
136 proto_tree_add_text(bpdu_tree, tvb, BPDU_MESSAGE_AGE,1, "Age: %d",
137 tvb_get_guint8(tvb,BPDU_MESSAGE_AGE));
138 proto_tree_add_text(bpdu_tree, tvb, BPDU_HELLO_TIME,1, "Hello time: %d",
139 tvb_get_guint8(tvb,BPDU_HELLO_TIME));
140 proto_tree_add_text(bpdu_tree, tvb, BPDU_MAX_AGE,1, "Max Age: %d",
141 tvb_get_guint8(tvb,BPDU_MAX_AGE));
142 proto_tree_add_text(bpdu_tree, tvb, BPDU_FORWARD_DELAY,1, "Forward Delay: %d",
143 tvb_get_guint8(tvb,BPDU_FORWARD_DELAY));
149 proto_register_dec_bpdu(void)
152 static gint *ett[] = {
156 proto_dec_bpdu = proto_register_protocol("DEC Spanning Tree Protocol", "DEC_STP", "dec_stp");
157 proto_register_subtree_array(ett, array_length(ett));
159 register_dissector("dec_bpdu", dissect_dec_bpdu);
163 proto_reg_handoff_dec_bpdu(void)
165 dissector_add("ethertype", ETHERTYPE_DEC_LB, dissect_dec_bpdu);