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.64 2002-08-06 04:42:05 guy Exp $";
33 #include <tcpdump-stdinc.h>
41 #include "interface.h"
42 #include "addrtoname.h"
47 static const char *get_rtpref(u_int
);
48 static const char *get_lifetime(u_int32_t
);
49 static void print_lladdr(const u_char
*, size_t);
50 void icmp6_opt_print(const u_char
*, int);
51 void mld6_print(const u_char
*);
52 static struct udphdr
*get_upperlayer(u_char
*, int *);
53 static void dnsname_print(const u_char
*, const u_char
*);
54 void icmp6_nodeinfo_print(int, const u_char
*, const u_char
*);
55 void icmp6_rrenum_print(int, const u_char
*, const u_char
*);
58 #define abs(a) ((0 < (a)) ? (a) : -(a))
64 static const char *rtpref_str
[] = {
71 return rtpref_str
[((v
& ND_RA_FLAG_RTPREF_MASK
) >> 3) & 0xff];
75 get_lifetime(u_int32_t v
)
79 if (v
== (u_int32_t
)~0UL)
82 snprintf(buf
, sizeof(buf
), "%u", v
);
88 print_lladdr(const u_int8_t
*p
, size_t l
)
90 const u_int8_t
*ep
, *q
;
94 while (l
> 0 && q
< ep
) {
103 icmp6_print(const u_char
*bp
, const u_char
*bp2
)
105 const struct icmp6_hdr
*dp
;
106 const struct ip6_hdr
*ip
;
108 const struct ip6_hdr
*oip
;
109 const struct udphdr
*ouh
;
115 dp
= (struct icmp6_hdr
*)bp
;
116 ip
= (struct ip6_hdr
*)bp2
;
117 oip
= (struct ip6_hdr
*)(dp
+ 1);
119 /* 'ep' points to the end of available data. */
122 icmp6len
= (ntohs(ip
->ip6_plen
) + sizeof(struct ip6_hdr
) -
124 else /* XXX: jumbo payload case... */
125 icmp6len
= snapend
- bp
;
127 TCHECK(dp
->icmp6_code
);
128 switch (dp
->icmp6_type
) {
129 case ICMP6_DST_UNREACH
:
130 TCHECK(oip
->ip6_dst
);
131 switch (dp
->icmp6_code
) {
132 case ICMP6_DST_UNREACH_NOROUTE
:
133 printf("icmp6: %s unreachable route",
134 ip6addr_string(&oip
->ip6_dst
));
136 case ICMP6_DST_UNREACH_ADMIN
:
137 printf("icmp6: %s unreachable prohibited",
138 ip6addr_string(&oip
->ip6_dst
));
140 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
141 printf("icmp6: %s beyond scope of source address %s",
142 ip6addr_string(&oip
->ip6_dst
),
143 ip6addr_string(&oip
->ip6_src
));
145 case ICMP6_DST_UNREACH_ADDR
:
146 printf("icmp6: %s unreachable address",
147 ip6addr_string(&oip
->ip6_dst
));
149 case ICMP6_DST_UNREACH_NOPORT
:
150 if ((ouh
= get_upperlayer((u_char
*)oip
, &prot
))
154 dport
= ntohs(ouh
->uh_dport
);
157 printf("icmp6: %s tcp port %s unreachable",
158 ip6addr_string(&oip
->ip6_dst
),
159 tcpport_string(dport
));
162 printf("icmp6: %s udp port %s unreachable",
163 ip6addr_string(&oip
->ip6_dst
),
164 udpport_string(dport
));
167 printf("icmp6: %s protocol %d port %d unreachable",
168 ip6addr_string(&oip
->ip6_dst
),
169 oip
->ip6_nxt
, dport
);
174 printf("icmp6: %s unreachable code-#%d",
175 ip6addr_string(&oip
->ip6_dst
),
180 case ICMP6_PACKET_TOO_BIG
:
181 TCHECK(dp
->icmp6_mtu
);
182 printf("icmp6: too big %u", (u_int32_t
)ntohl(dp
->icmp6_mtu
));
184 case ICMP6_TIME_EXCEEDED
:
185 TCHECK(oip
->ip6_dst
);
186 switch (dp
->icmp6_code
) {
187 case ICMP6_TIME_EXCEED_TRANSIT
:
188 printf("icmp6: time exceeded in-transit for %s",
189 ip6addr_string(&oip
->ip6_dst
));
191 case ICMP6_TIME_EXCEED_REASSEMBLY
:
192 printf("icmp6: ip6 reassembly time exceeded");
195 printf("icmp6: time exceeded code-#%d",
200 case ICMP6_PARAM_PROB
:
201 TCHECK(oip
->ip6_dst
);
202 switch (dp
->icmp6_code
) {
203 case ICMP6_PARAMPROB_HEADER
:
204 printf("icmp6: parameter problem errorneous - octet %u",
205 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
207 case ICMP6_PARAMPROB_NEXTHEADER
:
208 printf("icmp6: parameter problem next header - octet %u",
209 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
211 case ICMP6_PARAMPROB_OPTION
:
212 printf("icmp6: parameter problem option - octet %u",
213 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
216 printf("icmp6: parameter problem code-#%d",
221 case ICMP6_ECHO_REQUEST
:
222 printf("icmp6: echo request");
224 case ICMP6_ECHO_REPLY
:
225 printf("icmp6: echo reply");
227 case ICMP6_MEMBERSHIP_QUERY
:
228 printf("icmp6: multicast listener query ");
229 mld6_print((const u_char
*)dp
);
231 case ICMP6_MEMBERSHIP_REPORT
:
232 printf("icmp6: multicast listener report ");
233 mld6_print((const u_char
*)dp
);
235 case ICMP6_MEMBERSHIP_REDUCTION
:
236 printf("icmp6: multicast listener done ");
237 mld6_print((const u_char
*)dp
);
239 case ND_ROUTER_SOLICIT
:
240 printf("icmp6: router solicitation ");
243 icmp6_opt_print((const u_char
*)dp
+ RTSOLLEN
,
244 icmp6len
- RTSOLLEN
);
247 case ND_ROUTER_ADVERT
:
248 printf("icmp6: router advertisement");
250 struct nd_router_advert
*p
;
252 p
= (struct nd_router_advert
*)dp
;
253 TCHECK(p
->nd_ra_retransmit
);
254 printf("(chlim=%d, ", (int)p
->nd_ra_curhoplimit
);
255 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_MANAGED
)
257 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_OTHER
)
259 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_HOME_AGENT
)
262 if ((p
->nd_ra_flags_reserved
& ~ND_RA_FLAG_RTPREF_MASK
)
267 get_rtpref(p
->nd_ra_flags_reserved
));
269 printf("router_ltime=%d, ", ntohs(p
->nd_ra_router_lifetime
));
270 printf("reachable_time=%u, ",
271 (u_int32_t
)ntohl(p
->nd_ra_reachable
));
272 printf("retrans_time=%u)",
273 (u_int32_t
)ntohl(p
->nd_ra_retransmit
));
275 icmp6_opt_print((const u_char
*)dp
+ RTADVLEN
,
276 icmp6len
- RTADVLEN
);
279 case ND_NEIGHBOR_SOLICIT
:
281 struct nd_neighbor_solicit
*p
;
282 p
= (struct nd_neighbor_solicit
*)dp
;
283 TCHECK(p
->nd_ns_target
);
284 printf("icmp6: neighbor sol: who has %s",
285 ip6addr_string(&p
->nd_ns_target
));
288 icmp6_opt_print((const u_char
*)dp
+ NDSOLLEN
,
289 icmp6len
- NDSOLLEN
);
293 case ND_NEIGHBOR_ADVERT
:
295 struct nd_neighbor_advert
*p
;
297 p
= (struct nd_neighbor_advert
*)dp
;
298 TCHECK(p
->nd_na_target
);
299 printf("icmp6: neighbor adv: tgt is %s",
300 ip6addr_string(&p
->nd_na_target
));
302 #define ND_NA_FLAG_ALL \
303 (ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
304 /* we don't need ntohl() here. see advanced-api-04. */
305 if (p
->nd_na_flags_reserved
& ND_NA_FLAG_ALL
) {
306 #undef ND_NA_FLAG_ALL
309 flags
= p
->nd_na_flags_reserved
;
311 if (flags
& ND_NA_FLAG_ROUTER
)
313 if (flags
& ND_NA_FLAG_SOLICITED
)
315 if (flags
& ND_NA_FLAG_OVERRIDE
)
320 icmp6_opt_print((const u_char
*)dp
+ NDADVLEN
,
321 icmp6len
- NDADVLEN
);
327 #define RDR(i) ((struct nd_redirect *)(i))
328 TCHECK(RDR(dp
)->nd_rd_dst
);
329 printf("icmp6: redirect %s",
330 getname6((const u_char
*)&RDR(dp
)->nd_rd_dst
));
332 getname6((const u_char
*)&RDR(dp
)->nd_rd_target
));
333 #define REDIRECTLEN 40
335 icmp6_opt_print((const u_char
*)dp
+ REDIRECTLEN
,
336 icmp6len
- REDIRECTLEN
);
341 case ICMP6_ROUTER_RENUMBERING
:
342 icmp6_rrenum_print(icmp6len
, bp
, ep
);
346 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
348 case ICMP6_HADISCOV_REQUEST
:
349 printf("icmp6: ha discovery request");
351 TCHECK(dp
->icmp6_data16
[0]);
352 printf("(id=%d)", ntohs(dp
->icmp6_data16
[0]));
355 case ICMP6_HADISCOV_REPLY
:
356 printf("icmp6: ha discovery reply");
358 struct in6_addr
*in6
;
362 TCHECK(dp
->icmp6_data16
[0]);
363 printf("(id=%d", ntohs(dp
->icmp6_data16
[0]));
364 cp
= (u_char
*)dp
+ icmp6len
;
365 res
= (u_int32_t
*)(dp
+ 1);
366 in6
= (struct in6_addr
*)(res
+ 2);
367 for (; (u_char
*)in6
< cp
; in6
++) {
369 printf(", %s", ip6addr_string(in6
));
374 case ICMP6_MOBILEPREFIX_SOLICIT
:
375 printf("icmp6: mobile router solicitation");
377 case ICMP6_MOBILEPREFIX_ADVERT
:
378 printf("icmp6: mobile router advertisement");
381 icmp6_opt_print((const u_char
*)dp
+ MPADVLEN
,
382 icmp6len
- MPADVLEN
);
386 printf("icmp6: type-#%d", dp
->icmp6_type
);
391 fputs("[|icmp6]", stdout
);
394 static struct udphdr
*
395 get_upperlayer(u_char
*bp
, int *prot
)
398 struct ip6_hdr
*ip6
= (struct ip6_hdr
*)bp
;
401 struct ip6_frag
*fragh
;
405 /* 'ep' points to the end of available data. */
408 if (TTEST(ip6
->ip6_nxt
) == 0)
412 hlen
= sizeof(struct ip6_hdr
);
414 while (bp
< snapend
) {
420 uh
= (struct udphdr
*)bp
;
421 if (TTEST(uh
->uh_dport
)) {
429 case IPPROTO_HOPOPTS
:
430 case IPPROTO_DSTOPTS
:
431 case IPPROTO_ROUTING
:
432 hbh
= (struct ip6_hbh
*)bp
;
433 if (TTEST(hbh
->ip6h_len
) == 0)
436 hlen
= (hbh
->ip6h_len
+ 1) << 3;
439 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
440 fragh
= (struct ip6_frag
*)bp
;
441 if (TTEST(fragh
->ip6f_offlg
) == 0)
443 /* fragments with non-zero offset are meaningless */
444 if ((fragh
->ip6f_offlg
& IP6F_OFF_MASK
) != 0)
446 nh
= fragh
->ip6f_nxt
;
447 hlen
= sizeof(struct ip6_frag
);
451 ah
= (struct ah
*)bp
;
452 if (TTEST(ah
->ah_len
) == 0)
455 hlen
= (ah
->ah_len
+ 2) << 2;
458 default: /* unknown or undecodable header */
459 *prot
= nh
; /* meaningless, but set here anyway */
464 return(NULL
); /* should be notreached, though */
468 icmp6_opt_print(const u_char
*bp
, int resid
)
470 const struct nd_opt_hdr
*op
;
471 const struct nd_opt_hdr
*opl
; /* why there's no struct? */
472 const struct nd_opt_prefix_info
*opp
;
473 const struct icmp6_opts_redirect
*opr
;
474 const struct nd_opt_mtu
*opm
;
475 const struct nd_opt_advinterval
*opa
;
476 const struct nd_opt_homeagent_info
*oph
;
477 const struct nd_opt_route_info
*opri
;
478 const u_char
*cp
, *ep
;
479 struct in6_addr in6
, *in6p
;
482 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
485 /* 'ep' points to the end of available data. */
489 op
= (struct nd_opt_hdr
*)cp
;
491 ECHECK(op
->nd_opt_len
);
494 if (op
->nd_opt_len
== 0)
496 if (cp
+ (op
->nd_opt_len
<< 3) > ep
)
499 switch (op
->nd_opt_type
) {
500 case ND_OPT_SOURCE_LINKADDR
:
501 opl
= (struct nd_opt_hdr
*)op
;
502 printf("(src lladdr: ");
503 l
= (op
->nd_opt_len
<< 3) - 2;
504 print_lladdr(cp
+ 2, l
);
508 case ND_OPT_TARGET_LINKADDR
:
509 opl
= (struct nd_opt_hdr
*)op
;
510 printf("(tgt lladdr: ");
511 l
= (op
->nd_opt_len
<< 3) - 2;
512 print_lladdr(cp
+ 2, l
);
516 case ND_OPT_PREFIX_INFORMATION
:
517 opp
= (struct nd_opt_prefix_info
*)op
;
518 TCHECK(opp
->nd_opt_pi_prefix
);
519 printf("(prefix info: "); /*)*/
520 if (op
->nd_opt_len
!= 4) {
526 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ONLINK
)
528 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_AUTO
)
530 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ROUTER
)
532 if (opp
->nd_opt_pi_flags_reserved
)
534 printf("valid_ltime=%s,",
535 get_lifetime((u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
)));
536 printf("preferred_ltime=%s,",
537 get_lifetime((u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
)));
538 printf("prefix=%s/%d",
539 ip6addr_string(&opp
->nd_opt_pi_prefix
),
540 opp
->nd_opt_pi_prefix_len
);
541 if (opp
->nd_opt_pi_len
!= 4)
546 case ND_OPT_REDIRECTED_HEADER
:
547 opr
= (struct icmp6_opts_redirect
*)op
;
548 printf("(redirect)");
552 opm
= (struct nd_opt_mtu
*)op
;
553 TCHECK(opm
->nd_opt_mtu_mtu
);
554 printf("(mtu:"); /*)*/
555 if (op
->nd_opt_len
!= 1) {
561 printf(" mtu=%u", (u_int32_t
)ntohl(opm
->nd_opt_mtu_mtu
));
562 if (opm
->nd_opt_mtu_len
!= 1)
566 case ND_OPT_ADVINTERVAL
:
567 opa
= (struct nd_opt_advinterval
*)op
;
568 TCHECK(opa
->nd_opt_adv_interval
);
569 printf("(advint:"); /*)*/
571 (u_int32_t
)ntohl(opa
->nd_opt_adv_interval
));
575 case ND_OPT_HOMEAGENT_INFO
:
576 oph
= (struct nd_opt_homeagent_info
*)op
;
577 TCHECK(oph
->nd_opt_hai_lifetime
);
578 printf("(ha info:"); /*)*/
579 printf(" pref=%d", ntohs(oph
->nd_opt_hai_preference
));
580 printf(", lifetime=%u", ntohs(oph
->nd_opt_hai_lifetime
));
583 case ND_OPT_ROUTE_INFO
:
584 opri
= (struct nd_opt_route_info
*)op
;
585 TCHECK(opri
->nd_opt_rti_lifetime
);
586 memset(&in6
, 0, sizeof(in6
));
587 in6p
= (struct in6_addr
*)(opri
+ 1);
588 switch (op
->nd_opt_len
) {
593 memcpy(&in6
, opri
+ 1, 8);
597 memcpy(&in6
, opri
+ 1, sizeof(in6
));
602 printf("(rtinfo:"); /*)*/
603 printf(" %s/%u", ip6addr_string(&in6
),
604 opri
->nd_opt_rti_prefixlen
);
605 printf(", pref=%s", get_rtpref(opri
->nd_opt_rti_flags
));
606 printf(", lifetime=%s",
607 get_lifetime((u_int32_t
)ntohl(opri
->nd_opt_rti_lifetime
)));
612 printf("(unknown opt_type=%d, opt_len=%d)",
613 op
->nd_opt_type
, op
->nd_opt_len
);
617 cp
+= op
->nd_opt_len
<< 3;
618 resid
-= op
->nd_opt_len
<< 3;
623 fputs("[ndp opt]", stdout
);
629 mld6_print(const u_char
*bp
)
631 struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
634 /* 'ep' points to the end of available data. */
637 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
640 printf("max resp delay: %d ", ntohs(mp
->mld6_maxdelay
));
641 printf("addr: %s", ip6addr_string(&mp
->mld6_addr
));
645 dnsname_print(const u_char
*cp
, const u_char
*ep
)
649 /* DNS name decoding - no decompression */
658 while (i
-- && cp
< ep
) {
662 if (cp
+ 1 < ep
&& *cp
)
668 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
681 icmp6_nodeinfo_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
683 struct icmp6_nodeinfo
*ni6
;
684 struct icmp6_hdr
*dp
;
689 dp
= (struct icmp6_hdr
*)bp
;
690 ni6
= (struct icmp6_nodeinfo
*)bp
;
693 switch (ni6
->ni_type
) {
695 if (siz
== sizeof(*dp
) + 4) {
696 /* KAME who-are-you */
697 printf("icmp6: who-are-you request");
700 printf("icmp6: node information query");
702 TCHECK2(*dp
, sizeof(*ni6
));
703 ni6
= (struct icmp6_nodeinfo
*)dp
;
705 switch (ntohs(ni6
->ni_qtype
)) {
709 case NI_QTYPE_SUPTYPES
:
710 printf("supported qtypes");
711 i
= ntohs(ni6
->ni_flags
);
713 printf(" [%s]", (i
& 0x01) ? "C" : "");
719 case NI_QTYPE_NODEADDR
:
720 printf("node addresses");
724 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
725 printf(" [%s%s%s%s%s%s]",
726 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
727 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
728 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
729 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
730 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
731 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "");
738 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
739 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
740 if (siz
!= sizeof(*ni6
))
742 printf(", invalid len");
749 /* XXX backward compat, icmp-name-lookup-03 */
750 if (siz
== sizeof(*ni6
)) {
751 printf(", 03 draft");
757 switch (ni6
->ni_code
) {
758 case ICMP6_NI_SUBJ_IPV6
:
760 sizeof(*ni6
) + sizeof(struct in6_addr
)))
762 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
764 printf(", invalid subject len");
767 printf(", subject=%s",
768 getname6((const u_char
*)(ni6
+ 1)));
770 case ICMP6_NI_SUBJ_FQDN
:
771 printf(", subject=DNS name");
772 cp
= (const u_char
*)(ni6
+ 1);
773 if (cp
[0] == ep
- cp
- 1) {
774 /* icmp-name-lookup-03, pascal string */
776 printf(", 03 draft");
785 dnsname_print(cp
, ep
);
787 case ICMP6_NI_SUBJ_IPV4
:
788 if (!TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
790 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
792 printf(", invalid subject len");
795 printf(", subject=%s",
796 getname((const u_char
*)(ni6
+ 1)));
799 printf(", unknown subject");
808 if (icmp6len
> siz
) {
809 printf("[|icmp6: node information reply]");
815 ni6
= (struct icmp6_nodeinfo
*)dp
;
816 printf("icmp6: node information reply");
818 switch (ni6
->ni_code
) {
819 case ICMP6_NI_SUCCESS
:
825 case ICMP6_NI_REFUSED
:
828 if (siz
!= sizeof(*ni6
))
830 printf(", invalid length");
832 case ICMP6_NI_UNKNOWN
:
835 if (siz
!= sizeof(*ni6
))
837 printf(", invalid length");
841 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
847 switch (ntohs(ni6
->ni_qtype
)) {
852 if (siz
!= sizeof(*ni6
))
854 printf(", invalid length");
856 case NI_QTYPE_SUPTYPES
:
859 printf("supported qtypes");
860 i
= ntohs(ni6
->ni_flags
);
862 printf(" [%s]", (i
& 0x01) ? "C" : "");
868 cp
= (const u_char
*)(ni6
+ 1) + 4;
869 if (cp
[0] == ep
- cp
- 1) {
870 /* icmp-name-lookup-03, pascal string */
872 printf(", 03 draft");
881 dnsname_print(cp
, ep
);
882 if ((ntohs(ni6
->ni_flags
) & 0x01) != 0)
883 printf(" [TTL=%u]", *(u_int32_t
*)(ni6
+ 1));
885 case NI_QTYPE_NODEADDR
:
888 printf("node addresses");
891 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
893 printf(" %s", getname6(bp
+ i
));
894 i
+= sizeof(struct in6_addr
);
895 printf("(%d)", (int32_t)ntohl(*(int32_t *)(bp
+ i
)));
896 i
+= sizeof(int32_t);
901 printf(" [%s%s%s%s%s%s%s]",
902 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
903 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
904 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
905 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
906 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
907 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
908 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : "");
924 fputs("[|icmp6]", stdout
);
928 icmp6_rrenum_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
930 struct icmp6_router_renum
*rr6
;
931 struct icmp6_hdr
*dp
;
934 struct rr_pco_match
*match
;
935 struct rr_pco_use
*use
;
936 char hbuf
[NI_MAXHOST
];
939 dp
= (struct icmp6_hdr
*)bp
;
940 rr6
= (struct icmp6_router_renum
*)bp
;
942 cp
= (const char *)(rr6
+ 1);
944 TCHECK(rr6
->rr_reserved
);
945 switch (rr6
->rr_code
) {
946 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
947 printf("router renum: command");
949 case ICMP6_ROUTER_RENUMBERING_RESULT
:
950 printf("router renum: result");
952 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
953 printf("router renum: sequence number reset");
956 printf("router renum: code-#%d", rr6
->rr_code
);
960 printf(", seq=%u", (u_int32_t
)ntohl(rr6
->rr_seqnum
));
963 #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
966 printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
967 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
968 F(ICMP6_RR_FLAGS_FORCEAPPLY
, "A"),
969 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
970 F(ICMP6_RR_FLAGS_PREVDONE
, "P"));
972 printf("seg=%u,", rr6
->rr_segnum
);
973 printf("maxdelay=%u", rr6
->rr_maxdelay
);
974 if (rr6
->rr_reserved
)
975 printf("rsvd=0x%x", (u_int16_t
)ntohs(rr6
->rr_reserved
));
981 if (rr6
->rr_code
== ICMP6_ROUTER_RENUMBERING_COMMAND
) {
982 match
= (struct rr_pco_match
*)cp
;
983 cp
= (const char *)(match
+ 1);
985 TCHECK(match
->rpm_prefix
);
991 printf("match("); /*)*/
992 switch (match
->rpm_code
) {
993 case RPM_PCO_ADD
: printf("add"); break;
994 case RPM_PCO_CHANGE
: printf("change"); break;
995 case RPM_PCO_SETGLOBAL
: printf("setglobal"); break;
996 default: printf("#%u", match
->rpm_code
); break;
1000 printf(",ord=%u", match
->rpm_ordinal
);
1001 printf(",min=%u", match
->rpm_minlen
);
1002 printf(",max=%u", match
->rpm_maxlen
);
1004 if (inet_ntop(AF_INET6
, &match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
1005 printf(",%s/%u", hbuf
, match
->rpm_matchlen
);
1007 printf(",?/%u", match
->rpm_matchlen
);
1011 n
= match
->rpm_len
- 3;
1016 use
= (struct rr_pco_use
*)cp
;
1017 cp
= (const char *)(use
+ 1);
1019 TCHECK(use
->rpu_prefix
);
1025 printf("use("); /*)*/
1026 if (use
->rpu_flags
) {
1027 #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
1029 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
1030 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P"));
1034 printf("mask=0x%x,", use
->rpu_ramask
);
1035 printf("raflags=0x%x,", use
->rpu_raflags
);
1036 if (~use
->rpu_vltime
== 0)
1037 printf("vltime=infty,");
1039 printf("vltime=%u,",
1040 (u_int32_t
)ntohl(use
->rpu_vltime
));
1041 if (~use
->rpu_pltime
== 0)
1042 printf("pltime=infty,");
1044 printf("pltime=%u,",
1045 (u_int32_t
)ntohl(use
->rpu_pltime
));
1047 if (inet_ntop(AF_INET6
, &use
->rpu_prefix
, hbuf
,
1049 printf("%s/%u/%u", hbuf
, use
->rpu_uselen
,
1052 printf("?/%u/%u", use
->rpu_uselen
,
1062 fputs("[|icmp6]", stdout
);