1 /* packet-msnip.c 2001 Ronnie Sahlberg <See AUTHORS for email>
2 * Routines for IGMP/MSNIP packet disassembly
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
20 MSNIP " Multicast Source Notification of Interest Protocol
21 Defined in draft-ietf-idmr-igmp-msnip-00.txt
26 #include <epan/packet.h>
27 #include <epan/expert.h>
28 #include <epan/to_str.h>
29 #include "packet-igmp.h"
31 void proto_register_msnip(void);
32 void proto_reg_handoff_msnip(void);
34 static dissector_handle_t msnip_handle
;
36 static int proto_msnip
;
37 static int hf_checksum
;
38 static int hf_checksum_status
;
41 static int hf_holdtime
;
45 static int hf_holdtime16
;
47 static int hf_rec_type
;
50 static int ett_groups
;
52 static expert_field ei_checksum
;
54 #define MC_ALL_IGMPV3_ROUTERS 0xe0000016
58 #define MSNIP_RMR 0x25
59 static const value_string msnip_types
[] = {
60 {MSNIP_GM
, "Multicast Group Map"},
61 {MSNIP_IS
, "Multicast Interest Solicitation"},
62 {MSNIP_RMR
, "Multicast Receiver Membership Report"},
66 #define MSNIP_RECTYPE_TRANSMIT 1
67 #define MSNIP_RECTYPE_HOLD 2
68 static const value_string msnip_rec_types
[] = {
69 {MSNIP_RECTYPE_TRANSMIT
, "Request to start transmitting group"},
70 {MSNIP_RECTYPE_HOLD
, "Request to hold transmitting group"},
75 dissect_msnip_rmr(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, int offset
)
80 count
= tvb_get_uint8(tvb
, offset
);
81 proto_tree_add_uint(parent_tree
, hf_count
, tvb
, offset
, 1, count
);
85 igmp_checksum(parent_tree
, tvb
, hf_checksum
, hf_checksum_status
, &ei_checksum
, pinfo
, 0);
92 int old_offset
= offset
;
94 item
= proto_tree_add_item(parent_tree
, hf_groups
,
95 tvb
, offset
, -1, ENC_NA
);
96 tree
= proto_item_add_subtree(item
, ett_groups
);
99 rec_type
= tvb_get_uint8(tvb
, offset
);
100 proto_tree_add_uint(tree
, hf_rec_type
, tvb
, offset
, 1, rec_type
);
103 /* skip 3 unused bytes */
106 /* multicast group */
107 proto_tree_add_item(tree
, hf_maddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
111 proto_item_set_text(item
,"Group: %s %s",
112 tvb_ip_to_str(pinfo
->pool
, tvb
, offset
-4),
113 val_to_str(rec_type
, msnip_rec_types
,
114 "Unknown Type:0x%02x"));
116 proto_item_set_len(item
, offset
-old_offset
);
124 dissect_msnip_is(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, int offset
)
127 /* skip reserved byte */
131 igmp_checksum(parent_tree
, tvb
, hf_checksum
, hf_checksum_status
, &ei_checksum
, pinfo
, 0);
134 /* 16 bit holdtime */
135 proto_tree_add_item(parent_tree
, hf_holdtime16
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
139 proto_tree_add_item(parent_tree
, hf_genid
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
147 dissect_msnip_gm(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, int offset
)
152 count
= tvb_get_uint8(tvb
, offset
);
153 proto_tree_add_uint(parent_tree
, hf_count
, tvb
, offset
, 1, count
);
157 igmp_checksum(parent_tree
, tvb
, hf_checksum
, hf_checksum_status
, &ei_checksum
, pinfo
, 0);
161 proto_tree_add_uint(parent_tree
, hf_holdtime
, tvb
, offset
, 4, count
);
168 int old_offset
= offset
;
170 item
= proto_tree_add_item(parent_tree
, hf_groups
,
171 tvb
, offset
, -1, ENC_NA
);
172 tree
= proto_item_add_subtree(item
, ett_groups
);
174 /* multicast group */
175 proto_tree_add_item(tree
, hf_maddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
179 masklen
= tvb_get_uint8(tvb
, offset
);
180 proto_tree_add_uint(tree
, hf_mask
, tvb
,
184 /* skip 3 unused bytes */
188 proto_item_set_text(item
,"Group: %s/%d",
189 tvb_ip_to_str(pinfo
->pool
, tvb
, offset
- 8), masklen
);
191 proto_item_set_len(item
, offset
-old_offset
);
199 /* This function is only called from the IGMP dissector */
201 dissect_msnip(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void* data _U_
)
207 uint32_t dst
= g_htonl(MC_ALL_IGMPV3_ROUTERS
);
209 /* Shouldn't be destined for us */
210 if ((pinfo
->dst
.type
!= AT_IPv4
) || memcmp(pinfo
->dst
.data
, &dst
, 4))
213 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MSNIP");
214 col_clear(pinfo
->cinfo
, COL_INFO
);
216 item
= proto_tree_add_item(parent_tree
, proto_msnip
, tvb
, offset
, -1, ENC_NA
);
217 tree
= proto_item_add_subtree(item
, ett_msnip
);
219 type
= tvb_get_uint8(tvb
, offset
);
220 col_add_str(pinfo
->cinfo
, COL_INFO
,
221 val_to_str(type
, msnip_types
,
222 "Unknown Type:0x%02x"));
224 /* type of command */
225 proto_tree_add_uint(tree
, hf_type
, tvb
, offset
, 1, type
);
230 offset
= dissect_msnip_gm(tvb
, pinfo
, tree
, offset
);
233 offset
= dissect_msnip_is(tvb
, pinfo
, tree
, offset
);
236 offset
= dissect_msnip_rmr(tvb
, pinfo
, tree
, offset
);
241 proto_item_set_len(item
, offset
);
249 proto_register_msnip(void)
251 static hf_register_info hf
[] = {
253 { "Type", "msnip.type", FT_UINT8
, BASE_HEX
,
254 VALS(msnip_types
), 0, "MSNIP Packet Type", HFILL
}},
257 { "Checksum", "msnip.checksum", FT_UINT16
, BASE_HEX
,
258 NULL
, 0, "MSNIP Checksum", HFILL
}},
260 { &hf_checksum_status
,
261 { "Checksum Status", "msnip.checksum.status", FT_UINT8
, BASE_NONE
,
262 VALS(proto_checksum_vals
), 0x0, NULL
, HFILL
}},
265 { "Count", "msnip.count", FT_UINT8
, BASE_DEC
,
266 NULL
, 0, "MSNIP Number of groups", HFILL
}},
269 { "Holdtime", "msnip.holdtime", FT_UINT32
, BASE_DEC
,
270 NULL
, 0, "MSNIP Holdtime in seconds", HFILL
}},
273 { "Groups", "msnip.groups", FT_NONE
, BASE_NONE
,
274 NULL
, 0, "MSNIP Groups", HFILL
}},
277 { "Multicast group", "msnip.maddr", FT_IPv4
, BASE_NONE
,
278 NULL
, 0, "MSNIP Multicast Group", HFILL
}},
281 { "Netmask", "msnip.netmask", FT_UINT8
, BASE_DEC
,
282 NULL
, 0, "MSNIP Netmask", HFILL
}},
285 { "Holdtime", "msnip.holdtime16", FT_UINT16
, BASE_DEC
,
286 NULL
, 0, "MSNIP Holdtime in seconds", HFILL
}},
289 { "Generation ID", "msnip.genid", FT_UINT16
, BASE_DEC
,
290 NULL
, 0, "MSNIP Generation ID", HFILL
}},
293 { "Record Type", "msnip.rec_type", FT_UINT8
, BASE_DEC
,
294 VALS(msnip_rec_types
), 0, "MSNIP Record Type", HFILL
}},
297 static int *ett
[] = {
302 static ei_register_info ei
[] = {
303 { &ei_checksum
, { "msnip.bad_checksum", PI_CHECKSUM
, PI_ERROR
, "Bad checksum", EXPFILL
}},
306 expert_module_t
* expert_msnip
;
308 proto_msnip
= proto_register_protocol("MSNIP: Multicast Source Notification of Interest Protocol", "MSNIP", "msnip");
309 proto_register_field_array(proto_msnip
, hf
, array_length(hf
));
310 proto_register_subtree_array(ett
, array_length(ett
));
311 expert_msnip
= expert_register_protocol(proto_msnip
);
312 expert_register_field_array(expert_msnip
, ei
, array_length(ei
));
314 msnip_handle
= register_dissector("msnip", dissect_msnip
, proto_msnip
);
318 proto_reg_handoff_msnip(void)
320 dissector_add_uint("igmp.type", IGMP_TYPE_0x23
, msnip_handle
);
321 dissector_add_uint("igmp.type", IGMP_TYPE_0x24
, msnip_handle
);
322 dissector_add_uint("igmp.type", IGMP_TYPE_0x25
, msnip_handle
);
326 * Editor modelines - https://www.wireshark.org/tools/modelines.html
331 * indent-tabs-mode: t
334 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
335 * :indentSize=8:tabSize=8:noTabs=false: