FreeBSD/Linux Kernel Cross Reference
sys/sys/socketvar.h
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 * @(#)socketvar.h 8.3 (Berkeley) 2/19/95
30 * $FreeBSD$
31 */
32
33 #ifndef _SYS_SOCKETVAR_H_
34 #define _SYS_SOCKETVAR_H_
35
36 #include <sys/queue.h> /* for TAILQ macros */
37 #include <sys/selinfo.h> /* for struct selinfo */
38 #include <sys/_lock.h>
39 #include <sys/_mutex.h>
40 #include <sys/_sx.h>
41
42 /*
43 * Kernel structure per socket.
44 * Contains send and receive buffer queues,
45 * handle on protocol and pointer to protocol
46 * private data and error information.
47 */
48 typedef u_quad_t so_gen_t;
49
50 /*-
51 * Locking key to struct socket:
52 * (a) constant after allocation, no locking required.
53 * (b) locked by SOCK_LOCK(so).
54 * (c) locked by SOCKBUF_LOCK(&so->so_rcv).
55 * (d) locked by SOCKBUF_LOCK(&so->so_snd).
56 * (e) locked by ACCEPT_LOCK().
57 * (f) not locked since integer reads/writes are atomic.
58 * (g) used only as a sleep/wakeup address, no value.
59 * (h) locked by global mutex so_global_mtx.
60 */
61 struct socket {
62 int so_count; /* (b) reference count */
63 short so_type; /* (a) generic type, see socket.h */
64 short so_options; /* from socket call, see socket.h */
65 short so_linger; /* time to linger while closing */
66 short so_state; /* (b) internal state flags SS_* */
67 int so_qstate; /* (e) internal state flags SQ_* */
68 void *so_pcb; /* protocol control block */
69 struct protosw *so_proto; /* (a) protocol handle */
70 /*
71 * Variables for connection queuing.
72 * Socket where accepts occur is so_head in all subsidiary sockets.
73 * If so_head is 0, socket is not related to an accept.
74 * For head socket so_incomp queues partially completed connections,
75 * while so_comp is a queue of connections ready to be accepted.
76 * If a connection is aborted and it has so_head set, then
77 * it has to be pulled out of either so_incomp or so_comp.
78 * We allow connections to queue up based on current queue lengths
79 * and limit on number of queued connections for this socket.
80 */
81 struct socket *so_head; /* (e) back pointer to listen socket */
82 TAILQ_HEAD(, socket) so_incomp; /* (e) queue of partial unaccepted connections */
83 TAILQ_HEAD(, socket) so_comp; /* (e) queue of complete unaccepted connections */
84 TAILQ_ENTRY(socket) so_list; /* (e) list of unaccepted connections */
85 u_short so_qlen; /* (e) number of unaccepted connections */
86 u_short so_incqlen; /* (e) number of unaccepted incomplete
87 connections */
88 u_short so_qlimit; /* (e) max number queued connections */
89 short so_timeo; /* (g) connection timeout */
90 u_short so_error; /* (f) error affecting connection */
91 struct sigio *so_sigio; /* [sg] information for async I/O or
92 out of band data (SIGURG) */
93 u_long so_oobmark; /* (c) chars to oob mark */
94 TAILQ_HEAD(, aiocblist) so_aiojobq; /* AIO ops waiting on socket */
95 /*
96 * Variables for socket buffering.
97 */
98 struct sockbuf {
99 struct selinfo sb_sel; /* process selecting read/write */
100 struct mtx sb_mtx; /* sockbuf lock */
101 struct sx sb_sx; /* prevent I/O interlacing */
102 short sb_state; /* (c/d) socket state on sockbuf */
103 #define sb_startzero sb_mb
104 struct mbuf *sb_mb; /* (c/d) the mbuf chain */
105 struct mbuf *sb_mbtail; /* (c/d) the last mbuf in the chain */
106 struct mbuf *sb_lastrecord; /* (c/d) first mbuf of last
107 * record in socket buffer */
108 struct mbuf *sb_sndptr; /* (c/d) pointer into mbuf chain */
109 u_int sb_sndptroff; /* (c/d) byte offset of ptr into chain */
110 u_int sb_cc; /* (c/d) actual chars in buffer */
111 u_int sb_hiwat; /* (c/d) max actual char count */
112 u_int sb_mbcnt; /* (c/d) chars of mbufs used */
113 u_int sb_mbmax; /* (c/d) max chars of mbufs to use */
114 u_int sb_ctl; /* (c/d) non-data chars in buffer */
115 int sb_lowat; /* (c/d) low water mark */
116 int sb_timeo; /* (c/d) timeout for read/write */
117 short sb_flags; /* (c/d) flags, see below */
118 } so_rcv, so_snd;
119 /*
120 * Constants for sb_flags field of struct sockbuf.
121 */
122 #define SB_MAX (256*1024) /* default for max chars in sockbuf */
123 /*
124 * Constants for sb_flags field of struct sockbuf.
125 */
126 #define SB_WAIT 0x04 /* someone is waiting for data/space */
127 #define SB_SEL 0x08 /* someone is selecting */
128 #define SB_ASYNC 0x10 /* ASYNC I/O, need signals */
129 #define SB_UPCALL 0x20 /* someone wants an upcall */
130 #define SB_NOINTR 0x40 /* operations not interruptible */
131 #define SB_AIO 0x80 /* AIO operations queued */
132 #define SB_KNOTE 0x100 /* kernel note attached */
133 #define SB_AUTOSIZE 0x800 /* automatically size socket buffer */
134
135 void (*so_upcall)(struct socket *, void *, int);
136 void *so_upcallarg;
137 struct ucred *so_cred; /* (a) user credentials */
138 struct label *so_label; /* (b) MAC label for socket */
139 struct label *so_peerlabel; /* (b) cached MAC label for peer */
140 /* NB: generation count must not be first. */
141 so_gen_t so_gencnt; /* (h) generation count */
142 void *so_emuldata; /* (b) private data for emulators */
143 struct so_accf {
144 struct accept_filter *so_accept_filter;
145 void *so_accept_filter_arg; /* saved filter args */
146 char *so_accept_filter_str; /* saved user args */
147 } *so_accf;
148 };
149
150 #define SB_EMPTY_FIXUP(sb) do { \
151 if ((sb)->sb_mb == NULL) { \
152 (sb)->sb_mbtail = NULL; \
153 (sb)->sb_lastrecord = NULL; \
154 } \
155 } while (/*CONSTCOND*/0)
156
157 /*
158 * Global accept mutex to serialize access to accept queues and
159 * fields associated with multiple sockets. This allows us to
160 * avoid defining a lock order between listen and accept sockets
161 * until such time as it proves to be a good idea.
162 */
163 extern struct mtx accept_mtx;
164 #define ACCEPT_LOCK_ASSERT() mtx_assert(&accept_mtx, MA_OWNED)
165 #define ACCEPT_UNLOCK_ASSERT() mtx_assert(&accept_mtx, MA_NOTOWNED)
166 #define ACCEPT_LOCK() mtx_lock(&accept_mtx)
167 #define ACCEPT_UNLOCK() mtx_unlock(&accept_mtx)
168
169 /*
170 * Per-socket buffer mutex used to protect most fields in the socket
171 * buffer.
172 */
173 #define SOCKBUF_MTX(_sb) (&(_sb)->sb_mtx)
174 #define SOCKBUF_LOCK_INIT(_sb, _name) \
175 mtx_init(SOCKBUF_MTX(_sb), _name, NULL, MTX_DEF)
176 #define SOCKBUF_LOCK_DESTROY(_sb) mtx_destroy(SOCKBUF_MTX(_sb))
177 #define SOCKBUF_LOCK(_sb) mtx_lock(SOCKBUF_MTX(_sb))
178 #define SOCKBUF_OWNED(_sb) mtx_owned(SOCKBUF_MTX(_sb))
179 #define SOCKBUF_UNLOCK(_sb) mtx_unlock(SOCKBUF_MTX(_sb))
180 #define SOCKBUF_LOCK_ASSERT(_sb) mtx_assert(SOCKBUF_MTX(_sb), MA_OWNED)
181 #define SOCKBUF_UNLOCK_ASSERT(_sb) mtx_assert(SOCKBUF_MTX(_sb), MA_NOTOWNED)
182
183 /*
184 * Per-socket mutex: we reuse the receive socket buffer mutex for space
185 * efficiency. This decision should probably be revisited as we optimize
186 * locking for the socket code.
187 */
188 #define SOCK_MTX(_so) SOCKBUF_MTX(&(_so)->so_rcv)
189 #define SOCK_LOCK(_so) SOCKBUF_LOCK(&(_so)->so_rcv)
190 #define SOCK_OWNED(_so) SOCKBUF_OWNED(&(_so)->so_rcv)
191 #define SOCK_UNLOCK(_so) SOCKBUF_UNLOCK(&(_so)->so_rcv)
192 #define SOCK_LOCK_ASSERT(_so) SOCKBUF_LOCK_ASSERT(&(_so)->so_rcv)
193
194 /*
195 * Socket state bits.
196 *
197 * Historically, this bits were all kept in the so_state field. For
198 * locking reasons, they are now in multiple fields, as they are
199 * locked differently. so_state maintains basic socket state protected
200 * by the socket lock. so_qstate holds information about the socket
201 * accept queues. Each socket buffer also has a state field holding
202 * information relevant to that socket buffer (can't send, rcv). Many
203 * fields will be read without locks to improve performance and avoid
204 * lock order issues. However, this approach must be used with caution.
205 */
206 #define SS_NOFDREF 0x0001 /* no file table ref any more */
207 #define SS_ISCONNECTED 0x0002 /* socket connected to a peer */
208 #define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */
209 #define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */
210 #define SS_NBIO 0x0100 /* non-blocking ops */
211 #define SS_ASYNC 0x0200 /* async i/o notify */
212 #define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */
213 #define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
214 /*
215 * Protocols can mark a socket as SS_PROTOREF to indicate that, following
216 * pru_detach, they still want the socket to persist, and will free it
217 * themselves when they are done. Protocols should only ever call sofree()
218 * following setting this flag in pru_detach(), and never otherwise, as
219 * sofree() bypasses socket reference counting.
220 */
221 #define SS_PROTOREF 0x4000 /* strong protocol reference */
222
223 /*
224 * Socket state bits now stored in the socket buffer state field.
225 */
226 #define SBS_CANTSENDMORE 0x0010 /* can't send more data to peer */
227 #define SBS_CANTRCVMORE 0x0020 /* can't receive more data from peer */
228 #define SBS_RCVATMARK 0x0040 /* at mark on input */
229
230 /*
231 * Socket state bits stored in so_qstate.
232 */
233 #define SQ_INCOMP 0x0800 /* unaccepted, incomplete connection */
234 #define SQ_COMP 0x1000 /* unaccepted, complete connection */
235
236 /*
237 * Externalized form of struct socket used by the sysctl(3) interface.
238 */
239 struct xsocket {
240 size_t xso_len; /* length of this structure */
241 struct socket *xso_so; /* makes a convenient handle sometimes */
242 short so_type;
243 short so_options;
244 short so_linger;
245 short so_state;
246 caddr_t so_pcb; /* another convenient handle */
247 int xso_protocol;
248 int xso_family;
249 u_short so_qlen;
250 u_short so_incqlen;
251 u_short so_qlimit;
252 short so_timeo;
253 u_short so_error;
254 pid_t so_pgid;
255 u_long so_oobmark;
256 struct xsockbuf {
257 u_int sb_cc;
258 u_int sb_hiwat;
259 u_int sb_mbcnt;
260 u_int sb_mbmax;
261 int sb_lowat;
262 int sb_timeo;
263 short sb_flags;
264 } so_rcv, so_snd;
265 uid_t so_uid; /* XXX */
266 };
267
268 #ifdef _KERNEL
269
270 /*
271 * Macros for sockets and socket buffering.
272 */
273
274 /*
275 * Flags to sblock().
276 */
277 #define SBL_WAIT 0x00000001 /* Wait if not immediately available. */
278 #define SBL_NOINTR 0x00000002 /* Force non-interruptible sleep. */
279 #define SBL_VALID (SBL_WAIT | SBL_NOINTR)
280
281 /*
282 * Do we need to notify the other side when I/O is possible?
283 */
284 #define sb_notify(sb) (((sb)->sb_flags & (SB_WAIT | SB_SEL | SB_ASYNC | \
285 SB_UPCALL | SB_AIO | SB_KNOTE)) != 0)
286
287 /*
288 * How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
289 * This is problematical if the fields are unsigned, as the space might
290 * still be negative (cc > hiwat or mbcnt > mbmax). Should detect
291 * overflow and return 0. Should use "lmin" but it doesn't exist now.
292 */
293 #define sbspace(sb) \
294 ((long) imin((int)((sb)->sb_hiwat - (sb)->sb_cc), \
295 (int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
296
297 /* do we have to send all at once on a socket? */
298 #define sosendallatonce(so) \
299 ((so)->so_proto->pr_flags & PR_ATOMIC)
300
301 /* can we read something from so? */
302 #define soreadable(so) \
303 ((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \
304 ((so)->so_rcv.sb_state & SBS_CANTRCVMORE) || \
305 !TAILQ_EMPTY(&(so)->so_comp) || (so)->so_error)
306
307 /* can we write something to so? */
308 #define sowriteable(so) \
309 ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
310 (((so)->so_state&SS_ISCONNECTED) || \
311 ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \
312 ((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \
313 (so)->so_error)
314
315 /* adjust counters in sb reflecting allocation of m */
316 #define sballoc(sb, m) { \
317 (sb)->sb_cc += (m)->m_len; \
318 if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
319 (sb)->sb_ctl += (m)->m_len; \
320 (sb)->sb_mbcnt += MSIZE; \
321 if ((m)->m_flags & M_EXT) \
322 (sb)->sb_mbcnt += (m)->m_ext.ext_size; \
323 }
324
325 /* adjust counters in sb reflecting freeing of m */
326 #define sbfree(sb, m) { \
327 (sb)->sb_cc -= (m)->m_len; \
328 if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
329 (sb)->sb_ctl -= (m)->m_len; \
330 (sb)->sb_mbcnt -= MSIZE; \
331 if ((m)->m_flags & M_EXT) \
332 (sb)->sb_mbcnt -= (m)->m_ext.ext_size; \
333 if ((sb)->sb_sndptr == (m)) { \
334 (sb)->sb_sndptr = NULL; \
335 (sb)->sb_sndptroff = 0; \
336 } \
337 if ((sb)->sb_sndptroff != 0) \
338 (sb)->sb_sndptroff -= (m)->m_len; \
339 }
340
341 /*
342 * soref()/sorele() ref-count the socket structure. Note that you must
343 * still explicitly close the socket, but the last ref count will free
344 * the structure.
345 */
346 #define soref(so) do { \
347 SOCK_LOCK_ASSERT(so); \
348 ++(so)->so_count; \
349 } while (0)
350
351 #define sorele(so) do { \
352 ACCEPT_LOCK_ASSERT(); \
353 SOCK_LOCK_ASSERT(so); \
354 if ((so)->so_count <= 0) \
355 panic("sorele"); \
356 if (--(so)->so_count == 0) \
357 sofree(so); \
358 else { \
359 SOCK_UNLOCK(so); \
360 ACCEPT_UNLOCK(); \
361 } \
362 } while (0)
363
364 #define sotryfree(so) do { \
365 ACCEPT_LOCK_ASSERT(); \
366 SOCK_LOCK_ASSERT(so); \
367 if ((so)->so_count == 0) \
368 sofree(so); \
369 else { \
370 SOCK_UNLOCK(so); \
371 ACCEPT_UNLOCK(); \
372 } \
373 } while(0)
374
375 /*
376 * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to
377 * avoid a non-atomic test-and-wakeup. However, sowakeup is
378 * responsible for releasing the lock if it is called. We unlock only
379 * if we don't call into sowakeup. If any code is introduced that
380 * directly invokes the underlying sowakeup() primitives, it must
381 * maintain the same semantics.
382 */
383 #define sorwakeup_locked(so) do { \
384 SOCKBUF_LOCK_ASSERT(&(so)->so_rcv); \
385 if (sb_notify(&(so)->so_rcv)) \
386 sowakeup((so), &(so)->so_rcv); \
387 else \
388 SOCKBUF_UNLOCK(&(so)->so_rcv); \
389 } while (0)
390
391 #define sorwakeup(so) do { \
392 SOCKBUF_LOCK(&(so)->so_rcv); \
393 sorwakeup_locked(so); \
394 } while (0)
395
396 #define sowwakeup_locked(so) do { \
397 SOCKBUF_LOCK_ASSERT(&(so)->so_snd); \
398 if (sb_notify(&(so)->so_snd)) \
399 sowakeup((so), &(so)->so_snd); \
400 else \
401 SOCKBUF_UNLOCK(&(so)->so_snd); \
402 } while (0)
403
404 #define sowwakeup(so) do { \
405 SOCKBUF_LOCK(&(so)->so_snd); \
406 sowwakeup_locked(so); \
407 } while (0)
408
409 /*
410 * Argument structure for sosetopt et seq. This is in the KERNEL
411 * section because it will never be visible to user code.
412 */
413 enum sopt_dir { SOPT_GET, SOPT_SET };
414 struct sockopt {
415 enum sopt_dir sopt_dir; /* is this a get or a set? */
416 int sopt_level; /* second arg of [gs]etsockopt */
417 int sopt_name; /* third arg of [gs]etsockopt */
418 void *sopt_val; /* fourth arg of [gs]etsockopt */
419 size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */
420 struct thread *sopt_td; /* calling thread or null if kernel */
421 };
422
423 struct accept_filter {
424 char accf_name[16];
425 void (*accf_callback)
426 (struct socket *so, void *arg, int waitflag);
427 void * (*accf_create)
428 (struct socket *so, char *arg);
429 void (*accf_destroy)
430 (struct socket *so);
431 SLIST_ENTRY(accept_filter) accf_next;
432 };
433
434 #ifdef MALLOC_DECLARE
435 MALLOC_DECLARE(M_ACCF);
436 MALLOC_DECLARE(M_PCB);
437 MALLOC_DECLARE(M_SONAME);
438 #endif
439
440 extern int maxsockets;
441 extern u_long sb_max;
442 extern struct uma_zone *socket_zone;
443 extern so_gen_t so_gencnt;
444
445 struct mbuf;
446 struct sockaddr;
447 struct ucred;
448 struct uio;
449
450 /*
451 * From uipc_socket and friends
452 */
453 int do_getopt_accept_filter(struct socket *so, struct sockopt *sopt);
454 int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt);
455 int so_setsockopt(struct socket *so, int level, int optname,
456 void *optval, size_t optlen);
457 int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type);
458 int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
459 void sbappend(struct sockbuf *sb, struct mbuf *m);
460 void sbappend_locked(struct sockbuf *sb, struct mbuf *m);
461 void sbappendstream(struct sockbuf *sb, struct mbuf *m);
462 void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m);
463 int sbappendaddr(struct sockbuf *sb, const struct sockaddr *asa,
464 struct mbuf *m0, struct mbuf *control);
465 int sbappendaddr_locked(struct sockbuf *sb, const struct sockaddr *asa,
466 struct mbuf *m0, struct mbuf *control);
467 int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
468 struct mbuf *control);
469 int sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
470 struct mbuf *control);
471 void sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
472 void sbappendrecord_locked(struct sockbuf *sb, struct mbuf *m0);
473 void sbcheck(struct sockbuf *sb);
474 void sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
475 struct mbuf *
476 sbcreatecontrol(caddr_t p, int size, int type, int level);
477 void sbdestroy(struct sockbuf *sb, struct socket *so);
478 void sbdrop(struct sockbuf *sb, int len);
479 void sbdrop_locked(struct sockbuf *sb, int len);
480 void sbdroprecord(struct sockbuf *sb);
481 void sbdroprecord_locked(struct sockbuf *sb);
482 void sbflush(struct sockbuf *sb);
483 void sbflush_locked(struct sockbuf *sb);
484 void sbrelease(struct sockbuf *sb, struct socket *so);
485 void sbrelease_locked(struct sockbuf *sb, struct socket *so);
486 int sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
487 struct thread *td);
488 int sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so,
489 struct thread *td);
490 struct mbuf *
491 sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff);
492 void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
493 int sbwait(struct sockbuf *sb);
494 int sblock(struct sockbuf *sb, int flags);
495 void sbunlock(struct sockbuf *sb);
496 void soabort(struct socket *so);
497 int soaccept(struct socket *so, struct sockaddr **nam);
498 int socheckuid(struct socket *so, uid_t uid);
499 int sobind(struct socket *so, struct sockaddr *nam, struct thread *td);
500 void socantrcvmore(struct socket *so);
501 void socantrcvmore_locked(struct socket *so);
502 void socantsendmore(struct socket *so);
503 void socantsendmore_locked(struct socket *so);
504 int soclose(struct socket *so);
505 int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td);
506 int soconnect2(struct socket *so1, struct socket *so2);
507 int socow_setup(struct mbuf *m0, struct uio *uio);
508 int socreate(int dom, struct socket **aso, int type, int proto,
509 struct ucred *cred, struct thread *td);
510 int sodisconnect(struct socket *so);
511 struct sockaddr *sodupsockaddr(const struct sockaddr *sa, int mflags);
512 void sofree(struct socket *so);
513 int sogetopt(struct socket *so, struct sockopt *sopt);
514 void sohasoutofband(struct socket *so);
515 void soisconnected(struct socket *so);
516 void soisconnecting(struct socket *so);
517 void soisdisconnected(struct socket *so);
518 void soisdisconnecting(struct socket *so);
519 int solisten(struct socket *so, int backlog, struct thread *td);
520 void solisten_proto(struct socket *so, int backlog);
521 int solisten_proto_check(struct socket *so);
522 struct socket *
523 sonewconn(struct socket *head, int connstatus);
524 int sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);
525 int sooptcopyout(struct sockopt *sopt, const void *buf, size_t len);
526
527 /* XXX; prepare mbuf for (__FreeBSD__ < 3) routines. */
528 int soopt_getm(struct sockopt *sopt, struct mbuf **mp);
529 int soopt_mcopyin(struct sockopt *sopt, struct mbuf *m);
530 int soopt_mcopyout(struct sockopt *sopt, struct mbuf *m);
531
532 int sopoll(struct socket *so, int events, struct ucred *active_cred,
533 struct thread *td);
534 int sopoll_generic(struct socket *so, int events,
535 struct ucred *active_cred, struct thread *td);
536 int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio,
537 struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
538 int soreceive_generic(struct socket *so, struct sockaddr **paddr,
539 struct uio *uio, struct mbuf **mp0, struct mbuf **controlp,
540 int *flagsp);
541 int soreserve(struct socket *so, u_long sndcc, u_long rcvcc);
542 void sorflush(struct socket *so);
543 int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
544 struct mbuf *top, struct mbuf *control, int flags,
545 struct thread *td);
546 int sosend_dgram(struct socket *so, struct sockaddr *addr,
547 struct uio *uio, struct mbuf *top, struct mbuf *control,
548 int flags, struct thread *td);
549 int sosend_generic(struct socket *so, struct sockaddr *addr,
550 struct uio *uio, struct mbuf *top, struct mbuf *control,
551 int flags, struct thread *td);
552 int sosetopt(struct socket *so, struct sockopt *sopt);
553 int soshutdown(struct socket *so, int how);
554 void sotoxsocket(struct socket *so, struct xsocket *xso);
555 void sowakeup(struct socket *so, struct sockbuf *sb);
556
557 #ifdef SOCKBUF_DEBUG
558 void sblastrecordchk(struct sockbuf *, const char *, int);
559 #define SBLASTRECORDCHK(sb) sblastrecordchk((sb), __FILE__, __LINE__)
560
561 void sblastmbufchk(struct sockbuf *, const char *, int);
562 #define SBLASTMBUFCHK(sb) sblastmbufchk((sb), __FILE__, __LINE__)
563 #else
564 #define SBLASTRECORDCHK(sb) /* nothing */
565 #define SBLASTMBUFCHK(sb) /* nothing */
566 #endif /* SOCKBUF_DEBUG */
567
568 /*
569 * Accept filter functions (duh).
570 */
571 int accept_filt_add(struct accept_filter *filt);
572 int accept_filt_del(char *name);
573 struct accept_filter *accept_filt_get(char *name);
574 #ifdef ACCEPT_FILTER_MOD
575 #ifdef SYSCTL_DECL
576 SYSCTL_DECL(_net_inet_accf);
577 #endif
578 int accept_filt_generic_mod_event(module_t mod, int event, void *data);
579 #endif
580
581 #endif /* _KERNEL */
582
583 #endif /* !_SYS_SOCKETVAR_H_ */
Cache object: 49d7d5590ddadadc4e45cd447bbbb1b3
|