xref: /minix/sys/sys/socketvar.h (revision 6c8f7fc3)
1 /*	$NetBSD: socketvar.h,v 1.129 2012/02/01 02:27:23 matt Exp $	*/
2 
3 /*-
4  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Andrew Doran.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /*-
33  * Copyright (c) 1982, 1986, 1990, 1993
34  *	The Regents of the University of California.  All rights reserved.
35  *
36  * Redistribution and use in source and binary forms, with or without
37  * modification, are permitted provided that the following conditions
38  * are met:
39  * 1. Redistributions of source code must retain the above copyright
40  *    notice, this list of conditions and the following disclaimer.
41  * 2. Redistributions in binary form must reproduce the above copyright
42  *    notice, this list of conditions and the following disclaimer in the
43  *    documentation and/or other materials provided with the distribution.
44  * 3. Neither the name of the University nor the names of its contributors
45  *    may be used to endorse or promote products derived from this software
46  *    without specific prior written permission.
47  *
48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58  * SUCH DAMAGE.
59  *
60  *	@(#)socketvar.h	8.3 (Berkeley) 2/19/95
61  */
62 
63 #ifndef _SYS_SOCKETVAR_H_
64 #define	_SYS_SOCKETVAR_H_
65 
66 #include <sys/select.h>
67 #include <sys/selinfo.h>		/* for struct selinfo */
68 #include <sys/queue.h>
69 #include <sys/mutex.h>
70 #include <sys/condvar.h>
71 
72 #if !defined(_KERNEL)
73 struct uio;
74 struct lwp;
75 struct uidinfo;
76 #else
77 #include <sys/uidinfo.h>
78 #endif
79 
80 TAILQ_HEAD(soqhead, socket);
81 
82 /*
83  * Variables for socket buffering.
84  */
85 struct sockbuf {
86 	struct selinfo sb_sel;		/* process selecting read/write */
87 	struct mowner *sb_mowner;	/* who owns data for this sockbuf */
88 	struct socket *sb_so;		/* back pointer to socket */
89 	kcondvar_t sb_cv;		/* notifier */
90 	/* When re-zeroing this struct, we zero from sb_startzero to the end */
91 #define	sb_startzero	sb_cc
92 	u_long	sb_cc;			/* actual chars in buffer */
93 	u_long	sb_hiwat;		/* max actual char count */
94 	u_long	sb_mbcnt;		/* chars of mbufs used */
95 	u_long	sb_mbmax;		/* max chars of mbufs to use */
96 	long	sb_lowat;		/* low water mark */
97 	struct mbuf *sb_mb;		/* the mbuf chain */
98 	struct mbuf *sb_mbtail;		/* the last mbuf in the chain */
99 	struct mbuf *sb_lastrecord;	/* first mbuf of last record in
100 					   socket buffer */
101 	int	sb_flags;		/* flags, see below */
102 	int	sb_timeo;		/* timeout for read/write */
103 	u_long	sb_overflowed;		/* # of drops due to full buffer */
104 };
105 
106 #ifndef SB_MAX
107 #define	SB_MAX		(256*1024)	/* default for max chars in sockbuf */
108 #endif
109 
110 #define	SB_LOCK		0x01		/* lock on data queue */
111 #define	SB_NOTIFY	0x04		/* someone is waiting for data/space */
112 #define	SB_ASYNC	0x10		/* ASYNC I/O, need signals */
113 #define	SB_UPCALL	0x20		/* someone wants an upcall */
114 #define	SB_NOINTR	0x40		/* operations not interruptible */
115 #define	SB_KNOTE	0x100		/* kernel note attached */
116 #define	SB_AUTOSIZE	0x800		/* automatically size socket buffer */
117 
118 /*
119  * Kernel structure per socket.
120  * Contains send and receive buffer queues,
121  * handle on protocol and pointer to protocol
122  * private data and error information.
123  */
124 struct socket {
125 	kmutex_t * volatile so_lock;	/* pointer to lock on structure */
126 	kcondvar_t	so_cv;		/* notifier */
127 	short		so_type;	/* generic type, see socket.h */
128 	short		so_options;	/* from socket call, see socket.h */
129 	u_short		so_linger;	/* time to linger while closing */
130 	short		so_state;	/* internal state flags SS_*, below */
131 	int		so_unused;	/* used to be so_nbio */
132 	void		*so_pcb;	/* protocol control block */
133 	const struct protosw *so_proto;	/* protocol handle */
134 /*
135  * Variables for connection queueing.
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_q0 queues partially completed connections,
139  * while so_q 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_q0 or so_q.
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;	/* back pointer to accept socket */
146 	struct soqhead	*so_onq;	/* queue (q or q0) that we're on */
147 	struct soqhead	so_q0;		/* queue of partial connections */
148 	struct soqhead	so_q;		/* queue of incoming connections */
149 	TAILQ_ENTRY(socket) so_qe;	/* our queue entry (q or q0) */
150 	short		so_q0len;	/* partials on so_q0 */
151 	short		so_qlen;	/* number of connections on so_q */
152 	short		so_qlimit;	/* max number queued connections */
153 	short		so_timeo;	/* connection timeout */
154 	u_short		so_error;	/* error affecting connection */
155 	u_short		so_aborting;	/* references from soabort() */
156 	pid_t		so_pgid;	/* pgid for signals */
157 	u_long		so_oobmark;	/* chars to oob mark */
158 	struct sockbuf	so_snd;		/* send buffer */
159 	struct sockbuf	so_rcv;		/* receive buffer */
160 
161 	void		*so_internal;	/* Space for svr4 stream data */
162 	void		(*so_upcall) (struct socket *, void *, int, int);
163 	void *		so_upcallarg;	/* Arg for above */
164 	int		(*so_send) (struct socket *, struct mbuf *,
165 					struct uio *, struct mbuf *,
166 					struct mbuf *, int, struct lwp *);
167 	int		(*so_receive) (struct socket *,
168 					struct mbuf **,
169 					struct uio *, struct mbuf **,
170 					struct mbuf **, int *);
171 	struct mowner	*so_mowner;	/* who owns mbufs for this socket */
172 	struct uidinfo	*so_uidinfo;	/* who opened the socket */
173 	gid_t		so_egid;	/* creator effective gid */
174 	pid_t		so_cpid;	/* creator pid */
175 	struct so_accf {
176 		struct accept_filter	*so_accept_filter;
177 		void	*so_accept_filter_arg;	/* saved filter args */
178 		char	*so_accept_filter_str;	/* saved user args */
179 	} *so_accf;
180 	kauth_cred_t	so_cred;	/* socket credentials */
181 };
182 
183 #define	SB_EMPTY_FIXUP(sb)						\
184 do {									\
185 	KASSERT(solocked((sb)->sb_so));					\
186 	if ((sb)->sb_mb == NULL) {					\
187 		(sb)->sb_mbtail = NULL;					\
188 		(sb)->sb_lastrecord = NULL;				\
189 	}								\
190 } while (/*CONSTCOND*/0)
191 
192 /*
193  * Socket state bits.
194  */
195 #define	SS_NOFDREF		0x001	/* no file table ref any more */
196 #define	SS_ISCONNECTED		0x002	/* socket connected to a peer */
197 #define	SS_ISCONNECTING		0x004	/* in process of connecting to peer */
198 #define	SS_ISDISCONNECTING	0x008	/* in process of disconnecting */
199 #define	SS_CANTSENDMORE		0x010	/* can't send more data to peer */
200 #define	SS_CANTRCVMORE		0x020	/* can't receive more data from peer */
201 #define	SS_RCVATMARK		0x040	/* at mark on input */
202 #define	SS_ISABORTING		0x080	/* aborting fd references - close() */
203 #define	SS_RESTARTSYS		0x100	/* restart blocked system calls */
204 #define	SS_ISDISCONNECTED	0x800	/* socket disconnected from peer */
205 
206 #define	SS_ASYNC		0x100	/* async i/o notify */
207 #define	SS_ISCONFIRMING		0x200	/* deciding to accept connection req */
208 #define	SS_MORETOCOME		0x400	/*
209 					 * hint from sosend to lower layer;
210 					 * more data coming
211 					 */
212 #define	SS_ISAPIPE 		0x1000	/* socket is implementing a pipe */
213 #define	SS_NBIO			0x2000	/* socket is in non blocking I/O */
214 
215 #ifdef _KERNEL
216 
217 struct accept_filter {
218 	char	accf_name[16];
219 	void	(*accf_callback)
220 		(struct socket *, void *, int, int);
221 	void *	(*accf_create)
222 		(struct socket *, char *);
223 	void	(*accf_destroy)
224 		(struct socket *);
225 	LIST_ENTRY(accept_filter) accf_next;
226 	u_int	accf_refcnt;
227 };
228 
229 struct sockopt {
230 	int		sopt_level;		/* option level */
231 	int		sopt_name;		/* option name */
232 	size_t		sopt_size;		/* data length */
233 	void *		sopt_data;		/* data pointer */
234 	uint8_t		sopt_buf[sizeof(int)];	/* internal storage */
235 };
236 
237 extern u_long		sb_max;
238 extern int		somaxkva;
239 extern int		sock_loan_thresh;
240 extern kmutex_t		*softnet_lock;
241 
242 struct mbuf;
243 struct sockaddr;
244 struct lwp;
245 struct msghdr;
246 struct stat;
247 struct knote;
248 
249 struct	mbuf *getsombuf(struct socket *, int);
250 
251 /*
252  * File operations on sockets.
253  */
254 int	soo_read(file_t *, off_t *, struct uio *, kauth_cred_t, int);
255 int	soo_write(file_t *, off_t *, struct uio *, kauth_cred_t, int);
256 int	soo_fcntl(file_t *, u_int cmd, void *);
257 int	soo_ioctl(file_t *, u_long cmd, void *);
258 int	soo_poll(file_t *, int);
259 int	soo_kqfilter(file_t *, struct knote *);
260 int 	soo_close(file_t *);
261 int	soo_stat(file_t *, struct stat *);
262 void	soo_restart(file_t *);
263 void	sbappend(struct sockbuf *, struct mbuf *);
264 void	sbappendstream(struct sockbuf *, struct mbuf *);
265 int	sbappendaddr(struct sockbuf *, const struct sockaddr *, struct mbuf *,
266 	    struct mbuf *);
267 int	sbappendaddrchain(struct sockbuf *, const struct sockaddr *,
268 	     struct mbuf *, int);
269 int	sbappendcontrol(struct sockbuf *, struct mbuf *, struct mbuf *);
270 void	sbappendrecord(struct sockbuf *, struct mbuf *);
271 void	sbcheck(struct sockbuf *);
272 void	sbcompress(struct sockbuf *, struct mbuf *, struct mbuf *);
273 struct mbuf *
274 	sbcreatecontrol(void *, int, int, int);
275 void	sbdrop(struct sockbuf *, int);
276 void	sbdroprecord(struct sockbuf *);
277 void	sbflush(struct sockbuf *);
278 void	sbinsertoob(struct sockbuf *, struct mbuf *);
279 void	sbrelease(struct sockbuf *, struct socket *);
280 int	sbreserve(struct sockbuf *, u_long, struct socket *);
281 int	sbwait(struct sockbuf *);
282 int	sb_max_set(u_long);
283 void	soinit(void);
284 void	soinit1(void);
285 void	soinit2(void);
286 int	soabort(struct socket *);
287 int	soaccept(struct socket *, struct mbuf *);
288 int	sofamily(const struct socket *);
289 int	sobind(struct socket *, struct mbuf *, struct lwp *);
290 void	socantrcvmore(struct socket *);
291 void	socantsendmore(struct socket *);
292 int	soclose(struct socket *);
293 int	soconnect(struct socket *, struct mbuf *, struct lwp *);
294 int	soconnect2(struct socket *, struct socket *);
295 int	socreate(int, struct socket **, int, int, struct lwp *,
296 		 struct socket *);
297 int	fsocreate(int, struct socket **, int, int, struct lwp *, int *);
298 int	sodisconnect(struct socket *);
299 void	sofree(struct socket *);
300 int	sogetopt(struct socket *, struct sockopt *);
301 void	sohasoutofband(struct socket *);
302 void	soisconnected(struct socket *);
303 void	soisconnecting(struct socket *);
304 void	soisdisconnected(struct socket *);
305 void	soisdisconnecting(struct socket *);
306 int	solisten(struct socket *, int, struct lwp *);
307 struct socket *
308 	sonewconn(struct socket *, int);
309 void	soqinsque(struct socket *, struct socket *, int);
310 int	soqremque(struct socket *, int);
311 int	soreceive(struct socket *, struct mbuf **, struct uio *,
312 	    struct mbuf **, struct mbuf **, int *);
313 int	soreserve(struct socket *, u_long, u_long);
314 void	sorflush(struct socket *);
315 int	sosend(struct socket *, struct mbuf *, struct uio *,
316 	    struct mbuf *, struct mbuf *, int, struct lwp *);
317 int	sosetopt(struct socket *, struct sockopt *);
318 int	so_setsockopt(struct lwp *, struct socket *, int, int, const void *, size_t);
319 int	soshutdown(struct socket *, int);
320 void	sorestart(struct socket *);
321 void	sowakeup(struct socket *, struct sockbuf *, int);
322 int	sockargs(struct mbuf **, const void *, size_t, int);
323 int	sopoll(struct socket *, int);
324 struct	socket *soget(bool);
325 void	soput(struct socket *);
326 bool	solocked(struct socket *);
327 bool	solocked2(struct socket *, struct socket *);
328 int	sblock(struct sockbuf *, int);
329 void	sbunlock(struct sockbuf *);
330 int	sowait(struct socket *, bool, int);
331 void	solockretry(struct socket *, kmutex_t *);
332 void	sosetlock(struct socket *);
333 void	solockreset(struct socket *, kmutex_t *);
334 
335 void	sockopt_init(struct sockopt *, int, int, size_t);
336 void	sockopt_destroy(struct sockopt *);
337 int	sockopt_set(struct sockopt *, const void *, size_t);
338 int	sockopt_setint(struct sockopt *, int);
339 int	sockopt_get(const struct sockopt *, void *, size_t);
340 int	sockopt_getint(const struct sockopt *, int *);
341 int	sockopt_setmbuf(struct sockopt *, struct mbuf *);
342 struct mbuf *sockopt_getmbuf(const struct sockopt *);
343 
344 int	copyout_sockname(struct sockaddr *, unsigned int *, int, struct mbuf *);
345 int	copyout_msg_control(struct lwp *, struct msghdr *, struct mbuf *);
346 void	free_control_mbuf(struct lwp *, struct mbuf *, struct mbuf *);
347 
348 int	do_sys_getsockname(struct lwp *, int, int, struct mbuf **);
349 int	do_sys_sendmsg(struct lwp *, int, struct msghdr *, int, register_t *);
350 int	do_sys_recvmsg(struct lwp *, int, struct msghdr *, struct mbuf **,
351 	    struct mbuf **, register_t *);
352 
353 int	do_sys_bind(struct lwp *, int, struct mbuf *);
354 int	do_sys_connect(struct lwp *, int, struct mbuf *);
355 int	do_sys_accept(struct lwp *, int, struct mbuf **, register_t *,
356 	    const sigset_t *, int, int);
357 
358 /*
359  * Inline functions for sockets and socket buffering.
360  */
361 
362 #include <sys/protosw.h>
363 #include <sys/mbuf.h>
364 
365 /*
366  * Do we need to notify the other side when I/O is possible?
367  */
368 static inline int
369 sb_notify(struct sockbuf *sb)
370 {
371 
372 	KASSERT(solocked(sb->sb_so));
373 
374 	return sb->sb_flags & (SB_NOTIFY | SB_ASYNC | SB_UPCALL | SB_KNOTE);
375 }
376 
377 /*
378  * How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
379  * This is problematical if the fields are unsigned, as the space might
380  * still be negative (cc > hiwat or mbcnt > mbmax).  Should detect
381  * overflow and return 0.
382  */
383 static inline long
384 sbspace(struct sockbuf *sb)
385 {
386 
387 	KASSERT(solocked(sb->sb_so));
388 
389 	return lmin(sb->sb_hiwat - sb->sb_cc, sb->sb_mbmax - sb->sb_mbcnt);
390 }
391 
392 /* do we have to send all at once on a socket? */
393 static inline int
394 sosendallatonce(struct socket *so)
395 {
396 
397 	return so->so_proto->pr_flags & PR_ATOMIC;
398 }
399 
400 /* can we read something from so? */
401 static inline int
402 soreadable(struct socket *so)
403 {
404 
405 	KASSERT(solocked(so));
406 
407 	return so->so_rcv.sb_cc >= so->so_rcv.sb_lowat ||
408 	    (so->so_state & SS_CANTRCVMORE) != 0 ||
409 	    so->so_qlen != 0 || so->so_error != 0;
410 }
411 
412 /* can we write something to so? */
413 static inline int
414 sowritable(struct socket *so)
415 {
416 
417 	KASSERT(solocked(so));
418 
419 	return (sbspace(&so->so_snd) >= so->so_snd.sb_lowat &&
420 	    ((so->so_state & SS_ISCONNECTED) != 0 ||
421 	    (so->so_proto->pr_flags & PR_CONNREQUIRED) == 0)) ||
422 	    (so->so_state & SS_CANTSENDMORE) != 0 ||
423 	    so->so_error != 0;
424 }
425 
426 /* adjust counters in sb reflecting allocation of m */
427 static inline void
428 sballoc(struct sockbuf *sb, struct mbuf *m)
429 {
430 
431 	KASSERT(solocked(sb->sb_so));
432 
433 	sb->sb_cc += m->m_len;
434 	sb->sb_mbcnt += MSIZE;
435 	if (m->m_flags & M_EXT)
436 		sb->sb_mbcnt += m->m_ext.ext_size;
437 }
438 
439 /* adjust counters in sb reflecting freeing of m */
440 static inline void
441 sbfree(struct sockbuf *sb, struct mbuf *m)
442 {
443 
444 	KASSERT(solocked(sb->sb_so));
445 
446 	sb->sb_cc -= m->m_len;
447 	sb->sb_mbcnt -= MSIZE;
448 	if (m->m_flags & M_EXT)
449 		sb->sb_mbcnt -= m->m_ext.ext_size;
450 }
451 
452 static inline void
453 sorwakeup(struct socket *so)
454 {
455 
456 	KASSERT(solocked(so));
457 
458 	if (sb_notify(&so->so_rcv))
459 		sowakeup(so, &so->so_rcv, POLL_IN);
460 }
461 
462 static inline void
463 sowwakeup(struct socket *so)
464 {
465 
466 	KASSERT(solocked(so));
467 
468 	if (sb_notify(&so->so_snd))
469 		sowakeup(so, &so->so_snd, POLL_OUT);
470 }
471 
472 static inline void
473 solock(struct socket *so)
474 {
475 	kmutex_t *lock;
476 
477 	lock = so->so_lock;
478 	mutex_enter(lock);
479 	if (__predict_false(lock != so->so_lock))
480 		solockretry(so, lock);
481 }
482 
483 static inline void
484 sounlock(struct socket *so)
485 {
486 
487 	mutex_exit(so->so_lock);
488 }
489 
490 #ifdef SOCKBUF_DEBUG
491 /*
492  * SBLASTRECORDCHK: check sb->sb_lastrecord is maintained correctly.
493  * SBLASTMBUFCHK: check sb->sb_mbtail is maintained correctly.
494  *
495  * => panic if the socket buffer is inconsistent.
496  * => 'where' is used for a panic message.
497  */
498 void	sblastrecordchk(struct sockbuf *, const char *);
499 #define	SBLASTRECORDCHK(sb, where)	sblastrecordchk((sb), (where))
500 
501 void	sblastmbufchk(struct sockbuf *, const char *);
502 #define	SBLASTMBUFCHK(sb, where)	sblastmbufchk((sb), (where))
503 #define	SBCHECK(sb)			sbcheck(sb)
504 #else
505 #define	SBLASTRECORDCHK(sb, where)	/* nothing */
506 #define	SBLASTMBUFCHK(sb, where)	/* nothing */
507 #define	SBCHECK(sb)			/* nothing */
508 #endif /* SOCKBUF_DEBUG */
509 
510 /* sosend loan */
511 vaddr_t	sokvaalloc(vaddr_t, vsize_t, struct socket *);
512 void	sokvafree(vaddr_t, vsize_t);
513 void	soloanfree(struct mbuf *, void *, size_t, void *);
514 
515 /*
516  * Values for socket-buffer-append priority argument to sbappendaddrchain().
517  * The following flags are reserved for future implementation:
518  *
519  *  SB_PRIO_NONE:  honour normal socket-buffer limits.
520  *
521  *  SB_PRIO_ONESHOT_OVERFLOW:  if the socket has any space,
522  *	deliver the entire chain. Intended for large requests
523  *      that should be delivered in their entirety, or not at all.
524  *
525  * SB_PRIO_OVERDRAFT:  allow a small (2*MLEN) overflow, over and
526  *	aboce normal socket limits. Intended messages indicating
527  *      buffer overflow in earlier normal/lower-priority messages .
528  *
529  * SB_PRIO_BESTEFFORT: Ignore  limits entirely.  Intended only for
530  * 	kernel-generated messages to specially-marked scokets which
531  *	require "reliable" delivery, nd where the source socket/protocol
532  *	message generator enforce some hard limit (but possibly well
533  *	above kern.sbmax). It is entirely up to the in-kernel source to
534  *	avoid complete mbuf exhaustion or DoS scenarios.
535  */
536 #define SB_PRIO_NONE 	 	0
537 #define SB_PRIO_ONESHOT_OVERFLOW 1
538 #define SB_PRIO_OVERDRAFT	2
539 #define SB_PRIO_BESTEFFORT	3
540 
541 /*
542  * Accept filter functions (duh).
543  */
544 int	accept_filt_getopt(struct socket *, struct sockopt *);
545 int	accept_filt_setopt(struct socket *, const struct sockopt *);
546 int	accept_filt_clear(struct socket *);
547 int	accept_filt_add(struct accept_filter *);
548 int	accept_filt_del(struct accept_filter *);
549 struct	accept_filter *accept_filt_get(char *);
550 #ifdef ACCEPT_FILTER_MOD
551 #ifdef SYSCTL_DECL
552 SYSCTL_DECL(_net_inet_accf);
553 #endif
554 void	accept_filter_init(void);
555 #endif
556 
557 #endif /* _KERNEL */
558 
559 #endif /* !_SYS_SOCKETVAR_H_ */
560