]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/socketvar.h
35560c65b531056fb652f97a1d01b2cf4fe9bc09
[apple/xnu.git] / bsd / sys / socketvar.h
1 /*
2 * Copyright (c) 2000-2010 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 /* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */
29 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
30 /*-
31 * Copyright (c) 1982, 1986, 1990, 1993
32 * The Regents of the University of California. All rights reserved.
33 *
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
36 * are met:
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. All advertising materials mentioning features or use of this software
43 * must display the following acknowledgement:
44 * This product includes software developed by the University of
45 * California, Berkeley and its contributors.
46 * 4. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.
61 *
62 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
63 * $FreeBSD: src/sys/sys/socketvar.h,v 1.46.2.6 2001/08/31 13:45:49 jlemon Exp $
64 */
65 /*
66 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
67 * support for mandatory and extensible security protections. This notice
68 * is included in support of clause 2.2 (b) of the Apple Public License,
69 * Version 2.0.
70 */
71
72 #ifndef _SYS_SOCKETVAR_H_
73 #define _SYS_SOCKETVAR_H_
74
75 #include <sys/appleapiopts.h>
76 #include <sys/queue.h> /* for TAILQ macros */
77 #include <sys/select.h> /* for struct selinfo */
78 #include <net/kext_net.h>
79 #include <sys/ev.h>
80 #include <sys/cdefs.h>
81
82 /*
83 * Hacks to get around compiler complaints
84 */
85 struct mbuf;
86 struct socket_filter_entry;
87 struct protosw;
88 struct sockif;
89 struct sockutil;
90
91 #ifdef KERNEL_PRIVATE
92 /* strings for sleep message: */
93 extern char netio[], netcon[], netcls[];
94 #define SOCKET_CACHE_ON
95 #define SO_CACHE_FLUSH_INTERVAL 1 /* Seconds */
96 #define SO_CACHE_TIME_LIMIT (120/SO_CACHE_FLUSH_INTERVAL) /* Seconds */
97 #define SO_CACHE_MAX_FREE_BATCH 50
98 #define MAX_CACHED_SOCKETS 60000
99 #define TEMPDEBUG 0
100
101 /*
102 * Kernel structure per socket.
103 * Contains send and receive buffer queues,
104 * handle on protocol and pointer to protocol
105 * private data and error information.
106 */
107 #endif /* KERNEL_PRIVATE */
108
109 typedef u_quad_t so_gen_t;
110
111 #ifdef KERNEL_PRIVATE
112 #ifndef __APPLE__
113 /* We don't support BSD style socket filters */
114 struct accept_filter;
115 #endif
116
117 struct socket {
118 int so_zone; /* zone we were allocated from */
119 short so_type; /* generic type, see socket.h */
120 short so_options; /* from socket call, see socket.h */
121 short so_linger; /* time to linger while closing */
122 short so_state; /* internal state flags SS_*, below */
123 void *so_pcb; /* protocol control block */
124 struct protosw *so_proto; /* protocol handle */
125 /*
126 * Variables for connection queueing.
127 * Socket where accepts occur is so_head in all subsidiary sockets.
128 * If so_head is 0, socket is not related to an accept.
129 * For head socket so_incomp queues partially completed connections,
130 * while so_comp is a queue of connections ready to be accepted.
131 * If a connection is aborted and it has so_head set, then
132 * it has to be pulled out of either so_incomp or so_comp.
133 * We allow connections to queue up based on current queue lengths
134 * and limit on number of queued connections for this socket.
135 */
136 struct socket *so_head; /* back pointer to accept socket */
137 TAILQ_HEAD(, socket) so_incomp; /* q of partially unaccepted conns */
138 TAILQ_HEAD(, socket) so_comp; /* q of complete unaccepted conns */
139 TAILQ_ENTRY(socket) so_list; /* list of unaccepted connections */
140 short so_qlen; /* number of unaccepted connections */
141 short so_incqlen; /* number of unaccepted incomplete
142 connections */
143 short so_qlimit; /* max number queued connections */
144 short so_timeo; /* connection timeout */
145 u_short so_error; /* error affecting connection */
146 pid_t so_pgid; /* pgid for signals */
147 u_int32_t so_oobmark; /* chars to oob mark */
148 #ifndef __APPLE__
149 /* We don't support AIO ops */
150 TAILQ_HEAD(, aiocblist) so_aiojobq; /* AIO ops waiting on socket */
151 #endif
152 /*
153 * Variables for socket buffering.
154 */
155 struct sockbuf {
156 u_int32_t sb_cc; /* actual chars in buffer */
157 u_int32_t sb_hiwat; /* max actual char count */
158 u_int32_t sb_mbcnt; /* chars of mbufs used */
159 u_int32_t sb_mbmax; /* max chars of mbufs to use */
160 u_int32_t sb_ctl; /* non-data chars in buffer */
161 u_int32_t sb_lowat; /* low water mark */
162 struct mbuf *sb_mb; /* the mbuf chain */
163 struct mbuf *sb_mbtail; /* the last mbuf in the chain */
164 struct mbuf *sb_lastrecord; /* first mbuf of last record */
165 #if __APPLE__
166 struct socket *sb_so; /* socket back ptr for kexts */
167 #endif
168 struct selinfo sb_sel; /* process selecting read/write */
169 short sb_flags; /* flags, see below */
170 struct timeval sb_timeo; /* timeout for read/write */
171 u_int sb_maxused; /* max char count ever used in sockbuf */
172 void *reserved1[4]; /* for future use */
173 } so_rcv, so_snd;
174 #define SB_MAX (8192*1024) /* default for max chars in sockbuf */
175 #define LOW_SB_MAX (2*9*1024) /* lower limit on max socket buffer size, 2 max datagrams */
176 #define SB_LOCK 0x01 /* lock on data queue */
177 #define SB_WANT 0x02 /* someone is waiting to lock */
178 #define SB_WAIT 0x04 /* someone is waiting for data/space */
179 #define SB_SEL 0x08 /* someone is selecting */
180 #define SB_ASYNC 0x10 /* ASYNC I/O, need signals */
181 #define SB_UPCALL 0x20 /* someone wants an upcall */
182 #define SB_NOINTR 0x40 /* operations not interruptible */
183 #define SB_KNOTE 0x100 /* kernel note attached */
184 #define SB_USRSIZE 0x200 /* user specified sbreserve */
185 #ifndef __APPLE__
186 #define SB_AIO 0x80 /* AIO operations queued */
187 #else
188 #define SB_NOTIFY (SB_WAIT|SB_SEL|SB_ASYNC)
189 #define SB_DROP 0x400 /* does not accept any more data */
190 #define SB_UNIX 0x800 /* UNIX domain socket buffer */
191 #define SB_RECV 0x8000 /* this is rcv sb */
192
193 caddr_t so_tpcb; /* Wisc. protocol control block - XXX unused? */
194 #endif
195
196 void (*so_upcall)(struct socket *so, caddr_t arg, int waitf);
197 caddr_t so_upcallarg; /* Arg for above */
198 uid_t so_uid; /* who opened the socket */
199 /* NB: generation count must not be first; easiest to make it last. */
200 so_gen_t so_gencnt; /* generation count */
201 #ifndef __APPLE__
202 void *so_emuldata; /* private data for emulators */
203 struct so_accf {
204 struct accept_filter *so_accept_filter;
205 void *so_accept_filter_arg; /* saved filter args */
206 char *so_accept_filter_str; /* saved user args */
207 } *so_accf;
208 #else
209 TAILQ_HEAD(, eventqelt) so_evlist;
210 int cached_in_sock_layer; /* bundled with pcb/pcb.inp_ppcb? */
211 struct socket *cache_next;
212 struct socket *cache_prev;
213 u_int32_t cache_timestamp;
214 caddr_t so_saved_pcb; /* Saved pcb when cacheing */
215 struct mbuf *so_temp; /* Holding area for outbound frags */
216 /* Plug-in support - make the socket interface overridable */
217 struct mbuf *so_tail;
218 struct socket_filter_entry *so_filt; /* NKE hook */
219 u_int32_t so_flags; /* Flags */
220 #define SOF_NOSIGPIPE 0x1
221 #define SOF_NOADDRAVAIL 0x2 /* EADDRNOTAVAIL if src addr is gone */
222 #define SOF_PCBCLEARING 0x4 /* pru_disconnect done; don't call pru_detach */
223 #define SOF_DEFUNCT 0x8 /* accepted socket marked as inactive */
224 #define SOF_CLOSEWAIT 0x10 /* blocked in close awaiting some events */
225 #define SOF_UPCALLINUSE 0x20 /* socket upcall is currently in progress */
226 #define SOF_REUSESHAREUID 0x40 /* Allows SO_REUSEADDR/SO_REUSEPORT for multiple so_uid */
227 #define SOF_MULTIPAGES 0x80 /* jumbo clusters may be used for sosend */
228 #define SOF_ABORTED 0x100 /* soabort was already called once on the socket */
229 #define SOF_OVERFLOW 0x200 /* socket was dropped as overflow of listen queue */
230 #ifdef __APPLE_API_PRIVATE
231 #define SOF_NOTIFYCONFLICT 0x400 /* notify that a bind was done on a port already in use */
232 #endif
233 #define SOF_UPCALLCLOSEWAIT 0x800 /* block on close until an upcall returns */
234 #define SOF_BINDRANDOMPORT 0x1000 /* Request a randomized port number for the bind */
235 #define SOF_NPX_SETOPTSHUT 0x2000 /* Non POSIX extension to allow setsockopt(2) after shut down */
236 int so_usecount; /* refcounting of socket use */;
237 int so_retaincnt;
238 u_int32_t so_filteruse; /* usecount for the socket filters */
239 u_int32_t so_traffic_mgt_flags; /* traffic_mgt socket config */
240 thread_t so_send_filt_thread;
241 u_int32_t so_restrictions;
242
243 /* for debug pruposes */
244 #define SO_LCKDBG_MAX 4 /* number of debug locking Link Registers recorded */
245 void *lock_lr[SO_LCKDBG_MAX]; /* locking calling history */
246 int next_lock_lr;
247 void *unlock_lr[SO_LCKDBG_MAX]; /* unlocking caller history */
248 int next_unlock_lr;
249 void *reserved; /* reserved for future use */
250 #endif /* __APPLE__ */
251
252 struct label *so_label; /* MAC label for socket */
253 struct label *so_peerlabel; /* cached MAC label for socket peer */
254 thread_t so_background_thread; /* thread that marked this socket background */
255 #if PKT_PRIORITY
256 int so_traffic_class;
257 #endif /* PKT_PRIORITY */
258 };
259 #endif /* KERNEL_PRIVATE */
260
261 /*
262 * Socket state bits.
263 */
264 #define SS_NOFDREF 0x0001 /* no file table ref any more */
265 #define SS_ISCONNECTED 0x0002 /* socket connected to a peer */
266 #define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */
267 #define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */
268 #define SS_CANTSENDMORE 0x0010 /* can't send more data to peer */
269 #define SS_CANTRCVMORE 0x0020 /* can't receive more data from peer */
270 #define SS_RCVATMARK 0x0040 /* at mark on input */
271
272 #define SS_PRIV 0x0080 /* privileged for broadcast, raw... */
273 #define SS_NBIO 0x0100 /* non-blocking ops */
274 #define SS_ASYNC 0x0200 /* async i/o notify */
275 #define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */
276 #define SS_INCOMP 0x0800 /* Unaccepted, incomplete connection */
277 #define SS_COMP 0x1000 /* unaccepted, complete connection */
278 #define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
279 #define SS_DRAINING 0x4000 /* close waiting for blocked system
280 calls to drain */
281
282 #if defined(__LP64__)
283 #define _XSOCKET_PTR(x) u_int32_t
284 #else
285 #define _XSOCKET_PTR(x) x
286 #endif
287
288 #pragma pack(4)
289
290 struct xsockbuf {
291 u_int32_t sb_cc;
292 u_int32_t sb_hiwat;
293 u_int32_t sb_mbcnt;
294 u_int32_t sb_mbmax;
295 int32_t sb_lowat;
296 short sb_flags;
297 short sb_timeo;
298 };
299
300 /*
301 * Externalized form of struct socket used by the sysctl(3) interface.
302 */
303 struct xsocket {
304 u_int32_t xso_len; /* length of this structure */
305 _XSOCKET_PTR(struct socket *) xso_so; /* makes a convenient handle */
306 short so_type;
307 short so_options;
308 short so_linger;
309 short so_state;
310 _XSOCKET_PTR(caddr_t) so_pcb; /* another convenient handle */
311 int xso_protocol;
312 int xso_family;
313 short so_qlen;
314 short so_incqlen;
315 short so_qlimit;
316 short so_timeo;
317 u_short so_error;
318 pid_t so_pgid;
319 u_int32_t so_oobmark;
320 struct xsockbuf so_rcv;
321 struct xsockbuf so_snd;
322 uid_t so_uid; /* XXX */
323 };
324
325 #if !CONFIG_EMBEDDED
326
327 struct xsocket64 {
328 u_int32_t xso_len; /* length of this structure */
329 u_int64_t xso_so; /* makes a convenient handle */
330 short so_type;
331 short so_options;
332 short so_linger;
333 short so_state;
334 u_int64_t so_pcb; /* another convenient handle */
335 int xso_protocol;
336 int xso_family;
337 short so_qlen;
338 short so_incqlen;
339 short so_qlimit;
340 short so_timeo;
341 u_short so_error;
342 pid_t so_pgid;
343 u_int32_t so_oobmark;
344 struct xsockbuf so_rcv;
345 struct xsockbuf so_snd;
346 uid_t so_uid; /* XXX */
347 };
348
349 #endif /* !CONFIG_EMBEDDED */
350
351 #pragma pack()
352
353 #ifdef KERNEL_PRIVATE
354 /*
355 * Macros for sockets and socket buffering.
356 */
357
358 #define sbtoso(sb) (sb->sb_so)
359
360 /*
361 * Functions for sockets and socket buffering.
362 * These are macros on FreeBSD. On Darwin the
363 * implementation is in bsd/kern/uipc_socket2.c
364 */
365
366 __BEGIN_DECLS
367 int sb_notify(struct sockbuf *sb);
368 int sbspace(struct sockbuf *sb);
369 int sosendallatonce(struct socket *so);
370 int soreadable(struct socket *so);
371 int sowriteable(struct socket *so);
372 void sballoc(struct sockbuf *sb, struct mbuf *m);
373 void sbfree(struct sockbuf *sb, struct mbuf *m);
374 int sblock(struct sockbuf *sb, int wf);
375 void sbunlock(struct sockbuf *sb, int locked);
376 void sorwakeup(struct socket *so);
377 void sowwakeup(struct socket *so);
378 __END_DECLS
379
380 /*
381 * Socket extension mechanism: control block hooks:
382 * This is the "head" of any control block for an extenstion
383 * Note: we separate intercept function dispatch vectors from
384 * the NFDescriptor to permit selective replacement during
385 * operation, e.g., to disable some functions.
386 */
387 struct kextcb {
388 struct kextcb *e_next; /* Next kext control block */
389 void *e_fcb; /* Real filter control block */
390 struct NFDescriptor *e_nfd; /* NKE Descriptor */
391 /* Plug-in support - intercept functions */
392 struct sockif *e_soif; /* Socket functions */
393 struct sockutil *e_sout; /* Sockbuf utility functions */
394 };
395 #define EXT_NULL 0x0 /* STATE: Not in use */
396 #define sotokextcb(so) (so ? so->so_ext : 0)
397
398 #ifdef KERNEL
399
400 #define SO_FILT_HINT_LOCKED 0x1
401
402 /*
403 * Argument structure for sosetopt et seq. This is in the KERNEL
404 * section because it will never be visible to user code.
405 */
406 enum sopt_dir { SOPT_GET, SOPT_SET };
407 struct sockopt {
408 enum sopt_dir sopt_dir; /* is this a get or a set? */
409 int sopt_level; /* second arg of [gs]etsockopt */
410 int sopt_name; /* third arg of [gs]etsockopt */
411 user_addr_t sopt_val; /* fourth arg of [gs]etsockopt */
412 size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */
413 struct proc *sopt_p; /* calling process or null if kernel */
414 };
415
416 #if SENDFILE
417 struct sf_buf {
418 SLIST_ENTRY(sf_buf) free_list; /* list of free buffer slots */
419 int refcnt; /* reference count */
420 struct vm_page *m; /* currently mapped page */
421 vm_offset_t kva; /* va of mapping */
422 };
423 #endif
424
425 #ifdef MALLOC_DECLARE
426 MALLOC_DECLARE(M_PCB);
427 MALLOC_DECLARE(M_SONAME);
428 #endif
429
430 extern int maxsockets;
431 extern u_int32_t sb_max;
432 extern int socket_zone;
433 extern so_gen_t so_gencnt;
434 extern int socket_debug;
435 extern int sosendjcl;
436 extern int sosendjcl_ignore_capab;
437 extern int somaxconn;
438
439 struct file;
440 struct filedesc;
441 struct mbuf;
442 struct sockaddr;
443 struct stat;
444 struct ucred;
445 struct uio;
446 struct knote;
447
448 #define SBLASTRECORDCHK(sb, s) \
449 if (socket_debug) sblastrecordchk(sb, s);
450
451 #define SBLASTMBUFCHK(sb, s) \
452 if (socket_debug) sblastmbufchk(sb, s);
453
454 #define SB_EMPTY_FIXUP(sb) { \
455 if ((sb)->sb_mb == NULL) { \
456 (sb)->sb_mbtail = NULL; \
457 (sb)->sb_lastrecord = NULL; \
458 } \
459 }
460
461 /*
462 * From uipc_socket and friends
463 */
464 __BEGIN_DECLS
465 /* Not exported */
466 extern void socketinit(void) __attribute__((section("__TEXT, initcode")));
467
468 /* Exported */
469 extern struct sockaddr *dup_sockaddr(struct sockaddr *sa, int canwait);
470 extern int getsock(struct filedesc *fdp, int fd, struct file **fpp);
471 extern int sockargs(struct mbuf **mp, user_addr_t data, int buflen, int type);
472
473 extern int sbappend(struct sockbuf *sb, struct mbuf *m);
474 extern int sbappendstream(struct sockbuf *sb, struct mbuf *m);
475 extern int sbappendaddr(struct sockbuf *sb, struct sockaddr *asa,
476 struct mbuf *m0, struct mbuf *control, int *error_out);
477 extern int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
478 struct mbuf *control, int *error_out);
479 extern int sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
480 extern void sbcheck(struct sockbuf *sb);
481 extern void sblastmbufchk(struct sockbuf *, const char *);
482 extern void sblastrecordchk(struct sockbuf *, const char *);
483 extern struct mbuf *sbcreatecontrol(caddr_t p, int size, int type, int level);
484 extern void sbdrop(struct sockbuf *sb, int len);
485 extern void sbdroprecord(struct sockbuf *sb);
486 extern void sbflush(struct sockbuf *sb);
487 extern int sbinsertoob(struct sockbuf *sb, struct mbuf *m0);
488 extern void sbrelease(struct sockbuf *sb);
489 extern int sbreserve(struct sockbuf *sb, u_int32_t cc);
490 extern void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
491 extern int sbwait(struct sockbuf *sb);
492 extern int sb_lock(struct sockbuf *sb);
493 extern void sb_empty_assert(struct sockbuf *, const char *);
494
495 extern int soabort(struct socket *so);
496 extern int soaccept(struct socket *so, struct sockaddr **nam);
497 extern int soacceptlock(struct socket *so, struct sockaddr **nam, int dolock);
498 extern int soacceptfilter(struct socket *so);
499 extern struct socket *soalloc(int waitok, int dom, int type);
500 extern int sobind(struct socket *so, struct sockaddr *nam);
501 extern void socantrcvmore(struct socket *so);
502 extern void socantsendmore(struct socket *so);
503 extern int soclose(struct socket *so);
504 extern int soconnect(struct socket *so, struct sockaddr *nam);
505 extern int soconnectlock(struct socket *so, struct sockaddr *nam, int dolock);
506 extern int soconnect2(struct socket *so1, struct socket *so2);
507 extern int socreate(int dom, struct socket **aso, int type, int proto);
508 extern void sodealloc(struct socket *so);
509 extern int sodisconnect(struct socket *so);
510 extern int sodisconnectlocked(struct socket *so);
511 extern void sofree(struct socket *so);
512 extern void soreference(struct socket *so);
513 extern void sodereference(struct socket *so);
514 extern void somultipages(struct socket *, boolean_t);
515 extern int sogetopt(struct socket *so, struct sockopt *sopt);
516 extern void sohasoutofband(struct socket *so);
517 extern void soisconnected(struct socket *so);
518 extern void soisconnecting(struct socket *so);
519 extern void soisdisconnected(struct socket *so);
520 extern void soisdisconnecting(struct socket *so);
521 extern int soisbackground(struct socket *so);
522 extern int solisten(struct socket *so, int backlog);
523 extern struct socket *sodropablereq(struct socket *head);
524 extern struct socket *sonewconn(struct socket *head, int connstatus,
525 const struct sockaddr *from);
526 extern int sooptcopyin(struct sockopt *sopt, void *data, size_t len,
527 size_t minlen);
528 extern int sooptcopyout(struct sockopt *sopt, void *data, size_t len);
529 extern int socket_lock(struct socket *so, int refcount);
530 extern int socket_unlock(struct socket *so, int refcount);
531 extern void sofreelastref(struct socket *, int);
532 extern int sogetaddr_locked(struct socket *, struct sockaddr **, int);
533 extern const char *solockhistory_nr(struct socket *);
534 extern void set_traffic_class(struct mbuf *, struct socket *, int);
535 extern int mbuf_traffic_class_from_control(struct mbuf *);
536
537 /*
538 * XXX; prepare mbuf for (__FreeBSD__ < 3) routines.
539 * Used primarily in IPSec and IPv6 code.
540 */
541 extern int soopt_getm(struct sockopt *sopt, struct mbuf **mp);
542 extern int soopt_mcopyin(struct sockopt *sopt, struct mbuf *m);
543 extern int soopt_mcopyout(struct sockopt *sopt, struct mbuf *m);
544
545 extern int sopoll(struct socket *so, int events, struct ucred *cred, void *wql);
546 extern int soreceive(struct socket *so, struct sockaddr **paddr,
547 struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
548 extern int soreserve(struct socket *so, u_int32_t sndcc, u_int32_t rcvcc);
549 extern void sorflush(struct socket *so);
550 extern int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
551 struct mbuf *top, struct mbuf *control, int flags);
552
553 extern int sosetopt(struct socket *so, struct sockopt *sopt);
554 extern int soshutdown(struct socket *so, int how);
555 extern int soshutdownlock(struct socket *so, int how);
556 extern void sotoxsocket(struct socket *so, struct xsocket *xso);
557 #if !CONFIG_EMBEDDED
558 extern void sotoxsocket64(struct socket *so, struct xsocket64 *xso);
559 #endif
560 extern void sowakeup(struct socket *so, struct sockbuf *sb);
561 extern int soioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p);
562
563 #ifndef __APPLE__
564 /* accept filter functions */
565 extern int accept_filt_add(struct accept_filter *filt);
566 extern int accept_filt_del(char *name);
567 extern struct accept_filter *accept_filt_get(char *name);
568 #ifdef ACCEPT_FILTER_MOD
569 extern int accept_filt_generic_mod_event(module_t mod, int event, void *data);
570 SYSCTL_DECL(_net_inet_accf);
571 #endif /* ACCEPT_FILTER_MOD */
572 #endif /* !defined(__APPLE__) */
573
574 __END_DECLS
575
576 #endif /* KERNEL */
577 #endif /* KERNEL_PRIVATE */
578
579 #endif /* !_SYS_SOCKETVAR_H_ */