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