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.8 2002/08/28 21:00:22 jmayer 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
46 #include <epan/packet.h>
47 #include "packet-igmp.h"
48 #include "packet-msnip.h"
51 static int proto_msnip = -1;
52 static int hf_checksum = -1;
53 static int hf_checksum_bad = -1;
54 static int hf_type = -1;
55 static int hf_count = -1;
56 static int hf_holdtime = -1;
57 static int hf_groups = -1;
58 static int hf_maddr = -1;
59 static int hf_mask = -1;
60 static int hf_holdtime16 = -1;
61 static int hf_genid = -1;
62 static int hf_rec_type = -1;
64 static int ett_msnip = -1;
65 static int ett_groups = -1;
70 #define MSNIP_RMR 0x25
71 static const value_string msnip_types[] = {
72 {MSNIP_GM, "Multicast Group Map"},
73 {MSNIP_IS, "Multicast Interest Solicitation"},
74 {MSNIP_RMR, "Multicast Receiver Membership Report"},
78 #define MSNIP_RECTYPE_TRANSMIT 1
79 #define MSNIP_RECTYPE_HOLD 2
80 static const value_string msnip_rec_types[] = {
81 {MSNIP_RECTYPE_TRANSMIT, "Request to start transmitting group"},
82 {MSNIP_RECTYPE_HOLD, "Request to hold transmitting group"},
87 dissect_msnip_rmr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
92 count = tvb_get_guint8(tvb, offset);
93 proto_tree_add_uint(parent_tree, hf_count, tvb, offset, 1, count);
97 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
105 int old_offset = offset;
107 item = proto_tree_add_item(parent_tree, hf_groups,
108 tvb, offset, -1, FALSE);
109 tree = proto_item_add_subtree(item, ett_groups);
112 rec_type = tvb_get_guint8(tvb, offset);
113 proto_tree_add_uint(tree, hf_rec_type, tvb, offset, 1, rec_type);
116 /* skip 3 unused bytes */
119 /* multicast group */
120 tvb_memcpy(tvb, (guint8 *)&maddr, offset, 4);
121 proto_tree_add_ipv4(tree, hf_maddr, tvb, offset, 4,
126 proto_item_set_text(item,"Group: %s %s",
127 ip_to_str((guint8 *)&maddr),
128 val_to_str(rec_type, msnip_rec_types,
129 "Unknown Type:0x%02x"));
131 proto_item_set_len(item, offset-old_offset);
139 dissect_msnip_is(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
142 /* skip reserved byte */
146 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
149 /* 16 bit holdtime */
150 proto_tree_add_uint(parent_tree, hf_holdtime16, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
154 proto_tree_add_uint(parent_tree, hf_genid, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
162 dissect_msnip_gm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
167 count = tvb_get_guint8(tvb, offset);
168 proto_tree_add_uint(parent_tree, hf_count, tvb, offset, 1, count);
172 igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
176 proto_tree_add_uint(parent_tree, hf_holdtime, tvb, offset, 4, count);
184 int old_offset = offset;
186 item = proto_tree_add_item(parent_tree, hf_groups,
187 tvb, offset, -1, FALSE);
188 tree = proto_item_add_subtree(item, ett_groups);
190 /* multicast group */
191 tvb_memcpy(tvb, (guint8 *)&maddr, offset, 4);
192 proto_tree_add_ipv4(tree, hf_maddr, tvb, offset, 4,
197 masklen = tvb_get_guint8(tvb, offset);
198 proto_tree_add_uint(tree, hf_mask, tvb,
202 /* skip 3 unused bytes */
206 proto_item_set_text(item,"Group: %s/%d",
207 ip_to_str((guint8 *)&maddr), masklen);
209 proto_item_set_len(item, offset-old_offset);
217 /* This function is only called from the IGMP dissector */
219 dissect_msnip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
225 if (!proto_is_protocol_enabled(proto_msnip)) {
226 /* we are not enabled, skip entire packet to be nice
227 to the igmp layer. (so clicking on IGMP will display the data)
229 return offset+tvb_length_remaining(tvb, offset);
232 item = proto_tree_add_item(parent_tree, proto_msnip, tvb, offset, -1, FALSE);
233 tree = proto_item_add_subtree(item, ett_msnip);
236 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
237 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSNIP");
239 if (check_col(pinfo->cinfo, COL_INFO)) {
240 col_clear(pinfo->cinfo, COL_INFO);
244 type = tvb_get_guint8(tvb, offset);
245 if (check_col(pinfo->cinfo, COL_INFO)) {
246 col_add_fstr(pinfo->cinfo, COL_INFO,
247 "%s",val_to_str(type, msnip_types,
248 "Unknown Type:0x%02x"));
251 /* type of command */
252 proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);
257 offset = dissect_msnip_gm(tvb, pinfo, tree, offset);
260 offset = dissect_msnip_is(tvb, pinfo, tree, offset);
263 offset = dissect_msnip_rmr(tvb, pinfo, tree, offset);
268 proto_item_set_len(item, offset);
276 proto_register_msnip(void)
278 static hf_register_info hf[] = {
280 { "Type", "msnip.type", FT_UINT8, BASE_HEX,
281 VALS(msnip_types), 0, "MSNIP Packet Type", HFILL }},
284 { "Checksum", "msnip.checksum", FT_UINT16, BASE_HEX,
285 NULL, 0, "MSNIP Checksum", HFILL }},
288 { "Bad Checksum", "msnip.checksum_bad", FT_BOOLEAN, BASE_NONE,
289 NULL, 0, "Bad MSNIP Checksum", HFILL }},
292 { "Count", "msnip.count", FT_UINT8, BASE_DEC,
293 NULL, 0, "MSNIP Number of groups", HFILL }},
296 { "Holdtime", "msnip.holdtime", FT_UINT32, BASE_DEC,
297 NULL, 0, "MSNIP Holdtime in seconds", HFILL }},
300 { "Groups", "msnip.groups", FT_NONE, BASE_NONE,
301 NULL, 0, "MSNIP Groups", HFILL }},
304 { "Multicast group", "msnip.maddr", FT_IPv4, BASE_NONE,
305 NULL, 0, "MSNIP Multicast Group", HFILL }},
308 { "Netmask", "msnip.netmask", FT_UINT8, BASE_DEC,
309 NULL, 0, "MSNIP Netmask", HFILL }},
312 { "Holdtime", "msnip.holdtime16", FT_UINT16, BASE_DEC,
313 NULL, 0, "MSNIP Holdtime in seconds", HFILL }},
316 { "Generation ID", "msnip.genid", FT_UINT16, BASE_DEC,
317 NULL, 0, "MSNIP Generation ID", HFILL }},
320 { "Record Type", "msnip.rec_type", FT_UINT8, BASE_DEC,
321 VALS(msnip_rec_types), 0, "MSNIP Record Type", HFILL }},
324 static gint *ett[] = {
329 proto_msnip = proto_register_protocol("MSNIP: Multicast Source Notification of Interest Protocol",
331 proto_register_field_array(proto_msnip, hf, array_length(hf));
332 proto_register_subtree_array(ett, array_length(ett));