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