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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 MSNIP " Multicast Source Notification of Interest Protocol
35 Defined in draft-ietf-idmr-igmp-msnip-00.txt
42 #include <epan/packet.h>
43 #include <epan/to_str.h>
44 #include "packet-igmp.h"
45 #include "packet-msnip.h"
48 static int proto_msnip
= -1;
49 static int hf_checksum
= -1;
50 static int hf_checksum_bad
= -1;
51 static int hf_type
= -1;
52 static int hf_count
= -1;
53 static int hf_holdtime
= -1;
54 static int hf_groups
= -1;
55 static int hf_maddr
= -1;
56 static int hf_mask
= -1;
57 static int hf_holdtime16
= -1;
58 static int hf_genid
= -1;
59 static int hf_rec_type
= -1;
61 static int ett_msnip
= -1;
62 static int ett_groups
= -1;
67 #define MSNIP_RMR 0x25
68 static const value_string msnip_types
[] = {
69 {MSNIP_GM
, "Multicast Group Map"},
70 {MSNIP_IS
, "Multicast Interest Solicitation"},
71 {MSNIP_RMR
, "Multicast Receiver Membership Report"},
75 #define MSNIP_RECTYPE_TRANSMIT 1
76 #define MSNIP_RECTYPE_HOLD 2
77 static const value_string msnip_rec_types
[] = {
78 {MSNIP_RECTYPE_TRANSMIT
, "Request to start transmitting group"},
79 {MSNIP_RECTYPE_HOLD
, "Request to hold transmitting group"},
84 dissect_msnip_rmr(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, int offset
)
89 count
= tvb_get_guint8(tvb
, offset
);
90 proto_tree_add_uint(parent_tree
, hf_count
, tvb
, offset
, 1, count
);
94 igmp_checksum(parent_tree
, tvb
, hf_checksum
, hf_checksum_bad
, pinfo
, 0);
102 int old_offset
= offset
;
104 item
= proto_tree_add_item(parent_tree
, hf_groups
,
105 tvb
, offset
, -1, ENC_NA
);
106 tree
= proto_item_add_subtree(item
, ett_groups
);
109 rec_type
= tvb_get_guint8(tvb
, offset
);
110 proto_tree_add_uint(tree
, hf_rec_type
, tvb
, offset
, 1, rec_type
);
113 /* skip 3 unused bytes */
116 /* multicast group */
117 maddr
= tvb_get_ipv4(tvb
, offset
);
118 proto_tree_add_ipv4(tree
, hf_maddr
, tvb
, offset
, 4,
123 proto_item_set_text(item
,"Group: %s %s",
124 ip_to_str((guint8
*)&maddr
),
125 val_to_str(rec_type
, msnip_rec_types
,
126 "Unknown Type:0x%02x"));
128 proto_item_set_len(item
, offset
-old_offset
);
136 dissect_msnip_is(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, int offset
)
139 /* skip reserved byte */
143 igmp_checksum(parent_tree
, tvb
, hf_checksum
, hf_checksum_bad
, pinfo
, 0);
146 /* 16 bit holdtime */
147 proto_tree_add_uint(parent_tree
, hf_holdtime16
, tvb
, offset
, 2, tvb_get_ntohs(tvb
, offset
));
151 proto_tree_add_uint(parent_tree
, hf_genid
, tvb
, offset
, 2, tvb_get_ntohs(tvb
, offset
));
159 dissect_msnip_gm(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, int offset
)
164 count
= tvb_get_guint8(tvb
, offset
);
165 proto_tree_add_uint(parent_tree
, hf_count
, tvb
, offset
, 1, count
);
169 igmp_checksum(parent_tree
, tvb
, hf_checksum
, hf_checksum_bad
, pinfo
, 0);
173 proto_tree_add_uint(parent_tree
, hf_holdtime
, tvb
, offset
, 4, count
);
181 int old_offset
= offset
;
183 item
= proto_tree_add_item(parent_tree
, hf_groups
,
184 tvb
, offset
, -1, ENC_NA
);
185 tree
= proto_item_add_subtree(item
, ett_groups
);
187 /* multicast group */
188 maddr
= tvb_get_ipv4(tvb
, offset
);
189 proto_tree_add_ipv4(tree
, hf_maddr
, tvb
, offset
, 4,
194 masklen
= tvb_get_guint8(tvb
, offset
);
195 proto_tree_add_uint(tree
, hf_mask
, tvb
,
199 /* skip 3 unused bytes */
203 proto_item_set_text(item
,"Group: %s/%d",
204 ip_to_str((guint8
*)&maddr
), masklen
);
206 proto_item_set_len(item
, offset
-old_offset
);
214 /* This function is only called from the IGMP dissector */
216 dissect_msnip(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, int offset
)
222 if (!proto_is_protocol_enabled(find_protocol_by_id(proto_msnip
))) {
223 /* we are not enabled, skip entire packet to be nice
224 to the igmp layer. (so clicking on IGMP will display the data)
226 return offset
+tvb_length_remaining(tvb
, offset
);
229 item
= proto_tree_add_item(parent_tree
, proto_msnip
, tvb
, offset
, -1, ENC_NA
);
230 tree
= proto_item_add_subtree(item
, ett_msnip
);
233 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MSNIP");
234 col_clear(pinfo
->cinfo
, COL_INFO
);
237 type
= tvb_get_guint8(tvb
, offset
);
238 col_add_str(pinfo
->cinfo
, COL_INFO
,
239 val_to_str(type
, msnip_types
,
240 "Unknown Type:0x%02x"));
242 /* type of command */
243 proto_tree_add_uint(tree
, hf_type
, tvb
, offset
, 1, type
);
248 offset
= dissect_msnip_gm(tvb
, pinfo
, tree
, offset
);
251 offset
= dissect_msnip_is(tvb
, pinfo
, tree
, offset
);
254 offset
= dissect_msnip_rmr(tvb
, pinfo
, tree
, offset
);
259 proto_item_set_len(item
, offset
);
267 proto_register_msnip(void)
269 static hf_register_info hf
[] = {
271 { "Type", "msnip.type", FT_UINT8
, BASE_HEX
,
272 VALS(msnip_types
), 0, "MSNIP Packet Type", HFILL
}},
275 { "Checksum", "msnip.checksum", FT_UINT16
, BASE_HEX
,
276 NULL
, 0, "MSNIP Checksum", HFILL
}},
279 { "Bad Checksum", "msnip.checksum_bad", FT_BOOLEAN
, BASE_NONE
,
280 NULL
, 0x0, "Bad MSNIP Checksum", HFILL
}},
283 { "Count", "msnip.count", FT_UINT8
, BASE_DEC
,
284 NULL
, 0, "MSNIP Number of groups", HFILL
}},
287 { "Holdtime", "msnip.holdtime", FT_UINT32
, BASE_DEC
,
288 NULL
, 0, "MSNIP Holdtime in seconds", HFILL
}},
291 { "Groups", "msnip.groups", FT_NONE
, BASE_NONE
,
292 NULL
, 0, "MSNIP Groups", HFILL
}},
295 { "Multicast group", "msnip.maddr", FT_IPv4
, BASE_NONE
,
296 NULL
, 0, "MSNIP Multicast Group", HFILL
}},
299 { "Netmask", "msnip.netmask", FT_UINT8
, BASE_DEC
,
300 NULL
, 0, "MSNIP Netmask", HFILL
}},
303 { "Holdtime", "msnip.holdtime16", FT_UINT16
, BASE_DEC
,
304 NULL
, 0, "MSNIP Holdtime in seconds", HFILL
}},
307 { "Generation ID", "msnip.genid", FT_UINT16
, BASE_DEC
,
308 NULL
, 0, "MSNIP Generation ID", HFILL
}},
311 { "Record Type", "msnip.rec_type", FT_UINT8
, BASE_DEC
,
312 VALS(msnip_rec_types
), 0, "MSNIP Record Type", HFILL
}},
315 static gint
*ett
[] = {
320 proto_msnip
= proto_register_protocol("MSNIP: Multicast Source Notification of Interest Protocol",
322 proto_register_field_array(proto_msnip
, hf
, array_length(hf
));
323 proto_register_subtree_array(ett
, array_length(ett
));