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.
23 static const char rcsid
[] _U_
=
24 "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.43 2004-03-24 02:51:10 guy Exp $ (LBL)";
31 #include <tcpdump-stdinc.h>
32 #include "interface.h"
34 #define PIMV2_TYPE_HELLO 0
35 #define PIMV2_TYPE_REGISTER 1
36 #define PIMV2_TYPE_REGISTER_STOP 2
37 #define PIMV2_TYPE_JOIN_PRUNE 3
38 #define PIMV2_TYPE_BOOTSTRAP 4
39 #define PIMV2_TYPE_ASSERT 5
40 #define PIMV2_TYPE_GRAFT 6
41 #define PIMV2_TYPE_GRAFT_ACK 7
42 #define PIMV2_TYPE_CANDIDATE_RP 8
43 #define PIMV2_TYPE_PRUNE_REFRESH 9
45 static struct tok pimv2_type_values
[] = {
46 { PIMV2_TYPE_HELLO
, "Hello" },
47 { PIMV2_TYPE_REGISTER
, "Register" },
48 { PIMV2_TYPE_REGISTER_STOP
, "Register Stop" },
49 { PIMV2_TYPE_JOIN_PRUNE
, "Join / Prune" },
50 { PIMV2_TYPE_BOOTSTRAP
, "Bootstrap" },
51 { PIMV2_TYPE_ASSERT
, "Assert" },
52 { PIMV2_TYPE_GRAFT
, "Graft" },
53 { PIMV2_TYPE_GRAFT_ACK
, "Graft Acknowledgement" },
54 { PIMV2_TYPE_CANDIDATE_RP
, "Candidate RP Advertisement" },
55 { PIMV2_TYPE_PRUNE_REFRESH
, "Prune Refresh" },
59 #define PIMV2_HELLO_OPTION_HOLDTIME 1
60 #define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
61 #define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
62 #define PIMV2_HELLO_OPTION_DR_PRIORITY 19
63 #define PIMV2_HELLO_OPTION_GENID 20
64 #define PIMV2_HELLO_OPTION_REFRESH_CAP 21
65 #define PIMV2_HELLO_OPTION_BIDIR_CAP 22
66 #define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
67 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
69 static struct tok pimv2_hello_option_values
[] = {
70 { PIMV2_HELLO_OPTION_HOLDTIME
, "Hold Time" },
71 { PIMV2_HELLO_OPTION_LANPRUNEDELAY
, "LAN Prune Delay" },
72 { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
, "DR Priority (Old)" },
73 { PIMV2_HELLO_OPTION_DR_PRIORITY
, "DR Priority" },
74 { PIMV2_HELLO_OPTION_GENID
, "Generation ID" },
75 { PIMV2_HELLO_OPTION_REFRESH_CAP
, "State Refresh Capability" },
76 { PIMV2_HELLO_OPTION_BIDIR_CAP
, "Bi-Directional Capability" },
77 { PIMV2_HELLO_OPTION_ADDRESS_LIST
, "Address List" },
78 { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
, "Address List (Old)" },
84 * XXX: We consider a case where IPv6 is not ready yet for portability,
85 * but PIM dependent defintions should be independent of IPv6...
90 /* upper 4bit: PIM version number; 2 for PIMv2 */
91 /* lower 4bit: the PIM message type, currently they are:
92 * Hello, Register, Register-Stop, Join/Prune,
93 * Bootstrap, Assert, Graft (PIM-DM only),
94 * Graft-Ack (PIM-DM only), C-RP-Adv
96 #define PIM_VER(x) (((x) & 0xf0) >> 4)
97 #define PIM_TYPE(x) ((x) & 0x0f)
98 u_char pim_rsv
; /* Reserved */
99 u_short pim_cksum
; /* IP style check sum */
106 #include "interface.h"
107 #include "addrtoname.h"
112 static void pimv2_print(register const u_char
*bp
, register u_int len
);
115 pimv1_join_prune_print(register const u_char
*bp
, register u_int len
)
117 int maddrlen
, addrlen
, ngroups
, njoin
, nprune
;
120 /* If it's a single group and a single source, use 1-line output. */
121 if (TTEST2(bp
[0], 30) && bp
[11] == 1 &&
122 ((njoin
= EXTRACT_16BITS(&bp
[20])) + EXTRACT_16BITS(&bp
[22])) == 1) {
125 (void)printf(" RPF %s ", ipaddr_string(bp
));
126 hold
= EXTRACT_16BITS(&bp
[6]);
128 (void)printf("Hold ");
131 (void)printf("%s (%s/%d, %s", njoin
? "Join" : "Prune",
132 ipaddr_string(&bp
[26]), bp
[25] & 0x3f,
133 ipaddr_string(&bp
[12]));
134 if (EXTRACT_32BITS(&bp
[16]) != 0xffffffff)
135 (void)printf("/%s", ipaddr_string(&bp
[16]));
136 (void)printf(") %s%s %s",
137 (bp
[24] & 0x01) ? "Sparse" : "Dense",
138 (bp
[25] & 0x80) ? " WC" : "",
139 (bp
[25] & 0x40) ? "RP" : "SPT");
146 (void)printf(" Upstream Nbr: %s", ipaddr_string(bp
));
150 (void)printf(" Hold time: ");
151 relts_print(EXTRACT_16BITS(&bp
[6]));
165 (void)printf("\n\tGroup: %s", ipaddr_string(bp
));
167 if (EXTRACT_32BITS(&bp
[4]) != 0xffffffff)
168 (void)printf("/%s", ipaddr_string(&bp
[4]));
170 njoin
= EXTRACT_16BITS(&bp
[8]);
171 nprune
= EXTRACT_16BITS(&bp
[10]);
172 (void)printf(" joined: %d pruned: %d", njoin
, nprune
);
175 for (njp
= 0; njp
< (njoin
+ nprune
); njp
++) {
183 (void)printf("\n\t%s %s%s%s%s/%d", type
,
184 (bp
[0] & 0x01) ? "Sparse " : "Dense ",
185 (bp
[1] & 0x80) ? "WC " : "",
186 (bp
[1] & 0x40) ? "RP " : "SPT ",
187 ipaddr_string(&bp
[2]), bp
[1] & 0x3f);
194 (void)printf("[|pim]");
199 pimv1_print(register const u_char
*bp
, register u_int len
)
201 register const u_char
*ep
;
202 register u_char type
;
204 ep
= (const u_char
*)snapend
;
213 (void)printf(" Query");
215 switch (bp
[8] >> 4) {
217 (void)printf(" Dense-mode");
220 (void)printf(" Sparse-mode");
223 (void)printf(" Sparse-Dense-mode");
226 (void)printf(" mode-%d", bp
[8] >> 4);
232 (void)printf(" (Hold-time ");
233 relts_print(EXTRACT_16BITS(&bp
[10]));
239 (void)printf(" Register");
240 TCHECK2(bp
[8], 20); /* ip header */
241 (void)printf(" for %s > %s", ipaddr_string(&bp
[20]),
242 ipaddr_string(&bp
[24]));
245 (void)printf(" Register-Stop");
247 (void)printf(" for %s > %s", ipaddr_string(&bp
[8]),
248 ipaddr_string(&bp
[12]));
251 (void)printf(" Join/Prune");
253 pimv1_join_prune_print(&bp
[8], len
- 8);
256 (void)printf(" RP-reachable");
259 (void)printf(" group %s",
260 ipaddr_string(&bp
[8]));
261 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
262 (void)printf("/%s", ipaddr_string(&bp
[12]));
263 (void)printf(" RP %s hold ", ipaddr_string(&bp
[16]));
264 relts_print(EXTRACT_16BITS(&bp
[22]));
268 (void)printf(" Assert");
270 (void)printf(" for %s > %s", ipaddr_string(&bp
[16]),
271 ipaddr_string(&bp
[8]));
272 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
273 (void)printf("/%s", ipaddr_string(&bp
[12]));
275 (void)printf(" %s pref %d metric %d",
276 (bp
[20] & 0x80) ? "RP-tree" : "SPT",
277 EXTRACT_32BITS(&bp
[20]) & 0x7fffffff,
278 EXTRACT_32BITS(&bp
[24]));
281 (void)printf(" Graft");
283 pimv1_join_prune_print(&bp
[8], len
- 8);
286 (void)printf(" Graft-ACK");
288 pimv1_join_prune_print(&bp
[8], len
- 8);
291 (void)printf(" Mode");
294 (void)printf(" [type %d]", type
);
297 if ((bp
[4] >> 4) != 1)
298 (void)printf(" [v%d]", bp
[4] >> 4);
302 (void)printf("[|pim]");
307 * auto-RP is a cisco protocol, documented at
308 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
310 * This implements version 1+, dated Sept 9, 1998.
313 cisco_autorp_print(register const u_char
*bp
, register u_int len
)
320 (void)printf(" auto-rp ");
324 (void)printf("candidate-advert");
327 (void)printf("mapping");
330 (void)printf("type-0x%02x", type
);
338 (void)printf(" Hold ");
339 hold
= EXTRACT_16BITS(&bp
[2]);
341 relts_print(EXTRACT_16BITS(&bp
[2]));
345 /* Next 4 bytes are reserved. */
349 /*XXX skip unless -v? */
353 * numrps entries of the form:
356 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
357 * 8 bits: # of entries for this RP
358 * each entry: 7 bits: reserved, 1 bit: negative,
359 * 8 bits: mask 32 bits: source
360 * lather, rinse, repeat.
367 (void)printf(" RP %s", ipaddr_string(bp
));
369 switch (bp
[4] & 0x3) {
370 case 0: printf(" PIMv?");
372 case 1: printf(" PIMv1");
374 case 2: printf(" PIMv2");
376 case 3: printf(" PIMv1+2");
380 (void)printf(" [rsvd=0x%02x]", bp
[4] & 0xfc);
385 for (; nentries
; nentries
--) {
387 (void)printf("%c%s%s/%d", s
, bp
[0] & 1 ? "!" : "",
388 ipaddr_string(&bp
[2]), bp
[1]);
390 (void)printf("[rsvd=0x%02x]", bp
[0] & 0xfe);
398 (void)printf("[|autorp]");
403 pim_print(register const u_char
*bp
, register u_int len
)
405 register const u_char
*ep
;
406 register struct pim
*pim
= (struct pim
*)bp
;
408 ep
= (const u_char
*)snapend
;
411 #ifdef notyet /* currently we see only version and type */
412 TCHECK(pim
->pim_rsv
);
415 switch (PIM_VER(pim
->pim_typever
)) {
418 printf("PIMv%u, %s (%u), length: %u",
419 PIM_VER(pim
->pim_typever
),
420 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
421 PIM_TYPE(pim
->pim_typever
),
425 printf("PIMv%u, length: %u\n\t%s (%u)",
426 PIM_VER(pim
->pim_typever
),
428 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
429 PIM_TYPE(pim
->pim_typever
));
430 pimv2_print(bp
, len
);
434 printf("PIMv%u, length: %u",
435 PIM_VER(pim
->pim_typever
),
443 * PIMv2 uses encoded address representations.
445 * The last PIM-SM I-D before RFC2117 was published specified the
446 * following representation for unicast addresses. However, RFC2117
447 * specified no encoding for unicast addresses with the unicast
448 * address length specified in the header. Therefore, we have to
449 * guess which encoding is being used (Cisco's PIMv2 implementation
450 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
451 * field into a 'unicast-address-length-in-bytes' field. We guess
452 * that it's the draft encoding if this reserved field is zero.
454 * RFC2362 goes back to the encoded format, and calls the addr length
455 * field "reserved" again.
457 * The first byte is the address family, from:
460 * 1 IP (IP version 4)
461 * 2 IP6 (IP version 6)
463 * 4 HDLC (8-bit multidrop)
465 * 6 802 (includes all 802 media plus Ethernet "canonical format")
467 * 8 E.164 (SMDS, Frame Relay, ATM)
469 * 10 X.121 (X.25, Frame Relay)
474 * 15 E.164 with NSAP format subaddress
476 * In addition, the second byte is an "Encoding". 0 is the default
477 * encoding for the address family, and no other encodings are currently
482 static int pimv2_addr_len
;
484 enum pimv2_addrtype
{
485 pimv2_unicast
, pimv2_group
, pimv2_source
489 * 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
490 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
491 * | Addr Family | Encoding Type | Unicast Address |
492 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
494 * 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
495 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
496 * | Addr Family | Encoding Type | Reserved | Mask Len |
497 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
498 * | Group multicast Address |
499 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
501 * 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
502 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
503 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
504 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
506 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
509 pimv2_addr_print(const u_char
*bp
, enum pimv2_addrtype at
, int silent
)
517 if (pimv2_addr_len
== 0) {
539 switch (pimv2_addr_len
) {
554 len
= pimv2_addr_len
;
564 (void)printf("%s", ipaddr_string(bp
));
567 else if (af
== AF_INET6
) {
569 (void)printf("%s", ip6addr_string(bp
));
575 TCHECK2(bp
[0], len
+ 2);
578 (void)printf("%s", ipaddr_string(bp
+ 2));
580 (void)printf("/%u", bp
[1]);
584 else if (af
== AF_INET6
) {
586 (void)printf("%s", ip6addr_string(bp
+ 2));
588 (void)printf("/%u", bp
[1]);
592 if (bp
[0] && !silent
) {
593 if (at
== pimv2_group
) {
594 (void)printf("(0x%02x)", bp
[0]);
596 (void)printf("(%s%s%s",
597 bp
[0] & 0x04 ? "S" : "",
598 bp
[0] & 0x02 ? "W" : "",
599 bp
[0] & 0x01 ? "R" : "");
601 (void) printf("+0x%02x", bp
[0] & 0xf8);
606 return hdrlen
+ 2 + len
;
615 pimv2_print(register const u_char
*bp
, register u_int len
)
617 register const u_char
*ep
;
618 register struct pim
*pim
= (struct pim
*)bp
;
621 ep
= (const u_char
*)snapend
;
626 TCHECK(pim
->pim_rsv
);
627 pimv2_addr_len
= pim
->pim_rsv
;
628 if (pimv2_addr_len
!= 0)
629 (void)printf(", RFC2117-encoding");
631 switch (PIM_TYPE(pim
->pim_typever
)) {
632 case PIMV2_TYPE_HELLO
:
634 u_int16_t otype
, olen
;
638 otype
= EXTRACT_16BITS(&bp
[0]);
639 olen
= EXTRACT_16BITS(&bp
[2]);
640 TCHECK2(bp
[0], 4 + olen
);
642 printf("\n\t %s Option (%u), length: %u, Value: ",
643 tok2str( pimv2_hello_option_values
,"Unknown",otype
),
649 case PIMV2_HELLO_OPTION_HOLDTIME
:
650 relts_print(EXTRACT_16BITS(bp
));
653 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
655 (void)printf("ERROR: Option Lenght != 4 Bytes (%u)", olen
);
658 u_int16_t lan_delay
, override_interval
;
659 lan_delay
= EXTRACT_16BITS(bp
);
660 override_interval
= EXTRACT_16BITS(bp
+2);
661 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
662 lan_delay
&= ~0x8000;
663 (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
664 t_bit
, lan_delay
, override_interval
);
668 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
669 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
672 printf("Bi-Directional Capability (Old)");
675 printf("%u", EXTRACT_32BITS(bp
));
678 printf("ERROR: Option Lenght != 4 Bytes (%u)", olen
);
683 case PIMV2_HELLO_OPTION_GENID
:
684 (void)printf("0x%08x", EXTRACT_32BITS(bp
));
687 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
688 (void)printf("v%d", *bp
);
690 (void)printf(", interval ");
691 relts_print(*(bp
+1));
693 if (EXTRACT_16BITS(bp
+2) != 0) {
694 (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp
+2));
698 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
701 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
702 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
704 const u_char
*ptr
= bp
;
705 while (ptr
< (bp
+olen
)) {
709 advance
= pimv2_addr_print(ptr
, pimv2_unicast
, 0);
720 print_unknown_data(bp
,"\n\t ",olen
);
723 /* do we want to see an additionally hexdump ? */
725 print_unknown_data(bp
,"\n\t ",olen
);
731 case PIMV2_TYPE_REGISTER
:
735 if (vflag
&& bp
+ 8 <= ep
) {
736 (void)printf(" %s%s", bp
[4] & 0x80 ? "B" : "",
737 bp
[4] & 0x40 ? "N" : "");
741 /* encapsulated multicast packet */
744 ip
= (struct ip
*)bp
;
757 (void)printf(" IP ver %d", IP_V(ip
));
763 case PIMV2_TYPE_REGISTER_STOP
:
767 (void)printf(" group=");
768 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
772 bp
+= advance
; len
-= advance
;
775 (void)printf(" source=");
776 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
780 bp
+= advance
; len
-= advance
;
783 case PIMV2_TYPE_JOIN_PRUNE
:
784 case PIMV2_TYPE_GRAFT
:
785 case PIMV2_TYPE_GRAFT_ACK
:
790 * 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
791 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
792 * |PIM Ver| Type | Addr length | Checksum |
793 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
794 * | Unicast-Upstream Neighbor Address |
795 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
796 * | Reserved | Num groups | Holdtime |
797 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
798 * | Encoded-Multicast Group Address-1 |
799 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
800 * | Number of Joined Sources | Number of Pruned Sources |
801 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
802 * | Encoded-Joined Source Address-1 |
803 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
806 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
807 * | Encoded-Joined Source Address-n |
808 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
809 * | Encoded-Pruned Source Address-1 |
810 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
813 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
814 * | Encoded-Pruned Source Address-n |
815 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
818 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
819 * | Encoded-Multicast Group Address-n |
820 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
831 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
834 (void)printf(", upstream-neighbor: ");
835 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
839 bp
+= advance
; len
-= advance
;
844 holdtime
= EXTRACT_16BITS(&bp
[2]);
845 (void)printf("\n\t %u group(s)", ngroup
);
846 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
847 (void)printf(", holdtime: ");
848 if (holdtime
== 0xffff)
849 (void)printf("infinite");
851 relts_print(holdtime
);
854 for (i
= 0; i
< ngroup
; i
++) {
857 (void)printf("\n\t group #%u: ", i
+1);
858 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
859 (void)printf("...)");
862 bp
+= advance
; len
-= advance
;
864 (void)printf("...)");
867 njoin
= EXTRACT_16BITS(&bp
[0]);
868 nprune
= EXTRACT_16BITS(&bp
[2]);
869 (void)printf(", joined sources: %u, pruned sources: %u", njoin
,nprune
);
871 for (j
= 0; j
< njoin
; j
++) {
872 (void)printf("\n\t joined source #%u: ",j
+1);
873 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
874 (void)printf("...)");
877 bp
+= advance
; len
-= advance
;
879 for (j
= 0; j
< nprune
; j
++) {
880 (void)printf("\n\t pruned source #%u: ",j
+1);
881 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
882 (void)printf("...)");
885 bp
+= advance
; len
-= advance
;
892 case PIMV2_TYPE_BOOTSTRAP
:
897 /* Fragment Tag, Hash Mask len, and BSR-priority */
898 if (bp
+ sizeof(u_int16_t
) >= ep
) break;
899 (void)printf(" tag=%x", EXTRACT_16BITS(bp
));
900 bp
+= sizeof(u_int16_t
);
902 (void)printf(" hashmlen=%d", bp
[0]);
903 if (bp
+ 1 >= ep
) break;
904 (void)printf(" BSRprio=%d", bp
[1]);
907 /* Encoded-Unicast-BSR-Address */
909 (void)printf(" BSR=");
910 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
916 for (i
= 0; bp
< ep
; i
++) {
917 /* Encoded-Group Address */
918 (void)printf(" (group%d: ", i
);
919 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
921 (void)printf("...)");
926 /* RP-Count, Frag RP-Cnt, and rsvd */
928 (void)printf("...)");
931 (void)printf(" RPcnt=%d", bp
[0]);
933 (void)printf("...)");
936 (void)printf(" FRPcnt=%d", frpcnt
= bp
[1]);
939 for (j
= 0; j
< frpcnt
&& bp
< ep
; j
++) {
941 (void)printf(" RP%d=", j
);
942 if ((advance
= pimv2_addr_print(bp
,
945 (void)printf("...)");
951 (void)printf("...)");
954 (void)printf(",holdtime=");
955 relts_print(EXTRACT_16BITS(bp
));
957 (void)printf("...)");
960 (void)printf(",prio=%d", bp
[2]);
968 case PIMV2_TYPE_ASSERT
:
972 (void)printf(" group=");
973 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
977 bp
+= advance
; len
-= advance
;
980 (void)printf(" src=");
981 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
985 bp
+= advance
; len
-= advance
;
989 (void)printf(" RPT");
990 (void)printf(" pref=%u", EXTRACT_32BITS(&bp
[0]) & 0x7fffffff);
991 (void)printf(" metric=%u", EXTRACT_32BITS(&bp
[4]));
994 case PIMV2_TYPE_CANDIDATE_RP
:
999 /* Prefix-Cnt, Priority, and Holdtime */
1000 if (bp
>= ep
) break;
1001 (void)printf(" prefix-cnt=%d", bp
[0]);
1003 if (bp
+ 1 >= ep
) break;
1004 (void)printf(" prio=%d", bp
[1]);
1005 if (bp
+ 3 >= ep
) break;
1006 (void)printf(" holdtime=");
1007 relts_print(EXTRACT_16BITS(&bp
[2]));
1010 /* Encoded-Unicast-RP-Address */
1011 if (bp
>= ep
) break;
1012 (void)printf(" RP=");
1013 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1014 (void)printf("...");
1019 /* Encoded-Group Addresses */
1020 for (i
= 0; i
< pfxcnt
&& bp
< ep
; i
++) {
1021 (void)printf(" Group%d=", i
);
1022 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
1024 (void)printf("...");
1032 case PIMV2_TYPE_PRUNE_REFRESH
:
1033 (void)printf(" src=");
1034 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1035 (void)printf("...");
1039 (void)printf(" grp=");
1040 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
1041 (void)printf("...");
1045 (void)printf(" forwarder=");
1046 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1047 (void)printf("...");
1052 (void)printf(" TUNR ");
1053 relts_print(EXTRACT_16BITS(bp
));
1058 (void)printf(" [type %d]", PIM_TYPE(pim
->pim_typever
));
1065 (void)printf("[|pim]");