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.
22 #include <sys/cdefs.h>
24 __RCSID("$NetBSD: print-icmp6.c,v 1.8 2015/03/31 21:59:35 christos Exp $");
27 #define NETDISSECT_REWORKED
34 #include <tcpdump-stdinc.h>
39 #include "interface.h"
40 #include "addrtoname.h"
49 /* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
50 /* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
53 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
54 * All rights reserved.
56 * Redistribution and use in source and binary forms, with or without
57 * modification, are permitted provided that the following conditions
59 * 1. Redistributions of source code must retain the above copyright
60 * notice, this list of conditions and the following disclaimer.
61 * 2. Redistributions in binary form must reproduce the above copyright
62 * notice, this list of conditions and the following disclaimer in the
63 * documentation and/or other materials provided with the distribution.
64 * 3. Neither the name of the project nor the names of its contributors
65 * may be used to endorse or promote products derived from this software
66 * without specific prior written permission.
68 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
69 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
70 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
71 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
72 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
73 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
74 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
75 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
76 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
77 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
82 uint8_t icmp6_type
; /* type field */
83 uint8_t icmp6_code
; /* code field */
84 uint16_t icmp6_cksum
; /* checksum field */
86 uint32_t icmp6_un_data32
[1]; /* type-specific field */
87 uint16_t icmp6_un_data16
[2]; /* type-specific field */
88 uint8_t icmp6_un_data8
[4]; /* type-specific field */
92 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
93 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
94 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
95 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
96 #define icmp6_mtu icmp6_data32[0] /* packet too big */
97 #define icmp6_id icmp6_data16[0] /* echo request/reply */
98 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
99 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
101 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
102 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
103 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
104 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
106 #define ICMP6_ECHO_REQUEST 128 /* echo service */
107 #define ICMP6_ECHO_REPLY 129 /* echo reply */
108 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
109 #define MLD6_LISTENER_QUERY 130 /* multicast listener query */
110 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
111 #define MLD6_LISTENER_REPORT 131 /* multicast listener report */
112 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
113 #define MLD6_LISTENER_DONE 132 /* multicast listener done */
115 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
116 #define ND_ROUTER_ADVERT 134 /* router advertisement */
117 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
118 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
119 #define ND_REDIRECT 137 /* redirect */
121 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
123 #define ICMP6_WRUREQUEST 139 /* who are you request */
124 #define ICMP6_WRUREPLY 140 /* who are you reply */
125 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
126 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
127 #define ICMP6_NI_QUERY 139 /* node information request */
128 #define ICMP6_NI_REPLY 140 /* node information reply */
129 #define IND_SOLICIT 141 /* inverse neighbor solicitation */
130 #define IND_ADVERT 142 /* inverse neighbor advertisement */
132 #define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */
133 #define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */
134 #define ICMP6_HADISCOV_REQUEST 144
135 #define ICMP6_HADISCOV_REPLY 145
136 #define ICMP6_MOBILEPREFIX_SOLICIT 146
137 #define ICMP6_MOBILEPREFIX_ADVERT 147
139 #define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
140 #define MLD6_MTRACE 201 /* mtrace messages */
142 #define ICMP6_MAXTYPE 201
144 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
145 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
146 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
147 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
148 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
149 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
151 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
152 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
154 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
155 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
156 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
158 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
160 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
161 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
162 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
164 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
165 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
166 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
168 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
169 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
170 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
172 /* Used in kernel only */
173 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
174 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
177 * Multicast Listener Discovery
180 struct icmp6_hdr mld6_hdr
;
181 struct in6_addr mld6_addr
; /* multicast address */
184 #define mld6_type mld6_hdr.icmp6_type
185 #define mld6_code mld6_hdr.icmp6_code
186 #define mld6_cksum mld6_hdr.icmp6_cksum
187 #define mld6_maxdelay mld6_hdr.icmp6_data16[0]
188 #define mld6_reserved mld6_hdr.icmp6_data16[1]
190 #define MLD_MINLEN 24
191 #define MLDV2_MINLEN 28
197 struct nd_router_solicit
{ /* router solicitation */
198 struct icmp6_hdr nd_rs_hdr
;
199 /* could be followed by options */
202 #define nd_rs_type nd_rs_hdr.icmp6_type
203 #define nd_rs_code nd_rs_hdr.icmp6_code
204 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
205 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
207 struct nd_router_advert
{ /* router advertisement */
208 struct icmp6_hdr nd_ra_hdr
;
209 uint32_t nd_ra_reachable
; /* reachable time */
210 uint32_t nd_ra_retransmit
; /* retransmit timer */
211 /* could be followed by options */
214 #define nd_ra_type nd_ra_hdr.icmp6_type
215 #define nd_ra_code nd_ra_hdr.icmp6_code
216 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
217 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
218 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
219 #define ND_RA_FLAG_MANAGED 0x80
220 #define ND_RA_FLAG_OTHER 0x40
221 #define ND_RA_FLAG_HOME_AGENT 0x20
224 * Router preference values based on draft-draves-ipngwg-router-selection-01.
225 * These are non-standard definitions.
227 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
229 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
230 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
231 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
232 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
234 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
236 struct nd_neighbor_solicit
{ /* neighbor solicitation */
237 struct icmp6_hdr nd_ns_hdr
;
238 struct in6_addr nd_ns_target
; /*target address */
239 /* could be followed by options */
242 #define nd_ns_type nd_ns_hdr.icmp6_type
243 #define nd_ns_code nd_ns_hdr.icmp6_code
244 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
245 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
247 struct nd_neighbor_advert
{ /* neighbor advertisement */
248 struct icmp6_hdr nd_na_hdr
;
249 struct in6_addr nd_na_target
; /* target address */
250 /* could be followed by options */
253 #define nd_na_type nd_na_hdr.icmp6_type
254 #define nd_na_code nd_na_hdr.icmp6_code
255 #define nd_na_cksum nd_na_hdr.icmp6_cksum
256 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
258 #define ND_NA_FLAG_ROUTER 0x80000000
259 #define ND_NA_FLAG_SOLICITED 0x40000000
260 #define ND_NA_FLAG_OVERRIDE 0x20000000
262 struct nd_redirect
{ /* redirect */
263 struct icmp6_hdr nd_rd_hdr
;
264 struct in6_addr nd_rd_target
; /* target address */
265 struct in6_addr nd_rd_dst
; /* destination address */
266 /* could be followed by options */
269 #define nd_rd_type nd_rd_hdr.icmp6_type
270 #define nd_rd_code nd_rd_hdr.icmp6_code
271 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
272 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
274 struct nd_opt_hdr
{ /* Neighbor discovery option header */
277 /* followed by option specific data*/
280 #define ND_OPT_SOURCE_LINKADDR 1
281 #define ND_OPT_TARGET_LINKADDR 2
282 #define ND_OPT_PREFIX_INFORMATION 3
283 #define ND_OPT_REDIRECTED_HEADER 4
285 #define ND_OPT_ADVINTERVAL 7
286 #define ND_OPT_HOMEAGENT_INFO 8
287 #define ND_OPT_ROUTE_INFO 24 /* RFC4191 */
288 #define ND_OPT_RDNSS 25
289 #define ND_OPT_DNSSL 31
291 struct nd_opt_prefix_info
{ /* prefix information */
292 uint8_t nd_opt_pi_type
;
293 uint8_t nd_opt_pi_len
;
294 uint8_t nd_opt_pi_prefix_len
;
295 uint8_t nd_opt_pi_flags_reserved
;
296 uint8_t nd_opt_pi_valid_time
[4];
297 uint8_t nd_opt_pi_preferred_time
[4];
298 uint8_t nd_opt_pi_reserved2
[4];
299 struct in6_addr nd_opt_pi_prefix
;
302 #define ND_OPT_PI_FLAG_ONLINK 0x80
303 #define ND_OPT_PI_FLAG_AUTO 0x40
304 #define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
306 struct nd_opt_rd_hdr
{ /* redirected header */
307 uint8_t nd_opt_rh_type
;
308 uint8_t nd_opt_rh_len
;
309 uint16_t nd_opt_rh_reserved1
;
310 uint32_t nd_opt_rh_reserved2
;
311 /* followed by IP header and data */
314 struct nd_opt_mtu
{ /* MTU option */
315 uint8_t nd_opt_mtu_type
;
316 uint8_t nd_opt_mtu_len
;
317 uint16_t nd_opt_mtu_reserved
;
318 uint32_t nd_opt_mtu_mtu
;
321 struct nd_opt_rdnss
{ /* RDNSS RFC 6106 5.1 */
322 uint8_t nd_opt_rdnss_type
;
323 uint8_t nd_opt_rdnss_len
;
324 uint16_t nd_opt_rdnss_reserved
;
325 uint32_t nd_opt_rdnss_lifetime
;
326 struct in6_addr nd_opt_rdnss_addr
[1]; /* variable-length */
329 struct nd_opt_dnssl
{ /* DNSSL RFC 6106 5.2 */
330 uint8_t nd_opt_dnssl_type
;
331 uint8_t nd_opt_dnssl_len
;
332 uint16_t nd_opt_dnssl_reserved
;
333 uint32_t nd_opt_dnssl_lifetime
;
334 /* followed by list of DNS search domains, variable-length */
337 struct nd_opt_advinterval
{ /* Advertisement interval option */
338 uint8_t nd_opt_adv_type
;
339 uint8_t nd_opt_adv_len
;
340 uint16_t nd_opt_adv_reserved
;
341 uint32_t nd_opt_adv_interval
;
344 struct nd_opt_homeagent_info
{ /* Home Agent info */
345 uint8_t nd_opt_hai_type
;
346 uint8_t nd_opt_hai_len
;
347 uint16_t nd_opt_hai_reserved
;
348 int16_t nd_opt_hai_preference
;
349 uint16_t nd_opt_hai_lifetime
;
352 struct nd_opt_route_info
{ /* route info */
353 uint8_t nd_opt_rti_type
;
354 uint8_t nd_opt_rti_len
;
355 uint8_t nd_opt_rti_prefixlen
;
356 uint8_t nd_opt_rti_flags
;
357 uint32_t nd_opt_rti_lifetime
;
365 struct icmp6_namelookup
{
366 struct icmp6_hdr icmp6_nl_hdr
;
367 uint8_t icmp6_nl_nonce
[8];
368 int32_t icmp6_nl_ttl
;
370 uint8_t icmp6_nl_len
;
371 uint8_t icmp6_nl_name
[3];
373 /* could be followed by options */
377 * icmp6 node information
379 struct icmp6_nodeinfo
{
380 struct icmp6_hdr icmp6_ni_hdr
;
381 uint8_t icmp6_ni_nonce
[8];
382 /* could be followed by reply data */
385 #define ni_type icmp6_ni_hdr.icmp6_type
386 #define ni_code icmp6_ni_hdr.icmp6_code
387 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
388 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
389 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
391 #define NI_QTYPE_NOOP 0 /* NOOP */
392 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
393 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
394 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
395 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
396 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
399 #define NI_SUPTYPE_FLAG_COMPRESS ((uint16_t)htons(0x1))
400 #define NI_FQDN_FLAG_VALIDTTL ((uint16_t)htons(0x1))
403 #define NI_NODEADDR_FLAG_TRUNCATE ((uint16_t)htons(0x1))
404 #define NI_NODEADDR_FLAG_ALL ((uint16_t)htons(0x2))
405 #define NI_NODEADDR_FLAG_COMPAT ((uint16_t)htons(0x4))
406 #define NI_NODEADDR_FLAG_LINKLOCAL ((uint16_t)htons(0x8))
407 #define NI_NODEADDR_FLAG_SITELOCAL ((uint16_t)htons(0x10))
408 #define NI_NODEADDR_FLAG_GLOBAL ((uint16_t)htons(0x20))
409 #define NI_NODEADDR_FLAG_ANYCAST ((uint16_t)htons(0x40)) /* just experimental. not in spec */
411 struct ni_reply_fqdn
{
412 uint32_t ni_fqdn_ttl
; /* TTL */
413 uint8_t ni_fqdn_namelen
; /* length in octets of the FQDN */
414 uint8_t ni_fqdn_name
[3]; /* XXX: alignment */
418 * Router Renumbering. as router-renum-08.txt
420 struct icmp6_router_renum
{ /* router renumbering header */
421 struct icmp6_hdr rr_hdr
;
424 uint16_t rr_maxdelay
;
425 uint32_t rr_reserved
;
427 #define ICMP6_RR_FLAGS_TEST 0x80
428 #define ICMP6_RR_FLAGS_REQRESULT 0x40
429 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
430 #define ICMP6_RR_FLAGS_SPECSITE 0x10
431 #define ICMP6_RR_FLAGS_PREVDONE 0x08
433 #define rr_type rr_hdr.icmp6_type
434 #define rr_code rr_hdr.icmp6_code
435 #define rr_cksum rr_hdr.icmp6_cksum
436 #define rr_seqnum rr_hdr.icmp6_data32[0]
438 struct rr_pco_match
{ /* match prefix part */
442 uint8_t rpm_matchlen
;
445 uint16_t rpm_reserved
;
446 struct in6_addr rpm_prefix
;
449 #define RPM_PCO_ADD 1
450 #define RPM_PCO_CHANGE 2
451 #define RPM_PCO_SETGLOBAL 3
452 #define RPM_PCO_MAX 4
454 struct rr_pco_use
{ /* use prefix part */
462 struct in6_addr rpu_prefix
;
464 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
465 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
468 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((uint32_t)htonl(0x80000000))
469 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((uint32_t)htonl(0x40000000))
471 struct rr_result
{ /* router renumbering result message */
474 uint8_t rrr_matchedlen
;
476 struct in6_addr rrr_prefix
;
479 #define ICMP6_RR_RESULT_FLAGS_OOB ((uint16_t)htons(0x0002))
480 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((uint16_t)htons(0x0001))
482 static const char *get_rtpref(u_int
);
483 static const char *get_lifetime(uint32_t);
484 static void print_lladdr(netdissect_options
*ndo
, const u_char
*, size_t);
485 static void icmp6_opt_print(netdissect_options
*ndo
, const u_char
*, int);
486 static void mld6_print(netdissect_options
*ndo
, const u_char
*);
487 static void mldv2_report_print(netdissect_options
*ndo
, const u_char
*, u_int
);
488 static void mldv2_query_print(netdissect_options
*ndo
, const u_char
*, u_int
);
489 static const struct udphdr
*get_upperlayer(netdissect_options
*ndo
, const u_char
*, u_int
*);
490 static void dnsname_print(netdissect_options
*ndo
, const u_char
*, const u_char
*);
491 static void icmp6_nodeinfo_print(netdissect_options
*ndo
, u_int
, const u_char
*, const u_char
*);
492 static void icmp6_rrenum_print(netdissect_options
*ndo
, const u_char
*, const u_char
*);
495 #define abs(a) ((0 < (a)) ? (a) : -(a))
500 static const struct tok icmp6_type_values
[] = {
501 { ICMP6_DST_UNREACH
, "destination unreachable"},
502 { ICMP6_PACKET_TOO_BIG
, "packet too big"},
503 { ICMP6_TIME_EXCEEDED
, "time exceeded in-transit"},
504 { ICMP6_PARAM_PROB
, "parameter problem"},
505 { ICMP6_ECHO_REQUEST
, "echo request"},
506 { ICMP6_ECHO_REPLY
, "echo reply"},
507 { MLD6_LISTENER_QUERY
, "multicast listener query"},
508 { MLD6_LISTENER_REPORT
, "multicast listener report"},
509 { MLD6_LISTENER_DONE
, "multicast listener done"},
510 { ND_ROUTER_SOLICIT
, "router solicitation"},
511 { ND_ROUTER_ADVERT
, "router advertisement"},
512 { ND_NEIGHBOR_SOLICIT
, "neighbor solicitation"},
513 { ND_NEIGHBOR_ADVERT
, "neighbor advertisement"},
514 { ND_REDIRECT
, "redirect"},
515 { ICMP6_ROUTER_RENUMBERING
, "router renumbering"},
516 { IND_SOLICIT
, "inverse neighbor solicitation"},
517 { IND_ADVERT
, "inverse neighbor advertisement"},
518 { MLDV2_LISTENER_REPORT
, "multicast listener report v2"},
519 { ICMP6_HADISCOV_REQUEST
, "ha discovery request"},
520 { ICMP6_HADISCOV_REPLY
, "ha discovery reply"},
521 { ICMP6_MOBILEPREFIX_SOLICIT
, "mobile router solicitation"},
522 { ICMP6_MOBILEPREFIX_ADVERT
, "mobile router advertisement"},
523 { ICMP6_WRUREQUEST
, "who-are-you request"},
524 { ICMP6_WRUREPLY
, "who-are-you reply"},
525 { ICMP6_NI_QUERY
, "node information query"},
526 { ICMP6_NI_REPLY
, "node information reply"},
527 { MLD6_MTRACE
, "mtrace message"},
528 { MLD6_MTRACE_RESP
, "mtrace response"},
529 { ND_RPL_MESSAGE
, "RPL"},
533 static const struct tok icmp6_dst_unreach_code_values
[] = {
534 { ICMP6_DST_UNREACH_NOROUTE
, "unreachable route" },
535 { ICMP6_DST_UNREACH_ADMIN
, " unreachable prohibited"},
536 { ICMP6_DST_UNREACH_BEYONDSCOPE
, "beyond scope"},
537 { ICMP6_DST_UNREACH_ADDR
, "unreachable address"},
538 { ICMP6_DST_UNREACH_NOPORT
, "unreachable port"},
542 static const struct tok icmp6_opt_pi_flag_values
[] = {
543 { ND_OPT_PI_FLAG_ONLINK
, "onlink" },
544 { ND_OPT_PI_FLAG_AUTO
, "auto" },
545 { ND_OPT_PI_FLAG_ROUTER
, "router" },
549 static const struct tok icmp6_opt_ra_flag_values
[] = {
550 { ND_RA_FLAG_MANAGED
, "managed" },
551 { ND_RA_FLAG_OTHER
, "other stateful"},
552 { ND_RA_FLAG_HOME_AGENT
, "home agent"},
556 static const struct tok icmp6_nd_na_flag_values
[] = {
557 { ND_NA_FLAG_ROUTER
, "router" },
558 { ND_NA_FLAG_SOLICITED
, "solicited" },
559 { ND_NA_FLAG_OVERRIDE
, "override" },
564 static const struct tok icmp6_opt_values
[] = {
565 { ND_OPT_SOURCE_LINKADDR
, "source link-address"},
566 { ND_OPT_TARGET_LINKADDR
, "destination link-address"},
567 { ND_OPT_PREFIX_INFORMATION
, "prefix info"},
568 { ND_OPT_REDIRECTED_HEADER
, "redirected header"},
569 { ND_OPT_MTU
, "mtu"},
570 { ND_OPT_RDNSS
, "rdnss"},
571 { ND_OPT_DNSSL
, "dnssl"},
572 { ND_OPT_ADVINTERVAL
, "advertisement interval"},
573 { ND_OPT_HOMEAGENT_INFO
, "homeagent information"},
574 { ND_OPT_ROUTE_INFO
, "route info"},
578 /* mldv2 report types */
579 static const struct tok mldv2report2str
[] = {
592 static const char *rtpref_str
[] = {
599 return rtpref_str
[((v
& ND_RA_FLAG_RTPREF_MASK
) >> 3) & 0xff];
603 get_lifetime(uint32_t v
)
607 if (v
== (uint32_t)~0UL)
610 snprintf(buf
, sizeof(buf
), "%us", v
);
616 print_lladdr(netdissect_options
*ndo
, const uint8_t *p
, size_t l
)
618 const uint8_t *ep
, *q
;
622 while (l
> 0 && q
< ep
) {
625 ND_PRINT((ndo
,"%02x", *q
++));
630 static int icmp6_cksum(const struct ip6_hdr
*ip6
, const struct icmp6_hdr
*icp
,
633 return nextproto6_cksum(ip6
, (const uint8_t *)(void *)icp
, len
, len
,
637 const struct tok rpl_mop_values
[] = {
638 { RPL_DIO_NONSTORING
, "nonstoring"},
639 { RPL_DIO_STORING
, "storing"},
640 { RPL_DIO_NONSTORING_MULTICAST
, "nonstoring-multicast"},
641 { RPL_DIO_STORING_MULTICAST
, "storing-multicast"},
645 const struct tok rpl_subopt_values
[] = {
646 { RPL_OPT_PAD0
, "pad0"},
647 { RPL_OPT_PADN
, "padN"},
648 { RPL_DIO_METRICS
, "metrics"},
649 { RPL_DIO_ROUTINGINFO
, "routinginfo"},
650 { RPL_DIO_CONFIG
, "config"},
651 { RPL_DAO_RPLTARGET
, "rpltarget"},
652 { RPL_DAO_TRANSITINFO
, "transitinfo"},
653 { RPL_DIO_DESTPREFIX
, "destprefix"},
654 { RPL_DAO_RPLTARGET_DESC
, "rpltargetdesc"},
659 rpl_format_dagid(char dagid_str
[65], const u_char
*dagid
)
665 if(isprint(dagid
[i
])) {
668 snprintf(d
,5,"0x%02x", dagid
[i
]); /* 4 + null char */
676 rpl_dio_printopt(netdissect_options
*ndo
,
677 const struct rpl_dio_genoption
*opt
,
680 if(length
< RPL_DIO_GENOPTION_LEN
) return;
681 length
-= RPL_DIO_GENOPTION_LEN
;
683 ND_TCHECK(opt
->rpl_dio_len
);
685 while((opt
->rpl_dio_type
== RPL_OPT_PAD0
&&
686 (u_char
*)opt
< ndo
->ndo_snapend
) ||
687 ND_TTEST2(*opt
,(opt
->rpl_dio_len
+2))) {
689 unsigned int optlen
= opt
->rpl_dio_len
+2;
690 if(opt
->rpl_dio_type
== RPL_OPT_PAD0
) {
692 ND_PRINT((ndo
, " opt:pad0"));
694 ND_PRINT((ndo
, " opt:%s len:%u ",
695 tok2str(rpl_subopt_values
, "%subopt:%u", opt
->rpl_dio_type
),
697 if(ndo
->ndo_vflag
> 2) {
698 unsigned int paylen
= opt
->rpl_dio_len
;
699 if(paylen
> length
) paylen
= length
;
702 ((uint8_t *)opt
) + RPL_DIO_GENOPTION_LEN
, /* content of DIO option */
706 opt
= (struct rpl_dio_genoption
*)(((char *)opt
) + optlen
);
711 ND_PRINT((ndo
," [|truncated]"));
716 rpl_dio_print(netdissect_options
*ndo
,
717 const u_char
*bp
, u_int length
)
719 const struct nd_rpl_dio
*dio
= (struct nd_rpl_dio
*)bp
;
723 rpl_format_dagid(dagid_str
, dio
->rpl_dagid
);
725 ND_PRINT((ndo
, " [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
729 EXTRACT_16BITS(&dio
->rpl_dagrank
),
730 RPL_DIO_GROUNDED(dio
->rpl_mopprf
) ? "grounded,":"",
731 tok2str(rpl_mop_values
, "mop%u", RPL_DIO_MOP(dio
->rpl_mopprf
)),
732 RPL_DIO_PRF(dio
->rpl_mopprf
)));
734 if(ndo
->ndo_vflag
> 1) {
735 struct rpl_dio_genoption
*opt
= (struct rpl_dio_genoption
*)&dio
[1];
736 rpl_dio_printopt(ndo
, opt
, length
);
740 ND_PRINT((ndo
," [|truncated]"));
745 rpl_dao_print(netdissect_options
*ndo
,
746 const u_char
*bp
, u_int length
)
748 const struct nd_rpl_dao
*dao
= (struct nd_rpl_dao
*)bp
;
752 if (length
< ND_RPL_DAO_MIN_LEN
)
755 strcpy(dagid_str
,"<elided>");
756 bp
+= ND_RPL_DAO_MIN_LEN
;
757 length
-= ND_RPL_DAO_MIN_LEN
;
758 if(RPL_DAO_D(dao
->rpl_flags
)) {
759 ND_TCHECK2(dao
->rpl_dagid
, DAGID_LEN
);
760 if (length
< DAGID_LEN
)
762 rpl_format_dagid(dagid_str
, dao
->rpl_dagid
);
767 ND_PRINT((ndo
, " [dagid:%s,seq:%u,instance:%u%s%s,%02x]",
771 RPL_DAO_K(dao
->rpl_flags
) ? ",acK":"",
772 RPL_DAO_D(dao
->rpl_flags
) ? ",Dagid":"",
775 if(ndo
->ndo_vflag
> 1) {
776 const struct rpl_dio_genoption
*opt
= (struct rpl_dio_genoption
*)bp
;
777 rpl_dio_printopt(ndo
, opt
, length
);
782 ND_PRINT((ndo
," [|truncated]"));
786 ND_PRINT((ndo
," [|length too short]"));
791 rpl_daoack_print(netdissect_options
*ndo
,
792 const u_char
*bp
, u_int length
)
794 const struct nd_rpl_daoack
*daoack
= (struct nd_rpl_daoack
*)bp
;
797 ND_TCHECK2(*daoack
, ND_RPL_DAOACK_MIN_LEN
);
798 if (length
< ND_RPL_DAOACK_MIN_LEN
)
801 strcpy(dagid_str
,"<elided>");
802 bp
+= ND_RPL_DAOACK_MIN_LEN
;
803 length
-= ND_RPL_DAOACK_MIN_LEN
;
804 if(RPL_DAOACK_D(daoack
->rpl_flags
)) {
805 ND_TCHECK2(daoack
->rpl_dagid
, 16);
806 if (length
< DAGID_LEN
)
808 rpl_format_dagid(dagid_str
, daoack
->rpl_dagid
);
813 ND_PRINT((ndo
, " [dagid:%s,seq:%u,instance:%u,status:%u]",
816 daoack
->rpl_instanceid
,
817 daoack
->rpl_status
));
819 /* no officially defined options for DAOACK, but print any we find */
820 if(ndo
->ndo_vflag
> 1) {
821 const struct rpl_dio_genoption
*opt
= (struct rpl_dio_genoption
*)bp
;
822 rpl_dio_printopt(ndo
, opt
, length
);
827 ND_PRINT((ndo
," [|dao-truncated]"));
831 ND_PRINT((ndo
," [|dao-length too short]"));
836 rpl_print(netdissect_options
*ndo
,
837 const struct icmp6_hdr
*hdr
,
838 const u_char
*bp
, u_int length
)
840 int secured
= hdr
->icmp6_code
& 0x80;
841 int basecode
= hdr
->icmp6_code
& 0x7f;
844 ND_PRINT((ndo
, ", (SEC) [worktodo]"));
846 * the next header pointer needs to move forward to
847 * skip the secure part.
851 ND_PRINT((ndo
, ", (CLR)"));
856 ND_PRINT((ndo
, "DODAG Information Solicitation"));
861 ND_PRINT((ndo
, "DODAG Information Object"));
863 rpl_dio_print(ndo
, bp
, length
);
867 ND_PRINT((ndo
, "Destination Advertisement Object"));
869 rpl_dao_print(ndo
, bp
, length
);
873 ND_PRINT((ndo
, "Destination Advertisement Object Ack"));
875 rpl_daoack_print(ndo
, bp
, length
);
879 ND_PRINT((ndo
, "RPL message, unknown code %u",hdr
->icmp6_code
));
886 ND_PRINT((ndo
," [|truncated]"));
894 icmp6_print(netdissect_options
*ndo
,
895 const u_char
*bp
, u_int length
, const u_char
*bp2
, int fragmented
)
897 const struct icmp6_hdr
*dp
;
898 const struct ip6_hdr
*ip
;
899 const struct ip6_hdr
*oip
;
900 const struct udphdr
*ouh
;
905 dp
= (struct icmp6_hdr
*)bp
;
906 ip
= (struct ip6_hdr
*)bp2
;
907 oip
= (struct ip6_hdr
*)(dp
+ 1);
908 /* 'ep' points to the end of available data. */
909 ep
= ndo
->ndo_snapend
;
911 ND_TCHECK(dp
->icmp6_cksum
);
913 if (ndo
->ndo_vflag
&& !fragmented
) {
914 uint16_t sum
, udp_sum
;
916 if (ND_TTEST2(bp
[0], length
)) {
917 udp_sum
= EXTRACT_16BITS(&dp
->icmp6_cksum
);
918 sum
= icmp6_cksum(ip
, dp
, length
);
920 ND_PRINT((ndo
,"[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
922 in_cksum_shouldbe(udp_sum
, sum
)));
924 ND_PRINT((ndo
,"[icmp6 sum ok] "));
928 ND_PRINT((ndo
,"ICMP6, %s", tok2str(icmp6_type_values
,"unknown icmp6 type (%u)",dp
->icmp6_type
)));
930 /* display cosmetics: print the packet length for printer that use the vflag now */
932 switch (dp
->icmp6_type
) {
933 case ND_ROUTER_SOLICIT
:
934 case ND_ROUTER_ADVERT
:
935 case ND_NEIGHBOR_ADVERT
:
936 case ND_NEIGHBOR_SOLICIT
:
938 case ICMP6_HADISCOV_REPLY
:
939 case ICMP6_MOBILEPREFIX_ADVERT
:
940 ND_PRINT((ndo
, ", length %u", length
));
946 switch (dp
->icmp6_type
) {
947 case ICMP6_DST_UNREACH
:
948 ND_TCHECK(oip
->ip6_dst
);
949 ND_PRINT((ndo
,", %s", tok2str(icmp6_dst_unreach_code_values
,"unknown unreach code (%u)",dp
->icmp6_code
)));
950 switch (dp
->icmp6_code
) {
952 case ICMP6_DST_UNREACH_NOROUTE
: /* fall through */
953 case ICMP6_DST_UNREACH_ADMIN
:
954 case ICMP6_DST_UNREACH_ADDR
:
955 ND_PRINT((ndo
," %s",ip6addr_string(ndo
, &oip
->ip6_dst
)));
957 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
958 ND_PRINT((ndo
," %s, source address %s",
959 ip6addr_string(ndo
, &oip
->ip6_dst
),
960 ip6addr_string(ndo
, &oip
->ip6_src
)));
962 case ICMP6_DST_UNREACH_NOPORT
:
963 if ((ouh
= get_upperlayer(ndo
, (u_char
*)oip
, &prot
))
967 dport
= EXTRACT_16BITS(&ouh
->uh_dport
);
970 ND_PRINT((ndo
,", %s tcp port %s",
971 ip6addr_string(ndo
, &oip
->ip6_dst
),
972 tcpport_string(dport
)));
975 ND_PRINT((ndo
,", %s udp port %s",
976 ip6addr_string(ndo
, &oip
->ip6_dst
),
977 udpport_string(dport
)));
980 ND_PRINT((ndo
,", %s protocol %d port %d unreachable",
981 ip6addr_string(ndo
, &oip
->ip6_dst
),
982 oip
->ip6_nxt
, dport
));
987 if (ndo
->ndo_vflag
<= 1) {
988 print_unknown_data(ndo
, bp
,"\n\t",length
);
994 case ICMP6_PACKET_TOO_BIG
:
995 ND_TCHECK(dp
->icmp6_mtu
);
996 ND_PRINT((ndo
,", mtu %u", EXTRACT_32BITS(&dp
->icmp6_mtu
)));
998 case ICMP6_TIME_EXCEEDED
:
999 ND_TCHECK(oip
->ip6_dst
);
1000 switch (dp
->icmp6_code
) {
1001 case ICMP6_TIME_EXCEED_TRANSIT
:
1002 ND_PRINT((ndo
," for %s",
1003 ip6addr_string(ndo
, &oip
->ip6_dst
)));
1005 case ICMP6_TIME_EXCEED_REASSEMBLY
:
1006 ND_PRINT((ndo
," (reassembly)"));
1009 ND_PRINT((ndo
,", unknown code (%u)", dp
->icmp6_code
));
1013 case ICMP6_PARAM_PROB
:
1014 ND_TCHECK(oip
->ip6_dst
);
1015 switch (dp
->icmp6_code
) {
1016 case ICMP6_PARAMPROB_HEADER
:
1017 ND_PRINT((ndo
,", erroneous - octet %u", EXTRACT_32BITS(&dp
->icmp6_pptr
)));
1019 case ICMP6_PARAMPROB_NEXTHEADER
:
1020 ND_PRINT((ndo
,", next header - octet %u", EXTRACT_32BITS(&dp
->icmp6_pptr
)));
1022 case ICMP6_PARAMPROB_OPTION
:
1023 ND_PRINT((ndo
,", option - octet %u", EXTRACT_32BITS(&dp
->icmp6_pptr
)));
1026 ND_PRINT((ndo
,", code-#%d",
1031 case ICMP6_ECHO_REQUEST
:
1032 case ICMP6_ECHO_REPLY
:
1033 ND_TCHECK(dp
->icmp6_seq
);
1034 ND_PRINT((ndo
,", seq %u", EXTRACT_16BITS(&dp
->icmp6_seq
)));
1036 case ICMP6_MEMBERSHIP_QUERY
:
1037 if (length
== MLD_MINLEN
) {
1038 mld6_print(ndo
, (const u_char
*)dp
);
1039 } else if (length
>= MLDV2_MINLEN
) {
1040 ND_PRINT((ndo
," v2"));
1041 mldv2_query_print(ndo
, (const u_char
*)dp
, length
);
1043 ND_PRINT((ndo
," unknown-version (len %u) ", length
));
1046 case ICMP6_MEMBERSHIP_REPORT
:
1047 mld6_print(ndo
, (const u_char
*)dp
);
1049 case ICMP6_MEMBERSHIP_REDUCTION
:
1050 mld6_print(ndo
, (const u_char
*)dp
);
1052 case ND_ROUTER_SOLICIT
:
1054 if (ndo
->ndo_vflag
) {
1055 icmp6_opt_print(ndo
, (const u_char
*)dp
+ RTSOLLEN
,
1059 case ND_ROUTER_ADVERT
:
1061 if (ndo
->ndo_vflag
) {
1062 struct nd_router_advert
*p
;
1064 p
= (struct nd_router_advert
*)dp
;
1065 ND_TCHECK(p
->nd_ra_retransmit
);
1066 ND_PRINT((ndo
,"\n\thop limit %u, Flags [%s]" \
1067 ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
1068 (u_int
)p
->nd_ra_curhoplimit
,
1069 bittok2str(icmp6_opt_ra_flag_values
,"none",(p
->nd_ra_flags_reserved
)),
1070 get_rtpref(p
->nd_ra_flags_reserved
),
1071 EXTRACT_16BITS(&p
->nd_ra_router_lifetime
),
1072 EXTRACT_32BITS(&p
->nd_ra_reachable
),
1073 EXTRACT_32BITS(&p
->nd_ra_retransmit
)));
1075 icmp6_opt_print(ndo
, (const u_char
*)dp
+ RTADVLEN
,
1079 case ND_NEIGHBOR_SOLICIT
:
1081 struct nd_neighbor_solicit
*p
;
1082 p
= (struct nd_neighbor_solicit
*)dp
;
1083 ND_TCHECK(p
->nd_ns_target
);
1084 ND_PRINT((ndo
,", who has %s", ip6addr_string(ndo
, &p
->nd_ns_target
)));
1085 if (ndo
->ndo_vflag
) {
1087 icmp6_opt_print(ndo
, (const u_char
*)dp
+ NDSOLLEN
,
1092 case ND_NEIGHBOR_ADVERT
:
1094 struct nd_neighbor_advert
*p
;
1096 p
= (struct nd_neighbor_advert
*)dp
;
1097 ND_TCHECK(p
->nd_na_target
);
1098 ND_PRINT((ndo
,", tgt is %s",
1099 ip6addr_string(ndo
, &p
->nd_na_target
)));
1100 if (ndo
->ndo_vflag
) {
1101 ND_PRINT((ndo
,", Flags [%s]",
1102 bittok2str(icmp6_nd_na_flag_values
,
1104 EXTRACT_32BITS(&p
->nd_na_flags_reserved
))));
1106 icmp6_opt_print(ndo
, (const u_char
*)dp
+ NDADVLEN
,
1113 #define RDR(i) ((struct nd_redirect *)(i))
1114 ND_TCHECK(RDR(dp
)->nd_rd_dst
);
1115 ND_PRINT((ndo
,", %s", getname6(ndo
, (const u_char
*)&RDR(dp
)->nd_rd_dst
)));
1116 ND_TCHECK(RDR(dp
)->nd_rd_target
);
1117 ND_PRINT((ndo
," to %s",
1118 getname6(ndo
, (const u_char
*)&RDR(dp
)->nd_rd_target
)));
1119 #define REDIRECTLEN 40
1120 if (ndo
->ndo_vflag
) {
1121 icmp6_opt_print(ndo
, (const u_char
*)dp
+ REDIRECTLEN
,
1122 length
- REDIRECTLEN
);
1127 case ICMP6_ROUTER_RENUMBERING
:
1128 icmp6_rrenum_print(ndo
, bp
, ep
);
1130 case ICMP6_NI_QUERY
:
1131 case ICMP6_NI_REPLY
:
1132 icmp6_nodeinfo_print(ndo
, length
, bp
, ep
);
1137 case ICMP6_V2_MEMBERSHIP_REPORT
:
1138 mldv2_report_print(ndo
, (const u_char
*) dp
, length
);
1140 case ICMP6_MOBILEPREFIX_SOLICIT
: /* fall through */
1141 case ICMP6_HADISCOV_REQUEST
:
1142 ND_TCHECK(dp
->icmp6_data16
[0]);
1143 ND_PRINT((ndo
,", id 0x%04x", EXTRACT_16BITS(&dp
->icmp6_data16
[0])));
1145 case ICMP6_HADISCOV_REPLY
:
1146 if (ndo
->ndo_vflag
) {
1147 struct in6_addr
*in6
;
1150 ND_TCHECK(dp
->icmp6_data16
[0]);
1151 ND_PRINT((ndo
,", id 0x%04x", EXTRACT_16BITS(&dp
->icmp6_data16
[0])));
1152 cp
= (u_char
*)dp
+ length
;
1153 in6
= (struct in6_addr
*)(dp
+ 1);
1154 for (; (u_char
*)in6
< cp
; in6
++) {
1156 ND_PRINT((ndo
,", %s", ip6addr_string(ndo
, in6
)));
1160 case ICMP6_MOBILEPREFIX_ADVERT
:
1161 if (ndo
->ndo_vflag
) {
1162 ND_TCHECK(dp
->icmp6_data16
[0]);
1163 ND_PRINT((ndo
,", id 0x%04x", EXTRACT_16BITS(&dp
->icmp6_data16
[0])));
1164 if (dp
->icmp6_data16
[1] & 0xc0)
1165 ND_PRINT((ndo
," "));
1166 if (dp
->icmp6_data16
[1] & 0x80)
1167 ND_PRINT((ndo
,"M"));
1168 if (dp
->icmp6_data16
[1] & 0x40)
1169 ND_PRINT((ndo
,"O"));
1171 icmp6_opt_print(ndo
, (const u_char
*)dp
+ MPADVLEN
,
1175 case ND_RPL_MESSAGE
:
1176 /* plus 4, because struct icmp6_hdr contains 4 bytes of icmp payload */
1177 rpl_print(ndo
, dp
, &dp
->icmp6_data8
[0], length
-sizeof(struct icmp6_hdr
)+4);
1180 ND_PRINT((ndo
,", length %u", length
));
1181 if (ndo
->ndo_vflag
<= 1)
1182 print_unknown_data(ndo
, bp
,"\n\t", length
);
1185 if (!ndo
->ndo_vflag
)
1186 ND_PRINT((ndo
,", length %u", length
));
1189 ND_PRINT((ndo
, "[|icmp6]"));
1192 static const struct udphdr
*
1193 get_upperlayer(netdissect_options
*ndo
, const u_char
*bp
, u_int
*prot
)
1196 const struct ip6_hdr
*ip6
= (struct ip6_hdr
*)bp
;
1197 const struct udphdr
*uh
;
1198 const struct ip6_hbh
*hbh
;
1199 const struct ip6_frag
*fragh
;
1200 const struct ah
*ah
;
1204 /* 'ep' points to the end of available data. */
1205 ep
= ndo
->ndo_snapend
;
1207 if (!ND_TTEST(ip6
->ip6_nxt
))
1211 hlen
= sizeof(struct ip6_hdr
);
1219 uh
= (struct udphdr
*)bp
;
1220 if (ND_TTEST(uh
->uh_dport
)) {
1228 case IPPROTO_HOPOPTS
:
1229 case IPPROTO_DSTOPTS
:
1230 case IPPROTO_ROUTING
:
1231 hbh
= (struct ip6_hbh
*)bp
;
1232 if (!ND_TTEST(hbh
->ip6h_len
))
1235 hlen
= (hbh
->ip6h_len
+ 1) << 3;
1238 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
1239 fragh
= (struct ip6_frag
*)bp
;
1240 if (!ND_TTEST(fragh
->ip6f_offlg
))
1242 /* fragments with non-zero offset are meaningless */
1243 if ((EXTRACT_16BITS(&fragh
->ip6f_offlg
) & IP6F_OFF_MASK
) != 0)
1245 nh
= fragh
->ip6f_nxt
;
1246 hlen
= sizeof(struct ip6_frag
);
1250 ah
= (struct ah
*)bp
;
1251 if (!ND_TTEST(ah
->ah_len
))
1254 hlen
= (ah
->ah_len
+ 2) << 2;
1257 default: /* unknown or undecodable header */
1258 *prot
= nh
; /* meaningless, but set here anyway */
1263 return(NULL
); /* should be notreached, though */
1267 icmp6_opt_print(netdissect_options
*ndo
, const u_char
*bp
, int resid
)
1269 const struct nd_opt_hdr
*op
;
1270 const struct nd_opt_prefix_info
*opp
;
1271 const struct nd_opt_mtu
*opm
;
1272 const struct nd_opt_rdnss
*oprd
;
1273 const struct nd_opt_dnssl
*opds
;
1274 const struct nd_opt_advinterval
*opa
;
1275 const struct nd_opt_homeagent_info
*oph
;
1276 const struct nd_opt_route_info
*opri
;
1277 const u_char
*cp
, *ep
, *domp
;
1278 struct in6_addr in6
, *in6p
;
1282 #define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
1285 /* 'ep' points to the end of available data. */
1286 ep
= ndo
->ndo_snapend
;
1289 op
= (struct nd_opt_hdr
*)cp
;
1291 ECHECK(op
->nd_opt_len
);
1294 if (op
->nd_opt_len
== 0)
1296 if (cp
+ (op
->nd_opt_len
<< 3) > ep
)
1299 ND_PRINT((ndo
,"\n\t %s option (%u), length %u (%u): ",
1300 tok2str(icmp6_opt_values
, "unknown", op
->nd_opt_type
),
1302 op
->nd_opt_len
<< 3,
1305 switch (op
->nd_opt_type
) {
1306 case ND_OPT_SOURCE_LINKADDR
:
1307 l
= (op
->nd_opt_len
<< 3) - 2;
1308 print_lladdr(ndo
, cp
+ 2, l
);
1310 case ND_OPT_TARGET_LINKADDR
:
1311 l
= (op
->nd_opt_len
<< 3) - 2;
1312 print_lladdr(ndo
, cp
+ 2, l
);
1314 case ND_OPT_PREFIX_INFORMATION
:
1315 opp
= (struct nd_opt_prefix_info
*)op
;
1316 ND_TCHECK(opp
->nd_opt_pi_prefix
);
1317 ND_PRINT((ndo
,"%s/%u%s, Flags [%s], valid time %s",
1318 ip6addr_string(ndo
, &opp
->nd_opt_pi_prefix
),
1319 opp
->nd_opt_pi_prefix_len
,
1320 (op
->nd_opt_len
!= 4) ? "badlen" : "",
1321 bittok2str(icmp6_opt_pi_flag_values
, "none", opp
->nd_opt_pi_flags_reserved
),
1322 get_lifetime(EXTRACT_32BITS(&opp
->nd_opt_pi_valid_time
))));
1323 ND_PRINT((ndo
,", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp
->nd_opt_pi_preferred_time
))));
1325 case ND_OPT_REDIRECTED_HEADER
:
1326 print_unknown_data(ndo
, bp
,"\n\t ",op
->nd_opt_len
<<3);
1330 opm
= (struct nd_opt_mtu
*)op
;
1331 ND_TCHECK(opm
->nd_opt_mtu_mtu
);
1332 ND_PRINT((ndo
," %u%s",
1333 EXTRACT_32BITS(&opm
->nd_opt_mtu_mtu
),
1334 (op
->nd_opt_len
!= 1) ? "bad option length" : "" ));
1337 oprd
= (struct nd_opt_rdnss
*)op
;
1338 l
= (op
->nd_opt_len
- 1) / 2;
1339 ND_PRINT((ndo
," lifetime %us,",
1340 EXTRACT_32BITS(&oprd
->nd_opt_rdnss_lifetime
)));
1341 for (i
= 0; i
< l
; i
++) {
1342 ND_TCHECK(oprd
->nd_opt_rdnss_addr
[i
]);
1343 ND_PRINT((ndo
," addr: %s",
1344 ip6addr_string(ndo
, &oprd
->nd_opt_rdnss_addr
[i
])));
1348 opds
= (struct nd_opt_dnssl
*)op
;
1349 ND_PRINT((ndo
," lifetime %us, domain(s):",
1350 EXTRACT_32BITS(&opds
->nd_opt_dnssl_lifetime
)));
1351 domp
= cp
+ 8; /* domain names, variable-sized, RFC1035-encoded */
1352 while (domp
< cp
+ (op
->nd_opt_len
<< 3) && *domp
!= '\0')
1354 ND_PRINT((ndo
, " "));
1355 if ((domp
= ns_nprint (ndo
, domp
, bp
)) == NULL
)
1359 case ND_OPT_ADVINTERVAL
:
1360 opa
= (struct nd_opt_advinterval
*)op
;
1361 ND_TCHECK(opa
->nd_opt_adv_interval
);
1362 ND_PRINT((ndo
," %ums", EXTRACT_32BITS(&opa
->nd_opt_adv_interval
)));
1364 case ND_OPT_HOMEAGENT_INFO
:
1365 oph
= (struct nd_opt_homeagent_info
*)op
;
1366 ND_TCHECK(oph
->nd_opt_hai_lifetime
);
1367 ND_PRINT((ndo
," preference %u, lifetime %u",
1368 EXTRACT_16BITS(&oph
->nd_opt_hai_preference
),
1369 EXTRACT_16BITS(&oph
->nd_opt_hai_lifetime
)));
1371 case ND_OPT_ROUTE_INFO
:
1372 opri
= (struct nd_opt_route_info
*)op
;
1373 ND_TCHECK(opri
->nd_opt_rti_lifetime
);
1374 memset(&in6
, 0, sizeof(in6
));
1375 in6p
= (struct in6_addr
*)(opri
+ 1);
1376 switch (op
->nd_opt_len
) {
1380 ND_TCHECK2(*in6p
, 8);
1381 memcpy(&in6
, opri
+ 1, 8);
1385 memcpy(&in6
, opri
+ 1, sizeof(in6
));
1390 ND_PRINT((ndo
," %s/%u", ip6addr_string(ndo
, &in6
),
1391 opri
->nd_opt_rti_prefixlen
));
1392 ND_PRINT((ndo
,", pref=%s", get_rtpref(opri
->nd_opt_rti_flags
)));
1393 ND_PRINT((ndo
,", lifetime=%s",
1394 get_lifetime(EXTRACT_32BITS(&opri
->nd_opt_rti_lifetime
))));
1397 if (ndo
->ndo_vflag
<= 1) {
1398 print_unknown_data(ndo
,cp
+2,"\n\t ", (op
->nd_opt_len
<< 3) - 2); /* skip option header */
1403 /* do we want to see an additional hexdump ? */
1404 if (ndo
->ndo_vflag
> 1)
1405 print_unknown_data(ndo
, cp
+2,"\n\t ", (op
->nd_opt_len
<< 3) - 2); /* skip option header */
1407 cp
+= op
->nd_opt_len
<< 3;
1408 resid
-= op
->nd_opt_len
<< 3;
1413 ND_PRINT((ndo
, "[ndp opt]"));
1419 mld6_print(netdissect_options
*ndo
, const u_char
*bp
)
1421 const struct mld6_hdr
*mp
= (struct mld6_hdr
*)bp
;
1424 /* 'ep' points to the end of available data. */
1425 ep
= ndo
->ndo_snapend
;
1427 if ((u_char
*)mp
+ sizeof(*mp
) > ep
)
1430 ND_PRINT((ndo
,"max resp delay: %d ", EXTRACT_16BITS(&mp
->mld6_maxdelay
)));
1431 ND_PRINT((ndo
,"addr: %s", ip6addr_string(ndo
, &mp
->mld6_addr
)));
1435 mldv2_report_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len
)
1437 struct icmp6_hdr
*icp
= (struct icmp6_hdr
*) bp
;
1438 u_int group
, nsrcs
, ngroups
;
1441 /* Minimum len is 8 */
1443 ND_PRINT((ndo
," [invalid len %d]", len
));
1447 ND_TCHECK(icp
->icmp6_data16
[1]);
1448 ngroups
= EXTRACT_16BITS(&icp
->icmp6_data16
[1]);
1449 ND_PRINT((ndo
,", %d group record(s)", ngroups
));
1450 if (ndo
->ndo_vflag
> 0) {
1451 /* Print the group records */
1453 for (i
= 0; i
< ngroups
; i
++) {
1454 /* type(1) + auxlen(1) + numsrc(2) + grp(16) */
1455 if (len
< group
+ 20) {
1456 ND_PRINT((ndo
," [invalid number of groups]"));
1459 ND_TCHECK2(bp
[group
+ 4], sizeof(struct in6_addr
));
1460 ND_PRINT((ndo
," [gaddr %s", ip6addr_string(ndo
, &bp
[group
+ 4])));
1461 ND_PRINT((ndo
," %s", tok2str(mldv2report2str
, " [v2-report-#%d]",
1463 nsrcs
= (bp
[group
+ 2] << 8) + bp
[group
+ 3];
1464 /* Check the number of sources and print them */
1465 if (len
< group
+ 20 + (nsrcs
* sizeof(struct in6_addr
))) {
1466 ND_PRINT((ndo
," [invalid number of sources %d]", nsrcs
));
1469 if (ndo
->ndo_vflag
== 1)
1470 ND_PRINT((ndo
,", %d source(s)", nsrcs
));
1472 /* Print the sources */
1473 ND_PRINT((ndo
," {"));
1474 for (j
= 0; j
< nsrcs
; j
++) {
1475 ND_TCHECK2(bp
[group
+ 20 + j
* sizeof(struct in6_addr
)],
1476 sizeof(struct in6_addr
));
1477 ND_PRINT((ndo
," %s", ip6addr_string(ndo
, &bp
[group
+ 20 + j
* sizeof(struct in6_addr
)])));
1479 ND_PRINT((ndo
," }"));
1481 /* Next group record */
1482 group
+= 20 + nsrcs
* sizeof(struct in6_addr
);
1483 ND_PRINT((ndo
,"]"));
1488 ND_PRINT((ndo
,"[|icmp6]"));
1493 mldv2_query_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len
)
1495 struct icmp6_hdr
*icp
= (struct icmp6_hdr
*) bp
;
1501 /* Minimum len is 28 */
1503 ND_PRINT((ndo
," [invalid len %d]", len
));
1506 ND_TCHECK(icp
->icmp6_data16
[0]);
1507 mrc
= EXTRACT_16BITS(&icp
->icmp6_data16
[0]);
1511 mrt
= ((mrc
& 0x0fff) | 0x1000) << (((mrc
& 0x7000) >> 12) + 3);
1513 if (ndo
->ndo_vflag
) {
1514 ND_PRINT((ndo
," [max resp delay=%d]", mrt
));
1516 ND_TCHECK2(bp
[8], sizeof(struct in6_addr
));
1517 ND_PRINT((ndo
," [gaddr %s", ip6addr_string(ndo
, &bp
[8])));
1519 if (ndo
->ndo_vflag
) {
1521 if (bp
[24] & 0x08) {
1522 ND_PRINT((ndo
," sflag"));
1524 if (bp
[24] & 0x07) {
1525 ND_PRINT((ndo
," robustness=%d", bp
[24] & 0x07));
1530 qqi
= ((bp
[25] & 0x0f) | 0x10) << (((bp
[25] & 0x70) >> 4) + 3);
1532 ND_PRINT((ndo
," qqi=%d", qqi
));
1535 ND_TCHECK2(bp
[26], 2);
1536 nsrcs
= EXTRACT_16BITS(&bp
[26]);
1538 if (len
< 28 + nsrcs
* sizeof(struct in6_addr
))
1539 ND_PRINT((ndo
," [invalid number of sources]"));
1540 else if (ndo
->ndo_vflag
> 1) {
1541 ND_PRINT((ndo
," {"));
1542 for (i
= 0; i
< nsrcs
; i
++) {
1543 ND_TCHECK2(bp
[28 + i
* sizeof(struct in6_addr
)],
1544 sizeof(struct in6_addr
));
1545 ND_PRINT((ndo
," %s", ip6addr_string(ndo
, &bp
[28 + i
* sizeof(struct in6_addr
)])));
1547 ND_PRINT((ndo
," }"));
1549 ND_PRINT((ndo
,", %d source(s)", nsrcs
));
1551 ND_PRINT((ndo
,"]"));
1554 ND_PRINT((ndo
,"[|icmp6]"));
1559 dnsname_print(netdissect_options
*ndo
, const u_char
*cp
, const u_char
*ep
)
1563 /* DNS name decoding - no decompression */
1564 ND_PRINT((ndo
,", \""));
1569 ND_PRINT((ndo
,"???"));
1572 while (i
-- && cp
< ep
) {
1573 safeputchar(ndo
, *cp
);
1576 if (cp
+ 1 < ep
&& *cp
)
1577 ND_PRINT((ndo
,"."));
1581 ND_PRINT((ndo
,"."));
1582 } else if (cp
+ 1 == ep
&& *cp
== '\0') {
1586 ND_PRINT((ndo
,"???"));
1591 ND_PRINT((ndo
,"\""));
1595 icmp6_nodeinfo_print(netdissect_options
*ndo
, u_int icmp6len
, const u_char
*bp
, const u_char
*ep
)
1597 const struct icmp6_nodeinfo
*ni6
;
1598 const struct icmp6_hdr
*dp
;
1605 dp
= (struct icmp6_hdr
*)bp
;
1606 ni6
= (struct icmp6_nodeinfo
*)bp
;
1609 switch (ni6
->ni_type
) {
1610 case ICMP6_NI_QUERY
:
1611 if (siz
== sizeof(*dp
) + 4) {
1612 /* KAME who-are-you */
1613 ND_PRINT((ndo
," who-are-you request"));
1616 ND_PRINT((ndo
," node information query"));
1618 ND_TCHECK2(*dp
, sizeof(*ni6
));
1619 ni6
= (struct icmp6_nodeinfo
*)dp
;
1620 ND_PRINT((ndo
," (")); /*)*/
1621 switch (EXTRACT_16BITS(&ni6
->ni_qtype
)) {
1623 ND_PRINT((ndo
,"noop"));
1625 case NI_QTYPE_SUPTYPES
:
1626 ND_PRINT((ndo
,"supported qtypes"));
1627 i
= EXTRACT_16BITS(&ni6
->ni_flags
);
1629 ND_PRINT((ndo
," [%s]", (i
& 0x01) ? "C" : ""));
1632 ND_PRINT((ndo
,"DNS name"));
1634 case NI_QTYPE_NODEADDR
:
1635 ND_PRINT((ndo
,"node addresses"));
1639 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
1640 ND_PRINT((ndo
," [%s%s%s%s%s%s]",
1641 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
1642 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
1643 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
1644 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
1645 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
1646 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : ""));
1649 ND_PRINT((ndo
,"unknown"));
1653 if (ni6
->ni_qtype
== NI_QTYPE_NOOP
||
1654 ni6
->ni_qtype
== NI_QTYPE_SUPTYPES
) {
1655 if (siz
!= sizeof(*ni6
))
1657 ND_PRINT((ndo
,", invalid len"));
1659 ND_PRINT((ndo
,")"));
1664 /* XXX backward compat, icmp-name-lookup-03 */
1665 if (siz
== sizeof(*ni6
)) {
1666 ND_PRINT((ndo
,", 03 draft"));
1668 ND_PRINT((ndo
,")"));
1672 switch (ni6
->ni_code
) {
1673 case ICMP6_NI_SUBJ_IPV6
:
1675 sizeof(*ni6
) + sizeof(struct in6_addr
)))
1677 if (siz
!= sizeof(*ni6
) + sizeof(struct in6_addr
)) {
1679 ND_PRINT((ndo
,", invalid subject len"));
1682 ND_PRINT((ndo
,", subject=%s",
1683 getname6(ndo
, (const u_char
*)(ni6
+ 1))));
1685 case ICMP6_NI_SUBJ_FQDN
:
1686 ND_PRINT((ndo
,", subject=DNS name"));
1687 cp
= (const u_char
*)(ni6
+ 1);
1688 if (cp
[0] == ep
- cp
- 1) {
1689 /* icmp-name-lookup-03, pascal string */
1691 ND_PRINT((ndo
,", 03 draft"));
1693 ND_PRINT((ndo
,", \""));
1695 safeputchar(ndo
, *cp
);
1698 ND_PRINT((ndo
,"\""));
1700 dnsname_print(ndo
, cp
, ep
);
1702 case ICMP6_NI_SUBJ_IPV4
:
1703 if (!ND_TTEST2(*dp
, sizeof(*ni6
) + sizeof(struct in_addr
)))
1705 if (siz
!= sizeof(*ni6
) + sizeof(struct in_addr
)) {
1707 ND_PRINT((ndo
,", invalid subject len"));
1710 ND_PRINT((ndo
,", subject=%s",
1711 getname(ndo
, (const u_char
*)(ni6
+ 1))));
1714 ND_PRINT((ndo
,", unknown subject"));
1719 ND_PRINT((ndo
,")"));
1722 case ICMP6_NI_REPLY
:
1723 if (icmp6len
> siz
) {
1724 ND_PRINT((ndo
,"[|icmp6: node information reply]"));
1730 ni6
= (struct icmp6_nodeinfo
*)dp
;
1731 ND_PRINT((ndo
," node information reply"));
1732 ND_PRINT((ndo
," (")); /*)*/
1733 switch (ni6
->ni_code
) {
1734 case ICMP6_NI_SUCCESS
:
1735 if (ndo
->ndo_vflag
) {
1736 ND_PRINT((ndo
,"success"));
1740 case ICMP6_NI_REFUSED
:
1741 ND_PRINT((ndo
,"refused"));
1743 if (siz
!= sizeof(*ni6
))
1745 ND_PRINT((ndo
,", invalid length"));
1747 case ICMP6_NI_UNKNOWN
:
1748 ND_PRINT((ndo
,"unknown"));
1750 if (siz
!= sizeof(*ni6
))
1752 ND_PRINT((ndo
,", invalid length"));
1756 if (ni6
->ni_code
!= ICMP6_NI_SUCCESS
) {
1758 ND_PRINT((ndo
,")"));
1762 switch (EXTRACT_16BITS(&ni6
->ni_qtype
)) {
1765 ND_PRINT((ndo
,", "));
1766 ND_PRINT((ndo
,"noop"));
1767 if (siz
!= sizeof(*ni6
))
1769 ND_PRINT((ndo
,", invalid length"));
1771 case NI_QTYPE_SUPTYPES
:
1773 ND_PRINT((ndo
,", "));
1774 ND_PRINT((ndo
,"supported qtypes"));
1775 i
= EXTRACT_16BITS(&ni6
->ni_flags
);
1777 ND_PRINT((ndo
," [%s]", (i
& 0x01) ? "C" : ""));
1781 ND_PRINT((ndo
,", "));
1782 ND_PRINT((ndo
,"DNS name"));
1783 cp
= (const u_char
*)(ni6
+ 1) + 4;
1784 if (cp
[0] == ep
- cp
- 1) {
1785 /* icmp-name-lookup-03, pascal string */
1787 ND_PRINT((ndo
,", 03 draft"));
1789 ND_PRINT((ndo
,", \""));
1791 safeputchar(ndo
, *cp
);
1794 ND_PRINT((ndo
,"\""));
1796 dnsname_print(ndo
, cp
, ep
);
1797 if ((EXTRACT_16BITS(&ni6
->ni_flags
) & 0x01) != 0)
1798 ND_PRINT((ndo
," [TTL=%u]", *(uint32_t *)(ni6
+ 1)));
1800 case NI_QTYPE_NODEADDR
:
1802 ND_PRINT((ndo
,", "));
1803 ND_PRINT((ndo
,"node addresses"));
1806 if (i
+ sizeof(struct in6_addr
) + sizeof(int32_t) > siz
)
1808 ND_PRINT((ndo
," %s", getname6(ndo
, bp
+ i
)));
1809 i
+= sizeof(struct in6_addr
);
1810 ND_PRINT((ndo
,"(%d)", (int32_t)EXTRACT_32BITS(bp
+ i
)));
1811 i
+= sizeof(int32_t);
1816 ND_PRINT((ndo
," [%s%s%s%s%s%s%s]",
1817 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
1818 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
1819 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
1820 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
1821 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
1822 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
1823 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : ""));
1827 ND_PRINT((ndo
,", "));
1828 ND_PRINT((ndo
,"unknown"));
1833 ND_PRINT((ndo
,")"));
1839 ND_PRINT((ndo
, "[|icmp6]"));
1843 icmp6_rrenum_print(netdissect_options
*ndo
, const u_char
*bp
, const u_char
*ep
)
1845 const struct icmp6_router_renum
*rr6
;
1847 struct rr_pco_match
*match
;
1848 struct rr_pco_use
*use
;
1849 char hbuf
[NI_MAXHOST
];
1854 rr6
= (struct icmp6_router_renum
*)bp
;
1855 cp
= (const char *)(rr6
+ 1);
1857 ND_TCHECK(rr6
->rr_reserved
);
1858 switch (rr6
->rr_code
) {
1859 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
1860 ND_PRINT((ndo
,"router renum: command"));
1862 case ICMP6_ROUTER_RENUMBERING_RESULT
:
1863 ND_PRINT((ndo
,"router renum: result"));
1865 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
1866 ND_PRINT((ndo
,"router renum: sequence number reset"));
1869 ND_PRINT((ndo
,"router renum: code-#%d", rr6
->rr_code
));
1873 ND_PRINT((ndo
,", seq=%u", EXTRACT_32BITS(&rr6
->rr_seqnum
)));
1875 if (ndo
->ndo_vflag
) {
1876 #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
1877 ND_PRINT((ndo
,"[")); /*]*/
1878 if (rr6
->rr_flags
) {
1879 ND_PRINT((ndo
,"%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
1880 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
1881 F(ICMP6_RR_FLAGS_FORCEAPPLY
, "A"),
1882 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
1883 F(ICMP6_RR_FLAGS_PREVDONE
, "P")));
1885 ND_PRINT((ndo
,"seg=%u,", rr6
->rr_segnum
));
1886 ND_PRINT((ndo
,"maxdelay=%u", EXTRACT_16BITS(&rr6
->rr_maxdelay
)));
1887 if (rr6
->rr_reserved
)
1888 ND_PRINT((ndo
,"rsvd=0x%x", EXTRACT_32BITS(&rr6
->rr_reserved
)));
1890 ND_PRINT((ndo
,"]"));
1894 if (rr6
->rr_code
== ICMP6_ROUTER_RENUMBERING_COMMAND
) {
1895 match
= (struct rr_pco_match
*)cp
;
1896 cp
= (const char *)(match
+ 1);
1898 ND_TCHECK(match
->rpm_prefix
);
1900 if (ndo
->ndo_vflag
> 1)
1901 ND_PRINT((ndo
,"\n\t"));
1903 ND_PRINT((ndo
," "));
1904 ND_PRINT((ndo
,"match(")); /*)*/
1905 switch (match
->rpm_code
) {
1906 case RPM_PCO_ADD
: ND_PRINT((ndo
,"add")); break;
1907 case RPM_PCO_CHANGE
: ND_PRINT((ndo
,"change")); break;
1908 case RPM_PCO_SETGLOBAL
: ND_PRINT((ndo
,"setglobal")); break;
1909 default: ND_PRINT((ndo
,"#%u", match
->rpm_code
)); break;
1912 if (ndo
->ndo_vflag
) {
1913 ND_PRINT((ndo
,",ord=%u", match
->rpm_ordinal
));
1914 ND_PRINT((ndo
,",min=%u", match
->rpm_minlen
));
1915 ND_PRINT((ndo
,",max=%u", match
->rpm_maxlen
));
1917 if (inet_ntop(AF_INET6
, &match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
1918 ND_PRINT((ndo
,",%s/%u", hbuf
, match
->rpm_matchlen
));
1920 ND_PRINT((ndo
,",?/%u", match
->rpm_matchlen
));
1922 ND_PRINT((ndo
,")"));
1924 n
= match
->rpm_len
- 3;
1929 use
= (struct rr_pco_use
*)cp
;
1930 cp
= (const char *)(use
+ 1);
1932 ND_TCHECK(use
->rpu_prefix
);
1934 if (ndo
->ndo_vflag
> 1)
1935 ND_PRINT((ndo
,"\n\t"));
1937 ND_PRINT((ndo
," "));
1938 ND_PRINT((ndo
,"use(")); /*)*/
1939 if (use
->rpu_flags
) {
1940 #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
1941 ND_PRINT((ndo
,"%s%s,",
1942 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
1943 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P")));
1946 if (ndo
->ndo_vflag
) {
1947 ND_PRINT((ndo
,"mask=0x%x,", use
->rpu_ramask
));
1948 ND_PRINT((ndo
,"raflags=0x%x,", use
->rpu_raflags
));
1949 if (~use
->rpu_vltime
== 0)
1950 ND_PRINT((ndo
,"vltime=infty,"));
1952 ND_PRINT((ndo
,"vltime=%u,",
1953 EXTRACT_32BITS(&use
->rpu_vltime
)));
1954 if (~use
->rpu_pltime
== 0)
1955 ND_PRINT((ndo
,"pltime=infty,"));
1957 ND_PRINT((ndo
,"pltime=%u,",
1958 EXTRACT_32BITS(&use
->rpu_pltime
)));
1960 if (inet_ntop(AF_INET6
, &use
->rpu_prefix
, hbuf
,
1962 ND_PRINT((ndo
,"%s/%u/%u", hbuf
, use
->rpu_uselen
,
1965 ND_PRINT((ndo
,"?/%u/%u", use
->rpu_uselen
,
1968 ND_PRINT((ndo
,")"));
1975 ND_PRINT((ndo
,"[|icmp6]"));
1982 * c-style: whitesmith