1 /* packet-msnip.c 2001 Ronnie Sahlberg <See AUTHORS for email>
2 * Routines for IGMP/MSNIP packet disassembly
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 MSNIP " Multicast Source Notification of Interest Protocol
35 Defined in draft-ietf-idmr-igmp-msnip-00.txt
44 #include <epan/packet.h>
45 #include "packet-igmp.h"
46 #include "packet-msnip.h"
49 static int proto_msnip = -1;
50 static int hf_checksum = -1;
51 static int hf_checksum_bad = -1;
52 static int hf_type = -1;
53 static int hf_count = -1;
54 static int hf_holdtime = -1;
55 static int hf_groups = -1;
56 static int hf_maddr = -1;
57 static int hf_mask = -1;
58 static int hf_holdtime16 = -1;
59 static int hf_genid = -1;
60 static int hf_rec_type = -1;
62 static int ett_msnip = -1;
63 static int ett_groups = -1;
68 #define MSNIP_RMR 0x25
69 static const value_string msnip_types[] = {
70 {MSNIP_GM, "Multicast Group Map"},
71 {MSNIP_IS, "Multicast Interest Solicitation"},
72 {MSNIP_RMR, "Multicast Receiver Membership Report"},
76 #define MSNIP_RECTYPE_TRANSMIT 1
77 #define MSNIP_RECTYPE_HOLD 2
78 static const value_string msnip_rec_types[] = {
79 {MSNIP_RECTYPE_TRANSMIT, "Request to start transmitting group"},
80 {MSNIP_RECTYPE_HOLD, "Request to hold transmitting group"},
85 dissect_msnip_rmr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
90 count = tvb_get_guint8(tvb, offset);
91 proto_tree_add_uint(parent_tree, hf_count, tvb, offset, 1, count);
95 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
103 int old_offset = offset;
105 item = proto_tree_add_item(parent_tree, hf_groups,
106 tvb, offset, -1, FALSE);
107 tree = proto_item_add_subtree(item, ett_groups);
110 rec_type = tvb_get_guint8(tvb, offset);
111 proto_tree_add_uint(tree, hf_rec_type, tvb, offset, 1, rec_type);
114 /* skip 3 unused bytes */
117 /* multicast group */
118 maddr = tvb_get_ipv4(tvb, offset);
119 proto_tree_add_ipv4(tree, hf_maddr, tvb, offset, 4,
124 proto_item_set_text(item,"Group: %s %s",
125 ip_to_str((guint8 *)&maddr),
126 val_to_str(rec_type, msnip_rec_types,
127 "Unknown Type:0x%02x"));
129 proto_item_set_len(item, offset-old_offset);
137 dissect_msnip_is(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
140 /* skip reserved byte */
144 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
147 /* 16 bit holdtime */
148 proto_tree_add_uint(parent_tree, hf_holdtime16, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
152 proto_tree_add_uint(parent_tree, hf_genid, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
160 dissect_msnip_gm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
165 count = tvb_get_guint8(tvb, offset);
166 proto_tree_add_uint(parent_tree, hf_count, tvb, offset, 1, count);
170 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
174 proto_tree_add_uint(parent_tree, hf_holdtime, tvb, offset, 4, count);
182 int old_offset = offset;
184 item = proto_tree_add_item(parent_tree, hf_groups,
185 tvb, offset, -1, FALSE);
186 tree = proto_item_add_subtree(item, ett_groups);
188 /* multicast group */
189 maddr = tvb_get_ipv4(tvb, offset);
190 proto_tree_add_ipv4(tree, hf_maddr, tvb, offset, 4,
195 masklen = tvb_get_guint8(tvb, offset);
196 proto_tree_add_uint(tree, hf_mask, tvb,
200 /* skip 3 unused bytes */
204 proto_item_set_text(item,"Group: %s/%d",
205 ip_to_str((guint8 *)&maddr), masklen);
207 proto_item_set_len(item, offset-old_offset);
215 /* This function is only called from the IGMP dissector */
217 dissect_msnip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
223 if (!proto_is_protocol_enabled(find_protocol_by_id(proto_msnip))) {
224 /* we are not enabled, skip entire packet to be nice
225 to the igmp layer. (so clicking on IGMP will display the data)
227 return offset+tvb_length_remaining(tvb, offset);
230 item = proto_tree_add_item(parent_tree, proto_msnip, tvb, offset, -1, FALSE);
231 tree = proto_item_add_subtree(item, ett_msnip);
234 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSNIP");
235 col_clear(pinfo->cinfo, COL_INFO);
238 type = tvb_get_guint8(tvb, offset);
239 if (check_col(pinfo->cinfo, COL_INFO)) {
240 col_add_str(pinfo->cinfo, COL_INFO,
241 val_to_str(type, msnip_types,
242 "Unknown Type:0x%02x"));
245 /* type of command */
246 proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);
251 offset = dissect_msnip_gm(tvb, pinfo, tree, offset);
254 offset = dissect_msnip_is(tvb, pinfo, tree, offset);
257 offset = dissect_msnip_rmr(tvb, pinfo, tree, offset);
262 proto_item_set_len(item, offset);
270 proto_register_msnip(void)
272 static hf_register_info hf[] = {
274 { "Type", "msnip.type", FT_UINT8, BASE_HEX,
275 VALS(msnip_types), 0, "MSNIP Packet Type", HFILL }},
278 { "Checksum", "msnip.checksum", FT_UINT16, BASE_HEX,
279 NULL, 0, "MSNIP Checksum", HFILL }},
282 { "Bad Checksum", "msnip.checksum_bad", FT_BOOLEAN, BASE_NONE,
283 NULL, 0x0, "Bad MSNIP Checksum", HFILL }},
286 { "Count", "msnip.count", FT_UINT8, BASE_DEC,
287 NULL, 0, "MSNIP Number of groups", HFILL }},
290 { "Holdtime", "msnip.holdtime", FT_UINT32, BASE_DEC,
291 NULL, 0, "MSNIP Holdtime in seconds", HFILL }},
294 { "Groups", "msnip.groups", FT_NONE, BASE_NONE,
295 NULL, 0, "MSNIP Groups", HFILL }},
298 { "Multicast group", "msnip.maddr", FT_IPv4, BASE_NONE,
299 NULL, 0, "MSNIP Multicast Group", HFILL }},
302 { "Netmask", "msnip.netmask", FT_UINT8, BASE_DEC,
303 NULL, 0, "MSNIP Netmask", HFILL }},
306 { "Holdtime", "msnip.holdtime16", FT_UINT16, BASE_DEC,
307 NULL, 0, "MSNIP Holdtime in seconds", HFILL }},
310 { "Generation ID", "msnip.genid", FT_UINT16, BASE_DEC,
311 NULL, 0, "MSNIP Generation ID", HFILL }},
314 { "Record Type", "msnip.rec_type", FT_UINT8, BASE_DEC,
315 VALS(msnip_rec_types), 0, "MSNIP Record Type", HFILL }},
318 static gint *ett[] = {
323 proto_msnip = proto_register_protocol("MSNIP: Multicast Source Notification of Interest Protocol",
325 proto_register_field_array(proto_msnip, hf, array_length(hf));
326 proto_register_subtree_array(ett, array_length(ett));