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.3 2005/07/11 20:24: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)" },
86 * XXX: We consider a case where IPv6 is not ready yet for portability,
87 * but PIM dependent defintions should be independent of IPv6...
92 /* upper 4bit: PIM version number; 2 for PIMv2 */
93 /* lower 4bit: the PIM message type, currently they are:
94 * Hello, Register, Register-Stop, Join/Prune,
95 * Bootstrap, Assert, Graft (PIM-DM only),
96 * Graft-Ack (PIM-DM only), C-RP-Adv
98 #define PIM_VER(x) (((x) & 0xf0) >> 4)
99 #define PIM_TYPE(x) ((x) & 0x0f)
100 u_char pim_rsv; /* Reserved */
101 u_short pim_cksum; /* IP style check sum */
108 #include "interface.h"
109 #include "addrtoname.h"
114 static void pimv2_print(register const u_char *bp, register u_int len);
117 pimv1_join_prune_print(register const u_char *bp, register u_int len)
119 int maddrlen, addrlen, ngroups, njoin, nprune;
122 /* If it's a single group and a single source, use 1-line output. */
123 if (TTEST2(bp[0], 30) && bp[11] == 1 &&
124 ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
127 (void)printf(" RPF %s ", ipaddr_string(bp));
128 hold = EXTRACT_16BITS(&bp[6]);
130 (void)printf("Hold ");
133 (void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune",
134 ipaddr_string(&bp[26]), bp[25] & 0x3f,
135 ipaddr_string(&bp[12]));
136 if (EXTRACT_32BITS(&bp[16]) != 0xffffffff)
137 (void)printf("/%s", ipaddr_string(&bp[16]));
138 (void)printf(") %s%s %s",
139 (bp[24] & 0x01) ? "Sparse" : "Dense",
140 (bp[25] & 0x80) ? " WC" : "",
141 (bp[25] & 0x40) ? "RP" : "SPT");
145 TCHECK2(bp[0], sizeof(struct in_addr));
148 (void)printf(" Upstream Nbr: %s", ipaddr_string(bp));
152 (void)printf(" Hold time: ");
153 relts_print(EXTRACT_16BITS(&bp[6]));
167 * XXX - does the address have length "addrlen" and the
168 * mask length "maddrlen"?
170 TCHECK2(bp[0], sizeof(struct in_addr));
171 (void)printf("\n\tGroup: %s", ipaddr_string(bp));
172 TCHECK2(bp[4], sizeof(struct in_addr));
173 if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
174 (void)printf("/%s", ipaddr_string(&bp[4]));
176 njoin = EXTRACT_16BITS(&bp[8]);
177 nprune = EXTRACT_16BITS(&bp[10]);
178 (void)printf(" joined: %d pruned: %d", njoin, nprune);
181 for (njp = 0; njp < (njoin + nprune); njp++) {
189 (void)printf("\n\t%s %s%s%s%s/%d", type,
190 (bp[0] & 0x01) ? "Sparse " : "Dense ",
191 (bp[1] & 0x80) ? "WC " : "",
192 (bp[1] & 0x40) ? "RP " : "SPT ",
193 ipaddr_string(&bp[2]), bp[1] & 0x3f);
200 (void)printf("[|pim]");
205 pimv1_print(register const u_char *bp, register u_int len)
207 register const u_char *ep;
208 register u_char type;
210 ep = (const u_char *)snapend;
219 (void)printf(" Query");
221 switch (bp[8] >> 4) {
223 (void)printf(" Dense-mode");
226 (void)printf(" Sparse-mode");
229 (void)printf(" Sparse-Dense-mode");
232 (void)printf(" mode-%d", bp[8] >> 4);
238 (void)printf(" (Hold-time ");
239 relts_print(EXTRACT_16BITS(&bp[10]));
245 (void)printf(" Register");
246 TCHECK2(bp[8], 20); /* ip header */
247 (void)printf(" for %s > %s", ipaddr_string(&bp[20]),
248 ipaddr_string(&bp[24]));
251 (void)printf(" Register-Stop");
252 TCHECK2(bp[12], sizeof(struct in_addr));
253 (void)printf(" for %s > %s", ipaddr_string(&bp[8]),
254 ipaddr_string(&bp[12]));
257 (void)printf(" Join/Prune");
259 pimv1_join_prune_print(&bp[8], len - 8);
262 (void)printf(" RP-reachable");
265 (void)printf(" group %s",
266 ipaddr_string(&bp[8]));
267 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
268 (void)printf("/%s", ipaddr_string(&bp[12]));
269 (void)printf(" RP %s hold ", ipaddr_string(&bp[16]));
270 relts_print(EXTRACT_16BITS(&bp[22]));
274 (void)printf(" Assert");
275 TCHECK2(bp[16], sizeof(struct in_addr));
276 (void)printf(" for %s > %s", ipaddr_string(&bp[16]),
277 ipaddr_string(&bp[8]));
278 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
279 (void)printf("/%s", ipaddr_string(&bp[12]));
281 (void)printf(" %s pref %d metric %d",
282 (bp[20] & 0x80) ? "RP-tree" : "SPT",
283 EXTRACT_32BITS(&bp[20]) & 0x7fffffff,
284 EXTRACT_32BITS(&bp[24]));
287 (void)printf(" Graft");
289 pimv1_join_prune_print(&bp[8], len - 8);
292 (void)printf(" Graft-ACK");
294 pimv1_join_prune_print(&bp[8], len - 8);
297 (void)printf(" Mode");
300 (void)printf(" [type %d]", type);
303 if ((bp[4] >> 4) != 1)
304 (void)printf(" [v%d]", bp[4] >> 4);
308 (void)printf("[|pim]");
313 * auto-RP is a cisco protocol, documented at
314 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
316 * This implements version 1+, dated Sept 9, 1998.
319 cisco_autorp_print(register const u_char *bp, register u_int len)
326 (void)printf(" auto-rp ");
330 (void)printf("candidate-advert");
333 (void)printf("mapping");
336 (void)printf("type-0x%02x", type);
344 (void)printf(" Hold ");
345 hold = EXTRACT_16BITS(&bp[2]);
347 relts_print(EXTRACT_16BITS(&bp[2]));
351 /* Next 4 bytes are reserved. */
355 /*XXX skip unless -v? */
359 * numrps entries of the form:
362 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
363 * 8 bits: # of entries for this RP
364 * each entry: 7 bits: reserved, 1 bit: negative,
365 * 8 bits: mask 32 bits: source
366 * lather, rinse, repeat.
373 (void)printf(" RP %s", ipaddr_string(bp));
375 switch (bp[4] & 0x3) {
376 case 0: printf(" PIMv?");
378 case 1: printf(" PIMv1");
380 case 2: printf(" PIMv2");
382 case 3: printf(" PIMv1+2");
386 (void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc);
391 for (; nentries; nentries--) {
393 (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
394 ipaddr_string(&bp[2]), bp[1]);
396 (void)printf("[rsvd=0x%02x]", bp[0] & 0xfe);
404 (void)printf("[|autorp]");
409 pim_print(register const u_char *bp, register u_int len)
411 register const u_char *ep;
412 register struct pim *pim = (struct pim *)bp;
414 ep = (const u_char *)snapend;
417 #ifdef notyet /* currently we see only version and type */
418 TCHECK(pim->pim_rsv);
421 switch (PIM_VER(pim->pim_typever)) {
424 printf("PIMv%u, %s, length: %u",
425 PIM_VER(pim->pim_typever),
426 tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
430 printf("PIMv%u, length: %u\n\t%s",
431 PIM_VER(pim->pim_typever),
433 tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
434 pimv2_print(bp, len);
438 printf("PIMv%u, length: %u",
439 PIM_VER(pim->pim_typever),
447 * PIMv2 uses encoded address representations.
449 * The last PIM-SM I-D before RFC2117 was published specified the
450 * following representation for unicast addresses. However, RFC2117
451 * specified no encoding for unicast addresses with the unicast
452 * address length specified in the header. Therefore, we have to
453 * guess which encoding is being used (Cisco's PIMv2 implementation
454 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
455 * field into a 'unicast-address-length-in-bytes' field. We guess
456 * that it's the draft encoding if this reserved field is zero.
458 * RFC2362 goes back to the encoded format, and calls the addr length
459 * field "reserved" again.
461 * The first byte is the address family, from:
464 * 1 IP (IP version 4)
465 * 2 IP6 (IP version 6)
467 * 4 HDLC (8-bit multidrop)
469 * 6 802 (includes all 802 media plus Ethernet "canonical format")
471 * 8 E.164 (SMDS, Frame Relay, ATM)
473 * 10 X.121 (X.25, Frame Relay)
478 * 15 E.164 with NSAP format subaddress
480 * In addition, the second byte is an "Encoding". 0 is the default
481 * encoding for the address family, and no other encodings are currently
486 static int pimv2_addr_len;
488 enum pimv2_addrtype {
489 pimv2_unicast, pimv2_group, pimv2_source
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 | Unicast Address |
496 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
498 * 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
499 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
500 * | Addr Family | Encoding Type | Reserved | Mask Len |
501 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
502 * | Group multicast Address |
503 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
505 * 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
506 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
507 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
508 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
510 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
513 pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
520 if (pimv2_addr_len == 0) {
525 len = sizeof(struct in_addr);
530 len = sizeof(struct in6_addr);
540 switch (pimv2_addr_len) {
541 case sizeof(struct in_addr):
545 case sizeof(struct in6_addr):
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;
747 ip_print(gndo, bp, len);
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]");
1069 * c-style: whitesmith