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.
22 #define NETDISSECT_REWORKED
27 #include <tcpdump-stdinc.h>
29 #include "interface.h"
30 #include "addrtoname.h"
35 #define PIMV2_TYPE_HELLO 0
36 #define PIMV2_TYPE_REGISTER 1
37 #define PIMV2_TYPE_REGISTER_STOP 2
38 #define PIMV2_TYPE_JOIN_PRUNE 3
39 #define PIMV2_TYPE_BOOTSTRAP 4
40 #define PIMV2_TYPE_ASSERT 5
41 #define PIMV2_TYPE_GRAFT 6
42 #define PIMV2_TYPE_GRAFT_ACK 7
43 #define PIMV2_TYPE_CANDIDATE_RP 8
44 #define PIMV2_TYPE_PRUNE_REFRESH 9
46 static const struct tok pimv2_type_values
[] = {
47 { PIMV2_TYPE_HELLO
, "Hello" },
48 { PIMV2_TYPE_REGISTER
, "Register" },
49 { PIMV2_TYPE_REGISTER_STOP
, "Register Stop" },
50 { PIMV2_TYPE_JOIN_PRUNE
, "Join / Prune" },
51 { PIMV2_TYPE_BOOTSTRAP
, "Bootstrap" },
52 { PIMV2_TYPE_ASSERT
, "Assert" },
53 { PIMV2_TYPE_GRAFT
, "Graft" },
54 { PIMV2_TYPE_GRAFT_ACK
, "Graft Acknowledgement" },
55 { PIMV2_TYPE_CANDIDATE_RP
, "Candidate RP Advertisement" },
56 { PIMV2_TYPE_PRUNE_REFRESH
, "Prune Refresh" },
60 #define PIMV2_HELLO_OPTION_HOLDTIME 1
61 #define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
62 #define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
63 #define PIMV2_HELLO_OPTION_DR_PRIORITY 19
64 #define PIMV2_HELLO_OPTION_GENID 20
65 #define PIMV2_HELLO_OPTION_REFRESH_CAP 21
66 #define PIMV2_HELLO_OPTION_BIDIR_CAP 22
67 #define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
68 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
70 static const struct tok pimv2_hello_option_values
[] = {
71 { PIMV2_HELLO_OPTION_HOLDTIME
, "Hold Time" },
72 { PIMV2_HELLO_OPTION_LANPRUNEDELAY
, "LAN Prune Delay" },
73 { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
, "DR Priority (Old)" },
74 { PIMV2_HELLO_OPTION_DR_PRIORITY
, "DR Priority" },
75 { PIMV2_HELLO_OPTION_GENID
, "Generation ID" },
76 { PIMV2_HELLO_OPTION_REFRESH_CAP
, "State Refresh Capability" },
77 { PIMV2_HELLO_OPTION_BIDIR_CAP
, "Bi-Directional Capability" },
78 { PIMV2_HELLO_OPTION_ADDRESS_LIST
, "Address List" },
79 { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
, "Address List (Old)" },
83 #define PIMV2_REGISTER_FLAG_LEN 4
84 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
85 #define PIMV2_REGISTER_FLAG_NULL 0x40000000
87 static const struct tok pimv2_register_flag_values
[] = {
88 { PIMV2_REGISTER_FLAG_BORDER
, "Border" },
89 { PIMV2_REGISTER_FLAG_NULL
, "Null" },
94 * XXX: We consider a case where IPv6 is not ready yet for portability,
95 * but PIM dependent defintions should be independent of IPv6...
100 /* upper 4bit: PIM version number; 2 for PIMv2 */
101 /* lower 4bit: the PIM message type, currently they are:
102 * Hello, Register, Register-Stop, Join/Prune,
103 * Bootstrap, Assert, Graft (PIM-DM only),
104 * Graft-Ack (PIM-DM only), C-RP-Adv
106 #define PIM_VER(x) (((x) & 0xf0) >> 4)
107 #define PIM_TYPE(x) ((x) & 0x0f)
108 u_char pim_rsv
; /* Reserved */
109 u_short pim_cksum
; /* IP style check sum */
112 static void pimv2_print(netdissect_options
*, register const u_char
*bp
, register u_int len
, u_int cksum
);
115 pimv1_join_prune_print(netdissect_options
*ndo
,
116 register const u_char
*bp
, register u_int len
)
118 int ngroups
, njoin
, nprune
;
121 /* If it's a single group and a single source, use 1-line output. */
122 if (ND_TTEST2(bp
[0], 30) && bp
[11] == 1 &&
123 ((njoin
= EXTRACT_16BITS(&bp
[20])) + EXTRACT_16BITS(&bp
[22])) == 1) {
126 ND_PRINT((ndo
, " RPF %s ", ipaddr_string(bp
)));
127 hold
= EXTRACT_16BITS(&bp
[6]);
129 ND_PRINT((ndo
, "Hold "));
132 ND_PRINT((ndo
, "%s (%s/%d, %s", njoin
? "Join" : "Prune",
133 ipaddr_string(&bp
[26]), bp
[25] & 0x3f,
134 ipaddr_string(&bp
[12])));
135 if (EXTRACT_32BITS(&bp
[16]) != 0xffffffff)
136 ND_PRINT((ndo
, "/%s", ipaddr_string(&bp
[16])));
137 ND_PRINT((ndo
, ") %s%s %s",
138 (bp
[24] & 0x01) ? "Sparse" : "Dense",
139 (bp
[25] & 0x80) ? " WC" : "",
140 (bp
[25] & 0x40) ? "RP" : "SPT"));
144 ND_TCHECK2(bp
[0], sizeof(struct in_addr
));
145 if (ndo
->ndo_vflag
> 1)
146 ND_PRINT((ndo
, "\n"));
147 ND_PRINT((ndo
, " Upstream Nbr: %s", ipaddr_string(bp
)));
148 ND_TCHECK2(bp
[6], 2);
149 if (ndo
->ndo_vflag
> 1)
150 ND_PRINT((ndo
, "\n"));
151 ND_PRINT((ndo
, " Hold time: "));
152 relts_print(EXTRACT_16BITS(&bp
[6]));
153 if (ndo
->ndo_vflag
< 2)
158 ND_TCHECK2(bp
[0], 4);
164 * XXX - does the address have length "addrlen" and the
165 * mask length "maddrlen"?
167 ND_TCHECK2(bp
[0], sizeof(struct in_addr
));
168 ND_PRINT((ndo
, "\n\tGroup: %s", ipaddr_string(bp
)));
169 ND_TCHECK2(bp
[4], sizeof(struct in_addr
));
170 if (EXTRACT_32BITS(&bp
[4]) != 0xffffffff)
171 ND_PRINT((ndo
, "/%s", ipaddr_string(&bp
[4])));
172 ND_TCHECK2(bp
[8], 4);
173 njoin
= EXTRACT_16BITS(&bp
[8]);
174 nprune
= EXTRACT_16BITS(&bp
[10]);
175 ND_PRINT((ndo
, " joined: %d pruned: %d", njoin
, nprune
));
178 for (njp
= 0; njp
< (njoin
+ nprune
); njp
++) {
185 ND_TCHECK2(bp
[0], 6);
186 ND_PRINT((ndo
, "\n\t%s %s%s%s%s/%d", type
,
187 (bp
[0] & 0x01) ? "Sparse " : "Dense ",
188 (bp
[1] & 0x80) ? "WC " : "",
189 (bp
[1] & 0x40) ? "RP " : "SPT ",
190 ipaddr_string(&bp
[2]), bp
[1] & 0x3f));
197 ND_PRINT((ndo
, "[|pim]"));
202 pimv1_print(netdissect_options
*ndo
,
203 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
*)ndo
->ndo_snapend
;
217 ND_PRINT((ndo
, " Query"));
218 if (ND_TTEST(bp
[8])) {
219 switch (bp
[8] >> 4) {
221 ND_PRINT((ndo
, " Dense-mode"));
224 ND_PRINT((ndo
, " Sparse-mode"));
227 ND_PRINT((ndo
, " Sparse-Dense-mode"));
230 ND_PRINT((ndo
, " mode-%d", bp
[8] >> 4));
234 if (ndo
->ndo_vflag
) {
235 ND_TCHECK2(bp
[10],2);
236 ND_PRINT((ndo
, " (Hold-time "));
237 relts_print(EXTRACT_16BITS(&bp
[10]));
238 ND_PRINT((ndo
, ")"));
243 ND_PRINT((ndo
, " Register"));
244 ND_TCHECK2(bp
[8], 20); /* ip header */
245 ND_PRINT((ndo
, " for %s > %s", ipaddr_string(&bp
[20]),
246 ipaddr_string(&bp
[24])));
249 ND_PRINT((ndo
, " Register-Stop"));
250 ND_TCHECK2(bp
[12], sizeof(struct in_addr
));
251 ND_PRINT((ndo
, " for %s > %s", ipaddr_string(&bp
[8]),
252 ipaddr_string(&bp
[12])));
255 ND_PRINT((ndo
, " Join/Prune"));
257 pimv1_join_prune_print(ndo
, &bp
[8], len
- 8);
260 ND_PRINT((ndo
, " RP-reachable"));
261 if (ndo
->ndo_vflag
) {
262 ND_TCHECK2(bp
[22], 2);
263 ND_PRINT((ndo
, " group %s", ipaddr_string(&bp
[8])));
264 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
265 ND_PRINT((ndo
, "/%s", ipaddr_string(&bp
[12])));
266 ND_PRINT((ndo
, " RP %s hold ", ipaddr_string(&bp
[16])));
267 relts_print(EXTRACT_16BITS(&bp
[22]));
271 ND_PRINT((ndo
, " Assert"));
272 ND_TCHECK2(bp
[16], sizeof(struct in_addr
));
273 ND_PRINT((ndo
, " for %s > %s", ipaddr_string(&bp
[16]),
274 ipaddr_string(&bp
[8])));
275 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
276 ND_PRINT((ndo
, "/%s", ipaddr_string(&bp
[12])));
277 ND_TCHECK2(bp
[24], 4);
278 ND_PRINT((ndo
, " %s pref %d metric %d",
279 (bp
[20] & 0x80) ? "RP-tree" : "SPT",
280 EXTRACT_32BITS(&bp
[20]) & 0x7fffffff,
281 EXTRACT_32BITS(&bp
[24])));
284 ND_PRINT((ndo
, " Graft"));
286 pimv1_join_prune_print(ndo
, &bp
[8], len
- 8);
289 ND_PRINT((ndo
, " Graft-ACK"));
291 pimv1_join_prune_print(ndo
, &bp
[8], len
- 8);
294 ND_PRINT((ndo
, " Mode"));
297 ND_PRINT((ndo
, " [type %d]", type
));
300 if ((bp
[4] >> 4) != 1)
301 ND_PRINT((ndo
, " [v%d]", bp
[4] >> 4));
305 ND_PRINT((ndo
, "[|pim]"));
310 * auto-RP is a cisco protocol, documented at
311 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
313 * This implements version 1+, dated Sept 9, 1998.
316 cisco_autorp_print(netdissect_options
*ndo
,
317 register const u_char
*bp
, register u_int len
)
324 ND_PRINT((ndo
, " auto-rp "));
328 ND_PRINT((ndo
, "candidate-advert"));
331 ND_PRINT((ndo
, "mapping"));
334 ND_PRINT((ndo
, "type-0x%02x", type
));
341 ND_TCHECK2(bp
[2], 2);
342 ND_PRINT((ndo
, " Hold "));
343 hold
= EXTRACT_16BITS(&bp
[2]);
345 relts_print(EXTRACT_16BITS(&bp
[2]));
347 ND_PRINT((ndo
, "FOREVER"));
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.
370 ND_TCHECK2(bp
[0], 4);
371 ND_PRINT((ndo
, " RP %s", ipaddr_string(bp
)));
373 switch (bp
[4] & 0x3) {
374 case 0: ND_PRINT((ndo
, " PIMv?"));
376 case 1: ND_PRINT((ndo
, " PIMv1"));
378 case 2: ND_PRINT((ndo
, " PIMv2"));
380 case 3: ND_PRINT((ndo
, " PIMv1+2"));
384 ND_PRINT((ndo
, " [rsvd=0x%02x]", bp
[4] & 0xfc));
389 for (; nentries
; nentries
--) {
390 ND_TCHECK2(bp
[0], 6);
391 ND_PRINT((ndo
, "%c%s%s/%d", s
, bp
[0] & 1 ? "!" : "",
392 ipaddr_string(&bp
[2]), bp
[1]));
394 ND_PRINT((ndo
, " bidir"));
397 ND_PRINT((ndo
, "[rsvd=0x%02x]", bp
[0] & 0xfc));
406 ND_PRINT((ndo
, "[|autorp]"));
411 pim_print(netdissect_options
*ndo
,
412 register const u_char
*bp
, register u_int len
, u_int cksum
)
414 register const u_char
*ep
;
415 register struct pim
*pim
= (struct pim
*)bp
;
417 ep
= (const u_char
*)ndo
->ndo_snapend
;
420 #ifdef notyet /* currently we see only version and type */
421 ND_TCHECK(pim
->pim_rsv
);
424 switch (PIM_VER(pim
->pim_typever
)) {
426 if (!ndo
->ndo_vflag
) {
427 ND_PRINT((ndo
, "PIMv%u, %s, length %u",
428 PIM_VER(pim
->pim_typever
),
429 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
433 ND_PRINT((ndo
, "PIMv%u, length %u\n\t%s",
434 PIM_VER(pim
->pim_typever
),
436 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
))));
437 pimv2_print(ndo
, bp
, len
, cksum
);
441 ND_PRINT((ndo
, "PIMv%u, length %u",
442 PIM_VER(pim
->pim_typever
),
450 * PIMv2 uses encoded address representations.
452 * The last PIM-SM I-D before RFC2117 was published specified the
453 * following representation for unicast addresses. However, RFC2117
454 * specified no encoding for unicast addresses with the unicast
455 * address length specified in the header. Therefore, we have to
456 * guess which encoding is being used (Cisco's PIMv2 implementation
457 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
458 * field into a 'unicast-address-length-in-bytes' field. We guess
459 * that it's the draft encoding if this reserved field is zero.
461 * RFC2362 goes back to the encoded format, and calls the addr length
462 * field "reserved" again.
464 * The first byte is the address family, from:
467 * 1 IP (IP version 4)
468 * 2 IP6 (IP version 6)
470 * 4 HDLC (8-bit multidrop)
472 * 6 802 (includes all 802 media plus Ethernet "canonical format")
474 * 8 E.164 (SMDS, Frame Relay, ATM)
476 * 10 X.121 (X.25, Frame Relay)
481 * 15 E.164 with NSAP format subaddress
483 * In addition, the second byte is an "Encoding". 0 is the default
484 * encoding for the address family, and no other encodings are currently
489 static int pimv2_addr_len
;
491 enum pimv2_addrtype
{
492 pimv2_unicast
, pimv2_group
, pimv2_source
496 * 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
497 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
498 * | Addr Family | Encoding Type | Unicast Address |
499 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
501 * 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
502 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
503 * | Addr Family | Encoding Type | Reserved | Mask Len |
504 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
505 * | Group multicast Address |
506 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
508 * 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
509 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
510 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
511 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
513 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
516 pimv2_addr_print(netdissect_options
*ndo
,
517 const u_char
*bp
, enum pimv2_addrtype at
, int silent
)
524 if (pimv2_addr_len
== 0) {
529 len
= sizeof(struct in_addr
);
534 len
= sizeof(struct in6_addr
);
544 switch (pimv2_addr_len
) {
545 case sizeof(struct in_addr
):
549 case sizeof(struct in6_addr
):
557 len
= pimv2_addr_len
;
564 ND_TCHECK2(bp
[0], len
);
567 ND_PRINT((ndo
, "%s", ipaddr_string(bp
)));
570 else if (af
== AF_INET6
) {
572 ND_PRINT((ndo
, "%s", ip6addr_string(bp
)));
578 ND_TCHECK2(bp
[0], len
+ 2);
581 ND_PRINT((ndo
, "%s", ipaddr_string(bp
+ 2)));
583 ND_PRINT((ndo
, "/%u", bp
[1]));
587 else if (af
== AF_INET6
) {
589 ND_PRINT((ndo
, "%s", ip6addr_string(bp
+ 2)));
591 ND_PRINT((ndo
, "/%u", bp
[1]));
595 if (bp
[0] && !silent
) {
596 if (at
== pimv2_group
) {
597 ND_PRINT((ndo
, "(0x%02x)", bp
[0]));
599 ND_PRINT((ndo
, "(%s%s%s",
600 bp
[0] & 0x04 ? "S" : "",
601 bp
[0] & 0x02 ? "W" : "",
602 bp
[0] & 0x01 ? "R" : ""));
604 ND_PRINT((ndo
, "+0x%02x", bp
[0] & 0xf8));
606 ND_PRINT((ndo
, ")"));
609 return hdrlen
+ 2 + len
;
618 pimv2_print(netdissect_options
*ndo
,
619 register const u_char
*bp
, register u_int len
, u_int cksum
)
621 register const u_char
*ep
;
622 register struct pim
*pim
= (struct pim
*)bp
;
625 ep
= (const u_char
*)ndo
->ndo_snapend
;
630 ND_TCHECK(pim
->pim_rsv
);
631 pimv2_addr_len
= pim
->pim_rsv
;
632 if (pimv2_addr_len
!= 0)
633 ND_PRINT((ndo
, ", RFC2117-encoding"));
635 ND_PRINT((ndo
, ", cksum 0x%04x ", EXTRACT_16BITS(&pim
->pim_cksum
)));
636 if (EXTRACT_16BITS(&pim
->pim_cksum
) == 0) {
637 ND_PRINT((ndo
, "(unverified)"));
639 ND_PRINT((ndo
, "(%scorrect)", ND_TTEST2(bp
[0], len
) && cksum
? "in" : "" ));
642 switch (PIM_TYPE(pim
->pim_typever
)) {
643 case PIMV2_TYPE_HELLO
:
645 u_int16_t otype
, olen
;
648 ND_TCHECK2(bp
[0], 4);
649 otype
= EXTRACT_16BITS(&bp
[0]);
650 olen
= EXTRACT_16BITS(&bp
[2]);
651 ND_TCHECK2(bp
[0], 4 + olen
);
652 ND_PRINT((ndo
, "\n\t %s Option (%u), length %u, Value: ",
653 tok2str(pimv2_hello_option_values
, "Unknown", otype
),
659 case PIMV2_HELLO_OPTION_HOLDTIME
:
660 relts_print(EXTRACT_16BITS(bp
));
663 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
665 ND_PRINT((ndo
, "ERROR: Option Length != 4 Bytes (%u)", olen
));
668 u_int16_t lan_delay
, override_interval
;
669 lan_delay
= EXTRACT_16BITS(bp
);
670 override_interval
= EXTRACT_16BITS(bp
+2);
671 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
672 lan_delay
&= ~0x8000;
673 ND_PRINT((ndo
, "\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
674 t_bit
, lan_delay
, override_interval
));
678 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
679 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
682 ND_PRINT((ndo
, "Bi-Directional Capability (Old)"));
685 ND_PRINT((ndo
, "%u", EXTRACT_32BITS(bp
)));
688 ND_PRINT((ndo
, "ERROR: Option Length != 4 Bytes (%u)", olen
));
693 case PIMV2_HELLO_OPTION_GENID
:
694 ND_PRINT((ndo
, "0x%08x", EXTRACT_32BITS(bp
)));
697 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
698 ND_PRINT((ndo
, "v%d", *bp
));
700 ND_PRINT((ndo
, ", interval "));
701 relts_print(*(bp
+1));
703 if (EXTRACT_16BITS(bp
+2) != 0) {
704 ND_PRINT((ndo
, " ?0x%04x?", EXTRACT_16BITS(bp
+2)));
708 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
711 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
712 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
713 if (ndo
->ndo_vflag
> 1) {
714 const u_char
*ptr
= bp
;
715 while (ptr
< (bp
+olen
)) {
718 ND_PRINT((ndo
, "\n\t "));
719 advance
= pimv2_addr_print(ndo
, ptr
, pimv2_unicast
, 0);
721 ND_PRINT((ndo
, "..."));
729 if (ndo
->ndo_vflag
<= 1)
730 print_unknown_data(ndo
, bp
, "\n\t ", olen
);
733 /* do we want to see an additionally hexdump ? */
734 if (ndo
->ndo_vflag
> 1)
735 print_unknown_data(ndo
, bp
, "\n\t ", olen
);
741 case PIMV2_TYPE_REGISTER
:
745 if (!ND_TTEST2(*(bp
+4), PIMV2_REGISTER_FLAG_LEN
))
748 ND_PRINT((ndo
, ", Flags [ %s ]\n\t",
749 tok2str(pimv2_register_flag_values
,
751 EXTRACT_32BITS(bp
+4))));
754 /* encapsulated multicast packet */
755 ip
= (struct ip
*)bp
;
757 case 0: /* Null header */
758 ND_PRINT((ndo
, "IP-Null-header %s > %s",
759 ipaddr_string(&ip
->ip_src
),
760 ipaddr_string(&ip
->ip_dst
)));
764 ip_print(ndo
, bp
, len
);
768 ip6_print(ndo
, bp
, len
);
772 ND_PRINT((ndo
, "IP ver %d", IP_V(ip
)));
778 case PIMV2_TYPE_REGISTER_STOP
:
782 ND_PRINT((ndo
, " group="));
783 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
784 ND_PRINT((ndo
, "..."));
787 bp
+= advance
; len
-= advance
;
790 ND_PRINT((ndo
, " source="));
791 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
792 ND_PRINT((ndo
, "..."));
795 bp
+= advance
; len
-= advance
;
798 case PIMV2_TYPE_JOIN_PRUNE
:
799 case PIMV2_TYPE_GRAFT
:
800 case PIMV2_TYPE_GRAFT_ACK
:
805 * 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
806 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
807 * |PIM Ver| Type | Addr length | Checksum |
808 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
809 * | Unicast-Upstream Neighbor Address |
810 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
811 * | Reserved | Num groups | Holdtime |
812 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
813 * | Encoded-Multicast Group Address-1 |
814 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
815 * | Number of Joined Sources | Number of Pruned Sources |
816 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
817 * | Encoded-Joined Source Address-1 |
818 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
821 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
822 * | Encoded-Joined Source Address-n |
823 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
824 * | Encoded-Pruned Source Address-1 |
825 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
828 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
829 * | Encoded-Pruned Source Address-n |
830 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
833 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
834 * | Encoded-Multicast Group Address-n |
835 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
846 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
849 ND_PRINT((ndo
, ", upstream-neighbor: "));
850 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
851 ND_PRINT((ndo
, "..."));
854 bp
+= advance
; len
-= advance
;
859 holdtime
= EXTRACT_16BITS(&bp
[2]);
860 ND_PRINT((ndo
, "\n\t %u group(s)", ngroup
));
861 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
862 ND_PRINT((ndo
, ", holdtime: "));
863 if (holdtime
== 0xffff)
864 ND_PRINT((ndo
, "infinite"));
866 relts_print(holdtime
);
869 for (i
= 0; i
< ngroup
; i
++) {
872 ND_PRINT((ndo
, "\n\t group #%u: ", i
+1));
873 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
874 ND_PRINT((ndo
, "...)"));
877 bp
+= advance
; len
-= advance
;
879 ND_PRINT((ndo
, "...)"));
882 njoin
= EXTRACT_16BITS(&bp
[0]);
883 nprune
= EXTRACT_16BITS(&bp
[2]);
884 ND_PRINT((ndo
, ", joined sources: %u, pruned sources: %u", njoin
, nprune
));
886 for (j
= 0; j
< njoin
; j
++) {
887 ND_PRINT((ndo
, "\n\t joined source #%u: ", j
+1));
888 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_source
, 0)) < 0) {
889 ND_PRINT((ndo
, "...)"));
892 bp
+= advance
; len
-= advance
;
894 for (j
= 0; j
< nprune
; j
++) {
895 ND_PRINT((ndo
, "\n\t pruned source #%u: ", j
+1));
896 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_source
, 0)) < 0) {
897 ND_PRINT((ndo
, "...)"));
900 bp
+= advance
; len
-= advance
;
907 case PIMV2_TYPE_BOOTSTRAP
:
912 /* Fragment Tag, Hash Mask len, and BSR-priority */
913 if (bp
+ sizeof(u_int16_t
) >= ep
) break;
914 ND_PRINT((ndo
, " tag=%x", EXTRACT_16BITS(bp
)));
915 bp
+= sizeof(u_int16_t
);
917 ND_PRINT((ndo
, " hashmlen=%d", bp
[0]));
918 if (bp
+ 1 >= ep
) break;
919 ND_PRINT((ndo
, " BSRprio=%d", bp
[1]));
922 /* Encoded-Unicast-BSR-Address */
924 ND_PRINT((ndo
, " BSR="));
925 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
926 ND_PRINT((ndo
, "..."));
931 for (i
= 0; bp
< ep
; i
++) {
932 /* Encoded-Group Address */
933 ND_PRINT((ndo
, " (group%d: ", i
));
934 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0))
936 ND_PRINT((ndo
, "...)"));
941 /* RP-Count, Frag RP-Cnt, and rsvd */
943 ND_PRINT((ndo
, "...)"));
946 ND_PRINT((ndo
, " RPcnt=%d", bp
[0]));
948 ND_PRINT((ndo
, "...)"));
951 ND_PRINT((ndo
, " FRPcnt=%d", frpcnt
= bp
[1]));
954 for (j
= 0; j
< frpcnt
&& bp
< ep
; j
++) {
956 ND_PRINT((ndo
, " RP%d=", j
));
957 if ((advance
= pimv2_addr_print(ndo
, bp
,
960 ND_PRINT((ndo
, "...)"));
966 ND_PRINT((ndo
, "...)"));
969 ND_PRINT((ndo
, ",holdtime="));
970 relts_print(EXTRACT_16BITS(bp
));
972 ND_PRINT((ndo
, "...)"));
975 ND_PRINT((ndo
, ",prio=%d", bp
[2]));
978 ND_PRINT((ndo
, ")"));
983 case PIMV2_TYPE_ASSERT
:
987 ND_PRINT((ndo
, " group="));
988 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
989 ND_PRINT((ndo
, "..."));
992 bp
+= advance
; len
-= advance
;
995 ND_PRINT((ndo
, " src="));
996 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
997 ND_PRINT((ndo
, "..."));
1000 bp
+= advance
; len
-= advance
;
1004 ND_PRINT((ndo
, " RPT"));
1005 ND_PRINT((ndo
, " pref=%u", EXTRACT_32BITS(&bp
[0]) & 0x7fffffff));
1006 ND_PRINT((ndo
, " metric=%u", EXTRACT_32BITS(&bp
[4])));
1009 case PIMV2_TYPE_CANDIDATE_RP
:
1014 /* Prefix-Cnt, Priority, and Holdtime */
1015 if (bp
>= ep
) break;
1016 ND_PRINT((ndo
, " prefix-cnt=%d", bp
[0]));
1018 if (bp
+ 1 >= ep
) break;
1019 ND_PRINT((ndo
, " prio=%d", bp
[1]));
1020 if (bp
+ 3 >= ep
) break;
1021 ND_PRINT((ndo
, " holdtime="));
1022 relts_print(EXTRACT_16BITS(&bp
[2]));
1025 /* Encoded-Unicast-RP-Address */
1026 if (bp
>= ep
) break;
1027 ND_PRINT((ndo
, " RP="));
1028 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1029 ND_PRINT((ndo
, "..."));
1034 /* Encoded-Group Addresses */
1035 for (i
= 0; i
< pfxcnt
&& bp
< ep
; i
++) {
1036 ND_PRINT((ndo
, " Group%d=", i
));
1037 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0))
1039 ND_PRINT((ndo
, "..."));
1047 case PIMV2_TYPE_PRUNE_REFRESH
:
1048 ND_PRINT((ndo
, " src="));
1049 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1050 ND_PRINT((ndo
, "..."));
1054 ND_PRINT((ndo
, " grp="));
1055 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
1056 ND_PRINT((ndo
, "..."));
1060 ND_PRINT((ndo
, " forwarder="));
1061 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1062 ND_PRINT((ndo
, "..."));
1066 ND_TCHECK2(bp
[0], 2);
1067 ND_PRINT((ndo
, " TUNR "));
1068 relts_print(EXTRACT_16BITS(bp
));
1073 ND_PRINT((ndo
, " [type %d]", PIM_TYPE(pim
->pim_typever
)));
1080 ND_PRINT((ndo
, "[|pim]"));
1085 * c-style: whitesmith