HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-cgmp.c
blob4440e7f2d2a8a356abd8372ff481c1a89109747c
1 /* packet-cgmp.c
2 * Routines for the disassembly of the Cisco Group Management Protocol
4 * $Id$
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "config.h"
27 #include <glib.h>
29 #include <epan/packet.h>
32 * See
34 * http://www.barnett.sk/software/bbooks/cisco_multicasting_routing/chap04.html
36 * for some information on CGMP.
38 void proto_register_cgmp(void);
39 void proto_reg_handoff_cgmp(void);
41 static int proto_cgmp = -1;
42 static int hf_cgmp_version = -1;
43 static int hf_cgmp_type = -1;
44 static int hf_cgmp_count = -1;
45 static int hf_cgmp_gda = -1;
46 static int hf_cgmp_usa = -1;
48 static gint ett_cgmp = -1;
50 static const value_string type_vals[] = {
51 { 0, "Join" },
52 { 1, "Leave" },
53 { 0, NULL },
56 static void
57 dissect_cgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
59 proto_item *ti;
60 proto_tree *cgmp_tree = NULL;
61 int offset = 0;
62 guint8 count;
64 col_set_str(pinfo->cinfo, COL_PROTOCOL, "CGMP");
65 col_set_str(pinfo->cinfo, COL_INFO, "Cisco Group Management Protocol");
67 if (tree) {
68 ti = proto_tree_add_item(tree, proto_cgmp, tvb, offset, -1,
69 ENC_NA);
70 cgmp_tree = proto_item_add_subtree(ti, ett_cgmp);
72 proto_tree_add_item(cgmp_tree, hf_cgmp_version, tvb, offset, 1,
73 ENC_BIG_ENDIAN);
74 proto_tree_add_item(cgmp_tree, hf_cgmp_type, tvb, offset, 1,
75 ENC_BIG_ENDIAN);
76 offset += 1;
78 offset += 2; /* skip reserved field */
80 count = tvb_get_guint8(tvb, offset);
81 proto_tree_add_uint(cgmp_tree, hf_cgmp_count, tvb, offset, 1,
82 count);
83 offset += 1;
85 while (count != 0) {
86 proto_tree_add_item(cgmp_tree, hf_cgmp_gda, tvb, offset, 6,
87 ENC_NA);
88 offset += 6;
90 proto_tree_add_item(cgmp_tree, hf_cgmp_usa, tvb, offset, 6,
91 ENC_NA);
92 offset += 6;
94 count--;
99 void
100 proto_register_cgmp(void)
102 static hf_register_info hf[] = {
103 { &hf_cgmp_version,
104 { "Version", "cgmp.version", FT_UINT8, BASE_DEC, NULL, 0xF0,
105 NULL, HFILL }},
107 { &hf_cgmp_type,
108 { "Type", "cgmp.type", FT_UINT8, BASE_DEC, VALS(type_vals), 0x0F,
109 NULL, HFILL }},
111 { &hf_cgmp_count,
112 { "Count", "cgmp.count", FT_UINT8, BASE_DEC, NULL, 0x0,
113 NULL, HFILL }},
115 { &hf_cgmp_gda,
116 { "Group Destination Address", "cgmp.gda", FT_ETHER, BASE_NONE, NULL, 0x0,
117 NULL, HFILL }},
119 { &hf_cgmp_usa,
120 { "Unicast Source Address", "cgmp.usa", FT_ETHER, BASE_NONE, NULL, 0x0,
121 NULL, HFILL }},
123 static gint *ett[] = {
124 &ett_cgmp,
127 proto_cgmp = proto_register_protocol("Cisco Group Management Protocol",
128 "CGMP", "cgmp");
129 proto_register_field_array(proto_cgmp, hf, array_length(hf));
130 proto_register_subtree_array(ett, array_length(ett));
133 void
134 proto_reg_handoff_cgmp(void)
136 dissector_handle_t cgmp_handle;
138 cgmp_handle = create_dissector_handle(dissect_cgmp, proto_cgmp);
139 dissector_add_uint("llc.cisco_pid", 0x2001, cgmp_handle);
140 dissector_add_uint("ethertype", 0x2001, cgmp_handle);