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.69 2003-03-13 07:36:56 guy Exp $";
33 #include <tcpdump-stdinc.h>
41 #include "interface.h"
42 #include "addrtoname.h"
48 static const char *get_rtpref(u_int
);
49 static const char *get_lifetime(u_int32_t
);
50 static void print_lladdr(const u_char
*, size_t);
51 static void icmp6_opt_print(const u_char
*, int);
52 static void mld6_print(const u_char
*);
53 static struct udphdr
*get_upperlayer(u_char
*, u_int
*);
54 static void dnsname_print(const u_char
*, const u_char
*);
55 static void icmp6_nodeinfo_print(u_int
, const u_char
*, const u_char
*);
56 static void icmp6_rrenum_print(u_int
, const u_char
*, const u_char
*);
59 #define abs(a) ((0 < (a)) ? (a) : -(a))
65 static const char *rtpref_str
[] = {
72 return rtpref_str
[((v
& ND_RA_FLAG_RTPREF_MASK
) >> 3) & 0xff];
76 get_lifetime(u_int32_t v
)
80 if (v
== (u_int32_t
)~0UL)
83 snprintf(buf
, sizeof(buf
), "%u", v
);
89 print_lladdr(const u_int8_t
*p
, size_t l
)
91 const u_int8_t
*ep
, *q
;
95 while (l
> 0 && q
< ep
) {
104 icmp6_print(const u_char
*bp
, const u_char
*bp2
)
106 const struct icmp6_hdr
*dp
;
107 const struct ip6_hdr
*ip
;
109 const struct ip6_hdr
*oip
;
110 const struct udphdr
*ouh
;
114 u_int icmp6len
, prot
;
116 dp
= (struct icmp6_hdr
*)bp
;
117 ip
= (struct ip6_hdr
*)bp2
;
118 oip
= (struct ip6_hdr
*)(dp
+ 1);
120 /* 'ep' points to the end of available data. */
123 icmp6len
= (EXTRACT_16BITS(&ip
->ip6_plen
) + sizeof(struct ip6_hdr
) -
125 else /* XXX: jumbo payload case... */
126 icmp6len
= snapend
- bp
;
128 TCHECK(dp
->icmp6_code
);
129 switch (dp
->icmp6_type
) {
130 case ICMP6_DST_UNREACH
:
131 TCHECK(oip
->ip6_dst
);
132 switch (dp
->icmp6_code
) {
133 case ICMP6_DST_UNREACH_NOROUTE
:
134 printf("icmp6: %s unreachable route",
135 ip6addr_string(&oip
->ip6_dst
));
137 case ICMP6_DST_UNREACH_ADMIN
:
138 printf("icmp6: %s unreachable prohibited",
139 ip6addr_string(&oip
->ip6_dst
));
141 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
142 printf("icmp6: %s beyond scope of source address %s",
143 ip6addr_string(&oip
->ip6_dst
),
144 ip6addr_string(&oip
->ip6_src
));
146 case ICMP6_DST_UNREACH_ADDR
:
147 printf("icmp6: %s unreachable address",
148 ip6addr_string(&oip
->ip6_dst
));
150 case ICMP6_DST_UNREACH_NOPORT
:
151 if ((ouh
= get_upperlayer((u_char
*)oip
, &prot
))
155 dport
= EXTRACT_16BITS(&ouh
->uh_dport
);
158 printf("icmp6: %s tcp port %s unreachable",
159 ip6addr_string(&oip
->ip6_dst
),
160 tcpport_string(dport
));
163 printf("icmp6: %s udp port %s unreachable",
164 ip6addr_string(&oip
->ip6_dst
),
165 udpport_string(dport
));
168 printf("icmp6: %s protocol %d port %d unreachable",
169 ip6addr_string(&oip
->ip6_dst
),
170 oip
->ip6_nxt
, dport
);
175 printf("icmp6: %s unreachable code-#%d",
176 ip6addr_string(&oip
->ip6_dst
),
181 case ICMP6_PACKET_TOO_BIG
:
182 TCHECK(dp
->icmp6_mtu
);
183 printf("icmp6: too big %u", EXTRACT_32BITS(&dp
->icmp6_mtu
));
185 case ICMP6_TIME_EXCEEDED
:
186 TCHECK(oip
->ip6_dst
);
187 switch (dp
->icmp6_code
) {
188 case ICMP6_TIME_EXCEED_TRANSIT
:
189 printf("icmp6: time exceeded in-transit for %s",
190 ip6addr_string(&oip
->ip6_dst
));
192 case ICMP6_TIME_EXCEED_REASSEMBLY
:
193 printf("icmp6: ip6 reassembly time exceeded");
196 printf("icmp6: time exceeded code-#%d",
201 case ICMP6_PARAM_PROB
:
202 TCHECK(oip
->ip6_dst
);
203 switch (dp
->icmp6_code
) {
204 case ICMP6_PARAMPROB_HEADER
:
205 printf("icmp6: parameter problem errorneous - octet %u",
206 EXTRACT_32BITS(&dp
->icmp6_pptr
));
208 case ICMP6_PARAMPROB_NEXTHEADER
:
209 printf("icmp6: parameter problem next header - octet %u",
210 EXTRACT_32BITS(&dp
->icmp6_pptr
));
212 case ICMP6_PARAMPROB_OPTION
:
213 printf("icmp6: parameter problem option - octet %u",
214 EXTRACT_32BITS(&dp
->icmp6_pptr
));
217 printf("icmp6: parameter problem code-#%d",
222 case ICMP6_ECHO_REQUEST
:
223 case ICMP6_ECHO_REPLY
:
224 TCHECK(dp
->icmp6_seq
);
225 printf("icmp6: echo %s seq %u",
226 dp
->icmp6_type
== ICMP6_ECHO_REQUEST
?
228 EXTRACT_16BITS(&dp
->icmp6_seq
));
230 case ICMP6_MEMBERSHIP_QUERY
:
231 printf("icmp6: multicast listener query ");
232 mld6_print((const u_char
*)dp
);
234 case ICMP6_MEMBERSHIP_REPORT
:
235 printf("icmp6: multicast listener report ");
236 mld6_print((const u_char
*)dp
);
238 case ICMP6_MEMBERSHIP_REDUCTION
:
239 printf("icmp6: multicast listener done ");
240 mld6_print((const u_char
*)dp
);
242 case ND_ROUTER_SOLICIT
:
243 printf("icmp6: router solicitation ");
246 icmp6_opt_print((const u_char
*)dp
+ RTSOLLEN
,
247 icmp6len
- RTSOLLEN
);
250 case ND_ROUTER_ADVERT
:
251 printf("icmp6: router advertisement");
253 struct nd_router_advert
*p
;
255 p
= (struct nd_router_advert
*)dp
;
256 TCHECK(p
->nd_ra_retransmit
);
257 printf("(chlim=%d, ", (int)p
->nd_ra_curhoplimit
);
258 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_MANAGED
)
260 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_OTHER
)
262 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_HOME_AGENT
)
265 if ((p
->nd_ra_flags_reserved
& ~ND_RA_FLAG_RTPREF_MASK
)
270 get_rtpref(p
->nd_ra_flags_reserved
));
272 printf("router_ltime=%d, ", EXTRACT_16BITS(&p
->nd_ra_router_lifetime
));
273 printf("reachable_time=%u, ",
274 EXTRACT_32BITS(&p
->nd_ra_reachable
));
275 printf("retrans_time=%u)",
276 EXTRACT_32BITS(&p
->nd_ra_retransmit
));
278 icmp6_opt_print((const u_char
*)dp
+ RTADVLEN
,
279 icmp6len
- RTADVLEN
);
282 case ND_NEIGHBOR_SOLICIT
:
284 struct nd_neighbor_solicit
*p
;
285 p
= (struct nd_neighbor_solicit
*)dp
;
286 TCHECK(p
->nd_ns_target
);
287 printf("icmp6: neighbor sol: who has %s",
288 ip6addr_string(&p
->nd_ns_target
));
291 icmp6_opt_print((const u_char
*)dp
+ NDSOLLEN
,
292 icmp6len
- NDSOLLEN
);
296 case ND_NEIGHBOR_ADVERT
:
298 struct nd_neighbor_advert
*p
;
300 p
= (struct nd_neighbor_advert
*)dp
;
301 TCHECK(p
->nd_na_target
);
302 printf("icmp6: neighbor adv: tgt is %s",
303 ip6addr_string(&p
->nd_na_target
));
305 #define ND_NA_FLAG_ALL \
306 (ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
307 /* we don't need ntohl() here. see advanced-api-04. */
308 if (p
->nd_na_flags_reserved
& ND_NA_FLAG_ALL
) {
309 #undef ND_NA_FLAG_ALL
312 flags
= p
->nd_na_flags_reserved
;
314 if (flags
& ND_NA_FLAG_ROUTER
)
316 if (flags
& ND_NA_FLAG_SOLICITED
)
318 if (flags
& ND_NA_FLAG_OVERRIDE
)
323 icmp6_opt_print((const u_char
*)dp
+ NDADVLEN
,
324 icmp6len
- NDADVLEN
);
330 #define RDR(i) ((struct nd_redirect *)(i))
331 TCHECK(RDR(dp
)->nd_rd_dst
);
332 printf("icmp6: redirect %s",
333 getname6((const u_char
*)&RDR(dp
)->nd_rd_dst
));
335 getname6((const u_char
*)&RDR(dp
)->nd_rd_target
));
336 #define REDIRECTLEN 40
338 icmp6_opt_print((const u_char
*)dp
+ REDIRECTLEN
,
339 icmp6len
- REDIRECTLEN
);
344 case ICMP6_ROUTER_RENUMBERING
:
345 icmp6_rrenum_print(icmp6len
, bp
, ep
);
349 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
351 case ICMP6_HADISCOV_REQUEST
:
352 printf("icmp6: ha discovery request");
354 TCHECK(dp
->icmp6_data16
[0]);
355 printf("(id=%d)", EXTRACT_16BITS(&dp
->icmp6_data16
[0]));
358 case ICMP6_HADISCOV_REPLY
:
359 printf("icmp6: ha discovery reply");
361 struct in6_addr
*in6
;
364 TCHECK(dp
->icmp6_data16
[0]);
365 printf("(id=%d", EXTRACT_16BITS(&dp
->icmp6_data16
[0]));
366 cp
= (u_char
*)dp
+ icmp6len
;
367 in6
= (struct in6_addr
*)(dp
+ 1);
368 for (; (u_char
*)in6
< cp
; in6
++) {
370 printf(", %s", ip6addr_string(in6
));
375 case ICMP6_MOBILEPREFIX_SOLICIT
:
376 printf("icmp6: mobile router solicitation");
378 TCHECK(dp
->icmp6_data16
[0]);
379 printf("(id=%d)", EXTRACT_16BITS(&dp
->icmp6_data16
[0]));
382 case ICMP6_MOBILEPREFIX_ADVERT
:
383 printf("icmp6: mobile router advertisement");
385 TCHECK(dp
->icmp6_data16
[0]);
386 printf("(id=%d", EXTRACT_16BITS(&dp
->icmp6_data16
[0]));
387 if (dp
->icmp6_data16
[1] & 0xc0)
389 if (dp
->icmp6_data16
[1] & 0x80)
391 if (dp
->icmp6_data16
[1] & 0x40)
395 icmp6_opt_print((const u_char
*)dp
+ MPADVLEN
,
396 icmp6len
- MPADVLEN
);
400 printf("icmp6: type-#%d", dp
->icmp6_type
);
405 fputs("[|icmp6]", stdout
);
408 static struct udphdr
*
409 get_upperlayer(u_char
*bp
, u_int
*prot
)
412 struct ip6_hdr
*ip6
= (struct ip6_hdr
*)bp
;
415 struct ip6_frag
*fragh
;
420 /* 'ep' points to the end of available data. */
423 if (!TTEST(ip6
->ip6_nxt
))
427 hlen
= sizeof(struct ip6_hdr
);
429 while (bp
< snapend
) {
435 uh
= (struct udphdr
*)bp
;
436 if (TTEST(uh
->uh_dport
)) {
444 case IPPROTO_HOPOPTS
:
445 case IPPROTO_DSTOPTS
:
446 case IPPROTO_ROUTING
:
447 hbh
= (struct ip6_hbh
*)bp
;
448 if (!TTEST(hbh
->ip6h_len
))
451 hlen
= (hbh
->ip6h_len
+ 1) << 3;
454 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
455 fragh
= (struct ip6_frag
*)bp
;
456 if (!TTEST(fragh
->ip6f_offlg
))
458 /* fragments with non-zero offset are meaningless */
459 if ((EXTRACT_16BITS(&fragh
->ip6f_offlg
) & IP6F_OFF_MASK
) != 0)
461 nh
= fragh
->ip6f_nxt
;
462 hlen
= sizeof(struct ip6_frag
);
466 ah
= (struct ah
*)bp
;
467 if (!TTEST(ah
->ah_len
))
470 hlen
= (ah
->ah_len
+ 2) << 2;
473 default: /* unknown or undecodable header */
474 *prot
= nh
; /* meaningless, but set here anyway */
479 return(NULL
); /* should be notreached, though */
483 icmp6_opt_print(const u_char
*bp
, int resid
)
485 const struct nd_opt_hdr
*op
;
486 const struct nd_opt_hdr
*opl
; /* why there's no struct? */
487 const struct nd_opt_prefix_info
*opp
;
488 const struct icmp6_opts_redirect
*opr
;
489 const struct nd_opt_mtu
*opm
;
490 const struct nd_opt_advinterval
*opa
;
491 const struct nd_opt_homeagent_info
*oph
;
492 const struct nd_opt_route_info
*opri
;
493 const u_char
*cp
, *ep
;
494 struct in6_addr in6
, *in6p
;
497 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
500 /* 'ep' points to the end of available data. */
504 op
= (struct nd_opt_hdr
*)cp
;
506 ECHECK(op
->nd_opt_len
);
509 if (op
->nd_opt_len
== 0)
511 if (cp
+ (op
->nd_opt_len
<< 3) > ep
)
514 switch (op
->nd_opt_type
) {
515 case ND_OPT_SOURCE_LINKADDR
:
516 opl
= (struct nd_opt_hdr
*)op
;
517 printf("(src lladdr: ");
518 l
= (op
->nd_opt_len
<< 3) - 2;
519 print_lladdr(cp
+ 2, l
);
523 case ND_OPT_TARGET_LINKADDR
:
524 opl
= (struct nd_opt_hdr
*)op
;
525 printf("(tgt lladdr: ");
526 l
= (op
->nd_opt_len
<< 3) - 2;
527 print_lladdr(cp
+ 2, l
);
531 case ND_OPT_PREFIX_INFORMATION
:
532 opp
= (struct nd_opt_prefix_info
*)op
;
533 TCHECK(opp
->nd_opt_pi_prefix
);
534 printf("(prefix info: "); /*)*/
535 if (op
->nd_opt_len
!= 4) {
541 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ONLINK
)
543 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_AUTO
)
545 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ROUTER
)
547 if (opp
->nd_opt_pi_flags_reserved
)
549 printf("valid_ltime=%s,",
550 get_lifetime(EXTRACT_32BITS(&opp
->nd_opt_pi_valid_time
)));
551 printf("preferred_ltime=%s,",
552 get_lifetime(EXTRACT_32BITS(&opp
->nd_opt_pi_preferred_time
)));
553 printf("prefix=%s/%d",
554 ip6addr_string(&opp
->nd_opt_pi_prefix
),
555 opp
->nd_opt_pi_prefix_len
);
556 if (opp
->nd_opt_pi_len
!= 4)
561 case ND_OPT_REDIRECTED_HEADER
:
562 opr
= (struct icmp6_opts_redirect
*)op
;
563 printf("(redirect)");
567 opm
= (struct nd_opt_mtu
*)op
;
568 TCHECK(opm
->nd_opt_mtu_mtu
);
569 printf("(mtu:"); /*)*/
570 if (op
->nd_opt_len
!= 1) {
576 printf(" mtu=%u", EXTRACT_32BITS(&opm
->nd_opt_mtu_mtu
));
577 if (opm
->nd_opt_mtu_len
!= 1)
581 case ND_OPT_ADVINTERVAL
:
582 opa
= (struct nd_opt_advinterval
*)op
;
583 TCHECK(opa
->nd_opt_adv_interval
);
584 printf("(advint:"); /*)*/
586 EXTRACT_32BITS(&opa
->nd_opt_adv_interval
));
590 case ND_OPT_HOMEAGENT_INFO
:
591 oph
= (struct nd_opt_homeagent_info
*)op
;
592 TCHECK(oph
->nd_opt_hai_lifetime
);
593 printf("(ha info:"); /*)*/
594 printf(" pref=%d", EXTRACT_16BITS(&oph
->nd_opt_hai_preference
));
595 printf(", lifetime=%u", EXTRACT_16BITS(&oph
->nd_opt_hai_lifetime
));
598 case ND_OPT_ROUTE_INFO
:
599 opri
= (struct nd_opt_route_info
*)op
;
600 TCHECK(opri
->nd_opt_rti_lifetime
);
601 memset(&in6
, 0, sizeof(in6
));
602 in6p
= (struct in6_addr
*)(opri
+ 1);
603 switch (op
->nd_opt_len
) {
608 memcpy(&in6
, opri
+ 1, 8);
612 memcpy(&in6
, opri
+ 1, sizeof(in6
));
617 printf("(rtinfo:"); /*)*/
618 printf(" %s/%u", ip6addr_string(&in6
),
619 opri
->nd_opt_rti_prefixlen
);
620 printf(", pref=%s", get_rtpref(opri
->nd_opt_rti_flags
));
621 printf(", lifetime=%s",
622 get_lifetime(EXTRACT_32BITS(&opri
->nd_opt_rti_lifetime
)));
627 printf("(unknown opt_type=%d, opt_len=%d)",
628 op
->nd_opt_type
, op
->nd_opt_len
);
632 cp
+= op
->nd_opt_len
<< 3;
633 resid
-= op
->nd_opt_len
<< 3;
638 fputs("[ndp opt]", stdout
);
644 mld6_print(const u_char
*bp
)
646 struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
649 /* 'ep' points to the end of available data. */
652 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
655 printf("max resp delay: %d ", EXTRACT_16BITS(&mp
->mld6_maxdelay
));
656 printf("addr: %s", ip6addr_string(&mp
->mld6_addr
));
660 dnsname_print(const u_char
*cp
, const u_char
*ep
)
664 /* DNS name decoding - no decompression */
673 while (i
-- && cp
< ep
) {
677 if (cp
+ 1 < ep
&& *cp
)
683 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
696 icmp6_nodeinfo_print(u_int icmp6len
, const u_char
*bp
, const u_char
*ep
)
698 struct icmp6_nodeinfo
*ni6
;
699 struct icmp6_hdr
*dp
;
706 dp
= (struct icmp6_hdr
*)bp
;
707 ni6
= (struct icmp6_nodeinfo
*)bp
;
710 switch (ni6
->ni_type
) {
712 if (siz
== sizeof(*dp
) + 4) {
713 /* KAME who-are-you */
714 printf("icmp6: who-are-you request");
717 printf("icmp6: node information query");
719 TCHECK2(*dp
, sizeof(*ni6
));
720 ni6
= (struct icmp6_nodeinfo
*)dp
;
722 switch (EXTRACT_16BITS(&ni6
->ni_qtype
)) {
726 case NI_QTYPE_SUPTYPES
:
727 printf("supported qtypes");
728 i
= EXTRACT_16BITS(&ni6
->ni_flags
);
730 printf(" [%s]", (i
& 0x01) ? "C" : "");
736 case NI_QTYPE_NODEADDR
:
737 printf("node addresses");
741 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
742 printf(" [%s%s%s%s%s%s]",
743 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
744 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
745 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
746 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
747 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
748 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "");
755 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
756 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
757 if (siz
!= sizeof(*ni6
))
759 printf(", invalid len");
766 /* XXX backward compat, icmp-name-lookup-03 */
767 if (siz
== sizeof(*ni6
)) {
768 printf(", 03 draft");
774 switch (ni6
->ni_code
) {
775 case ICMP6_NI_SUBJ_IPV6
:
777 sizeof(*ni6
) + sizeof(struct in6_addr
)))
779 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
781 printf(", invalid subject len");
784 printf(", subject=%s",
785 getname6((const u_char
*)(ni6
+ 1)));
787 case ICMP6_NI_SUBJ_FQDN
:
788 printf(", subject=DNS name");
789 cp
= (const u_char
*)(ni6
+ 1);
790 if (cp
[0] == ep
- cp
- 1) {
791 /* icmp-name-lookup-03, pascal string */
793 printf(", 03 draft");
802 dnsname_print(cp
, ep
);
804 case ICMP6_NI_SUBJ_IPV4
:
805 if (!TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
807 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
809 printf(", invalid subject len");
812 printf(", subject=%s",
813 getname((const u_char
*)(ni6
+ 1)));
816 printf(", unknown subject");
825 if (icmp6len
> siz
) {
826 printf("[|icmp6: node information reply]");
832 ni6
= (struct icmp6_nodeinfo
*)dp
;
833 printf("icmp6: node information reply");
835 switch (ni6
->ni_code
) {
836 case ICMP6_NI_SUCCESS
:
842 case ICMP6_NI_REFUSED
:
845 if (siz
!= sizeof(*ni6
))
847 printf(", invalid length");
849 case ICMP6_NI_UNKNOWN
:
852 if (siz
!= sizeof(*ni6
))
854 printf(", invalid length");
858 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
864 switch (EXTRACT_16BITS(&ni6
->ni_qtype
)) {
869 if (siz
!= sizeof(*ni6
))
871 printf(", invalid length");
873 case NI_QTYPE_SUPTYPES
:
876 printf("supported qtypes");
877 i
= EXTRACT_16BITS(&ni6
->ni_flags
);
879 printf(" [%s]", (i
& 0x01) ? "C" : "");
885 cp
= (const u_char
*)(ni6
+ 1) + 4;
886 if (cp
[0] == ep
- cp
- 1) {
887 /* icmp-name-lookup-03, pascal string */
889 printf(", 03 draft");
898 dnsname_print(cp
, ep
);
899 if ((EXTRACT_16BITS(&ni6
->ni_flags
) & 0x01) != 0)
900 printf(" [TTL=%u]", *(u_int32_t
*)(ni6
+ 1));
902 case NI_QTYPE_NODEADDR
:
905 printf("node addresses");
908 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
910 printf(" %s", getname6(bp
+ i
));
911 i
+= sizeof(struct in6_addr
);
912 printf("(%d)", (int32_t)EXTRACT_32BITS(bp
+ i
));
913 i
+= sizeof(int32_t);
918 printf(" [%s%s%s%s%s%s%s]",
919 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
920 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
921 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
922 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
923 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
924 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
925 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : "");
941 fputs("[|icmp6]", stdout
);
945 icmp6_rrenum_print(u_int icmp6len
, const u_char
*bp
, const u_char
*ep
)
947 struct icmp6_router_renum
*rr6
;
948 struct icmp6_hdr
*dp
;
951 struct rr_pco_match
*match
;
952 struct rr_pco_use
*use
;
953 char hbuf
[NI_MAXHOST
];
958 dp
= (struct icmp6_hdr
*)bp
;
959 rr6
= (struct icmp6_router_renum
*)bp
;
961 cp
= (const char *)(rr6
+ 1);
963 TCHECK(rr6
->rr_reserved
);
964 switch (rr6
->rr_code
) {
965 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
966 printf("router renum: command");
968 case ICMP6_ROUTER_RENUMBERING_RESULT
:
969 printf("router renum: result");
971 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
972 printf("router renum: sequence number reset");
975 printf("router renum: code-#%d", rr6
->rr_code
);
979 printf(", seq=%u", EXTRACT_32BITS(&rr6
->rr_seqnum
));
982 #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
985 printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
986 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
987 F(ICMP6_RR_FLAGS_FORCEAPPLY
, "A"),
988 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
989 F(ICMP6_RR_FLAGS_PREVDONE
, "P"));
991 printf("seg=%u,", rr6
->rr_segnum
);
992 printf("maxdelay=%u", rr6
->rr_maxdelay
);
993 if (rr6
->rr_reserved
)
994 printf("rsvd=0x%x", EXTRACT_16BITS(&rr6
->rr_reserved
));
1000 if (rr6
->rr_code
== ICMP6_ROUTER_RENUMBERING_COMMAND
) {
1001 match
= (struct rr_pco_match
*)cp
;
1002 cp
= (const char *)(match
+ 1);
1004 TCHECK(match
->rpm_prefix
);
1010 printf("match("); /*)*/
1011 switch (match
->rpm_code
) {
1012 case RPM_PCO_ADD
: printf("add"); break;
1013 case RPM_PCO_CHANGE
: printf("change"); break;
1014 case RPM_PCO_SETGLOBAL
: printf("setglobal"); break;
1015 default: printf("#%u", match
->rpm_code
); break;
1019 printf(",ord=%u", match
->rpm_ordinal
);
1020 printf(",min=%u", match
->rpm_minlen
);
1021 printf(",max=%u", match
->rpm_maxlen
);
1023 if (inet_ntop(AF_INET6
, &match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
1024 printf(",%s/%u", hbuf
, match
->rpm_matchlen
);
1026 printf(",?/%u", match
->rpm_matchlen
);
1030 n
= match
->rpm_len
- 3;
1035 use
= (struct rr_pco_use
*)cp
;
1036 cp
= (const char *)(use
+ 1);
1038 TCHECK(use
->rpu_prefix
);
1044 printf("use("); /*)*/
1045 if (use
->rpu_flags
) {
1046 #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
1048 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
1049 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P"));
1053 printf("mask=0x%x,", use
->rpu_ramask
);
1054 printf("raflags=0x%x,", use
->rpu_raflags
);
1055 if (~use
->rpu_vltime
== 0)
1056 printf("vltime=infty,");
1058 printf("vltime=%u,",
1059 EXTRACT_32BITS(&use
->rpu_vltime
));
1060 if (~use
->rpu_pltime
== 0)
1061 printf("pltime=infty,");
1063 printf("pltime=%u,",
1064 EXTRACT_32BITS(&use
->rpu_pltime
));
1066 if (inet_ntop(AF_INET6
, &use
->rpu_prefix
, hbuf
,
1068 printf("%s/%u/%u", hbuf
, use
->rpu_uselen
,
1071 printf("?/%u/%u", use
->rpu_uselen
,
1081 fputs("[|icmp6]", stdout
);