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.49 2006-02-13 01:31:35 hannes Exp $ (LBL)";
31 #include <tcpdump-stdinc.h>
36 #include "interface.h"
37 #include "addrtoname.h"
42 #define PIMV2_TYPE_HELLO 0
43 #define PIMV2_TYPE_REGISTER 1
44 #define PIMV2_TYPE_REGISTER_STOP 2
45 #define PIMV2_TYPE_JOIN_PRUNE 3
46 #define PIMV2_TYPE_BOOTSTRAP 4
47 #define PIMV2_TYPE_ASSERT 5
48 #define PIMV2_TYPE_GRAFT 6
49 #define PIMV2_TYPE_GRAFT_ACK 7
50 #define PIMV2_TYPE_CANDIDATE_RP 8
51 #define PIMV2_TYPE_PRUNE_REFRESH 9
53 static struct tok pimv2_type_values
[] = {
54 { PIMV2_TYPE_HELLO
, "Hello" },
55 { PIMV2_TYPE_REGISTER
, "Register" },
56 { PIMV2_TYPE_REGISTER_STOP
, "Register Stop" },
57 { PIMV2_TYPE_JOIN_PRUNE
, "Join / Prune" },
58 { PIMV2_TYPE_BOOTSTRAP
, "Bootstrap" },
59 { PIMV2_TYPE_ASSERT
, "Assert" },
60 { PIMV2_TYPE_GRAFT
, "Graft" },
61 { PIMV2_TYPE_GRAFT_ACK
, "Graft Acknowledgement" },
62 { PIMV2_TYPE_CANDIDATE_RP
, "Candidate RP Advertisement" },
63 { PIMV2_TYPE_PRUNE_REFRESH
, "Prune Refresh" },
67 #define PIMV2_HELLO_OPTION_HOLDTIME 1
68 #define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
69 #define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
70 #define PIMV2_HELLO_OPTION_DR_PRIORITY 19
71 #define PIMV2_HELLO_OPTION_GENID 20
72 #define PIMV2_HELLO_OPTION_REFRESH_CAP 21
73 #define PIMV2_HELLO_OPTION_BIDIR_CAP 22
74 #define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
75 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
77 static struct tok pimv2_hello_option_values
[] = {
78 { PIMV2_HELLO_OPTION_HOLDTIME
, "Hold Time" },
79 { PIMV2_HELLO_OPTION_LANPRUNEDELAY
, "LAN Prune Delay" },
80 { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
, "DR Priority (Old)" },
81 { PIMV2_HELLO_OPTION_DR_PRIORITY
, "DR Priority" },
82 { PIMV2_HELLO_OPTION_GENID
, "Generation ID" },
83 { PIMV2_HELLO_OPTION_REFRESH_CAP
, "State Refresh Capability" },
84 { PIMV2_HELLO_OPTION_BIDIR_CAP
, "Bi-Directional Capability" },
85 { PIMV2_HELLO_OPTION_ADDRESS_LIST
, "Address List" },
86 { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
, "Address List (Old)" },
90 #define PIMV2_REGISTER_FLAG_LEN 4
91 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
92 #define PIMV2_REGISTER_FLAG_NULL 0x40000000
94 static struct tok pimv2_register_flag_values
[] = {
95 { PIMV2_REGISTER_FLAG_BORDER
, "Border" },
96 { PIMV2_REGISTER_FLAG_NULL
, "Null" },
101 * XXX: We consider a case where IPv6 is not ready yet for portability,
102 * but PIM dependent defintions should be independent of IPv6...
106 u_int8_t pim_typever
;
107 /* upper 4bit: PIM version number; 2 for PIMv2 */
108 /* lower 4bit: the PIM message type, currently they are:
109 * Hello, Register, Register-Stop, Join/Prune,
110 * Bootstrap, Assert, Graft (PIM-DM only),
111 * Graft-Ack (PIM-DM only), C-RP-Adv
113 #define PIM_VER(x) (((x) & 0xf0) >> 4)
114 #define PIM_TYPE(x) ((x) & 0x0f)
115 u_char pim_rsv
; /* Reserved */
116 u_short pim_cksum
; /* IP style check sum */
119 static void pimv2_print(register const u_char
*bp
, register u_int len
, u_int cksum
);
122 pimv1_join_prune_print(register const u_char
*bp
, register u_int len
)
124 int maddrlen
, addrlen
, ngroups
, njoin
, nprune
;
127 /* If it's a single group and a single source, use 1-line output. */
128 if (TTEST2(bp
[0], 30) && bp
[11] == 1 &&
129 ((njoin
= EXTRACT_16BITS(&bp
[20])) + EXTRACT_16BITS(&bp
[22])) == 1) {
132 (void)printf(" RPF %s ", ipaddr_string(bp
));
133 hold
= EXTRACT_16BITS(&bp
[6]);
135 (void)printf("Hold ");
138 (void)printf("%s (%s/%d, %s", njoin
? "Join" : "Prune",
139 ipaddr_string(&bp
[26]), bp
[25] & 0x3f,
140 ipaddr_string(&bp
[12]));
141 if (EXTRACT_32BITS(&bp
[16]) != 0xffffffff)
142 (void)printf("/%s", ipaddr_string(&bp
[16]));
143 (void)printf(") %s%s %s",
144 (bp
[24] & 0x01) ? "Sparse" : "Dense",
145 (bp
[25] & 0x80) ? " WC" : "",
146 (bp
[25] & 0x40) ? "RP" : "SPT");
150 TCHECK2(bp
[0], sizeof(struct in_addr
));
153 (void)printf(" Upstream Nbr: %s", ipaddr_string(bp
));
157 (void)printf(" Hold time: ");
158 relts_print(EXTRACT_16BITS(&bp
[6]));
172 * XXX - does the address have length "addrlen" and the
173 * mask length "maddrlen"?
175 TCHECK2(bp
[0], sizeof(struct in_addr
));
176 (void)printf("\n\tGroup: %s", ipaddr_string(bp
));
177 TCHECK2(bp
[4], sizeof(struct in_addr
));
178 if (EXTRACT_32BITS(&bp
[4]) != 0xffffffff)
179 (void)printf("/%s", ipaddr_string(&bp
[4]));
181 njoin
= EXTRACT_16BITS(&bp
[8]);
182 nprune
= EXTRACT_16BITS(&bp
[10]);
183 (void)printf(" joined: %d pruned: %d", njoin
, nprune
);
186 for (njp
= 0; njp
< (njoin
+ nprune
); njp
++) {
194 (void)printf("\n\t%s %s%s%s%s/%d", type
,
195 (bp
[0] & 0x01) ? "Sparse " : "Dense ",
196 (bp
[1] & 0x80) ? "WC " : "",
197 (bp
[1] & 0x40) ? "RP " : "SPT ",
198 ipaddr_string(&bp
[2]), bp
[1] & 0x3f);
205 (void)printf("[|pim]");
210 pimv1_print(register const u_char
*bp
, register u_int len
)
212 register const u_char
*ep
;
213 register u_char type
;
215 ep
= (const u_char
*)snapend
;
224 (void)printf(" Query");
226 switch (bp
[8] >> 4) {
228 (void)printf(" Dense-mode");
231 (void)printf(" Sparse-mode");
234 (void)printf(" Sparse-Dense-mode");
237 (void)printf(" mode-%d", bp
[8] >> 4);
243 (void)printf(" (Hold-time ");
244 relts_print(EXTRACT_16BITS(&bp
[10]));
250 (void)printf(" Register");
251 TCHECK2(bp
[8], 20); /* ip header */
252 (void)printf(" for %s > %s", ipaddr_string(&bp
[20]),
253 ipaddr_string(&bp
[24]));
256 (void)printf(" Register-Stop");
257 TCHECK2(bp
[12], sizeof(struct in_addr
));
258 (void)printf(" for %s > %s", ipaddr_string(&bp
[8]),
259 ipaddr_string(&bp
[12]));
262 (void)printf(" Join/Prune");
264 pimv1_join_prune_print(&bp
[8], len
- 8);
267 (void)printf(" RP-reachable");
270 (void)printf(" group %s",
271 ipaddr_string(&bp
[8]));
272 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
273 (void)printf("/%s", ipaddr_string(&bp
[12]));
274 (void)printf(" RP %s hold ", ipaddr_string(&bp
[16]));
275 relts_print(EXTRACT_16BITS(&bp
[22]));
279 (void)printf(" Assert");
280 TCHECK2(bp
[16], sizeof(struct in_addr
));
281 (void)printf(" for %s > %s", ipaddr_string(&bp
[16]),
282 ipaddr_string(&bp
[8]));
283 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
284 (void)printf("/%s", ipaddr_string(&bp
[12]));
286 (void)printf(" %s pref %d metric %d",
287 (bp
[20] & 0x80) ? "RP-tree" : "SPT",
288 EXTRACT_32BITS(&bp
[20]) & 0x7fffffff,
289 EXTRACT_32BITS(&bp
[24]));
292 (void)printf(" Graft");
294 pimv1_join_prune_print(&bp
[8], len
- 8);
297 (void)printf(" Graft-ACK");
299 pimv1_join_prune_print(&bp
[8], len
- 8);
302 (void)printf(" Mode");
305 (void)printf(" [type %d]", type
);
308 if ((bp
[4] >> 4) != 1)
309 (void)printf(" [v%d]", bp
[4] >> 4);
313 (void)printf("[|pim]");
318 * auto-RP is a cisco protocol, documented at
319 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
321 * This implements version 1+, dated Sept 9, 1998.
324 cisco_autorp_print(register const u_char
*bp
, register u_int len
)
331 (void)printf(" auto-rp ");
335 (void)printf("candidate-advert");
338 (void)printf("mapping");
341 (void)printf("type-0x%02x", type
);
349 (void)printf(" Hold ");
350 hold
= EXTRACT_16BITS(&bp
[2]);
352 relts_print(EXTRACT_16BITS(&bp
[2]));
356 /* Next 4 bytes are reserved. */
360 /*XXX skip unless -v? */
364 * numrps entries of the form:
367 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
368 * 8 bits: # of entries for this RP
369 * each entry: 7 bits: reserved, 1 bit: negative,
370 * 8 bits: mask 32 bits: source
371 * lather, rinse, repeat.
378 (void)printf(" RP %s", ipaddr_string(bp
));
380 switch (bp
[4] & 0x3) {
381 case 0: printf(" PIMv?");
383 case 1: printf(" PIMv1");
385 case 2: printf(" PIMv2");
387 case 3: printf(" PIMv1+2");
391 (void)printf(" [rsvd=0x%02x]", bp
[4] & 0xfc);
396 for (; nentries
; nentries
--) {
398 (void)printf("%c%s%s/%d", s
, bp
[0] & 1 ? "!" : "",
399 ipaddr_string(&bp
[2]), bp
[1]);
401 (void)printf(" bidir");
404 (void)printf("[rsvd=0x%02x]", bp
[0] & 0xfc);
413 (void)printf("[|autorp]");
418 pim_print(register const u_char
*bp
, register u_int len
, u_int cksum
)
420 register const u_char
*ep
;
421 register struct pim
*pim
= (struct pim
*)bp
;
423 ep
= (const u_char
*)snapend
;
426 #ifdef notyet /* currently we see only version and type */
427 TCHECK(pim
->pim_rsv
);
430 switch (PIM_VER(pim
->pim_typever
)) {
433 printf("PIMv%u, %s, length %u",
434 PIM_VER(pim
->pim_typever
),
435 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
439 printf("PIMv%u, length %u\n\t%s",
440 PIM_VER(pim
->pim_typever
),
442 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)));
443 pimv2_print(bp
, len
, cksum
);
447 printf("PIMv%u, length %u",
448 PIM_VER(pim
->pim_typever
),
456 * PIMv2 uses encoded address representations.
458 * The last PIM-SM I-D before RFC2117 was published specified the
459 * following representation for unicast addresses. However, RFC2117
460 * specified no encoding for unicast addresses with the unicast
461 * address length specified in the header. Therefore, we have to
462 * guess which encoding is being used (Cisco's PIMv2 implementation
463 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
464 * field into a 'unicast-address-length-in-bytes' field. We guess
465 * that it's the draft encoding if this reserved field is zero.
467 * RFC2362 goes back to the encoded format, and calls the addr length
468 * field "reserved" again.
470 * The first byte is the address family, from:
473 * 1 IP (IP version 4)
474 * 2 IP6 (IP version 6)
476 * 4 HDLC (8-bit multidrop)
478 * 6 802 (includes all 802 media plus Ethernet "canonical format")
480 * 8 E.164 (SMDS, Frame Relay, ATM)
482 * 10 X.121 (X.25, Frame Relay)
487 * 15 E.164 with NSAP format subaddress
489 * In addition, the second byte is an "Encoding". 0 is the default
490 * encoding for the address family, and no other encodings are currently
495 static int pimv2_addr_len
;
497 enum pimv2_addrtype
{
498 pimv2_unicast
, pimv2_group
, pimv2_source
502 * 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
503 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
504 * | Addr Family | Encoding Type | Unicast Address |
505 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
507 * 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
508 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
509 * | Addr Family | Encoding Type | Reserved | Mask Len |
510 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
511 * | Group multicast Address |
512 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
514 * 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
515 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
516 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
517 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
519 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
522 pimv2_addr_print(const u_char
*bp
, enum pimv2_addrtype at
, int silent
)
529 if (pimv2_addr_len
== 0) {
534 len
= sizeof(struct in_addr
);
539 len
= sizeof(struct in6_addr
);
549 switch (pimv2_addr_len
) {
550 case sizeof(struct in_addr
):
554 case sizeof(struct in6_addr
):
562 len
= pimv2_addr_len
;
572 (void)printf("%s", ipaddr_string(bp
));
575 else if (af
== AF_INET6
) {
577 (void)printf("%s", ip6addr_string(bp
));
583 TCHECK2(bp
[0], len
+ 2);
586 (void)printf("%s", ipaddr_string(bp
+ 2));
588 (void)printf("/%u", bp
[1]);
592 else if (af
== AF_INET6
) {
594 (void)printf("%s", ip6addr_string(bp
+ 2));
596 (void)printf("/%u", bp
[1]);
600 if (bp
[0] && !silent
) {
601 if (at
== pimv2_group
) {
602 (void)printf("(0x%02x)", bp
[0]);
604 (void)printf("(%s%s%s",
605 bp
[0] & 0x04 ? "S" : "",
606 bp
[0] & 0x02 ? "W" : "",
607 bp
[0] & 0x01 ? "R" : "");
609 (void) printf("+0x%02x", bp
[0] & 0xf8);
614 return hdrlen
+ 2 + len
;
623 pimv2_print(register const u_char
*bp
, register u_int len
, u_int cksum
)
625 register const u_char
*ep
;
626 register struct pim
*pim
= (struct pim
*)bp
;
629 ep
= (const u_char
*)snapend
;
634 TCHECK(pim
->pim_rsv
);
635 pimv2_addr_len
= pim
->pim_rsv
;
636 if (pimv2_addr_len
!= 0)
637 (void)printf(", RFC2117-encoding");
639 printf(", cksum 0x%04x ", EXTRACT_16BITS(&pim
->pim_cksum
));
640 if (EXTRACT_16BITS(&pim
->pim_cksum
) == 0) {
641 printf("(unverified)");
643 printf("(%scorrect)", TTEST2(bp
[0], len
) && cksum
? "in" : "" );
646 switch (PIM_TYPE(pim
->pim_typever
)) {
647 case PIMV2_TYPE_HELLO
:
649 u_int16_t otype
, olen
;
653 otype
= EXTRACT_16BITS(&bp
[0]);
654 olen
= EXTRACT_16BITS(&bp
[2]);
655 TCHECK2(bp
[0], 4 + olen
);
657 printf("\n\t %s Option (%u), length %u, Value: ",
658 tok2str( pimv2_hello_option_values
,"Unknown",otype
),
664 case PIMV2_HELLO_OPTION_HOLDTIME
:
665 relts_print(EXTRACT_16BITS(bp
));
668 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
670 (void)printf("ERROR: Option Length != 4 Bytes (%u)", olen
);
673 u_int16_t lan_delay
, override_interval
;
674 lan_delay
= EXTRACT_16BITS(bp
);
675 override_interval
= EXTRACT_16BITS(bp
+2);
676 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
677 lan_delay
&= ~0x8000;
678 (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
679 t_bit
, lan_delay
, override_interval
);
683 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
684 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
687 printf("Bi-Directional Capability (Old)");
690 printf("%u", EXTRACT_32BITS(bp
));
693 printf("ERROR: Option Length != 4 Bytes (%u)", olen
);
698 case PIMV2_HELLO_OPTION_GENID
:
699 (void)printf("0x%08x", EXTRACT_32BITS(bp
));
702 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
703 (void)printf("v%d", *bp
);
705 (void)printf(", interval ");
706 relts_print(*(bp
+1));
708 if (EXTRACT_16BITS(bp
+2) != 0) {
709 (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp
+2));
713 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
716 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
717 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
719 const u_char
*ptr
= bp
;
720 while (ptr
< (bp
+olen
)) {
724 advance
= pimv2_addr_print(ptr
, pimv2_unicast
, 0);
735 print_unknown_data(bp
,"\n\t ",olen
);
738 /* do we want to see an additionally hexdump ? */
740 print_unknown_data(bp
,"\n\t ",olen
);
746 case PIMV2_TYPE_REGISTER
:
750 if (!TTEST2(*(bp
+4), PIMV2_REGISTER_FLAG_LEN
))
753 printf(", Flags [ %s ]\n\t",
754 tok2str(pimv2_register_flag_values
,
756 EXTRACT_32BITS(bp
+4)));
759 /* encapsulated multicast packet */
760 ip
= (struct ip
*)bp
;
762 case 0: /* Null header */
763 (void)printf("IP-Null-header %s > %s",
764 ipaddr_string(&ip
->ip_src
),
765 ipaddr_string(&ip
->ip_dst
));
769 ip_print(gndo
, bp
, len
);
773 ip6_print(gndo
, bp
, len
);
777 (void)printf("IP ver %d", IP_V(ip
));
783 case PIMV2_TYPE_REGISTER_STOP
:
787 (void)printf(" group=");
788 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
792 bp
+= advance
; len
-= advance
;
795 (void)printf(" source=");
796 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
800 bp
+= advance
; len
-= advance
;
803 case PIMV2_TYPE_JOIN_PRUNE
:
804 case PIMV2_TYPE_GRAFT
:
805 case PIMV2_TYPE_GRAFT_ACK
:
810 * 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
811 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
812 * |PIM Ver| Type | Addr length | Checksum |
813 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
814 * | Unicast-Upstream Neighbor Address |
815 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
816 * | Reserved | Num groups | Holdtime |
817 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
818 * | Encoded-Multicast Group Address-1 |
819 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
820 * | Number of Joined Sources | Number of Pruned Sources |
821 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
822 * | Encoded-Joined Source Address-1 |
823 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
826 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
827 * | Encoded-Joined Source Address-n |
828 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
829 * | Encoded-Pruned Source Address-1 |
830 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
833 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
834 * | Encoded-Pruned Source Address-n |
835 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
838 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
839 * | Encoded-Multicast Group Address-n |
840 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
851 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
854 (void)printf(", upstream-neighbor: ");
855 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
859 bp
+= advance
; len
-= advance
;
864 holdtime
= EXTRACT_16BITS(&bp
[2]);
865 (void)printf("\n\t %u group(s)", ngroup
);
866 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
867 (void)printf(", holdtime: ");
868 if (holdtime
== 0xffff)
869 (void)printf("infinite");
871 relts_print(holdtime
);
874 for (i
= 0; i
< ngroup
; i
++) {
877 (void)printf("\n\t group #%u: ", i
+1);
878 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
879 (void)printf("...)");
882 bp
+= advance
; len
-= advance
;
884 (void)printf("...)");
887 njoin
= EXTRACT_16BITS(&bp
[0]);
888 nprune
= EXTRACT_16BITS(&bp
[2]);
889 (void)printf(", joined sources: %u, pruned sources: %u", njoin
,nprune
);
891 for (j
= 0; j
< njoin
; j
++) {
892 (void)printf("\n\t joined source #%u: ",j
+1);
893 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
894 (void)printf("...)");
897 bp
+= advance
; len
-= advance
;
899 for (j
= 0; j
< nprune
; j
++) {
900 (void)printf("\n\t pruned source #%u: ",j
+1);
901 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
902 (void)printf("...)");
905 bp
+= advance
; len
-= advance
;
912 case PIMV2_TYPE_BOOTSTRAP
:
917 /* Fragment Tag, Hash Mask len, and BSR-priority */
918 if (bp
+ sizeof(u_int16_t
) >= ep
) break;
919 (void)printf(" tag=%x", EXTRACT_16BITS(bp
));
920 bp
+= sizeof(u_int16_t
);
922 (void)printf(" hashmlen=%d", bp
[0]);
923 if (bp
+ 1 >= ep
) break;
924 (void)printf(" BSRprio=%d", bp
[1]);
927 /* Encoded-Unicast-BSR-Address */
929 (void)printf(" BSR=");
930 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
936 for (i
= 0; bp
< ep
; i
++) {
937 /* Encoded-Group Address */
938 (void)printf(" (group%d: ", i
);
939 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
941 (void)printf("...)");
946 /* RP-Count, Frag RP-Cnt, and rsvd */
948 (void)printf("...)");
951 (void)printf(" RPcnt=%d", bp
[0]);
953 (void)printf("...)");
956 (void)printf(" FRPcnt=%d", frpcnt
= bp
[1]);
959 for (j
= 0; j
< frpcnt
&& bp
< ep
; j
++) {
961 (void)printf(" RP%d=", j
);
962 if ((advance
= pimv2_addr_print(bp
,
965 (void)printf("...)");
971 (void)printf("...)");
974 (void)printf(",holdtime=");
975 relts_print(EXTRACT_16BITS(bp
));
977 (void)printf("...)");
980 (void)printf(",prio=%d", bp
[2]);
988 case PIMV2_TYPE_ASSERT
:
992 (void)printf(" group=");
993 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
997 bp
+= advance
; len
-= advance
;
1000 (void)printf(" src=");
1001 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1002 (void)printf("...");
1005 bp
+= advance
; len
-= advance
;
1009 (void)printf(" RPT");
1010 (void)printf(" pref=%u", EXTRACT_32BITS(&bp
[0]) & 0x7fffffff);
1011 (void)printf(" metric=%u", EXTRACT_32BITS(&bp
[4]));
1014 case PIMV2_TYPE_CANDIDATE_RP
:
1019 /* Prefix-Cnt, Priority, and Holdtime */
1020 if (bp
>= ep
) break;
1021 (void)printf(" prefix-cnt=%d", bp
[0]);
1023 if (bp
+ 1 >= ep
) break;
1024 (void)printf(" prio=%d", bp
[1]);
1025 if (bp
+ 3 >= ep
) break;
1026 (void)printf(" holdtime=");
1027 relts_print(EXTRACT_16BITS(&bp
[2]));
1030 /* Encoded-Unicast-RP-Address */
1031 if (bp
>= ep
) break;
1032 (void)printf(" RP=");
1033 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1034 (void)printf("...");
1039 /* Encoded-Group Addresses */
1040 for (i
= 0; i
< pfxcnt
&& bp
< ep
; i
++) {
1041 (void)printf(" Group%d=", i
);
1042 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
1044 (void)printf("...");
1052 case PIMV2_TYPE_PRUNE_REFRESH
:
1053 (void)printf(" src=");
1054 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1055 (void)printf("...");
1059 (void)printf(" grp=");
1060 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
1061 (void)printf("...");
1065 (void)printf(" forwarder=");
1066 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1067 (void)printf("...");
1072 (void)printf(" TUNR ");
1073 relts_print(EXTRACT_16BITS(bp
));
1078 (void)printf(" [type %d]", PIM_TYPE(pim
->pim_typever
));
1085 (void)printf("[|pim]");
1090 * c-style: whitesmith