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>
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)" },
82 #define PIMV2_REGISTER_FLAG_LEN 4
83 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
84 #define PIMV2_REGISTER_FLAG_NULL 0x40000000
86 static struct tok pimv2_register_flag_values[] = {
87 { PIMV2_REGISTER_FLAG_BORDER, "Border" },
88 { PIMV2_REGISTER_FLAG_NULL, "Null" },
93 * XXX: We consider a case where IPv6 is not ready yet for portability,
94 * but PIM dependent defintions should be independent of IPv6...
99 /* upper 4bit: PIM version number; 2 for PIMv2 */
100 /* lower 4bit: the PIM message type, currently they are:
101 * Hello, Register, Register-Stop, Join/Prune,
102 * Bootstrap, Assert, Graft (PIM-DM only),
103 * Graft-Ack (PIM-DM only), C-RP-Adv
105 #define PIM_VER(x) (((x) & 0xf0) >> 4)
106 #define PIM_TYPE(x) ((x) & 0x0f)
107 u_char pim_rsv; /* Reserved */
108 u_short pim_cksum; /* IP style check sum */
115 #include "interface.h"
116 #include "addrtoname.h"
121 static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
124 pimv1_join_prune_print(register const u_char *bp, register u_int len)
126 int maddrlen, addrlen, ngroups, njoin, nprune;
129 /* If it's a single group and a single source, use 1-line output. */
130 if (TTEST2(bp[0], 30) && bp[11] == 1 &&
131 ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
134 (void)printf(" RPF %s ", ipaddr_string(bp));
135 hold = EXTRACT_16BITS(&bp[6]);
137 (void)printf("Hold ");
140 (void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune",
141 ipaddr_string(&bp[26]), bp[25] & 0x3f,
142 ipaddr_string(&bp[12]));
143 if (EXTRACT_32BITS(&bp[16]) != 0xffffffff)
144 (void)printf("/%s", ipaddr_string(&bp[16]));
145 (void)printf(") %s%s %s",
146 (bp[24] & 0x01) ? "Sparse" : "Dense",
147 (bp[25] & 0x80) ? " WC" : "",
148 (bp[25] & 0x40) ? "RP" : "SPT");
152 TCHECK2(bp[0], sizeof(struct in_addr));
155 (void)printf(" Upstream Nbr: %s", ipaddr_string(bp));
159 (void)printf(" Hold time: ");
160 relts_print(EXTRACT_16BITS(&bp[6]));
174 * XXX - does the address have length "addrlen" and the
175 * mask length "maddrlen"?
177 TCHECK2(bp[0], sizeof(struct in_addr));
178 (void)printf("\n\tGroup: %s", ipaddr_string(bp));
179 TCHECK2(bp[4], sizeof(struct in_addr));
180 if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
181 (void)printf("/%s", ipaddr_string(&bp[4]));
183 njoin = EXTRACT_16BITS(&bp[8]);
184 nprune = EXTRACT_16BITS(&bp[10]);
185 (void)printf(" joined: %d pruned: %d", njoin, nprune);
188 for (njp = 0; njp < (njoin + nprune); njp++) {
196 (void)printf("\n\t%s %s%s%s%s/%d", type,
197 (bp[0] & 0x01) ? "Sparse " : "Dense ",
198 (bp[1] & 0x80) ? "WC " : "",
199 (bp[1] & 0x40) ? "RP " : "SPT ",
200 ipaddr_string(&bp[2]), bp[1] & 0x3f);
207 (void)printf("[|pim]");
212 pimv1_print(register const u_char *bp, register u_int len)
214 register const u_char *ep;
215 register u_char type;
217 ep = (const u_char *)snapend;
226 (void)printf(" Query");
228 switch (bp[8] >> 4) {
230 (void)printf(" Dense-mode");
233 (void)printf(" Sparse-mode");
236 (void)printf(" Sparse-Dense-mode");
239 (void)printf(" mode-%d", bp[8] >> 4);
245 (void)printf(" (Hold-time ");
246 relts_print(EXTRACT_16BITS(&bp[10]));
252 (void)printf(" Register");
253 TCHECK2(bp[8], 20); /* ip header */
254 (void)printf(" for %s > %s", ipaddr_string(&bp[20]),
255 ipaddr_string(&bp[24]));
258 (void)printf(" Register-Stop");
259 TCHECK2(bp[12], sizeof(struct in_addr));
260 (void)printf(" for %s > %s", ipaddr_string(&bp[8]),
261 ipaddr_string(&bp[12]));
264 (void)printf(" Join/Prune");
266 pimv1_join_prune_print(&bp[8], len - 8);
269 (void)printf(" RP-reachable");
272 (void)printf(" group %s",
273 ipaddr_string(&bp[8]));
274 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
275 (void)printf("/%s", ipaddr_string(&bp[12]));
276 (void)printf(" RP %s hold ", ipaddr_string(&bp[16]));
277 relts_print(EXTRACT_16BITS(&bp[22]));
281 (void)printf(" Assert");
282 TCHECK2(bp[16], sizeof(struct in_addr));
283 (void)printf(" for %s > %s", ipaddr_string(&bp[16]),
284 ipaddr_string(&bp[8]));
285 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
286 (void)printf("/%s", ipaddr_string(&bp[12]));
288 (void)printf(" %s pref %d metric %d",
289 (bp[20] & 0x80) ? "RP-tree" : "SPT",
290 EXTRACT_32BITS(&bp[20]) & 0x7fffffff,
291 EXTRACT_32BITS(&bp[24]));
294 (void)printf(" Graft");
296 pimv1_join_prune_print(&bp[8], len - 8);
299 (void)printf(" Graft-ACK");
301 pimv1_join_prune_print(&bp[8], len - 8);
304 (void)printf(" Mode");
307 (void)printf(" [type %d]", type);
310 if ((bp[4] >> 4) != 1)
311 (void)printf(" [v%d]", bp[4] >> 4);
315 (void)printf("[|pim]");
320 * auto-RP is a cisco protocol, documented at
321 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
323 * This implements version 1+, dated Sept 9, 1998.
326 cisco_autorp_print(register const u_char *bp, register u_int len)
333 (void)printf(" auto-rp ");
337 (void)printf("candidate-advert");
340 (void)printf("mapping");
343 (void)printf("type-0x%02x", type);
351 (void)printf(" Hold ");
352 hold = EXTRACT_16BITS(&bp[2]);
354 relts_print(EXTRACT_16BITS(&bp[2]));
358 /* Next 4 bytes are reserved. */
362 /*XXX skip unless -v? */
366 * numrps entries of the form:
369 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
370 * 8 bits: # of entries for this RP
371 * each entry: 7 bits: reserved, 1 bit: negative,
372 * 8 bits: mask 32 bits: source
373 * lather, rinse, repeat.
380 (void)printf(" RP %s", ipaddr_string(bp));
382 switch (bp[4] & 0x3) {
383 case 0: printf(" PIMv?");
385 case 1: printf(" PIMv1");
387 case 2: printf(" PIMv2");
389 case 3: printf(" PIMv1+2");
393 (void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc);
398 for (; nentries; nentries--) {
400 (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
401 ipaddr_string(&bp[2]), bp[1]);
403 (void)printf("[rsvd=0x%02x]", bp[0] & 0xfe);
411 (void)printf("[|autorp]");
416 pim_print(register const u_char *bp, register u_int len, u_int cksum)
418 register const u_char *ep;
419 register struct pim *pim = (struct pim *)bp;
421 ep = (const u_char *)snapend;
424 #ifdef notyet /* currently we see only version and type */
425 TCHECK(pim->pim_rsv);
428 switch (PIM_VER(pim->pim_typever)) {
431 printf("PIMv%u, %s, length %u",
432 PIM_VER(pim->pim_typever),
433 tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
437 printf("PIMv%u, length %u\n\t%s",
438 PIM_VER(pim->pim_typever),
440 tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
441 pimv2_print(bp, len, cksum);
445 printf("PIMv%u, length %u",
446 PIM_VER(pim->pim_typever),
454 * PIMv2 uses encoded address representations.
456 * The last PIM-SM I-D before RFC2117 was published specified the
457 * following representation for unicast addresses. However, RFC2117
458 * specified no encoding for unicast addresses with the unicast
459 * address length specified in the header. Therefore, we have to
460 * guess which encoding is being used (Cisco's PIMv2 implementation
461 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
462 * field into a 'unicast-address-length-in-bytes' field. We guess
463 * that it's the draft encoding if this reserved field is zero.
465 * RFC2362 goes back to the encoded format, and calls the addr length
466 * field "reserved" again.
468 * The first byte is the address family, from:
471 * 1 IP (IP version 4)
472 * 2 IP6 (IP version 6)
474 * 4 HDLC (8-bit multidrop)
476 * 6 802 (includes all 802 media plus Ethernet "canonical format")
478 * 8 E.164 (SMDS, Frame Relay, ATM)
480 * 10 X.121 (X.25, Frame Relay)
485 * 15 E.164 with NSAP format subaddress
487 * In addition, the second byte is an "Encoding". 0 is the default
488 * encoding for the address family, and no other encodings are currently
493 static int pimv2_addr_len;
495 enum pimv2_addrtype {
496 pimv2_unicast, pimv2_group, pimv2_source
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 | Unicast 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 | Reserved | Mask Len |
508 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
509 * | Group multicast Address |
510 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
512 * 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
513 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
514 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
515 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
517 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
520 pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
527 if (pimv2_addr_len == 0) {
532 len = sizeof(struct in_addr);
537 len = sizeof(struct in6_addr);
547 switch (pimv2_addr_len) {
548 case sizeof(struct in_addr):
552 case sizeof(struct in6_addr):
560 len = pimv2_addr_len;
570 (void)printf("%s", ipaddr_string(bp));
573 else if (af == AF_INET6) {
575 (void)printf("%s", ip6addr_string(bp));
581 TCHECK2(bp[0], len + 2);
584 (void)printf("%s", ipaddr_string(bp + 2));
586 (void)printf("/%u", bp[1]);
590 else if (af == AF_INET6) {
592 (void)printf("%s", ip6addr_string(bp + 2));
594 (void)printf("/%u", bp[1]);
598 if (bp[0] && !silent) {
599 if (at == pimv2_group) {
600 (void)printf("(0x%02x)", bp[0]);
602 (void)printf("(%s%s%s",
603 bp[0] & 0x04 ? "S" : "",
604 bp[0] & 0x02 ? "W" : "",
605 bp[0] & 0x01 ? "R" : "");
607 (void) printf("+0x%02x", bp[0] & 0xf8);
612 return hdrlen + 2 + len;
621 pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
623 register const u_char *ep;
624 register struct pim *pim = (struct pim *)bp;
627 ep = (const u_char *)snapend;
632 TCHECK(pim->pim_rsv);
633 pimv2_addr_len = pim->pim_rsv;
634 if (pimv2_addr_len != 0)
635 (void)printf(", RFC2117-encoding");
637 printf(", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum));
638 if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
639 printf("(unverified)");
641 printf("(%scorrect)", TTEST2(bp[0], len) && cksum ? "in" : "" );
644 switch (PIM_TYPE(pim->pim_typever)) {
645 case PIMV2_TYPE_HELLO:
647 u_int16_t otype, olen;
651 otype = EXTRACT_16BITS(&bp[0]);
652 olen = EXTRACT_16BITS(&bp[2]);
653 TCHECK2(bp[0], 4 + olen);
655 printf("\n\t %s Option (%u), length %u, Value: ",
656 tok2str( pimv2_hello_option_values,"Unknown",otype),
662 case PIMV2_HELLO_OPTION_HOLDTIME:
663 relts_print(EXTRACT_16BITS(bp));
666 case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
668 (void)printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
671 u_int16_t lan_delay, override_interval;
672 lan_delay = EXTRACT_16BITS(bp);
673 override_interval = EXTRACT_16BITS(bp+2);
674 t_bit = (lan_delay & 0x8000)? 1 : 0;
675 lan_delay &= ~0x8000;
676 (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
677 t_bit, lan_delay, override_interval);
681 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD:
682 case PIMV2_HELLO_OPTION_DR_PRIORITY:
685 printf("Bi-Directional Capability (Old)");
688 printf("%u", EXTRACT_32BITS(bp));
691 printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
696 case PIMV2_HELLO_OPTION_GENID:
697 (void)printf("0x%08x", EXTRACT_32BITS(bp));
700 case PIMV2_HELLO_OPTION_REFRESH_CAP:
701 (void)printf("v%d", *bp);
703 (void)printf(", interval ");
704 relts_print(*(bp+1));
706 if (EXTRACT_16BITS(bp+2) != 0) {
707 (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp+2));
711 case PIMV2_HELLO_OPTION_BIDIR_CAP:
714 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
715 case PIMV2_HELLO_OPTION_ADDRESS_LIST:
717 const u_char *ptr = bp;
718 while (ptr < (bp+olen)) {
722 advance = pimv2_addr_print(ptr, pimv2_unicast, 0);
733 print_unknown_data(bp,"\n\t ",olen);
736 /* do we want to see an additionally hexdump ? */
738 print_unknown_data(bp,"\n\t ",olen);
744 case PIMV2_TYPE_REGISTER:
748 if (!TTEST2(*(bp+4), PIMV2_REGISTER_FLAG_LEN))
751 printf(", Flags [ %s ]\n\t",
752 tok2str(pimv2_register_flag_values,
754 EXTRACT_32BITS(bp+4)));
757 /* encapsulated multicast packet */
758 ip = (struct ip *)bp;
760 case 0: /* Null header */
761 (void)printf("IP-Null-header %s > %s",
762 ipaddr_string(&ip->ip_src),
763 ipaddr_string(&ip->ip_dst));
767 ip_print(gndo, bp, len);
775 (void)printf("IP ver %d", IP_V(ip));
781 case PIMV2_TYPE_REGISTER_STOP:
785 (void)printf(" group=");
786 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
790 bp += advance; len -= advance;
793 (void)printf(" source=");
794 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
798 bp += advance; len -= advance;
801 case PIMV2_TYPE_JOIN_PRUNE:
802 case PIMV2_TYPE_GRAFT:
803 case PIMV2_TYPE_GRAFT_ACK:
808 * 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
809 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
810 * |PIM Ver| Type | Addr length | Checksum |
811 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
812 * | Unicast-Upstream Neighbor Address |
813 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
814 * | Reserved | Num groups | Holdtime |
815 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
816 * | Encoded-Multicast Group Address-1 |
817 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
818 * | Number of Joined Sources | Number of Pruned Sources |
819 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
820 * | Encoded-Joined Source Address-1 |
821 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
824 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
825 * | Encoded-Joined Source Address-n |
826 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
827 * | Encoded-Pruned Source Address-1 |
828 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
831 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
832 * | Encoded-Pruned Source Address-n |
833 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
836 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
837 * | Encoded-Multicast Group Address-n |
838 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
849 if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
852 (void)printf(", upstream-neighbor: ");
853 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
857 bp += advance; len -= advance;
862 holdtime = EXTRACT_16BITS(&bp[2]);
863 (void)printf("\n\t %u group(s)", ngroup);
864 if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
865 (void)printf(", holdtime: ");
866 if (holdtime == 0xffff)
867 (void)printf("infinite");
869 relts_print(holdtime);
872 for (i = 0; i < ngroup; i++) {
875 (void)printf("\n\t group #%u: ", i+1);
876 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
877 (void)printf("...)");
880 bp += advance; len -= advance;
882 (void)printf("...)");
885 njoin = EXTRACT_16BITS(&bp[0]);
886 nprune = EXTRACT_16BITS(&bp[2]);
887 (void)printf(", joined sources: %u, pruned sources: %u", njoin,nprune);
889 for (j = 0; j < njoin; j++) {
890 (void)printf("\n\t joined source #%u: ",j+1);
891 if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
892 (void)printf("...)");
895 bp += advance; len -= advance;
897 for (j = 0; j < nprune; j++) {
898 (void)printf("\n\t pruned source #%u: ",j+1);
899 if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
900 (void)printf("...)");
903 bp += advance; len -= advance;
910 case PIMV2_TYPE_BOOTSTRAP:
915 /* Fragment Tag, Hash Mask len, and BSR-priority */
916 if (bp + sizeof(u_int16_t) >= ep) break;
917 (void)printf(" tag=%x", EXTRACT_16BITS(bp));
918 bp += sizeof(u_int16_t);
920 (void)printf(" hashmlen=%d", bp[0]);
921 if (bp + 1 >= ep) break;
922 (void)printf(" BSRprio=%d", bp[1]);
925 /* Encoded-Unicast-BSR-Address */
927 (void)printf(" BSR=");
928 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
934 for (i = 0; bp < ep; i++) {
935 /* Encoded-Group Address */
936 (void)printf(" (group%d: ", i);
937 if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
939 (void)printf("...)");
944 /* RP-Count, Frag RP-Cnt, and rsvd */
946 (void)printf("...)");
949 (void)printf(" RPcnt=%d", bp[0]);
951 (void)printf("...)");
954 (void)printf(" FRPcnt=%d", frpcnt = bp[1]);
957 for (j = 0; j < frpcnt && bp < ep; j++) {
959 (void)printf(" RP%d=", j);
960 if ((advance = pimv2_addr_print(bp,
963 (void)printf("...)");
969 (void)printf("...)");
972 (void)printf(",holdtime=");
973 relts_print(EXTRACT_16BITS(bp));
975 (void)printf("...)");
978 (void)printf(",prio=%d", bp[2]);
986 case PIMV2_TYPE_ASSERT:
990 (void)printf(" group=");
991 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
995 bp += advance; len -= advance;
998 (void)printf(" src=");
999 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
1000 (void)printf("...");
1003 bp += advance; len -= advance;
1007 (void)printf(" RPT");
1008 (void)printf(" pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff);
1009 (void)printf(" metric=%u", EXTRACT_32BITS(&bp[4]));
1012 case PIMV2_TYPE_CANDIDATE_RP:
1017 /* Prefix-Cnt, Priority, and Holdtime */
1018 if (bp >= ep) break;
1019 (void)printf(" prefix-cnt=%d", bp[0]);
1021 if (bp + 1 >= ep) break;
1022 (void)printf(" prio=%d", bp[1]);
1023 if (bp + 3 >= ep) break;
1024 (void)printf(" holdtime=");
1025 relts_print(EXTRACT_16BITS(&bp[2]));
1028 /* Encoded-Unicast-RP-Address */
1029 if (bp >= ep) break;
1030 (void)printf(" RP=");
1031 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
1032 (void)printf("...");
1037 /* Encoded-Group Addresses */
1038 for (i = 0; i < pfxcnt && bp < ep; i++) {
1039 (void)printf(" Group%d=", i);
1040 if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
1042 (void)printf("...");
1050 case PIMV2_TYPE_PRUNE_REFRESH:
1051 (void)printf(" src=");
1052 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
1053 (void)printf("...");
1057 (void)printf(" grp=");
1058 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
1059 (void)printf("...");
1063 (void)printf(" forwarder=");
1064 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
1065 (void)printf("...");
1070 (void)printf(" TUNR ");
1071 relts_print(EXTRACT_16BITS(bp));
1076 (void)printf(" [type %d]", PIM_TYPE(pim->pim_typever));
1083 (void)printf("[|pim]");
1088 * c-style: whitesmith