socketvar.h revision 86487
11541Srgrimes/*-
21541Srgrimes * Copyright (c) 1982, 1986, 1990, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by the University of
161541Srgrimes *	California, Berkeley and its contributors.
171541Srgrimes * 4. Neither the name of the University nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes *
3314505Shsu *	@(#)socketvar.h	8.3 (Berkeley) 2/19/95
3450477Speter * $FreeBSD: head/sys/sys/socketvar.h 86487 2001-11-17 03:07:11Z dillon $
351541Srgrimes */
361541Srgrimes
372165Spaul#ifndef _SYS_SOCKETVAR_H_
382165Spaul#define _SYS_SOCKETVAR_H_
392165Spaul
4015492Sbde#include <sys/queue.h>			/* for TAILQ macros */
4186487Sdillon#include <sys/sx.h>			/* SX locks */
4270834Swollman#include <sys/selinfo.h>		/* for struct selinfo */
431541Srgrimes
441541Srgrimes/*
451541Srgrimes * Kernel structure per socket.
461541Srgrimes * Contains send and receive buffer queues,
471541Srgrimes * handle on protocol and pointer to protocol
481541Srgrimes * private data and error information.
491541Srgrimes */
5036079Swollmantypedef	u_quad_t so_gen_t;
5136079Swollman
5261837Salfredstruct accept_filter;
5361837Salfred
541541Srgrimesstruct socket {
5536079Swollman	struct	vm_zone *so_zone;	/* zone we were allocated from */
5686487Sdillon	int	so_count;		/* reference count */
571541Srgrimes	short	so_type;		/* generic type, see socket.h */
581541Srgrimes	short	so_options;		/* from socket call, see socket.h */
591541Srgrimes	short	so_linger;		/* time to linger while closing */
601541Srgrimes	short	so_state;		/* internal state flags SS_*, below */
611541Srgrimes	caddr_t	so_pcb;			/* protocol control block */
621541Srgrimes	struct	protosw *so_proto;	/* protocol handle */
631541Srgrimes/*
6413765Smpp * Variables for connection queuing.
651541Srgrimes * Socket where accepts occur is so_head in all subsidiary sockets.
661541Srgrimes * If so_head is 0, socket is not related to an accept.
6778913Sjlemon * For head socket so_incomp queues partially completed connections,
6878913Sjlemon * while so_comp is a queue of connections ready to be accepted.
691541Srgrimes * If a connection is aborted and it has so_head set, then
7078913Sjlemon * it has to be pulled out of either so_incomp or so_comp.
711541Srgrimes * We allow connections to queue up based on current queue lengths
721541Srgrimes * and limit on number of queued connections for this socket.
731541Srgrimes */
741541Srgrimes	struct	socket *so_head;	/* back pointer to accept socket */
7560938Sjake	TAILQ_HEAD(, socket) so_incomp;	/* queue of partial unaccepted connections */
7660938Sjake	TAILQ_HEAD(, socket) so_comp;	/* queue of complete unaccepted connections */
7760938Sjake	TAILQ_ENTRY(socket) so_list;	/* list of unaccepted connections */
7814547Sdg	short	so_qlen;		/* number of unaccepted connections */
7918787Spst	short	so_incqlen;		/* number of unaccepted incomplete
8018787Spst					   connections */
811541Srgrimes	short	so_qlimit;		/* max number queued connections */
821541Srgrimes	short	so_timeo;		/* connection timeout */
831541Srgrimes	u_short	so_error;		/* error affecting connection */
8441087Struckman	struct  sigio *so_sigio;	/* information for async I/O or
8541087Struckman					   out of band data (SIGURG) */
861541Srgrimes	u_long	so_oobmark;		/* chars to oob mark */
8760938Sjake	TAILQ_HEAD(, aiocblist) so_aiojobq; /* AIO ops waiting on socket */
881541Srgrimes/*
891541Srgrimes * Variables for socket buffering.
901541Srgrimes */
9183421Sobrien	struct sockbuf {
921541Srgrimes		u_long	sb_cc;		/* actual chars in buffer */
931541Srgrimes		u_long	sb_hiwat;	/* max actual char count */
941541Srgrimes		u_long	sb_mbcnt;	/* chars of mbufs used */
951541Srgrimes		u_long	sb_mbmax;	/* max chars of mbufs to use */
961541Srgrimes		long	sb_lowat;	/* low water mark */
971541Srgrimes		struct	mbuf *sb_mb;	/* the mbuf chain */
981541Srgrimes		struct	selinfo sb_sel;	/* process selecting read/write */
991541Srgrimes		short	sb_flags;	/* flags, see below */
1001541Srgrimes		short	sb_timeo;	/* timeout for read/write */
1011541Srgrimes	} so_rcv, so_snd;
1021541Srgrimes#define	SB_MAX		(256*1024)	/* default for max chars in sockbuf */
1031541Srgrimes#define	SB_LOCK		0x01		/* lock on data queue */
1041541Srgrimes#define	SB_WANT		0x02		/* someone is waiting to lock */
1051541Srgrimes#define	SB_WAIT		0x04		/* someone is waiting for data/space */
1061541Srgrimes#define	SB_SEL		0x08		/* someone is selecting */
1071541Srgrimes#define	SB_ASYNC	0x10		/* ASYNC I/O, need signals */
10836527Speter#define	SB_UPCALL	0x20		/* someone wants an upcall */
1091541Srgrimes#define	SB_NOINTR	0x40		/* operations not interruptible */
11055943Sjasone#define SB_AIO		0x80		/* AIO operations queued */
11159288Sjlemon#define SB_KNOTE	0x100		/* kernel note attached */
1121541Srgrimes
11338482Swollman	void	(*so_upcall) __P((struct socket *, void *, int));
11438482Swollman	void	*so_upcallarg;
11551381Sgreen	struct	ucred *so_cred;		/* user credentials */
11638482Swollman	/* NB: generation count must not be first; easiest to make it last. */
11736079Swollman	so_gen_t so_gencnt;		/* generation count */
11843458Sbde	void	*so_emuldata;		/* private data for emulators */
11983421Sobrien	struct so_accf {
12061837Salfred		struct	accept_filter *so_accept_filter;
12161837Salfred		void	*so_accept_filter_arg;	/* saved filter args */
12261837Salfred		char	*so_accept_filter_str;	/* saved user args */
12361837Salfred	} *so_accf;
1241541Srgrimes};
1251541Srgrimes
1261541Srgrimes/*
1271541Srgrimes * Socket state bits.
1281541Srgrimes */
12914547Sdg#define	SS_NOFDREF		0x0001	/* no file table ref any more */
13014547Sdg#define	SS_ISCONNECTED		0x0002	/* socket connected to a peer */
13114547Sdg#define	SS_ISCONNECTING		0x0004	/* in process of connecting to peer */
13214547Sdg#define	SS_ISDISCONNECTING	0x0008	/* in process of disconnecting */
13314547Sdg#define	SS_CANTSENDMORE		0x0010	/* can't send more data to peer */
13414547Sdg#define	SS_CANTRCVMORE		0x0020	/* can't receive more data from peer */
13514547Sdg#define	SS_RCVATMARK		0x0040	/* at mark on input */
1361541Srgrimes
13714547Sdg#define	SS_NBIO			0x0100	/* non-blocking ops */
13814547Sdg#define	SS_ASYNC		0x0200	/* async i/o notify */
13914547Sdg#define	SS_ISCONFIRMING		0x0400	/* deciding to accept connection req */
1401541Srgrimes
14114547Sdg#define	SS_INCOMP		0x0800	/* unaccepted, incomplete connection */
14214547Sdg#define	SS_COMP			0x1000	/* unaccepted, complete connection */
14343196Sfenner#define	SS_ISDISCONNECTED	0x2000	/* socket disconnected from peer */
1441541Srgrimes
14536079Swollman/*
14636079Swollman * Externalized form of struct socket used by the sysctl(3) interface.
14736079Swollman */
14883045Sobrienstruct xsocket {
14936079Swollman	size_t	xso_len;	/* length of this structure */
15036079Swollman	struct	socket *xso_so;	/* makes a convenient handle sometimes */
15136079Swollman	short	so_type;
15236079Swollman	short	so_options;
15336079Swollman	short	so_linger;
15436079Swollman	short	so_state;
15536079Swollman	caddr_t	so_pcb;		/* another convenient handle */
15636079Swollman	int	xso_protocol;
15736079Swollman	int	xso_family;
15836079Swollman	short	so_qlen;
15936079Swollman	short	so_incqlen;
16036079Swollman	short	so_qlimit;
16136079Swollman	short	so_timeo;
16236079Swollman	u_short	so_error;
16336079Swollman	pid_t	so_pgid;
16436079Swollman	u_long	so_oobmark;
16583421Sobrien	struct xsockbuf {
16636079Swollman		u_long	sb_cc;
16736079Swollman		u_long	sb_hiwat;
16836079Swollman		u_long	sb_mbcnt;
16936079Swollman		u_long	sb_mbmax;
17036079Swollman		long	sb_lowat;
17136079Swollman		short	sb_flags;
17236079Swollman		short	sb_timeo;
17336079Swollman	} so_rcv, so_snd;
17436079Swollman	uid_t	so_uid;		/* XXX */
17536079Swollman};
17614547Sdg
1771541Srgrimes/*
1781541Srgrimes * Macros for sockets and socket buffering.
1791541Srgrimes */
1801541Srgrimes
1811541Srgrimes/*
18236527Speter * Do we need to notify the other side when I/O is possible?
18336527Speter */
18455943Sjasone#define	sb_notify(sb)	(((sb)->sb_flags & (SB_WAIT | SB_SEL | SB_ASYNC | \
18559288Sjlemon    SB_UPCALL | SB_AIO | SB_KNOTE)) != 0)
18636527Speter
18736527Speter/*
1881541Srgrimes * How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
1891541Srgrimes * This is problematical if the fields are unsigned, as the space might
1901541Srgrimes * still be negative (cc > hiwat or mbcnt > mbmax).  Should detect
1911541Srgrimes * overflow and return 0.  Should use "lmin" but it doesn't exist now.
1921541Srgrimes */
1931541Srgrimes#define	sbspace(sb) \
1941541Srgrimes    ((long) imin((int)((sb)->sb_hiwat - (sb)->sb_cc), \
1951541Srgrimes	 (int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
1961541Srgrimes
1971541Srgrimes/* do we have to send all at once on a socket? */
1981541Srgrimes#define	sosendallatonce(so) \
1991541Srgrimes    ((so)->so_proto->pr_flags & PR_ATOMIC)
2001541Srgrimes
2011541Srgrimes/* can we read something from so? */
2021541Srgrimes#define	soreadable(so) \
2031541Srgrimes    ((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \
2041541Srgrimes	((so)->so_state & SS_CANTRCVMORE) || \
20570536Sphk	!TAILQ_EMPTY(&(so)->so_comp) || (so)->so_error)
2061541Srgrimes
2071541Srgrimes/* can we write something to so? */
2081541Srgrimes#define	sowriteable(so) \
2093304Sphk    ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
2101541Srgrimes	(((so)->so_state&SS_ISCONNECTED) || \
2113304Sphk	  ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \
2121541Srgrimes     ((so)->so_state & SS_CANTSENDMORE) || \
2131541Srgrimes     (so)->so_error)
2141541Srgrimes
2151541Srgrimes/* adjust counters in sb reflecting allocation of m */
2161541Srgrimes#define	sballoc(sb, m) { \
2171541Srgrimes	(sb)->sb_cc += (m)->m_len; \
2181541Srgrimes	(sb)->sb_mbcnt += MSIZE; \
2191541Srgrimes	if ((m)->m_flags & M_EXT) \
2201541Srgrimes		(sb)->sb_mbcnt += (m)->m_ext.ext_size; \
2211541Srgrimes}
2221541Srgrimes
2231541Srgrimes/* adjust counters in sb reflecting freeing of m */
2241541Srgrimes#define	sbfree(sb, m) { \
2251541Srgrimes	(sb)->sb_cc -= (m)->m_len; \
2261541Srgrimes	(sb)->sb_mbcnt -= MSIZE; \
2271541Srgrimes	if ((m)->m_flags & M_EXT) \
2281541Srgrimes		(sb)->sb_mbcnt -= (m)->m_ext.ext_size; \
2291541Srgrimes}
2301541Srgrimes
2311541Srgrimes/*
2321541Srgrimes * Set lock on sockbuf sb; sleep if lock is already held.
2331541Srgrimes * Unless SB_NOINTR is set on sockbuf, sleep is interruptible.
2341541Srgrimes * Returns error without lock if sleep is interrupted.
2351541Srgrimes */
2361541Srgrimes#define sblock(sb, wf) ((sb)->sb_flags & SB_LOCK ? \
2371541Srgrimes		(((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \
2381541Srgrimes		((sb)->sb_flags |= SB_LOCK), 0)
2391541Srgrimes
2401541Srgrimes/* release lock on sockbuf sb */
2411541Srgrimes#define	sbunlock(sb) { \
2421541Srgrimes	(sb)->sb_flags &= ~SB_LOCK; \
2431541Srgrimes	if ((sb)->sb_flags & SB_WANT) { \
2441541Srgrimes		(sb)->sb_flags &= ~SB_WANT; \
2451541Srgrimes		wakeup((caddr_t)&(sb)->sb_flags); \
2461541Srgrimes	} \
2471541Srgrimes}
2481541Srgrimes
24986487Sdillon/*
25086487Sdillon * soref()/sorele() ref-count the socket structure.  Note that you must
25186487Sdillon * still explicitly close the socket, but the last ref count will free
25286487Sdillon * the structure.
25386487Sdillon */
25486487Sdillon
25586487Sdillon#define soref(so)	do {			\
25686487Sdillon				++so->so_count; \
25786487Sdillon			} while (0)
25886487Sdillon
25986487Sdillon#define sorele(so)	do {				\
26086487Sdillon				if (so->so_count <= 0)	\
26186487Sdillon					panic("sorele");\
26286487Sdillon				if (--so->so_count == 0)\
26386487Sdillon					sofree(so);	\
26486487Sdillon			} while (0)
26586487Sdillon
26686487Sdillon#define sotryfree(so)	do {				\
26786487Sdillon				if (so->so_count == 0)	\
26886487Sdillon					sofree(so);	\
26986487Sdillon			} while(0)
27086487Sdillon
27136527Speter#define	sorwakeup(so)	do { \
27236527Speter			  if (sb_notify(&(so)->so_rcv)) \
27336527Speter			    sowakeup((so), &(so)->so_rcv); \
27436527Speter			} while (0)
2751541Srgrimes
27636527Speter#define	sowwakeup(so)	do { \
27736527Speter			  if (sb_notify(&(so)->so_snd)) \
27836527Speter			    sowakeup((so), &(so)->so_snd); \
27936527Speter			} while (0)
2801541Srgrimes
28155205Speter#ifdef _KERNEL
28231927Sbde
28338482Swollman/*
28438482Swollman * Argument structure for sosetopt et seq.  This is in the KERNEL
28538482Swollman * section because it will never be visible to user code.
28638482Swollman */
28738482Swollmanenum sopt_dir { SOPT_GET, SOPT_SET };
28838482Swollmanstruct sockopt {
28938482Swollman	enum	sopt_dir sopt_dir; /* is this a get or a set? */
29038482Swollman	int	sopt_level;	/* second arg of [gs]etsockopt */
29138482Swollman	int	sopt_name;	/* third arg of [gs]etsockopt */
29238482Swollman	void   *sopt_val;	/* fourth arg of [gs]etsockopt */
29338482Swollman	size_t	sopt_valsize;	/* (almost) fifth arg of [gs]etsockopt */
29483366Sjulian	struct	thread *sopt_td;	/* calling thread or null if kernel */
29538482Swollman};
29638482Swollman
29740931Sdgstruct sf_buf {
29860938Sjake	SLIST_ENTRY(sf_buf) free_list;	/* list of free buffer slots */
29940931Sdg	struct		vm_page *m;	/* currently mapped page */
30040931Sdg	vm_offset_t	kva;		/* va of mapping */
30140931Sdg};
30240931Sdg
30361837Salfredstruct accept_filter {
30461837Salfred	char	accf_name[16];
30561837Salfred	void	(*accf_callback)
30661837Salfred		__P((struct socket *so, void *arg, int waitflag));
30761837Salfred	void *	(*accf_create)
30861837Salfred		__P((struct socket *so, char *arg));
30961837Salfred	void	(*accf_destroy)
31061837Salfred		__P((struct socket *so));
31161837Salfred	SLIST_ENTRY(accept_filter) accf_next;	/* next on the list */
31282656Sjlemon};
31361837Salfred
31431927Sbde#ifdef MALLOC_DECLARE
31531927SbdeMALLOC_DECLARE(M_PCB);
31631927SbdeMALLOC_DECLARE(M_SONAME);
31761837SalfredMALLOC_DECLARE(M_ACCF);
31831927Sbde#endif
31931927Sbde
32036079Swollmanextern int	maxsockets;
3212112Swollmanextern u_long	sb_max;
32236079Swollmanextern struct	vm_zone *socket_zone;
32336079Swollmanextern so_gen_t so_gencnt;
32414505Shsu
32532995Sbdestruct file;
32615492Sbdestruct filedesc;
32715492Sbdestruct mbuf;
32815492Sbdestruct sockaddr;
32915492Sbdestruct stat;
33032995Sbdestruct ucred;
33132995Sbdestruct uio;
33272521Sjlemonstruct knote;
33315492Sbde
3341541Srgrimes/*
3351541Srgrimes * File operations on sockets.
3361541Srgrimes */
33745311Sdtint	soo_read __P((struct file *fp, struct uio *uio, struct ucred *cred,
33883366Sjulian	    int flags, struct thread *td));
33945311Sdtint	soo_write __P((struct file *fp, struct uio *uio, struct ucred *cred,
34083366Sjulian	    int flags, struct thread *td));
34183366Sjulianint	soo_close __P((struct file *fp, struct thread *td));
34236735Sdfrint	soo_ioctl __P((struct file *fp, u_long cmd, caddr_t data,
34383366Sjulian	    struct thread *td));
34429350Speterint	soo_poll __P((struct file *fp, int events, struct ucred *cred,
34583366Sjulian	    struct thread *td));
34683366Sjulianint	soo_stat __P((struct file *fp, struct stat *ub, struct thread *td));
34772521Sjlemonint	sokqfilter __P((struct file *fp, struct knote *kn));
3483304Sphk
3493304Sphk/*
3503304Sphk * From uipc_socket and friends
3513304Sphk */
35228270Swollmanstruct	sockaddr *dup_sockaddr __P((struct sockaddr *sa, int canwait));
35368883Sdillonint	holdsock __P((struct filedesc *fdp, int fdes, struct file **fpp));
35414505Shsuint	sockargs __P((struct mbuf **mp, caddr_t buf, int buflen, int type));
35528270Swollmanint	getsockaddr __P((struct sockaddr **namp, caddr_t uaddr, size_t len));
35614505Shsuvoid	sbappend __P((struct sockbuf *sb, struct mbuf *m));
35714505Shsuint	sbappendaddr __P((struct sockbuf *sb, struct sockaddr *asa,
35814505Shsu	    struct mbuf *m0, struct mbuf *control));
35914505Shsuint	sbappendcontrol __P((struct sockbuf *sb, struct mbuf *m0,
36014505Shsu	    struct mbuf *control));
36114505Shsuvoid	sbappendrecord __P((struct sockbuf *sb, struct mbuf *m0));
36214505Shsuvoid	sbcheck __P((struct sockbuf *sb));
36314505Shsuvoid	sbcompress __P((struct sockbuf *sb, struct mbuf *m, struct mbuf *n));
36419670Sbdestruct mbuf *
36519670Sbde	sbcreatecontrol __P((caddr_t p, int size, int type, int level));
36614505Shsuvoid	sbdrop __P((struct sockbuf *sb, int len));
36714505Shsuvoid	sbdroprecord __P((struct sockbuf *sb));
36814505Shsuvoid	sbflush __P((struct sockbuf *sb));
36914505Shsuvoid	sbinsertoob __P((struct sockbuf *sb, struct mbuf *m0));
37052070Sgreenvoid	sbrelease __P((struct sockbuf *sb, struct socket *so));
37152070Sgreenint	sbreserve __P((struct sockbuf *sb, u_long cc, struct socket *so,
37283366Sjulian		       struct thread *td));
37336079Swollmanvoid	sbtoxsockbuf __P((struct sockbuf *sb, struct xsockbuf *xsb));
37414505Shsuint	sbwait __P((struct sockbuf *sb));
37514505Shsuint	sb_lock __P((struct sockbuf *sb));
37614505Shsuint	soabort __P((struct socket *so));
37728270Swollmanint	soaccept __P((struct socket *so, struct sockaddr **nam));
37836079Swollmanstruct	socket *soalloc __P((int waitok));
37983366Sjulianint	sobind __P((struct socket *so, struct sockaddr *nam, struct thread *td));
38014505Shsuvoid	socantrcvmore __P((struct socket *so));
38114505Shsuvoid	socantsendmore __P((struct socket *so));
38214505Shsuint	soclose __P((struct socket *so));
38383366Sjulianint	soconnect __P((struct socket *so, struct sockaddr *nam, struct thread *td));
38414505Shsuint	soconnect2 __P((struct socket *so1, struct socket *so2));
38514505Shsuint	socreate __P((int dom, struct socket **aso, int type, int proto,
38683366Sjulian	    struct thread *td));
38714505Shsuint	sodisconnect __P((struct socket *so));
38814505Shsuvoid	sofree __P((struct socket *so));
38938482Swollmanint	sogetopt __P((struct socket *so, struct sockopt *sopt));
39014505Shsuvoid	sohasoutofband __P((struct socket *so));
39114505Shsuvoid	soisconnected __P((struct socket *so));
39214505Shsuvoid	soisconnecting __P((struct socket *so));
39314505Shsuvoid	soisdisconnected __P((struct socket *so));
39414505Shsuvoid	soisdisconnecting __P((struct socket *so));
39583366Sjulianint	solisten __P((struct socket *so, int backlog, struct thread *td));
39614505Shsustruct socket *
39718787Spst	sodropablereq __P((struct socket *head));
39818787Spststruct socket *
39927531Sfenner	sonewconn __P((struct socket *head, int connstatus));
40051381Sgreenstruct socket *
40183366Sjulian	sonewconn3 __P((struct socket *head, int connstatus, struct thread *td));
40238482Swollmanint	sooptcopyin __P((struct sockopt *sopt, void *buf, size_t len,
40338482Swollman			 size_t minlen));
40438482Swollmanint	sooptcopyout __P((struct sockopt *sopt, void *buf, size_t len));
40553541Sshin
40653541Sshin/* XXX; prepare mbuf for (__FreeBSD__ < 3) routines. */
40753541Sshinint	soopt_getm __P((struct sockopt *sopt, struct mbuf **mp));
40853541Sshinint	soopt_mcopyin __P((struct sockopt *sopt, struct mbuf *m));
40953541Sshinint	soopt_mcopyout __P((struct sockopt *sopt, struct mbuf *m));
41053541Sshin
41129350Speterint	sopoll __P((struct socket *so, int events, struct ucred *cred,
41283366Sjulian		    struct thread *td));
41328270Swollmanint	soreceive __P((struct socket *so, struct sockaddr **paddr,
41428270Swollman		       struct uio *uio, struct mbuf **mp0,
41528270Swollman		       struct mbuf **controlp, int *flagsp));
41614505Shsuint	soreserve __P((struct socket *so, u_long sndcc, u_long rcvcc));
41714505Shsuvoid	sorflush __P((struct socket *so));
41828270Swollmanint	sosend __P((struct socket *so, struct sockaddr *addr, struct uio *uio,
41928270Swollman		    struct mbuf *top, struct mbuf *control, int flags,
42083366Sjulian		    struct thread *td));
42138482Swollmanint	sosetopt __P((struct socket *so, struct sockopt *sopt));
42214505Shsuint	soshutdown __P((struct socket *so, int how));
42336079Swollmanvoid	sotoxsocket __P((struct socket *so, struct xsocket *xso));
42414505Shsuvoid	sowakeup __P((struct socket *so, struct sockbuf *sb));
42531927Sbde
42661837Salfred/* accept filter functions */
42761837Salfredint	accept_filt_add __P((struct accept_filter *filt));
42861837Salfredint	accept_filt_del __P((char *name));
42961837Salfredstruct accept_filter *	accept_filt_get __P((char *name));
43061837Salfred#ifdef ACCEPT_FILTER_MOD
43161837Salfredint accept_filt_generic_mod_event __P((module_t mod, int event, void *data));
43265534SalfredSYSCTL_DECL(_net_inet_accf);
43361837Salfred#endif /* ACCEPT_FILTER_MOD */
43461837Salfred
43584527Spsint	socheckuid __P((struct socket *so, uid_t uid));
43684527Spsint	socheckproc __P((struct socket *so, struct proc *p));
43784527Sps
43855205Speter#endif /* _KERNEL */
4392165Spaul
44014505Shsu#endif /* !_SYS_SOCKETVAR_H_ */
441