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.49 2001-05-10 05:30:21 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 void icmp6_opt_print(const u_char
*, int);
58 void mld6_print(const u_char
*);
59 static struct udphdr
*get_upperlayer(u_char
*, int *);
60 static void dnsname_print(const u_char
*, const u_char
*);
61 void icmp6_nodeinfo_print(int, const u_char
*, const u_char
*);
62 void icmp6_rrenum_print(int, const u_char
*, const u_char
*);
65 #define abs(a) ((0 < (a)) ? (a) : -(a))
68 static char *rtpref_str
[] = {
76 icmp6_print(register const u_char
*bp
, register const u_char
*bp2
)
78 const struct icmp6_hdr
*dp
;
79 register const struct ip6_hdr
*ip
;
80 register const char *str
;
81 register const struct ip6_hdr
*oip
;
82 register const struct udphdr
*ouh
;
84 register const u_char
*ep
;
89 #define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
92 dp
= (struct icmp6_hdr
*)bp
;
93 ip
= (struct ip6_hdr
*)bp2
;
94 oip
= (struct ip6_hdr
*)(dp
+ 1);
96 /* 'ep' points to the end of available data. */
99 icmp6len
= (ntohs(ip
->ip6_plen
) + sizeof(struct ip6_hdr
) -
101 else /* XXX: jumbo payload case... */
102 icmp6len
= snapend
- bp
;
105 (void)printf("%s > %s: ",
106 ip6addr_string(&ip
->ip6_src
),
107 ip6addr_string(&ip
->ip6_dst
));
110 TCHECK(dp
->icmp6_code
);
111 switch (dp
->icmp6_type
) {
112 case ICMP6_DST_UNREACH
:
113 TCHECK(oip
->ip6_dst
);
114 switch (dp
->icmp6_code
) {
115 case ICMP6_DST_UNREACH_NOROUTE
:
116 printf("icmp6: %s unreachable route",
117 ip6addr_string(&oip
->ip6_dst
));
119 case ICMP6_DST_UNREACH_ADMIN
:
120 printf("icmp6: %s unreachable prohibited",
121 ip6addr_string(&oip
->ip6_dst
));
123 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
124 printf("icmp6: %s beyond scope of source address %s",
125 ip6addr_string(&oip
->ip6_dst
),
126 ip6addr_string(&oip
->ip6_src
));
128 case ICMP6_DST_UNREACH_ADDR
:
129 printf("icmp6: %s unreachable address",
130 ip6addr_string(&oip
->ip6_dst
));
132 case ICMP6_DST_UNREACH_NOPORT
:
133 if ((ouh
= get_upperlayer((u_char
*)oip
, &prot
))
137 dport
= ntohs(ouh
->uh_dport
);
140 printf("icmp6: %s tcp port %s unreachable",
141 ip6addr_string(&oip
->ip6_dst
),
142 tcpport_string(dport
));
145 printf("icmp6: %s udp port %s unreachable",
146 ip6addr_string(&oip
->ip6_dst
),
147 udpport_string(dport
));
150 printf("icmp6: %s protocol %d port %d unreachable",
151 ip6addr_string(&oip
->ip6_dst
),
152 oip
->ip6_nxt
, dport
);
157 printf("icmp6: %s unreachable code-#%d",
158 ip6addr_string(&oip
->ip6_dst
),
163 case ICMP6_PACKET_TOO_BIG
:
164 TCHECK(dp
->icmp6_mtu
);
165 printf("icmp6: too big %u", (u_int32_t
)ntohl(dp
->icmp6_mtu
));
167 case ICMP6_TIME_EXCEEDED
:
168 TCHECK(oip
->ip6_dst
);
169 switch (dp
->icmp6_code
) {
170 case ICMP6_TIME_EXCEED_TRANSIT
:
171 printf("icmp6: time exceeded in-transit for %s",
172 ip6addr_string(&oip
->ip6_dst
));
174 case ICMP6_TIME_EXCEED_REASSEMBLY
:
175 printf("icmp6: ip6 reassembly time exceeded");
178 printf("icmp6: time exceeded code-#%d",
183 case ICMP6_PARAM_PROB
:
184 TCHECK(oip
->ip6_dst
);
185 switch (dp
->icmp6_code
) {
186 case ICMP6_PARAMPROB_HEADER
:
187 printf("icmp6: parameter problem errorneous - octet %u",
188 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
190 case ICMP6_PARAMPROB_NEXTHEADER
:
191 printf("icmp6: parameter problem next header - octet %u",
192 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
194 case ICMP6_PARAMPROB_OPTION
:
195 printf("icmp6: parameter problem option - octet %u",
196 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
199 printf("icmp6: parameter problem code-#%d",
204 case ICMP6_ECHO_REQUEST
:
205 printf("icmp6: echo request");
207 case ICMP6_ECHO_REPLY
:
208 printf("icmp6: echo reply");
210 case ICMP6_MEMBERSHIP_QUERY
:
211 printf("icmp6: multicast listener query ");
212 mld6_print((const u_char
*)dp
);
214 case ICMP6_MEMBERSHIP_REPORT
:
215 printf("icmp6: multicast listener report ");
216 mld6_print((const u_char
*)dp
);
218 case ICMP6_MEMBERSHIP_REDUCTION
:
219 printf("icmp6: multicast listener done ");
220 mld6_print((const u_char
*)dp
);
222 case ND_ROUTER_SOLICIT
:
223 printf("icmp6: router solicitation ");
226 icmp6_opt_print((const u_char
*)dp
+ RTSOLLEN
,
227 icmp6len
- RTSOLLEN
);
230 case ND_ROUTER_ADVERT
:
231 printf("icmp6: router advertisement");
233 struct nd_router_advert
*p
;
236 p
= (struct nd_router_advert
*)dp
;
237 TCHECK(p
->nd_ra_retransmit
);
238 printf("(chlim=%d, ", (int)p
->nd_ra_curhoplimit
);
239 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_MANAGED
)
241 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_OTHER
)
243 #ifndef ND_RA_FLAG_HA
244 #define ND_RA_FLAG_HA 0x20
246 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_HA
)
248 #ifndef ND_RA_FLAG_RTPREF_MASK
249 #define ND_RA_FLAG_RTPREF_MASK 0x18
252 if ((p
->nd_ra_flags_reserved
& ~ND_RA_FLAG_RTPREF_MASK
)
256 rtpref
= ((p
->nd_ra_flags_reserved
& ND_RA_FLAG_RTPREF_MASK
) >> 3) & 0xff;
257 printf("pref=%s, ", rtpref_str
[rtpref
]);
259 printf("router_ltime=%d, ", ntohs(p
->nd_ra_router_lifetime
));
260 printf("reachable_time=%u, ",
261 (u_int32_t
)ntohl(p
->nd_ra_reachable
));
262 printf("retrans_time=%u)",
263 (u_int32_t
)ntohl(p
->nd_ra_retransmit
));
265 icmp6_opt_print((const u_char
*)dp
+ RTADVLEN
,
266 icmp6len
- RTADVLEN
);
269 case ND_NEIGHBOR_SOLICIT
:
271 struct nd_neighbor_solicit
*p
;
272 p
= (struct nd_neighbor_solicit
*)dp
;
273 TCHECK(p
->nd_ns_target
);
274 printf("icmp6: neighbor sol: who has %s",
275 ip6addr_string(&p
->nd_ns_target
));
278 icmp6_opt_print((const u_char
*)dp
+ NDSOLLEN
,
279 icmp6len
- NDSOLLEN
);
283 case ND_NEIGHBOR_ADVERT
:
285 struct nd_neighbor_advert
*p
;
287 p
= (struct nd_neighbor_advert
*)dp
;
288 TCHECK(p
->nd_na_target
);
289 printf("icmp6: neighbor adv: tgt is %s",
290 ip6addr_string(&p
->nd_na_target
));
292 #define ND_NA_FLAG_ALL \
293 (ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
294 /* we don't need ntohl() here. see advanced-api-04. */
295 if (p
->nd_na_flags_reserved
& ND_NA_FLAG_ALL
) {
296 #undef ND_NA_FLAG_ALL
299 flags
= p
->nd_na_flags_reserved
;
301 if (flags
& ND_NA_FLAG_ROUTER
)
303 if (flags
& ND_NA_FLAG_SOLICITED
)
305 if (flags
& ND_NA_FLAG_OVERRIDE
)
310 icmp6_opt_print((const u_char
*)dp
+ NDADVLEN
,
311 icmp6len
- NDADVLEN
);
317 #define RDR(i) ((struct nd_redirect *)(i))
318 TCHECK(RDR(dp
)->nd_rd_dst
);
319 printf("icmp6: redirect %s",
320 getname6((const u_char
*)&RDR(dp
)->nd_rd_dst
));
322 getname6((const u_char
*)&RDR(dp
)->nd_rd_target
));
323 #define REDIRECTLEN 40
325 icmp6_opt_print((const u_char
*)dp
+ REDIRECTLEN
,
326 icmp6len
- REDIRECTLEN
);
331 case ICMP6_ROUTER_RENUMBERING
:
332 icmp6_rrenum_print(icmp6len
, bp
, ep
);
336 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
339 printf("icmp6: type-#%d", dp
->icmp6_type
);
344 fputs("[|icmp6]", stdout
);
350 static struct udphdr
*
351 get_upperlayer(register u_char
*bp
, int *prot
)
353 register const u_char
*ep
;
354 struct ip6_hdr
*ip6
= (struct ip6_hdr
*)bp
;
357 struct ip6_frag
*fragh
;
361 /* 'ep' points to the end of available data. */
364 if (TTEST(ip6
->ip6_nxt
) == 0)
368 hlen
= sizeof(struct ip6_hdr
);
370 while (bp
< snapend
) {
376 uh
= (struct udphdr
*)bp
;
377 if (TTEST(uh
->uh_dport
)) {
385 case IPPROTO_HOPOPTS
:
386 case IPPROTO_DSTOPTS
:
387 case IPPROTO_ROUTING
:
388 hbh
= (struct ip6_hbh
*)bp
;
389 if (TTEST(hbh
->ip6h_len
) == 0)
392 hlen
= (hbh
->ip6h_len
+ 1) << 3;
395 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
396 fragh
= (struct ip6_frag
*)bp
;
397 if (TTEST(fragh
->ip6f_offlg
) == 0)
399 /* fragments with non-zero offset are meaningless */
400 if ((fragh
->ip6f_offlg
& IP6F_OFF_MASK
) != 0)
402 nh
= fragh
->ip6f_nxt
;
403 hlen
= sizeof(struct ip6_frag
);
407 ah
= (struct ah
*)bp
;
408 if (TTEST(ah
->ah_len
) == 0)
411 hlen
= (ah
->ah_len
+ 2) << 2;
414 default: /* unknown or undecodable header */
415 *prot
= nh
; /* meaningless, but set here anyway */
420 return(NULL
); /* should be notreached, though */
424 icmp6_opt_print(register const u_char
*bp
, int resid
)
426 register const struct nd_opt_hdr
*op
;
427 register const struct nd_opt_hdr
*opl
; /* why there's no struct? */
428 register const struct nd_opt_prefix_info
*opp
;
429 register const struct icmp6_opts_redirect
*opr
;
430 register const struct nd_opt_mtu
*opm
;
431 register const struct nd_opt_advinterval
*opa
;
432 register const u_char
*ep
;
435 register const struct ip6_hdr
*ip
;
436 register const char *str
;
437 register const struct ip6_hdr
*oip
;
438 register const struct udphdr
*ouh
;
439 register int hlen
, dport
;
443 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
445 op
= (struct nd_opt_hdr
*)bp
;
447 ip
= (struct ip6_hdr
*)bp2
;
448 oip
= &dp
->icmp6_ip6
;
451 /* 'ep' points to the end of available data. */
454 ECHECK(op
->nd_opt_len
);
457 switch (op
->nd_opt_type
) {
458 case ND_OPT_SOURCE_LINKADDR
:
459 opl
= (struct nd_opt_hdr
*)op
;
461 if ((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) > ep
)
464 TCHECK((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) - 1);
466 printf("(src lladdr: %s", /*)*/
467 etheraddr_string((u_char
*)(opl
+ 1)));
468 if (opl
->nd_opt_len
!= 1)
472 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
473 resid
- (op
->nd_opt_len
<< 3));
475 case ND_OPT_TARGET_LINKADDR
:
476 opl
= (struct nd_opt_hdr
*)op
;
478 if ((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) > ep
)
481 TCHECK((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) - 1);
483 printf("(tgt lladdr: %s", /*)*/
484 etheraddr_string((u_char
*)(opl
+ 1)));
485 if (opl
->nd_opt_len
!= 1)
489 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
490 resid
- (op
->nd_opt_len
<< 3));
492 case ND_OPT_PREFIX_INFORMATION
:
493 opp
= (struct nd_opt_prefix_info
*)op
;
494 TCHECK(opp
->nd_opt_pi_prefix
);
495 printf("(prefix info: "); /*)*/
496 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ONLINK
)
498 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_AUTO
)
500 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ROUTER
)
502 if (opp
->nd_opt_pi_flags_reserved
)
504 printf("valid_ltime=");
505 if ((u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
) == ~0U)
508 printf("%u", (u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
));
511 printf("preferred_ltime=");
512 if ((u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
) == ~0U)
515 printf("%u", (u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
));
518 printf("prefix=%s/%d", ip6addr_string(&opp
->nd_opt_pi_prefix
),
519 opp
->nd_opt_pi_prefix_len
);
520 if (opp
->nd_opt_pi_len
!= 4)
524 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
525 resid
- (op
->nd_opt_len
<< 3));
527 case ND_OPT_REDIRECTED_HEADER
:
528 opr
= (struct icmp6_opts_redirect
*)op
;
529 printf("(redirect)");
531 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
532 resid
- (op
->nd_opt_len
<< 3));
535 opm
= (struct nd_opt_mtu
*)op
;
536 TCHECK(opm
->nd_opt_mtu_mtu
);
537 printf("(mtu: "); /*)*/
538 printf("mtu=%u", (u_int32_t
)ntohl(opm
->nd_opt_mtu_mtu
));
539 if (opm
->nd_opt_mtu_len
!= 1)
542 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
543 resid
- (op
->nd_opt_len
<< 3));
545 case ND_OPT_ADVINTERVAL
:
546 opa
= (struct nd_opt_advinterval
*)op
;
547 TCHECK(opa
->nd_opt_adv_interval
);
548 printf("(advint: "); /*)*/
550 (u_int32_t
)ntohl(opa
->nd_opt_adv_interval
));
553 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
554 resid
- (op
->nd_opt_len
<< 3));
557 opts_len
= op
->nd_opt_len
;
558 printf("(unknwon opt_type=%d, opt_len=%d)",
559 op
->nd_opt_type
, opts_len
);
561 opts_len
= 1; /* XXX */
562 icmp6_opt_print((const u_char
*)op
+ (opts_len
<< 3),
563 resid
- (opts_len
<< 3));
568 fputs("[ndp opt]", stdout
);
574 mld6_print(register const u_char
*bp
)
576 register struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
577 register const u_char
*ep
;
579 /* 'ep' points to the end of available data. */
582 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
585 printf("max resp delay: %d ", ntohs(mp
->mld6_maxdelay
));
586 printf("addr: %s", ip6addr_string(&mp
->mld6_addr
));
590 dnsname_print(const u_char
*cp
, const u_char
*ep
)
594 /* DNS name decoding - no decompression */
603 while (i
-- && cp
< ep
) {
607 if (cp
+ 1 < ep
&& *cp
)
613 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
626 icmp6_nodeinfo_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
628 struct icmp6_nodeinfo
*ni6
;
629 struct icmp6_hdr
*dp
;
634 dp
= (struct icmp6_hdr
*)bp
;
635 ni6
= (struct icmp6_nodeinfo
*)bp
;
638 switch (ni6
->ni_type
) {
640 if (siz
== sizeof(*dp
) + 4) {
641 /* KAME who-are-you */
642 printf("icmp6: who-are-you request");
645 printf("icmp6: node information query");
647 TCHECK2(*dp
, sizeof(*ni6
));
648 ni6
= (struct icmp6_nodeinfo
*)dp
;
650 switch (ntohs(ni6
->ni_qtype
)) {
654 case NI_QTYPE_SUPTYPES
:
655 printf("supported qtypes");
656 i
= ntohs(ni6
->ni_flags
);
658 printf(" [%s]", (i
& 0x01) ? "C" : "");
664 case NI_QTYPE_NODEADDR
:
665 printf("node addresses");
669 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
670 printf(" [%s%s%s%s%s%s]",
671 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
672 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
673 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
674 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
675 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
676 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "");
683 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
684 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
685 if (siz
!= sizeof(*ni6
))
687 printf(", invalid len");
694 /* XXX backward compat, icmp-name-lookup-03 */
695 if (siz
== sizeof(*ni6
)) {
696 printf(", 03 draft");
702 switch (ni6
->ni_code
) {
703 case ICMP6_NI_SUBJ_IPV6
:
705 sizeof(*ni6
) + sizeof(struct in6_addr
)))
707 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
709 printf(", invalid subject len");
712 printf(", subject=%s",
713 getname6((const u_char
*)(ni6
+ 1)));
715 case ICMP6_NI_SUBJ_FQDN
:
716 printf(", subject=DNS name");
717 cp
= (const u_char
*)(ni6
+ 1);
718 if (cp
[0] == ep
- cp
- 1) {
719 /* icmp-name-lookup-03, pascal string */
721 printf(", 03 draft");
730 dnsname_print(cp
, ep
);
732 case ICMP6_NI_SUBJ_IPV4
:
733 if (!TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
735 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
737 printf(", invalid subject len");
740 printf(", subject=%s",
741 getname((const u_char
*)(ni6
+ 1)));
744 printf(", unknown subject");
753 if (icmp6len
> siz
) {
754 printf("[|icmp6: node information reply]");
760 ni6
= (struct icmp6_nodeinfo
*)dp
;
761 printf("icmp6: node information reply");
763 switch (ni6
->ni_code
) {
764 case ICMP6_NI_SUCCESS
:
770 case ICMP6_NI_REFUSED
:
773 if (siz
!= sizeof(*ni6
))
775 printf(", invalid length");
777 case ICMP6_NI_UNKNOWN
:
780 if (siz
!= sizeof(*ni6
))
782 printf(", invalid length");
786 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
792 switch (ntohs(ni6
->ni_qtype
)) {
797 if (siz
!= sizeof(*ni6
))
799 printf(", invalid length");
801 case NI_QTYPE_SUPTYPES
:
804 printf("supported qtypes");
805 i
= ntohs(ni6
->ni_flags
);
807 printf(" [%s]", (i
& 0x01) ? "C" : "");
813 cp
= (const u_char
*)(ni6
+ 1) + 4;
814 if (cp
[0] == ep
- cp
- 1) {
815 /* icmp-name-lookup-03, pascal string */
817 printf(", 03 draft");
826 dnsname_print(cp
, ep
);
827 if ((ntohs(ni6
->ni_flags
) & 0x01) != 0)
828 printf(" [TTL=%u]", *(u_int32_t
*)(ni6
+ 1));
830 case NI_QTYPE_NODEADDR
:
833 printf("node addresses");
836 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
838 printf(" %s", getname6(bp
+ i
));
839 i
+= sizeof(struct in6_addr
);
840 printf("(%d)", (int32_t)ntohl(*(int32_t *)(bp
+ i
)));
841 i
+= sizeof(int32_t);
846 printf(" [%s%s%s%s%s%s%s]",
847 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
848 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
849 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
850 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
851 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
852 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
853 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : "");
869 fputs("[|icmp6]", stdout
);
873 icmp6_rrenum_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
875 struct icmp6_router_renum
*rr6
;
876 struct icmp6_hdr
*dp
;
879 struct rr_pco_match
*match
;
880 struct rr_pco_use
*use
;
881 char hbuf
[NI_MAXHOST
];
884 dp
= (struct icmp6_hdr
*)bp
;
885 rr6
= (struct icmp6_router_renum
*)bp
;
887 cp
= (const char *)(rr6
+ 1);
889 TCHECK(rr6
->rr_reserved
);
890 switch (rr6
->rr_code
) {
891 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
892 printf("router renum: command");
894 case ICMP6_ROUTER_RENUMBERING_RESULT
:
895 printf("router renum: result");
897 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
898 printf("router renum: sequence number reset");
901 printf("router renum: code-#%d", rr6
->rr_code
);
905 printf(", seq=%u", (u_int32_t
)ntohl(rr6
->rr_seqnum
));
908 #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
911 printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
912 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
913 F(ICMP6_RR_FLAGS_FORCEAPPLY
, "A"),
914 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
915 F(ICMP6_RR_FLAGS_PREVDONE
, "P"));
917 printf("seg=%u,", rr6
->rr_segnum
);
918 printf("maxdelay=%u", rr6
->rr_maxdelay
);
919 if (rr6
->rr_reserved
)
920 printf("rsvd=0x%x", (u_int16_t
)ntohs(rr6
->rr_reserved
));
926 if (rr6
->rr_code
== ICMP6_ROUTER_RENUMBERING_COMMAND
) {
927 match
= (struct rr_pco_match
*)cp
;
928 cp
= (const char *)(match
+ 1);
930 TCHECK(match
->rpm_prefix
);
936 printf("match("); /*)*/
937 switch (match
->rpm_code
) {
938 case RPM_PCO_ADD
: printf("add"); break;
939 case RPM_PCO_CHANGE
: printf("change"); break;
940 case RPM_PCO_SETGLOBAL
: printf("setglobal"); break;
941 default: printf("#%u", match
->rpm_code
); break;
945 printf(",ord=%u", match
->rpm_ordinal
);
946 printf(",min=%u", match
->rpm_minlen
);
947 printf(",max=%u", match
->rpm_maxlen
);
949 if (inet_ntop(AF_INET6
, &match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
950 printf(",%s/%u", hbuf
, match
->rpm_matchlen
);
952 printf(",?/%u", match
->rpm_matchlen
);
956 n
= match
->rpm_len
- 3;
961 use
= (struct rr_pco_use
*)cp
;
962 cp
= (const char *)(use
+ 1);
964 TCHECK(use
->rpu_prefix
);
970 printf("use("); /*)*/
971 if (use
->rpu_flags
) {
972 #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
974 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
975 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P"));
979 printf("mask=0x%x,", use
->rpu_ramask
);
980 printf("raflags=0x%x,", use
->rpu_raflags
);
981 if (~use
->rpu_vltime
== 0)
982 printf("vltime=infty,");
985 (u_int32_t
)ntohl(use
->rpu_vltime
));
986 if (~use
->rpu_pltime
== 0)
987 printf("pltime=infty,");
990 (u_int32_t
)ntohl(use
->rpu_pltime
));
992 if (inet_ntop(AF_INET6
, &use
->rpu_prefix
, hbuf
,
994 printf("%s/%u/%u", hbuf
, use
->rpu_uselen
,
997 printf("?/%u/%u", use
->rpu_uselen
,
1007 fputs("[|icmp6]", stdout
);