d42418d0325277c56be4d2cb4acdd1e33c39e466
[obnox/wireshark/wip.git] / epan / dissectors / packet-retix-bpdu.c
1 /* packet-retix-bpdu.c
2  * Routines for BPDU (Retix Spanning Tree Protocol) disassembly
3  *
4  * $Id$
5  *
6  * Copyright 2005 Giles Scott (gscott <AT> arubanetworks dot com>
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
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.
16  *
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.
21  *
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.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #if 0
32 #endif
33 #include <glib.h>
34 #include <epan/packet.h>
35 #if 0
36 #include <epan/llcsaps.h>
37 #include <epan/ppptypes.h>
38 #include <epan/chdlctypes.h>
39 #endif
40 #include <epan/addr_resolv.h>
41
42 static gint ett_retix_bpdu = -1;
43 static int proto_retix_bpdu = -1;
44
45 static int hf_retix_bpdu_root_mac = -1;
46 static int hf_retix_bpdu_bridge_mac = -1;
47 static int hf_retix_bpdu_max_age = -1;
48 static int hf_retix_bpdu_hello_time = -1;
49 static int hf_retix_bpdu_forward_delay = -1;
50
51 /* I don't have the spec's for this protcol so its been reverse engineered
52  * It seems quite like 802.1D
53  * It looks like the protocol version is specified in the ethernet trailer
54  * In the single packet I have the trailer is
55  * "RevC CBPDU"
56  * There are several fields I've not dissected as I'm not exactly sure what they are
57  * What ever happened to Retix anyway?
58 */
59 static void
60 dissect_retix_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
61 {
62   proto_tree *retix_bpdu_tree;
63   proto_tree *ti;
64
65   col_set_str(pinfo->cinfo, COL_PROTOCOL, "R-STP");
66   col_clear(pinfo->cinfo, COL_INFO);
67   if (check_col(pinfo->cinfo, COL_INFO)){
68     col_add_fstr(pinfo->cinfo, COL_INFO, "Bridge MAC %s", tvb_ether_to_str(tvb, 10));
69   }
70
71
72   retix_bpdu_tree = NULL;
73
74   if (tree) {
75     ti = proto_tree_add_item(tree, proto_retix_bpdu, tvb, 0, -1, FALSE);
76     retix_bpdu_tree = proto_item_add_subtree(ti, ett_retix_bpdu);
77   }
78
79   proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_root_mac, tvb, 0, 6, ENC_NA);
80
81   proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_bridge_mac, tvb, 10, 6, ENC_NA);
82
83   proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_max_age, tvb, 20, 2, ENC_BIG_ENDIAN);
84   proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_hello_time, tvb, 22, 2, ENC_BIG_ENDIAN);
85   proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_forward_delay, tvb, 24, 2, ENC_BIG_ENDIAN);
86
87 }
88
89
90 void
91 proto_register_retix_bpdu(void)
92 {
93   static hf_register_info hf[] = {
94     { &hf_retix_bpdu_root_mac,
95     { "Root MAC",  "rstp.root.hw", FT_ETHER, BASE_NONE, NULL, 0x0,
96     NULL, HFILL}},
97
98     { &hf_retix_bpdu_bridge_mac,
99     { "Bridge MAC", "rstp.bridge.hw", FT_ETHER, BASE_NONE, NULL, 0x0,
100     NULL, HFILL}},
101
102     { &hf_retix_bpdu_max_age,
103     { "Max Age", "rstp.maxage", FT_UINT16, BASE_DEC, NULL, 0x0,
104     NULL, HFILL}},
105
106     { &hf_retix_bpdu_hello_time,
107     { "Hello Time", "rstp.hello", FT_UINT16, BASE_DEC, NULL, 0x0,
108     NULL, HFILL}},
109
110     { &hf_retix_bpdu_forward_delay,
111     { "Forward Delay", "rstp.forward", FT_UINT16, BASE_DEC, NULL, 0x0,
112     NULL, HFILL}},
113   };
114
115   static gint *ett[] ={
116     &ett_retix_bpdu,
117   };
118
119   proto_retix_bpdu = proto_register_protocol("Retix Spanning Tree Protocol", "R-STP", "r-stp");
120   proto_register_field_array(proto_retix_bpdu, hf, array_length(hf));
121   proto_register_subtree_array(ett, array_length(ett));
122   register_dissector("rbpdu", dissect_retix_bpdu, proto_retix_bpdu);
123 }
124
125 void
126 proto_reg_handoff_retix_bpdu(void)
127 {
128 }