1 /* packet-msnip.c 2001 Ronnie Sahlberg <See AUTHORS for email>
2 * Routines for IGMP/MSNIP packet disassembly
4 * $Id: packet-msnip.c,v 1.6 2002/02/01 11:01:57 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
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
42 #ifdef HAVE_SYS_TYPES_H
43 # include <sys/types.h>
50 #include <epan/packet.h>
51 #include "packet-igmp.h"
52 #include "packet-msnip.h"
55 static int proto_msnip = -1;
56 static int hf_checksum = -1;
57 static int hf_checksum_bad = -1;
58 static int hf_type = -1;
59 static int hf_count = -1;
60 static int hf_holdtime = -1;
61 static int hf_groups = -1;
62 static int hf_maddr = -1;
63 static int hf_mask = -1;
64 static int hf_holdtime16 = -1;
65 static int hf_genid = -1;
66 static int hf_rec_type = -1;
68 static int ett_msnip = -1;
69 static int ett_groups = -1;
74 #define MSNIP_RMR 0x25
75 static const value_string msnip_types[] = {
76 {MSNIP_GM, "Multicast Group Map"},
77 {MSNIP_IS, "Multicast Interest Solicitation"},
78 {MSNIP_RMR, "Multicast Receiver Membership Report"},
82 #define MSNIP_RECTYPE_TRANSMIT 1
83 #define MSNIP_RECTYPE_HOLD 2
84 static const value_string msnip_rec_types[] = {
85 {MSNIP_RECTYPE_TRANSMIT, "Request to start transmitting group"},
86 {MSNIP_RECTYPE_HOLD, "Request to hold transmitting group"},
91 dissect_msnip_rmr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
96 count = tvb_get_guint8(tvb, offset);
97 proto_tree_add_uint(parent_tree, hf_count, tvb, offset, 1, count);
101 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
109 int old_offset = offset;
111 item = proto_tree_add_item(parent_tree, hf_groups,
112 tvb, offset, -1, FALSE);
113 tree = proto_item_add_subtree(item, ett_groups);
116 rec_type = tvb_get_guint8(tvb, offset);
117 proto_tree_add_uint(tree, hf_rec_type, tvb, offset, 1, rec_type);
120 /* skip 3 unused bytes */
123 /* multicast group */
124 tvb_memcpy(tvb, (guint8 *)&maddr, offset, 4);
125 proto_tree_add_ipv4(tree, hf_maddr, tvb, offset, 4,
130 proto_item_set_text(item,"Group: %s %s",
131 ip_to_str((guint8 *)&maddr),
132 val_to_str(rec_type, msnip_rec_types,
133 "Unknown Type:0x%02x"));
135 proto_item_set_len(item, offset-old_offset);
143 dissect_msnip_is(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
146 /* skip reserved byte */
150 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
153 /* 16 bit holdtime */
154 proto_tree_add_uint(parent_tree, hf_holdtime16, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
158 proto_tree_add_uint(parent_tree, hf_genid, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
166 dissect_msnip_gm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
171 count = tvb_get_guint8(tvb, offset);
172 proto_tree_add_uint(parent_tree, hf_count, tvb, offset, 1, count);
176 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
180 proto_tree_add_uint(parent_tree, hf_holdtime, tvb, offset, 4, count);
188 int old_offset = offset;
190 item = proto_tree_add_item(parent_tree, hf_groups,
191 tvb, offset, -1, FALSE);
192 tree = proto_item_add_subtree(item, ett_groups);
194 /* multicast group */
195 tvb_memcpy(tvb, (guint8 *)&maddr, offset, 4);
196 proto_tree_add_ipv4(tree, hf_maddr, tvb, offset, 4,
201 masklen = tvb_get_guint8(tvb, offset);
202 proto_tree_add_uint(tree, hf_mask, tvb,
206 /* skip 3 unused bytes */
210 proto_item_set_text(item,"Group: %s/%d",
211 ip_to_str((guint8 *)&maddr), masklen);
213 proto_item_set_len(item, offset-old_offset);
221 /* This function is only called from the IGMP dissector */
223 dissect_msnip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
229 if (!proto_is_protocol_enabled(proto_msnip)) {
230 /* we are not enabled, skip entire packet to be nice
231 to the igmp layer. (so clicking on IGMP will display the data)
233 return offset+tvb_length_remaining(tvb, offset);
236 item = proto_tree_add_item(parent_tree, proto_msnip, tvb, offset, -1, FALSE);
237 tree = proto_item_add_subtree(item, ett_msnip);
240 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
241 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSNIP");
243 if (check_col(pinfo->cinfo, COL_INFO)) {
244 col_clear(pinfo->cinfo, COL_INFO);
248 type = tvb_get_guint8(tvb, offset);
249 if (check_col(pinfo->cinfo, COL_INFO)) {
250 col_add_fstr(pinfo->cinfo, COL_INFO,
251 "%s",val_to_str(type, msnip_types,
252 "Unknown Type:0x%02x"));
255 /* type of command */
256 proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);
261 offset = dissect_msnip_gm(tvb, pinfo, tree, offset);
264 offset = dissect_msnip_is(tvb, pinfo, tree, offset);
267 offset = dissect_msnip_rmr(tvb, pinfo, tree, offset);
272 proto_item_set_len(item, offset);
280 proto_register_msnip(void)
282 static hf_register_info hf[] = {
284 { "Type", "msnip.type", FT_UINT8, BASE_HEX,
285 VALS(msnip_types), 0, "MSNIP Packet Type", HFILL }},
288 { "Checksum", "msnip.checksum", FT_UINT16, BASE_HEX,
289 NULL, 0, "MSNIP Checksum", HFILL }},
292 { "Bad Checksum", "msnip.checksum_bad", FT_BOOLEAN, BASE_NONE,
293 NULL, 0, "Bad MSNIP Checksum", HFILL }},
296 { "Count", "msnip.count", FT_UINT8, BASE_DEC,
297 NULL, 0, "MSNIP Number of groups", HFILL }},
300 { "Holdtime", "msnip.holdtime", FT_UINT32, BASE_DEC,
301 NULL, 0, "MSNIP Holdtime in seconds", HFILL }},
304 { "Groups", "msnip.groups", FT_NONE, BASE_NONE,
305 NULL, 0, "MSNIP Groups", HFILL }},
308 { "Multicast group", "msnip.maddr", FT_IPv4, BASE_NONE,
309 NULL, 0, "MSNIP Multicast Group", HFILL }},
312 { "Netmask", "msnip.netmask", FT_UINT8, BASE_DEC,
313 NULL, 0, "MSNIP Netmask", HFILL }},
316 { "Holdtime", "msnip.holdtime16", FT_UINT16, BASE_DEC,
317 NULL, 0, "MSNIP Holdtime in seconds", HFILL }},
320 { "Generation ID", "msnip.genid", FT_UINT16, BASE_DEC,
321 NULL, 0, "MSNIP Generation ID", HFILL }},
324 { "Record Type", "msnip.rec_type", FT_UINT8, BASE_DEC,
325 VALS(msnip_rec_types), 0, "MSNIP Record Type", HFILL }},
328 static gint *ett[] = {
333 proto_msnip = proto_register_protocol("MSNIP: Multicast Source Notification of Interest Protocol",
335 proto_register_field_array(proto_msnip, hf, array_length(hf));
336 proto_register_subtree_array(ett, array_length(ett));