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 PIMV1_TYPE_QUERY 0
36 #define PIMV1_TYPE_REGISTER 1
37 #define PIMV1_TYPE_REGISTER_STOP 2
38 #define PIMV1_TYPE_JOIN_PRUNE 3
39 #define PIMV1_TYPE_RP_REACHABILITY 4
40 #define PIMV1_TYPE_ASSERT 5
41 #define PIMV1_TYPE_GRAFT 6
42 #define PIMV1_TYPE_GRAFT_ACK 7
44 static const struct tok pimv1_type_str
[] = {
45 { PIMV1_TYPE_QUERY
, "Query" },
46 { PIMV1_TYPE_REGISTER
, "Register" },
47 { PIMV1_TYPE_REGISTER_STOP
, "Register-Stop" },
48 { PIMV1_TYPE_JOIN_PRUNE
, "Join/Prune" },
49 { PIMV1_TYPE_RP_REACHABILITY
, "RP-reachable" },
50 { PIMV1_TYPE_ASSERT
, "Assert" },
51 { PIMV1_TYPE_GRAFT
, "Graft" },
52 { PIMV1_TYPE_GRAFT_ACK
, "Graft-ACK" },
56 #define PIMV2_TYPE_HELLO 0
57 #define PIMV2_TYPE_REGISTER 1
58 #define PIMV2_TYPE_REGISTER_STOP 2
59 #define PIMV2_TYPE_JOIN_PRUNE 3
60 #define PIMV2_TYPE_BOOTSTRAP 4
61 #define PIMV2_TYPE_ASSERT 5
62 #define PIMV2_TYPE_GRAFT 6
63 #define PIMV2_TYPE_GRAFT_ACK 7
64 #define PIMV2_TYPE_CANDIDATE_RP 8
65 #define PIMV2_TYPE_PRUNE_REFRESH 9
66 #define PIMV2_TYPE_DF_ELECTION 10
67 #define PIMV2_TYPE_ECMP_REDIRECT 11
69 static const struct tok pimv2_type_values
[] = {
70 { PIMV2_TYPE_HELLO
, "Hello" },
71 { PIMV2_TYPE_REGISTER
, "Register" },
72 { PIMV2_TYPE_REGISTER_STOP
, "Register Stop" },
73 { PIMV2_TYPE_JOIN_PRUNE
, "Join / Prune" },
74 { PIMV2_TYPE_BOOTSTRAP
, "Bootstrap" },
75 { PIMV2_TYPE_ASSERT
, "Assert" },
76 { PIMV2_TYPE_GRAFT
, "Graft" },
77 { PIMV2_TYPE_GRAFT_ACK
, "Graft Acknowledgement" },
78 { PIMV2_TYPE_CANDIDATE_RP
, "Candidate RP Advertisement" },
79 { PIMV2_TYPE_PRUNE_REFRESH
, "Prune Refresh" },
80 { PIMV2_TYPE_DF_ELECTION
, "DF Election" },
81 { PIMV2_TYPE_ECMP_REDIRECT
, "ECMP Redirect" },
85 #define PIMV2_HELLO_OPTION_HOLDTIME 1
86 #define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
87 #define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
88 #define PIMV2_HELLO_OPTION_DR_PRIORITY 19
89 #define PIMV2_HELLO_OPTION_GENID 20
90 #define PIMV2_HELLO_OPTION_REFRESH_CAP 21
91 #define PIMV2_HELLO_OPTION_BIDIR_CAP 22
92 #define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
93 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
95 static const struct tok pimv2_hello_option_values
[] = {
96 { PIMV2_HELLO_OPTION_HOLDTIME
, "Hold Time" },
97 { PIMV2_HELLO_OPTION_LANPRUNEDELAY
, "LAN Prune Delay" },
98 { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
, "DR Priority (Old)" },
99 { PIMV2_HELLO_OPTION_DR_PRIORITY
, "DR Priority" },
100 { PIMV2_HELLO_OPTION_GENID
, "Generation ID" },
101 { PIMV2_HELLO_OPTION_REFRESH_CAP
, "State Refresh Capability" },
102 { PIMV2_HELLO_OPTION_BIDIR_CAP
, "Bi-Directional Capability" },
103 { PIMV2_HELLO_OPTION_ADDRESS_LIST
, "Address List" },
104 { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
, "Address List (Old)" },
108 #define PIMV2_REGISTER_FLAG_LEN 4
109 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
110 #define PIMV2_REGISTER_FLAG_NULL 0x40000000
112 static const struct tok pimv2_register_flag_values
[] = {
113 { PIMV2_REGISTER_FLAG_BORDER
, "Border" },
114 { PIMV2_REGISTER_FLAG_NULL
, "Null" },
119 * XXX: We consider a case where IPv6 is not ready yet for portability,
120 * but PIM dependent defintions should be independent of IPv6...
125 /* upper 4bit: PIM version number; 2 for PIMv2 */
126 /* lower 4bit: the PIM message type, currently they are:
127 * Hello, Register, Register-Stop, Join/Prune,
128 * Bootstrap, Assert, Graft (PIM-DM only),
129 * Graft-Ack (PIM-DM only), C-RP-Adv
131 #define PIM_VER(x) (((x) & 0xf0) >> 4)
132 #define PIM_TYPE(x) ((x) & 0x0f)
133 u_char pim_rsv
; /* Reserved */
134 u_short pim_cksum
; /* IP style check sum */
137 static void pimv2_print(netdissect_options
*, register const u_char
*bp
, register u_int len
, u_int cksum
);
140 pimv1_join_prune_print(netdissect_options
*ndo
,
141 register const u_char
*bp
, register u_int len
)
143 int ngroups
, njoin
, nprune
;
146 /* If it's a single group and a single source, use 1-line output. */
147 if (ND_TTEST2(bp
[0], 30) && bp
[11] == 1 &&
148 ((njoin
= EXTRACT_16BITS(&bp
[20])) + EXTRACT_16BITS(&bp
[22])) == 1) {
151 ND_PRINT((ndo
, " RPF %s ", ipaddr_string(ndo
, bp
)));
152 hold
= EXTRACT_16BITS(&bp
[6]);
154 ND_PRINT((ndo
, "Hold "));
155 relts_print(ndo
, hold
);
157 ND_PRINT((ndo
, "%s (%s/%d, %s", njoin
? "Join" : "Prune",
158 ipaddr_string(ndo
, &bp
[26]), bp
[25] & 0x3f,
159 ipaddr_string(ndo
, &bp
[12])));
160 if (EXTRACT_32BITS(&bp
[16]) != 0xffffffff)
161 ND_PRINT((ndo
, "/%s", ipaddr_string(ndo
, &bp
[16])));
162 ND_PRINT((ndo
, ") %s%s %s",
163 (bp
[24] & 0x01) ? "Sparse" : "Dense",
164 (bp
[25] & 0x80) ? " WC" : "",
165 (bp
[25] & 0x40) ? "RP" : "SPT"));
169 ND_TCHECK2(bp
[0], sizeof(struct in_addr
));
170 if (ndo
->ndo_vflag
> 1)
171 ND_PRINT((ndo
, "\n"));
172 ND_PRINT((ndo
, " Upstream Nbr: %s", ipaddr_string(ndo
, bp
)));
173 ND_TCHECK2(bp
[6], 2);
174 if (ndo
->ndo_vflag
> 1)
175 ND_PRINT((ndo
, "\n"));
176 ND_PRINT((ndo
, " Hold time: "));
177 relts_print(ndo
, EXTRACT_16BITS(&bp
[6]));
178 if (ndo
->ndo_vflag
< 2)
183 ND_TCHECK2(bp
[0], 4);
189 * XXX - does the address have length "addrlen" and the
190 * mask length "maddrlen"?
192 ND_TCHECK2(bp
[0], sizeof(struct in_addr
));
193 ND_PRINT((ndo
, "\n\tGroup: %s", ipaddr_string(ndo
, bp
)));
194 ND_TCHECK2(bp
[4], sizeof(struct in_addr
));
195 if (EXTRACT_32BITS(&bp
[4]) != 0xffffffff)
196 ND_PRINT((ndo
, "/%s", ipaddr_string(ndo
, &bp
[4])));
197 ND_TCHECK2(bp
[8], 4);
198 njoin
= EXTRACT_16BITS(&bp
[8]);
199 nprune
= EXTRACT_16BITS(&bp
[10]);
200 ND_PRINT((ndo
, " joined: %d pruned: %d", njoin
, nprune
));
203 for (njp
= 0; njp
< (njoin
+ nprune
); njp
++) {
210 ND_TCHECK2(bp
[0], 6);
211 ND_PRINT((ndo
, "\n\t%s %s%s%s%s/%d", type
,
212 (bp
[0] & 0x01) ? "Sparse " : "Dense ",
213 (bp
[1] & 0x80) ? "WC " : "",
214 (bp
[1] & 0x40) ? "RP " : "SPT ",
215 ipaddr_string(ndo
, &bp
[2]), bp
[1] & 0x3f));
222 ND_PRINT((ndo
, "[|pim]"));
227 pimv1_print(netdissect_options
*ndo
,
228 register const u_char
*bp
, register u_int len
)
230 register const u_char
*ep
;
231 register u_char type
;
233 ep
= (const u_char
*)ndo
->ndo_snapend
;
240 ND_PRINT((ndo
, " %s", tok2str(pimv1_type_str
, "[type %u]", type
)));
242 case PIMV1_TYPE_QUERY
:
243 if (ND_TTEST(bp
[8])) {
244 switch (bp
[8] >> 4) {
246 ND_PRINT((ndo
, " Dense-mode"));
249 ND_PRINT((ndo
, " Sparse-mode"));
252 ND_PRINT((ndo
, " Sparse-Dense-mode"));
255 ND_PRINT((ndo
, " mode-%d", bp
[8] >> 4));
259 if (ndo
->ndo_vflag
) {
260 ND_TCHECK2(bp
[10],2);
261 ND_PRINT((ndo
, " (Hold-time "));
262 relts_print(ndo
, EXTRACT_16BITS(&bp
[10]));
263 ND_PRINT((ndo
, ")"));
267 case PIMV1_TYPE_REGISTER
:
268 ND_TCHECK2(bp
[8], 20); /* ip header */
269 ND_PRINT((ndo
, " for %s > %s", ipaddr_string(ndo
, &bp
[20]),
270 ipaddr_string(ndo
, &bp
[24])));
272 case PIMV1_TYPE_REGISTER_STOP
:
273 ND_TCHECK2(bp
[12], sizeof(struct in_addr
));
274 ND_PRINT((ndo
, " for %s > %s", ipaddr_string(ndo
, &bp
[8]),
275 ipaddr_string(ndo
, &bp
[12])));
277 case PIMV1_TYPE_RP_REACHABILITY
:
278 if (ndo
->ndo_vflag
) {
279 ND_TCHECK2(bp
[22], 2);
280 ND_PRINT((ndo
, " group %s", ipaddr_string(ndo
, &bp
[8])));
281 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
282 ND_PRINT((ndo
, "/%s", ipaddr_string(ndo
, &bp
[12])));
283 ND_PRINT((ndo
, " RP %s hold ", ipaddr_string(ndo
, &bp
[16])));
284 relts_print(ndo
, EXTRACT_16BITS(&bp
[22]));
287 case PIMV1_TYPE_ASSERT
:
288 ND_TCHECK2(bp
[16], sizeof(struct in_addr
));
289 ND_PRINT((ndo
, " for %s > %s", ipaddr_string(ndo
, &bp
[16]),
290 ipaddr_string(ndo
, &bp
[8])));
291 if (EXTRACT_32BITS(&bp
[12]) != 0xffffffff)
292 ND_PRINT((ndo
, "/%s", ipaddr_string(ndo
, &bp
[12])));
293 ND_TCHECK2(bp
[24], 4);
294 ND_PRINT((ndo
, " %s pref %d metric %d",
295 (bp
[20] & 0x80) ? "RP-tree" : "SPT",
296 EXTRACT_32BITS(&bp
[20]) & 0x7fffffff,
297 EXTRACT_32BITS(&bp
[24])));
299 case PIMV1_TYPE_JOIN_PRUNE
:
300 case PIMV1_TYPE_GRAFT
:
301 case PIMV1_TYPE_GRAFT_ACK
:
303 pimv1_join_prune_print(ndo
, &bp
[8], len
- 8);
306 if ((bp
[4] >> 4) != 1)
307 ND_PRINT((ndo
, " [v%d]", bp
[4] >> 4));
311 ND_PRINT((ndo
, "[|pim]"));
316 * auto-RP is a cisco protocol, documented at
317 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
319 * This implements version 1+, dated Sept 9, 1998.
322 cisco_autorp_print(netdissect_options
*ndo
,
323 register const u_char
*bp
, register u_int len
)
330 ND_PRINT((ndo
, " auto-rp "));
334 ND_PRINT((ndo
, "candidate-advert"));
337 ND_PRINT((ndo
, "mapping"));
340 ND_PRINT((ndo
, "type-0x%02x", type
));
347 ND_TCHECK2(bp
[2], 2);
348 ND_PRINT((ndo
, " Hold "));
349 hold
= EXTRACT_16BITS(&bp
[2]);
351 relts_print(ndo
, EXTRACT_16BITS(&bp
[2]));
353 ND_PRINT((ndo
, "FOREVER"));
355 /* Next 4 bytes are reserved. */
359 /*XXX skip unless -v? */
363 * numrps entries of the form:
366 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
367 * 8 bits: # of entries for this RP
368 * each entry: 7 bits: reserved, 1 bit: negative,
369 * 8 bits: mask 32 bits: source
370 * lather, rinse, repeat.
376 ND_TCHECK2(bp
[0], 4);
377 ND_PRINT((ndo
, " RP %s", ipaddr_string(ndo
, bp
)));
379 switch (bp
[4] & 0x3) {
380 case 0: ND_PRINT((ndo
, " PIMv?"));
382 case 1: ND_PRINT((ndo
, " PIMv1"));
384 case 2: ND_PRINT((ndo
, " PIMv2"));
386 case 3: ND_PRINT((ndo
, " PIMv1+2"));
390 ND_PRINT((ndo
, " [rsvd=0x%02x]", bp
[4] & 0xfc));
395 for (; nentries
; nentries
--) {
396 ND_TCHECK2(bp
[0], 6);
397 ND_PRINT((ndo
, "%c%s%s/%d", s
, bp
[0] & 1 ? "!" : "",
398 ipaddr_string(ndo
, &bp
[2]), bp
[1]));
400 ND_PRINT((ndo
, " bidir"));
403 ND_PRINT((ndo
, "[rsvd=0x%02x]", bp
[0] & 0xfc));
412 ND_PRINT((ndo
, "[|autorp]"));
417 pim_print(netdissect_options
*ndo
,
418 register const u_char
*bp
, register u_int len
, u_int cksum
)
420 register const u_char
*ep
;
421 register struct pim
*pim
= (struct pim
*)bp
;
423 ep
= (const u_char
*)ndo
->ndo_snapend
;
426 #ifdef notyet /* currently we see only version and type */
427 ND_TCHECK(pim
->pim_rsv
);
430 switch (PIM_VER(pim
->pim_typever
)) {
432 if (!ndo
->ndo_vflag
) {
433 ND_PRINT((ndo
, "PIMv%u, %s, length %u",
434 PIM_VER(pim
->pim_typever
),
435 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
)),
439 ND_PRINT((ndo
, "PIMv%u, length %u\n\t%s",
440 PIM_VER(pim
->pim_typever
),
442 tok2str(pimv2_type_values
,"Unknown Type",PIM_TYPE(pim
->pim_typever
))));
443 pimv2_print(ndo
, bp
, len
, cksum
);
447 ND_PRINT((ndo
, "PIMv%u, length %u",
448 PIM_VER(pim
->pim_typever
),
456 * PIMv2 uses encoded address representations.
458 * The last PIM-SM I-D before RFC2117 was published specified the
459 * following representation for unicast addresses. However, RFC2117
460 * specified no encoding for unicast addresses with the unicast
461 * address length specified in the header. Therefore, we have to
462 * guess which encoding is being used (Cisco's PIMv2 implementation
463 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
464 * field into a 'unicast-address-length-in-bytes' field. We guess
465 * that it's the draft encoding if this reserved field is zero.
467 * RFC2362 goes back to the encoded format, and calls the addr length
468 * field "reserved" again.
470 * The first byte is the address family, from:
473 * 1 IP (IP version 4)
474 * 2 IP6 (IP version 6)
476 * 4 HDLC (8-bit multidrop)
478 * 6 802 (includes all 802 media plus Ethernet "canonical format")
480 * 8 E.164 (SMDS, Frame Relay, ATM)
482 * 10 X.121 (X.25, Frame Relay)
487 * 15 E.164 with NSAP format subaddress
489 * In addition, the second byte is an "Encoding". 0 is the default
490 * encoding for the address family, and no other encodings are currently
495 static int pimv2_addr_len
;
497 enum pimv2_addrtype
{
498 pimv2_unicast
, pimv2_group
, pimv2_source
502 * 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
503 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
504 * | Addr Family | Encoding Type | Unicast 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 | Reserved | Mask Len |
510 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
511 * | Group multicast Address |
512 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
514 * 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
515 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
516 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
517 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
519 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
522 pimv2_addr_print(netdissect_options
*ndo
,
523 const u_char
*bp
, enum pimv2_addrtype at
, int silent
)
530 if (pimv2_addr_len
== 0) {
535 len
= sizeof(struct in_addr
);
540 len
= sizeof(struct in6_addr
);
550 switch (pimv2_addr_len
) {
551 case sizeof(struct in_addr
):
555 case sizeof(struct in6_addr
):
563 len
= pimv2_addr_len
;
570 ND_TCHECK2(bp
[0], len
);
573 ND_PRINT((ndo
, "%s", ipaddr_string(ndo
, bp
)));
576 else if (af
== AF_INET6
) {
578 ND_PRINT((ndo
, "%s", ip6addr_string(ndo
, bp
)));
584 ND_TCHECK2(bp
[0], len
+ 2);
587 ND_PRINT((ndo
, "%s", ipaddr_string(ndo
, bp
+ 2)));
589 ND_PRINT((ndo
, "/%u", bp
[1]));
593 else if (af
== AF_INET6
) {
595 ND_PRINT((ndo
, "%s", ip6addr_string(ndo
, bp
+ 2)));
597 ND_PRINT((ndo
, "/%u", bp
[1]));
601 if (bp
[0] && !silent
) {
602 if (at
== pimv2_group
) {
603 ND_PRINT((ndo
, "(0x%02x)", bp
[0]));
605 ND_PRINT((ndo
, "(%s%s%s",
606 bp
[0] & 0x04 ? "S" : "",
607 bp
[0] & 0x02 ? "W" : "",
608 bp
[0] & 0x01 ? "R" : ""));
610 ND_PRINT((ndo
, "+0x%02x", bp
[0] & 0xf8));
612 ND_PRINT((ndo
, ")"));
615 return hdrlen
+ 2 + len
;
624 pimv2_print(netdissect_options
*ndo
,
625 register const u_char
*bp
, register u_int len
, u_int cksum
)
627 register const u_char
*ep
;
628 register struct pim
*pim
= (struct pim
*)bp
;
631 ep
= (const u_char
*)ndo
->ndo_snapend
;
636 ND_TCHECK(pim
->pim_rsv
);
637 pimv2_addr_len
= pim
->pim_rsv
;
638 if (pimv2_addr_len
!= 0)
639 ND_PRINT((ndo
, ", RFC2117-encoding"));
641 ND_PRINT((ndo
, ", cksum 0x%04x ", EXTRACT_16BITS(&pim
->pim_cksum
)));
642 if (EXTRACT_16BITS(&pim
->pim_cksum
) == 0) {
643 ND_PRINT((ndo
, "(unverified)"));
645 ND_PRINT((ndo
, "(%scorrect)", ND_TTEST2(bp
[0], len
) && cksum
? "in" : "" ));
648 switch (PIM_TYPE(pim
->pim_typever
)) {
649 case PIMV2_TYPE_HELLO
:
651 uint16_t otype
, olen
;
654 ND_TCHECK2(bp
[0], 4);
655 otype
= EXTRACT_16BITS(&bp
[0]);
656 olen
= EXTRACT_16BITS(&bp
[2]);
657 ND_TCHECK2(bp
[0], 4 + olen
);
658 ND_PRINT((ndo
, "\n\t %s Option (%u), length %u, Value: ",
659 tok2str(pimv2_hello_option_values
, "Unknown", otype
),
665 case PIMV2_HELLO_OPTION_HOLDTIME
:
666 relts_print(ndo
, EXTRACT_16BITS(bp
));
669 case PIMV2_HELLO_OPTION_LANPRUNEDELAY
:
671 ND_PRINT((ndo
, "ERROR: Option Length != 4 Bytes (%u)", olen
));
674 uint16_t lan_delay
, override_interval
;
675 lan_delay
= EXTRACT_16BITS(bp
);
676 override_interval
= EXTRACT_16BITS(bp
+2);
677 t_bit
= (lan_delay
& 0x8000)? 1 : 0;
678 lan_delay
&= ~0x8000;
679 ND_PRINT((ndo
, "\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
680 t_bit
, lan_delay
, override_interval
));
684 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD
:
685 case PIMV2_HELLO_OPTION_DR_PRIORITY
:
688 ND_PRINT((ndo
, "Bi-Directional Capability (Old)"));
691 ND_PRINT((ndo
, "%u", EXTRACT_32BITS(bp
)));
694 ND_PRINT((ndo
, "ERROR: Option Length != 4 Bytes (%u)", olen
));
699 case PIMV2_HELLO_OPTION_GENID
:
700 ND_PRINT((ndo
, "0x%08x", EXTRACT_32BITS(bp
)));
703 case PIMV2_HELLO_OPTION_REFRESH_CAP
:
704 ND_PRINT((ndo
, "v%d", *bp
));
706 ND_PRINT((ndo
, ", interval "));
707 relts_print(ndo
, *(bp
+1));
709 if (EXTRACT_16BITS(bp
+2) != 0) {
710 ND_PRINT((ndo
, " ?0x%04x?", EXTRACT_16BITS(bp
+2)));
714 case PIMV2_HELLO_OPTION_BIDIR_CAP
:
717 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD
:
718 case PIMV2_HELLO_OPTION_ADDRESS_LIST
:
719 if (ndo
->ndo_vflag
> 1) {
720 const u_char
*ptr
= bp
;
721 while (ptr
< (bp
+olen
)) {
724 ND_PRINT((ndo
, "\n\t "));
725 advance
= pimv2_addr_print(ndo
, ptr
, pimv2_unicast
, 0);
727 ND_PRINT((ndo
, "..."));
735 if (ndo
->ndo_vflag
<= 1)
736 print_unknown_data(ndo
, bp
, "\n\t ", olen
);
739 /* do we want to see an additionally hexdump ? */
740 if (ndo
->ndo_vflag
> 1)
741 print_unknown_data(ndo
, bp
, "\n\t ", olen
);
747 case PIMV2_TYPE_REGISTER
:
751 ND_TCHECK2(*(bp
+ 4), PIMV2_REGISTER_FLAG_LEN
);
753 ND_PRINT((ndo
, ", Flags [ %s ]\n\t",
754 tok2str(pimv2_register_flag_values
,
756 EXTRACT_32BITS(bp
+4))));
759 /* encapsulated multicast packet */
760 ip
= (struct ip
*)bp
;
762 case 0: /* Null header */
763 ND_PRINT((ndo
, "IP-Null-header %s > %s",
764 ipaddr_string(ndo
, &ip
->ip_src
),
765 ipaddr_string(ndo
, &ip
->ip_dst
)));
769 ip_print(ndo
, bp
, len
);
773 ip6_print(ndo
, bp
, len
);
777 ND_PRINT((ndo
, "IP ver %d", IP_V(ip
)));
783 case PIMV2_TYPE_REGISTER_STOP
:
787 ND_PRINT((ndo
, " group="));
788 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
789 ND_PRINT((ndo
, "..."));
792 bp
+= advance
; len
-= advance
;
795 ND_PRINT((ndo
, " source="));
796 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
797 ND_PRINT((ndo
, "..."));
800 bp
+= advance
; len
-= advance
;
803 case PIMV2_TYPE_JOIN_PRUNE
:
804 case PIMV2_TYPE_GRAFT
:
805 case PIMV2_TYPE_GRAFT_ACK
:
810 * 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
811 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
812 * |PIM Ver| Type | Addr length | Checksum |
813 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
814 * | Unicast-Upstream Neighbor Address |
815 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
816 * | Reserved | Num groups | Holdtime |
817 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
818 * | Encoded-Multicast Group Address-1 |
819 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
820 * | Number of Joined Sources | Number of Pruned Sources |
821 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
822 * | Encoded-Joined Source Address-1 |
823 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
826 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
827 * | Encoded-Joined Source Address-n |
828 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
829 * | Encoded-Pruned Source Address-1 |
830 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
833 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
834 * | Encoded-Pruned Source Address-n |
835 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
838 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
839 * | Encoded-Multicast Group Address-n |
840 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
851 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
854 ND_PRINT((ndo
, ", upstream-neighbor: "));
855 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
856 ND_PRINT((ndo
, "..."));
859 bp
+= advance
; len
-= advance
;
864 holdtime
= EXTRACT_16BITS(&bp
[2]);
865 ND_PRINT((ndo
, "\n\t %u group(s)", ngroup
));
866 if (PIM_TYPE(pim
->pim_typever
) != 7) { /*not for Graft-ACK*/
867 ND_PRINT((ndo
, ", holdtime: "));
868 if (holdtime
== 0xffff)
869 ND_PRINT((ndo
, "infinite"));
871 relts_print(ndo
, holdtime
);
874 for (i
= 0; i
< ngroup
; i
++) {
877 ND_PRINT((ndo
, "\n\t group #%u: ", i
+1));
878 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
879 ND_PRINT((ndo
, "...)"));
882 bp
+= advance
; len
-= advance
;
884 ND_PRINT((ndo
, "...)"));
887 njoin
= EXTRACT_16BITS(&bp
[0]);
888 nprune
= EXTRACT_16BITS(&bp
[2]);
889 ND_PRINT((ndo
, ", joined sources: %u, pruned sources: %u", njoin
, nprune
));
891 for (j
= 0; j
< njoin
; j
++) {
892 ND_PRINT((ndo
, "\n\t joined source #%u: ", j
+1));
893 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_source
, 0)) < 0) {
894 ND_PRINT((ndo
, "...)"));
897 bp
+= advance
; len
-= advance
;
899 for (j
= 0; j
< nprune
; j
++) {
900 ND_PRINT((ndo
, "\n\t pruned source #%u: ", j
+1));
901 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_source
, 0)) < 0) {
902 ND_PRINT((ndo
, "...)"));
905 bp
+= advance
; len
-= advance
;
912 case PIMV2_TYPE_BOOTSTRAP
:
917 /* Fragment Tag, Hash Mask len, and BSR-priority */
918 if (bp
+ sizeof(uint16_t) >= ep
) break;
919 ND_PRINT((ndo
, " tag=%x", EXTRACT_16BITS(bp
)));
920 bp
+= sizeof(uint16_t);
922 ND_PRINT((ndo
, " hashmlen=%d", bp
[0]));
923 if (bp
+ 1 >= ep
) break;
924 ND_PRINT((ndo
, " BSRprio=%d", bp
[1]));
927 /* Encoded-Unicast-BSR-Address */
929 ND_PRINT((ndo
, " BSR="));
930 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
931 ND_PRINT((ndo
, "..."));
936 for (i
= 0; bp
< ep
; i
++) {
937 /* Encoded-Group Address */
938 ND_PRINT((ndo
, " (group%d: ", i
));
939 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0))
941 ND_PRINT((ndo
, "...)"));
946 /* RP-Count, Frag RP-Cnt, and rsvd */
948 ND_PRINT((ndo
, "...)"));
951 ND_PRINT((ndo
, " RPcnt=%d", bp
[0]));
953 ND_PRINT((ndo
, "...)"));
956 ND_PRINT((ndo
, " FRPcnt=%d", frpcnt
= bp
[1]));
959 for (j
= 0; j
< frpcnt
&& bp
< ep
; j
++) {
961 ND_PRINT((ndo
, " RP%d=", j
));
962 if ((advance
= pimv2_addr_print(ndo
, bp
,
965 ND_PRINT((ndo
, "...)"));
971 ND_PRINT((ndo
, "...)"));
974 ND_PRINT((ndo
, ",holdtime="));
975 relts_print(ndo
, EXTRACT_16BITS(bp
));
977 ND_PRINT((ndo
, "...)"));
980 ND_PRINT((ndo
, ",prio=%d", bp
[2]));
983 ND_PRINT((ndo
, ")"));
988 case PIMV2_TYPE_ASSERT
:
992 ND_PRINT((ndo
, " group="));
993 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
994 ND_PRINT((ndo
, "..."));
997 bp
+= advance
; len
-= advance
;
1000 ND_PRINT((ndo
, " src="));
1001 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1002 ND_PRINT((ndo
, "..."));
1005 bp
+= advance
; len
-= advance
;
1009 ND_PRINT((ndo
, " RPT"));
1010 ND_PRINT((ndo
, " pref=%u", EXTRACT_32BITS(&bp
[0]) & 0x7fffffff));
1011 ND_PRINT((ndo
, " metric=%u", EXTRACT_32BITS(&bp
[4])));
1014 case PIMV2_TYPE_CANDIDATE_RP
:
1019 /* Prefix-Cnt, Priority, and Holdtime */
1020 if (bp
>= ep
) break;
1021 ND_PRINT((ndo
, " prefix-cnt=%d", bp
[0]));
1023 if (bp
+ 1 >= ep
) break;
1024 ND_PRINT((ndo
, " prio=%d", bp
[1]));
1025 if (bp
+ 3 >= ep
) break;
1026 ND_PRINT((ndo
, " holdtime="));
1027 relts_print(ndo
, EXTRACT_16BITS(&bp
[2]));
1030 /* Encoded-Unicast-RP-Address */
1031 if (bp
>= ep
) break;
1032 ND_PRINT((ndo
, " RP="));
1033 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1034 ND_PRINT((ndo
, "..."));
1039 /* Encoded-Group Addresses */
1040 for (i
= 0; i
< pfxcnt
&& bp
< ep
; i
++) {
1041 ND_PRINT((ndo
, " Group%d=", i
));
1042 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0))
1044 ND_PRINT((ndo
, "..."));
1052 case PIMV2_TYPE_PRUNE_REFRESH
:
1053 ND_PRINT((ndo
, " src="));
1054 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1055 ND_PRINT((ndo
, "..."));
1059 ND_PRINT((ndo
, " grp="));
1060 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_group
, 0)) < 0) {
1061 ND_PRINT((ndo
, "..."));
1065 ND_PRINT((ndo
, " forwarder="));
1066 if ((advance
= pimv2_addr_print(ndo
, bp
, pimv2_unicast
, 0)) < 0) {
1067 ND_PRINT((ndo
, "..."));
1071 ND_TCHECK2(bp
[0], 2);
1072 ND_PRINT((ndo
, " TUNR "));
1073 relts_print(ndo
, EXTRACT_16BITS(bp
));
1078 ND_PRINT((ndo
, " [type %d]", PIM_TYPE(pim
->pim_typever
)));
1085 ND_PRINT((ndo
, "[|pim]"));
1090 * c-style: whitesmith