2 * Copyright (c) 2000,2008 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $ */
31 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
32 * All rights reserved.
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. Neither the name of the project nor the names of its contributors
43 * may be used to endorse or promote products derived from this software
44 * without specific prior written permission.
46 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * Copyright (c) 1982, 1986, 1993
61 * The Regents of the University of California. All rights reserved.
63 * Redistribution and use in source and binary forms, with or without
64 * modification, are permitted provided that the following conditions
66 * 1. Redistributions of source code must retain the above copyright
67 * notice, this list of conditions and the following disclaimer.
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in the
70 * documentation and/or other materials provided with the distribution.
71 * 3. All advertising materials mentioning features or use of this software
72 * must display the following acknowledgement:
73 * This product includes software developed by the University of
74 * California, Berkeley and its contributors.
75 * 4. Neither the name of the University nor the names of its contributors
76 * may be used to endorse or promote products derived from this software
77 * without specific prior written permission.
79 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
80 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
81 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
82 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
83 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
84 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
85 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
86 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
87 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
88 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
91 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
94 #ifndef _NETINET_ICMP6_H_
95 #define _NETINET_ICMP6_H_
96 #include <sys/appleapiopts.h>
98 #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
99 - sizeof(struct icmp6_hdr) */
102 u_int8_t icmp6_type
; /* type field */
103 u_int8_t icmp6_code
; /* code field */
104 u_int16_t icmp6_cksum
; /* checksum field */
106 u_int32_t icmp6_un_data32
[1]; /* type-specific field */
107 u_int16_t icmp6_un_data16
[2]; /* type-specific field */
108 u_int8_t icmp6_un_data8
[4]; /* type-specific field */
112 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
113 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
114 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
115 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
116 #define icmp6_mtu icmp6_data32[0] /* packet too big */
117 #define icmp6_id icmp6_data16[0] /* echo request/reply */
118 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
119 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
121 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
122 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
123 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
124 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
126 #define ICMP6_ECHO_REQUEST 128 /* echo service */
127 #define ICMP6_ECHO_REPLY 129 /* echo reply */
128 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
129 #define MLD6_LISTENER_QUERY 130 /* multicast listener query */
130 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
131 #define MLD6_LISTENER_REPORT 131 /* multicast listener report */
132 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
133 #define MLD6_LISTENER_DONE 132 /* multicast listener done */
136 #define MLD_LISTENER_QUERY MLD6_LISTENER_QUERY
137 #define MLD_LISTENER_REPORT MLD6_LISTENER_REPORT
138 #define MLD_LISTENER_DONE MLD6_LISTENER_DONE
141 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
142 #define ND_ROUTER_ADVERT 134 /* router advertisment */
143 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
144 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
145 #define ND_REDIRECT 137 /* redirect */
147 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
149 #define ICMP6_WRUREQUEST 139 /* who are you request */
150 #define ICMP6_WRUREPLY 140 /* who are you reply */
151 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
152 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
153 #define ICMP6_NI_QUERY 139 /* node information request */
154 #define ICMP6_NI_REPLY 140 /* node information reply */
156 /* The definitions below are experimental. TBA */
157 #define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
158 #define MLD6_MTRACE 201 /* mtrace messages */
161 #define MLD_MTRACE_RESP MLD6_MTRACE_RESP
162 #define MLD_MTRACE MLD6_MTRACE
165 #define ICMP6_HADISCOV_REQUEST 202 /* XXX To be defined */
166 #define ICMP6_HADISCOV_REPLY 203 /* XXX To be defined */
168 #define ICMP6_MAXTYPE 203
170 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
171 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
172 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
173 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
174 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
175 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
177 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
178 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
180 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
181 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
182 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
184 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
186 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
187 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
188 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
190 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
191 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
192 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
194 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
195 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
196 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
198 /* Used in kernel only */
199 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
200 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
203 * Multicast Listener Discovery
206 struct icmp6_hdr mld6_hdr
;
207 struct in6_addr mld6_addr
; /* multicast address */
210 #define mld6_type mld6_hdr.icmp6_type
211 #define mld6_code mld6_hdr.icmp6_code
212 #define mld6_cksum mld6_hdr.icmp6_cksum
213 #define mld6_maxdelay mld6_hdr.icmp6_data16[0]
214 #define mld6_reserved mld6_hdr.icmp6_data16[1]
220 struct nd_router_solicit
{ /* router solicitation */
221 struct icmp6_hdr nd_rs_hdr
;
222 /* could be followed by options */
225 #define nd_rs_type nd_rs_hdr.icmp6_type
226 #define nd_rs_code nd_rs_hdr.icmp6_code
227 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
228 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
230 struct nd_router_advert
{ /* router advertisement */
231 struct icmp6_hdr nd_ra_hdr
;
232 u_int32_t nd_ra_reachable
; /* reachable time */
233 u_int32_t nd_ra_retransmit
; /* retransmit timer */
234 /* could be followed by options */
237 #define nd_ra_type nd_ra_hdr.icmp6_type
238 #define nd_ra_code nd_ra_hdr.icmp6_code
239 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
240 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
241 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
242 #define ND_RA_FLAG_MANAGED 0x80
243 #define ND_RA_FLAG_OTHER 0x40
244 #define ND_RA_FLAG_HA 0x20
247 * Router preference values based on draft-draves-ipngwg-router-selection-01.
248 * These are non-standard definitions.
250 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
252 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
253 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
254 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
255 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
257 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
259 struct nd_neighbor_solicit
{ /* neighbor solicitation */
260 struct icmp6_hdr nd_ns_hdr
;
261 struct in6_addr nd_ns_target
; /*target address */
262 /* could be followed by options */
265 #define nd_ns_type nd_ns_hdr.icmp6_type
266 #define nd_ns_code nd_ns_hdr.icmp6_code
267 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
268 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
270 struct nd_neighbor_advert
{ /* neighbor advertisement */
271 struct icmp6_hdr nd_na_hdr
;
272 struct in6_addr nd_na_target
; /* target address */
273 /* could be followed by options */
276 #define nd_na_type nd_na_hdr.icmp6_type
277 #define nd_na_code nd_na_hdr.icmp6_code
278 #define nd_na_cksum nd_na_hdr.icmp6_cksum
279 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
280 #if BYTE_ORDER == BIG_ENDIAN
281 #define ND_NA_FLAG_ROUTER 0x80000000
282 #define ND_NA_FLAG_SOLICITED 0x40000000
283 #define ND_NA_FLAG_OVERRIDE 0x20000000
285 #if BYTE_ORDER == LITTLE_ENDIAN
286 #define ND_NA_FLAG_ROUTER 0x80
287 #define ND_NA_FLAG_SOLICITED 0x40
288 #define ND_NA_FLAG_OVERRIDE 0x20
292 struct nd_redirect
{ /* redirect */
293 struct icmp6_hdr nd_rd_hdr
;
294 struct in6_addr nd_rd_target
; /* target address */
295 struct in6_addr nd_rd_dst
; /* destination address */
296 /* could be followed by options */
299 #define nd_rd_type nd_rd_hdr.icmp6_type
300 #define nd_rd_code nd_rd_hdr.icmp6_code
301 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
302 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
304 struct nd_opt_hdr
{ /* Neighbor discovery option header */
305 u_int8_t nd_opt_type
;
307 /* followed by option specific data*/
310 #define ND_OPT_SOURCE_LINKADDR 1
311 #define ND_OPT_TARGET_LINKADDR 2
312 #define ND_OPT_PREFIX_INFORMATION 3
313 #define ND_OPT_REDIRECTED_HEADER 4
316 #define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
318 struct nd_opt_prefix_info
{ /* prefix information */
319 u_int8_t nd_opt_pi_type
;
320 u_int8_t nd_opt_pi_len
;
321 u_int8_t nd_opt_pi_prefix_len
;
322 u_int8_t nd_opt_pi_flags_reserved
;
323 u_int32_t nd_opt_pi_valid_time
;
324 u_int32_t nd_opt_pi_preferred_time
;
325 u_int32_t nd_opt_pi_reserved2
;
326 struct in6_addr nd_opt_pi_prefix
;
329 #define ND_OPT_PI_FLAG_ONLINK 0x80
330 #define ND_OPT_PI_FLAG_AUTO 0x40
332 struct nd_opt_rd_hdr
{ /* redirected header */
333 u_int8_t nd_opt_rh_type
;
334 u_int8_t nd_opt_rh_len
;
335 u_int16_t nd_opt_rh_reserved1
;
336 u_int32_t nd_opt_rh_reserved2
;
337 /* followed by IP header and data */
340 struct nd_opt_mtu
{ /* MTU option */
341 u_int8_t nd_opt_mtu_type
;
342 u_int8_t nd_opt_mtu_len
;
343 u_int16_t nd_opt_mtu_reserved
;
344 u_int32_t nd_opt_mtu_mtu
;
347 struct nd_opt_route_info
{ /* route info */
348 u_int8_t nd_opt_rti_type
;
349 u_int8_t nd_opt_rti_len
;
350 u_int8_t nd_opt_rti_prefixlen
;
351 u_int8_t nd_opt_rti_flags
;
352 u_int32_t nd_opt_rti_lifetime
;
353 /* followed by prefix */
360 struct icmp6_namelookup
{
361 struct icmp6_hdr icmp6_nl_hdr
;
362 u_int8_t icmp6_nl_nonce
[8];
363 int32_t icmp6_nl_ttl
;
365 u_int8_t icmp6_nl_len
;
366 u_int8_t icmp6_nl_name
[3];
368 /* could be followed by options */
372 * icmp6 node information
374 struct icmp6_nodeinfo
{
375 struct icmp6_hdr icmp6_ni_hdr
;
376 u_int8_t icmp6_ni_nonce
[8];
377 /* could be followed by reply data */
380 #define ni_type icmp6_ni_hdr.icmp6_type
381 #define ni_code icmp6_ni_hdr.icmp6_code
382 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
383 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
384 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
386 #define NI_QTYPE_NOOP 0 /* NOOP */
387 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
388 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
389 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
390 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
391 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
393 #if BYTE_ORDER == BIG_ENDIAN
394 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
395 #define NI_FQDN_FLAG_VALIDTTL 0x1
396 #elif BYTE_ORDER == LITTLE_ENDIAN
397 #define NI_SUPTYPE_FLAG_COMPRESS 0x0100
398 #define NI_FQDN_FLAG_VALIDTTL 0x0100
401 #ifdef NAME_LOOKUPS_04
402 #if BYTE_ORDER == BIG_ENDIAN
403 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
404 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
405 #define NI_NODEADDR_FLAG_GLOBAL 0x4
406 #define NI_NODEADDR_FLAG_ALL 0x8
407 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
408 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
409 #elif BYTE_ORDER == LITTLE_ENDIAN
410 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
411 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
412 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
413 #define NI_NODEADDR_FLAG_ALL 0x0800
414 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
415 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
417 #else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
418 #if BYTE_ORDER == BIG_ENDIAN
419 #define NI_NODEADDR_FLAG_TRUNCATE 0x1
420 #define NI_NODEADDR_FLAG_ALL 0x2
421 #define NI_NODEADDR_FLAG_COMPAT 0x4
422 #define NI_NODEADDR_FLAG_LINKLOCAL 0x8
423 #define NI_NODEADDR_FLAG_SITELOCAL 0x10
424 #define NI_NODEADDR_FLAG_GLOBAL 0x20
425 #define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
426 #elif BYTE_ORDER == LITTLE_ENDIAN
427 #define NI_NODEADDR_FLAG_TRUNCATE 0x0100
428 #define NI_NODEADDR_FLAG_ALL 0x0200
429 #define NI_NODEADDR_FLAG_COMPAT 0x0400
430 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
431 #define NI_NODEADDR_FLAG_SITELOCAL 0x1000
432 #define NI_NODEADDR_FLAG_GLOBAL 0x2000
433 #define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
437 struct ni_reply_fqdn
{
438 u_int32_t ni_fqdn_ttl
; /* TTL */
439 u_int8_t ni_fqdn_namelen
; /* length in octets of the FQDN */
440 u_int8_t ni_fqdn_name
[3]; /* XXX: alignment */
444 * Router Renumbering. as router-renum-08.txt
446 struct icmp6_router_renum
{ /* router renumbering header */
447 struct icmp6_hdr rr_hdr
;
450 u_int16_t rr_maxdelay
;
451 u_int32_t rr_reserved
;
454 #define ICMP6_RR_FLAGS_TEST 0x80
455 #define ICMP6_RR_FLAGS_REQRESULT 0x40
456 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
457 #define ICMP6_RR_FLAGS_SPECSITE 0x10
458 #define ICMP6_RR_FLAGS_PREVDONE 0x08
460 #define rr_type rr_hdr.icmp6_type
461 #define rr_code rr_hdr.icmp6_code
462 #define rr_cksum rr_hdr.icmp6_cksum
463 #define rr_seqnum rr_hdr.icmp6_data32[0]
465 struct rr_pco_match
{ /* match prefix part */
468 u_int8_t rpm_ordinal
;
469 u_int8_t rpm_matchlen
;
472 u_int16_t rpm_reserved
;
473 struct in6_addr rpm_prefix
;
476 #define RPM_PCO_ADD 1
477 #define RPM_PCO_CHANGE 2
478 #define RPM_PCO_SETGLOBAL 3
479 #define RPM_PCO_MAX 4
481 struct rr_pco_use
{ /* use prefix part */
483 u_int8_t rpu_keeplen
;
485 u_int8_t rpu_raflags
;
486 u_int32_t rpu_vltime
;
487 u_int32_t rpu_pltime
;
489 struct in6_addr rpu_prefix
;
491 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
492 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
494 #if BYTE_ORDER == BIG_ENDIAN
495 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
496 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
497 #elif BYTE_ORDER == LITTLE_ENDIAN
498 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
499 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
502 struct rr_result
{ /* router renumbering result message */
504 u_int8_t rrr_ordinal
;
505 u_int8_t rrr_matchedlen
;
507 struct in6_addr rrr_prefix
;
509 #if BYTE_ORDER == BIG_ENDIAN
510 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
511 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
512 #elif BYTE_ORDER == LITTLE_ENDIAN
513 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
514 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
518 * icmp6 filter structures.
521 struct icmp6_filter
{
522 u_int32_t icmp6_filt
[8];
526 #define ICMP6_FILTER_SETPASSALL(filterp) \
528 int i; u_char *ptr; \
529 ptr = (u_char *)filterp; \
530 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
533 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
534 bzero(filterp, sizeof(struct icmp6_filter))
536 #define ICMP6_FILTER_SETPASSALL(filterp) \
537 memset(filterp, 0xff, sizeof(struct icmp6_filter))
538 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
539 memset(filterp, 0x00, sizeof(struct icmp6_filter))
542 #define ICMP6_FILTER_SETPASS(type, filterp) \
543 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
544 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
545 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
546 #define ICMP6_FILTER_WILLPASS(type, filterp) \
547 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
548 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
549 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
552 * Variables related to this implementation
553 * of the internet control message protocol version 6.
555 struct icmp6errstat
{
556 u_quad_t icp6errs_dst_unreach_noroute
;
557 u_quad_t icp6errs_dst_unreach_admin
;
558 u_quad_t icp6errs_dst_unreach_beyondscope
;
559 u_quad_t icp6errs_dst_unreach_addr
;
560 u_quad_t icp6errs_dst_unreach_noport
;
561 u_quad_t icp6errs_packet_too_big
;
562 u_quad_t icp6errs_time_exceed_transit
;
563 u_quad_t icp6errs_time_exceed_reassembly
;
564 u_quad_t icp6errs_paramprob_header
;
565 u_quad_t icp6errs_paramprob_nextheader
;
566 u_quad_t icp6errs_paramprob_option
;
567 u_quad_t icp6errs_redirect
; /* we regard redirect as an error here */
568 u_quad_t icp6errs_unknown
;
572 /* statistics related to icmp6 packets generated */
573 u_quad_t icp6s_error
; /* # of calls to icmp6_error */
574 u_quad_t icp6s_canterror
; /* no error 'cuz old was icmp */
575 u_quad_t icp6s_toofreq
; /* no error 'cuz rate limitation */
576 u_quad_t icp6s_outhist
[256];
577 /* statistics related to input message processed */
578 u_quad_t icp6s_badcode
; /* icmp6_code out of range */
579 u_quad_t icp6s_tooshort
; /* packet < sizeof(struct icmp6_hdr) */
580 u_quad_t icp6s_checksum
; /* bad checksum */
581 u_quad_t icp6s_badlen
; /* calculated bound mismatch */
582 u_quad_t icp6s_reflect
; /* number of responses */
583 u_quad_t icp6s_inhist
[256];
584 u_quad_t icp6s_nd_toomanyopt
; /* too many ND options */
585 struct icmp6errstat icp6s_outerrhist
;
586 #define icp6s_odst_unreach_noroute \
587 icp6s_outerrhist.icp6errs_dst_unreach_noroute
588 #define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
589 #define icp6s_odst_unreach_beyondscope \
590 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
591 #define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
592 #define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
593 #define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
594 #define icp6s_otime_exceed_transit \
595 icp6s_outerrhist.icp6errs_time_exceed_transit
596 #define icp6s_otime_exceed_reassembly \
597 icp6s_outerrhist.icp6errs_time_exceed_reassembly
598 #define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
599 #define icp6s_oparamprob_nextheader \
600 icp6s_outerrhist.icp6errs_paramprob_nextheader
601 #define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
602 #define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
603 #define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
604 u_quad_t icp6s_pmtuchg
; /* path MTU changes */
605 u_quad_t icp6s_nd_badopt
; /* bad ND options */
606 u_quad_t icp6s_badns
; /* bad neighbor solicitation */
607 u_quad_t icp6s_badna
; /* bad neighbor advertisement */
608 u_quad_t icp6s_badrs
; /* bad router advertisement */
609 u_quad_t icp6s_badra
; /* bad router advertisement */
610 u_quad_t icp6s_badredirect
; /* bad redirect message */
614 * Names for ICMP sysctl objects
616 #define ICMPV6CTL_STATS 1
617 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
618 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
619 #define ICMPV6CTL_ND6_PRUNE 6
620 #define ICMPV6CTL_ND6_DELAY 8
621 #define ICMPV6CTL_ND6_UMAXTRIES 9
622 #define ICMPV6CTL_ND6_MMAXTRIES 10
623 #define ICMPV6CTL_ND6_USELOOPBACK 11
624 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
625 #define ICMPV6CTL_NODEINFO 13
626 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
627 #define ICMPV6CTL_ND6_MAXNUDHINT 15
628 #define ICMPV6CTL_MTUDISC_HIWAT 16
629 #define ICMPV6CTL_MTUDISC_LOWAT 17
630 #define ICMPV6CTL_ND6_DEBUG 18
631 #define ICMPV6CTL_ND6_DRLIST 19
632 #define ICMPV6CTL_ND6_PRLIST 20
633 #define ICMPV6CTL_MAXID 21
635 #ifdef KERNEL_PRIVATE
636 #define ICMPV6CTL_NAMES { \
639 { "rediraccept", CTLTYPE_INT }, \
640 { "redirtimeout", CTLTYPE_INT }, \
643 { "nd6_prune", CTLTYPE_INT }, \
645 { "nd6_delay", CTLTYPE_INT }, \
646 { "nd6_umaxtries", CTLTYPE_INT }, \
647 { "nd6_mmaxtries", CTLTYPE_INT }, \
648 { "nd6_useloopback", CTLTYPE_INT }, \
650 { "nodeinfo", CTLTYPE_INT }, \
651 { "errppslimit", CTLTYPE_INT }, \
652 { "nd6_maxnudhint", CTLTYPE_INT }, \
653 { "mtudisc_hiwat", CTLTYPE_INT }, \
654 { "mtudisc_lowat", CTLTYPE_INT }, \
655 { "nd6_debug", CTLTYPE_INT }, \
660 #define RTF_PROBEMTU RTF_PROTO1
667 void icmp6_init(void);
668 void icmp6_paramerror(struct mbuf
*, int);
669 void icmp6_error(struct mbuf
*, int, int, int);
670 int icmp6_input(struct mbuf
**, int *);
671 void icmp6_fasttimo(void);
672 void icmp6_reflect(struct mbuf
*, size_t);
673 void icmp6_prepare(struct mbuf
*);
674 void icmp6_redirect_input(struct mbuf
*, int);
675 void icmp6_redirect_output(struct mbuf
*, struct rtentry
*);
678 void icmp6_mtudisc_update(struct ip6ctlparam
*, int);
680 /* XXX: is this the right place for these macros? */
681 #define icmp6_ifstat_inc(ifp, tag) \
683 if ((ifp) && (ifp)->if_index <= if_index \
684 && (ifp)->if_index < icmp6_ifstatmax \
685 && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) { \
686 icmp6_ifstat[(ifp)->if_index]->tag++; \
690 #define icmp6_ifoutstat_inc(ifp, type, code) \
692 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
693 if (type < ICMP6_INFOMSG_MASK) \
694 icmp6_ifstat_inc(ifp, ifs6_out_error); \
696 case ICMP6_DST_UNREACH: \
697 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
698 if (code == ICMP6_DST_UNREACH_ADMIN) \
699 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
701 case ICMP6_PACKET_TOO_BIG: \
702 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
704 case ICMP6_TIME_EXCEEDED: \
705 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
707 case ICMP6_PARAM_PROB: \
708 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
710 case ICMP6_ECHO_REQUEST: \
711 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
713 case ICMP6_ECHO_REPLY: \
714 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
716 case MLD6_LISTENER_QUERY: \
717 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
719 case MLD6_LISTENER_REPORT: \
720 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
722 case MLD6_LISTENER_DONE: \
723 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
725 case ND_ROUTER_SOLICIT: \
726 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
728 case ND_ROUTER_ADVERT: \
729 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
731 case ND_NEIGHBOR_SOLICIT: \
732 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
734 case ND_NEIGHBOR_ADVERT: \
735 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
738 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
743 extern int icmp6_rediraccept
; /* accept/process redirects */
744 extern int icmp6_redirtimeout
; /* cache time for redirect routes */
745 #endif /* KERNEL_PRIVATE */
747 #endif /* !_NETINET_ICMP6_H_ */