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.38 2000-11-08 10:10:59 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 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))
69 icmp6_print(register const u_char
*bp
, register const u_char
*bp2
)
71 const struct icmp6_hdr
*dp
;
72 register const struct ip6_hdr
*ip
;
73 register const char *str
;
74 register const struct ip6_hdr
*oip
;
75 register const struct udphdr
*ouh
;
77 register const u_char
*ep
;
82 #define TCHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) goto trunc
85 dp
= (struct icmp6_hdr
*)bp
;
86 ip
= (struct ip6_hdr
*)bp2
;
87 oip
= (struct ip6_hdr
*)(dp
+ 1);
89 /* 'ep' points to the end of available data. */
92 icmp6len
= (ntohs(ip
->ip6_plen
) + sizeof(struct ip6_hdr
) -
94 else /* XXX: jumbo payload case... */
95 icmp6len
= snapend
- bp
;
98 (void)printf("%s > %s: ",
99 ip6addr_string(&ip
->ip6_src
),
100 ip6addr_string(&ip
->ip6_dst
));
103 TCHECK(dp
->icmp6_code
);
104 switch (dp
->icmp6_type
) {
105 case ICMP6_DST_UNREACH
:
106 TCHECK(oip
->ip6_dst
);
107 switch (dp
->icmp6_code
) {
108 case ICMP6_DST_UNREACH_NOROUTE
:
109 printf("icmp6: %s unreachable route",
110 ip6addr_string(&oip
->ip6_dst
));
112 case ICMP6_DST_UNREACH_ADMIN
:
113 printf("icmp6: %s unreachable prohibited",
114 ip6addr_string(&oip
->ip6_dst
));
116 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
117 printf("icmp6: %s beyond scope of source address %s",
118 ip6addr_string(&oip
->ip6_dst
),
119 ip6addr_string(&oip
->ip6_src
));
121 case ICMP6_DST_UNREACH_ADDR
:
122 printf("icmp6: %s unreachable address",
123 ip6addr_string(&oip
->ip6_dst
));
125 case ICMP6_DST_UNREACH_NOPORT
:
126 if ((ouh
= get_upperlayer((u_char
*)oip
, &prot
))
130 dport
= ntohs(ouh
->uh_dport
);
133 printf("icmp6: %s tcp port %s unreachable",
134 ip6addr_string(&oip
->ip6_dst
),
135 tcpport_string(dport
));
138 printf("icmp6: %s udp port %s unreachable",
139 ip6addr_string(&oip
->ip6_dst
),
140 udpport_string(dport
));
143 printf("icmp6: %s protocol %d port %d unreachable",
144 ip6addr_string(&oip
->ip6_dst
),
145 oip
->ip6_nxt
, dport
);
150 printf("icmp6: %s unreachable code-#%d",
151 ip6addr_string(&oip
->ip6_dst
),
156 case ICMP6_PACKET_TOO_BIG
:
157 TCHECK(dp
->icmp6_mtu
);
158 printf("icmp6: too big %u\n", (u_int32_t
)ntohl(dp
->icmp6_mtu
));
160 case ICMP6_TIME_EXCEEDED
:
161 TCHECK(oip
->ip6_dst
);
162 switch (dp
->icmp6_code
) {
163 case ICMP6_TIME_EXCEED_TRANSIT
:
164 printf("icmp6: time exceeded in-transit for %s",
165 ip6addr_string(&oip
->ip6_dst
));
167 case ICMP6_TIME_EXCEED_REASSEMBLY
:
168 printf("icmp6: ip6 reassembly time exceeded");
171 printf("icmp6: time exceeded code-#%d",
176 case ICMP6_PARAM_PROB
:
177 TCHECK(oip
->ip6_dst
);
178 switch (dp
->icmp6_code
) {
179 case ICMP6_PARAMPROB_HEADER
:
180 printf("icmp6: parameter problem errorneous - octet %u\n",
181 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
183 case ICMP6_PARAMPROB_NEXTHEADER
:
184 printf("icmp6: parameter problem next header - octet %u\n",
185 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
187 case ICMP6_PARAMPROB_OPTION
:
188 printf("icmp6: parameter problem option - octet %u\n",
189 (u_int32_t
)ntohl(dp
->icmp6_pptr
));
192 printf("icmp6: parameter problem code-#%d",
197 case ICMP6_ECHO_REQUEST
:
198 printf("icmp6: echo request");
200 case ICMP6_ECHO_REPLY
:
201 printf("icmp6: echo reply");
203 case ICMP6_MEMBERSHIP_QUERY
:
204 printf("icmp6: multicast listener query ");
205 mld6_print((const u_char
*)dp
);
207 case ICMP6_MEMBERSHIP_REPORT
:
208 printf("icmp6: multicast listener report ");
209 mld6_print((const u_char
*)dp
);
211 case ICMP6_MEMBERSHIP_REDUCTION
:
212 printf("icmp6: multicast listener done ");
213 mld6_print((const u_char
*)dp
);
215 case ND_ROUTER_SOLICIT
:
216 printf("icmp6: router solicitation ");
219 icmp6_opt_print((const u_char
*)dp
+ RTSOLLEN
,
220 icmp6len
- RTSOLLEN
);
223 case ND_ROUTER_ADVERT
:
224 printf("icmp6: router advertisement");
226 struct nd_router_advert
*p
;
228 p
= (struct nd_router_advert
*)dp
;
229 TCHECK(p
->nd_ra_retransmit
);
230 printf("(chlim=%d, ", (int)p
->nd_ra_curhoplimit
);
231 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_MANAGED
)
233 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_OTHER
)
235 #ifndef ND_RA_FLAG_HA
236 #define ND_RA_FLAG_HA 0x20
238 if (p
->nd_ra_flags_reserved
& ND_RA_FLAG_HA
)
240 if (p
->nd_ra_flags_reserved
!= 0)
242 printf("router_ltime=%d, ", ntohs(p
->nd_ra_router_lifetime
));
243 printf("reachable_time=%u, ",
244 (u_int32_t
)ntohl(p
->nd_ra_reachable
));
245 printf("retrans_time=%u)",
246 (u_int32_t
)ntohl(p
->nd_ra_retransmit
));
248 icmp6_opt_print((const u_char
*)dp
+ RTADVLEN
,
249 icmp6len
- RTADVLEN
);
252 case ND_NEIGHBOR_SOLICIT
:
254 struct nd_neighbor_solicit
*p
;
255 p
= (struct nd_neighbor_solicit
*)dp
;
256 TCHECK(p
->nd_ns_target
);
257 printf("icmp6: neighbor sol: who has %s",
258 ip6addr_string(&p
->nd_ns_target
));
261 icmp6_opt_print((const u_char
*)dp
+ NDSOLLEN
,
262 icmp6len
- NDSOLLEN
);
266 case ND_NEIGHBOR_ADVERT
:
268 struct nd_neighbor_advert
*p
;
270 p
= (struct nd_neighbor_advert
*)dp
;
271 TCHECK(p
->nd_na_target
);
272 printf("icmp6: neighbor adv: tgt is %s",
273 ip6addr_string(&p
->nd_na_target
));
275 #define ND_NA_FLAG_ALL \
276 (ND_NA_FLAG_ROUTER|ND_NA_FLAG_SOLICITED|ND_NA_FLAG_OVERRIDE)
277 /* we don't need ntohl() here. see advanced-api-04. */
278 if (p
->nd_na_flags_reserved
& ND_NA_FLAG_ALL
) {
279 #undef ND_NA_FLAG_ALL
282 flags
= p
->nd_na_flags_reserved
;
284 if (flags
& ND_NA_FLAG_ROUTER
)
286 if (flags
& ND_NA_FLAG_SOLICITED
)
288 if (flags
& ND_NA_FLAG_OVERRIDE
)
293 icmp6_opt_print((const u_char
*)dp
+ NDADVLEN
,
294 icmp6len
- NDADVLEN
);
300 #define RDR(i) ((struct nd_redirect *)(i))
301 TCHECK(RDR(dp
)->nd_rd_dst
);
302 printf("icmp6: redirect %s",
303 getname6((const u_char
*)&RDR(dp
)->nd_rd_dst
));
305 getname6((const u_char
*)&RDR(dp
)->nd_rd_target
));
306 #define REDIRECTLEN 40
308 icmp6_opt_print((const u_char
*)dp
+ REDIRECTLEN
,
309 icmp6len
- REDIRECTLEN
);
314 case ICMP6_ROUTER_RENUMBERING
:
315 icmp6_rrenum_print(icmp6len
, bp
, ep
);
318 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
321 icmp6_nodeinfo_print(icmp6len
, bp
, ep
);
324 printf("icmp6: type-#%d", dp
->icmp6_type
);
329 fputs("[|icmp6]", stdout
);
335 static struct udphdr
*
336 get_upperlayer(register u_char
*bp
, int *prot
)
338 register const u_char
*ep
;
339 struct ip6_hdr
*ip6
= (struct ip6_hdr
*)bp
;
342 struct ip6_frag
*fragh
;
346 /* 'ep' points to the end of available data. */
349 if (TTEST(ip6
->ip6_nxt
) == 0)
353 hlen
= sizeof(struct ip6_hdr
);
355 while (bp
< snapend
) {
361 uh
= (struct udphdr
*)bp
;
362 if (TTEST(uh
->uh_dport
)) {
370 case IPPROTO_HOPOPTS
:
371 case IPPROTO_DSTOPTS
:
372 case IPPROTO_ROUTING
:
373 hbh
= (struct ip6_hbh
*)bp
;
374 if (TTEST(hbh
->ip6h_len
) == 0)
377 hlen
= (hbh
->ip6h_len
+ 1) << 3;
380 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
381 fragh
= (struct ip6_frag
*)bp
;
382 if (TTEST(fragh
->ip6f_offlg
) == 0)
384 /* fragments with non-zero offset are meaningless */
385 if ((fragh
->ip6f_offlg
& IP6F_OFF_MASK
) != 0)
387 nh
= fragh
->ip6f_nxt
;
388 hlen
= sizeof(struct ip6_frag
);
392 ah
= (struct ah
*)bp
;
393 if (TTEST(ah
->ah_len
) == 0)
396 hlen
= (ah
->ah_len
+ 2) << 2;
399 default: /* unknown or undecodable header */
400 *prot
= nh
; /* meaningless, but set here anyway */
405 return(NULL
); /* should be notreached, though */
409 icmp6_opt_print(register const u_char
*bp
, int resid
)
411 register const struct nd_opt_hdr
*op
;
412 register const struct nd_opt_hdr
*opl
; /* why there's no struct? */
413 register const struct nd_opt_prefix_info
*opp
;
414 register const struct icmp6_opts_redirect
*opr
;
415 register const struct nd_opt_mtu
*opm
;
416 register const u_char
*ep
;
419 register const struct ip6_hdr
*ip
;
420 register const char *str
;
421 register const struct ip6_hdr
*oip
;
422 register const struct udphdr
*ouh
;
423 register int hlen
, dport
;
427 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
429 op
= (struct nd_opt_hdr
*)bp
;
431 ip
= (struct ip6_hdr
*)bp2
;
432 oip
= &dp
->icmp6_ip6
;
435 /* 'ep' points to the end of available data. */
438 ECHECK(op
->nd_opt_len
);
441 switch (op
->nd_opt_type
) {
442 case ND_OPT_SOURCE_LINKADDR
:
443 opl
= (struct nd_opt_hdr
*)op
;
445 if ((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) > ep
)
448 TCHECK((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) - 1);
450 printf("(src lladdr: %s", /*)*/
451 etheraddr_string((u_char
*)(opl
+ 1)));
452 if (opl
->nd_opt_len
!= 1)
456 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
457 resid
- (op
->nd_opt_len
<< 3));
459 case ND_OPT_TARGET_LINKADDR
:
460 opl
= (struct nd_opt_hdr
*)op
;
462 if ((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) > ep
)
465 TCHECK((u_char
*)opl
+ (opl
->nd_opt_len
<< 3) - 1);
467 printf("(tgt lladdr: %s", /*)*/
468 etheraddr_string((u_char
*)(opl
+ 1)));
469 if (opl
->nd_opt_len
!= 1)
473 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
474 resid
- (op
->nd_opt_len
<< 3));
476 case ND_OPT_PREFIX_INFORMATION
:
477 opp
= (struct nd_opt_prefix_info
*)op
;
478 TCHECK(opp
->nd_opt_pi_prefix
);
479 printf("(prefix info: "); /*)*/
480 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_ONLINK
)
482 if (opp
->nd_opt_pi_flags_reserved
& ND_OPT_PI_FLAG_AUTO
)
484 if (opp
->nd_opt_pi_flags_reserved
)
486 printf("valid_ltime=");
487 if ((u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
) == ~0U)
490 printf("%u", (u_int32_t
)ntohl(opp
->nd_opt_pi_valid_time
));
493 printf("preffered_ltime=");
494 if ((u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
) == ~0U)
497 printf("%u", (u_int32_t
)ntohl(opp
->nd_opt_pi_preferred_time
));
500 printf("prefix=%s/%d", ip6addr_string(&opp
->nd_opt_pi_prefix
),
501 opp
->nd_opt_pi_prefix_len
);
502 if (opp
->nd_opt_pi_len
!= 4)
506 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
507 resid
- (op
->nd_opt_len
<< 3));
509 case ND_OPT_REDIRECTED_HEADER
:
510 opr
= (struct icmp6_opts_redirect
*)op
;
511 printf("(redirect)");
513 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
514 resid
- (op
->nd_opt_len
<< 3));
517 opm
= (struct nd_opt_mtu
*)op
;
518 TCHECK(opm
->nd_opt_mtu_mtu
);
519 printf("(mtu: "); /*)*/
520 printf("mtu=%u", (u_int32_t
)ntohl(opm
->nd_opt_mtu_mtu
));
521 if (opm
->nd_opt_mtu_len
!= 1)
524 icmp6_opt_print((const u_char
*)op
+ (op
->nd_opt_len
<< 3),
525 resid
- (op
->nd_opt_len
<< 3));
528 opts_len
= op
->nd_opt_len
;
529 printf("(unknwon opt_type=%d, opt_len=%d)",
530 op
->nd_opt_type
, opts_len
);
532 opts_len
= 1; /* XXX */
533 icmp6_opt_print((const u_char
*)op
+ (opts_len
<< 3),
534 resid
- (opts_len
<< 3));
539 fputs("[ndp opt]", stdout
);
545 mld6_print(register const u_char
*bp
)
547 register struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
548 register const u_char
*ep
;
550 /* 'ep' points to the end of available data. */
553 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
556 printf("max resp delay: %d ", ntohs(mp
->mld6_maxdelay
));
557 printf("addr: %s", ip6addr_string(&mp
->mld6_addr
));
561 dnsname_print(const u_char
*cp
, const u_char
*ep
)
565 /* DNS name decoding - no decompression */
574 while (i
-- && cp
< ep
) {
578 if (cp
+ 1 < ep
&& *cp
)
584 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
597 icmp6_nodeinfo_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
599 struct icmp6_nodeinfo
*ni6
;
600 struct icmp6_hdr
*dp
;
605 dp
= (struct icmp6_hdr
*)bp
;
606 ni6
= (struct icmp6_nodeinfo
*)bp
;
609 switch (ni6
->ni_type
) {
611 if (siz
== sizeof(*dp
) + 4) {
612 /* KAME who-are-you */
613 printf("icmp6: who-are-you request");
616 printf("icmp6: node information query");
618 TCHECK2(*dp
, sizeof(*ni6
));
619 ni6
= (struct icmp6_nodeinfo
*)dp
;
621 switch (ntohs(ni6
->ni_qtype
)) {
625 case NI_QTYPE_SUPTYPES
:
626 printf("supported qtypes");
627 i
= ntohs(ni6
->ni_flags
);
629 printf(" [%s]", (i
& 0x01) ? "C" : "");
635 case NI_QTYPE_NODEADDR
:
636 printf("node addresses");
640 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
641 printf(" [%s%s%s%s%s%s]",
642 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
643 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
644 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
645 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
646 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
647 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "");
654 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
655 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
656 if (siz
!= sizeof(*ni6
))
658 printf(", invalid len");
665 /* XXX backward compat, icmp-name-lookup-03 */
666 if (siz
== sizeof(*ni6
)) {
667 printf(", 03 draft");
673 switch (ni6
->ni_code
) {
674 case ICMP6_NI_SUBJ_IPV6
:
676 sizeof(*ni6
) + sizeof(struct in6_addr
)))
678 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
680 printf(", invalid subject len");
683 printf(", subject=%s",
684 getname6((const u_char
*)(ni6
+ 1)));
686 case ICMP6_NI_SUBJ_FQDN
:
687 printf(", subject=DNS name");
688 cp
= (const u_char
*)(ni6
+ 1);
689 if (cp
[0] == ep
- cp
- 1) {
690 /* icmp-name-lookup-03, pascal string */
692 printf(", 03 draft");
701 dnsname_print(cp
, ep
);
703 case ICMP6_NI_SUBJ_IPV4
:
704 if (!TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
706 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
708 printf(", invalid subject len");
711 printf(", subject=%s",
712 getname((const u_char
*)(ni6
+ 1)));
715 printf(", unknown subject");
724 if (icmp6len
> siz
) {
725 printf("[|icmp6: node information reply]");
731 ni6
= (struct icmp6_nodeinfo
*)dp
;
732 printf("icmp6: node information reply");
734 switch (ni6
->ni_code
) {
735 case ICMP6_NI_SUCCESS
:
741 case ICMP6_NI_REFUSED
:
744 if (siz
!= sizeof(*ni6
))
746 printf(", invalid length");
748 case ICMP6_NI_UNKNOWN
:
751 if (siz
!= sizeof(*ni6
))
753 printf(", invalid length");
757 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
763 switch (ntohs(ni6
->ni_qtype
)) {
768 if (siz
!= sizeof(*ni6
))
770 printf(", invalid length");
772 case NI_QTYPE_SUPTYPES
:
775 printf("supported qtypes");
776 i
= ntohs(ni6
->ni_flags
);
778 printf(" [%s]", (i
& 0x01) ? "C" : "");
784 cp
= (const u_char
*)(ni6
+ 1) + 4;
785 if (cp
[0] == ep
- cp
- 1) {
786 /* icmp-name-lookup-03, pascal string */
788 printf(", 03 draft");
797 dnsname_print(cp
, ep
);
798 if ((ntohs(ni6
->ni_flags
) & 0x01) != 0)
799 printf(" [TTL=%u]", *(u_int32_t
*)(ni6
+ 1));
801 case NI_QTYPE_NODEADDR
:
804 printf("node addresses");
807 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
809 printf(" %s", getname6(bp
+ i
));
810 i
+= sizeof(struct in6_addr
);
811 printf("(%d)", ntohl(*(int32_t *)(bp
+ i
)));
812 i
+= sizeof(int32_t);
817 printf(" [%s%s%s%s%s%s%s]",
818 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
819 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
820 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
821 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
822 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
823 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
824 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : "");
840 fputs("[|icmp6]", stdout
);
844 icmp6_rrenum_print(int icmp6len
, const u_char
*bp
, const u_char
*ep
)
846 struct icmp6_router_renum
*rr6
;
847 struct icmp6_hdr
*dp
;
850 struct rr_pco_match
*match
;
851 struct rr_pco_use
*use
;
852 char hbuf
[NI_MAXHOST
];
855 dp
= (struct icmp6_hdr
*)bp
;
856 rr6
= (struct icmp6_router_renum
*)bp
;
858 cp
= (const char *)(rr6
+ 1);
860 TCHECK(rr6
->rr_reserved
);
861 switch (rr6
->rr_code
) {
862 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
863 printf("router renum: command");
865 case ICMP6_ROUTER_RENUMBERING_RESULT
:
866 printf("router renum: result");
868 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
869 printf("router renum: sequence number reset");
872 printf("router renum: code-#%d", rr6
->rr_code
);
877 #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
880 printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
881 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
882 F(ICMP6_RR_FLAGS_ALLIF
, "A"),
883 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
884 F(ICMP6_RR_FLAGS_PREVDONE
, "P"));
886 printf("segnum=%u,", rr6
->rr_segnum
);
887 printf("maxdelay=%u", rr6
->rr_maxdelay
);
888 if (rr6
->rr_reserved
)
889 printf("rsvd=0x%x", (u_int16_t
)ntohs(rr6
->rr_reserved
));
895 if (rr6
->rr_code
== ICMP6_ROUTER_RENUMBERING_COMMAND
) {
896 match
= (struct rr_pco_match
*)cp
;
897 cp
= (const char *)(match
+ 1);
899 TCHECK(match
->rpm_prefix
);
905 printf("match("); /*)*/
906 switch (match
->rpm_code
) {
907 case RPM_PCO_ADD
: printf("add"); break;
908 case RPM_PCO_CHANGE
: printf("change"); break;
909 case RPM_PCO_SETGLOBAL
: printf("setglobal"); break;
910 default: printf("#%u", match
->rpm_code
); break;
914 printf(",ord=%u", match
->rpm_ordinal
);
915 printf(",min=%u", match
->rpm_minlen
);
916 printf(",max=%u", match
->rpm_maxlen
);
918 if (inet_ntop(AF_INET6
, &match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
919 printf(",%s/%u", hbuf
, match
->rpm_matchlen
);
921 printf(",?/%u", match
->rpm_matchlen
);
925 n
= match
->rpm_len
- 3;
930 use
= (struct rr_pco_use
*)cp
;
931 cp
= (const char *)(use
+ 1);
933 TCHECK(use
->rpu_prefix
);
939 printf("use("); /*)*/
940 if (use
->rpu_flags
) {
941 #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
943 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
944 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P"));
948 printf("mask=0x%x,", use
->rpu_ramask
);
949 printf("raflags=0x%x,", use
->rpu_raflags
);
950 if (~use
->rpu_vltime
== 0)
951 printf("vltime=infty,");
954 (u_int32_t
)ntohl(use
->rpu_vltime
));
955 if (~use
->rpu_pltime
== 0)
956 printf("pltime=infty,");
959 (u_int32_t
)ntohl(use
->rpu_pltime
));
961 if (inet_ntop(AF_INET6
, &use
->rpu_prefix
, hbuf
,
963 printf("%s/%u/%u", hbuf
, use
->rpu_uselen
,
966 printf("?/%u/%u", use
->rpu_uselen
,
976 fputs("[|icmp6]", stdout
);