1 /* packet-igmp.c 2001 Ronnie Sahlberg <See AUTHORS for email>
2 * Routines for IGMP packet disassembly
4 * $Id: packet-igmp.c,v 1.22 2003/03/04 06:47:09 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.
25 IGMP is defined in the following RFCs
26 RFC988 Version 0 Obsolete
28 RFC1112 Version 1 (same as RFC1054 as far as we are concerned)
30 draft-ietf-idmr-igmp-v3-07 Version 3
32 Size in bytes for each packet
33 type RFC988 RFC1054 RFC2236 RFC???? DVMRP MRDISC MSNIP
55 * Differs in second byte of protocol. Always 0 in V1
58 Multicast traceroute was taken from
59 draft-ietf-idmr-traceroute-ipm-07.txt
61 Size in bytes for each packet
62 type draft-ietf-idmr-traceroute-ipm-07.ps
64 0x1f 24 + n*32 (n == 0 for Query)
66 x DVMRP Protocol see packet-dvmrp.c
68 DVMRP is defined in the following RFCs
70 draft-ietf-idmr-dvmrp-v3-10.txt Version 3
72 V1 and V3 can be distinguished by looking at bytes 6 and 7 in the
74 If header[6]==0xff and header[7]==0x03 we have version 3.
76 a MRDISC Protocol see packet-mrdisc.c
78 MRDISC : IGMP Multicast Router DISCovery
79 draft-ietf-idmr-igmp-mrdisc-06.txt
80 TTL == 1 and IP.DST==224.0.0.2 for all packets
82 b MSNIP Protocol see packet-msnip.c
84 MSNIP : Multicast Source Notification of Interest Protocol
85 draft-ietf-idmr-msnip-00.txt
86 0x23, 0x24 are sent with ip.dst==224.0.0.22
87 0x25 is sent as unicast.
99 #ifdef NEED_SNPRINTF_H
100 # include "snprintf.h"
103 #include <epan/packet.h>
105 #include "in_cksum.h"
106 #include "packet-dvmrp.h"
107 #include "packet-pim.h"
108 #include "packet-mrdisc.h"
109 #include "packet-msnip.h"
111 static int proto_igmp = -1;
112 static int hf_type = -1;
113 static int hf_version = -1;
114 static int hf_group_type = -1;
115 static int hf_reply_code = -1;
116 static int hf_reply_pending = -1;
117 static int hf_checksum = -1;
118 static int hf_checksum_bad = -1;
119 static int hf_identifier = -1;
120 static int hf_access_key = -1;
121 static int hf_max_resp = -1;
122 static int hf_max_resp_exp = -1;
123 static int hf_max_resp_mant = -1;
124 static int hf_supress = -1;
125 static int hf_qrv = -1;
126 static int hf_qqic = -1;
127 static int hf_num_src = -1;
128 static int hf_saddr = -1;
129 static int hf_num_grp_recs = -1;
130 static int hf_record_type = -1;
131 static int hf_aux_data_len = -1;
132 static int hf_maddr = -1;
133 static int hf_aux_data = -1;
134 static int hf_mtrace_max_hops = -1;
135 static int hf_mtrace_saddr = -1;
136 static int hf_mtrace_raddr = -1;
137 static int hf_mtrace_rspaddr = -1;
138 static int hf_mtrace_resp_ttl = -1;
139 static int hf_mtrace_q_id = -1;
140 static int hf_mtrace_q_arrival = -1;
141 static int hf_mtrace_q_inaddr = -1;
142 static int hf_mtrace_q_outaddr = -1;
143 static int hf_mtrace_q_prevrtr = -1;
144 static int hf_mtrace_q_inpkt = -1;
145 static int hf_mtrace_q_outpkt = -1;
146 static int hf_mtrace_q_total = -1;
147 static int hf_mtrace_q_rtg_proto = -1;
148 static int hf_mtrace_q_fwd_ttl = -1;
149 static int hf_mtrace_q_mbz = -1;
150 static int hf_mtrace_q_s = -1;
151 static int hf_mtrace_q_src_mask = -1;
152 static int hf_mtrace_q_fwd_code = -1;
154 static int ett_igmp = -1;
155 static int ett_group_record = -1;
156 static int ett_sqrv_bits = -1;
157 static int ett_max_resp = -1;
158 static int ett_mtrace_block = -1;
160 #define MC_ALL_ROUTERS 0xe0000002
161 #define MC_ALL_IGMPV3_ROUTERS 0xe0000016
164 #define IGMP_V0_CREATE_GROUP_REQUEST 0x01
165 #define IGMP_V0_CREATE_GROUP_REPLY 0x02
166 #define IGMP_V0_JOIN_GROUP_REQUEST 0x03
167 #define IGMP_V0_JOIN_GROUP_REPLY 0x04
168 #define IGMP_V0_LEAVE_GROUP_REQUEST 0x05
169 #define IGMP_V0_LEAVE_GROUP_REPLY 0x06
170 #define IGMP_V0_CONFIRM_GROUP_REQUEST 0x07
171 #define IGMP_V0_CONFIRM_GROUP_REPLY 0x08
172 #define IGMP_V1_HOST_MEMBERSHIP_QUERY 0x11
173 #define IGMP_V1_HOST_MEMBERSHIP_REPORT 0x12
174 #define IGMP_DVMRP 0x13
175 #define IGMP_V1_PIM_ROUTING_MESSAGE 0x14
176 #define IGMP_V2_MEMBERSHIP_REPORT 0x16
177 #define IGMP_V2_LEAVE_GROUP 0x17
178 #define IGMP_TRACEROUTE_RESPONSE 0x1e
179 #define IGMP_TRACEROUTE_QUERY_REQ 0x1f
180 #define IGMP_V3_MEMBERSHIP_REPORT 0x22
181 #define IGMP_TYPE_0x23 0x23
182 #define IGMP_TYPE_0x24 0x24
183 #define IGMP_TYPE_0x25 0x25
184 #define IGMP_TYPE_0x26 0x26
186 #define IGMP_TRACEROUTE_HDR_LEN 24
187 #define IGMP_TRACEROUTE_RSP_LEN 32
189 static const value_string commands[] = {
190 {IGMP_V0_CREATE_GROUP_REQUEST, "Create Group Request" },
191 {IGMP_V0_CREATE_GROUP_REPLY, "Create Group Reply" },
192 {IGMP_V0_JOIN_GROUP_REQUEST, "Join Group Request" },
193 {IGMP_V0_JOIN_GROUP_REPLY, "Join Group Reply" },
194 {IGMP_V0_LEAVE_GROUP_REQUEST, "Leave Group Request" },
195 {IGMP_V0_LEAVE_GROUP_REPLY, "Leave Group Reply" },
196 {IGMP_V0_CONFIRM_GROUP_REQUEST, "Confirm Group Request" },
197 {IGMP_V0_CONFIRM_GROUP_REPLY, "Confirm Group Reply" },
198 {IGMP_V1_HOST_MEMBERSHIP_QUERY, "Membership Query" },
199 {IGMP_V1_HOST_MEMBERSHIP_REPORT,"Membership Report" },
200 {IGMP_DVMRP, "DVMRP Protocol" },
201 {IGMP_V1_PIM_ROUTING_MESSAGE, "PIM Routing Message" },
202 {IGMP_V2_MEMBERSHIP_REPORT, "Membership Report" },
203 {IGMP_V2_LEAVE_GROUP, "Leave Group" },
204 {IGMP_TRACEROUTE_RESPONSE, "Traceroute Response" },
205 {IGMP_TRACEROUTE_QUERY_REQ, "Traceroute Query or Request" },
206 {IGMP_V3_MEMBERSHIP_REPORT, "Membership Report" },
210 #define IGMP_V3_S 0x08
211 #define IGMP_V3_QRV_MASK 0x07
213 #define IGMP_MAX_RESP_EXP 0x70
214 #define IGMP_MAX_RESP_MANT 0x0f
216 #define IGMP_V0_GROUP_PUBLIC 0x00
217 #define IGMP_V0_GROUP_PRIVATE 0x01
219 static const value_string vs_group_type[] = {
220 {IGMP_V0_GROUP_PUBLIC, "Public Group" },
221 {IGMP_V0_GROUP_PRIVATE, "Private Group" },
225 #define IGMP_V0_REPLY_GRANTED 0x00
226 #define IGMP_V0_REPLY_NO_RESOURCES 0x01
227 #define IGMP_V0_REPLY_INVALID_CODE 0x02
228 #define IGMP_V0_REPLY_INVALID_GROUP 0x03
229 #define IGMP_V0_REPLY_INVALID_KEY 0x04
231 static const value_string vs_reply_code[] = {
232 {IGMP_V0_REPLY_GRANTED, "Request Granted" },
233 {IGMP_V0_REPLY_NO_RESOURCES, "Request Denied, No Resources" },
234 {IGMP_V0_REPLY_INVALID_CODE, "Request Denied, Invalid Code" },
235 {IGMP_V0_REPLY_INVALID_GROUP, "Request Denied, Invalid Group" },
236 {IGMP_V0_REPLY_INVALID_KEY, "Request Denied, Invalid Key" },
240 static const true_false_string tfs_s = {
241 "SUPRESS router side processing",
242 "Do not supress router side processing"
245 #define IGMP_V3_MODE_IS_INCLUDE 1
246 #define IGMP_V3_MODE_IS_EXCLUDE 2
247 #define IGMP_V3_CHANGE_TO_INCLUDE_MODE 3
248 #define IGMP_V3_CHANGE_TO_EXCLUDE_MODE 4
249 #define IGMP_V3_ALLOW_NEW_SOURCES 5
250 #define IGMP_V3_BLOCK_OLD_SOURCES 6
252 static const value_string vs_record_type[] = {
253 {IGMP_V3_MODE_IS_INCLUDE, "Mode Is Include" },
254 {IGMP_V3_MODE_IS_EXCLUDE, "Mode Is Exclude" },
255 {IGMP_V3_CHANGE_TO_INCLUDE_MODE,"Change To Include Mode" },
256 {IGMP_V3_CHANGE_TO_EXCLUDE_MODE,"Change To Exclude Mode" },
257 {IGMP_V3_ALLOW_NEW_SOURCES, "Allow New Sources" },
258 {IGMP_V3_BLOCK_OLD_SOURCES, "Block Old Sources" },
262 static const value_string mtrace_rtg_vals[] = {
267 {5, "PIM using special routing table" },
268 {6, "PIM using a static route" },
269 {7, "DVMRP using a static route" },
270 {8, "PIM using MBGP (aka BGP4+) route" },
271 {9, "CBT using special routing table" },
272 {10, "CBT using a static route" },
273 {11, "PIM using state created by Assert processing" },
277 static const value_string mtrace_fwd_code_vals[] = {
280 {0x02, "PRUNE_SENT" },
281 {0x03, "PRUNE_RCVD" },
284 {0x06, "WRONG_LAST_HOP" },
285 {0x07, "NOT_FORWARDING" },
286 {0x08, "REACHED_RP" },
288 {0x0A, "NO_MULTICAST" },
289 {0x0B, "INFO_HIDDEN" },
291 {0x82, "OLD_ROUTER" },
292 {0x83, "ADMIN_PROHIB" },
296 #define PRINT_IGMP_VERSION(version) \
297 if (check_col(pinfo->cinfo, COL_INFO)) { \
298 col_add_fstr(pinfo->cinfo, COL_INFO, \
299 "V%d %s",version,val_to_str(type, commands, \
300 "Unknown Type:0x%02x")); \
302 /* version of IGMP protocol */ \
303 proto_tree_add_uint(tree, hf_version, tvb, 0, 0, version); \
304 /* type of command */ \
305 proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type); \
308 void igmp_checksum(proto_tree *tree, tvbuff_t *tvb, int hf_index,
309 int hf_index_bad, packet_info *pinfo, guint len)
311 guint16 cksum, hdrcksum;
316 * Checksum the entire IGMP packet.
318 len = tvb_reported_length(tvb);
321 hdrcksum = tvb_get_ntohs(tvb, 2);
322 if (!pinfo->fragmented && tvb_length(tvb) >= len) {
324 * The packet isn't part of a fragmented datagram and isn't
325 * truncated, so we can checksum it.
327 cksum_vec[0].ptr = tvb_get_ptr(tvb, 0, len);
328 cksum_vec[0].len = len;
330 cksum = in_cksum(&cksum_vec[0],1);
333 proto_tree_add_uint_format(tree, hf_index,
335 "Header checksum: 0x%04x (correct)", hdrcksum);
337 proto_tree_add_boolean_hidden(tree, hf_index_bad,
339 proto_tree_add_uint_format(tree, hf_index,
341 "Header checksum: 0x%04x (incorrect, should be 0x%04x)", hdrcksum,in_cksum_shouldbe(hdrcksum,cksum));
344 proto_tree_add_uint(tree, hf_index, tvb, 2, 2, hdrcksum);
350 /* Unknown IGMP message type */
352 dissect_igmp_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset)
356 if (check_col(pinfo->cinfo, COL_INFO)) {
357 col_add_str(pinfo->cinfo, COL_INFO,
358 val_to_str(type, commands, "Unknown Type:0x%02x"));
361 /* type of command */
362 proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);
365 /* Just call the rest of it "data" */
366 len = tvb_length_remaining(tvb, offset);
367 proto_tree_add_text(tree, tvb, offset, len, "Data");
375 /*************************************************************
376 * IGMP Protocol dissectors
377 *************************************************************/
379 dissect_v3_max_resp(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
386 bits = tvb_get_guint8(tvb, offset);
388 tsecs = ((bits&IGMP_MAX_RESP_MANT)|0x10);
389 tsecs = tsecs << ( ((bits&IGMP_MAX_RESP_EXP)>>4) + 3);
394 item = proto_tree_add_uint_format(parent_tree, hf_max_resp, tvb,
395 offset, 1, tsecs, "Max Response Time: %.1f sec (0x%02x)",tsecs*0.1,bits);
398 tree = proto_item_add_subtree(item, ett_max_resp);
400 proto_tree_add_uint(tree, hf_max_resp_exp, tvb, offset, 1,
402 proto_tree_add_uint(tree, hf_max_resp_mant, tvb, offset, 1,
412 dissect_v3_sqrv_bits(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
418 bits = tvb_get_guint8(tvb, offset);
420 item = proto_tree_add_text(parent_tree, tvb, offset, 1,
421 "QRV=%d S=%s", bits&IGMP_V3_QRV_MASK,
422 (bits&IGMP_V3_S)?tfs_s.true_string:tfs_s.false_string);
423 tree = proto_item_add_subtree(item, ett_sqrv_bits);
426 proto_tree_add_boolean(tree, hf_supress, tvb, offset, 1, bits);
428 proto_tree_add_uint(tree, hf_qrv, tvb, offset, 1, bits);
435 dissect_v3_group_record(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
439 int old_offset = offset;
444 tvb_memcpy(tvb, (guint8 *)&ip, offset+4, 4);
445 item = proto_tree_add_text(parent_tree, tvb, offset, -1,
446 "Group Record : %s %s",
447 ip_to_str((gchar*)&ip),
448 val_to_str(tvb_get_guint8(tvb, offset), vs_record_type,"")
450 tree = proto_item_add_subtree(item, ett_group_record);
453 proto_tree_add_item(tree, hf_record_type, tvb, offset, 1, FALSE);
457 adl = tvb_get_guint8(tvb, offset);
458 proto_tree_add_uint(tree, hf_aux_data_len, tvb, offset, 1, adl);
461 /*number of sources*/
462 num = tvb_get_ntohs(tvb, offset);
463 proto_tree_add_uint(tree, hf_num_src, tvb, offset, 2, num);
466 /* multicast address */
467 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, FALSE);
470 /* source addresses */
472 proto_tree_add_item(tree, hf_saddr, tvb, offset, 4, FALSE);
478 proto_tree_add_item(tree, hf_aux_data, tvb, offset, adl*4,
483 proto_item_set_len(item, offset-old_offset);
487 /* dissectors for version 3, rfc???? */
489 dissect_igmp_v3_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset)
493 PRINT_IGMP_VERSION(3);
495 /* skip reserved field*/
499 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
502 /* skip reserved field */
505 /* number of group records */
506 num = tvb_get_ntohs(tvb, offset);
507 proto_tree_add_uint(tree, hf_num_grp_recs, tvb, offset, 2, num);
511 offset = dissect_v3_group_record(tvb, tree, offset);
518 dissect_igmp_v3_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset)
522 PRINT_IGMP_VERSION(3);
524 num = tvb_get_ntohs(tvb, offset+9);
526 offset = dissect_v3_max_resp(tvb, tree, offset);
529 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
533 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, FALSE);
536 /* bitmask for S and QRV */
537 offset = dissect_v3_sqrv_bits(tvb, tree, offset);
540 proto_tree_add_item(tree, hf_qqic, tvb, offset, 1, FALSE);
543 /*number of sources*/
544 proto_tree_add_uint(tree, hf_num_src, tvb, offset, 2, num);
548 proto_tree_add_item(tree, hf_saddr, tvb, offset, 4, FALSE);
555 /* dissector for version 2, rfc2236 */
557 dissect_igmp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset)
561 PRINT_IGMP_VERSION(2);
564 tsecs = tvb_get_guint8(tvb, offset);
565 proto_tree_add_uint_format(tree, hf_max_resp, tvb,
566 offset, 1, tsecs, "Max Response Time: %.1f sec (0x%02x)", tsecs*0.1,tsecs);
570 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 8);
574 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, FALSE);
580 /* dissector for version 1, rfc1054 */
582 dissect_igmp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset)
584 PRINT_IGMP_VERSION(1);
586 /* skip unused byte */
590 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 8);
594 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, FALSE);
600 /* dissector for version 0, rfc988 */
602 dissect_igmp_v0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset)
606 PRINT_IGMP_VERSION(0);
609 code = tvb_get_guint8(tvb, offset);
610 if (type==IGMP_V0_CREATE_GROUP_REQUEST) {
611 proto_tree_add_uint(tree, hf_group_type, tvb, offset, 1, code);
612 } else if (!(type&0x01)) {
614 proto_tree_add_uint(tree, hf_reply_code, tvb, offset, 1, code);
616 proto_tree_add_uint(tree, hf_reply_pending, tvb, offset, 1, code);
622 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 20);
626 proto_tree_add_item(tree, hf_identifier, tvb, offset, 4, FALSE);
630 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, FALSE);
634 proto_tree_add_item(tree, hf_access_key, tvb, offset, 8, FALSE);
640 /* dissector for multicast traceroute, rfc???? */
642 dissect_igmp_mtrace(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int type, int offset)
644 char *typestr, *blocks = NULL;
647 /* All multicast traceroute packets (Query, Request and
648 * Response) have the same fixed header. Request and Response
649 * have one or more response data blocks following this fixed
650 * header. Since Query and Request share the same IGMP type,
651 * the method to differentiate between them is to check the
652 * IGMP packet length. Queries are only
653 * IGMP_TRACEROUTE_HDR_LEN bytes long.
655 if (type == IGMP_TRACEROUTE_RESPONSE) {
656 int i = (tvb_reported_length_remaining(tvb, offset) - IGMP_TRACEROUTE_HDR_LEN) / IGMP_TRACEROUTE_RSP_LEN;
657 snprintf(buf, sizeof buf, ", %d block%s", i, plurality(i, "", "s"));
658 typestr = "Traceroute Response";
660 } else if (tvb_reported_length_remaining(tvb, offset) == IGMP_TRACEROUTE_HDR_LEN)
661 typestr = "Traceroute Query";
663 typestr = "Traceroute Request";
665 if (check_col(pinfo->cinfo, COL_INFO)) {
666 col_set_str(pinfo->cinfo, COL_INFO, typestr);
667 if (blocks) col_append_str(pinfo->cinfo, COL_INFO, blocks);
670 proto_tree_add_uint_format(tree, hf_type, tvb, offset, 1, type,
671 "Type: %s (0x%02x)", typestr, type);
674 /* maximum number of hops that the requester wants to trace */
675 proto_tree_add_item(tree, hf_mtrace_max_hops, tvb, offset, 1, FALSE);
679 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
682 /* group address to be traced */
683 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, FALSE);
686 /* address of multicast source for the path being traced */
687 proto_tree_add_item(tree, hf_mtrace_saddr, tvb, offset, 4, FALSE);
690 /* address of multicast receiver for the path being traced */
691 proto_tree_add_item(tree, hf_mtrace_raddr, tvb, offset, 4, FALSE);
694 /* address where the completed traceroute response packet gets sent */
695 proto_tree_add_item(tree, hf_mtrace_rspaddr, tvb, offset, 4, FALSE);
698 /* for multicasted responses, TTL at which to multicast the response */
699 proto_tree_add_item(tree, hf_mtrace_resp_ttl, tvb, offset, 1, FALSE);
702 /* unique identifier for this traceroute request (for e.g. duplicate/delay detection) */
703 proto_tree_add_item(tree, hf_mtrace_q_id, tvb, offset, 3, FALSE);
706 /* If this was Query, we only had the fixed header */
707 if (tvb_reported_length_remaining(tvb, offset) == 0)
710 /* Loop through the response data blocks */
711 while (tvb_reported_length_remaining(tvb, offset) >= IGMP_TRACEROUTE_RSP_LEN) {
713 proto_tree *block_tree;
715 bi = proto_tree_add_text(tree, tvb, offset, IGMP_TRACEROUTE_RSP_LEN,
716 "Response data block: %s -> %s, Proto: %s, Forwarding Code: %s",
717 ip_to_str(tvb_get_ptr(tvb, offset + 4, 4)),
718 ip_to_str(tvb_get_ptr(tvb, offset + 8, 4)),
719 val_to_str(tvb_get_guint8(tvb, offset + 28), mtrace_rtg_vals, "Unknown"),
720 val_to_str(tvb_get_guint8(tvb, offset + 31), mtrace_fwd_code_vals, "Unknown"));
721 block_tree = proto_item_add_subtree(bi, ett_mtrace_block);
723 /* Query Arrival Time */
724 proto_tree_add_item(block_tree, hf_mtrace_q_arrival, tvb, offset, 4, FALSE);
727 /* Incoming Interface Address */
728 proto_tree_add_item(block_tree, hf_mtrace_q_inaddr, tvb, offset, 4, FALSE);
731 /* Outgoing Interface Address */
732 proto_tree_add_item(block_tree, hf_mtrace_q_outaddr, tvb, offset, 4, FALSE);
735 /* Previous-Hop Router Address */
736 proto_tree_add_item(block_tree, hf_mtrace_q_prevrtr, tvb, offset, 4, FALSE);
739 /* Input packet count on incoming interface */
740 proto_tree_add_item(block_tree, hf_mtrace_q_inpkt, tvb, offset, 4, FALSE);
743 /* Output packet count on outgoing interface */
744 proto_tree_add_item(block_tree, hf_mtrace_q_outpkt, tvb, offset, 4, FALSE);
747 /* Total number of packets for this source-group pair */
748 proto_tree_add_item(block_tree, hf_mtrace_q_total, tvb, offset, 4, FALSE);
751 /* Routing protocol in use between this and previous-hop router */
752 proto_tree_add_item(block_tree, hf_mtrace_q_rtg_proto, tvb, offset, 1, FALSE);
755 /* TTL that a packet is required to be forwarded */
756 proto_tree_add_item(block_tree, hf_mtrace_q_fwd_ttl, tvb, offset, 1, FALSE);
759 /* Must be zeroed and ignored bit, S bit and src network mask length */
760 proto_tree_add_item(block_tree, hf_mtrace_q_mbz, tvb, offset, 1, FALSE);
761 proto_tree_add_item(block_tree, hf_mtrace_q_s, tvb, offset, 1, FALSE);
762 proto_tree_add_item(block_tree, hf_mtrace_q_src_mask, tvb, offset, 1, FALSE);
765 /* Forwarding information/error code */
766 proto_tree_add_item(block_tree, hf_mtrace_q_fwd_code, tvb, offset, 1, FALSE);
775 dissect_igmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
783 item = proto_tree_add_item(parent_tree, proto_igmp, tvb, offset, -1, FALSE);
784 tree = proto_item_add_subtree(item, ett_igmp);
787 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
788 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IGMP");
790 if (check_col(pinfo->cinfo, COL_INFO)) {
791 col_clear(pinfo->cinfo, COL_INFO);
795 type = tvb_get_guint8(tvb, offset);
800 offset = dissect_igmp_v0(tvb, pinfo, tree, type, offset);
806 case IGMP_V1_HOST_MEMBERSHIP_QUERY: /* 0x11 v1/v2/v3 */
807 if ( (pinfo->iplen-pinfo->iphdrlen)>=12 ) {
809 offset = dissect_igmp_v3_query(tvb, pinfo, tree, type, offset);
811 /* v1 and v2 differs in second byte of header */
812 if (tvb_get_guint8(tvb, offset)) {
813 offset = dissect_igmp_v2(tvb, pinfo, tree, type, offset);
815 offset = dissect_igmp_v1(tvb, pinfo, tree, type, offset);
820 case IGMP_V1_HOST_MEMBERSHIP_REPORT: /* 0x12 v1/v2 */
821 /* v1 and v2 differs in second byte of header */
822 if (tvb_get_guint8(tvb, offset)) {
823 offset = dissect_igmp_v2(tvb, pinfo, tree, type, offset);
825 offset = dissect_igmp_v1(tvb, pinfo, tree, type, offset);
830 offset = dissect_dvmrp(tvb, pinfo, parent_tree, offset);
833 case IGMP_V1_PIM_ROUTING_MESSAGE:
834 offset = dissect_pimv1(tvb, pinfo, parent_tree, offset);
837 case IGMP_V2_MEMBERSHIP_REPORT:
838 case IGMP_V2_LEAVE_GROUP:
839 offset = dissect_igmp_v2(tvb, pinfo, tree, type, offset);
842 case IGMP_TRACEROUTE_RESPONSE:
843 case IGMP_TRACEROUTE_QUERY_REQ:
844 offset = dissect_igmp_mtrace(tvb, pinfo, tree, type, offset);
847 case IGMP_V3_MEMBERSHIP_REPORT:
848 offset = dissect_igmp_v3_response(tvb, pinfo, tree, type, offset);
852 dst = g_htonl(MC_ALL_IGMPV3_ROUTERS);
853 if (!memcmp(pinfo->dst.data, &dst, 4)) {
854 offset = dissect_msnip(tvb, pinfo, parent_tree, offset);
859 dst = g_htonl(MC_ALL_ROUTERS);
860 if (!memcmp(pinfo->dst.data, &dst, 4)) {
861 offset = dissect_mrdisc(tvb, pinfo, parent_tree, offset);
863 dst = g_htonl(MC_ALL_IGMPV3_ROUTERS);
864 if (!memcmp(pinfo->dst.data, &dst, 4)) {
865 offset = dissect_msnip(tvb, pinfo, parent_tree, offset);
870 if ( (pinfo->iplen-pinfo->iphdrlen)>=8 ) {
871 /* if len of igmp packet>=8 we assume it is MSNIP */
872 offset = dissect_msnip(tvb, pinfo, parent_tree, offset);
874 /* ok its not MSNIP, check if it might be MRDISC */
875 dst = g_htonl(MC_ALL_ROUTERS);
876 if (!memcmp(pinfo->dst.data, &dst, 4)) {
877 offset = dissect_mrdisc(tvb, pinfo, parent_tree, offset);
883 dst = g_htonl(MC_ALL_ROUTERS);
884 if (!memcmp(pinfo->dst.data, &dst, 4)) {
885 offset = dissect_mrdisc(tvb, pinfo, parent_tree, offset);
890 offset = dissect_igmp_unknown(tvb, pinfo, tree, type, offset);
895 proto_item_set_len(item, offset);
899 proto_register_igmp(void)
901 static hf_register_info hf[] = {
903 { "Type", "igmp.type", FT_UINT8, BASE_HEX,
904 VALS(commands), 0, "IGMP Packet Type", HFILL }},
907 { "IGMP Version", "igmp.version", FT_UINT8, BASE_DEC,
908 NULL, 0, "IGMP Version", HFILL }},
911 { "Type Of Group", "igmp.group_type", FT_UINT8, BASE_DEC,
912 VALS(vs_group_type), 0, "IGMP V0 Type Of Group", HFILL }},
915 { "Reply", "igmp.reply", FT_UINT8, BASE_DEC,
916 VALS(vs_reply_code), 0, "IGMP V0 Reply", HFILL }},
919 { "Reply Pending", "igmp.reply.pending", FT_UINT8, BASE_DEC,
920 NULL, 0, "IGMP V0 Reply Pending, Retry in this many seconds", HFILL }},
923 { "Checksum", "igmp.checksum", FT_UINT16, BASE_HEX,
924 NULL, 0, "IGMP Checksum", HFILL }},
927 { "Bad Checksum", "igmp.checksum_bad", FT_BOOLEAN, BASE_NONE,
928 NULL, 0, "Bad IGMP Checksum", HFILL }},
931 { "Identifier", "igmp.identifier", FT_UINT32, BASE_DEC,
932 NULL, 0, "IGMP V0 Identifier", HFILL }},
935 { "Access Key", "igmp.access_key", FT_BYTES, BASE_HEX,
936 NULL, 0, "IGMP V0 Access Key", HFILL }},
939 { "Max Resp Time", "igmp.max_resp", FT_UINT8, BASE_DEC,
940 NULL, 0, "Max Response Time", HFILL }},
943 { "S", "igmp.s", FT_BOOLEAN, 8,
944 TFS(&tfs_s), IGMP_V3_S, "Supress Router Side Processing", HFILL }},
947 { "QRV", "igmp.qrv", FT_UINT8, BASE_DEC,
948 NULL, IGMP_V3_QRV_MASK, "Querier's Robustness Value", HFILL }},
951 { "QQIC", "igmp.qqic", FT_UINT8, BASE_DEC,
952 NULL, 0, "Querier's Query Interval Code", HFILL }},
955 { "Num Src", "igmp.num_src", FT_UINT16, BASE_DEC,
956 NULL, 0, "Number Of Sources", HFILL }},
959 { "Source Address", "igmp.saddr", FT_IPv4, BASE_NONE,
960 NULL, 0, "Source Address", HFILL }},
963 { "Num Group Records", "igmp.num_grp_recs", FT_UINT16, BASE_DEC,
964 NULL, 0, "Number Of Group Records", HFILL }},
967 { "Record Type", "igmp.record_type", FT_UINT8, BASE_DEC,
968 VALS(vs_record_type), 0, "Record Type", HFILL }},
971 { "Aux Data Len", "igmp.aux_data_len", FT_UINT8, BASE_DEC,
972 NULL, 0, "Aux Data Len, In units of 32bit words", HFILL }},
975 { "Multicast Address", "igmp.maddr", FT_IPv4, BASE_NONE,
976 NULL, 0, "Multicast Address", HFILL }},
979 { "Aux Data", "igmp.aux_data", FT_BYTES, BASE_HEX,
980 NULL, 0, "IGMP V3 Auxiliary Data", HFILL }},
983 { "Exponent", "igmp.max_resp.exp", FT_UINT8, BASE_HEX,
984 NULL, IGMP_MAX_RESP_EXP, "Maxmimum Response Time, Exponent", HFILL }},
987 { "Mantissa", "igmp.max_resp.mant", FT_UINT8, BASE_HEX,
988 NULL, IGMP_MAX_RESP_MANT, "Maxmimum Response Time, Mantissa", HFILL }},
990 { &hf_mtrace_max_hops,
991 { "# hops", "igmp.mtrace.max_hops", FT_UINT8, BASE_DEC,
992 NULL, 0, "Maxmimum Number of Hops to Trace", HFILL }},
995 { "Source Address", "igmp.mtrace.saddr", FT_IPv4, BASE_NONE,
996 NULL, 0, "Multicast Source for the Path Being Traced", HFILL }},
999 { "Receiver Address", "igmp.mtrace.raddr", FT_IPv4, BASE_NONE,
1000 NULL, 0, "Multicast Receiver for the Path Being Traced", HFILL }},
1002 { &hf_mtrace_rspaddr,
1003 { "Response Address", "igmp.mtrace.rspaddr", FT_IPv4, BASE_NONE,
1004 NULL, 0, "Destination of Completed Traceroute Response", HFILL }},
1006 { &hf_mtrace_resp_ttl,
1007 { "Response TTL", "igmp.mtrace.resp_ttl", FT_UINT8, BASE_DEC,
1008 NULL, 0, "TTL for Multicasted Responses", HFILL }},
1011 { "Query ID", "igmp.mtrace.q_id", FT_UINT24, BASE_DEC,
1012 NULL, 0, "Identifier for this Traceroute Request", HFILL }},
1014 { &hf_mtrace_q_arrival,
1015 { "Query Arrival", "igmp.mtrace.q_arrival", FT_UINT32, BASE_DEC,
1016 NULL, 0, "Query Arrival Time", HFILL }},
1018 { &hf_mtrace_q_inaddr,
1019 { "In itf addr", "igmp.mtrace.q_inaddr", FT_IPv4, BASE_NONE,
1020 NULL, 0, "Incoming Interface Address", HFILL }},
1022 { &hf_mtrace_q_outaddr,
1023 { "Out itf addr", "igmp.mtrace.q_outaddr", FT_IPv4, BASE_NONE,
1024 NULL, 0, "Outgoing Interface Address", HFILL }},
1026 { &hf_mtrace_q_prevrtr,
1027 { "Previous rtr addr", "igmp.mtrace.q_prevrtr", FT_IPv4, BASE_NONE,
1028 NULL, 0, "Previous-Hop Router Address", HFILL }},
1030 { &hf_mtrace_q_inpkt,
1031 { "In pkts", "igmp.mtrace.q_inpkt", FT_UINT32, BASE_DEC,
1032 NULL, 0, "Input packet count on incoming interface", HFILL }},
1034 { &hf_mtrace_q_outpkt,
1035 { "Out pkts", "igmp.mtrace.q_outpkt", FT_UINT32, BASE_DEC,
1036 NULL, 0, "Output packet count on outgoing interface", HFILL }},
1038 { &hf_mtrace_q_total,
1039 { "S,G pkt count", "igmp.mtrace.q_total", FT_UINT32, BASE_DEC,
1040 NULL, 0, "Total number of packets for this source-group pair", HFILL }},
1042 { &hf_mtrace_q_rtg_proto,
1043 { "Rtg Protocol", "igmp.mtrace.q_rtg_proto", FT_UINT8, BASE_DEC,
1044 VALS(&mtrace_rtg_vals), 0, "Routing protocol between this and previous hop rtr", HFILL }},
1046 { &hf_mtrace_q_fwd_ttl,
1047 { "FwdTTL", "igmp.mtrace.q_fwd_ttl", FT_UINT8, BASE_DEC,
1048 NULL, 0, "TTL required for forwarding", HFILL }},
1051 { "MBZ", "igmp.mtrace.q_mbz", FT_UINT8, BASE_HEX,
1052 NULL, 0x80, "Must be zeroed on transmission and ignored on reception", HFILL }},
1055 { "S", "igmp.mtrace.q_s", FT_UINT8, BASE_HEX,
1056 NULL, 0x40, "Set if S,G packet count is for source network", HFILL }},
1058 { &hf_mtrace_q_src_mask,
1059 { "Src Mask", "igmp.mtrace.q_src_mask", FT_UINT8, BASE_HEX,
1060 NULL, 0x3F, "Source mask length. 63 when forwarding on group state", HFILL }},
1062 { &hf_mtrace_q_fwd_code,
1063 { "Forwarding Code", "igmp.mtrace.q_fwd_code", FT_UINT8, BASE_HEX,
1064 VALS(&mtrace_fwd_code_vals), 0, "Forwarding information/error code", HFILL }},
1067 static gint *ett[] = {
1075 proto_igmp = proto_register_protocol("Internet Group Management Protocol",
1077 proto_register_field_array(proto_igmp, hf, array_length(hf));
1078 proto_register_subtree_array(ett, array_length(ett));
1082 proto_reg_handoff_igmp(void)
1084 dissector_handle_t igmp_handle;
1086 igmp_handle = create_dissector_handle(dissect_igmp, proto_igmp);
1087 dissector_add("ip.proto", IP_PROTO_IGMP, igmp_handle);