2 * Routines for DEC BPDU (DEC Spanning Tree Protocol) disassembly
4 * $Id: packet-dec-bpdu.c,v 1.3 2001/01/07 00:23:03 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 #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 CHECK_DISPLAY_AS_DATA(proto_dec_bpdu, tvb, pinfo, tree);
82 pinfo->current_proto = "DEC_STP";
84 if (check_col(pinfo->fd, COL_PROTOCOL)) {
85 col_set_str(pinfo->fd, COL_PROTOCOL, "DEC_STP");
88 bpdu_type = tvb_get_guint8(tvb, BPDU_TYPE);
89 flags=tvb_get_guint8(tvb,BPDU_FLAGS);
91 if (check_col(pinfo->fd, COL_INFO)) {
93 col_add_fstr(pinfo->fd, COL_INFO, "Hello Packet");
94 else if (bpdu_type == 0x02)
95 col_add_fstr(pinfo->fd, COL_INFO, "Topology Change Notification");
98 tvb_set_reported_length(tvb, DEC_BPDU_SIZE);
101 protocol_identifier = tvb_get_guint8(tvb, BPDU_DEC_CODE);
103 protocol_version = tvb_get_guint8(tvb, BPDU_VERSION);
105 ti = proto_tree_add_protocol_format(tree, proto_dec_bpdu, tvb, 0, DEC_BPDU_SIZE,
106 "DEC Spanning Tree Protocol");
107 bpdu_tree = proto_item_add_subtree(ti, ett_dec_bpdu);
109 proto_tree_add_text(bpdu_tree, tvb, BPDU_DEC_CODE, 1, "Protocol ID: 0x%02x (%s)",
111 protocol_identifier==0xe1?"DEC Spanning Tree Protocol":
112 "Unknown protocol, the dissection may be wrong");
114 proto_tree_add_text(bpdu_tree, tvb, BPDU_TYPE,1, "BPDU Type: %u (%s)", bpdu_type,
115 (bpdu_type==25?"Hello Packet":(bpdu_type==2?"Topology change notice":"Unknown")));
117 proto_tree_add_text(bpdu_tree, tvb, BPDU_VERSION,1, "BPDU Version: %u (%s)",
118 protocol_version,protocol_version==1?"DEC STP Version 1":"Unknown Version");
120 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS,1, "Flags: 0x%02x",flags);
123 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS, 1, " 1... .... Use short timers");
125 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS, 1, " .... ..1. Topology Change Acknowledgment");
127 proto_tree_add_text(bpdu_tree, tvb, BPDU_FLAGS, 1, " .... ...1 Topology Change");
129 proto_tree_add_text(bpdu_tree, tvb, BPDU_ROOT_PRI,2, "Root priority: %u",
130 tvb_get_ntohs(tvb,BPDU_ROOT_PRI));
131 proto_tree_add_text(bpdu_tree, tvb, BPDU_ROOT_MAC,6, "Root MAC: %s",
132 ether_to_str(tvb_get_ptr(tvb,BPDU_ROOT_MAC,6)));
133 proto_tree_add_text(bpdu_tree, tvb, BPDU_ROOT_PATH_COST,2, "Root path cost: %u",
134 tvb_get_ntohs(tvb,BPDU_ROOT_PATH_COST));
135 proto_tree_add_text(bpdu_tree, tvb, BPDU_BRIDGE_PRI,2, "Root priority: %u",
136 tvb_get_ntohs(tvb,BPDU_BRIDGE_PRI));
137 proto_tree_add_text(bpdu_tree, tvb, BPDU_BRIDGE_MAC,6, "Root MAC: %s",
138 ether_to_str(tvb_get_ptr(tvb,BPDU_BRIDGE_MAC,6)));
139 proto_tree_add_text(bpdu_tree, tvb, BPDU_PORT_IDENTIFIER,1, "Port identifier: %u",
140 tvb_get_guint8(tvb,BPDU_PORT_IDENTIFIER));
141 proto_tree_add_text(bpdu_tree, tvb, BPDU_MESSAGE_AGE,1, "Age: %u",
142 tvb_get_guint8(tvb,BPDU_MESSAGE_AGE));
143 proto_tree_add_text(bpdu_tree, tvb, BPDU_HELLO_TIME,1, "Hello time: %u",
144 tvb_get_guint8(tvb,BPDU_HELLO_TIME));
145 proto_tree_add_text(bpdu_tree, tvb, BPDU_MAX_AGE,1, "Max Age: %u",
146 tvb_get_guint8(tvb,BPDU_MAX_AGE));
147 proto_tree_add_text(bpdu_tree, tvb, BPDU_FORWARD_DELAY,1, "Forward Delay: %u",
148 tvb_get_guint8(tvb,BPDU_FORWARD_DELAY));
154 proto_register_dec_bpdu(void)
156 static gint *ett[] = {
160 proto_dec_bpdu = proto_register_protocol("DEC Spanning Tree Protocol", "DEC_STP", "dec_stp");
161 proto_register_subtree_array(ett, array_length(ett));
165 proto_reg_handoff_dec_bpdu(void)
167 dissector_add("ethertype", ETHERTYPE_DEC_LB, dissect_dec_bpdu);