]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000-2008 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
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. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
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. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
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 | |
61 | * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.32.2.4 2001/08/13 16:26:17 ume Exp $ | |
62 | */ | |
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 | */ | |
69 | ||
70 | #ifndef _NETINET_IN_PCB_H_ | |
71 | #define _NETINET_IN_PCB_H_ | |
72 | #include <sys/appleapiopts.h> | |
73 | ||
74 | #include <sys/types.h> | |
75 | #include <sys/queue.h> | |
76 | #ifdef KERNEL_PRIVATE | |
77 | #ifdef KERNEL | |
78 | #include <kern/locks.h> | |
79 | #endif | |
80 | #endif /* KERNEL_PRIVATE */ | |
81 | ||
82 | #include <netinet6/ipsec.h> /* for IPSEC */ | |
83 | ||
84 | #ifdef KERNEL_PRIVATE | |
85 | ||
86 | #define in6pcb inpcb /* for KAME src sync over BSD*'s */ | |
87 | #define in6p_sp inp_sp /* for KAME src sync over BSD*'s */ | |
88 | ||
89 | /* | |
90 | * Common structure pcb for internet protocol implementation. | |
91 | * Here are stored pointers to local and foreign host table | |
92 | * entries, local and foreign socket numbers, and pointers | |
93 | * up (to a socket structure) and down (to a protocol-specific) | |
94 | * control block. | |
95 | */ | |
96 | LIST_HEAD(inpcbhead, inpcb); | |
97 | LIST_HEAD(inpcbporthead, inpcbport); | |
98 | #endif /* KERNEL_PRIVATE */ | |
99 | typedef u_quad_t inp_gen_t; | |
100 | ||
101 | /* | |
102 | * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet. | |
103 | * So, AF_INET6 null laddr is also used as AF_INET null laddr, | |
104 | * by utilize following structure. (At last, same as INRIA) | |
105 | */ | |
106 | struct in_addr_4in6 { | |
107 | u_int32_t ia46_pad32[3]; | |
108 | struct in_addr ia46_addr4; | |
109 | }; | |
110 | ||
111 | #ifdef KERNEL_PRIVATE | |
112 | /* | |
113 | * NB: the zone allocator is type-stable EXCEPT FOR THE FIRST TWO LONGS | |
114 | * of the structure. Therefore, it is important that the members in | |
115 | * that position not contain any information which is required to be | |
116 | * stable. | |
117 | */ | |
118 | struct icmp6_filter; | |
119 | #if CONFIG_MACF_NET | |
120 | struct label; | |
121 | #endif | |
122 | ||
123 | struct inpcb { | |
124 | LIST_ENTRY(inpcb) inp_hash; /* hash list */ | |
125 | int inp_wantcnt; /* pcb wanted count. protected by pcb list lock */ | |
126 | int inp_state; /* state of this pcb, in use, recycled, ready for recycling... */ | |
127 | u_short inp_fport; /* foreign port */ | |
128 | u_short inp_lport; /* local port */ | |
129 | LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */ | |
130 | caddr_t inp_ppcb; /* pointer to per-protocol pcb */ | |
131 | struct inpcbinfo *inp_pcbinfo; /* PCB list info */ | |
132 | struct socket *inp_socket; /* back pointer to socket */ | |
133 | u_char nat_owner; /* Used to NAT TCP/UDP traffic */ | |
134 | u_int32_t nat_cookie; /* Cookie stored and returned to NAT */ | |
135 | LIST_ENTRY(inpcb) inp_portlist; /* list for this PCB's local port */ | |
136 | struct inpcbport *inp_phd; /* head of this list */ | |
137 | inp_gen_t inp_gencnt; /* generation count of this instance */ | |
138 | int inp_flags; /* generic IP/datagram flags */ | |
139 | u_int32_t inp_flow; | |
140 | ||
141 | u_char inp_vflag; /* INP_IPV4 or INP_IPV6 */ | |
142 | ||
143 | u_char inp_ip_ttl; /* time to live proto */ | |
144 | u_char inp_ip_p; /* protocol proto */ | |
145 | /* protocol dependent part */ | |
146 | union { | |
147 | /* foreign host table entry */ | |
148 | struct in_addr_4in6 inp46_foreign; | |
149 | struct in6_addr inp6_foreign; | |
150 | } inp_dependfaddr; | |
151 | union { | |
152 | /* local host table entry */ | |
153 | struct in_addr_4in6 inp46_local; | |
154 | struct in6_addr inp6_local; | |
155 | } inp_dependladdr; | |
156 | union { | |
157 | /* placeholder for routing entry */ | |
158 | struct route inp4_route; | |
159 | struct route_in6 inp6_route; | |
160 | } inp_dependroute; | |
161 | struct { | |
162 | /* type of service proto */ | |
163 | u_char inp4_ip_tos; | |
164 | /* IP options */ | |
165 | struct mbuf *inp4_options; | |
166 | /* IP multicast options */ | |
167 | struct ip_moptions *inp4_moptions; | |
168 | } inp_depend4; | |
169 | struct { | |
170 | /* IP options */ | |
171 | struct mbuf *inp6_options; | |
172 | u_int8_t inp6_hlim; | |
173 | u_int8_t unused_uint8_1; | |
174 | ushort unused_uint16_1; | |
175 | /* IP6 options for outgoing packets */ | |
176 | struct ip6_pktopts *inp6_outputopts; | |
177 | /* IP multicast options */ | |
178 | struct ip6_moptions *inp6_moptions; | |
179 | /* ICMPv6 code type filter */ | |
180 | struct icmp6_filter *inp6_icmp6filt; | |
181 | /* IPV6_CHECKSUM setsockopt */ | |
182 | int inp6_cksum; | |
183 | u_short inp6_ifindex; | |
184 | short inp6_hops; | |
185 | } inp_depend6; | |
186 | ||
187 | int hash_element; /* Array index of pcb's hash list */ | |
188 | caddr_t inp_saved_ppcb; /* place to save pointer while cached */ | |
189 | struct inpcbpolicy *inp_sp; | |
190 | #ifdef _KERN_LOCKS_H_ | |
191 | lck_mtx_t *inpcb_mtx; /* inpcb per-socket mutex */ | |
192 | #else | |
193 | void *inpcb_mtx; | |
194 | #endif | |
195 | unsigned int inp_boundif; /* interface scope for INP_BOUND_IF */ | |
196 | u_int32_t inp_reserved[3]; /* reserved for future use */ | |
197 | #if CONFIG_MACF_NET | |
198 | struct label *inp_label; /* MAC label */ | |
199 | #endif | |
200 | }; | |
201 | ||
202 | #endif /* KERNEL_PRIVATE */ | |
203 | ||
204 | /* | |
205 | * The range of the generation count, as used in this implementation, | |
206 | * is 9e19. We would have to create 300 billion connections per | |
207 | * second for this number to roll over in a year. This seems sufficiently | |
208 | * unlikely that we simply don't concern ourselves with that possibility. | |
209 | */ | |
210 | ||
211 | /* | |
212 | * Interface exported to userland by various protocols which use | |
213 | * inpcbs. Hack alert -- only define if struct xsocket is in scope. | |
214 | */ | |
215 | ||
216 | /* | |
217 | * This is a copy of the inpcb as it shipped in Panther. This structure | |
218 | * is filled out in a copy function. This allows the inpcb to change | |
219 | * without breaking userland tools. | |
220 | * | |
221 | * CAUTION: Many fields may not be filled out. Fewer may be filled out | |
222 | * in the future. Code defensively. | |
223 | */ | |
224 | ||
225 | #pragma pack(4) | |
226 | ||
227 | #if defined(__LP64__) | |
228 | struct _inpcb_list_entry { | |
229 | u_int32_t le_next; | |
230 | u_int32_t le_prev; | |
231 | }; | |
232 | #define _INPCB_PTR(x) u_int32_t | |
233 | #define _INPCB_LIST_ENTRY(x) struct _inpcb_list_entry | |
234 | #else | |
235 | #define _INPCB_PTR(x) x | |
236 | #define _INPCB_LIST_ENTRY(x) LIST_ENTRY(x) | |
237 | #endif | |
238 | ||
239 | #ifdef KERNEL_PRIVATE | |
240 | struct inpcb_compat { | |
241 | #else | |
242 | struct inpcbinfo; | |
243 | struct inpcbport; | |
244 | struct mbuf; | |
245 | struct ip6_pktopts; | |
246 | struct ip6_moptions; | |
247 | struct icmp6_filter; | |
248 | struct inpcbpolicy; | |
249 | ||
250 | struct inpcb { | |
251 | #endif /* KERNEL_PRIVATE */ | |
252 | _INPCB_LIST_ENTRY(inpcb) inp_hash; /* hash list */ | |
253 | struct in_addr reserved1; /* APPLE reserved: inp_faddr defined in protcol indep. part */ | |
254 | struct in_addr reserved2; /* APPLE reserved */ | |
255 | u_short inp_fport; /* foreign port */ | |
256 | u_short inp_lport; /* local port */ | |
257 | _INPCB_LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */ | |
258 | _INPCB_PTR(caddr_t) inp_ppcb; /* pointer to per-protocol pcb */ | |
259 | _INPCB_PTR(struct inpcbinfo *) inp_pcbinfo; /* PCB list info */ | |
260 | _INPCB_PTR(void *) inp_socket; /* back pointer to socket */ | |
261 | u_char nat_owner; /* Used to NAT TCP/UDP traffic */ | |
262 | u_int32_t nat_cookie; /* Cookie stored and returned to NAT */ | |
263 | _INPCB_LIST_ENTRY(inpcb) inp_portlist; /* list for this PCB's local port */ | |
264 | _INPCB_PTR(struct inpcbport *) inp_phd; /* head of this list */ | |
265 | inp_gen_t inp_gencnt; /* generation count of this instance */ | |
266 | int inp_flags; /* generic IP/datagram flags */ | |
267 | u_int32_t inp_flow; | |
268 | ||
269 | u_char inp_vflag; | |
270 | ||
271 | u_char inp_ip_ttl; /* time to live proto */ | |
272 | u_char inp_ip_p; /* protocol proto */ | |
273 | /* protocol dependent part */ | |
274 | union { | |
275 | /* foreign host table entry */ | |
276 | struct in_addr_4in6 inp46_foreign; | |
277 | struct in6_addr inp6_foreign; | |
278 | } inp_dependfaddr; | |
279 | union { | |
280 | /* local host table entry */ | |
281 | struct in_addr_4in6 inp46_local; | |
282 | struct in6_addr inp6_local; | |
283 | } inp_dependladdr; | |
284 | union { | |
285 | /* placeholder for routing entry */ | |
286 | u_char inp4_route[20]; | |
287 | u_char inp6_route[32]; | |
288 | } inp_dependroute; | |
289 | struct { | |
290 | /* type of service proto */ | |
291 | u_char inp4_ip_tos; | |
292 | /* IP options */ | |
293 | _INPCB_PTR(struct mbuf *) inp4_options; | |
294 | /* IP multicast options */ | |
295 | _INPCB_PTR(struct ip_moptions *) inp4_moptions; | |
296 | } inp_depend4; | |
297 | ||
298 | struct { | |
299 | /* IP options */ | |
300 | _INPCB_PTR(struct mbuf *) inp6_options; | |
301 | u_int8_t inp6_hlim; | |
302 | u_int8_t unused_uint8_1; | |
303 | ushort unused_uint16_1; | |
304 | /* IP6 options for outgoing packets */ | |
305 | _INPCB_PTR(struct ip6_pktopts *) inp6_outputopts; | |
306 | /* IP multicast options */ | |
307 | _INPCB_PTR(struct ip6_moptions *) inp6_moptions; | |
308 | /* ICMPv6 code type filter */ | |
309 | _INPCB_PTR(struct icmp6_filter *) inp6_icmp6filt; | |
310 | /* IPV6_CHECKSUM setsockopt */ | |
311 | int inp6_cksum; | |
312 | u_short inp6_ifindex; | |
313 | short inp6_hops; | |
314 | } inp_depend6; | |
315 | ||
316 | int hash_element; /* Array index of pcb's hash list */ | |
317 | _INPCB_PTR(caddr_t) inp_saved_ppcb; /* place to save pointer while cached */ | |
318 | _INPCB_PTR(struct inpcbpolicy *) inp_sp; | |
319 | u_int32_t reserved[3]; /* For future use */ | |
320 | }; | |
321 | ||
322 | struct xinpcb { | |
323 | u_int32_t xi_len; /* length of this structure */ | |
324 | #ifdef KERNEL_PRIVATE | |
325 | struct inpcb_compat xi_inp; | |
326 | #else | |
327 | struct inpcb xi_inp; | |
328 | #endif | |
329 | struct xsocket xi_socket; | |
330 | u_quad_t xi_alignment_hack; | |
331 | }; | |
332 | ||
333 | #if !CONFIG_EMBEDDED | |
334 | ||
335 | struct inpcb64_list_entry { | |
336 | u_int64_t le_next; | |
337 | u_int64_t le_prev; | |
338 | }; | |
339 | ||
340 | struct xinpcb64 { | |
341 | u_int64_t xi_len; /* length of this structure */ | |
342 | u_int64_t xi_inpp; | |
343 | u_short inp_fport; /* foreign port */ | |
344 | u_short inp_lport; /* local port */ | |
345 | struct inpcb64_list_entry | |
346 | inp_list; /* list for all PCBs of this proto */ | |
347 | u_int64_t inp_ppcb; /* pointer to per-protocol pcb */ | |
348 | u_int64_t inp_pcbinfo; /* PCB list info */ | |
349 | struct inpcb64_list_entry | |
350 | inp_portlist; /* list for this PCB's local port */ | |
351 | u_int64_t inp_phd; /* head of this list */ | |
352 | inp_gen_t inp_gencnt; /* generation count of this instance */ | |
353 | int inp_flags; /* generic IP/datagram flags */ | |
354 | u_int32_t inp_flow; | |
355 | u_char inp_vflag; | |
356 | u_char inp_ip_ttl; /* time to live */ | |
357 | u_char inp_ip_p; /* protocol */ | |
358 | union { /* foreign host table entry */ | |
359 | struct in_addr_4in6 inp46_foreign; | |
360 | struct in6_addr inp6_foreign; | |
361 | } inp_dependfaddr; | |
362 | union { /* local host table entry */ | |
363 | struct in_addr_4in6 inp46_local; | |
364 | struct in6_addr inp6_local; | |
365 | } inp_dependladdr; | |
366 | struct { | |
367 | u_char inp4_ip_tos; /* type of service */ | |
368 | } inp_depend4; | |
369 | struct { | |
370 | u_int8_t inp6_hlim; | |
371 | int inp6_cksum; | |
372 | u_short inp6_ifindex; | |
373 | short inp6_hops; | |
374 | } inp_depend6; | |
375 | struct xsocket64 xi_socket; | |
376 | u_quad_t xi_alignment_hack; | |
377 | }; | |
378 | ||
379 | #endif /* !CONFIG_EMBEDDED */ | |
380 | ||
381 | struct xinpgen { | |
382 | u_int32_t xig_len; /* length of this structure */ | |
383 | u_int xig_count; /* number of PCBs at this time */ | |
384 | inp_gen_t xig_gen; /* generation count at this time */ | |
385 | so_gen_t xig_sogen; /* socket generation count at this time */ | |
386 | }; | |
387 | ||
388 | #pragma pack() | |
389 | ||
390 | /* | |
391 | * These defines are for use with the inpcb. | |
392 | */ | |
393 | #define INP_IPV4 0x1 | |
394 | #define INP_IPV6 0x2 | |
395 | #define inp_faddr inp_dependfaddr.inp46_foreign.ia46_addr4 | |
396 | #define inp_laddr inp_dependladdr.inp46_local.ia46_addr4 | |
397 | #define inp_route inp_dependroute.inp4_route | |
398 | #define inp_ip_tos inp_depend4.inp4_ip_tos | |
399 | #define inp_options inp_depend4.inp4_options | |
400 | #define inp_moptions inp_depend4.inp4_moptions | |
401 | #define in6p_faddr inp_dependfaddr.inp6_foreign | |
402 | #define in6p_laddr inp_dependladdr.inp6_local | |
403 | #define in6p_route inp_dependroute.inp6_route | |
404 | #define in6p_ip6_hlim inp_depend6.inp6_hlim | |
405 | #define in6p_hops inp_depend6.inp6_hops /* default hop limit */ | |
406 | #define in6p_ip6_nxt inp_ip_p | |
407 | #define in6p_flowinfo inp_flow | |
408 | #define in6p_vflag inp_vflag | |
409 | #define in6p_options inp_depend6.inp6_options | |
410 | #define in6p_outputopts inp_depend6.inp6_outputopts | |
411 | #define in6p_moptions inp_depend6.inp6_moptions | |
412 | #define in6p_icmp6filt inp_depend6.inp6_icmp6filt | |
413 | #define in6p_cksum inp_depend6.inp6_cksum | |
414 | #define in6p_ifindex inp_depend6.inp6_ifindex | |
415 | #define in6p_flags inp_flags /* for KAME src sync over BSD*'s */ | |
416 | #define in6p_socket inp_socket /* for KAME src sync over BSD*'s */ | |
417 | #define in6p_lport inp_lport /* for KAME src sync over BSD*'s */ | |
418 | #define in6p_fport inp_fport /* for KAME src sync over BSD*'s */ | |
419 | #define in6p_ppcb inp_ppcb /* for KAME src sync over BSD*'s */ | |
420 | #define in6p_state inp_state | |
421 | #define in6p_wantcnt inp_wantcnt | |
422 | ||
423 | #ifdef KERNEL_PRIVATE | |
424 | struct inpcbport { | |
425 | LIST_ENTRY(inpcbport) phd_hash; | |
426 | struct inpcbhead phd_pcblist; | |
427 | u_short phd_port; | |
428 | }; | |
429 | ||
430 | struct inpcbinfo { /* XXX documentation, prefixes */ | |
431 | struct inpcbhead *hashbase; | |
432 | #ifdef __APPLE__ | |
433 | u_int32_t hashsize; /* in elements */ | |
434 | #endif | |
435 | u_long hashmask; /* needs to be u_long as expected by hash functions */ | |
436 | struct inpcbporthead *porthashbase; | |
437 | u_long porthashmask; /* needs to be u_long as expected by hash functions */ | |
438 | struct inpcbhead *listhead; | |
439 | u_short lastport; | |
440 | u_short lastlow; | |
441 | u_short lasthi; | |
442 | void *ipi_zone; /* zone to allocate pcbs from */ | |
443 | u_int ipi_count; /* number of pcbs in this list */ | |
444 | u_quad_t ipi_gencnt; /* current generation count */ | |
445 | #ifdef __APPLE__ | |
446 | #ifdef _KERN_LOCKS_H_ | |
447 | lck_attr_t *mtx_attr; /* mutex attributes */ | |
448 | lck_grp_t *mtx_grp; /* mutex group definition */ | |
449 | lck_grp_attr_t *mtx_grp_attr; /* mutex group attributes */ | |
450 | lck_rw_t *mtx; /* global mutex for the pcblist*/ | |
451 | #else | |
452 | void *mtx_attr; /* mutex attributes */ | |
453 | void *mtx_grp; /* mutex group definition */ | |
454 | void *mtx_grp_attr; /* mutex group attributes */ | |
455 | void *mtx; /* global mutex for the pcblist*/ | |
456 | #endif | |
457 | #endif | |
458 | }; | |
459 | ||
460 | #define INP_PCBHASH(faddr, lport, fport, mask) \ | |
461 | (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) | |
462 | #define INP_PCBPORTHASH(lport, mask) \ | |
463 | (ntohs((lport)) & (mask)) | |
464 | ||
465 | #endif /* KERNEL_PRIVATE */ | |
466 | ||
467 | /* flags in inp_flags: */ | |
468 | #define INP_RECVOPTS 0x01 /* receive incoming IP options */ | |
469 | #define INP_RECVRETOPTS 0x02 /* receive IP options for reply */ | |
470 | #define INP_RECVDSTADDR 0x04 /* receive IP dst address */ | |
471 | #define INP_HDRINCL 0x08 /* user supplies entire IP header */ | |
472 | #define INP_HIGHPORT 0x10 /* user wants "high" port binding */ | |
473 | #define INP_LOWPORT 0x20 /* user wants "low" port binding */ | |
474 | #define INP_ANONPORT 0x40 /* port chosen for user */ | |
475 | #define INP_RECVIF 0x80 /* receive incoming interface */ | |
476 | #define INP_MTUDISC 0x100 /* user can do MTU discovery */ | |
477 | #ifdef __APPLE__ | |
478 | #define INP_STRIPHDR 0x200 /* Strip headers in raw_ip, for OT support */ | |
479 | #endif | |
480 | #define INP_FAITH 0x400 /* accept FAITH'ed connections */ | |
481 | #define INP_INADDR_ANY 0x800 /* local address wasn't specified */ | |
482 | ||
483 | #define INP_RECVTTL 0x1000 | |
484 | #define INP_UDP_NOCKSUM 0x2000 /* Turn off outbound UDP checksum */ | |
485 | #define INP_BOUND_IF 0x4000 /* bind socket to an ifindex */ | |
486 | ||
487 | #define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */ | |
488 | ||
489 | #define IN6P_PKTINFO 0x010000 /* receive IP6 dst and I/F */ | |
490 | #define IN6P_HOPLIMIT 0x020000 /* receive hoplimit */ | |
491 | #define IN6P_HOPOPTS 0x040000 /* receive hop-by-hop options */ | |
492 | #define IN6P_DSTOPTS 0x080000 /* receive dst options after rthdr */ | |
493 | #define IN6P_RTHDR 0x100000 /* receive routing header */ | |
494 | #define IN6P_RTHDRDSTOPTS 0x200000 /* receive dstoptions before rthdr */ | |
495 | #define IN6P_TCLASS 0x400000 /* receive traffic class value */ | |
496 | #define IN6P_AUTOFLOWLABEL 0x800000 /* attach flowlabel automatically */ | |
497 | #define IN6P_BINDV6ONLY 0x10000000 /* do not grab IPv4 traffic */ | |
498 | ||
499 | #ifdef KERNEL_PRIVATE | |
500 | #define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\ | |
501 | INP_RECVIF|INP_RECVTTL|\ | |
502 | IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\ | |
503 | IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\ | |
504 | IN6P_TCLASS|IN6P_AUTOFLOWLABEL) | |
505 | #define INP_UNMAPPABLEOPTS (IN6P_HOPOPTS|IN6P_DSTOPTS|IN6P_RTHDR|\ | |
506 | IN6P_TCLASS|IN6P_AUTOFLOWLABEL) | |
507 | ||
508 | /* for KAME src sync over BSD*'s */ | |
509 | #define IN6P_HIGHPORT INP_HIGHPORT | |
510 | #define IN6P_LOWPORT INP_LOWPORT | |
511 | #define IN6P_ANONPORT INP_ANONPORT | |
512 | #define IN6P_RECVIF INP_RECVIF | |
513 | #define IN6P_MTUDISC INP_MTUDISC | |
514 | #define IN6P_FAITH INP_FAITH | |
515 | #define IN6P_CONTROLOPTS INP_CONTROLOPTS | |
516 | /* | |
517 | * socket AF version is {newer than,or include} | |
518 | * actual datagram AF version | |
519 | */ | |
520 | ||
521 | #define INPLOOKUP_WILDCARD 1 | |
522 | #ifdef __APPLE__ | |
523 | #define INPCB_ALL_OWNERS 0xff | |
524 | #define INPCB_NO_OWNER 0x0 | |
525 | #define INPCB_OWNED_BY_X 0x80 | |
526 | #define INPCB_MAX_IDS 7 | |
527 | #endif /* __APPLE__ */ | |
528 | ||
529 | #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) | |
530 | #define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */ | |
531 | ||
532 | #define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family | |
533 | ||
534 | #define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af) | |
535 | ||
536 | #ifdef KERNEL | |
537 | extern int ipport_lowfirstauto; | |
538 | extern int ipport_lowlastauto; | |
539 | extern int ipport_firstauto; | |
540 | extern int ipport_lastauto; | |
541 | extern int ipport_hifirstauto; | |
542 | extern int ipport_hilastauto; | |
543 | ||
544 | #define INPCB_STATE_INUSE 0x1 /* freshly allocated PCB, it's in use */ | |
545 | #define INPCB_STATE_CACHED 0x2 /* this pcb is sitting in a a cache */ | |
546 | #define INPCB_STATE_DEAD 0x3 /* should treat as gone, will be garbage collected and freed */ | |
547 | ||
548 | #define WNT_STOPUSING 0xffff /* marked as ready to be garbaged collected, should be treated as not found */ | |
549 | #define WNT_ACQUIRE 0x1 /* that pcb is being acquired, do not recycle this time */ | |
550 | #define WNT_RELEASE 0x2 /* release acquired mode, can be garbage collected when wantcnt is null */ | |
551 | ||
552 | extern void in_losing(struct inpcb *); | |
553 | extern void in_rtchange(struct inpcb *, int); | |
554 | extern int in_pcballoc(struct socket *, struct inpcbinfo *, struct proc *); | |
555 | extern int in_pcbbind(struct inpcb *, struct sockaddr *, struct proc *); | |
556 | extern int in_pcbconnect(struct inpcb *, struct sockaddr *, struct proc *); | |
557 | extern void in_pcbdetach(struct inpcb *); | |
558 | extern void in_pcbdispose (struct inpcb *); | |
559 | extern void in_pcbdisconnect(struct inpcb *); | |
560 | extern int in_pcbinshash(struct inpcb *, int); | |
561 | extern int in_pcbladdr(struct inpcb *, struct sockaddr *, | |
562 | struct sockaddr_in **); | |
563 | extern struct inpcb *in_pcblookup_local(struct inpcbinfo *, struct in_addr, | |
564 | u_int, int); | |
565 | extern struct inpcb *in_pcblookup_local_and_cleanup(struct inpcbinfo *, | |
566 | struct in_addr, u_int, int); | |
567 | extern struct inpcb *in_pcblookup_hash(struct inpcbinfo *, struct in_addr, | |
568 | u_int, struct in_addr, u_int, int, struct ifnet *); | |
569 | extern void in_pcbnotifyall(struct inpcbinfo *, struct in_addr, int, | |
570 | void (*)(struct inpcb *, int)); | |
571 | extern void in_pcbrehash(struct inpcb *); | |
572 | extern int in_setpeeraddr(struct socket *so, struct sockaddr **nam); | |
573 | extern int in_setsockaddr(struct socket *so, struct sockaddr **nam); | |
574 | extern int in_pcb_checkstate(struct inpcb *pcb, int mode, int locked); | |
575 | ||
576 | extern void in_pcbremlists(struct inpcb *inp); | |
577 | extern void inpcb_to_compat(struct inpcb *inp, | |
578 | struct inpcb_compat *inp_compat); | |
579 | #if !CONFIG_EMBEDDED | |
580 | extern void inpcb_to_xinpcb64(struct inpcb *inp, | |
581 | struct xinpcb64 *xinp); | |
582 | #endif | |
583 | extern void inp_route_copyout(struct inpcb *, struct route *); | |
584 | extern void inp_route_copyin(struct inpcb *, struct route *); | |
585 | ||
586 | #endif /* KERNEL */ | |
587 | #endif /* KERNEL_PRIVATE */ | |
588 | ||
589 | #endif /* !_NETINET_IN_PCB_H_ */ |