xref: /illumos-gate/usr/src/uts/common/sys/socket.h (revision b494511a9cf72b1fc4eb13a0e593f55c624ab829)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
26 /*	  All Rights Reserved	*/
27 
28 /*
29  * University Copyright- Copyright (c) 1982, 1986, 1988
30  * The Regents of the University of California
31  * All Rights Reserved
32  *
33  * University Acknowledgment- Portions of this document are derived from
34  * software developed by the University of California, Berkeley, and its
35  * contributors.
36  */
37 
38 #ifndef	_SYS_SOCKET_H
39 #define	_SYS_SOCKET_H
40 
41 #include <sys/types.h>
42 #include <sys/uio.h>
43 #include <sys/feature_tests.h>
44 #include <sys/socket_impl.h>
45 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
46 #ifndef	_KERNEL
47 #include <sys/netconfig.h>
48 #endif	/* !_KERNEL */
49 #include <netinet/in.h>
50 #endif	/* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
51 
52 #ifdef	__cplusplus
53 extern "C" {
54 #endif
55 
56 #ifndef	_SOCKLEN_T
57 #define	_SOCKLEN_T
58 
59 /*
60  * The socklen definitions are reproduced in netinet/in.h for the inet6_
61  * functions.  Exposing all of sys/socket.h via netinet/in.h breaks existing
62  * applications and is not required by austin.
63  */
64 #if defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64)
65 typedef	size_t		socklen_t;
66 #else
67 typedef	uint32_t	socklen_t;
68 #endif	/* defined(_XPG4_2) && !defined(_XPG5) && !defined(_LP64) */
69 
70 #if defined(_XPG4_2) || defined(_BOOT)
71 typedef	socklen_t	*_RESTRICT_KYWD Psocklen_t;
72 #else
73 typedef	void		*_RESTRICT_KYWD Psocklen_t;
74 #endif	/* defined(_XPG4_2) || defined(_BOOT) */
75 
76 #endif	/* _SOCKLEN_T */
77 
78 /*
79  * Definitions related to sockets: types, address families, options.
80  */
81 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
82 #ifndef	NC_TPI_CLTS
83 #define	NC_TPI_CLTS	1		/* must agree with netconfig.h */
84 #define	NC_TPI_COTS	2		/* must agree with netconfig.h */
85 #define	NC_TPI_COTS_ORD	3		/* must agree with netconfig.h */
86 #define	NC_TPI_RAW	4		/* must agree with netconfig.h */
87 #endif	/* !NC_TPI_CLTS */
88 #endif	/* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
89 
90 /*
91  * Types
92  */
93 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
94 #define	SOCK_STREAM	NC_TPI_COTS	/* stream socket */
95 #define	SOCK_DGRAM	NC_TPI_CLTS	/* datagram socket */
96 #define	SOCK_RAW	NC_TPI_RAW	/* raw-protocol interface */
97 #else
98 #define	SOCK_STREAM	2		/* stream socket */
99 #define	SOCK_DGRAM	1		/* datagram socket */
100 #define	SOCK_RAW	4		/* raw-protocol interface */
101 #endif	/* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
102 #define	SOCK_RDM	5		/* reliably-delivered message */
103 #define	SOCK_SEQPACKET	6		/* sequenced packet stream */
104 
105 /*
106  * Option flags per-socket.
107  */
108 #define	SO_DEBUG	0x0001		/* turn on debugging info recording */
109 #define	SO_ACCEPTCONN	0x0002		/* socket has had listen() */
110 #define	SO_REUSEADDR	0x0004		/* allow local address reuse */
111 #define	SO_KEEPALIVE	0x0008		/* keep connections alive */
112 #define	SO_DONTROUTE	0x0010		/* just use interface addresses */
113 #define	SO_BROADCAST	0x0020		/* permit sending of broadcast msgs */
114 #define	SO_USELOOPBACK	0x0040		/* bypass hardware when possible */
115 #define	SO_LINGER	0x0080		/* linger on close if data present */
116 #define	SO_OOBINLINE	0x0100		/* leave received OOB data in line */
117 #define	SO_DGRAM_ERRIND	0x0200		/* Application wants delayed error */
118 #define	SO_RECVUCRED	0x0400		/* Application wants ucred of sender */
119 
120 /*
121  * Socket options are passed using a signed integer, but it is also rare
122  * for more than one to ever be passed at the same time with setsockopt
123  * and only one at a time can be retrieved with getsockopt.
124  *
125  * Since the lower numbers cannot be renumbered for compatibility reasons,
126  * it would seem that we need to start a new number space (0x40000000 -
127  * 0x7fffffff) for those that don't need to be stored as a bit flag
128  * somewhere. This limits the flag options to 30 but that seems to be
129  * plenty, anyway. 0x40000000 is reserved for future use.
130  */
131 #define	SO_ATTACH_FILTER	0x40000001
132 #define	SO_DETACH_FILTER	0x40000002
133 
134 #ifdef _KERNEL
135 #define	SO_SND_COPYAVOID 0x0800		/* Internal: use zero-copy */
136 #define	SO_SND_BUFINFO	0x1000		/* Internal: get buffer info */
137 					/* when doing zero-copy */
138 
139 struct so_snd_bufinfo {
140 	ushort_t	sbi_wroff; 	/* Write offset */
141 	ssize_t		sbi_maxblk;	/* Max size of a single mblk */
142 	ssize_t		sbi_maxpsz;	/* Max total size of a mblk chain */
143 	ushort_t	sbi_tail;	/* Extra space available at the end */
144 };
145 #endif /* _KERNEL */
146 
147 /*
148  * N.B.: The following definition is present only for compatibility
149  * with release 3.0.  It will disappear in later releases.
150  */
151 #define	SO_DONTLINGER	(~SO_LINGER)	/* ~SO_LINGER */
152 
153 /*
154  * Additional options, not kept in so_options.
155  */
156 #define	SO_SNDBUF	0x1001		/* send buffer size */
157 #define	SO_RCVBUF	0x1002		/* receive buffer size */
158 #define	SO_SNDLOWAT	0x1003		/* send low-water mark */
159 #define	SO_RCVLOWAT	0x1004		/* receive low-water mark */
160 #define	SO_SNDTIMEO	0x1005		/* send timeout */
161 #define	SO_RCVTIMEO	0x1006		/* receive timeout */
162 #define	SO_ERROR	0x1007		/* get error status and clear */
163 #define	SO_TYPE		0x1008		/* get socket type */
164 #define	SO_PROTOTYPE	0x1009		/* get/set protocol type */
165 #define	SO_ANON_MLP	0x100a		/* create MLP on anonymous bind */
166 #define	SO_MAC_EXEMPT	0x100b		/* allow dominated unlabeled peers */
167 #define	SO_DOMAIN	0x100c		/* get socket domain */
168 #define	SO_RCVPSH	0x100d		/* receive interval to push data */
169 
170 /* "Socket"-level control message types: */
171 #define	SCM_RIGHTS	0x1010		/* access rights (array of int) */
172 #define	SO_SECATTR	0x1011		/* socket's security attributes */
173 #define	SCM_UCRED	0x1012		/* sender's ucred */
174 #define	SO_TIMESTAMP	0x1013		/* socket-level timestamp option */
175 #define	SCM_TIMESTAMP	SO_TIMESTAMP	/* socket control message timestamp */
176 #define	SO_ALLZONES	0x1014		/* bind in all zones */
177 #define	SO_EXCLBIND	0x1015		/* exclusive binding */
178 #define	SO_MAC_IMPLICIT	0x1016		/* hide mac labels on wire */
179 #define	SO_VRRP		0x1017		/* VRRP control socket */
180 
181 #ifdef	_KERNEL
182 #define	SO_SRCADDR	0x2001		/* Internal: AF_UNIX source address */
183 #define	SO_FILEP	0x2002		/* Internal: AF_UNIX file pointer */
184 #define	SO_UNIX_CLOSE	0x2003		/* Internal: AF_UNIX peer closed */
185 #endif	/* _KERNEL */
186 
187 /*
188  * Socket filter options
189  */
190 #define	FIL_ATTACH	0x1		/* attach filter */
191 #define	FIL_DETACH	0x2		/* detach filter */
192 #define	FIL_LIST	0x3		/* list attached filters */
193 
194 #define	FILNAME_MAX	32
195 /*
196  * Structure returned by FIL_LIST
197  */
198 struct fil_info {
199 	int	fi_flags;		/* see below (FILF_*) */
200 	int	fi_pos;			/* position (0 is bottom) */
201 	char	fi_name[FILNAME_MAX];	/* filter name */
202 };
203 
204 #define	FILF_PROG	0x1		/* programmatic attach */
205 #define	FILF_AUTO	0x2		/* automatic attach */
206 #define	FILF_BYPASS	0x4		/* filter is not active */
207 
208 #ifdef	_KERNEL
209 /*
210  * new socket open flags to identify socket and acceptor streams
211  */
212 #define	SO_ACCEPTOR	0x20000		/* acceptor socket */
213 #define	SO_SOCKSTR	0x40000		/* normal socket stream */
214 #define	SO_FALLBACK	0x80000		/* fallback to TPI socket */
215 
216 /*
217  * Flags for socket_create() and socket_newconn()
218  */
219 #define	SOCKET_SLEEP	KM_SLEEP
220 #define	SOCKET_NOSLEEP	KM_NOSLEEP
221 
222 #endif	/* _KERNEL */
223 
224 /*
225  * Structure used for manipulating linger option.
226  */
227 struct	linger {
228 	int	l_onoff;		/* option on/off */
229 	int	l_linger;		/* linger time */
230 };
231 
232 /*
233  * Levels for (get/set)sockopt() that don't apply to a specific protocol.
234  */
235 #define	SOL_SOCKET	0xffff		/* options for socket level */
236 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
237 #define	SOL_ROUTE	0xfffe		/* options for routing socket level */
238 #endif
239 #define	SOL_PACKET	0xfffd		/* options for packet level */
240 #define	SOL_FILTER	0xfffc		/* options for socket filter level */
241 
242 /*
243  * Address families.
244  *
245  * Some of these constant names are copied for the DTrace IP provider in
246  * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept
247  * in sync.
248  */
249 #define	AF_UNSPEC	0		/* unspecified */
250 #define	AF_UNIX		1		/* local to host (pipes, portals) */
251 #define	AF_LOCAL	AF_UNIX		/* Synonym for AF_UNIX */
252 #define	AF_FILE		AF_UNIX		/* Synonym for AF_UNIX */
253 #define	AF_INET		2		/* internetwork: UDP, TCP, etc. */
254 #define	AF_IMPLINK	3		/* arpanet imp addresses */
255 #define	AF_PUP		4		/* pup protocols: e.g. BSP */
256 #define	AF_CHAOS	5		/* mit CHAOS protocols */
257 #define	AF_NS		6		/* XEROX NS protocols */
258 #define	AF_NBS		7		/* nbs protocols */
259 #define	AF_ECMA		8		/* european computer manufacturers */
260 #define	AF_DATAKIT	9		/* datakit protocols */
261 #define	AF_CCITT	10		/* CCITT protocols, X.25 etc */
262 #define	AF_SNA		11		/* IBM SNA */
263 #define	AF_DECnet	12		/* DECnet */
264 #define	AF_DLI		13		/* Direct data link interface */
265 #define	AF_LAT		14		/* LAT */
266 #define	AF_HYLINK	15		/* NSC Hyperchannel */
267 #define	AF_APPLETALK	16		/* Apple Talk */
268 #define	AF_NIT		17		/* Network Interface Tap */
269 #define	AF_802		18		/* IEEE 802.2, also ISO 8802 */
270 #define	AF_OSI		19		/* umbrella for all families used */
271 #define	AF_X25		20		/* CCITT X.25 in particular */
272 #define	AF_OSINET	21		/* AFI = 47, IDI = 4 */
273 #define	AF_GOSIP	22		/* U.S. Government OSI */
274 #define	AF_IPX		23		/* Novell Internet Protocol */
275 #define	AF_ROUTE	24		/* Internal Routing Protocol */
276 #define	AF_LINK		25		/* Link-layer interface */
277 #define	AF_INET6	26		/* Internet Protocol, Version 6 */
278 #define	AF_KEY		27		/* Security Association DB socket */
279 #define	AF_NCA		28		/* NCA socket */
280 #define	AF_POLICY	29		/* Security Policy DB socket */
281 #define	AF_INET_OFFLOAD	30		/* Sun private; do not use */
282 #define	AF_TRILL	31		/* TRILL interface */
283 #define	AF_PACKET	32		/* PF_PACKET Linux socket interface */
284 
285 #define	AF_MAX		32
286 
287 /*
288  * Protocol families, same as address families for now.
289  */
290 #define	PF_UNSPEC	AF_UNSPEC
291 #define	PF_UNIX		AF_UNIX
292 #define	PF_LOCAL	PF_UNIX
293 #define	PF_FILE		PF_UNIX
294 #define	PF_INET		AF_INET
295 #define	PF_IMPLINK	AF_IMPLINK
296 #define	PF_PUP		AF_PUP
297 #define	PF_CHAOS	AF_CHAOS
298 #define	PF_NS		AF_NS
299 #define	PF_NBS		AF_NBS
300 #define	PF_ECMA		AF_ECMA
301 #define	PF_DATAKIT	AF_DATAKIT
302 #define	PF_CCITT	AF_CCITT
303 #define	PF_SNA		AF_SNA
304 #define	PF_DECnet	AF_DECnet
305 #define	PF_DLI		AF_DLI
306 #define	PF_LAT		AF_LAT
307 #define	PF_HYLINK	AF_HYLINK
308 #define	PF_APPLETALK	AF_APPLETALK
309 #define	PF_NIT		AF_NIT
310 #define	PF_802		AF_802
311 #define	PF_OSI		AF_OSI
312 #define	PF_X25		AF_X25
313 #define	PF_OSINET	AF_OSINET
314 #define	PF_GOSIP	AF_GOSIP
315 #define	PF_IPX		AF_IPX
316 #define	PF_ROUTE	AF_ROUTE
317 #define	PF_LINK		AF_LINK
318 #define	PF_INET6	AF_INET6
319 #define	PF_KEY		AF_KEY
320 #define	PF_NCA		AF_NCA
321 #define	PF_POLICY	AF_POLICY
322 #define	PF_INET_OFFLOAD	AF_INET_OFFLOAD	/* Sun private; do not use */
323 #define	PF_TRILL	AF_TRILL
324 #define	PF_PACKET	AF_PACKET
325 
326 #define	PF_MAX		AF_MAX
327 
328 /*
329  * Maximum queue length specifiable by listen.
330  */
331 #define	SOMAXCONN	128
332 
333 /*
334  * Message header for recvmsg and sendmsg calls.
335  */
336 struct msghdr {
337 	void		*msg_name;		/* optional address */
338 	socklen_t	msg_namelen;		/* size of address */
339 	struct iovec	*msg_iov;		/* scatter/gather array */
340 	int		msg_iovlen;		/* # elements in msg_iov */
341 
342 #if defined(_XPG4_2) || defined(_KERNEL)
343 	void		*msg_control;		/* ancillary data */
344 	socklen_t	msg_controllen;		/* ancillary data buffer len */
345 	int		msg_flags;		/* flags on received message */
346 #else
347 	caddr_t		msg_accrights;	/* access rights sent/received */
348 	int		msg_accrightslen;
349 #endif	/* defined(_XPG4_2) || defined(_KERNEL) */
350 };
351 
352 #if	defined(_KERNEL)
353 
354 /*
355  *	N.B.:  we assume that omsghdr and nmsghdr are isomorphic, with
356  *	the sole exception that nmsghdr has the additional msg_flags
357  *	field at the end.
358  */
359 struct omsghdr {
360 	void		*msg_name;	/* optional address */
361 	socklen_t	msg_namelen;	/* size of address */
362 	struct	iovec	*msg_iov;	/* scatter/gather array */
363 	int		msg_iovlen;	/* # elements in msg_iov */
364 	caddr_t		msg_accrights;	/* access rights sent/received */
365 	int		msg_accrightslen;
366 };
367 
368 #define	nmsghdr		msghdr
369 
370 #if defined(_SYSCALL32)
371 
372 struct omsghdr32 {
373 	caddr32_t	msg_name;	/* optional address */
374 	uint32_t	msg_namelen;	/* size of address */
375 	caddr32_t	msg_iov;	/* scatter/gather array */
376 	int32_t		msg_iovlen;	/* # elements in msg_iov */
377 	caddr32_t	msg_accrights;	/* access rights sent/received */
378 	uint32_t	msg_accrightslen;
379 };
380 
381 struct msghdr32 {
382 	caddr32_t	msg_name;	/* optional address */
383 	uint32_t	msg_namelen;	/* size of address */
384 	caddr32_t	msg_iov;	/* scatter/gather array */
385 	int32_t		msg_iovlen;	/* # elements in msg_iov */
386 	caddr32_t	msg_control;	/* ancillary data */
387 	uint32_t	msg_controllen;	/* ancillary data buffer len */
388 	int32_t		msg_flags;	/* flags on received message */
389 };
390 
391 #define	nmsghdr32	msghdr32
392 
393 #endif	/* _SYSCALL32 */
394 #endif	/* _KERNEL */
395 
396 #define	MSG_OOB		0x1		/* process out-of-band data */
397 #define	MSG_PEEK	0x2		/* peek at incoming message */
398 #define	MSG_DONTROUTE	0x4		/* send without using routing tables */
399 /* Added for XPGv2 compliance */
400 #define	MSG_EOR		0x8		/* Terminates a record */
401 #define	MSG_CTRUNC	0x10		/* Control data truncated */
402 #define	MSG_TRUNC	0x20		/* Normal data truncated */
403 #define	MSG_WAITALL	0x40		/* Wait for complete recv or error */
404 #define	MSG_DUPCTRL	0x800		/* Save control message for use with */
405 					/* with left over data */
406 /* End of XPGv2 compliance */
407 #define	MSG_DONTWAIT	0x80		/* Don't block for this recv */
408 #define	MSG_NOTIFICATION 0x100		/* Notification, not data */
409 #define	MSG_XPG4_2	0x8000		/* Private: XPG4.2 flag */
410 
411 #define	MSG_MAXIOVLEN	16
412 
413 #ifdef _KERNEL
414 
415 /*
416  * for kernel socket only
417  */
418 #define	MSG_MBLK_QUICKRELE	0x10000000	/* free mblk chain */
419 						/* in timely manner */
420 #define	MSG_USERSPACE		0x20000000	/* buffer from user space */
421 
422 #endif /* _KERNEL */
423 
424 
425 /* Added for XPGv2 compliance */
426 #define	SHUT_RD		0
427 #define	SHUT_WR		1
428 #define	SHUT_RDWR	2
429 
430 struct cmsghdr {
431 	socklen_t	cmsg_len;	/* data byte count, including hdr */
432 	int		cmsg_level;	/* originating protocol */
433 	int		cmsg_type;	/* protocol-specific type */
434 };
435 
436 #if defined(_XPG4_2) || defined(_KERNEL)
437 #if defined(__sparc)
438 /* To maintain backward compatibility, alignment needs to be 8 on sparc. */
439 #define	_CMSG_HDR_ALIGNMENT	8
440 #else
441 /* for __i386 (and other future architectures) */
442 #define	_CMSG_HDR_ALIGNMENT	4
443 #endif	/* defined(__sparc) */
444 #endif	/* defined(_XPG4_2) || defined(_KERNEL) */
445 
446 #if defined(_XPG4_2)
447 /*
448  * The cmsg headers (and macros dealing with them) were made available as
449  * part of UNIX95 and hence need to be protected with a _XPG4_2 define.
450  */
451 #define	_CMSG_DATA_ALIGNMENT	(sizeof (int))
452 #define	_CMSG_HDR_ALIGN(x)	(((uintptr_t)(x) + _CMSG_HDR_ALIGNMENT - 1) & \
453 				    ~(_CMSG_HDR_ALIGNMENT - 1))
454 #define	_CMSG_DATA_ALIGN(x)	(((uintptr_t)(x) + _CMSG_DATA_ALIGNMENT - 1) & \
455 				    ~(_CMSG_DATA_ALIGNMENT - 1))
456 #define	CMSG_DATA(c)							\
457 	((unsigned char *)_CMSG_DATA_ALIGN((struct cmsghdr *)(c) + 1))
458 
459 #define	CMSG_FIRSTHDR(m)						\
460 	(((m)->msg_controllen < sizeof (struct cmsghdr)) ?		\
461 	    (struct cmsghdr *)0 : (struct cmsghdr *)((m)->msg_control))
462 
463 #define	CMSG_NXTHDR(m, c)						\
464 	(((c) == 0) ? CMSG_FIRSTHDR(m) :			\
465 	((((uintptr_t)_CMSG_HDR_ALIGN((char *)(c) +			\
466 	((struct cmsghdr *)(c))->cmsg_len) + sizeof (struct cmsghdr)) >	\
467 	(((uintptr_t)((struct msghdr *)(m))->msg_control) +		\
468 	((uintptr_t)((struct msghdr *)(m))->msg_controllen))) ?		\
469 	((struct cmsghdr *)0) :						\
470 	((struct cmsghdr *)_CMSG_HDR_ALIGN((char *)(c) +		\
471 	    ((struct cmsghdr *)(c))->cmsg_len))))
472 
473 /* Amount of space + padding needed for a message of length l */
474 #define	CMSG_SPACE(l)							\
475 	((unsigned int)_CMSG_HDR_ALIGN(sizeof (struct cmsghdr) + (l)))
476 
477 /* Value to be used in cmsg_len, does not include trailing padding */
478 #define	CMSG_LEN(l)							\
479 	((unsigned int)_CMSG_DATA_ALIGN(sizeof (struct cmsghdr)) + (l))
480 
481 #endif	/* _XPG4_2 */
482 
483 #ifdef	_XPG4_2
484 #ifdef	__PRAGMA_REDEFINE_EXTNAME
485 #pragma redefine_extname bind __xnet_bind
486 #pragma redefine_extname connect __xnet_connect
487 #pragma redefine_extname recvmsg __xnet_recvmsg
488 #pragma redefine_extname sendmsg __xnet_sendmsg
489 #pragma redefine_extname sendto __xnet_sendto
490 #pragma redefine_extname socket __xnet_socket
491 #pragma redefine_extname socketpair __xnet_socketpair
492 #pragma redefine_extname getsockopt __xnet_getsockopt
493 #else	/* __PRAGMA_REDEFINE_EXTNAME */
494 #define	bind	__xnet_bind
495 #define	connect	__xnet_connect
496 #define	recvmsg	__xnet_recvmsg
497 #define	sendmsg	__xnet_sendmsg
498 #define	sendto	__xnet_sendto
499 #define	socket	__xnet_socket
500 #define	socketpair	__xnet_socketpair
501 #define	getsockopt	__xnet_getsockopt
502 #endif	/* __PRAGMA_REDEFINE_EXTNAME */
503 
504 #endif	/* _XPG4_2 */
505 
506 #if defined(_XPG4_2) && !defined(_XPG5)
507 #ifdef	__PRAGMA_REDEFINE_EXTNAME
508 #pragma redefine_extname listen __xnet_listen
509 #else	/* __PRAGMA_REDEFINE_EXTNAME */
510 #define	listen	__xnet_listen
511 #endif	/* __PRAGMA_REDEFINE_EXTNAME */
512 #endif /* (_XPG4_2) && !defined(_XPG5) */
513 
514 #if !defined(_KERNEL) || defined(_BOOT)
515 #ifdef	__STDC__
516 extern int accept(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t);
517 extern int bind(int, const struct sockaddr *, socklen_t);
518 extern int connect(int, const struct sockaddr *, socklen_t);
519 extern int getpeername(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t);
520 extern int getsockname(int, struct sockaddr *_RESTRICT_KYWD, Psocklen_t);
521 extern int getsockopt(int, int, int, void *_RESTRICT_KYWD, Psocklen_t);
522 extern int listen(int, int);	/* XXX - fixme???  where do I go */
523 extern int socketpair(int, int, int, int *);
524 extern ssize_t recv(int, void *, size_t, int);
525 extern ssize_t recvfrom(int, void *_RESTRICT_KYWD, size_t, int,
526 	struct sockaddr *_RESTRICT_KYWD, Psocklen_t);
527 extern ssize_t recvmsg(int, struct msghdr *, int);
528 extern ssize_t send(int, const void *, size_t, int);
529 extern ssize_t sendmsg(int, const struct msghdr *, int);
530 extern ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *,
531 	socklen_t);
532 extern int setsockopt(int, int, int, const void *, socklen_t);
533 extern int shutdown(int, int);
534 extern int socket(int, int, int);
535 
536 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
537 extern int sockatmark(int);
538 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
539 #else	/* __STDC__ */
540 extern int accept();
541 extern int bind();
542 extern int connect();
543 extern int getpeername();
544 extern int getsockname();
545 extern int getsockopt();
546 extern int listen();
547 extern int recv();
548 extern int recvfrom();
549 extern int send();
550 extern int sendto();
551 extern int setsockopt();
552 extern int sockatmark();
553 extern int socket();
554 extern int recvmsg();
555 extern int sendmsg();
556 extern int shutdown();
557 extern int socketpair();
558 #endif	/* __STDC__ */
559 #endif	/* !defined(_KERNEL) || defined(_BOOT) */
560 
561 #ifdef	__cplusplus
562 }
563 #endif
564 
565 #endif	/* _SYS_SOCKET_H */
566