2 * Copyright (c) 2000,2008-2010 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 #ifdef XNU_KERNEL_PRIVATE
99 #include <sys/mcache.h>
102 #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
103 - sizeof(struct icmp6_hdr) */
106 u_int8_t icmp6_type
; /* type field */
107 u_int8_t icmp6_code
; /* code field */
108 u_int16_t icmp6_cksum
; /* checksum field */
110 u_int32_t icmp6_un_data32
[1]; /* type-specific field */
111 u_int16_t icmp6_un_data16
[2]; /* type-specific field */
112 u_int8_t icmp6_un_data8
[4]; /* type-specific field */
114 } __attribute__((__packed__
));
116 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
117 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
118 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
119 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
120 #define icmp6_mtu icmp6_data32[0] /* packet too big */
121 #define icmp6_id icmp6_data16[0] /* echo request/reply */
122 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
123 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
125 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
126 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
127 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
128 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
130 #define ICMP6_ECHO_REQUEST 128 /* echo service */
131 #define ICMP6_ECHO_REPLY 129 /* echo reply */
132 #define MLD_LISTENER_QUERY 130 /* multicast listener query */
133 #define MLD_LISTENER_REPORT 131 /* multicast listener report */
134 #define MLD_LISTENER_DONE 132 /* multicast listener done */
135 #define MLD_LISTENER_REDUCTION MLD_LISTENER_DONE /* RFC3542 definition */
138 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
139 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
140 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
143 /* the followings are for backward compatibility to old KAME apps. */
144 #define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY
145 #define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT
146 #define MLD6_LISTENER_DONE MLD_LISTENER_DONE
149 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
150 #define ND_ROUTER_ADVERT 134 /* router advertisement */
151 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
152 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
153 #define ND_REDIRECT 137 /* redirect */
155 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
157 #define ICMP6_WRUREQUEST 139 /* who are you request */
158 #define ICMP6_WRUREPLY 140 /* who are you reply */
159 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
160 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
161 #define ICMP6_NI_QUERY 139 /* node information request */
162 #define ICMP6_NI_REPLY 140 /* node information reply */
163 #define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */
165 /* The definitions below are experimental. TBA */
166 #define MLD_MTRACE_RESP 200 /* mtrace resp (to sender) */
167 #define MLD_MTRACE 201 /* mtrace messages */
170 #define MLD6_MTRACE_RESP MLD_MTRACE_RESP
171 #define MLD6_MTRACE MLD_MTRACE
174 #define ICMP6_MAXTYPE 201
176 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
177 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
178 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
179 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
180 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
181 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
183 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
184 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
186 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
187 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
188 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
190 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
192 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
193 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
194 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
196 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
197 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
198 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
200 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
201 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
202 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
204 /* Used in kernel only */
205 #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
206 #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
209 * Multicast Listener Discovery
212 struct icmp6_hdr mld_icmp6_hdr
;
213 struct in6_addr mld_addr
; /* multicast address */
214 } __attribute__((__packed__
));
216 /* definitions to provide backward compatibility to old KAME applications */
218 #define mld6_hdr mld_hdr
219 #define mld6_type mld_type
220 #define mld6_code mld_code
221 #define mld6_cksum mld_cksum
222 #define mld6_maxdelay mld_maxdelay
223 #define mld6_reserved mld_reserved
224 #define mld6_addr mld_addr
227 /* shortcut macro definitions */
228 #define mld_type mld_icmp6_hdr.icmp6_type
229 #define mld_code mld_icmp6_hdr.icmp6_code
230 #define mld_cksum mld_icmp6_hdr.icmp6_cksum
231 #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
232 #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
233 #define mld_v2_reserved mld_icmp6_hdr.icmp6_data16[0]
234 #define mld_v2_numrecs mld_icmp6_hdr.icmp6_data16[1]
240 struct nd_router_solicit
{ /* router solicitation */
241 struct icmp6_hdr nd_rs_hdr
;
242 /* could be followed by options */
243 }__attribute__((__packed__
));
245 #define nd_rs_type nd_rs_hdr.icmp6_type
246 #define nd_rs_code nd_rs_hdr.icmp6_code
247 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
248 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
250 struct nd_router_advert
{ /* router advertisement */
251 struct icmp6_hdr nd_ra_hdr
;
252 u_int32_t nd_ra_reachable
; /* reachable time */
253 u_int32_t nd_ra_retransmit
; /* retransmit timer */
254 /* could be followed by options */
255 } __attribute__((__packed__
));
257 #define nd_ra_type nd_ra_hdr.icmp6_type
258 #define nd_ra_code nd_ra_hdr.icmp6_code
259 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
260 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
261 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
262 #define ND_RA_FLAG_MANAGED 0x80
263 #define ND_RA_FLAG_OTHER 0x40
264 #define ND_RA_FLAG_HA 0x20
267 * Router preference values based on draft-draves-ipngwg-router-selection-01.
268 * These are non-standard definitions.
270 #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
272 #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
273 #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
274 #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
275 #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
277 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
279 struct nd_neighbor_solicit
{ /* neighbor solicitation */
280 struct icmp6_hdr nd_ns_hdr
;
281 struct in6_addr nd_ns_target
; /*target address */
282 /* could be followed by options */
283 }__attribute__((__packed__
));
285 #define nd_ns_type nd_ns_hdr.icmp6_type
286 #define nd_ns_code nd_ns_hdr.icmp6_code
287 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
288 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
290 struct nd_neighbor_advert
{ /* neighbor advertisement */
291 struct icmp6_hdr nd_na_hdr
;
292 struct in6_addr nd_na_target
; /* target address */
293 /* could be followed by options */
294 }__attribute__((__packed__
));
296 #define nd_na_type nd_na_hdr.icmp6_type
297 #define nd_na_code nd_na_hdr.icmp6_code
298 #define nd_na_cksum nd_na_hdr.icmp6_cksum
299 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
300 #if BYTE_ORDER == BIG_ENDIAN
301 #define ND_NA_FLAG_ROUTER 0x80000000
302 #define ND_NA_FLAG_SOLICITED 0x40000000
303 #define ND_NA_FLAG_OVERRIDE 0x20000000
305 #if BYTE_ORDER == LITTLE_ENDIAN
306 #define ND_NA_FLAG_ROUTER 0x80
307 #define ND_NA_FLAG_SOLICITED 0x40
308 #define ND_NA_FLAG_OVERRIDE 0x20
312 struct nd_redirect
{ /* redirect */
313 struct icmp6_hdr nd_rd_hdr
;
314 struct in6_addr nd_rd_target
; /* target address */
315 struct in6_addr nd_rd_dst
; /* destination address */
316 /* could be followed by options */
317 }__attribute__((__packed__
));
319 #define nd_rd_type nd_rd_hdr.icmp6_type
320 #define nd_rd_code nd_rd_hdr.icmp6_code
321 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
322 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
324 struct nd_opt_hdr
{ /* Neighbor discovery option header */
325 u_int8_t nd_opt_type
;
327 /* followed by option specific data*/
328 }__attribute__((__packed__
));
330 #define ND_OPT_SOURCE_LINKADDR 1
331 #define ND_OPT_TARGET_LINKADDR 2
332 #define ND_OPT_PREFIX_INFORMATION 3
333 #define ND_OPT_REDIRECTED_HEADER 4
335 #define ND_OPT_RDNSS 25 /* RFC 5006 */
337 #define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
339 struct nd_opt_prefix_info
{ /* prefix information */
340 u_int8_t nd_opt_pi_type
;
341 u_int8_t nd_opt_pi_len
;
342 u_int8_t nd_opt_pi_prefix_len
;
343 u_int8_t nd_opt_pi_flags_reserved
;
344 u_int32_t nd_opt_pi_valid_time
;
345 u_int32_t nd_opt_pi_preferred_time
;
346 u_int32_t nd_opt_pi_reserved2
;
347 struct in6_addr nd_opt_pi_prefix
;
348 }__attribute__((__packed__
));
350 #define ND_OPT_PI_FLAG_ONLINK 0x80
351 #define ND_OPT_PI_FLAG_AUTO 0x40
353 struct nd_opt_rd_hdr
{ /* redirected header */
354 u_int8_t nd_opt_rh_type
;
355 u_int8_t nd_opt_rh_len
;
356 u_int16_t nd_opt_rh_reserved1
;
357 u_int32_t nd_opt_rh_reserved2
;
358 /* followed by IP header and data */
359 } __attribute__((__packed__
));
361 struct nd_opt_mtu
{ /* MTU option */
362 u_int8_t nd_opt_mtu_type
;
363 u_int8_t nd_opt_mtu_len
;
364 u_int16_t nd_opt_mtu_reserved
;
365 u_int32_t nd_opt_mtu_mtu
;
366 }__attribute__((__packed__
));
368 struct nd_opt_route_info
{ /* route info */
369 u_int8_t nd_opt_rti_type
;
370 u_int8_t nd_opt_rti_len
;
371 u_int8_t nd_opt_rti_prefixlen
;
372 u_int8_t nd_opt_rti_flags
;
373 u_int32_t nd_opt_rti_lifetime
;
375 }__attribute__((__packed__
));
377 struct nd_opt_rdnss
{ /* recursive domain name system servers */
378 u_int8_t nd_opt_rdnss_type
;
379 u_int8_t nd_opt_rdnss_len
;
380 u_int16_t nd_opt_rdnss_reserved
;
381 u_int32_t nd_opt_rdnss_lifetime
;
382 struct in6_addr nd_opt_rdnss_addr
[1];
383 } __attribute__((__packed__
));
389 struct icmp6_namelookup
{
390 struct icmp6_hdr icmp6_nl_hdr
;
391 u_int8_t icmp6_nl_nonce
[8];
392 int32_t icmp6_nl_ttl
;
394 u_int8_t icmp6_nl_len
;
395 u_int8_t icmp6_nl_name
[3];
397 /* could be followed by options */
398 }__attribute__((__packed__
));
401 * icmp6 node information
403 struct icmp6_nodeinfo
{
404 struct icmp6_hdr icmp6_ni_hdr
;
405 u_int8_t icmp6_ni_nonce
[8];
406 /* could be followed by reply data */
407 }__attribute__((__packed__
));
409 #define ni_type icmp6_ni_hdr.icmp6_type
410 #define ni_code icmp6_ni_hdr.icmp6_code
411 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
412 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
413 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
415 #define NI_QTYPE_NOOP 0 /* NOOP */
416 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
417 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
418 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
419 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
420 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
422 #if BYTE_ORDER == BIG_ENDIAN
423 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
424 #define NI_FQDN_FLAG_VALIDTTL 0x1
425 #elif BYTE_ORDER == LITTLE_ENDIAN
426 #define NI_SUPTYPE_FLAG_COMPRESS 0x0100
427 #define NI_FQDN_FLAG_VALIDTTL 0x0100
430 #ifdef NAME_LOOKUPS_04
431 #if BYTE_ORDER == BIG_ENDIAN
432 #define NI_NODEADDR_FLAG_LINKLOCAL 0x1
433 #define NI_NODEADDR_FLAG_SITELOCAL 0x2
434 #define NI_NODEADDR_FLAG_GLOBAL 0x4
435 #define NI_NODEADDR_FLAG_ALL 0x8
436 #define NI_NODEADDR_FLAG_TRUNCATE 0x10
437 #define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
438 #elif BYTE_ORDER == LITTLE_ENDIAN
439 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
440 #define NI_NODEADDR_FLAG_SITELOCAL 0x0200
441 #define NI_NODEADDR_FLAG_GLOBAL 0x0400
442 #define NI_NODEADDR_FLAG_ALL 0x0800
443 #define NI_NODEADDR_FLAG_TRUNCATE 0x1000
444 #define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
446 #else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
447 #if BYTE_ORDER == BIG_ENDIAN
448 #define NI_NODEADDR_FLAG_TRUNCATE 0x1
449 #define NI_NODEADDR_FLAG_ALL 0x2
450 #define NI_NODEADDR_FLAG_COMPAT 0x4
451 #define NI_NODEADDR_FLAG_LINKLOCAL 0x8
452 #define NI_NODEADDR_FLAG_SITELOCAL 0x10
453 #define NI_NODEADDR_FLAG_GLOBAL 0x20
454 #define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
455 #elif BYTE_ORDER == LITTLE_ENDIAN
456 #define NI_NODEADDR_FLAG_TRUNCATE 0x0100
457 #define NI_NODEADDR_FLAG_ALL 0x0200
458 #define NI_NODEADDR_FLAG_COMPAT 0x0400
459 #define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
460 #define NI_NODEADDR_FLAG_SITELOCAL 0x1000
461 #define NI_NODEADDR_FLAG_GLOBAL 0x2000
462 #define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
466 struct ni_reply_fqdn
{
467 u_int32_t ni_fqdn_ttl
; /* TTL */
468 u_int8_t ni_fqdn_namelen
; /* length in octets of the FQDN */
469 u_int8_t ni_fqdn_name
[3]; /* XXX: alignment */
470 }__attribute__((__packed__
));
473 * Router Renumbering. as router-renum-08.txt
475 struct icmp6_router_renum
{ /* router renumbering header */
476 struct icmp6_hdr rr_hdr
;
479 u_int16_t rr_maxdelay
;
480 u_int32_t rr_reserved
;
481 } __attribute__((__packed__
));
483 #define ICMP6_RR_FLAGS_TEST 0x80
484 #define ICMP6_RR_FLAGS_REQRESULT 0x40
485 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
486 #define ICMP6_RR_FLAGS_SPECSITE 0x10
487 #define ICMP6_RR_FLAGS_PREVDONE 0x08
489 #define rr_type rr_hdr.icmp6_type
490 #define rr_code rr_hdr.icmp6_code
491 #define rr_cksum rr_hdr.icmp6_cksum
492 #define rr_seqnum rr_hdr.icmp6_data32[0]
494 struct rr_pco_match
{ /* match prefix part */
497 u_int8_t rpm_ordinal
;
498 u_int8_t rpm_matchlen
;
501 u_int16_t rpm_reserved
;
502 struct in6_addr rpm_prefix
;
503 } __attribute__((__packed__
));
505 #define RPM_PCO_ADD 1
506 #define RPM_PCO_CHANGE 2
507 #define RPM_PCO_SETGLOBAL 3
508 #define RPM_PCO_MAX 4
510 struct rr_pco_use
{ /* use prefix part */
512 u_int8_t rpu_keeplen
;
514 u_int8_t rpu_raflags
;
515 u_int32_t rpu_vltime
;
516 u_int32_t rpu_pltime
;
518 struct in6_addr rpu_prefix
;
519 } __attribute__((__packed__
));
520 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
521 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
523 #if BYTE_ORDER == BIG_ENDIAN
524 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
525 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
526 #elif BYTE_ORDER == LITTLE_ENDIAN
527 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
528 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
531 struct rr_result
{ /* router renumbering result message */
533 u_int8_t rrr_ordinal
;
534 u_int8_t rrr_matchedlen
;
536 struct in6_addr rrr_prefix
;
537 } __attribute__((__packed__
));
538 #if BYTE_ORDER == BIG_ENDIAN
539 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
540 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
541 #elif BYTE_ORDER == LITTLE_ENDIAN
542 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
543 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
547 * icmp6 filter structures.
550 struct icmp6_filter
{
551 u_int32_t icmp6_filt
[8];
555 #define ICMP6_FILTER_SETPASSALL(filterp) \
557 int i; u_char *ptr; \
558 ptr = (u_char *)filterp; \
559 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
562 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
563 bzero(filterp, sizeof(struct icmp6_filter))
565 #define ICMP6_FILTER_SETPASSALL(filterp) \
566 memset(filterp, 0xff, sizeof(struct icmp6_filter))
567 #define ICMP6_FILTER_SETBLOCKALL(filterp) \
568 memset(filterp, 0x00, sizeof(struct icmp6_filter))
571 #define ICMP6_FILTER_SETPASS(type, filterp) \
572 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
573 #define ICMP6_FILTER_SETBLOCK(type, filterp) \
574 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
575 #define ICMP6_FILTER_WILLPASS(type, filterp) \
576 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
577 #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
578 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
581 * Variables related to this implementation
582 * of the internet control message protocol version 6.
584 struct icmp6errstat
{
585 u_quad_t icp6errs_dst_unreach_noroute
;
586 u_quad_t icp6errs_dst_unreach_admin
;
587 u_quad_t icp6errs_dst_unreach_beyondscope
;
588 u_quad_t icp6errs_dst_unreach_addr
;
589 u_quad_t icp6errs_dst_unreach_noport
;
590 u_quad_t icp6errs_packet_too_big
;
591 u_quad_t icp6errs_time_exceed_transit
;
592 u_quad_t icp6errs_time_exceed_reassembly
;
593 u_quad_t icp6errs_paramprob_header
;
594 u_quad_t icp6errs_paramprob_nextheader
;
595 u_quad_t icp6errs_paramprob_option
;
596 u_quad_t icp6errs_redirect
; /* we regard redirect as an error here */
597 u_quad_t icp6errs_unknown
;
601 /* statistics related to icmp6 packets generated */
602 u_quad_t icp6s_error
; /* # of calls to icmp6_error */
603 u_quad_t icp6s_canterror
; /* no error 'cuz old was icmp */
604 u_quad_t icp6s_toofreq
; /* no error 'cuz rate limitation */
605 u_quad_t icp6s_outhist
[256];
606 /* statistics related to input message processed */
607 u_quad_t icp6s_badcode
; /* icmp6_code out of range */
608 u_quad_t icp6s_tooshort
; /* packet < sizeof(struct icmp6_hdr) */
609 u_quad_t icp6s_checksum
; /* bad checksum */
610 u_quad_t icp6s_badlen
; /* calculated bound mismatch */
611 u_quad_t icp6s_reflect
; /* number of responses */
612 u_quad_t icp6s_inhist
[256];
613 u_quad_t icp6s_nd_toomanyopt
; /* too many ND options */
614 struct icmp6errstat icp6s_outerrhist
;
615 #define icp6s_odst_unreach_noroute \
616 icp6s_outerrhist.icp6errs_dst_unreach_noroute
617 #define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
618 #define icp6s_odst_unreach_beyondscope \
619 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
620 #define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
621 #define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
622 #define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
623 #define icp6s_otime_exceed_transit \
624 icp6s_outerrhist.icp6errs_time_exceed_transit
625 #define icp6s_otime_exceed_reassembly \
626 icp6s_outerrhist.icp6errs_time_exceed_reassembly
627 #define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
628 #define icp6s_oparamprob_nextheader \
629 icp6s_outerrhist.icp6errs_paramprob_nextheader
630 #define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
631 #define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
632 #define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
633 u_quad_t icp6s_pmtuchg
; /* path MTU changes */
634 u_quad_t icp6s_nd_badopt
; /* bad ND options */
635 u_quad_t icp6s_badns
; /* bad neighbor solicitation */
636 u_quad_t icp6s_badna
; /* bad neighbor advertisement */
637 u_quad_t icp6s_badrs
; /* bad router advertisement */
638 u_quad_t icp6s_badra
; /* bad router advertisement */
639 u_quad_t icp6s_badredirect
; /* bad redirect message */
643 * Names for ICMP sysctl objects
645 #define ICMPV6CTL_STATS 1
646 #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
647 #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
649 #define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
651 #define ICMPV6CTL_ND6_PRUNE 6
652 #define ICMPV6CTL_ND6_DELAY 8
653 #define ICMPV6CTL_ND6_UMAXTRIES 9
654 #define ICMPV6CTL_ND6_MMAXTRIES 10
655 #define ICMPV6CTL_ND6_USELOOPBACK 11
656 /*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
657 #define ICMPV6CTL_NODEINFO 13
658 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
659 #define ICMPV6CTL_ND6_MAXNUDHINT 15
660 #define ICMPV6CTL_MTUDISC_HIWAT 16
661 #define ICMPV6CTL_MTUDISC_LOWAT 17
662 #define ICMPV6CTL_ND6_DEBUG 18
663 #define ICMPV6CTL_ND6_DRLIST 19
664 #define ICMPV6CTL_ND6_PRLIST 20
665 #define ICMPV6CTL_MLD_MAXSRCFILTER 21
666 #define ICMPV6CTL_MLD_SOMAXSRC 22
667 #define ICMPV6CTL_MLD_VERSION 23
668 #define ICMPV6CTL_ND6_MAXQLEN 24
669 #define ICMPV6CTL_ND6_ACCEPT_6TO4 25
670 #define ICMPV6CTL_MAXID 26
672 #ifdef KERNEL_PRIVATE
673 #define ICMPV6CTL_NAMES { \
676 { "rediraccept", CTLTYPE_INT }, \
677 { "redirtimeout", CTLTYPE_INT }, \
680 { "nd6_prune", CTLTYPE_INT }, \
682 { "nd6_delay", CTLTYPE_INT }, \
683 { "nd6_umaxtries", CTLTYPE_INT }, \
684 { "nd6_mmaxtries", CTLTYPE_INT }, \
685 { "nd6_useloopback", CTLTYPE_INT }, \
687 { "nodeinfo", CTLTYPE_INT }, \
688 { "errppslimit", CTLTYPE_INT }, \
689 { "nd6_maxnudhint", CTLTYPE_INT }, \
690 { "mtudisc_hiwat", CTLTYPE_INT }, \
691 { "mtudisc_lowat", CTLTYPE_INT }, \
692 { "nd6_debug", CTLTYPE_INT }, \
699 { "nd6_accept_6to4", CTLTYPE_INT }, \
702 #define RTF_PROBEMTU RTF_PROTO1
709 void icmp6_init(void);
710 void icmp6_paramerror(struct mbuf
*, int);
711 void icmp6_error(struct mbuf
*, int, int, int);
712 void icmp6_error2(struct mbuf
*, int, int, int, struct ifnet
*);
713 int icmp6_input(struct mbuf
**, int *, int);
714 void icmp6_reflect(struct mbuf
*, size_t);
715 void icmp6_prepare(struct mbuf
*);
716 void icmp6_redirect_input(struct mbuf
*, int);
717 void icmp6_redirect_output(struct mbuf
*, struct rtentry
*);
720 void icmp6_mtudisc_update(struct ip6ctlparam
*, int);
722 extern lck_rw_t icmp6_ifs_rwlock
;
723 /* XXX: is this the right place for these macros? */
724 #define icmp6_ifstat_inc(ifp, tag) \
726 lck_rw_lock_shared(&icmp6_ifs_rwlock); \
727 if ((ifp) && (ifp)->if_index <= if_index \
728 && (ifp)->if_index < icmp6_ifstatmax \
729 && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) { \
730 atomic_add_64(&icmp6_ifstat[(ifp)->if_index]->tag, 1); \
732 lck_rw_done(&icmp6_ifs_rwlock); \
735 #define icmp6_ifoutstat_inc(ifp, type, code) \
737 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
738 if (type < ICMP6_INFOMSG_MASK) \
739 icmp6_ifstat_inc(ifp, ifs6_out_error); \
741 case ICMP6_DST_UNREACH: \
742 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
743 if (code == ICMP6_DST_UNREACH_ADMIN) \
744 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
746 case ICMP6_PACKET_TOO_BIG: \
747 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
749 case ICMP6_TIME_EXCEEDED: \
750 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
752 case ICMP6_PARAM_PROB: \
753 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
755 case ICMP6_ECHO_REQUEST: \
756 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
758 case ICMP6_ECHO_REPLY: \
759 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
761 case MLD_LISTENER_QUERY: \
762 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
764 case MLD_LISTENER_REPORT: \
765 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
767 case MLD_LISTENER_DONE: \
768 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
770 case ND_ROUTER_SOLICIT: \
771 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
773 case ND_ROUTER_ADVERT: \
774 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
776 case ND_NEIGHBOR_SOLICIT: \
777 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
779 case ND_NEIGHBOR_ADVERT: \
780 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
783 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
788 extern int icmp6_rediraccept
; /* accept/process redirects */
789 extern int icmp6_redirtimeout
; /* cache time for redirect routes */
791 #define ICMP6_NODEINFO_FQDNOK 0x1
792 #define ICMP6_NODEINFO_NODEADDROK 0x2
793 #define ICMP6_NODEINFO_TMPADDROK 0x4
794 #define ICMP6_NODEINFO_GLOBALOK 0x8
796 #endif /* KERNEL_PRIVATE */
798 #endif /* !_NETINET_ICMP6_H_ */