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.
24 #define NETDISSECT_REWORKED
29 #include <tcpdump-stdinc.h>
31 #include "interface.h"
32 #include "addrtoname.h"
37 #define PIMV1_TYPE_QUERY 0
38 #define PIMV1_TYPE_REGISTER 1
39 #define PIMV1_TYPE_REGISTER_STOP 2
40 #define PIMV1_TYPE_JOIN_PRUNE 3
41 #define PIMV1_TYPE_RP_REACHABILITY 4
42 #define PIMV1_TYPE_ASSERT 5
43 #define PIMV1_TYPE_GRAFT 6
44 #define PIMV1_TYPE_GRAFT_ACK 7
46 static const struct tok pimv1_type_str[] = {
47 { PIMV1_TYPE_QUERY, "Query" },
48 { PIMV1_TYPE_REGISTER, "Register" },
49 { PIMV1_TYPE_REGISTER_STOP, "Register-Stop" },
50 { PIMV1_TYPE_JOIN_PRUNE, "Join/Prune" },
51 { PIMV1_TYPE_RP_REACHABILITY, "RP-reachable" },
52 { PIMV1_TYPE_ASSERT, "Assert" },
53 { PIMV1_TYPE_GRAFT, "Graft" },
54 { PIMV1_TYPE_GRAFT_ACK, "Graft-ACK" },
58 #define PIMV2_TYPE_HELLO 0
59 #define PIMV2_TYPE_REGISTER 1
60 #define PIMV2_TYPE_REGISTER_STOP 2
61 #define PIMV2_TYPE_JOIN_PRUNE 3
62 #define PIMV2_TYPE_BOOTSTRAP 4
63 #define PIMV2_TYPE_ASSERT 5
64 #define PIMV2_TYPE_GRAFT 6
65 #define PIMV2_TYPE_GRAFT_ACK 7
66 #define PIMV2_TYPE_CANDIDATE_RP 8
67 #define PIMV2_TYPE_PRUNE_REFRESH 9
68 #define PIMV2_TYPE_DF_ELECTION 10
69 #define PIMV2_TYPE_ECMP_REDIRECT 11
71 static const struct tok pimv2_type_values[] = {
72 { PIMV2_TYPE_HELLO, "Hello" },
73 { PIMV2_TYPE_REGISTER, "Register" },
74 { PIMV2_TYPE_REGISTER_STOP, "Register Stop" },
75 { PIMV2_TYPE_JOIN_PRUNE, "Join / Prune" },
76 { PIMV2_TYPE_BOOTSTRAP, "Bootstrap" },
77 { PIMV2_TYPE_ASSERT, "Assert" },
78 { PIMV2_TYPE_GRAFT, "Graft" },
79 { PIMV2_TYPE_GRAFT_ACK, "Graft Acknowledgement" },
80 { PIMV2_TYPE_CANDIDATE_RP, "Candidate RP Advertisement" },
81 { PIMV2_TYPE_PRUNE_REFRESH, "Prune Refresh" },
82 { PIMV2_TYPE_DF_ELECTION, "DF Election" },
83 { PIMV2_TYPE_ECMP_REDIRECT, "ECMP Redirect" },
87 #define PIMV2_HELLO_OPTION_HOLDTIME 1
88 #define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
89 #define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
90 #define PIMV2_HELLO_OPTION_DR_PRIORITY 19
91 #define PIMV2_HELLO_OPTION_GENID 20
92 #define PIMV2_HELLO_OPTION_REFRESH_CAP 21
93 #define PIMV2_HELLO_OPTION_BIDIR_CAP 22
94 #define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
95 #define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
97 static const struct tok pimv2_hello_option_values[] = {
98 { PIMV2_HELLO_OPTION_HOLDTIME, "Hold Time" },
99 { PIMV2_HELLO_OPTION_LANPRUNEDELAY, "LAN Prune Delay" },
100 { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD, "DR Priority (Old)" },
101 { PIMV2_HELLO_OPTION_DR_PRIORITY, "DR Priority" },
102 { PIMV2_HELLO_OPTION_GENID, "Generation ID" },
103 { PIMV2_HELLO_OPTION_REFRESH_CAP, "State Refresh Capability" },
104 { PIMV2_HELLO_OPTION_BIDIR_CAP, "Bi-Directional Capability" },
105 { PIMV2_HELLO_OPTION_ADDRESS_LIST, "Address List" },
106 { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD, "Address List (Old)" },
110 #define PIMV2_REGISTER_FLAG_LEN 4
111 #define PIMV2_REGISTER_FLAG_BORDER 0x80000000
112 #define PIMV2_REGISTER_FLAG_NULL 0x40000000
114 static const struct tok pimv2_register_flag_values[] = {
115 { PIMV2_REGISTER_FLAG_BORDER, "Border" },
116 { PIMV2_REGISTER_FLAG_NULL, "Null" },
121 * XXX: We consider a case where IPv6 is not ready yet for portability,
122 * but PIM dependent defintions should be independent of IPv6...
127 /* upper 4bit: PIM version number; 2 for PIMv2 */
128 /* lower 4bit: the PIM message type, currently they are:
129 * Hello, Register, Register-Stop, Join/Prune,
130 * Bootstrap, Assert, Graft (PIM-DM only),
131 * Graft-Ack (PIM-DM only), C-RP-Adv
133 #define PIM_VER(x) (((x) & 0xf0) >> 4)
134 #define PIM_TYPE(x) ((x) & 0x0f)
135 u_char pim_rsv; /* Reserved */
136 u_short pim_cksum; /* IP style check sum */
139 static void pimv2_print(netdissect_options *, register const u_char *bp, register u_int len, u_int cksum);
142 pimv1_join_prune_print(netdissect_options *ndo,
143 register const u_char *bp, register u_int len)
145 int ngroups, njoin, nprune;
148 /* If it's a single group and a single source, use 1-line output. */
149 if (ND_TTEST2(bp[0], 30) && bp[11] == 1 &&
150 ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
153 ND_PRINT((ndo, " RPF %s ", ipaddr_string(ndo, bp)));
154 hold = EXTRACT_16BITS(&bp[6]);
156 ND_PRINT((ndo, "Hold "));
157 relts_print(ndo, hold);
159 ND_PRINT((ndo, "%s (%s/%d, %s", njoin ? "Join" : "Prune",
160 ipaddr_string(ndo, &bp[26]), bp[25] & 0x3f,
161 ipaddr_string(ndo, &bp[12])));
162 if (EXTRACT_32BITS(&bp[16]) != 0xffffffff)
163 ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[16])));
164 ND_PRINT((ndo, ") %s%s %s",
165 (bp[24] & 0x01) ? "Sparse" : "Dense",
166 (bp[25] & 0x80) ? " WC" : "",
167 (bp[25] & 0x40) ? "RP" : "SPT"));
171 ND_TCHECK2(bp[0], sizeof(struct in_addr));
172 if (ndo->ndo_vflag > 1)
173 ND_PRINT((ndo, "\n"));
174 ND_PRINT((ndo, " Upstream Nbr: %s", ipaddr_string(ndo, bp)));
175 ND_TCHECK2(bp[6], 2);
176 if (ndo->ndo_vflag > 1)
177 ND_PRINT((ndo, "\n"));
178 ND_PRINT((ndo, " Hold time: "));
179 relts_print(ndo, EXTRACT_16BITS(&bp[6]));
180 if (ndo->ndo_vflag < 2)
185 ND_TCHECK2(bp[0], 4);
191 * XXX - does the address have length "addrlen" and the
192 * mask length "maddrlen"?
194 ND_TCHECK2(bp[0], sizeof(struct in_addr));
195 ND_PRINT((ndo, "\n\tGroup: %s", ipaddr_string(ndo, bp)));
196 ND_TCHECK2(bp[4], sizeof(struct in_addr));
197 if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
198 ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[4])));
199 ND_TCHECK2(bp[8], 4);
200 njoin = EXTRACT_16BITS(&bp[8]);
201 nprune = EXTRACT_16BITS(&bp[10]);
202 ND_PRINT((ndo, " joined: %d pruned: %d", njoin, nprune));
205 for (njp = 0; njp < (njoin + nprune); njp++) {
212 ND_TCHECK2(bp[0], 6);
213 ND_PRINT((ndo, "\n\t%s %s%s%s%s/%d", type,
214 (bp[0] & 0x01) ? "Sparse " : "Dense ",
215 (bp[1] & 0x80) ? "WC " : "",
216 (bp[1] & 0x40) ? "RP " : "SPT ",
217 ipaddr_string(ndo, &bp[2]), bp[1] & 0x3f));
224 ND_PRINT((ndo, "[|pim]"));
229 pimv1_print(netdissect_options *ndo,
230 register const u_char *bp, register u_int len)
232 register const u_char *ep;
233 register u_char type;
235 ep = (const u_char *)ndo->ndo_snapend;
242 ND_PRINT((ndo, " %s", tok2str(pimv1_type_str, "[type %u]", type)));
244 case PIMV1_TYPE_QUERY:
245 if (ND_TTEST(bp[8])) {
246 switch (bp[8] >> 4) {
248 ND_PRINT((ndo, " Dense-mode"));
251 ND_PRINT((ndo, " Sparse-mode"));
254 ND_PRINT((ndo, " Sparse-Dense-mode"));
257 ND_PRINT((ndo, " mode-%d", bp[8] >> 4));
261 if (ndo->ndo_vflag) {
262 ND_TCHECK2(bp[10],2);
263 ND_PRINT((ndo, " (Hold-time "));
264 relts_print(ndo, EXTRACT_16BITS(&bp[10]));
265 ND_PRINT((ndo, ")"));
269 case PIMV1_TYPE_REGISTER:
270 ND_TCHECK2(bp[8], 20); /* ip header */
271 ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[20]),
272 ipaddr_string(ndo, &bp[24])));
274 case PIMV1_TYPE_REGISTER_STOP:
275 ND_TCHECK2(bp[12], sizeof(struct in_addr));
276 ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[8]),
277 ipaddr_string(ndo, &bp[12])));
279 case PIMV1_TYPE_RP_REACHABILITY:
280 if (ndo->ndo_vflag) {
281 ND_TCHECK2(bp[22], 2);
282 ND_PRINT((ndo, " group %s", ipaddr_string(ndo, &bp[8])));
283 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
284 ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
285 ND_PRINT((ndo, " RP %s hold ", ipaddr_string(ndo, &bp[16])));
286 relts_print(ndo, EXTRACT_16BITS(&bp[22]));
289 case PIMV1_TYPE_ASSERT:
290 ND_TCHECK2(bp[16], sizeof(struct in_addr));
291 ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[16]),
292 ipaddr_string(ndo, &bp[8])));
293 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
294 ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
295 ND_TCHECK2(bp[24], 4);
296 ND_PRINT((ndo, " %s pref %d metric %d",
297 (bp[20] & 0x80) ? "RP-tree" : "SPT",
298 EXTRACT_32BITS(&bp[20]) & 0x7fffffff,
299 EXTRACT_32BITS(&bp[24])));
301 case PIMV1_TYPE_JOIN_PRUNE:
302 case PIMV1_TYPE_GRAFT:
303 case PIMV1_TYPE_GRAFT_ACK:
305 pimv1_join_prune_print(ndo, &bp[8], len - 8);
308 if ((bp[4] >> 4) != 1)
309 ND_PRINT((ndo, " [v%d]", bp[4] >> 4));
313 ND_PRINT((ndo, "[|pim]"));
318 * auto-RP is a cisco protocol, documented at
319 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt
321 * This implements version 1+, dated Sept 9, 1998.
324 cisco_autorp_print(netdissect_options *ndo,
325 register const u_char *bp, register u_int len)
332 ND_PRINT((ndo, " auto-rp "));
336 ND_PRINT((ndo, "candidate-advert"));
339 ND_PRINT((ndo, "mapping"));
342 ND_PRINT((ndo, "type-0x%02x", type));
349 ND_TCHECK2(bp[2], 2);
350 ND_PRINT((ndo, " Hold "));
351 hold = EXTRACT_16BITS(&bp[2]);
353 relts_print(ndo, EXTRACT_16BITS(&bp[2]));
355 ND_PRINT((ndo, "FOREVER"));
357 /* Next 4 bytes are reserved. */
361 /*XXX skip unless -v? */
365 * numrps entries of the form:
368 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2".
369 * 8 bits: # of entries for this RP
370 * each entry: 7 bits: reserved, 1 bit: negative,
371 * 8 bits: mask 32 bits: source
372 * lather, rinse, repeat.
378 ND_TCHECK2(bp[0], 4);
379 ND_PRINT((ndo, " RP %s", ipaddr_string(ndo, bp)));
381 switch (bp[4] & 0x3) {
382 case 0: ND_PRINT((ndo, " PIMv?"));
384 case 1: ND_PRINT((ndo, " PIMv1"));
386 case 2: ND_PRINT((ndo, " PIMv2"));
388 case 3: ND_PRINT((ndo, " PIMv1+2"));
392 ND_PRINT((ndo, " [rsvd=0x%02x]", bp[4] & 0xfc));
397 for (; nentries; nentries--) {
398 ND_TCHECK2(bp[0], 6);
399 ND_PRINT((ndo, "%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
400 ipaddr_string(ndo, &bp[2]), bp[1]));
402 ND_PRINT((ndo, " bidir"));
405 ND_PRINT((ndo, "[rsvd=0x%02x]", bp[0] & 0xfc));
414 ND_PRINT((ndo, "[|autorp]"));
419 pim_print(netdissect_options *ndo,
420 register const u_char *bp, register u_int len, u_int cksum)
422 register const u_char *ep;
423 register struct pim *pim = (struct pim *)bp;
425 ep = (const u_char *)ndo->ndo_snapend;
428 #ifdef notyet /* currently we see only version and type */
429 ND_TCHECK(pim->pim_rsv);
432 switch (PIM_VER(pim->pim_typever)) {
434 if (!ndo->ndo_vflag) {
435 ND_PRINT((ndo, "PIMv%u, %s, length %u",
436 PIM_VER(pim->pim_typever),
437 tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
441 ND_PRINT((ndo, "PIMv%u, length %u\n\t%s",
442 PIM_VER(pim->pim_typever),
444 tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever))));
445 pimv2_print(ndo, bp, len, cksum);
449 ND_PRINT((ndo, "PIMv%u, length %u",
450 PIM_VER(pim->pim_typever),
458 * PIMv2 uses encoded address representations.
460 * The last PIM-SM I-D before RFC2117 was published specified the
461 * following representation for unicast addresses. However, RFC2117
462 * specified no encoding for unicast addresses with the unicast
463 * address length specified in the header. Therefore, we have to
464 * guess which encoding is being used (Cisco's PIMv2 implementation
465 * uses the non-RFC encoding). RFC2117 turns a previously "Reserved"
466 * field into a 'unicast-address-length-in-bytes' field. We guess
467 * that it's the draft encoding if this reserved field is zero.
469 * RFC2362 goes back to the encoded format, and calls the addr length
470 * field "reserved" again.
472 * The first byte is the address family, from:
475 * 1 IP (IP version 4)
476 * 2 IP6 (IP version 6)
478 * 4 HDLC (8-bit multidrop)
480 * 6 802 (includes all 802 media plus Ethernet "canonical format")
482 * 8 E.164 (SMDS, Frame Relay, ATM)
484 * 10 X.121 (X.25, Frame Relay)
489 * 15 E.164 with NSAP format subaddress
491 * In addition, the second byte is an "Encoding". 0 is the default
492 * encoding for the address family, and no other encodings are currently
497 static int pimv2_addr_len;
499 enum pimv2_addrtype {
500 pimv2_unicast, pimv2_group, pimv2_source
504 * 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
505 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
506 * | Addr Family | Encoding Type | Unicast Address |
507 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++
509 * 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
510 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
511 * | Addr Family | Encoding Type | Reserved | Mask Len |
512 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
513 * | Group multicast Address |
514 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
516 * 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
517 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
518 * | Addr Family | Encoding Type | Rsrvd |S|W|R| Mask Len |
519 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
521 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
524 pimv2_addr_print(netdissect_options *ndo,
525 const u_char *bp, enum pimv2_addrtype at, int silent)
532 if (pimv2_addr_len == 0) {
537 len = sizeof(struct in_addr);
542 len = sizeof(struct in6_addr);
552 switch (pimv2_addr_len) {
553 case sizeof(struct in_addr):
557 case sizeof(struct in6_addr):
565 len = pimv2_addr_len;
572 ND_TCHECK2(bp[0], len);
575 ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp)));
578 else if (af == AF_INET6) {
580 ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp)));
586 ND_TCHECK2(bp[0], len + 2);
589 ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp + 2)));
591 ND_PRINT((ndo, "/%u", bp[1]));
595 else if (af == AF_INET6) {
597 ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2)));
599 ND_PRINT((ndo, "/%u", bp[1]));
603 if (bp[0] && !silent) {
604 if (at == pimv2_group) {
605 ND_PRINT((ndo, "(0x%02x)", bp[0]));
607 ND_PRINT((ndo, "(%s%s%s",
608 bp[0] & 0x04 ? "S" : "",
609 bp[0] & 0x02 ? "W" : "",
610 bp[0] & 0x01 ? "R" : ""));
612 ND_PRINT((ndo, "+0x%02x", bp[0] & 0xf8));
614 ND_PRINT((ndo, ")"));
617 return hdrlen + 2 + len;
626 pimv2_print(netdissect_options *ndo,
627 register const u_char *bp, register u_int len, u_int cksum)
629 register const u_char *ep;
630 register struct pim *pim = (struct pim *)bp;
633 ep = (const u_char *)ndo->ndo_snapend;
638 ND_TCHECK(pim->pim_rsv);
639 pimv2_addr_len = pim->pim_rsv;
640 if (pimv2_addr_len != 0)
641 ND_PRINT((ndo, ", RFC2117-encoding"));
643 ND_PRINT((ndo, ", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum)));
644 if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
645 ND_PRINT((ndo, "(unverified)"));
647 ND_PRINT((ndo, "(%scorrect)", ND_TTEST2(bp[0], len) && cksum ? "in" : "" ));
650 switch (PIM_TYPE(pim->pim_typever)) {
651 case PIMV2_TYPE_HELLO:
653 uint16_t otype, olen;
656 ND_TCHECK2(bp[0], 4);
657 otype = EXTRACT_16BITS(&bp[0]);
658 olen = EXTRACT_16BITS(&bp[2]);
659 ND_TCHECK2(bp[0], 4 + olen);
660 ND_PRINT((ndo, "\n\t %s Option (%u), length %u, Value: ",
661 tok2str(pimv2_hello_option_values, "Unknown", otype),
667 case PIMV2_HELLO_OPTION_HOLDTIME:
668 relts_print(ndo, EXTRACT_16BITS(bp));
671 case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
673 ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen));
676 uint16_t lan_delay, override_interval;
677 lan_delay = EXTRACT_16BITS(bp);
678 override_interval = EXTRACT_16BITS(bp+2);
679 t_bit = (lan_delay & 0x8000)? 1 : 0;
680 lan_delay &= ~0x8000;
681 ND_PRINT((ndo, "\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
682 t_bit, lan_delay, override_interval));
686 case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD:
687 case PIMV2_HELLO_OPTION_DR_PRIORITY:
690 ND_PRINT((ndo, "Bi-Directional Capability (Old)"));
693 ND_PRINT((ndo, "%u", EXTRACT_32BITS(bp)));
696 ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen));
701 case PIMV2_HELLO_OPTION_GENID:
702 ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(bp)));
705 case PIMV2_HELLO_OPTION_REFRESH_CAP:
706 ND_PRINT((ndo, "v%d", *bp));
708 ND_PRINT((ndo, ", interval "));
709 relts_print(ndo, *(bp+1));
711 if (EXTRACT_16BITS(bp+2) != 0) {
712 ND_PRINT((ndo, " ?0x%04x?", EXTRACT_16BITS(bp+2)));
716 case PIMV2_HELLO_OPTION_BIDIR_CAP:
719 case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
720 case PIMV2_HELLO_OPTION_ADDRESS_LIST:
721 if (ndo->ndo_vflag > 1) {
722 const u_char *ptr = bp;
723 while (ptr < (bp+olen)) {
726 ND_PRINT((ndo, "\n\t "));
727 advance = pimv2_addr_print(ndo, ptr, pimv2_unicast, 0);
729 ND_PRINT((ndo, "..."));
737 if (ndo->ndo_vflag <= 1)
738 print_unknown_data(ndo, bp, "\n\t ", olen);
741 /* do we want to see an additionally hexdump ? */
742 if (ndo->ndo_vflag> 1)
743 print_unknown_data(ndo, bp, "\n\t ", olen);
749 case PIMV2_TYPE_REGISTER:
753 ND_TCHECK2(*(bp + 4), PIMV2_REGISTER_FLAG_LEN);
755 ND_PRINT((ndo, ", Flags [ %s ]\n\t",
756 tok2str(pimv2_register_flag_values,
758 EXTRACT_32BITS(bp+4))));
761 /* encapsulated multicast packet */
762 ip = (struct ip *)bp;
764 case 0: /* Null header */
765 ND_PRINT((ndo, "IP-Null-header %s > %s",
766 ipaddr_string(ndo, &ip->ip_src),
767 ipaddr_string(ndo, &ip->ip_dst)));
771 ip_print(ndo, bp, len);
775 ip6_print(ndo, bp, len);
779 ND_PRINT((ndo, "IP ver %d", IP_V(ip)));
785 case PIMV2_TYPE_REGISTER_STOP:
789 ND_PRINT((ndo, " group="));
790 if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
791 ND_PRINT((ndo, "..."));
794 bp += advance; len -= advance;
797 ND_PRINT((ndo, " source="));
798 if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
799 ND_PRINT((ndo, "..."));
802 bp += advance; len -= advance;
805 case PIMV2_TYPE_JOIN_PRUNE:
806 case PIMV2_TYPE_GRAFT:
807 case PIMV2_TYPE_GRAFT_ACK:
812 * 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
813 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
814 * |PIM Ver| Type | Addr length | Checksum |
815 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
816 * | Unicast-Upstream Neighbor Address |
817 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
818 * | Reserved | Num groups | Holdtime |
819 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
820 * | Encoded-Multicast Group Address-1 |
821 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
822 * | Number of Joined Sources | Number of Pruned Sources |
823 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
824 * | Encoded-Joined Source Address-1 |
825 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
828 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
829 * | Encoded-Joined Source Address-n |
830 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
831 * | Encoded-Pruned Source Address-1 |
832 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
835 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
836 * | Encoded-Pruned Source Address-n |
837 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
840 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
841 * | Encoded-Multicast Group Address-n |
842 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
853 if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
856 ND_PRINT((ndo, ", upstream-neighbor: "));
857 if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
858 ND_PRINT((ndo, "..."));
861 bp += advance; len -= advance;
866 holdtime = EXTRACT_16BITS(&bp[2]);
867 ND_PRINT((ndo, "\n\t %u group(s)", ngroup));
868 if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
869 ND_PRINT((ndo, ", holdtime: "));
870 if (holdtime == 0xffff)
871 ND_PRINT((ndo, "infinite"));
873 relts_print(ndo, holdtime);
876 for (i = 0; i < ngroup; i++) {
879 ND_PRINT((ndo, "\n\t group #%u: ", i+1));
880 if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
881 ND_PRINT((ndo, "...)"));
884 bp += advance; len -= advance;
886 ND_PRINT((ndo, "...)"));
889 njoin = EXTRACT_16BITS(&bp[0]);
890 nprune = EXTRACT_16BITS(&bp[2]);
891 ND_PRINT((ndo, ", joined sources: %u, pruned sources: %u", njoin, nprune));
893 for (j = 0; j < njoin; j++) {
894 ND_PRINT((ndo, "\n\t joined source #%u: ", j+1));
895 if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) {
896 ND_PRINT((ndo, "...)"));
899 bp += advance; len -= advance;
901 for (j = 0; j < nprune; j++) {
902 ND_PRINT((ndo, "\n\t pruned source #%u: ", j+1));
903 if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) {
904 ND_PRINT((ndo, "...)"));
907 bp += advance; len -= advance;
914 case PIMV2_TYPE_BOOTSTRAP:
919 /* Fragment Tag, Hash Mask len, and BSR-priority */
920 if (bp + sizeof(uint16_t) >= ep) break;
921 ND_PRINT((ndo, " tag=%x", EXTRACT_16BITS(bp)));
922 bp += sizeof(uint16_t);
924 ND_PRINT((ndo, " hashmlen=%d", bp[0]));
925 if (bp + 1 >= ep) break;
926 ND_PRINT((ndo, " BSRprio=%d", bp[1]));
929 /* Encoded-Unicast-BSR-Address */
931 ND_PRINT((ndo, " BSR="));
932 if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
933 ND_PRINT((ndo, "..."));
938 for (i = 0; bp < ep; i++) {
939 /* Encoded-Group Address */
940 ND_PRINT((ndo, " (group%d: ", i));
941 if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0))
943 ND_PRINT((ndo, "...)"));
948 /* RP-Count, Frag RP-Cnt, and rsvd */
950 ND_PRINT((ndo, "...)"));
953 ND_PRINT((ndo, " RPcnt=%d", bp[0]));
955 ND_PRINT((ndo, "...)"));
958 ND_PRINT((ndo, " FRPcnt=%d", frpcnt = bp[1]));
961 for (j = 0; j < frpcnt && bp < ep; j++) {
963 ND_PRINT((ndo, " RP%d=", j));
964 if ((advance = pimv2_addr_print(ndo, bp,
967 ND_PRINT((ndo, "...)"));
973 ND_PRINT((ndo, "...)"));
976 ND_PRINT((ndo, ",holdtime="));
977 relts_print(ndo, EXTRACT_16BITS(bp));
979 ND_PRINT((ndo, "...)"));
982 ND_PRINT((ndo, ",prio=%d", bp[2]));
985 ND_PRINT((ndo, ")"));
990 case PIMV2_TYPE_ASSERT:
994 ND_PRINT((ndo, " group="));
995 if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
996 ND_PRINT((ndo, "..."));
999 bp += advance; len -= advance;
1002 ND_PRINT((ndo, " src="));
1003 if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
1004 ND_PRINT((ndo, "..."));
1007 bp += advance; len -= advance;
1011 ND_PRINT((ndo, " RPT"));
1012 ND_PRINT((ndo, " pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff));
1013 ND_PRINT((ndo, " metric=%u", EXTRACT_32BITS(&bp[4])));
1016 case PIMV2_TYPE_CANDIDATE_RP:
1021 /* Prefix-Cnt, Priority, and Holdtime */
1022 if (bp >= ep) break;
1023 ND_PRINT((ndo, " prefix-cnt=%d", bp[0]));
1025 if (bp + 1 >= ep) break;
1026 ND_PRINT((ndo, " prio=%d", bp[1]));
1027 if (bp + 3 >= ep) break;
1028 ND_PRINT((ndo, " holdtime="));
1029 relts_print(ndo, EXTRACT_16BITS(&bp[2]));
1032 /* Encoded-Unicast-RP-Address */
1033 if (bp >= ep) break;
1034 ND_PRINT((ndo, " RP="));
1035 if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
1036 ND_PRINT((ndo, "..."));
1041 /* Encoded-Group Addresses */
1042 for (i = 0; i < pfxcnt && bp < ep; i++) {
1043 ND_PRINT((ndo, " Group%d=", i));
1044 if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0))
1046 ND_PRINT((ndo, "..."));
1054 case PIMV2_TYPE_PRUNE_REFRESH:
1055 ND_PRINT((ndo, " src="));
1056 if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
1057 ND_PRINT((ndo, "..."));
1061 ND_PRINT((ndo, " grp="));
1062 if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
1063 ND_PRINT((ndo, "..."));
1067 ND_PRINT((ndo, " forwarder="));
1068 if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
1069 ND_PRINT((ndo, "..."));
1073 ND_TCHECK2(bp[0], 2);
1074 ND_PRINT((ndo, " TUNR "));
1075 relts_print(ndo, EXTRACT_16BITS(bp));
1080 ND_PRINT((ndo, " [type %d]", PIM_TYPE(pim->pim_typever)));
1087 ND_PRINT((ndo, "[|pim]"));
1092 * c-style: whitesmith