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.26 2000-09-28 11:27:35 itojun Exp $";
35 #include <sys/param.h>
37 #include <sys/types.h>
38 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <netinet/in_systm.h>
44 #include <arpa/inet.h>
48 #include <netinet/ip6.h>
49 #include <netinet/udp.h>
50 #include <netinet/icmp6.h>
52 #include "interface.h"
53 #include "addrtoname.h"
55 void icmp6_opt_print(const u_char
*, int);
56 void mld6_print(const u_char
*);
57 #ifdef HAVE_STRUCT_ICMP6_NODEINFO
58 static void dnsname_print(const u_char
*, const u_char
*);
59 void icmp6_nodeinfo_print(int, const u_char
*, const u_char
*);
63 #define abs(a) ((0 < (a)) ? (a) : -(a))
66 #ifndef HAVE_STRUCT_ICMP6_NODEINFO
67 struct icmp6_nodeinfo
{
68 struct icmp6_hdr icmp6_ni_hdr
;
69 u_int8_t icmp6_ni_nonce
[8];
70 /* could be followed by reply data */
73 #define ni_type icmp6_ni_hdr.icmp6_type
74 #define ni_code icmp6_ni_hdr.icmp6_code
75 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
76 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
77 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
80 /* cope with past KAME typo - shipped with freebsd4[01] and openbsd27 */
81 #if defined(ICMP6_NI_SUCESS) && !defined(ICMP6_NI_SUCCESS)
82 #define ICMP6_NI_SUCCESS ICMP6_NI_SUCESS
84 #ifndef ICMP6_NI_SUCCESS
85 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
86 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
87 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
91 #define NI_QTYPE_NOOP 0 /* NOOP */
92 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
93 #define NI_QTYPE_FQDN 2 /* FQDN */
94 #define NI_QTYPE_NODEADDR 3 /* Node Addresses. XXX: spec says 2, but it may be a typo... */
97 #ifndef ICMP6_NI_SUBJ_IPV6
98 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
99 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
100 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
104 icmp6_print(register const u_char
*bp
, register const u_char
*bp2
)
106 const struct icmp6_hdr
*dp
;
107 register const struct ip6_hdr
*ip
;
108 register const char *str
;
109 register const struct ip6_hdr
*oip
;
110 register const struct udphdr
*ouh
;
111 register int hlen
, dport
;
112 register const u_char
*ep
;
117 #define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
120 dp
= (struct icmp6_hdr
*)bp
;
121 ip
= (struct ip6_hdr
*)bp2
;
122 oip
= (struct ip6_hdr
*)(dp
+ 1);
124 /* 'ep' points to the end of avaible data. */
127 icmp6len
= (ntohs(ip
->ip6_plen
) + sizeof(struct ip6_hdr
) -
129 else /* XXX: jumbo payload case... */
130 icmp6len
= snapend
- bp
;
133 (void)printf("%s > %s: ",
134 ip6addr_string(&ip
->ip6_src
),
135 ip6addr_string(&ip
->ip6_dst
));
138 TCHECK(dp
->icmp6_code
);
139 switch (dp
->icmp6_type
) {
140 case ICMP6_DST_UNREACH
:
141 TCHECK(oip
->ip6_dst
);
142 switch (dp
->icmp6_code
) {
143 case ICMP6_DST_UNREACH_NOROUTE
:
144 printf("icmp6: %s unreachable route",
145 ip6addr_string(&oip
->ip6_dst
));
147 case ICMP6_DST_UNREACH_ADMIN
:
148 printf("icmp6: %s unreachable prohibited",
149 ip6addr_string(&oip
->ip6_dst
));
151 #ifdef ICMP6_DST_UNREACH_BEYONDSCOPE
152 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
154 case ICMP6_DST_UNREACH_NOTNEIGHBOR
:
156 printf("icmp6: %s beyond scope of source address %s",
157 ip6addr_string(&oip
->ip6_dst
),
158 ip6addr_string(&oip
->ip6_src
));
160 case ICMP6_DST_UNREACH_ADDR
:
161 printf("icmp6: %s unreachable address",
162 ip6addr_string(&oip
->ip6_dst
));
164 case ICMP6_DST_UNREACH_NOPORT
:
165 TCHECK(oip
->ip6_nxt
);
166 hlen
= sizeof(struct ip6_hdr
);
167 ouh
= (struct udphdr
*)(((u_char
*)oip
) + hlen
);
168 dport
= ntohs(ouh
->uh_dport
);
169 switch (oip
->ip6_nxt
) {
171 printf("icmp6: %s tcp port %s unreachable",
172 ip6addr_string(&oip
->ip6_dst
),
173 tcpport_string(dport
));
176 printf("icmp6: %s udp port %s unreachable",
177 ip6addr_string(&oip
->ip6_dst
),
178 udpport_string(dport
));
181 printf("icmp6: %s protocol %d port %d unreachable",
182 ip6addr_string(&oip
->ip6_dst
),
183 oip
->ip6_nxt
, dport
);
188 printf("icmp6: %s unreachable code-#%d",
189 ip6addr_string(&oip
->ip6_dst
),
194 case ICMP6_PACKET_TOO_BIG
:
195 TCHECK(dp
->icmp6_mtu
);
196 printf("icmp6: too big %u\n", (u_int32_t
)ntohl(dp
->icmp6_mtu
));
198 case ICMP6_TIME_EXCEEDED
:
199 TCHECK(oip
->ip6_dst
);
200 switch (dp
->icmp6_code
) {
201 case ICMP6_TIME_EXCEED_TRANSIT
:
202 printf("icmp6: time exceeded in-transit for %s",
203 ip6addr_string(&oip
->ip6_dst
));
205 case ICMP6_TIME_EXCEED_REASSEMBLY
:
206 printf("icmp6: ip6 reassembly time exceeded");
209 printf("icmp6: time exceeded code-#%d",
214 case ICMP6_PARAM_PROB
:
215 TCHECK(oip
->ip6_dst
);
216 switch (dp
->icmp6_code
) {
217 case ICMP6_PARAMPROB_HEADER
:
218 printf("icmp6: parameter problem errorneous - octet %u\n",
219 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
221 case ICMP6_PARAMPROB_NEXTHEADER
:
222 printf("icmp6: parameter problem next header - octet %u\n",
223 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
225 case ICMP6_PARAMPROB_OPTION
:
226 printf("icmp6: parameter problem option - octet %u\n",
227 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
230 printf("icmp6: parameter problem code-#%d",
235 case ICMP6_ECHO_REQUEST
:
236 printf("icmp6: echo request");
238 case ICMP6_ECHO_REPLY
:
239 printf("icmp6: echo reply");
241 #if defined(HAVE_STRUCT_MLD6_HDR) || defined(HAVE_STRUCT_ICMP6_MLD)
242 case ICMP6_MEMBERSHIP_QUERY
:
243 printf("icmp6: multicast listener query ");
244 mld6_print((const u_char
*)dp
);
246 case ICMP6_MEMBERSHIP_REPORT
:
247 printf("icmp6: multicast listener report ");
248 mld6_print((const u_char
*)dp
);
250 case ICMP6_MEMBERSHIP_REDUCTION
:
251 printf("icmp6: multicast listener done ");
252 mld6_print((const u_char
*)dp
);
255 case ND_ROUTER_SOLICIT
:
256 printf("icmp6: router solicitation ");
259 icmp6_opt_print((const u_char
*)dp
+ RTSOLLEN
,
260 icmp6len
- RTSOLLEN
);
263 case ND_ROUTER_ADVERT
:
264 printf("icmp6: router advertisement");
266 struct nd_router_advert
*p
;
268 p
= (struct nd_router_advert
*)dp
;
269 TCHECK(p
->nd_ra_retransmit
);
270 printf("(chlim=%d, ", (int)p
->nd_ra_curhoplimit
);
271 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_MANAGED
)
273 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_OTHER
)
275 #ifndef ND_RA_FLAG_HA
276 #define ND_RA_FLAG_HA 0x20
278 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_HA
)
280 if (p
->nd_ra_flags_reserved
!= 0)
282 printf("router_ltime=%d, ", ntohs(p
->nd_ra_router_lifetime
));
283 printf("reachable_time=%u, ",
284 (u_int32_t
)ntohl(p
->nd_ra_reachable
));
285 printf("retrans_time=%u)",
286 (u_int32_t
)ntohl(p
->nd_ra_retransmit
));
288 icmp6_opt_print((const u_char
*)dp
+ RTADVLEN
,
289 icmp6len
- RTADVLEN
);
292 case ND_NEIGHBOR_SOLICIT
:
294 struct nd_neighbor_solicit
*p
;
295 p
= (struct nd_neighbor_solicit
*)dp
;
296 TCHECK(p
->nd_ns_target
);
297 printf("icmp6: neighbor sol: who has %s",
298 ip6addr_string(&p
->nd_ns_target
));
301 icmp6_opt_print((const u_char
*)dp
+ NDSOLLEN
,
302 icmp6len
- NDSOLLEN
);
306 case ND_NEIGHBOR_ADVERT
:
308 struct nd_neighbor_advert
*p
;
310 p
= (struct nd_neighbor_advert
*)dp
;
311 TCHECK(p
->nd_na_target
);
312 printf("icmp6: neighbor adv: tgt is %s",
313 ip6addr_string(&p
->nd_na_target
));
315 #define ND_NA_FLAG_ALL \
316 (ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
317 /* we don't need ntohl() here. see advanced-api-04. */
318 if (p
->nd_na_flags_reserved
& ND_NA_FLAG_ALL
) {
319 #undef ND_NA_FLAG_ALL
322 flags
= p
->nd_na_flags_reserved
;
324 if (flags
& ND_NA_FLAG_ROUTER
)
326 if (flags
& ND_NA_FLAG_SOLICITED
)
328 if (flags
& ND_NA_FLAG_OVERRIDE
)
333 icmp6_opt_print((const u_char
*)dp
+ NDADVLEN
,
334 icmp6len
- NDADVLEN
);
340 #define RDR(i) ((struct nd_redirect *)(i))
341 TCHECK(RDR(dp
)->nd_rd_dst
);
342 printf("icmp6: redirect %s",
343 getname6((const u_char
*)&RDR(dp
)->nd_rd_dst
));
345 getname6((const u_char
*)&RDR(dp
)->nd_rd_target
));
346 #define REDIRECTLEN 40
348 icmp6_opt_print((const u_char
*)dp
+ REDIRECTLEN
,
349 icmp6len
- REDIRECTLEN
);
354 #ifndef ICMP6_ROUTER_RENUMBERING
355 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
357 case ICMP6_ROUTER_RENUMBERING
:
358 switch (dp
->icmp6_code
) {
359 #ifndef ICMP6_ROUTER_RENUMBERING_COMMAND
360 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
362 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
363 printf("icmp6: router renum command");
365 #ifndef ICMP6_ROUTER_RENUMBERING_RESULT
366 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
368 case ICMP6_ROUTER_RENUMBERING_RESULT
:
369 printf("icmp6: router renum result");
372 printf("icmp6: router renum code-#%d", dp
->icmp6_code
);
376 #ifdef HAVE_STRUCT_ICMP6_NODEINFO
377 #ifndef ICMP6_NI_QUERY
378 #define ICMP6_NI_QUERY 139
381 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
383 #ifndef ICMP6_NI_REPLY
384 #define ICMP6_NI_REPLY 140
387 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
391 printf("icmp6: type-#%d", dp
->icmp6_type
);
396 fputs("[|icmp6]", stdout
);
403 icmp6_opt_print(register const u_char
*bp
, int resid
)
405 register const struct nd_opt_hdr
*op
;
406 register const struct nd_opt_hdr
*opl
; /* why there's no struct? */
407 register const struct nd_opt_prefix_info
*opp
;
408 register const struct icmp6_opts_redirect
*opr
;
409 register const struct nd_opt_mtu
*opm
;
410 register const u_char
*ep
;
413 register const struct ip6_hdr
*ip
;
414 register const char *str
;
415 register const struct ip6_hdr
*oip
;
416 register const struct udphdr
*ouh
;
417 register int hlen
, dport
;
421 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
423 op
= (struct nd_opt_hdr
*)bp
;
425 ip
= (struct ip6_hdr
*)bp2
;
426 oip
= &dp
->icmp6_ip6
;
429 /* 'ep' points to the end of avaible data. */
432 ECHECK(op
->nd_opt_len
);
435 switch (op
->nd_opt_type
) {
436 case ND_OPT_SOURCE_LINKADDR
:
437 opl
= (struct nd_opt_hdr
*)op
;
439 if ((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) > ep
)
442 TCHECK((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) - 1);
444 printf("(src lladdr: %s", /*)*/
445 etheraddr_string((u_char
*)(opl
+ 1)));
446 if (opl
->nd_opt_len
!= 1)
450 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
451 resid
- (op
->nd_opt_len
<< 3));
453 case ND_OPT_TARGET_LINKADDR
:
454 opl
= (struct nd_opt_hdr
*)op
;
456 if ((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) > ep
)
459 TCHECK((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) - 1);
461 printf("(tgt lladdr: %s", /*)*/
462 etheraddr_string((u_char
*)(opl
+ 1)));
463 if (opl
->nd_opt_len
!= 1)
467 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
468 resid
- (op
->nd_opt_len
<< 3));
470 case ND_OPT_PREFIX_INFORMATION
:
471 opp
= (struct nd_opt_prefix_info
*)op
;
472 TCHECK(opp
->nd_opt_pi_prefix
);
473 printf("(prefix info: "); /*)*/
474 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ONLINK
)
476 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_AUTO
)
478 if (opp
->nd_opt_pi_flags_reserved
)
480 printf("valid_ltime=");
481 if ((u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
) == ~0U)
484 printf("%u", (u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
));
487 printf("preffered_ltime=");
488 if ((u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
) == ~0U)
491 printf("%u", (u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
));
494 printf("prefix=%s/%d", ip6addr_string(&opp
->nd_opt_pi_prefix
),
495 opp
->nd_opt_pi_prefix_len
);
496 if (opp
->nd_opt_pi_len
!= 4)
500 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
501 resid
- (op
->nd_opt_len
<< 3));
503 case ND_OPT_REDIRECTED_HEADER
:
504 opr
= (struct icmp6_opts_redirect
*)op
;
505 printf("(redirect)");
507 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
508 resid
- (op
->nd_opt_len
<< 3));
511 opm
= (struct nd_opt_mtu
*)op
;
512 TCHECK(opm
->nd_opt_mtu_mtu
);
513 printf("(mtu: "); /*)*/
514 printf("mtu=%u", (u_int32_t
)ntohl(opm
->nd_opt_mtu_mtu
));
515 if (opm
->nd_opt_mtu_len
!= 1)
518 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
519 resid
- (op
->nd_opt_len
<< 3));
522 opts_len
= op
->nd_opt_len
;
523 printf("(unknwon opt_type=%d, opt_len=%d)",
524 op
->nd_opt_type
, opts_len
);
526 opts_len
= 1; /* XXX */
527 icmp6_opt_print((const u_char
*)op
+ (opts_len
<< 3),
528 resid
- (opts_len
<< 3));
533 fputs("[ndp opt]", stdout
);
538 #if defined(HAVE_STRUCT_MLD6_HDR)
540 mld6_print(register const u_char
*bp
)
542 register struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
543 register const u_char
*ep
;
545 /* 'ep' points to the end of avaible data. */
548 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
551 printf("max resp delay: %d ", ntohs(mp
->mld6_maxdelay
));
552 printf("addr: %s", ip6addr_string(&mp
->mld6_addr
));
555 #elif defined(HAVE_STRUCT_ICMP6_MLD)
558 mld6_print(register const u_char
*bp
)
560 register struct icmp6_mld
*mp
= (struct icmp6_mld
*)bp
;
561 register const u_char
*ep
;
563 /* 'ep' points to the end of avaible data. */
566 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
569 printf("max resp delay: %d ", ntohs(mp
->icmp6m_hdr
.icmp6_maxdelay
));
570 printf("addr: %s", ip6addr_string(&mp
->icmp6m_group
));
575 #ifdef HAVE_STRUCT_ICMP6_NODEINFO
577 dnsname_print(const u_char
*cp
, const u_char
*ep
)
581 /* DNS name decoding - no decompression */
590 while (i
-- && cp
< ep
) {
594 if (cp
+ 1 < ep
&& *cp
)
600 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
613 icmp6_nodeinfo_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
615 struct icmp6_nodeinfo
*ni6
;
616 struct icmp6_hdr
*dp
;
621 dp
= (struct icmp6_hdr
*)bp
;
622 ni6
= (struct icmp6_nodeinfo
*)bp
;
625 switch (ni6
->ni_type
) {
627 if (siz
== sizeof(*dp
) + 4) {
628 /* KAME who-are-you */
629 printf("icmp6: who-are-you request");
632 printf("icmp6: node information query");
634 TCHECK2(*dp
, sizeof(*ni6
));
635 ni6
= (struct icmp6_nodeinfo
*)dp
;
637 switch (ntohs(ni6
->ni_qtype
)) {
641 case NI_QTYPE_SUPTYPES
:
642 printf("supported qtypes");
643 i
= ntohs(ni6
->ni_flags
);
645 printf(" [%s]", (i
& 0x01) ? "C" : "");
651 case NI_QTYPE_NODEADDR
:
652 printf("node addresses");
656 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
657 printf(" [%s%s%s%s%s%s]",
658 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
659 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
660 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
661 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
662 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
663 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "");
670 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
671 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
672 if (siz
!= sizeof(*ni6
))
674 printf(", invalid len");
681 /* XXX backward compat, icmp-name-lookup-03 */
682 if (siz
== sizeof(*ni6
)) {
683 printf(", 03 draft");
689 switch (ni6
->ni_code
) {
690 case ICMP6_NI_SUBJ_IPV6
:
692 sizeof(*ni6
) + sizeof(struct in6_addr
)))
694 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
696 printf(", invalid subject len");
699 printf(", subject=%s",
700 getname6((const u_char
*)(ni6
+ 1)));
702 case ICMP6_NI_SUBJ_FQDN
:
703 printf(", subject=DNS name");
704 cp
= (const u_char
*)(ni6
+ 1);
705 if (cp
[0] == ep
- cp
- 1) {
706 /* icmp-name-lookup-03, pascal string */
708 printf(", 03 draft");
717 dnsname_print(cp
, ep
);
719 case ICMP6_NI_SUBJ_IPV4
:
720 if (!TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
722 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
724 printf(", invalid subject len");
727 printf(", subject=%s",
728 getname((const u_char
*)(ni6
+ 1)));
731 printf(", unknown subject");
740 if (icmp6len
> siz
) {
741 printf("[|icmp6: node information reply]");
747 ni6
= (struct icmp6_nodeinfo
*)dp
;
748 printf("icmp6: node information reply");
750 switch (ni6
->ni_code
) {
751 case ICMP6_NI_SUCCESS
:
757 case ICMP6_NI_REFUSED
:
760 if (siz
!= sizeof(*ni6
))
762 printf(", invalid length");
764 case ICMP6_NI_UNKNOWN
:
767 if (siz
!= sizeof(*ni6
))
769 printf(", invalid length");
773 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
779 switch (ntohs(ni6
->ni_qtype
)) {
784 if (siz
!= sizeof(*ni6
))
786 printf(", invalid length");
788 case NI_QTYPE_SUPTYPES
:
791 printf("supported qtypes");
792 i
= ntohs(ni6
->ni_flags
);
794 printf(" [%s]", (i
& 0x01) ? "C" : "");
800 cp
= (const u_char
*)(ni6
+ 1) + 4;
801 if (cp
[0] == ep
- cp
- 1) {
802 /* icmp-name-lookup-03, pascal string */
804 printf(", 03 draft");
813 dnsname_print(cp
, ep
);
814 if ((ntohs(ni6
->ni_flags
) & 0x01) != 0)
815 printf(" [TTL=%u]", *(u_int32_t
*)(ni6
+ 1));
817 case NI_QTYPE_NODEADDR
:
820 printf("node addresses");
823 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
825 printf(" %s", getname6(bp
+ i
));
826 i
+= sizeof(struct in6_addr
);
827 printf("(%d)", ntohl(*(int32_t *)(bp
+ i
)));
828 i
+= sizeof(int32_t);
833 printf(" [%s%s%s%s%s%s%s]",
834 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
835 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
836 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
837 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
838 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
839 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
840 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : "");
856 fputs("[|icmp6]", stdout
);