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