aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-retix-bpdu.c
blob: 8cd7b3505066b263b04cd0bffd9cd204aa95fa2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* packet-retix-bpdu.c
 * Routines for BPDU (Retix Spanning Tree Protocol) disassembly
 *
 * $Id$
 *
 * Copyright 2005 Giles Scott (gscott <AT> arubanetworks dot com> 
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@ethereal.com>
 * Copyright 1998 Gerald Combs
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#if 0
#include <stdio.h>
#include <string.h>
#endif
#include <glib.h>
#include <epan/packet.h>
#if 0
#include "llcsaps.h"
#include "ppptypes.h"
#include "chdlctypes.h"
#endif
#include <epan/addr_resolv.h>

static gint ett_retix_bpdu = -1;
static int proto_retix_bpdu = -1;

static int hf_retix_bpdu_root_mac = -1;
static int hf_retix_bpdu_bridge_mac = -1;
static int hf_retix_bpdu_max_age = -1;
static int hf_retix_bpdu_hello_time = -1;
static int hf_retix_bpdu_forward_delay = -1;

/* I don't have the spec's for this protcol so its been reverse engineered
 * It seems quite like 802.1D
 * It looks like the protocol version is specified in the ethernet trailer
 * In the single packet I have the trailer is
 * "RevC CBPDU"
 * There are several fields I've not dissected as I'm not exactly sure what they are
 * What ever happened to Retix anyway?
*/
static void
dissect_retix_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  proto_tree *retix_bpdu_tree;
  proto_tree *ti;
  const guint8 *bridge_mac_str;

  if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "R-STP");
  }
  if (check_col(pinfo->cinfo, COL_INFO)) {
    col_clear(pinfo->cinfo, COL_INFO);
  }
  bridge_mac_str = tvb_get_ptr(tvb, 10, 6);
  if (check_col(pinfo->cinfo, COL_INFO)){
    col_add_fstr(pinfo->cinfo, COL_INFO, "Bridge MAC %s", ether_to_str(bridge_mac_str)); 
  }

  
  retix_bpdu_tree = NULL;

  if (tree) {
    ti = proto_tree_add_item(tree, proto_retix_bpdu, tvb, 0, -1, FALSE);
    retix_bpdu_tree = proto_item_add_subtree(ti, ett_retix_bpdu);
  }

  proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_root_mac, tvb, 0, 6, FALSE);

  proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_bridge_mac, tvb, 10, 6, FALSE);

  proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_max_age, tvb, 20, 2, FALSE);
  proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_hello_time, tvb, 22, 2, FALSE);
  proto_tree_add_item(retix_bpdu_tree, hf_retix_bpdu_forward_delay, tvb, 24, 2, FALSE);

}


void
proto_register_retix_bpdu(void)
{
  static hf_register_info hf[] = {
    { &hf_retix_bpdu_root_mac,
    { "Root MAC",  "rstp.root.hw", FT_ETHER, BASE_NONE, NULL, 0x0,
    "", HFILL}},

    { &hf_retix_bpdu_bridge_mac,
    { "Bridge MAC", "rstp.bridge.hw", FT_ETHER, BASE_NONE, NULL, 0x0,
    "", HFILL}},

    { &hf_retix_bpdu_max_age,
    { "Max Age", "rstp.maxage", FT_UINT16, BASE_DEC, NULL, 0x0,
    "", HFILL}},

    { &hf_retix_bpdu_hello_time,
    { "Hello Time", "rstp.hello", FT_UINT16, BASE_DEC, NULL, 0x0,
    "", HFILL}},

    { &hf_retix_bpdu_forward_delay,
    { "Forward Delay", "rstp.forward", FT_UINT16, BASE_DEC, NULL, 0x0,
    "", HFILL}},
  };

  static gint *ett[] ={
    &ett_retix_bpdu,
  };

  proto_retix_bpdu = proto_register_protocol("Retix Spanning Tree Protocol", "R-STP", "r-stp");
  proto_register_field_array(proto_retix_bpdu, hf, array_length(hf)); 
  proto_register_subtree_array(ett, array_length(ett));
  register_dissector("rbpdu", dissect_retix_bpdu, proto_retix_bpdu);
}

void
proto_reg_handoff_retix_bpdu(void)
{
}