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.
25 static const char rcsid
[] _U_
=
26 "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45.2.4 2006/02/13 01:32:34 hannes Exp $ (LBL)";
33 #include <tcpdump-stdinc.h>
34 #include "interface.h"
36 #define PIMV2_TYPE_HELLO 0
37 #define PIMV2_TYPE_REGISTER 1
38 #define PIMV2_TYPE_REGISTER_STOP 2
39 #define PIMV2_TYPE_JOIN_PRUNE 3
40 #define PIMV2_TYPE_BOOTSTRAP 4
41 #define PIMV2_TYPE_ASSERT 5
42 #define PIMV2_TYPE_GRAFT 6
43 #define PIMV2_TYPE_GRAFT_ACK 7
44 #define PIMV2_TYPE_CANDIDATE_RP 8
45 #define PIMV2_TYPE_PRUNE_REFRESH 9
47 static struct tok pimv2_type_values
[] = {
48 { PIMV2_TYPE_HELLO
, "Hello" },
49 { PIMV2_TYPE_REGISTER
, "Register" },
50 { PIMV2_TYPE_REGISTER_STOP
, "Register Stop" },
51 { PIMV2_TYPE_JOIN_PRUNE
, "Join / Prune" },
52 { PIMV2_TYPE_BOOTSTRAP
, "Bootstrap" },
53 { PIMV2_TYPE_ASSERT
, "Assert" },
54 { PIMV2_TYPE_GRAFT
, "Graft" },
55 { PIMV2_TYPE_GRAFT_ACK
, "Graft Acknowledgement" },
56 { PIMV2_TYPE_CANDIDATE_RP
, "Candidate RP Advertisement" },
57 { PIMV2_TYPE_PRUNE_REFRESH
, "Prune Refresh" },
61 #define PIMV2_HELLO_OPTION_HOLDTIME 1
62 #define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
63 #define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
64 #define PIMV2_HELLO_OPTION_DR_PRIORITY 19
65 #define PIMV2_HELLO_OPTION_GENID 20
66 #define PIMV2_HELLO_OPTION_REFRESH_CAP 21
67 #define PIMV2_HELLO_OPTION_BIDIR_CAP 22
68 #define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
69 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
71 static struct tok pimv2_hello_option_values
[] = {
72 { PIMV2_HELLO_OPTION_HOLDTIME
, "Hold Time" },
73 { PIMV2_HELLO_OPTION_LANPRUNEDELAY
, "LAN Prune Delay" },
74 { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
, "DR Priority (Old)" },
75 { PIMV2_HELLO_OPTION_DR_PRIORITY
, "DR Priority" },
76 { PIMV2_HELLO_OPTION_GENID
, "Generation ID" },
77 { PIMV2_HELLO_OPTION_REFRESH_CAP
, "State Refresh Capability" },
78 { PIMV2_HELLO_OPTION_BIDIR_CAP
, "Bi-Directional Capability" },
79 { PIMV2_HELLO_OPTION_ADDRESS_LIST
, "Address List" },
80 { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
, "Address List (Old)" },
84 #define PIMV2_REGISTER_FLAG_LEN 4
85 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
86 #define PIMV2_REGISTER_FLAG_NULL 0x40000000
88 static struct tok pimv2_register_flag_values
[] = {
89 { PIMV2_REGISTER_FLAG_BORDER
, "Border" },
90 { PIMV2_REGISTER_FLAG_NULL
, "Null" },
95 * XXX: We consider a case where IPv6 is not ready yet for portability,
96 * but PIM dependent defintions should be independent of IPv6...
100 u_int8_t pim_typever
;
101 /* upper 4bit: PIM version number; 2 for PIMv2 */
102 /* lower 4bit: the PIM message type, currently they are:
103 * Hello, Register, Register-Stop, Join/Prune,
104 * Bootstrap, Assert, Graft (PIM-DM only),
105 * Graft-Ack (PIM-DM only), C-RP-Adv
107 #define PIM_VER(x) (((x) & 0xf0) >> 4)
108 #define PIM_TYPE(x) ((x) & 0x0f)
109 u_char pim_rsv
; /* Reserved */
110 u_short pim_cksum
; /* IP style check sum */
117 #include "interface.h"
118 #include "addrtoname.h"
123 static void pimv2_print(register const u_char
*bp
, register u_int len
);
126 pimv1_join_prune_print(register const u_char
*bp
, register u_int len
)
128 int maddrlen
, addrlen
, ngroups
, njoin
, nprune
;
131 /* If it's a single group and a single source, use 1-line output. */
132 if (TTEST2(bp
[0], 30) && bp
[11] == 1 &&
133 ((njoin
= EXTRACT_16BITS(&bp
[20])) + EXTRACT_16BITS(&bp
[22])) == 1) {
136 (void)printf(" RPF %s ", ipaddr_string(bp
));
137 hold
= EXTRACT_16BITS(&bp
[6]);
139 (void)printf("Hold ");
142 (void)printf("%s (%s/%d, %s", njoin
? "Join" : "Prune",
143 ipaddr_string(&bp
[26]), bp
[25] & 0x3f,
144 ipaddr_string(&bp
[12]));
145 if (EXTRACT_32BITS(&bp
[16]) != 0xffffffff)
146 (void)printf("/%s", ipaddr_string(&bp
[16]));
147 (void)printf(") %s%s %s",
148 (bp
[24] & 0x01) ? "Sparse" : "Dense",
149 (bp
[25] & 0x80) ? " WC" : "",
150 (bp
[25] & 0x40) ? "RP" : "SPT");
154 TCHECK2(bp
[0], sizeof(struct in_addr
));
157 (void)printf(" Upstream Nbr: %s", ipaddr_string(bp
));
161 (void)printf(" Hold time: ");
162 relts_print(EXTRACT_16BITS(&bp
[6]));
176 * XXX - does the address have length "addrlen" and the
177 * mask length "maddrlen"?
179 TCHECK2(bp
[0], sizeof(struct in_addr
));
180 (void)printf("\n\tGroup: %s", ipaddr_string(bp
));
181 TCHECK2(bp
[4], sizeof(struct in_addr
));
182 if (EXTRACT_32BITS(&bp
[4]) != 0xffffffff)
183 (void)printf("/%s", ipaddr_string(&bp
[4]));
185 njoin
= EXTRACT_16BITS(&bp
[8]);
186 nprune
= EXTRACT_16BITS(&bp
[10]);
187 (void)printf(" joined: %d pruned: %d", njoin
, nprune
);
190 for (njp
= 0; njp
< (njoin
+ nprune
); njp
++) {
198 (void)printf("\n\t%s %s%s%s%s/%d", type
,
199 (bp
[0] & 0x01) ? "Sparse " : "Dense ",
200 (bp
[1] & 0x80) ? "WC " : "",
201 (bp
[1] & 0x40) ? "RP " : "SPT ",
202 ipaddr_string(&bp
[2]), bp
[1] & 0x3f);
209 (void)printf("[|pim]");
214 pimv1_print(register const u_char
*bp
, register u_int len
)
216 register const u_char
*ep
;
217 register u_char type
;
219 ep
= (const u_char
*)snapend
;
228 (void)printf(" Query");
230 switch (bp
[8] >> 4) {
232 (void)printf(" Dense-mode");
235 (void)printf(" Sparse-mode");
238 (void)printf(" Sparse-Dense-mode");
241 (void)printf(" mode-%d", bp
[8] >> 4);
247 (void)printf(" (Hold-time ");
248 relts_print(EXTRACT_16BITS(&bp
[10]));
254 (void)printf(" Register");
255 TCHECK2(bp
[8], 20); /* ip header */
256 (void)printf(" for %s > %s", ipaddr_string(&bp
[20]),
257 ipaddr_string(&bp
[24]));
260 (void)printf(" Register-Stop");
261 TCHECK2(bp
[12], sizeof(struct in_addr
));
262 (void)printf(" for %s > %s", ipaddr_string(&bp
[8]),
263 ipaddr_string(&bp
[12]));
266 (void)printf(" Join/Prune");
268 pimv1_join_prune_print(&bp
[8], len
- 8);
271 (void)printf(" RP-reachable");
274 (void)printf(" group %s",
275 ipaddr_string(&bp
[8]));
276 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
277 (void)printf("/%s", ipaddr_string(&bp
[12]));
278 (void)printf(" RP %s hold ", ipaddr_string(&bp
[16]));
279 relts_print(EXTRACT_16BITS(&bp
[22]));
283 (void)printf(" Assert");
284 TCHECK2(bp
[16], sizeof(struct in_addr
));
285 (void)printf(" for %s > %s", ipaddr_string(&bp
[16]),
286 ipaddr_string(&bp
[8]));
287 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
288 (void)printf("/%s", ipaddr_string(&bp
[12]));
290 (void)printf(" %s pref %d metric %d",
291 (bp
[20] & 0x80) ? "RP-tree" : "SPT",
292 EXTRACT_32BITS(&bp
[20]) & 0x7fffffff,
293 EXTRACT_32BITS(&bp
[24]));
296 (void)printf(" Graft");
298 pimv1_join_prune_print(&bp
[8], len
- 8);
301 (void)printf(" Graft-ACK");
303 pimv1_join_prune_print(&bp
[8], len
- 8);
306 (void)printf(" Mode");
309 (void)printf(" [type %d]", type
);
312 if ((bp
[4] >> 4) != 1)
313 (void)printf(" [v%d]", bp
[4] >> 4);
317 (void)printf("[|pim]");
322 * auto-RP is a cisco protocol, documented at
323 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
325 * This implements version 1+, dated Sept 9, 1998.
328 cisco_autorp_print(register const u_char
*bp
, register u_int len
)
335 (void)printf(" auto-rp ");
339 (void)printf("candidate-advert");
342 (void)printf("mapping");
345 (void)printf("type-0x%02x", type
);
353 (void)printf(" Hold ");
354 hold
= EXTRACT_16BITS(&bp
[2]);
356 relts_print(EXTRACT_16BITS(&bp
[2]));
360 /* Next 4 bytes are reserved. */
364 /*XXX skip unless -v? */
368 * numrps entries of the form:
371 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
372 * 8 bits: # of entries for this RP
373 * each entry: 7 bits: reserved, 1 bit: negative,
374 * 8 bits: mask 32 bits: source
375 * lather, rinse, repeat.
382 (void)printf(" RP %s", ipaddr_string(bp
));
384 switch (bp
[4] & 0x3) {
385 case 0: printf(" PIMv?");
387 case 1: printf(" PIMv1");
389 case 2: printf(" PIMv2");
391 case 3: printf(" PIMv1+2");
395 (void)printf(" [rsvd=0x%02x]", bp
[4] & 0xfc);
400 for (; nentries
; nentries
--) {
402 (void)printf("%c%s%s/%d", s
, bp
[0] & 1 ? "!" : "",
403 ipaddr_string(&bp
[2]), bp
[1]);
405 (void)printf("[rsvd=0x%02x]", bp
[0] & 0xfe);
413 (void)printf("[|autorp]");
418 pim_print(register const u_char
*bp
, register u_int len
)
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
);
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
)
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)",
644 TTEST2(bp
[0], len
) &&
645 in_cksum((const u_short
*)bp
, len
, 0) ? "in" : "" );
648 switch (PIM_TYPE(pim
->pim_typever
)) {
649 case PIMV2_TYPE_HELLO
:
651 u_int16_t otype
, olen
;
655 otype
= EXTRACT_16BITS(&bp
[0]);
656 olen
= EXTRACT_16BITS(&bp
[2]);
657 TCHECK2(bp
[0], 4 + olen
);
659 printf("\n\t %s Option (%u), length %u, Value: ",
660 tok2str( pimv2_hello_option_values
,"Unknown",otype
),
666 case PIMV2_HELLO_OPTION_HOLDTIME
:
667 relts_print(EXTRACT_16BITS(bp
));
670 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
672 (void)printf("ERROR: Option Lenght != 4 Bytes (%u)", olen
);
675 u_int16_t lan_delay
, override_interval
;
676 lan_delay
= EXTRACT_16BITS(bp
);
677 override_interval
= EXTRACT_16BITS(bp
+2);
678 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
679 lan_delay
&= ~0x8000;
680 (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
681 t_bit
, lan_delay
, override_interval
);
685 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
686 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
689 printf("Bi-Directional Capability (Old)");
692 printf("%u", EXTRACT_32BITS(bp
));
695 printf("ERROR: Option Lenght != 4 Bytes (%u)", olen
);
700 case PIMV2_HELLO_OPTION_GENID
:
701 (void)printf("0x%08x", EXTRACT_32BITS(bp
));
704 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
705 (void)printf("v%d", *bp
);
707 (void)printf(", interval ");
708 relts_print(*(bp
+1));
710 if (EXTRACT_16BITS(bp
+2) != 0) {
711 (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp
+2));
715 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
718 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
719 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
721 const u_char
*ptr
= bp
;
722 while (ptr
< (bp
+olen
)) {
726 advance
= pimv2_addr_print(ptr
, pimv2_unicast
, 0);
737 print_unknown_data(bp
,"\n\t ",olen
);
740 /* do we want to see an additionally hexdump ? */
742 print_unknown_data(bp
,"\n\t ",olen
);
748 case PIMV2_TYPE_REGISTER
:
752 if (!TTEST2(*(bp
+4), PIMV2_REGISTER_FLAG_LEN
))
755 printf(", Flags [ %s ]\n\t",
756 tok2str(pimv2_register_flag_values
,
758 EXTRACT_32BITS(bp
+4)));
761 /* encapsulated multicast packet */
762 ip
= (struct ip
*)bp
;
764 case 0: /* Null header */
765 (void)printf("IP-Null-header %s > %s",
766 ipaddr_string(&ip
->ip_src
),
767 ipaddr_string(&ip
->ip_dst
));
771 ip_print(gndo
, bp
, len
);
779 (void)printf("IP ver %d", IP_V(ip
));
785 case PIMV2_TYPE_REGISTER_STOP
:
789 (void)printf(" group=");
790 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
794 bp
+= advance
; len
-= advance
;
797 (void)printf(" source=");
798 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
802 bp
+= advance
; len
-= advance
;
805 case PIMV2_TYPE_JOIN_PRUNE
:
806 case PIMV2_TYPE_GRAFT
:
807 case PIMV2_TYPE_GRAFT_ACK
:
812 * 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
813 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
814 * |PIM Ver| Type | Addr length | Checksum |
815 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
816 * | Unicast-Upstream Neighbor Address |
817 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
818 * | Reserved | Num groups | Holdtime |
819 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
820 * | Encoded-Multicast Group Address-1 |
821 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
822 * | Number of Joined Sources | Number of Pruned Sources |
823 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
824 * | Encoded-Joined Source Address-1 |
825 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
828 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
829 * | Encoded-Joined Source Address-n |
830 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
831 * | Encoded-Pruned Source Address-1 |
832 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
835 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
836 * | Encoded-Pruned Source Address-n |
837 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
840 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
841 * | Encoded-Multicast Group Address-n |
842 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
853 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
856 (void)printf(", upstream-neighbor: ");
857 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
861 bp
+= advance
; len
-= advance
;
866 holdtime
= EXTRACT_16BITS(&bp
[2]);
867 (void)printf("\n\t %u group(s)", ngroup
);
868 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
869 (void)printf(", holdtime: ");
870 if (holdtime
== 0xffff)
871 (void)printf("infinite");
873 relts_print(holdtime
);
876 for (i
= 0; i
< ngroup
; i
++) {
879 (void)printf("\n\t group #%u: ", i
+1);
880 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
881 (void)printf("...)");
884 bp
+= advance
; len
-= advance
;
886 (void)printf("...)");
889 njoin
= EXTRACT_16BITS(&bp
[0]);
890 nprune
= EXTRACT_16BITS(&bp
[2]);
891 (void)printf(", joined sources: %u, pruned sources: %u", njoin
,nprune
);
893 for (j
= 0; j
< njoin
; j
++) {
894 (void)printf("\n\t joined source #%u: ",j
+1);
895 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
896 (void)printf("...)");
899 bp
+= advance
; len
-= advance
;
901 for (j
= 0; j
< nprune
; j
++) {
902 (void)printf("\n\t pruned source #%u: ",j
+1);
903 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
904 (void)printf("...)");
907 bp
+= advance
; len
-= advance
;
914 case PIMV2_TYPE_BOOTSTRAP
:
919 /* Fragment Tag, Hash Mask len, and BSR-priority */
920 if (bp
+ sizeof(u_int16_t
) >= ep
) break;
921 (void)printf(" tag=%x", EXTRACT_16BITS(bp
));
922 bp
+= sizeof(u_int16_t
);
924 (void)printf(" hashmlen=%d", bp
[0]);
925 if (bp
+ 1 >= ep
) break;
926 (void)printf(" BSRprio=%d", bp
[1]);
929 /* Encoded-Unicast-BSR-Address */
931 (void)printf(" BSR=");
932 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
938 for (i
= 0; bp
< ep
; i
++) {
939 /* Encoded-Group Address */
940 (void)printf(" (group%d: ", i
);
941 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
943 (void)printf("...)");
948 /* RP-Count, Frag RP-Cnt, and rsvd */
950 (void)printf("...)");
953 (void)printf(" RPcnt=%d", bp
[0]);
955 (void)printf("...)");
958 (void)printf(" FRPcnt=%d", frpcnt
= bp
[1]);
961 for (j
= 0; j
< frpcnt
&& bp
< ep
; j
++) {
963 (void)printf(" RP%d=", j
);
964 if ((advance
= pimv2_addr_print(bp
,
967 (void)printf("...)");
973 (void)printf("...)");
976 (void)printf(",holdtime=");
977 relts_print(EXTRACT_16BITS(bp
));
979 (void)printf("...)");
982 (void)printf(",prio=%d", bp
[2]);
990 case PIMV2_TYPE_ASSERT
:
994 (void)printf(" group=");
995 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
999 bp
+= advance
; len
-= advance
;
1002 (void)printf(" src=");
1003 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1004 (void)printf("...");
1007 bp
+= advance
; len
-= advance
;
1011 (void)printf(" RPT");
1012 (void)printf(" pref=%u", EXTRACT_32BITS(&bp
[0]) & 0x7fffffff);
1013 (void)printf(" metric=%u", EXTRACT_32BITS(&bp
[4]));
1016 case PIMV2_TYPE_CANDIDATE_RP
:
1021 /* Prefix-Cnt, Priority, and Holdtime */
1022 if (bp
>= ep
) break;
1023 (void)printf(" prefix-cnt=%d", bp
[0]);
1025 if (bp
+ 1 >= ep
) break;
1026 (void)printf(" prio=%d", bp
[1]);
1027 if (bp
+ 3 >= ep
) break;
1028 (void)printf(" holdtime=");
1029 relts_print(EXTRACT_16BITS(&bp
[2]));
1032 /* Encoded-Unicast-RP-Address */
1033 if (bp
>= ep
) break;
1034 (void)printf(" RP=");
1035 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1036 (void)printf("...");
1041 /* Encoded-Group Addresses */
1042 for (i
= 0; i
< pfxcnt
&& bp
< ep
; i
++) {
1043 (void)printf(" Group%d=", i
);
1044 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
1046 (void)printf("...");
1054 case PIMV2_TYPE_PRUNE_REFRESH
:
1055 (void)printf(" src=");
1056 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1057 (void)printf("...");
1061 (void)printf(" grp=");
1062 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
1063 (void)printf("...");
1067 (void)printf(" forwarder=");
1068 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1069 (void)printf("...");
1074 (void)printf(" TUNR ");
1075 relts_print(EXTRACT_16BITS(bp
));
1080 (void)printf(" [type %d]", PIM_TYPE(pim
->pim_typever
));
1087 (void)printf("[|pim]");
1092 * c-style: whitesmith