socket.h revision 66240
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
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 *
331541Srgrimes *	@(#)socket.h	8.4 (Berkeley) 2/21/94
3450477Speter * $FreeBSD: head/sys/sys/socket.h 66240 2000-09-22 10:52:00Z asmodai $
351541Srgrimes */
361541Srgrimes
371541Srgrimes#ifndef _SYS_SOCKET_H_
381541Srgrimes#define	_SYS_SOCKET_H_
391541Srgrimes
401541Srgrimes/*
411541Srgrimes * Definitions related to sockets: types, address families, options.
421541Srgrimes */
431541Srgrimes
441541Srgrimes/*
4553678Sphk * Data types.
4653678Sphk */
4753678Sphktypedef u_char		sa_family_t;
4853678Sphktypedef u_int32_t	socklen_t;
4953678Sphk
5053678Sphk/*
511541Srgrimes * Types
521541Srgrimes */
531541Srgrimes#define	SOCK_STREAM	1		/* stream socket */
541541Srgrimes#define	SOCK_DGRAM	2		/* datagram socket */
551541Srgrimes#define	SOCK_RAW	3		/* raw-protocol interface */
561541Srgrimes#define	SOCK_RDM	4		/* reliably-delivered message */
571541Srgrimes#define	SOCK_SEQPACKET	5		/* sequenced packet stream */
581541Srgrimes
591541Srgrimes/*
601541Srgrimes * Option flags per-socket.
611541Srgrimes */
621541Srgrimes#define	SO_DEBUG	0x0001		/* turn on debugging info recording */
631541Srgrimes#define	SO_ACCEPTCONN	0x0002		/* socket has had listen() */
641541Srgrimes#define	SO_REUSEADDR	0x0004		/* allow local address reuse */
651541Srgrimes#define	SO_KEEPALIVE	0x0008		/* keep connections alive */
661541Srgrimes#define	SO_DONTROUTE	0x0010		/* just use interface addresses */
671541Srgrimes#define	SO_BROADCAST	0x0020		/* permit sending of broadcast msgs */
681541Srgrimes#define	SO_USELOOPBACK	0x0040		/* bypass hardware when possible */
691541Srgrimes#define	SO_LINGER	0x0080		/* linger on close if data present */
701541Srgrimes#define	SO_OOBINLINE	0x0100		/* leave received OOB data in line */
711541Srgrimes#define	SO_REUSEPORT	0x0200		/* allow local address & port reuse */
7215701Swollman#define	SO_TIMESTAMP	0x0400		/* timestamp received dgram traffic */
7361837Salfred#define	SO_ACCEPTFILTER	0x1000		/* there is an accept filter */
741541Srgrimes
751541Srgrimes/*
761541Srgrimes * Additional options, not kept in so_options.
771541Srgrimes */
781541Srgrimes#define SO_SNDBUF	0x1001		/* send buffer size */
791541Srgrimes#define SO_RCVBUF	0x1002		/* receive buffer size */
801541Srgrimes#define SO_SNDLOWAT	0x1003		/* send low-water mark */
811541Srgrimes#define SO_RCVLOWAT	0x1004		/* receive low-water mark */
821541Srgrimes#define SO_SNDTIMEO	0x1005		/* send timeout */
831541Srgrimes#define SO_RCVTIMEO	0x1006		/* receive timeout */
841541Srgrimes#define	SO_ERROR	0x1007		/* get error status and clear */
851541Srgrimes#define	SO_TYPE		0x1008		/* get socket type */
8625311Swollman/*efine	SO_PRIVSTATE	0x1009		   get/deny privileged state */
871541Srgrimes
881541Srgrimes/*
891541Srgrimes * Structure used for manipulating linger option.
901541Srgrimes */
911541Srgrimesstruct	linger {
921541Srgrimes	int	l_onoff;		/* option on/off */
931541Srgrimes	int	l_linger;		/* linger time */
941541Srgrimes};
951541Srgrimes
9661837Salfredstruct	accept_filter_arg {
9761837Salfred	char	af_name[16];
9861837Salfred	char	af_arg[256-16];
9961837Salfred};
10061837Salfred
1011541Srgrimes/*
1021541Srgrimes * Level number for (get/set)sockopt() to apply to socket itself.
1031541Srgrimes */
1041541Srgrimes#define	SOL_SOCKET	0xffff		/* options for socket level */
1051541Srgrimes
1061541Srgrimes/*
1071541Srgrimes * Address families.
1081541Srgrimes */
1091541Srgrimes#define	AF_UNSPEC	0		/* unspecified */
1101541Srgrimes#define	AF_LOCAL	1		/* local to host (pipes, portals) */
1111541Srgrimes#define	AF_UNIX		AF_LOCAL	/* backward compatibility */
1121541Srgrimes#define	AF_INET		2		/* internetwork: UDP, TCP, etc. */
1131541Srgrimes#define	AF_IMPLINK	3		/* arpanet imp addresses */
1141541Srgrimes#define	AF_PUP		4		/* pup protocols: e.g. BSP */
1151541Srgrimes#define	AF_CHAOS	5		/* mit CHAOS protocols */
1161541Srgrimes#define	AF_NS		6		/* XEROX NS protocols */
1171541Srgrimes#define	AF_ISO		7		/* ISO protocols */
1181541Srgrimes#define	AF_OSI		AF_ISO
11913765Smpp#define	AF_ECMA		8		/* European computer manufacturers */
1201541Srgrimes#define	AF_DATAKIT	9		/* datakit protocols */
1211541Srgrimes#define	AF_CCITT	10		/* CCITT protocols, X.25 etc */
1221541Srgrimes#define	AF_SNA		11		/* IBM SNA */
1231541Srgrimes#define AF_DECnet	12		/* DECnet */
1241541Srgrimes#define AF_DLI		13		/* DEC Direct data link interface */
1251541Srgrimes#define AF_LAT		14		/* LAT */
1261541Srgrimes#define	AF_HYLINK	15		/* NSC Hyperchannel */
1271541Srgrimes#define	AF_APPLETALK	16		/* Apple Talk */
1281541Srgrimes#define	AF_ROUTE	17		/* Internal Routing Protocol */
1291541Srgrimes#define	AF_LINK		18		/* Link layer interface */
1301541Srgrimes#define	pseudo_AF_XTP	19		/* eXpress Transfer Protocol (no AF) */
1311541Srgrimes#define	AF_COIP		20		/* connection-oriented IP, aka ST II */
1321541Srgrimes#define	AF_CNT		21		/* Computer Network Technology */
1331541Srgrimes#define pseudo_AF_RTIP	22		/* Help Identify RTIP packets */
1341541Srgrimes#define	AF_IPX		23		/* Novell Internet Protocol */
1351541Srgrimes#define	AF_SIP		24		/* Simple Internet Protocol */
1365413Sse#define	pseudo_AF_PIP	25		/* Help Identify PIP packets */
1375413Sse#define	AF_ISDN		26		/* Integrated Services Digital Network*/
1385413Sse#define	AF_E164		AF_ISDN		/* CCITT E.164 recommendation */
13916368Swollman#define	pseudo_AF_KEY	27		/* Internal key-management function */
14017938Speter#define	AF_INET6	28		/* IPv6 */
14125609Skjc#define	AF_NATM		29		/* native ATM access */
14239271Sphk#define	AF_ATM		30		/* ATM */
14352248Smsmith#define pseudo_AF_HDRCMPLT 31		/* Used by BPF to not rewrite headers
14452248Smsmith					 * in interface output routine
14552248Smsmith					 */
14652424Sjulian#define	AF_NETGRAPH	32		/* Netgraph sockets */
1471541Srgrimes
14852424Sjulian#define	AF_MAX		33
1491541Srgrimes
1501541Srgrimes/*
1511541Srgrimes * Structure used by kernel to store most
1521541Srgrimes * addresses.
1531541Srgrimes */
1541541Srgrimesstruct sockaddr {
15553678Sphk	u_char		sa_len;		/* total length */
15653678Sphk	sa_family_t	sa_family;	/* address family */
15753678Sphk	char		sa_data[14];	/* actually longer; address value */
1581541Srgrimes};
15928270Swollman#define	SOCK_MAXADDRLEN	255		/* longest possible addresses */
1601541Srgrimes
1611541Srgrimes/*
1621541Srgrimes * Structure used by kernel to pass protocol
1631541Srgrimes * information in raw sockets.
1641541Srgrimes */
1651541Srgrimesstruct sockproto {
1661541Srgrimes	u_short	sp_family;		/* address family */
1671541Srgrimes	u_short	sp_protocol;		/* protocol */
1681541Srgrimes};
1691541Srgrimes
1701541Srgrimes/*
17166240Sasmodai * RFC 2553: protocol-independent placeholder for socket addresses
17252904Sshin */
17352904Sshin#define	_SS_MAXSIZE	128
17452904Sshin#define	_SS_ALIGNSIZE	(sizeof(int64_t))
17557911Sshin#define	_SS_PAD1SIZE	(_SS_ALIGNSIZE - sizeof(u_char) - sizeof(sa_family_t))
17657911Sshin#define	_SS_PAD2SIZE	(_SS_MAXSIZE - sizeof(u_char) - sizeof(sa_family_t) - \
17752904Sshin				_SS_PAD1SIZE - _SS_ALIGNSIZE)
17852904Sshin
17952904Sshinstruct sockaddr_storage {
18055917Sshin	u_char		ss_len;		/* address length */
18155917Sshin	sa_family_t	ss_family;	/* address family */
18253678Sphk	char		__ss_pad1[_SS_PAD1SIZE];
18353678Sphk	int64_t		__ss_align;	/* force desired structure storage alignment */
18453678Sphk	char		__ss_pad2[_SS_PAD2SIZE];
18552904Sshin};
18652904Sshin
18752904Sshin/*
1881541Srgrimes * Protocol families, same as address families for now.
1891541Srgrimes */
1901541Srgrimes#define	PF_UNSPEC	AF_UNSPEC
1911541Srgrimes#define	PF_LOCAL	AF_LOCAL
1921541Srgrimes#define	PF_UNIX		PF_LOCAL	/* backward compatibility */
1931541Srgrimes#define	PF_INET		AF_INET
1941541Srgrimes#define	PF_IMPLINK	AF_IMPLINK
1951541Srgrimes#define	PF_PUP		AF_PUP
1961541Srgrimes#define	PF_CHAOS	AF_CHAOS
1971541Srgrimes#define	PF_NS		AF_NS
1981541Srgrimes#define	PF_ISO		AF_ISO
1991541Srgrimes#define	PF_OSI		AF_ISO
2001541Srgrimes#define	PF_ECMA		AF_ECMA
2011541Srgrimes#define	PF_DATAKIT	AF_DATAKIT
2021541Srgrimes#define	PF_CCITT	AF_CCITT
2031541Srgrimes#define	PF_SNA		AF_SNA
2041541Srgrimes#define PF_DECnet	AF_DECnet
2051541Srgrimes#define PF_DLI		AF_DLI
2061541Srgrimes#define PF_LAT		AF_LAT
2071541Srgrimes#define	PF_HYLINK	AF_HYLINK
2081541Srgrimes#define	PF_APPLETALK	AF_APPLETALK
2091541Srgrimes#define	PF_ROUTE	AF_ROUTE
2101541Srgrimes#define	PF_LINK		AF_LINK
2111541Srgrimes#define	PF_XTP		pseudo_AF_XTP	/* really just proto family, no AF */
2121541Srgrimes#define	PF_COIP		AF_COIP
2131541Srgrimes#define	PF_CNT		AF_CNT
2141541Srgrimes#define	PF_SIP		AF_SIP
2151541Srgrimes#define	PF_IPX		AF_IPX		/* same format as AF_NS */
21617603Sjdp#define PF_RTIP		pseudo_AF_RTIP	/* same format as AF_INET */
2171541Srgrimes#define PF_PIP		pseudo_AF_PIP
2185413Sse#define	PF_ISDN		AF_ISDN
21916480Swollman#define	PF_KEY		pseudo_AF_KEY
22017938Speter#define	PF_INET6	AF_INET6
22125609Skjc#define	PF_NATM		AF_NATM
22239271Sphk#define	PF_ATM		AF_ATM
22352419Sjulian#define	PF_NETGRAPH	AF_NETGRAPH
2241541Srgrimes
2251541Srgrimes#define	PF_MAX		AF_MAX
2261541Srgrimes
2271541Srgrimes/*
2281541Srgrimes * Definitions for network related sysctl, CTL_NET.
2291541Srgrimes *
2301541Srgrimes * Second level is protocol family.
2311541Srgrimes * Third level is protocol number.
2321541Srgrimes *
2331541Srgrimes * Further levels are defined by the individual families below.
2341541Srgrimes */
2351541Srgrimes#define NET_MAXID	AF_MAX
2361541Srgrimes
2371541Srgrimes#define CTL_NET_NAMES { \
2381541Srgrimes	{ 0, 0 }, \
2391541Srgrimes	{ "unix", CTLTYPE_NODE }, \
2401541Srgrimes	{ "inet", CTLTYPE_NODE }, \
2411541Srgrimes	{ "implink", CTLTYPE_NODE }, \
2421541Srgrimes	{ "pup", CTLTYPE_NODE }, \
2431541Srgrimes	{ "chaos", CTLTYPE_NODE }, \
2441541Srgrimes	{ "xerox_ns", CTLTYPE_NODE }, \
2451541Srgrimes	{ "iso", CTLTYPE_NODE }, \
2461541Srgrimes	{ "emca", CTLTYPE_NODE }, \
2471541Srgrimes	{ "datakit", CTLTYPE_NODE }, \
2481541Srgrimes	{ "ccitt", CTLTYPE_NODE }, \
2491541Srgrimes	{ "ibm_sna", CTLTYPE_NODE }, \
2501541Srgrimes	{ "decnet", CTLTYPE_NODE }, \
2511541Srgrimes	{ "dec_dli", CTLTYPE_NODE }, \
2521541Srgrimes	{ "lat", CTLTYPE_NODE }, \
2531541Srgrimes	{ "hylink", CTLTYPE_NODE }, \
2541541Srgrimes	{ "appletalk", CTLTYPE_NODE }, \
2551541Srgrimes	{ "route", CTLTYPE_NODE }, \
2561541Srgrimes	{ "link_layer", CTLTYPE_NODE }, \
2571541Srgrimes	{ "xtp", CTLTYPE_NODE }, \
2581541Srgrimes	{ "coip", CTLTYPE_NODE }, \
2591541Srgrimes	{ "cnt", CTLTYPE_NODE }, \
2601541Srgrimes	{ "rtip", CTLTYPE_NODE }, \
2611541Srgrimes	{ "ipx", CTLTYPE_NODE }, \
2621541Srgrimes	{ "sip", CTLTYPE_NODE }, \
2631541Srgrimes	{ "pip", CTLTYPE_NODE }, \
26416368Swollman	{ "isdn", CTLTYPE_NODE }, \
26516368Swollman	{ "key", CTLTYPE_NODE }, \
26633006Salex	{ "inet6", CTLTYPE_NODE }, \
26725609Skjc	{ "natm", CTLTYPE_NODE }, \
26852435Sjulian	{ "atm", CTLTYPE_NODE }, \
26952435Sjulian	{ "hdrcomplete", CTLTYPE_NODE }, \
27052419Sjulian	{ "netgraph", CTLTYPE_NODE }, \
2711541Srgrimes}
2721541Srgrimes
2731541Srgrimes/*
2741541Srgrimes * PF_ROUTE - Routing table
2751541Srgrimes *
2761541Srgrimes * Three additional levels are defined:
2771541Srgrimes *	Fourth: address family, 0 is wildcard
2781541Srgrimes *	Fifth: type of info, defined below
2791541Srgrimes *	Sixth: flag(s) to mask with for NET_RT_FLAGS
2801541Srgrimes */
2811541Srgrimes#define NET_RT_DUMP	1		/* dump; may limit to a.f. */
2821541Srgrimes#define NET_RT_FLAGS	2		/* by flags, e.g. RESOLVING */
2831541Srgrimes#define NET_RT_IFLIST	3		/* survey interface list */
2841541Srgrimes#define	NET_RT_MAXID	4
2851541Srgrimes
2861541Srgrimes#define CTL_NET_RT_NAMES { \
2871541Srgrimes	{ 0, 0 }, \
2881541Srgrimes	{ "dump", CTLTYPE_STRUCT }, \
2891541Srgrimes	{ "flags", CTLTYPE_STRUCT }, \
2901541Srgrimes	{ "iflist", CTLTYPE_STRUCT }, \
2911541Srgrimes}
2921541Srgrimes
2931541Srgrimes/*
2941541Srgrimes * Maximum queue length specifiable by listen.
2951541Srgrimes */
29613258Sdg#define	SOMAXCONN	128
2971541Srgrimes
2981541Srgrimes/*
2991541Srgrimes * Message header for recvmsg and sendmsg calls.
3001541Srgrimes * Used value-result for recvmsg, value only for sendmsg.
3011541Srgrimes */
3021541Srgrimesstruct msghdr {
30353678Sphk	void		*msg_name;		/* optional address */
30453678Sphk	socklen_t	 msg_namelen;		/* size of address */
30553678Sphk	struct iovec	*msg_iov;		/* scatter/gather array */
30653678Sphk	int		 msg_iovlen;		/* # elements in msg_iov */
30753678Sphk	void		*msg_control;		/* ancillary data, see below */
30853678Sphk	socklen_t	 msg_controllen;	/* ancillary data buffer len */
30953678Sphk	int		 msg_flags;		/* flags on received message */
3101541Srgrimes};
3111541Srgrimes
3121541Srgrimes#define	MSG_OOB		0x1		/* process out-of-band data */
3131541Srgrimes#define	MSG_PEEK	0x2		/* peek at incoming message */
3141541Srgrimes#define	MSG_DONTROUTE	0x4		/* send without using routing tables */
3151541Srgrimes#define	MSG_EOR		0x8		/* data completes record */
3161541Srgrimes#define	MSG_TRUNC	0x10		/* data discarded before delivery */
3171541Srgrimes#define	MSG_CTRUNC	0x20		/* control data lost before delivery */
3181541Srgrimes#define	MSG_WAITALL	0x40		/* wait for full request or error */
3191541Srgrimes#define	MSG_DONTWAIT	0x80		/* this message should be nonblocking */
3206223Swollman#define	MSG_EOF		0x100		/* data completes connection */
3213304Sphk#define MSG_COMPAT      0x8000		/* used in sendit() */
3221541Srgrimes
3231541Srgrimes/*
3241541Srgrimes * Header for ancillary data objects in msg_control buffer.
3251541Srgrimes * Used for additional information with/about a datagram
3261541Srgrimes * not expressible by flags.  The format is a sequence
3271541Srgrimes * of message elements headed by cmsghdr structures.
3281541Srgrimes */
3291541Srgrimesstruct cmsghdr {
33053678Sphk	socklen_t	cmsg_len;		/* data byte count, including hdr */
33153678Sphk	int		cmsg_level;		/* originating protocol */
33253678Sphk	int		cmsg_type;		/* protocol-specific type */
3331541Srgrimes/* followed by	u_char  cmsg_data[]; */
3341541Srgrimes};
3351541Srgrimes
33624083Swpaul/*
33724083Swpaul * While we may have more groups than this, the cmsgcred struct must
33824083Swpaul * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow
33924083Swpaul * this.
34024083Swpaul*/
34124083Swpaul#define CMGROUP_MAX 16
34224083Swpaul
34324083Swpaul/*
34424083Swpaul * Credentials structure, used to verify the identity of a peer
34524083Swpaul * process that has sent us a message. This is allocated by the
34624083Swpaul * peer process but filled in by the kernel. This prevents the
34724083Swpaul * peer from lying about its identity. (Note that cmcred_groups[0]
34824083Swpaul * is the effective GID.)
34924083Swpaul */
35024083Swpaulstruct cmsgcred {
35124083Swpaul	pid_t	cmcred_pid;		/* PID of sending process */
35224083Swpaul	uid_t	cmcred_uid;		/* real UID of sending process */
35324083Swpaul	uid_t	cmcred_euid;		/* effective UID of sending process */
35424083Swpaul	gid_t	cmcred_gid;		/* real GID of sending process */
35524083Swpaul	short	cmcred_ngroups;		/* number or groups */
35624083Swpaul	gid_t	cmcred_groups[CMGROUP_MAX];	/* groups */
35724083Swpaul};
35824083Swpaul
3591541Srgrimes/* given pointer to struct cmsghdr, return pointer to data */
36057719Sshin#define	CMSG_DATA(cmsg)		((u_char *)(cmsg) + \
36157719Sshin				 ALIGN(sizeof(struct cmsghdr)))
3621541Srgrimes
3631541Srgrimes/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
3641541Srgrimes#define	CMSG_NXTHDR(mhdr, cmsg)	\
36557719Sshin	(((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len) + \
36657719Sshin	  ALIGN(sizeof(struct cmsghdr)) > \
36755009Sshin	    (caddr_t)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
3681541Srgrimes	    (struct cmsghdr *)NULL : \
36957719Sshin	    (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
3701541Srgrimes
3711541Srgrimes#define	CMSG_FIRSTHDR(mhdr)	((struct cmsghdr *)(mhdr)->msg_control)
3721541Srgrimes
37357719Sshin#define	CMSG_SPACE(l)		(ALIGN(sizeof(struct cmsghdr)) + ALIGN(l))
37457719Sshin#define	CMSG_LEN(l)		(ALIGN(sizeof(struct cmsghdr)) + (l))
37552904Sshin
3761541Srgrimes/* "Socket"-level control message types: */
3771541Srgrimes#define	SCM_RIGHTS	0x01		/* access rights (array of int) */
37815701Swollman#define	SCM_TIMESTAMP	0x02		/* timestamp (struct timeval) */
37924083Swpaul#define	SCM_CREDS	0x03		/* process creds (struct cmsgcred) */
3801541Srgrimes
3811541Srgrimes/*
3821541Srgrimes * 4.3 compat sockaddr, move to compat file later
3831541Srgrimes */
3841541Srgrimesstruct osockaddr {
3851541Srgrimes	u_short	sa_family;		/* address family */
3861541Srgrimes	char	sa_data[14];		/* up to 14 bytes of direct address */
3871541Srgrimes};
3881541Srgrimes
3891541Srgrimes/*
3901541Srgrimes * 4.3-compat message header (move to compat file later).
3911541Srgrimes */
3921541Srgrimesstruct omsghdr {
3931541Srgrimes	caddr_t	msg_name;		/* optional address */
3941541Srgrimes	int	msg_namelen;		/* size of address */
3951541Srgrimes	struct	iovec *msg_iov;		/* scatter/gather array */
3961541Srgrimes	int	msg_iovlen;		/* # elements in msg_iov */
3971541Srgrimes	caddr_t	msg_accrights;		/* access rights sent/received */
3981541Srgrimes	int	msg_accrightslen;
3991541Srgrimes};
4001541Srgrimes
40139114Swollman/*
40239114Swollman * howto arguments for shutdown(2), specified by Posix.1g.
40339114Swollman */
40439114Swollman#define	SHUT_RD		0		/* shut down the reading side */
40539114Swollman#define	SHUT_WR		1		/* shut down the writing side */
40639114Swollman#define	SHUT_RDWR	2		/* shut down both sides */
40739114Swollman
40840931Sdg/*
40940931Sdg * sendfile(2) header/trailer struct
41040931Sdg */
41140931Sdgstruct sf_hdtr {
41240931Sdg	struct iovec *headers;	/* pointer to an array of header struct iovec's */
41340931Sdg	int hdr_cnt;		/* number of header iovec's */
41440931Sdg	struct iovec *trailers;	/* pointer to an array of trailer struct iovec's */
41540931Sdg	int trl_cnt;		/* number of trailer iovec's */
41640931Sdg};
41740931Sdg
41855205Speter#ifndef	_KERNEL
4191541Srgrimes
4201541Srgrimes#include <sys/cdefs.h>
4211541Srgrimes
4221541Srgrimes__BEGIN_DECLS
42353678Sphkint	accept __P((int, struct sockaddr *, socklen_t *));
42453678Sphkint	bind __P((int, const struct sockaddr *, socklen_t));
42553678Sphkint	connect __P((int, const struct sockaddr *, socklen_t));
42653678Sphkint	getpeername __P((int, struct sockaddr *, socklen_t *));
42753678Sphkint	getsockname __P((int, struct sockaddr *, socklen_t *));
42853678Sphkint	getsockopt __P((int, int, int, void *, socklen_t *));
4291541Srgrimesint	listen __P((int, int));
4301541Srgrimesssize_t	recv __P((int, void *, size_t, int));
43153678Sphkssize_t	recvfrom __P((int, void *, size_t, int, struct sockaddr *, socklen_t *));
4321541Srgrimesssize_t	recvmsg __P((int, struct msghdr *, int));
4331541Srgrimesssize_t	send __P((int, const void *, size_t, int));
4341541Srgrimesssize_t	sendto __P((int, const void *,
43553678Sphk	    size_t, int, const struct sockaddr *, socklen_t));
4361541Srgrimesssize_t	sendmsg __P((int, const struct msghdr *, int));
43740931Sdgint	sendfile __P((int, int, off_t, size_t, struct sf_hdtr *, off_t *, int));
43853678Sphkint	setsockopt __P((int, int, int, const void *, socklen_t));
4391541Srgrimesint	shutdown __P((int, int));
4401541Srgrimesint	socket __P((int, int, int));
4411541Srgrimesint	socketpair __P((int, int, int, int *));
44252904Sshin
44352904Sshinvoid	pfctlinput __P((int, struct sockaddr *));
4441541Srgrimes__END_DECLS
4451541Srgrimes
44655205Speter#endif /* !_KERNEL */
44731927Sbde
4481541Srgrimes#endif /* !_SYS_SOCKET_H_ */
449