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