HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-rgmp.c
blob641a0d44fc55654e6d7a9cf11f4e9117fe375289
1 /* packet-rgmp.c
2 * Routines for IGMP/RGMP packet disassembly
3 * Copyright 2006 Jaap Keuter
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 Based on RFC3488
29 This is a setup for RGMP dissection, a simple protocol bolted on IGMP.
30 The trick is to have IGMP dissector call this function (which by itself is not
31 registered as dissector). IGAP and other do the same.
35 #include "config.h"
37 #include <glib.h>
38 #include <epan/packet.h>
39 #include <epan/strutil.h>
40 #include "packet-igmp.h"
41 #include "packet-rgmp.h"
44 static int proto_rgmp = -1;
45 static int hf_type = -1;
46 static int hf_checksum = -1;
47 static int hf_checksum_bad = -1;
48 static int hf_maddr = -1;
50 static int ett_rgmp = -1;
52 static const value_string rgmp_types[] = {
53 {IGMP_RGMP_LEAVE, "Leave"},
54 {IGMP_RGMP_JOIN, "Join"},
55 {IGMP_RGMP_BYE, "Bye"},
56 {IGMP_RGMP_HELLO, "Hello"},
57 {0, NULL}
60 /* This function is only called from the IGMP dissector */
61 int
62 dissect_rgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
64 proto_tree *tree;
65 proto_item *item;
66 guint8 type;
68 if (!proto_is_protocol_enabled(find_protocol_by_id(proto_rgmp))) {
69 /* we are not enabled, skip entire packet to be nice
70 to the igmp layer. (so clicking on IGMP will display the data)
72 return offset + tvb_length_remaining(tvb, offset);
75 item = proto_tree_add_item(parent_tree, proto_rgmp, tvb, offset, -1, ENC_NA);
76 tree = proto_item_add_subtree(item, ett_rgmp);
78 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RGMP");
79 col_clear(pinfo->cinfo, COL_INFO);
81 type = tvb_get_guint8(tvb, offset);
82 col_add_str(pinfo->cinfo, COL_INFO,
83 val_to_str(type, rgmp_types, "Unknown Type: 0x%02x"));
84 proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);
85 offset += 1;
87 /* reserved */
89 offset += 1;
91 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
92 offset += 2;
94 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, ENC_BIG_ENDIAN);
95 offset += 4;
97 return offset;
101 void
102 proto_register_rgmp(void)
104 static hf_register_info hf[] = {
105 { &hf_type,
106 { "Type", "rgmp.type", FT_UINT8, BASE_HEX,
107 VALS(rgmp_types), 0, "RGMP Packet Type", HFILL }
110 { &hf_checksum,
111 { "Checksum", "rgmp.checksum", FT_UINT16, BASE_HEX,
112 NULL, 0, NULL, HFILL }
115 { &hf_checksum_bad,
116 { "Bad Checksum", "rgmp.checksum_bad", FT_BOOLEAN, BASE_NONE,
117 NULL, 0x0, NULL, HFILL }
120 { &hf_maddr,
121 { "Multicast group address", "rgmp.maddr", FT_IPv4, BASE_NONE,
122 NULL, 0, NULL, HFILL }
126 static gint *ett[] = {
127 &ett_rgmp
130 proto_rgmp = proto_register_protocol
131 ("Router-port Group Management Protocol", "RGMP", "rgmp");
132 proto_register_field_array(proto_rgmp, hf, array_length(hf));
133 proto_register_subtree_array(ett, array_length(ett));