]>
Commit | Line | Data |
---|---|---|
b0d623f7 | 1 | /* |
eb6b6ca3 | 2 | * Copyright (c) 2000-2020 Apple Inc. All rights reserved. |
b0d623f7 A |
3 | * |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
39236c6e | 5 | * |
b0d623f7 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 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. | |
39236c6e | 14 | * |
b0d623f7 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
39236c6e | 17 | * |
b0d623f7 A |
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. | |
39236c6e | 25 | * |
b0d623f7 A |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ | |
28 | ||
1c79356b A |
29 | /* |
30 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
31 | * All rights reserved. | |
32 | * | |
33 | * Redistribution and use in source and binary forms, with or without | |
34 | * modification, are permitted provided that the following conditions | |
35 | * are met: | |
36 | * 1. Redistributions of source code must retain the above copyright | |
37 | * notice, this list of conditions and the following disclaimer. | |
38 | * 2. Redistributions in binary form must reproduce the above copyright | |
39 | * notice, this list of conditions and the following disclaimer in the | |
40 | * documentation and/or other materials provided with the distribution. | |
41 | * 3. Neither the name of the project nor the names of its contributors | |
42 | * may be used to endorse or promote products derived from this software | |
43 | * without specific prior written permission. | |
44 | * | |
45 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | |
46 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
55 | * SUCH DAMAGE. | |
56 | */ | |
57 | ||
58 | /* | |
59 | * Copyright (c) 1982, 1986, 1993 | |
60 | * The Regents of the University of California. All rights reserved. | |
61 | * | |
62 | * Redistribution and use in source and binary forms, with or without | |
63 | * modification, are permitted provided that the following conditions | |
64 | * are met: | |
65 | * 1. Redistributions of source code must retain the above copyright | |
66 | * notice, this list of conditions and the following disclaimer. | |
67 | * 2. Redistributions in binary form must reproduce the above copyright | |
68 | * notice, this list of conditions and the following disclaimer in the | |
69 | * documentation and/or other materials provided with the distribution. | |
70 | * 3. All advertising materials mentioning features or use of this software | |
71 | * must display the following acknowledgement: | |
72 | * This product includes software developed by the University of | |
73 | * California, Berkeley and its contributors. | |
74 | * 4. Neither the name of the University nor the names of its contributors | |
75 | * may be used to endorse or promote products derived from this software | |
76 | * without specific prior written permission. | |
77 | * | |
78 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
79 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
80 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
81 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
82 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
83 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
84 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
85 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
86 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
87 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
88 | * SUCH DAMAGE. | |
89 | * | |
90 | * @(#)ip_var.h 8.1 (Berkeley) 6/10/93 | |
91 | */ | |
92 | ||
93 | #ifndef _NETINET6_IP6_VAR_H_ | |
0a7de745 | 94 | #define _NETINET6_IP6_VAR_H_ |
9bccf70c | 95 | #include <sys/appleapiopts.h> |
1c79356b | 96 | |
39236c6e A |
97 | #ifdef BSD_KERNEL_PRIVATE |
98 | #include <net/ethernet.h> | |
99 | ||
1c79356b A |
100 | /* |
101 | * IP6 reassembly queue structure. Each fragment | |
102 | * being reassembled is attached to one of these structures. | |
103 | */ | |
0a7de745 | 104 | struct ip6q { |
1c79356b A |
105 | struct ip6asfrag *ip6q_down; |
106 | struct ip6asfrag *ip6q_up; | |
0a7de745 A |
107 | u_int32_t ip6q_ident; |
108 | u_int8_t ip6q_nxt; | |
109 | u_int8_t ip6q_ecn; | |
110 | u_int8_t ip6q_ttl; | |
6d2010ae | 111 | struct in6_addr ip6q_src, ip6q_dst; |
0a7de745 A |
112 | struct ip6q *ip6q_next; |
113 | struct ip6q *ip6q_prev; | |
114 | int ip6q_unfrglen; /* len of unfragmentable part */ | |
39236c6e | 115 | #ifdef notyet |
0a7de745 | 116 | u_char *ip6q_nxtp; |
1c79356b | 117 | #endif |
0a7de745 A |
118 | int ip6q_nfrag; /* # of fragments */ |
119 | uint32_t ip6q_csum_flags; /* checksum flags */ | |
120 | uint32_t ip6q_csum; /* partial checksum value */ | |
1c79356b A |
121 | }; |
122 | ||
0a7de745 | 123 | struct ip6asfrag { |
1c79356b A |
124 | struct ip6asfrag *ip6af_down; |
125 | struct ip6asfrag *ip6af_up; | |
0a7de745 A |
126 | struct mbuf *ip6af_m; |
127 | int ip6af_offset; /* offset in ip6af_m to next header */ | |
128 | int ip6af_frglen; /* fragmentable part length */ | |
129 | int ip6af_off; /* fragment offset */ | |
130 | u_int16_t ip6af_mff; /* more fragment bit in frag off */ | |
1c79356b A |
131 | }; |
132 | ||
0a7de745 | 133 | #define IP6_REASS_MBUF(ip6af) (*(struct mbuf **)&((ip6af)->ip6af_m)) |
1c79356b | 134 | |
0a7de745 | 135 | struct ip6_moptions { |
6d2010ae | 136 | decl_lck_mtx_data(, im6o_lock); |
0a7de745 A |
137 | uint32_t im6o_refcnt; /* ref count */ |
138 | uint32_t im6o_debug; /* see ifa_debug flags */ | |
139 | struct ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */ | |
140 | u_char im6o_multicast_hlim; /* hoplimit for outgoing multicasts */ | |
141 | u_char im6o_multicast_loop; /* 1 >= hear sends if a member */ | |
142 | u_short im6o_num_memberships; /* no. memberships this socket */ | |
143 | u_short im6o_max_memberships; /* max memberships this socket */ | |
144 | struct in6_multi **im6o_membership; /* group memberships */ | |
145 | struct in6_mfilter *im6o_mfilters; /* source filters */ | |
146 | void (*im6o_trace) /* callback fn for tracing refs */ | |
147 | (struct ip6_moptions *, int); | |
1c79356b A |
148 | }; |
149 | ||
0a7de745 | 150 | #define IM6O_LOCK_ASSERT_HELD(_im6o) \ |
5ba3f43e | 151 | LCK_MTX_ASSERT(&(_im6o)->im6o_lock, LCK_MTX_ASSERT_OWNED) |
6d2010ae | 152 | |
0a7de745 | 153 | #define IM6O_LOCK_ASSERT_NOTHELD(_im6o) \ |
5ba3f43e | 154 | LCK_MTX_ASSERT(&(_im6o)->im6o_lock, LCK_MTX_ASSERT_NOTOWNED) |
6d2010ae | 155 | |
0a7de745 | 156 | #define IM6O_LOCK(_im6o) \ |
6d2010ae A |
157 | lck_mtx_lock(&(_im6o)->im6o_lock) |
158 | ||
0a7de745 | 159 | #define IM6O_LOCK_SPIN(_im6o) \ |
6d2010ae A |
160 | lck_mtx_lock_spin(&(_im6o)->im6o_lock) |
161 | ||
0a7de745 A |
162 | #define IM6O_CONVERT_LOCK(_im6o) do { \ |
163 | IM6O_LOCK_ASSERT_HELD(_im6o); \ | |
164 | lck_mtx_convert_spin(&(_im6o)->im6o_lock); \ | |
6d2010ae A |
165 | } while (0) |
166 | ||
0a7de745 | 167 | #define IM6O_UNLOCK(_im6o) \ |
6d2010ae A |
168 | lck_mtx_unlock(&(_im6o)->im6o_lock) |
169 | ||
0a7de745 | 170 | #define IM6O_ADDREF(_im6o) \ |
6d2010ae A |
171 | im6o_addref(_im6o, 0) |
172 | ||
0a7de745 | 173 | #define IM6O_ADDREF_LOCKED(_im6o) \ |
6d2010ae A |
174 | im6o_addref(_im6o, 1) |
175 | ||
0a7de745 | 176 | #define IM6O_REMREF(_im6o) \ |
6d2010ae A |
177 | im6o_remref(_im6o) |
178 | ||
316670eb A |
179 | struct ip6_exthdrs { |
180 | struct mbuf *ip6e_ip6; | |
181 | struct mbuf *ip6e_hbh; | |
182 | struct mbuf *ip6e_dest1; | |
183 | struct mbuf *ip6e_rthdr; | |
184 | struct mbuf *ip6e_dest2; | |
3e170ce0 | 185 | boolean_t merged; |
316670eb A |
186 | }; |
187 | ||
1c79356b A |
188 | /* |
189 | * Control options for outgoing packets | |
190 | */ | |
191 | ||
192 | /* Routing header related info */ | |
0a7de745 A |
193 | struct ip6po_rhinfo { |
194 | struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */ | |
195 | struct route_in6 ip6po_rhi_route; /* Route to the 1st hop */ | |
1c79356b | 196 | }; |
0a7de745 A |
197 | #define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr |
198 | #define ip6po_route ip6po_rhinfo.ip6po_rhi_route | |
1c79356b | 199 | |
6d2010ae | 200 | /* Nexthop related info */ |
0a7de745 A |
201 | struct ip6po_nhinfo { |
202 | struct sockaddr *ip6po_nhi_nexthop; | |
203 | struct route_in6 ip6po_nhi_route; /* Route to the nexthop */ | |
6d2010ae | 204 | }; |
0a7de745 A |
205 | #define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop |
206 | #define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route | |
6d2010ae | 207 | |
0a7de745 A |
208 | struct ip6_pktopts { |
209 | struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */ | |
210 | int ip6po_hlim; /* Hoplimit for outgoing packets */ | |
1c79356b A |
211 | |
212 | /* Outgoing IF/address information */ | |
0a7de745 | 213 | struct in6_pktinfo *ip6po_pktinfo; |
1c79356b | 214 | |
6d2010ae | 215 | /* Next-hop address information */ |
0a7de745 | 216 | struct ip6po_nhinfo ip6po_nhinfo; |
6d2010ae | 217 | |
0a7de745 | 218 | struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */ |
1c79356b A |
219 | |
220 | /* Destination options header (before a routing header) */ | |
0a7de745 | 221 | struct ip6_dest *ip6po_dest1; |
1c79356b A |
222 | |
223 | /* Routing header related info. */ | |
0a7de745 | 224 | struct ip6po_rhinfo ip6po_rhinfo; |
1c79356b A |
225 | |
226 | /* Destination options header (after a routing header) */ | |
0a7de745 | 227 | struct ip6_dest *ip6po_dest2; |
b0d623f7 | 228 | |
0a7de745 | 229 | int ip6po_tclass; /* traffic class */ |
6d2010ae | 230 | |
0a7de745 A |
231 | int ip6po_minmtu; /* fragment vs PMTU discovery policy */ |
232 | #define IP6PO_MINMTU_MCASTONLY -1 /* default; send at min MTU for multicast */ | |
233 | #define IP6PO_MINMTU_DISABLE 0 /* always perform pmtu disc */ | |
234 | #define IP6PO_MINMTU_ALL 1 /* always send at min MTU */ | |
39236c6e A |
235 | |
236 | /* whether temporary addresses are preferred as source address */ | |
0a7de745 | 237 | int ip6po_prefer_tempaddr; |
6d2010ae | 238 | |
0a7de745 A |
239 | #define IP6PO_TEMPADDR_SYSTEM -1 /* follow the system default */ |
240 | #define IP6PO_TEMPADDR_NOTPREFER 0 /* not prefer temporary address */ | |
241 | #define IP6PO_TEMPADDR_PREFER 1 /* prefer temporary address */ | |
6d2010ae A |
242 | |
243 | int ip6po_flags; | |
0a7de745 A |
244 | #if 0 /* parameters in this block is obsolete. do not reuse the values. */ |
245 | #define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation. */ | |
246 | #define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */ | |
6d2010ae | 247 | #endif |
0a7de745 A |
248 | #define IP6PO_DONTFRAG 0x04 /* no fragmentation (IPV6_DONTFRAG) */ |
249 | #define IP6PO_USECOA 0x08 /* use care of address */ | |
1c79356b A |
250 | }; |
251 | ||
252 | /* | |
253 | * Control options for incoming packets | |
254 | */ | |
39236c6e | 255 | #endif /* BSD_KERNEL_PRIVATE */ |
1c79356b | 256 | |
0a7de745 | 257 | #define IP6S_SRCRULE_COUNT 16 |
3e170ce0 A |
258 | #include <netinet6/scope6_var.h> |
259 | ||
0a7de745 A |
260 | struct ip6stat { |
261 | u_quad_t ip6s_total; /* total packets received */ | |
262 | u_quad_t ip6s_tooshort; /* packet too short */ | |
263 | u_quad_t ip6s_toosmall; /* not enough data */ | |
264 | u_quad_t ip6s_fragments; /* fragments received */ | |
265 | u_quad_t ip6s_fragdropped; /* frags dropped(dups, out of space) */ | |
266 | u_quad_t ip6s_fragtimeout; /* fragments timed out */ | |
267 | u_quad_t ip6s_fragoverflow; /* fragments that exceeded limit */ | |
268 | u_quad_t ip6s_forward; /* packets forwarded */ | |
269 | u_quad_t ip6s_cantforward; /* packets rcvd for unreachable dest */ | |
270 | u_quad_t ip6s_redirectsent; /* packets forwarded on same net */ | |
271 | u_quad_t ip6s_delivered; /* datagrams delivered to upper level */ | |
272 | u_quad_t ip6s_localout; /* total ip packets generated here */ | |
273 | u_quad_t ip6s_odropped; /* lost packets due to nobufs, etc. */ | |
274 | u_quad_t ip6s_reassembled; /* total packets reassembled ok */ | |
275 | u_quad_t ip6s_atmfrag_rcvd; /* atomic fragments received */ | |
276 | u_quad_t ip6s_fragmented; /* datagrams successfully fragmented */ | |
277 | u_quad_t ip6s_ofragments; /* output fragments created */ | |
278 | u_quad_t ip6s_cantfrag; /* don't fragment flag was set, etc. */ | |
279 | u_quad_t ip6s_badoptions; /* error in option processing */ | |
280 | u_quad_t ip6s_noroute; /* packets discarded due to no route */ | |
281 | u_quad_t ip6s_badvers; /* ip6 version != 6 */ | |
282 | u_quad_t ip6s_rawout; /* total raw ip packets generated */ | |
283 | u_quad_t ip6s_badscope; /* scope error */ | |
284 | u_quad_t ip6s_notmember; /* don't join this multicast group */ | |
285 | u_quad_t ip6s_nxthist[256]; /* next header history */ | |
286 | u_quad_t ip6s_m1; /* one mbuf */ | |
287 | u_quad_t ip6s_m2m[32]; /* two or more mbuf */ | |
288 | u_quad_t ip6s_mext1; /* one ext mbuf */ | |
289 | u_quad_t ip6s_mext2m; /* two or more ext mbuf */ | |
290 | u_quad_t ip6s_exthdrtoolong; /* ext hdr are not continuous */ | |
291 | u_quad_t ip6s_nogif; /* no match gif found */ | |
292 | u_quad_t ip6s_toomanyhdr; /* discarded due to too many headers */ | |
1c79356b A |
293 | |
294 | /* | |
295 | * statistics for improvement of the source address selection | |
296 | * algorithm: | |
1c79356b A |
297 | */ |
298 | /* number of times that address selection fails */ | |
299 | u_quad_t ip6s_sources_none; | |
300 | /* number of times that an address on the outgoing I/F is chosen */ | |
3e170ce0 | 301 | u_quad_t ip6s_sources_sameif[SCOPE6_ID_MAX]; |
1c79356b | 302 | /* number of times that an address on a non-outgoing I/F is chosen */ |
3e170ce0 | 303 | u_quad_t ip6s_sources_otherif[SCOPE6_ID_MAX]; |
1c79356b A |
304 | /* |
305 | * number of times that an address that has the same scope | |
306 | * from the destination is chosen. | |
307 | */ | |
3e170ce0 | 308 | u_quad_t ip6s_sources_samescope[SCOPE6_ID_MAX]; |
1c79356b A |
309 | /* |
310 | * number of times that an address that has a different scope | |
311 | * from the destination is chosen. | |
312 | */ | |
3e170ce0 | 313 | u_quad_t ip6s_sources_otherscope[SCOPE6_ID_MAX]; |
6d2010ae | 314 | /* number of times that a deprecated address is chosen */ |
3e170ce0 | 315 | u_quad_t ip6s_sources_deprecated[SCOPE6_ID_MAX]; |
9bccf70c A |
316 | |
317 | u_quad_t ip6s_forward_cachehit; | |
318 | u_quad_t ip6s_forward_cachemiss; | |
6d2010ae A |
319 | |
320 | /* number of times that each rule of source selection is applied. */ | |
3e170ce0 A |
321 | u_quad_t ip6s_sources_rule[IP6S_SRCRULE_COUNT]; |
322 | ||
323 | /* number of times we ignored address on expensive secondary interfaces */ | |
324 | u_quad_t ip6s_sources_skip_expensive_secondary_if; | |
325 | ||
39236c6e A |
326 | /* pkt dropped, no mbufs for control data */ |
327 | u_quad_t ip6s_pktdropcntrl; | |
328 | ||
329 | /* total packets trimmed/adjusted */ | |
330 | u_quad_t ip6s_adj; | |
331 | /* hwcksum info discarded during adjustment */ | |
332 | u_quad_t ip6s_adj_hwcsum_clr; | |
333 | ||
334 | /* duplicate address detection collisions */ | |
335 | u_quad_t ip6s_dad_collide; | |
39037602 A |
336 | |
337 | /* DAD NS looped back */ | |
338 | u_quad_t ip6s_dad_loopcount; | |
5ba3f43e A |
339 | |
340 | /* NECP policy related drop */ | |
341 | u_quad_t ip6s_necp_policy_drop; | |
d9a64523 A |
342 | |
343 | /* CLAT46 stats */ | |
344 | u_quad_t ip6s_clat464_in_tooshort_drop; | |
345 | u_quad_t ip6s_clat464_in_nov6addr_drop; | |
346 | u_quad_t ip6s_clat464_in_nov4addr_drop; | |
347 | u_quad_t ip6s_clat464_in_v4synthfail_drop; | |
348 | u_quad_t ip6s_clat464_in_64transfail_drop; | |
349 | u_quad_t ip6s_clat464_in_64proto_transfail_drop; | |
350 | u_quad_t ip6s_clat464_in_64frag_transfail_drop; | |
351 | u_quad_t ip6s_clat464_in_invalpbuf_drop; | |
352 | u_quad_t ip6s_clat464_in_success; | |
353 | u_quad_t ip6s_clat464_in_drop; | |
354 | u_quad_t ip6s_clat464_in_v4_drop; | |
355 | ||
356 | u_quad_t ip6s_clat464_out_nov6addr_drop; | |
357 | u_quad_t ip6s_clat464_out_v6synthfail_drop; | |
358 | u_quad_t ip6s_clat464_out_46transfail_drop; | |
359 | u_quad_t ip6s_clat464_out_46proto_transfail_drop; | |
360 | u_quad_t ip6s_clat464_out_46frag_transfail_drop; | |
361 | u_quad_t ip6s_clat464_out_invalpbuf_drop; | |
362 | u_quad_t ip6s_clat464_out_success; | |
363 | u_quad_t ip6s_clat464_out_drop; | |
364 | ||
365 | u_quad_t ip6s_clat464_v6addr_conffail; | |
366 | u_quad_t ip6s_clat464_plat64_pfx_setfail; | |
367 | u_quad_t ip6s_clat464_plat64_pfx_getfail; | |
eb6b6ca3 A |
368 | |
369 | u_quad_t ip6s_rcv_if_weak_match; | |
370 | u_quad_t ip6s_rcv_if_no_match; | |
9bccf70c A |
371 | }; |
372 | ||
fe8ab488 A |
373 | enum ip6s_sources_rule_index { |
374 | IP6S_SRCRULE_0, IP6S_SRCRULE_1, IP6S_SRCRULE_2, IP6S_SRCRULE_3, IP6S_SRCRULE_4, | |
5ba3f43e | 375 | IP6S_SRCRULE_5, IP6S_SRCRULE_6, IP6S_SRCRULE_7, |
fe8ab488 A |
376 | IP6S_SRCRULE_7x, IP6S_SRCRULE_8 |
377 | }; | |
378 | ||
39236c6e | 379 | #ifdef BSD_KERNEL_PRIVATE |
9bccf70c A |
380 | /* |
381 | * IPv6 onion peeling state. | |
39236c6e A |
382 | * |
383 | * This is currently allocated for packets destined to the all-nodes | |
384 | * multicast address over Ethernet. IPv6 destination address information | |
385 | * is now stored in the mbuf itself. | |
9bccf70c A |
386 | */ |
387 | struct ip6aux { | |
388 | u_int32_t ip6a_flags; | |
0a7de745 | 389 | #define IP6A_HASEEN 0x01 /* HA was present */ |
39236c6e A |
390 | |
391 | #ifdef notyet | |
0a7de745 A |
392 | #define IP6A_SWAP 0x02 /* swapped home/care-of on packet */ |
393 | #define IP6A_BRUID 0x04 /* BR Unique Identifier was present */ | |
394 | #define IP6A_RTALERTSEEN 0x08 /* rtalert present */ | |
9bccf70c A |
395 | |
396 | /* ip6.ip6_src */ | |
0a7de745 A |
397 | struct in6_addr ip6a_careof; /* care-of address of the peer */ |
398 | struct in6_addr ip6a_home; /* home address of the peer */ | |
399 | u_int16_t ip6a_bruid; /* BR unique identifier */ | |
9bccf70c | 400 | |
9bccf70c | 401 | /* rtalert */ |
0a7de745 | 402 | u_int16_t ip6a_rtalert; /* rtalert option value */ |
39236c6e | 403 | #endif /* notyet */ |
9bccf70c | 404 | |
39236c6e A |
405 | /* ether source address if all-nodes multicast destination */ |
406 | u_char ip6a_ehsrc[ETHER_ADDR_LEN]; | |
1c79356b A |
407 | }; |
408 | ||
1c79356b | 409 | /* flags passed to ip6_output as last parameter */ |
0a7de745 A |
410 | #define IPV6_UNSPECSRC 0x01 /* allow :: as the source address */ |
411 | #define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */ | |
412 | #define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */ | |
413 | #define IPV6_FLAG_NOSRCIFSEL 0x80 /* bypas source address selection */ | |
414 | #define IPV6_OUTARGS 0x100 /* has ancillary output info */ | |
6d2010ae | 415 | |
39236c6e | 416 | #ifdef BSD_KERNEL_PRIVATE |
0a7de745 | 417 | #define IP6_HDR_ALIGNED_P(_ip6) ((((uintptr_t)(_ip6)) & ((uintptr_t)3)) == 0) |
316670eb A |
418 | |
419 | /* | |
420 | * On platforms which require strict alignment (currently for anything but | |
421 | * i386 or x86_64), this macro checks whether the pointer to the IP header | |
422 | * is 32-bit aligned, and assert otherwise. | |
423 | */ | |
424 | #if defined(__i386__) || defined(__x86_64__) | |
0a7de745 | 425 | #define IP6_HDR_STRICT_ALIGNMENT_CHECK(_ip6) do { } while (0) |
316670eb | 426 | #else /* !__i386__ && !__x86_64__ */ |
0a7de745 A |
427 | #define IP6_HDR_STRICT_ALIGNMENT_CHECK(_ip6) do { \ |
428 | if (!IP_HDR_ALIGNED_P(_ip6)) { \ | |
429 | panic_plain("\n%s: Unaligned IPv6 header %p\n", \ | |
430 | __func__, _ip6); \ | |
431 | } \ | |
316670eb A |
432 | } while (0) |
433 | #endif /* !__i386__ && !__x86_64__ */ | |
39236c6e | 434 | #endif /* BSD_KERNEL_PRIVATE */ |
316670eb A |
435 | |
436 | #include <net/flowadv.h> | |
6d2010ae A |
437 | |
438 | /* | |
316670eb | 439 | * Extra information passed to ip6_output when IPV6_OUTARGS is set. |
6d2010ae A |
440 | */ |
441 | struct ip6_out_args { | |
0a7de745 A |
442 | unsigned int ip6oa_boundif; /* bound outgoing interface */ |
443 | struct flowadv ip6oa_flowadv; /* flow advisory code */ | |
444 | u_int32_t ip6oa_flags; /* IP6OAF flags (see below) */ | |
445 | #define IP6OAF_SELECT_SRCIF 0x00000001 /* src interface selection */ | |
446 | #define IP6OAF_BOUND_IF 0x00000002 /* boundif value is valid */ | |
447 | #define IP6OAF_BOUND_SRCADDR 0x00000004 /* bound to src address */ | |
448 | #define IP6OAF_NO_CELLULAR 0x00000010 /* skip IFT_CELLULAR */ | |
449 | #define IP6OAF_NO_EXPENSIVE 0x00000020 /* skip IFEF_EXPENSIVE */ | |
450 | #define IP6OAF_AWDL_UNRESTRICTED 0x00000040 /* privileged AWDL */ | |
451 | #define IP6OAF_QOSMARKING_ALLOWED 0x00000080 /* policy allows Fastlane DSCP marking */ | |
452 | #define IP6OAF_INTCOPROC_ALLOWED 0x00000100 /* access to internal coproc interfaces */ | |
453 | #define IP6OAF_NO_LOW_POWER 0x00000200 /* skip low power */ | |
cb323159 A |
454 | #define IP6OAF_NO_CONSTRAINED 0x00000400 /* skip IFXF_CONSTRAINED */ |
455 | #define IP6OAF_SKIP_PF 0x00000800 /* skip PF */ | |
0a7de745 A |
456 | u_int32_t ip6oa_retflags; /* IP6OARF return flags (see below) */ |
457 | #define IP6OARF_IFDENIED 0x00000001 /* denied access to interface */ | |
458 | int ip6oa_sotc; /* traffic class for Fastlane DSCP mapping */ | |
459 | int ip6oa_netsvctype; | |
6d2010ae | 460 | }; |
1c79356b | 461 | |
0a7de745 A |
462 | extern struct ip6stat ip6stat; /* statistics */ |
463 | extern int ip6_defhlim; /* default hop limit */ | |
464 | extern int ip6_defmcasthlim; /* default multicast hop limit */ | |
465 | extern int ip6_forwarding; /* act as router? */ | |
466 | extern int ip6_gif_hlim; /* Hop limit for gif encap packet */ | |
467 | extern int ip6_use_deprecated; /* allow deprecated addr as source */ | |
468 | extern int ip6_rr_prune; /* router renumbering prefix */ | |
469 | /* walk list every 5 sec. */ | |
470 | extern int ip6_mcast_pmtu; /* enable pMTU discovery for multicast? */ | |
471 | #define ip6_mapped_addr_on (!ip6_v6only) | |
39236c6e A |
472 | extern int ip6_v6only; |
473 | ||
474 | extern int ip6_neighborgcthresh; /* Threshold # of NDP entries for GC */ | |
0a7de745 A |
475 | extern int ip6_maxifprefixes; /* Max acceptable prefixes via RA per IF */ |
476 | extern int ip6_maxifdefrouters; /* Max acceptable def routers via RA */ | |
477 | extern int ip6_maxdynroutes; /* Max # of routes created via redirect */ | |
478 | extern int ip6_sendredirects; /* send IP redirects when forwarding? */ | |
479 | extern int ip6_accept_rtadv; /* deprecated */ | |
39236c6e A |
480 | extern int ip6_log_interval; |
481 | extern uint64_t ip6_log_time; | |
0a7de745 A |
482 | extern int ip6_hdrnestlimit; /* upper limit of # of extension headers */ |
483 | extern int ip6_dad_count; /* DupAddrDetectionTransmits */ | |
39236c6e A |
484 | |
485 | /* RFC4193 Unique Local Unicast Prefixes only */ | |
486 | extern int ip6_only_allow_rfc4193_prefix; | |
487 | ||
1c79356b | 488 | extern int ip6_auto_flowlabel; |
9bccf70c A |
489 | extern int ip6_auto_linklocal; |
490 | ||
0a7de745 A |
491 | extern int ip6_anonportmin; /* minimum ephemeral port */ |
492 | extern int ip6_anonportmax; /* maximum ephemeral port */ | |
493 | extern int ip6_lowportmin; /* minimum reserved port */ | |
494 | extern int ip6_lowportmax; /* maximum reserved port */ | |
9bccf70c | 495 | |
39236c6e | 496 | extern int ip6_use_tempaddr; /* whether to use temporary addresses. */ |
1c79356b | 497 | |
39236c6e A |
498 | /* whether to prefer temporary addresses in the source address selection */ |
499 | extern int ip6_prefer_tempaddr; | |
1c79356b | 500 | |
39236c6e A |
501 | /* whether to use the default scope zone when unspecified */ |
502 | extern int ip6_use_defzone; | |
1c79356b | 503 | |
39236c6e A |
504 | extern struct pr_usrreqs rip6_usrreqs; |
505 | extern struct pr_usrreqs icmp6_dgram_usrreqs; | |
2d21ac55 | 506 | |
39236c6e A |
507 | struct sockopt; |
508 | struct inpcb; | |
5ba3f43e | 509 | struct ip6_hdr; |
9bccf70c | 510 | struct in6_ifaddr; |
39236c6e A |
511 | struct ip6protosw; |
512 | struct domain; | |
513 | ||
514 | extern int icmp6_ctloutput(struct socket *, struct sockopt *); | |
515 | extern int icmp6_dgram_ctloutput(struct socket *, struct sockopt *); | |
516 | extern int icmp6_dgram_send(struct socket *, int, struct mbuf *, | |
517 | struct sockaddr *, struct mbuf *, struct proc *); | |
518 | extern int icmp6_dgram_attach(struct socket *, int, struct proc *); | |
519 | ||
520 | extern void ip6_init(struct ip6protosw *, struct domain *); | |
521 | extern void ip6_input(struct mbuf *); | |
522 | extern void ip6_setsrcifaddr_info(struct mbuf *, uint32_t, struct in6_ifaddr *); | |
523 | extern void ip6_setdstifaddr_info(struct mbuf *, uint32_t, struct in6_ifaddr *); | |
524 | extern int ip6_getsrcifaddr_info(struct mbuf *, uint32_t *, uint32_t *); | |
525 | extern int ip6_getdstifaddr_info(struct mbuf *, uint32_t *, uint32_t *); | |
526 | extern void ip6_freepcbopts(struct ip6_pktopts *); | |
527 | extern int ip6_unknown_opt(u_int8_t *, struct mbuf *, int); | |
528 | extern char *ip6_get_prevhdr(struct mbuf *, int); | |
529 | extern int ip6_nexthdr(struct mbuf *, int, int, int *); | |
530 | extern int ip6_lasthdr(struct mbuf *, int, int, int *); | |
eb6b6ca3 | 531 | extern boolean_t ip6_pkt_has_ulp(struct mbuf *m); |
91447636 | 532 | |
6d2010ae A |
533 | extern void ip6_moptions_init(void); |
534 | extern struct ip6_moptions *ip6_allocmoptions(int); | |
535 | extern void im6o_addref(struct ip6_moptions *, int); | |
536 | extern void im6o_remref(struct ip6_moptions *); | |
537 | ||
39236c6e A |
538 | extern struct ip6aux *ip6_addaux(struct mbuf *); |
539 | extern struct ip6aux *ip6_findaux(struct mbuf *); | |
540 | extern void ip6_delaux(struct mbuf *); | |
1c79356b | 541 | |
39236c6e A |
542 | extern int ip6_process_hopopts(struct mbuf *, u_int8_t *, int, u_int32_t *, |
543 | u_int32_t *); | |
544 | extern struct mbuf **ip6_savecontrol_v4(struct inpcb *, struct mbuf *, | |
545 | struct mbuf **, int *); | |
546 | extern int ip6_savecontrol(struct inpcb *, struct mbuf *, struct mbuf **); | |
547 | extern struct mbuf *ip6_forward(struct mbuf *, struct route_in6 *, int); | |
548 | extern void ip6_notify_pmtu(struct inpcb *, struct sockaddr_in6 *, u_int32_t *); | |
549 | extern void ip6_mloopback(struct ifnet *, struct ifnet *, struct mbuf *, | |
550 | struct sockaddr_in6 *, uint32_t, int32_t); | |
551 | extern int ip6_output(struct mbuf *, struct ip6_pktopts *, struct route_in6 *, | |
552 | int, struct ip6_moptions *, struct ifnet **, struct ip6_out_args *); | |
553 | extern int ip6_output_list(struct mbuf *, int, struct ip6_pktopts *, | |
554 | struct route_in6 *, int, struct ip6_moptions *, struct ifnet **, | |
555 | struct ip6_out_args *); | |
556 | extern int ip6_ctloutput(struct socket *, struct sockopt *); | |
557 | extern int ip6_raw_ctloutput(struct socket *, struct sockopt *); | |
558 | extern void ip6_initpktopts(struct ip6_pktopts *); | |
559 | extern int ip6_setpktoptions(struct mbuf *, struct ip6_pktopts *, int, int); | |
560 | extern void ip6_clearpktopts(struct ip6_pktopts *, int); | |
561 | extern struct ip6_pktopts *ip6_copypktopts(struct ip6_pktopts *, int); | |
562 | extern int ip6_optlen(struct inpcb *); | |
563 | extern void ip6_drain(void); | |
5ba3f43e | 564 | extern int ip6_do_fragmentation(struct mbuf **, uint32_t, struct ifnet *, uint32_t, |
cb323159 | 565 | struct ip6_hdr *, uint8_t *, uint32_t, int, uint32_t); |
39236c6e A |
566 | |
567 | extern int route6_input(struct mbuf **, int *, int); | |
568 | ||
569 | extern void frag6_init(void); | |
570 | extern int frag6_input(struct mbuf **, int *, int); | |
571 | extern void frag6_drain(void); | |
572 | ||
573 | extern int rip6_input(struct mbuf **, int *, int); | |
5ba3f43e | 574 | extern void rip6_ctlinput(int, struct sockaddr *, void *, struct ifnet *); |
39236c6e A |
575 | extern int rip6_ctloutput(struct socket *so, struct sockopt *sopt); |
576 | extern int rip6_output(struct mbuf *, struct socket *, struct sockaddr_in6 *, | |
577 | struct mbuf *, int); | |
578 | ||
579 | extern int dest6_input(struct mbuf **, int *, int); | |
5ba3f43e A |
580 | /* |
581 | * IPv6 source address selection hints | |
582 | */ | |
583 | #define IPV6_SRCSEL_HINT_PREFER_TMPADDR 0x00000001 | |
584 | ||
9d749ea3 | 585 | extern struct ifaddr * in6_selectsrc_core_ifa(struct sockaddr_in6 *, struct ifnet *, int); |
5ba3f43e A |
586 | extern struct in6_addr * in6_selectsrc_core(struct sockaddr_in6 *, |
587 | uint32_t, struct ifnet *, int, | |
588 | struct in6_addr *, struct ifnet **, int *, struct ifaddr **); | |
39236c6e A |
589 | extern struct in6_addr *in6_selectsrc(struct sockaddr_in6 *, |
590 | struct ip6_pktopts *, struct inpcb *, struct route_in6 *, | |
591 | struct ifnet **, struct in6_addr *, unsigned int, int *); | |
592 | extern struct in6_addrpolicy *in6_addrsel_lookup_policy(struct sockaddr_in6 *); | |
593 | extern int in6_selectroute(struct sockaddr_in6 *, struct sockaddr_in6 *, | |
594 | struct ip6_pktopts *, struct ip6_moptions *, struct in6_ifaddr **, | |
595 | struct route_in6 *, struct ifnet **, struct rtentry **, int, | |
596 | struct ip6_out_args *); | |
597 | extern int ip6_setpktopts(struct mbuf *control, struct ip6_pktopts *opt, | |
598 | struct ip6_pktopts *stickyopt, int uproto); | |
599 | extern u_int32_t ip6_randomid(void); | |
600 | extern u_int32_t ip6_randomflowlabel(void); | |
601 | #endif /* BSD_KERNEL_PRIVATE */ | |
1c79356b | 602 | #endif /* !_NETINET6_IP6_VAR_H_ */ |