xref: /titanic_50/usr/src/lib/libbc/inc/include/sys/socket.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
7*7c478bd9Sstevel@tonic-gate 
8*7c478bd9Sstevel@tonic-gate /*
9*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1982, 1985, 1986 Regents of the University of California.
10*7c478bd9Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
11*7c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
12*7c478bd9Sstevel@tonic-gate  */
13*7c478bd9Sstevel@tonic-gate 
14*7c478bd9Sstevel@tonic-gate #ifndef _sys_socket_h
15*7c478bd9Sstevel@tonic-gate #define _sys_socket_h
16*7c478bd9Sstevel@tonic-gate 
17*7c478bd9Sstevel@tonic-gate /*
18*7c478bd9Sstevel@tonic-gate  * Definitions related to sockets: types, address families, options.
19*7c478bd9Sstevel@tonic-gate  */
20*7c478bd9Sstevel@tonic-gate 
21*7c478bd9Sstevel@tonic-gate /*
22*7c478bd9Sstevel@tonic-gate  * Types
23*7c478bd9Sstevel@tonic-gate  */
24*7c478bd9Sstevel@tonic-gate #define	SOCK_STREAM	1		/* stream socket */
25*7c478bd9Sstevel@tonic-gate #define	SOCK_DGRAM	2		/* datagram socket */
26*7c478bd9Sstevel@tonic-gate #define	SOCK_RAW	3		/* raw-protocol interface */
27*7c478bd9Sstevel@tonic-gate #define	SOCK_RDM	4		/* reliably-delivered message */
28*7c478bd9Sstevel@tonic-gate #define	SOCK_SEQPACKET	5		/* sequenced packet stream */
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * Option flags per-socket.
32*7c478bd9Sstevel@tonic-gate  */
33*7c478bd9Sstevel@tonic-gate #define	SO_DEBUG	0x0001		/* turn on debugging info recording */
34*7c478bd9Sstevel@tonic-gate #define	SO_ACCEPTCONN	0x0002		/* socket has had listen() */
35*7c478bd9Sstevel@tonic-gate #define	SO_REUSEADDR	0x0004		/* allow local address reuse */
36*7c478bd9Sstevel@tonic-gate #define	SO_KEEPALIVE	0x0008		/* keep connections alive */
37*7c478bd9Sstevel@tonic-gate #define	SO_DONTROUTE	0x0010		/* just use interface addresses */
38*7c478bd9Sstevel@tonic-gate #define	SO_BROADCAST	0x0020		/* permit sending of broadcast msgs */
39*7c478bd9Sstevel@tonic-gate #define	SO_USELOOPBACK	0x0040		/* bypass hardware when possible */
40*7c478bd9Sstevel@tonic-gate #define	SO_LINGER	0x0080		/* linger on close if data present */
41*7c478bd9Sstevel@tonic-gate #define	SO_OOBINLINE	0x0100		/* leave received OOB data in line */
42*7c478bd9Sstevel@tonic-gate /*
43*7c478bd9Sstevel@tonic-gate  * N.B.: The following definition is present only for compatibility
44*7c478bd9Sstevel@tonic-gate  * with release 3.0.  It will disappear in later releases.
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate #define	SO_DONTLINGER	(~SO_LINGER)	/* ~SO_LINGER */
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate /*
49*7c478bd9Sstevel@tonic-gate  * Additional options, not kept in so_options.
50*7c478bd9Sstevel@tonic-gate  */
51*7c478bd9Sstevel@tonic-gate #define	SO_SNDBUF	0x1001		/* send buffer size */
52*7c478bd9Sstevel@tonic-gate #define	SO_RCVBUF	0x1002		/* receive buffer size */
53*7c478bd9Sstevel@tonic-gate #define	SO_SNDLOWAT	0x1003		/* send low-water mark */
54*7c478bd9Sstevel@tonic-gate #define	SO_RCVLOWAT	0x1004		/* receive low-water mark */
55*7c478bd9Sstevel@tonic-gate #define	SO_SNDTIMEO	0x1005		/* send timeout */
56*7c478bd9Sstevel@tonic-gate #define	SO_RCVTIMEO	0x1006		/* receive timeout */
57*7c478bd9Sstevel@tonic-gate #define	SO_ERROR	0x1007		/* get error status and clear */
58*7c478bd9Sstevel@tonic-gate #define	SO_TYPE		0x1008		/* get socket type */
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate /*
61*7c478bd9Sstevel@tonic-gate  * Structure used for manipulating linger option.
62*7c478bd9Sstevel@tonic-gate  */
63*7c478bd9Sstevel@tonic-gate struct	linger {
64*7c478bd9Sstevel@tonic-gate 	int	l_onoff;		/* option on/off */
65*7c478bd9Sstevel@tonic-gate 	int	l_linger;		/* linger time */
66*7c478bd9Sstevel@tonic-gate };
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate /*
69*7c478bd9Sstevel@tonic-gate  * Level number for (get/set)sockopt() to apply to socket itself.
70*7c478bd9Sstevel@tonic-gate  */
71*7c478bd9Sstevel@tonic-gate #define	SOL_SOCKET	0xffff		/* options for socket level */
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate /*
74*7c478bd9Sstevel@tonic-gate  * Address families.
75*7c478bd9Sstevel@tonic-gate  */
76*7c478bd9Sstevel@tonic-gate #define	AF_UNSPEC	0		/* unspecified */
77*7c478bd9Sstevel@tonic-gate #define	AF_UNIX		1		/* local to host (pipes, portals) */
78*7c478bd9Sstevel@tonic-gate #define	AF_INET		2		/* internetwork: UDP, TCP, etc. */
79*7c478bd9Sstevel@tonic-gate #define	AF_IMPLINK	3		/* arpanet imp addresses */
80*7c478bd9Sstevel@tonic-gate #define	AF_PUP		4		/* pup protocols: e.g. BSP */
81*7c478bd9Sstevel@tonic-gate #define	AF_CHAOS	5		/* mit CHAOS protocols */
82*7c478bd9Sstevel@tonic-gate #define	AF_NS		6		/* XEROX NS protocols */
83*7c478bd9Sstevel@tonic-gate #define	AF_NBS		7		/* nbs protocols */
84*7c478bd9Sstevel@tonic-gate #define	AF_ECMA		8		/* european computer manufacturers */
85*7c478bd9Sstevel@tonic-gate #define	AF_DATAKIT	9		/* datakit protocols */
86*7c478bd9Sstevel@tonic-gate #define	AF_CCITT	10		/* CCITT protocols, X.25 etc */
87*7c478bd9Sstevel@tonic-gate #define	AF_SNA		11		/* IBM SNA */
88*7c478bd9Sstevel@tonic-gate #define	AF_DECnet	12		/* DECnet */
89*7c478bd9Sstevel@tonic-gate #define	AF_DLI		13		/* Direct data link interface */
90*7c478bd9Sstevel@tonic-gate #define	AF_LAT		14		/* LAT */
91*7c478bd9Sstevel@tonic-gate #define	AF_HYLINK	15		/* NSC Hyperchannel */
92*7c478bd9Sstevel@tonic-gate #define	AF_APPLETALK	16		/* Apple Talk */
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate #define	AF_NIT		17		/* Network Interface Tap */
95*7c478bd9Sstevel@tonic-gate #define	AF_802		18		/* IEEE 802.2, also ISO 8802 */
96*7c478bd9Sstevel@tonic-gate #define	AF_OSI		19		/* umbrella for all families used
97*7c478bd9Sstevel@tonic-gate 					 * by OSI (e.g. protosw lookup) */
98*7c478bd9Sstevel@tonic-gate #define	AF_X25		20		/* CCITT X.25 in particular */
99*7c478bd9Sstevel@tonic-gate #define	AF_OSINET	21		/* AFI = 47, IDI = 4 */
100*7c478bd9Sstevel@tonic-gate #define	AF_GOSIP	22		/* U.S. Government OSI */
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate #define	AF_MAX		21
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate /*
105*7c478bd9Sstevel@tonic-gate  * Structure used by kernel to store most
106*7c478bd9Sstevel@tonic-gate  * addresses.
107*7c478bd9Sstevel@tonic-gate  */
108*7c478bd9Sstevel@tonic-gate struct sockaddr {
109*7c478bd9Sstevel@tonic-gate 	u_short	sa_family;		/* address family */
110*7c478bd9Sstevel@tonic-gate 	char	sa_data[14];		/* up to 14 bytes of direct address */
111*7c478bd9Sstevel@tonic-gate };
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate /*
114*7c478bd9Sstevel@tonic-gate  * Structure used by kernel to pass protocol
115*7c478bd9Sstevel@tonic-gate  * information in raw sockets.
116*7c478bd9Sstevel@tonic-gate  */
117*7c478bd9Sstevel@tonic-gate struct sockproto {
118*7c478bd9Sstevel@tonic-gate 	u_short	sp_family;		/* address family */
119*7c478bd9Sstevel@tonic-gate 	u_short	sp_protocol;		/* protocol */
120*7c478bd9Sstevel@tonic-gate };
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate /*
123*7c478bd9Sstevel@tonic-gate  * Protocol families, same as address families for now.
124*7c478bd9Sstevel@tonic-gate  */
125*7c478bd9Sstevel@tonic-gate #define	PF_UNSPEC	AF_UNSPEC
126*7c478bd9Sstevel@tonic-gate #define	PF_UNIX		AF_UNIX
127*7c478bd9Sstevel@tonic-gate #define	PF_INET		AF_INET
128*7c478bd9Sstevel@tonic-gate #define	PF_IMPLINK	AF_IMPLINK
129*7c478bd9Sstevel@tonic-gate #define	PF_PUP		AF_PUP
130*7c478bd9Sstevel@tonic-gate #define	PF_CHAOS	AF_CHAOS
131*7c478bd9Sstevel@tonic-gate #define	PF_NS		AF_NS
132*7c478bd9Sstevel@tonic-gate #define	PF_NBS		AF_NBS
133*7c478bd9Sstevel@tonic-gate #define	PF_ECMA		AF_ECMA
134*7c478bd9Sstevel@tonic-gate #define	PF_DATAKIT	AF_DATAKIT
135*7c478bd9Sstevel@tonic-gate #define	PF_CCITT	AF_CCITT
136*7c478bd9Sstevel@tonic-gate #define	PF_SNA		AF_SNA
137*7c478bd9Sstevel@tonic-gate #define	PF_DECnet	AF_DECnet
138*7c478bd9Sstevel@tonic-gate #define	PF_DLI		AF_DLI
139*7c478bd9Sstevel@tonic-gate #define	PF_LAT		AF_LAT
140*7c478bd9Sstevel@tonic-gate #define	PF_HYLINK	AF_HYLINK
141*7c478bd9Sstevel@tonic-gate #define	PF_APPLETALK	AF_APPLETALK
142*7c478bd9Sstevel@tonic-gate #define	PF_NIT		AF_NIT
143*7c478bd9Sstevel@tonic-gate #define	PF_802		AF_802
144*7c478bd9Sstevel@tonic-gate #define	PF_OSI		AF_OSI
145*7c478bd9Sstevel@tonic-gate #define	PF_X25		AF_X25
146*7c478bd9Sstevel@tonic-gate #define	PF_OSINET	AF_OSINET
147*7c478bd9Sstevel@tonic-gate #define	PF_GOSIP	AF_GOSIP
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate #define	PF_MAX		AF_MAX
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate /*
152*7c478bd9Sstevel@tonic-gate  * Maximum queue length specifiable by listen.
153*7c478bd9Sstevel@tonic-gate  */
154*7c478bd9Sstevel@tonic-gate #define	SOMAXCONN	5
155*7c478bd9Sstevel@tonic-gate 
156*7c478bd9Sstevel@tonic-gate /*
157*7c478bd9Sstevel@tonic-gate  * Message header for recvmsg and sendmsg calls.
158*7c478bd9Sstevel@tonic-gate  */
159*7c478bd9Sstevel@tonic-gate struct msghdr {
160*7c478bd9Sstevel@tonic-gate 	caddr_t	msg_name;		/* optional address */
161*7c478bd9Sstevel@tonic-gate 	int	msg_namelen;		/* size of address */
162*7c478bd9Sstevel@tonic-gate 	struct	iovec *msg_iov;		/* scatter/gather array */
163*7c478bd9Sstevel@tonic-gate 	int	msg_iovlen;		/* # elements in msg_iov */
164*7c478bd9Sstevel@tonic-gate 	caddr_t	msg_accrights;		/* access rights sent/received */
165*7c478bd9Sstevel@tonic-gate 	int	msg_accrightslen;
166*7c478bd9Sstevel@tonic-gate };
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate #define	MSG_OOB		0x1		/* process out-of-band data */
169*7c478bd9Sstevel@tonic-gate #define	MSG_PEEK	0x2		/* peek at incoming message */
170*7c478bd9Sstevel@tonic-gate #define	MSG_DONTROUTE	0x4		/* send without using routing tables */
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate #define	MSG_MAXIOVLEN	16
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate #endif /*!_sys_socket_h*/
175