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 2014 Garrett D'Amore <garrett@damore.org>
23 *
24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 */
26
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29
30 /*
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
34 *
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
38 */
39
40 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
41
42 #ifndef _SYS_SOCKET_H
43 #define _SYS_SOCKET_H
44
45 #include <sys/types.h>
46 #include <sys/uio.h>
47 #include <sys/feature_tests.h>
48 #include <sys/socket_impl.h>
49 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
50 #ifndef _KERNEL
51 #include <sys/netconfig.h>
52 #endif /* !_KERNEL */
53 #include <netinet/in.h>
54 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60 #ifndef _SOCKLEN_T
61 #define _SOCKLEN_T
177 #define SO_ANON_MLP 0x100a /* create MLP on anonymous bind */
178 #define SO_MAC_EXEMPT 0x100b /* allow dominated unlabeled peers */
179 #define SO_DOMAIN 0x100c /* get socket domain */
180 #define SO_RCVPSH 0x100d /* receive interval to push data */
181
182 /* "Socket"-level control message types: */
183 #define SCM_RIGHTS 0x1010 /* access rights (array of int) */
184 #define SO_SECATTR 0x1011 /* socket's security attributes */
185 #define SCM_UCRED 0x1012 /* sender's ucred */
186 #define SO_TIMESTAMP 0x1013 /* socket-level timestamp option */
187 #define SCM_TIMESTAMP SO_TIMESTAMP /* socket control message timestamp */
188 #define SO_ALLZONES 0x1014 /* bind in all zones */
189 #define SO_EXCLBIND 0x1015 /* exclusive binding */
190 #define SO_MAC_IMPLICIT 0x1016 /* hide mac labels on wire */
191 #define SO_VRRP 0x1017 /* VRRP control socket */
192
193 #ifdef _KERNEL
194 #define SO_SRCADDR 0x2001 /* Internal: AF_UNIX source address */
195 #define SO_FILEP 0x2002 /* Internal: AF_UNIX file pointer */
196 #define SO_UNIX_CLOSE 0x2003 /* Internal: AF_UNIX peer closed */
197 #endif /* _KERNEL */
198
199 /*
200 * Socket filter options
201 */
202 #define FIL_ATTACH 0x1 /* attach filter */
203 #define FIL_DETACH 0x2 /* detach filter */
204 #define FIL_LIST 0x3 /* list attached filters */
205
206 #define FILNAME_MAX 32
207 /*
208 * Structure returned by FIL_LIST
209 */
210 struct fil_info {
211 int fi_flags; /* see below (FILF_*) */
212 int fi_pos; /* position (0 is bottom) */
213 char fi_name[FILNAME_MAX]; /* filter name */
214 };
215
216 #define FILF_PROG 0x1 /* programmatic attach */
276 #define AF_DLI 13 /* Direct data link interface */
277 #define AF_LAT 14 /* LAT */
278 #define AF_HYLINK 15 /* NSC Hyperchannel */
279 #define AF_APPLETALK 16 /* Apple Talk */
280 #define AF_NIT 17 /* Network Interface Tap */
281 #define AF_802 18 /* IEEE 802.2, also ISO 8802 */
282 #define AF_OSI 19 /* umbrella for all families used */
283 #define AF_X25 20 /* CCITT X.25 in particular */
284 #define AF_OSINET 21 /* AFI = 47, IDI = 4 */
285 #define AF_GOSIP 22 /* U.S. Government OSI */
286 #define AF_IPX 23 /* Novell Internet Protocol */
287 #define AF_ROUTE 24 /* Internal Routing Protocol */
288 #define AF_LINK 25 /* Link-layer interface */
289 #define AF_INET6 26 /* Internet Protocol, Version 6 */
290 #define AF_KEY 27 /* Security Association DB socket */
291 #define AF_NCA 28 /* NCA socket */
292 #define AF_POLICY 29 /* Security Policy DB socket */
293 #define AF_INET_OFFLOAD 30 /* Sun private; do not use */
294 #define AF_TRILL 31 /* TRILL interface */
295 #define AF_PACKET 32 /* PF_PACKET Linux socket interface */
296
297 #define AF_MAX 32
298
299 /*
300 * Protocol families, same as address families for now.
301 */
302 #define PF_UNSPEC AF_UNSPEC
303 #define PF_UNIX AF_UNIX
304 #define PF_LOCAL PF_UNIX
305 #define PF_FILE PF_UNIX
306 #define PF_INET AF_INET
307 #define PF_IMPLINK AF_IMPLINK
308 #define PF_PUP AF_PUP
309 #define PF_CHAOS AF_CHAOS
310 #define PF_NS AF_NS
311 #define PF_NBS AF_NBS
312 #define PF_ECMA AF_ECMA
313 #define PF_DATAKIT AF_DATAKIT
314 #define PF_CCITT AF_CCITT
315 #define PF_SNA AF_SNA
316 #define PF_DECnet AF_DECnet
317 #define PF_DLI AF_DLI
318 #define PF_LAT AF_LAT
319 #define PF_HYLINK AF_HYLINK
320 #define PF_APPLETALK AF_APPLETALK
321 #define PF_NIT AF_NIT
322 #define PF_802 AF_802
323 #define PF_OSI AF_OSI
324 #define PF_X25 AF_X25
325 #define PF_OSINET AF_OSINET
326 #define PF_GOSIP AF_GOSIP
327 #define PF_IPX AF_IPX
328 #define PF_ROUTE AF_ROUTE
329 #define PF_LINK AF_LINK
330 #define PF_INET6 AF_INET6
331 #define PF_KEY AF_KEY
332 #define PF_NCA AF_NCA
333 #define PF_POLICY AF_POLICY
334 #define PF_INET_OFFLOAD AF_INET_OFFLOAD /* Sun private; do not use */
335 #define PF_TRILL AF_TRILL
336 #define PF_PACKET AF_PACKET
337
338 #define PF_MAX AF_MAX
339
340 /*
341 * Maximum queue length specifiable by listen.
342 */
343 #define SOMAXCONN 128
344
345 /*
346 * Message header for recvmsg and sendmsg calls.
347 */
348 struct msghdr {
349 void *msg_name; /* optional address */
350 socklen_t msg_namelen; /* size of address */
351 struct iovec *msg_iov; /* scatter/gather array */
352 int msg_iovlen; /* # elements in msg_iov */
353
354 #if defined(_XPG4_2) || defined(_KERNEL)
355 void *msg_control; /* ancillary data */
356 socklen_t msg_controllen; /* ancillary data buffer len */
403 #define nmsghdr32 msghdr32
404
405 #endif /* _SYSCALL32 */
406 #endif /* _KERNEL */
407
408 #define MSG_OOB 0x1 /* process out-of-band data */
409 #define MSG_PEEK 0x2 /* peek at incoming message */
410 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
411 /* Added for XPGv2 compliance */
412 #define MSG_EOR 0x8 /* Terminates a record */
413 #define MSG_CTRUNC 0x10 /* Control data truncated */
414 #define MSG_TRUNC 0x20 /* Normal data truncated */
415 #define MSG_WAITALL 0x40 /* Wait for complete recv or error */
416 #define MSG_DUPCTRL 0x800 /* Save control message for use with */
417 /* with left over data */
418 /* End of XPGv2 compliance */
419 #define MSG_DONTWAIT 0x80 /* Don't block for this recv */
420 #define MSG_NOTIFICATION 0x100 /* Notification, not data */
421 #define MSG_XPG4_2 0x8000 /* Private: XPG4.2 flag */
422
423 #define MSG_MAXIOVLEN 16
424
425 #ifdef _KERNEL
426
427 /*
428 * for kernel socket only
429 */
430 #define MSG_MBLK_QUICKRELE 0x10000000 /* free mblk chain */
431 /* in timely manner */
432 #define MSG_USERSPACE 0x20000000 /* buffer from user space */
433
434 #endif /* _KERNEL */
435
436
437 /* Added for XPGv2 compliance */
438 #define SHUT_RD 0
439 #define SHUT_WR 1
440 #define SHUT_RDWR 2
441
442 struct cmsghdr {
|
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 2014 Garrett D'Amore <garrett@damore.org>
23 *
24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright 2015, Joyent, Inc. All rights reserved.
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 /*
44 * Copyright (c) 2014, Joyent, Inc. All rights reserved.
45 */
46 #ifndef _SYS_SOCKET_H
47 #define _SYS_SOCKET_H
48
49 #include <sys/types.h>
50 #include <sys/uio.h>
51 #include <sys/feature_tests.h>
52 #include <sys/socket_impl.h>
53 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
54 #ifndef _KERNEL
55 #include <sys/netconfig.h>
56 #endif /* !_KERNEL */
57 #include <netinet/in.h>
58 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64 #ifndef _SOCKLEN_T
65 #define _SOCKLEN_T
181 #define SO_ANON_MLP 0x100a /* create MLP on anonymous bind */
182 #define SO_MAC_EXEMPT 0x100b /* allow dominated unlabeled peers */
183 #define SO_DOMAIN 0x100c /* get socket domain */
184 #define SO_RCVPSH 0x100d /* receive interval to push data */
185
186 /* "Socket"-level control message types: */
187 #define SCM_RIGHTS 0x1010 /* access rights (array of int) */
188 #define SO_SECATTR 0x1011 /* socket's security attributes */
189 #define SCM_UCRED 0x1012 /* sender's ucred */
190 #define SO_TIMESTAMP 0x1013 /* socket-level timestamp option */
191 #define SCM_TIMESTAMP SO_TIMESTAMP /* socket control message timestamp */
192 #define SO_ALLZONES 0x1014 /* bind in all zones */
193 #define SO_EXCLBIND 0x1015 /* exclusive binding */
194 #define SO_MAC_IMPLICIT 0x1016 /* hide mac labels on wire */
195 #define SO_VRRP 0x1017 /* VRRP control socket */
196
197 #ifdef _KERNEL
198 #define SO_SRCADDR 0x2001 /* Internal: AF_UNIX source address */
199 #define SO_FILEP 0x2002 /* Internal: AF_UNIX file pointer */
200 #define SO_UNIX_CLOSE 0x2003 /* Internal: AF_UNIX peer closed */
201 #define SO_REUSEPORT 0x2004 /* allow simultaneous port reuse */
202 #endif /* _KERNEL */
203
204 /*
205 * Socket filter options
206 */
207 #define FIL_ATTACH 0x1 /* attach filter */
208 #define FIL_DETACH 0x2 /* detach filter */
209 #define FIL_LIST 0x3 /* list attached filters */
210
211 #define FILNAME_MAX 32
212 /*
213 * Structure returned by FIL_LIST
214 */
215 struct fil_info {
216 int fi_flags; /* see below (FILF_*) */
217 int fi_pos; /* position (0 is bottom) */
218 char fi_name[FILNAME_MAX]; /* filter name */
219 };
220
221 #define FILF_PROG 0x1 /* programmatic attach */
281 #define AF_DLI 13 /* Direct data link interface */
282 #define AF_LAT 14 /* LAT */
283 #define AF_HYLINK 15 /* NSC Hyperchannel */
284 #define AF_APPLETALK 16 /* Apple Talk */
285 #define AF_NIT 17 /* Network Interface Tap */
286 #define AF_802 18 /* IEEE 802.2, also ISO 8802 */
287 #define AF_OSI 19 /* umbrella for all families used */
288 #define AF_X25 20 /* CCITT X.25 in particular */
289 #define AF_OSINET 21 /* AFI = 47, IDI = 4 */
290 #define AF_GOSIP 22 /* U.S. Government OSI */
291 #define AF_IPX 23 /* Novell Internet Protocol */
292 #define AF_ROUTE 24 /* Internal Routing Protocol */
293 #define AF_LINK 25 /* Link-layer interface */
294 #define AF_INET6 26 /* Internet Protocol, Version 6 */
295 #define AF_KEY 27 /* Security Association DB socket */
296 #define AF_NCA 28 /* NCA socket */
297 #define AF_POLICY 29 /* Security Policy DB socket */
298 #define AF_INET_OFFLOAD 30 /* Sun private; do not use */
299 #define AF_TRILL 31 /* TRILL interface */
300 #define AF_PACKET 32 /* PF_PACKET Linux socket interface */
301 #define AF_LX_NETLINK 33 /* Linux-compatible netlink */
302
303 #define AF_MAX 33
304
305 /*
306 * Protocol families, same as address families for now.
307 */
308 #define PF_UNSPEC AF_UNSPEC
309 #define PF_UNIX AF_UNIX
310 #define PF_LOCAL PF_UNIX
311 #define PF_FILE PF_UNIX
312 #define PF_INET AF_INET
313 #define PF_IMPLINK AF_IMPLINK
314 #define PF_PUP AF_PUP
315 #define PF_CHAOS AF_CHAOS
316 #define PF_NS AF_NS
317 #define PF_NBS AF_NBS
318 #define PF_ECMA AF_ECMA
319 #define PF_DATAKIT AF_DATAKIT
320 #define PF_CCITT AF_CCITT
321 #define PF_SNA AF_SNA
322 #define PF_DECnet AF_DECnet
323 #define PF_DLI AF_DLI
324 #define PF_LAT AF_LAT
325 #define PF_HYLINK AF_HYLINK
326 #define PF_APPLETALK AF_APPLETALK
327 #define PF_NIT AF_NIT
328 #define PF_802 AF_802
329 #define PF_OSI AF_OSI
330 #define PF_X25 AF_X25
331 #define PF_OSINET AF_OSINET
332 #define PF_GOSIP AF_GOSIP
333 #define PF_IPX AF_IPX
334 #define PF_ROUTE AF_ROUTE
335 #define PF_LINK AF_LINK
336 #define PF_INET6 AF_INET6
337 #define PF_KEY AF_KEY
338 #define PF_NCA AF_NCA
339 #define PF_POLICY AF_POLICY
340 #define PF_INET_OFFLOAD AF_INET_OFFLOAD /* Sun private; do not use */
341 #define PF_TRILL AF_TRILL
342 #define PF_PACKET AF_PACKET
343 #define PF_LX_NETLINK AF_LX_NETLINK
344
345 #define PF_MAX AF_MAX
346
347 /*
348 * Maximum queue length specifiable by listen.
349 */
350 #define SOMAXCONN 128
351
352 /*
353 * Message header for recvmsg and sendmsg calls.
354 */
355 struct msghdr {
356 void *msg_name; /* optional address */
357 socklen_t msg_namelen; /* size of address */
358 struct iovec *msg_iov; /* scatter/gather array */
359 int msg_iovlen; /* # elements in msg_iov */
360
361 #if defined(_XPG4_2) || defined(_KERNEL)
362 void *msg_control; /* ancillary data */
363 socklen_t msg_controllen; /* ancillary data buffer len */
410 #define nmsghdr32 msghdr32
411
412 #endif /* _SYSCALL32 */
413 #endif /* _KERNEL */
414
415 #define MSG_OOB 0x1 /* process out-of-band data */
416 #define MSG_PEEK 0x2 /* peek at incoming message */
417 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
418 /* Added for XPGv2 compliance */
419 #define MSG_EOR 0x8 /* Terminates a record */
420 #define MSG_CTRUNC 0x10 /* Control data truncated */
421 #define MSG_TRUNC 0x20 /* Normal data truncated */
422 #define MSG_WAITALL 0x40 /* Wait for complete recv or error */
423 #define MSG_DUPCTRL 0x800 /* Save control message for use with */
424 /* with left over data */
425 /* End of XPGv2 compliance */
426 #define MSG_DONTWAIT 0x80 /* Don't block for this recv */
427 #define MSG_NOTIFICATION 0x100 /* Notification, not data */
428 #define MSG_XPG4_2 0x8000 /* Private: XPG4.2 flag */
429
430 /* Obsolete but kept for compilation compatability. Use IOV_MAX. */
431 #define MSG_MAXIOVLEN 16
432
433 #ifdef _KERNEL
434
435 /*
436 * for kernel socket only
437 */
438 #define MSG_MBLK_QUICKRELE 0x10000000 /* free mblk chain */
439 /* in timely manner */
440 #define MSG_USERSPACE 0x20000000 /* buffer from user space */
441
442 #endif /* _KERNEL */
443
444
445 /* Added for XPGv2 compliance */
446 #define SHUT_RD 0
447 #define SHUT_WR 1
448 #define SHUT_RDWR 2
449
450 struct cmsghdr {
|