Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-pim.c
blob3c66e73da475f2383850b1664ddac1c9095008ea
1 /* packet-pim.c
2 * Routines for PIM disassembly
3 * (c) Copyright Jun-ichiro itojun Hagino <itojun@itojun.org>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <epan/ipproto.h>
16 #include <epan/afn.h>
17 #include <epan/prefs.h>
18 #include <epan/expert.h>
19 #include <epan/in_cksum.h>
20 #include <epan/to_str.h>
21 #include <epan/tfs.h>
22 #include <wsutil/array.h>
23 #include "packet-igmp.h"
25 void proto_register_pim(void);
26 void proto_reg_handoff_pim(void);
28 #define PIM_TYPE(x) ((x) & 0x0f)
29 #define PIM_VER(x) (((x) & 0xf0) >> 4)
30 #define PIM_BIDIR_SUBTYPE(x) ((x) & 0x0f)
31 #define PIM_SUBTYPE(x) (((x) & 0xf0) >> 4)
33 /* PIM message type */
35 #define PIM_TYPE_HELLO 0 /* Hello [RFC3973][RFC4601] */
36 #define PIM_TYPE_REGISTER 1 /* Register [RFC4601] */
37 #define PIM_TYPE_REGISTER_STOP 2 /* Register Stop [RFC4601] */
38 #define PIM_TYPE_JOIN_PRUNE 3 /* Join/Prune [RFC3973][RFC4601] */
39 #define PIM_TYPE_BOOTSTRAP 4 /* Bootstrap [RFC4601] */
40 #define PIM_TYPE_ASSERT 5 /* Assert [RFC3973][RFC4601] */
41 #define PIM_TYPE_GRAFT 6 /* Graft [RFC3973] */
42 #define PIM_TYPE_GRAFT_ACK 7 /* Graft-Ack [RFC3973] */
43 #define PIM_TYPE_CAND_RP_ADV 8 /* Candidate RP Advertisement [RFC4601] */
44 #define PIM_TYPE_STATE_REFRESH 9 /* State Refresh [RFC3973] */
45 #define PIM_TYPE_DF_ELECT 10 /* DF Election [RFC5015] */
46 #define PIM_TYPE_ECMP_REDIR 11 /* ECMP Redirect [RFC6754] */
47 #define PIM_TYPE_PFM 12 /* PIM PFM [RFC8364] */
48 #define PIM_TYPE_PACKED_REGISTER 13 /* PIM PFM [RFC9465] */
50 /* PIM Message Subtypes */
52 #define PIM_TYPE_PACKED_NULL_REGISTER 0 /* 13.0 */
53 #define PIM_TYPE_PACKED_REGISTER_STOP 1 /* 13.1 */
55 /* PIM Message hello options */
57 #define PIM_HELLO_HOLD_T 1 /* Hold Time [RFC7761] */
58 #define PIM_HELLO_LAN_PRUNE_DELAY 2 /* LAN Prune Delay [RFC3973] */
59 #define PIM_HELLO_LABEL_PARA 17 /* Label Parameters [Dino_Farinacci] */
60 #define PIM_HELLO_DEPRECATED_18 18 /* Deprecated */
61 #define PIM_HELLO_DR_PRIORITY 19 /* DR Priority [RFC7761] */
62 #define PIM_HELLO_GEN_ID 20 /* Generation ID [RFC3973] */
63 #define PIM_HELLO_STATE_REFRESH 21 /* State-Refresh [RFC3973] */
64 #define PIM_HELLO_BIDIR_CAPA 22 /* Bidirectional Capable [RFC5015] */
65 #define PIM_HELLO_VCI_CAPA 23 /* VCI Capability */
66 #define PIM_HELLO_VAR_ADDR_LST 24 /* variable Address List [RF7761] */
67 #define PIM_HELLO_VAR_NEIG_LST 25 /* variable Neighbor List TLV */
68 #define PIM_HELL0_JOIN_ATTR 26 /* Join Attribute [RFC5384] */
69 #define PIM_HELLO_O_TCP_CAPA 27 /* variable PIM-over-TCP-Capable [RFC6559] */
70 #define PIM_HELLO_O_SCTP_CAPA 28 /* variable PIM-over-SCTP-Capable [RFC6559] */
71 #define PIM_HELLO_VAR_POP_COUNT 29 /* variable Pop-Count [RFC6807] */
72 #define PIM_HELLO_MT_ID 30 /* PIM MT-ID [RFC6420] */
73 #define PIM_HELLO_INT_ID 31 /* Interface ID [RFC6395] */
74 #define PIM_HELLO_ECMP_REDIR 32 /* PIM ECMP Redirect Hello Option [RFC6754] */
75 #define PIM_HELLO_VPC_PEER_ID 33 /* 2 vPC Peer ID */
76 #define PIM_HELLO_DR_LB_CAPA 34 /* variable DR Load Balancing Capability [RFC8775] */
77 #define PIM_HELLO_DR_LB_LIST 35 /* variable DR Load Balancing List [RFC8775] */
78 #define PIM_HELLO_HIER_JP_ATTR 36 /* Hierarchical Join/Prune Attribute [RFC7887] */
79 #define PIM_HELLO_ADDR_LST 65001 /* Address list, old implementation */
80 #define PIM_HELLO_RPF_PROXY 65004 /* RPF Proxy Vector (Cisco proprietary) */
82 /* PIM PFM message */
84 #define PIM_PFM_GROUP_SOURCE 1 /* Source Group Holdtime [RFC8364] */
87 /* PIM BIDIR DF election messages */
89 #define PIM_BDIR_DF_OFFER 1
90 #define PIM_BDIR_DF_WINNER 2
91 #define PIM_BDIR_DF_BACKOFF 3
92 #define PIM_BDIR_DF_PASS 4
94 /* PIM Address Encoding Types */
96 #define PIM_ADDR_ET_NATIVE 0 /* RFC7761 */
97 #define PIM_ADDR_ET_NATIVE_JA 1 /* RFC5384 */
99 #define PIM_TRANSPORT_MODE_MULTICAST 0 /*RFC8059*/
100 #define PIM_TRANSPORT_MODE_UNICAST_REPLICATION 1 /*RFC8059*/
102 #define PIM_JOIN_ATTRIBUTE_TYPE_RPF 0 /* RFC5496 */
103 #define PIM_JOIN_ATTRIBUTE_TYPE_MVPN 1 /* RFC6513 */
104 #define PIM_JOIN_ATTRIBUTE_TYPE_MTID 2 /* RFC6420 */
105 #define PIM_JOIN_ATTRIBUTE_TYPE_PC 3 /* RFC6807 */
106 #define PIM_JOIN_ATTRIBUTE_TYPE_EX_RPF 4 /* RFC7891 */
107 #define PIM_JOIN_ATTRIBUTE_TYPE_TA 5 /* RFC8059 */
108 #define PIM_JOIN_ATTRIBUTE_TYPE_RLOC 6 /* RFC8059 */
110 #define PIM_GROUP_ADDR_FLAGS_B 0x80
111 #define PIM_GROUP_ADDR_FLAGS_RESERVED 0x7E
112 #define PIM_GROUP_ADDR_FLAGS_Z 0x01
114 #define PIM_SOURCE_ADDR_FLAGS_RESERVED 0xF8
115 #define PIM_SOURCE_ADDR_FLAGS_S 0x04
116 #define PIM_SOURCE_ADDR_FLAGS_W 0x02
117 #define PIM_SOURCE_ADDR_FLAGS_R 0x01
119 #define PIM_SOURCE_JA_FLAGS_F 0x80
120 #define PIM_SOURCE_JA_FLAGS_E 0x40
121 #define PIM_SOURCE_JA_FLAGS_ATTR_TYPE 0x3F
123 static const value_string pimtypevals[] = {
124 { PIM_TYPE_HELLO, "Hello" },
125 { PIM_TYPE_REGISTER, "Register" },
126 { PIM_TYPE_REGISTER_STOP, "Register-stop" },
127 { PIM_TYPE_JOIN_PRUNE, "Join/Prune" },
128 { PIM_TYPE_BOOTSTRAP, "Bootstrap" },
129 { PIM_TYPE_ASSERT, "Assert" },
130 { PIM_TYPE_GRAFT, "Graft" },
131 { PIM_TYPE_GRAFT_ACK, "Graft-Ack" },
132 { PIM_TYPE_CAND_RP_ADV, "Candidate-RP-Advertisement" },
133 { PIM_TYPE_STATE_REFRESH, "State-Refresh" },
134 { PIM_TYPE_DF_ELECT, "DF election"},
135 { PIM_TYPE_ECMP_REDIR, "ECMP redirect" },
136 { PIM_TYPE_PFM, "PFM source discovery"},
137 { PIM_TYPE_PACKED_REGISTER, "Packed Register"},
138 { 0, NULL }
142 * List of subtypes for PIM message Type 13.
144 static const value_string pimtype13subtypevals[] = {
145 { PIM_TYPE_PACKED_NULL_REGISTER, "Packed Null-Register" },
146 { PIM_TYPE_PACKED_REGISTER_STOP, "Packed Register-Stop" },
147 { 0, NULL }
150 static const value_string pimbdirdfvals[] = {
151 { PIM_BDIR_DF_OFFER, "offer"},
152 { PIM_BDIR_DF_WINNER, "DF Winner"},
153 { PIM_BDIR_DF_BACKOFF, "DF Backoff"},
154 { PIM_BDIR_DF_PASS, "DF Pass"},
155 { 0, NULL }
158 static const value_string pim_opt_vals[] = {
159 { PIM_HELLO_HOLD_T, "Hold Time" },
160 { PIM_HELLO_LAN_PRUNE_DELAY, "LAN Prune Delay" },
161 { PIM_HELLO_LABEL_PARA, "Label Parameters" },
162 { PIM_HELLO_DEPRECATED_18, "Deprecated" },
163 { PIM_HELLO_DR_PRIORITY, "DR Priority" },
164 { PIM_HELLO_GEN_ID, "Generation ID" },
165 { PIM_HELLO_STATE_REFRESH, "State-Refresh" },
166 { PIM_HELLO_BIDIR_CAPA, "Bidirectional Capable" },
167 { PIM_HELLO_VCI_CAPA, "VCI Capability" },
168 { PIM_HELLO_VAR_ADDR_LST, "Address List" },
169 { PIM_HELLO_VAR_NEIG_LST, "Neighbor List TLV" },
170 { PIM_HELL0_JOIN_ATTR, "Join Attribute" },
171 { PIM_HELLO_O_TCP_CAPA, "PIM-over-TCP-Capable" },
172 { PIM_HELLO_O_SCTP_CAPA, "PIM-over-SCTP-Capable" },
173 { PIM_HELLO_VAR_POP_COUNT, "Pop-Count" },
174 { PIM_HELLO_MT_ID, "PIM MT-ID" },
175 { PIM_HELLO_INT_ID, "Interface ID" },
176 { PIM_HELLO_ECMP_REDIR, "PIM ECMP Redirect Hello Option" },
177 { PIM_HELLO_VPC_PEER_ID, "vPC Peer ID" },
178 { PIM_HELLO_DR_LB_CAPA, "DR Load Balancing Capability" },
179 { PIM_HELLO_DR_LB_LIST, "DR Load Balancing List" },
180 { PIM_HELLO_HIER_JP_ATTR, "Hierarchical Join/Prune Attribute" },
181 { PIM_HELLO_ADDR_LST, "Address list, old implementation" },
182 { PIM_HELLO_RPF_PROXY, "RPF Proxy Vector (Cisco proprietary)" },
183 { 0, NULL }
186 static const value_string pim_opt_vals1[] = {
187 { PIM_PFM_GROUP_SOURCE, "Group Source Holdtime TLV" },
188 { 0, NULL }
193 static const value_string pim_addr_et_vals[] = {
194 { PIM_ADDR_ET_NATIVE, "Native"},
195 { PIM_ADDR_ET_NATIVE_JA, "Native with Join Attribute"},
196 { 0, NULL }
199 static const value_string attribute_transport_mode[] = {
200 {PIM_TRANSPORT_MODE_UNICAST_REPLICATION, "Unicast Replication"},
201 {PIM_TRANSPORT_MODE_MULTICAST, "Multicast"},
202 {0, NULL}};
204 static const value_string pim_join_attribute_type_vals[] = {
205 { PIM_JOIN_ATTRIBUTE_TYPE_RPF, "RPF Vector TLV"},
206 { PIM_JOIN_ATTRIBUTE_TYPE_MVPN, "MVPN Join Attribute"},
207 { PIM_JOIN_ATTRIBUTE_TYPE_MTID, "MT-ID Join Attribute"},
208 { PIM_JOIN_ATTRIBUTE_TYPE_PC, "Pop-Count"},
209 { PIM_JOIN_ATTRIBUTE_TYPE_EX_RPF, "Explicit RPF Vector"},
210 { PIM_JOIN_ATTRIBUTE_TYPE_TA, "Transport Attribute"},
211 { PIM_JOIN_ATTRIBUTE_TYPE_RLOC, "Receiver RLOC Attribute"},
212 { 0, NULL }
215 enum pimv2_addrtype {
216 pimv2_unicast, pimv2_group, pimv2_source
219 static int proto_pim;
220 static int hf_pim_version;
221 static int hf_pim_type;
222 static int hf_pim_code;
223 static int hf_pim_igmp_type;
224 static int hf_pim_df_elect_subtype;
225 static int hf_pim_df_elect_rsvd;
226 static int hf_pim_cksum;
227 static int hf_pim_cksum_status;
228 static int hf_pim_res_bytes;
229 static int hf_pim_reg_stop_p_bit;
230 static int hf_pim_type_13_subtype;
231 static int hf_pim_type_13_flagbits;
232 /* PIM Hello options (RFC 4601, section 4.9.2 and RFC 3973, section 4.7.5) */
233 static int hf_pim_option;
234 static int hf_pim_optiontype;
235 static int hf_pim_optionlength;
236 static int hf_pim_optionvalue;
237 static int hf_pim_register_flag;
238 static int hf_pim_register_flag_border;
239 static int hf_pim_register_flag_null_register;
240 static int hf_pim_mode;
241 static int hf_pim_holdtime;
242 static int hf_pim_holdtime_t;
243 static int hf_pim_numgroups;
244 static int hf_pim_numjoins;
245 static int hf_pim_numprunes;
246 static int hf_pim_t;
247 static int hf_pim_propagation_delay;
248 static int hf_pim_override_interval;
249 static int hf_pim_dr_priority;
250 static int hf_pim_generation_id;
251 static int hf_pim_state_refresh_version;
252 static int hf_pim_state_refresh_interval;
253 static int hf_pim_state_refresh_reserved;
254 /* Assert fields */
255 static int hf_pim_rpt;
256 static int hf_pim_metric_pref;
257 static int hf_pim_df_metric_pref;
258 static int hf_pim_metric;
259 static int hf_pim_prune_indicator;
260 static int hf_pim_prune_now;
261 static int hf_pim_assert_override;
262 static int hf_pim_ip_version;
263 static int hf_pim_dummy_header;
264 static int hf_pim_source_ip4;
265 static int hf_pim_source_ip6;
266 static int hf_pim_group_ip4;
267 static int hf_pim_group_ip6;
268 static int hf_pim_group_mask_ip4;
269 static int hf_pim_upstream_neighbor_ip4;
270 static int hf_pim_upstream_neighbor_ip6;
271 static int hf_pim_join_ip4;
272 static int hf_pim_join_ip6;
273 static int hf_pim_prune_ip4;
274 static int hf_pim_prune_ip6;
275 static int hf_pim_address_list_ip4;
276 static int hf_pim_address_list_ip6;
277 static int hf_pim_bsr_ip4;
278 static int hf_pim_bsr_ip6;
279 static int hf_pim_rp_ip4;
280 static int hf_pim_rp_ip6;
281 static int hf_pim_bd_bo_offer_ip4;
282 static int hf_pim_bd_bo_offer_ip6;
283 static int hf_pim_bd_offer_metric_pref;
284 static int hf_pim_bd_offer_metric;
285 static int hf_pim_bd_offer_interval;
286 static int hf_pim_bd_pass_ip4;
287 static int hf_pim_bd_pass_ip6;
288 static int hf_pim_bd_pass_metric_pref;
289 static int hf_pim_bd_pass_metric;
290 static int hf_pim_originator_ip4;
291 static int hf_pim_originator_ip6;
292 static int hf_pim_group_address_ip4;
293 static int hf_pim_fragment_tag;
294 static int hf_pim_hash_mask_len;
295 static int hf_pim_bsr_priority;
296 static int hf_pim_rp_count;
297 static int hf_pim_frp_count;
298 static int hf_pim_priority;
299 static int hf_pim_prefix_count;
300 static int hf_pim_addr_len;
301 static int hf_pim_src_flags_a;
302 static int hf_pim_src_flags_s;
303 static int hf_pim_src_flags_w;
304 static int hf_pim_src_flags_r;
305 static int hf_pim_src_flags_rsv;
306 static int hf_pim_mask_len;
307 static int hf_pim_addr_af;
308 static int hf_pim_addr_et;
309 static int hf_pim_unicast_addr_ipv4;
310 static int hf_pim_unicast_addr_ipv6;
311 static int hf_pim_rloc_addr_ipv4;
312 static int hf_pim_rloc_addr_ipv6;
313 static int hf_pim_attribute_transport_mode;
314 static int hf_pim_group;
315 static int hf_pim_group_addr_flags;
316 static int hf_pim_group_addr_flags_b;
317 static int hf_pim_group_addr_flags_reserved;
318 static int hf_pim_group_addr_flags_z;
319 static int hf_pim_source_addr_flags;
320 static int hf_pim_source_addr_flags_reserved;
321 static int hf_pim_source_addr_flags_s;
322 static int hf_pim_source_addr_flags_w;
323 static int hf_pim_source_addr_flags_r;
324 static int hf_pim_source_join_attribute;
325 static int hf_pim_source_ja_flags;
326 static int hf_pim_source_ja_flags_f;
327 static int hf_pim_source_ja_flags_e;
328 static int hf_pim_source_ja_flags_attr_type;
329 static int hf_pim_source_ja_length;
330 static int hf_pim_source_ja_value;
331 static int hf_pim_ttl;
332 static int hf_pim_interval;
333 static int hf_pim_srcount;
334 static int hf_pim_srcholdt;
335 static int hf_pim_transitivetype;
336 static int hf_pim_optiontype1;
337 static int hf_pfm_no_forward_bit;
339 static int ett_pim;
340 static int ett_pim_opts;
341 static int ett_pim_opt;
342 static int ett_pim_addr_flags;
344 static expert_field ei_pim_cksum;
346 static dissector_handle_t pim_handle;
347 static dissector_handle_t pimv1_handle;
349 static dissector_handle_t ip_handle;
350 static dissector_handle_t ipv6_handle;
352 static bool use_main_tree = true;
355 * The Story About Ping^WPIM:
357 * http://www.cs.usc.edu/assets/003/83187.pdf
359 * dated January 11, 1995, entitled "Protocol Independent Multicast (PIM):
360 * Protocol Specification", calls itself draft-ietf-idmr-pim-spec-01,
361 * and is in PostScript-converted-to-PDF form. It describes a protocol
362 * that runs atop IGMP, with a type of 4 for "Router PIM Messages", and
363 * a PIM version number field of 1.
365 * https://tools.ietf.org/html/draft-ietf-idmr-pim-sm-spec-00
367 * dated September 7, 1995, and
369 * https://tools.ietf.org/html/draft-ietf-idmr-pim-spec-02
371 * dated September 7, 1995, both entitled "Protocol Independent Multicast-
372 * Sparse Mode (PIM-SM): Protocol Specification", describe a protocol that
373 * runs atop IGMP, with a type of 4 for "Router PIM Messages", and a PIM
374 * version number field of 2.
376 * https://tools.ietf.org/html/draft-ietf-idmr-pim-sm-spec-03
378 * dated June 6, 1996, and all subsequent drafts, and RFC 2117, dated
379 * June 1997, all entitled "Protocol Independent Multicast-Sparse Mode
380 * (PIM-SM): Protocol Specification", describe a protocol that runs
381 * atop IP, with a protocol number of 103, and with a PIM version number
382 * field of 2. RFC 2117 was obsoleted by RFC 2362, which was obsoleted by
383 * RFC 4601.
385 * None of them, including the PDF from USC, appear to describe the protocol
386 * dissected by the dissect_pimv1() code. In particular, none have a
387 * packet type value of 8 meaning "Mode"; the PDF from USC doesn't mention
388 * it at all, and subsequent drafts and RFC 2117 have (Candidate-)RP-
389 * Advertisement. Perhaps what's dissected by dissect_pimv1() was
390 * something between the PDF and draft-ietf-idmr-pim-spec-02.
392 * Looking at the Dense Mode specs,
394 * https://tools.ietf.org/html/draft-ietf-idmr-pim-dm-spec-02
396 * entitled "Protocol Independent Multicast-Dense Mode (PIM-DM): Protocol
397 * Specification", dated September 1995, describes a protocol that runs
398 * atop IGMP, with a type of 4 for "Router PIM Messages", and with a PIM
399 * version number field of 2.
401 * RFC 3973, entitled "Protocol Independent Multicast-Dense Mode (PIM-DM):
402 * Protocol Specification", also describes a protocol that runs atop IP,
403 * with a protocol number of 103, and with a PIM version number field of 2.
405 static int * const pim_src_flags_fields[] = {
406 &hf_pim_src_flags_a,
407 &hf_pim_src_flags_s,
408 &hf_pim_src_flags_w,
409 &hf_pim_src_flags_r,
410 &hf_pim_src_flags_rsv,
411 NULL
414 static int * const pim_group_addr_flags[] = {
415 &hf_pim_group_addr_flags_b,
416 &hf_pim_group_addr_flags_reserved,
417 &hf_pim_group_addr_flags_z,
418 NULL
421 static int * const pim_source_addr_flags[] = {
422 &hf_pim_source_addr_flags_reserved,
423 &hf_pim_source_addr_flags_s,
424 &hf_pim_source_addr_flags_w,
425 &hf_pim_source_addr_flags_r,
426 NULL
429 static int * const pim_source_ja_flags[] = {
430 &hf_pim_source_ja_flags_f,
431 &hf_pim_source_ja_flags_e,
432 &hf_pim_source_ja_flags_attr_type,
433 NULL
436 static void
437 dissect_pimv1_addr(tvbuff_t *tvb, int offset, proto_tree *pim_tree, int hf_ip) {
439 proto_tree_add_bitmask_list(pim_tree, tvb, offset, 1, pim_src_flags_fields, ENC_BIG_ENDIAN);
440 offset += 1;
442 proto_tree_add_item(pim_tree, hf_pim_mask_len, tvb, offset, 1, ENC_BIG_ENDIAN);
443 offset += 1;
445 proto_tree_add_item(pim_tree, hf_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
449 static const value_string pim_type1_vals[] = {
450 { 0, "Query" },
451 { 1, "Register" },
452 { 2, "Register-stop" },
453 { 3, "Join/Prune" },
454 { 4, "RP-Reachable" },
455 { 5, "Assert" },
456 { 6, "Graft" },
457 { 7, "Graft-Ack" },
458 { 8, "Mode" },
459 { 0, NULL },
462 static const value_string pimv1_modevals[] = {
463 { 0, "Dense" },
464 { 1, "Sparse" },
465 { 2, "Sparse-Dense" },
466 { 0, NULL }
469 static const value_string pim_ip_version_vals[] = {
470 { 0, "Dummy Header" },
471 { 4, "IPv4" },
472 { 6, "IPv6" },
473 { 0, NULL }
476 static const value_string unique_infinity[] = {
477 { 0xffff, "Infinity" },
478 { 0, NULL }
481 static const value_string unique_infinity_t[] = {
482 { 0, "goodbye" },
483 { 0xffff, "Infinity" },
484 { 0, NULL }
487 /* This function is only called from the IGMP dissector */
488 static int
489 dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
490 uint8_t pim_type;
491 uint8_t pim_ver;
492 unsigned length, pim_length;
493 vec_t cksum_vec[1];
494 proto_tree *pim_tree = NULL;
495 proto_item *ti;
496 proto_tree *pimopt_tree = NULL;
497 int offset = 0;
499 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PIMv1");
500 col_clear(pinfo->cinfo, COL_INFO);
502 ti = proto_tree_add_item(tree, proto_pim, tvb, offset, -1, ENC_NA);
503 pim_tree = proto_item_add_subtree(ti, ett_pim);
505 /* Put IGMP type, 0x14, into the tree */
506 proto_tree_add_string(pim_tree, hf_pim_igmp_type, tvb, offset, 0, "PIM (0x14)");
508 offset += 1;
510 pim_type = tvb_get_uint8(tvb, offset);
511 col_add_str(pinfo->cinfo, COL_INFO,
512 val_to_str(pim_type, pim_type1_vals, "Unknown (%u)"));
514 proto_tree_add_uint(pim_tree, hf_pim_code, tvb, offset, 1, pim_type);
515 offset += 1;
517 pim_ver = PIM_VER(tvb_get_uint8(tvb, offset + 2));
518 if (pim_ver != 1) {
519 proto_tree_add_checksum(pim_tree, tvb, offset, hf_pim_cksum, hf_pim_cksum_status, &ei_pim_cksum, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
522 * Not PIMv1; should we bother dissecting the PIM drafts
523 * with a version number of 2 and with PIM running atop
524 * IGMP?
526 offset += 2;
527 proto_tree_add_item(pim_tree, hf_pim_version, tvb, offset, 1, ENC_BIG_ENDIAN);
528 return offset+tvb_reported_length_remaining(tvb, offset);
532 * Well, it's PIM v1, so we can check whether this is a
533 * Register message, and thus can figure out how much to
534 * checksum and whether to make the columns read-only.
536 length = tvb_reported_length(tvb);
537 if (pim_type == 1) {
539 * Register message - the PIM header is 8 bytes long.
540 * Also set the columns non-writable. Otherwise the IPv4 or
541 * IPv6 dissector for the encapsulated packet that caused
542 * this register will overwrite the PIM info in the columns.
544 * XXX - that's not what draft-ietf-idmr-pim-spec-01 or
545 * draft-ietf-idmr-pim-spec-02 say; they say that the checksum
546 * covers the entire IGMP message. Later drafts say it
547 * doesn't cover the encapsulated packet; perhaps that's what
548 * was always intended, and they just felt they needed to
549 * explicitly state that.
551 pim_length = 8;
552 col_set_writable(pinfo->cinfo, -1, false);
553 } else {
555 * Other message - checksum the entire packet.
557 pim_length = length;
560 if (!pinfo->fragmented && length >= pim_length &&
561 tvb_captured_length(tvb) >= pim_length) {
563 * The packet isn't part of a fragmented datagram and isn't
564 * truncated, so we can checksum it.
566 SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, pim_length);
567 proto_tree_add_checksum(pim_tree, tvb, offset, hf_pim_cksum, hf_pim_cksum_status, &ei_pim_cksum,
568 pinfo, in_cksum(&cksum_vec[0], 1), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
569 } else {
570 proto_tree_add_checksum(pim_tree, tvb, offset, hf_pim_cksum, hf_pim_cksum_status, &ei_pim_cksum,
571 pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
573 offset += 2;
575 proto_tree_add_item(pim_tree, hf_pim_version, tvb, offset, 1, ENC_BIG_ENDIAN);
576 offset += 1;
578 /* reserved stuff */
579 proto_tree_add_item(pim_tree, hf_pim_res_bytes, tvb, offset, 3, ENC_NA);
580 offset += 3;
582 if (tvb_reported_length_remaining(tvb, offset) > 0) {
583 proto_item *subitem;
584 subitem = proto_tree_add_item(pim_tree, hf_pim_option, tvb, offset, -1, ENC_NA);
585 pimopt_tree = proto_item_add_subtree(subitem, ett_pim_opts);
586 } else
587 return offset;
589 /* version 1 decoder */
590 switch (pim_type) {
591 case 0: /* query */
593 proto_tree_add_item(pimopt_tree, hf_pim_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
594 offset += 2;
596 proto_tree_add_item(pimopt_tree, hf_pim_holdtime, tvb, offset, 2, ENC_BIG_ENDIAN);
597 offset += 2;
598 break;
601 case 1: /* register */
603 uint8_t v_hl;
604 tvbuff_t *next_tvb;
607 * The rest of the packet is a multicast data packet.
609 next_tvb = tvb_new_subset_remaining(tvb, offset);
612 * It's an IP packet - determine whether it's IPv4 or IPv6.
614 v_hl = tvb_get_uint8(tvb, offset);
615 proto_tree_add_item(pimopt_tree, hf_pim_ip_version, tvb, offset, 1, ENC_BIG_ENDIAN);
617 switch((v_hl & 0xf0) >> 4) {
618 case 0: /* Null-Register dummy header.
619 * Has the same address family as the encapsulating PIM packet,
620 * e.g. an IPv6 data packet is encapsulated in IPv6 PIM packet.
622 ti = proto_tree_add_item(pimopt_tree, hf_pim_dummy_header, tvb, offset, -1, ENC_NA);
623 if (pinfo->src.type == AT_IPv4) {
624 proto_item_append_text(ti, " IPv4");
625 proto_tree_add_item(pimopt_tree, hf_pim_source_ip4, tvb, offset + 12, 4, ENC_BIG_ENDIAN);
626 proto_tree_add_item(pimopt_tree, hf_pim_group_ip4, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
627 } else if (pinfo->src.type == AT_IPv6) {
628 proto_item_append_text(ti, " IPv6");
629 proto_tree_add_item(pimopt_tree, hf_pim_source_ip6, tvb, offset + 8, 16, ENC_NA);
630 proto_tree_add_item(pimopt_tree, hf_pim_group_ip6, tvb, offset + 8 + 16, 16, ENC_NA);
631 } else
632 proto_item_append_text(ti, " for an unknown protocol");
634 break;
635 case 4: /* IPv4 */
636 if (use_main_tree) {
637 call_dissector(ip_handle, next_tvb, pinfo, tree);
638 } else {
639 call_dissector(ip_handle, next_tvb, pinfo, pimopt_tree);
641 break;
642 case 6: /* IPv6 */
643 if (use_main_tree) {
644 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
645 } else {
646 call_dissector(ipv6_handle, next_tvb, pinfo, pimopt_tree);
648 break;
649 default:
650 break;
652 break;
655 case 2: /* register-stop */
657 proto_tree_add_item(pimopt_tree, hf_pim_group_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
658 offset += 4;
659 proto_tree_add_item(pimopt_tree, hf_pim_source_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
660 offset += 4;
661 break;
664 case 3: /* join/prune */
665 case 6: /* graft */
666 case 7: /* graft-ack */
668 int off;
669 int ngroup, i, njoin, nprune, j;
670 proto_tree *grouptree = NULL;
671 proto_item *tigroup;
672 proto_tree *subtree = NULL;
673 proto_item *tisub;
675 proto_tree_add_item(pimopt_tree, hf_pim_upstream_neighbor_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
676 offset += 4;
678 /* reserved stuff */
679 proto_tree_add_item(pim_tree, hf_pim_res_bytes, tvb, offset, 2, ENC_NA);
680 offset += 2;
682 proto_tree_add_item(pimopt_tree, hf_pim_holdtime, tvb, offset, 2, ENC_BIG_ENDIAN);
683 offset += 2;
685 /* reserved stuff */
686 proto_tree_add_item(pim_tree, hf_pim_res_bytes, tvb, offset, 1, ENC_NA);
687 offset += 1;
689 proto_tree_add_item(pimopt_tree, hf_pim_mask_len, tvb, offset, 1, ENC_NA);
690 offset += 1;
692 proto_tree_add_item(pimopt_tree, hf_pim_addr_len, tvb, offset, 1, ENC_NA);
693 offset += 1;
695 ngroup = tvb_get_uint8(tvb, offset);
696 proto_tree_add_item(pimopt_tree, hf_pim_numgroups, tvb, offset, 1, ENC_BIG_ENDIAN);
697 offset += 1;
699 for (i = 0; i < ngroup; i++) {
701 * XXX - does the group address have the length "adr_len"
702 * and the group mask the length "mask_len"?
704 tigroup = proto_tree_add_ipv4_format(pimopt_tree, hf_pim_group_ip4, tvb, offset, 4,
705 tvb_get_ipv4(tvb, offset), "Group %d: %s", i, tvb_ip_to_str(pinfo->pool, tvb, offset));
706 grouptree = proto_item_add_subtree(tigroup, ett_pim);
707 offset += 4;
709 proto_tree_add_ipv4_format(grouptree, hf_pim_group_mask_ip4, tvb, offset, 4,
710 tvb_get_ipv4(tvb, offset), "Group %d Mask: %s", i, tvb_ip_to_str(pinfo->pool, tvb, offset));
711 offset += 4;
713 njoin = tvb_get_ntohs(tvb, offset);
714 nprune = tvb_get_ntohs(tvb, offset + 2);
715 tisub = proto_tree_add_item(grouptree, hf_pim_numjoins, tvb,
716 offset, 2, ENC_BIG_ENDIAN);
717 subtree = proto_item_add_subtree(tisub, ett_pim);
718 off = offset + 4;
719 for (j = 0; j < njoin; j++) {
720 dissect_pimv1_addr(tvb, off, subtree, hf_pim_join_ip4);
721 off += 6;
724 tisub = proto_tree_add_item(grouptree, hf_pim_numprunes, tvb,
725 offset + 2, 2, ENC_BIG_ENDIAN);
726 subtree = proto_item_add_subtree(tisub, ett_pim);
727 for (j = 0; j < nprune; j++) {
728 dissect_pimv1_addr(tvb, off, subtree, hf_pim_prune_ip4);
729 off += 6;
731 offset = off;
733 break;
736 case 4: /* rp-reachability */
738 proto_tree_add_item(pimopt_tree, hf_pim_group_address_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
739 offset += 4;
741 proto_tree_add_item(pimopt_tree, hf_pim_group_mask_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
742 offset += 4;
744 proto_tree_add_item(pimopt_tree, hf_pim_rp_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
745 offset += 4;
747 /* reserved stuff */
748 proto_tree_add_item(pim_tree, hf_pim_res_bytes, tvb, offset, 2, ENC_NA);
749 offset += 2;
751 proto_tree_add_item(pimopt_tree, hf_pim_holdtime, tvb, offset, 2, ENC_BIG_ENDIAN);
752 offset += 2;
753 break;
756 case 5: /* assert */
759 proto_tree_add_item(pimopt_tree, hf_pim_group_address_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
760 offset += 4;
762 proto_tree_add_item(pimopt_tree, hf_pim_group_mask_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
763 offset += 4;
765 proto_tree_add_item(pimopt_tree, hf_pim_rpt, tvb, offset, 1, ENC_BIG_ENDIAN);
766 proto_tree_add_item(pimopt_tree, hf_pim_metric_pref, tvb,
767 offset, 4, ENC_BIG_ENDIAN);
768 offset += 4;
770 proto_tree_add_item(pimopt_tree, hf_pim_metric, tvb, offset, 4, ENC_BIG_ENDIAN);
771 offset += 4;
772 break;
775 default:
776 break;
779 return offset;
782 static bool
783 // NOLINTNEXTLINE(misc-no-recursion)
784 dissect_pim_addr(packet_info *pinfo, proto_tree* tree, tvbuff_t *tvb, int offset, enum pimv2_addrtype at,
785 const char* label, proto_item** ret_item, int hf_ip4, int hf_ip6, int *advance) {
786 uint8_t af, et, flags, mask_len, ja_af;
787 ws_in6_addr ipv6;
788 uint32_t ipv4 = 0;
789 proto_item* ti = NULL;
790 proto_tree* addr_tree = NULL;
791 proto_item *rloc_tree = NULL;
792 proto_tree *rloc_sub_tree = NULL;
793 proto_tree* ja_tree = NULL;
794 int len = 0;
795 int ja_offset = 0;
796 uint8_t ja_eos_type = 0;
797 uint8_t ja_length = 0;
798 int ja_length_sum = 0;
800 af = tvb_get_uint8(tvb, offset);
801 if (af != AFNUM_INET && af != AFNUM_INET6) {
803 * We don't handle the other formats, and addresses don't include
804 * a length field, so we can't even show them as raw bytes.
806 return false;
809 et = tvb_get_uint8(tvb, offset + 1);
810 if ((et != PIM_ADDR_ET_NATIVE) && (et != PIM_ADDR_ET_NATIVE_JA)) {
812 * The only defined encoding type is 0 and 1, for the native encoding
813 * and native with Join Attribute TLVs;
814 * again, as addresses don't include a length field, we can't
815 * even show addresses with a different encoding type as raw
816 * bytes.
818 return false;
821 switch (at) {
822 case pimv2_unicast:
823 switch (af) {
824 case AFNUM_INET:
825 len = 4;
826 ipv4 = tvb_get_ipv4(tvb, offset + 2);
827 if (label)
829 ti = proto_tree_add_ipv4_format(tree, hf_ip4, tvb, offset, 2 + len,
830 ipv4, "%s: %s", label, tvb_ip_to_str(pinfo->pool, tvb, offset + 2));
832 else
834 ti = proto_tree_add_ipv4(tree, hf_ip4, tvb, offset, 2 + len, ipv4);
836 break;
838 case AFNUM_INET6:
839 len = 16;
840 tvb_get_ipv6(tvb, offset + 2, &ipv6);
841 if (label)
843 ti = proto_tree_add_ipv6_format(tree, hf_ip6, tvb, offset, 2 + len,
844 &ipv6, "%s: %s", label, tvb_ip6_to_str(pinfo->pool, tvb, offset + 2));
846 else
848 ti = proto_tree_add_ipv6(tree, hf_ip6, tvb, offset, 2 + len, &ipv6);
850 break;
852 addr_tree = proto_item_add_subtree(ti, ett_pim);
853 proto_tree_add_item(addr_tree, hf_pim_addr_af, tvb, offset, 1, ENC_NA);
854 proto_tree_add_item(addr_tree, hf_pim_addr_et, tvb, offset+1, 1, ENC_NA);
855 switch (af) {
856 case AFNUM_INET:
857 proto_tree_add_item(addr_tree, hf_pim_unicast_addr_ipv4, tvb, offset+2, 4, ENC_BIG_ENDIAN);
858 break;
859 case AFNUM_INET6:
860 proto_tree_add_item(addr_tree, hf_pim_unicast_addr_ipv6, tvb, offset+2, 16, ENC_NA);
861 break;
863 if (et == PIM_ADDR_ET_NATIVE_JA){
864 ja_offset = offset + len + 2;
865 while (((ja_eos_type & 0x40) != 0x40) && (tvb_reported_length_remaining(tvb, ja_offset) >= 2)){
866 ja_length = tvb_get_uint8(tvb, ja_offset+1);
867 ti = proto_tree_add_item(addr_tree, hf_pim_source_join_attribute, tvb, ja_offset, ja_length + 2, ENC_NA);
868 ja_tree = proto_item_add_subtree(ti, ett_pim);
869 ja_eos_type = tvb_get_uint8(tvb, ja_offset);
870 proto_tree_add_bitmask(ja_tree, tvb, ja_offset, hf_pim_source_ja_flags,
871 ett_pim_addr_flags, pim_source_ja_flags, ENC_BIG_ENDIAN);
872 proto_item_append_text(ti, ": %s", val_to_str_const(ja_eos_type & 0x3F, pim_join_attribute_type_vals, "Unknown"));
873 ja_offset += 1;
874 proto_tree_add_item(ja_tree, hf_pim_source_ja_length, tvb, ja_offset, 1, ENC_BIG_ENDIAN);
875 ja_offset += 1;
876 switch(ja_eos_type & 0x3F){
877 case PIM_JOIN_ATTRIBUTE_TYPE_TA:
878 proto_tree_add_item(ja_tree, hf_pim_attribute_transport_mode, tvb, ja_offset, 1, ENC_NA);
879 break;
880 case PIM_JOIN_ATTRIBUTE_TYPE_RLOC:
881 ja_af = tvb_get_uint8(tvb, offset);
882 switch(ja_af) {
883 case AFNUM_INET:
884 rloc_tree = proto_tree_add_ipv4_format(ja_tree, hf_ip4, tvb, ja_offset, ja_length,
885 ipv4, "RLOC: %s", tvb_ip_to_str(pinfo->pool, tvb, ja_offset+ 1));
886 rloc_sub_tree = proto_item_add_subtree(rloc_tree, ett_pim);
887 proto_tree_add_item(rloc_sub_tree, hf_pim_addr_af, tvb, ja_offset, 1, ENC_NA);
888 proto_tree_add_item(rloc_sub_tree, hf_pim_rloc_addr_ipv4, tvb, ja_offset + 1, 4, ENC_BIG_ENDIAN);
889 break;
890 case AFNUM_INET6:
891 rloc_tree = proto_tree_add_ipv6_format(ja_tree, hf_ip6, tvb, ja_offset, ja_length,
892 &ipv6, "RLOC: %s", tvb_ip_to_str(pinfo->pool, tvb, ja_offset+ 1));
893 rloc_sub_tree = proto_item_add_subtree(rloc_tree, ett_pim);
894 proto_tree_add_item(rloc_sub_tree, hf_pim_addr_af, tvb, ja_offset, 1, ENC_NA);
895 proto_tree_add_item(rloc_sub_tree, hf_pim_rloc_addr_ipv6, tvb, ja_offset + 1, 16, ENC_NA);
896 break;
898 break;
899 default:
900 break;
902 ja_offset += ja_length;
903 ja_length_sum += (2 + (int)ja_length);
905 *advance = 2 + len + ja_length_sum;
906 break;
908 *advance = 2 + len;
909 break;
911 case pimv2_group:
912 mask_len = tvb_get_uint8(tvb, offset + 3);
913 switch (af) {
914 case AFNUM_INET:
915 len = 4;
916 ipv4 = tvb_get_ipv4(tvb, offset + 4);
917 if (label)
919 ti = proto_tree_add_ipv4_format(tree, hf_ip4, tvb, offset, 4 + len,
920 ipv4, "%s: %s", label, tvb_ip_to_str(pinfo->pool, tvb, offset + 4));
922 else
924 ti = proto_tree_add_ipv4(tree, hf_ip4, tvb, offset, 4 + len, ipv4);
927 proto_item_append_text(ti, "/%u", mask_len);
928 break;
930 case AFNUM_INET6:
931 len = 16;
932 tvb_get_ipv6(tvb, offset + 4, &ipv6);
933 if (label)
935 ti = proto_tree_add_ipv6_format(tree, hf_ip6, tvb, offset, 4 + len,
936 &ipv6, "%s: %s", label, tvb_ip6_to_str(pinfo->pool, tvb, offset + 4));
938 else
940 ti = proto_tree_add_ipv6(tree, hf_ip6, tvb, offset, 4 + len, &ipv6);
942 proto_item_append_text(ti, "/%u", mask_len);
943 break;
945 addr_tree = proto_item_add_subtree(ti, ett_pim);
946 proto_tree_add_item(addr_tree, hf_pim_addr_af, tvb, offset, 1, ENC_NA);
947 proto_tree_add_item(addr_tree, hf_pim_addr_et, tvb, offset+1, 1, ENC_NA);
948 proto_tree_add_bitmask(addr_tree, tvb, offset+2, hf_pim_group_addr_flags,
949 ett_pim_addr_flags, pim_group_addr_flags, ENC_BIG_ENDIAN);
950 proto_tree_add_item(addr_tree, hf_pim_mask_len, tvb, offset+3, 1, ENC_NA);
951 switch (af) {
952 case AFNUM_INET:
953 proto_tree_add_item(addr_tree, hf_pim_group_ip4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
954 break;
955 case AFNUM_INET6:
956 proto_tree_add_item(addr_tree, hf_pim_group_ip6, tvb, offset+4, 16, ENC_NA);
957 break;
959 *advance = 4 + len;
960 break;
962 case pimv2_source:
963 flags = tvb_get_uint8(tvb, offset + 2);
964 mask_len = tvb_get_uint8(tvb, offset + 3);
965 switch (af) {
966 case AFNUM_INET:
967 len = 4;
968 ipv4 = tvb_get_ipv4(tvb, offset + 4);
969 if (label)
971 ti = proto_tree_add_ipv4_format(tree, hf_ip4, tvb, offset, 4 + len,
972 ipv4, "%s: %s", label, tvb_ip_to_str(pinfo->pool, tvb, offset + 4));
974 else
976 ti = proto_tree_add_ipv4_format_value(tree, hf_ip4, tvb, offset, 4 + len, ipv4,
977 "%s", tvb_ip_to_str(pinfo->pool, tvb, offset + 4));
979 proto_item_append_text(ti, "/%u", mask_len);
980 break;
982 case AFNUM_INET6:
983 len = 16;
984 tvb_get_ipv6(tvb, offset + 4, &ipv6);
985 if (label)
987 ti = proto_tree_add_ipv6_format(tree, hf_ip6, tvb, offset, 4 + len,
988 &ipv6, "%s: %s", label, tvb_ip6_to_str(pinfo->pool, tvb, offset + 4));
990 else
992 ti = proto_tree_add_ipv6_format_value(tree, hf_ip6, tvb, offset, 4 + len, &ipv6,
993 "%s", tvb_ip6_to_str(pinfo->pool, tvb, offset + 4));
995 proto_item_append_text(ti, "/%u", mask_len);
996 break;
998 if (flags) {
999 proto_item_append_text(ti, " (%s%s%s)",
1000 flags & 0x04 ? "S" : "",
1001 flags & 0x02 ? "W" : "",
1002 flags & 0x01 ? "R" : "");
1004 addr_tree = proto_item_add_subtree(ti, ett_pim);
1005 proto_tree_add_item(addr_tree, hf_pim_addr_af, tvb, offset, 1, ENC_NA);
1006 proto_tree_add_item(addr_tree, hf_pim_addr_et, tvb, offset+1, 1, ENC_NA);
1007 proto_tree_add_bitmask(addr_tree, tvb, offset+2, hf_pim_source_addr_flags,
1008 ett_pim_addr_flags, pim_source_addr_flags, ENC_BIG_ENDIAN);
1009 proto_tree_add_item(addr_tree, hf_pim_mask_len, tvb, offset+3, 1, ENC_NA);
1010 switch (af) {
1011 case AFNUM_INET:
1012 proto_tree_add_item(addr_tree, hf_pim_source_ip4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
1013 break;
1014 case AFNUM_INET6:
1015 proto_tree_add_item(addr_tree, hf_pim_source_ip6, tvb, offset+4, 16, ENC_NA);
1016 break;
1019 if (et == PIM_ADDR_ET_NATIVE_JA) {
1020 ja_offset = offset + 4 + len;
1021 while (((ja_eos_type & 0x40) != 0x40) && (tvb_reported_length_remaining(tvb, ja_offset) >= 2)) {
1022 ja_length = tvb_get_uint8(tvb, ja_offset+1);
1023 ti = proto_tree_add_item(addr_tree, hf_pim_source_join_attribute, tvb, ja_offset, ja_length + 2, ENC_NA);
1024 ja_tree = proto_item_add_subtree(ti, ett_pim);
1025 ja_eos_type = tvb_get_uint8(tvb, ja_offset);
1026 proto_tree_add_bitmask(ja_tree, tvb, ja_offset, hf_pim_source_ja_flags,
1027 ett_pim_addr_flags, pim_source_ja_flags, ENC_BIG_ENDIAN);
1028 proto_item_append_text(ti, ": %s", val_to_str_const(ja_eos_type & 0x3F, pim_join_attribute_type_vals, "Unknown"));
1029 ja_offset += 1;
1030 proto_tree_add_item(ja_tree, hf_pim_source_ja_length, tvb, ja_offset, 1, ENC_BIG_ENDIAN);
1031 ja_offset += 1;
1032 switch(ja_eos_type & 0x3F) {
1033 case PIM_JOIN_ATTRIBUTE_TYPE_RPF:
1034 if ((ja_length == 6) || (ja_length == 18)) {
1035 int advance_attr;
1036 // We recurse here, but we'll run out of packet before we run out of stack.
1037 if (!dissect_pim_addr(pinfo, ja_tree, tvb, ja_offset, pimv2_unicast, NULL, NULL,
1038 hf_pim_unicast_addr_ipv4, hf_pim_unicast_addr_ipv6, &advance_attr))
1039 break;
1040 } else {
1041 proto_tree_add_item(ja_tree, hf_pim_source_ja_value, tvb, ja_offset, ja_length, ENC_NA);
1043 break;
1044 case PIM_JOIN_ATTRIBUTE_TYPE_RLOC:
1045 ja_af = tvb_get_uint8(tvb, offset);
1046 switch(ja_af) {
1047 case AFNUM_INET:
1048 rloc_tree = proto_tree_add_ipv4_format(ja_tree, hf_ip4, tvb, ja_offset, ja_length,
1049 ipv4, "RLOC: %s", tvb_ip_to_str(pinfo->pool, tvb, ja_offset+ 1));
1050 rloc_sub_tree = proto_item_add_subtree(rloc_tree, ett_pim);
1051 proto_tree_add_item(rloc_sub_tree, hf_pim_addr_af, tvb, ja_offset, 1, ENC_NA);
1052 proto_tree_add_item(rloc_sub_tree, hf_pim_rloc_addr_ipv4, tvb, ja_offset + 1, 4, ENC_BIG_ENDIAN);
1053 break;
1054 case AFNUM_INET6:
1055 rloc_tree = proto_tree_add_ipv6_format(ja_tree, hf_ip6, tvb, ja_offset, ja_length,
1056 &ipv6, "RLOC: %s", tvb_ip_to_str(pinfo->pool, tvb, ja_offset+ 1));
1057 rloc_sub_tree = proto_item_add_subtree(rloc_tree, ett_pim);
1058 proto_tree_add_item(rloc_sub_tree, hf_pim_addr_af, tvb, ja_offset, 1, ENC_NA);
1059 proto_tree_add_item(rloc_sub_tree, hf_pim_rloc_addr_ipv6, tvb, ja_offset + 1, 16, ENC_NA);
1060 break;
1062 break;
1063 default:
1064 proto_tree_add_item(ja_tree, hf_pim_source_ja_value, tvb, ja_offset, ja_length, ENC_NA);
1066 ja_offset += ja_length;
1067 ja_length_sum += (2 + (int)ja_length);
1070 *advance = 4 + len + ja_length_sum;
1072 break;
1073 default:
1074 return false;
1077 if (ret_item != NULL)
1078 *ret_item = ti;
1080 return true;
1085 * For PIM v2, see RFC 4601, RFC 3973 and draft-ietf-pim-sm-v2-new-03
1086 * (when PIM is run over IPv6, the rules for computing the PIM checksum
1087 * from the draft in question, not from RFC 2362, should be used).
1089 static int
1090 dissect_pim(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
1091 int offset = 0;
1092 uint8_t pim_typever;
1093 uint8_t pim_subtype;
1094 uint8_t pim_bidir_subtype = 0;
1095 unsigned length, pim_length;
1096 vec_t cksum_vec[4];
1097 uint32_t phdr[2];
1098 const char *typestr;
1099 proto_tree *pim_tree = NULL;
1100 proto_item *ti;
1101 proto_tree *pimopt_tree = NULL;
1102 proto_item *tiopt;
1104 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PIM");
1105 col_clear(pinfo->cinfo, COL_INFO);
1107 pim_typever = tvb_get_uint8(tvb, 0);
1108 pim_subtype = PIM_SUBTYPE(tvb_get_uint8(tvb, 1));
1110 switch (PIM_VER(pim_typever)) {
1111 case 2:
1112 if (PIM_TYPE(pim_typever) < 12) {
1113 typestr = val_to_str(PIM_TYPE(pim_typever), pimtypevals, "Unknown (%u)");
1114 } else if ((PIM_TYPE(pim_typever) == PIM_TYPE_PACKED_REGISTER)) {
1116 * Need only the first 4 bits for subtype as per the new PIM Common header.
1118 typestr = val_to_str(pim_subtype, pimtype13subtypevals, "Unknown (%u)");
1119 } else {
1120 typestr = "Unknown";
1122 break;
1123 case 1: /* PIMv1 - we should never see this */
1124 default:
1125 typestr = "Unknown";
1126 break;
1129 col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "PIMv%d",
1130 PIM_VER(pim_typever));
1131 col_add_str(pinfo->cinfo, COL_INFO, typestr);
1133 ti = proto_tree_add_item(tree, proto_pim, tvb, offset, -1, ENC_NA);
1134 pim_tree = proto_item_add_subtree(ti, ett_pim);
1136 proto_tree_add_item(pim_tree, hf_pim_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1137 proto_tree_add_item(pim_tree, hf_pim_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1138 if (PIM_TYPE(pim_typever) == PIM_TYPE_PFM) {
1139 proto_tree_add_item(pim_tree, hf_pfm_no_forward_bit, tvb, offset+1, 1, ENC_BIG_ENDIAN);
1141 if (PIM_TYPE(pim_typever) == PIM_TYPE_REGISTER_STOP) {
1143 * [version-4bits][type-4bits][0x01]
1145 proto_tree_add_item(pim_tree, hf_pim_reg_stop_p_bit, tvb, offset+1, 1, ENC_BIG_ENDIAN);
1147 if (PIM_TYPE(pim_typever) == PIM_TYPE_DF_ELECT) {
1148 proto_tree_add_item(pim_tree, hf_pim_df_elect_subtype, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
1149 proto_tree_add_item(pim_tree, hf_pim_df_elect_rsvd, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
1150 pim_bidir_subtype = tvb_get_uint8(tvb,offset);
1151 } else if ((PIM_TYPE(pim_typever) == PIM_TYPE_PACKED_REGISTER)) {
1153 * [version-4bits][type-4bits][0x[SubType-4bits][Flagbits-4bits]
1155 proto_tree_add_item(pim_tree, hf_pim_type_13_subtype, tvb, offset+1, 1, ENC_BIG_ENDIAN);
1156 proto_tree_add_item(pim_tree, hf_pim_type_13_flagbits, tvb, offset+1, 1, ENC_BIG_ENDIAN);
1157 } else {
1158 proto_tree_add_item(pim_tree, hf_pim_res_bytes, tvb, offset + 1, 1, ENC_NA);
1161 if (PIM_VER(pim_typever) != 2) {
1162 proto_tree_add_checksum(pim_tree, tvb, offset+2, hf_pim_cksum, hf_pim_cksum_status, &ei_pim_cksum,
1163 pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
1165 * We don't know this version, so we don't know how much of the
1166 * packet the checksum covers.
1168 if (tvb_reported_length_remaining(tvb, offset) > 0) {
1169 proto_tree_add_item(pim_tree, hf_pim_option, tvb, offset, -1, ENC_NA);
1171 goto done;
1175 * Well, it's PIM v2, so we can check whether this is a Register
1176 * message, and thus can figure out how much to checksum and
1177 * whether to make the columns read-only.
1179 length = tvb_reported_length(tvb);
1180 if (PIM_TYPE(pim_typever) == 1) {
1182 * Register message - the PIM header is 8 bytes long.
1183 * Also set the columns non-writable. Otherwise the IPv4 or
1184 * IPv6 dissector for the encapsulated packet that caused
1185 * this register will overwrite the PIM info in the columns.
1187 pim_length = 8;
1188 col_set_writable(pinfo->cinfo, -1, false);
1189 } else {
1191 * Other message - checksum the entire packet.
1193 pim_length = length;
1195 if (!pinfo->fragmented && length >= pim_length &&
1196 tvb_captured_length(tvb) >= pim_length) {
1198 * The packet isn't part of a fragmented datagram and isn't
1199 * truncated, so we can checksum it.
1202 switch (pinfo->src.type) {
1203 case AT_IPv4:
1204 SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, pim_length);
1205 proto_tree_add_checksum(pim_tree, tvb, offset+2, hf_pim_cksum, hf_pim_cksum_status, &ei_pim_cksum,
1206 pinfo, in_cksum(&cksum_vec[0], 1), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
1207 break;
1208 case AT_IPv6:
1209 /* Set up the fields of the pseudo-header. */
1210 SET_CKSUM_VEC_PTR(cksum_vec[0], (const uint8_t *)pinfo->src.data, pinfo->src.len);
1211 SET_CKSUM_VEC_PTR(cksum_vec[1], (const uint8_t *)pinfo->dst.data, pinfo->dst.len);
1212 phdr[0] = g_htonl(pim_length);
1213 phdr[1] = g_htonl(IP_PROTO_PIM);
1214 SET_CKSUM_VEC_PTR(cksum_vec[2], (const uint8_t *)&phdr, 8);
1215 SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, pim_length);
1216 proto_tree_add_checksum(pim_tree, tvb, offset+2, hf_pim_cksum, hf_pim_cksum_status, &ei_pim_cksum,
1217 pinfo, in_cksum(&cksum_vec[0], 4), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
1218 break;
1219 default:
1220 /* PIM is available for IPv4 and IPv6 right now */
1221 DISSECTOR_ASSERT_NOT_REACHED();
1222 break;
1224 } else {
1225 proto_tree_add_checksum(pim_tree, tvb, offset+2, hf_pim_cksum, hf_pim_cksum_status, &ei_pim_cksum,
1226 pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
1228 offset += 4;
1230 if (tvb_reported_length_remaining(tvb, offset) > 0) {
1231 tiopt = proto_tree_add_item(pim_tree, hf_pim_option, tvb, offset, -1, ENC_NA);
1232 pimopt_tree = proto_item_add_subtree(tiopt, ett_pim_opts);
1233 } else
1234 goto done;
1236 /* version 2 decoder */
1237 switch (PIM_TYPE(pim_typever)) {
1238 case PIM_TYPE_HELLO: /*hello*/
1240 int opt_count = 0;
1242 while (tvb_reported_length_remaining(tvb, offset) >= 2) {
1243 uint16_t hello_opt, opt_len;
1244 uint32_t holdtime;
1245 const char* hold_str;
1246 proto_item *opt_item;
1247 proto_tree *opt_tree;
1249 opt_count++;
1250 hello_opt = tvb_get_ntohs(tvb, offset);
1251 opt_len = tvb_get_ntohs(tvb, offset + 2);
1252 opt_tree = proto_tree_add_subtree_format(pimopt_tree, tvb, offset, 4 + opt_len,
1253 ett_pim_opt, &opt_item, "Option %u: %s", hello_opt,
1254 val_to_str(hello_opt, pim_opt_vals, "Unknown: %u"));
1255 proto_tree_add_item(opt_tree, hf_pim_optiontype, tvb, offset, 2, ENC_BIG_ENDIAN);
1256 proto_tree_add_item(opt_tree, hf_pim_optionlength, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
1258 switch(hello_opt) {
1259 case PIM_HELLO_HOLD_T: /* Hello Hold Time Option */
1261 proto_tree_add_item_ret_uint(opt_tree, hf_pim_holdtime_t, tvb,
1262 offset+4, 2, ENC_BIG_ENDIAN, &holdtime);
1263 proto_item_append_text(opt_item, ": %u", holdtime);
1264 hold_str = try_val_to_str(holdtime, unique_infinity_t);
1265 if (hold_str != NULL)
1266 proto_item_append_text(opt_item, " (%s)", hold_str);
1268 break;
1270 case PIM_HELLO_LAN_PRUNE_DELAY: /* LAN Prune Delay Option */
1271 proto_tree_add_item(opt_tree, hf_pim_t, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
1272 proto_tree_add_item(opt_tree, hf_pim_propagation_delay, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
1273 proto_tree_add_item(opt_tree, hf_pim_override_interval, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
1274 proto_item_append_text(opt_item,
1275 ": T = %u, Propagation Delay = %ums, Override Interval = %ums",
1276 tvb_get_uint8(tvb, offset + 4) & 0x80 ? 1 : 0,
1277 tvb_get_ntohs(tvb, offset + 4) & 0x7fff,
1278 tvb_get_ntohs(tvb, offset + 6));
1279 break;
1281 case PIM_HELLO_DR_PRIORITY: /* DR priority */
1282 proto_tree_add_item(opt_tree, hf_pim_dr_priority, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
1283 proto_item_append_text(opt_item, ": %u", tvb_get_ntohl(tvb, offset + 4));
1284 break;
1286 case PIM_HELLO_GEN_ID: /* Generation ID */
1287 proto_tree_add_item(opt_tree, hf_pim_generation_id, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
1288 proto_item_append_text(opt_item, ": %u", tvb_get_ntohl(tvb, offset + 4));
1289 break;
1291 case PIM_HELLO_STATE_REFRESH: /* State Refresh Capable Option */
1292 proto_tree_add_item(opt_tree, hf_pim_state_refresh_version, tvb, offset + 4, 1, ENC_BIG_ENDIAN);
1293 proto_tree_add_item(opt_tree, hf_pim_state_refresh_interval, tvb, offset + 5, 1, ENC_BIG_ENDIAN);
1294 proto_tree_add_item(opt_tree, hf_pim_state_refresh_reserved, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
1295 proto_item_append_text(opt_item, ": Version = %u, Interval = %us",
1296 tvb_get_uint8(tvb, offset + 4),
1297 tvb_get_uint8(tvb, offset + 5));
1298 break;
1300 case PIM_HELLO_VAR_ADDR_LST: /* address list */
1301 case PIM_HELLO_ADDR_LST: /* address list (old implementations) */
1303 int i;
1304 proto_tree *sub_tree = NULL;
1306 sub_tree = proto_tree_add_subtree_format(opt_tree, tvb, offset, 4 + opt_len,
1307 ett_pim_opt, NULL, "%sAddress List (%u)",
1308 hello_opt == 65001 ? "old " : "",
1309 hello_opt);
1310 for (i = offset + 4; i < offset + 4 + opt_len; ) {
1311 int advance;
1312 if (!dissect_pim_addr(pinfo, sub_tree, tvb, i, pimv2_unicast, NULL, NULL,
1313 hf_pim_address_list_ip4, hf_pim_address_list_ip6, &advance))
1314 break;
1315 i += advance;
1317 break;
1320 default:
1321 if (opt_len)
1322 proto_tree_add_item(opt_tree, hf_pim_optionvalue, tvb,
1323 offset + 4, opt_len, ENC_NA);
1324 break;
1326 offset += 4 + opt_len;
1328 proto_item_append_text(tiopt, ": %u", opt_count);
1329 break;
1332 case PIM_TYPE_REGISTER: /* register */
1334 uint8_t v_hl;
1335 tvbuff_t *next_tvb;
1336 proto_tree *flag_tree;
1337 proto_item *tiflag;
1339 tiflag = proto_tree_add_item(pimopt_tree, hf_pim_register_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
1340 flag_tree = proto_item_add_subtree(tiflag, ett_pim);
1341 proto_tree_add_item(flag_tree, hf_pim_register_flag_border, tvb, offset, 4, ENC_BIG_ENDIAN);
1342 proto_tree_add_item(flag_tree, hf_pim_register_flag_null_register, tvb, offset, 4, ENC_BIG_ENDIAN);
1343 offset += 4;
1346 * The rest of the packet is a multicast data packet.
1348 next_tvb = tvb_new_subset_remaining(tvb, offset);
1351 * It's an IP packet - determine whether it's IPv4 or IPv6.
1353 v_hl = tvb_get_uint8(tvb, offset);
1354 proto_tree_add_item(pimopt_tree, hf_pim_ip_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1356 switch((v_hl & 0xf0) >> 4) {
1357 case 0: /* Null-Register dummy header.
1358 * Has the same address family as the encapsulating PIM packet,
1359 * e.g. an IPv6 data packet is encapsulated in IPv6 PIM packet.
1361 ti = proto_tree_add_item(pimopt_tree, hf_pim_dummy_header, tvb, offset, -1, ENC_NA);
1362 if (pinfo->src.type == AT_IPv4) {
1363 proto_item_append_text(ti, "IPv4");
1364 proto_tree_add_item(pimopt_tree, hf_pim_source_ip4, tvb, offset + 12, 4, ENC_BIG_ENDIAN);
1365 proto_tree_add_item(pimopt_tree, hf_pim_group_ip4, tvb, offset + 16, 4, ENC_BIG_ENDIAN);
1366 } else if (pinfo->src.type == AT_IPv6) {
1367 proto_item_append_text(ti, "IPv6");
1368 proto_tree_add_item(pimopt_tree, hf_pim_source_ip6, tvb, offset + 8, 16, ENC_NA);
1369 proto_tree_add_item(pimopt_tree, hf_pim_group_ip6, tvb, offset + 8 + 16, 16, ENC_NA);
1370 } else
1371 proto_item_append_text(ti, "for an unknown protocol");
1372 break;
1373 case 4: /* IPv4 */
1374 if (use_main_tree) {
1375 call_dissector(ip_handle, next_tvb, pinfo, tree);
1376 } else {
1377 call_dissector(ip_handle, next_tvb, pinfo, pimopt_tree);
1379 break;
1380 case 6: /* IPv6 */
1381 if (use_main_tree) {
1382 call_dissector(ipv6_handle, next_tvb, pinfo, tree);
1383 } else {
1384 call_dissector(ipv6_handle, next_tvb, pinfo, pimopt_tree);
1386 break;
1387 default:
1388 break;
1390 break;
1393 case PIM_TYPE_REGISTER_STOP: /* register-stop */
1395 int advance;
1397 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_group, NULL, NULL,
1398 hf_pim_group_ip4, hf_pim_group_ip6, &advance))
1399 break;
1400 offset += advance;
1401 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast, NULL, NULL,
1402 hf_pim_source_ip4, hf_pim_source_ip6, &advance))
1403 break;
1404 break;
1407 case PIM_TYPE_JOIN_PRUNE: /* join/prune */
1408 case PIM_TYPE_GRAFT: /* graft */
1409 case PIM_TYPE_GRAFT_ACK: /* graft-ack */
1411 int advance;
1412 int off;
1413 int ngroup, i, njoin, nprune, j;
1414 proto_tree *grouptree = NULL;
1415 proto_item *tigroup;
1416 proto_tree *subtree = NULL;
1417 proto_item *tisub;
1419 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast, NULL, NULL,
1420 hf_pim_upstream_neighbor_ip4, hf_pim_upstream_neighbor_ip6, &advance))
1421 break;
1423 offset += advance;
1425 /* reserved field */
1426 proto_tree_add_item(pimopt_tree, hf_pim_res_bytes, tvb, offset, 1, ENC_NA);
1427 offset += 1;
1429 ngroup = tvb_get_uint8(tvb, offset);
1430 proto_tree_add_item(pimopt_tree, hf_pim_numgroups, tvb, offset, 1, ENC_BIG_ENDIAN);
1431 offset += 1;
1433 proto_tree_add_item(pimopt_tree, hf_pim_holdtime, tvb, offset, 2, ENC_BIG_ENDIAN);
1434 offset += 2;
1436 for (i = 0; i < ngroup; i++) {
1437 tigroup=proto_tree_add_string_format(pimopt_tree, hf_pim_group, tvb, offset, -1, "", "Group %d", i);
1438 grouptree = proto_item_add_subtree(tigroup, ett_pim);
1439 if (!dissect_pim_addr(pinfo, grouptree, tvb, offset, pimv2_group,
1440 wmem_strdup_printf(pinfo->pool, "Group %d", i), NULL,
1441 hf_pim_group_ip4, hf_pim_group_ip6, &advance))
1442 goto breakbreak3;
1444 offset += advance;
1446 njoin = tvb_get_ntohs(tvb, offset);
1447 nprune = tvb_get_ntohs(tvb, offset + 2);
1448 tisub = proto_tree_add_item(grouptree, hf_pim_numjoins, tvb,
1449 offset, 2, ENC_BIG_ENDIAN);
1450 subtree = proto_item_add_subtree(tisub, ett_pim);
1451 off = offset + 4;
1452 for (j = 0; j < njoin; j++) {
1453 if (!dissect_pim_addr(pinfo, subtree, tvb, off, pimv2_source, NULL, NULL,
1454 hf_pim_join_ip4, hf_pim_join_ip6, &advance))
1455 goto breakbreak3;
1457 off += advance;
1460 tisub = proto_tree_add_item(grouptree, hf_pim_numprunes, tvb,
1461 offset + 2, 2, ENC_BIG_ENDIAN);
1462 subtree = proto_item_add_subtree(tisub, ett_pim);
1463 for (j = 0; j < nprune; j++) {
1464 if (!dissect_pim_addr(pinfo, subtree, tvb, off, pimv2_source, NULL, NULL,
1465 hf_pim_prune_ip4, hf_pim_prune_ip6, &advance))
1466 goto breakbreak3;
1468 off += advance;
1470 offset = off;
1472 breakbreak3:
1473 break;
1476 case PIM_TYPE_BOOTSTRAP: /* bootstrap */
1478 int advance;
1479 int i, j;
1480 int frpcnt;
1481 proto_tree *grouptree = NULL;
1482 proto_item *tigroup;
1484 proto_tree_add_item(pimopt_tree, hf_pim_fragment_tag, tvb,
1485 offset, 2, ENC_BIG_ENDIAN);
1486 offset += 2;
1488 proto_tree_add_item(pimopt_tree, hf_pim_hash_mask_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1489 offset += 1;
1490 proto_tree_add_item(pimopt_tree, hf_pim_bsr_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
1491 offset += 1;
1493 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast, NULL, NULL,
1494 hf_pim_bsr_ip4, hf_pim_bsr_ip6, &advance))
1495 break;
1496 offset += advance;
1498 for (i = 0; tvb_reported_length_remaining(tvb, offset) > 0; i++) {
1499 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_group,
1500 wmem_strdup_printf(pinfo->pool, "Group %d", i), &tigroup,
1501 hf_pim_group_ip4, hf_pim_group_ip6, &advance))
1502 goto breakbreak4;
1504 grouptree = proto_item_add_subtree(tigroup, ett_pim);
1505 offset += advance;
1507 proto_tree_add_item(grouptree, hf_pim_rp_count, tvb, offset, 1, ENC_BIG_ENDIAN);
1508 offset += 1;
1509 frpcnt = tvb_get_uint8(tvb, offset);
1510 proto_tree_add_item(grouptree, hf_pim_frp_count, tvb, offset, 1, ENC_BIG_ENDIAN);
1511 offset += 3;
1513 for (j = 0; j < frpcnt; j++) {
1514 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast,
1515 wmem_strdup_printf(pinfo->pool, "RP %d", j), NULL,
1516 hf_pim_rp_ip4, hf_pim_rp_ip6, &advance))
1518 goto breakbreak4;
1519 offset += advance;
1521 proto_tree_add_item(pimopt_tree, hf_pim_holdtime, tvb, offset, 2, ENC_BIG_ENDIAN);
1522 offset += 2;
1523 proto_tree_add_item(grouptree, hf_pim_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
1524 offset += 1;
1526 /* reserved stuff */
1527 proto_tree_add_item(pim_tree, hf_pim_res_bytes, tvb, offset, 1, ENC_NA);
1528 offset += 1;
1532 breakbreak4:
1533 break;
1536 case PIM_TYPE_ASSERT: /* assert */
1538 int advance;
1540 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_group,
1541 NULL, NULL,
1542 hf_pim_group_ip4, hf_pim_group_ip6, &advance))
1543 break;
1544 offset += advance;
1546 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast,
1547 NULL, NULL,
1548 hf_pim_source_ip4, hf_pim_source_ip6, &advance))
1549 break;
1550 offset += advance;
1552 proto_tree_add_item(pimopt_tree, hf_pim_rpt, tvb, offset, 1, ENC_BIG_ENDIAN);
1553 proto_tree_add_item(pimopt_tree, hf_pim_metric_pref, tvb,
1554 offset, 4, ENC_BIG_ENDIAN);
1555 offset += 4;
1557 proto_tree_add_item(pimopt_tree, hf_pim_metric, tvb, offset, 4, ENC_BIG_ENDIAN);
1558 /* offset += 4;*/
1559 break;
1562 case PIM_TYPE_CAND_RP_ADV: /* Candidate-RP-Advertisement */
1564 int advance;
1565 int pfxcnt;
1566 int i;
1568 pfxcnt = tvb_get_uint8(tvb, offset);
1569 proto_tree_add_item(pimopt_tree, hf_pim_prefix_count, tvb, offset, 1, ENC_BIG_ENDIAN);
1570 offset += 1;
1571 proto_tree_add_item(pimopt_tree, hf_pim_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
1572 offset += 1;
1574 proto_tree_add_item(pimopt_tree, hf_pim_holdtime, tvb, offset, 2, ENC_BIG_ENDIAN);
1575 offset += 2;
1577 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast,
1578 NULL, NULL,
1579 hf_pim_rp_ip4, hf_pim_rp_ip6, &advance))
1580 break;
1581 offset += advance;
1583 for (i = 0; i < pfxcnt; i++) {
1584 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_group,
1585 wmem_strdup_printf(pinfo->pool, "Group %d", i), NULL,
1586 hf_pim_group_ip4, hf_pim_group_ip6, &advance))
1587 goto breakbreak8;
1588 offset += advance;
1590 breakbreak8:
1591 break;
1594 case PIM_TYPE_STATE_REFRESH: /* State-Refresh */
1596 int advance;
1598 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_group,
1599 NULL, NULL,
1600 hf_pim_group_ip4, hf_pim_group_ip6, &advance))
1601 break;
1602 offset += advance;
1604 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast,
1605 NULL, NULL,
1606 hf_pim_source_ip4, hf_pim_source_ip6, &advance))
1607 break;
1608 offset += advance;
1610 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast,
1611 NULL, NULL,
1612 hf_pim_originator_ip4, hf_pim_originator_ip6, &advance))
1613 break;
1614 offset += advance;
1616 proto_tree_add_item(pimopt_tree, hf_pim_rpt, tvb, offset, 1, ENC_BIG_ENDIAN);
1617 proto_tree_add_item(pimopt_tree, hf_pim_metric_pref, tvb,
1618 offset, 4, ENC_BIG_ENDIAN);
1619 offset += 4;
1621 proto_tree_add_item(pimopt_tree, hf_pim_metric, tvb, offset, 4, ENC_BIG_ENDIAN);
1622 offset += 4;
1624 proto_tree_add_item(pimopt_tree, hf_pim_mask_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1625 offset += 1;
1627 proto_tree_add_item(pimopt_tree, hf_pim_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
1628 offset += 1;
1630 proto_tree_add_item(pimopt_tree, hf_pim_prune_indicator, tvb, offset, 1, ENC_BIG_ENDIAN);
1631 proto_tree_add_item(pimopt_tree, hf_pim_prune_now, tvb, offset, 1, ENC_BIG_ENDIAN);
1632 proto_tree_add_item(pimopt_tree, hf_pim_assert_override, tvb, offset, 1, ENC_BIG_ENDIAN);
1633 offset += 1;
1635 proto_tree_add_item(pimopt_tree, hf_pim_interval, tvb, offset, 1, ENC_BIG_ENDIAN);
1636 /*offset += 1;*/
1638 break;
1641 case PIM_TYPE_DF_ELECT:
1643 int advance;
1645 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast,
1646 NULL, NULL,
1647 hf_pim_rp_ip4, hf_pim_rp_ip6, &advance))
1648 break;
1649 offset += advance;
1650 proto_tree_add_item(pimopt_tree, hf_pim_df_metric_pref, tvb,
1651 offset, 4, ENC_BIG_ENDIAN);
1652 offset += 4;
1653 proto_tree_add_item(pimopt_tree, hf_pim_metric, tvb, offset, 4, ENC_BIG_ENDIAN);
1654 offset += 4;
1656 switch(PIM_BIDIR_SUBTYPE(pim_bidir_subtype)) {
1657 case PIM_BDIR_DF_BACKOFF :
1658 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast,
1659 NULL, NULL,
1660 hf_pim_bd_bo_offer_ip4, hf_pim_bd_bo_offer_ip6, &advance))
1661 break;
1662 offset += advance;
1663 proto_tree_add_item(pimopt_tree, hf_pim_bd_offer_metric_pref, tvb, offset, 4, ENC_BIG_ENDIAN);
1664 offset += 4;
1665 proto_tree_add_item(pimopt_tree, hf_pim_bd_offer_metric, tvb, offset, 4, ENC_BIG_ENDIAN);
1666 offset += 4;
1667 proto_tree_add_item(pimopt_tree, hf_pim_bd_offer_interval, tvb, offset, 2, ENC_BIG_ENDIAN);
1668 break;
1669 case PIM_BDIR_DF_PASS:
1670 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast,
1671 NULL, NULL,
1672 hf_pim_bd_pass_ip4, hf_pim_bd_pass_ip6, &advance))
1673 break;
1674 offset += advance;
1675 proto_tree_add_item(pimopt_tree, hf_pim_bd_pass_metric_pref, tvb, offset, 4, ENC_BIG_ENDIAN);
1676 offset += 4;
1677 proto_tree_add_item(pimopt_tree, hf_pim_bd_pass_metric, tvb, offset, 4, ENC_BIG_ENDIAN);
1678 break;
1680 break;
1683 case PIM_TYPE_PFM: /*pfm*/
1685 int opt_count = 0;
1686 int advance;
1688 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast, NULL, NULL,
1689 hf_pim_originator_ip4, hf_pim_originator_ip6, &advance))
1690 break;
1691 offset += advance;
1692 while (tvb_reported_length_remaining(tvb, offset) >= 2) {
1693 uint16_t pfm, pfm_opt, opt_len;
1694 proto_item *opt_item;
1695 proto_tree *opt_tree;
1697 opt_count++;
1698 pfm = tvb_get_ntohs(tvb, offset);
1699 opt_len = tvb_get_ntohs(tvb, offset + 2);
1700 pfm_opt = pfm & 0x7FFF;
1701 opt_tree = proto_tree_add_subtree_format(pimopt_tree, tvb, offset, 4 + opt_len,
1702 ett_pim_opt, &opt_item, "Option %u: %s", pfm_opt,
1703 val_to_str(pfm_opt, pim_opt_vals1, "Unknown: %u"));
1704 proto_tree_add_item(opt_tree, hf_pim_transitivetype, tvb, offset, 1, ENC_BIG_ENDIAN);
1705 proto_tree_add_item(opt_tree, hf_pim_optiontype1, tvb, offset, 2, ENC_BIG_ENDIAN);
1706 proto_tree_add_item(opt_tree, hf_pim_optionlength, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
1707 offset += 4;
1708 switch(pfm_opt){
1709 case PIM_PFM_GROUP_SOURCE:
1711 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_group, NULL, NULL,
1712 hf_pim_group_ip4, hf_pim_group_ip6, &advance))
1713 break;
1714 offset += advance;
1715 uint16_t src_count;
1716 src_count=tvb_get_ntohs(tvb, offset);
1717 proto_tree_add_item(pimopt_tree, hf_pim_srcount, tvb, offset, 2, ENC_BIG_ENDIAN);
1718 offset += 2;
1719 proto_tree_add_item(pimopt_tree, hf_pim_srcholdt, tvb, offset, 2, ENC_BIG_ENDIAN);
1720 offset += 2;
1721 while(src_count>0){
1722 if (!dissect_pim_addr(pinfo, pimopt_tree, tvb, offset, pimv2_unicast, NULL, NULL,
1723 hf_pim_source_ip4, hf_pim_source_ip6, &advance))
1724 goto breakbreak12;
1725 offset+=advance;
1726 src_count--;
1728 break;
1730 default:
1731 if (opt_len)
1732 proto_tree_add_item(opt_tree, hf_pim_optionvalue, tvb,
1733 offset, opt_len, ENC_NA);
1734 offset += opt_len;
1735 break;
1738 proto_item_append_text(tiopt, ": %u", opt_count);
1739 breakbreak12:
1740 break;
1743 case PIM_TYPE_PACKED_REGISTER: /* Packed Register */
1745 int ngroups;
1746 int advance, i;
1747 proto_tree *grouptree = NULL;
1748 proto_item *tigroup;
1750 switch (pim_subtype) {
1751 case PIM_TYPE_PACKED_NULL_REGISTER:
1752 case PIM_TYPE_PACKED_REGISTER_STOP:
1754 * Total length minus PIM header length
1755 * divided by 1 encoded record size (14 bytes).
1757 ngroups = (length-4)/14;
1758 for (i = 0; i < ngroups; i++) {
1760 * RFC9465 states that an (S,G) entry is called a "Record".
1762 tigroup=proto_tree_add_string_format(pimopt_tree, hf_pim_group, tvb, offset, -1, "", "Record %d", i+1);
1763 grouptree = proto_item_add_subtree(tigroup, ett_pim);
1764 if (!dissect_pim_addr(pinfo, grouptree, tvb, offset, pimv2_group,
1765 wmem_strdup_printf(pinfo->pool, "Group"), NULL,
1766 hf_pim_group_ip4, hf_pim_group_ip6, &advance))
1767 goto breakpackedreg;
1768 offset += advance;
1769 if (!dissect_pim_addr(pinfo, grouptree, tvb, offset, pimv2_unicast, NULL, NULL,
1770 hf_pim_source_ip4, hf_pim_source_ip6, &advance))
1771 goto breakpackedreg;
1772 offset += advance;
1774 break;
1775 default:
1776 break;
1778 breakpackedreg:
1779 break;
1782 default:
1783 break;
1785 done:
1786 return tvb_captured_length(tvb);
1789 void
1790 proto_register_pim(void)
1792 static hf_register_info hf[] =
1794 { &hf_pim_version,
1795 { "Version", "pim.version",
1796 FT_UINT8, BASE_DEC, NULL, 0xf0,
1797 NULL, HFILL }
1799 { &hf_pim_type,
1800 { "Type", "pim.type",
1801 FT_UINT8, BASE_DEC, VALS(pimtypevals), 0x0f,
1802 NULL, HFILL }
1804 { &hf_pim_df_elect_subtype,
1805 { "DF Subtype", "pim.df_elect.subtype",
1806 FT_UINT8, BASE_DEC, VALS(pimbdirdfvals), 0xf0,
1807 NULL, HFILL}
1809 { &hf_pim_df_elect_rsvd,
1810 { "DF reserved", "pim.df_elect.rsvd",
1811 FT_UINT8, BASE_DEC, NULL, 0x0f,
1812 NULL, HFILL}
1814 { &hf_pim_igmp_type,
1815 { "Type", "pim.igmp_type",
1816 FT_STRING, BASE_NONE, NULL, 0x0,
1817 NULL, HFILL }
1819 { &hf_pim_code,
1820 { "Code", "pim.code",
1821 FT_UINT8, BASE_DEC, VALS(pim_type1_vals), 0x0,
1822 NULL, HFILL }
1824 { &hf_pim_cksum,
1825 { "Checksum", "pim.cksum",
1826 FT_UINT16, BASE_HEX, NULL, 0x0,
1827 NULL, HFILL }
1829 { &hf_pim_cksum_status,
1830 { "Checksum Status", "pim.cksum.status",
1831 FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
1832 NULL, HFILL }
1834 { &hf_pim_res_bytes,
1835 { "Reserved byte(s)", "pim.res_bytes",
1836 FT_BYTES, BASE_NONE, NULL, 0x0,
1837 NULL, HFILL }
1839 { &hf_pim_type_13_subtype,
1840 { "Subtype", "pim.subtype_type13",
1841 FT_UINT8, BASE_DEC, VALS(pimtype13subtypevals), 0xf0,
1842 NULL, HFILL }
1844 { &hf_pim_type_13_flagbits,
1845 { "Flag Bits", "pim.flag_bits_type13",
1846 FT_UINT8, BASE_DEC, NULL, 0x0f,
1847 NULL, HFILL }
1850 { &hf_pim_option,
1851 { "PIM Options", "pim.option",
1852 FT_NONE, BASE_NONE, NULL, 0x0,
1853 NULL, HFILL }
1855 { &hf_pim_optiontype,
1856 { "Type", "pim.optiontype",
1857 FT_UINT16, BASE_DEC, NULL, 0x0,
1858 NULL, HFILL }
1860 { &hf_pim_optiontype1,
1861 { "Type", "pim.optiontype",
1862 FT_UINT16, BASE_DEC, NULL, 0x7fff,
1863 NULL, HFILL }
1865 { &hf_pim_optionlength,
1866 { "Length", "pim.optionlength",
1867 FT_UINT16, BASE_DEC, NULL, 0x0,
1868 NULL, HFILL }
1870 { &hf_pim_optionvalue,
1871 { "Unknown", "pim.optionvalue",
1872 FT_BYTES, BASE_NONE, NULL, 0x0,
1873 NULL, HFILL }
1875 { &hf_pim_register_flag,
1876 { "Flags", "pim.register_flag",
1877 FT_UINT32, BASE_HEX, NULL, 0x0,
1878 NULL, HFILL }
1880 { &hf_pim_register_flag_border,
1881 { "Border", "pim.register_flag.border",
1882 FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x80000000,
1883 NULL, HFILL }
1885 { &hf_pim_register_flag_null_register,
1886 { "Null-Register", "pim.register_flag.null_register",
1887 FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x40000000,
1888 NULL, HFILL }
1890 { &hf_pim_mode,
1891 { "Mode", "pim.mode",
1892 FT_UINT8, BASE_DEC, VALS(pimv1_modevals), 0xf0,
1893 NULL, HFILL }
1895 { &hf_pim_holdtime,
1896 { "Holdtime", "pim.holdtime",
1897 FT_UINT16, BASE_DEC|BASE_SPECIAL_VALS, VALS(unique_infinity), 0x0,
1898 "The amount of time a receiver must keep the neighbor "
1899 "reachable, in seconds.", HFILL }
1901 { &hf_pim_holdtime_t,
1902 { "Holdtime", "pim.holdtime",
1903 FT_UINT16, BASE_DEC|BASE_SPECIAL_VALS, VALS(unique_infinity_t), 0x0,
1904 "The amount of time a receiver must keep the neighbor "
1905 "reachable, in seconds.", HFILL }
1907 { &hf_pim_numgroups,
1908 { "Num Groups", "pim.numgroups",
1909 FT_UINT16, BASE_DEC, NULL, 0x0,
1910 "Number of multicast group sets contained in the message.",
1911 HFILL }
1913 { &hf_pim_numjoins,
1914 { "Num Joins", "pim.numjoins",
1915 FT_UINT16, BASE_DEC, NULL, 0x0,
1916 "Number of joined sources.", HFILL }
1918 { &hf_pim_numprunes,
1919 { "Num Prunes", "pim.numprunes",
1920 FT_UINT16, BASE_DEC, NULL, 0x0,
1921 "Number of pruned sources.", HFILL }
1923 { &hf_pim_t,
1924 { "T", "pim.t",
1925 FT_BOOLEAN, 8, NULL, 0x80,
1926 "Specifies the ability of the sending router to disable joins "
1927 "suppression.", HFILL }
1929 { &hf_pim_propagation_delay,
1930 { "Propagation Delay", "pim.propagation_delay",
1931 FT_UINT16, BASE_DEC, NULL, 0x7fff,
1932 "Units are milli-seconds", HFILL }
1934 { &hf_pim_override_interval,
1935 { "Override Interval", "pim.override_interval",
1936 FT_UINT16, BASE_DEC, NULL, 0x0,
1937 "Units are milli-seconds", HFILL }
1939 { &hf_pim_dr_priority,
1940 { "DR Priority", "pim.dr_priority",
1941 FT_UINT32, BASE_DEC, NULL, 0x0,
1942 NULL, HFILL }
1944 { &hf_pim_generation_id,
1945 { "Generation ID", "pim.generation_id",
1946 FT_UINT32, BASE_DEC, NULL, 0x0,
1947 NULL, HFILL }
1949 { &hf_pim_state_refresh_version,
1950 { "Version", "pim.state_refresh_version",
1951 FT_UINT8, BASE_DEC, NULL, 0x0,
1952 NULL, HFILL }
1954 { &hf_pim_state_refresh_interval,
1955 { "Interval", "pim.state_refresh_interval",
1956 FT_UINT8, BASE_DEC, NULL, 0x0,
1957 "Units in seconds.", HFILL }
1959 { &hf_pim_state_refresh_reserved,
1960 { "Reserved", "pim.state_refresh_reserved",
1961 FT_UINT16, BASE_DEC, NULL, 0x0,
1962 NULL, HFILL }
1964 { &hf_pim_rpt,
1965 { "RP Tree", "pim.rpt",
1966 FT_BOOLEAN, 8, NULL, 0x80,
1967 "Set to 1 for assert(*,G) messages and 0 for assert(S,G) "
1968 "messages.", HFILL }
1970 { &hf_pim_metric_pref,
1971 { "Metric Preference", "pim.metric_pref",
1972 FT_UINT32, BASE_DEC, NULL, 0x7fffffff,
1973 NULL, HFILL }
1975 { &hf_pim_df_metric_pref,
1976 { "DF Metric Preference", "pim.metric_pref",
1977 FT_UINT32, BASE_DEC, NULL, 0,
1978 NULL, HFILL }
1980 { &hf_pim_metric,
1981 { "Metric", "pim.metric",
1982 FT_UINT32, BASE_DEC, NULL, 0x0,
1983 NULL, HFILL }
1985 { &hf_pim_prune_indicator,
1986 { "Prune indicator", "pim.prune_indicator",
1987 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x80,
1988 NULL, HFILL }
1990 { &hf_pim_prune_now,
1991 { "Prune now", "pim.prune_now",
1992 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40,
1993 NULL, HFILL }
1995 { &hf_pim_assert_override,
1996 { "Assert override", "pim.assert_override",
1997 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x20,
1998 NULL, HFILL }
2000 { &hf_pim_ip_version,
2001 { "IP Version", "pim.ip_version",
2002 FT_UINT8, BASE_DEC, VALS(pim_ip_version_vals), 0xF0,
2003 NULL, HFILL }
2005 { &hf_pim_dummy_header,
2006 { "Dummy Header", "pim.dummy_header",
2007 FT_NONE, BASE_NONE, NULL, 0,
2008 NULL, HFILL }
2010 { &hf_pim_source_ip4,
2011 { "Source", "pim.source",
2012 FT_IPv4, BASE_NONE, NULL, 0,
2013 NULL, HFILL }
2015 { &hf_pim_source_ip6,
2016 { "Source", "pim.source_ip6",
2017 FT_IPv6, BASE_NONE, NULL, 0,
2018 NULL, HFILL }
2020 { &hf_pim_group_ip4,
2021 { "Group", "pim.group",
2022 FT_IPv4, BASE_NONE, NULL, 0,
2023 NULL, HFILL }
2025 { &hf_pim_group_mask_ip4,
2026 { "Mask", "pim.group_mask",
2027 FT_IPv4, BASE_NONE, NULL, 0,
2028 NULL, HFILL }
2030 { &hf_pim_group_ip6,
2031 { "Group", "pim.group_ip6",
2032 FT_IPv6, BASE_NONE, NULL, 0,
2033 NULL, HFILL }
2035 { &hf_pim_upstream_neighbor_ip4,
2036 { "Upstream-neighbor", "pim.upstream_neighbor",
2037 FT_IPv4, BASE_NONE, NULL, 0,
2038 NULL, HFILL }
2040 { &hf_pim_upstream_neighbor_ip6,
2041 { "Upstream-neighbor", "pim.upstream_neighbor_ip6",
2042 FT_IPv6, BASE_NONE, NULL, 0,
2043 NULL, HFILL }
2045 { &hf_pim_join_ip4,
2046 { "IP address", "pim.join_ip",
2047 FT_IPv4, BASE_NONE, NULL, 0,
2048 NULL, HFILL }
2050 { &hf_pim_join_ip6,
2051 { "IP address", "pim.join_ip6",
2052 FT_IPv6, BASE_NONE, NULL, 0,
2053 NULL, HFILL }
2055 { &hf_pim_prune_ip4,
2056 { "IP address", "pim.prune_ip",
2057 FT_IPv4, BASE_NONE, NULL, 0,
2058 NULL, HFILL }
2060 { &hf_pim_prune_ip6,
2061 { "IP address", "pim.prune_ip6",
2062 FT_IPv6, BASE_NONE, NULL, 0,
2063 NULL, HFILL }
2065 { &hf_pim_address_list_ip4,
2066 { "Address", "pim.address_list",
2067 FT_IPv4, BASE_NONE, NULL, 0,
2068 NULL, HFILL }
2070 { &hf_pim_address_list_ip6,
2071 { "Address", "pim.address_list_ip6",
2072 FT_IPv6, BASE_NONE, NULL, 0,
2073 NULL, HFILL }
2075 { &hf_pim_bsr_ip4,
2076 { "BSR", "pim.bsr",
2077 FT_IPv4, BASE_NONE, NULL, 0,
2078 NULL, HFILL }
2080 { &hf_pim_bsr_ip6,
2081 { "BSR", "pim.bsr_ip6",
2082 FT_IPv6, BASE_NONE, NULL, 0,
2083 NULL, HFILL }
2085 { &hf_pim_rp_ip4,
2086 { "RP", "pim.rp",
2087 FT_IPv4, BASE_NONE, NULL, 0,
2088 NULL, HFILL }
2090 { &hf_pim_rp_ip6,
2091 { "RP", "pim.rp_ip6",
2092 FT_IPv6, BASE_NONE, NULL, 0,
2093 NULL, HFILL }
2095 { &hf_pim_originator_ip4,
2096 { "Originator", "pim.originator",
2097 FT_IPv4, BASE_NONE, NULL, 0,
2098 NULL, HFILL }
2100 { &hf_pim_originator_ip6,
2101 { "Originator", "pim.originator_ip6",
2102 FT_IPv6, BASE_NONE, NULL, 0,
2103 NULL, HFILL }
2105 { &hf_pim_group_address_ip4,
2106 { "Group Address", "pim.group_address",
2107 FT_IPv4, BASE_NONE, NULL, 0,
2108 NULL, HFILL }
2110 { &hf_pim_bd_pass_ip4,
2111 { "New Winner IP", "pim.bidir_winner_ip4",
2112 FT_IPv4, BASE_NONE, NULL, 0,
2113 NULL, HFILL }
2115 { &hf_pim_bd_pass_ip6,
2116 { "New Winner IP", "pim.bidir_winner_ip6",
2117 FT_IPv6, BASE_NONE, NULL, 0,
2118 NULL, HFILL }
2120 { &hf_pim_bd_pass_metric_pref,
2121 { "Winner Metric Preference", "pim.bidir_win_metric_pref",
2122 FT_UINT32, BASE_DEC, NULL, 0,
2123 NULL, HFILL }
2125 { &hf_pim_bd_pass_metric,
2126 { "Winner Metric", "pim.bidir_win_metric",
2127 FT_UINT32, BASE_DEC, NULL, 0,
2128 NULL, HFILL }
2130 { &hf_pim_bd_bo_offer_ip4,
2131 { "Offering IP", "pim.bidir_offering_ip4",
2132 FT_IPv4, BASE_NONE, NULL, 0,
2133 NULL, HFILL }
2135 { &hf_pim_bd_bo_offer_ip6,
2136 { "Offering IP", "pim.bidir_offering_ip6",
2137 FT_IPv6, BASE_NONE, NULL, 0,
2138 NULL, HFILL }
2140 { &hf_pim_bd_offer_metric_pref,
2141 { "Offering Metric Preference", "pim.bidir_off_metric_pref",
2142 FT_UINT32, BASE_DEC, NULL, 0,
2143 NULL, HFILL }
2145 { &hf_pim_bd_offer_metric,
2146 { "Offering Metric", "pim.bidir_off_metric",
2147 FT_UINT32, BASE_DEC, NULL, 0,
2148 NULL, HFILL }
2150 { &hf_pim_bd_offer_interval,
2151 { "Offering interval (ms)", "pim.bidir_offering_interval",
2152 FT_UINT16, BASE_DEC, NULL, 0,
2153 NULL, HFILL }
2155 { &hf_pim_fragment_tag,
2156 { "Fragment tag", "pim.fragment_tag",
2157 FT_UINT16, BASE_HEX, NULL, 0x0,
2158 NULL, HFILL }
2160 { &hf_pim_hash_mask_len,
2161 { "Hash mask len", "pim.hash_mask_len",
2162 FT_UINT8, BASE_DEC, NULL, 0x0,
2163 NULL, HFILL }
2165 { &hf_pim_bsr_priority,
2166 { "BSR priority", "pim.bsr_priority",
2167 FT_UINT8, BASE_DEC, NULL, 0x0,
2168 NULL, HFILL }
2170 { &hf_pim_rp_count,
2171 { "RP count", "pim.rp_count",
2172 FT_UINT8, BASE_DEC, NULL, 0x0,
2173 NULL, HFILL }
2175 { &hf_pim_frp_count,
2176 { "FRP count", "pim.frp_count",
2177 FT_UINT8, BASE_DEC, NULL, 0x0,
2178 NULL, HFILL }
2180 { &hf_pim_priority,
2181 { "Priority", "pim.priority",
2182 FT_UINT8, BASE_DEC, NULL, 0x0,
2183 NULL, HFILL }
2185 { &hf_pim_prefix_count,
2186 { "Prefix-count", "pim.prefix_count",
2187 FT_UINT8, BASE_DEC, NULL, 0x0,
2188 NULL, HFILL }
2190 { &hf_pim_src_flags_a,
2191 { "Annotated", "pim.src_flags.a",
2192 FT_UINT8, BASE_DEC, NULL, 0x08,
2193 NULL, HFILL }
2195 { &hf_pim_src_flags_s,
2196 { "Sparse", "pim.src_flags.s",
2197 FT_UINT8, BASE_DEC, NULL, 0x04,
2198 NULL, HFILL }
2200 { &hf_pim_src_flags_w,
2201 { "WC", "pim.src_flags.w",
2202 FT_UINT8, BASE_DEC, NULL, 0x02,
2203 NULL, HFILL }
2205 { &hf_pim_src_flags_r,
2206 { "RP", "pim.src_flags.r",
2207 FT_UINT8, BASE_DEC, NULL, 0x01,
2208 NULL, HFILL }
2210 { &hf_pim_src_flags_rsv,
2211 { "Reserved", "pim.src_flags.rsv",
2212 FT_UINT8, BASE_DEC, NULL, 0xF0,
2213 NULL, HFILL }
2215 { &hf_pim_mask_len,
2216 { "Masklen", "pim.mask_len",
2217 FT_UINT8, BASE_DEC, NULL, 0x0,
2218 NULL, HFILL }
2220 { &hf_pim_addr_len,
2221 { "Address Len", "pim.addr_len",
2222 FT_UINT8, BASE_DEC, NULL, 0x0,
2223 NULL, HFILL }
2225 { &hf_pim_ttl,
2226 { "TTL", "pim.ttl",
2227 FT_UINT8, BASE_DEC, NULL, 0x0,
2228 NULL, HFILL }
2230 { &hf_pim_interval,
2231 { "Interval", "pim.interval",
2232 FT_UINT8, BASE_DEC, NULL, 0x0,
2233 NULL, HFILL }
2235 { &hf_pim_addr_af,
2236 { "Address Family", "pim.addr_address_family",
2237 FT_UINT8, BASE_DEC, VALS(afn_vals), 0x0,
2238 NULL, HFILL }
2240 { &hf_pim_addr_et,
2241 { "Encoding Type", "pim.addr_encoding_type",
2242 FT_UINT8, BASE_DEC, VALS(pim_addr_et_vals), 0x0,
2243 NULL, HFILL }
2245 { &hf_pim_unicast_addr_ipv4,
2246 { "Unicast", "pim.unicast",
2247 FT_IPv4, BASE_NONE, NULL, 0x0,
2248 NULL, HFILL }
2250 { &hf_pim_unicast_addr_ipv6,
2251 { "Unicast", "pim.unicast_ipv6",
2252 FT_IPv6, BASE_NONE, NULL, 0x0,
2253 NULL, HFILL }
2255 { &hf_pim_attribute_transport_mode,
2256 { "Attribute Transport Mode", "pim.attribute_transport_mode",
2257 FT_UINT8, BASE_DEC, VALS(attribute_transport_mode), 0x0,
2258 NULL, HFILL }
2260 { &hf_pim_rloc_addr_ipv4,
2261 { "RLOC", "pim.rloc",
2262 FT_IPv4, BASE_NONE, NULL, 0x0,
2263 NULL, HFILL }
2265 { &hf_pim_rloc_addr_ipv6,
2266 { "RLOC", "pim.rloc_ipv6",
2267 FT_IPv6, BASE_NONE, NULL, 0x0,
2268 NULL, HFILL }
2270 { &hf_pim_group,
2271 { "Group", "pim.group_set",
2272 FT_STRING, BASE_NONE, NULL, 0x0,
2273 NULL, HFILL }
2275 { &hf_pim_group_addr_flags,
2276 { "Flags", "pim.group_addr.flags",
2277 FT_UINT8, BASE_HEX, NULL, 0x0,
2278 NULL, HFILL }
2280 { &hf_pim_group_addr_flags_b,
2281 { "Bidirectional PIM", "pim.group_addr.flags.b",
2282 FT_BOOLEAN, 8, TFS(&tfs_set_notset), PIM_GROUP_ADDR_FLAGS_B,
2283 NULL, HFILL }
2285 { &hf_pim_group_addr_flags_reserved,
2286 { "Reserved", "pim.group_addr.flags.reserved",
2287 FT_UINT8, BASE_HEX, NULL, PIM_GROUP_ADDR_FLAGS_RESERVED,
2288 NULL, HFILL }
2290 { &hf_pim_group_addr_flags_z,
2291 { "Admin Scope Zone", "pim.group_addr.flags.z",
2292 FT_BOOLEAN, 8, TFS(&tfs_set_notset), PIM_GROUP_ADDR_FLAGS_Z,
2293 NULL, HFILL }
2295 { &hf_pim_source_addr_flags,
2296 { "Flags", "pim.source_addr.flags",
2297 FT_UINT8, BASE_HEX, NULL, 0x0,
2298 NULL, HFILL }
2300 { &hf_pim_source_addr_flags_reserved,
2301 { "Reserved", "pim.source_addr.flags.reserved",
2302 FT_UINT8, BASE_HEX, NULL, PIM_SOURCE_ADDR_FLAGS_RESERVED,
2303 NULL, HFILL }
2305 { &hf_pim_source_addr_flags_s,
2306 { "Sparse", "pim.source_addr.flags.s",
2307 FT_BOOLEAN, 8, TFS(&tfs_set_notset), PIM_SOURCE_ADDR_FLAGS_S,
2308 NULL, HFILL }
2310 { &hf_pim_source_addr_flags_w,
2311 { "WildCard", "pim.source_addr.flags.w",
2312 FT_BOOLEAN, 8, TFS(&tfs_set_notset), PIM_SOURCE_ADDR_FLAGS_W,
2313 NULL, HFILL }
2315 { &hf_pim_source_addr_flags_r,
2316 { "Rendezvous Point Tree", "pim.source_addr.flags.r",
2317 FT_BOOLEAN, 8, TFS(&tfs_set_notset), PIM_SOURCE_ADDR_FLAGS_R,
2318 NULL, HFILL }
2320 { &hf_pim_source_join_attribute,
2321 { "Join Attribute", "pim.source_ja",
2322 FT_NONE, BASE_NONE, NULL, 0x0,
2323 NULL, HFILL }
2325 { &hf_pim_source_ja_flags,
2326 { "Flags", "pim.source_ja.flags",
2327 FT_UINT8, BASE_HEX, NULL, 0x0,
2328 NULL, HFILL }
2330 { &hf_pim_source_ja_flags_f,
2331 { "Forward", "pim.source_ja.flags.f",
2332 FT_BOOLEAN, 8, TFS(&tfs_set_notset), PIM_SOURCE_JA_FLAGS_F,
2333 NULL, HFILL }
2335 { &hf_pim_source_ja_flags_e,
2336 { "End of Attributes", "pim.source_ja.flags.e",
2337 FT_BOOLEAN, 8, TFS(&tfs_set_notset), PIM_SOURCE_JA_FLAGS_E,
2338 NULL, HFILL }
2340 { &hf_pim_source_ja_flags_attr_type,
2341 { "Attribute Type", "pim.source_ja.flags.attr_type",
2342 FT_UINT8, BASE_DEC, VALS(pim_join_attribute_type_vals), PIM_SOURCE_JA_FLAGS_ATTR_TYPE,
2343 NULL, HFILL }
2345 { &hf_pim_source_ja_length,
2346 { "Length", "pim.source_ja.length",
2347 FT_UINT8, BASE_DEC, NULL, 0x0,
2348 NULL, HFILL }
2350 { &hf_pim_source_ja_value,
2351 { "Value", "pim.source_ja.value",
2352 FT_BYTES, BASE_NONE, NULL, 0x0,
2353 NULL, HFILL }
2355 { &hf_pim_srcount,
2356 { "Source Count", "pim.srccount",
2357 FT_UINT16, BASE_DEC, NULL, 0x0,
2358 "Number of sources.", HFILL }
2360 { &hf_pim_srcholdt,
2361 { "Source Holdtime", "pim.srcholdtime",
2362 FT_UINT16, BASE_DEC|BASE_SPECIAL_VALS, VALS(unique_infinity_t), 0x0,
2363 "The amount of time a receiver must keep the source reachable, in seconds.", HFILL }
2365 { &hf_pim_transitivetype,
2366 { "Transitive Type", "pim.transitivetype",
2367 FT_BOOLEAN, 8, NULL, 0x80,
2368 "Set to 1 if this type is to be forwarded even if a router does not support it.", HFILL }
2370 { &hf_pfm_no_forward_bit,
2371 { "Pfm no forward bit", "pim.pfmnoforwardbit",
2372 FT_BOOLEAN, 8, NULL, 0x80,
2373 "When set, this bit means that the PFM message is not to be forwarded.", HFILL }
2375 { &hf_pim_reg_stop_p_bit,
2376 { "P-bit", "pim.packedregstoppbit",
2377 FT_BOOLEAN, 8, NULL, 0x01,
2378 "RP is indicating Register-Packing capability (RFC9465).", HFILL }
2382 static int *ett[] = {
2383 &ett_pim,
2384 &ett_pim_opts, /* Tree for all options */
2385 &ett_pim_opt, /* Tree for each option */
2386 &ett_pim_addr_flags /* Tree for flags */
2389 static ei_register_info ei[] = {
2390 { &ei_pim_cksum, { "pim.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
2393 expert_module_t* expert_pim;
2394 module_t *pim_module;
2396 proto_pim = proto_register_protocol("Protocol Independent Multicast", "PIM", "pim");
2397 proto_register_field_array(proto_pim, hf, array_length(hf));
2398 proto_register_subtree_array(ett, array_length(ett));
2399 expert_pim = expert_register_protocol(proto_pim);
2400 expert_register_field_array(expert_pim, ei, array_length(ei));
2402 pim_handle = register_dissector("pim", dissect_pim, proto_pim);
2403 pimv1_handle = register_dissector("pimv1", dissect_pimv1, proto_pim);
2405 pim_module = prefs_register_protocol(proto_pim, NULL);
2406 prefs_register_bool_preference(pim_module, "payload_tree",
2407 "PIM payload shown on main tree",
2408 "Whether the PIM payload is shown off of the main tree or encapsulated within the PIM options",
2409 &use_main_tree);
2413 void
2414 proto_reg_handoff_pim(void)
2416 dissector_add_uint("ip.proto", IP_PROTO_PIM, pim_handle);
2417 dissector_add_uint("igmp.type", IGMP_V1_PIM_ROUTING_MESSAGE, pimv1_handle);
2420 * Get handles for the IPv4 and IPv6 dissectors.
2422 ip_handle = find_dissector_add_dependency("ip", proto_pim);
2423 ipv6_handle = find_dissector_add_dependency("ipv6", proto_pim);
2427 * Editor modelines - https://www.wireshark.org/tools/modelines.html
2429 * Local variables:
2430 * c-basic-offset: 4
2431 * tab-width: 8
2432 * indent-tabs-mode: nil
2433 * End:
2435 * vi: set shiftwidth=4 tabstop=8 expandtab:
2436 * :indentSize=4:tabSize=8:noTabs=true: