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 /* \summary: IPv6 Internet Control Message Protocol (ICMPv6) printer */
26 #include "netdissect-stdinc.h"
31 #include "netdissect.h"
32 #include "addrtoname.h"
33 #include "addrtostr.h"
42 /* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
43 /* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
46 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
47 * All rights reserved.
49 * Redistribution and use in source and binary forms, with or without
50 * modification, are permitted provided that the following conditions
52 * 1. Redistributions of source code must retain the above copyright
53 * notice, this list of conditions and the following disclaimer.
54 * 2. Redistributions in binary form must reproduce the above copyright
55 * notice, this list of conditions and the following disclaimer in the
56 * documentation and/or other materials provided with the distribution.
57 * 3. Neither the name of the project nor the names of its contributors
58 * may be used to endorse or promote products derived from this software
59 * without specific prior written permission.
61 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
62 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
63 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
64 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
65 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
66 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
67 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
69 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
70 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
75 nd_uint8_t icmp6_type
; /* type field */
76 nd_uint8_t icmp6_code
; /* code field */
77 nd_uint16_t icmp6_cksum
; /* checksum field */
79 nd_uint32_t icmp6_un_data32
[1]; /* type-specific field */
80 nd_uint16_t icmp6_un_data16
[2]; /* type-specific field */
81 nd_uint8_t icmp6_un_data8
[4]; /* type-specific field */
82 nd_byte icmp6_un_data
[1]; /* type-specific field */
86 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
87 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
88 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
89 #define icmp6_data icmp6_dataun.icmp6_un_data
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 MLD6_LISTENER_QUERY 130 /* multicast listener query */
104 #define MLD6_LISTENER_REPORT 131 /* multicast listener report */
105 #define MLD6_LISTENER_DONE 132 /* multicast listener done */
107 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
108 #define ND_ROUTER_ADVERT 134 /* router advertisement */
109 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
110 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
111 #define ND_REDIRECT 137 /* redirect */
113 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
115 #define ICMP6_NI_QUERY 139 /* node information query - RFC 4620 */
116 #define ICMP6_NI_REPLY 140 /* node information reply - RFC 4620 */
117 #define IND_SOLICIT 141 /* inverse neighbor solicitation */
118 #define IND_ADVERT 142 /* inverse neighbor advertisement */
120 #define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */
121 #define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */
122 #define ICMP6_HADISCOV_REQUEST 144
123 #define ICMP6_HADISCOV_REPLY 145
124 #define ICMP6_MOBILEPREFIX_SOLICIT 146
125 #define ICMP6_MOBILEPREFIX_ADVERT 147
127 #define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
128 #define MLD6_MTRACE 201 /* mtrace messages */
130 #define ICMP6_MAXTYPE 201
132 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
133 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
134 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
135 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
136 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
137 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
139 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
140 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
142 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
143 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
144 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
145 #define ICMP6_PARAMPROB_FRAGHDRCHAIN 3 /* incomplete header chain */
147 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
149 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
150 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
151 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
153 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
154 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
155 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
157 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
158 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
159 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
161 /* Used in kernel only */
162 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
163 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
166 * Multicast Listener Discovery
169 struct icmp6_hdr mld6_hdr
;
170 nd_ipv6 mld6_addr
; /* multicast address */
173 #define mld6_type mld6_hdr.icmp6_type
174 #define mld6_code mld6_hdr.icmp6_code
175 #define mld6_cksum mld6_hdr.icmp6_cksum
176 #define mld6_maxdelay mld6_hdr.icmp6_data16[0]
177 #define mld6_reserved mld6_hdr.icmp6_data16[1]
179 #define MLD_MINLEN 24
180 #define MLDV2_MINLEN 28
186 struct nd_router_solicit
{ /* router solicitation */
187 struct icmp6_hdr nd_rs_hdr
;
188 /* could be followed by options */
191 #define nd_rs_type nd_rs_hdr.icmp6_type
192 #define nd_rs_code nd_rs_hdr.icmp6_code
193 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
194 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
196 struct nd_router_advert
{ /* router advertisement */
197 struct icmp6_hdr nd_ra_hdr
;
198 nd_uint32_t nd_ra_reachable
; /* reachable time */
199 nd_uint32_t nd_ra_retransmit
; /* retransmit timer */
200 /* could be followed by options */
203 #define nd_ra_type nd_ra_hdr.icmp6_type
204 #define nd_ra_code nd_ra_hdr.icmp6_code
205 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
206 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
207 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
208 #define ND_RA_FLAG_MANAGED 0x80
209 #define ND_RA_FLAG_OTHER 0x40
210 #define ND_RA_FLAG_HOME_AGENT 0x20
211 #define ND_RA_FLAG_IPV6ONLY 0x02
214 * Router preference values based on draft-draves-ipngwg-router-selection-01.
215 * These are non-standard definitions.
217 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
219 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
220 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
221 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
222 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
224 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
226 struct nd_neighbor_solicit
{ /* neighbor solicitation */
227 struct icmp6_hdr nd_ns_hdr
;
228 nd_ipv6 nd_ns_target
; /*target address */
229 /* could be followed by options */
232 #define nd_ns_type nd_ns_hdr.icmp6_type
233 #define nd_ns_code nd_ns_hdr.icmp6_code
234 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
235 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
237 struct nd_neighbor_advert
{ /* neighbor advertisement */
238 struct icmp6_hdr nd_na_hdr
;
239 nd_ipv6 nd_na_target
; /* target address */
240 /* could be followed by options */
243 #define nd_na_type nd_na_hdr.icmp6_type
244 #define nd_na_code nd_na_hdr.icmp6_code
245 #define nd_na_cksum nd_na_hdr.icmp6_cksum
246 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
248 #define ND_NA_FLAG_ROUTER 0x80000000
249 #define ND_NA_FLAG_SOLICITED 0x40000000
250 #define ND_NA_FLAG_OVERRIDE 0x20000000
252 struct nd_redirect
{ /* redirect */
253 struct icmp6_hdr nd_rd_hdr
;
254 nd_ipv6 nd_rd_target
; /* target address */
255 nd_ipv6 nd_rd_dst
; /* destination address */
256 /* could be followed by options */
259 #define nd_rd_type nd_rd_hdr.icmp6_type
260 #define nd_rd_code nd_rd_hdr.icmp6_code
261 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
262 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
264 struct nd_opt_hdr
{ /* Neighbor discovery option header */
265 nd_uint8_t nd_opt_type
;
266 nd_uint8_t nd_opt_len
;
267 /* followed by option specific data*/
270 #define ND_OPT_SOURCE_LINKADDR 1
271 #define ND_OPT_TARGET_LINKADDR 2
272 #define ND_OPT_PREFIX_INFORMATION 3
273 #define ND_OPT_REDIRECTED_HEADER 4
275 #define ND_OPT_ADVINTERVAL 7
276 #define ND_OPT_HOMEAGENT_INFO 8
277 #define ND_OPT_ROUTE_INFO 24 /* RFC4191 */
278 #define ND_OPT_RDNSS 25
279 #define ND_OPT_DNSSL 31
281 struct nd_opt_prefix_info
{ /* prefix information */
282 nd_uint8_t nd_opt_pi_type
;
283 nd_uint8_t nd_opt_pi_len
;
284 nd_uint8_t nd_opt_pi_prefix_len
;
285 nd_uint8_t nd_opt_pi_flags_reserved
;
286 nd_uint32_t nd_opt_pi_valid_time
;
287 nd_uint32_t nd_opt_pi_preferred_time
;
288 nd_uint32_t nd_opt_pi_reserved2
;
289 nd_ipv6 nd_opt_pi_prefix
;
292 #define ND_OPT_PI_FLAG_ONLINK 0x80
293 #define ND_OPT_PI_FLAG_AUTO 0x40
294 #define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
296 struct nd_opt_rd_hdr
{ /* redirected header */
297 nd_uint8_t nd_opt_rh_type
;
298 nd_uint8_t nd_opt_rh_len
;
299 nd_uint16_t nd_opt_rh_reserved1
;
300 nd_uint32_t nd_opt_rh_reserved2
;
301 /* followed by IP header and data */
304 struct nd_opt_mtu
{ /* MTU option */
305 nd_uint8_t nd_opt_mtu_type
;
306 nd_uint8_t nd_opt_mtu_len
;
307 nd_uint16_t nd_opt_mtu_reserved
;
308 nd_uint32_t nd_opt_mtu_mtu
;
311 struct nd_opt_rdnss
{ /* RDNSS RFC 6106 5.1 */
312 nd_uint8_t nd_opt_rdnss_type
;
313 nd_uint8_t nd_opt_rdnss_len
;
314 nd_uint16_t nd_opt_rdnss_reserved
;
315 nd_uint32_t nd_opt_rdnss_lifetime
;
316 nd_ipv6 nd_opt_rdnss_addr
[1]; /* variable-length */
319 struct nd_opt_dnssl
{ /* DNSSL RFC 6106 5.2 */
320 nd_uint8_t nd_opt_dnssl_type
;
321 nd_uint8_t nd_opt_dnssl_len
;
322 nd_uint16_t nd_opt_dnssl_reserved
;
323 nd_uint32_t nd_opt_dnssl_lifetime
;
324 /* followed by list of DNS search domains, variable-length */
327 struct nd_opt_advinterval
{ /* Advertisement interval option */
328 nd_uint8_t nd_opt_adv_type
;
329 nd_uint8_t nd_opt_adv_len
;
330 nd_uint16_t nd_opt_adv_reserved
;
331 nd_uint32_t nd_opt_adv_interval
;
334 struct nd_opt_homeagent_info
{ /* Home Agent info */
335 nd_uint8_t nd_opt_hai_type
;
336 nd_uint8_t nd_opt_hai_len
;
337 nd_uint16_t nd_opt_hai_reserved
;
338 nd_uint16_t nd_opt_hai_preference
;
339 nd_uint16_t nd_opt_hai_lifetime
;
342 struct nd_opt_route_info
{ /* route info */
343 nd_uint8_t nd_opt_rti_type
;
344 nd_uint8_t nd_opt_rti_len
;
345 nd_uint8_t nd_opt_rti_prefixlen
;
346 nd_uint8_t nd_opt_rti_flags
;
347 nd_uint32_t nd_opt_rti_lifetime
;
355 struct icmp6_namelookup
{
356 struct icmp6_hdr icmp6_nl_hdr
;
357 nd_byte icmp6_nl_nonce
[8];
358 nd_int32_t icmp6_nl_ttl
;
360 nd_uint8_t icmp6_nl_len
;
361 nd_byte icmp6_nl_name
[3];
363 /* could be followed by options */
367 * icmp6 node information
369 struct icmp6_nodeinfo
{
370 struct icmp6_hdr icmp6_ni_hdr
;
371 nd_byte icmp6_ni_nonce
[8];
372 /* could be followed by reply data */
375 #define ni_type icmp6_ni_hdr.icmp6_type
376 #define ni_code icmp6_ni_hdr.icmp6_code
377 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
378 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
379 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
381 #define NI_QTYPE_NOOP 0 /* NOOP */
382 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes (Obsolete) */
383 #define NI_QTYPE_NODENAME 2 /* Node Name */
384 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
385 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
387 #define NI_NODEADDR_FLAG_TRUNCATE 0x0001
388 #define NI_NODEADDR_FLAG_ALL 0x0002
389 #define NI_NODEADDR_FLAG_COMPAT 0x0004
390 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0008
391 #define NI_NODEADDR_FLAG_SITELOCAL 0x0010
392 #define NI_NODEADDR_FLAG_GLOBAL 0x0020
393 #define NI_NODEADDR_FLAG_ANYCAST 0x0040 /* just experimental. not in spec */
395 struct ni_reply_fqdn
{
396 nd_uint32_t ni_fqdn_ttl
; /* TTL */
397 nd_uint8_t ni_fqdn_namelen
; /* length in octets of the FQDN */
398 nd_byte ni_fqdn_name
[3]; /* XXX: alignment */
402 * Router Renumbering. as router-renum-08.txt
404 struct icmp6_router_renum
{ /* router renumbering header */
405 struct icmp6_hdr rr_hdr
;
406 nd_uint8_t rr_segnum
;
408 nd_uint16_t rr_maxdelay
;
409 nd_uint32_t rr_reserved
;
411 #define ICMP6_RR_FLAGS_TEST 0x80
412 #define ICMP6_RR_FLAGS_REQRESULT 0x40
413 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
414 #define ICMP6_RR_FLAGS_SPECSITE 0x10
415 #define ICMP6_RR_FLAGS_PREVDONE 0x08
417 #define rr_type rr_hdr.icmp6_type
418 #define rr_code rr_hdr.icmp6_code
419 #define rr_cksum rr_hdr.icmp6_cksum
420 #define rr_seqnum rr_hdr.icmp6_data32[0]
422 struct rr_pco_match
{ /* match prefix part */
425 nd_uint8_t rpm_ordinal
;
426 nd_uint8_t rpm_matchlen
;
427 nd_uint8_t rpm_minlen
;
428 nd_uint8_t rpm_maxlen
;
429 nd_uint16_t rpm_reserved
;
433 #define RPM_PCO_ADD 1
434 #define RPM_PCO_CHANGE 2
435 #define RPM_PCO_SETGLOBAL 3
436 #define RPM_PCO_MAX 4
438 struct rr_pco_use
{ /* use prefix part */
439 nd_uint8_t rpu_uselen
;
440 nd_uint8_t rpu_keeplen
;
441 nd_uint8_t rpu_ramask
;
442 nd_uint8_t rpu_raflags
;
443 nd_uint32_t rpu_vltime
;
444 nd_uint32_t rpu_pltime
;
445 nd_uint32_t rpu_flags
;
448 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
449 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
452 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((uint32_t)htonl(0x80000000))
453 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((uint32_t)htonl(0x40000000))
455 struct rr_result
{ /* router renumbering result message */
456 nd_uint16_t rrr_flags
;
457 nd_uint8_t rrr_ordinal
;
458 nd_uint8_t rrr_matchedlen
;
459 nd_uint32_t rrr_ifid
;
463 #define ICMP6_RR_RESULT_FLAGS_OOB ((uint16_t)htons(0x0002))
464 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((uint16_t)htons(0x0001))
466 static const char *get_rtpref(u_int
);
467 static const char *get_lifetime(uint32_t);
468 static void print_lladdr(netdissect_options
*ndo
, const u_char
*, size_t);
469 static int icmp6_opt_print(netdissect_options
*ndo
, const u_char
*, int);
470 static void mld6_print(netdissect_options
*ndo
, const u_char
*);
471 static void mldv2_report_print(netdissect_options
*ndo
, const u_char
*, u_int
);
472 static void mldv2_query_print(netdissect_options
*ndo
, const u_char
*, u_int
);
473 static const struct udphdr
*get_upperlayer(netdissect_options
*ndo
, const u_char
*, u_int
*);
474 static void dnsname_print(netdissect_options
*ndo
, const u_char
*, const u_char
*);
475 static void icmp6_nodeinfo_print(netdissect_options
*ndo
, u_int
, const u_char
*, const u_char
*);
476 static void icmp6_rrenum_print(netdissect_options
*ndo
, const u_char
*, const u_char
*);
479 * DIO: Updated to RFC6550, as published in 2012: section 6. (page 30)
482 #define ND_RPL_MESSAGE 155 /* 0x9B */
489 ND_RPL_SEC_DAG_IS
= 0x80,
490 ND_RPL_SEC_DAG_IO
= 0x81,
491 ND_RPL_SEC_DAG
= 0x82,
492 ND_RPL_SEC_DAG_ACK
= 0x83,
493 ND_RPL_SEC_CONSIST
= 0x8A
496 enum ND_RPL_DIO_FLAGS
{
497 ND_RPL_DIO_GROUNDED
= 0x80,
498 ND_RPL_DIO_DATRIG
= 0x40,
499 ND_RPL_DIO_DASUPPORT
= 0x20,
500 ND_RPL_DIO_RES4
= 0x10,
501 ND_RPL_DIO_RES3
= 0x08,
502 ND_RPL_DIO_PRF_MASK
= 0x07 /* 3-bit preference */
507 /* section 6 of draft-ietf-roll-rpl-19 */
508 struct nd_rpl_security
{
509 nd_uint8_t rpl_sec_t_reserved
; /* bit 7 is T-bit */
510 nd_uint8_t rpl_sec_algo
;
511 nd_uint16_t rpl_sec_kim_lvl_flags
; /* bit 15/14, KIM */
512 /* bit 10-8, LVL, bit 7-0 flags */
513 nd_uint32_t rpl_sec_counter
;
515 nd_byte rpl_sec_ki
[0]; /* depends upon kim */
519 /* section 6.2.1, DODAG Information Solicitation (DIS_IS) */
520 struct nd_rpl_dis_is
{
521 nd_uint8_t rpl_dis_flags
;
522 nd_uint8_t rpl_dis_reserved
;
524 nd_byte rpl_dis_options
[0];
528 /* section 6.3.1, DODAG Information Object (DIO) */
530 nd_uint8_t rpl_instanceid
;
531 nd_uint8_t rpl_version
;
532 nd_uint16_t rpl_dagrank
;
533 nd_uint8_t rpl_mopprf
; /* bit 7=G, 5-3=MOP, 2-0=PRF */
534 nd_uint8_t rpl_dtsn
; /* Dest. Advertisement Trigger Sequence Number */
535 nd_uint8_t rpl_flags
; /* no flags defined yet */
536 nd_uint8_t rpl_resv1
;
537 nd_byte rpl_dagid
[DAGID_LEN
];
539 #define RPL_DIO_GROUND_FLAG 0x80
540 #define RPL_DIO_MOP_SHIFT 3
541 #define RPL_DIO_MOP_MASK (7 << RPL_DIO_MOP_SHIFT)
542 #define RPL_DIO_PRF_SHIFT 0
543 #define RPL_DIO_PRF_MASK (7 << RPL_DIO_PRF_SHIFT)
544 #define RPL_DIO_GROUNDED(X) ((X)&RPL_DIO_GROUND_FLAG)
545 #define RPL_DIO_MOP(X) (enum RPL_DIO_MOP)(((X)&RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT)
546 #define RPL_DIO_PRF(X) (((X)&RPL_DIO_PRF_MASK) >> RPL_DIO_PRF_SHIFT)
549 RPL_DIO_NONSTORING
= 0x0,
550 RPL_DIO_STORING
= 0x1,
551 RPL_DIO_NONSTORING_MULTICAST
= 0x2,
552 RPL_DIO_STORING_MULTICAST
= 0x3
559 RPL_DIO_ROUTINGINFO
= 3,
561 RPL_DAO_RPLTARGET
= 5,
562 RPL_DAO_TRANSITINFO
= 6,
563 RPL_DIO_DESTPREFIX
= 8,
564 RPL_DAO_RPLTARGET_DESC
=9
567 struct rpl_genoption
{
568 nd_uint8_t rpl_dio_type
;
569 nd_uint8_t rpl_dio_len
; /* suboption length, not including type/len */
571 #define RPL_GENOPTION_LEN 2
573 #define RPL_DIO_LIFETIME_INFINITE 0xffffffff
574 #define RPL_DIO_LIFETIME_DISCONNECT 0
576 struct rpl_dio_destprefix
{
577 nd_uint8_t rpl_dio_type
;
578 nd_uint8_t rpl_dio_len
;
579 nd_uint8_t rpl_dio_prefixlen
; /* in bits */
580 nd_uint8_t rpl_dio_prf
; /* flags, including Route Preference */
581 nd_uint32_t rpl_dio_prefixlifetime
; /* in seconds */
583 nd_byte rpl_dio_prefix
[0]; /* variable number of bytes */
587 /* section 6.4.1, DODAG Information Object (DIO) */
589 nd_uint8_t rpl_instanceid
;
590 nd_uint8_t rpl_flags
; /* bit 7=K, 6=D */
592 nd_uint8_t rpl_daoseq
;
593 nd_byte rpl_dagid
[DAGID_LEN
]; /* present when D set. */
595 #define ND_RPL_DAO_MIN_LEN 4 /* length without DAGID */
597 /* indicates if this DAO is to be acK'ed */
598 #define RPL_DAO_K_SHIFT 7
599 #define RPL_DAO_K_MASK (1 << RPL_DAO_K_SHIFT)
600 #define RPL_DAO_K(X) (((X)&RPL_DAO_K_MASK) >> RPL_DAO_K_SHIFT)
602 /* indicates if the DAGID is present */
603 #define RPL_DAO_D_SHIFT 6
604 #define RPL_DAO_D_MASK (1 << RPL_DAO_D_SHIFT)
605 #define RPL_DAO_D(X) (((X)&RPL_DAO_D_MASK) >> RPL_DAO_D_SHIFT)
607 struct rpl_dao_target
{
608 nd_uint8_t rpl_dao_type
;
609 nd_uint8_t rpl_dao_len
;
610 nd_uint8_t rpl_dao_flags
; /* unused */
611 nd_uint8_t rpl_dao_prefixlen
; /* in bits */
613 nd_byte rpl_dao_prefix
[0]; /* variable number of bytes */
617 /* section 6.5.1, Destination Advertisement Object Acknowledgement (DAO-ACK) */
618 struct nd_rpl_daoack
{
619 nd_uint8_t rpl_instanceid
;
620 nd_uint8_t rpl_flags
; /* bit 7=D */
621 nd_uint8_t rpl_daoseq
;
622 nd_uint8_t rpl_status
;
623 nd_byte rpl_dagid
[DAGID_LEN
]; /* present when D set. */
625 #define ND_RPL_DAOACK_MIN_LEN 4 /* length without DAGID */
626 /* indicates if the DAGID is present */
627 #define RPL_DAOACK_D_SHIFT 7
628 #define RPL_DAOACK_D_MASK (1 << RPL_DAOACK_D_SHIFT)
629 #define RPL_DAOACK_D(X) (((X)&RPL_DAOACK_D_MASK) >> RPL_DAOACK_D_SHIFT)
631 static const struct tok icmp6_type_values
[] = {
632 { ICMP6_DST_UNREACH
, "destination unreachable"},
633 { ICMP6_PACKET_TOO_BIG
, "packet too big"},
634 { ICMP6_TIME_EXCEEDED
, "time exceeded in-transit"},
635 { ICMP6_PARAM_PROB
, "parameter problem"},
636 { ICMP6_ECHO_REQUEST
, "echo request"},
637 { ICMP6_ECHO_REPLY
, "echo reply"},
638 { MLD6_LISTENER_QUERY
, "multicast listener query"},
639 { MLD6_LISTENER_REPORT
, "multicast listener report"},
640 { MLD6_LISTENER_DONE
, "multicast listener done"},
641 { ND_ROUTER_SOLICIT
, "router solicitation"},
642 { ND_ROUTER_ADVERT
, "router advertisement"},
643 { ND_NEIGHBOR_SOLICIT
, "neighbor solicitation"},
644 { ND_NEIGHBOR_ADVERT
, "neighbor advertisement"},
645 { ND_REDIRECT
, "redirect"},
646 { ICMP6_ROUTER_RENUMBERING
, "router renumbering"},
647 { IND_SOLICIT
, "inverse neighbor solicitation"},
648 { IND_ADVERT
, "inverse neighbor advertisement"},
649 { MLDV2_LISTENER_REPORT
, "multicast listener report v2"},
650 { ICMP6_HADISCOV_REQUEST
, "ha discovery request"},
651 { ICMP6_HADISCOV_REPLY
, "ha discovery reply"},
652 { ICMP6_MOBILEPREFIX_SOLICIT
, "mobile router solicitation"},
653 { ICMP6_MOBILEPREFIX_ADVERT
, "mobile router advertisement"},
654 { ICMP6_NI_QUERY
, "node information query"},
655 { ICMP6_NI_REPLY
, "node information reply"},
656 { MLD6_MTRACE
, "mtrace message"},
657 { MLD6_MTRACE_RESP
, "mtrace response"},
658 { ND_RPL_MESSAGE
, "RPL"},
662 static const struct tok icmp6_dst_unreach_code_values
[] = {
663 { ICMP6_DST_UNREACH_NOROUTE
, "unreachable route" },
664 { ICMP6_DST_UNREACH_ADMIN
, " unreachable prohibited"},
665 { ICMP6_DST_UNREACH_BEYONDSCOPE
, "beyond scope"},
666 { ICMP6_DST_UNREACH_ADDR
, "unreachable address"},
667 { ICMP6_DST_UNREACH_NOPORT
, "unreachable port"},
671 static const struct tok icmp6_opt_pi_flag_values
[] = {
672 { ND_OPT_PI_FLAG_ONLINK
, "onlink" },
673 { ND_OPT_PI_FLAG_AUTO
, "auto" },
674 { ND_OPT_PI_FLAG_ROUTER
, "router" },
678 static const struct tok icmp6_opt_ra_flag_values
[] = {
679 { ND_RA_FLAG_MANAGED
, "managed" },
680 { ND_RA_FLAG_OTHER
, "other stateful"},
681 { ND_RA_FLAG_HOME_AGENT
, "home agent"},
682 { ND_RA_FLAG_IPV6ONLY
, "ipv6 only"},
686 static const struct tok icmp6_nd_na_flag_values
[] = {
687 { ND_NA_FLAG_ROUTER
, "router" },
688 { ND_NA_FLAG_SOLICITED
, "solicited" },
689 { ND_NA_FLAG_OVERRIDE
, "override" },
693 static const struct tok icmp6_opt_values
[] = {
694 { ND_OPT_SOURCE_LINKADDR
, "source link-address"},
695 { ND_OPT_TARGET_LINKADDR
, "destination link-address"},
696 { ND_OPT_PREFIX_INFORMATION
, "prefix info"},
697 { ND_OPT_REDIRECTED_HEADER
, "redirected header"},
698 { ND_OPT_MTU
, "mtu"},
699 { ND_OPT_RDNSS
, "rdnss"},
700 { ND_OPT_DNSSL
, "dnssl"},
701 { ND_OPT_ADVINTERVAL
, "advertisement interval"},
702 { ND_OPT_HOMEAGENT_INFO
, "homeagent information"},
703 { ND_OPT_ROUTE_INFO
, "route info"},
707 /* mldv2 report types */
708 static const struct tok mldv2report2str
[] = {
721 static const char *rtpref_str
[] = {
728 return rtpref_str
[((v
& ND_RA_FLAG_RTPREF_MASK
) >> 3) & 0xff];
732 get_lifetime(uint32_t v
)
736 if (v
== (uint32_t)~0UL)
739 snprintf(buf
, sizeof(buf
), "%us", v
);
745 print_lladdr(netdissect_options
*ndo
, const uint8_t *p
, size_t l
)
747 const uint8_t *ep
, *q
;
751 while (l
> 0 && q
< ep
) {
754 ND_PRINT("%02x", GET_U_1(q
));
760 static uint16_t icmp6_cksum(netdissect_options
*ndo
, const struct ip6_hdr
*ip6
,
761 const struct icmp6_hdr
*icp
, u_int len
)
763 return nextproto6_cksum(ndo
, ip6
, (const uint8_t *)(const void *)icp
, len
, len
,
767 static const struct tok rpl_mop_values
[] = {
768 { RPL_DIO_NONSTORING
, "nonstoring"},
769 { RPL_DIO_STORING
, "storing"},
770 { RPL_DIO_NONSTORING_MULTICAST
, "nonstoring-multicast"},
771 { RPL_DIO_STORING_MULTICAST
, "storing-multicast"},
775 static const struct tok rpl_subopt_values
[] = {
776 { RPL_OPT_PAD1
, "pad1"},
777 { RPL_OPT_PADN
, "padN"},
778 { RPL_DIO_METRICS
, "metrics"},
779 { RPL_DIO_ROUTINGINFO
, "routinginfo"},
780 { RPL_DIO_CONFIG
, "config"},
781 { RPL_DAO_RPLTARGET
, "rpltarget"},
782 { RPL_DAO_TRANSITINFO
, "transitinfo"},
783 { RPL_DIO_DESTPREFIX
, "destprefix"},
784 { RPL_DAO_RPLTARGET_DESC
, "rpltargetdesc"},
789 rpl_printopts(netdissect_options
*ndo
, const uint8_t *opts
, u_int length
)
791 const struct rpl_genoption
*opt
;
795 while (length
!= 0) {
796 opt
= (const struct rpl_genoption
*)opts
;
797 dio_type
= GET_U_1(opt
->rpl_dio_type
);
798 if (dio_type
== RPL_OPT_PAD1
) {
800 ND_PRINT(" opt:pad1");
802 if (length
< RPL_GENOPTION_LEN
)
804 optlen
= GET_U_1(opt
->rpl_dio_len
)+RPL_GENOPTION_LEN
;
805 ND_PRINT(" opt:%s len:%u ",
806 tok2str(rpl_subopt_values
, "subopt:%u", dio_type
),
808 ND_TCHECK_LEN(opt
, optlen
);
811 if (ndo
->ndo_vflag
> 2) {
814 opts
+ RPL_GENOPTION_LEN
, /* content of DIO option */
815 optlen
- RPL_GENOPTION_LEN
);
827 rpl_dio_print(netdissect_options
*ndo
,
828 const u_char
*bp
, u_int length
)
830 const struct nd_rpl_dio
*dio
= (const struct nd_rpl_dio
*)bp
;
832 ND_ICHECK_ZU(length
, <, sizeof(struct nd_rpl_dio
));
833 ND_PRINT(" [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
834 GET_IP6ADDR_STRING(dio
->rpl_dagid
),
835 GET_U_1(dio
->rpl_dtsn
),
836 GET_U_1(dio
->rpl_instanceid
),
837 GET_BE_U_2(dio
->rpl_dagrank
),
838 RPL_DIO_GROUNDED(GET_U_1(dio
->rpl_mopprf
)) ? "grounded,":"",
839 tok2str(rpl_mop_values
, "mop%u",
840 RPL_DIO_MOP(GET_U_1(dio
->rpl_mopprf
))),
841 RPL_DIO_PRF(GET_U_1(dio
->rpl_mopprf
)));
843 if(ndo
->ndo_vflag
> 1) {
844 rpl_printopts(ndo
, bp
+ sizeof(struct nd_rpl_dio
),
845 length
- sizeof(struct nd_rpl_dio
));
849 nd_print_invalid(ndo
);
853 rpl_dao_print(netdissect_options
*ndo
,
854 const u_char
*bp
, u_int length
)
856 const struct nd_rpl_dao
*dao
= (const struct nd_rpl_dao
*)bp
;
857 const char *dagid_str
= "<elided>";
861 if (length
< ND_RPL_DAO_MIN_LEN
)
864 bp
+= ND_RPL_DAO_MIN_LEN
;
865 length
-= ND_RPL_DAO_MIN_LEN
;
866 rpl_flags
= GET_U_1(dao
->rpl_flags
);
867 if(RPL_DAO_D(rpl_flags
)) {
868 ND_TCHECK_LEN(dao
->rpl_dagid
, DAGID_LEN
);
869 if (length
< DAGID_LEN
)
871 dagid_str
= ip6addr_string (ndo
, dao
->rpl_dagid
);
876 ND_PRINT(" [dagid:%s,seq:%u,instance:%u%s%s,flags:%02x]",
878 GET_U_1(dao
->rpl_daoseq
),
879 GET_U_1(dao
->rpl_instanceid
),
880 RPL_DAO_K(rpl_flags
) ? ",acK":"",
881 RPL_DAO_D(rpl_flags
) ? ",Dagid":"",
884 if(ndo
->ndo_vflag
> 1) {
885 rpl_printopts(ndo
, bp
, length
);
894 ND_PRINT(" [|length too short]");
898 rpl_daoack_print(netdissect_options
*ndo
,
899 const u_char
*bp
, u_int length
)
901 const struct nd_rpl_daoack
*daoack
= (const struct nd_rpl_daoack
*)bp
;
902 const char *dagid_str
= "<elided>";
904 ND_TCHECK_LEN(daoack
, ND_RPL_DAOACK_MIN_LEN
);
905 if (length
< ND_RPL_DAOACK_MIN_LEN
)
908 bp
+= ND_RPL_DAOACK_MIN_LEN
;
909 length
-= ND_RPL_DAOACK_MIN_LEN
;
910 if(RPL_DAOACK_D(GET_U_1(daoack
->rpl_flags
))) {
911 ND_TCHECK_LEN(daoack
->rpl_dagid
, DAGID_LEN
);
912 if (length
< DAGID_LEN
)
914 dagid_str
= ip6addr_string (ndo
, daoack
->rpl_dagid
);
919 ND_PRINT(" [dagid:%s,seq:%u,instance:%u,status:%u]",
921 GET_U_1(daoack
->rpl_daoseq
),
922 GET_U_1(daoack
->rpl_instanceid
),
923 GET_U_1(daoack
->rpl_status
));
925 /* no officially defined options for DAOACK, but print any we find */
926 if(ndo
->ndo_vflag
> 1) {
927 rpl_printopts(ndo
, bp
, length
);
936 ND_PRINT(" [|dao-length too short]");
940 rpl_print(netdissect_options
*ndo
,
942 const u_char
*bp
, u_int length
)
944 int secured
= icmp6_code
& 0x80;
945 int basecode
= icmp6_code
& 0x7f;
948 ND_PRINT(", (SEC) [worktodo]");
950 * the next header pointer needs to move forward to
951 * skip the secure part.
960 ND_PRINT("DODAG Information Solicitation");
965 ND_PRINT("DODAG Information Object");
967 rpl_dio_print(ndo
, bp
, length
);
971 ND_PRINT("Destination Advertisement Object");
973 rpl_dao_print(ndo
, bp
, length
);
977 ND_PRINT("Destination Advertisement Object Ack");
979 rpl_daoack_print(ndo
, bp
, length
);
983 ND_PRINT("RPL message, unknown code %u",icmp6_code
);
997 icmp6_print(netdissect_options
*ndo
,
998 const u_char
*bp
, u_int length
, const u_char
*bp2
, int fragmented
)
1000 const struct icmp6_hdr
*dp
;
1001 uint8_t icmp6_type
, icmp6_code
;
1002 const struct ip6_hdr
*ip
;
1003 const struct ip6_hdr
*oip
;
1004 const struct udphdr
*ouh
;
1009 ndo
->ndo_protocol
= "icmp6";
1010 dp
= (const struct icmp6_hdr
*)bp
;
1011 ip
= (const struct ip6_hdr
*)bp2
;
1012 oip
= (const struct ip6_hdr
*)(dp
+ 1);
1013 /* 'ep' points to the end of available data. */
1014 ep
= ndo
->ndo_snapend
;
1016 ND_PRINT("ICMP6, length 0");
1017 nd_print_invalid(ndo
);
1021 if (ndo
->ndo_vflag
&& !fragmented
) {
1022 uint16_t sum
, udp_sum
;
1024 if (ND_TTEST_LEN(bp
, length
)) {
1025 udp_sum
= GET_BE_U_2(dp
->icmp6_cksum
);
1026 sum
= icmp6_cksum(ndo
, ip
, dp
, length
);
1028 ND_PRINT("[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
1030 in_cksum_shouldbe(udp_sum
, sum
));
1032 ND_PRINT("[icmp6 sum ok] ");
1036 icmp6_type
= GET_U_1(dp
->icmp6_type
);
1037 ND_PRINT("ICMP6, %s", tok2str(icmp6_type_values
,"unknown icmp6 type (%u)",icmp6_type
));
1039 /* display cosmetics: print the packet length for printer that use the vflag now */
1040 if (ndo
->ndo_vflag
&& (icmp6_type
== ND_ROUTER_SOLICIT
||
1041 icmp6_type
== ND_ROUTER_ADVERT
||
1042 icmp6_type
== ND_NEIGHBOR_ADVERT
||
1043 icmp6_type
== ND_NEIGHBOR_SOLICIT
||
1044 icmp6_type
== ND_REDIRECT
||
1045 icmp6_type
== ICMP6_HADISCOV_REPLY
||
1046 icmp6_type
== ICMP6_MOBILEPREFIX_ADVERT
))
1047 ND_PRINT(", length %u", length
);
1049 icmp6_code
= GET_U_1(dp
->icmp6_code
);
1051 switch (icmp6_type
) {
1052 case ICMP6_DST_UNREACH
:
1053 ND_PRINT(", %s", tok2str(icmp6_dst_unreach_code_values
,"unknown unreach code (%u)",icmp6_code
));
1054 switch (icmp6_code
) {
1056 case ICMP6_DST_UNREACH_NOROUTE
: /* fall through */
1057 case ICMP6_DST_UNREACH_ADMIN
:
1058 case ICMP6_DST_UNREACH_ADDR
:
1059 ND_PRINT(" %s",GET_IP6ADDR_STRING(oip
->ip6_dst
));
1061 case ICMP6_DST_UNREACH_BEYONDSCOPE
:
1062 ND_PRINT(" %s, source address %s",
1063 GET_IP6ADDR_STRING(oip
->ip6_dst
),
1064 GET_IP6ADDR_STRING(oip
->ip6_src
));
1066 case ICMP6_DST_UNREACH_NOPORT
:
1067 if ((ouh
= get_upperlayer(ndo
, (const u_char
*)oip
, &prot
))
1071 dport
= GET_BE_U_2(ouh
->uh_dport
);
1074 ND_PRINT(", %s tcp port %s",
1075 GET_IP6ADDR_STRING(oip
->ip6_dst
),
1076 tcpport_string(ndo
, dport
));
1079 ND_PRINT(", %s udp port %s",
1080 GET_IP6ADDR_STRING(oip
->ip6_dst
),
1081 udpport_string(ndo
, dport
));
1084 ND_PRINT(", %s protocol %u port %u unreachable",
1085 GET_IP6ADDR_STRING(oip
->ip6_dst
),
1091 if (ndo
->ndo_vflag
<= 1) {
1092 print_unknown_data(ndo
, bp
,"\n\t",length
);
1098 case ICMP6_PACKET_TOO_BIG
:
1099 ND_PRINT(", mtu %u", GET_BE_U_4(dp
->icmp6_mtu
));
1101 case ICMP6_TIME_EXCEEDED
:
1102 switch (icmp6_code
) {
1103 case ICMP6_TIME_EXCEED_TRANSIT
:
1105 GET_IP6ADDR_STRING(oip
->ip6_dst
));
1107 case ICMP6_TIME_EXCEED_REASSEMBLY
:
1108 ND_PRINT(" (reassembly)");
1111 ND_PRINT(", unknown code (%u)", icmp6_code
);
1115 case ICMP6_PARAM_PROB
:
1116 ND_TCHECK_16(oip
->ip6_dst
);
1117 switch (icmp6_code
) {
1118 case ICMP6_PARAMPROB_HEADER
:
1119 ND_PRINT(", erroneous - octet %u",
1120 GET_BE_U_4(dp
->icmp6_pptr
));
1122 case ICMP6_PARAMPROB_NEXTHEADER
:
1123 ND_PRINT(", next header - octet %u",
1124 GET_BE_U_4(dp
->icmp6_pptr
));
1126 case ICMP6_PARAMPROB_OPTION
:
1127 ND_PRINT(", option - octet %u",
1128 GET_BE_U_4(dp
->icmp6_pptr
));
1130 case ICMP6_PARAMPROB_FRAGHDRCHAIN
:
1131 ND_PRINT(", incomplete header chain - octet %u",
1132 GET_BE_U_4(dp
->icmp6_pptr
));
1135 ND_PRINT(", code-#%u",
1140 case ICMP6_ECHO_REQUEST
:
1141 case ICMP6_ECHO_REPLY
:
1142 ND_PRINT(", id %u, seq %u", GET_BE_U_2(dp
->icmp6_id
),
1143 GET_BE_U_2(dp
->icmp6_seq
));
1145 case MLD6_LISTENER_QUERY
:
1146 if (length
== MLD_MINLEN
) {
1147 mld6_print(ndo
, (const u_char
*)dp
);
1148 } else if (length
>= MLDV2_MINLEN
) {
1150 mldv2_query_print(ndo
, (const u_char
*)dp
, length
);
1152 ND_PRINT(" unknown-version (len %u) ", length
);
1155 case MLD6_LISTENER_REPORT
:
1156 mld6_print(ndo
, (const u_char
*)dp
);
1158 case MLD6_LISTENER_DONE
:
1159 mld6_print(ndo
, (const u_char
*)dp
);
1161 case ND_ROUTER_SOLICIT
:
1163 if (ndo
->ndo_vflag
) {
1164 if (icmp6_opt_print(ndo
, (const u_char
*)dp
+ RTSOLLEN
,
1165 length
- RTSOLLEN
) == -1)
1169 case ND_ROUTER_ADVERT
:
1171 if (ndo
->ndo_vflag
) {
1172 const struct nd_router_advert
*p
;
1174 p
= (const struct nd_router_advert
*)dp
;
1175 ND_PRINT("\n\thop limit %u, Flags [%s]"
1176 ", pref %s, router lifetime %us, reachable time %ums, retrans timer %ums",
1177 GET_U_1(p
->nd_ra_curhoplimit
),
1178 bittok2str(icmp6_opt_ra_flag_values
,"none",GET_U_1(p
->nd_ra_flags_reserved
)),
1179 get_rtpref(GET_U_1(p
->nd_ra_flags_reserved
)),
1180 GET_BE_U_2(p
->nd_ra_router_lifetime
),
1181 GET_BE_U_4(p
->nd_ra_reachable
),
1182 GET_BE_U_4(p
->nd_ra_retransmit
));
1184 if (icmp6_opt_print(ndo
, (const u_char
*)dp
+ RTADVLEN
,
1185 length
- RTADVLEN
) == -1)
1189 case ND_NEIGHBOR_SOLICIT
:
1191 const struct nd_neighbor_solicit
*p
;
1192 p
= (const struct nd_neighbor_solicit
*)dp
;
1193 ND_PRINT(", who has %s", GET_IP6ADDR_STRING(p
->nd_ns_target
));
1194 if (ndo
->ndo_vflag
) {
1196 if (icmp6_opt_print(ndo
, (const u_char
*)dp
+ NDSOLLEN
,
1197 length
- NDSOLLEN
) == -1)
1202 case ND_NEIGHBOR_ADVERT
:
1204 const struct nd_neighbor_advert
*p
;
1206 p
= (const struct nd_neighbor_advert
*)dp
;
1207 ND_PRINT(", tgt is %s",
1208 GET_IP6ADDR_STRING(p
->nd_na_target
));
1209 if (ndo
->ndo_vflag
) {
1210 ND_PRINT(", Flags [%s]",
1211 bittok2str(icmp6_nd_na_flag_values
,
1213 GET_BE_U_4(p
->nd_na_flags_reserved
)));
1215 if (icmp6_opt_print(ndo
, (const u_char
*)dp
+ NDADVLEN
,
1216 length
- NDADVLEN
) == -1)
1224 const struct nd_redirect
*p
;
1226 p
= (const struct nd_redirect
*)dp
;
1227 ND_PRINT(", %s", GET_IP6ADDR_STRING(p
->nd_rd_dst
));
1228 ND_PRINT(" to %s", GET_IP6ADDR_STRING(p
->nd_rd_target
));
1229 #define REDIRECTLEN 40
1230 if (ndo
->ndo_vflag
) {
1231 if (icmp6_opt_print(ndo
, (const u_char
*)dp
+ REDIRECTLEN
,
1232 length
- REDIRECTLEN
) == -1)
1238 case ICMP6_ROUTER_RENUMBERING
:
1239 icmp6_rrenum_print(ndo
, bp
, ep
);
1241 case ICMP6_NI_QUERY
:
1242 case ICMP6_NI_REPLY
:
1243 icmp6_nodeinfo_print(ndo
, length
, bp
, ep
);
1248 case ICMP6_V2_MEMBERSHIP_REPORT
:
1249 mldv2_report_print(ndo
, (const u_char
*) dp
, length
);
1251 case ICMP6_MOBILEPREFIX_SOLICIT
: /* fall through */
1252 case ICMP6_HADISCOV_REQUEST
:
1253 ND_PRINT(", id 0x%04x", GET_BE_U_2(dp
->icmp6_data16
[0]));
1255 case ICMP6_HADISCOV_REPLY
:
1256 if (ndo
->ndo_vflag
) {
1260 ND_PRINT(", id 0x%04x",
1261 GET_BE_U_2(dp
->icmp6_data16
[0]));
1262 cp
= (const u_char
*)dp
+
1263 ND_MIN(length
, ND_BYTES_AVAILABLE_AFTER(dp
));
1264 p
= (const u_char
*)(dp
+ 1);
1266 ND_PRINT(", %s", GET_IP6ADDR_STRING(p
));
1271 case ICMP6_MOBILEPREFIX_ADVERT
:
1272 if (ndo
->ndo_vflag
) {
1275 ND_PRINT(", id 0x%04x",
1276 GET_BE_U_2(dp
->icmp6_data16
[0]));
1277 flags
= GET_BE_U_2(dp
->icmp6_data16
[1]);
1285 if (icmp6_opt_print(ndo
, (const u_char
*)dp
+ MPADVLEN
,
1286 length
- MPADVLEN
) == -1)
1290 case ND_RPL_MESSAGE
:
1291 /* plus 4, because struct icmp6_hdr contains 4 bytes of icmp payload */
1292 rpl_print(ndo
, icmp6_code
, dp
->icmp6_data
, length
-sizeof(struct icmp6_hdr
)+4);
1295 ND_PRINT(", length %u", length
);
1296 if (ndo
->ndo_vflag
<= 1)
1297 print_unknown_data(ndo
, bp
,"\n\t", length
);
1300 if (!ndo
->ndo_vflag
)
1301 ND_PRINT(", length %u", length
);
1304 nd_print_trunc(ndo
);
1307 static const struct udphdr
*
1308 get_upperlayer(netdissect_options
*ndo
, const u_char
*bp
, u_int
*prot
)
1311 const struct ip6_hdr
*ip6
= (const struct ip6_hdr
*)bp
;
1312 const struct udphdr
*uh
;
1313 const struct ip6_hbh
*hbh
;
1314 const struct ip6_frag
*fragh
;
1315 const struct ah
*ah
;
1319 /* 'ep' points to the end of available data. */
1320 ep
= ndo
->ndo_snapend
;
1322 if (!ND_TTEST_1(ip6
->ip6_nxt
))
1325 nh
= GET_U_1(ip6
->ip6_nxt
);
1326 hlen
= sizeof(struct ip6_hdr
);
1334 uh
= (const struct udphdr
*)bp
;
1335 if (ND_TTEST_2(uh
->uh_dport
)) {
1342 case IPPROTO_HOPOPTS
:
1343 case IPPROTO_DSTOPTS
:
1344 case IPPROTO_ROUTING
:
1345 hbh
= (const struct ip6_hbh
*)bp
;
1346 if (!ND_TTEST_1(hbh
->ip6h_len
))
1348 nh
= GET_U_1(hbh
->ip6h_nxt
);
1349 hlen
= (GET_U_1(hbh
->ip6h_len
) + 1) << 3;
1352 case IPPROTO_FRAGMENT
: /* this should be odd, but try anyway */
1353 fragh
= (const struct ip6_frag
*)bp
;
1354 if (!ND_TTEST_2(fragh
->ip6f_offlg
))
1356 /* fragments with non-zero offset are meaningless */
1357 if ((GET_BE_U_2(fragh
->ip6f_offlg
) & IP6F_OFF_MASK
) != 0)
1359 nh
= GET_U_1(fragh
->ip6f_nxt
);
1360 hlen
= sizeof(struct ip6_frag
);
1364 ah
= (const struct ah
*)bp
;
1365 if (!ND_TTEST_1(ah
->ah_len
))
1367 nh
= GET_U_1(ah
->ah_nxt
);
1368 hlen
= (GET_U_1(ah
->ah_len
) + 2) << 2;
1371 default: /* unknown or undecodable header */
1372 *prot
= nh
; /* meaningless, but set here anyway */
1377 return(NULL
); /* should be notreached, though */
1381 icmp6_opt_print(netdissect_options
*ndo
, const u_char
*bp
, int resid
)
1383 const struct nd_opt_hdr
*op
;
1386 const struct nd_opt_prefix_info
*opp
;
1387 const struct nd_opt_mtu
*opm
;
1388 const struct nd_opt_rdnss
*oprd
;
1389 const struct nd_opt_dnssl
*opds
;
1390 const struct nd_opt_advinterval
*opa
;
1391 const struct nd_opt_homeagent_info
*oph
;
1392 const struct nd_opt_route_info
*opri
;
1393 const u_char
*cp
, *ep
, *domp
;
1399 /* 'ep' points to the end of available data. */
1400 ep
= ndo
->ndo_snapend
;
1403 op
= (const struct nd_opt_hdr
*)cp
;
1405 ND_TCHECK_1(op
->nd_opt_len
);
1408 opt_type
= GET_U_1(op
->nd_opt_type
);
1409 opt_len
= GET_U_1(op
->nd_opt_len
);
1412 if (cp
+ (opt_len
<< 3) > ep
)
1415 ND_PRINT("\n\t %s option (%u), length %u (%u): ",
1416 tok2str(icmp6_opt_values
, "unknown", opt_type
),
1422 case ND_OPT_SOURCE_LINKADDR
:
1423 l
= (opt_len
<< 3) - 2;
1424 print_lladdr(ndo
, cp
+ 2, l
);
1426 case ND_OPT_TARGET_LINKADDR
:
1427 l
= (opt_len
<< 3) - 2;
1428 print_lladdr(ndo
, cp
+ 2, l
);
1430 case ND_OPT_PREFIX_INFORMATION
:
1431 opp
= (const struct nd_opt_prefix_info
*)op
;
1432 ND_PRINT("%s/%u%s, Flags [%s], valid time %s",
1433 GET_IP6ADDR_STRING(opp
->nd_opt_pi_prefix
),
1434 GET_U_1(opp
->nd_opt_pi_prefix_len
),
1435 (opt_len
!= 4) ? "badlen" : "",
1436 bittok2str(icmp6_opt_pi_flag_values
, "none", GET_U_1(opp
->nd_opt_pi_flags_reserved
)),
1437 get_lifetime(GET_BE_U_4(opp
->nd_opt_pi_valid_time
)));
1438 ND_PRINT(", pref. time %s",
1439 get_lifetime(GET_BE_U_4(opp
->nd_opt_pi_preferred_time
)));
1441 case ND_OPT_REDIRECTED_HEADER
:
1442 print_unknown_data(ndo
, bp
,"\n\t ",opt_len
<<3);
1446 opm
= (const struct nd_opt_mtu
*)op
;
1448 GET_BE_U_4(opm
->nd_opt_mtu_mtu
),
1449 (opt_len
!= 1) ? "bad option length" : "" );
1452 oprd
= (const struct nd_opt_rdnss
*)op
;
1453 l
= (opt_len
- 1) / 2;
1454 ND_PRINT(" lifetime %us,",
1455 GET_BE_U_4(oprd
->nd_opt_rdnss_lifetime
));
1456 for (i
= 0; i
< l
; i
++) {
1457 ND_PRINT(" addr: %s",
1458 GET_IP6ADDR_STRING(oprd
->nd_opt_rdnss_addr
[i
]));
1462 opds
= (const struct nd_opt_dnssl
*)op
;
1463 ND_PRINT(" lifetime %us, domain(s):",
1464 GET_BE_U_4(opds
->nd_opt_dnssl_lifetime
));
1465 domp
= cp
+ 8; /* domain names, variable-sized, RFC1035-encoded */
1466 while (domp
< cp
+ (opt_len
<< 3) && GET_U_1(domp
) != '\0') {
1468 if ((domp
= fqdn_print(ndo
, domp
, bp
)) == NULL
)
1472 case ND_OPT_ADVINTERVAL
:
1473 opa
= (const struct nd_opt_advinterval
*)op
;
1475 GET_BE_U_4(opa
->nd_opt_adv_interval
));
1477 case ND_OPT_HOMEAGENT_INFO
:
1478 oph
= (const struct nd_opt_homeagent_info
*)op
;
1479 ND_PRINT(" preference %u, lifetime %u",
1480 GET_BE_U_2(oph
->nd_opt_hai_preference
),
1481 GET_BE_U_2(oph
->nd_opt_hai_lifetime
));
1483 case ND_OPT_ROUTE_INFO
:
1484 opri
= (const struct nd_opt_route_info
*)op
;
1485 ND_TCHECK_4(opri
->nd_opt_rti_lifetime
);
1486 memset(&in6
, 0, sizeof(in6
));
1491 GET_CPY_BYTES(&in6
, opri
+ 1, 8);
1494 GET_CPY_BYTES(&in6
, opri
+ 1, 16);
1499 ND_PRINT(" %s/%u", ip6addr_string(ndo
, (const u_char
*)&in6
), /* local buffer, not packet data; don't use GET_IP6ADDR_STRING() */
1500 GET_U_1(opri
->nd_opt_rti_prefixlen
));
1501 ND_PRINT(", pref=%s",
1502 get_rtpref(GET_U_1(opri
->nd_opt_rti_flags
)));
1503 ND_PRINT(", lifetime=%s",
1504 get_lifetime(GET_BE_U_4(opri
->nd_opt_rti_lifetime
)));
1507 if (ndo
->ndo_vflag
<= 1) {
1508 print_unknown_data(ndo
,cp
+2,"\n\t ", (opt_len
<< 3) - 2); /* skip option header */
1513 /* do we want to see an additional hexdump ? */
1514 if (ndo
->ndo_vflag
> 1)
1515 print_unknown_data(ndo
, cp
+2,"\n\t ", (opt_len
<< 3) - 2); /* skip option header */
1518 resid
-= opt_len
<< 3;
1527 mld6_print(netdissect_options
*ndo
, const u_char
*bp
)
1529 const struct mld6_hdr
*mp
= (const struct mld6_hdr
*)bp
;
1532 /* 'ep' points to the end of available data. */
1533 ep
= ndo
->ndo_snapend
;
1535 if ((const u_char
*)mp
+ sizeof(*mp
) > ep
)
1538 ND_PRINT("max resp delay: %u ", GET_BE_U_2(mp
->mld6_maxdelay
));
1539 ND_PRINT("addr: %s", GET_IP6ADDR_STRING(mp
->mld6_addr
));
1543 mldv2_report_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len
)
1545 const struct icmp6_hdr
*icp
= (const struct icmp6_hdr
*) bp
;
1546 u_int group
, nsrcs
, ngroups
;
1549 /* Minimum len is 8 */
1551 ND_PRINT(" [invalid len %u]", len
);
1555 ngroups
= GET_BE_U_2(icp
->icmp6_data16
[1]);
1556 ND_PRINT(", %u group record(s)", ngroups
);
1557 if (ndo
->ndo_vflag
> 0) {
1558 /* Print the group records */
1560 for (i
= 0; i
< ngroups
; i
++) {
1561 /* type(1) + auxlen(1) + numsrc(2) + grp(16) */
1562 if (len
< group
+ 20) {
1563 ND_PRINT(" [invalid number of groups]");
1566 ND_PRINT(" [gaddr %s", GET_IP6ADDR_STRING(bp
+ group
+ 4));
1567 ND_PRINT(" %s", tok2str(mldv2report2str
, " [v2-report-#%u]",
1568 GET_U_1(bp
+ group
)));
1569 nsrcs
= GET_BE_U_2(bp
+ group
+ 2);
1570 /* Check the number of sources and print them */
1571 if (len
< group
+ 20 + (nsrcs
* sizeof(nd_ipv6
))) {
1572 ND_PRINT(" [invalid number of sources %u]", nsrcs
);
1575 if (ndo
->ndo_vflag
== 1)
1576 ND_PRINT(", %u source(s)", nsrcs
);
1578 /* Print the sources */
1580 for (j
= 0; j
< nsrcs
; j
++) {
1581 ND_PRINT(" %s", GET_IP6ADDR_STRING(bp
+ group
+ 20 + (j
* sizeof(nd_ipv6
))));
1585 /* Next group record */
1586 group
+= 20 + nsrcs
* sizeof(nd_ipv6
);
1593 mldv2_query_print(netdissect_options
*ndo
, const u_char
*bp
, u_int len
)
1595 const struct icmp6_hdr
*icp
= (const struct icmp6_hdr
*) bp
;
1601 /* Minimum len is 28 */
1603 ND_PRINT(" [invalid len %u]", len
);
1606 mrc
= GET_BE_U_2(icp
->icmp6_data16
[0]);
1610 mrt
= ((mrc
& 0x0fff) | 0x1000) << (((mrc
& 0x7000) >> 12) + 3);
1612 if (ndo
->ndo_vflag
) {
1613 ND_PRINT(" [max resp delay=%u]", mrt
);
1615 ND_PRINT(" [gaddr %s", GET_IP6ADDR_STRING(bp
+ 8));
1617 if (ndo
->ndo_vflag
) {
1618 if (GET_U_1(bp
+ 24) & 0x08) {
1621 if (GET_U_1(bp
+ 24) & 0x07) {
1622 ND_PRINT(" robustness=%u", GET_U_1(bp
+ 24) & 0x07);
1624 if (GET_U_1(bp
+ 25) < 128) {
1625 qqi
= GET_U_1(bp
+ 25);
1627 qqi
= ((GET_U_1(bp
+ 25) & 0x0f) | 0x10) <<
1628 (((GET_U_1(bp
+ 25) & 0x70) >> 4) + 3);
1630 ND_PRINT(" qqi=%u", qqi
);
1633 nsrcs
= GET_BE_U_2(bp
+ 26);
1635 if (len
< 28 + nsrcs
* sizeof(nd_ipv6
))
1636 ND_PRINT(" [invalid number of sources]");
1637 else if (ndo
->ndo_vflag
> 1) {
1639 for (i
= 0; i
< nsrcs
; i
++) {
1640 ND_PRINT(" %s", GET_IP6ADDR_STRING(bp
+ 28 + (i
* sizeof(nd_ipv6
))));
1644 ND_PRINT(", %u source(s)", nsrcs
);
1650 dnsname_print(netdissect_options
*ndo
, const u_char
*cp
, const u_char
*ep
)
1654 /* DNS name decoding - no decompression */
1664 while (i
-- && cp
< ep
) {
1665 fn_print_char(ndo
, GET_U_1(cp
));
1668 if (cp
+ 1 < ep
&& GET_U_1(cp
))
1674 } else if (cp
+ 1 == ep
&& GET_U_1(cp
) == '\0') {
1687 icmp6_nodeinfo_print(netdissect_options
*ndo
, u_int icmp6len
, const u_char
*bp
, const u_char
*ep
)
1689 const struct icmp6_nodeinfo
*ni6
;
1690 const struct icmp6_hdr
*dp
;
1697 dp
= (const struct icmp6_hdr
*)bp
;
1698 ni6
= (const struct icmp6_nodeinfo
*)bp
;
1701 switch (GET_U_1(ni6
->ni_type
)) {
1702 case ICMP6_NI_QUERY
:
1703 if (siz
== sizeof(*dp
) + 4) {
1704 /* KAME who-are-you */
1705 ND_PRINT(" who-are-you request");
1709 ND_TCHECK_LEN(dp
, sizeof(*ni6
));
1710 ni6
= (const struct icmp6_nodeinfo
*)dp
;
1711 ND_PRINT(" ("); /*)*/
1712 switch (GET_BE_U_2(ni6
->ni_qtype
)) {
1716 case NI_QTYPE_NODENAME
:
1717 ND_PRINT("node name");
1719 case NI_QTYPE_NODEADDR
:
1720 ND_PRINT("node addresses");
1721 i
= GET_BE_U_2(ni6
->ni_flags
);
1724 /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
1725 ND_PRINT(" [%s%s%s%s%s%s]",
1726 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
1727 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
1728 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
1729 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
1730 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
1731 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "");
1734 ND_PRINT("unknown");
1738 if (GET_BE_U_2(ni6
->ni_qtype
) == NI_QTYPE_NOOP
) {
1739 if (siz
!= sizeof(*ni6
))
1741 ND_PRINT(", invalid len");
1747 cp
= (const u_char
*)(ni6
+ 1);
1748 switch (GET_U_1(ni6
->ni_code
)) {
1749 case ICMP6_NI_SUBJ_IPV6
:
1750 if (!ND_TTEST_LEN(dp
, sizeof(*ni6
) + sizeof(nd_ipv6
)))
1752 if (siz
!= sizeof(*ni6
) + sizeof(nd_ipv6
)) {
1754 ND_PRINT(", invalid subject len");
1757 ND_PRINT(", subject=%s",
1758 GET_IP6ADDR_STRING(cp
));
1760 case ICMP6_NI_SUBJ_FQDN
:
1761 ND_PRINT(", subject=DNS name");
1762 dnsname_print(ndo
, cp
, ep
);
1764 case ICMP6_NI_SUBJ_IPV4
:
1765 if (!ND_TTEST_LEN(dp
, sizeof(*ni6
) + sizeof(nd_ipv4
)))
1767 if (siz
!= sizeof(*ni6
) + sizeof(nd_ipv4
)) {
1769 ND_PRINT(", invalid subject len");
1772 ND_PRINT(", subject=%s",
1773 GET_IPADDR_STRING(cp
));
1776 ND_PRINT(", unknown subject");
1784 case ICMP6_NI_REPLY
:
1790 ND_TCHECK_LEN(dp
, sizeof(*ni6
));
1791 ni6
= (const struct icmp6_nodeinfo
*)dp
;
1792 ND_PRINT(" ("); /*)*/
1793 switch (GET_U_1(ni6
->ni_code
)) {
1794 case ICMP6_NI_SUCCESS
:
1795 if (ndo
->ndo_vflag
) {
1796 ND_PRINT("success");
1800 case ICMP6_NI_REFUSED
:
1801 ND_PRINT("refused");
1803 if (siz
!= sizeof(*ni6
))
1805 ND_PRINT(", invalid length");
1807 case ICMP6_NI_UNKNOWN
:
1808 ND_PRINT("unknown");
1810 if (siz
!= sizeof(*ni6
))
1812 ND_PRINT(", invalid length");
1816 if (GET_U_1(ni6
->ni_code
) != ICMP6_NI_SUCCESS
) {
1822 switch (GET_BE_U_2(ni6
->ni_qtype
)) {
1827 if (siz
!= sizeof(*ni6
))
1829 ND_PRINT(", invalid length");
1831 case NI_QTYPE_NODENAME
:
1834 ND_PRINT("node name");
1835 cp
= (const u_char
*)(ni6
+ 1) + 4;
1836 dnsname_print(ndo
, cp
, ep
);
1837 if ((GET_BE_U_2(ni6
->ni_flags
) & 0x01) != 0)
1838 ND_PRINT(" [TTL=%u]", GET_BE_U_4(ni6
+ 1));
1840 case NI_QTYPE_NODEADDR
:
1843 ND_PRINT("node addresses");
1846 if (i
+ sizeof(uint32_t) + sizeof(nd_ipv6
) > siz
)
1849 GET_IP6ADDR_STRING(bp
+ i
+ sizeof(uint32_t)),
1850 GET_BE_U_4(bp
+ i
));
1851 i
+= sizeof(uint32_t) + sizeof(nd_ipv6
);
1853 i
= GET_BE_U_2(ni6
->ni_flags
);
1856 ND_PRINT(" [%s%s%s%s%s%s%s]",
1857 (i
& NI_NODEADDR_FLAG_ANYCAST
) ? "a" : "",
1858 (i
& NI_NODEADDR_FLAG_GLOBAL
) ? "G" : "",
1859 (i
& NI_NODEADDR_FLAG_SITELOCAL
) ? "S" : "",
1860 (i
& NI_NODEADDR_FLAG_LINKLOCAL
) ? "L" : "",
1861 (i
& NI_NODEADDR_FLAG_COMPAT
) ? "C" : "",
1862 (i
& NI_NODEADDR_FLAG_ALL
) ? "A" : "",
1863 (i
& NI_NODEADDR_FLAG_TRUNCATE
) ? "T" : "");
1868 ND_PRINT("unknown");
1879 nd_print_trunc(ndo
);
1883 icmp6_rrenum_print(netdissect_options
*ndo
, const u_char
*bp
, const u_char
*ep
)
1885 const struct icmp6_router_renum
*rr6
;
1887 const struct rr_pco_match
*match
;
1888 const struct rr_pco_use
*use
;
1889 char hbuf
[NI_MAXHOST
];
1894 rr6
= (const struct icmp6_router_renum
*)bp
;
1895 cp
= (const char *)(rr6
+ 1);
1897 ND_TCHECK_4(rr6
->rr_reserved
);
1898 switch (GET_U_1(rr6
->rr_code
)) {
1899 case ICMP6_ROUTER_RENUMBERING_COMMAND
:
1900 ND_PRINT(", command");
1902 case ICMP6_ROUTER_RENUMBERING_RESULT
:
1903 ND_PRINT(", result");
1905 case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
:
1906 ND_PRINT(", sequence number reset");
1909 ND_PRINT(", code-#%u", GET_U_1(rr6
->rr_code
));
1913 ND_PRINT(", seq=%u", GET_BE_U_4(rr6
->rr_seqnum
));
1915 if (ndo
->ndo_vflag
) {
1916 uint8_t rr_flags
= GET_U_1(rr6
->rr_flags
);
1917 #define F(x, y) (rr_flags & (x) ? (y) : "")
1918 ND_PRINT("["); /*]*/
1920 ND_PRINT("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST
, "T"),
1921 F(ICMP6_RR_FLAGS_REQRESULT
, "R"),
1922 F(ICMP6_RR_FLAGS_FORCEAPPLY
, "A"),
1923 F(ICMP6_RR_FLAGS_SPECSITE
, "S"),
1924 F(ICMP6_RR_FLAGS_PREVDONE
, "P"));
1926 ND_PRINT("seg=%u,", GET_U_1(rr6
->rr_segnum
));
1927 ND_PRINT("maxdelay=%u", GET_BE_U_2(rr6
->rr_maxdelay
));
1928 if (GET_BE_U_4(rr6
->rr_reserved
))
1929 ND_PRINT("rsvd=0x%x", GET_BE_U_4(rr6
->rr_reserved
));
1935 if (GET_U_1(rr6
->rr_code
) == ICMP6_ROUTER_RENUMBERING_COMMAND
) {
1936 match
= (const struct rr_pco_match
*)cp
;
1937 cp
= (const char *)(match
+ 1);
1939 ND_TCHECK_16(match
->rpm_prefix
);
1941 if (ndo
->ndo_vflag
> 1)
1945 ND_PRINT("match("); /*)*/
1946 switch (GET_U_1(match
->rpm_code
)) {
1947 case RPM_PCO_ADD
: ND_PRINT("add"); break;
1948 case RPM_PCO_CHANGE
: ND_PRINT("change"); break;
1949 case RPM_PCO_SETGLOBAL
: ND_PRINT("setglobal"); break;
1950 default: ND_PRINT("#%u",
1951 GET_U_1(match
->rpm_code
)); break;
1954 if (ndo
->ndo_vflag
) {
1955 ND_PRINT(",ord=%u", GET_U_1(match
->rpm_ordinal
));
1956 ND_PRINT(",min=%u", GET_U_1(match
->rpm_minlen
));
1957 ND_PRINT(",max=%u", GET_U_1(match
->rpm_maxlen
));
1959 if (addrtostr6(match
->rpm_prefix
, hbuf
, sizeof(hbuf
)))
1960 ND_PRINT(",%s/%u", hbuf
, GET_U_1(match
->rpm_matchlen
));
1962 ND_PRINT(",?/%u", GET_U_1(match
->rpm_matchlen
));
1966 n
= GET_U_1(match
->rpm_len
) - 3;
1971 use
= (const struct rr_pco_use
*)cp
;
1972 cp
= (const char *)(use
+ 1);
1974 ND_TCHECK_16(use
->rpu_prefix
);
1976 if (ndo
->ndo_vflag
> 1)
1980 ND_PRINT("use("); /*)*/
1981 if (GET_U_1(use
->rpu_flags
)) {
1982 #define F(x, y) (GET_U_1(use->rpu_flags) & (x) ? (y) : "")
1984 F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME
, "V"),
1985 F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME
, "P"));
1988 if (ndo
->ndo_vflag
) {
1989 ND_PRINT("mask=0x%x,",
1990 GET_U_1(use
->rpu_ramask
));
1991 ND_PRINT("raflags=0x%x,",
1992 GET_U_1(use
->rpu_raflags
));
1993 if (GET_BE_U_4(use
->rpu_vltime
) == 0xffffffff)
1994 ND_PRINT("vltime=infty,");
1996 ND_PRINT("vltime=%u,",
1997 GET_BE_U_4(use
->rpu_vltime
));
1998 if (GET_BE_U_4(use
->rpu_pltime
) == 0xffffffff)
1999 ND_PRINT("pltime=infty,");
2001 ND_PRINT("pltime=%u,",
2002 GET_BE_U_4(use
->rpu_pltime
));
2004 if (addrtostr6(use
->rpu_prefix
, hbuf
, sizeof(hbuf
)))
2005 ND_PRINT("%s/%u/%u", hbuf
,
2006 GET_U_1(use
->rpu_uselen
),
2007 GET_U_1(use
->rpu_keeplen
));
2009 ND_PRINT("?/%u/%u", GET_U_1(use
->rpu_uselen
),
2010 GET_U_1(use
->rpu_keeplen
));
2019 nd_print_trunc(ndo
);