2 * Copyright (c) 1995, 1996
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 /* \summary: Protocol Independent Multicast (PIM) printer */
28 #include "netdissect-stdinc.h"
30 #include "netdissect.h"
31 #include "addrtoname.h"
38 #define PIMV1_TYPE_QUERY 0
39 #define PIMV1_TYPE_REGISTER 1
40 #define PIMV1_TYPE_REGISTER_STOP 2
41 #define PIMV1_TYPE_JOIN_PRUNE 3
42 #define PIMV1_TYPE_RP_REACHABILITY 4
43 #define PIMV1_TYPE_ASSERT 5
44 #define PIMV1_TYPE_GRAFT 6
45 #define PIMV1_TYPE_GRAFT_ACK 7
47 static const struct tok pimv1_type_str
[] = {
48 { PIMV1_TYPE_QUERY
, "Query" },
49 { PIMV1_TYPE_REGISTER
, "Register" },
50 { PIMV1_TYPE_REGISTER_STOP
, "Register-Stop" },
51 { PIMV1_TYPE_JOIN_PRUNE
, "Join/Prune" },
52 { PIMV1_TYPE_RP_REACHABILITY
, "RP-reachable" },
53 { PIMV1_TYPE_ASSERT
, "Assert" },
54 { PIMV1_TYPE_GRAFT
, "Graft" },
55 { PIMV1_TYPE_GRAFT_ACK
, "Graft-ACK" },
59 #define PIMV2_TYPE_HELLO 0
60 #define PIMV2_TYPE_REGISTER 1
61 #define PIMV2_TYPE_REGISTER_STOP 2
62 #define PIMV2_TYPE_JOIN_PRUNE 3
63 #define PIMV2_TYPE_BOOTSTRAP 4
64 #define PIMV2_TYPE_ASSERT 5
65 #define PIMV2_TYPE_GRAFT 6
66 #define PIMV2_TYPE_GRAFT_ACK 7
67 #define PIMV2_TYPE_CANDIDATE_RP 8
68 #define PIMV2_TYPE_PRUNE_REFRESH 9
69 #define PIMV2_TYPE_DF_ELECTION 10
70 #define PIMV2_TYPE_ECMP_REDIRECT 11
72 static const struct tok pimv2_type_values
[] = {
73 { PIMV2_TYPE_HELLO
, "Hello" },
74 { PIMV2_TYPE_REGISTER
, "Register" },
75 { PIMV2_TYPE_REGISTER_STOP
, "Register Stop" },
76 { PIMV2_TYPE_JOIN_PRUNE
, "Join / Prune" },
77 { PIMV2_TYPE_BOOTSTRAP
, "Bootstrap" },
78 { PIMV2_TYPE_ASSERT
, "Assert" },
79 { PIMV2_TYPE_GRAFT
, "Graft" },
80 { PIMV2_TYPE_GRAFT_ACK
, "Graft Acknowledgement" },
81 { PIMV2_TYPE_CANDIDATE_RP
, "Candidate RP Advertisement" },
82 { PIMV2_TYPE_PRUNE_REFRESH
, "Prune Refresh" },
83 { PIMV2_TYPE_DF_ELECTION
, "DF Election" },
84 { PIMV2_TYPE_ECMP_REDIRECT
, "ECMP Redirect" },
88 #define PIMV2_HELLO_OPTION_HOLDTIME 1
89 #define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
90 #define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
91 #define PIMV2_HELLO_OPTION_DR_PRIORITY 19
92 #define PIMV2_HELLO_OPTION_GENID 20
93 #define PIMV2_HELLO_OPTION_REFRESH_CAP 21
94 #define PIMV2_HELLO_OPTION_BIDIR_CAP 22
95 #define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
96 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
98 static const struct tok pimv2_hello_option_values
[] = {
99 { PIMV2_HELLO_OPTION_HOLDTIME
, "Hold Time" },
100 { PIMV2_HELLO_OPTION_LANPRUNEDELAY
, "LAN Prune Delay" },
101 { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
, "DR Priority (Old)" },
102 { PIMV2_HELLO_OPTION_DR_PRIORITY
, "DR Priority" },
103 { PIMV2_HELLO_OPTION_GENID
, "Generation ID" },
104 { PIMV2_HELLO_OPTION_REFRESH_CAP
, "State Refresh Capability" },
105 { PIMV2_HELLO_OPTION_BIDIR_CAP
, "Bi-Directional Capability" },
106 { PIMV2_HELLO_OPTION_ADDRESS_LIST
, "Address List" },
107 { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
, "Address List (Old)" },
111 #define PIMV2_REGISTER_FLAG_LEN 4
112 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
113 #define PIMV2_REGISTER_FLAG_NULL 0x40000000
115 static const struct tok pimv2_register_flag_values
[] = {
116 { PIMV2_REGISTER_FLAG_BORDER
, "Border" },
117 { PIMV2_REGISTER_FLAG_NULL
, "Null" },
122 * XXX: We consider a case where IPv6 is not ready yet for portability,
123 * but PIM dependent defintions should be independent of IPv6...
127 nd_uint8_t pim_typever
;
128 /* upper 4bit: PIM version number; 2 for PIMv2 */
129 /* lower 4bit: the PIM message type, currently they are:
130 * Hello, Register, Register-Stop, Join/Prune,
131 * Bootstrap, Assert, Graft (PIM-DM only),
132 * Graft-Ack (PIM-DM only), C-RP-Adv
134 #define PIM_VER(x) (((x) & 0xf0) >> 4)
135 #define PIM_TYPE(x) ((x) & 0x0f)
136 nd_uint8_t pim_rsv
; /* Reserved in v1, address length in v2 */
137 nd_uint16_t pim_cksum
; /* IP style check sum */
140 static void pimv2_print(netdissect_options
*, const u_char
*bp
, u_int len
, const u_char
*);
143 pimv1_join_prune_print(netdissect_options
*ndo
,
144 const u_char
*bp
, u_int len
)
146 u_int ngroups
, njoin
, nprune
;
149 /* If it's a single group and a single source, use 1-line output. */
150 if (ND_TTEST_LEN(bp
, 30) && GET_U_1(bp
+ 11) == 1 &&
151 ((njoin
= GET_BE_U_2(bp
+ 20)) + GET_BE_U_2(bp
+ 22)) == 1) {
154 ND_PRINT(" RPF %s ", ipaddr_string(ndo
, bp
));
155 hold
= GET_BE_U_2(bp
+ 6);
158 unsigned_relts_print(ndo
, hold
);
160 ND_PRINT("%s (%s/%u, %s", njoin
? "Join" : "Prune",
161 ipaddr_string(ndo
, bp
+ 26), GET_U_1(bp
+ 25) & 0x3f,
162 ipaddr_string(ndo
, bp
+ 12));
163 if (GET_BE_U_4(bp
+ 16) != 0xffffffff)
164 ND_PRINT("/%s", ipaddr_string(ndo
, bp
+ 16));
165 ND_PRINT(") %s%s %s",
166 (GET_U_1(bp
+ 24) & 0x01) ? "Sparse" : "Dense",
167 (GET_U_1(bp
+ 25) & 0x80) ? " WC" : "",
168 (GET_U_1(bp
+ 25) & 0x40) ? "RP" : "SPT");
172 if (len
< sizeof(nd_ipv4
))
174 ND_TCHECK_LEN(bp
, sizeof(nd_ipv4
));
175 if (ndo
->ndo_vflag
> 1)
177 ND_PRINT(" Upstream Nbr: %s", ipaddr_string(ndo
, bp
));
183 if (ndo
->ndo_vflag
> 1)
185 ND_PRINT(" Hold time: ");
186 unsigned_relts_print(ndo
, GET_BE_U_2(bp
+ 2));
187 if (ndo
->ndo_vflag
< 2)
195 ngroups
= GET_U_1(bp
+ 3);
198 while (ngroups
!= 0) {
200 * XXX - does the address have length "addrlen" and the
201 * mask length "maddrlen"?
205 ND_TCHECK_LEN(bp
, sizeof(nd_ipv4
));
206 ND_PRINT("\n\tGroup: %s", ipaddr_string(ndo
, bp
));
211 ND_TCHECK_LEN(bp
, sizeof(nd_ipv4
));
212 if (GET_BE_U_4(bp
) != 0xffffffff)
213 ND_PRINT("/%s", ipaddr_string(ndo
, bp
));
219 njoin
= GET_BE_U_2(bp
);
220 nprune
= GET_BE_U_2(bp
+ 2);
221 ND_PRINT(" joined: %u pruned: %u", njoin
, nprune
);
224 for (njp
= 0; njp
< (njoin
+ nprune
); njp
++) {
234 ND_PRINT("\n\t%s %s%s%s%s/%u", type
,
235 (GET_U_1(bp
) & 0x01) ? "Sparse " : "Dense ",
236 (GET_U_1(bp
+ 1) & 0x80) ? "WC " : "",
237 (GET_U_1(bp
+ 1) & 0x40) ? "RP " : "SPT ",
238 ipaddr_string(ndo
, bp
+ 2),
239 GET_U_1(bp
+ 1) & 0x3f);
252 pimv1_print(netdissect_options
*ndo
,
253 const u_char
*bp
, u_int len
)
257 ndo
->ndo_protocol
= "pimv1";
259 type
= GET_U_1(bp
+ 1);
261 ND_PRINT(" %s", tok2str(pimv1_type_str
, "[type %u]", type
));
263 case PIMV1_TYPE_QUERY
:
264 if (ND_TTEST_1(bp
+ 8)) {
265 switch (GET_U_1(bp
+ 8) >> 4) {
267 ND_PRINT(" Dense-mode");
270 ND_PRINT(" Sparse-mode");
273 ND_PRINT(" Sparse-Dense-mode");
276 ND_PRINT(" mode-%u", GET_U_1(bp
+ 8) >> 4);
280 if (ndo
->ndo_vflag
) {
281 ND_TCHECK_2(bp
+ 10);
282 ND_PRINT(" (Hold-time ");
283 unsigned_relts_print(ndo
, GET_BE_U_2(bp
+ 10));
288 case PIMV1_TYPE_REGISTER
:
289 ND_TCHECK_LEN(bp
+ 8, 20); /* ip header */
290 ND_PRINT(" for %s > %s", ipaddr_string(ndo
, bp
+ 20),
291 ipaddr_string(ndo
, bp
+ 24));
293 case PIMV1_TYPE_REGISTER_STOP
:
294 ND_TCHECK_LEN(bp
+ 12, sizeof(nd_ipv4
));
295 ND_PRINT(" for %s > %s", ipaddr_string(ndo
, bp
+ 8),
296 ipaddr_string(ndo
, bp
+ 12));
298 case PIMV1_TYPE_RP_REACHABILITY
:
299 if (ndo
->ndo_vflag
) {
300 ND_TCHECK_2(bp
+ 22);
301 ND_PRINT(" group %s", ipaddr_string(ndo
, bp
+ 8));
302 if (GET_BE_U_4(bp
+ 12) != 0xffffffff)
303 ND_PRINT("/%s", ipaddr_string(ndo
, bp
+ 12));
304 ND_PRINT(" RP %s hold ", ipaddr_string(ndo
, bp
+ 16));
305 unsigned_relts_print(ndo
, GET_BE_U_2(bp
+ 22));
308 case PIMV1_TYPE_ASSERT
:
309 ND_TCHECK_LEN(bp
+ 16, sizeof(nd_ipv4
));
310 ND_PRINT(" for %s > %s", ipaddr_string(ndo
, bp
+ 16),
311 ipaddr_string(ndo
, bp
+ 8));
312 if (GET_BE_U_4(bp
+ 12) != 0xffffffff)
313 ND_PRINT("/%s", ipaddr_string(ndo
, bp
+ 12));
314 ND_TCHECK_4(bp
+ 24);
315 ND_PRINT(" %s pref %u metric %u",
316 (GET_U_1(bp
+ 20) & 0x80) ? "RP-tree" : "SPT",
317 GET_BE_U_4(bp
+ 20) & 0x7fffffff,
318 GET_BE_U_4(bp
+ 24));
320 case PIMV1_TYPE_JOIN_PRUNE
:
321 case PIMV1_TYPE_GRAFT
:
322 case PIMV1_TYPE_GRAFT_ACK
:
323 if (ndo
->ndo_vflag
) {
326 pimv1_join_prune_print(ndo
, bp
+ 8, len
- 8);
331 if ((GET_U_1(bp
+ 4) >> 4) != 1)
332 ND_PRINT(" [v%u]", GET_U_1(bp
+ 4) >> 4);
341 * auto-RP is a cisco protocol, documented at
342 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
344 * This implements version 1+, dated Sept 9, 1998.
347 cisco_autorp_print(netdissect_options
*ndo
,
348 const u_char
*bp
, u_int len
)
354 ndo
->ndo_protocol
= "cisco_autorp";
358 ND_PRINT(" auto-rp ");
362 ND_PRINT("candidate-advert");
368 ND_PRINT("type-0x%02x", type
);
373 numrps
= GET_U_1(bp
+ 1);
377 hold
= GET_BE_U_2(bp
+ 2);
379 unsigned_relts_print(ndo
, GET_BE_U_2(bp
+ 2));
383 /* Next 4 bytes are reserved. */
387 /*XXX skip unless -v? */
391 * numrps entries of the form:
394 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
395 * 8 bits: # of entries for this RP
396 * each entry: 7 bits: reserved, 1 bit: negative,
397 * 8 bits: mask 32 bits: source
398 * lather, rinse, repeat.
400 while (numrps
!= 0) {
407 ND_PRINT(" RP %s", ipaddr_string(ndo
, bp
));
413 switch (GET_U_1(bp
) & 0x3) {
414 case 0: ND_PRINT(" PIMv?");
416 case 1: ND_PRINT(" PIMv1");
418 case 2: ND_PRINT(" PIMv2");
420 case 3: ND_PRINT(" PIMv1+2");
423 if (GET_U_1(bp
) & 0xfc)
424 ND_PRINT(" [rsvd=0x%02x]", GET_U_1(bp
) & 0xfc);
430 nentries
= GET_U_1(bp
);
434 while (nentries
!= 0) {
438 ND_PRINT("%c%s%s/%u", s
, GET_U_1(bp
) & 1 ? "!" : "",
439 ipaddr_string(ndo
, bp
+ 2), GET_U_1(bp
+ 1));
440 if (GET_U_1(bp
) & 0x02) {
443 if (GET_U_1(bp
) & 0xfc) {
444 ND_PRINT("[rsvd=0x%02x]", GET_U_1(bp
) & 0xfc);
460 pim_print(netdissect_options
*ndo
,
461 const u_char
*bp
, u_int len
, const u_char
*bp2
)
463 const struct pim
*pim
= (const struct pim
*)bp
;
466 ndo
->ndo_protocol
= "pim";
467 #ifdef notyet /* currently we see only version and type */
468 ND_TCHECK_1(pim
->pim_rsv
);
471 ND_TCHECK_1(pim
->pim_typever
);
472 pim_typever
= GET_U_1(pim
->pim_typever
);
473 switch (PIM_VER(pim_typever
)) {
475 if (!ndo
->ndo_vflag
) {
476 ND_PRINT("PIMv%u, %s, length %u",
477 PIM_VER(pim_typever
),
478 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim_typever
)),
482 ND_PRINT("PIMv%u, length %u\n\t%s",
483 PIM_VER(pim_typever
),
485 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim_typever
)));
486 pimv2_print(ndo
, bp
, len
, bp2
);
490 ND_PRINT("PIMv%u, length %u",
491 PIM_VER(pim_typever
),
503 * PIMv2 uses encoded address representations.
505 * The last PIM-SM I-D before RFC2117 was published specified the
506 * following representation for unicast addresses. However, RFC2117
507 * specified no encoding for unicast addresses with the unicast
508 * address length specified in the header. Therefore, we have to
509 * guess which encoding is being used (Cisco's PIMv2 implementation
510 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
511 * field into a 'unicast-address-length-in-bytes' field. We guess
512 * that it's the draft encoding if this reserved field is zero.
514 * RFC2362 goes back to the encoded format, and calls the addr length
515 * field "reserved" again.
517 * The first byte is the address family, from:
520 * 1 IP (IP version 4)
521 * 2 IP6 (IP version 6)
523 * 4 HDLC (8-bit multidrop)
525 * 6 802 (includes all 802 media plus Ethernet "canonical format")
527 * 8 E.164 (SMDS, Frame Relay, ATM)
529 * 10 X.121 (X.25, Frame Relay)
534 * 15 E.164 with NSAP format subaddress
536 * In addition, the second byte is an "Encoding". 0 is the default
537 * encoding for the address family, and no other encodings are currently
542 enum pimv2_addrtype
{
543 pimv2_unicast
, pimv2_group
, pimv2_source
547 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
548 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
549 * | Addr Family | Encoding Type | Unicast Address |
550 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
552 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
553 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
554 * | Addr Family | Encoding Type | Reserved | Mask Len |
555 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
556 * | Group multicast Address |
557 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
559 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
560 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
561 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
562 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
564 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
567 pimv2_addr_print(netdissect_options
*ndo
,
568 const u_char
*bp
, u_int len
, enum pimv2_addrtype at
,
569 u_int addr_len
, int silent
)
578 switch (GET_U_1(bp
)) {
581 addr_len
= (u_int
)sizeof(nd_ipv4
);
585 addr_len
= (u_int
)sizeof(nd_ipv6
);
590 if (GET_U_1(bp
+ 1) != 0)
595 case sizeof(nd_ipv4
):
598 case sizeof(nd_ipv6
):
614 ND_TCHECK_LEN(bp
, addr_len
);
617 ND_PRINT("%s", ipaddr_string(ndo
, bp
));
619 else if (af
== AF_INET6
) {
621 ND_PRINT("%s", ip6addr_string(ndo
, bp
));
623 return hdrlen
+ addr_len
;
626 if (len
< addr_len
+ 2)
628 ND_TCHECK_LEN(bp
, addr_len
+ 2);
631 ND_PRINT("%s", ipaddr_string(ndo
, bp
+ 2));
632 if (GET_U_1(bp
+ 1) != 32)
633 ND_PRINT("/%u", GET_U_1(bp
+ 1));
636 else if (af
== AF_INET6
) {
638 ND_PRINT("%s", ip6addr_string(ndo
, bp
+ 2));
639 if (GET_U_1(bp
+ 1) != 128)
640 ND_PRINT("/%u", GET_U_1(bp
+ 1));
643 if (GET_U_1(bp
) && !silent
) {
644 if (at
== pimv2_group
) {
645 ND_PRINT("(0x%02x)", GET_U_1(bp
));
648 GET_U_1(bp
) & 0x04 ? "S" : "",
649 GET_U_1(bp
) & 0x02 ? "W" : "",
650 GET_U_1(bp
) & 0x01 ? "R" : "");
651 if (GET_U_1(bp
) & 0xf8) {
658 return hdrlen
+ 2 + addr_len
;
666 enum checksum_status
{
672 static enum checksum_status
673 pimv2_check_checksum(netdissect_options
*ndo
, const u_char
*bp
,
674 const u_char
*bp2
, u_int len
)
679 if (!ND_TTEST_LEN(bp
, len
)) {
680 /* We don't have all the data. */
683 ip
= (const struct ip
*)bp2
;
685 struct cksum_vec vec
[1];
689 cksum
= in_cksum(vec
, 1);
690 return (cksum
? INCORRECT
: CORRECT
);
691 } else if (IP_V(ip
) == 6) {
692 const struct ip6_hdr
*ip6
;
694 ip6
= (const struct ip6_hdr
*)bp2
;
695 cksum
= nextproto6_cksum(ndo
, ip6
, bp
, len
, len
, IPPROTO_PIM
);
696 return (cksum
? INCORRECT
: CORRECT
);
703 pimv2_print(netdissect_options
*ndo
,
704 const u_char
*bp
, u_int len
, const u_char
*bp2
)
706 const struct pim
*pim
= (const struct pim
*)bp
;
708 enum checksum_status cksum_status
;
710 u_int pimv2_addr_len
;
712 ndo
->ndo_protocol
= "pimv2";
715 ND_TCHECK_1(pim
->pim_rsv
);
716 pim_typever
= GET_U_1(pim
->pim_typever
);
717 pimv2_addr_len
= GET_U_1(pim
->pim_rsv
);
718 if (pimv2_addr_len
!= 0)
719 ND_PRINT(", RFC2117-encoding");
723 ND_TCHECK_2(pim
->pim_cksum
);
724 ND_PRINT(", cksum 0x%04x ", GET_BE_U_2(pim
->pim_cksum
));
725 if (GET_BE_U_2(pim
->pim_cksum
) == 0) {
726 ND_PRINT("(unverified)");
728 if (PIM_TYPE(pim_typever
) == PIMV2_TYPE_REGISTER
) {
730 * The checksum only covers the packet header,
731 * not the encapsulated packet.
733 cksum_status
= pimv2_check_checksum(ndo
, bp
, bp2
, 8);
734 if (cksum_status
== INCORRECT
) {
736 * To quote RFC 4601, "For interoperability
737 * reasons, a message carrying a checksum
738 * calculated over the entire PIM Register
739 * message should also be accepted."
741 cksum_status
= pimv2_check_checksum(ndo
, bp
, bp2
, len
);
745 * The checksum covers the entire packet.
747 cksum_status
= pimv2_check_checksum(ndo
, bp
, bp2
, len
);
749 switch (cksum_status
) {
752 ND_PRINT("(correct)");
756 ND_PRINT("(incorrect)");
760 ND_PRINT("(unverified)");
767 switch (PIM_TYPE(pim_typever
)) {
768 case PIMV2_TYPE_HELLO
:
770 uint16_t otype
, olen
;
775 otype
= GET_BE_U_2(bp
);
776 olen
= GET_BE_U_2(bp
+ 2);
777 ND_PRINT("\n\t %s Option (%u), length %u, Value: ",
778 tok2str(pimv2_hello_option_values
, "Unknown", otype
),
786 ND_TCHECK_LEN(bp
, olen
);
788 case PIMV2_HELLO_OPTION_HOLDTIME
:
790 ND_PRINT("ERROR: Option Length != 2 Bytes (%u)", olen
);
792 unsigned_relts_print(ndo
,
797 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
799 ND_PRINT("ERROR: Option Length != 4 Bytes (%u)", olen
);
802 uint16_t lan_delay
, override_interval
;
803 lan_delay
= GET_BE_U_2(bp
);
804 override_interval
= GET_BE_U_2(bp
+ 2);
805 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
806 lan_delay
&= ~0x8000;
807 ND_PRINT("\n\t T-bit=%u, LAN delay %ums, Override interval %ums",
808 t_bit
, lan_delay
, override_interval
);
812 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
813 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
816 ND_PRINT("Bi-Directional Capability (Old)");
819 ND_PRINT("%u", GET_BE_U_4(bp
));
822 ND_PRINT("ERROR: Option Length != 4 Bytes (%u)", olen
);
827 case PIMV2_HELLO_OPTION_GENID
:
829 ND_PRINT("ERROR: Option Length != 4 Bytes (%u)", olen
);
831 ND_PRINT("0x%08x", GET_BE_U_4(bp
));
835 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
837 ND_PRINT("ERROR: Option Length != 4 Bytes (%u)", olen
);
839 ND_PRINT("v%u", GET_U_1(bp
));
840 if (GET_U_1(bp
+ 1) != 0) {
841 ND_PRINT(", interval ");
842 unsigned_relts_print(ndo
,
845 if (GET_BE_U_2(bp
+ 2) != 0) {
846 ND_PRINT(" ?0x%04x?",
852 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
855 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
856 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
857 if (ndo
->ndo_vflag
> 1) {
858 const u_char
*ptr
= bp
;
860 while (ptr
< (bp
+olen
)) {
862 advance
= pimv2_addr_print(ndo
, ptr
, plen
, pimv2_unicast
, pimv2_addr_len
, 0);
871 if (ndo
->ndo_vflag
<= 1)
872 print_unknown_data(ndo
, bp
, "\n\t ", olen
);
875 /* do we want to see an additionally hexdump ? */
876 if (ndo
->ndo_vflag
> 1)
877 print_unknown_data(ndo
, bp
, "\n\t ", olen
);
884 case PIMV2_TYPE_REGISTER
:
890 ND_TCHECK_LEN(bp
, PIMV2_REGISTER_FLAG_LEN
);
892 ND_PRINT(", Flags [ %s ]\n\t",
893 tok2str(pimv2_register_flag_values
,
898 /* encapsulated multicast packet */
901 ip
= (const struct ip
*)bp
;
902 ND_TCHECK_1(ip
->ip_vhl
);
904 case 0: /* Null header */
905 ND_TCHECK_4(ip
->ip_dst
);
906 ND_PRINT("IP-Null-header %s > %s",
907 ipaddr_string(ndo
, ip
->ip_src
),
908 ipaddr_string(ndo
, ip
->ip_dst
));
912 ip_print(ndo
, bp
, len
);
916 ip6_print(ndo
, bp
, len
);
920 ND_PRINT("IP ver %u", IP_V(ip
));
926 case PIMV2_TYPE_REGISTER_STOP
:
928 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_group
, pimv2_addr_len
, 0)) < 0)
930 bp
+= advance
; len
-= advance
;
931 ND_PRINT(" source=");
932 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_unicast
, pimv2_addr_len
, 0)) < 0)
934 bp
+= advance
; len
-= advance
;
937 case PIMV2_TYPE_JOIN_PRUNE
:
938 case PIMV2_TYPE_GRAFT
:
939 case PIMV2_TYPE_GRAFT_ACK
:
944 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
945 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
946 * |PIM Ver| Type | Addr length | Checksum |
947 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
948 * | Unicast-Upstream Neighbor Address |
949 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
950 * | Reserved | Num groups | Holdtime |
951 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
952 * | Encoded-Multicast Group Address-1 |
953 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
954 * | Number of Joined Sources | Number of Pruned Sources |
955 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
956 * | Encoded-Joined Source Address-1 |
957 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
960 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
961 * | Encoded-Joined Source Address-n |
962 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
963 * | Encoded-Pruned Source Address-1 |
964 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
967 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
968 * | Encoded-Pruned Source Address-n |
969 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
972 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
973 * | Encoded-Multicast Group Address-n |
974 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
984 if (PIM_TYPE(pim_typever
) != 7) { /*not for Graft-ACK*/
985 ND_PRINT(", upstream-neighbor: ");
986 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_unicast
, pimv2_addr_len
, 0)) < 0)
988 bp
+= advance
; len
-= advance
;
993 ngroup
= GET_U_1(bp
+ 1);
994 holdtime
= GET_BE_U_2(bp
+ 2);
995 ND_PRINT("\n\t %u group(s)", ngroup
);
996 if (PIM_TYPE(pim_typever
) != 7) { /*not for Graft-ACK*/
997 ND_PRINT(", holdtime: ");
998 if (holdtime
== 0xffff)
999 ND_PRINT("infinite");
1001 unsigned_relts_print(ndo
, holdtime
);
1004 for (i
= 0; i
< ngroup
; i
++) {
1005 ND_PRINT("\n\t group #%u: ", i
+1);
1006 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_group
, pimv2_addr_len
, 0)) < 0)
1008 bp
+= advance
; len
-= advance
;
1012 njoin
= GET_BE_U_2(bp
);
1013 nprune
= GET_BE_U_2(bp
+ 2);
1014 ND_PRINT(", joined sources: %u, pruned sources: %u", njoin
, nprune
);
1016 for (j
= 0; j
< njoin
; j
++) {
1017 ND_PRINT("\n\t joined source #%u: ", j
+1);
1018 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_source
, pimv2_addr_len
, 0)) < 0)
1020 bp
+= advance
; len
-= advance
;
1022 for (j
= 0; j
< nprune
; j
++) {
1023 ND_PRINT("\n\t pruned source #%u: ", j
+1);
1024 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_source
, pimv2_addr_len
, 0)) < 0)
1026 bp
+= advance
; len
-= advance
;
1032 case PIMV2_TYPE_BOOTSTRAP
:
1036 /* Fragment Tag, Hash Mask len, and BSR-priority */
1040 ND_PRINT(" tag=%x", GET_BE_U_2(bp
));
1046 ND_PRINT(" hashmlen=%u", GET_U_1(bp
));
1049 ND_TCHECK_1(bp
+ 2);
1050 ND_PRINT(" BSRprio=%u", GET_U_1(bp
+ 1));
1054 /* Encoded-Unicast-BSR-Address */
1056 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_unicast
, pimv2_addr_len
, 0)) < 0)
1061 for (i
= 0; len
> 0; i
++) {
1062 /* Encoded-Group Address */
1063 ND_PRINT(" (group%u: ", i
);
1064 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_group
, pimv2_addr_len
, 0)) < 0)
1069 /* RP-Count, Frag RP-Cnt, and rsvd */
1073 ND_PRINT(" RPcnt=%u", GET_U_1(bp
));
1076 ND_TCHECK_1(bp
+ 1);
1077 frpcnt
= GET_U_1(bp
+ 1);
1078 ND_PRINT(" FRPcnt=%u", frpcnt
);
1084 for (j
= 0; j
< frpcnt
&& len
> 0; j
++) {
1086 ND_PRINT(" RP%u=", j
);
1087 if ((advance
= pimv2_addr_print(ndo
, bp
, len
,
1098 ND_PRINT(",holdtime=");
1099 unsigned_relts_print(ndo
,
1103 ND_TCHECK_1(bp
+ 2);
1104 ND_PRINT(",prio=%u", GET_U_1(bp
+ 2));
1114 case PIMV2_TYPE_ASSERT
:
1115 ND_PRINT(" group=");
1116 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_group
, pimv2_addr_len
, 0)) < 0)
1118 bp
+= advance
; len
-= advance
;
1120 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_unicast
, pimv2_addr_len
, 0)) < 0)
1122 bp
+= advance
; len
-= advance
;
1126 if (GET_U_1(bp
) & 0x80)
1128 ND_PRINT(" pref=%u", GET_BE_U_4(bp
) & 0x7fffffff);
1129 ND_PRINT(" metric=%u", GET_BE_U_4(bp
+ 4));
1132 case PIMV2_TYPE_CANDIDATE_RP
:
1136 /* Prefix-Cnt, Priority, and Holdtime */
1140 ND_PRINT(" prefix-cnt=%u", GET_U_1(bp
));
1141 pfxcnt
= GET_U_1(bp
);
1144 ND_TCHECK_1(bp
+ 1);
1145 ND_PRINT(" prio=%u", GET_U_1(bp
+ 1));
1148 ND_TCHECK_2(bp
+ 2);
1149 ND_PRINT(" holdtime=");
1150 unsigned_relts_print(ndo
, GET_BE_U_2(bp
+ 2));
1154 /* Encoded-Unicast-RP-Address */
1156 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_unicast
, pimv2_addr_len
, 0)) < 0)
1161 /* Encoded-Group Addresses */
1162 for (i
= 0; i
< pfxcnt
&& len
> 0; i
++) {
1163 ND_PRINT(" Group%u=", i
);
1164 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_group
, pimv2_addr_len
, 0)) < 0)
1172 case PIMV2_TYPE_PRUNE_REFRESH
:
1174 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_unicast
, pimv2_addr_len
, 0)) < 0)
1179 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_group
, pimv2_addr_len
, 0)) < 0)
1183 ND_PRINT(" forwarder=");
1184 if ((advance
= pimv2_addr_print(ndo
, bp
, len
, pimv2_unicast
, pimv2_addr_len
, 0)) < 0)
1192 unsigned_relts_print(ndo
, GET_BE_U_2(bp
));
1197 ND_PRINT(" [type %u]", PIM_TYPE(pim_typever
));
1204 nd_print_trunc(ndo
);