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.54 2001-06-01 23:01:04 itojun 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 static const char *get_rtpref(u_int
);
58 static const char *get_lifetime(u_int32_t
);
59 static void print_lladdr(const u_char
*, size_t);
60 void icmp6_opt_print(const u_char
*, int);
61 void mld6_print(const u_char
*);
62 static struct udphdr
*get_upperlayer(u_char
*, int *);
63 static void dnsname_print(const u_char
*, const u_char
*);
64 void icmp6_nodeinfo_print(int, const u_char
*, const u_char
*);
65 void icmp6_rrenum_print(int, const u_char
*, const u_char
*);
68 #define abs(a) ((0 < (a)) ? (a) : -(a))
74 static const char *rtpref_str
[] = {
81 return rtpref_str
[((v
& ND_RA_FLAG_RTPREF_MASK
) >> 3) & 0xff];
85 get_lifetime(u_int32_t v
)
89 if (v
== (u_int32_t
)~0UL)
92 snprintf(buf
, sizeof(buf
), "%u", v
);
98 print_lladdr(const u_int8_t
*p
, size_t l
)
100 const u_int8_t
*ep
, *q
;
104 while (l
> 0 && q
< ep
) {
107 printf("%02x", *q
++);
113 icmp6_print(const u_char
*bp
, const u_char
*bp2
)
115 const struct icmp6_hdr
*dp
;
116 const struct ip6_hdr
*ip
;
118 const struct ip6_hdr
*oip
;
119 const struct udphdr
*ouh
;
126 #define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
129 dp
= (struct icmp6_hdr
*)bp
;
130 ip
= (struct ip6_hdr
*)bp2
;
131 oip
= (struct ip6_hdr
*)(dp
+ 1);
133 /* 'ep' points to the end of available data. */
136 icmp6len
= (ntohs(ip
->ip6_plen
) + sizeof(struct ip6_hdr
) -
138 else /* XXX: jumbo payload case... */
139 icmp6len
= snapend
- bp
;
142 (void)printf("%s > %s: ",
143 ip6addr_string(&ip
->ip6_src
),
144 ip6addr_string(&ip
->ip6_dst
));
147 TCHECK(dp
->icmp6_code
);
148 switch (dp
->icmp6_type
) {
149 case ICMP6_DST_UNREACH
:
150 TCHECK(oip
->ip6_dst
);
151 switch (dp
->icmp6_code
) {
152 case ICMP6_DST_UNREACH_NOROUTE
:
153 printf("icmp6: %s unreachable route",
154 ip6addr_string(&oip
->ip6_dst
));
156 case ICMP6_DST_UNREACH_ADMIN
:
157 printf("icmp6: %s unreachable prohibited",
158 ip6addr_string(&oip
->ip6_dst
));
160 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
161 printf("icmp6: %s beyond scope of source address %s",
162 ip6addr_string(&oip
->ip6_dst
),
163 ip6addr_string(&oip
->ip6_src
));
165 case ICMP6_DST_UNREACH_ADDR
:
166 printf("icmp6: %s unreachable address",
167 ip6addr_string(&oip
->ip6_dst
));
169 case ICMP6_DST_UNREACH_NOPORT
:
170 if ((ouh
= get_upperlayer((u_char
*)oip
, &prot
))
174 dport
= ntohs(ouh
->uh_dport
);
177 printf("icmp6: %s tcp port %s unreachable",
178 ip6addr_string(&oip
->ip6_dst
),
179 tcpport_string(dport
));
182 printf("icmp6: %s udp port %s unreachable",
183 ip6addr_string(&oip
->ip6_dst
),
184 udpport_string(dport
));
187 printf("icmp6: %s protocol %d port %d unreachable",
188 ip6addr_string(&oip
->ip6_dst
),
189 oip
->ip6_nxt
, dport
);
194 printf("icmp6: %s unreachable code-#%d",
195 ip6addr_string(&oip
->ip6_dst
),
200 case ICMP6_PACKET_TOO_BIG
:
201 TCHECK(dp
->icmp6_mtu
);
202 printf("icmp6: too big %u", (u_int32_t
)ntohl(dp
->icmp6_mtu
));
204 case ICMP6_TIME_EXCEEDED
:
205 TCHECK(oip
->ip6_dst
);
206 switch (dp
->icmp6_code
) {
207 case ICMP6_TIME_EXCEED_TRANSIT
:
208 printf("icmp6: time exceeded in-transit for %s",
209 ip6addr_string(&oip
->ip6_dst
));
211 case ICMP6_TIME_EXCEED_REASSEMBLY
:
212 printf("icmp6: ip6 reassembly time exceeded");
215 printf("icmp6: time exceeded code-#%d",
220 case ICMP6_PARAM_PROB
:
221 TCHECK(oip
->ip6_dst
);
222 switch (dp
->icmp6_code
) {
223 case ICMP6_PARAMPROB_HEADER
:
224 printf("icmp6: parameter problem errorneous - octet %u",
225 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
227 case ICMP6_PARAMPROB_NEXTHEADER
:
228 printf("icmp6: parameter problem next header - octet %u",
229 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
231 case ICMP6_PARAMPROB_OPTION
:
232 printf("icmp6: parameter problem option - octet %u",
233 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
236 printf("icmp6: parameter problem code-#%d",
241 case ICMP6_ECHO_REQUEST
:
242 printf("icmp6: echo request");
244 case ICMP6_ECHO_REPLY
:
245 printf("icmp6: echo reply");
247 case ICMP6_MEMBERSHIP_QUERY
:
248 printf("icmp6: multicast listener query ");
249 mld6_print((const u_char
*)dp
);
251 case ICMP6_MEMBERSHIP_REPORT
:
252 printf("icmp6: multicast listener report ");
253 mld6_print((const u_char
*)dp
);
255 case ICMP6_MEMBERSHIP_REDUCTION
:
256 printf("icmp6: multicast listener done ");
257 mld6_print((const u_char
*)dp
);
259 case ND_ROUTER_SOLICIT
:
260 printf("icmp6: router solicitation ");
263 icmp6_opt_print((const u_char
*)dp
+ RTSOLLEN
,
264 icmp6len
- RTSOLLEN
);
267 case ND_ROUTER_ADVERT
:
268 printf("icmp6: router advertisement");
270 struct nd_router_advert
*p
;
272 p
= (struct nd_router_advert
*)dp
;
273 TCHECK(p
->nd_ra_retransmit
);
274 printf("(chlim=%d, ", (int)p
->nd_ra_curhoplimit
);
275 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_MANAGED
)
277 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_OTHER
)
279 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_HOME_AGENT
)
282 if ((p
->nd_ra_flags_reserved
& ~ND_RA_FLAG_RTPREF_MASK
)
287 get_rtpref(p
->nd_ra_flags_reserved
));
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 case ICMP6_ROUTER_RENUMBERING
:
362 icmp6_rrenum_print(icmp6len
, bp
, ep
);
366 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
369 printf("icmp6: type-#%d", dp
->icmp6_type
);
374 fputs("[|icmp6]", stdout
);
380 static struct udphdr
*
381 get_upperlayer(u_char
*bp
, int *prot
)
384 struct ip6_hdr
*ip6
= (struct ip6_hdr
*)bp
;
387 struct ip6_frag
*fragh
;
391 /* 'ep' points to the end of available data. */
394 if (TTEST(ip6
->ip6_nxt
) == 0)
398 hlen
= sizeof(struct ip6_hdr
);
400 while (bp
< snapend
) {
406 uh
= (struct udphdr
*)bp
;
407 if (TTEST(uh
->uh_dport
)) {
415 case IPPROTO_HOPOPTS
:
416 case IPPROTO_DSTOPTS
:
417 case IPPROTO_ROUTING
:
418 hbh
= (struct ip6_hbh
*)bp
;
419 if (TTEST(hbh
->ip6h_len
) == 0)
422 hlen
= (hbh
->ip6h_len
+ 1) << 3;
425 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
426 fragh
= (struct ip6_frag
*)bp
;
427 if (TTEST(fragh
->ip6f_offlg
) == 0)
429 /* fragments with non-zero offset are meaningless */
430 if ((fragh
->ip6f_offlg
& IP6F_OFF_MASK
) != 0)
432 nh
= fragh
->ip6f_nxt
;
433 hlen
= sizeof(struct ip6_frag
);
437 ah
= (struct ah
*)bp
;
438 if (TTEST(ah
->ah_len
) == 0)
441 hlen
= (ah
->ah_len
+ 2) << 2;
444 default: /* unknown or undecodable header */
445 *prot
= nh
; /* meaningless, but set here anyway */
450 return(NULL
); /* should be notreached, though */
454 icmp6_opt_print(const u_char
*bp
, int resid
)
456 const struct nd_opt_hdr
*op
;
457 const struct nd_opt_hdr
*opl
; /* why there's no struct? */
458 const struct nd_opt_prefix_info
*opp
;
459 const struct icmp6_opts_redirect
*opr
;
460 const struct nd_opt_mtu
*opm
;
461 const struct nd_opt_advinterval
*opa
;
462 const struct nd_opt_route_info
*opri
;
463 const u_char
*cp
, *ep
;
464 struct in6_addr in6
, *in6p
;
467 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
470 /* 'ep' points to the end of available data. */
474 op
= (struct nd_opt_hdr
*)cp
;
476 ECHECK(op
->nd_opt_len
);
479 if (op
->nd_opt_len
== 0)
481 if (cp
+ (op
->nd_opt_len
<< 3) > ep
)
484 switch (op
->nd_opt_type
) {
485 case ND_OPT_SOURCE_LINKADDR
:
486 opl
= (struct nd_opt_hdr
*)op
;
487 printf("(src lladdr: ");
488 l
= (op
->nd_opt_len
<< 3) - 2;
489 print_lladdr(cp
+ 2, l
);
493 case ND_OPT_TARGET_LINKADDR
:
494 opl
= (struct nd_opt_hdr
*)op
;
495 printf("(tgt lladdr: ");
496 l
= (op
->nd_opt_len
<< 3) - 2;
497 print_lladdr(cp
+ 2, l
);
501 case ND_OPT_PREFIX_INFORMATION
:
502 opp
= (struct nd_opt_prefix_info
*)op
;
503 TCHECK(opp
->nd_opt_pi_prefix
);
504 printf("(prefix info: "); /*)*/
505 if (op
->nd_opt_len
!= 4) {
511 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ONLINK
)
513 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_AUTO
)
515 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ROUTER
)
517 if (opp
->nd_opt_pi_flags_reserved
)
519 printf("valid_ltime=%s,",
520 get_lifetime((u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
)));
521 printf("preferred_ltime=%s,",
522 get_lifetime((u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
)));
523 printf("prefix=%s/%d",
524 ip6addr_string(&opp
->nd_opt_pi_prefix
),
525 opp
->nd_opt_pi_prefix_len
);
526 if (opp
->nd_opt_pi_len
!= 4)
531 case ND_OPT_REDIRECTED_HEADER
:
532 opr
= (struct icmp6_opts_redirect
*)op
;
533 printf("(redirect)");
537 opm
= (struct nd_opt_mtu
*)op
;
538 TCHECK(opm
->nd_opt_mtu_mtu
);
539 printf("(mtu:"); /*)*/
540 if (op
->nd_opt_len
!= 1) {
546 printf(" mtu=%u", (u_int32_t
)ntohl(opm
->nd_opt_mtu_mtu
));
547 if (opm
->nd_opt_mtu_len
!= 1)
551 case ND_OPT_ADVINTERVAL
:
552 opa
= (struct nd_opt_advinterval
*)op
;
553 TCHECK(opa
->nd_opt_adv_interval
);
554 printf("(advint:"); /*)*/
556 (u_int32_t
)ntohl(opa
->nd_opt_adv_interval
));
560 case ND_OPT_ROUTE_INFO
:
561 opri
= (struct nd_opt_route_info
*)op
;
562 TCHECK(opri
->nd_opt_rti_lifetime
);
563 memset(&in6
, 0, sizeof(in6
));
564 in6p
= (struct in6_addr
*)(opri
+ 1);
565 switch (op
->nd_opt_len
) {
570 memcpy(&in6
, opri
+ 1, 8);
574 memcpy(&in6
, opri
+ 1, sizeof(in6
));
579 printf("(rtinfo:"); /*)*/
580 printf(" %s/%u", ip6addr_string(&in6
),
581 opri
->nd_opt_rti_prefixlen
);
582 printf(", pref=%s", get_rtpref(opri
->nd_opt_rti_flags
));
583 printf(", lifetime=%s",
584 get_lifetime((u_int32_t
)ntohl(opri
->nd_opt_rti_lifetime
)));
589 printf("(unknwon opt_type=%d, opt_len=%d)",
590 op
->nd_opt_type
, op
->nd_opt_len
);
594 cp
+= op
->nd_opt_len
<< 3;
595 resid
-= op
->nd_opt_len
<< 3;
600 fputs("[ndp opt]", stdout
);
606 mld6_print(const u_char
*bp
)
608 struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
611 /* 'ep' points to the end of available data. */
614 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
617 printf("max resp delay: %d ", ntohs(mp
->mld6_maxdelay
));
618 printf("addr: %s", ip6addr_string(&mp
->mld6_addr
));
622 dnsname_print(const u_char
*cp
, const u_char
*ep
)
626 /* DNS name decoding - no decompression */
635 while (i
-- && cp
< ep
) {
639 if (cp
+ 1 < ep
&& *cp
)
645 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
658 icmp6_nodeinfo_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
660 struct icmp6_nodeinfo
*ni6
;
661 struct icmp6_hdr
*dp
;
666 dp
= (struct icmp6_hdr
*)bp
;
667 ni6
= (struct icmp6_nodeinfo
*)bp
;
670 switch (ni6
->ni_type
) {
672 if (siz
== sizeof(*dp
) + 4) {
673 /* KAME who-are-you */
674 printf("icmp6: who-are-you request");
677 printf("icmp6: node information query");
679 TCHECK2(*dp
, sizeof(*ni6
));
680 ni6
= (struct icmp6_nodeinfo
*)dp
;
682 switch (ntohs(ni6
->ni_qtype
)) {
686 case NI_QTYPE_SUPTYPES
:
687 printf("supported qtypes");
688 i
= ntohs(ni6
->ni_flags
);
690 printf(" [%s]", (i
& 0x01) ? "C" : "");
696 case NI_QTYPE_NODEADDR
:
697 printf("node addresses");
701 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
702 printf(" [%s%s%s%s%s%s]",
703 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
704 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
705 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
706 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
707 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
708 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "");
715 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
716 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
717 if (siz
!= sizeof(*ni6
))
719 printf(", invalid len");
726 /* XXX backward compat, icmp-name-lookup-03 */
727 if (siz
== sizeof(*ni6
)) {
728 printf(", 03 draft");
734 switch (ni6
->ni_code
) {
735 case ICMP6_NI_SUBJ_IPV6
:
737 sizeof(*ni6
) + sizeof(struct in6_addr
)))
739 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
741 printf(", invalid subject len");
744 printf(", subject=%s",
745 getname6((const u_char
*)(ni6
+ 1)));
747 case ICMP6_NI_SUBJ_FQDN
:
748 printf(", subject=DNS name");
749 cp
= (const u_char
*)(ni6
+ 1);
750 if (cp
[0] == ep
- cp
- 1) {
751 /* icmp-name-lookup-03, pascal string */
753 printf(", 03 draft");
762 dnsname_print(cp
, ep
);
764 case ICMP6_NI_SUBJ_IPV4
:
765 if (!TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
767 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
769 printf(", invalid subject len");
772 printf(", subject=%s",
773 getname((const u_char
*)(ni6
+ 1)));
776 printf(", unknown subject");
785 if (icmp6len
> siz
) {
786 printf("[|icmp6: node information reply]");
792 ni6
= (struct icmp6_nodeinfo
*)dp
;
793 printf("icmp6: node information reply");
795 switch (ni6
->ni_code
) {
796 case ICMP6_NI_SUCCESS
:
802 case ICMP6_NI_REFUSED
:
805 if (siz
!= sizeof(*ni6
))
807 printf(", invalid length");
809 case ICMP6_NI_UNKNOWN
:
812 if (siz
!= sizeof(*ni6
))
814 printf(", invalid length");
818 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
824 switch (ntohs(ni6
->ni_qtype
)) {
829 if (siz
!= sizeof(*ni6
))
831 printf(", invalid length");
833 case NI_QTYPE_SUPTYPES
:
836 printf("supported qtypes");
837 i
= ntohs(ni6
->ni_flags
);
839 printf(" [%s]", (i
& 0x01) ? "C" : "");
845 cp
= (const u_char
*)(ni6
+ 1) + 4;
846 if (cp
[0] == ep
- cp
- 1) {
847 /* icmp-name-lookup-03, pascal string */
849 printf(", 03 draft");
858 dnsname_print(cp
, ep
);
859 if ((ntohs(ni6
->ni_flags
) & 0x01) != 0)
860 printf(" [TTL=%u]", *(u_int32_t
*)(ni6
+ 1));
862 case NI_QTYPE_NODEADDR
:
865 printf("node addresses");
868 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
870 printf(" %s", getname6(bp
+ i
));
871 i
+= sizeof(struct in6_addr
);
872 printf("(%d)", (int32_t)ntohl(*(int32_t *)(bp
+ i
)));
873 i
+= sizeof(int32_t);
878 printf(" [%s%s%s%s%s%s%s]",
879 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
880 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
881 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
882 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
883 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
884 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
885 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : "");
901 fputs("[|icmp6]", stdout
);
905 icmp6_rrenum_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
907 struct icmp6_router_renum
*rr6
;
908 struct icmp6_hdr
*dp
;
911 struct rr_pco_match
*match
;
912 struct rr_pco_use
*use
;
913 char hbuf
[NI_MAXHOST
];
916 dp
= (struct icmp6_hdr
*)bp
;
917 rr6
= (struct icmp6_router_renum
*)bp
;
919 cp
= (const char *)(rr6
+ 1);
921 TCHECK(rr6
->rr_reserved
);
922 switch (rr6
->rr_code
) {
923 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
924 printf("router renum: command");
926 case ICMP6_ROUTER_RENUMBERING_RESULT
:
927 printf("router renum: result");
929 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
930 printf("router renum: sequence number reset");
933 printf("router renum: code-#%d", rr6
->rr_code
);
937 printf(", seq=%u", (u_int32_t
)ntohl(rr6
->rr_seqnum
));
940 #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
943 printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
944 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
945 F(ICMP6_RR_FLAGS_FORCEAPPLY
, "A"),
946 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
947 F(ICMP6_RR_FLAGS_PREVDONE
, "P"));
949 printf("seg=%u,", rr6
->rr_segnum
);
950 printf("maxdelay=%u", rr6
->rr_maxdelay
);
951 if (rr6
->rr_reserved
)
952 printf("rsvd=0x%x", (u_int16_t
)ntohs(rr6
->rr_reserved
));
958 if (rr6
->rr_code
== ICMP6_ROUTER_RENUMBERING_COMMAND
) {
959 match
= (struct rr_pco_match
*)cp
;
960 cp
= (const char *)(match
+ 1);
962 TCHECK(match
->rpm_prefix
);
968 printf("match("); /*)*/
969 switch (match
->rpm_code
) {
970 case RPM_PCO_ADD
: printf("add"); break;
971 case RPM_PCO_CHANGE
: printf("change"); break;
972 case RPM_PCO_SETGLOBAL
: printf("setglobal"); break;
973 default: printf("#%u", match
->rpm_code
); break;
977 printf(",ord=%u", match
->rpm_ordinal
);
978 printf(",min=%u", match
->rpm_minlen
);
979 printf(",max=%u", match
->rpm_maxlen
);
981 if (inet_ntop(AF_INET6
, &match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
982 printf(",%s/%u", hbuf
, match
->rpm_matchlen
);
984 printf(",?/%u", match
->rpm_matchlen
);
988 n
= match
->rpm_len
- 3;
993 use
= (struct rr_pco_use
*)cp
;
994 cp
= (const char *)(use
+ 1);
996 TCHECK(use
->rpu_prefix
);
1002 printf("use("); /*)*/
1003 if (use
->rpu_flags
) {
1004 #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
1006 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
1007 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P"));
1011 printf("mask=0x%x,", use
->rpu_ramask
);
1012 printf("raflags=0x%x,", use
->rpu_raflags
);
1013 if (~use
->rpu_vltime
== 0)
1014 printf("vltime=infty,");
1016 printf("vltime=%u,",
1017 (u_int32_t
)ntohl(use
->rpu_vltime
));
1018 if (~use
->rpu_pltime
== 0)
1019 printf("pltime=infty,");
1021 printf("pltime=%u,",
1022 (u_int32_t
)ntohl(use
->rpu_pltime
));
1024 if (inet_ntop(AF_INET6
, &use
->rpu_prefix
, hbuf
,
1026 printf("%s/%u/%u", hbuf
, use
->rpu_uselen
,
1029 printf("?/%u/%u", use
->rpu_uselen
,
1039 fputs("[|icmp6]", stdout
);