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.21 2000-08-30 14:28:44 itojun Exp $";
35 #include <sys/param.h>
37 #include <sys/types.h>
38 #include <sys/socket.h>
42 #include <netinet/in.h>
43 #include <netinet/if_ether.h>
44 #include <netinet/in_systm.h>
45 #include <netinet/ip.h>
46 #include <netinet/ip_icmp.h>
47 #include <netinet/ip_var.h>
48 #include <netinet/udp.h>
49 #include <netinet/udp_var.h>
50 #include <netinet/tcp.h>
52 #include <arpa/inet.h>
56 #include <netinet/ip6.h>
57 #include <netinet/icmp6.h>
59 #include "interface.h"
60 #include "addrtoname.h"
62 void icmp6_opt_print(const u_char
*, int);
63 void mld6_print(const u_char
*);
64 #ifdef HAVE_STRUCT_ICMP6_NODEINFO
65 static void dnsname_print(const u_char
*, const u_char
*);
66 void icmp6_nodeinfo_print(int, const u_char
*, const u_char
*);
70 #define abs(a) ((0 < (a)) ? (a) : -(a))
73 #ifndef HAVE_STRUCT_ICMP6_NODEINFO
74 struct icmp6_nodeinfo
{
75 struct icmp6_hdr icmp6_ni_hdr
;
76 u_int8_t icmp6_ni_nonce
[8];
77 /* could be followed by reply data */
80 #define ni_type icmp6_ni_hdr.icmp6_type
81 #define ni_code icmp6_ni_hdr.icmp6_code
82 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
83 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
84 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
87 /* cope with past KAME typo - shipped with freebsd4[01] and openbsd27 */
88 #if defined(ICMP6_NI_SUCESS) && !defined(ICMP6_NI_SUCCESS)
89 #define ICMP6_NI_SUCCESS ICMP6_NI_SUCESS
91 #ifndef ICMP6_NI_SUCCESS
92 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
93 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
94 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
98 #define NI_QTYPE_NOOP 0 /* NOOP */
99 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
100 #define NI_QTYPE_FQDN 2 /* FQDN */
101 #define NI_QTYPE_NODEADDR 3 /* Node Addresses. XXX: spec says 2, but it may be a typo... */
104 #ifndef ICMP6_NI_SUBJ_IPV6
105 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
106 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
107 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
111 icmp6_print(register const u_char
*bp
, register const u_char
*bp2
)
113 const struct icmp6_hdr
*dp
;
114 register const struct ip6_hdr
*ip
;
115 register const char *str
;
116 register const struct ip6_hdr
*oip
;
117 register const struct udphdr
*ouh
;
118 register int hlen
, dport
;
119 register const u_char
*ep
;
124 #define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
127 dp
= (struct icmp6_hdr
*)bp
;
128 ip
= (struct ip6_hdr
*)bp2
;
129 oip
= (struct ip6_hdr
*)(dp
+ 1);
131 /* 'ep' points to the end of avaible data. */
134 icmp6len
= (ntohs(ip
->ip6_plen
) + sizeof(struct ip6_hdr
) -
136 else /* XXX: jumbo payload case... */
137 icmp6len
= snapend
- bp
;
140 (void)printf("%s > %s: ",
141 ip6addr_string(&ip
->ip6_src
),
142 ip6addr_string(&ip
->ip6_dst
));
145 TCHECK(dp
->icmp6_code
);
146 switch (dp
->icmp6_type
) {
147 case ICMP6_DST_UNREACH
:
148 TCHECK(oip
->ip6_dst
);
149 switch (dp
->icmp6_code
) {
150 case ICMP6_DST_UNREACH_NOROUTE
:
151 printf("icmp6: %s unreachable route",
152 ip6addr_string(&oip
->ip6_dst
));
154 case ICMP6_DST_UNREACH_ADMIN
:
155 printf("icmp6: %s unreachable prohibited",
156 ip6addr_string(&oip
->ip6_dst
));
158 #ifdef ICMP6_DST_UNREACH_BEYONDSCOPE
159 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
161 case ICMP6_DST_UNREACH_NOTNEIGHBOR
:
163 printf("icmp6: %s beyond scope of source address %s",
164 ip6addr_string(&oip
->ip6_dst
),
165 ip6addr_string(&oip
->ip6_src
));
167 case ICMP6_DST_UNREACH_ADDR
:
168 printf("icmp6: %s unreachable address",
169 ip6addr_string(&oip
->ip6_dst
));
171 case ICMP6_DST_UNREACH_NOPORT
:
172 TCHECK(oip
->ip6_nxt
);
173 hlen
= sizeof(struct ip6_hdr
);
174 ouh
= (struct udphdr
*)(((u_char
*)oip
) + hlen
);
175 dport
= ntohs(ouh
->uh_dport
);
176 switch (oip
->ip6_nxt
) {
178 printf("icmp6: %s tcp port %s unreachable",
179 ip6addr_string(&oip
->ip6_dst
),
180 tcpport_string(dport
));
183 printf("icmp6: %s udp port %s unreachable",
184 ip6addr_string(&oip
->ip6_dst
),
185 udpport_string(dport
));
188 printf("icmp6: %s protocol %d port %d unreachable",
189 ip6addr_string(&oip
->ip6_dst
),
190 oip
->ip6_nxt
, dport
);
195 printf("icmp6: %s unreachable code-#%d",
196 ip6addr_string(&oip
->ip6_dst
),
201 case ICMP6_PACKET_TOO_BIG
:
202 TCHECK(dp
->icmp6_mtu
);
203 printf("icmp6: too big %u\n", (u_int32_t
)ntohl(dp
->icmp6_mtu
));
205 case ICMP6_TIME_EXCEEDED
:
206 TCHECK(oip
->ip6_dst
);
207 switch (dp
->icmp6_code
) {
208 case ICMP6_TIME_EXCEED_TRANSIT
:
209 printf("icmp6: time exceeded in-transit for %s",
210 ip6addr_string(&oip
->ip6_dst
));
212 case ICMP6_TIME_EXCEED_REASSEMBLY
:
213 printf("icmp6: ip6 reassembly time exceeded");
216 printf("icmp6: time exceeded code-#%d",
221 case ICMP6_PARAM_PROB
:
222 TCHECK(oip
->ip6_dst
);
223 switch (dp
->icmp6_code
) {
224 case ICMP6_PARAMPROB_HEADER
:
225 printf("icmp6: parameter problem errorneous - octet %u\n",
226 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
228 case ICMP6_PARAMPROB_NEXTHEADER
:
229 printf("icmp6: parameter problem next header - octet %u\n",
230 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
232 case ICMP6_PARAMPROB_OPTION
:
233 printf("icmp6: parameter problem option - octet %u\n",
234 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
237 printf("icmp6: parameter problem code-#%d",
242 case ICMP6_ECHO_REQUEST
:
243 printf("icmp6: echo request");
245 case ICMP6_ECHO_REPLY
:
246 printf("icmp6: echo reply");
248 #if defined(HAVE_STRUCT_MLD6_HDR) || defined(HAVE_STRUCT_ICMP6_MLD)
249 case ICMP6_MEMBERSHIP_QUERY
:
250 printf("icmp6: multicast listener query ");
251 mld6_print((const u_char
*)dp
);
253 case ICMP6_MEMBERSHIP_REPORT
:
254 printf("icmp6: multicast listener report ");
255 mld6_print((const u_char
*)dp
);
257 case ICMP6_MEMBERSHIP_REDUCTION
:
258 printf("icmp6: multicast listener done ");
259 mld6_print((const u_char
*)dp
);
262 case ND_ROUTER_SOLICIT
:
263 printf("icmp6: router solicitation ");
266 icmp6_opt_print((const u_char
*)dp
+ RTSOLLEN
,
267 icmp6len
- RTSOLLEN
);
270 case ND_ROUTER_ADVERT
:
271 printf("icmp6: router advertisement");
273 struct nd_router_advert
*p
;
275 p
= (struct nd_router_advert
*)dp
;
276 TCHECK(p
->nd_ra_retransmit
);
277 printf("(chlim=%d, ", (int)p
->nd_ra_curhoplimit
);
278 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_MANAGED
)
280 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_OTHER
)
282 #ifndef ND_RA_FLAG_HA
283 #define ND_RA_FLAG_HA 0x20
285 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_HA
)
287 if (p
->nd_ra_flags_reserved
!= 0)
289 printf("router_ltime=%d, ", ntohs(p
->nd_ra_router_lifetime
));
290 printf("reachable_time=%u, ",
291 (u_int32_t
)ntohl(p
->nd_ra_reachable
));
292 printf("retrans_time=%u)",
293 (u_int32_t
)ntohl(p
->nd_ra_retransmit
));
295 icmp6_opt_print((const u_char
*)dp
+ RTADVLEN
,
296 icmp6len
- RTADVLEN
);
299 case ND_NEIGHBOR_SOLICIT
:
301 struct nd_neighbor_solicit
*p
;
302 p
= (struct nd_neighbor_solicit
*)dp
;
303 TCHECK(p
->nd_ns_target
);
304 printf("icmp6: neighbor sol: who has %s",
305 ip6addr_string(&p
->nd_ns_target
));
308 icmp6_opt_print((const u_char
*)dp
+ NDSOLLEN
,
309 icmp6len
- NDSOLLEN
);
313 case ND_NEIGHBOR_ADVERT
:
315 struct nd_neighbor_advert
*p
;
317 p
= (struct nd_neighbor_advert
*)dp
;
318 TCHECK(p
->nd_na_target
);
319 printf("icmp6: neighbor adv: tgt is %s",
320 ip6addr_string(&p
->nd_na_target
));
322 #define ND_NA_FLAG_ALL \
323 (ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
324 /* we don't need ntohl() here. see advanced-api-04. */
325 if (p
->nd_na_flags_reserved
& ND_NA_FLAG_ALL
) {
326 #undef ND_NA_FLAG_ALL
329 flags
= p
->nd_na_flags_reserved
;
331 if (flags
& ND_NA_FLAG_ROUTER
)
333 if (flags
& ND_NA_FLAG_SOLICITED
)
335 if (flags
& ND_NA_FLAG_OVERRIDE
)
340 icmp6_opt_print((const u_char
*)dp
+ NDADVLEN
,
341 icmp6len
- NDADVLEN
);
347 #define RDR(i) ((struct nd_redirect *)(i))
348 TCHECK(RDR(dp
)->nd_rd_dst
);
349 printf("icmp6: redirect %s",
350 getname6((const u_char
*)&RDR(dp
)->nd_rd_dst
));
352 getname6((const u_char
*)&RDR(dp
)->nd_rd_target
));
353 #define REDIRECTLEN 40
355 icmp6_opt_print((const u_char
*)dp
+ REDIRECTLEN
,
356 icmp6len
- REDIRECTLEN
);
361 #ifndef ICMP6_ROUTER_RENUMBERING
362 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
364 case ICMP6_ROUTER_RENUMBERING
:
365 switch (dp
->icmp6_code
) {
366 #ifndef ICMP6_ROUTER_RENUMBERING_COMMAND
367 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
369 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
370 printf("icmp6: router renum command");
372 #ifndef ICMP6_ROUTER_RENUMBERING_RESULT
373 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
375 case ICMP6_ROUTER_RENUMBERING_RESULT
:
376 printf("icmp6: router renum result");
379 printf("icmp6: router renum code-#%d", dp
->icmp6_code
);
383 #ifdef HAVE_STRUCT_ICMP6_NODEINFO
384 #ifndef ICMP6_NI_QUERY
385 #define ICMP6_NI_QUERY 139
388 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
390 #ifndef ICMP6_NI_REPLY
391 #define ICMP6_NI_REPLY 140
394 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
398 printf("icmp6: type-#%d", dp
->icmp6_type
);
403 fputs("[|icmp6]", stdout
);
410 icmp6_opt_print(register const u_char
*bp
, int resid
)
412 register const struct nd_opt_hdr
*op
;
413 register const struct nd_opt_hdr
*opl
; /* why there's no struct? */
414 register const struct nd_opt_prefix_info
*opp
;
415 register const struct icmp6_opts_redirect
*opr
;
416 register const struct nd_opt_mtu
*opm
;
417 register const u_char
*ep
;
420 register const struct ip6_hdr
*ip
;
421 register const char *str
;
422 register const struct ip6_hdr
*oip
;
423 register const struct udphdr
*ouh
;
424 register int hlen
, dport
;
428 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
430 op
= (struct nd_opt_hdr
*)bp
;
432 ip
= (struct ip6_hdr
*)bp2
;
433 oip
= &dp
->icmp6_ip6
;
436 /* 'ep' points to the end of avaible data. */
439 ECHECK(op
->nd_opt_len
);
442 switch (op
->nd_opt_type
) {
443 case ND_OPT_SOURCE_LINKADDR
:
444 opl
= (struct nd_opt_hdr
*)op
;
446 if ((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) > ep
)
449 TCHECK((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) - 1);
451 printf("(src lladdr: %s", /*)*/
452 etheraddr_string((u_char
*)(opl
+ 1)));
453 if (opl
->nd_opt_len
!= 1)
457 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
458 resid
- (op
->nd_opt_len
<< 3));
460 case ND_OPT_TARGET_LINKADDR
:
461 opl
= (struct nd_opt_hdr
*)op
;
463 if ((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) > ep
)
466 TCHECK((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) - 1);
468 printf("(tgt lladdr: %s", /*)*/
469 etheraddr_string((u_char
*)(opl
+ 1)));
470 if (opl
->nd_opt_len
!= 1)
474 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
475 resid
- (op
->nd_opt_len
<< 3));
477 case ND_OPT_PREFIX_INFORMATION
:
478 opp
= (struct nd_opt_prefix_info
*)op
;
479 TCHECK(opp
->nd_opt_pi_prefix
);
480 printf("(prefix info: "); /*)*/
481 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ONLINK
)
483 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_AUTO
)
485 if (opp
->nd_opt_pi_flags_reserved
)
487 printf("valid_ltime=");
488 if ((u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
) == ~0U)
491 printf("%u", (u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
));
494 printf("preffered_ltime=");
495 if ((u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
) == ~0U)
498 printf("%u", (u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
));
501 printf("prefix=%s/%d", ip6addr_string(&opp
->nd_opt_pi_prefix
),
502 opp
->nd_opt_pi_prefix_len
);
503 if (opp
->nd_opt_pi_len
!= 4)
507 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
508 resid
- (op
->nd_opt_len
<< 3));
510 case ND_OPT_REDIRECTED_HEADER
:
511 opr
= (struct icmp6_opts_redirect
*)op
;
512 printf("(redirect)");
514 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
515 resid
- (op
->nd_opt_len
<< 3));
518 opm
= (struct nd_opt_mtu
*)op
;
519 TCHECK(opm
->nd_opt_mtu_mtu
);
520 printf("(mtu: "); /*)*/
521 printf("mtu=%u", (u_int32_t
)ntohl(opm
->nd_opt_mtu_mtu
));
522 if (opm
->nd_opt_mtu_len
!= 1)
525 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
526 resid
- (op
->nd_opt_len
<< 3));
529 opts_len
= op
->nd_opt_len
;
530 printf("(unknwon opt_type=%d, opt_len=%d)",
531 op
->nd_opt_type
, opts_len
);
533 opts_len
= 1; /* XXX */
534 icmp6_opt_print((const u_char
*)op
+ (opts_len
<< 3),
535 resid
- (opts_len
<< 3));
540 fputs("[ndp opt]", stdout
);
545 #if defined(HAVE_STRUCT_MLD6_HDR)
547 mld6_print(register const u_char
*bp
)
549 register struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
550 register const u_char
*ep
;
552 /* 'ep' points to the end of avaible data. */
555 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
558 printf("max resp delay: %d ", ntohs(mp
->mld6_maxdelay
));
559 printf("addr: %s", ip6addr_string(&mp
->mld6_addr
));
562 #elif defined(HAVE_STRUCT_ICMP6_MLD)
565 mld6_print(register const u_char
*bp
)
567 register struct icmp6_mld
*mp
= (struct icmp6_mld
*)bp
;
568 register const u_char
*ep
;
570 /* 'ep' points to the end of avaible data. */
573 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
576 printf("max resp delay: %d ", ntohs(mp
->icmp6m_hdr
.icmp6_maxdelay
));
577 printf("addr: %s", ip6addr_string(&mp
->icmp6m_group
));
582 #ifdef HAVE_STRUCT_ICMP6_NODEINFO
584 dnsname_print(const u_char
*cp
, const u_char
*ep
)
588 /* DNS name decoding - no decompression */
597 while (i
-- && cp
< ep
) {
601 if (cp
+ 1 < ep
&& *cp
)
607 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
620 icmp6_nodeinfo_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
622 struct icmp6_nodeinfo
*ni6
;
623 struct icmp6_hdr
*dp
;
628 dp
= (struct icmp6_hdr
*)bp
;
629 ni6
= (struct icmp6_nodeinfo
*)bp
;
632 switch (ni6
->ni_type
) {
634 if (siz
== sizeof(*dp
) + 4) {
635 /* KAME who-are-you */
636 printf("icmp6: who-are-you request");
639 printf("icmp6: node information query");
641 TCHECK2(*dp
, sizeof(*ni6
));
642 ni6
= (struct icmp6_nodeinfo
*)dp
;
644 switch (ntohs(ni6
->ni_qtype
)) {
648 case NI_QTYPE_SUPTYPES
:
649 printf("supported qtypes");
650 i
= ntohs(ni6
->ni_flags
);
652 printf(" [%s]", (i
& 0x01) ? "C" : "");
658 case NI_QTYPE_NODEADDR
:
659 printf("node addresses");
663 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
664 printf(" [%s%s%s%s%s%s]",
665 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
666 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
667 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
668 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
669 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
670 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "");
677 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
678 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
679 if (siz
!= sizeof(*ni6
))
681 printf(", invalid len");
688 /* XXX backward compat, icmp-name-lookup-03 */
689 if (siz
== sizeof(*ni6
)) {
690 printf(", 03 draft");
696 switch (ni6
->ni_code
) {
697 case ICMP6_NI_SUBJ_IPV6
:
699 sizeof(*ni6
) + sizeof(struct in6_addr
)))
701 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
703 printf(", invalid subject len");
706 printf(", subject=%s",
707 getname6((const u_char
*)(ni6
+ 1)));
709 case ICMP6_NI_SUBJ_FQDN
:
710 printf(", subject=DNS name");
711 cp
= (const u_char
*)(ni6
+ 1);
712 if (cp
[0] == ep
- cp
- 1) {
713 /* icmp-name-lookup-03, pascal string */
715 printf(", 03 draft");
724 dnsname_print(cp
, ep
);
726 case ICMP6_NI_SUBJ_IPV4
:
727 if (!TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
729 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
731 printf(", invalid subject len");
734 printf(", subject=%s",
735 getname((const u_char
*)(ni6
+ 1)));
738 printf(", unknown subject");
747 if (icmp6len
> siz
) {
748 printf("[|icmp6: node information reply]");
754 ni6
= (struct icmp6_nodeinfo
*)dp
;
755 printf("icmp6: node information reply");
757 switch (ni6
->ni_code
) {
758 case ICMP6_NI_SUCCESS
:
764 case ICMP6_NI_REFUSED
:
767 if (siz
!= sizeof(*ni6
))
769 printf(", invalid length");
771 case ICMP6_NI_UNKNOWN
:
774 if (siz
!= sizeof(*ni6
))
776 printf(", invalid length");
780 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
786 switch (ntohs(ni6
->ni_qtype
)) {
791 if (siz
!= sizeof(*ni6
))
793 printf(", invalid length");
795 case NI_QTYPE_SUPTYPES
:
798 printf("supported qtypes");
799 i
= ntohs(ni6
->ni_flags
);
801 printf(" [%s]", (i
& 0x01) ? "C" : "");
807 cp
= (const u_char
*)(ni6
+ 1) + 4;
808 if (cp
[0] == ep
- cp
- 1) {
809 /* icmp-name-lookup-03, pascal string */
811 printf(", 03 draft");
820 dnsname_print(cp
, ep
);
821 if ((ntohs(ni6
->ni_flags
) & 0x01) != 0)
822 printf(" [TTL=%u]", *(u_int32_t
*)(ni6
+ 1));
824 case NI_QTYPE_NODEADDR
:
827 printf("node addresses");
830 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
832 printf(" %s", getname6(bp
+ i
));
833 i
+= sizeof(struct in6_addr
);
834 printf("(%d)", ntohl(*(int32_t *)(bp
+ i
)));
835 i
+= sizeof(int32_t);
840 printf(" [%s%s%s%s%s%s%s]",
841 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
842 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
843 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
844 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
845 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
846 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
847 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : "");
863 fputs("[|icmp6]", stdout
);