xref: /csrg-svn/sys/sys/socket.h (revision 12787)
1*12787Ssam /*	socket.h	4.27	83/05/27	*/
24658Swnj 
34658Swnj /*
4*12787Ssam  * Definitions related to sockets: types, address families, options.
54658Swnj  */
64892Swnj 
74892Swnj /*
8*12787Ssam  * Types
94892Swnj  */
104930Swnj #define	SOCK_STREAM	1		/* stream socket */
114930Swnj #define	SOCK_DGRAM	2		/* datagram socket */
124930Swnj #define	SOCK_RAW	3		/* raw-protocol interface */
134930Swnj #define	SOCK_RDM	4		/* reliably-delivered message */
14*12787Ssam #define	SOCK_SEQPACKET	5		/* sequenced packet stream */
154658Swnj 
164812Swnj /*
174812Swnj  * Option flags per-socket.
184812Swnj  */
194812Swnj #define	SO_DEBUG	0x01		/* turn on debugging info recording */
20*12787Ssam #define	SO_ACCEPTCONN	0x02		/* socket has had listen() */
21*12787Ssam #define	SO_REUSEADDR	0x04		/* allow local address reuse */
226215Swnj #define	SO_KEEPALIVE	0x08		/* keep connections alive */
237132Swnj #define	SO_DONTROUTE	0x10		/* just use interface addresses */
24*12787Ssam 				/* 0x20 was SO_NEWFDONCONN */
2510209Ssam #define	SO_USELOOPBACK	0x40		/* bypass hardware when possible */
2610597Ssam #define	SO_LINGER	0x80		/* linger on close if data present */
2710597Ssam #define	SO_DONTLINGER	(~SO_LINGER)	/* ~SO_LINGER */
284930Swnj 
294930Swnj /*
30*12787Ssam  * Address families.
314930Swnj  */
32*12787Ssam #define	AF_UNSPEC	0		/* unspecified */
33*12787Ssam #define	AF_UNIX		1		/* local to host (pipes, portals) */
34*12787Ssam #define	AF_INET		2		/* internetwork: UDP, TCP, etc. */
35*12787Ssam #define	AF_IMPLINK	3		/* arpanet imp addresses */
36*12787Ssam #define	AF_PUP		4		/* pup protocols: e.g. BSP */
37*12787Ssam #define	AF_CHAOS	5		/* mit CHAOS protocols */
38*12787Ssam #define	AF_NS		6		/* XEROX NS protocols */
39*12787Ssam #define	AF_NBS		7		/* nbs protocols */
40*12787Ssam #define	AF_ECMA		8		/* european computer manufacturers */
41*12787Ssam #define	AF_DATAKIT	9		/* datakit protocols */
42*12787Ssam #define	AF_CCITT	10		/* CCITT protocols, X.25 etc */
43*12787Ssam #define	AF_SNA		11		/* IBM SNA */
444930Swnj 
45*12787Ssam #define	AF_MAX		12
464930Swnj 
474930Swnj /*
48*12787Ssam  * Structure used by kernel to store most
49*12787Ssam  * addresses.
504930Swnj  */
514930Swnj struct sockaddr {
5212508Ssam 	u_short	sa_family;		/* address family */
534930Swnj 	char	sa_data[14];		/* up to 14 bytes of direct address */
544930Swnj };
554930Swnj 
564930Swnj /*
57*12787Ssam  * Structure used by kernel to pass protocol
58*12787Ssam  * information in raw sockets.
594930Swnj  */
60*12787Ssam struct sockproto {
61*12787Ssam 	u_short	sp_family;		/* address family */
62*12787Ssam 	u_short	sp_protocol;		/* protocol */
63*12787Ssam };
646620Ssam 
65*12787Ssam /*
66*12787Ssam  * Protocol families, same as address families for now.
67*12787Ssam  */
68*12787Ssam #define	PF_UNSPEC	AF_UNSPEC
69*12787Ssam #define	PF_UNIX		AF_UNIX
70*12787Ssam #define	PF_INET		AF_INET
71*12787Ssam #define	PF_IMPLINK	AF_IMPLINK
72*12787Ssam #define	PF_PUP		AF_PUP
73*12787Ssam #define	PF_CHAOS	AF_CHAOS
74*12787Ssam #define	PF_NS		AF_NS
75*12787Ssam #define	PF_NBS		AF_NBS
76*12787Ssam #define	PF_ECMA		AF_ECMA
77*12787Ssam #define	PF_DATAKIT	AF_DATAKIT
78*12787Ssam #define	PF_CCITT	AF_CCITT
79*12787Ssam #define	PF_SNA		AF_SNA
808274Sroot 
81*12787Ssam #define	PF_MAX		12
82*12787Ssam 
83*12787Ssam /*
84*12787Ssam  * Level number for (get/set)sockopt() to apply to socket itself.
85*12787Ssam  */
8610209Ssam #define	SOL_SOCKET	0xffff		/* options for socket level */
8710209Ssam 
88*12787Ssam /*
89*12787Ssam  * Maximum queue length specifiable by listen.
90*12787Ssam  */
91*12787Ssam #define	SOMAXCONN	5
92*12787Ssam 
93*12787Ssam /*
94*12787Ssam  * Message header for recvmsg and sendmsg calls.
95*12787Ssam  */
96*12787Ssam struct msghdr {
97*12787Ssam 	caddr_t	msg_name;		/* optional address */
98*12787Ssam 	int	msg_namelen;		/* size of address */
99*12787Ssam 	struct	iovec *msg_iov;		/* scatter/gather array */
100*12787Ssam 	int	msg_iovlen;		/* # elements in msg_iov */
101*12787Ssam 	caddr_t	msg_accrights;		/* access rights sent/received */
102*12787Ssam 	int	msg_accrightslen;
103*12787Ssam };
104*12787Ssam 
105*12787Ssam #define	MSG_OOB		0x1		/* process out-of-band data */
106*12787Ssam #define	MSG_PEEK	0x2		/* peek at incoming message */
107*12787Ssam #define	MSG_DONTROUTE	0x4		/* send without using routing tables */
108*12787Ssam 
109*12787Ssam #define	MSG_MAXIOVLEN	16
110