2 * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1982, 1986, 1990, 1993
30 * The Regents of the University of California. All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
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.
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
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 $
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,
70 #ifndef _NETINET_IN_PCB_H_
71 #define _NETINET_IN_PCB_H_
72 #include <sys/appleapiopts.h>
74 #include <sys/types.h>
75 #include <sys/queue.h>
77 #ifdef BSD_KERNEL_PRIVATE
79 #endif /* BSD_KERNEL_PRIVATE */
80 #include <kern/locks.h>
81 #endif /* KERNEL_PRIVATE */
83 #include <netinet6/ipsec.h> /* for IPSEC */
87 #define in6pcb inpcb /* for KAME src sync over BSD*'s */
88 #define in6p_sp inp_sp /* for KAME src sync over BSD*'s */
89 #endif /* KERNEL_PRIVATE */
91 #ifdef BSD_KERNEL_PRIVATE
93 * Common structure pcb for internet protocol implementation.
94 * Here are stored pointers to local and foreign host table
95 * entries, local and foreign socket numbers, and pointers
96 * up (to a socket structure) and down (to a protocol-specific)
99 LIST_HEAD(inpcbhead
, inpcb
);
100 LIST_HEAD(inpcbporthead
, inpcbport
);
101 #endif /* BSD_KERNEL_PRIVATE */
103 typedef u_quad_t inp_gen_t
;
105 * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet.
106 * So, AF_INET6 null laddr is also used as AF_INET null laddr, by utilizing
107 * the following structure.
109 struct in_addr_4in6
{
110 u_int32_t ia46_pad32
[3];
111 struct in_addr ia46_addr4
;
114 #ifdef KERNEL_PRIVATE
116 * NB: the zone allocator is type-stable EXCEPT FOR THE FIRST TWO LONGS
117 * of the structure. Therefore, it is important that the members in
118 * that position not contain any information which is required to be
127 #ifdef BSD_KERNEL_PRIVATE
128 /* Flow control entry per socket */
129 struct inp_fc_entry
{
130 RB_ENTRY(inp_fc_entry
) infc_link
;
131 u_int32_t infc_flowhash
;
132 struct inpcb
*infc_inp
;
134 #endif /* BSD_KERNEL_PRIVATE */
145 LIST_ENTRY(inpcb
) inp_hash
; /* hash list */
146 int inp_wantcnt
; /* pcb wanted count. protected by pcb list lock */
147 int inp_state
; /* state of this pcb, in use, recycled, ready for recycling... */
148 u_short inp_fport
; /* foreign port */
149 u_short inp_lport
; /* local port */
150 LIST_ENTRY(inpcb
) inp_list
; /* list for all PCBs of this proto */
151 void *inp_ppcb
; /* pointer to per-protocol pcb */
152 struct inpcbinfo
*inp_pcbinfo
; /* PCB list info */
153 struct socket
*inp_socket
; /* back pointer to socket */
154 u_int32_t nat_cookie
; /* Cookie stored and returned to NAT */
155 LIST_ENTRY(inpcb
) inp_portlist
; /* list for this PCB's local port */
156 struct inpcbport
*inp_phd
; /* head of this list */
157 inp_gen_t inp_gencnt
; /* generation count of this instance */
158 u_int32_t inp_flags
; /* generic IP/datagram flags */
161 u_char inp_sndinprog_cnt
; /* outstanding send operations */
162 u_char inp_vflag
; /* INP_IPV4 or INP_IPV6 */
164 u_char inp_ip_ttl
; /* time to live proto */
165 u_char inp_ip_p
; /* protocol proto */
166 /* protocol dependent part */
168 /* foreign host table entry */
169 struct in_addr_4in6 inp46_foreign
;
170 struct in6_addr inp6_foreign
;
173 /* local host table entry */
174 struct in_addr_4in6 inp46_local
;
175 struct in6_addr inp6_local
;
178 /* placeholder for routing entry */
179 struct route inp4_route
;
180 struct route_in6 inp6_route
;
183 /* type of service proto */
186 struct mbuf
*inp4_options
;
187 /* IP multicast options */
188 struct ip_moptions
*inp4_moptions
;
192 struct mbuf
*inp6_options
;
194 u_int8_t unused_uint8_1
;
195 ushort unused_uint16_1
;
196 /* IP6 options for outgoing packets */
197 struct ip6_pktopts
*inp6_outputopts
;
198 /* IP multicast options */
199 struct ip6_moptions
*inp6_moptions
;
200 /* ICMPv6 code type filter */
201 struct icmp6_filter
*inp6_icmp6filt
;
202 /* IPV6_CHECKSUM setsockopt */
204 u_short inp6_ifindex
;
208 int hash_element
; /* Array index of pcb's hash list */
209 caddr_t inp_saved_ppcb
; /* place to save pointer while cached */
210 struct inpcbpolicy
*inp_sp
;
211 decl_lck_mtx_data( ,inpcb_mtx
); /* inpcb per-socket mutex */
212 struct ifnet
*inp_boundifp
; /* interface for INP_BOUND_IF */
213 struct ifnet
*inp_last_outifp
; /* last known outgoing interface */
214 u_int32_t inp_reserved
[2]; /* reserved for future use */
215 u_int32_t inp_flowhash
; /* flow hash */
218 struct label
*inp_label
; /* MAC label */
220 struct inp_stat
*inp_stat
;
221 u_int8_t inp_stat_store
[sizeof(struct inp_stat
) + sizeof(u_int64_t
)];
224 #endif /* KERNEL_PRIVATE */
227 * The range of the generation count, as used in this implementation,
228 * is 9e19. We would have to create 300 billion connections per
229 * second for this number to roll over in a year. This seems sufficiently
230 * unlikely that we simply don't concern ourselves with that possibility.
234 * Interface exported to userland by various protocols which use
235 * inpcbs. Hack alert -- only define if struct xsocket is in scope.
239 * This is a copy of the inpcb as it shipped in Panther. This structure
240 * is filled out in a copy function. This allows the inpcb to change
241 * without breaking userland tools.
243 * CAUTION: Many fields may not be filled out. Fewer may be filled out
244 * in the future. Code defensively.
249 #if defined(__LP64__)
250 struct _inpcb_list_entry
{
254 #define _INPCB_PTR(x) u_int32_t
255 #define _INPCB_LIST_ENTRY(x) struct _inpcb_list_entry
257 #define _INPCB_PTR(x) x
258 #define _INPCB_LIST_ENTRY(x) LIST_ENTRY(x)
261 #ifdef KERNEL_PRIVATE
262 struct inpcb_compat
{
273 #endif /* KERNEL_PRIVATE */
274 _INPCB_LIST_ENTRY(inpcb
) inp_hash
; /* hash list */
275 struct in_addr reserved1
; /* APPLE reserved: inp_faddr defined in protcol indep. part */
276 struct in_addr reserved2
; /* APPLE reserved */
277 u_short inp_fport
; /* foreign port */
278 u_short inp_lport
; /* local port */
279 _INPCB_LIST_ENTRY(inpcb
) inp_list
; /* list for all PCBs of this proto */
280 _INPCB_PTR(caddr_t
) inp_ppcb
; /* pointer to per-protocol pcb */
281 _INPCB_PTR(struct inpcbinfo
*) inp_pcbinfo
; /* PCB list info */
282 _INPCB_PTR(void *) inp_socket
; /* back pointer to socket */
283 u_char nat_owner
; /* Used to NAT TCP/UDP traffic */
284 u_int32_t nat_cookie
; /* Cookie stored and returned to NAT */
285 _INPCB_LIST_ENTRY(inpcb
) inp_portlist
; /* list for this PCB's local port */
286 _INPCB_PTR(struct inpcbport
*) inp_phd
; /* head of this list */
287 inp_gen_t inp_gencnt
; /* generation count of this instance */
288 int inp_flags
; /* generic IP/datagram flags */
293 u_char inp_ip_ttl
; /* time to live proto */
294 u_char inp_ip_p
; /* protocol proto */
295 /* protocol dependent part */
297 /* foreign host table entry */
298 struct in_addr_4in6 inp46_foreign
;
299 struct in6_addr inp6_foreign
;
302 /* local host table entry */
303 struct in_addr_4in6 inp46_local
;
304 struct in6_addr inp6_local
;
307 /* placeholder for routing entry */
308 u_char inp4_route
[20];
309 u_char inp6_route
[32];
312 /* type of service proto */
315 _INPCB_PTR(struct mbuf
*) inp4_options
;
316 /* IP multicast options */
317 _INPCB_PTR(struct ip_moptions
*) inp4_moptions
;
322 _INPCB_PTR(struct mbuf
*) inp6_options
;
324 u_int8_t unused_uint8_1
;
325 ushort unused_uint16_1
;
326 /* IP6 options for outgoing packets */
327 _INPCB_PTR(struct ip6_pktopts
*) inp6_outputopts
;
328 /* IP multicast options */
329 _INPCB_PTR(struct ip6_moptions
*) inp6_moptions
;
330 /* ICMPv6 code type filter */
331 _INPCB_PTR(struct icmp6_filter
*) inp6_icmp6filt
;
332 /* IPV6_CHECKSUM setsockopt */
334 u_short inp6_ifindex
;
338 int hash_element
; /* Array index of pcb's hash list */
339 _INPCB_PTR(caddr_t
) inp_saved_ppcb
; /* place to save pointer while cached */
340 _INPCB_PTR(struct inpcbpolicy
*) inp_sp
;
341 u_int32_t reserved
[3]; /* For future use */
345 u_int32_t xi_len
; /* length of this structure */
346 #ifdef KERNEL_PRIVATE
347 struct inpcb_compat xi_inp
;
351 struct xsocket xi_socket
;
352 u_quad_t xi_alignment_hack
;
357 struct inpcb64_list_entry
{
363 u_int64_t xi_len
; /* length of this structure */
365 u_short inp_fport
; /* foreign port */
366 u_short inp_lport
; /* local port */
367 struct inpcb64_list_entry
368 inp_list
; /* list for all PCBs of this proto */
369 u_int64_t inp_ppcb
; /* pointer to per-protocol pcb */
370 u_int64_t inp_pcbinfo
; /* PCB list info */
371 struct inpcb64_list_entry
372 inp_portlist
; /* list for this PCB's local port */
373 u_int64_t inp_phd
; /* head of this list */
374 inp_gen_t inp_gencnt
; /* generation count of this instance */
375 int inp_flags
; /* generic IP/datagram flags */
378 u_char inp_ip_ttl
; /* time to live */
379 u_char inp_ip_p
; /* protocol */
380 union { /* foreign host table entry */
381 struct in_addr_4in6 inp46_foreign
;
382 struct in6_addr inp6_foreign
;
384 union { /* local host table entry */
385 struct in_addr_4in6 inp46_local
;
386 struct in6_addr inp6_local
;
389 u_char inp4_ip_tos
; /* type of service */
394 u_short inp6_ifindex
;
397 struct xsocket64 xi_socket
;
398 u_quad_t xi_alignment_hack
;
401 #endif /* !CONFIG_EMBEDDED */
405 struct xinpcb_list_entry
{
411 u_int32_t xi_len
; /* length of this structure */
412 u_int32_t xi_kind
; /* XSO_INPCB */
414 u_short inp_fport
; /* foreign port */
415 u_short inp_lport
; /* local port */
416 u_int64_t inp_ppcb
; /* pointer to per-protocol pcb */
417 inp_gen_t inp_gencnt
; /* generation count of this instance */
418 int inp_flags
; /* generic IP/datagram flags */
421 u_char inp_ip_ttl
; /* time to live */
422 u_char inp_ip_p
; /* protocol */
423 union { /* foreign host table entry */
424 struct in_addr_4in6 inp46_foreign
;
425 struct in6_addr inp6_foreign
;
427 union { /* local host table entry */
428 struct in_addr_4in6 inp46_local
;
429 struct in6_addr inp6_local
;
432 u_char inp4_ip_tos
; /* type of service */
437 u_short inp6_ifindex
;
440 u_int32_t inp_flowhash
;
446 u_int32_t xig_len
; /* length of this structure */
447 u_int xig_count
; /* number of PCBs at this time */
448 inp_gen_t xig_gen
; /* generation count at this time */
449 so_gen_t xig_sogen
; /* socket generation count at this time */
455 * These defines are for use with the inpcb.
459 #define inp_faddr inp_dependfaddr.inp46_foreign.ia46_addr4
460 #define inp_laddr inp_dependladdr.inp46_local.ia46_addr4
461 #define in6p_faddr inp_dependfaddr.inp6_foreign
462 #define in6p_laddr inp_dependladdr.inp6_local
464 #ifdef BSD_KERNEL_PRIVATE
465 #define inp_route inp_dependroute.inp4_route
466 #define inp_ip_tos inp_depend4.inp4_ip_tos
467 #define inp_options inp_depend4.inp4_options
468 #define inp_moptions inp_depend4.inp4_moptions
469 #define in6p_route inp_dependroute.inp6_route
470 #define in6p_ip6_hlim inp_depend6.inp6_hlim
471 #define in6p_hops inp_depend6.inp6_hops /* default hop limit */
472 #define in6p_ip6_nxt inp_ip_p
473 #define in6p_flowinfo inp_flow
474 #define in6p_vflag inp_vflag
475 #define in6p_options inp_depend6.inp6_options
476 #define in6p_outputopts inp_depend6.inp6_outputopts
477 #define in6p_moptions inp_depend6.inp6_moptions
478 #define in6p_icmp6filt inp_depend6.inp6_icmp6filt
479 #define in6p_cksum inp_depend6.inp6_cksum
480 #define in6p_ifindex inp_depend6.inp6_ifindex
481 #define in6p_flags inp_flags /* for KAME src sync over BSD*'s */
482 #define in6p_socket inp_socket /* for KAME src sync over BSD*'s */
483 #endif /* BSD_KERNEL_PRIVATE */
485 #define in6p_lport inp_lport /* for KAME src sync over BSD*'s */
486 #define in6p_fport inp_fport /* for KAME src sync over BSD*'s */
487 #define in6p_ppcb inp_ppcb /* for KAME src sync over BSD*'s */
489 #ifdef BSD_KERNEL_PRIVATE
490 #define in6p_state inp_state
491 #define in6p_wantcnt inp_wantcnt
492 #define in6p_last_outifp inp_last_outifp
493 #endif /* BSD_KERNEL_PRIVATE */
495 #ifdef BSD_KERNEL_PRIVATE
497 LIST_ENTRY(inpcbport
) phd_hash
;
498 struct inpcbhead phd_pcblist
;
502 struct inpcbinfo
{ /* XXX documentation, prefixes */
503 struct inpcbhead
*hashbase
;
505 u_int32_t hashsize
; /* in elements */
507 u_long hashmask
; /* u_long as expected by hash functions */
508 struct inpcbporthead
*porthashbase
;
509 u_long porthashmask
; /* u_long as expected by hash functions */
510 struct inpcbhead
*listhead
;
514 void *ipi_zone
; /* zone to allocate pcbs from */
515 u_int ipi_count
; /* number of pcbs in this list */
516 u_quad_t ipi_gencnt
; /* current generation count */
518 #ifdef _KERN_LOCKS_H_
519 lck_attr_t
*mtx_attr
; /* mutex attributes */
520 lck_grp_t
*mtx_grp
; /* mutex group definition */
521 lck_grp_attr_t
*mtx_grp_attr
; /* mutex group attributes */
522 lck_rw_t
*mtx
; /* global mutex for the pcblist*/
524 void *mtx_attr
; /* mutex attributes */
525 void *mtx_grp
; /* mutex group definition */
526 void *mtx_grp_attr
; /* mutex group attributes */
527 void *mtx
; /* global mutex for the pcblist*/
532 #define INP_PCBHASH(faddr, lport, fport, mask) \
533 (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask))
534 #define INP_PCBPORTHASH(lport, mask) \
535 (ntohs((lport)) & (mask))
537 #define INP_IS_FLOW_CONTROLLED(_inp_) ((_inp_)->inp_flags & INP_FLOW_CONTROLLED)
538 #define INP_IS_FLOW_SUSPENDED(_inp_) \
539 (((_inp_)->inp_flags & INP_FLOW_SUSPENDED) || \
540 ((_inp_)->inp_socket->so_flags & SOF_SUSPENDED))
541 #define INP_WAIT_FOR_IF_FEEDBACK(_inp_) \
542 (((_inp_)->inp_flags & (INP_FLOW_CONTROLLED | INP_FLOW_SUSPENDED)) != 0)
544 #endif /* BSD_KERNEL_PRIVATE */
546 /* flags in inp_flags: */
547 #ifdef BSD_KERNEL_PRIVATE
548 #define INP_RECVOPTS 0x01 /* receive incoming IP options */
549 #define INP_RECVRETOPTS 0x02 /* receive IP options for reply */
550 #define INP_RECVDSTADDR 0x04 /* receive IP dst address */
551 #define INP_HDRINCL 0x08 /* user supplies entire IP header */
552 #define INP_HIGHPORT 0x10 /* user wants "high" port binding */
553 #define INP_LOWPORT 0x20 /* user wants "low" port binding */
554 #endif /* BSD_KERNEL_PRIVATE */
555 #define INP_ANONPORT 0x40 /* port chosen for user */
556 #ifdef BSD_KERNEL_PRIVATE
557 #define INP_RECVIF 0x80 /* receive incoming interface */
558 #define INP_MTUDISC 0x100 /* user can do MTU discovery */
560 #define INP_STRIPHDR 0x200 /* Strip headers in raw_ip, for OT support */
562 #define INP_RECV_ANYIF 0x400 /* don't restrict inbound interface */
563 #endif /* BSD_KERNEL_PRIVATE */
564 #define INP_INADDR_ANY 0x800 /* local address wasn't specified */
566 #ifdef BSD_KERNEL_PRIVATE
567 #define INP_RECVTTL 0x1000
568 #define INP_UDP_NOCKSUM 0x2000 /* Turn off outbound UDP checksum */
569 #define INP_BOUND_IF 0x4000 /* bind socket to an ifindex */
570 #endif /* BSD_KERNEL_PRIVATE */
572 #define IN6P_IPV6_V6ONLY 0x8000 /* restrict AF_INET6 socket for v6 */
574 #ifdef BSD_KERNEL_PRIVATE
575 #define IN6P_PKTINFO 0x10000 /* receive IP6 dst and I/F */
576 #define IN6P_HOPLIMIT 0x20000 /* receive hoplimit */
577 #define IN6P_HOPOPTS 0x40000 /* receive hop-by-hop options */
578 #define IN6P_DSTOPTS 0x80000 /* receive dst options after rthdr */
579 #define IN6P_RTHDR 0x100000 /* receive routing header */
580 #define IN6P_RTHDRDSTOPTS 0x200000 /* receive dstoptions before rthdr */
581 #define IN6P_TCLASS 0x400000 /* receive traffic class value */
582 #define IN6P_AUTOFLOWLABEL 0x800000 /* attach flowlabel automatically */
583 #endif /* BSD_KERNEL_PRIVATE */
585 #define IN6P_BINDV6ONLY 0x1000000 /* do not grab IPv4 traffic */
587 #ifdef BSD_KERNEL_PRIVATE
588 #define IN6P_RFC2292 0x2000000 /* used RFC2292 API on the socket */
589 #define IN6P_MTU 0x4000000 /* receive path MTU */
590 #define INP_PKTINFO 0x8000000 /* receive and send PKTINFO for IPv4 */
591 #define INP_FLOW_SUSPENDED 0x10000000 /* flow suspended */
592 #define INP_NO_IFT_CELLULAR 0x20000000 /* do not use IFT_CELLULAR route */
593 #define INP_FLOW_CONTROLLED 0x40000000 /* flow controlled */
594 #define INP_FC_FEEDBACK 0x80000000 /* got interface flow adv feedback */
596 #define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\
597 INP_RECVIF|INP_RECVTTL|INP_PKTINFO|\
598 IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\
599 IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\
600 IN6P_TCLASS|IN6P_RFC2292|IN6P_MTU)
602 #define INP_UNMAPPABLEOPTS (IN6P_HOPOPTS|IN6P_DSTOPTS|IN6P_RTHDR|\
603 IN6P_TCLASS|IN6P_AUTOFLOWLABEL)
605 /* for KAME src sync over BSD*'s */
606 #define IN6P_HIGHPORT INP_HIGHPORT
607 #define IN6P_LOWPORT INP_LOWPORT
608 #define IN6P_ANONPORT INP_ANONPORT
609 #define IN6P_RECVIF INP_RECVIF
610 #define IN6P_MTUDISC INP_MTUDISC
611 #define IN6P_RECV_ANYIF INP_RECV_ANYIF
612 #define IN6P_CONTROLOPTS INP_CONTROLOPTS
613 #define IN6P_NO_IFT_CELLULAR INP_NO_IFT_CELLULAR
615 * socket AF version is {newer than,or include}
616 * actual datagram AF version
619 #define INPLOOKUP_WILDCARD 1
621 #define INPCB_ALL_OWNERS 0xff
622 #define INPCB_NO_OWNER 0x0
623 #define INPCB_OWNED_BY_X 0x80
624 #define INPCB_MAX_IDS 7
625 #endif /* __APPLE__ */
626 #endif /* BSD_KERNEL_PRIVATE */
628 #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
629 #define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */
631 #ifdef BSD_KERNEL_PRIVATE
632 #define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
633 #define INP_SOCKTYPE(so) so->so_proto->pr_type
635 #define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af)
636 #define INP_CHECK_SOCKTYPE(so, type) (INP_SOCKTYPE(so) == type)
638 extern int ipport_lowfirstauto
;
639 extern int ipport_lowlastauto
;
640 extern int ipport_firstauto
;
641 extern int ipport_lastauto
;
642 #endif /* BSD_KERNEL_PRIVATE */
644 extern int ipport_hifirstauto
;
645 extern int ipport_hilastauto
;
649 #ifdef BSD_KERNEL_PRIVATE
651 #define INPCB_STATE_INUSE 0x1 /* freshly allocated PCB, it's in use */
652 #define INPCB_STATE_CACHED 0x2 /* this pcb is sitting in a a cache */
653 #define INPCB_STATE_DEAD 0x3 /* should treat as gone, will be garbage collected and freed */
655 #define WNT_STOPUSING 0xffff /* marked as ready to be garbaged collected, should be treated as not found */
656 #define WNT_ACQUIRE 0x1 /* that pcb is being acquired, do not recycle this time */
657 #define WNT_RELEASE 0x2 /* release acquired mode, can be garbage collected when wantcnt is null */
659 extern void in_losing(struct inpcb
*);
660 extern void in_rtchange(struct inpcb
*, int);
661 extern int in_pcballoc(struct socket
*, struct inpcbinfo
*, struct proc
*);
662 extern int in_pcbbind(struct inpcb
*, struct sockaddr
*, struct proc
*);
663 extern int in_pcbconnect(struct inpcb
*, struct sockaddr
*, struct proc
*,
665 extern void in_pcbdetach(struct inpcb
*);
666 extern void in_pcbdispose (struct inpcb
*);
667 extern void in_pcbdisconnect(struct inpcb
*);
668 extern int in_pcbinshash(struct inpcb
*, int);
669 extern int in_pcbladdr(struct inpcb
*, struct sockaddr
*,
670 struct sockaddr_in
*, struct ifnet
**);
671 extern struct inpcb
*in_pcblookup_local(struct inpcbinfo
*, struct in_addr
,
673 extern struct inpcb
*in_pcblookup_local_and_cleanup(struct inpcbinfo
*,
674 struct in_addr
, u_int
, int);
675 extern struct inpcb
*in_pcblookup_hash(struct inpcbinfo
*, struct in_addr
,
676 u_int
, struct in_addr
, u_int
, int, struct ifnet
*);
677 extern int in_pcblookup_hash_exists(struct inpcbinfo
*, struct in_addr
,
678 u_int
, struct in_addr
, u_int
, int, uid_t
*, gid_t
*, struct ifnet
*);
679 extern void in_pcbnotifyall(struct inpcbinfo
*, struct in_addr
, int,
680 void (*)(struct inpcb
*, int));
681 extern void in_pcbrehash(struct inpcb
*);
682 extern int in_setpeeraddr(struct socket
*so
, struct sockaddr
**nam
);
683 extern int in_setsockaddr(struct socket
*so
, struct sockaddr
**nam
);
684 extern int in_pcb_checkstate(struct inpcb
*pcb
, int mode
, int locked
);
686 extern void in_pcbremlists(struct inpcb
*inp
);
687 extern void inpcb_to_compat(struct inpcb
*inp
,
688 struct inpcb_compat
*inp_compat
);
690 extern void inpcb_to_xinpcb64(struct inpcb
*inp
,
691 struct xinpcb64
*xinp
);
693 extern int get_pcblist_n(short , struct sysctl_req
*, struct inpcbinfo
*);
694 extern void inpcb_get_ports_used(unsigned int , uint8_t *, struct inpcbinfo
*);
696 #define INPCB_OPPORTUNISTIC_THROTTLEON 0x0001
697 #define INPCB_OPPORTUNISTIC_SETCMD 0x0002
698 extern uint32_t inpcb_count_opportunistic(unsigned int , struct inpcbinfo
*, u_int32_t
);
699 extern void inp_route_copyout(struct inpcb
*, struct route
*);
700 extern void inp_route_copyin(struct inpcb
*, struct route
*);
701 extern int inp_bindif(struct inpcb
*, unsigned int);
702 extern int inp_nocellular(struct inpcb
*, unsigned int);
703 extern u_int32_t
inp_calc_flowhash(struct inpcb
*);
704 extern void socket_flowadv_init(void);
705 extern int inp_fc_addinp(struct inpcb
*);
706 extern struct inp_fc_entry
*inp_fc_getinp(u_int32_t
);
707 extern void inp_fc_entry_free(struct inp_fc_entry
*);
708 extern void inp_fc_feedback(struct inpcb
*);
709 extern void inp_reset_fc_state(struct inpcb
*);
710 extern int inp_set_fc_state(struct inpcb
*, int advcode
);
711 extern void inp_fc_unthrottle_tcp(struct inpcb
*);
712 extern int inp_flush(struct inpcb
*, int);
713 #endif /* BSD_KERNEL_PRIVATE */
715 #ifdef KERNEL_PRIVATE
716 extern void inp_clear_INP_INADDR_ANY(struct socket
*so
);
717 #endif /* KERNEL_PRIVATE */
719 #endif /* !_NETINET_IN_PCB_H_ */