xref: /csrg-svn/sys/sys/socket.h (revision 28881)
123438Smckusick /*
2*28881Skarels  * Copyright (c) 1982,1985 Regents of the University of California.
323438Smckusick  * All rights reserved.  The Berkeley software License Agreement
423438Smckusick  * specifies the terms and conditions for redistribution.
523438Smckusick  *
6*28881Skarels  *	@(#)socket.h	6.11 (Berkeley) 05/29/86
723438Smckusick  */
84658Swnj 
94658Swnj /*
1012787Ssam  * Definitions related to sockets: types, address families, options.
114658Swnj  */
124892Swnj 
134892Swnj /*
1412787Ssam  * Types
154892Swnj  */
164930Swnj #define	SOCK_STREAM	1		/* stream socket */
174930Swnj #define	SOCK_DGRAM	2		/* datagram socket */
184930Swnj #define	SOCK_RAW	3		/* raw-protocol interface */
194930Swnj #define	SOCK_RDM	4		/* reliably-delivered message */
2012787Ssam #define	SOCK_SEQPACKET	5		/* sequenced packet stream */
214658Swnj 
224812Swnj /*
234812Swnj  * Option flags per-socket.
244812Swnj  */
2527192Skarels #define	SO_DEBUG	0x0001		/* turn on debugging info recording */
2627192Skarels #define	SO_ACCEPTCONN	0x0002		/* socket has had listen() */
2727192Skarels #define	SO_REUSEADDR	0x0004		/* allow local address reuse */
2827192Skarels #define	SO_KEEPALIVE	0x0008		/* keep connections alive */
2927192Skarels #define	SO_DONTROUTE	0x0010		/* just use interface addresses */
3027192Skarels #define	SO_BROADCAST	0x0020		/* permit sending of broadcast msgs */
3127192Skarels #define	SO_USELOOPBACK	0x0040		/* bypass hardware when possible */
3227192Skarels #define	SO_LINGER	0x0080		/* linger on close if data present */
3327192Skarels #define	SO_OOBINLINE	0x0100		/* leave received OOB data in line */
344930Swnj 
354930Swnj /*
3617552Skarels  * Additional options, not kept in so_options.
3717552Skarels  */
3817552Skarels #define SO_SNDBUF	0x1001		/* send buffer size */
3917552Skarels #define SO_RCVBUF	0x1002		/* receive buffer size */
4017552Skarels #define SO_SNDLOWAT	0x1003		/* send low-water mark */
4117552Skarels #define SO_RCVLOWAT	0x1004		/* receive low-water mark */
4217552Skarels #define SO_SNDTIMEO	0x1005		/* send timeout */
4317552Skarels #define SO_RCVTIMEO	0x1006		/* receive timeout */
4424825Skarels #define	SO_ERROR	0x1007		/* get error status and clear */
4525503Skarels #define	SO_TYPE		0x1008		/* get socket type */
4617552Skarels 
4717552Skarels /*
4817160Ssam  * Structure used for manipulating linger option.
4917052Skarels  */
5017160Ssam struct	linger {
5117160Ssam 	int	l_onoff;		/* option on/off */
5217160Ssam 	int	l_linger;		/* linger time */
5317160Ssam };
5417052Skarels 
5517052Skarels /*
5617160Ssam  * Level number for (get/set)sockopt() to apply to socket itself.
5717160Ssam  */
5817160Ssam #define	SOL_SOCKET	0xffff		/* options for socket level */
5917160Ssam 
6017160Ssam /*
6112787Ssam  * Address families.
624930Swnj  */
6312787Ssam #define	AF_UNSPEC	0		/* unspecified */
6412787Ssam #define	AF_UNIX		1		/* local to host (pipes, portals) */
6512787Ssam #define	AF_INET		2		/* internetwork: UDP, TCP, etc. */
6612787Ssam #define	AF_IMPLINK	3		/* arpanet imp addresses */
6712787Ssam #define	AF_PUP		4		/* pup protocols: e.g. BSP */
6812787Ssam #define	AF_CHAOS	5		/* mit CHAOS protocols */
6912787Ssam #define	AF_NS		6		/* XEROX NS protocols */
7012787Ssam #define	AF_NBS		7		/* nbs protocols */
7112787Ssam #define	AF_ECMA		8		/* european computer manufacturers */
7212787Ssam #define	AF_DATAKIT	9		/* datakit protocols */
7312787Ssam #define	AF_CCITT	10		/* CCITT protocols, X.25 etc */
7412787Ssam #define	AF_SNA		11		/* IBM SNA */
7523751Skarels #define AF_DECnet	12		/* DECnet */
7623751Skarels #define AF_DLI		13		/* Direct data link interface */
7723751Skarels #define AF_LAT		14		/* LAT */
7823751Skarels #define	AF_HYLINK	15		/* NSC Hyperchannel */
79*28881Skarels #define	AF_APPLETALK	16		/* Apple Talk */
804930Swnj 
81*28881Skarels #define	AF_MAX		17
824930Swnj 
834930Swnj /*
8412787Ssam  * Structure used by kernel to store most
8512787Ssam  * addresses.
864930Swnj  */
874930Swnj struct sockaddr {
8812508Ssam 	u_short	sa_family;		/* address family */
894930Swnj 	char	sa_data[14];		/* up to 14 bytes of direct address */
904930Swnj };
914930Swnj 
924930Swnj /*
9312787Ssam  * Structure used by kernel to pass protocol
9412787Ssam  * information in raw sockets.
954930Swnj  */
9612787Ssam struct sockproto {
9712787Ssam 	u_short	sp_family;		/* address family */
9812787Ssam 	u_short	sp_protocol;		/* protocol */
9912787Ssam };
1006620Ssam 
10112787Ssam /*
10212787Ssam  * Protocol families, same as address families for now.
10312787Ssam  */
10412787Ssam #define	PF_UNSPEC	AF_UNSPEC
10512787Ssam #define	PF_UNIX		AF_UNIX
10612787Ssam #define	PF_INET		AF_INET
10712787Ssam #define	PF_IMPLINK	AF_IMPLINK
10812787Ssam #define	PF_PUP		AF_PUP
10912787Ssam #define	PF_CHAOS	AF_CHAOS
11012787Ssam #define	PF_NS		AF_NS
11112787Ssam #define	PF_NBS		AF_NBS
11212787Ssam #define	PF_ECMA		AF_ECMA
11312787Ssam #define	PF_DATAKIT	AF_DATAKIT
11412787Ssam #define	PF_CCITT	AF_CCITT
11512787Ssam #define	PF_SNA		AF_SNA
11623751Skarels #define PF_DECnet	AF_DECnet
11723751Skarels #define PF_DLI		AF_DLI
11823751Skarels #define PF_LAT		AF_LAT
11923751Skarels #define	PF_HYLINK	AF_HYLINK
120*28881Skarels #define	PF_APPLETALK	AF_APPLETALK
1218274Sroot 
12223751Skarels #define	PF_MAX		AF_MAX
12312787Ssam 
12412787Ssam /*
12512787Ssam  * Maximum queue length specifiable by listen.
12612787Ssam  */
12712787Ssam #define	SOMAXCONN	5
12812787Ssam 
12912787Ssam /*
13012787Ssam  * Message header for recvmsg and sendmsg calls.
13112787Ssam  */
13212787Ssam struct msghdr {
13312787Ssam 	caddr_t	msg_name;		/* optional address */
13412787Ssam 	int	msg_namelen;		/* size of address */
13512787Ssam 	struct	iovec *msg_iov;		/* scatter/gather array */
13612787Ssam 	int	msg_iovlen;		/* # elements in msg_iov */
13712787Ssam 	caddr_t	msg_accrights;		/* access rights sent/received */
13812787Ssam 	int	msg_accrightslen;
13912787Ssam };
14012787Ssam 
14112787Ssam #define	MSG_OOB		0x1		/* process out-of-band data */
14212787Ssam #define	MSG_PEEK	0x2		/* peek at incoming message */
14312787Ssam #define	MSG_DONTROUTE	0x4		/* send without using routing tables */
14412787Ssam 
14512787Ssam #define	MSG_MAXIOVLEN	16
146