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.42 2004-03-18 14:12:18 hannes 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
));
166 if (EXTRACT_32BITS(&bp
[4]) != 0xffffffff)
167 (void)printf("/%s", ipaddr_string(&bp
[4]));
169 njoin
= EXTRACT_16BITS(&bp
[8]);
170 nprune
= EXTRACT_16BITS(&bp
[10]);
171 (void)printf(" joined: %d pruned: %d", njoin
, nprune
);
174 for (njp
= 0; njp
< (njoin
+ nprune
); njp
++) {
182 (void)printf("\n\t%s %s%s%s%s/%d", type
,
183 (bp
[0] & 0x01) ? "Sparse " : "Dense ",
184 (bp
[1] & 0x80) ? "WC " : "",
185 (bp
[1] & 0x40) ? "RP " : "SPT ",
186 ipaddr_string(&bp
[2]), bp
[1] & 0x3f);
193 (void)printf("[|pim]");
198 pimv1_print(register const u_char
*bp
, register u_int len
)
200 register const u_char
*ep
;
201 register u_char type
;
203 ep
= (const u_char
*)snapend
;
212 (void)printf(" Query");
214 switch (bp
[8] >> 4) {
216 (void)printf(" Dense-mode");
219 (void)printf(" Sparse-mode");
222 (void)printf(" Sparse-Dense-mode");
225 (void)printf(" mode-%d", bp
[8] >> 4);
231 (void)printf(" (Hold-time ");
232 relts_print(EXTRACT_16BITS(&bp
[10]));
238 (void)printf(" Register");
239 TCHECK2(bp
[8], 20); /* ip header */
240 (void)printf(" for %s > %s", ipaddr_string(&bp
[20]),
241 ipaddr_string(&bp
[24]));
244 (void)printf(" Register-Stop");
246 (void)printf(" for %s > %s", ipaddr_string(&bp
[8]),
247 ipaddr_string(&bp
[12]));
250 (void)printf(" Join/Prune");
252 pimv1_join_prune_print(&bp
[8], len
- 8);
255 (void)printf(" RP-reachable");
258 (void)printf(" group %s",
259 ipaddr_string(&bp
[8]));
260 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
261 (void)printf("/%s", ipaddr_string(&bp
[12]));
262 (void)printf(" RP %s hold ", ipaddr_string(&bp
[16]));
263 relts_print(EXTRACT_16BITS(&bp
[22]));
267 (void)printf(" Assert");
269 (void)printf(" for %s > %s", ipaddr_string(&bp
[16]),
270 ipaddr_string(&bp
[8]));
271 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
272 (void)printf("/%s", ipaddr_string(&bp
[12]));
274 (void)printf(" %s pref %d metric %d",
275 (bp
[20] & 0x80) ? "RP-tree" : "SPT",
276 EXTRACT_32BITS(&bp
[20]) & 0x7fffffff,
277 EXTRACT_32BITS(&bp
[24]));
280 (void)printf(" Graft");
282 pimv1_join_prune_print(&bp
[8], len
- 8);
285 (void)printf(" Graft-ACK");
287 pimv1_join_prune_print(&bp
[8], len
- 8);
290 (void)printf(" Mode");
293 (void)printf(" [type %d]", type
);
296 if ((bp
[4] >> 4) != 1)
297 (void)printf(" [v%d]", bp
[4] >> 4);
301 (void)printf("[|pim]");
306 * auto-RP is a cisco protocol, documented at
307 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
309 * This implements version 1+, dated Sept 9, 1998.
312 cisco_autorp_print(register const u_char
*bp
, register u_int len
)
319 (void)printf(" auto-rp ");
323 (void)printf("candidate-advert");
326 (void)printf("mapping");
329 (void)printf("type-0x%02x", type
);
337 (void)printf(" Hold ");
338 hold
= EXTRACT_16BITS(&bp
[2]);
340 relts_print(EXTRACT_16BITS(&bp
[2]));
344 /* Next 4 bytes are reserved. */
348 /*XXX skip unless -v? */
352 * numrps entries of the form:
355 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
356 * 8 bits: # of entries for this RP
357 * each entry: 7 bits: reserved, 1 bit: negative,
358 * 8 bits: mask 32 bits: source
359 * lather, rinse, repeat.
366 (void)printf(" RP %s", ipaddr_string(bp
));
368 switch (bp
[4] & 0x3) {
369 case 0: printf(" PIMv?");
371 case 1: printf(" PIMv1");
373 case 2: printf(" PIMv2");
375 case 3: printf(" PIMv1+2");
379 (void)printf(" [rsvd=0x%02x]", bp
[4] & 0xfc);
384 for (; nentries
; nentries
--) {
386 (void)printf("%c%s%s/%d", s
, bp
[0] & 1 ? "!" : "",
387 ipaddr_string(&bp
[2]), bp
[1]);
389 (void)printf("[rsvd=0x%02x]", bp
[0] & 0xfe);
397 (void)printf("[|autorp]");
402 pim_print(register const u_char
*bp
, register u_int len
)
404 register const u_char
*ep
;
405 register struct pim
*pim
= (struct pim
*)bp
;
407 ep
= (const u_char
*)snapend
;
410 #ifdef notyet /* currently we see only version and type */
411 TCHECK(pim
->pim_rsv
);
414 switch (PIM_VER(pim
->pim_typever
)) {
417 printf("PIMv%u, %s (%u), length: %u",
418 PIM_VER(pim
->pim_typever
),
419 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
420 PIM_TYPE(pim
->pim_typever
),
424 printf("PIMv%u, length: %u\n\t%s (%u)",
425 PIM_VER(pim
->pim_typever
),
427 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
428 PIM_TYPE(pim
->pim_typever
));
429 pimv2_print(bp
, len
);
433 printf("PIMv%u, length: %u",
434 PIM_VER(pim
->pim_typever
),
442 * PIMv2 uses encoded address representations.
444 * The last PIM-SM I-D before RFC2117 was published specified the
445 * following representation for unicast addresses. However, RFC2117
446 * specified no encoding for unicast addresses with the unicast
447 * address length specified in the header. Therefore, we have to
448 * guess which encoding is being used (Cisco's PIMv2 implementation
449 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
450 * field into a 'unicast-address-length-in-bytes' field. We guess
451 * that it's the draft encoding if this reserved field is zero.
453 * RFC2362 goes back to the encoded format, and calls the addr length
454 * field "reserved" again.
456 * The first byte is the address family, from:
459 * 1 IP (IP version 4)
460 * 2 IP6 (IP version 6)
462 * 4 HDLC (8-bit multidrop)
464 * 6 802 (includes all 802 media plus Ethernet "canonical format")
466 * 8 E.164 (SMDS, Frame Relay, ATM)
468 * 10 X.121 (X.25, Frame Relay)
473 * 15 E.164 with NSAP format subaddress
475 * In addition, the second byte is an "Encoding". 0 is the default
476 * encoding for the address family, and no other encodings are currently
481 static int pimv2_addr_len
;
483 enum pimv2_addrtype
{
484 pimv2_unicast
, pimv2_group
, pimv2_source
488 * 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
489 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
490 * | Addr Family | Encoding Type | Unicast Address |
491 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
493 * 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
494 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
495 * | Addr Family | Encoding Type | Reserved | Mask Len |
496 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
497 * | Group multicast Address |
498 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
500 * 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
501 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
502 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
503 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
505 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
508 pimv2_addr_print(const u_char
*bp
, enum pimv2_addrtype at
, int silent
)
516 if (pimv2_addr_len
== 0) {
538 switch (pimv2_addr_len
) {
553 len
= pimv2_addr_len
;
563 (void)printf("%s", ipaddr_string(bp
));
566 else if (af
== AF_INET6
) {
568 (void)printf("%s", ip6addr_string(bp
));
574 TCHECK2(bp
[0], len
+ 2);
577 (void)printf("%s", ipaddr_string(bp
+ 2));
579 (void)printf("/%u", bp
[1]);
583 else if (af
== AF_INET6
) {
585 (void)printf("%s", ip6addr_string(bp
+ 2));
587 (void)printf("/%u", bp
[1]);
591 if (bp
[0] && !silent
) {
592 if (at
== pimv2_group
) {
593 (void)printf("(0x%02x)", bp
[0]);
595 (void)printf("(%s%s%s",
596 bp
[0] & 0x04 ? "S" : "",
597 bp
[0] & 0x02 ? "W" : "",
598 bp
[0] & 0x01 ? "R" : "");
600 (void) printf("+0x%02x", bp
[0] & 0xf8);
605 return hdrlen
+ 2 + len
;
614 pimv2_print(register const u_char
*bp
, register u_int len
)
616 register const u_char
*ep
;
617 register struct pim
*pim
= (struct pim
*)bp
;
620 ep
= (const u_char
*)snapend
;
625 TCHECK(pim
->pim_rsv
);
626 pimv2_addr_len
= pim
->pim_rsv
;
627 if (pimv2_addr_len
!= 0)
628 (void)printf(", RFC2117-encoding");
630 switch (PIM_TYPE(pim
->pim_typever
)) {
631 case PIMV2_TYPE_HELLO
:
633 u_int16_t otype
, olen
;
637 otype
= EXTRACT_16BITS(&bp
[0]);
638 olen
= EXTRACT_16BITS(&bp
[2]);
639 TCHECK2(bp
[0], 4 + olen
);
641 printf("\n\t %s Option (%u), length: %u, Value: ",
642 tok2str( pimv2_hello_option_values
,"Unknown",otype
),
648 case PIMV2_HELLO_OPTION_HOLDTIME
:
649 relts_print(EXTRACT_16BITS(bp
));
652 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
654 (void)printf("ERROR: Option Lenght != 4 Bytes (%u)", olen
);
657 u_int16_t lan_delay
, override_interval
;
658 lan_delay
= EXTRACT_16BITS(bp
);
659 override_interval
= EXTRACT_16BITS(bp
+2);
660 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
661 lan_delay
&= ~0x8000;
662 (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
663 t_bit
, lan_delay
, override_interval
);
667 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
668 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
671 printf("Bi-Directional Capability (Old)");
674 printf("%u", EXTRACT_32BITS(bp
));
677 printf("ERROR: Option Lenght != 4 Bytes (%u)", olen
);
682 case PIMV2_HELLO_OPTION_GENID
:
683 (void)printf("0x%08x", EXTRACT_32BITS(bp
));
686 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
687 (void)printf("v%d", *bp
);
689 (void)printf(", interval ");
690 relts_print(*(bp
+1));
692 if (EXTRACT_16BITS(bp
+2) != 0) {
693 (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp
+2));
697 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
700 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
701 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
703 const u_char
*ptr
= bp
;
704 while (ptr
< (bp
+olen
)) {
708 advance
= pimv2_addr_print(ptr
, pimv2_unicast
, 0);
719 print_unknown_data(bp
,"\n\t ",olen
);
722 /* do we want to see an additionally hexdump ? */
724 print_unknown_data(bp
,"\n\t ",olen
);
730 case PIMV2_TYPE_REGISTER
:
734 if (vflag
&& bp
+ 8 <= ep
) {
735 (void)printf(" %s%s", bp
[4] & 0x80 ? "B" : "",
736 bp
[4] & 0x40 ? "N" : "");
740 /* encapsulated multicast packet */
743 ip
= (struct ip
*)bp
;
756 (void)printf(" IP ver %d", IP_V(ip
));
762 case PIMV2_TYPE_REGISTER_STOP
:
766 (void)printf(" group=");
767 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
771 bp
+= advance
; len
-= advance
;
774 (void)printf(" source=");
775 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
779 bp
+= advance
; len
-= advance
;
782 case PIMV2_TYPE_JOIN_PRUNE
:
783 case PIMV2_TYPE_GRAFT
:
784 case PIMV2_TYPE_GRAFT_ACK
:
789 * 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
790 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
791 * |PIM Ver| Type | Addr length | Checksum |
792 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
793 * | Unicast-Upstream Neighbor Address |
794 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
795 * | Reserved | Num groups | Holdtime |
796 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
797 * | Encoded-Multicast Group Address-1 |
798 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
799 * | Number of Joined Sources | Number of Pruned Sources |
800 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
801 * | Encoded-Joined Source Address-1 |
802 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
805 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
806 * | Encoded-Joined Source Address-n |
807 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
808 * | Encoded-Pruned Source Address-1 |
809 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
812 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
813 * | Encoded-Pruned Source Address-n |
814 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
817 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
818 * | Encoded-Multicast Group Address-n |
819 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
830 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
833 (void)printf(", upstream-neighbor: ");
834 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
838 bp
+= advance
; len
-= advance
;
843 holdtime
= EXTRACT_16BITS(&bp
[2]);
844 (void)printf("\n\t %u group(s)", ngroup
);
845 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
846 (void)printf(", holdtime: ");
847 if (holdtime
== 0xffff)
848 (void)printf("infinite");
850 relts_print(holdtime
);
853 for (i
= 0; i
< ngroup
; i
++) {
856 (void)printf("\n\t group #%u: ", i
+1);
857 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
858 (void)printf("...)");
861 bp
+= advance
; len
-= advance
;
863 (void)printf("...)");
866 njoin
= EXTRACT_16BITS(&bp
[0]);
867 nprune
= EXTRACT_16BITS(&bp
[2]);
868 (void)printf(", joined sources: %u, pruned sources: %u", njoin
,nprune
);
870 for (j
= 0; j
< njoin
; j
++) {
871 (void)printf("\n\t joined source #%u: ",j
+1);
872 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
873 (void)printf("...)");
876 bp
+= advance
; len
-= advance
;
878 for (j
= 0; j
< nprune
; j
++) {
879 (void)printf("\n\t pruned source #%u: ",j
+1);
880 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
881 (void)printf("...)");
884 bp
+= advance
; len
-= advance
;
891 case PIMV2_TYPE_BOOTSTRAP
:
896 /* Fragment Tag, Hash Mask len, and BSR-priority */
897 if (bp
+ sizeof(u_int16_t
) >= ep
) break;
898 (void)printf(" tag=%x", EXTRACT_16BITS(bp
));
899 bp
+= sizeof(u_int16_t
);
901 (void)printf(" hashmlen=%d", bp
[0]);
902 if (bp
+ 1 >= ep
) break;
903 (void)printf(" BSRprio=%d", bp
[1]);
906 /* Encoded-Unicast-BSR-Address */
908 (void)printf(" BSR=");
909 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
915 for (i
= 0; bp
< ep
; i
++) {
916 /* Encoded-Group Address */
917 (void)printf(" (group%d: ", i
);
918 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
920 (void)printf("...)");
925 /* RP-Count, Frag RP-Cnt, and rsvd */
927 (void)printf("...)");
930 (void)printf(" RPcnt=%d", bp
[0]);
932 (void)printf("...)");
935 (void)printf(" FRPcnt=%d", frpcnt
= bp
[1]);
938 for (j
= 0; j
< frpcnt
&& bp
< ep
; j
++) {
940 (void)printf(" RP%d=", j
);
941 if ((advance
= pimv2_addr_print(bp
,
944 (void)printf("...)");
950 (void)printf("...)");
953 (void)printf(",holdtime=");
954 relts_print(EXTRACT_16BITS(bp
));
956 (void)printf("...)");
959 (void)printf(",prio=%d", bp
[2]);
967 case PIMV2_TYPE_ASSERT
:
971 (void)printf(" group=");
972 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
976 bp
+= advance
; len
-= advance
;
979 (void)printf(" src=");
980 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
984 bp
+= advance
; len
-= advance
;
988 (void)printf(" RPT");
989 (void)printf(" pref=%u", EXTRACT_32BITS(&bp
[0]) & 0x7fffffff);
990 (void)printf(" metric=%u", EXTRACT_32BITS(&bp
[4]));
993 case PIMV2_TYPE_CANDIDATE_RP
:
998 /* Prefix-Cnt, Priority, and Holdtime */
1000 (void)printf(" prefix-cnt=%d", bp
[0]);
1002 if (bp
+ 1 >= ep
) break;
1003 (void)printf(" prio=%d", bp
[1]);
1004 if (bp
+ 3 >= ep
) break;
1005 (void)printf(" holdtime=");
1006 relts_print(EXTRACT_16BITS(&bp
[2]));
1009 /* Encoded-Unicast-RP-Address */
1010 if (bp
>= ep
) break;
1011 (void)printf(" RP=");
1012 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1013 (void)printf("...");
1018 /* Encoded-Group Addresses */
1019 for (i
= 0; i
< pfxcnt
&& bp
< ep
; i
++) {
1020 (void)printf(" Group%d=", i
);
1021 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
1023 (void)printf("...");
1031 case PIMV2_TYPE_PRUNE_REFRESH
:
1032 (void)printf(" src=");
1033 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1034 (void)printf("...");
1038 (void)printf(" grp=");
1039 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
1040 (void)printf("...");
1044 (void)printf(" forwarder=");
1045 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1046 (void)printf("...");
1051 (void)printf(" TUNR ");
1052 relts_print(EXTRACT_16BITS(bp
));
1057 (void)printf(" [type %d]", PIM_TYPE(pim
->pim_typever
));
1064 (void)printf("[|pim]");