]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
f427ee49 | 2 | * Copyright (c) 2000-2020 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
39236c6e | 5 | * |
2d21ac55 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 | * |
2d21ac55 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 | * |
2d21ac55 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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * Copyright (c) 1982, 1986, 1990, 1993 | |
30 | * The Regents of the University of California. All rights reserved. | |
31 | * | |
32 | * Redistribution and use in source and binary forms, with or without | |
33 | * modification, are permitted provided that the following conditions | |
34 | * are met: | |
35 | * 1. Redistributions of source code must retain the above copyright | |
36 | * notice, this list of conditions and the following disclaimer. | |
37 | * 2. Redistributions in binary form must reproduce the above copyright | |
38 | * notice, this list of conditions and the following disclaimer in the | |
39 | * documentation and/or other materials provided with the distribution. | |
40 | * 3. All advertising materials mentioning features or use of this software | |
41 | * must display the following acknowledgement: | |
42 | * This product includes software developed by the University of | |
43 | * California, Berkeley and its contributors. | |
44 | * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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 | * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 | |
9bccf70c | 61 | * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.32.2.4 2001/08/13 16:26:17 ume Exp $ |
1c79356b | 62 | */ |
2d21ac55 A |
63 | /* |
64 | * NOTICE: This file was modified by SPARTA, Inc. in 2007 to introduce | |
65 | * support for mandatory and extensible security protections. This notice | |
66 | * is included in support of clause 2.2 (b) of the Apple Public License, | |
67 | * Version 2.0. | |
68 | */ | |
1c79356b A |
69 | |
70 | #ifndef _NETINET_IN_PCB_H_ | |
0a7de745 | 71 | #define _NETINET_IN_PCB_H_ |
9bccf70c | 72 | #include <sys/appleapiopts.h> |
1c79356b | 73 | |
91447636 | 74 | #include <sys/types.h> |
1c79356b | 75 | #include <sys/queue.h> |
316670eb | 76 | #ifdef BSD_KERNEL_PRIVATE |
39236c6e | 77 | #include <sys/bitstring.h> |
316670eb | 78 | #include <sys/tree.h> |
91447636 | 79 | #include <kern/locks.h> |
39236c6e | 80 | #include <kern/zalloc.h> |
5ba3f43e | 81 | #include <netinet/in_stat.h> |
39236c6e | 82 | #endif /* BSD_KERNEL_PRIVATE */ |
c3c9b80d A |
83 | #if !KERNEL |
84 | #include <TargetConditionals.h> | |
85 | #endif | |
9bccf70c | 86 | |
5ba3f43e | 87 | #if IPSEC |
9bccf70c | 88 | #include <netinet6/ipsec.h> /* for IPSEC */ |
5ba3f43e A |
89 | #endif /* IPSEC */ |
90 | ||
fe8ab488 A |
91 | #if NECP |
92 | #include <net/necp.h> | |
93 | #endif | |
94 | ||
9bccf70c | 95 | |
316670eb | 96 | #ifdef BSD_KERNEL_PRIVATE |
1c79356b | 97 | /* |
39236c6e A |
98 | * struct inpcb is the common protocol control block structure used in most |
99 | * IP transport protocols. | |
100 | * | |
101 | * Pointers to local and foreign host table entries, local and foreign socket | |
102 | * numbers, and pointers up (to a socket structure) and down (to a | |
103 | * protocol-specific control block) are stored here. | |
1c79356b A |
104 | */ |
105 | LIST_HEAD(inpcbhead, inpcb); | |
106 | LIST_HEAD(inpcbporthead, inpcbport); | |
316670eb | 107 | #endif /* BSD_KERNEL_PRIVATE */ |
0a7de745 | 108 | typedef u_quad_t inp_gen_t; |
39236c6e | 109 | |
1c79356b A |
110 | /* |
111 | * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet. | |
6d2010ae A |
112 | * So, AF_INET6 null laddr is also used as AF_INET null laddr, by utilizing |
113 | * the following structure. | |
1c79356b A |
114 | */ |
115 | struct in_addr_4in6 { | |
0a7de745 A |
116 | u_int32_t ia46_pad32[3]; |
117 | struct in_addr ia46_addr4; | |
1c79356b A |
118 | }; |
119 | ||
39236c6e | 120 | #ifdef BSD_KERNEL_PRIVATE |
1c79356b A |
121 | /* |
122 | * NB: the zone allocator is type-stable EXCEPT FOR THE FIRST TWO LONGS | |
123 | * of the structure. Therefore, it is important that the members in | |
124 | * that position not contain any information which is required to be | |
125 | * stable. | |
126 | */ | |
0a7de745 | 127 | struct icmp6_filter; |
316670eb A |
128 | struct ifnet; |
129 | ||
316670eb | 130 | struct inp_stat { |
0a7de745 A |
131 | u_int64_t rxpackets; |
132 | u_int64_t rxbytes; | |
133 | u_int64_t txpackets; | |
134 | u_int64_t txbytes; | |
6d2010ae A |
135 | }; |
136 | ||
39236c6e A |
137 | /* |
138 | * struct inpcb captures the network layer state for TCP, UDP and raw IPv6 | |
139 | * and IPv6 sockets. In the case of TCP, further per-connection state is | |
140 | * hung off of inp_ppcb most of the time. | |
141 | */ | |
1c79356b | 142 | struct inpcb { |
0a7de745 A |
143 | decl_lck_mtx_data(, inpcb_mtx); /* inpcb per-socket mutex */ |
144 | LIST_ENTRY(inpcb) inp_hash; /* hash list */ | |
145 | LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */ | |
146 | void *inp_ppcb; /* pointer to per-protocol pcb */ | |
147 | struct inpcbinfo *inp_pcbinfo; /* PCB list info */ | |
148 | struct socket *inp_socket; /* back pointer to socket */ | |
149 | LIST_ENTRY(inpcb) inp_portlist; /* list for this PCB's local port */ | |
150 | RB_ENTRY(inpcb) infc_link; /* link for flowhash RB tree */ | |
151 | struct inpcbport *inp_phd; /* head of this list */ | |
152 | inp_gen_t inp_gencnt; /* generation count of this instance */ | |
153 | int inp_hash_element; /* array index of pcb's hash list */ | |
154 | int inp_wantcnt; /* wanted count; atomically updated */ | |
155 | int inp_state; /* state (INUSE/CACHED/DEAD) */ | |
156 | u_short inp_fport; /* foreign port */ | |
157 | u_short inp_lport; /* local port */ | |
158 | u_int32_t inp_flags; /* generic IP/datagram flags */ | |
159 | u_int32_t inp_flags2; /* generic IP/datagram flags #2 */ | |
160 | u_int32_t inp_flow; /* IPv6 flow information */ | |
161 | ||
162 | u_char inp_sndinprog_cnt; /* outstanding send operations */ | |
cb323159 | 163 | uint32_t inp_sndingprog_waiters;/* waiters for outstanding send */ |
0a7de745 A |
164 | u_char inp_vflag; /* INP_IPV4 or INP_IPV6 */ |
165 | ||
166 | u_char inp_ip_ttl; /* time to live proto */ | |
167 | u_char inp_ip_p; /* protocol proto */ | |
168 | ||
169 | struct ifnet *inp_boundifp; /* interface for INP_BOUND_IF */ | |
170 | struct ifnet *inp_last_outifp; /* last known outgoing interface */ | |
171 | u_int32_t inp_flowhash; /* flow hash */ | |
39236c6e A |
172 | |
173 | /* Protocol-dependent part */ | |
1c79356b A |
174 | union { |
175 | /* foreign host table entry */ | |
39236c6e A |
176 | struct in_addr_4in6 inp46_foreign; |
177 | struct in6_addr inp6_foreign; | |
1c79356b A |
178 | } inp_dependfaddr; |
179 | union { | |
180 | /* local host table entry */ | |
39236c6e A |
181 | struct in_addr_4in6 inp46_local; |
182 | struct in6_addr inp6_local; | |
1c79356b A |
183 | } inp_dependladdr; |
184 | union { | |
185 | /* placeholder for routing entry */ | |
39236c6e A |
186 | struct route inp4_route; |
187 | struct route_in6 inp6_route; | |
1c79356b A |
188 | } inp_dependroute; |
189 | struct { | |
190 | /* type of service proto */ | |
191 | u_char inp4_ip_tos; | |
192 | /* IP options */ | |
193 | struct mbuf *inp4_options; | |
194 | /* IP multicast options */ | |
195 | struct ip_moptions *inp4_moptions; | |
196 | } inp_depend4; | |
1c79356b A |
197 | struct { |
198 | /* IP options */ | |
199 | struct mbuf *inp6_options; | |
1c79356b | 200 | /* IP6 options for outgoing packets */ |
0a7de745 | 201 | struct ip6_pktopts *inp6_outputopts; |
1c79356b | 202 | /* IP multicast options */ |
0a7de745 | 203 | struct ip6_moptions *inp6_moptions; |
1c79356b | 204 | /* ICMPv6 code type filter */ |
0a7de745 | 205 | struct icmp6_filter *inp6_icmp6filt; |
1c79356b | 206 | /* IPV6_CHECKSUM setsockopt */ |
0a7de745 A |
207 | int inp6_cksum; |
208 | short inp6_hops; | |
1c79356b | 209 | } inp_depend6; |
9bccf70c | 210 | |
0a7de745 | 211 | caddr_t inp_saved_ppcb; /* place to save pointer while cached */ |
39236c6e | 212 | #if IPSEC |
cb323159 | 213 | struct inpcbpolicy *inp_sp; /* for IPsec */ |
39236c6e | 214 | #endif /* IPSEC */ |
fe8ab488 A |
215 | #if NECP |
216 | struct { | |
217 | char *inp_domain; | |
218 | char *inp_account; | |
219 | } inp_necp_attributes; | |
220 | struct necp_inpcb_result inp_policyresult; | |
5ba3f43e | 221 | uuid_t necp_client_uuid; |
d9a64523 | 222 | necp_client_flow_cb necp_cb; |
fe8ab488 | 223 | #endif |
0a7de745 | 224 | u_char *inp_keepalive_data; /* for keepalive offload */ |
3e170ce0 | 225 | u_int8_t inp_keepalive_datalen; /* keepalive data length */ |
0a7de745 | 226 | u_int8_t inp_keepalive_type; /* type of application */ |
3e170ce0 A |
227 | u_int16_t inp_keepalive_interval; /* keepalive interval */ |
228 | uint32_t inp_nstat_refcnt __attribute__((aligned(4))); | |
0a7de745 A |
229 | struct inp_stat *inp_stat; |
230 | struct inp_stat *inp_cstat; /* cellular data */ | |
231 | struct inp_stat *inp_wstat; /* Wi-Fi data */ | |
232 | struct inp_stat *inp_Wstat; /* Wired data */ | |
233 | u_int8_t inp_stat_store[sizeof(struct inp_stat) + sizeof(u_int64_t)]; | |
234 | u_int8_t inp_cstat_store[sizeof(struct inp_stat) + sizeof(u_int64_t)]; | |
235 | u_int8_t inp_wstat_store[sizeof(struct inp_stat) + sizeof(u_int64_t)]; | |
236 | u_int8_t inp_Wstat_store[sizeof(struct inp_stat) + sizeof(u_int64_t)]; | |
5ba3f43e A |
237 | activity_bitmap_t inp_nw_activity; |
238 | u_int64_t inp_start_timestamp; | |
cb323159 A |
239 | |
240 | char inp_last_proc_name[MAXCOMLEN + 1]; | |
241 | char inp_e_proc_name[MAXCOMLEN + 1]; | |
1c79356b | 242 | }; |
91447636 | 243 | |
0a7de745 A |
244 | #define INP_ADD_STAT(_inp, _cnt_cellular, _cnt_wifi, _cnt_wired, _a, _n) \ |
245 | do { \ | |
246 | locked_add_64(&((_inp)->inp_stat->_a), (_n)); \ | |
247 | if (_cnt_cellular) \ | |
248 | locked_add_64(&((_inp)->inp_cstat->_a), (_n)); \ | |
249 | if (_cnt_wifi) \ | |
250 | locked_add_64(&((_inp)->inp_wstat->_a), (_n)); \ | |
251 | if (_cnt_wired) \ | |
252 | locked_add_64(&((_inp)->inp_Wstat->_a), (_n)); \ | |
39236c6e A |
253 | } while (0); |
254 | #endif /* BSD_KERNEL_PRIVATE */ | |
1c79356b A |
255 | |
256 | /* | |
257 | * Interface exported to userland by various protocols which use | |
258 | * inpcbs. Hack alert -- only define if struct xsocket is in scope. | |
259 | */ | |
39236c6e | 260 | #pragma pack(4) |
91447636 | 261 | |
39236c6e A |
262 | #if defined(__LP64__) |
263 | struct _inpcb_list_entry { | |
0a7de745 A |
264 | u_int32_t le_next; |
265 | u_int32_t le_prev; | |
39236c6e | 266 | }; |
0a7de745 A |
267 | #define _INPCB_PTR(x) u_int32_t |
268 | #define _INPCB_LIST_ENTRY(x) struct _inpcb_list_entry | |
39236c6e | 269 | #else /* !__LP64__ */ |
0a7de745 A |
270 | #define _INPCB_PTR(x) x |
271 | #define _INPCB_LIST_ENTRY(x) LIST_ENTRY(x) | |
39236c6e A |
272 | #endif /* !__LP64__ */ |
273 | ||
274 | #ifdef XNU_KERNEL_PRIVATE | |
91447636 A |
275 | /* |
276 | * This is a copy of the inpcb as it shipped in Panther. This structure | |
277 | * is filled out in a copy function. This allows the inpcb to change | |
278 | * without breaking userland tools. | |
39236c6e | 279 | * |
91447636 A |
280 | * CAUTION: Many fields may not be filled out. Fewer may be filled out |
281 | * in the future. Code defensively. | |
282 | */ | |
91447636 A |
283 | struct inpcb_compat { |
284 | #else | |
285 | struct inpcbinfo; | |
286 | struct inpcbport; | |
287 | struct mbuf; | |
2d21ac55 A |
288 | struct ip6_pktopts; |
289 | struct ip6_moptions; | |
290 | struct icmp6_filter; | |
91447636 A |
291 | struct inpcbpolicy; |
292 | ||
293 | struct inpcb { | |
294 | #endif /* KERNEL_PRIVATE */ | |
0a7de745 A |
295 | _INPCB_LIST_ENTRY(inpcb) inp_hash; /* hash list */ |
296 | struct in_addr reserved1; /* reserved */ | |
297 | struct in_addr reserved2; /* reserved */ | |
298 | u_short inp_fport; /* foreign port */ | |
299 | u_short inp_lport; /* local port */ | |
300 | _INPCB_LIST_ENTRY(inpcb) inp_list; /* list for all peer PCBs */ | |
301 | _INPCB_PTR(caddr_t) inp_ppcb; /* per-protocol pcb */ | |
302 | _INPCB_PTR(struct inpcbinfo *) inp_pcbinfo; /* PCB list info */ | |
303 | _INPCB_PTR(void *) inp_socket; /* back pointer to socket */ | |
304 | u_char nat_owner; /* Used to NAT TCP/UDP traffic */ | |
305 | u_int32_t nat_cookie; /* Cookie stored and returned to NAT */ | |
306 | _INPCB_LIST_ENTRY(inpcb) inp_portlist; /* this PCB's local port list */ | |
39236c6e | 307 | _INPCB_PTR(struct inpcbport *) inp_phd; /* head of this list */ |
0a7de745 A |
308 | inp_gen_t inp_gencnt; /* generation count of this instance */ |
309 | int inp_flags; /* generic IP/datagram flags */ | |
91447636 A |
310 | u_int32_t inp_flow; |
311 | ||
39236c6e | 312 | u_char inp_vflag; |
91447636 | 313 | |
0a7de745 A |
314 | u_char inp_ip_ttl; /* time to live proto */ |
315 | u_char inp_ip_p; /* protocol proto */ | |
91447636 A |
316 | /* protocol dependent part */ |
317 | union { | |
318 | /* foreign host table entry */ | |
39236c6e A |
319 | struct in_addr_4in6 inp46_foreign; |
320 | struct in6_addr inp6_foreign; | |
91447636 A |
321 | } inp_dependfaddr; |
322 | union { | |
323 | /* local host table entry */ | |
39236c6e A |
324 | struct in_addr_4in6 inp46_local; |
325 | struct in6_addr inp6_local; | |
91447636 A |
326 | } inp_dependladdr; |
327 | union { | |
328 | /* placeholder for routing entry */ | |
39236c6e A |
329 | u_char inp4_route[20]; |
330 | u_char inp6_route[32]; | |
91447636 A |
331 | } inp_dependroute; |
332 | struct { | |
333 | /* type of service proto */ | |
334 | u_char inp4_ip_tos; | |
335 | /* IP options */ | |
2d21ac55 | 336 | _INPCB_PTR(struct mbuf *) inp4_options; |
91447636 | 337 | /* IP multicast options */ |
2d21ac55 | 338 | _INPCB_PTR(struct ip_moptions *) inp4_moptions; |
91447636 A |
339 | } inp_depend4; |
340 | ||
341 | struct { | |
342 | /* IP options */ | |
39236c6e A |
343 | _INPCB_PTR(struct mbuf *) inp6_options; |
344 | u_int8_t inp6_hlim; | |
345 | u_int8_t unused_uint8_1; | |
346 | ushort unused_uint16_1; | |
91447636 | 347 | /* IP6 options for outgoing packets */ |
39236c6e | 348 | _INPCB_PTR(struct ip6_pktopts *) inp6_outputopts; |
91447636 | 349 | /* IP multicast options */ |
39236c6e | 350 | _INPCB_PTR(struct ip6_moptions *) inp6_moptions; |
91447636 | 351 | /* ICMPv6 code type filter */ |
39236c6e | 352 | _INPCB_PTR(struct icmp6_filter *) inp6_icmp6filt; |
91447636 | 353 | /* IPV6_CHECKSUM setsockopt */ |
0a7de745 A |
354 | int inp6_cksum; |
355 | u_short inp6_ifindex; | |
356 | short inp6_hops; | |
91447636 A |
357 | } inp_depend6; |
358 | ||
0a7de745 | 359 | int hash_element; /* Array index of pcb's hash list */ |
39236c6e A |
360 | _INPCB_PTR(caddr_t) inp_saved_ppcb; /* pointer while cached */ |
361 | _INPCB_PTR(struct inpcbpolicy *) inp_sp; | |
0a7de745 | 362 | u_int32_t reserved[3]; /* reserved */ |
91447636 A |
363 | }; |
364 | ||
0a7de745 A |
365 | struct xinpcb { |
366 | u_int32_t xi_len; /* length of this structure */ | |
39236c6e | 367 | #ifdef XNU_KERNEL_PRIVATE |
0a7de745 | 368 | struct inpcb_compat xi_inp; |
91447636 | 369 | #else |
0a7de745 | 370 | struct inpcb xi_inp; |
91447636 | 371 | #endif |
0a7de745 A |
372 | struct xsocket xi_socket; |
373 | u_quad_t xi_alignment_hack; | |
1c79356b A |
374 | }; |
375 | ||
c3c9b80d | 376 | #if XNU_TARGET_OS_OSX || KERNEL || !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) |
b0d623f7 | 377 | struct inpcb64_list_entry { |
0a7de745 A |
378 | u_int64_t le_next; |
379 | u_int64_t le_prev; | |
b0d623f7 A |
380 | }; |
381 | ||
0a7de745 A |
382 | struct xinpcb64 { |
383 | u_int64_t xi_len; /* length of this structure */ | |
384 | u_int64_t xi_inpp; | |
385 | u_short inp_fport; /* foreign port */ | |
386 | u_short inp_lport; /* local port */ | |
39236c6e | 387 | struct inpcb64_list_entry inp_list; /* list for all PCBs */ |
0a7de745 A |
388 | u_int64_t inp_ppcb; /* ptr to per-protocol PCB */ |
389 | u_int64_t inp_pcbinfo; /* PCB list info */ | |
390 | struct inpcb64_list_entry inp_portlist; /* this PCB's local port list */ | |
391 | u_int64_t inp_phd; /* head of this list */ | |
392 | inp_gen_t inp_gencnt; /* current generation count */ | |
393 | int inp_flags; /* generic IP/datagram flags */ | |
394 | u_int32_t inp_flow; | |
395 | u_char inp_vflag; | |
396 | u_char inp_ip_ttl; /* time to live */ | |
397 | u_char inp_ip_p; /* protocol */ | |
398 | union { /* foreign host table entry */ | |
399 | struct in_addr_4in6 inp46_foreign; | |
400 | struct in6_addr inp6_foreign; | |
39236c6e | 401 | } inp_dependfaddr; |
0a7de745 A |
402 | union { /* local host table entry */ |
403 | struct in_addr_4in6 inp46_local; | |
404 | struct in6_addr inp6_local; | |
39236c6e | 405 | } inp_dependladdr; |
6d2010ae | 406 | struct { |
0a7de745 | 407 | u_char inp4_ip_tos; /* type of service */ |
39236c6e | 408 | } inp_depend4; |
6d2010ae | 409 | struct { |
39236c6e | 410 | u_int8_t inp6_hlim; |
0a7de745 A |
411 | int inp6_cksum; |
412 | u_short inp6_ifindex; | |
413 | short inp6_hops; | |
39236c6e A |
414 | } inp_depend6; |
415 | struct xsocket64 xi_socket; | |
0a7de745 | 416 | u_quad_t xi_alignment_hack; |
b0d623f7 | 417 | }; |
c3c9b80d | 418 | #endif /* XNU_TARGET_OS_OSX || KERNEL || !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) */ |
b0d623f7 | 419 | |
6d2010ae | 420 | #ifdef PRIVATE |
6d2010ae | 421 | struct xinpcb_list_entry { |
0a7de745 A |
422 | u_int64_t le_next; |
423 | u_int64_t le_prev; | |
6d2010ae A |
424 | }; |
425 | ||
0a7de745 A |
426 | struct xinpcb_n { |
427 | u_int32_t xi_len; /* length of this structure */ | |
428 | u_int32_t xi_kind; /* XSO_INPCB */ | |
429 | u_int64_t xi_inpp; | |
430 | u_short inp_fport; /* foreign port */ | |
431 | u_short inp_lport; /* local port */ | |
432 | u_int64_t inp_ppcb; /* pointer to per-protocol pcb */ | |
433 | inp_gen_t inp_gencnt; /* generation count of this instance */ | |
434 | int inp_flags; /* generic IP/datagram flags */ | |
435 | u_int32_t inp_flow; | |
436 | u_char inp_vflag; | |
437 | u_char inp_ip_ttl; /* time to live */ | |
438 | u_char inp_ip_p; /* protocol */ | |
439 | union { /* foreign host table entry */ | |
440 | struct in_addr_4in6 inp46_foreign; | |
441 | struct in6_addr inp6_foreign; | |
39236c6e | 442 | } inp_dependfaddr; |
0a7de745 A |
443 | union { /* local host table entry */ |
444 | struct in_addr_4in6 inp46_local; | |
445 | struct in6_addr inp6_local; | |
39236c6e | 446 | } inp_dependladdr; |
6d2010ae | 447 | struct { |
0a7de745 | 448 | u_char inp4_ip_tos; /* type of service */ |
39236c6e | 449 | } inp_depend4; |
6d2010ae | 450 | struct { |
39236c6e | 451 | u_int8_t inp6_hlim; |
0a7de745 A |
452 | int inp6_cksum; |
453 | u_short inp6_ifindex; | |
454 | short inp6_hops; | |
39236c6e | 455 | } inp_depend6; |
0a7de745 A |
456 | u_int32_t inp_flowhash; |
457 | u_int32_t inp_flags2; | |
6d2010ae | 458 | }; |
6d2010ae A |
459 | #endif /* PRIVATE */ |
460 | ||
0a7de745 A |
461 | struct xinpgen { |
462 | u_int32_t xig_len; /* length of this structure */ | |
463 | u_int xig_count; /* number of PCBs at this time */ | |
464 | inp_gen_t xig_gen; /* generation count at this time */ | |
465 | so_gen_t xig_sogen; /* current socket generation count */ | |
1c79356b | 466 | }; |
1c79356b | 467 | |
2d21ac55 A |
468 | #pragma pack() |
469 | ||
91447636 A |
470 | /* |
471 | * These defines are for use with the inpcb. | |
472 | */ | |
0a7de745 A |
473 | #define INP_IPV4 0x1 |
474 | #define INP_IPV6 0x2 | |
475 | #define inp_faddr inp_dependfaddr.inp46_foreign.ia46_addr4 | |
476 | #define inp_laddr inp_dependladdr.inp46_local.ia46_addr4 | |
477 | #define in6p_faddr inp_dependfaddr.inp6_foreign | |
478 | #define in6p_laddr inp_dependladdr.inp6_local | |
316670eb A |
479 | |
480 | #ifdef BSD_KERNEL_PRIVATE | |
0a7de745 A |
481 | #define inp_route inp_dependroute.inp4_route |
482 | #define inp_ip_tos inp_depend4.inp4_ip_tos | |
483 | #define inp_options inp_depend4.inp4_options | |
484 | #define inp_moptions inp_depend4.inp4_moptions | |
485 | #define in6p_route inp_dependroute.inp6_route | |
486 | #define in6p_ip6_hlim inp_depend6.inp6_hlim | |
487 | #define in6p_hops inp_depend6.inp6_hops /* default hop limit */ | |
488 | #define in6p_ip6_nxt inp_ip_p | |
489 | #define in6p_vflag inp_vflag | |
490 | #define in6p_options inp_depend6.inp6_options | |
491 | #define in6p_outputopts inp_depend6.inp6_outputopts | |
492 | #define in6p_moptions inp_depend6.inp6_moptions | |
493 | #define in6p_icmp6filt inp_depend6.inp6_icmp6filt | |
494 | #define in6p_cksum inp_depend6.inp6_cksum | |
495 | #define in6p_ifindex inp_depend6.inp6_ifindex | |
496 | #define in6p_flags inp_flags | |
497 | #define in6p_flags2 inp_flags2 | |
498 | #define in6p_socket inp_socket | |
499 | #define in6p_lport inp_lport | |
500 | #define in6p_fport inp_fport | |
501 | #define in6p_ppcb inp_ppcb | |
502 | #define in6p_state inp_state | |
503 | #define in6p_wantcnt inp_wantcnt | |
504 | #define in6p_last_outifp inp_last_outifp | |
505 | #define in6pcb inpcb | |
39236c6e | 506 | #if IPSEC |
0a7de745 | 507 | #define in6p_sp inp_sp |
39236c6e | 508 | #endif /* IPSEC */ |
4bd07ac2 A |
509 | #define INP_INC_IFNET_STAT(_inp_, _stat_) { \ |
510 | if ((_inp_)->inp_last_outifp != NULL) { \ | |
0a7de745 A |
511 | if ((_inp_)->inp_vflag & INP_IPV6) { \ |
512 | (_inp_)->inp_last_outifp->if_ipv6_stat->_stat_++;\ | |
513 | } else { \ | |
514 | (_inp_)->inp_last_outifp->if_ipv4_stat->_stat_++;\ | |
515 | }\ | |
4bd07ac2 A |
516 | }\ |
517 | } | |
91447636 | 518 | |
1c79356b A |
519 | struct inpcbport { |
520 | LIST_ENTRY(inpcbport) phd_hash; | |
521 | struct inpcbhead phd_pcblist; | |
522 | u_short phd_port; | |
523 | }; | |
524 | ||
39236c6e | 525 | struct intimercount { |
0a7de745 | 526 | u_int32_t intimer_lazy; /* lazy requests for timer scheduling */ |
39236c6e A |
527 | u_int32_t intimer_fast; /* fast requests, can be coalesced */ |
528 | u_int32_t intimer_nodelay; /* fast requests, never coalesced */ | |
1c79356b A |
529 | }; |
530 | ||
39236c6e A |
531 | typedef void (*inpcb_timer_func_t)(struct inpcbinfo *); |
532 | ||
533 | /* | |
534 | * Global data structure for each high-level protocol (UDP, TCP, ...) in both | |
535 | * IPv4 and IPv6. Holds inpcb lists and information for managing them. Each | |
536 | * pcbinfo is protected by a RW lock: ipi_lock. | |
537 | * | |
538 | * All INPCB pcbinfo entries are linked together via ipi_entry. | |
539 | */ | |
540 | struct inpcbinfo { | |
541 | /* | |
542 | * Glue to all PCB infos, as well as garbage collector and | |
543 | * timer callbacks, protected by inpcb_lock. Callout request | |
544 | * counts are atomically updated. | |
545 | */ | |
0a7de745 A |
546 | TAILQ_ENTRY(inpcbinfo) ipi_entry; |
547 | inpcb_timer_func_t ipi_gc; | |
548 | inpcb_timer_func_t ipi_timer; | |
549 | struct intimercount ipi_gc_req; | |
550 | struct intimercount ipi_timer_req; | |
39236c6e A |
551 | |
552 | /* | |
553 | * Per-protocol lock protecting pcb list, pcb count, etc. | |
554 | */ | |
0a7de745 | 555 | lck_rw_t *ipi_lock; |
39236c6e A |
556 | |
557 | /* | |
558 | * List and count of pcbs on the protocol. | |
559 | */ | |
0a7de745 A |
560 | struct inpcbhead *ipi_listhead; |
561 | uint32_t ipi_count; | |
39236c6e A |
562 | |
563 | /* | |
564 | * Count of pcbs marked with INP2_TIMEWAIT flag. | |
565 | */ | |
0a7de745 | 566 | uint32_t ipi_twcount; |
39236c6e A |
567 | |
568 | /* | |
569 | * Generation count -- incremented each time a connection is | |
570 | * allocated or freed. | |
571 | */ | |
0a7de745 | 572 | uint64_t ipi_gencnt; |
39236c6e A |
573 | |
574 | /* | |
575 | * Fields associated with port lookup and allocation. | |
576 | */ | |
0a7de745 A |
577 | uint16_t ipi_lastport; |
578 | uint16_t ipi_lastlow; | |
579 | uint16_t ipi_lasthi; | |
39236c6e A |
580 | |
581 | /* | |
582 | * Zone from which inpcbs are allocated for this protocol. | |
583 | */ | |
0a7de745 | 584 | struct zone *ipi_zone; |
39236c6e A |
585 | |
586 | /* | |
587 | * Per-protocol hash of pcbs, hashed by local and foreign | |
588 | * addresses and port numbers. | |
589 | */ | |
0a7de745 A |
590 | struct inpcbhead *ipi_hashbase; |
591 | u_long ipi_hashmask; | |
39236c6e A |
592 | |
593 | /* | |
594 | * Per-protocol hash of pcbs, hashed by only local port number. | |
595 | */ | |
0a7de745 A |
596 | struct inpcbporthead *ipi_porthashbase; |
597 | u_long ipi_porthashmask; | |
39236c6e A |
598 | |
599 | /* | |
600 | * Misc. | |
601 | */ | |
0a7de745 A |
602 | lck_attr_t *ipi_lock_attr; |
603 | lck_grp_t *ipi_lock_grp; | |
604 | lck_grp_attr_t *ipi_lock_grp_attr; | |
39037602 | 605 | |
0a7de745 A |
606 | #define INPCBINFO_UPDATE_MSS 0x1 |
607 | #define INPCBINFO_HANDLE_LQM_ABORT 0x2 | |
608 | u_int32_t ipi_flags; | |
39236c6e A |
609 | }; |
610 | ||
0a7de745 | 611 | #define INP_PCBHASH(faddr, lport, fport, mask) \ |
1c79356b | 612 | (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) |
0a7de745 | 613 | #define INP_PCBPORTHASH(lport, mask) \ |
1c79356b A |
614 | (ntohs((lport)) & (mask)) |
615 | ||
0a7de745 | 616 | #define INP_IS_FLOW_CONTROLLED(_inp_) \ |
39236c6e | 617 | ((_inp_)->inp_flags & INP_FLOW_CONTROLLED) |
0a7de745 A |
618 | #define INP_IS_FLOW_SUSPENDED(_inp_) \ |
619 | (((_inp_)->inp_flags & INP_FLOW_SUSPENDED) || \ | |
316670eb | 620 | ((_inp_)->inp_socket->so_flags & SOF_SUSPENDED)) |
0a7de745 | 621 | #define INP_WAIT_FOR_IF_FEEDBACK(_inp_) \ |
316670eb A |
622 | (((_inp_)->inp_flags & (INP_FLOW_CONTROLLED | INP_FLOW_SUSPENDED)) != 0) |
623 | ||
fe8ab488 A |
624 | #define INP_NO_CELLULAR(_inp) \ |
625 | ((_inp)->inp_flags & INP_NO_IFT_CELLULAR) | |
626 | #define INP_NO_EXPENSIVE(_inp) \ | |
627 | ((_inp)->inp_flags2 & INP2_NO_IFF_EXPENSIVE) | |
cb323159 A |
628 | #define INP_NO_CONSTRAINED(_inp) \ |
629 | ((_inp)->inp_flags2 & INP2_NO_IFF_CONSTRAINED) | |
0a7de745 | 630 | #define INP_AWDL_UNRESTRICTED(_inp) \ |
fe8ab488 | 631 | ((_inp)->inp_flags2 & INP2_AWDL_UNRESTRICTED) |
0a7de745 | 632 | #define INP_INTCOPROC_ALLOWED(_inp) \ |
39037602 | 633 | ((_inp)->inp_flags2 & INP2_INTCOPROC_ALLOWED) |
fe8ab488 | 634 | |
316670eb | 635 | #endif /* BSD_KERNEL_PRIVATE */ |
91447636 | 636 | |
39236c6e A |
637 | /* |
638 | * Flags for inp_flags. | |
639 | * | |
640 | * Some of these are publicly defined for legacy reasons, as they are | |
641 | * (unfortunately) used by certain applications to determine, at compile | |
642 | * time, whether or not the OS supports certain features. | |
643 | */ | |
316670eb | 644 | #ifdef BSD_KERNEL_PRIVATE |
0a7de745 A |
645 | #define INP_RECVOPTS 0x00000001 /* receive incoming IP options */ |
646 | #define INP_RECVRETOPTS 0x00000002 /* receive IP options for reply */ | |
647 | #define INP_RECVDSTADDR 0x00000004 /* receive IP dst address */ | |
648 | #define INP_HDRINCL 0x00000008 /* user supplies entire IP header */ | |
649 | #define INP_HIGHPORT 0x00000010 /* user wants "high" port binding */ | |
650 | #define INP_LOWPORT 0x00000020 /* user wants "low" port binding */ | |
316670eb | 651 | #endif /* BSD_KERNEL_PRIVATE */ |
9bccf70c | 652 | |
0a7de745 | 653 | #define INP_ANONPORT 0x00000040 /* port chosen for user */ |
316670eb A |
654 | |
655 | #ifdef BSD_KERNEL_PRIVATE | |
0a7de745 A |
656 | #define INP_RECVIF 0x00000080 /* receive incoming interface */ |
657 | #define INP_MTUDISC 0x00000100 /* unused */ | |
658 | #define INP_STRIPHDR 0x00000200 /* strip hdrs in raw_ip (for OT) */ | |
659 | #define INP_RECV_ANYIF 0x00000400 /* don't restrict inbound iface */ | |
660 | #define INP_INADDR_ANY 0x00000800 /* local address wasn't specified */ | |
661 | #define INP_IN6ADDR_ANY INP_INADDR_ANY | |
662 | #define INP_RECVTTL 0x00001000 /* receive incoming IP TTL */ | |
663 | #define INP_UDP_NOCKSUM 0x00002000 /* turn off outbound UDP checksum */ | |
664 | #define INP_BOUND_IF 0x00004000 /* bind socket to an interface */ | |
316670eb A |
665 | #endif /* BSD_KERNEL_PRIVATE */ |
666 | ||
0a7de745 | 667 | #define IN6P_IPV6_V6ONLY 0x00008000 /* restrict AF_INET6 socket for v6 */ |
316670eb A |
668 | |
669 | #ifdef BSD_KERNEL_PRIVATE | |
0a7de745 A |
670 | #define IN6P_PKTINFO 0x00010000 /* receive IP6 dst and I/F */ |
671 | #define IN6P_HOPLIMIT 0x00020000 /* receive hoplimit */ | |
672 | #define IN6P_HOPOPTS 0x00040000 /* receive hop-by-hop options */ | |
673 | #define IN6P_DSTOPTS 0x00080000 /* receive dst options after rthdr */ | |
674 | #define IN6P_RTHDR 0x00100000 /* receive routing header */ | |
675 | #define IN6P_RTHDRDSTOPTS 0x00200000 /* receive dstoptions before rthdr */ | |
676 | #define IN6P_TCLASS 0x00400000 /* receive traffic class value */ | |
677 | #define INP_RECVTOS IN6P_TCLASS /* receive incoming IP TOS */ | |
678 | #define IN6P_AUTOFLOWLABEL 0x00800000 /* attach flowlabel automatically */ | |
316670eb | 679 | #endif /* BSD_KERNEL_PRIVATE */ |
1c79356b | 680 | |
0a7de745 | 681 | #define IN6P_BINDV6ONLY 0x01000000 /* do not grab IPv4 traffic */ |
1c79356b | 682 | |
316670eb | 683 | #ifdef BSD_KERNEL_PRIVATE |
0a7de745 | 684 | #define IN6P_RFC2292 0x02000000 /* used RFC2292 API on the socket */ |
f427ee49 | 685 | #define IN6P_MTU 0x04000000 /* receive path MTU for IPv6 */ |
0a7de745 A |
686 | #define INP_PKTINFO 0x08000000 /* rcv and snd PKTINFO for IPv4 */ |
687 | #define INP_FLOW_SUSPENDED 0x10000000 /* flow suspended */ | |
688 | #define INP_NO_IFT_CELLULAR 0x20000000 /* do not use cellular interface */ | |
689 | #define INP_FLOW_CONTROLLED 0x40000000 /* flow controlled */ | |
690 | #define INP_FC_FEEDBACK 0x80000000 /* got interface flow adv feedback */ | |
691 | ||
692 | #define INP_CONTROLOPTS \ | |
39236c6e A |
693 | (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|INP_RECVIF|INP_RECVTTL| \ |
694 | INP_PKTINFO|IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|IN6P_DSTOPTS| \ | |
695 | IN6P_RTHDR|IN6P_RTHDRDSTOPTS|IN6P_TCLASS|IN6P_RFC2292|IN6P_MTU) | |
696 | ||
0a7de745 | 697 | #define INP_UNMAPPABLEOPTS \ |
d9a64523 | 698 | (IN6P_HOPOPTS|IN6P_DSTOPTS|IN6P_RTHDR|IN6P_AUTOFLOWLABEL) |
1c79356b | 699 | |
39236c6e A |
700 | /* |
701 | * Flags for inp_flags2. | |
702 | * | |
703 | * Overflowed INP flags; use INP2 prefix to avoid misuse. | |
704 | */ | |
0a7de745 A |
705 | #define INP2_TIMEWAIT 0x00000001 /* in TIMEWAIT */ |
706 | #define INP2_IN_FCTREE 0x00000002 /* in inp_fc_tree */ | |
707 | #define INP2_WANT_APP_POLICY 0x00000004 /* necp app policy check is desired */ | |
708 | #define INP2_NO_IFF_EXPENSIVE 0x00000008 /* do not use expensive interface */ | |
709 | #define INP2_INHASHLIST 0x00000010 /* pcb is in inp_hash list */ | |
710 | #define INP2_AWDL_UNRESTRICTED 0x00000020 /* AWDL restricted mode allowed */ | |
711 | #define INP2_KEEPALIVE_OFFLOAD 0x00000040 /* Enable UDP or TCP keepalive offload */ | |
712 | #define INP2_INTCOPROC_ALLOWED 0x00000080 /* Allow communication via internal co-processor interfaces */ | |
713 | #define INP2_CONNECT_IN_PROGRESS 0x00000100 /* A connect call is in progress, so binds are intermediate steps */ | |
714 | #define INP2_CLAT46_FLOW 0x00000200 /* The flow is going to use CLAT46 path */ | |
cb323159 A |
715 | #define INP2_EXTERNAL_PORT 0x00000400 /* The port is registered externally, for NECP listeners */ |
716 | #define INP2_NO_IFF_CONSTRAINED 0x00000800 /* do not use constrained interface */ | |
f427ee49 | 717 | #define INP2_DONTFRAG 0x00001000 /* mark the DF bit in the IP header to avoid fragmentation */ |
1c79356b | 718 | |
39236c6e A |
719 | /* |
720 | * Flags passed to in_pcblookup*() functions. | |
721 | */ | |
0a7de745 | 722 | #define INPLOOKUP_WILDCARD 1 |
316670eb | 723 | |
0a7de745 A |
724 | #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) |
725 | #define sotoin6pcb(so) sotoinpcb(so) | |
9bccf70c | 726 | |
6d2010ae A |
727 | struct sysctl_req; |
728 | ||
39236c6e A |
729 | extern int ipport_lowfirstauto; |
730 | extern int ipport_lowlastauto; | |
731 | extern int ipport_firstauto; | |
732 | extern int ipport_lastauto; | |
733 | extern int ipport_hifirstauto; | |
734 | extern int ipport_hilastauto; | |
f427ee49 A |
735 | extern int allow_udp_port_exhaustion; |
736 | #define UDP_RANDOM_PORT_RESERVE 4096 | |
39236c6e A |
737 | |
738 | /* freshly allocated PCB, it's in use */ | |
0a7de745 | 739 | #define INPCB_STATE_INUSE 0x1 |
39236c6e | 740 | /* this pcb is sitting in a a cache */ |
0a7de745 | 741 | #define INPCB_STATE_CACHED 0x2 |
39236c6e | 742 | /* should treat as gone, will be garbage collected and freed */ |
0a7de745 | 743 | #define INPCB_STATE_DEAD 0x3 |
39236c6e A |
744 | |
745 | /* marked as ready to be garbaged collected, should be treated as not found */ | |
0a7de745 | 746 | #define WNT_STOPUSING 0xffff |
39236c6e | 747 | /* that pcb is being acquired, do not recycle this time */ |
0a7de745 | 748 | #define WNT_ACQUIRE 0x1 |
39236c6e | 749 | /* release acquired mode, can be garbage collected when wantcnt is null */ |
0a7de745 | 750 | #define WNT_RELEASE 0x2 |
39236c6e A |
751 | |
752 | extern void in_pcbinit(void); | |
753 | extern void in_pcbinfo_attach(struct inpcbinfo *); | |
754 | extern int in_pcbinfo_detach(struct inpcbinfo *); | |
755 | ||
756 | /* type of timer to be scheduled by inpcb_gc_sched and inpcb_timer_sched */ | |
757 | enum { | |
758 | INPCB_TIMER_LAZY = 0x1, | |
759 | INPCB_TIMER_FAST, | |
760 | INPCB_TIMER_NODELAY | |
761 | }; | |
762 | extern void inpcb_gc_sched(struct inpcbinfo *, u_int32_t type); | |
763 | extern void inpcb_timer_sched(struct inpcbinfo *, u_int32_t type); | |
764 | ||
765 | extern void in_losing(struct inpcb *); | |
766 | extern void in_rtchange(struct inpcb *, int); | |
767 | extern int in_pcballoc(struct socket *, struct inpcbinfo *, struct proc *); | |
768 | extern int in_pcbbind(struct inpcb *, struct sockaddr *, struct proc *); | |
769 | extern int in_pcbconnect(struct inpcb *, struct sockaddr *, struct proc *, | |
770 | unsigned int, struct ifnet **); | |
771 | extern void in_pcbdetach(struct inpcb *); | |
772 | extern void in_pcbdispose(struct inpcb *); | |
773 | extern void in_pcbdisconnect(struct inpcb *); | |
774 | extern int in_pcbinshash(struct inpcb *, int); | |
775 | extern int in_pcbladdr(struct inpcb *, struct sockaddr *, struct in_addr *, | |
39037602 | 776 | unsigned int, struct ifnet **, int); |
b0d623f7 | 777 | extern struct inpcb *in_pcblookup_local(struct inpcbinfo *, struct in_addr, |
39236c6e | 778 | u_int, int); |
b0d623f7 | 779 | extern struct inpcb *in_pcblookup_local_and_cleanup(struct inpcbinfo *, |
39236c6e | 780 | struct in_addr, u_int, int); |
b0d623f7 | 781 | extern struct inpcb *in_pcblookup_hash(struct inpcbinfo *, struct in_addr, |
39236c6e A |
782 | u_int, struct in_addr, u_int, int, struct ifnet *); |
783 | extern int in_pcblookup_hash_exists(struct inpcbinfo *, struct in_addr, | |
784 | u_int, struct in_addr, u_int, int, uid_t *, gid_t *, struct ifnet *); | |
785 | extern void in_pcbnotifyall(struct inpcbinfo *, struct in_addr, int, | |
786 | void (*)(struct inpcb *, int)); | |
787 | extern void in_pcbrehash(struct inpcb *); | |
788 | extern int in_getpeeraddr(struct socket *, struct sockaddr **); | |
39236c6e | 789 | extern int in_getsockaddr(struct socket *, struct sockaddr **); |
5ba3f43e | 790 | extern int in_getsockaddr_s(struct socket *, struct sockaddr_in *); |
39236c6e A |
791 | extern int in_pcb_checkstate(struct inpcb *, int, int); |
792 | extern void in_pcbremlists(struct inpcb *); | |
793 | extern void inpcb_to_compat(struct inpcb *, struct inpcb_compat *); | |
f427ee49 | 794 | #if XNU_TARGET_OS_OSX |
39236c6e | 795 | extern void inpcb_to_xinpcb64(struct inpcb *, struct xinpcb64 *); |
f427ee49 | 796 | #endif /* XNU_TARGET_OS_OSX */ |
3e170ce0 | 797 | |
39236c6e | 798 | extern int get_pcblist_n(short, struct sysctl_req *, struct inpcbinfo *); |
3e170ce0 | 799 | |
39236c6e A |
800 | extern void inpcb_get_ports_used(u_int32_t, int, u_int32_t, bitstr_t *, |
801 | struct inpcbinfo *); | |
0a7de745 A |
802 | #define INPCB_OPPORTUNISTIC_THROTTLEON 0x0001 |
803 | #define INPCB_OPPORTUNISTIC_SETCMD 0x0002 | |
39236c6e A |
804 | extern uint32_t inpcb_count_opportunistic(unsigned int, struct inpcbinfo *, |
805 | u_int32_t); | |
806 | extern uint32_t inpcb_find_anypcb_byaddr(struct ifaddr *, struct inpcbinfo *); | |
807 | extern void inp_route_copyout(struct inpcb *, struct route *); | |
808 | extern void inp_route_copyin(struct inpcb *, struct route *); | |
809 | extern int inp_bindif(struct inpcb *, unsigned int, struct ifnet **); | |
810 | extern void inp_set_nocellular(struct inpcb *); | |
811 | extern void inp_clear_nocellular(struct inpcb *); | |
fe8ab488 | 812 | extern void inp_set_noexpensive(struct inpcb *); |
cb323159 | 813 | extern void inp_set_noconstrained(struct inpcb *); |
fe8ab488 A |
814 | extern void inp_set_awdl_unrestricted(struct inpcb *); |
815 | extern boolean_t inp_get_awdl_unrestricted(struct inpcb *); | |
816 | extern void inp_clear_awdl_unrestricted(struct inpcb *); | |
39037602 A |
817 | extern void inp_set_intcoproc_allowed(struct inpcb *); |
818 | extern boolean_t inp_get_intcoproc_allowed(struct inpcb *); | |
819 | extern void inp_clear_intcoproc_allowed(struct inpcb *); | |
fe8ab488 A |
820 | #if NECP |
821 | extern void inp_update_necp_policy(struct inpcb *, struct sockaddr *, struct sockaddr *, u_int); | |
822 | extern void inp_set_want_app_policy(struct inpcb *); | |
823 | extern void inp_clear_want_app_policy(struct inpcb *); | |
824 | #endif /* NECP */ | |
316670eb | 825 | extern u_int32_t inp_calc_flowhash(struct inpcb *); |
39236c6e A |
826 | extern void inp_reset_fc_state(struct inpcb *); |
827 | extern int inp_set_fc_state(struct inpcb *, int advcode); | |
828 | extern void inp_fc_unthrottle_tcp(struct inpcb *); | |
f427ee49 | 829 | extern void inp_fc_throttle_tcp(struct inpcb *inp); |
39236c6e A |
830 | extern void inp_flowadv(uint32_t); |
831 | extern int inp_flush(struct inpcb *, int); | |
832 | extern int inp_findinpcb_procinfo(struct inpcbinfo *, uint32_t, struct so_procinfo *); | |
833 | extern void inp_get_soprocinfo(struct inpcb *, struct so_procinfo *); | |
834 | extern int inp_update_policy(struct inpcb *); | |
fe8ab488 A |
835 | extern boolean_t inp_restricted_recv(struct inpcb *, struct ifnet *); |
836 | extern boolean_t inp_restricted_send(struct inpcb *, struct ifnet *); | |
39037602 A |
837 | extern void inp_incr_sndbytes_total(struct socket *, int); |
838 | extern void inp_decr_sndbytes_total(struct socket *, int); | |
839 | extern void inp_count_sndbytes(struct inpcb *, u_int32_t); | |
840 | extern void inp_incr_sndbytes_unsent(struct socket *, int32_t); | |
841 | extern void inp_decr_sndbytes_unsent(struct socket *, int32_t); | |
842 | extern int32_t inp_get_sndbytes_allunsent(struct socket *, u_int32_t); | |
843 | extern void inp_decr_sndbytes_allunsent(struct socket *, u_int32_t); | |
5ba3f43e A |
844 | extern void inp_set_activity_bitmap(struct inpcb *inp); |
845 | extern void inp_get_activity_bitmap(struct inpcb *inp, activity_bitmap_t *b); | |
cb323159 A |
846 | extern void inp_update_last_owner(struct socket *so, struct proc *p, struct proc *ep); |
847 | extern void inp_copy_last_owner(struct socket *so, struct socket *head); | |
316670eb | 848 | #endif /* BSD_KERNEL_PRIVATE */ |
316670eb | 849 | #ifdef KERNEL_PRIVATE |
39236c6e A |
850 | /* exported for PPP */ |
851 | extern void inp_clear_INP_INADDR_ANY(struct socket *); | |
f427ee49 A |
852 | extern int inp_limit_companion_link(struct inpcbinfo *pcbinfo, u_int32_t limit); |
853 | extern int inp_recover_companion_link(struct inpcbinfo *pcbinfo); | |
91447636 | 854 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 855 | #endif /* !_NETINET_IN_PCB_H_ */ |