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