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>
28 #include "interface.h"
29 #include "addrtoname.h"
34 #define PIMV1_TYPE_QUERY 0
35 #define PIMV1_TYPE_REGISTER 1
36 #define PIMV1_TYPE_REGISTER_STOP 2
37 #define PIMV1_TYPE_JOIN_PRUNE 3
38 #define PIMV1_TYPE_RP_REACHABILITY 4
39 #define PIMV1_TYPE_ASSERT 5
40 #define PIMV1_TYPE_GRAFT 6
41 #define PIMV1_TYPE_GRAFT_ACK 7
43 static const struct tok pimv1_type_str
[] = {
44 { PIMV1_TYPE_QUERY
, "Query" },
45 { PIMV1_TYPE_REGISTER
, "Register" },
46 { PIMV1_TYPE_REGISTER_STOP
, "Register-Stop" },
47 { PIMV1_TYPE_JOIN_PRUNE
, "Join/Prune" },
48 { PIMV1_TYPE_RP_REACHABILITY
, "RP-reachable" },
49 { PIMV1_TYPE_ASSERT
, "Assert" },
50 { PIMV1_TYPE_GRAFT
, "Graft" },
51 { PIMV1_TYPE_GRAFT_ACK
, "Graft-ACK" },
55 #define PIMV2_TYPE_HELLO 0
56 #define PIMV2_TYPE_REGISTER 1
57 #define PIMV2_TYPE_REGISTER_STOP 2
58 #define PIMV2_TYPE_JOIN_PRUNE 3
59 #define PIMV2_TYPE_BOOTSTRAP 4
60 #define PIMV2_TYPE_ASSERT 5
61 #define PIMV2_TYPE_GRAFT 6
62 #define PIMV2_TYPE_GRAFT_ACK 7
63 #define PIMV2_TYPE_CANDIDATE_RP 8
64 #define PIMV2_TYPE_PRUNE_REFRESH 9
65 #define PIMV2_TYPE_DF_ELECTION 10
66 #define PIMV2_TYPE_ECMP_REDIRECT 11
68 static const struct tok pimv2_type_values
[] = {
69 { PIMV2_TYPE_HELLO
, "Hello" },
70 { PIMV2_TYPE_REGISTER
, "Register" },
71 { PIMV2_TYPE_REGISTER_STOP
, "Register Stop" },
72 { PIMV2_TYPE_JOIN_PRUNE
, "Join / Prune" },
73 { PIMV2_TYPE_BOOTSTRAP
, "Bootstrap" },
74 { PIMV2_TYPE_ASSERT
, "Assert" },
75 { PIMV2_TYPE_GRAFT
, "Graft" },
76 { PIMV2_TYPE_GRAFT_ACK
, "Graft Acknowledgement" },
77 { PIMV2_TYPE_CANDIDATE_RP
, "Candidate RP Advertisement" },
78 { PIMV2_TYPE_PRUNE_REFRESH
, "Prune Refresh" },
79 { PIMV2_TYPE_DF_ELECTION
, "DF Election" },
80 { PIMV2_TYPE_ECMP_REDIRECT
, "ECMP Redirect" },
84 #define PIMV2_HELLO_OPTION_HOLDTIME 1
85 #define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
86 #define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
87 #define PIMV2_HELLO_OPTION_DR_PRIORITY 19
88 #define PIMV2_HELLO_OPTION_GENID 20
89 #define PIMV2_HELLO_OPTION_REFRESH_CAP 21
90 #define PIMV2_HELLO_OPTION_BIDIR_CAP 22
91 #define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
92 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
94 static const struct tok pimv2_hello_option_values
[] = {
95 { PIMV2_HELLO_OPTION_HOLDTIME
, "Hold Time" },
96 { PIMV2_HELLO_OPTION_LANPRUNEDELAY
, "LAN Prune Delay" },
97 { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
, "DR Priority (Old)" },
98 { PIMV2_HELLO_OPTION_DR_PRIORITY
, "DR Priority" },
99 { PIMV2_HELLO_OPTION_GENID
, "Generation ID" },
100 { PIMV2_HELLO_OPTION_REFRESH_CAP
, "State Refresh Capability" },
101 { PIMV2_HELLO_OPTION_BIDIR_CAP
, "Bi-Directional Capability" },
102 { PIMV2_HELLO_OPTION_ADDRESS_LIST
, "Address List" },
103 { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
, "Address List (Old)" },
107 #define PIMV2_REGISTER_FLAG_LEN 4
108 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
109 #define PIMV2_REGISTER_FLAG_NULL 0x40000000
111 static const struct tok pimv2_register_flag_values
[] = {
112 { PIMV2_REGISTER_FLAG_BORDER
, "Border" },
113 { PIMV2_REGISTER_FLAG_NULL
, "Null" },
118 * XXX: We consider a case where IPv6 is not ready yet for portability,
119 * but PIM dependent defintions should be independent of IPv6...
124 /* upper 4bit: PIM version number; 2 for PIMv2 */
125 /* lower 4bit: the PIM message type, currently they are:
126 * Hello, Register, Register-Stop, Join/Prune,
127 * Bootstrap, Assert, Graft (PIM-DM only),
128 * Graft-Ack (PIM-DM only), C-RP-Adv
130 #define PIM_VER(x) (((x) & 0xf0) >> 4)
131 #define PIM_TYPE(x) ((x) & 0x0f)
132 u_char pim_rsv
; /* Reserved */
133 u_short pim_cksum
; /* IP style check sum */
136 static void pimv2_print(netdissect_options
*, register const u_char
*bp
, register u_int len
, u_int cksum
);
139 pimv1_join_prune_print(netdissect_options
*ndo
,
140 register const u_char
*bp
, register u_int len
)
142 int ngroups
, njoin
, nprune
;
145 /* If it's a single group and a single source, use 1-line output. */
146 if (ND_TTEST2(bp
[0], 30) && bp
[11] == 1 &&
147 ((njoin
= EXTRACT_16BITS(&bp
[20])) + EXTRACT_16BITS(&bp
[22])) == 1) {
150 ND_PRINT((ndo
, " RPF %s ", ipaddr_string(ndo
, bp
)));
151 hold
= EXTRACT_16BITS(&bp
[6]);
153 ND_PRINT((ndo
, "Hold "));
154 relts_print(ndo
, hold
);
156 ND_PRINT((ndo
, "%s (%s/%d, %s", njoin
? "Join" : "Prune",
157 ipaddr_string(ndo
, &bp
[26]), bp
[25] & 0x3f,
158 ipaddr_string(ndo
, &bp
[12])));
159 if (EXTRACT_32BITS(&bp
[16]) != 0xffffffff)
160 ND_PRINT((ndo
, "/%s", ipaddr_string(ndo
, &bp
[16])));
161 ND_PRINT((ndo
, ") %s%s %s",
162 (bp
[24] & 0x01) ? "Sparse" : "Dense",
163 (bp
[25] & 0x80) ? " WC" : "",
164 (bp
[25] & 0x40) ? "RP" : "SPT"));
168 ND_TCHECK2(bp
[0], sizeof(struct in_addr
));
169 if (ndo
->ndo_vflag
> 1)
170 ND_PRINT((ndo
, "\n"));
171 ND_PRINT((ndo
, " Upstream Nbr: %s", ipaddr_string(ndo
, bp
)));
172 ND_TCHECK2(bp
[6], 2);
173 if (ndo
->ndo_vflag
> 1)
174 ND_PRINT((ndo
, "\n"));
175 ND_PRINT((ndo
, " Hold time: "));
176 relts_print(ndo
, EXTRACT_16BITS(&bp
[6]));
177 if (ndo
->ndo_vflag
< 2)
182 ND_TCHECK2(bp
[0], 4);
188 * XXX - does the address have length "addrlen" and the
189 * mask length "maddrlen"?
191 ND_TCHECK2(bp
[0], sizeof(struct in_addr
));
192 ND_PRINT((ndo
, "\n\tGroup: %s", ipaddr_string(ndo
, bp
)));
193 ND_TCHECK2(bp
[4], sizeof(struct in_addr
));
194 if (EXTRACT_32BITS(&bp
[4]) != 0xffffffff)
195 ND_PRINT((ndo
, "/%s", ipaddr_string(ndo
, &bp
[4])));
196 ND_TCHECK2(bp
[8], 4);
197 njoin
= EXTRACT_16BITS(&bp
[8]);
198 nprune
= EXTRACT_16BITS(&bp
[10]);
199 ND_PRINT((ndo
, " joined: %d pruned: %d", njoin
, nprune
));
202 for (njp
= 0; njp
< (njoin
+ nprune
); njp
++) {
209 ND_TCHECK2(bp
[0], 6);
210 ND_PRINT((ndo
, "\n\t%s %s%s%s%s/%d", type
,
211 (bp
[0] & 0x01) ? "Sparse " : "Dense ",
212 (bp
[1] & 0x80) ? "WC " : "",
213 (bp
[1] & 0x40) ? "RP " : "SPT ",
214 ipaddr_string(ndo
, &bp
[2]), bp
[1] & 0x3f));
221 ND_PRINT((ndo
, "[|pim]"));
226 pimv1_print(netdissect_options
*ndo
,
227 register const u_char
*bp
, register u_int len
)
229 register const u_char
*ep
;
230 register u_char type
;
232 ep
= (const u_char
*)ndo
->ndo_snapend
;
239 ND_PRINT((ndo
, " %s", tok2str(pimv1_type_str
, "[type %u]", type
)));
241 case PIMV1_TYPE_QUERY
:
242 if (ND_TTEST(bp
[8])) {
243 switch (bp
[8] >> 4) {
245 ND_PRINT((ndo
, " Dense-mode"));
248 ND_PRINT((ndo
, " Sparse-mode"));
251 ND_PRINT((ndo
, " Sparse-Dense-mode"));
254 ND_PRINT((ndo
, " mode-%d", bp
[8] >> 4));
258 if (ndo
->ndo_vflag
) {
259 ND_TCHECK2(bp
[10],2);
260 ND_PRINT((ndo
, " (Hold-time "));
261 relts_print(ndo
, EXTRACT_16BITS(&bp
[10]));
262 ND_PRINT((ndo
, ")"));
266 case PIMV1_TYPE_REGISTER
:
267 ND_TCHECK2(bp
[8], 20); /* ip header */
268 ND_PRINT((ndo
, " for %s > %s", ipaddr_string(ndo
, &bp
[20]),
269 ipaddr_string(ndo
, &bp
[24])));
271 case PIMV1_TYPE_REGISTER_STOP
:
272 ND_TCHECK2(bp
[12], sizeof(struct in_addr
));
273 ND_PRINT((ndo
, " for %s > %s", ipaddr_string(ndo
, &bp
[8]),
274 ipaddr_string(ndo
, &bp
[12])));
276 case PIMV1_TYPE_RP_REACHABILITY
:
277 if (ndo
->ndo_vflag
) {
278 ND_TCHECK2(bp
[22], 2);
279 ND_PRINT((ndo
, " group %s", ipaddr_string(ndo
, &bp
[8])));
280 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
281 ND_PRINT((ndo
, "/%s", ipaddr_string(ndo
, &bp
[12])));
282 ND_PRINT((ndo
, " RP %s hold ", ipaddr_string(ndo
, &bp
[16])));
283 relts_print(ndo
, EXTRACT_16BITS(&bp
[22]));
286 case PIMV1_TYPE_ASSERT
:
287 ND_TCHECK2(bp
[16], sizeof(struct in_addr
));
288 ND_PRINT((ndo
, " for %s > %s", ipaddr_string(ndo
, &bp
[16]),
289 ipaddr_string(ndo
, &bp
[8])));
290 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
291 ND_PRINT((ndo
, "/%s", ipaddr_string(ndo
, &bp
[12])));
292 ND_TCHECK2(bp
[24], 4);
293 ND_PRINT((ndo
, " %s pref %d metric %d",
294 (bp
[20] & 0x80) ? "RP-tree" : "SPT",
295 EXTRACT_32BITS(&bp
[20]) & 0x7fffffff,
296 EXTRACT_32BITS(&bp
[24])));
298 case PIMV1_TYPE_JOIN_PRUNE
:
299 case PIMV1_TYPE_GRAFT
:
300 case PIMV1_TYPE_GRAFT_ACK
:
302 pimv1_join_prune_print(ndo
, &bp
[8], len
- 8);
305 if ((bp
[4] >> 4) != 1)
306 ND_PRINT((ndo
, " [v%d]", bp
[4] >> 4));
310 ND_PRINT((ndo
, "[|pim]"));
315 * auto-RP is a cisco protocol, documented at
316 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
318 * This implements version 1+, dated Sept 9, 1998.
321 cisco_autorp_print(netdissect_options
*ndo
,
322 register const u_char
*bp
, register u_int len
)
329 ND_PRINT((ndo
, " auto-rp "));
333 ND_PRINT((ndo
, "candidate-advert"));
336 ND_PRINT((ndo
, "mapping"));
339 ND_PRINT((ndo
, "type-0x%02x", type
));
346 ND_TCHECK2(bp
[2], 2);
347 ND_PRINT((ndo
, " Hold "));
348 hold
= EXTRACT_16BITS(&bp
[2]);
350 relts_print(ndo
, EXTRACT_16BITS(&bp
[2]));
352 ND_PRINT((ndo
, "FOREVER"));
354 /* Next 4 bytes are reserved. */
358 /*XXX skip unless -v? */
362 * numrps entries of the form:
365 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
366 * 8 bits: # of entries for this RP
367 * each entry: 7 bits: reserved, 1 bit: negative,
368 * 8 bits: mask 32 bits: source
369 * lather, rinse, repeat.
375 ND_TCHECK2(bp
[0], 4);
376 ND_PRINT((ndo
, " RP %s", ipaddr_string(ndo
, bp
)));
378 switch (bp
[4] & 0x3) {
379 case 0: ND_PRINT((ndo
, " PIMv?"));
381 case 1: ND_PRINT((ndo
, " PIMv1"));
383 case 2: ND_PRINT((ndo
, " PIMv2"));
385 case 3: ND_PRINT((ndo
, " PIMv1+2"));
389 ND_PRINT((ndo
, " [rsvd=0x%02x]", bp
[4] & 0xfc));
394 for (; nentries
; nentries
--) {
395 ND_TCHECK2(bp
[0], 6);
396 ND_PRINT((ndo
, "%c%s%s/%d", s
, bp
[0] & 1 ? "!" : "",
397 ipaddr_string(ndo
, &bp
[2]), bp
[1]));
399 ND_PRINT((ndo
, " bidir"));
402 ND_PRINT((ndo
, "[rsvd=0x%02x]", bp
[0] & 0xfc));
411 ND_PRINT((ndo
, "[|autorp]"));
416 pim_print(netdissect_options
*ndo
,
417 register const u_char
*bp
, register u_int len
, u_int cksum
)
419 register const u_char
*ep
;
420 register const struct pim
*pim
= (const struct pim
*)bp
;
422 ep
= (const u_char
*)ndo
->ndo_snapend
;
425 #ifdef notyet /* currently we see only version and type */
426 ND_TCHECK(pim
->pim_rsv
);
429 switch (PIM_VER(pim
->pim_typever
)) {
431 if (!ndo
->ndo_vflag
) {
432 ND_PRINT((ndo
, "PIMv%u, %s, length %u",
433 PIM_VER(pim
->pim_typever
),
434 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
438 ND_PRINT((ndo
, "PIMv%u, length %u\n\t%s",
439 PIM_VER(pim
->pim_typever
),
441 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
))));
442 pimv2_print(ndo
, bp
, len
, cksum
);
446 ND_PRINT((ndo
, "PIMv%u, length %u",
447 PIM_VER(pim
->pim_typever
),
455 * PIMv2 uses encoded address representations.
457 * The last PIM-SM I-D before RFC2117 was published specified the
458 * following representation for unicast addresses. However, RFC2117
459 * specified no encoding for unicast addresses with the unicast
460 * address length specified in the header. Therefore, we have to
461 * guess which encoding is being used (Cisco's PIMv2 implementation
462 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
463 * field into a 'unicast-address-length-in-bytes' field. We guess
464 * that it's the draft encoding if this reserved field is zero.
466 * RFC2362 goes back to the encoded format, and calls the addr length
467 * field "reserved" again.
469 * The first byte is the address family, from:
472 * 1 IP (IP version 4)
473 * 2 IP6 (IP version 6)
475 * 4 HDLC (8-bit multidrop)
477 * 6 802 (includes all 802 media plus Ethernet "canonical format")
479 * 8 E.164 (SMDS, Frame Relay, ATM)
481 * 10 X.121 (X.25, Frame Relay)
486 * 15 E.164 with NSAP format subaddress
488 * In addition, the second byte is an "Encoding". 0 is the default
489 * encoding for the address family, and no other encodings are currently
494 static int pimv2_addr_len
;
496 enum pimv2_addrtype
{
497 pimv2_unicast
, pimv2_group
, pimv2_source
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 | Unicast Address |
504 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
506 * 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
507 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
508 * | Addr Family | Encoding Type | Reserved | Mask Len |
509 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
510 * | Group multicast Address |
511 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
513 * 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
514 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
515 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
516 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
518 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
521 pimv2_addr_print(netdissect_options
*ndo
,
522 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
;
569 ND_TCHECK2(bp
[0], len
);
572 ND_PRINT((ndo
, "%s", ipaddr_string(ndo
, bp
)));
575 else if (af
== AF_INET6
) {
577 ND_PRINT((ndo
, "%s", ip6addr_string(ndo
, bp
)));
583 ND_TCHECK2(bp
[0], len
+ 2);
586 ND_PRINT((ndo
, "%s", ipaddr_string(ndo
, bp
+ 2)));
588 ND_PRINT((ndo
, "/%u", bp
[1]));
592 else if (af
== AF_INET6
) {
594 ND_PRINT((ndo
, "%s", ip6addr_string(ndo
, bp
+ 2)));
596 ND_PRINT((ndo
, "/%u", bp
[1]));
600 if (bp
[0] && !silent
) {
601 if (at
== pimv2_group
) {
602 ND_PRINT((ndo
, "(0x%02x)", bp
[0]));
604 ND_PRINT((ndo
, "(%s%s%s",
605 bp
[0] & 0x04 ? "S" : "",
606 bp
[0] & 0x02 ? "W" : "",
607 bp
[0] & 0x01 ? "R" : ""));
609 ND_PRINT((ndo
, "+0x%02x", bp
[0] & 0xf8));
611 ND_PRINT((ndo
, ")"));
614 return hdrlen
+ 2 + len
;
623 pimv2_print(netdissect_options
*ndo
,
624 register const u_char
*bp
, register u_int len
, u_int cksum
)
626 register const u_char
*ep
;
627 register const struct pim
*pim
= (const struct pim
*)bp
;
630 ep
= (const u_char
*)ndo
->ndo_snapend
;
635 ND_TCHECK(pim
->pim_rsv
);
636 pimv2_addr_len
= pim
->pim_rsv
;
637 if (pimv2_addr_len
!= 0)
638 ND_PRINT((ndo
, ", RFC2117-encoding"));
640 ND_PRINT((ndo
, ", cksum 0x%04x ", EXTRACT_16BITS(&pim
->pim_cksum
)));
641 if (EXTRACT_16BITS(&pim
->pim_cksum
) == 0) {
642 ND_PRINT((ndo
, "(unverified)"));
644 ND_PRINT((ndo
, "(%scorrect)", ND_TTEST2(bp
[0], len
) && cksum
? "in" : "" ));
647 switch (PIM_TYPE(pim
->pim_typever
)) {
648 case PIMV2_TYPE_HELLO
:
650 uint16_t otype
, olen
;
653 ND_TCHECK2(bp
[0], 4);
654 otype
= EXTRACT_16BITS(&bp
[0]);
655 olen
= EXTRACT_16BITS(&bp
[2]);
656 ND_TCHECK2(bp
[0], 4 + olen
);
657 ND_PRINT((ndo
, "\n\t %s Option (%u), length %u, Value: ",
658 tok2str(pimv2_hello_option_values
, "Unknown", otype
),
664 case PIMV2_HELLO_OPTION_HOLDTIME
:
665 relts_print(ndo
, EXTRACT_16BITS(bp
));
668 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
670 ND_PRINT((ndo
, "ERROR: Option Length != 4 Bytes (%u)", olen
));
673 uint16_t lan_delay
, override_interval
;
674 lan_delay
= EXTRACT_16BITS(bp
);
675 override_interval
= EXTRACT_16BITS(bp
+2);
676 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
677 lan_delay
&= ~0x8000;
678 ND_PRINT((ndo
, "\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
679 t_bit
, lan_delay
, override_interval
));
683 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
684 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
687 ND_PRINT((ndo
, "Bi-Directional Capability (Old)"));
690 ND_PRINT((ndo
, "%u", EXTRACT_32BITS(bp
)));
693 ND_PRINT((ndo
, "ERROR: Option Length != 4 Bytes (%u)", olen
));
698 case PIMV2_HELLO_OPTION_GENID
:
699 ND_PRINT((ndo
, "0x%08x", EXTRACT_32BITS(bp
)));
702 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
703 ND_PRINT((ndo
, "v%d", *bp
));
705 ND_PRINT((ndo
, ", interval "));
706 relts_print(ndo
, *(bp
+1));
708 if (EXTRACT_16BITS(bp
+2) != 0) {
709 ND_PRINT((ndo
, " ?0x%04x?", EXTRACT_16BITS(bp
+2)));
713 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
716 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
717 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
718 if (ndo
->ndo_vflag
> 1) {
719 const u_char
*ptr
= bp
;
720 while (ptr
< (bp
+olen
)) {
723 ND_PRINT((ndo
, "\n\t "));
724 advance
= pimv2_addr_print(ndo
, ptr
, pimv2_unicast
, 0);
726 ND_PRINT((ndo
, "..."));
734 if (ndo
->ndo_vflag
<= 1)
735 print_unknown_data(ndo
, bp
, "\n\t ", olen
);
738 /* do we want to see an additionally hexdump ? */
739 if (ndo
->ndo_vflag
> 1)
740 print_unknown_data(ndo
, bp
, "\n\t ", olen
);
746 case PIMV2_TYPE_REGISTER
:
750 ND_TCHECK2(*(bp
+ 4), PIMV2_REGISTER_FLAG_LEN
);
752 ND_PRINT((ndo
, ", Flags [ %s ]\n\t",
753 tok2str(pimv2_register_flag_values
,
755 EXTRACT_32BITS(bp
+4))));
758 /* encapsulated multicast packet */
759 ip
= (const struct ip
*)bp
;
761 case 0: /* Null header */
762 ND_PRINT((ndo
, "IP-Null-header %s > %s",
763 ipaddr_string(ndo
, &ip
->ip_src
),
764 ipaddr_string(ndo
, &ip
->ip_dst
)));
768 ip_print(ndo
, bp
, len
);
772 ip6_print(ndo
, bp
, len
);
776 ND_PRINT((ndo
, "IP ver %d", IP_V(ip
)));
782 case PIMV2_TYPE_REGISTER_STOP
:
786 ND_PRINT((ndo
, " group="));
787 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
788 ND_PRINT((ndo
, "..."));
791 bp
+= advance
; len
-= advance
;
794 ND_PRINT((ndo
, " source="));
795 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
796 ND_PRINT((ndo
, "..."));
799 bp
+= advance
; len
-= advance
;
802 case PIMV2_TYPE_JOIN_PRUNE
:
803 case PIMV2_TYPE_GRAFT
:
804 case PIMV2_TYPE_GRAFT_ACK
:
809 * 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
810 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
811 * |PIM Ver| Type | Addr length | Checksum |
812 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
813 * | Unicast-Upstream Neighbor Address |
814 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
815 * | Reserved | Num groups | Holdtime |
816 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
817 * | Encoded-Multicast Group Address-1 |
818 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
819 * | Number of Joined Sources | Number of Pruned Sources |
820 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
821 * | Encoded-Joined Source Address-1 |
822 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
825 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
826 * | Encoded-Joined Source Address-n |
827 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
828 * | Encoded-Pruned Source Address-1 |
829 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
832 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
833 * | Encoded-Pruned Source Address-n |
834 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
837 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
838 * | Encoded-Multicast Group Address-n |
839 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
850 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
853 ND_PRINT((ndo
, ", upstream-neighbor: "));
854 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
855 ND_PRINT((ndo
, "..."));
858 bp
+= advance
; len
-= advance
;
863 holdtime
= EXTRACT_16BITS(&bp
[2]);
864 ND_PRINT((ndo
, "\n\t %u group(s)", ngroup
));
865 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
866 ND_PRINT((ndo
, ", holdtime: "));
867 if (holdtime
== 0xffff)
868 ND_PRINT((ndo
, "infinite"));
870 relts_print(ndo
, holdtime
);
873 for (i
= 0; i
< ngroup
; i
++) {
876 ND_PRINT((ndo
, "\n\t group #%u: ", i
+1));
877 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
878 ND_PRINT((ndo
, "...)"));
881 bp
+= advance
; len
-= advance
;
883 ND_PRINT((ndo
, "...)"));
886 njoin
= EXTRACT_16BITS(&bp
[0]);
887 nprune
= EXTRACT_16BITS(&bp
[2]);
888 ND_PRINT((ndo
, ", joined sources: %u, pruned sources: %u", njoin
, nprune
));
890 for (j
= 0; j
< njoin
; j
++) {
891 ND_PRINT((ndo
, "\n\t joined source #%u: ", j
+1));
892 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_source
, 0)) < 0) {
893 ND_PRINT((ndo
, "...)"));
896 bp
+= advance
; len
-= advance
;
898 for (j
= 0; j
< nprune
; j
++) {
899 ND_PRINT((ndo
, "\n\t pruned source #%u: ", j
+1));
900 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_source
, 0)) < 0) {
901 ND_PRINT((ndo
, "...)"));
904 bp
+= advance
; len
-= advance
;
911 case PIMV2_TYPE_BOOTSTRAP
:
916 /* Fragment Tag, Hash Mask len, and BSR-priority */
917 if (bp
+ sizeof(uint16_t) >= ep
) break;
918 ND_PRINT((ndo
, " tag=%x", EXTRACT_16BITS(bp
)));
919 bp
+= sizeof(uint16_t);
921 ND_PRINT((ndo
, " hashmlen=%d", bp
[0]));
922 if (bp
+ 1 >= ep
) break;
923 ND_PRINT((ndo
, " BSRprio=%d", bp
[1]));
926 /* Encoded-Unicast-BSR-Address */
928 ND_PRINT((ndo
, " BSR="));
929 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
930 ND_PRINT((ndo
, "..."));
935 for (i
= 0; bp
< ep
; i
++) {
936 /* Encoded-Group Address */
937 ND_PRINT((ndo
, " (group%d: ", i
));
938 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0))
940 ND_PRINT((ndo
, "...)"));
945 /* RP-Count, Frag RP-Cnt, and rsvd */
947 ND_PRINT((ndo
, "...)"));
950 ND_PRINT((ndo
, " RPcnt=%d", bp
[0]));
952 ND_PRINT((ndo
, "...)"));
955 ND_PRINT((ndo
, " FRPcnt=%d", frpcnt
= bp
[1]));
958 for (j
= 0; j
< frpcnt
&& bp
< ep
; j
++) {
960 ND_PRINT((ndo
, " RP%d=", j
));
961 if ((advance
= pimv2_addr_print(ndo
, bp
,
964 ND_PRINT((ndo
, "...)"));
970 ND_PRINT((ndo
, "...)"));
973 ND_PRINT((ndo
, ",holdtime="));
974 relts_print(ndo
, EXTRACT_16BITS(bp
));
976 ND_PRINT((ndo
, "...)"));
979 ND_PRINT((ndo
, ",prio=%d", bp
[2]));
982 ND_PRINT((ndo
, ")"));
987 case PIMV2_TYPE_ASSERT
:
991 ND_PRINT((ndo
, " group="));
992 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
993 ND_PRINT((ndo
, "..."));
996 bp
+= advance
; len
-= advance
;
999 ND_PRINT((ndo
, " src="));
1000 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1001 ND_PRINT((ndo
, "..."));
1004 bp
+= advance
; len
-= advance
;
1008 ND_PRINT((ndo
, " RPT"));
1009 ND_PRINT((ndo
, " pref=%u", EXTRACT_32BITS(&bp
[0]) & 0x7fffffff));
1010 ND_PRINT((ndo
, " metric=%u", EXTRACT_32BITS(&bp
[4])));
1013 case PIMV2_TYPE_CANDIDATE_RP
:
1018 /* Prefix-Cnt, Priority, and Holdtime */
1019 if (bp
>= ep
) break;
1020 ND_PRINT((ndo
, " prefix-cnt=%d", bp
[0]));
1022 if (bp
+ 1 >= ep
) break;
1023 ND_PRINT((ndo
, " prio=%d", bp
[1]));
1024 if (bp
+ 3 >= ep
) break;
1025 ND_PRINT((ndo
, " holdtime="));
1026 relts_print(ndo
, EXTRACT_16BITS(&bp
[2]));
1029 /* Encoded-Unicast-RP-Address */
1030 if (bp
>= ep
) break;
1031 ND_PRINT((ndo
, " RP="));
1032 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1033 ND_PRINT((ndo
, "..."));
1038 /* Encoded-Group Addresses */
1039 for (i
= 0; i
< pfxcnt
&& bp
< ep
; i
++) {
1040 ND_PRINT((ndo
, " Group%d=", i
));
1041 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0))
1043 ND_PRINT((ndo
, "..."));
1051 case PIMV2_TYPE_PRUNE_REFRESH
:
1052 ND_PRINT((ndo
, " src="));
1053 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1054 ND_PRINT((ndo
, "..."));
1058 ND_PRINT((ndo
, " grp="));
1059 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
1060 ND_PRINT((ndo
, "..."));
1064 ND_PRINT((ndo
, " forwarder="));
1065 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1066 ND_PRINT((ndo
, "..."));
1070 ND_TCHECK2(bp
[0], 2);
1071 ND_PRINT((ndo
, " TUNR "));
1072 relts_print(ndo
, EXTRACT_16BITS(bp
));
1077 ND_PRINT((ndo
, " [type %d]", PIM_TYPE(pim
->pim_typever
)));
1084 ND_PRINT((ndo
, "[|pim]"));
1089 * c-style: whitesmith