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.
28 #include <tcpdump-stdinc.h>
33 #include "netdissect.h"
34 #include "interface.h"
35 #include "addrtoname.h"
44 /* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
45 /* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
48 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
49 * All rights reserved.
51 * Redistribution and use in source and binary forms, with or without
52 * modification, are permitted provided that the following conditions
54 * 1. Redistributions of source code must retain the above copyright
55 * notice, this list of conditions and the following disclaimer.
56 * 2. Redistributions in binary form must reproduce the above copyright
57 * notice, this list of conditions and the following disclaimer in the
58 * documentation and/or other materials provided with the distribution.
59 * 3. Neither the name of the project nor the names of its contributors
60 * may be used to endorse or promote products derived from this software
61 * without specific prior written permission.
63 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
64 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
65 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
66 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
67 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
69 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
70 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
71 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
72 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
77 u_int8_t icmp6_type
; /* type field */
78 u_int8_t icmp6_code
; /* code field */
79 u_int16_t icmp6_cksum
; /* checksum field */
81 u_int32_t icmp6_un_data32
[1]; /* type-specific field */
82 u_int16_t icmp6_un_data16
[2]; /* type-specific field */
83 u_int8_t icmp6_un_data8
[4]; /* type-specific field */
87 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
88 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
89 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
90 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
91 #define icmp6_mtu icmp6_data32[0] /* packet too big */
92 #define icmp6_id icmp6_data16[0] /* echo request/reply */
93 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
94 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
96 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
97 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
98 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
99 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
101 #define ICMP6_ECHO_REQUEST 128 /* echo service */
102 #define ICMP6_ECHO_REPLY 129 /* echo reply */
103 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
104 #define MLD6_LISTENER_QUERY 130 /* multicast listener query */
105 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
106 #define MLD6_LISTENER_REPORT 131 /* multicast listener report */
107 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
108 #define MLD6_LISTENER_DONE 132 /* multicast listener done */
110 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
111 #define ND_ROUTER_ADVERT 134 /* router advertisement */
112 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
113 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
114 #define ND_REDIRECT 137 /* redirect */
116 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
118 #define ICMP6_WRUREQUEST 139 /* who are you request */
119 #define ICMP6_WRUREPLY 140 /* who are you reply */
120 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
121 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
122 #define ICMP6_NI_QUERY 139 /* node information request */
123 #define ICMP6_NI_REPLY 140 /* node information reply */
124 #define IND_SOLICIT 141 /* inverse neighbor solicitation */
125 #define IND_ADVERT 142 /* inverse neighbor advertisement */
127 #define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */
128 #define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */
129 #define ICMP6_HADISCOV_REQUEST 144
130 #define ICMP6_HADISCOV_REPLY 145
131 #define ICMP6_MOBILEPREFIX_SOLICIT 146
132 #define ICMP6_MOBILEPREFIX_ADVERT 147
134 #define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
135 #define MLD6_MTRACE 201 /* mtrace messages */
137 #define ICMP6_MAXTYPE 201
139 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
140 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
141 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
142 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
143 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
144 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
146 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
147 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
149 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
150 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
151 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
153 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
155 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
156 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
157 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
159 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
160 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
161 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
163 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
164 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
165 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
167 /* Used in kernel only */
168 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
169 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
172 * Multicast Listener Discovery
175 struct icmp6_hdr mld6_hdr
;
176 struct in6_addr mld6_addr
; /* multicast address */
179 #define mld6_type mld6_hdr.icmp6_type
180 #define mld6_code mld6_hdr.icmp6_code
181 #define mld6_cksum mld6_hdr.icmp6_cksum
182 #define mld6_maxdelay mld6_hdr.icmp6_data16[0]
183 #define mld6_reserved mld6_hdr.icmp6_data16[1]
185 #define MLD_MINLEN 24
186 #define MLDV2_MINLEN 28
192 struct nd_router_solicit
{ /* router solicitation */
193 struct icmp6_hdr nd_rs_hdr
;
194 /* could be followed by options */
197 #define nd_rs_type nd_rs_hdr.icmp6_type
198 #define nd_rs_code nd_rs_hdr.icmp6_code
199 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
200 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
202 struct nd_router_advert
{ /* router advertisement */
203 struct icmp6_hdr nd_ra_hdr
;
204 u_int32_t nd_ra_reachable
; /* reachable time */
205 u_int32_t nd_ra_retransmit
; /* retransmit timer */
206 /* could be followed by options */
209 #define nd_ra_type nd_ra_hdr.icmp6_type
210 #define nd_ra_code nd_ra_hdr.icmp6_code
211 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
212 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
213 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
214 #define ND_RA_FLAG_MANAGED 0x80
215 #define ND_RA_FLAG_OTHER 0x40
216 #define ND_RA_FLAG_HOME_AGENT 0x20
219 * Router preference values based on draft-draves-ipngwg-router-selection-01.
220 * These are non-standard definitions.
222 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
224 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
225 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
226 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
227 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
229 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
231 struct nd_neighbor_solicit
{ /* neighbor solicitation */
232 struct icmp6_hdr nd_ns_hdr
;
233 struct in6_addr nd_ns_target
; /*target address */
234 /* could be followed by options */
237 #define nd_ns_type nd_ns_hdr.icmp6_type
238 #define nd_ns_code nd_ns_hdr.icmp6_code
239 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
240 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
242 struct nd_neighbor_advert
{ /* neighbor advertisement */
243 struct icmp6_hdr nd_na_hdr
;
244 struct in6_addr nd_na_target
; /* target address */
245 /* could be followed by options */
248 #define nd_na_type nd_na_hdr.icmp6_type
249 #define nd_na_code nd_na_hdr.icmp6_code
250 #define nd_na_cksum nd_na_hdr.icmp6_cksum
251 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
253 #define ND_NA_FLAG_ROUTER 0x80000000
254 #define ND_NA_FLAG_SOLICITED 0x40000000
255 #define ND_NA_FLAG_OVERRIDE 0x20000000
257 struct nd_redirect
{ /* redirect */
258 struct icmp6_hdr nd_rd_hdr
;
259 struct in6_addr nd_rd_target
; /* target address */
260 struct in6_addr nd_rd_dst
; /* destination address */
261 /* could be followed by options */
264 #define nd_rd_type nd_rd_hdr.icmp6_type
265 #define nd_rd_code nd_rd_hdr.icmp6_code
266 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
267 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
269 struct nd_opt_hdr
{ /* Neighbor discovery option header */
270 u_int8_t nd_opt_type
;
272 /* followed by option specific data*/
275 #define ND_OPT_SOURCE_LINKADDR 1
276 #define ND_OPT_TARGET_LINKADDR 2
277 #define ND_OPT_PREFIX_INFORMATION 3
278 #define ND_OPT_REDIRECTED_HEADER 4
280 #define ND_OPT_ADVINTERVAL 7
281 #define ND_OPT_HOMEAGENT_INFO 8
282 #define ND_OPT_ROUTE_INFO 24 /* RFC4191 */
283 #define ND_OPT_RDNSS 25
284 #define ND_OPT_DNSSL 31
286 struct nd_opt_prefix_info
{ /* prefix information */
287 u_int8_t nd_opt_pi_type
;
288 u_int8_t nd_opt_pi_len
;
289 u_int8_t nd_opt_pi_prefix_len
;
290 u_int8_t nd_opt_pi_flags_reserved
;
291 u_int8_t nd_opt_pi_valid_time
[4];
292 u_int8_t nd_opt_pi_preferred_time
[4];
293 u_int8_t nd_opt_pi_reserved2
[4];
294 struct in6_addr nd_opt_pi_prefix
;
297 #define ND_OPT_PI_FLAG_ONLINK 0x80
298 #define ND_OPT_PI_FLAG_AUTO 0x40
299 #define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
301 struct nd_opt_rd_hdr
{ /* redirected header */
302 u_int8_t nd_opt_rh_type
;
303 u_int8_t nd_opt_rh_len
;
304 u_int16_t nd_opt_rh_reserved1
;
305 u_int32_t nd_opt_rh_reserved2
;
306 /* followed by IP header and data */
309 struct nd_opt_mtu
{ /* MTU option */
310 u_int8_t nd_opt_mtu_type
;
311 u_int8_t nd_opt_mtu_len
;
312 u_int16_t nd_opt_mtu_reserved
;
313 u_int32_t nd_opt_mtu_mtu
;
316 struct nd_opt_rdnss
{ /* RDNSS RFC 6106 5.1 */
317 u_int8_t nd_opt_rdnss_type
;
318 u_int8_t nd_opt_rdnss_len
;
319 u_int16_t nd_opt_rdnss_reserved
;
320 u_int32_t nd_opt_rdnss_lifetime
;
321 struct in6_addr nd_opt_rdnss_addr
[1]; /* variable-length */
324 struct nd_opt_dnssl
{ /* DNSSL RFC 6106 5.2 */
325 u_int8_t nd_opt_dnssl_type
;
326 u_int8_t nd_opt_dnssl_len
;
327 u_int16_t nd_opt_dnssl_reserved
;
328 u_int32_t nd_opt_dnssl_lifetime
;
329 /* followed by list of DNS search domains, variable-length */
332 struct nd_opt_advinterval
{ /* Advertisement interval option */
333 u_int8_t nd_opt_adv_type
;
334 u_int8_t nd_opt_adv_len
;
335 u_int16_t nd_opt_adv_reserved
;
336 u_int32_t nd_opt_adv_interval
;
339 struct nd_opt_homeagent_info
{ /* Home Agent info */
340 u_int8_t nd_opt_hai_type
;
341 u_int8_t nd_opt_hai_len
;
342 u_int16_t nd_opt_hai_reserved
;
343 int16_t nd_opt_hai_preference
;
344 u_int16_t nd_opt_hai_lifetime
;
347 struct nd_opt_route_info
{ /* route info */
348 u_int8_t nd_opt_rti_type
;
349 u_int8_t nd_opt_rti_len
;
350 u_int8_t nd_opt_rti_prefixlen
;
351 u_int8_t nd_opt_rti_flags
;
352 u_int32_t nd_opt_rti_lifetime
;
360 struct icmp6_namelookup
{
361 struct icmp6_hdr icmp6_nl_hdr
;
362 u_int8_t icmp6_nl_nonce
[8];
363 int32_t icmp6_nl_ttl
;
365 u_int8_t icmp6_nl_len
;
366 u_int8_t icmp6_nl_name
[3];
368 /* could be followed by options */
372 * icmp6 node information
374 struct icmp6_nodeinfo
{
375 struct icmp6_hdr icmp6_ni_hdr
;
376 u_int8_t icmp6_ni_nonce
[8];
377 /* could be followed by reply data */
380 #define ni_type icmp6_ni_hdr.icmp6_type
381 #define ni_code icmp6_ni_hdr.icmp6_code
382 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
383 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
384 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
386 #define NI_QTYPE_NOOP 0 /* NOOP */
387 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
388 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
389 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
390 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
391 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
394 #define NI_SUPTYPE_FLAG_COMPRESS ((u_int16_t)htons(0x1))
395 #define NI_FQDN_FLAG_VALIDTTL ((u_int16_t)htons(0x1))
398 #define NI_NODEADDR_FLAG_TRUNCATE ((u_int16_t)htons(0x1))
399 #define NI_NODEADDR_FLAG_ALL ((u_int16_t)htons(0x2))
400 #define NI_NODEADDR_FLAG_COMPAT ((u_int16_t)htons(0x4))
401 #define NI_NODEADDR_FLAG_LINKLOCAL ((u_int16_t)htons(0x8))
402 #define NI_NODEADDR_FLAG_SITELOCAL ((u_int16_t)htons(0x10))
403 #define NI_NODEADDR_FLAG_GLOBAL ((u_int16_t)htons(0x20))
404 #define NI_NODEADDR_FLAG_ANYCAST ((u_int16_t)htons(0x40)) /* just experimental. not in spec */
406 struct ni_reply_fqdn
{
407 u_int32_t ni_fqdn_ttl
; /* TTL */
408 u_int8_t ni_fqdn_namelen
; /* length in octets of the FQDN */
409 u_int8_t ni_fqdn_name
[3]; /* XXX: alignment */
413 * Router Renumbering. as router-renum-08.txt
415 struct icmp6_router_renum
{ /* router renumbering header */
416 struct icmp6_hdr rr_hdr
;
419 u_int16_t rr_maxdelay
;
420 u_int32_t rr_reserved
;
422 #define ICMP6_RR_FLAGS_TEST 0x80
423 #define ICMP6_RR_FLAGS_REQRESULT 0x40
424 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
425 #define ICMP6_RR_FLAGS_SPECSITE 0x10
426 #define ICMP6_RR_FLAGS_PREVDONE 0x08
428 #define rr_type rr_hdr.icmp6_type
429 #define rr_code rr_hdr.icmp6_code
430 #define rr_cksum rr_hdr.icmp6_cksum
431 #define rr_seqnum rr_hdr.icmp6_data32[0]
433 struct rr_pco_match
{ /* match prefix part */
436 u_int8_t rpm_ordinal
;
437 u_int8_t rpm_matchlen
;
440 u_int16_t rpm_reserved
;
441 struct in6_addr rpm_prefix
;
444 #define RPM_PCO_ADD 1
445 #define RPM_PCO_CHANGE 2
446 #define RPM_PCO_SETGLOBAL 3
447 #define RPM_PCO_MAX 4
449 struct rr_pco_use
{ /* use prefix part */
451 u_int8_t rpu_keeplen
;
453 u_int8_t rpu_raflags
;
454 u_int32_t rpu_vltime
;
455 u_int32_t rpu_pltime
;
457 struct in6_addr rpu_prefix
;
459 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
460 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
463 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((u_int32_t)htonl(0x80000000))
464 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((u_int32_t)htonl(0x40000000))
466 struct rr_result
{ /* router renumbering result message */
468 u_int8_t rrr_ordinal
;
469 u_int8_t rrr_matchedlen
;
471 struct in6_addr rrr_prefix
;
474 #define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002))
475 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001))
477 static const char *get_rtpref(u_int
);
478 static const char *get_lifetime(u_int32_t
);
479 static void print_lladdr(netdissect_options
*ndo
, const u_char
*, size_t);
480 static void icmp6_opt_print(netdissect_options
*ndo
, const u_char
*, int);
481 static void mld6_print(netdissect_options
*ndo
, const u_char
*);
482 static void mldv2_report_print(netdissect_options
*ndo
, const u_char
*, u_int
);
483 static void mldv2_query_print(netdissect_options
*ndo
, const u_char
*, u_int
);
484 static const struct udphdr
*get_upperlayer(netdissect_options
*ndo
, const u_char
*, u_int
*);
485 static void dnsname_print(netdissect_options
*ndo
, const u_char
*, const u_char
*);
486 static void icmp6_nodeinfo_print(netdissect_options
*ndo
, u_int
, const u_char
*, const u_char
*);
487 static void icmp6_rrenum_print(netdissect_options
*ndo
, const u_char
*, const u_char
*);
490 #define abs(a) ((0 < (a)) ? (a) : -(a))
495 static const struct tok icmp6_type_values
[] = {
496 { ICMP6_DST_UNREACH
, "destination unreachable"},
497 { ICMP6_PACKET_TOO_BIG
, "packet too big"},
498 { ICMP6_TIME_EXCEEDED
, "time exceeded in-transit"},
499 { ICMP6_PARAM_PROB
, "parameter problem"},
500 { ICMP6_ECHO_REQUEST
, "echo request"},
501 { ICMP6_ECHO_REPLY
, "echo reply"},
502 { MLD6_LISTENER_QUERY
, "multicast listener query"},
503 { MLD6_LISTENER_REPORT
, "multicast listener report"},
504 { MLD6_LISTENER_DONE
, "multicast listener done"},
505 { ND_ROUTER_SOLICIT
, "router solicitation"},
506 { ND_ROUTER_ADVERT
, "router advertisement"},
507 { ND_NEIGHBOR_SOLICIT
, "neighbor solicitation"},
508 { ND_NEIGHBOR_ADVERT
, "neighbor advertisement"},
509 { ND_REDIRECT
, "redirect"},
510 { ICMP6_ROUTER_RENUMBERING
, "router renumbering"},
511 { IND_SOLICIT
, "inverse neighbor solicitation"},
512 { IND_ADVERT
, "inverse neighbor advertisement"},
513 { MLDV2_LISTENER_REPORT
, "multicast listener report v2"},
514 { ICMP6_HADISCOV_REQUEST
, "ha discovery request"},
515 { ICMP6_HADISCOV_REPLY
, "ha discovery reply"},
516 { ICMP6_MOBILEPREFIX_SOLICIT
, "mobile router solicitation"},
517 { ICMP6_MOBILEPREFIX_ADVERT
, "mobile router advertisement"},
518 { ICMP6_WRUREQUEST
, "who-are-you request"},
519 { ICMP6_WRUREPLY
, "who-are-you reply"},
520 { ICMP6_NI_QUERY
, "node information query"},
521 { ICMP6_NI_REPLY
, "node information reply"},
522 { MLD6_MTRACE
, "mtrace message"},
523 { MLD6_MTRACE_RESP
, "mtrace response"},
524 { ND_RPL_MESSAGE
, "RPL"},
528 static const struct tok icmp6_dst_unreach_code_values
[] = {
529 { ICMP6_DST_UNREACH_NOROUTE
, "unreachable route" },
530 { ICMP6_DST_UNREACH_ADMIN
, " unreachable prohibited"},
531 { ICMP6_DST_UNREACH_BEYONDSCOPE
, "beyond scope"},
532 { ICMP6_DST_UNREACH_ADDR
, "unreachable address"},
533 { ICMP6_DST_UNREACH_NOPORT
, "unreachable port"},
537 static const struct tok icmp6_opt_pi_flag_values
[] = {
538 { ND_OPT_PI_FLAG_ONLINK
, "onlink" },
539 { ND_OPT_PI_FLAG_AUTO
, "auto" },
540 { ND_OPT_PI_FLAG_ROUTER
, "router" },
544 static const struct tok icmp6_opt_ra_flag_values
[] = {
545 { ND_RA_FLAG_MANAGED
, "managed" },
546 { ND_RA_FLAG_OTHER
, "other stateful"},
547 { ND_RA_FLAG_HOME_AGENT
, "home agent"},
551 static const struct tok icmp6_nd_na_flag_values
[] = {
552 { ND_NA_FLAG_ROUTER
, "router" },
553 { ND_NA_FLAG_SOLICITED
, "solicited" },
554 { ND_NA_FLAG_OVERRIDE
, "override" },
559 static const struct tok icmp6_opt_values
[] = {
560 { ND_OPT_SOURCE_LINKADDR
, "source link-address"},
561 { ND_OPT_TARGET_LINKADDR
, "destination link-address"},
562 { ND_OPT_PREFIX_INFORMATION
, "prefix info"},
563 { ND_OPT_REDIRECTED_HEADER
, "redirected header"},
564 { ND_OPT_MTU
, "mtu"},
565 { ND_OPT_RDNSS
, "rdnss"},
566 { ND_OPT_DNSSL
, "dnssl"},
567 { ND_OPT_ADVINTERVAL
, "advertisement interval"},
568 { ND_OPT_HOMEAGENT_INFO
, "homeagent information"},
569 { ND_OPT_ROUTE_INFO
, "route info"},
573 /* mldv2 report types */
574 static const struct tok mldv2report2str
[] = {
587 static const char *rtpref_str
[] = {
594 return rtpref_str
[((v
& ND_RA_FLAG_RTPREF_MASK
) >> 3) & 0xff];
598 get_lifetime(u_int32_t v
)
602 if (v
== (u_int32_t
)~0UL)
605 snprintf(buf
, sizeof(buf
), "%us", v
);
611 print_lladdr(netdissect_options
*ndo
, const u_int8_t
*p
, size_t l
)
613 const u_int8_t
*ep
, *q
;
617 while (l
> 0 && q
< ep
) {
620 ND_PRINT((ndo
,"%02x", *q
++));
625 static int icmp6_cksum(const struct ip6_hdr
*ip6
, const struct icmp6_hdr
*icp
,
628 return nextproto6_cksum(ip6
, (const u_int8_t
*)(void *)icp
, len
, len
,
632 const struct tok rpl_mop_values
[] = {
633 { RPL_DIO_NONSTORING
, "nonstoring"},
634 { RPL_DIO_STORING
, "storing"},
635 { RPL_DIO_NONSTORING_MULTICAST
, "nonstoring-multicast"},
636 { RPL_DIO_STORING_MULTICAST
, "storing-multicast"},
640 const struct tok rpl_subopt_values
[] = {
641 { RPL_OPT_PAD0
, "pad0"},
642 { RPL_OPT_PADN
, "padN"},
643 { RPL_DIO_METRICS
, "metrics"},
644 { RPL_DIO_ROUTINGINFO
, "routinginfo"},
645 { RPL_DIO_CONFIG
, "config"},
646 { RPL_DAO_RPLTARGET
, "rpltarget"},
647 { RPL_DAO_TRANSITINFO
, "transitinfo"},
648 { RPL_DIO_DESTPREFIX
, "destprefix"},
649 { RPL_DAO_RPLTARGET_DESC
, "rpltargetdesc"},
654 rpl_format_dagid(char dagid_str
[65], const u_char
*dagid
)
660 if(isprint(dagid
[i
])) {
663 snprintf(d
,4,"0x%02x", dagid
[i
]);
671 rpl_dio_printopt(netdissect_options
*ndo
,
672 const struct rpl_dio_genoption
*opt
,
675 if(length
< RPL_DIO_GENOPTION_LEN
) return;
676 length
-= RPL_DIO_GENOPTION_LEN
;
678 ND_TCHECK(opt
->rpl_dio_len
);
680 while((opt
->rpl_dio_type
== RPL_OPT_PAD0
&&
681 (u_char
*)opt
< ndo
->ndo_snapend
) ||
682 ND_TTEST2(*opt
,(opt
->rpl_dio_len
+2))) {
684 unsigned int optlen
= opt
->rpl_dio_len
+2;
685 if(opt
->rpl_dio_type
== RPL_OPT_PAD0
) {
687 ND_PRINT((ndo
, " opt:pad0"));
689 ND_PRINT((ndo
, " opt:%s len:%u ",
690 tok2str(rpl_subopt_values
, "%subopt:%u", opt
->rpl_dio_type
),
692 if(ndo
->ndo_vflag
> 2) {
693 unsigned int paylen
= opt
->rpl_dio_len
;
694 if(paylen
> length
) paylen
= length
;
697 ((u_int8_t
*)opt
) + RPL_DIO_GENOPTION_LEN
, /* content of DIO option */
701 opt
= (struct rpl_dio_genoption
*)(((char *)opt
) + optlen
);
706 ND_PRINT((ndo
," [|truncated]"));
711 rpl_dio_print(netdissect_options
*ndo
,
712 const u_char
*bp
, u_int length
)
714 const struct nd_rpl_dio
*dio
= (struct nd_rpl_dio
*)bp
;
718 rpl_format_dagid(dagid_str
, dio
->rpl_dagid
);
720 ND_PRINT((ndo
, " [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
724 EXTRACT_16BITS(&dio
->rpl_dagrank
),
725 RPL_DIO_GROUNDED(dio
->rpl_mopprf
) ? "grounded,":"",
726 tok2str(rpl_mop_values
, "mop%u", RPL_DIO_MOP(dio
->rpl_mopprf
)),
727 RPL_DIO_PRF(dio
->rpl_mopprf
)));
729 if(ndo
->ndo_vflag
> 1) {
730 struct rpl_dio_genoption
*opt
= (struct rpl_dio_genoption
*)&dio
[1];
731 rpl_dio_printopt(ndo
, opt
, length
);
735 ND_PRINT((ndo
," [|truncated]"));
740 rpl_dao_print(netdissect_options
*ndo
,
741 const u_char
*bp
, u_int length
)
743 const struct nd_rpl_dao
*dao
= (struct nd_rpl_dao
*)bp
;
747 if (length
< ND_RPL_DAO_MIN_LEN
)
750 strcpy(dagid_str
,"<elided>");
751 bp
+= ND_RPL_DAO_MIN_LEN
;
752 length
-= ND_RPL_DAO_MIN_LEN
;
753 if(RPL_DAO_D(dao
->rpl_flags
)) {
754 ND_TCHECK2(dao
->rpl_dagid
, DAGID_LEN
);
755 if (length
< DAGID_LEN
)
757 rpl_format_dagid(dagid_str
, dao
->rpl_dagid
);
762 ND_PRINT((ndo
, " [dagid:%s,seq:%u,instance:%u]",
765 dao
->rpl_instanceid
));
767 if(ndo
->ndo_vflag
> 1) {
768 const struct rpl_dio_genoption
*opt
= (struct rpl_dio_genoption
*)bp
;
769 rpl_dio_printopt(ndo
, opt
, length
);
774 ND_PRINT((ndo
," [|truncated]"));
778 ND_PRINT((ndo
," [|length too short]"));
783 rpl_daoack_print(netdissect_options
*ndo
,
784 const u_char
*bp
, u_int length
)
786 const struct nd_rpl_daoack
*daoack
= (struct nd_rpl_daoack
*)bp
;
789 ND_TCHECK2(*daoack
, ND_RPL_DAOACK_MIN_LEN
);
790 if (length
< ND_RPL_DAOACK_MIN_LEN
)
793 strcpy(dagid_str
,"<elided>");
794 bp
+= ND_RPL_DAOACK_MIN_LEN
;
795 length
-= ND_RPL_DAOACK_MIN_LEN
;
796 if(RPL_DAOACK_D(daoack
->rpl_flags
)) {
797 ND_TCHECK2(daoack
->rpl_dagid
, 16);
798 if (length
< DAGID_LEN
)
800 rpl_format_dagid(dagid_str
, daoack
->rpl_dagid
);
805 ND_PRINT((ndo
, " [dagid:%s,seq:%u,instance:%u,status:%u]",
808 daoack
->rpl_instanceid
,
809 daoack
->rpl_status
));
811 /* no officially defined options for DAOACK, but print any we find */
812 if(ndo
->ndo_vflag
> 1) {
813 const struct rpl_dio_genoption
*opt
= (struct rpl_dio_genoption
*)bp
;
814 rpl_dio_printopt(ndo
, opt
, length
);
819 ND_PRINT((ndo
," [|dao-truncated]"));
823 ND_PRINT((ndo
," [|dao-length too short]"));
828 rpl_print(netdissect_options
*ndo
,
829 const struct icmp6_hdr
*hdr
,
830 const u_char
*bp
, u_int length
)
832 int secured
= hdr
->icmp6_code
& 0x80;
833 int basecode
= hdr
->icmp6_code
& 0x7f;
836 ND_PRINT((ndo
, ", (SEC) [worktodo]"));
838 * the next header pointer needs to move forward to
839 * skip the secure part.
843 ND_PRINT((ndo
, ", (CLR)"));
848 ND_PRINT((ndo
, "DODAG Information Solicitation"));
853 ND_PRINT((ndo
, "DODAG Information Object"));
855 rpl_dio_print(ndo
, bp
, length
);
859 ND_PRINT((ndo
, "Destination Advertisement Object"));
861 rpl_dao_print(ndo
, bp
, length
);
865 ND_PRINT((ndo
, "Destination Advertisement Object Ack"));
867 rpl_daoack_print(ndo
, bp
, length
);
871 ND_PRINT((ndo
, "RPL message, unknown code %u",hdr
->icmp6_code
));
878 ND_PRINT((ndo
," [|truncated]"));
886 icmp6_print(netdissect_options
*ndo
,
887 const u_char
*bp
, u_int length
, const u_char
*bp2
, int fragmented
)
889 const struct icmp6_hdr
*dp
;
890 const struct ip6_hdr
*ip
;
891 const struct ip6_hdr
*oip
;
892 const struct udphdr
*ouh
;
897 dp
= (struct icmp6_hdr
*)bp
;
898 ip
= (struct ip6_hdr
*)bp2
;
899 oip
= (struct ip6_hdr
*)(dp
+ 1);
900 /* 'ep' points to the end of available data. */
901 ep
= ndo
->ndo_snapend
;
903 ND_TCHECK(dp
->icmp6_cksum
);
905 if (ndo
->ndo_vflag
&& !fragmented
) {
906 u_int16_t sum
, udp_sum
;
908 if (ND_TTEST2(bp
[0], length
)) {
909 udp_sum
= EXTRACT_16BITS(&dp
->icmp6_cksum
);
910 sum
= icmp6_cksum(ip
, dp
, length
);
912 (void)ND_PRINT((ndo
,"[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
914 in_cksum_shouldbe(udp_sum
, sum
)));
916 (void)ND_PRINT((ndo
,"[icmp6 sum ok] "));
920 ND_PRINT((ndo
,"ICMP6, %s", tok2str(icmp6_type_values
,"unknown icmp6 type (%u)",dp
->icmp6_type
)));
922 /* display cosmetics: print the packet length for printer that use the vflag now */
923 if (ndo
->ndo_vflag
&& (dp
->icmp6_type
== ND_ROUTER_SOLICIT
||
924 dp
->icmp6_type
== ND_ROUTER_ADVERT
||
925 dp
->icmp6_type
== ND_NEIGHBOR_ADVERT
||
926 dp
->icmp6_type
== ND_NEIGHBOR_SOLICIT
||
927 dp
->icmp6_type
== ND_REDIRECT
||
928 dp
->icmp6_type
== ICMP6_HADISCOV_REPLY
||
929 dp
->icmp6_type
== ICMP6_MOBILEPREFIX_ADVERT
))
930 ND_PRINT((ndo
,", length %u", length
));
932 switch (dp
->icmp6_type
) {
933 case ICMP6_DST_UNREACH
:
934 ND_TCHECK(oip
->ip6_dst
);
935 ND_PRINT((ndo
,", %s", tok2str(icmp6_dst_unreach_code_values
,"unknown unreach code (%u)",dp
->icmp6_code
)));
936 switch (dp
->icmp6_code
) {
938 case ICMP6_DST_UNREACH_NOROUTE
: /* fall through */
939 case ICMP6_DST_UNREACH_ADMIN
:
940 case ICMP6_DST_UNREACH_ADDR
:
941 ND_PRINT((ndo
," %s",ip6addr_string(&oip
->ip6_dst
)));
943 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
944 ND_PRINT((ndo
," %s, source address %s",
945 ip6addr_string(&oip
->ip6_dst
),
946 ip6addr_string(&oip
->ip6_src
)));
948 case ICMP6_DST_UNREACH_NOPORT
:
949 if ((ouh
= get_upperlayer(ndo
, (u_char
*)oip
, &prot
))
953 dport
= EXTRACT_16BITS(&ouh
->uh_dport
);
956 ND_PRINT((ndo
,", %s tcp port %s",
957 ip6addr_string(&oip
->ip6_dst
),
958 tcpport_string(dport
)));
961 ND_PRINT((ndo
,", %s udp port %s",
962 ip6addr_string(&oip
->ip6_dst
),
963 udpport_string(dport
)));
966 ND_PRINT((ndo
,", %s protocol %d port %d unreachable",
967 ip6addr_string(&oip
->ip6_dst
),
968 oip
->ip6_nxt
, dport
));
973 if (ndo
->ndo_vflag
<= 1) {
974 print_unknown_data(ndo
, bp
,"\n\t",length
);
980 case ICMP6_PACKET_TOO_BIG
:
981 ND_TCHECK(dp
->icmp6_mtu
);
982 ND_PRINT((ndo
,", mtu %u", EXTRACT_32BITS(&dp
->icmp6_mtu
)));
984 case ICMP6_TIME_EXCEEDED
:
985 ND_TCHECK(oip
->ip6_dst
);
986 switch (dp
->icmp6_code
) {
987 case ICMP6_TIME_EXCEED_TRANSIT
:
988 ND_PRINT((ndo
," for %s",
989 ip6addr_string(&oip
->ip6_dst
)));
991 case ICMP6_TIME_EXCEED_REASSEMBLY
:
992 ND_PRINT((ndo
," (reassembly)"));
995 ND_PRINT((ndo
,", unknown code (%u)", dp
->icmp6_code
));
999 case ICMP6_PARAM_PROB
:
1000 ND_TCHECK(oip
->ip6_dst
);
1001 switch (dp
->icmp6_code
) {
1002 case ICMP6_PARAMPROB_HEADER
:
1003 ND_PRINT((ndo
,", erroneous - octet %u", EXTRACT_32BITS(&dp
->icmp6_pptr
)));
1005 case ICMP6_PARAMPROB_NEXTHEADER
:
1006 ND_PRINT((ndo
,", next header - octet %u", EXTRACT_32BITS(&dp
->icmp6_pptr
)));
1008 case ICMP6_PARAMPROB_OPTION
:
1009 ND_PRINT((ndo
,", option - octet %u", EXTRACT_32BITS(&dp
->icmp6_pptr
)));
1012 ND_PRINT((ndo
,", code-#%d",
1017 case ICMP6_ECHO_REQUEST
:
1018 case ICMP6_ECHO_REPLY
:
1019 ND_TCHECK(dp
->icmp6_seq
);
1020 ND_PRINT((ndo
,", seq %u", EXTRACT_16BITS(&dp
->icmp6_seq
)));
1022 case ICMP6_MEMBERSHIP_QUERY
:
1023 if (length
== MLD_MINLEN
) {
1024 mld6_print(ndo
, (const u_char
*)dp
);
1025 } else if (length
>= MLDV2_MINLEN
) {
1026 ND_PRINT((ndo
," v2"));
1027 mldv2_query_print(ndo
, (const u_char
*)dp
, length
);
1029 ND_PRINT((ndo
," unknown-version (len %u) ", length
));
1032 case ICMP6_MEMBERSHIP_REPORT
:
1033 mld6_print(ndo
, (const u_char
*)dp
);
1035 case ICMP6_MEMBERSHIP_REDUCTION
:
1036 mld6_print(ndo
, (const u_char
*)dp
);
1038 case ND_ROUTER_SOLICIT
:
1040 if (ndo
->ndo_vflag
) {
1041 icmp6_opt_print(ndo
, (const u_char
*)dp
+ RTSOLLEN
,
1045 case ND_ROUTER_ADVERT
:
1047 if (ndo
->ndo_vflag
) {
1048 struct nd_router_advert
*p
;
1050 p
= (struct nd_router_advert
*)dp
;
1051 ND_TCHECK(p
->nd_ra_retransmit
);
1052 ND_PRINT((ndo
,"\n\thop limit %u, Flags [%s]" \
1053 ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
1054 (u_int
)p
->nd_ra_curhoplimit
,
1055 bittok2str(icmp6_opt_ra_flag_values
,"none",(p
->nd_ra_flags_reserved
)),
1056 get_rtpref(p
->nd_ra_flags_reserved
),
1057 EXTRACT_16BITS(&p
->nd_ra_router_lifetime
),
1058 EXTRACT_32BITS(&p
->nd_ra_reachable
),
1059 EXTRACT_32BITS(&p
->nd_ra_retransmit
)));
1061 icmp6_opt_print(ndo
, (const u_char
*)dp
+ RTADVLEN
,
1065 case ND_NEIGHBOR_SOLICIT
:
1067 struct nd_neighbor_solicit
*p
;
1068 p
= (struct nd_neighbor_solicit
*)dp
;
1069 ND_TCHECK(p
->nd_ns_target
);
1070 ND_PRINT((ndo
,", who has %s", ip6addr_string(&p
->nd_ns_target
)));
1071 if (ndo
->ndo_vflag
) {
1073 icmp6_opt_print(ndo
, (const u_char
*)dp
+ NDSOLLEN
,
1078 case ND_NEIGHBOR_ADVERT
:
1080 struct nd_neighbor_advert
*p
;
1082 p
= (struct nd_neighbor_advert
*)dp
;
1083 ND_TCHECK(p
->nd_na_target
);
1084 ND_PRINT((ndo
,", tgt is %s",
1085 ip6addr_string(&p
->nd_na_target
)));
1086 if (ndo
->ndo_vflag
) {
1087 ND_PRINT((ndo
,", Flags [%s]",
1088 bittok2str(icmp6_nd_na_flag_values
,
1090 EXTRACT_32BITS(&p
->nd_na_flags_reserved
))));
1092 icmp6_opt_print(ndo
, (const u_char
*)dp
+ NDADVLEN
,
1099 #define RDR(i) ((struct nd_redirect *)(i))
1100 ND_TCHECK(RDR(dp
)->nd_rd_dst
);
1101 ND_PRINT((ndo
,", %s", getname6((const u_char
*)&RDR(dp
)->nd_rd_dst
)));
1102 ND_TCHECK(RDR(dp
)->nd_rd_target
);
1103 ND_PRINT((ndo
," to %s",
1104 getname6((const u_char
*)&RDR(dp
)->nd_rd_target
)));
1105 #define REDIRECTLEN 40
1106 if (ndo
->ndo_vflag
) {
1107 icmp6_opt_print(ndo
, (const u_char
*)dp
+ REDIRECTLEN
,
1108 length
- REDIRECTLEN
);
1113 case ICMP6_ROUTER_RENUMBERING
:
1114 icmp6_rrenum_print(ndo
, bp
, ep
);
1116 case ICMP6_NI_QUERY
:
1117 case ICMP6_NI_REPLY
:
1118 icmp6_nodeinfo_print(ndo
, length
, bp
, ep
);
1123 case ICMP6_V2_MEMBERSHIP_REPORT
:
1124 mldv2_report_print(ndo
, (const u_char
*) dp
, length
);
1126 case ICMP6_MOBILEPREFIX_SOLICIT
: /* fall through */
1127 case ICMP6_HADISCOV_REQUEST
:
1128 ND_TCHECK(dp
->icmp6_data16
[0]);
1129 ND_PRINT((ndo
,", id 0x%04x", EXTRACT_16BITS(&dp
->icmp6_data16
[0])));
1131 case ICMP6_HADISCOV_REPLY
:
1132 if (ndo
->ndo_vflag
) {
1133 struct in6_addr
*in6
;
1136 ND_TCHECK(dp
->icmp6_data16
[0]);
1137 ND_PRINT((ndo
,", id 0x%04x", EXTRACT_16BITS(&dp
->icmp6_data16
[0])));
1138 cp
= (u_char
*)dp
+ length
;
1139 in6
= (struct in6_addr
*)(dp
+ 1);
1140 for (; (u_char
*)in6
< cp
; in6
++) {
1142 ND_PRINT((ndo
,", %s", ip6addr_string(in6
)));
1146 case ICMP6_MOBILEPREFIX_ADVERT
:
1147 if (ndo
->ndo_vflag
) {
1148 ND_TCHECK(dp
->icmp6_data16
[0]);
1149 ND_PRINT((ndo
,", id 0x%04x", EXTRACT_16BITS(&dp
->icmp6_data16
[0])));
1150 if (dp
->icmp6_data16
[1] & 0xc0)
1151 ND_PRINT((ndo
," "));
1152 if (dp
->icmp6_data16
[1] & 0x80)
1153 ND_PRINT((ndo
,"M"));
1154 if (dp
->icmp6_data16
[1] & 0x40)
1155 ND_PRINT((ndo
,"O"));
1157 icmp6_opt_print(ndo
, (const u_char
*)dp
+ MPADVLEN
,
1161 case ND_RPL_MESSAGE
:
1162 /* plus 4, because struct icmp6_hdr contains 4 bytes of icmp payload */
1163 rpl_print(ndo
, dp
, &dp
->icmp6_data8
[0], length
-sizeof(struct icmp6_hdr
)+4);
1166 ND_PRINT((ndo
,", length %u", length
));
1167 if (ndo
->ndo_vflag
<= 1)
1168 print_unknown_data(ndo
, bp
,"\n\t", length
);
1171 if (!ndo
->ndo_vflag
)
1172 ND_PRINT((ndo
,", length %u", length
));
1175 ND_PRINT((ndo
, "[|icmp6]"));
1178 static const struct udphdr
*
1179 get_upperlayer(netdissect_options
*ndo
, const u_char
*bp
, u_int
*prot
)
1182 const struct ip6_hdr
*ip6
= (struct ip6_hdr
*)bp
;
1183 const struct udphdr
*uh
;
1184 const struct ip6_hbh
*hbh
;
1185 const struct ip6_frag
*fragh
;
1186 const struct ah
*ah
;
1190 /* 'ep' points to the end of available data. */
1191 ep
= ndo
->ndo_snapend
;
1193 if (!ND_TTEST(ip6
->ip6_nxt
))
1197 hlen
= sizeof(struct ip6_hdr
);
1205 uh
= (struct udphdr
*)bp
;
1206 if (ND_TTEST(uh
->uh_dport
)) {
1214 case IPPROTO_HOPOPTS
:
1215 case IPPROTO_DSTOPTS
:
1216 case IPPROTO_ROUTING
:
1217 hbh
= (struct ip6_hbh
*)bp
;
1218 if (!ND_TTEST(hbh
->ip6h_len
))
1221 hlen
= (hbh
->ip6h_len
+ 1) << 3;
1224 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
1225 fragh
= (struct ip6_frag
*)bp
;
1226 if (!ND_TTEST(fragh
->ip6f_offlg
))
1228 /* fragments with non-zero offset are meaningless */
1229 if ((EXTRACT_16BITS(&fragh
->ip6f_offlg
) & IP6F_OFF_MASK
) != 0)
1231 nh
= fragh
->ip6f_nxt
;
1232 hlen
= sizeof(struct ip6_frag
);
1236 ah
= (struct ah
*)bp
;
1237 if (!ND_TTEST(ah
->ah_len
))
1240 hlen
= (ah
->ah_len
+ 2) << 2;
1243 default: /* unknown or undecodable header */
1244 *prot
= nh
; /* meaningless, but set here anyway */
1249 return(NULL
); /* should be notreached, though */
1253 icmp6_opt_print(netdissect_options
*ndo
, const u_char
*bp
, int resid
)
1255 const struct nd_opt_hdr
*op
;
1256 const struct nd_opt_prefix_info
*opp
;
1257 const struct nd_opt_mtu
*opm
;
1258 const struct nd_opt_rdnss
*oprd
;
1259 const struct nd_opt_dnssl
*opds
;
1260 const struct nd_opt_advinterval
*opa
;
1261 const struct nd_opt_homeagent_info
*oph
;
1262 const struct nd_opt_route_info
*opri
;
1263 const u_char
*cp
, *ep
, *domp
;
1264 struct in6_addr in6
, *in6p
;
1268 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
1271 /* 'ep' points to the end of available data. */
1272 ep
= ndo
->ndo_snapend
;
1275 op
= (struct nd_opt_hdr
*)cp
;
1277 ECHECK(op
->nd_opt_len
);
1280 if (op
->nd_opt_len
== 0)
1282 if (cp
+ (op
->nd_opt_len
<< 3) > ep
)
1285 ND_PRINT((ndo
,"\n\t %s option (%u), length %u (%u): ",
1286 tok2str(icmp6_opt_values
, "unknown", op
->nd_opt_type
),
1288 op
->nd_opt_len
<< 3,
1291 switch (op
->nd_opt_type
) {
1292 case ND_OPT_SOURCE_LINKADDR
:
1293 l
= (op
->nd_opt_len
<< 3) - 2;
1294 print_lladdr(ndo
, cp
+ 2, l
);
1296 case ND_OPT_TARGET_LINKADDR
:
1297 l
= (op
->nd_opt_len
<< 3) - 2;
1298 print_lladdr(ndo
, cp
+ 2, l
);
1300 case ND_OPT_PREFIX_INFORMATION
:
1301 opp
= (struct nd_opt_prefix_info
*)op
;
1302 ND_TCHECK(opp
->nd_opt_pi_prefix
);
1303 ND_PRINT((ndo
,"%s/%u%s, Flags [%s], valid time %s",
1304 ip6addr_string(&opp
->nd_opt_pi_prefix
),
1305 opp
->nd_opt_pi_prefix_len
,
1306 (op
->nd_opt_len
!= 4) ? "badlen" : "",
1307 bittok2str(icmp6_opt_pi_flag_values
, "none", opp
->nd_opt_pi_flags_reserved
),
1308 get_lifetime(EXTRACT_32BITS(&opp
->nd_opt_pi_valid_time
))));
1309 ND_PRINT((ndo
,", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp
->nd_opt_pi_preferred_time
))));
1311 case ND_OPT_REDIRECTED_HEADER
:
1312 print_unknown_data(ndo
, bp
,"\n\t ",op
->nd_opt_len
<<3);
1316 opm
= (struct nd_opt_mtu
*)op
;
1317 ND_TCHECK(opm
->nd_opt_mtu_mtu
);
1318 ND_PRINT((ndo
," %u%s",
1319 EXTRACT_32BITS(&opm
->nd_opt_mtu_mtu
),
1320 (op
->nd_opt_len
!= 1) ? "bad option length" : "" ));
1323 oprd
= (struct nd_opt_rdnss
*)op
;
1324 l
= (op
->nd_opt_len
- 1) / 2;
1325 ND_PRINT((ndo
," lifetime %us,",
1326 EXTRACT_32BITS(&oprd
->nd_opt_rdnss_lifetime
)));
1327 for (i
= 0; i
< l
; i
++) {
1328 ND_TCHECK(oprd
->nd_opt_rdnss_addr
[i
]);
1329 ND_PRINT((ndo
," addr: %s",
1330 ip6addr_string(&oprd
->nd_opt_rdnss_addr
[i
])));
1334 opds
= (struct nd_opt_dnssl
*)op
;
1335 ND_PRINT((ndo
," lifetime %us, domain(s):",
1336 EXTRACT_32BITS(&opds
->nd_opt_dnssl_lifetime
)));
1337 domp
= cp
+ 8; /* domain names, variable-sized, RFC1035-encoded */
1338 while (domp
< cp
+ (op
->nd_opt_len
<< 3) && *domp
!= '\0')
1340 ND_PRINT((ndo
, " "));
1341 if ((domp
= ns_nprint (domp
, bp
)) == NULL
)
1345 case ND_OPT_ADVINTERVAL
:
1346 opa
= (struct nd_opt_advinterval
*)op
;
1347 ND_TCHECK(opa
->nd_opt_adv_interval
);
1348 ND_PRINT((ndo
," %ums", EXTRACT_32BITS(&opa
->nd_opt_adv_interval
)));
1350 case ND_OPT_HOMEAGENT_INFO
:
1351 oph
= (struct nd_opt_homeagent_info
*)op
;
1352 ND_TCHECK(oph
->nd_opt_hai_lifetime
);
1353 ND_PRINT((ndo
," preference %u, lifetime %u",
1354 EXTRACT_16BITS(&oph
->nd_opt_hai_preference
),
1355 EXTRACT_16BITS(&oph
->nd_opt_hai_lifetime
)));
1357 case ND_OPT_ROUTE_INFO
:
1358 opri
= (struct nd_opt_route_info
*)op
;
1359 ND_TCHECK(opri
->nd_opt_rti_lifetime
);
1360 memset(&in6
, 0, sizeof(in6
));
1361 in6p
= (struct in6_addr
*)(opri
+ 1);
1362 switch (op
->nd_opt_len
) {
1366 ND_TCHECK2(*in6p
, 8);
1367 memcpy(&in6
, opri
+ 1, 8);
1371 memcpy(&in6
, opri
+ 1, sizeof(in6
));
1376 ND_PRINT((ndo
," %s/%u", ip6addr_string(&in6
),
1377 opri
->nd_opt_rti_prefixlen
));
1378 ND_PRINT((ndo
,", pref=%s", get_rtpref(opri
->nd_opt_rti_flags
)));
1379 ND_PRINT((ndo
,", lifetime=%s",
1380 get_lifetime(EXTRACT_32BITS(&opri
->nd_opt_rti_lifetime
))));
1383 if (ndo
->ndo_vflag
<= 1) {
1384 print_unknown_data(ndo
,cp
+2,"\n\t ", (op
->nd_opt_len
<< 3) - 2); /* skip option header */
1389 /* do we want to see an additional hexdump ? */
1390 if (ndo
->ndo_vflag
> 1)
1391 print_unknown_data(ndo
, cp
+2,"\n\t ", (op
->nd_opt_len
<< 3) - 2); /* skip option header */
1393 cp
+= op
->nd_opt_len
<< 3;
1394 resid
-= op
->nd_opt_len
<< 3;
1399 ND_PRINT((ndo
, "[ndp opt]"));
1405 mld6_print(netdissect_options
*ndo
, const u_char
*bp
)
1407 const struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
1410 /* 'ep' points to the end of available data. */
1411 ep
= ndo
->ndo_snapend
;
1413 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
1416 ND_PRINT((ndo
,"max resp delay: %d ", EXTRACT_16BITS(&mp
->mld6_maxdelay
)));
1417 ND_PRINT((ndo
,"addr: %s", ip6addr_string(&mp
->mld6_addr
)));
1421 mldv2_report_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len
)
1423 struct icmp6_hdr
*icp
= (struct icmp6_hdr
*) bp
;
1424 u_int group
, nsrcs
, ngroups
;
1427 /* Minimum len is 8 */
1429 ND_PRINT((ndo
," [invalid len %d]", len
));
1433 ND_TCHECK(icp
->icmp6_data16
[1]);
1434 ngroups
= EXTRACT_16BITS(&icp
->icmp6_data16
[1]);
1435 ND_PRINT((ndo
,", %d group record(s)", ngroups
));
1436 if (ndo
->ndo_vflag
> 0) {
1437 /* Print the group records */
1439 for (i
= 0; i
< ngroups
; i
++) {
1440 /* type(1) + auxlen(1) + numsrc(2) + grp(16) */
1441 if (len
< group
+ 20) {
1442 ND_PRINT((ndo
," [invalid number of groups]"));
1445 ND_TCHECK2(bp
[group
+ 4], sizeof(struct in6_addr
));
1446 ND_PRINT((ndo
," [gaddr %s", ip6addr_string(&bp
[group
+ 4])));
1447 ND_PRINT((ndo
," %s", tok2str(mldv2report2str
, " [v2-report-#%d]",
1449 nsrcs
= (bp
[group
+ 2] << 8) + bp
[group
+ 3];
1450 /* Check the number of sources and print them */
1451 if (len
< group
+ 20 + (nsrcs
* sizeof(struct in6_addr
))) {
1452 ND_PRINT((ndo
," [invalid number of sources %d]", nsrcs
));
1455 if (ndo
->ndo_vflag
== 1)
1456 ND_PRINT((ndo
,", %d source(s)", nsrcs
));
1458 /* Print the sources */
1459 (void)ND_PRINT((ndo
," {"));
1460 for (j
= 0; j
< nsrcs
; j
++) {
1461 ND_TCHECK2(bp
[group
+ 20 + j
* sizeof(struct in6_addr
)],
1462 sizeof(struct in6_addr
));
1463 ND_PRINT((ndo
," %s", ip6addr_string(&bp
[group
+ 20 + j
* sizeof(struct in6_addr
)])));
1465 (void)ND_PRINT((ndo
," }"));
1467 /* Next group record */
1468 group
+= 20 + nsrcs
* sizeof(struct in6_addr
);
1469 ND_PRINT((ndo
,"]"));
1474 (void)ND_PRINT((ndo
,"[|icmp6]"));
1479 mldv2_query_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len
)
1481 struct icmp6_hdr
*icp
= (struct icmp6_hdr
*) bp
;
1487 /* Minimum len is 28 */
1489 ND_PRINT((ndo
," [invalid len %d]", len
));
1492 ND_TCHECK(icp
->icmp6_data16
[0]);
1493 mrc
= EXTRACT_16BITS(&icp
->icmp6_data16
[0]);
1497 mrt
= ((mrc
& 0x0fff) | 0x1000) << (((mrc
& 0x7000) >> 12) + 3);
1499 if (ndo
->ndo_vflag
) {
1500 (void)ND_PRINT((ndo
," [max resp delay=%d]", mrt
));
1502 ND_TCHECK2(bp
[8], sizeof(struct in6_addr
));
1503 ND_PRINT((ndo
," [gaddr %s", ip6addr_string(&bp
[8])));
1505 if (ndo
->ndo_vflag
) {
1507 if (bp
[24] & 0x08) {
1508 ND_PRINT((ndo
," sflag"));
1510 if (bp
[24] & 0x07) {
1511 ND_PRINT((ndo
," robustness=%d", bp
[24] & 0x07));
1516 qqi
= ((bp
[25] & 0x0f) | 0x10) << (((bp
[25] & 0x70) >> 4) + 3);
1518 ND_PRINT((ndo
," qqi=%d", qqi
));
1521 ND_TCHECK2(bp
[26], 2);
1522 nsrcs
= EXTRACT_16BITS(&bp
[26]);
1524 if (len
< 28 + nsrcs
* sizeof(struct in6_addr
))
1525 ND_PRINT((ndo
," [invalid number of sources]"));
1526 else if (ndo
->ndo_vflag
> 1) {
1527 ND_PRINT((ndo
," {"));
1528 for (i
= 0; i
< nsrcs
; i
++) {
1529 ND_TCHECK2(bp
[28 + i
* sizeof(struct in6_addr
)],
1530 sizeof(struct in6_addr
));
1531 ND_PRINT((ndo
," %s", ip6addr_string(&bp
[28 + i
* sizeof(struct in6_addr
)])));
1533 ND_PRINT((ndo
," }"));
1535 ND_PRINT((ndo
,", %d source(s)", nsrcs
));
1537 ND_PRINT((ndo
,"]"));
1540 (void)ND_PRINT((ndo
,"[|icmp6]"));
1545 dnsname_print(netdissect_options
*ndo
, const u_char
*cp
, const u_char
*ep
)
1549 /* DNS name decoding - no decompression */
1550 ND_PRINT((ndo
,", \""));
1555 ND_PRINT((ndo
,"???"));
1558 while (i
-- && cp
< ep
) {
1562 if (cp
+ 1 < ep
&& *cp
)
1563 ND_PRINT((ndo
,"."));
1567 ND_PRINT((ndo
,"."));
1568 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
1572 ND_PRINT((ndo
,"???"));
1577 ND_PRINT((ndo
,"\""));
1581 icmp6_nodeinfo_print(netdissect_options
*ndo
, u_int icmp6len
, const u_char
*bp
, const u_char
*ep
)
1583 const struct icmp6_nodeinfo
*ni6
;
1584 const struct icmp6_hdr
*dp
;
1591 dp
= (struct icmp6_hdr
*)bp
;
1592 ni6
= (struct icmp6_nodeinfo
*)bp
;
1595 switch (ni6
->ni_type
) {
1596 case ICMP6_NI_QUERY
:
1597 if (siz
== sizeof(*dp
) + 4) {
1598 /* KAME who-are-you */
1599 ND_PRINT((ndo
," who-are-you request"));
1602 ND_PRINT((ndo
," node information query"));
1604 ND_TCHECK2(*dp
, sizeof(*ni6
));
1605 ni6
= (struct icmp6_nodeinfo
*)dp
;
1606 ND_PRINT((ndo
," (")); /*)*/
1607 switch (EXTRACT_16BITS(&ni6
->ni_qtype
)) {
1609 ND_PRINT((ndo
,"noop"));
1611 case NI_QTYPE_SUPTYPES
:
1612 ND_PRINT((ndo
,"supported qtypes"));
1613 i
= EXTRACT_16BITS(&ni6
->ni_flags
);
1615 ND_PRINT((ndo
," [%s]", (i
& 0x01) ? "C" : ""));
1618 ND_PRINT((ndo
,"DNS name"));
1620 case NI_QTYPE_NODEADDR
:
1621 ND_PRINT((ndo
,"node addresses"));
1625 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
1626 ND_PRINT((ndo
," [%s%s%s%s%s%s]",
1627 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
1628 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
1629 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
1630 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
1631 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
1632 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : ""));
1635 ND_PRINT((ndo
,"unknown"));
1639 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
1640 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
1641 if (siz
!= sizeof(*ni6
))
1643 ND_PRINT((ndo
,", invalid len"));
1645 ND_PRINT((ndo
,")"));
1650 /* XXX backward compat, icmp-name-lookup-03 */
1651 if (siz
== sizeof(*ni6
)) {
1652 ND_PRINT((ndo
,", 03 draft"));
1654 ND_PRINT((ndo
,")"));
1658 switch (ni6
->ni_code
) {
1659 case ICMP6_NI_SUBJ_IPV6
:
1661 sizeof(*ni6
) + sizeof(struct in6_addr
)))
1663 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
1665 ND_PRINT((ndo
,", invalid subject len"));
1668 ND_PRINT((ndo
,", subject=%s",
1669 getname6((const u_char
*)(ni6
+ 1))));
1671 case ICMP6_NI_SUBJ_FQDN
:
1672 ND_PRINT((ndo
,", subject=DNS name"));
1673 cp
= (const u_char
*)(ni6
+ 1);
1674 if (cp
[0] == ep
- cp
- 1) {
1675 /* icmp-name-lookup-03, pascal string */
1677 ND_PRINT((ndo
,", 03 draft"));
1679 ND_PRINT((ndo
,", \""));
1684 ND_PRINT((ndo
,"\""));
1686 dnsname_print(ndo
, cp
, ep
);
1688 case ICMP6_NI_SUBJ_IPV4
:
1689 if (!ND_TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
1691 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
1693 ND_PRINT((ndo
,", invalid subject len"));
1696 ND_PRINT((ndo
,", subject=%s",
1697 getname((const u_char
*)(ni6
+ 1))));
1700 ND_PRINT((ndo
,", unknown subject"));
1705 ND_PRINT((ndo
,")"));
1708 case ICMP6_NI_REPLY
:
1709 if (icmp6len
> siz
) {
1710 ND_PRINT((ndo
,"[|icmp6: node information reply]"));
1716 ni6
= (struct icmp6_nodeinfo
*)dp
;
1717 ND_PRINT((ndo
," node information reply"));
1718 ND_PRINT((ndo
," (")); /*)*/
1719 switch (ni6
->ni_code
) {
1720 case ICMP6_NI_SUCCESS
:
1721 if (ndo
->ndo_vflag
) {
1722 ND_PRINT((ndo
,"success"));
1726 case ICMP6_NI_REFUSED
:
1727 ND_PRINT((ndo
,"refused"));
1729 if (siz
!= sizeof(*ni6
))
1731 ND_PRINT((ndo
,", invalid length"));
1733 case ICMP6_NI_UNKNOWN
:
1734 ND_PRINT((ndo
,"unknown"));
1736 if (siz
!= sizeof(*ni6
))
1738 ND_PRINT((ndo
,", invalid length"));
1742 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
1744 ND_PRINT((ndo
,")"));
1748 switch (EXTRACT_16BITS(&ni6
->ni_qtype
)) {
1751 ND_PRINT((ndo
,", "));
1752 ND_PRINT((ndo
,"noop"));
1753 if (siz
!= sizeof(*ni6
))
1755 ND_PRINT((ndo
,", invalid length"));
1757 case NI_QTYPE_SUPTYPES
:
1759 ND_PRINT((ndo
,", "));
1760 ND_PRINT((ndo
,"supported qtypes"));
1761 i
= EXTRACT_16BITS(&ni6
->ni_flags
);
1763 ND_PRINT((ndo
," [%s]", (i
& 0x01) ? "C" : ""));
1767 ND_PRINT((ndo
,", "));
1768 ND_PRINT((ndo
,"DNS name"));
1769 cp
= (const u_char
*)(ni6
+ 1) + 4;
1770 if (cp
[0] == ep
- cp
- 1) {
1771 /* icmp-name-lookup-03, pascal string */
1773 ND_PRINT((ndo
,", 03 draft"));
1775 ND_PRINT((ndo
,", \""));
1780 ND_PRINT((ndo
,"\""));
1782 dnsname_print(ndo
, cp
, ep
);
1783 if ((EXTRACT_16BITS(&ni6
->ni_flags
) & 0x01) != 0)
1784 ND_PRINT((ndo
," [TTL=%u]", *(u_int32_t
*)(ni6
+ 1)));
1786 case NI_QTYPE_NODEADDR
:
1788 ND_PRINT((ndo
,", "));
1789 ND_PRINT((ndo
,"node addresses"));
1792 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
1794 ND_PRINT((ndo
," %s", getname6(bp
+ i
)));
1795 i
+= sizeof(struct in6_addr
);
1796 ND_PRINT((ndo
,"(%d)", (int32_t)EXTRACT_32BITS(bp
+ i
)));
1797 i
+= sizeof(int32_t);
1802 ND_PRINT((ndo
," [%s%s%s%s%s%s%s]",
1803 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
1804 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
1805 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
1806 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
1807 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
1808 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
1809 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : ""));
1813 ND_PRINT((ndo
,", "));
1814 ND_PRINT((ndo
,"unknown"));
1819 ND_PRINT((ndo
,")"));
1825 ND_PRINT((ndo
, "[|icmp6]"));
1829 icmp6_rrenum_print(netdissect_options
*ndo
, const u_char
*bp
, const u_char
*ep
)
1831 const struct icmp6_router_renum
*rr6
;
1833 struct rr_pco_match
*match
;
1834 struct rr_pco_use
*use
;
1835 char hbuf
[NI_MAXHOST
];
1840 rr6
= (struct icmp6_router_renum
*)bp
;
1841 cp
= (const char *)(rr6
+ 1);
1843 ND_TCHECK(rr6
->rr_reserved
);
1844 switch (rr6
->rr_code
) {
1845 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
1846 ND_PRINT((ndo
,"router renum: command"));
1848 case ICMP6_ROUTER_RENUMBERING_RESULT
:
1849 ND_PRINT((ndo
,"router renum: result"));
1851 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
1852 ND_PRINT((ndo
,"router renum: sequence number reset"));
1855 ND_PRINT((ndo
,"router renum: code-#%d", rr6
->rr_code
));
1859 ND_PRINT((ndo
,", seq=%u", EXTRACT_32BITS(&rr6
->rr_seqnum
)));
1861 if (ndo
->ndo_vflag
) {
1862 #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
1863 ND_PRINT((ndo
,"[")); /*]*/
1864 if (rr6
->rr_flags
) {
1865 ND_PRINT((ndo
,"%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
1866 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
1867 F(ICMP6_RR_FLAGS_FORCEAPPLY
, "A"),
1868 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
1869 F(ICMP6_RR_FLAGS_PREVDONE
, "P")));
1871 ND_PRINT((ndo
,"seg=%u,", rr6
->rr_segnum
));
1872 ND_PRINT((ndo
,"maxdelay=%u", EXTRACT_16BITS(&rr6
->rr_maxdelay
)));
1873 if (rr6
->rr_reserved
)
1874 ND_PRINT((ndo
,"rsvd=0x%x", EXTRACT_32BITS(&rr6
->rr_reserved
)));
1876 ND_PRINT((ndo
,"]"));
1880 if (rr6
->rr_code
== ICMP6_ROUTER_RENUMBERING_COMMAND
) {
1881 match
= (struct rr_pco_match
*)cp
;
1882 cp
= (const char *)(match
+ 1);
1884 ND_TCHECK(match
->rpm_prefix
);
1886 if (ndo
->ndo_vflag
> 1)
1887 ND_PRINT((ndo
,"\n\t"));
1889 ND_PRINT((ndo
," "));
1890 ND_PRINT((ndo
,"match(")); /*)*/
1891 switch (match
->rpm_code
) {
1892 case RPM_PCO_ADD
: ND_PRINT((ndo
,"add")); break;
1893 case RPM_PCO_CHANGE
: ND_PRINT((ndo
,"change")); break;
1894 case RPM_PCO_SETGLOBAL
: ND_PRINT((ndo
,"setglobal")); break;
1895 default: ND_PRINT((ndo
,"#%u", match
->rpm_code
)); break;
1898 if (ndo
->ndo_vflag
) {
1899 ND_PRINT((ndo
,",ord=%u", match
->rpm_ordinal
));
1900 ND_PRINT((ndo
,",min=%u", match
->rpm_minlen
));
1901 ND_PRINT((ndo
,",max=%u", match
->rpm_maxlen
));
1903 if (inet_ntop(AF_INET6
, &match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
1904 ND_PRINT((ndo
,",%s/%u", hbuf
, match
->rpm_matchlen
));
1906 ND_PRINT((ndo
,",?/%u", match
->rpm_matchlen
));
1908 ND_PRINT((ndo
,")"));
1910 n
= match
->rpm_len
- 3;
1915 use
= (struct rr_pco_use
*)cp
;
1916 cp
= (const char *)(use
+ 1);
1918 ND_TCHECK(use
->rpu_prefix
);
1920 if (ndo
->ndo_vflag
> 1)
1921 ND_PRINT((ndo
,"\n\t"));
1923 ND_PRINT((ndo
," "));
1924 ND_PRINT((ndo
,"use(")); /*)*/
1925 if (use
->rpu_flags
) {
1926 #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
1927 ND_PRINT((ndo
,"%s%s,",
1928 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
1929 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P")));
1932 if (ndo
->ndo_vflag
) {
1933 ND_PRINT((ndo
,"mask=0x%x,", use
->rpu_ramask
));
1934 ND_PRINT((ndo
,"raflags=0x%x,", use
->rpu_raflags
));
1935 if (~use
->rpu_vltime
== 0)
1936 ND_PRINT((ndo
,"vltime=infty,"));
1938 ND_PRINT((ndo
,"vltime=%u,",
1939 EXTRACT_32BITS(&use
->rpu_vltime
)));
1940 if (~use
->rpu_pltime
== 0)
1941 ND_PRINT((ndo
,"pltime=infty,"));
1943 ND_PRINT((ndo
,"pltime=%u,",
1944 EXTRACT_32BITS(&use
->rpu_pltime
)));
1946 if (inet_ntop(AF_INET6
, &use
->rpu_prefix
, hbuf
,
1948 ND_PRINT((ndo
,"%s/%u/%u", hbuf
, use
->rpu_uselen
,
1951 ND_PRINT((ndo
,"?/%u/%u", use
->rpu_uselen
,
1954 ND_PRINT((ndo
,")"));
1961 ND_PRINT((ndo
,"[|icmp6]"));
1968 * c-style: whitesmith