xref: /csrg-svn/sys/sys/socket.h (revision 23438)
1*23438Smckusick /*
2*23438Smckusick  * Copyright (c) 1982 Regents of the University of California.
3*23438Smckusick  * All rights reserved.  The Berkeley software License Agreement
4*23438Smckusick  * specifies the terms and conditions for redistribution.
5*23438Smckusick  *
6*23438Smckusick  *	@(#)socket.h	6.6 (Berkeley) 06/08/85
7*23438Smckusick  */
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  */
254812Swnj #define	SO_DEBUG	0x01		/* turn on debugging info recording */
2612787Ssam #define	SO_ACCEPTCONN	0x02		/* socket has had listen() */
2712787Ssam #define	SO_REUSEADDR	0x04		/* allow local address reuse */
286215Swnj #define	SO_KEEPALIVE	0x08		/* keep connections alive */
297132Swnj #define	SO_DONTROUTE	0x10		/* just use interface addresses */
3017052Skarels #define	SO_BROADCAST	0x20		/* permit sending of broadcast msgs */
3110209Ssam #define	SO_USELOOPBACK	0x40		/* bypass hardware when possible */
3210597Ssam #define	SO_LINGER	0x80		/* linger on close if data present */
334930Swnj 
344930Swnj /*
3517552Skarels  * Additional options, not kept in so_options.
3617552Skarels  */
3717552Skarels #define SO_SNDBUF	0x1001		/* send buffer size */
3817552Skarels #define SO_RCVBUF	0x1002		/* receive buffer size */
3917552Skarels #define SO_SNDLOWAT	0x1003		/* send low-water mark */
4017552Skarels #define SO_RCVLOWAT	0x1004		/* receive low-water mark */
4117552Skarels #define SO_SNDTIMEO	0x1005		/* send timeout */
4217552Skarels #define SO_RCVTIMEO	0x1006		/* receive timeout */
4317552Skarels 
4417552Skarels /*
4517160Ssam  * Structure used for manipulating linger option.
4617052Skarels  */
4717160Ssam struct	linger {
4817160Ssam 	int	l_onoff;		/* option on/off */
4917160Ssam 	int	l_linger;		/* linger time */
5017160Ssam };
5117052Skarels 
5217052Skarels /*
5317160Ssam  * Level number for (get/set)sockopt() to apply to socket itself.
5417160Ssam  */
5517160Ssam #define	SOL_SOCKET	0xffff		/* options for socket level */
5617160Ssam 
5717160Ssam /*
5812787Ssam  * Address families.
594930Swnj  */
6012787Ssam #define	AF_UNSPEC	0		/* unspecified */
6112787Ssam #define	AF_UNIX		1		/* local to host (pipes, portals) */
6212787Ssam #define	AF_INET		2		/* internetwork: UDP, TCP, etc. */
6312787Ssam #define	AF_IMPLINK	3		/* arpanet imp addresses */
6412787Ssam #define	AF_PUP		4		/* pup protocols: e.g. BSP */
6512787Ssam #define	AF_CHAOS	5		/* mit CHAOS protocols */
6612787Ssam #define	AF_NS		6		/* XEROX NS protocols */
6712787Ssam #define	AF_NBS		7		/* nbs protocols */
6812787Ssam #define	AF_ECMA		8		/* european computer manufacturers */
6912787Ssam #define	AF_DATAKIT	9		/* datakit protocols */
7012787Ssam #define	AF_CCITT	10		/* CCITT protocols, X.25 etc */
7112787Ssam #define	AF_SNA		11		/* IBM SNA */
724930Swnj 
7312787Ssam #define	AF_MAX		12
744930Swnj 
754930Swnj /*
7612787Ssam  * Structure used by kernel to store most
7712787Ssam  * addresses.
784930Swnj  */
794930Swnj struct sockaddr {
8012508Ssam 	u_short	sa_family;		/* address family */
814930Swnj 	char	sa_data[14];		/* up to 14 bytes of direct address */
824930Swnj };
834930Swnj 
844930Swnj /*
8512787Ssam  * Structure used by kernel to pass protocol
8612787Ssam  * information in raw sockets.
874930Swnj  */
8812787Ssam struct sockproto {
8912787Ssam 	u_short	sp_family;		/* address family */
9012787Ssam 	u_short	sp_protocol;		/* protocol */
9112787Ssam };
926620Ssam 
9312787Ssam /*
9412787Ssam  * Protocol families, same as address families for now.
9512787Ssam  */
9612787Ssam #define	PF_UNSPEC	AF_UNSPEC
9712787Ssam #define	PF_UNIX		AF_UNIX
9812787Ssam #define	PF_INET		AF_INET
9912787Ssam #define	PF_IMPLINK	AF_IMPLINK
10012787Ssam #define	PF_PUP		AF_PUP
10112787Ssam #define	PF_CHAOS	AF_CHAOS
10212787Ssam #define	PF_NS		AF_NS
10312787Ssam #define	PF_NBS		AF_NBS
10412787Ssam #define	PF_ECMA		AF_ECMA
10512787Ssam #define	PF_DATAKIT	AF_DATAKIT
10612787Ssam #define	PF_CCITT	AF_CCITT
10712787Ssam #define	PF_SNA		AF_SNA
1088274Sroot 
10912787Ssam #define	PF_MAX		12
11012787Ssam 
11112787Ssam /*
11212787Ssam  * Maximum queue length specifiable by listen.
11312787Ssam  */
11412787Ssam #define	SOMAXCONN	5
11512787Ssam 
11612787Ssam /*
11712787Ssam  * Message header for recvmsg and sendmsg calls.
11812787Ssam  */
11912787Ssam struct msghdr {
12012787Ssam 	caddr_t	msg_name;		/* optional address */
12112787Ssam 	int	msg_namelen;		/* size of address */
12212787Ssam 	struct	iovec *msg_iov;		/* scatter/gather array */
12312787Ssam 	int	msg_iovlen;		/* # elements in msg_iov */
12412787Ssam 	caddr_t	msg_accrights;		/* access rights sent/received */
12512787Ssam 	int	msg_accrightslen;
12612787Ssam };
12712787Ssam 
12812787Ssam #define	MSG_OOB		0x1		/* process out-of-band data */
12912787Ssam #define	MSG_PEEK	0x2		/* peek at incoming message */
13012787Ssam #define	MSG_DONTROUTE	0x4		/* send without using routing tables */
13112787Ssam 
13212787Ssam #define	MSG_MAXIOVLEN	16
133