webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
user_socketvar.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 1982, 1986, 1990, 1993
3  * The Regents of the University of California. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 4. Neither the name of the University nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  */
30 
31 /* __Userspace__ version of <sys/socketvar.h> goes here.*/
32 
33 #ifndef _USER_SOCKETVAR_H_
34 #define _USER_SOCKETVAR_H_
35 
36 #if defined(__Userspace_os_Darwin)
37 #include <sys/types.h>
38 #include <unistd.h>
39 #endif
40 
41 /* #include <sys/selinfo.h> */ /*__Userspace__ alternative?*/ /* for struct selinfo */
42 /* #include <sys/_lock.h> was 0 byte file */
43 /* #include <sys/_mutex.h> was 0 byte file */
44 /* #include <sys/_sx.h> */ /*__Userspace__ alternative?*/
45 #if !defined(__Userspace_os_DragonFly) && !defined(__Userspace_os_FreeBSD) && !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_Windows) && !defined(__Userspace_os_NaCl)
46 #include <sys/uio.h>
47 #endif
48 #define SOCK_MAXADDRLEN 255
49 #if !defined(MSG_NOTIFICATION)
50 #define MSG_NOTIFICATION 0x2000 /* SCTP notification */
51 #endif
52 #define SCTP_SO_LINGER 0x0001
53 #define SCTP_SO_ACCEPTCONN 0x0002
54 #define SS_CANTRCVMORE 0x020
55 #define SS_CANTSENDMORE 0x010
56 
57 #if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_OpenBSD) || defined (__Userspace_os_Windows) || defined(__Userspace_os_NaCl)
58 #define UIO_MAXIOV 1024
59 #define ERESTART (-1)
60 #endif
61 
62 #if !defined(__Userspace_os_Darwin) && !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_OpenBSD)
64 #endif
65 
66 #if !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_OpenBSD)
67 /* Segment flag values. */
68 enum uio_seg {
69  UIO_USERSPACE, /* from user data space */
70  UIO_SYSSPACE /* from system space */
71 };
72 #endif
73 
74 struct proc {
75  int stub; /* struct proc is a dummy for __Userspace__ */
76 };
77 
78 MALLOC_DECLARE(M_ACCF);
79 MALLOC_DECLARE(M_PCB);
80 MALLOC_DECLARE(M_SONAME);
81 
82 /* __Userspace__ Are these all the fields we need?
83  * Removing struct thread *uio_td; owner field
84 */
85 struct uio {
86  struct iovec *uio_iov; /* scatter/gather list */
87  int uio_iovcnt; /* length of scatter/gather list */
88  off_t uio_offset; /* offset in target object */
89  ssize_t uio_resid; /* remaining bytes to process */
90  enum uio_seg uio_segflg; /* address space */
91  enum uio_rw uio_rw; /* operation */
92 };
93 
94 
95 /* __Userspace__ */
96 
97 /*
98  * Kernel structure per socket.
99  * Contains send and receive buffer queues,
100  * handle on protocol and pointer to protocol
101  * private data and error information.
102  */
103 #if defined (__Userspace_os_Windows)
104 #define AF_ROUTE 17
105 typedef __int32 pid_t;
106 typedef unsigned __int32 uid_t;
107 enum sigType {
108  SIGNAL = 0,
109  BROADCAST = 1,
110  MAX_EVENTS = 2
111 };
112 #endif
113 
114 /*-
115  * Locking key to struct socket:
116  * (a) constant after allocation, no locking required.
117  * (b) locked by SOCK_LOCK(so).
118  * (c) locked by SOCKBUF_LOCK(&so->so_rcv).
119  * (d) locked by SOCKBUF_LOCK(&so->so_snd).
120  * (e) locked by ACCEPT_LOCK().
121  * (f) not locked since integer reads/writes are atomic.
122  * (g) used only as a sleep/wakeup address, no value.
123  * (h) locked by global mutex so_global_mtx.
124  */
125 struct socket {
126  int so_count; /* (b) reference count */
127  short so_type; /* (a) generic type, see socket.h */
128  short so_options; /* from socket call, see socket.h */
129  short so_linger; /* time to linger while closing */
130  short so_state; /* (b) internal state flags SS_* */
131  int so_qstate; /* (e) internal state flags SQ_* */
132  void *so_pcb; /* protocol control block */
133  int so_dom;
134 /*
135  * Variables for connection queuing.
136  * Socket where accepts occur is so_head in all subsidiary sockets.
137  * If so_head is 0, socket is not related to an accept.
138  * For head socket so_incomp queues partially completed connections,
139  * while so_comp is a queue of connections ready to be accepted.
140  * If a connection is aborted and it has so_head set, then
141  * it has to be pulled out of either so_incomp or so_comp.
142  * We allow connections to queue up based on current queue lengths
143  * and limit on number of queued connections for this socket.
144  */
145  struct socket *so_head; /* (e) back pointer to listen socket */
146  TAILQ_HEAD(, socket) so_incomp; /* (e) queue of partial unaccepted connections */
147  TAILQ_HEAD(, socket) so_comp; /* (e) queue of complete unaccepted connections */
148  TAILQ_ENTRY(socket) so_list; /* (e) list of unaccepted connections */
149  u_short so_qlen; /* (e) number of unaccepted connections */
150  u_short so_incqlen; /* (e) number of unaccepted incomplete
151  connections */
152  u_short so_qlimit; /* (e) max number queued connections */
153  short so_timeo; /* (g) connection timeout */
154  userland_cond_t timeo_cond; /* timeo_cond condition variable being used in wakeup */
155 
156  u_short so_error; /* (f) error affecting connection */
157  struct sigio *so_sigio; /* [sg] information for async I/O or
158  out of band data (SIGURG) */
159  u_long so_oobmark; /* (c) chars to oob mark */
160  TAILQ_HEAD(, aiocblist) so_aiojobq; /* AIO ops waiting on socket */
161 /*
162  * Variables for socket buffering.
163  */
164  struct sockbuf {
165  /* __Userspace__ Many of these fields may
166  * not be required for the sctp stack.
167  * Commenting out the following.
168  * Including pthread mutex and condition variable to be
169  * used by sbwait, sorwakeup and sowwakeup.
170  */
171  /* struct selinfo sb_sel;*/ /* process selecting read/write */
172  /* struct mtx sb_mtx;*/ /* sockbuf lock */
173  /* struct sx sb_sx;*/ /* prevent I/O interlacing */
174  userland_cond_t sb_cond; /* sockbuf condition variable */
175  userland_mutex_t sb_mtx; /* sockbuf lock associated with sb_cond */
176  short sb_state; /* (c/d) socket state on sockbuf */
177 #define sb_startzero sb_mb
178  struct mbuf *sb_mb; /* (c/d) the mbuf chain */
179  struct mbuf *sb_mbtail; /* (c/d) the last mbuf in the chain */
180  struct mbuf *sb_lastrecord; /* (c/d) first mbuf of last
181  * record in socket buffer */
182  struct mbuf *sb_sndptr; /* (c/d) pointer into mbuf chain */
183  u_int sb_sndptroff; /* (c/d) byte offset of ptr into chain */
184  u_int sb_cc; /* (c/d) actual chars in buffer */
185  u_int sb_hiwat; /* (c/d) max actual char count */
186  u_int sb_mbcnt; /* (c/d) chars of mbufs used */
187  u_int sb_mbmax; /* (c/d) max chars of mbufs to use */
188  u_int sb_ctl; /* (c/d) non-data chars in buffer */
189  int sb_lowat; /* (c/d) low water mark */
190  int sb_timeo; /* (c/d) timeout for read/write */
191  short sb_flags; /* (c/d) flags, see below */
192  } so_rcv, so_snd;
193 /*
194  * Constants for sb_flags field of struct sockbuf.
195  */
196 #define SB_MAX (256*1024) /* default for max chars in sockbuf */
197 #define SB_RAW (64*1024*2) /*Aligning so->so_rcv.sb_hiwat with the receive buffer size of raw socket*/
198 /*
199  * Constants for sb_flags field of struct sockbuf.
200  */
201 #define SB_WAIT 0x04 /* someone is waiting for data/space */
202 #define SB_SEL 0x08 /* someone is selecting */
203 #define SB_ASYNC 0x10 /* ASYNC I/O, need signals */
204 #define SB_UPCALL 0x20 /* someone wants an upcall */
205 #define SB_NOINTR 0x40 /* operations not interruptible */
206 #define SB_AIO 0x80 /* AIO operations queued */
207 #define SB_KNOTE 0x100 /* kernel note attached */
208 #define SB_AUTOSIZE 0x800 /* automatically size socket buffer */
209 
210  void (*so_upcall)(struct socket *, void *, int);
212  struct ucred *so_cred; /* (a) user credentials */
213  struct label *so_label; /* (b) MAC label for socket */
214  struct label *so_peerlabel; /* (b) cached MAC label for peer */
215  /* NB: generation count must not be first. */
216  uint32_t so_gencnt; /* (h) generation count */
217  void *so_emuldata; /* (b) private data for emulators */
218  struct so_accf {
219  struct accept_filter *so_accept_filter;
220  void *so_accept_filter_arg; /* saved filter args */
221  char *so_accept_filter_str; /* saved user args */
222  } *so_accf;
223 };
224 
225 #define SB_EMPTY_FIXUP(sb) do { \
226  if ((sb)->sb_mb == NULL) { \
227  (sb)->sb_mbtail = NULL; \
228  (sb)->sb_lastrecord = NULL; \
229  } \
230 } while (/*CONSTCOND*/0)
231 
232 /*
233  * Global accept mutex to serialize access to accept queues and
234  * fields associated with multiple sockets. This allows us to
235  * avoid defining a lock order between listen and accept sockets
236  * until such time as it proves to be a good idea.
237  */
238 #if defined(__Userspace_os_Windows)
241 #define ACCEPT_LOCK_ASSERT()
242 #define ACCEPT_LOCK() do { \
243  EnterCriticalSection(&accept_mtx); \
244 } while (0)
245 #define ACCEPT_UNLOCK() do { \
246  LeaveCriticalSection(&accept_mtx); \
247 } while (0)
248 #define ACCEPT_UNLOCK_ASSERT()
249 #else
251 
253 #ifdef INVARIANTS
254 #define ACCEPT_LOCK() KASSERT(pthread_mutex_lock(&accept_mtx) == 0, ("%s: accept_mtx already locked", __func__))
255 #define ACCEPT_UNLOCK() KASSERT(pthread_mutex_unlock(&accept_mtx) == 0, ("%s: accept_mtx not locked", __func__))
256 #else
257 #define ACCEPT_LOCK() (void)pthread_mutex_lock(&accept_mtx)
258 #define ACCEPT_UNLOCK() (void)pthread_mutex_unlock(&accept_mtx)
259 #endif
260 #define ACCEPT_LOCK_ASSERT() \
261  KASSERT(pthread_mutex_trylock(&accept_mtx) == EBUSY, ("%s: accept_mtx not locked", __func__))
262 #define ACCEPT_UNLOCK_ASSERT() do { \
263  KASSERT(pthread_mutex_trylock(&accept_mtx) == 0, ("%s: accept_mtx locked", __func__)); \
264  (void)pthread_mutex_unlock(&accept_mtx); \
265  } while (0)
266 #endif
267 
268 /*
269  * Per-socket buffer mutex used to protect most fields in the socket
270  * buffer.
271  */
272 #define SOCKBUF_MTX(_sb) (&(_sb)->sb_mtx)
273 #if defined (__Userspace_os_Windows)
274 #define SOCKBUF_LOCK_INIT(_sb, _name) \
275  InitializeCriticalSection(SOCKBUF_MTX(_sb))
276 #define SOCKBUF_LOCK_DESTROY(_sb) DeleteCriticalSection(SOCKBUF_MTX(_sb))
277 #define SOCKBUF_COND_INIT(_sb) InitializeConditionVariable((&(_sb)->sb_cond))
278 #define SOCKBUF_COND_DESTROY(_sb) DeleteConditionVariable((&(_sb)->sb_cond))
279 #define SOCK_COND_INIT(_so) InitializeConditionVariable((&(_so)->timeo_cond))
280 #define SOCK_COND_DESTROY(_so) DeleteConditionVariable((&(_so)->timeo_cond))
281 #define SOCK_COND(_so) (&(_so)->timeo_cond)
282 #else
283 #ifdef INVARIANTS
284 #define SOCKBUF_LOCK_INIT(_sb, _name) do { \
285  pthread_mutexattr_t mutex_attr; \
286  \
287  pthread_mutexattr_init(&mutex_attr); \
288  pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_ERRORCHECK); \
289  pthread_mutex_init(SOCKBUF_MTX(_sb), &mutex_attr); \
290  pthread_mutexattr_destroy(&mutex_attr); \
291 } while (0)
292 #else
293 #define SOCKBUF_LOCK_INIT(_sb, _name) \
294  pthread_mutex_init(SOCKBUF_MTX(_sb), NULL)
295 #endif
296 #define SOCKBUF_LOCK_DESTROY(_sb) pthread_mutex_destroy(SOCKBUF_MTX(_sb))
297 #define SOCKBUF_COND_INIT(_sb) pthread_cond_init((&(_sb)->sb_cond), NULL)
298 #define SOCKBUF_COND_DESTROY(_sb) pthread_cond_destroy((&(_sb)->sb_cond))
299 #define SOCK_COND_INIT(_so) pthread_cond_init((&(_so)->timeo_cond), NULL)
300 #define SOCK_COND_DESTROY(_so) pthread_cond_destroy((&(_so)->timeo_cond))
301 #define SOCK_COND(_so) (&(_so)->timeo_cond)
302 #endif
303 /*__Userspace__ SOCKBUF_LOCK(_sb) is now defined in netinet/sctp_process_lock.h */
304 
305 /* #define SOCKBUF_OWNED(_sb) mtx_owned(SOCKBUF_MTX(_sb)) unused */
306 /*__Userspace__ SOCKBUF_UNLOCK(_sb) is now defined in netinet/sctp_process_lock.h */
307 
308 /*__Userspace__ SOCKBUF_LOCK_ASSERT(_sb) is now defined in netinet/sctp_process_lock.h */
309 
310 /* #define SOCKBUF_UNLOCK_ASSERT(_sb) mtx_assert(SOCKBUF_MTX(_sb), MA_NOTOWNED) unused */
311 
312 /*
313  * Per-socket mutex: we reuse the receive socket buffer mutex for space
314  * efficiency. This decision should probably be revisited as we optimize
315  * locking for the socket code.
316  */
317 #define SOCK_MTX(_so) SOCKBUF_MTX(&(_so)->so_rcv)
318 /*__Userspace__ SOCK_LOCK(_so) is now defined in netinet/sctp_process_lock.h */
319 
320 /* #define SOCK_OWNED(_so) SOCKBUF_OWNED(&(_so)->so_rcv) unused */
321 /*__Userspace__ SOCK_UNLOCK(_so) is now defined in netinet/sctp_process_lock.h */
322 
323 #define SOCK_LOCK_ASSERT(_so) SOCKBUF_LOCK_ASSERT(&(_so)->so_rcv)
324 
325 /*
326  * Socket state bits.
327  *
328  * Historically, this bits were all kept in the so_state field. For
329  * locking reasons, they are now in multiple fields, as they are
330  * locked differently. so_state maintains basic socket state protected
331  * by the socket lock. so_qstate holds information about the socket
332  * accept queues. Each socket buffer also has a state field holding
333  * information relevant to that socket buffer (can't send, rcv). Many
334  * fields will be read without locks to improve performance and avoid
335  * lock order issues. However, this approach must be used with caution.
336  */
337 #define SS_NOFDREF 0x0001 /* no file table ref any more */
338 #define SS_ISCONNECTED 0x0002 /* socket connected to a peer */
339 #define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */
340 #define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */
341 #define SS_NBIO 0x0100 /* non-blocking ops */
342 #define SS_ASYNC 0x0200 /* async i/o notify */
343 #define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */
344 #define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
345 /*
346  * Protocols can mark a socket as SS_PROTOREF to indicate that, following
347  * pru_detach, they still want the socket to persist, and will free it
348  * themselves when they are done. Protocols should only ever call sofree()
349  * following setting this flag in pru_detach(), and never otherwise, as
350  * sofree() bypasses socket reference counting.
351  */
352 #define SS_PROTOREF 0x4000 /* strong protocol reference */
353 
354 /*
355  * Socket state bits now stored in the socket buffer state field.
356  */
357 #define SBS_CANTSENDMORE 0x0010 /* can't send more data to peer */
358 #define SBS_CANTRCVMORE 0x0020 /* can't receive more data from peer */
359 #define SBS_RCVATMARK 0x0040 /* at mark on input */
360 
361 /*
362  * Socket state bits stored in so_qstate.
363  */
364 #define SQ_INCOMP 0x0800 /* unaccepted, incomplete connection */
365 #define SQ_COMP 0x1000 /* unaccepted, complete connection */
366 
367 /*
368  * Externalized form of struct socket used by the sysctl(3) interface.
369  */
370 struct xsocket {
371  size_t xso_len; /* length of this structure */
372  struct socket *xso_so; /* makes a convenient handle sometimes */
373  short so_type;
374  short so_options;
375  short so_linger;
376  short so_state;
377  caddr_t so_pcb; /* another convenient handle */
380  u_short so_qlen;
381  u_short so_incqlen;
382  u_short so_qlimit;
383  short so_timeo;
384  u_short so_error;
385  pid_t so_pgid;
386  u_long so_oobmark;
387  struct xsockbuf {
388  u_int sb_cc;
389  u_int sb_hiwat;
390  u_int sb_mbcnt;
391  u_int sb_mbmax;
392  int sb_lowat;
393  int sb_timeo;
394  short sb_flags;
395  } so_rcv, so_snd;
396  uid_t so_uid; /* XXX */
397 };
398 
399 #if defined(_KERNEL)
400 
401 
402 /*
403  * Macros for sockets and socket buffering.
404  */
405 
406 /*
407  * Do we need to notify the other side when I/O is possible?
408  */
409 #define sb_notify(sb) (((sb)->sb_flags & (SB_WAIT | SB_SEL | SB_ASYNC | \
410  SB_UPCALL | SB_AIO | SB_KNOTE)) != 0)
411 
412 /*
413  * How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
414  * This is problematical if the fields are unsigned, as the space might
415  * still be negative (cc > hiwat or mbcnt > mbmax). Should detect
416  * overflow and return 0. Should use "lmin" but it doesn't exist now.
417  */
418 #define sbspace(sb) \
419  ((long) imin((int)((sb)->sb_hiwat - (sb)->sb_cc), \
420  (int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
421 
422 /* do we have to send all at once on a socket? */
423 #define sosendallatonce(so) \
424  ((so)->so_proto->pr_flags & PR_ATOMIC)
425 
426 /* can we read something from so? */
427 #define soreadable(so) \
428  ((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \
429  ((so)->so_rcv.sb_state & SBS_CANTRCVMORE) || \
430  !TAILQ_EMPTY(&(so)->so_comp) || (so)->so_error)
431 
432 /* can we write something to so? */
433 #define sowriteable(so) \
434  ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
435  (((so)->so_state&SS_ISCONNECTED) || \
436  ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \
437  ((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \
438  (so)->so_error)
439 
440 /* adjust counters in sb reflecting allocation of m */
441 #define sballoc(sb, m) { \
442  (sb)->sb_cc += (m)->m_len; \
443  if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
444  (sb)->sb_ctl += (m)->m_len; \
445  (sb)->sb_mbcnt += MSIZE; \
446  if ((m)->m_flags & M_EXT) \
447  (sb)->sb_mbcnt += (m)->m_ext.ext_size; \
448 }
449 
450 /* adjust counters in sb reflecting freeing of m */
451 #define sbfree(sb, m) { \
452  (sb)->sb_cc -= (m)->m_len; \
453  if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
454  (sb)->sb_ctl -= (m)->m_len; \
455  (sb)->sb_mbcnt -= MSIZE; \
456  if ((m)->m_flags & M_EXT) \
457  (sb)->sb_mbcnt -= (m)->m_ext.ext_size; \
458  if ((sb)->sb_sndptr == (m)) { \
459  (sb)->sb_sndptr = NULL; \
460  (sb)->sb_sndptroff = 0; \
461  } \
462  if ((sb)->sb_sndptroff != 0) \
463  (sb)->sb_sndptroff -= (m)->m_len; \
464 }
465 
466 /*
467  * soref()/sorele() ref-count the socket structure. Note that you must
468  * still explicitly close the socket, but the last ref count will free
469  * the structure.
470  */
471 #define soref(so) do { \
472  SOCK_LOCK_ASSERT(so); \
473  ++(so)->so_count; \
474 } while (0)
475 
476 #define sorele(so) do { \
477  ACCEPT_LOCK_ASSERT(); \
478  SOCK_LOCK_ASSERT(so); \
479  KASSERT((so)->so_count > 0, ("sorele")); \
480  if (--(so)->so_count == 0) \
481  sofree(so); \
482  else { \
483  SOCK_UNLOCK(so); \
484  ACCEPT_UNLOCK(); \
485  } \
486 } while (0)
487 
488 #define sotryfree(so) do { \
489  ACCEPT_LOCK_ASSERT(); \
490  SOCK_LOCK_ASSERT(so); \
491  if ((so)->so_count == 0) \
492  sofree(so); \
493  else { \
494  SOCK_UNLOCK(so); \
495  ACCEPT_UNLOCK(); \
496  } \
497 } while(0)
498 
499 /*
500  * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to
501  * avoid a non-atomic test-and-wakeup. However, sowakeup is
502  * responsible for releasing the lock if it is called. We unlock only
503  * if we don't call into sowakeup. If any code is introduced that
504  * directly invokes the underlying sowakeup() primitives, it must
505  * maintain the same semantics.
506  */
507 #define sorwakeup_locked(so) do { \
508  SOCKBUF_LOCK_ASSERT(&(so)->so_rcv); \
509  if (sb_notify(&(so)->so_rcv)) \
510  sowakeup((so), &(so)->so_rcv); \
511  else \
512  SOCKBUF_UNLOCK(&(so)->so_rcv); \
513 } while (0)
514 
515 #define sorwakeup(so) do { \
516  SOCKBUF_LOCK(&(so)->so_rcv); \
517  sorwakeup_locked(so); \
518 } while (0)
519 
520 #define sowwakeup_locked(so) do { \
521  SOCKBUF_LOCK_ASSERT(&(so)->so_snd); \
522  if (sb_notify(&(so)->so_snd)) \
523  sowakeup((so), &(so)->so_snd); \
524  else \
525  SOCKBUF_UNLOCK(&(so)->so_snd); \
526 } while (0)
527 
528 #define sowwakeup(so) do { \
529  SOCKBUF_LOCK(&(so)->so_snd); \
530  sowwakeup_locked(so); \
531 } while (0)
532 
533 /*
534  * Argument structure for sosetopt et seq. This is in the KERNEL
535  * section because it will never be visible to user code.
536  */
537 enum sopt_dir { SOPT_GET, SOPT_SET };
538 struct sockopt {
539  enum sopt_dir sopt_dir; /* is this a get or a set? */
540  int sopt_level; /* second arg of [gs]etsockopt */
541  int sopt_name; /* third arg of [gs]etsockopt */
542  void *sopt_val; /* fourth arg of [gs]etsockopt */
543  size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */
544  struct thread *sopt_td; /* calling thread or null if kernel */
545 };
546 
547 struct accept_filter {
548  char accf_name[16];
549  void (*accf_callback)
550  (struct socket *so, void *arg, int waitflag);
551  void * (*accf_create)
552  (struct socket *so, char *arg);
553  void (*accf_destroy)
554  (struct socket *so);
555  SLIST_ENTRY(accept_filter) accf_next;
556 };
557 
558 extern int maxsockets;
559 extern u_long sb_max;
560 extern struct uma_zone *socket_zone;
561 extern so_gen_t so_gencnt;
562 
563 struct mbuf;
564 struct sockaddr;
565 struct ucred;
566 struct uio;
567 
568 /*
569  * From uipc_socket and friends
570  */
571 int do_getopt_accept_filter(struct socket *so, struct sockopt *sopt);
572 int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt);
573 int so_setsockopt(struct socket *so, int level, int optname,
574  void *optval, size_t optlen);
575 int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type);
576 int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
577 void sbappend(struct sockbuf *sb, struct mbuf *m);
578 void sbappend_locked(struct sockbuf *sb, struct mbuf *m);
579 void sbappendstream(struct sockbuf *sb, struct mbuf *m);
580 void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m);
581 int sbappendaddr(struct sockbuf *sb, const struct sockaddr *asa,
582  struct mbuf *m0, struct mbuf *control);
583 int sbappendaddr_locked(struct sockbuf *sb, const struct sockaddr *asa,
584  struct mbuf *m0, struct mbuf *control);
585 int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
586  struct mbuf *control);
587 int sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
588  struct mbuf *control);
589 void sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
590 void sbappendrecord_locked(struct sockbuf *sb, struct mbuf *m0);
591 void sbcheck(struct sockbuf *sb);
592 void sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
593 struct mbuf *
594  sbcreatecontrol(caddr_t p, int size, int type, int level);
595 void sbdestroy(struct sockbuf *sb, struct socket *so);
596 void sbdrop(struct sockbuf *sb, int len);
597 void sbdrop_locked(struct sockbuf *sb, int len);
598 void sbdroprecord(struct sockbuf *sb);
599 void sbdroprecord_locked(struct sockbuf *sb);
600 void sbflush(struct sockbuf *sb);
601 void sbflush_locked(struct sockbuf *sb);
602 void sbrelease(struct sockbuf *sb, struct socket *so);
603 void sbrelease_locked(struct sockbuf *sb, struct socket *so);
604 int sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
605  struct thread *td);
606 int sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so,
607  struct thread *td);
608 struct mbuf *
609  sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff);
610 void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
611 int sbwait(struct sockbuf *sb);
612 int sblock(struct sockbuf *sb, int flags);
613 void sbunlock(struct sockbuf *sb);
614 void soabort(struct socket *so);
615 int soaccept(struct socket *so, struct sockaddr **nam);
616 int socheckuid(struct socket *so, uid_t uid);
617 int sobind(struct socket *so, struct sockaddr *nam, struct thread *td);
618 void socantrcvmore(struct socket *so);
619 void socantrcvmore_locked(struct socket *so);
620 void socantsendmore(struct socket *so);
621 void socantsendmore_locked(struct socket *so);
622 int soclose(struct socket *so);
623 int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td);
624 int soconnect2(struct socket *so1, struct socket *so2);
625 int socow_setup(struct mbuf *m0, struct uio *uio);
626 int socreate(int dom, struct socket **aso, int type, int proto,
627  struct ucred *cred, struct thread *td);
628 int sodisconnect(struct socket *so);
629 struct sockaddr *sodupsockaddr(const struct sockaddr *sa, int mflags);
630 void sofree(struct socket *so);
631 int sogetopt(struct socket *so, struct sockopt *sopt);
632 void sohasoutofband(struct socket *so);
633 void soisconnected(struct socket *so);
634 void soisconnecting(struct socket *so);
635 void soisdisconnected(struct socket *so);
636 void soisdisconnecting(struct socket *so);
637 int solisten(struct socket *so, int backlog, struct thread *td);
638 void solisten_proto(struct socket *so, int backlog);
639 int solisten_proto_check(struct socket *so);
640 struct socket *
641  sonewconn(struct socket *head, int connstatus);
642 int sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);
643 int sooptcopyout(struct sockopt *sopt, const void *buf, size_t len);
644 
645 /* XXX; prepare mbuf for (__FreeBSD__ < 3) routines. */
646 int soopt_getm(struct sockopt *sopt, struct mbuf **mp);
647 int soopt_mcopyin(struct sockopt *sopt, struct mbuf *m);
648 int soopt_mcopyout(struct sockopt *sopt, struct mbuf *m);
649 
650 int sopoll(struct socket *so, int events, struct ucred *active_cred,
651  struct thread *td);
652 int sopoll_generic(struct socket *so, int events,
653  struct ucred *active_cred, struct thread *td);
654 int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio,
655  struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
656 int soreceive_generic(struct socket *so, struct sockaddr **paddr,
657  struct uio *uio, struct mbuf **mp0, struct mbuf **controlp,
658  int *flagsp);
659 int soreserve(struct socket *so, u_long sndcc, u_long rcvcc);
660 void sorflush(struct socket *so);
661 int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
662  struct mbuf *top, struct mbuf *control, int flags,
663  struct thread *td);
664 int sosend_dgram(struct socket *so, struct sockaddr *addr,
665  struct uio *uio, struct mbuf *top, struct mbuf *control,
666  int flags, struct thread *td);
667 int sosend_generic(struct socket *so, struct sockaddr *addr,
668  struct uio *uio, struct mbuf *top, struct mbuf *control,
669  int flags, struct thread *td);
670 int sosetopt(struct socket *so, struct sockopt *sopt);
671 int soshutdown(struct socket *so, int how);
672 void sotoxsocket(struct socket *so, struct xsocket *xso);
673 void sowakeup(struct socket *so, struct sockbuf *sb);
674 
675 #ifdef SOCKBUF_DEBUG
676 void sblastrecordchk(struct sockbuf *, const char *, int);
677 #define SBLASTRECORDCHK(sb) sblastrecordchk((sb), __FILE__, __LINE__)
678 
679 void sblastmbufchk(struct sockbuf *, const char *, int);
680 #define SBLASTMBUFCHK(sb) sblastmbufchk((sb), __FILE__, __LINE__)
681 #else
682 #define SBLASTRECORDCHK(sb) /* nothing */
683 #define SBLASTMBUFCHK(sb) /* nothing */
684 #endif /* SOCKBUF_DEBUG */
685 
686 /*
687  * Accept filter functions (duh).
688  */
689 int accept_filt_add(struct accept_filter *filt);
690 int accept_filt_del(char *name);
691 struct accept_filter *accept_filt_get(char *name);
692 #ifdef ACCEPT_FILTER_MOD
693 #ifdef SYSCTL_DECL
694 SYSCTL_DECL(_net_inet_accf);
695 #endif
696 int accept_filt_generic_mod_event(module_t mod, int event, void *data);
697 #endif
698 
699 #endif /* _KERNEL */
700 
701 
702 /*-------------------------------------------------------------*/
703 /*-------------------------------------------------------------*/
704 /* __Userspace__ */
705 /*-------------------------------------------------------------*/
706 /*-------------------------------------------------------------*/
707 /* this new __Userspace__ section is to copy portions of the _KERNEL block
708  * above into, avoiding having to port the entire thing at once...
709  * For function prototypes, the full bodies are in user_socket.c .
710  */
711 #if defined(__Userspace__)
712 
713 /* ---------------------------------------------------------- */
714 /* --- function prototypes (implemented in user_socket.c) --- */
715 /* ---------------------------------------------------------- */
716 void soisconnecting(struct socket *so);
717 void soisdisconnecting(struct socket *so);
718 void soisconnected(struct socket *so);
719 struct socket * sonewconn(struct socket *head, int connstatus);
720 void socantrcvmore(struct socket *so);
721 void socantsendmore(struct socket *so);
722 
723 
724 
725 /* -------------- */
726 /* --- macros --- */
727 /* -------------- */
728 
729 #define soref(so) do { \
730  SOCK_LOCK_ASSERT(so); \
731  ++(so)->so_count; \
732 } while (0)
733 
734 #define sorele(so) do { \
735  ACCEPT_LOCK_ASSERT(); \
736  SOCK_LOCK_ASSERT(so); \
737  KASSERT((so)->so_count > 0, ("sorele")); \
738  if (--(so)->so_count == 0) \
739  sofree(so); \
740  else { \
741  SOCK_UNLOCK(so); \
742  ACCEPT_UNLOCK(); \
743  } \
744 } while (0)
745 
746 
747 /* replacing imin with min (user_environment.h) */
748 #define sbspace(sb) \
749  ((long) min((int)((sb)->sb_hiwat - (sb)->sb_cc), \
750  (int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
751 
752 /* do we have to send all at once on a socket? */
753 #define sosendallatonce(so) \
754  ((so)->so_proto->pr_flags & PR_ATOMIC)
755 
756 /* can we read something from so? */
757 #define soreadable(so) \
758  ((int)((so)->so_rcv.sb_cc) >= (so)->so_rcv.sb_lowat || \
759  ((so)->so_rcv.sb_state & SBS_CANTRCVMORE) || \
760  !TAILQ_EMPTY(&(so)->so_comp) || (so)->so_error)
761 
762 #if 0 /* original */
763 #define PR_CONNREQUIRED 0x04 /* from sys/protosw.h "needed" for sowriteable */
764 #define sowriteable(so) \
765  ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
766  (((so)->so_state&SS_ISCONNECTED) || \
767  ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \
768  ((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \
769  (so)->so_error)
770 #else /* line with PR_CONNREQUIRED removed */
771 /* can we write something to so? */
772 #define sowriteable(so) \
773  ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
774  (((so)->so_state&SS_ISCONNECTED))) || \
775  ((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \
776  (so)->so_error)
777 #endif
778 
779 extern void solisten_proto(struct socket *so, int backlog);
780 extern int solisten_proto_check(struct socket *so);
781 extern int sctp_listen(struct socket *so, int backlog, struct proc *p);
782 extern void socantrcvmore_locked(struct socket *so);
783 extern int sctp_bind(struct socket *so, struct sockaddr *addr);
784 extern int sctp6_bind(struct socket *so, struct sockaddr *addr, void *proc);
785 #if defined(__Userspace__)
786 extern int sctpconn_bind(struct socket *so, struct sockaddr *addr);
787 #endif
788 extern int sctp_accept(struct socket *so, struct sockaddr **addr);
789 extern int sctp_attach(struct socket *so, int proto, uint32_t vrf_id);
790 extern int sctp6_attach(struct socket *so, int proto, uint32_t vrf_id);
791 extern int sctp_abort(struct socket *so);
792 extern int sctp6_abort(struct socket *so);
793 extern void sctp_close(struct socket *so);
794 extern int soaccept(struct socket *so, struct sockaddr **nam);
795 extern int solisten(struct socket *so, int backlog);
796 extern int soreserve(struct socket *so, u_long sndcc, u_long rcvcc);
797 extern void sowakeup(struct socket *so, struct sockbuf *sb);
798 extern void wakeup(void *ident, struct socket *so); /*__Userspace__ */
799 extern int uiomove(void *cp, int n, struct uio *uio);
800 extern int sbwait(struct sockbuf *sb);
801 extern int sodisconnect(struct socket *so);
802 extern int soconnect(struct socket *so, struct sockaddr *nam);
803 extern int sctp_disconnect(struct socket *so);
804 extern int sctp_connect(struct socket *so, struct sockaddr *addr);
805 extern int sctp6_connect(struct socket *so, struct sockaddr *addr);
806 #if defined(__Userspace__)
807 extern int sctpconn_connect(struct socket *so, struct sockaddr *addr);
808 #endif
809 extern void sctp_finish(void);
810 
811 /* ------------------------------------------------ */
812 /* ----- macros copied from above ---- */
813 /* ------------------------------------------------ */
814 
815 /*
816  * Do we need to notify the other side when I/O is possible?
817  */
818 #define sb_notify(sb) (((sb)->sb_flags & (SB_WAIT | SB_SEL | SB_ASYNC | \
819  SB_UPCALL | SB_AIO | SB_KNOTE)) != 0)
820 
821 
822 /*
823  * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to
824  * avoid a non-atomic test-and-wakeup. However, sowakeup is
825  * responsible for releasing the lock if it is called. We unlock only
826  * if we don't call into sowakeup. If any code is introduced that
827  * directly invokes the underlying sowakeup() primitives, it must
828  * maintain the same semantics.
829  */
830 #define sorwakeup_locked(so) do { \
831  SOCKBUF_LOCK_ASSERT(&(so)->so_rcv); \
832  if (sb_notify(&(so)->so_rcv)) \
833  sowakeup((so), &(so)->so_rcv); \
834  else \
835  SOCKBUF_UNLOCK(&(so)->so_rcv); \
836 } while (0)
837 
838 #define sorwakeup(so) do { \
839  SOCKBUF_LOCK(&(so)->so_rcv); \
840  sorwakeup_locked(so); \
841 } while (0)
842 
843 #define sowwakeup_locked(so) do { \
844  SOCKBUF_LOCK_ASSERT(&(so)->so_snd); \
845  if (sb_notify(&(so)->so_snd)) \
846  sowakeup((so), &(so)->so_snd); \
847  else \
848  SOCKBUF_UNLOCK(&(so)->so_snd); \
849 } while (0)
850 
851 #define sowwakeup(so) do { \
852  SOCKBUF_LOCK(&(so)->so_snd); \
853  sowwakeup_locked(so); \
854 } while (0)
855 
856 
857 
858 #endif /* __Userspace__ */
859 
860 #endif /* !_SYS_SOCKETVAR_H_ */
u_short so_qlen
Definition: user_socketvar.h:149
int sb_lowat
Definition: user_socketvar.h:392
u_int sb_ctl
Definition: user_socketvar.h:188
thread
Definition: __init__.py:35
void * so_emuldata
Definition: user_socketvar.h:217
int sb_timeo
Definition: user_socketvar.h:190
userland_cond_t timeo_cond
Definition: user_socketvar.h:154
int sobind(struct socket *so, struct sockaddr *nam)
Definition: user_socket.c:1612
EGLStreamKHR EGLint EGLint EGLint size
Definition: eglext.h:984
pthread_cond_t userland_cond_t
Definition: sctp_os_userspace.h:281
u_int sb_cc
Definition: user_socketvar.h:388
void soisconnecting(struct socket *so)
Definition: user_socket.c:332
int solisten(struct socket *so, int backlog)
Definition: user_socket.c:1666
struct mbuf * sb_mbtail
Definition: user_socketvar.h:179
DOMString p
Definition: WebCryptoAPI.idl:116
u_short so_qlen
Definition: user_socketvar.h:380
userland_mutex_t sb_mtx
Definition: user_socketvar.h:175
struct socket * xso_so
Definition: user_socketvar.h:372
u_int sb_hiwat
Definition: user_socketvar.h:389
int soaccept(struct socket *so, struct sockaddr **nam)
Definition: user_socket.c:1731
uint32_t so_gencnt
Definition: user_socketvar.h:216
void sofree(struct socket *so)
Definition: user_socket.c:243
int socreate(int dom, struct socket **aso, int type, int proto, struct ucred *cred, struct thread *td)
Definition: user_socket.c:1326
unsigned int uint32_t
Definition: ptypes.h:105
u_int sb_mbcnt
Definition: user_socketvar.h:186
struct label * so_label
Definition: user_socketvar.h:213
u_short so_qlimit
Definition: user_socketvar.h:382
Definition: user_socketvar.h:69
int so_dom
Definition: user_socketvar.h:133
struct mbuf * sb_lastrecord
Definition: user_socketvar.h:180
size_t xso_len
Definition: user_socketvar.h:371
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: gl2ext.h:134
struct mbuf * sb_sndptr
Definition: user_socketvar.h:182
short so_state
Definition: user_socketvar.h:376
uid_t so_uid
Definition: user_socketvar.h:396
int sodisconnect(struct socket *so)
Definition: user_socket.c:1980
int soreserve(struct socket *so, u_long sndcc, u_long rcvcc)
Definition: user_socket.c:1512
short so_type
Definition: user_socketvar.h:127
short so_state
Definition: user_socketvar.h:130
int xso_protocol
Definition: user_socketvar.h:378
void soisdisconnecting(struct socket *so)
Definition: user_socket.c:345
const GLfloat * m
Definition: gl2ext.h:850
off_t uio_offset
Definition: user_socketvar.h:88
void wakeup(void *ident, struct socket *so)
Definition: user_socket.c:378
Definition: user_socketvar.h:125
u_int sb_mbmax
Definition: user_socketvar.h:187
EGLenum EGLObjectKHR EGLLabelKHR label
Definition: eglext.h:121
struct socket * so_head
Definition: user_socketvar.h:145
short sb_flags
Definition: user_socketvar.h:191
#define TAILQ_ENTRY(type)
Definition: user_queue.h:466
Definition: user_uma.h:56
u_int sb_hiwat
Definition: user_socketvar.h:185
int stub
Definition: user_socketvar.h:75
struct mbuf * sb_mb
Definition: user_socketvar.h:178
int sbwait(struct sockbuf *sb)
Definition: user_socket.c:154
void soisconnected(struct socket *so)
Definition: user_socket.c:421
u_short so_qlimit
Definition: user_socketvar.h:152
u_short so_error
Definition: user_socketvar.h:384
struct iovec * uio_iov
Definition: user_socketvar.h:86
int solisten_proto_check(struct socket *so)
Definition: user_socket.c:1677
userland_mutex_t accept_mtx
Definition: user_socket.c:59
Definition: user_socketvar.h:74
short sb_flags
Definition: user_socketvar.h:394
GLint level
Definition: gl2.h:402
void
Definition: AVFoundationCFSoftLinking.h:81
u_long so_oobmark
Definition: user_socketvar.h:386
void socantrcvmore_locked(struct socket *so)
Definition: user_socket.c:121
EGLStreamKHR EGLint n
Definition: eglext.h:984
int sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so)
Definition: user_socket.c:1459
int
Definition: runtests.py:53
u_int sb_mbmax
Definition: user_socketvar.h:391
short so_timeo
Definition: user_socketvar.h:383
int top
Definition: float-mm.c:109
OPENSSL_EXPORT const ASN1_OBJECT int const unsigned char int len
Definition: x509.h:1053
userland_cond_t sb_cond
Definition: user_socketvar.h:174
int uio_iovcnt
Definition: user_socketvar.h:87
struct socket * sonewconn(struct socket *head, int connstatus)
Definition: user_socket.c:454
int sctp_accept(struct socket *so, struct mbuf *nam)
Definition: sctp_usrreq.c:8335
struct ucred * so_cred
Definition: user_socketvar.h:212
short so_options
Definition: user_socketvar.h:374
u_long so_oobmark
Definition: user_socketvar.h:159
u_int sb_sndptroff
Definition: user_socketvar.h:183
void socantrcvmore(struct socket *so)
Definition: user_socket.c:128
struct accept_filter * so_accept_filter
Definition: user_socketvar.h:219
head
Definition: make-polyfill-tests.py:4
int so_count
Definition: user_socketvar.h:126
int so_qstate
Definition: user_socketvar.h:131
void solisten_proto(struct socket *so, int backlog)
Definition: user_socket.c:1691
short so_linger
Definition: user_socketvar.h:375
u_short so_error
Definition: user_socketvar.h:156
Definition: user_socketvar.h:164
EGLImageKHR EGLint * name
Definition: eglext.h:851
uio_seg
Definition: user_socketvar.h:68
int uiomove(void *cp, int n, struct uio *uio)
Definition: user_socket.c:631
void * so_accept_filter_arg
Definition: user_socketvar.h:220
MALLOC_DECLARE(M_ACCF)
int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len)
Definition: user_socket.c:685
short sb[N]
Definition: gcc-loops.cpp:21
Definition: user_mbuf.h:231
u_int sb_mbcnt
Definition: user_socketvar.h:390
void * so_pcb
Definition: user_socketvar.h:132
Definition: user_socketvar.h:85
#define off_t
Definition: macconfig.h:47
void sowakeup(struct socket *so, struct sockbuf *sb)
Definition: user_socket.c:1582
ssize_t uio_resid
Definition: user_socketvar.h:89
int sb_timeo
Definition: user_socketvar.h:393
short sa[N]
Definition: gcc-loops.cpp:20
Definition: InternalSettings.idl:27
char * so_accept_filter_str
Definition: user_socketvar.h:221
short so_timeo
Definition: user_socketvar.h:153
pthread_mutex_t userland_mutex_t
Definition: sctp_os_userspace.h:280
EGLenum type
Definition: eglext.h:63
Definition: user_socketvar.h:63
EGLStreamKHR EGLint EGLint EGLint const void * data
Definition: eglext.h:984
u_long sb_max
Definition: user_socket.c:1448
u_short so_incqlen
Definition: user_socketvar.h:150
Definition: user_socketvar.h:387
void socantsendmore(struct socket *so)
Definition: user_socket.c:143
#define SLIST_ENTRY(type)
Definition: user_queue.h:153
short sb_state
Definition: user_socketvar.h:176
int sctp_listen(struct socket *so, struct proc *p)
Definition: sctp_usrreq.c:8118
int maxsockets
Definition: user_environment.c:49
void soabort(struct socket *so)
Definition: user_socket.c:304
pid_t so_pgid
Definition: user_socketvar.h:385
#define TAILQ_HEAD(name, type)
Definition: user_queue.h:456
short so_options
Definition: user_socketvar.h:128
void sctp_finish(void)
Definition: sctp_usrreq.c:178
Definition: user_socketvar.h:63
uio_rw
Definition: user_socketvar.h:63
Definition: user_socketvar.h:70
int sctp_disconnect(struct socket *so)
Definition: sctp_usrreq.c:1080
int xso_family
Definition: user_socketvar.h:379
int sctp_attach(struct socket *so, int proto, uint32_t vrf_id)
void * so_upcallarg
Definition: user_socketvar.h:211
u_short so_incqlen
Definition: user_socketvar.h:381
void socantsendmore_locked(struct socket *so)
Definition: user_socket.c:135
struct sigio * so_sigio
Definition: user_socketvar.h:157
u_int sb_cc
Definition: user_socketvar.h:184
Definition: user_socketvar.h:218
userland_cond_t accept_cond
Definition: user_socket.c:60
Definition: bwe_rtp.cc:26
caddr_t so_pcb
Definition: user_socketvar.h:377
struct label * so_peerlabel
Definition: user_socketvar.h:214
uint32_t optval
Definition: tsctp.c:64
short so_type
Definition: user_socketvar.h:373
int sb_lowat
Definition: user_socketvar.h:189
int soconnect(struct socket *so, struct sockaddr *nam)
Definition: user_socket.c:2029
short so_linger
Definition: user_socketvar.h:129
Definition: user_socketvar.h:370