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.
26 #include <tcpdump-stdinc.h>
31 #include "interface.h"
32 #include "addrtoname.h"
37 #define PIMV2_TYPE_HELLO 0
38 #define PIMV2_TYPE_REGISTER 1
39 #define PIMV2_TYPE_REGISTER_STOP 2
40 #define PIMV2_TYPE_JOIN_PRUNE 3
41 #define PIMV2_TYPE_BOOTSTRAP 4
42 #define PIMV2_TYPE_ASSERT 5
43 #define PIMV2_TYPE_GRAFT 6
44 #define PIMV2_TYPE_GRAFT_ACK 7
45 #define PIMV2_TYPE_CANDIDATE_RP 8
46 #define PIMV2_TYPE_PRUNE_REFRESH 9
48 static const struct tok pimv2_type_values
[] = {
49 { PIMV2_TYPE_HELLO
, "Hello" },
50 { PIMV2_TYPE_REGISTER
, "Register" },
51 { PIMV2_TYPE_REGISTER_STOP
, "Register Stop" },
52 { PIMV2_TYPE_JOIN_PRUNE
, "Join / Prune" },
53 { PIMV2_TYPE_BOOTSTRAP
, "Bootstrap" },
54 { PIMV2_TYPE_ASSERT
, "Assert" },
55 { PIMV2_TYPE_GRAFT
, "Graft" },
56 { PIMV2_TYPE_GRAFT_ACK
, "Graft Acknowledgement" },
57 { PIMV2_TYPE_CANDIDATE_RP
, "Candidate RP Advertisement" },
58 { PIMV2_TYPE_PRUNE_REFRESH
, "Prune Refresh" },
62 #define PIMV2_HELLO_OPTION_HOLDTIME 1
63 #define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
64 #define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
65 #define PIMV2_HELLO_OPTION_DR_PRIORITY 19
66 #define PIMV2_HELLO_OPTION_GENID 20
67 #define PIMV2_HELLO_OPTION_REFRESH_CAP 21
68 #define PIMV2_HELLO_OPTION_BIDIR_CAP 22
69 #define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
70 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
72 static const struct tok pimv2_hello_option_values
[] = {
73 { PIMV2_HELLO_OPTION_HOLDTIME
, "Hold Time" },
74 { PIMV2_HELLO_OPTION_LANPRUNEDELAY
, "LAN Prune Delay" },
75 { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
, "DR Priority (Old)" },
76 { PIMV2_HELLO_OPTION_DR_PRIORITY
, "DR Priority" },
77 { PIMV2_HELLO_OPTION_GENID
, "Generation ID" },
78 { PIMV2_HELLO_OPTION_REFRESH_CAP
, "State Refresh Capability" },
79 { PIMV2_HELLO_OPTION_BIDIR_CAP
, "Bi-Directional Capability" },
80 { PIMV2_HELLO_OPTION_ADDRESS_LIST
, "Address List" },
81 { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
, "Address List (Old)" },
85 #define PIMV2_REGISTER_FLAG_LEN 4
86 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
87 #define PIMV2_REGISTER_FLAG_NULL 0x40000000
89 static const struct tok pimv2_register_flag_values
[] = {
90 { PIMV2_REGISTER_FLAG_BORDER
, "Border" },
91 { PIMV2_REGISTER_FLAG_NULL
, "Null" },
96 * XXX: We consider a case where IPv6 is not ready yet for portability,
97 * but PIM dependent defintions should be independent of IPv6...
101 u_int8_t pim_typever
;
102 /* upper 4bit: PIM version number; 2 for PIMv2 */
103 /* lower 4bit: the PIM message type, currently they are:
104 * Hello, Register, Register-Stop, Join/Prune,
105 * Bootstrap, Assert, Graft (PIM-DM only),
106 * Graft-Ack (PIM-DM only), C-RP-Adv
108 #define PIM_VER(x) (((x) & 0xf0) >> 4)
109 #define PIM_TYPE(x) ((x) & 0x0f)
110 u_char pim_rsv
; /* Reserved */
111 u_short pim_cksum
; /* IP style check sum */
114 static void pimv2_print(register const u_char
*bp
, register u_int len
, u_int cksum
);
117 pimv1_join_prune_print(register const u_char
*bp
, register u_int len
)
119 int 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]));
165 * XXX - does the address have length "addrlen" and the
166 * mask length "maddrlen"?
168 TCHECK2(bp
[0], sizeof(struct in_addr
));
169 (void)printf("\n\tGroup: %s", ipaddr_string(bp
));
170 TCHECK2(bp
[4], sizeof(struct in_addr
));
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");
250 TCHECK2(bp
[12], sizeof(struct in_addr
));
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");
273 TCHECK2(bp
[16], sizeof(struct in_addr
));
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(" bidir");
397 (void)printf("[rsvd=0x%02x]", bp
[0] & 0xfc);
406 (void)printf("[|autorp]");
411 pim_print(register const u_char
*bp
, register u_int len
, u_int cksum
)
413 register const u_char
*ep
;
414 register struct pim
*pim
= (struct pim
*)bp
;
416 ep
= (const u_char
*)snapend
;
419 #ifdef notyet /* currently we see only version and type */
420 TCHECK(pim
->pim_rsv
);
423 switch (PIM_VER(pim
->pim_typever
)) {
426 printf("PIMv%u, %s, length %u",
427 PIM_VER(pim
->pim_typever
),
428 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
432 printf("PIMv%u, length %u\n\t%s",
433 PIM_VER(pim
->pim_typever
),
435 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)));
436 pimv2_print(bp
, len
, cksum
);
440 printf("PIMv%u, length %u",
441 PIM_VER(pim
->pim_typever
),
449 * PIMv2 uses encoded address representations.
451 * The last PIM-SM I-D before RFC2117 was published specified the
452 * following representation for unicast addresses. However, RFC2117
453 * specified no encoding for unicast addresses with the unicast
454 * address length specified in the header. Therefore, we have to
455 * guess which encoding is being used (Cisco's PIMv2 implementation
456 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
457 * field into a 'unicast-address-length-in-bytes' field. We guess
458 * that it's the draft encoding if this reserved field is zero.
460 * RFC2362 goes back to the encoded format, and calls the addr length
461 * field "reserved" again.
463 * The first byte is the address family, from:
466 * 1 IP (IP version 4)
467 * 2 IP6 (IP version 6)
469 * 4 HDLC (8-bit multidrop)
471 * 6 802 (includes all 802 media plus Ethernet "canonical format")
473 * 8 E.164 (SMDS, Frame Relay, ATM)
475 * 10 X.121 (X.25, Frame Relay)
480 * 15 E.164 with NSAP format subaddress
482 * In addition, the second byte is an "Encoding". 0 is the default
483 * encoding for the address family, and no other encodings are currently
488 static int pimv2_addr_len
;
490 enum pimv2_addrtype
{
491 pimv2_unicast
, pimv2_group
, pimv2_source
495 * 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
496 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
497 * | Addr Family | Encoding Type | Unicast Address |
498 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
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 | Reserved | Mask Len |
503 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
504 * | Group multicast 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 | Rsrvd |S|W|R| Mask Len |
510 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
512 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
515 pimv2_addr_print(const u_char
*bp
, enum pimv2_addrtype at
, int silent
)
522 if (pimv2_addr_len
== 0) {
527 len
= sizeof(struct in_addr
);
532 len
= sizeof(struct in6_addr
);
542 switch (pimv2_addr_len
) {
543 case sizeof(struct in_addr
):
547 case sizeof(struct in6_addr
):
555 len
= pimv2_addr_len
;
565 (void)printf("%s", ipaddr_string(bp
));
568 else if (af
== AF_INET6
) {
570 (void)printf("%s", ip6addr_string(bp
));
576 TCHECK2(bp
[0], len
+ 2);
579 (void)printf("%s", ipaddr_string(bp
+ 2));
581 (void)printf("/%u", bp
[1]);
585 else if (af
== AF_INET6
) {
587 (void)printf("%s", ip6addr_string(bp
+ 2));
589 (void)printf("/%u", bp
[1]);
593 if (bp
[0] && !silent
) {
594 if (at
== pimv2_group
) {
595 (void)printf("(0x%02x)", bp
[0]);
597 (void)printf("(%s%s%s",
598 bp
[0] & 0x04 ? "S" : "",
599 bp
[0] & 0x02 ? "W" : "",
600 bp
[0] & 0x01 ? "R" : "");
602 (void) printf("+0x%02x", bp
[0] & 0xf8);
607 return hdrlen
+ 2 + len
;
616 pimv2_print(register const u_char
*bp
, register u_int len
, u_int cksum
)
618 register const u_char
*ep
;
619 register struct pim
*pim
= (struct pim
*)bp
;
622 ep
= (const u_char
*)snapend
;
627 TCHECK(pim
->pim_rsv
);
628 pimv2_addr_len
= pim
->pim_rsv
;
629 if (pimv2_addr_len
!= 0)
630 (void)printf(", RFC2117-encoding");
632 printf(", cksum 0x%04x ", EXTRACT_16BITS(&pim
->pim_cksum
));
633 if (EXTRACT_16BITS(&pim
->pim_cksum
) == 0) {
634 printf("(unverified)");
636 printf("(%scorrect)", TTEST2(bp
[0], len
) && cksum
? "in" : "" );
639 switch (PIM_TYPE(pim
->pim_typever
)) {
640 case PIMV2_TYPE_HELLO
:
642 u_int16_t otype
, olen
;
646 otype
= EXTRACT_16BITS(&bp
[0]);
647 olen
= EXTRACT_16BITS(&bp
[2]);
648 TCHECK2(bp
[0], 4 + olen
);
650 printf("\n\t %s Option (%u), length %u, Value: ",
651 tok2str( pimv2_hello_option_values
,"Unknown",otype
),
657 case PIMV2_HELLO_OPTION_HOLDTIME
:
658 relts_print(EXTRACT_16BITS(bp
));
661 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
663 (void)printf("ERROR: Option Length != 4 Bytes (%u)", olen
);
666 u_int16_t lan_delay
, override_interval
;
667 lan_delay
= EXTRACT_16BITS(bp
);
668 override_interval
= EXTRACT_16BITS(bp
+2);
669 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
670 lan_delay
&= ~0x8000;
671 (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
672 t_bit
, lan_delay
, override_interval
);
676 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
677 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
680 printf("Bi-Directional Capability (Old)");
683 printf("%u", EXTRACT_32BITS(bp
));
686 printf("ERROR: Option Length != 4 Bytes (%u)", olen
);
691 case PIMV2_HELLO_OPTION_GENID
:
692 (void)printf("0x%08x", EXTRACT_32BITS(bp
));
695 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
696 (void)printf("v%d", *bp
);
698 (void)printf(", interval ");
699 relts_print(*(bp
+1));
701 if (EXTRACT_16BITS(bp
+2) != 0) {
702 (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp
+2));
706 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
709 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
710 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
712 const u_char
*ptr
= bp
;
713 while (ptr
< (bp
+olen
)) {
717 advance
= pimv2_addr_print(ptr
, pimv2_unicast
, 0);
728 print_unknown_data(gndo
,bp
,"\n\t ",olen
);
731 /* do we want to see an additionally hexdump ? */
733 print_unknown_data(gndo
,bp
,"\n\t ",olen
);
739 case PIMV2_TYPE_REGISTER
:
743 if (!TTEST2(*(bp
+4), PIMV2_REGISTER_FLAG_LEN
))
746 printf(", Flags [ %s ]\n\t",
747 tok2str(pimv2_register_flag_values
,
749 EXTRACT_32BITS(bp
+4)));
752 /* encapsulated multicast packet */
753 ip
= (struct ip
*)bp
;
755 case 0: /* Null header */
756 (void)printf("IP-Null-header %s > %s",
757 ipaddr_string(&ip
->ip_src
),
758 ipaddr_string(&ip
->ip_dst
));
762 ip_print(gndo
, bp
, len
);
766 ip6_print(gndo
, bp
, len
);
770 (void)printf("IP ver %d", IP_V(ip
));
776 case PIMV2_TYPE_REGISTER_STOP
:
780 (void)printf(" group=");
781 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
785 bp
+= advance
; len
-= advance
;
788 (void)printf(" source=");
789 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
793 bp
+= advance
; len
-= advance
;
796 case PIMV2_TYPE_JOIN_PRUNE
:
797 case PIMV2_TYPE_GRAFT
:
798 case PIMV2_TYPE_GRAFT_ACK
:
803 * 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
804 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
805 * |PIM Ver| Type | Addr length | Checksum |
806 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
807 * | Unicast-Upstream Neighbor Address |
808 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
809 * | Reserved | Num groups | Holdtime |
810 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
811 * | Encoded-Multicast Group Address-1 |
812 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
813 * | Number of Joined Sources | Number of Pruned Sources |
814 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
815 * | Encoded-Joined Source Address-1 |
816 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
819 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
820 * | Encoded-Joined Source Address-n |
821 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
822 * | Encoded-Pruned Source Address-1 |
823 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
826 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
827 * | Encoded-Pruned Source Address-n |
828 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
831 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
832 * | Encoded-Multicast Group Address-n |
833 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
844 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
847 (void)printf(", upstream-neighbor: ");
848 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
852 bp
+= advance
; len
-= advance
;
857 holdtime
= EXTRACT_16BITS(&bp
[2]);
858 (void)printf("\n\t %u group(s)", ngroup
);
859 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
860 (void)printf(", holdtime: ");
861 if (holdtime
== 0xffff)
862 (void)printf("infinite");
864 relts_print(holdtime
);
867 for (i
= 0; i
< ngroup
; i
++) {
870 (void)printf("\n\t group #%u: ", i
+1);
871 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
872 (void)printf("...)");
875 bp
+= advance
; len
-= advance
;
877 (void)printf("...)");
880 njoin
= EXTRACT_16BITS(&bp
[0]);
881 nprune
= EXTRACT_16BITS(&bp
[2]);
882 (void)printf(", joined sources: %u, pruned sources: %u", njoin
,nprune
);
884 for (j
= 0; j
< njoin
; j
++) {
885 (void)printf("\n\t joined source #%u: ",j
+1);
886 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
887 (void)printf("...)");
890 bp
+= advance
; len
-= advance
;
892 for (j
= 0; j
< nprune
; j
++) {
893 (void)printf("\n\t pruned source #%u: ",j
+1);
894 if ((advance
= pimv2_addr_print(bp
, pimv2_source
, 0)) < 0) {
895 (void)printf("...)");
898 bp
+= advance
; len
-= advance
;
905 case PIMV2_TYPE_BOOTSTRAP
:
910 /* Fragment Tag, Hash Mask len, and BSR-priority */
911 if (bp
+ sizeof(u_int16_t
) >= ep
) break;
912 (void)printf(" tag=%x", EXTRACT_16BITS(bp
));
913 bp
+= sizeof(u_int16_t
);
915 (void)printf(" hashmlen=%d", bp
[0]);
916 if (bp
+ 1 >= ep
) break;
917 (void)printf(" BSRprio=%d", bp
[1]);
920 /* Encoded-Unicast-BSR-Address */
922 (void)printf(" BSR=");
923 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
929 for (i
= 0; bp
< ep
; i
++) {
930 /* Encoded-Group Address */
931 (void)printf(" (group%d: ", i
);
932 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
934 (void)printf("...)");
939 /* RP-Count, Frag RP-Cnt, and rsvd */
941 (void)printf("...)");
944 (void)printf(" RPcnt=%d", bp
[0]);
946 (void)printf("...)");
949 (void)printf(" FRPcnt=%d", frpcnt
= bp
[1]);
952 for (j
= 0; j
< frpcnt
&& bp
< ep
; j
++) {
954 (void)printf(" RP%d=", j
);
955 if ((advance
= pimv2_addr_print(bp
,
958 (void)printf("...)");
964 (void)printf("...)");
967 (void)printf(",holdtime=");
968 relts_print(EXTRACT_16BITS(bp
));
970 (void)printf("...)");
973 (void)printf(",prio=%d", bp
[2]);
981 case PIMV2_TYPE_ASSERT
:
985 (void)printf(" group=");
986 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
990 bp
+= advance
; len
-= advance
;
993 (void)printf(" src=");
994 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
998 bp
+= advance
; len
-= advance
;
1002 (void)printf(" RPT");
1003 (void)printf(" pref=%u", EXTRACT_32BITS(&bp
[0]) & 0x7fffffff);
1004 (void)printf(" metric=%u", EXTRACT_32BITS(&bp
[4]));
1007 case PIMV2_TYPE_CANDIDATE_RP
:
1012 /* Prefix-Cnt, Priority, and Holdtime */
1013 if (bp
>= ep
) break;
1014 (void)printf(" prefix-cnt=%d", bp
[0]);
1016 if (bp
+ 1 >= ep
) break;
1017 (void)printf(" prio=%d", bp
[1]);
1018 if (bp
+ 3 >= ep
) break;
1019 (void)printf(" holdtime=");
1020 relts_print(EXTRACT_16BITS(&bp
[2]));
1023 /* Encoded-Unicast-RP-Address */
1024 if (bp
>= ep
) break;
1025 (void)printf(" RP=");
1026 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1027 (void)printf("...");
1032 /* Encoded-Group Addresses */
1033 for (i
= 0; i
< pfxcnt
&& bp
< ep
; i
++) {
1034 (void)printf(" Group%d=", i
);
1035 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0))
1037 (void)printf("...");
1045 case PIMV2_TYPE_PRUNE_REFRESH
:
1046 (void)printf(" src=");
1047 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1048 (void)printf("...");
1052 (void)printf(" grp=");
1053 if ((advance
= pimv2_addr_print(bp
, pimv2_group
, 0)) < 0) {
1054 (void)printf("...");
1058 (void)printf(" forwarder=");
1059 if ((advance
= pimv2_addr_print(bp
, pimv2_unicast
, 0)) < 0) {
1060 (void)printf("...");
1065 (void)printf(" TUNR ");
1066 relts_print(EXTRACT_16BITS(bp
));
1071 (void)printf(" [type %d]", PIM_TYPE(pim
->pim_typever
));
1078 (void)printf("[|pim]");
1083 * c-style: whitesmith