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.46 2005-04-20 22:05:08 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 * XXX - does the address have length "addrlen" and the
166 * mask length "maddrlen"?
169 (void)printf("\n\tGroup: %s", ipaddr_string(bp
));
171 if (EXTRACT_32BITS(&bp
[4]) != 0xffffffff)
172 (void)printf("/%s", ipaddr_string(&bp
[4]));
174 njoin
= EXTRACT_16BITS(&bp
[8]);
175 nprune
= EXTRACT_16BITS(&bp
[10]);
176 (void)printf(" joined: %d pruned: %d", njoin
, nprune
);
179 for (njp
= 0; njp
< (njoin
+ nprune
); njp
++) {
187 (void)printf("\n\t%s %s%s%s%s/%d", type
,
188 (bp
[0] & 0x01) ? "Sparse " : "Dense ",
189 (bp
[1] & 0x80) ? "WC " : "",
190 (bp
[1] & 0x40) ? "RP " : "SPT ",
191 ipaddr_string(&bp
[2]), bp
[1] & 0x3f);
198 (void)printf("[|pim]");
203 pimv1_print(register const u_char
*bp
, register u_int len
)
205 register const u_char
*ep
;
206 register u_char type
;
208 ep
= (const u_char
*)snapend
;
217 (void)printf(" Query");
219 switch (bp
[8] >> 4) {
221 (void)printf(" Dense-mode");
224 (void)printf(" Sparse-mode");
227 (void)printf(" Sparse-Dense-mode");
230 (void)printf(" mode-%d", bp
[8] >> 4);
236 (void)printf(" (Hold-time ");
237 relts_print(EXTRACT_16BITS(&bp
[10]));
243 (void)printf(" Register");
244 TCHECK2(bp
[8], 20); /* ip header */
245 (void)printf(" for %s > %s", ipaddr_string(&bp
[20]),
246 ipaddr_string(&bp
[24]));
249 (void)printf(" Register-Stop");
251 (void)printf(" for %s > %s", ipaddr_string(&bp
[8]),
252 ipaddr_string(&bp
[12]));
255 (void)printf(" Join/Prune");
257 pimv1_join_prune_print(&bp
[8], len
- 8);
260 (void)printf(" RP-reachable");
263 (void)printf(" group %s",
264 ipaddr_string(&bp
[8]));
265 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
266 (void)printf("/%s", ipaddr_string(&bp
[12]));
267 (void)printf(" RP %s hold ", ipaddr_string(&bp
[16]));
268 relts_print(EXTRACT_16BITS(&bp
[22]));
272 (void)printf(" Assert");
274 (void)printf(" for %s > %s", ipaddr_string(&bp
[16]),
275 ipaddr_string(&bp
[8]));
276 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
277 (void)printf("/%s", ipaddr_string(&bp
[12]));
279 (void)printf(" %s pref %d metric %d",
280 (bp
[20] & 0x80) ? "RP-tree" : "SPT",
281 EXTRACT_32BITS(&bp
[20]) & 0x7fffffff,
282 EXTRACT_32BITS(&bp
[24]));
285 (void)printf(" Graft");
287 pimv1_join_prune_print(&bp
[8], len
- 8);
290 (void)printf(" Graft-ACK");
292 pimv1_join_prune_print(&bp
[8], len
- 8);
295 (void)printf(" Mode");
298 (void)printf(" [type %d]", type
);
301 if ((bp
[4] >> 4) != 1)
302 (void)printf(" [v%d]", bp
[4] >> 4);
306 (void)printf("[|pim]");
311 * auto-RP is a cisco protocol, documented at
312 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
314 * This implements version 1+, dated Sept 9, 1998.
317 cisco_autorp_print(register const u_char
*bp
, register u_int len
)
324 (void)printf(" auto-rp ");
328 (void)printf("candidate-advert");
331 (void)printf("mapping");
334 (void)printf("type-0x%02x", type
);
342 (void)printf(" Hold ");
343 hold
= EXTRACT_16BITS(&bp
[2]);
345 relts_print(EXTRACT_16BITS(&bp
[2]));
349 /* Next 4 bytes are reserved. */
353 /*XXX skip unless -v? */
357 * numrps entries of the form:
360 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
361 * 8 bits: # of entries for this RP
362 * each entry: 7 bits: reserved, 1 bit: negative,
363 * 8 bits: mask 32 bits: source
364 * lather, rinse, repeat.
371 (void)printf(" RP %s", ipaddr_string(bp
));
373 switch (bp
[4] & 0x3) {
374 case 0: printf(" PIMv?");
376 case 1: printf(" PIMv1");
378 case 2: printf(" PIMv2");
380 case 3: printf(" PIMv1+2");
384 (void)printf(" [rsvd=0x%02x]", bp
[4] & 0xfc);
389 for (; nentries
; nentries
--) {
391 (void)printf("%c%s%s/%d", s
, bp
[0] & 1 ? "!" : "",
392 ipaddr_string(&bp
[2]), bp
[1]);
394 (void)printf("[rsvd=0x%02x]", bp
[0] & 0xfe);
402 (void)printf("[|autorp]");
407 pim_print(register const u_char
*bp
, register u_int len
)
409 register const u_char
*ep
;
410 register struct pim
*pim
= (struct pim
*)bp
;
412 ep
= (const u_char
*)snapend
;
415 #ifdef notyet /* currently we see only version and type */
416 TCHECK(pim
->pim_rsv
);
419 switch (PIM_VER(pim
->pim_typever
)) {
422 printf("PIMv%u, %s, length: %u",
423 PIM_VER(pim
->pim_typever
),
424 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
428 printf("PIMv%u, length: %u\n\t%s",
429 PIM_VER(pim
->pim_typever
),
431 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)));
432 pimv2_print(bp
, len
);
436 printf("PIMv%u, length: %u",
437 PIM_VER(pim
->pim_typever
),
445 * PIMv2 uses encoded address representations.
447 * The last PIM-SM I-D before RFC2117 was published specified the
448 * following representation for unicast addresses. However, RFC2117
449 * specified no encoding for unicast addresses with the unicast
450 * address length specified in the header. Therefore, we have to
451 * guess which encoding is being used (Cisco's PIMv2 implementation
452 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
453 * field into a 'unicast-address-length-in-bytes' field. We guess
454 * that it's the draft encoding if this reserved field is zero.
456 * RFC2362 goes back to the encoded format, and calls the addr length
457 * field "reserved" again.
459 * The first byte is the address family, from:
462 * 1 IP (IP version 4)
463 * 2 IP6 (IP version 6)
465 * 4 HDLC (8-bit multidrop)
467 * 6 802 (includes all 802 media plus Ethernet "canonical format")
469 * 8 E.164 (SMDS, Frame Relay, ATM)
471 * 10 X.121 (X.25, Frame Relay)
476 * 15 E.164 with NSAP format subaddress
478 * In addition, the second byte is an "Encoding". 0 is the default
479 * encoding for the address family, and no other encodings are currently
484 static int pimv2_addr_len
;
486 enum pimv2_addrtype
{
487 pimv2_unicast
, pimv2_group
, pimv2_source
491 * 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
492 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
493 * | Addr Family | Encoding Type | Unicast Address |
494 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
496 * 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
497 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
498 * | Addr Family | Encoding Type | Reserved | Mask Len |
499 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
500 * | Group multicast Address |
501 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
503 * 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
504 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
505 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
506 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
508 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
511 pimv2_addr_print(const u_char
*bp
, enum pimv2_addrtype at
, int silent
)
519 if (pimv2_addr_len
== 0) {
541 switch (pimv2_addr_len
) {
556 len
= pimv2_addr_len
;
566 (void)printf("%s", ipaddr_string(bp
));
569 else if (af
== AF_INET6
) {
571 (void)printf("%s", ip6addr_string(bp
));
577 TCHECK2(bp
[0], len
+ 2);
580 (void)printf("%s", ipaddr_string(bp
+ 2));
582 (void)printf("/%u", bp
[1]);
586 else if (af
== AF_INET6
) {
588 (void)printf("%s", ip6addr_string(bp
+ 2));
590 (void)printf("/%u", bp
[1]);
594 if (bp
[0] && !silent
) {
595 if (at
== pimv2_group
) {
596 (void)printf("(0x%02x)", bp
[0]);
598 (void)printf("(%s%s%s",
599 bp
[0] & 0x04 ? "S" : "",
600 bp
[0] & 0x02 ? "W" : "",
601 bp
[0] & 0x01 ? "R" : "");
603 (void) printf("+0x%02x", bp
[0] & 0xf8);
608 return hdrlen
+ 2 + len
;
617 pimv2_print(register const u_char
*bp
, register u_int len
)
619 register const u_char
*ep
;
620 register struct pim
*pim
= (struct pim
*)bp
;
623 ep
= (const u_char
*)snapend
;
628 TCHECK(pim
->pim_rsv
);
629 pimv2_addr_len
= pim
->pim_rsv
;
630 if (pimv2_addr_len
!= 0)
631 (void)printf(", RFC2117-encoding");
633 switch (PIM_TYPE(pim
->pim_typever
)) {
634 case PIMV2_TYPE_HELLO
:
636 u_int16_t otype
, olen
;
640 otype
= EXTRACT_16BITS(&bp
[0]);
641 olen
= EXTRACT_16BITS(&bp
[2]);
642 TCHECK2(bp
[0], 4 + olen
);
644 printf("\n\t %s Option (%u), length: %u, Value: ",
645 tok2str( pimv2_hello_option_values
,"Unknown",otype
),
651 case PIMV2_HELLO_OPTION_HOLDTIME
:
652 relts_print(EXTRACT_16BITS(bp
));
655 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
657 (void)printf("ERROR: Option Lenght != 4 Bytes (%u)", olen
);
660 u_int16_t lan_delay
, override_interval
;
661 lan_delay
= EXTRACT_16BITS(bp
);
662 override_interval
= EXTRACT_16BITS(bp
+2);
663 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
664 lan_delay
&= ~0x8000;
665 (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
666 t_bit
, lan_delay
, override_interval
);
670 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
671 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
674 printf("Bi-Directional Capability (Old)");
677 printf("%u", EXTRACT_32BITS(bp
));
680 printf("ERROR: Option Lenght != 4 Bytes (%u)", olen
);
685 case PIMV2_HELLO_OPTION_GENID
:
686 (void)printf("0x%08x", EXTRACT_32BITS(bp
));
689 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
690 (void)printf("v%d", *bp
);
692 (void)printf(", interval ");
693 relts_print(*(bp
+1));
695 if (EXTRACT_16BITS(bp
+2) != 0) {
696 (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp
+2));
700 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
703 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
704 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
706 const u_char
*ptr
= bp
;
707 while (ptr
< (bp
+olen
)) {
711 advance
= pimv2_addr_print(ptr
, pimv2_unicast
, 0);
722 print_unknown_data(bp
,"\n\t ",olen
);
725 /* do we want to see an additionally hexdump ? */
727 print_unknown_data(bp
,"\n\t ",olen
);
733 case PIMV2_TYPE_REGISTER
:
737 if (vflag
&& bp
+ 8 <= ep
) {
738 (void)printf(" %s%s", bp
[4] & 0x80 ? "B" : "",
739 bp
[4] & 0x40 ? "N" : "");
743 /* encapsulated multicast packet */
746 ip
= (struct ip
*)bp
;
750 ip_print(gndo
, bp
, len
);
759 (void)printf(" IP ver %d", IP_V(ip
));
765 case PIMV2_TYPE_REGISTER_STOP
:
769 (void)printf(" group=");
770 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
774 bp
+= advance
; len
-= advance
;
777 (void)printf(" source=");
778 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
782 bp
+= advance
; len
-= advance
;
785 case PIMV2_TYPE_JOIN_PRUNE
:
786 case PIMV2_TYPE_GRAFT
:
787 case PIMV2_TYPE_GRAFT_ACK
:
792 * 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
793 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
794 * |PIM Ver| Type | Addr length | Checksum |
795 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
796 * | Unicast-Upstream Neighbor Address |
797 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
798 * | Reserved | Num groups | Holdtime |
799 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
800 * | Encoded-Multicast Group Address-1 |
801 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
802 * | Number of Joined Sources | Number of Pruned Sources |
803 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
804 * | Encoded-Joined Source Address-1 |
805 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
808 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
809 * | Encoded-Joined Source Address-n |
810 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
811 * | Encoded-Pruned Source Address-1 |
812 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
815 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
816 * | Encoded-Pruned Source Address-n |
817 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
820 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
821 * | Encoded-Multicast Group Address-n |
822 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
833 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
836 (void)printf(", upstream-neighbor: ");
837 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
841 bp
+= advance
; len
-= advance
;
846 holdtime
= EXTRACT_16BITS(&bp
[2]);
847 (void)printf("\n\t %u group(s)", ngroup
);
848 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
849 (void)printf(", holdtime: ");
850 if (holdtime
== 0xffff)
851 (void)printf("infinite");
853 relts_print(holdtime
);
856 for (i
= 0; i
< ngroup
; i
++) {
859 (void)printf("\n\t group #%u: ", i
+1);
860 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
861 (void)printf("...)");
864 bp
+= advance
; len
-= advance
;
866 (void)printf("...)");
869 njoin
= EXTRACT_16BITS(&bp
[0]);
870 nprune
= EXTRACT_16BITS(&bp
[2]);
871 (void)printf(", joined sources: %u, pruned sources: %u", njoin
,nprune
);
873 for (j
= 0; j
< njoin
; j
++) {
874 (void)printf("\n\t joined source #%u: ",j
+1);
875 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
876 (void)printf("...)");
879 bp
+= advance
; len
-= advance
;
881 for (j
= 0; j
< nprune
; j
++) {
882 (void)printf("\n\t pruned source #%u: ",j
+1);
883 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
884 (void)printf("...)");
887 bp
+= advance
; len
-= advance
;
894 case PIMV2_TYPE_BOOTSTRAP
:
899 /* Fragment Tag, Hash Mask len, and BSR-priority */
900 if (bp
+ sizeof(u_int16_t
) >= ep
) break;
901 (void)printf(" tag=%x", EXTRACT_16BITS(bp
));
902 bp
+= sizeof(u_int16_t
);
904 (void)printf(" hashmlen=%d", bp
[0]);
905 if (bp
+ 1 >= ep
) break;
906 (void)printf(" BSRprio=%d", bp
[1]);
909 /* Encoded-Unicast-BSR-Address */
911 (void)printf(" BSR=");
912 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
918 for (i
= 0; bp
< ep
; i
++) {
919 /* Encoded-Group Address */
920 (void)printf(" (group%d: ", i
);
921 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
923 (void)printf("...)");
928 /* RP-Count, Frag RP-Cnt, and rsvd */
930 (void)printf("...)");
933 (void)printf(" RPcnt=%d", bp
[0]);
935 (void)printf("...)");
938 (void)printf(" FRPcnt=%d", frpcnt
= bp
[1]);
941 for (j
= 0; j
< frpcnt
&& bp
< ep
; j
++) {
943 (void)printf(" RP%d=", j
);
944 if ((advance
= pimv2_addr_print(bp
,
947 (void)printf("...)");
953 (void)printf("...)");
956 (void)printf(",holdtime=");
957 relts_print(EXTRACT_16BITS(bp
));
959 (void)printf("...)");
962 (void)printf(",prio=%d", bp
[2]);
970 case PIMV2_TYPE_ASSERT
:
974 (void)printf(" group=");
975 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
979 bp
+= advance
; len
-= advance
;
982 (void)printf(" src=");
983 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
987 bp
+= advance
; len
-= advance
;
991 (void)printf(" RPT");
992 (void)printf(" pref=%u", EXTRACT_32BITS(&bp
[0]) & 0x7fffffff);
993 (void)printf(" metric=%u", EXTRACT_32BITS(&bp
[4]));
996 case PIMV2_TYPE_CANDIDATE_RP
:
1001 /* Prefix-Cnt, Priority, and Holdtime */
1002 if (bp
>= ep
) break;
1003 (void)printf(" prefix-cnt=%d", bp
[0]);
1005 if (bp
+ 1 >= ep
) break;
1006 (void)printf(" prio=%d", bp
[1]);
1007 if (bp
+ 3 >= ep
) break;
1008 (void)printf(" holdtime=");
1009 relts_print(EXTRACT_16BITS(&bp
[2]));
1012 /* Encoded-Unicast-RP-Address */
1013 if (bp
>= ep
) break;
1014 (void)printf(" RP=");
1015 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1016 (void)printf("...");
1021 /* Encoded-Group Addresses */
1022 for (i
= 0; i
< pfxcnt
&& bp
< ep
; i
++) {
1023 (void)printf(" Group%d=", i
);
1024 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
1026 (void)printf("...");
1034 case PIMV2_TYPE_PRUNE_REFRESH
:
1035 (void)printf(" src=");
1036 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1037 (void)printf("...");
1041 (void)printf(" grp=");
1042 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
1043 (void)printf("...");
1047 (void)printf(" forwarder=");
1048 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1049 (void)printf("...");
1054 (void)printf(" TUNR ");
1055 relts_print(EXTRACT_16BITS(bp
));
1060 (void)printf(" [type %d]", PIM_TYPE(pim
->pim_typever
));
1067 (void)printf("[|pim]");
1072 * c-style: whitesmith