xref: /minix3/sys/sys/socketvar.h (revision 0b98e8aad89f2bd4ba80b523d73cf29e9dd82ce1)
1 /*	$NetBSD: socketvar.h,v 1.131 2013/08/29 17:49:21 rmind 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_MORETOCOME		0x400	/*
208 					 * hint from sosend to lower layer;
209 					 * more data coming
210 					 */
211 #define	SS_ISAPIPE 		0x1000	/* socket is implementing a pipe */
212 #define	SS_NBIO			0x2000	/* socket is in non blocking I/O */
213 
214 #ifdef _KERNEL
215 
216 struct accept_filter {
217 	char	accf_name[16];
218 	void	(*accf_callback)
219 		(struct socket *, void *, int, int);
220 	void *	(*accf_create)
221 		(struct socket *, char *);
222 	void	(*accf_destroy)
223 		(struct socket *);
224 	LIST_ENTRY(accept_filter) accf_next;
225 	u_int	accf_refcnt;
226 };
227 
228 struct sockopt {
229 	int		sopt_level;		/* option level */
230 	int		sopt_name;		/* option name */
231 	size_t		sopt_size;		/* data length */
232 	void *		sopt_data;		/* data pointer */
233 	uint8_t		sopt_buf[sizeof(int)];	/* internal storage */
234 };
235 
236 extern u_long		sb_max;
237 extern int		somaxkva;
238 extern int		sock_loan_thresh;
239 extern kmutex_t		*softnet_lock;
240 
241 struct mbuf;
242 struct sockaddr;
243 struct lwp;
244 struct msghdr;
245 struct stat;
246 struct knote;
247 
248 struct	mbuf *getsombuf(struct socket *, int);
249 
250 /*
251  * File operations on sockets.
252  */
253 int	soo_read(file_t *, off_t *, struct uio *, kauth_cred_t, int);
254 int	soo_write(file_t *, off_t *, struct uio *, kauth_cred_t, int);
255 int	soo_fcntl(file_t *, u_int cmd, void *);
256 int	soo_ioctl(file_t *, u_long cmd, void *);
257 int	soo_poll(file_t *, int);
258 int	soo_kqfilter(file_t *, struct knote *);
259 int 	soo_close(file_t *);
260 int	soo_stat(file_t *, struct stat *);
261 void	soo_restart(file_t *);
262 void	sbappend(struct sockbuf *, struct mbuf *);
263 void	sbappendstream(struct sockbuf *, struct mbuf *);
264 int	sbappendaddr(struct sockbuf *, const struct sockaddr *, struct mbuf *,
265 	    struct mbuf *);
266 int	sbappendaddrchain(struct sockbuf *, const struct sockaddr *,
267 	     struct mbuf *, int);
268 int	sbappendcontrol(struct sockbuf *, struct mbuf *, struct mbuf *);
269 void	sbappendrecord(struct sockbuf *, struct mbuf *);
270 void	sbcheck(struct sockbuf *);
271 void	sbcompress(struct sockbuf *, struct mbuf *, struct mbuf *);
272 struct mbuf *
273 	sbcreatecontrol(void *, int, int, int);
274 struct mbuf *
275 	sbcreatecontrol1(void **, int, int, int, int);
276 void	sbdrop(struct sockbuf *, int);
277 void	sbdroprecord(struct sockbuf *);
278 void	sbflush(struct sockbuf *);
279 void	sbinsertoob(struct sockbuf *, struct mbuf *);
280 void	sbrelease(struct sockbuf *, struct socket *);
281 int	sbreserve(struct sockbuf *, u_long, struct socket *);
282 int	sbwait(struct sockbuf *);
283 int	sb_max_set(u_long);
284 void	soinit(void);
285 void	soinit1(void);
286 void	soinit2(void);
287 int	soabort(struct socket *);
288 int	soaccept(struct socket *, struct mbuf *);
289 int	sofamily(const struct socket *);
290 int	sobind(struct socket *, struct mbuf *, struct lwp *);
291 void	socantrcvmore(struct socket *);
292 void	socantsendmore(struct socket *);
293 int	soclose(struct socket *);
294 int	soconnect(struct socket *, struct mbuf *, struct lwp *);
295 int	soconnect2(struct socket *, struct socket *);
296 int	socreate(int, struct socket **, int, int, struct lwp *,
297 		 struct socket *);
298 int	fsocreate(int, struct socket **, int, int, struct lwp *, int *);
299 int	sodisconnect(struct socket *);
300 void	sofree(struct socket *);
301 int	sogetopt(struct socket *, struct sockopt *);
302 void	sohasoutofband(struct socket *);
303 void	soisconnected(struct socket *);
304 void	soisconnecting(struct socket *);
305 void	soisdisconnected(struct socket *);
306 void	soisdisconnecting(struct socket *);
307 int	solisten(struct socket *, int, struct lwp *);
308 struct socket *
309 	sonewconn(struct socket *, bool);
310 void	soqinsque(struct socket *, struct socket *, int);
311 int	soqremque(struct socket *, int);
312 int	soreceive(struct socket *, struct mbuf **, struct uio *,
313 	    struct mbuf **, struct mbuf **, int *);
314 int	soreserve(struct socket *, u_long, u_long);
315 void	sorflush(struct socket *);
316 int	sosend(struct socket *, struct mbuf *, struct uio *,
317 	    struct mbuf *, struct mbuf *, int, struct lwp *);
318 int	sosetopt(struct socket *, struct sockopt *);
319 int	so_setsockopt(struct lwp *, struct socket *, int, int, const void *, size_t);
320 int	soshutdown(struct socket *, int);
321 void	sorestart(struct socket *);
322 void	sowakeup(struct socket *, struct sockbuf *, int);
323 int	sockargs(struct mbuf **, const void *, size_t, int);
324 int	sopoll(struct socket *, int);
325 struct	socket *soget(bool);
326 void	soput(struct socket *);
327 bool	solocked(struct socket *);
328 bool	solocked2(struct socket *, struct socket *);
329 int	sblock(struct sockbuf *, int);
330 void	sbunlock(struct sockbuf *);
331 int	sowait(struct socket *, bool, int);
332 void	solockretry(struct socket *, kmutex_t *);
333 void	sosetlock(struct socket *);
334 void	solockreset(struct socket *, kmutex_t *);
335 
336 void	sockopt_init(struct sockopt *, int, int, size_t);
337 void	sockopt_destroy(struct sockopt *);
338 int	sockopt_set(struct sockopt *, const void *, size_t);
339 int	sockopt_setint(struct sockopt *, int);
340 int	sockopt_get(const struct sockopt *, void *, size_t);
341 int	sockopt_getint(const struct sockopt *, int *);
342 int	sockopt_setmbuf(struct sockopt *, struct mbuf *);
343 struct mbuf *sockopt_getmbuf(const struct sockopt *);
344 
345 int	copyout_sockname(struct sockaddr *, unsigned int *, int, struct mbuf *);
346 int	copyout_msg_control(struct lwp *, struct msghdr *, struct mbuf *);
347 void	free_control_mbuf(struct lwp *, struct mbuf *, struct mbuf *);
348 
349 int	do_sys_getsockname(struct lwp *, int, int, struct mbuf **);
350 int	do_sys_sendmsg(struct lwp *, int, struct msghdr *, int, register_t *);
351 int	do_sys_recvmsg(struct lwp *, int, struct msghdr *, struct mbuf **,
352 	    struct mbuf **, register_t *);
353 
354 int	do_sys_bind(struct lwp *, int, struct mbuf *);
355 int	do_sys_connect(struct lwp *, int, struct mbuf *);
356 int	do_sys_accept(struct lwp *, int, struct mbuf **, register_t *,
357 	    const sigset_t *, int, int);
358 
359 /*
360  * Inline functions for sockets and socket buffering.
361  */
362 
363 #include <sys/protosw.h>
364 #include <sys/mbuf.h>
365 
366 /*
367  * Do we need to notify the other side when I/O is possible?
368  */
369 static inline int
370 sb_notify(struct sockbuf *sb)
371 {
372 
373 	KASSERT(solocked(sb->sb_so));
374 
375 	return sb->sb_flags & (SB_NOTIFY | SB_ASYNC | SB_UPCALL | SB_KNOTE);
376 }
377 
378 /*
379  * How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
380  * This is problematical if the fields are unsigned, as the space might
381  * still be negative (cc > hiwat or mbcnt > mbmax).  Should detect
382  * overflow and return 0.
383  */
384 static inline long
385 sbspace(struct sockbuf *sb)
386 {
387 
388 	KASSERT(solocked(sb->sb_so));
389 
390 	return lmin(sb->sb_hiwat - sb->sb_cc, sb->sb_mbmax - sb->sb_mbcnt);
391 }
392 
393 /* do we have to send all at once on a socket? */
394 static inline int
395 sosendallatonce(struct socket *so)
396 {
397 
398 	return so->so_proto->pr_flags & PR_ATOMIC;
399 }
400 
401 /* can we read something from so? */
402 static inline int
403 soreadable(struct socket *so)
404 {
405 
406 	KASSERT(solocked(so));
407 
408 	return so->so_rcv.sb_cc >= so->so_rcv.sb_lowat ||
409 	    (so->so_state & SS_CANTRCVMORE) != 0 ||
410 	    so->so_qlen != 0 || so->so_error != 0;
411 }
412 
413 /* can we write something to so? */
414 static inline int
415 sowritable(struct socket *so)
416 {
417 
418 	KASSERT(solocked(so));
419 
420 	return (sbspace(&so->so_snd) >= so->so_snd.sb_lowat &&
421 	    ((so->so_state & SS_ISCONNECTED) != 0 ||
422 	    (so->so_proto->pr_flags & PR_CONNREQUIRED) == 0)) ||
423 	    (so->so_state & SS_CANTSENDMORE) != 0 ||
424 	    so->so_error != 0;
425 }
426 
427 /* adjust counters in sb reflecting allocation of m */
428 static inline void
429 sballoc(struct sockbuf *sb, struct mbuf *m)
430 {
431 
432 	KASSERT(solocked(sb->sb_so));
433 
434 	sb->sb_cc += m->m_len;
435 	sb->sb_mbcnt += MSIZE;
436 	if (m->m_flags & M_EXT)
437 		sb->sb_mbcnt += m->m_ext.ext_size;
438 }
439 
440 /* adjust counters in sb reflecting freeing of m */
441 static inline void
442 sbfree(struct sockbuf *sb, struct mbuf *m)
443 {
444 
445 	KASSERT(solocked(sb->sb_so));
446 
447 	sb->sb_cc -= m->m_len;
448 	sb->sb_mbcnt -= MSIZE;
449 	if (m->m_flags & M_EXT)
450 		sb->sb_mbcnt -= m->m_ext.ext_size;
451 }
452 
453 static inline void
454 sorwakeup(struct socket *so)
455 {
456 
457 	KASSERT(solocked(so));
458 
459 	if (sb_notify(&so->so_rcv))
460 		sowakeup(so, &so->so_rcv, POLL_IN);
461 }
462 
463 static inline void
464 sowwakeup(struct socket *so)
465 {
466 
467 	KASSERT(solocked(so));
468 
469 	if (sb_notify(&so->so_snd))
470 		sowakeup(so, &so->so_snd, POLL_OUT);
471 }
472 
473 static inline void
474 solock(struct socket *so)
475 {
476 	kmutex_t *lock;
477 
478 	lock = so->so_lock;
479 	mutex_enter(lock);
480 	if (__predict_false(lock != so->so_lock))
481 		solockretry(so, lock);
482 }
483 
484 static inline void
485 sounlock(struct socket *so)
486 {
487 
488 	mutex_exit(so->so_lock);
489 }
490 
491 #ifdef SOCKBUF_DEBUG
492 /*
493  * SBLASTRECORDCHK: check sb->sb_lastrecord is maintained correctly.
494  * SBLASTMBUFCHK: check sb->sb_mbtail is maintained correctly.
495  *
496  * => panic if the socket buffer is inconsistent.
497  * => 'where' is used for a panic message.
498  */
499 void	sblastrecordchk(struct sockbuf *, const char *);
500 #define	SBLASTRECORDCHK(sb, where)	sblastrecordchk((sb), (where))
501 
502 void	sblastmbufchk(struct sockbuf *, const char *);
503 #define	SBLASTMBUFCHK(sb, where)	sblastmbufchk((sb), (where))
504 #define	SBCHECK(sb)			sbcheck(sb)
505 #else
506 #define	SBLASTRECORDCHK(sb, where)	/* nothing */
507 #define	SBLASTMBUFCHK(sb, where)	/* nothing */
508 #define	SBCHECK(sb)			/* nothing */
509 #endif /* SOCKBUF_DEBUG */
510 
511 /* sosend loan */
512 vaddr_t	sokvaalloc(vaddr_t, vsize_t, struct socket *);
513 void	sokvafree(vaddr_t, vsize_t);
514 void	soloanfree(struct mbuf *, void *, size_t, void *);
515 
516 /*
517  * Values for socket-buffer-append priority argument to sbappendaddrchain().
518  * The following flags are reserved for future implementation:
519  *
520  *  SB_PRIO_NONE:  honour normal socket-buffer limits.
521  *
522  *  SB_PRIO_ONESHOT_OVERFLOW:  if the socket has any space,
523  *	deliver the entire chain. Intended for large requests
524  *      that should be delivered in their entirety, or not at all.
525  *
526  * SB_PRIO_OVERDRAFT:  allow a small (2*MLEN) overflow, over and
527  *	aboce normal socket limits. Intended messages indicating
528  *      buffer overflow in earlier normal/lower-priority messages .
529  *
530  * SB_PRIO_BESTEFFORT: Ignore  limits entirely.  Intended only for
531  * 	kernel-generated messages to specially-marked scokets which
532  *	require "reliable" delivery, nd where the source socket/protocol
533  *	message generator enforce some hard limit (but possibly well
534  *	above kern.sbmax). It is entirely up to the in-kernel source to
535  *	avoid complete mbuf exhaustion or DoS scenarios.
536  */
537 #define SB_PRIO_NONE 	 	0
538 #define SB_PRIO_ONESHOT_OVERFLOW 1
539 #define SB_PRIO_OVERDRAFT	2
540 #define SB_PRIO_BESTEFFORT	3
541 
542 /*
543  * Accept filter functions (duh).
544  */
545 int	accept_filt_getopt(struct socket *, struct sockopt *);
546 int	accept_filt_setopt(struct socket *, const struct sockopt *);
547 int	accept_filt_clear(struct socket *);
548 int	accept_filt_add(struct accept_filter *);
549 int	accept_filt_del(struct accept_filter *);
550 struct	accept_filter *accept_filt_get(char *);
551 #ifdef ACCEPT_FILTER_MOD
552 #ifdef SYSCTL_DECL
553 SYSCTL_DECL(_net_inet_accf);
554 #endif
555 void	accept_filter_init(void);
556 #endif
557 
558 #endif /* _KERNEL */
559 
560 #endif /* !_SYS_SOCKETVAR_H_ */
561