2 * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
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.
23 static const char rcsid
[] =
24 "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.55 2001-06-15 22:17:32 fenner Exp $";
35 #include <sys/param.h>
37 #include <sys/types.h>
38 #include <sys/socket.h>
41 #include <netinet/in.h>
43 #include <arpa/inet.h>
51 #include "interface.h"
52 #include "addrtoname.h"
57 static const char *get_rtpref(u_int
);
58 static const char *get_lifetime(u_int32_t
);
59 static void print_lladdr(const u_char
*, size_t);
60 void icmp6_opt_print(const u_char
*, int);
61 void mld6_print(const u_char
*);
62 static struct udphdr
*get_upperlayer(u_char
*, int *);
63 static void dnsname_print(const u_char
*, const u_char
*);
64 void icmp6_nodeinfo_print(int, const u_char
*, const u_char
*);
65 void icmp6_rrenum_print(int, const u_char
*, const u_char
*);
68 #define abs(a) ((0 < (a)) ? (a) : -(a))
74 static const char *rtpref_str
[] = {
81 return rtpref_str
[((v
& ND_RA_FLAG_RTPREF_MASK
) >> 3) & 0xff];
85 get_lifetime(u_int32_t v
)
89 if (v
== (u_int32_t
)~0UL)
92 snprintf(buf
, sizeof(buf
), "%u", v
);
98 print_lladdr(const u_int8_t
*p
, size_t l
)
100 const u_int8_t
*ep
, *q
;
104 while (l
> 0 && q
< ep
) {
107 printf("%02x", *q
++);
113 icmp6_print(const u_char
*bp
, const u_char
*bp2
)
115 const struct icmp6_hdr
*dp
;
116 const struct ip6_hdr
*ip
;
118 const struct ip6_hdr
*oip
;
119 const struct udphdr
*ouh
;
125 dp
= (struct icmp6_hdr
*)bp
;
126 ip
= (struct ip6_hdr
*)bp2
;
127 oip
= (struct ip6_hdr
*)(dp
+ 1);
129 /* 'ep' points to the end of available data. */
132 icmp6len
= (ntohs(ip
->ip6_plen
) + sizeof(struct ip6_hdr
) -
134 else /* XXX: jumbo payload case... */
135 icmp6len
= snapend
- bp
;
137 TCHECK(dp
->icmp6_code
);
138 switch (dp
->icmp6_type
) {
139 case ICMP6_DST_UNREACH
:
140 TCHECK(oip
->ip6_dst
);
141 switch (dp
->icmp6_code
) {
142 case ICMP6_DST_UNREACH_NOROUTE
:
143 printf("icmp6: %s unreachable route",
144 ip6addr_string(&oip
->ip6_dst
));
146 case ICMP6_DST_UNREACH_ADMIN
:
147 printf("icmp6: %s unreachable prohibited",
148 ip6addr_string(&oip
->ip6_dst
));
150 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
151 printf("icmp6: %s beyond scope of source address %s",
152 ip6addr_string(&oip
->ip6_dst
),
153 ip6addr_string(&oip
->ip6_src
));
155 case ICMP6_DST_UNREACH_ADDR
:
156 printf("icmp6: %s unreachable address",
157 ip6addr_string(&oip
->ip6_dst
));
159 case ICMP6_DST_UNREACH_NOPORT
:
160 if ((ouh
= get_upperlayer((u_char
*)oip
, &prot
))
164 dport
= ntohs(ouh
->uh_dport
);
167 printf("icmp6: %s tcp port %s unreachable",
168 ip6addr_string(&oip
->ip6_dst
),
169 tcpport_string(dport
));
172 printf("icmp6: %s udp port %s unreachable",
173 ip6addr_string(&oip
->ip6_dst
),
174 udpport_string(dport
));
177 printf("icmp6: %s protocol %d port %d unreachable",
178 ip6addr_string(&oip
->ip6_dst
),
179 oip
->ip6_nxt
, dport
);
184 printf("icmp6: %s unreachable code-#%d",
185 ip6addr_string(&oip
->ip6_dst
),
190 case ICMP6_PACKET_TOO_BIG
:
191 TCHECK(dp
->icmp6_mtu
);
192 printf("icmp6: too big %u", (u_int32_t
)ntohl(dp
->icmp6_mtu
));
194 case ICMP6_TIME_EXCEEDED
:
195 TCHECK(oip
->ip6_dst
);
196 switch (dp
->icmp6_code
) {
197 case ICMP6_TIME_EXCEED_TRANSIT
:
198 printf("icmp6: time exceeded in-transit for %s",
199 ip6addr_string(&oip
->ip6_dst
));
201 case ICMP6_TIME_EXCEED_REASSEMBLY
:
202 printf("icmp6: ip6 reassembly time exceeded");
205 printf("icmp6: time exceeded code-#%d",
210 case ICMP6_PARAM_PROB
:
211 TCHECK(oip
->ip6_dst
);
212 switch (dp
->icmp6_code
) {
213 case ICMP6_PARAMPROB_HEADER
:
214 printf("icmp6: parameter problem errorneous - octet %u",
215 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
217 case ICMP6_PARAMPROB_NEXTHEADER
:
218 printf("icmp6: parameter problem next header - octet %u",
219 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
221 case ICMP6_PARAMPROB_OPTION
:
222 printf("icmp6: parameter problem option - octet %u",
223 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
226 printf("icmp6: parameter problem code-#%d",
231 case ICMP6_ECHO_REQUEST
:
232 printf("icmp6: echo request");
234 case ICMP6_ECHO_REPLY
:
235 printf("icmp6: echo reply");
237 case ICMP6_MEMBERSHIP_QUERY
:
238 printf("icmp6: multicast listener query ");
239 mld6_print((const u_char
*)dp
);
241 case ICMP6_MEMBERSHIP_REPORT
:
242 printf("icmp6: multicast listener report ");
243 mld6_print((const u_char
*)dp
);
245 case ICMP6_MEMBERSHIP_REDUCTION
:
246 printf("icmp6: multicast listener done ");
247 mld6_print((const u_char
*)dp
);
249 case ND_ROUTER_SOLICIT
:
250 printf("icmp6: router solicitation ");
253 icmp6_opt_print((const u_char
*)dp
+ RTSOLLEN
,
254 icmp6len
- RTSOLLEN
);
257 case ND_ROUTER_ADVERT
:
258 printf("icmp6: router advertisement");
260 struct nd_router_advert
*p
;
262 p
= (struct nd_router_advert
*)dp
;
263 TCHECK(p
->nd_ra_retransmit
);
264 printf("(chlim=%d, ", (int)p
->nd_ra_curhoplimit
);
265 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_MANAGED
)
267 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_OTHER
)
269 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_HOME_AGENT
)
272 if ((p
->nd_ra_flags_reserved
& ~ND_RA_FLAG_RTPREF_MASK
)
277 get_rtpref(p
->nd_ra_flags_reserved
));
279 printf("router_ltime=%d, ", ntohs(p
->nd_ra_router_lifetime
));
280 printf("reachable_time=%u, ",
281 (u_int32_t
)ntohl(p
->nd_ra_reachable
));
282 printf("retrans_time=%u)",
283 (u_int32_t
)ntohl(p
->nd_ra_retransmit
));
285 icmp6_opt_print((const u_char
*)dp
+ RTADVLEN
,
286 icmp6len
- RTADVLEN
);
289 case ND_NEIGHBOR_SOLICIT
:
291 struct nd_neighbor_solicit
*p
;
292 p
= (struct nd_neighbor_solicit
*)dp
;
293 TCHECK(p
->nd_ns_target
);
294 printf("icmp6: neighbor sol: who has %s",
295 ip6addr_string(&p
->nd_ns_target
));
298 icmp6_opt_print((const u_char
*)dp
+ NDSOLLEN
,
299 icmp6len
- NDSOLLEN
);
303 case ND_NEIGHBOR_ADVERT
:
305 struct nd_neighbor_advert
*p
;
307 p
= (struct nd_neighbor_advert
*)dp
;
308 TCHECK(p
->nd_na_target
);
309 printf("icmp6: neighbor adv: tgt is %s",
310 ip6addr_string(&p
->nd_na_target
));
312 #define ND_NA_FLAG_ALL \
313 (ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
314 /* we don't need ntohl() here. see advanced-api-04. */
315 if (p
->nd_na_flags_reserved
& ND_NA_FLAG_ALL
) {
316 #undef ND_NA_FLAG_ALL
319 flags
= p
->nd_na_flags_reserved
;
321 if (flags
& ND_NA_FLAG_ROUTER
)
323 if (flags
& ND_NA_FLAG_SOLICITED
)
325 if (flags
& ND_NA_FLAG_OVERRIDE
)
330 icmp6_opt_print((const u_char
*)dp
+ NDADVLEN
,
331 icmp6len
- NDADVLEN
);
337 #define RDR(i) ((struct nd_redirect *)(i))
338 TCHECK(RDR(dp
)->nd_rd_dst
);
339 printf("icmp6: redirect %s",
340 getname6((const u_char
*)&RDR(dp
)->nd_rd_dst
));
342 getname6((const u_char
*)&RDR(dp
)->nd_rd_target
));
343 #define REDIRECTLEN 40
345 icmp6_opt_print((const u_char
*)dp
+ REDIRECTLEN
,
346 icmp6len
- REDIRECTLEN
);
351 case ICMP6_ROUTER_RENUMBERING
:
352 icmp6_rrenum_print(icmp6len
, bp
, ep
);
356 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
359 printf("icmp6: type-#%d", dp
->icmp6_type
);
364 fputs("[|icmp6]", stdout
);
367 static struct udphdr
*
368 get_upperlayer(u_char
*bp
, int *prot
)
371 struct ip6_hdr
*ip6
= (struct ip6_hdr
*)bp
;
374 struct ip6_frag
*fragh
;
378 /* 'ep' points to the end of available data. */
381 if (TTEST(ip6
->ip6_nxt
) == 0)
385 hlen
= sizeof(struct ip6_hdr
);
387 while (bp
< snapend
) {
393 uh
= (struct udphdr
*)bp
;
394 if (TTEST(uh
->uh_dport
)) {
402 case IPPROTO_HOPOPTS
:
403 case IPPROTO_DSTOPTS
:
404 case IPPROTO_ROUTING
:
405 hbh
= (struct ip6_hbh
*)bp
;
406 if (TTEST(hbh
->ip6h_len
) == 0)
409 hlen
= (hbh
->ip6h_len
+ 1) << 3;
412 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
413 fragh
= (struct ip6_frag
*)bp
;
414 if (TTEST(fragh
->ip6f_offlg
) == 0)
416 /* fragments with non-zero offset are meaningless */
417 if ((fragh
->ip6f_offlg
& IP6F_OFF_MASK
) != 0)
419 nh
= fragh
->ip6f_nxt
;
420 hlen
= sizeof(struct ip6_frag
);
424 ah
= (struct ah
*)bp
;
425 if (TTEST(ah
->ah_len
) == 0)
428 hlen
= (ah
->ah_len
+ 2) << 2;
431 default: /* unknown or undecodable header */
432 *prot
= nh
; /* meaningless, but set here anyway */
437 return(NULL
); /* should be notreached, though */
441 icmp6_opt_print(const u_char
*bp
, int resid
)
443 const struct nd_opt_hdr
*op
;
444 const struct nd_opt_hdr
*opl
; /* why there's no struct? */
445 const struct nd_opt_prefix_info
*opp
;
446 const struct icmp6_opts_redirect
*opr
;
447 const struct nd_opt_mtu
*opm
;
448 const struct nd_opt_advinterval
*opa
;
449 const struct nd_opt_route_info
*opri
;
450 const u_char
*cp
, *ep
;
451 struct in6_addr in6
, *in6p
;
454 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
457 /* 'ep' points to the end of available data. */
461 op
= (struct nd_opt_hdr
*)cp
;
463 ECHECK(op
->nd_opt_len
);
466 if (op
->nd_opt_len
== 0)
468 if (cp
+ (op
->nd_opt_len
<< 3) > ep
)
471 switch (op
->nd_opt_type
) {
472 case ND_OPT_SOURCE_LINKADDR
:
473 opl
= (struct nd_opt_hdr
*)op
;
474 printf("(src lladdr: ");
475 l
= (op
->nd_opt_len
<< 3) - 2;
476 print_lladdr(cp
+ 2, l
);
480 case ND_OPT_TARGET_LINKADDR
:
481 opl
= (struct nd_opt_hdr
*)op
;
482 printf("(tgt lladdr: ");
483 l
= (op
->nd_opt_len
<< 3) - 2;
484 print_lladdr(cp
+ 2, l
);
488 case ND_OPT_PREFIX_INFORMATION
:
489 opp
= (struct nd_opt_prefix_info
*)op
;
490 TCHECK(opp
->nd_opt_pi_prefix
);
491 printf("(prefix info: "); /*)*/
492 if (op
->nd_opt_len
!= 4) {
498 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ONLINK
)
500 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_AUTO
)
502 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ROUTER
)
504 if (opp
->nd_opt_pi_flags_reserved
)
506 printf("valid_ltime=%s,",
507 get_lifetime((u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
)));
508 printf("preferred_ltime=%s,",
509 get_lifetime((u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
)));
510 printf("prefix=%s/%d",
511 ip6addr_string(&opp
->nd_opt_pi_prefix
),
512 opp
->nd_opt_pi_prefix_len
);
513 if (opp
->nd_opt_pi_len
!= 4)
518 case ND_OPT_REDIRECTED_HEADER
:
519 opr
= (struct icmp6_opts_redirect
*)op
;
520 printf("(redirect)");
524 opm
= (struct nd_opt_mtu
*)op
;
525 TCHECK(opm
->nd_opt_mtu_mtu
);
526 printf("(mtu:"); /*)*/
527 if (op
->nd_opt_len
!= 1) {
533 printf(" mtu=%u", (u_int32_t
)ntohl(opm
->nd_opt_mtu_mtu
));
534 if (opm
->nd_opt_mtu_len
!= 1)
538 case ND_OPT_ADVINTERVAL
:
539 opa
= (struct nd_opt_advinterval
*)op
;
540 TCHECK(opa
->nd_opt_adv_interval
);
541 printf("(advint:"); /*)*/
543 (u_int32_t
)ntohl(opa
->nd_opt_adv_interval
));
547 case ND_OPT_ROUTE_INFO
:
548 opri
= (struct nd_opt_route_info
*)op
;
549 TCHECK(opri
->nd_opt_rti_lifetime
);
550 memset(&in6
, 0, sizeof(in6
));
551 in6p
= (struct in6_addr
*)(opri
+ 1);
552 switch (op
->nd_opt_len
) {
557 memcpy(&in6
, opri
+ 1, 8);
561 memcpy(&in6
, opri
+ 1, sizeof(in6
));
566 printf("(rtinfo:"); /*)*/
567 printf(" %s/%u", ip6addr_string(&in6
),
568 opri
->nd_opt_rti_prefixlen
);
569 printf(", pref=%s", get_rtpref(opri
->nd_opt_rti_flags
));
570 printf(", lifetime=%s",
571 get_lifetime((u_int32_t
)ntohl(opri
->nd_opt_rti_lifetime
)));
576 printf("(unknwon opt_type=%d, opt_len=%d)",
577 op
->nd_opt_type
, op
->nd_opt_len
);
581 cp
+= op
->nd_opt_len
<< 3;
582 resid
-= op
->nd_opt_len
<< 3;
587 fputs("[ndp opt]", stdout
);
593 mld6_print(const u_char
*bp
)
595 struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
598 /* 'ep' points to the end of available data. */
601 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
604 printf("max resp delay: %d ", ntohs(mp
->mld6_maxdelay
));
605 printf("addr: %s", ip6addr_string(&mp
->mld6_addr
));
609 dnsname_print(const u_char
*cp
, const u_char
*ep
)
613 /* DNS name decoding - no decompression */
622 while (i
-- && cp
< ep
) {
626 if (cp
+ 1 < ep
&& *cp
)
632 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
645 icmp6_nodeinfo_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
647 struct icmp6_nodeinfo
*ni6
;
648 struct icmp6_hdr
*dp
;
653 dp
= (struct icmp6_hdr
*)bp
;
654 ni6
= (struct icmp6_nodeinfo
*)bp
;
657 switch (ni6
->ni_type
) {
659 if (siz
== sizeof(*dp
) + 4) {
660 /* KAME who-are-you */
661 printf("icmp6: who-are-you request");
664 printf("icmp6: node information query");
666 TCHECK2(*dp
, sizeof(*ni6
));
667 ni6
= (struct icmp6_nodeinfo
*)dp
;
669 switch (ntohs(ni6
->ni_qtype
)) {
673 case NI_QTYPE_SUPTYPES
:
674 printf("supported qtypes");
675 i
= ntohs(ni6
->ni_flags
);
677 printf(" [%s]", (i
& 0x01) ? "C" : "");
683 case NI_QTYPE_NODEADDR
:
684 printf("node addresses");
688 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
689 printf(" [%s%s%s%s%s%s]",
690 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
691 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
692 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
693 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
694 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
695 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "");
702 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
703 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
704 if (siz
!= sizeof(*ni6
))
706 printf(", invalid len");
713 /* XXX backward compat, icmp-name-lookup-03 */
714 if (siz
== sizeof(*ni6
)) {
715 printf(", 03 draft");
721 switch (ni6
->ni_code
) {
722 case ICMP6_NI_SUBJ_IPV6
:
724 sizeof(*ni6
) + sizeof(struct in6_addr
)))
726 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
728 printf(", invalid subject len");
731 printf(", subject=%s",
732 getname6((const u_char
*)(ni6
+ 1)));
734 case ICMP6_NI_SUBJ_FQDN
:
735 printf(", subject=DNS name");
736 cp
= (const u_char
*)(ni6
+ 1);
737 if (cp
[0] == ep
- cp
- 1) {
738 /* icmp-name-lookup-03, pascal string */
740 printf(", 03 draft");
749 dnsname_print(cp
, ep
);
751 case ICMP6_NI_SUBJ_IPV4
:
752 if (!TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
754 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
756 printf(", invalid subject len");
759 printf(", subject=%s",
760 getname((const u_char
*)(ni6
+ 1)));
763 printf(", unknown subject");
772 if (icmp6len
> siz
) {
773 printf("[|icmp6: node information reply]");
779 ni6
= (struct icmp6_nodeinfo
*)dp
;
780 printf("icmp6: node information reply");
782 switch (ni6
->ni_code
) {
783 case ICMP6_NI_SUCCESS
:
789 case ICMP6_NI_REFUSED
:
792 if (siz
!= sizeof(*ni6
))
794 printf(", invalid length");
796 case ICMP6_NI_UNKNOWN
:
799 if (siz
!= sizeof(*ni6
))
801 printf(", invalid length");
805 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
811 switch (ntohs(ni6
->ni_qtype
)) {
816 if (siz
!= sizeof(*ni6
))
818 printf(", invalid length");
820 case NI_QTYPE_SUPTYPES
:
823 printf("supported qtypes");
824 i
= ntohs(ni6
->ni_flags
);
826 printf(" [%s]", (i
& 0x01) ? "C" : "");
832 cp
= (const u_char
*)(ni6
+ 1) + 4;
833 if (cp
[0] == ep
- cp
- 1) {
834 /* icmp-name-lookup-03, pascal string */
836 printf(", 03 draft");
845 dnsname_print(cp
, ep
);
846 if ((ntohs(ni6
->ni_flags
) & 0x01) != 0)
847 printf(" [TTL=%u]", *(u_int32_t
*)(ni6
+ 1));
849 case NI_QTYPE_NODEADDR
:
852 printf("node addresses");
855 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
857 printf(" %s", getname6(bp
+ i
));
858 i
+= sizeof(struct in6_addr
);
859 printf("(%d)", (int32_t)ntohl(*(int32_t *)(bp
+ i
)));
860 i
+= sizeof(int32_t);
865 printf(" [%s%s%s%s%s%s%s]",
866 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
867 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
868 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
869 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
870 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
871 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
872 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : "");
888 fputs("[|icmp6]", stdout
);
892 icmp6_rrenum_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
894 struct icmp6_router_renum
*rr6
;
895 struct icmp6_hdr
*dp
;
898 struct rr_pco_match
*match
;
899 struct rr_pco_use
*use
;
900 char hbuf
[NI_MAXHOST
];
903 dp
= (struct icmp6_hdr
*)bp
;
904 rr6
= (struct icmp6_router_renum
*)bp
;
906 cp
= (const char *)(rr6
+ 1);
908 TCHECK(rr6
->rr_reserved
);
909 switch (rr6
->rr_code
) {
910 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
911 printf("router renum: command");
913 case ICMP6_ROUTER_RENUMBERING_RESULT
:
914 printf("router renum: result");
916 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
917 printf("router renum: sequence number reset");
920 printf("router renum: code-#%d", rr6
->rr_code
);
924 printf(", seq=%u", (u_int32_t
)ntohl(rr6
->rr_seqnum
));
927 #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
930 printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
931 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
932 F(ICMP6_RR_FLAGS_FORCEAPPLY
, "A"),
933 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
934 F(ICMP6_RR_FLAGS_PREVDONE
, "P"));
936 printf("seg=%u,", rr6
->rr_segnum
);
937 printf("maxdelay=%u", rr6
->rr_maxdelay
);
938 if (rr6
->rr_reserved
)
939 printf("rsvd=0x%x", (u_int16_t
)ntohs(rr6
->rr_reserved
));
945 if (rr6
->rr_code
== ICMP6_ROUTER_RENUMBERING_COMMAND
) {
946 match
= (struct rr_pco_match
*)cp
;
947 cp
= (const char *)(match
+ 1);
949 TCHECK(match
->rpm_prefix
);
955 printf("match("); /*)*/
956 switch (match
->rpm_code
) {
957 case RPM_PCO_ADD
: printf("add"); break;
958 case RPM_PCO_CHANGE
: printf("change"); break;
959 case RPM_PCO_SETGLOBAL
: printf("setglobal"); break;
960 default: printf("#%u", match
->rpm_code
); break;
964 printf(",ord=%u", match
->rpm_ordinal
);
965 printf(",min=%u", match
->rpm_minlen
);
966 printf(",max=%u", match
->rpm_maxlen
);
968 if (inet_ntop(AF_INET6
, &match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
969 printf(",%s/%u", hbuf
, match
->rpm_matchlen
);
971 printf(",?/%u", match
->rpm_matchlen
);
975 n
= match
->rpm_len
- 3;
980 use
= (struct rr_pco_use
*)cp
;
981 cp
= (const char *)(use
+ 1);
983 TCHECK(use
->rpu_prefix
);
989 printf("use("); /*)*/
990 if (use
->rpu_flags
) {
991 #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
993 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
994 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P"));
998 printf("mask=0x%x,", use
->rpu_ramask
);
999 printf("raflags=0x%x,", use
->rpu_raflags
);
1000 if (~use
->rpu_vltime
== 0)
1001 printf("vltime=infty,");
1003 printf("vltime=%u,",
1004 (u_int32_t
)ntohl(use
->rpu_vltime
));
1005 if (~use
->rpu_pltime
== 0)
1006 printf("pltime=infty,");
1008 printf("pltime=%u,",
1009 (u_int32_t
)ntohl(use
->rpu_pltime
));
1011 if (inet_ntop(AF_INET6
, &use
->rpu_prefix
, hbuf
,
1013 printf("%s/%u/%u", hbuf
, use
->rpu_uselen
,
1016 printf("?/%u/%u", use
->rpu_uselen
,
1026 fputs("[|icmp6]", stdout
);