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.
26 #include <netdissect-stdinc.h>
31 #include "netdissect.h"
32 #include "addrtoname.h"
33 #include "addrtostr.h"
42 /* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
43 /* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
46 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
47 * All rights reserved.
49 * Redistribution and use in source and binary forms, with or without
50 * modification, are permitted provided that the following conditions
52 * 1. Redistributions of source code must retain the above copyright
53 * notice, this list of conditions and the following disclaimer.
54 * 2. Redistributions in binary form must reproduce the above copyright
55 * notice, this list of conditions and the following disclaimer in the
56 * documentation and/or other materials provided with the distribution.
57 * 3. Neither the name of the project nor the names of its contributors
58 * may be used to endorse or promote products derived from this software
59 * without specific prior written permission.
61 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
62 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
63 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
64 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
65 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
66 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
67 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
69 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
70 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
75 uint8_t icmp6_type
; /* type field */
76 uint8_t icmp6_code
; /* code field */
77 uint16_t icmp6_cksum
; /* checksum field */
79 uint32_t icmp6_un_data32
[1]; /* type-specific field */
80 uint16_t icmp6_un_data16
[2]; /* type-specific field */
81 uint8_t icmp6_un_data8
[4]; /* type-specific field */
85 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
86 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
87 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
88 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
89 #define icmp6_mtu icmp6_data32[0] /* packet too big */
90 #define icmp6_id icmp6_data16[0] /* echo request/reply */
91 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
92 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
94 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
95 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
96 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
97 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
99 #define ICMP6_ECHO_REQUEST 128 /* echo service */
100 #define ICMP6_ECHO_REPLY 129 /* echo reply */
101 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
102 #define MLD6_LISTENER_QUERY 130 /* multicast listener query */
103 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
104 #define MLD6_LISTENER_REPORT 131 /* multicast listener report */
105 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
106 #define MLD6_LISTENER_DONE 132 /* multicast listener done */
108 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
109 #define ND_ROUTER_ADVERT 134 /* router advertisement */
110 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
111 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
112 #define ND_REDIRECT 137 /* redirect */
114 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
116 #define ICMP6_WRUREQUEST 139 /* who are you request */
117 #define ICMP6_WRUREPLY 140 /* who are you reply */
118 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
119 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
120 #define ICMP6_NI_QUERY 139 /* node information request */
121 #define ICMP6_NI_REPLY 140 /* node information reply */
122 #define IND_SOLICIT 141 /* inverse neighbor solicitation */
123 #define IND_ADVERT 142 /* inverse neighbor advertisement */
125 #define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */
126 #define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */
127 #define ICMP6_HADISCOV_REQUEST 144
128 #define ICMP6_HADISCOV_REPLY 145
129 #define ICMP6_MOBILEPREFIX_SOLICIT 146
130 #define ICMP6_MOBILEPREFIX_ADVERT 147
132 #define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
133 #define MLD6_MTRACE 201 /* mtrace messages */
135 #define ICMP6_MAXTYPE 201
137 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
138 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
139 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
140 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
141 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
142 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
144 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
145 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
147 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
148 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
149 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
151 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
153 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
154 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
155 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
157 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
158 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
159 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
161 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
162 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
163 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
165 /* Used in kernel only */
166 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
167 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
170 * Multicast Listener Discovery
173 struct icmp6_hdr mld6_hdr
;
174 struct in6_addr mld6_addr
; /* multicast address */
177 #define mld6_type mld6_hdr.icmp6_type
178 #define mld6_code mld6_hdr.icmp6_code
179 #define mld6_cksum mld6_hdr.icmp6_cksum
180 #define mld6_maxdelay mld6_hdr.icmp6_data16[0]
181 #define mld6_reserved mld6_hdr.icmp6_data16[1]
183 #define MLD_MINLEN 24
184 #define MLDV2_MINLEN 28
190 struct nd_router_solicit
{ /* router solicitation */
191 struct icmp6_hdr nd_rs_hdr
;
192 /* could be followed by options */
195 #define nd_rs_type nd_rs_hdr.icmp6_type
196 #define nd_rs_code nd_rs_hdr.icmp6_code
197 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
198 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
200 struct nd_router_advert
{ /* router advertisement */
201 struct icmp6_hdr nd_ra_hdr
;
202 uint32_t nd_ra_reachable
; /* reachable time */
203 uint32_t nd_ra_retransmit
; /* retransmit timer */
204 /* could be followed by options */
207 #define nd_ra_type nd_ra_hdr.icmp6_type
208 #define nd_ra_code nd_ra_hdr.icmp6_code
209 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
210 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
211 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
212 #define ND_RA_FLAG_MANAGED 0x80
213 #define ND_RA_FLAG_OTHER 0x40
214 #define ND_RA_FLAG_HOME_AGENT 0x20
217 * Router preference values based on draft-draves-ipngwg-router-selection-01.
218 * These are non-standard definitions.
220 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
222 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
223 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
224 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
225 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
227 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
229 struct nd_neighbor_solicit
{ /* neighbor solicitation */
230 struct icmp6_hdr nd_ns_hdr
;
231 struct in6_addr nd_ns_target
; /*target address */
232 /* could be followed by options */
235 #define nd_ns_type nd_ns_hdr.icmp6_type
236 #define nd_ns_code nd_ns_hdr.icmp6_code
237 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
238 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
240 struct nd_neighbor_advert
{ /* neighbor advertisement */
241 struct icmp6_hdr nd_na_hdr
;
242 struct in6_addr nd_na_target
; /* target address */
243 /* could be followed by options */
246 #define nd_na_type nd_na_hdr.icmp6_type
247 #define nd_na_code nd_na_hdr.icmp6_code
248 #define nd_na_cksum nd_na_hdr.icmp6_cksum
249 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
251 #define ND_NA_FLAG_ROUTER 0x80000000
252 #define ND_NA_FLAG_SOLICITED 0x40000000
253 #define ND_NA_FLAG_OVERRIDE 0x20000000
255 struct nd_redirect
{ /* redirect */
256 struct icmp6_hdr nd_rd_hdr
;
257 struct in6_addr nd_rd_target
; /* target address */
258 struct in6_addr nd_rd_dst
; /* destination address */
259 /* could be followed by options */
262 #define nd_rd_type nd_rd_hdr.icmp6_type
263 #define nd_rd_code nd_rd_hdr.icmp6_code
264 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
265 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
267 struct nd_opt_hdr
{ /* Neighbor discovery option header */
270 /* followed by option specific data*/
273 #define ND_OPT_SOURCE_LINKADDR 1
274 #define ND_OPT_TARGET_LINKADDR 2
275 #define ND_OPT_PREFIX_INFORMATION 3
276 #define ND_OPT_REDIRECTED_HEADER 4
278 #define ND_OPT_ADVINTERVAL 7
279 #define ND_OPT_HOMEAGENT_INFO 8
280 #define ND_OPT_ROUTE_INFO 24 /* RFC4191 */
281 #define ND_OPT_RDNSS 25
282 #define ND_OPT_DNSSL 31
284 struct nd_opt_prefix_info
{ /* prefix information */
285 uint8_t nd_opt_pi_type
;
286 uint8_t nd_opt_pi_len
;
287 uint8_t nd_opt_pi_prefix_len
;
288 uint8_t nd_opt_pi_flags_reserved
;
289 uint8_t nd_opt_pi_valid_time
[4];
290 uint8_t nd_opt_pi_preferred_time
[4];
291 uint8_t nd_opt_pi_reserved2
[4];
292 struct in6_addr nd_opt_pi_prefix
;
295 #define ND_OPT_PI_FLAG_ONLINK 0x80
296 #define ND_OPT_PI_FLAG_AUTO 0x40
297 #define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
299 struct nd_opt_rd_hdr
{ /* redirected header */
300 uint8_t nd_opt_rh_type
;
301 uint8_t nd_opt_rh_len
;
302 uint16_t nd_opt_rh_reserved1
;
303 uint32_t nd_opt_rh_reserved2
;
304 /* followed by IP header and data */
307 struct nd_opt_mtu
{ /* MTU option */
308 uint8_t nd_opt_mtu_type
;
309 uint8_t nd_opt_mtu_len
;
310 uint16_t nd_opt_mtu_reserved
;
311 uint32_t nd_opt_mtu_mtu
;
314 struct nd_opt_rdnss
{ /* RDNSS RFC 6106 5.1 */
315 uint8_t nd_opt_rdnss_type
;
316 uint8_t nd_opt_rdnss_len
;
317 uint16_t nd_opt_rdnss_reserved
;
318 uint32_t nd_opt_rdnss_lifetime
;
319 struct in6_addr nd_opt_rdnss_addr
[1]; /* variable-length */
322 struct nd_opt_dnssl
{ /* DNSSL RFC 6106 5.2 */
323 uint8_t nd_opt_dnssl_type
;
324 uint8_t nd_opt_dnssl_len
;
325 uint16_t nd_opt_dnssl_reserved
;
326 uint32_t nd_opt_dnssl_lifetime
;
327 /* followed by list of DNS search domains, variable-length */
330 struct nd_opt_advinterval
{ /* Advertisement interval option */
331 uint8_t nd_opt_adv_type
;
332 uint8_t nd_opt_adv_len
;
333 uint16_t nd_opt_adv_reserved
;
334 uint32_t nd_opt_adv_interval
;
337 struct nd_opt_homeagent_info
{ /* Home Agent info */
338 uint8_t nd_opt_hai_type
;
339 uint8_t nd_opt_hai_len
;
340 uint16_t nd_opt_hai_reserved
;
341 int16_t nd_opt_hai_preference
;
342 uint16_t nd_opt_hai_lifetime
;
345 struct nd_opt_route_info
{ /* route info */
346 uint8_t nd_opt_rti_type
;
347 uint8_t nd_opt_rti_len
;
348 uint8_t nd_opt_rti_prefixlen
;
349 uint8_t nd_opt_rti_flags
;
350 uint32_t nd_opt_rti_lifetime
;
358 struct icmp6_namelookup
{
359 struct icmp6_hdr icmp6_nl_hdr
;
360 uint8_t icmp6_nl_nonce
[8];
361 int32_t icmp6_nl_ttl
;
363 uint8_t icmp6_nl_len
;
364 uint8_t icmp6_nl_name
[3];
366 /* could be followed by options */
370 * icmp6 node information
372 struct icmp6_nodeinfo
{
373 struct icmp6_hdr icmp6_ni_hdr
;
374 uint8_t icmp6_ni_nonce
[8];
375 /* could be followed by reply data */
378 #define ni_type icmp6_ni_hdr.icmp6_type
379 #define ni_code icmp6_ni_hdr.icmp6_code
380 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
381 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
382 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
384 #define NI_QTYPE_NOOP 0 /* NOOP */
385 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
386 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
387 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
388 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
389 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
392 #define NI_SUPTYPE_FLAG_COMPRESS ((uint16_t)htons(0x1))
393 #define NI_FQDN_FLAG_VALIDTTL ((uint16_t)htons(0x1))
396 #define NI_NODEADDR_FLAG_TRUNCATE ((uint16_t)htons(0x1))
397 #define NI_NODEADDR_FLAG_ALL ((uint16_t)htons(0x2))
398 #define NI_NODEADDR_FLAG_COMPAT ((uint16_t)htons(0x4))
399 #define NI_NODEADDR_FLAG_LINKLOCAL ((uint16_t)htons(0x8))
400 #define NI_NODEADDR_FLAG_SITELOCAL ((uint16_t)htons(0x10))
401 #define NI_NODEADDR_FLAG_GLOBAL ((uint16_t)htons(0x20))
402 #define NI_NODEADDR_FLAG_ANYCAST ((uint16_t)htons(0x40)) /* just experimental. not in spec */
404 struct ni_reply_fqdn
{
405 uint32_t ni_fqdn_ttl
; /* TTL */
406 uint8_t ni_fqdn_namelen
; /* length in octets of the FQDN */
407 uint8_t ni_fqdn_name
[3]; /* XXX: alignment */
411 * Router Renumbering. as router-renum-08.txt
413 struct icmp6_router_renum
{ /* router renumbering header */
414 struct icmp6_hdr rr_hdr
;
417 uint16_t rr_maxdelay
;
418 uint32_t rr_reserved
;
420 #define ICMP6_RR_FLAGS_TEST 0x80
421 #define ICMP6_RR_FLAGS_REQRESULT 0x40
422 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
423 #define ICMP6_RR_FLAGS_SPECSITE 0x10
424 #define ICMP6_RR_FLAGS_PREVDONE 0x08
426 #define rr_type rr_hdr.icmp6_type
427 #define rr_code rr_hdr.icmp6_code
428 #define rr_cksum rr_hdr.icmp6_cksum
429 #define rr_seqnum rr_hdr.icmp6_data32[0]
431 struct rr_pco_match
{ /* match prefix part */
435 uint8_t rpm_matchlen
;
438 uint16_t rpm_reserved
;
439 struct in6_addr rpm_prefix
;
442 #define RPM_PCO_ADD 1
443 #define RPM_PCO_CHANGE 2
444 #define RPM_PCO_SETGLOBAL 3
445 #define RPM_PCO_MAX 4
447 struct rr_pco_use
{ /* use prefix part */
455 struct in6_addr rpu_prefix
;
457 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
458 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
461 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((uint32_t)htonl(0x80000000))
462 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((uint32_t)htonl(0x40000000))
464 struct rr_result
{ /* router renumbering result message */
467 uint8_t rrr_matchedlen
;
469 struct in6_addr rrr_prefix
;
472 #define ICMP6_RR_RESULT_FLAGS_OOB ((uint16_t)htons(0x0002))
473 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((uint16_t)htons(0x0001))
475 static const char *get_rtpref(u_int
);
476 static const char *get_lifetime(uint32_t);
477 static void print_lladdr(netdissect_options
*ndo
, const u_char
*, size_t);
478 static void icmp6_opt_print(netdissect_options
*ndo
, const u_char
*, int);
479 static void mld6_print(netdissect_options
*ndo
, const u_char
*);
480 static void mldv2_report_print(netdissect_options
*ndo
, const u_char
*, u_int
);
481 static void mldv2_query_print(netdissect_options
*ndo
, const u_char
*, u_int
);
482 static const struct udphdr
*get_upperlayer(netdissect_options
*ndo
, const u_char
*, u_int
*);
483 static void dnsname_print(netdissect_options
*ndo
, const u_char
*, const u_char
*);
484 static void icmp6_nodeinfo_print(netdissect_options
*ndo
, u_int
, const u_char
*, const u_char
*);
485 static void icmp6_rrenum_print(netdissect_options
*ndo
, const u_char
*, const u_char
*);
488 #define abs(a) ((0 < (a)) ? (a) : -(a))
493 static const struct tok icmp6_type_values
[] = {
494 { ICMP6_DST_UNREACH
, "destination unreachable"},
495 { ICMP6_PACKET_TOO_BIG
, "packet too big"},
496 { ICMP6_TIME_EXCEEDED
, "time exceeded in-transit"},
497 { ICMP6_PARAM_PROB
, "parameter problem"},
498 { ICMP6_ECHO_REQUEST
, "echo request"},
499 { ICMP6_ECHO_REPLY
, "echo reply"},
500 { MLD6_LISTENER_QUERY
, "multicast listener query"},
501 { MLD6_LISTENER_REPORT
, "multicast listener report"},
502 { MLD6_LISTENER_DONE
, "multicast listener done"},
503 { ND_ROUTER_SOLICIT
, "router solicitation"},
504 { ND_ROUTER_ADVERT
, "router advertisement"},
505 { ND_NEIGHBOR_SOLICIT
, "neighbor solicitation"},
506 { ND_NEIGHBOR_ADVERT
, "neighbor advertisement"},
507 { ND_REDIRECT
, "redirect"},
508 { ICMP6_ROUTER_RENUMBERING
, "router renumbering"},
509 { IND_SOLICIT
, "inverse neighbor solicitation"},
510 { IND_ADVERT
, "inverse neighbor advertisement"},
511 { MLDV2_LISTENER_REPORT
, "multicast listener report v2"},
512 { ICMP6_HADISCOV_REQUEST
, "ha discovery request"},
513 { ICMP6_HADISCOV_REPLY
, "ha discovery reply"},
514 { ICMP6_MOBILEPREFIX_SOLICIT
, "mobile router solicitation"},
515 { ICMP6_MOBILEPREFIX_ADVERT
, "mobile router advertisement"},
516 { ICMP6_WRUREQUEST
, "who-are-you request"},
517 { ICMP6_WRUREPLY
, "who-are-you reply"},
518 { ICMP6_NI_QUERY
, "node information query"},
519 { ICMP6_NI_REPLY
, "node information reply"},
520 { MLD6_MTRACE
, "mtrace message"},
521 { MLD6_MTRACE_RESP
, "mtrace response"},
522 { ND_RPL_MESSAGE
, "RPL"},
526 static const struct tok icmp6_dst_unreach_code_values
[] = {
527 { ICMP6_DST_UNREACH_NOROUTE
, "unreachable route" },
528 { ICMP6_DST_UNREACH_ADMIN
, " unreachable prohibited"},
529 { ICMP6_DST_UNREACH_BEYONDSCOPE
, "beyond scope"},
530 { ICMP6_DST_UNREACH_ADDR
, "unreachable address"},
531 { ICMP6_DST_UNREACH_NOPORT
, "unreachable port"},
535 static const struct tok icmp6_opt_pi_flag_values
[] = {
536 { ND_OPT_PI_FLAG_ONLINK
, "onlink" },
537 { ND_OPT_PI_FLAG_AUTO
, "auto" },
538 { ND_OPT_PI_FLAG_ROUTER
, "router" },
542 static const struct tok icmp6_opt_ra_flag_values
[] = {
543 { ND_RA_FLAG_MANAGED
, "managed" },
544 { ND_RA_FLAG_OTHER
, "other stateful"},
545 { ND_RA_FLAG_HOME_AGENT
, "home agent"},
549 static const struct tok icmp6_nd_na_flag_values
[] = {
550 { ND_NA_FLAG_ROUTER
, "router" },
551 { ND_NA_FLAG_SOLICITED
, "solicited" },
552 { ND_NA_FLAG_OVERRIDE
, "override" },
557 static const struct tok icmp6_opt_values
[] = {
558 { ND_OPT_SOURCE_LINKADDR
, "source link-address"},
559 { ND_OPT_TARGET_LINKADDR
, "destination link-address"},
560 { ND_OPT_PREFIX_INFORMATION
, "prefix info"},
561 { ND_OPT_REDIRECTED_HEADER
, "redirected header"},
562 { ND_OPT_MTU
, "mtu"},
563 { ND_OPT_RDNSS
, "rdnss"},
564 { ND_OPT_DNSSL
, "dnssl"},
565 { ND_OPT_ADVINTERVAL
, "advertisement interval"},
566 { ND_OPT_HOMEAGENT_INFO
, "homeagent information"},
567 { ND_OPT_ROUTE_INFO
, "route info"},
571 /* mldv2 report types */
572 static const struct tok mldv2report2str
[] = {
585 static const char *rtpref_str
[] = {
592 return rtpref_str
[((v
& ND_RA_FLAG_RTPREF_MASK
) >> 3) & 0xff];
596 get_lifetime(uint32_t v
)
600 if (v
== (uint32_t)~0UL)
603 snprintf(buf
, sizeof(buf
), "%us", v
);
609 print_lladdr(netdissect_options
*ndo
, const uint8_t *p
, size_t l
)
611 const uint8_t *ep
, *q
;
615 while (l
> 0 && q
< ep
) {
618 ND_PRINT((ndo
,"%02x", *q
++));
623 static int icmp6_cksum(netdissect_options
*ndo
, const struct ip6_hdr
*ip6
,
624 const struct icmp6_hdr
*icp
, u_int len
)
626 return nextproto6_cksum(ndo
, ip6
, (const uint8_t *)(const void *)icp
, len
, len
,
630 const struct tok rpl_mop_values
[] = {
631 { RPL_DIO_NONSTORING
, "nonstoring"},
632 { RPL_DIO_STORING
, "storing"},
633 { RPL_DIO_NONSTORING_MULTICAST
, "nonstoring-multicast"},
634 { RPL_DIO_STORING_MULTICAST
, "storing-multicast"},
638 const struct tok rpl_subopt_values
[] = {
639 { RPL_OPT_PAD0
, "pad0"},
640 { RPL_OPT_PADN
, "padN"},
641 { RPL_DIO_METRICS
, "metrics"},
642 { RPL_DIO_ROUTINGINFO
, "routinginfo"},
643 { RPL_DIO_CONFIG
, "config"},
644 { RPL_DAO_RPLTARGET
, "rpltarget"},
645 { RPL_DAO_TRANSITINFO
, "transitinfo"},
646 { RPL_DIO_DESTPREFIX
, "destprefix"},
647 { RPL_DAO_RPLTARGET_DESC
, "rpltargetdesc"},
652 rpl_format_dagid(char dagid_str
[65], const u_char
*dagid
)
654 inet_ntop(AF_INET6
, dagid
, dagid_str
, 64);
658 rpl_dio_printopt(netdissect_options
*ndo
,
659 const struct rpl_dio_genoption
*opt
,
662 if(length
< RPL_DIO_GENOPTION_LEN
) return;
663 length
-= RPL_DIO_GENOPTION_LEN
;
665 ND_TCHECK(opt
->rpl_dio_len
);
667 while((opt
->rpl_dio_type
== RPL_OPT_PAD0
&&
668 (const u_char
*)opt
< ndo
->ndo_snapend
) ||
669 ND_TTEST2(*opt
,(opt
->rpl_dio_len
+2))) {
671 unsigned int optlen
= opt
->rpl_dio_len
+2;
672 if(opt
->rpl_dio_type
== RPL_OPT_PAD0
) {
674 ND_PRINT((ndo
, " opt:pad0"));
676 ND_PRINT((ndo
, " opt:%s len:%u ",
677 tok2str(rpl_subopt_values
, "subopt:%u", opt
->rpl_dio_type
),
679 if(ndo
->ndo_vflag
> 2) {
680 unsigned int paylen
= opt
->rpl_dio_len
;
681 if(paylen
> length
) paylen
= length
;
684 ((const uint8_t *)opt
) + RPL_DIO_GENOPTION_LEN
, /* content of DIO option */
688 opt
= (const struct rpl_dio_genoption
*)(((const char *)opt
) + optlen
);
693 ND_PRINT((ndo
," [|truncated]"));
698 rpl_dio_print(netdissect_options
*ndo
,
699 const u_char
*bp
, u_int length
)
701 const struct nd_rpl_dio
*dio
= (const struct nd_rpl_dio
*)bp
;
705 rpl_format_dagid(dagid_str
, dio
->rpl_dagid
);
707 ND_PRINT((ndo
, " [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
711 EXTRACT_16BITS(&dio
->rpl_dagrank
),
712 RPL_DIO_GROUNDED(dio
->rpl_mopprf
) ? "grounded,":"",
713 tok2str(rpl_mop_values
, "mop%u", RPL_DIO_MOP(dio
->rpl_mopprf
)),
714 RPL_DIO_PRF(dio
->rpl_mopprf
)));
716 if(ndo
->ndo_vflag
> 1) {
717 const struct rpl_dio_genoption
*opt
= (const struct rpl_dio_genoption
*)&dio
[1];
718 rpl_dio_printopt(ndo
, opt
, length
);
722 ND_PRINT((ndo
," [|truncated]"));
727 rpl_dao_print(netdissect_options
*ndo
,
728 const u_char
*bp
, u_int length
)
730 const struct nd_rpl_dao
*dao
= (const struct nd_rpl_dao
*)bp
;
734 if (length
< ND_RPL_DAO_MIN_LEN
)
737 strcpy(dagid_str
,"<elided>");
738 bp
+= ND_RPL_DAO_MIN_LEN
;
739 length
-= ND_RPL_DAO_MIN_LEN
;
740 if(RPL_DAO_D(dao
->rpl_flags
)) {
741 ND_TCHECK2(dao
->rpl_dagid
, DAGID_LEN
);
742 if (length
< DAGID_LEN
)
744 rpl_format_dagid(dagid_str
, dao
->rpl_dagid
);
749 ND_PRINT((ndo
, " [dagid:%s,seq:%u,instance:%u%s%s,%02x]",
753 RPL_DAO_K(dao
->rpl_flags
) ? ",acK":"",
754 RPL_DAO_D(dao
->rpl_flags
) ? ",Dagid":"",
757 if(ndo
->ndo_vflag
> 1) {
758 const struct rpl_dio_genoption
*opt
= (const struct rpl_dio_genoption
*)bp
;
759 rpl_dio_printopt(ndo
, opt
, length
);
764 ND_PRINT((ndo
," [|truncated]"));
768 ND_PRINT((ndo
," [|length too short]"));
773 rpl_daoack_print(netdissect_options
*ndo
,
774 const u_char
*bp
, u_int length
)
776 const struct nd_rpl_daoack
*daoack
= (const struct nd_rpl_daoack
*)bp
;
779 ND_TCHECK2(*daoack
, ND_RPL_DAOACK_MIN_LEN
);
780 if (length
< ND_RPL_DAOACK_MIN_LEN
)
783 strcpy(dagid_str
,"<elided>");
784 bp
+= ND_RPL_DAOACK_MIN_LEN
;
785 length
-= ND_RPL_DAOACK_MIN_LEN
;
786 if(RPL_DAOACK_D(daoack
->rpl_flags
)) {
787 ND_TCHECK2(daoack
->rpl_dagid
, 16);
788 if (length
< DAGID_LEN
)
790 rpl_format_dagid(dagid_str
, daoack
->rpl_dagid
);
795 ND_PRINT((ndo
, " [dagid:%s,seq:%u,instance:%u,status:%u]",
798 daoack
->rpl_instanceid
,
799 daoack
->rpl_status
));
801 /* no officially defined options for DAOACK, but print any we find */
802 if(ndo
->ndo_vflag
> 1) {
803 const struct rpl_dio_genoption
*opt
= (const struct rpl_dio_genoption
*)bp
;
804 rpl_dio_printopt(ndo
, opt
, length
);
809 ND_PRINT((ndo
," [|dao-truncated]"));
813 ND_PRINT((ndo
," [|dao-length too short]"));
818 rpl_print(netdissect_options
*ndo
,
819 const struct icmp6_hdr
*hdr
,
820 const u_char
*bp
, u_int length
)
822 int secured
= hdr
->icmp6_code
& 0x80;
823 int basecode
= hdr
->icmp6_code
& 0x7f;
826 ND_PRINT((ndo
, ", (SEC) [worktodo]"));
828 * the next header pointer needs to move forward to
829 * skip the secure part.
833 ND_PRINT((ndo
, ", (CLR)"));
838 ND_PRINT((ndo
, "DODAG Information Solicitation"));
843 ND_PRINT((ndo
, "DODAG Information Object"));
845 rpl_dio_print(ndo
, bp
, length
);
849 ND_PRINT((ndo
, "Destination Advertisement Object"));
851 rpl_dao_print(ndo
, bp
, length
);
855 ND_PRINT((ndo
, "Destination Advertisement Object Ack"));
857 rpl_daoack_print(ndo
, bp
, length
);
861 ND_PRINT((ndo
, "RPL message, unknown code %u",hdr
->icmp6_code
));
868 ND_PRINT((ndo
," [|truncated]"));
876 icmp6_print(netdissect_options
*ndo
,
877 const u_char
*bp
, u_int length
, const u_char
*bp2
, int fragmented
)
879 const struct icmp6_hdr
*dp
;
880 const struct ip6_hdr
*ip
;
881 const struct ip6_hdr
*oip
;
882 const struct udphdr
*ouh
;
887 dp
= (const struct icmp6_hdr
*)bp
;
888 ip
= (const struct ip6_hdr
*)bp2
;
889 oip
= (const struct ip6_hdr
*)(dp
+ 1);
890 /* 'ep' points to the end of available data. */
891 ep
= ndo
->ndo_snapend
;
893 ND_TCHECK(dp
->icmp6_cksum
);
895 if (ndo
->ndo_vflag
&& !fragmented
) {
896 uint16_t sum
, udp_sum
;
898 if (ND_TTEST2(bp
[0], length
)) {
899 udp_sum
= EXTRACT_16BITS(&dp
->icmp6_cksum
);
900 sum
= icmp6_cksum(ndo
, ip
, dp
, length
);
902 ND_PRINT((ndo
,"[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
904 in_cksum_shouldbe(udp_sum
, sum
)));
906 ND_PRINT((ndo
,"[icmp6 sum ok] "));
910 ND_PRINT((ndo
,"ICMP6, %s", tok2str(icmp6_type_values
,"unknown icmp6 type (%u)",dp
->icmp6_type
)));
912 /* display cosmetics: print the packet length for printer that use the vflag now */
913 if (ndo
->ndo_vflag
&& (dp
->icmp6_type
== ND_ROUTER_SOLICIT
||
914 dp
->icmp6_type
== ND_ROUTER_ADVERT
||
915 dp
->icmp6_type
== ND_NEIGHBOR_ADVERT
||
916 dp
->icmp6_type
== ND_NEIGHBOR_SOLICIT
||
917 dp
->icmp6_type
== ND_REDIRECT
||
918 dp
->icmp6_type
== ICMP6_HADISCOV_REPLY
||
919 dp
->icmp6_type
== ICMP6_MOBILEPREFIX_ADVERT
))
920 ND_PRINT((ndo
,", length %u", length
));
922 switch (dp
->icmp6_type
) {
923 case ICMP6_DST_UNREACH
:
924 ND_TCHECK(oip
->ip6_dst
);
925 ND_PRINT((ndo
,", %s", tok2str(icmp6_dst_unreach_code_values
,"unknown unreach code (%u)",dp
->icmp6_code
)));
926 switch (dp
->icmp6_code
) {
928 case ICMP6_DST_UNREACH_NOROUTE
: /* fall through */
929 case ICMP6_DST_UNREACH_ADMIN
:
930 case ICMP6_DST_UNREACH_ADDR
:
931 ND_PRINT((ndo
," %s",ip6addr_string(ndo
, &oip
->ip6_dst
)));
933 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
934 ND_PRINT((ndo
," %s, source address %s",
935 ip6addr_string(ndo
, &oip
->ip6_dst
),
936 ip6addr_string(ndo
, &oip
->ip6_src
)));
938 case ICMP6_DST_UNREACH_NOPORT
:
939 if ((ouh
= get_upperlayer(ndo
, (const u_char
*)oip
, &prot
))
943 dport
= EXTRACT_16BITS(&ouh
->uh_dport
);
946 ND_PRINT((ndo
,", %s tcp port %s",
947 ip6addr_string(ndo
, &oip
->ip6_dst
),
948 tcpport_string(ndo
, dport
)));
951 ND_PRINT((ndo
,", %s udp port %s",
952 ip6addr_string(ndo
, &oip
->ip6_dst
),
953 udpport_string(ndo
, dport
)));
956 ND_PRINT((ndo
,", %s protocol %d port %d unreachable",
957 ip6addr_string(ndo
, &oip
->ip6_dst
),
958 oip
->ip6_nxt
, dport
));
963 if (ndo
->ndo_vflag
<= 1) {
964 print_unknown_data(ndo
, bp
,"\n\t",length
);
970 case ICMP6_PACKET_TOO_BIG
:
971 ND_TCHECK(dp
->icmp6_mtu
);
972 ND_PRINT((ndo
,", mtu %u", EXTRACT_32BITS(&dp
->icmp6_mtu
)));
974 case ICMP6_TIME_EXCEEDED
:
975 ND_TCHECK(oip
->ip6_dst
);
976 switch (dp
->icmp6_code
) {
977 case ICMP6_TIME_EXCEED_TRANSIT
:
978 ND_PRINT((ndo
," for %s",
979 ip6addr_string(ndo
, &oip
->ip6_dst
)));
981 case ICMP6_TIME_EXCEED_REASSEMBLY
:
982 ND_PRINT((ndo
," (reassembly)"));
985 ND_PRINT((ndo
,", unknown code (%u)", dp
->icmp6_code
));
989 case ICMP6_PARAM_PROB
:
990 ND_TCHECK(oip
->ip6_dst
);
991 switch (dp
->icmp6_code
) {
992 case ICMP6_PARAMPROB_HEADER
:
993 ND_PRINT((ndo
,", erroneous - octet %u", EXTRACT_32BITS(&dp
->icmp6_pptr
)));
995 case ICMP6_PARAMPROB_NEXTHEADER
:
996 ND_PRINT((ndo
,", next header - octet %u", EXTRACT_32BITS(&dp
->icmp6_pptr
)));
998 case ICMP6_PARAMPROB_OPTION
:
999 ND_PRINT((ndo
,", option - octet %u", EXTRACT_32BITS(&dp
->icmp6_pptr
)));
1002 ND_PRINT((ndo
,", code-#%d",
1007 case ICMP6_ECHO_REQUEST
:
1008 case ICMP6_ECHO_REPLY
:
1009 ND_TCHECK(dp
->icmp6_seq
);
1010 ND_PRINT((ndo
,", seq %u", EXTRACT_16BITS(&dp
->icmp6_seq
)));
1012 case ICMP6_MEMBERSHIP_QUERY
:
1013 if (length
== MLD_MINLEN
) {
1014 mld6_print(ndo
, (const u_char
*)dp
);
1015 } else if (length
>= MLDV2_MINLEN
) {
1016 ND_PRINT((ndo
," v2"));
1017 mldv2_query_print(ndo
, (const u_char
*)dp
, length
);
1019 ND_PRINT((ndo
," unknown-version (len %u) ", length
));
1022 case ICMP6_MEMBERSHIP_REPORT
:
1023 mld6_print(ndo
, (const u_char
*)dp
);
1025 case ICMP6_MEMBERSHIP_REDUCTION
:
1026 mld6_print(ndo
, (const u_char
*)dp
);
1028 case ND_ROUTER_SOLICIT
:
1030 if (ndo
->ndo_vflag
) {
1031 icmp6_opt_print(ndo
, (const u_char
*)dp
+ RTSOLLEN
,
1035 case ND_ROUTER_ADVERT
:
1037 if (ndo
->ndo_vflag
) {
1038 const struct nd_router_advert
*p
;
1040 p
= (const struct nd_router_advert
*)dp
;
1041 ND_TCHECK(p
->nd_ra_retransmit
);
1042 ND_PRINT((ndo
,"\n\thop limit %u, Flags [%s]" \
1043 ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
1044 (u_int
)p
->nd_ra_curhoplimit
,
1045 bittok2str(icmp6_opt_ra_flag_values
,"none",(p
->nd_ra_flags_reserved
)),
1046 get_rtpref(p
->nd_ra_flags_reserved
),
1047 EXTRACT_16BITS(&p
->nd_ra_router_lifetime
),
1048 EXTRACT_32BITS(&p
->nd_ra_reachable
),
1049 EXTRACT_32BITS(&p
->nd_ra_retransmit
)));
1051 icmp6_opt_print(ndo
, (const u_char
*)dp
+ RTADVLEN
,
1055 case ND_NEIGHBOR_SOLICIT
:
1057 const struct nd_neighbor_solicit
*p
;
1058 p
= (const struct nd_neighbor_solicit
*)dp
;
1059 ND_TCHECK(p
->nd_ns_target
);
1060 ND_PRINT((ndo
,", who has %s", ip6addr_string(ndo
, &p
->nd_ns_target
)));
1061 if (ndo
->ndo_vflag
) {
1063 icmp6_opt_print(ndo
, (const u_char
*)dp
+ NDSOLLEN
,
1068 case ND_NEIGHBOR_ADVERT
:
1070 const struct nd_neighbor_advert
*p
;
1072 p
= (const struct nd_neighbor_advert
*)dp
;
1073 ND_TCHECK(p
->nd_na_target
);
1074 ND_PRINT((ndo
,", tgt is %s",
1075 ip6addr_string(ndo
, &p
->nd_na_target
)));
1076 if (ndo
->ndo_vflag
) {
1077 ND_PRINT((ndo
,", Flags [%s]",
1078 bittok2str(icmp6_nd_na_flag_values
,
1080 EXTRACT_32BITS(&p
->nd_na_flags_reserved
))));
1082 icmp6_opt_print(ndo
, (const u_char
*)dp
+ NDADVLEN
,
1089 #define RDR(i) ((const struct nd_redirect *)(i))
1090 ND_TCHECK(RDR(dp
)->nd_rd_dst
);
1091 ND_PRINT((ndo
,", %s", ip6addr_string(ndo
, &RDR(dp
)->nd_rd_dst
)));
1092 ND_TCHECK(RDR(dp
)->nd_rd_target
);
1093 ND_PRINT((ndo
," to %s",
1094 ip6addr_string(ndo
, &RDR(dp
)->nd_rd_target
)));
1095 #define REDIRECTLEN 40
1096 if (ndo
->ndo_vflag
) {
1097 icmp6_opt_print(ndo
, (const u_char
*)dp
+ REDIRECTLEN
,
1098 length
- REDIRECTLEN
);
1103 case ICMP6_ROUTER_RENUMBERING
:
1104 icmp6_rrenum_print(ndo
, bp
, ep
);
1106 case ICMP6_NI_QUERY
:
1107 case ICMP6_NI_REPLY
:
1108 icmp6_nodeinfo_print(ndo
, length
, bp
, ep
);
1113 case ICMP6_V2_MEMBERSHIP_REPORT
:
1114 mldv2_report_print(ndo
, (const u_char
*) dp
, length
);
1116 case ICMP6_MOBILEPREFIX_SOLICIT
: /* fall through */
1117 case ICMP6_HADISCOV_REQUEST
:
1118 ND_TCHECK(dp
->icmp6_data16
[0]);
1119 ND_PRINT((ndo
,", id 0x%04x", EXTRACT_16BITS(&dp
->icmp6_data16
[0])));
1121 case ICMP6_HADISCOV_REPLY
:
1122 if (ndo
->ndo_vflag
) {
1123 const struct in6_addr
*in6
;
1126 ND_TCHECK(dp
->icmp6_data16
[0]);
1127 ND_PRINT((ndo
,", id 0x%04x", EXTRACT_16BITS(&dp
->icmp6_data16
[0])));
1128 cp
= (const u_char
*)dp
+ length
;
1129 in6
= (const struct in6_addr
*)(dp
+ 1);
1130 for (; (const u_char
*)in6
< cp
; in6
++) {
1132 ND_PRINT((ndo
,", %s", ip6addr_string(ndo
, in6
)));
1136 case ICMP6_MOBILEPREFIX_ADVERT
:
1137 if (ndo
->ndo_vflag
) {
1138 ND_TCHECK(dp
->icmp6_data16
[0]);
1139 ND_PRINT((ndo
,", id 0x%04x", EXTRACT_16BITS(&dp
->icmp6_data16
[0])));
1140 if (dp
->icmp6_data16
[1] & 0xc0)
1141 ND_PRINT((ndo
," "));
1142 if (dp
->icmp6_data16
[1] & 0x80)
1143 ND_PRINT((ndo
,"M"));
1144 if (dp
->icmp6_data16
[1] & 0x40)
1145 ND_PRINT((ndo
,"O"));
1147 icmp6_opt_print(ndo
, (const u_char
*)dp
+ MPADVLEN
,
1151 case ND_RPL_MESSAGE
:
1152 /* plus 4, because struct icmp6_hdr contains 4 bytes of icmp payload */
1153 rpl_print(ndo
, dp
, &dp
->icmp6_data8
[0], length
-sizeof(struct icmp6_hdr
)+4);
1156 ND_PRINT((ndo
,", length %u", length
));
1157 if (ndo
->ndo_vflag
<= 1)
1158 print_unknown_data(ndo
, bp
,"\n\t", length
);
1161 if (!ndo
->ndo_vflag
)
1162 ND_PRINT((ndo
,", length %u", length
));
1165 ND_PRINT((ndo
, "[|icmp6]"));
1168 static const struct udphdr
*
1169 get_upperlayer(netdissect_options
*ndo
, const u_char
*bp
, u_int
*prot
)
1172 const struct ip6_hdr
*ip6
= (const struct ip6_hdr
*)bp
;
1173 const struct udphdr
*uh
;
1174 const struct ip6_hbh
*hbh
;
1175 const struct ip6_frag
*fragh
;
1176 const struct ah
*ah
;
1180 /* 'ep' points to the end of available data. */
1181 ep
= ndo
->ndo_snapend
;
1183 if (!ND_TTEST(ip6
->ip6_nxt
))
1187 hlen
= sizeof(struct ip6_hdr
);
1195 uh
= (const struct udphdr
*)bp
;
1196 if (ND_TTEST(uh
->uh_dport
)) {
1204 case IPPROTO_HOPOPTS
:
1205 case IPPROTO_DSTOPTS
:
1206 case IPPROTO_ROUTING
:
1207 hbh
= (const struct ip6_hbh
*)bp
;
1208 if (!ND_TTEST(hbh
->ip6h_len
))
1211 hlen
= (hbh
->ip6h_len
+ 1) << 3;
1214 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
1215 fragh
= (const struct ip6_frag
*)bp
;
1216 if (!ND_TTEST(fragh
->ip6f_offlg
))
1218 /* fragments with non-zero offset are meaningless */
1219 if ((EXTRACT_16BITS(&fragh
->ip6f_offlg
) & IP6F_OFF_MASK
) != 0)
1221 nh
= fragh
->ip6f_nxt
;
1222 hlen
= sizeof(struct ip6_frag
);
1226 ah
= (const struct ah
*)bp
;
1227 if (!ND_TTEST(ah
->ah_len
))
1230 hlen
= (ah
->ah_len
+ 2) << 2;
1233 default: /* unknown or undecodable header */
1234 *prot
= nh
; /* meaningless, but set here anyway */
1239 return(NULL
); /* should be notreached, though */
1243 icmp6_opt_print(netdissect_options
*ndo
, const u_char
*bp
, int resid
)
1245 const struct nd_opt_hdr
*op
;
1246 const struct nd_opt_prefix_info
*opp
;
1247 const struct nd_opt_mtu
*opm
;
1248 const struct nd_opt_rdnss
*oprd
;
1249 const struct nd_opt_dnssl
*opds
;
1250 const struct nd_opt_advinterval
*opa
;
1251 const struct nd_opt_homeagent_info
*oph
;
1252 const struct nd_opt_route_info
*opri
;
1253 const u_char
*cp
, *ep
, *domp
;
1254 struct in6_addr in6
;
1255 const struct in6_addr
*in6p
;
1259 #define ECHECK(var) if ((const u_char *)&(var) > ep - sizeof(var)) return
1262 /* 'ep' points to the end of available data. */
1263 ep
= ndo
->ndo_snapend
;
1266 op
= (const struct nd_opt_hdr
*)cp
;
1268 ECHECK(op
->nd_opt_len
);
1271 if (op
->nd_opt_len
== 0)
1273 if (cp
+ (op
->nd_opt_len
<< 3) > ep
)
1276 ND_PRINT((ndo
,"\n\t %s option (%u), length %u (%u): ",
1277 tok2str(icmp6_opt_values
, "unknown", op
->nd_opt_type
),
1279 op
->nd_opt_len
<< 3,
1282 switch (op
->nd_opt_type
) {
1283 case ND_OPT_SOURCE_LINKADDR
:
1284 l
= (op
->nd_opt_len
<< 3) - 2;
1285 print_lladdr(ndo
, cp
+ 2, l
);
1287 case ND_OPT_TARGET_LINKADDR
:
1288 l
= (op
->nd_opt_len
<< 3) - 2;
1289 print_lladdr(ndo
, cp
+ 2, l
);
1291 case ND_OPT_PREFIX_INFORMATION
:
1292 opp
= (const struct nd_opt_prefix_info
*)op
;
1293 ND_TCHECK(opp
->nd_opt_pi_prefix
);
1294 ND_PRINT((ndo
,"%s/%u%s, Flags [%s], valid time %s",
1295 ip6addr_string(ndo
, &opp
->nd_opt_pi_prefix
),
1296 opp
->nd_opt_pi_prefix_len
,
1297 (op
->nd_opt_len
!= 4) ? "badlen" : "",
1298 bittok2str(icmp6_opt_pi_flag_values
, "none", opp
->nd_opt_pi_flags_reserved
),
1299 get_lifetime(EXTRACT_32BITS(&opp
->nd_opt_pi_valid_time
))));
1300 ND_PRINT((ndo
,", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp
->nd_opt_pi_preferred_time
))));
1302 case ND_OPT_REDIRECTED_HEADER
:
1303 print_unknown_data(ndo
, bp
,"\n\t ",op
->nd_opt_len
<<3);
1307 opm
= (const struct nd_opt_mtu
*)op
;
1308 ND_TCHECK(opm
->nd_opt_mtu_mtu
);
1309 ND_PRINT((ndo
," %u%s",
1310 EXTRACT_32BITS(&opm
->nd_opt_mtu_mtu
),
1311 (op
->nd_opt_len
!= 1) ? "bad option length" : "" ));
1314 oprd
= (const struct nd_opt_rdnss
*)op
;
1315 l
= (op
->nd_opt_len
- 1) / 2;
1316 ND_PRINT((ndo
," lifetime %us,",
1317 EXTRACT_32BITS(&oprd
->nd_opt_rdnss_lifetime
)));
1318 for (i
= 0; i
< l
; i
++) {
1319 ND_TCHECK(oprd
->nd_opt_rdnss_addr
[i
]);
1320 ND_PRINT((ndo
," addr: %s",
1321 ip6addr_string(ndo
, &oprd
->nd_opt_rdnss_addr
[i
])));
1325 opds
= (const struct nd_opt_dnssl
*)op
;
1326 ND_PRINT((ndo
," lifetime %us, domain(s):",
1327 EXTRACT_32BITS(&opds
->nd_opt_dnssl_lifetime
)));
1328 domp
= cp
+ 8; /* domain names, variable-sized, RFC1035-encoded */
1329 while (domp
< cp
+ (op
->nd_opt_len
<< 3) && *domp
!= '\0')
1331 ND_PRINT((ndo
, " "));
1332 if ((domp
= ns_nprint (ndo
, domp
, bp
)) == NULL
)
1336 case ND_OPT_ADVINTERVAL
:
1337 opa
= (const struct nd_opt_advinterval
*)op
;
1338 ND_TCHECK(opa
->nd_opt_adv_interval
);
1339 ND_PRINT((ndo
," %ums", EXTRACT_32BITS(&opa
->nd_opt_adv_interval
)));
1341 case ND_OPT_HOMEAGENT_INFO
:
1342 oph
= (const struct nd_opt_homeagent_info
*)op
;
1343 ND_TCHECK(oph
->nd_opt_hai_lifetime
);
1344 ND_PRINT((ndo
," preference %u, lifetime %u",
1345 EXTRACT_16BITS(&oph
->nd_opt_hai_preference
),
1346 EXTRACT_16BITS(&oph
->nd_opt_hai_lifetime
)));
1348 case ND_OPT_ROUTE_INFO
:
1349 opri
= (const struct nd_opt_route_info
*)op
;
1350 ND_TCHECK(opri
->nd_opt_rti_lifetime
);
1351 memset(&in6
, 0, sizeof(in6
));
1352 in6p
= (const struct in6_addr
*)(opri
+ 1);
1353 switch (op
->nd_opt_len
) {
1357 ND_TCHECK2(*in6p
, 8);
1358 memcpy(&in6
, opri
+ 1, 8);
1362 memcpy(&in6
, opri
+ 1, sizeof(in6
));
1367 ND_PRINT((ndo
," %s/%u", ip6addr_string(ndo
, &in6
),
1368 opri
->nd_opt_rti_prefixlen
));
1369 ND_PRINT((ndo
,", pref=%s", get_rtpref(opri
->nd_opt_rti_flags
)));
1370 ND_PRINT((ndo
,", lifetime=%s",
1371 get_lifetime(EXTRACT_32BITS(&opri
->nd_opt_rti_lifetime
))));
1374 if (ndo
->ndo_vflag
<= 1) {
1375 print_unknown_data(ndo
,cp
+2,"\n\t ", (op
->nd_opt_len
<< 3) - 2); /* skip option header */
1380 /* do we want to see an additional hexdump ? */
1381 if (ndo
->ndo_vflag
> 1)
1382 print_unknown_data(ndo
, cp
+2,"\n\t ", (op
->nd_opt_len
<< 3) - 2); /* skip option header */
1384 cp
+= op
->nd_opt_len
<< 3;
1385 resid
-= op
->nd_opt_len
<< 3;
1390 ND_PRINT((ndo
, "[ndp opt]"));
1396 mld6_print(netdissect_options
*ndo
, const u_char
*bp
)
1398 const struct mld6_hdr
*mp
= (const struct mld6_hdr
*)bp
;
1401 /* 'ep' points to the end of available data. */
1402 ep
= ndo
->ndo_snapend
;
1404 if ((const u_char
*)mp
+ sizeof(*mp
) > ep
)
1407 ND_PRINT((ndo
,"max resp delay: %d ", EXTRACT_16BITS(&mp
->mld6_maxdelay
)));
1408 ND_PRINT((ndo
,"addr: %s", ip6addr_string(ndo
, &mp
->mld6_addr
)));
1412 mldv2_report_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len
)
1414 const struct icmp6_hdr
*icp
= (const struct icmp6_hdr
*) bp
;
1415 u_int group
, nsrcs
, ngroups
;
1418 /* Minimum len is 8 */
1420 ND_PRINT((ndo
," [invalid len %d]", len
));
1424 ND_TCHECK(icp
->icmp6_data16
[1]);
1425 ngroups
= EXTRACT_16BITS(&icp
->icmp6_data16
[1]);
1426 ND_PRINT((ndo
,", %d group record(s)", ngroups
));
1427 if (ndo
->ndo_vflag
> 0) {
1428 /* Print the group records */
1430 for (i
= 0; i
< ngroups
; i
++) {
1431 /* type(1) + auxlen(1) + numsrc(2) + grp(16) */
1432 if (len
< group
+ 20) {
1433 ND_PRINT((ndo
," [invalid number of groups]"));
1436 ND_TCHECK2(bp
[group
+ 4], sizeof(struct in6_addr
));
1437 ND_PRINT((ndo
," [gaddr %s", ip6addr_string(ndo
, &bp
[group
+ 4])));
1438 ND_PRINT((ndo
," %s", tok2str(mldv2report2str
, " [v2-report-#%d]",
1440 nsrcs
= (bp
[group
+ 2] << 8) + bp
[group
+ 3];
1441 /* Check the number of sources and print them */
1442 if (len
< group
+ 20 + (nsrcs
* sizeof(struct in6_addr
))) {
1443 ND_PRINT((ndo
," [invalid number of sources %d]", nsrcs
));
1446 if (ndo
->ndo_vflag
== 1)
1447 ND_PRINT((ndo
,", %d source(s)", nsrcs
));
1449 /* Print the sources */
1450 ND_PRINT((ndo
," {"));
1451 for (j
= 0; j
< nsrcs
; j
++) {
1452 ND_TCHECK2(bp
[group
+ 20 + j
* sizeof(struct in6_addr
)],
1453 sizeof(struct in6_addr
));
1454 ND_PRINT((ndo
," %s", ip6addr_string(ndo
, &bp
[group
+ 20 + j
* sizeof(struct in6_addr
)])));
1456 ND_PRINT((ndo
," }"));
1458 /* Next group record */
1459 group
+= 20 + nsrcs
* sizeof(struct in6_addr
);
1460 ND_PRINT((ndo
,"]"));
1465 ND_PRINT((ndo
,"[|icmp6]"));
1470 mldv2_query_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len
)
1472 const struct icmp6_hdr
*icp
= (const struct icmp6_hdr
*) bp
;
1478 /* Minimum len is 28 */
1480 ND_PRINT((ndo
," [invalid len %d]", len
));
1483 ND_TCHECK(icp
->icmp6_data16
[0]);
1484 mrc
= EXTRACT_16BITS(&icp
->icmp6_data16
[0]);
1488 mrt
= ((mrc
& 0x0fff) | 0x1000) << (((mrc
& 0x7000) >> 12) + 3);
1490 if (ndo
->ndo_vflag
) {
1491 ND_PRINT((ndo
," [max resp delay=%d]", mrt
));
1493 ND_TCHECK2(bp
[8], sizeof(struct in6_addr
));
1494 ND_PRINT((ndo
," [gaddr %s", ip6addr_string(ndo
, &bp
[8])));
1496 if (ndo
->ndo_vflag
) {
1498 if (bp
[24] & 0x08) {
1499 ND_PRINT((ndo
," sflag"));
1501 if (bp
[24] & 0x07) {
1502 ND_PRINT((ndo
," robustness=%d", bp
[24] & 0x07));
1507 qqi
= ((bp
[25] & 0x0f) | 0x10) << (((bp
[25] & 0x70) >> 4) + 3);
1509 ND_PRINT((ndo
," qqi=%d", qqi
));
1512 ND_TCHECK2(bp
[26], 2);
1513 nsrcs
= EXTRACT_16BITS(&bp
[26]);
1515 if (len
< 28 + nsrcs
* sizeof(struct in6_addr
))
1516 ND_PRINT((ndo
," [invalid number of sources]"));
1517 else if (ndo
->ndo_vflag
> 1) {
1518 ND_PRINT((ndo
," {"));
1519 for (i
= 0; i
< nsrcs
; i
++) {
1520 ND_TCHECK2(bp
[28 + i
* sizeof(struct in6_addr
)],
1521 sizeof(struct in6_addr
));
1522 ND_PRINT((ndo
," %s", ip6addr_string(ndo
, &bp
[28 + i
* sizeof(struct in6_addr
)])));
1524 ND_PRINT((ndo
," }"));
1526 ND_PRINT((ndo
,", %d source(s)", nsrcs
));
1528 ND_PRINT((ndo
,"]"));
1531 ND_PRINT((ndo
,"[|icmp6]"));
1536 dnsname_print(netdissect_options
*ndo
, const u_char
*cp
, const u_char
*ep
)
1540 /* DNS name decoding - no decompression */
1541 ND_PRINT((ndo
,", \""));
1546 ND_PRINT((ndo
,"???"));
1549 while (i
-- && cp
< ep
) {
1550 safeputchar(ndo
, *cp
);
1553 if (cp
+ 1 < ep
&& *cp
)
1554 ND_PRINT((ndo
,"."));
1558 ND_PRINT((ndo
,"."));
1559 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
1563 ND_PRINT((ndo
,"???"));
1568 ND_PRINT((ndo
,"\""));
1572 icmp6_nodeinfo_print(netdissect_options
*ndo
, u_int icmp6len
, const u_char
*bp
, const u_char
*ep
)
1574 const struct icmp6_nodeinfo
*ni6
;
1575 const struct icmp6_hdr
*dp
;
1582 dp
= (const struct icmp6_hdr
*)bp
;
1583 ni6
= (const struct icmp6_nodeinfo
*)bp
;
1586 switch (ni6
->ni_type
) {
1587 case ICMP6_NI_QUERY
:
1588 if (siz
== sizeof(*dp
) + 4) {
1589 /* KAME who-are-you */
1590 ND_PRINT((ndo
," who-are-you request"));
1593 ND_PRINT((ndo
," node information query"));
1595 ND_TCHECK2(*dp
, sizeof(*ni6
));
1596 ni6
= (const struct icmp6_nodeinfo
*)dp
;
1597 ND_PRINT((ndo
," (")); /*)*/
1598 switch (EXTRACT_16BITS(&ni6
->ni_qtype
)) {
1600 ND_PRINT((ndo
,"noop"));
1602 case NI_QTYPE_SUPTYPES
:
1603 ND_PRINT((ndo
,"supported qtypes"));
1604 i
= EXTRACT_16BITS(&ni6
->ni_flags
);
1606 ND_PRINT((ndo
," [%s]", (i
& 0x01) ? "C" : ""));
1609 ND_PRINT((ndo
,"DNS name"));
1611 case NI_QTYPE_NODEADDR
:
1612 ND_PRINT((ndo
,"node addresses"));
1616 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
1617 ND_PRINT((ndo
," [%s%s%s%s%s%s]",
1618 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
1619 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
1620 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
1621 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
1622 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
1623 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : ""));
1626 ND_PRINT((ndo
,"unknown"));
1630 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
1631 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
1632 if (siz
!= sizeof(*ni6
))
1634 ND_PRINT((ndo
,", invalid len"));
1636 ND_PRINT((ndo
,")"));
1641 /* XXX backward compat, icmp-name-lookup-03 */
1642 if (siz
== sizeof(*ni6
)) {
1643 ND_PRINT((ndo
,", 03 draft"));
1645 ND_PRINT((ndo
,")"));
1649 switch (ni6
->ni_code
) {
1650 case ICMP6_NI_SUBJ_IPV6
:
1652 sizeof(*ni6
) + sizeof(struct in6_addr
)))
1654 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
1656 ND_PRINT((ndo
,", invalid subject len"));
1659 ND_PRINT((ndo
,", subject=%s",
1660 ip6addr_string(ndo
, ni6
+ 1)));
1662 case ICMP6_NI_SUBJ_FQDN
:
1663 ND_PRINT((ndo
,", subject=DNS name"));
1664 cp
= (const u_char
*)(ni6
+ 1);
1665 if (cp
[0] == ep
- cp
- 1) {
1666 /* icmp-name-lookup-03, pascal string */
1668 ND_PRINT((ndo
,", 03 draft"));
1670 ND_PRINT((ndo
,", \""));
1672 safeputchar(ndo
, *cp
);
1675 ND_PRINT((ndo
,"\""));
1677 dnsname_print(ndo
, cp
, ep
);
1679 case ICMP6_NI_SUBJ_IPV4
:
1680 if (!ND_TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
1682 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
1684 ND_PRINT((ndo
,", invalid subject len"));
1687 ND_PRINT((ndo
,", subject=%s",
1688 getname(ndo
, (const u_char
*)(ni6
+ 1))));
1691 ND_PRINT((ndo
,", unknown subject"));
1696 ND_PRINT((ndo
,")"));
1699 case ICMP6_NI_REPLY
:
1700 if (icmp6len
> siz
) {
1701 ND_PRINT((ndo
,"[|icmp6: node information reply]"));
1707 ni6
= (const struct icmp6_nodeinfo
*)dp
;
1708 ND_PRINT((ndo
," node information reply"));
1709 ND_PRINT((ndo
," (")); /*)*/
1710 switch (ni6
->ni_code
) {
1711 case ICMP6_NI_SUCCESS
:
1712 if (ndo
->ndo_vflag
) {
1713 ND_PRINT((ndo
,"success"));
1717 case ICMP6_NI_REFUSED
:
1718 ND_PRINT((ndo
,"refused"));
1720 if (siz
!= sizeof(*ni6
))
1722 ND_PRINT((ndo
,", invalid length"));
1724 case ICMP6_NI_UNKNOWN
:
1725 ND_PRINT((ndo
,"unknown"));
1727 if (siz
!= sizeof(*ni6
))
1729 ND_PRINT((ndo
,", invalid length"));
1733 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
1735 ND_PRINT((ndo
,")"));
1739 switch (EXTRACT_16BITS(&ni6
->ni_qtype
)) {
1742 ND_PRINT((ndo
,", "));
1743 ND_PRINT((ndo
,"noop"));
1744 if (siz
!= sizeof(*ni6
))
1746 ND_PRINT((ndo
,", invalid length"));
1748 case NI_QTYPE_SUPTYPES
:
1750 ND_PRINT((ndo
,", "));
1751 ND_PRINT((ndo
,"supported qtypes"));
1752 i
= EXTRACT_16BITS(&ni6
->ni_flags
);
1754 ND_PRINT((ndo
," [%s]", (i
& 0x01) ? "C" : ""));
1758 ND_PRINT((ndo
,", "));
1759 ND_PRINT((ndo
,"DNS name"));
1760 cp
= (const u_char
*)(ni6
+ 1) + 4;
1761 if (cp
[0] == ep
- cp
- 1) {
1762 /* icmp-name-lookup-03, pascal string */
1764 ND_PRINT((ndo
,", 03 draft"));
1766 ND_PRINT((ndo
,", \""));
1768 safeputchar(ndo
, *cp
);
1771 ND_PRINT((ndo
,"\""));
1773 dnsname_print(ndo
, cp
, ep
);
1774 if ((EXTRACT_16BITS(&ni6
->ni_flags
) & 0x01) != 0)
1775 ND_PRINT((ndo
," [TTL=%u]", EXTRACT_32BITS(ni6
+ 1)));
1777 case NI_QTYPE_NODEADDR
:
1779 ND_PRINT((ndo
,", "));
1780 ND_PRINT((ndo
,"node addresses"));
1783 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
1785 ND_PRINT((ndo
," %s", ip6addr_string(ndo
, bp
+ i
)));
1786 i
+= sizeof(struct in6_addr
);
1787 ND_PRINT((ndo
,"(%d)", (int32_t)EXTRACT_32BITS(bp
+ i
)));
1788 i
+= sizeof(int32_t);
1793 ND_PRINT((ndo
," [%s%s%s%s%s%s%s]",
1794 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
1795 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
1796 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
1797 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
1798 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
1799 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
1800 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : ""));
1804 ND_PRINT((ndo
,", "));
1805 ND_PRINT((ndo
,"unknown"));
1810 ND_PRINT((ndo
,")"));
1816 ND_PRINT((ndo
, "[|icmp6]"));
1820 icmp6_rrenum_print(netdissect_options
*ndo
, const u_char
*bp
, const u_char
*ep
)
1822 const struct icmp6_router_renum
*rr6
;
1824 const struct rr_pco_match
*match
;
1825 const struct rr_pco_use
*use
;
1826 char hbuf
[NI_MAXHOST
];
1831 rr6
= (const struct icmp6_router_renum
*)bp
;
1832 cp
= (const char *)(rr6
+ 1);
1834 ND_TCHECK(rr6
->rr_reserved
);
1835 switch (rr6
->rr_code
) {
1836 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
1837 ND_PRINT((ndo
,"router renum: command"));
1839 case ICMP6_ROUTER_RENUMBERING_RESULT
:
1840 ND_PRINT((ndo
,"router renum: result"));
1842 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
1843 ND_PRINT((ndo
,"router renum: sequence number reset"));
1846 ND_PRINT((ndo
,"router renum: code-#%d", rr6
->rr_code
));
1850 ND_PRINT((ndo
,", seq=%u", EXTRACT_32BITS(&rr6
->rr_seqnum
)));
1852 if (ndo
->ndo_vflag
) {
1853 #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
1854 ND_PRINT((ndo
,"[")); /*]*/
1855 if (rr6
->rr_flags
) {
1856 ND_PRINT((ndo
,"%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
1857 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
1858 F(ICMP6_RR_FLAGS_FORCEAPPLY
, "A"),
1859 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
1860 F(ICMP6_RR_FLAGS_PREVDONE
, "P")));
1862 ND_PRINT((ndo
,"seg=%u,", rr6
->rr_segnum
));
1863 ND_PRINT((ndo
,"maxdelay=%u", EXTRACT_16BITS(&rr6
->rr_maxdelay
)));
1864 if (rr6
->rr_reserved
)
1865 ND_PRINT((ndo
,"rsvd=0x%x", EXTRACT_32BITS(&rr6
->rr_reserved
)));
1867 ND_PRINT((ndo
,"]"));
1871 if (rr6
->rr_code
== ICMP6_ROUTER_RENUMBERING_COMMAND
) {
1872 match
= (const struct rr_pco_match
*)cp
;
1873 cp
= (const char *)(match
+ 1);
1875 ND_TCHECK(match
->rpm_prefix
);
1877 if (ndo
->ndo_vflag
> 1)
1878 ND_PRINT((ndo
,"\n\t"));
1880 ND_PRINT((ndo
," "));
1881 ND_PRINT((ndo
,"match(")); /*)*/
1882 switch (match
->rpm_code
) {
1883 case RPM_PCO_ADD
: ND_PRINT((ndo
,"add")); break;
1884 case RPM_PCO_CHANGE
: ND_PRINT((ndo
,"change")); break;
1885 case RPM_PCO_SETGLOBAL
: ND_PRINT((ndo
,"setglobal")); break;
1886 default: ND_PRINT((ndo
,"#%u", match
->rpm_code
)); break;
1889 if (ndo
->ndo_vflag
) {
1890 ND_PRINT((ndo
,",ord=%u", match
->rpm_ordinal
));
1891 ND_PRINT((ndo
,",min=%u", match
->rpm_minlen
));
1892 ND_PRINT((ndo
,",max=%u", match
->rpm_maxlen
));
1894 if (addrtostr6(&match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
1895 ND_PRINT((ndo
,",%s/%u", hbuf
, match
->rpm_matchlen
));
1897 ND_PRINT((ndo
,",?/%u", match
->rpm_matchlen
));
1899 ND_PRINT((ndo
,")"));
1901 n
= match
->rpm_len
- 3;
1906 use
= (const struct rr_pco_use
*)cp
;
1907 cp
= (const char *)(use
+ 1);
1909 ND_TCHECK(use
->rpu_prefix
);
1911 if (ndo
->ndo_vflag
> 1)
1912 ND_PRINT((ndo
,"\n\t"));
1914 ND_PRINT((ndo
," "));
1915 ND_PRINT((ndo
,"use(")); /*)*/
1916 if (use
->rpu_flags
) {
1917 #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
1918 ND_PRINT((ndo
,"%s%s,",
1919 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
1920 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P")));
1923 if (ndo
->ndo_vflag
) {
1924 ND_PRINT((ndo
,"mask=0x%x,", use
->rpu_ramask
));
1925 ND_PRINT((ndo
,"raflags=0x%x,", use
->rpu_raflags
));
1926 if (~use
->rpu_vltime
== 0)
1927 ND_PRINT((ndo
,"vltime=infty,"));
1929 ND_PRINT((ndo
,"vltime=%u,",
1930 EXTRACT_32BITS(&use
->rpu_vltime
)));
1931 if (~use
->rpu_pltime
== 0)
1932 ND_PRINT((ndo
,"pltime=infty,"));
1934 ND_PRINT((ndo
,"pltime=%u,",
1935 EXTRACT_32BITS(&use
->rpu_pltime
)));
1937 if (addrtostr6(&use
->rpu_prefix
, hbuf
, sizeof(hbuf
)))
1938 ND_PRINT((ndo
,"%s/%u/%u", hbuf
, use
->rpu_uselen
,
1941 ND_PRINT((ndo
,"?/%u/%u", use
->rpu_uselen
,
1944 ND_PRINT((ndo
,")"));
1951 ND_PRINT((ndo
,"[|icmp6]"));
1956 * c-style: whitesmith