]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
6d2010ae | 2 | * Copyright (c) 2000-2011 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */ | |
29 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
30 | /* | |
31 | * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 | |
32 | * The Regents of the University of California. All rights reserved. | |
33 | * | |
34 | * Redistribution and use in source and binary forms, with or without | |
35 | * modification, are permitted provided that the following conditions | |
36 | * are met: | |
37 | * 1. Redistributions of source code must retain the above copyright | |
38 | * notice, this list of conditions and the following disclaimer. | |
39 | * 2. Redistributions in binary form must reproduce the above copyright | |
40 | * notice, this list of conditions and the following disclaimer in the | |
41 | * documentation and/or other materials provided with the distribution. | |
42 | * 3. All advertising materials mentioning features or use of this software | |
43 | * must display the following acknowledgement: | |
44 | * This product includes software developed by the University of | |
45 | * California, Berkeley and its contributors. | |
46 | * 4. Neither the name of the University nor the names of its contributors | |
47 | * may be used to endorse or promote products derived from this software | |
48 | * without specific prior written permission. | |
49 | * | |
50 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
51 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
52 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
53 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
56 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
57 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
58 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
59 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
60 | * SUCH DAMAGE. | |
61 | * | |
62 | * @(#)socket.h 8.4 (Berkeley) 2/21/94 | |
9bccf70c | 63 | * $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $ |
1c79356b | 64 | */ |
2d21ac55 A |
65 | /* |
66 | * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce | |
67 | * support for mandatory and extensible security protections. This notice | |
68 | * is included in support of clause 2.2 (b) of the Apple Public License, | |
69 | * Version 2.0. | |
70 | */ | |
1c79356b A |
71 | |
72 | #ifndef _SYS_SOCKET_H_ | |
73 | #define _SYS_SOCKET_H_ | |
74 | ||
b0d623f7 | 75 | #include <sys/types.h> |
91447636 | 76 | #include <sys/cdefs.h> |
2d21ac55 | 77 | #include <machine/_param.h> |
1c79356b | 78 | |
6d2010ae A |
79 | #ifdef PRIVATE |
80 | #include <sys/param.h> | |
81 | #endif /* PRIVATE */ | |
82 | ||
83 | #ifndef KERNEL | |
84 | #include <Availability.h> | |
85 | #endif | |
86 | ||
1c79356b A |
87 | /* |
88 | * Definitions related to sockets: types, address families, options. | |
89 | */ | |
90 | ||
9bccf70c A |
91 | /* |
92 | * Data types. | |
93 | */ | |
91447636 A |
94 | #ifndef _GID_T |
95 | typedef __darwin_gid_t gid_t; | |
96 | #define _GID_T | |
97 | #endif | |
98 | ||
99 | #ifndef _OFF_T | |
100 | typedef __darwin_off_t off_t; | |
101 | #define _OFF_T | |
102 | #endif | |
103 | ||
104 | #ifndef _PID_T | |
105 | typedef __darwin_pid_t pid_t; | |
106 | #define _PID_T | |
107 | #endif | |
108 | ||
109 | #ifndef _SA_FAMILY_T | |
110 | #define _SA_FAMILY_T | |
111 | typedef __uint8_t sa_family_t; | |
112 | #endif | |
113 | ||
114 | #ifndef _SOCKLEN_T | |
115 | #define _SOCKLEN_T | |
116 | typedef __darwin_socklen_t socklen_t; | |
117 | #endif | |
118 | ||
119 | /* XXX Not explicitly defined by POSIX, but function return types are */ | |
120 | #ifndef _SIZE_T | |
121 | #define _SIZE_T | |
122 | typedef __darwin_size_t size_t; | |
123 | #endif | |
124 | ||
125 | /* XXX Not explicitly defined by POSIX, but function return types are */ | |
126 | #ifndef _SSIZE_T | |
127 | #define _SSIZE_T | |
128 | typedef __darwin_ssize_t ssize_t; | |
129 | #endif | |
130 | ||
131 | /* | |
132 | * [XSI] The iovec structure shall be defined as described in <sys/uio.h>. | |
133 | */ | |
134 | #ifndef _STRUCT_IOVEC | |
135 | #define _STRUCT_IOVEC | |
136 | struct iovec { | |
137 | void * iov_base; /* [XSI] Base address of I/O memory region */ | |
138 | size_t iov_len; /* [XSI] Size of region iov_base points to */ | |
139 | }; | |
9bccf70c | 140 | #endif |
6d2010ae A |
141 | |
142 | #ifdef PRIVATE | |
143 | #define SO_TCDBG_PID 0x01 /* Set/get traffic class for PID */ | |
144 | #define SO_TCDBG_PNAME 0x02 /* Set/get traffic class for processes of that name */ | |
145 | #define SO_TCDBG_PURGE 0x04 /* Purge entries for unused PIDs */ | |
146 | #define SO_TCDBG_FLUSH 0x08 /* Flush all entries */ | |
147 | #define SO_TCDBG_COUNT 0x10 /* Get count of entries */ | |
148 | #define SO_TCDBG_LIST 0x20 /* List entries */ | |
149 | ||
150 | struct so_tcdbg { | |
151 | u_int32_t so_tcdbg_cmd; | |
152 | int32_t so_tcdbg_tclass; | |
153 | u_int32_t so_tcdbg_count; | |
154 | pid_t so_tcdbg_pid; | |
155 | char so_tcdbg_pname[MAXCOMLEN + 1]; | |
156 | }; | |
157 | #endif /* PRIVATE */ | |
9bccf70c | 158 | |
1c79356b A |
159 | /* |
160 | * Types | |
161 | */ | |
162 | #define SOCK_STREAM 1 /* stream socket */ | |
163 | #define SOCK_DGRAM 2 /* datagram socket */ | |
164 | #define SOCK_RAW 3 /* raw-protocol interface */ | |
2d21ac55 | 165 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b | 166 | #define SOCK_RDM 4 /* reliably-delivered message */ |
2d21ac55 | 167 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
168 | #define SOCK_SEQPACKET 5 /* sequenced packet stream */ |
169 | ||
170 | /* | |
171 | * Option flags per-socket. | |
172 | */ | |
173 | #define SO_DEBUG 0x0001 /* turn on debugging info recording */ | |
174 | #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ | |
175 | #define SO_REUSEADDR 0x0004 /* allow local address reuse */ | |
176 | #define SO_KEEPALIVE 0x0008 /* keep connections alive */ | |
177 | #define SO_DONTROUTE 0x0010 /* just use interface addresses */ | |
178 | #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ | |
2d21ac55 | 179 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b | 180 | #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ |
91447636 A |
181 | #define SO_LINGER 0x0080 /* linger on close if data present (in ticks) */ |
182 | #else | |
183 | #define SO_LINGER 0x1080 /* linger on close if data present (in seconds) */ | |
2d21ac55 | 184 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b | 185 | #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ |
2d21ac55 | 186 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
187 | #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ |
188 | #define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ | |
6d2010ae | 189 | #define SO_TIMESTAMP_MONOTONIC 0x0800 /* Monotonically increasing timestamp on rcvd dgram */ |
9bccf70c A |
190 | #ifndef __APPLE__ |
191 | #define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ | |
192 | #else | |
1c79356b A |
193 | #define SO_DONTTRUNC 0x2000 /* APPLE: Retain unread data */ |
194 | /* (ATOMIC proto) */ | |
9bccf70c A |
195 | #define SO_WANTMORE 0x4000 /* APPLE: Give hint when more data ready */ |
196 | #define SO_WANTOOBFLAG 0x8000 /* APPLE: Want OOB in MSG_FLAG on receive */ | |
197 | #endif | |
2d21ac55 | 198 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
199 | |
200 | /* | |
201 | * Additional options, not kept in so_options. | |
202 | */ | |
203 | #define SO_SNDBUF 0x1001 /* send buffer size */ | |
204 | #define SO_RCVBUF 0x1002 /* receive buffer size */ | |
205 | #define SO_SNDLOWAT 0x1003 /* send low-water mark */ | |
206 | #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ | |
207 | #define SO_SNDTIMEO 0x1005 /* send timeout */ | |
208 | #define SO_RCVTIMEO 0x1006 /* receive timeout */ | |
209 | #define SO_ERROR 0x1007 /* get error status and clear */ | |
210 | #define SO_TYPE 0x1008 /* get socket type */ | |
2d21ac55 | 211 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c | 212 | /*efine SO_PRIVSTATE 0x1009 get/deny privileged state */ |
6d2010ae A |
213 | #define SO_LABEL 0x1010 /* socket's MAC label */ |
214 | #define SO_PEERLABEL 0x1011 /* socket's peer MAC label */ | |
9bccf70c | 215 | #ifdef __APPLE__ |
1c79356b A |
216 | #define SO_NREAD 0x1020 /* APPLE: get 1st-packet byte count */ |
217 | #define SO_NKE 0x1021 /* APPLE: Install socket-level NKE */ | |
9bccf70c | 218 | #define SO_NOSIGPIPE 0x1022 /* APPLE: No SIGPIPE on EPIPE */ |
55e303ae | 219 | #define SO_NOADDRERR 0x1023 /* APPLE: Returns EADDRNOTAVAIL when src is not available anymore */ |
91447636 | 220 | #define SO_NWRITE 0x1024 /* APPLE: Get number of bytes currently in send socket buffer */ |
2d21ac55 A |
221 | #define SO_REUSESHAREUID 0x1025 /* APPLE: Allow reuse of port/socket by different userids */ |
222 | #ifdef __APPLE_API_PRIVATE | |
223 | #define SO_NOTIFYCONFLICT 0x1026 /* APPLE: send notification if there is a bind on a port which is already in use */ | |
4a3eedf9 | 224 | #define SO_UPCALLCLOSEWAIT 0x1027 /* APPLE: block on close until an upcall returns */ |
2d21ac55 | 225 | #endif |
91447636 | 226 | #define SO_LINGER_SEC 0x1080 /* linger on close if data present (in seconds) */ |
2d21ac55 A |
227 | #define SO_RESTRICTIONS 0x1081 /* APPLE: deny inbound/outbound/both/flag set */ |
228 | #define SO_RESTRICT_DENYIN 0x00000001 /* flag for SO_RESTRICTIONS - deny inbound */ | |
229 | #define SO_RESTRICT_DENYOUT 0x00000002 /* flag for SO_RESTRICTIONS - deny outbound */ | |
230 | #define SO_RESTRICT_DENYSET 0x80000000 /* flag for SO_RESTRICTIONS - deny has been set */ | |
b0d623f7 A |
231 | #define SO_RANDOMPORT 0x1082 /* APPLE: request local port randomization */ |
232 | #define SO_NP_EXTENSIONS 0x1083 /* To turn off some POSIX behavior */ | |
9bccf70c | 233 | #endif |
6d2010ae | 234 | |
2d21ac55 A |
235 | #ifdef PRIVATE |
236 | #define SO_EXECPATH 0x1085 /* Application Firewall Socket option */ | |
6d2010ae | 237 | #define SO_TRAFFIC_CLASS 0x1086 /* Traffic class (int)*/ |
d41d1dae A |
238 | #define SO_TC_BE 0 /* Best effort, normal */ |
239 | #define SO_TC_BK 1 /* Background, low priority or bulk traffic */ | |
240 | #define SO_TC_VI 2 /* Interactive video, constant bit rate, low latency */ | |
241 | #define SO_TC_VO 3 /* Interactive voice, constant bit rate, lowest latency */ | |
6d2010ae A |
242 | #define SO_TC_MAX 4 /* Max traffic class value */ |
243 | ||
244 | /* Background socket configuration flags */ | |
245 | #define TRAFFIC_MGT_SO_BACKGROUND 0x0001 /* background socket */ | |
246 | #define TRAFFIC_MGT_TCP_RECVBG 0x0002 /* Only TCP sockets, receiver throttling */ | |
247 | ||
248 | #define SO_RECV_TRAFFIC_CLASS 0x1087 /* Receive traffic class (bool)*/ | |
249 | #define SO_TRAFFIC_CLASS_DBG 0x1088 /* Debug traffic class (struct so_tcdbg) */ | |
250 | #define SO_TRAFFIC_CLASS_STATS 0x1089 /* Traffic class statistics */ | |
251 | #define SO_DEFUNCTOK 0x1100 /* can be defunct'd */ | |
252 | #define SO_ISDEFUNCT 0x1101 /* get defunct status */ | |
253 | #endif /* PRIVATE */ | |
2d21ac55 | 254 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
91447636 | 255 | |
1c79356b A |
256 | /* |
257 | * Structure used for manipulating linger option. | |
258 | */ | |
259 | struct linger { | |
260 | int l_onoff; /* option on/off */ | |
261 | int l_linger; /* linger time */ | |
262 | }; | |
263 | ||
9bccf70c A |
264 | #ifndef __APPLE__ |
265 | struct accept_filter_arg { | |
266 | char af_name[16]; | |
267 | char af_arg[256-16]; | |
268 | }; | |
269 | #endif | |
270 | ||
b0d623f7 A |
271 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
272 | #ifdef __APPLE__ | |
273 | ||
274 | /* | |
275 | * Structure to control non-portable Sockets extension to POSIX | |
276 | */ | |
277 | struct so_np_extensions { | |
278 | u_int32_t npx_flags; | |
279 | u_int32_t npx_mask; | |
280 | }; | |
281 | ||
282 | #define SONPX_SETOPTSHUT 0x000000001 /* flag for allowing setsockopt after shutdown */ | |
283 | ||
284 | ||
285 | #ifdef KERNEL_PRIVATE | |
286 | #define SONPX_MASK_VALID (SONPX_SETOPTSHUT) | |
287 | #endif | |
288 | ||
289 | #endif | |
290 | #endif | |
291 | ||
1c79356b A |
292 | /* |
293 | * Level number for (get/set)sockopt() to apply to socket itself. | |
294 | */ | |
295 | #define SOL_SOCKET 0xffff /* options for socket level */ | |
296 | ||
2d21ac55 | 297 | |
1c79356b A |
298 | /* |
299 | * Address families. | |
300 | */ | |
301 | #define AF_UNSPEC 0 /* unspecified */ | |
91447636 | 302 | #define AF_UNIX 1 /* local to host (pipes) */ |
2d21ac55 | 303 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
91447636 | 304 | #define AF_LOCAL AF_UNIX /* backward compatibility */ |
2d21ac55 | 305 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b | 306 | #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ |
2d21ac55 | 307 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
308 | #define AF_IMPLINK 3 /* arpanet imp addresses */ |
309 | #define AF_PUP 4 /* pup protocols: e.g. BSP */ | |
310 | #define AF_CHAOS 5 /* mit CHAOS protocols */ | |
311 | #define AF_NS 6 /* XEROX NS protocols */ | |
312 | #define AF_ISO 7 /* ISO protocols */ | |
313 | #define AF_OSI AF_ISO | |
9bccf70c | 314 | #define AF_ECMA 8 /* European computer manufacturers */ |
1c79356b A |
315 | #define AF_DATAKIT 9 /* datakit protocols */ |
316 | #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ | |
317 | #define AF_SNA 11 /* IBM SNA */ | |
318 | #define AF_DECnet 12 /* DECnet */ | |
319 | #define AF_DLI 13 /* DEC Direct data link interface */ | |
320 | #define AF_LAT 14 /* LAT */ | |
321 | #define AF_HYLINK 15 /* NSC Hyperchannel */ | |
322 | #define AF_APPLETALK 16 /* Apple Talk */ | |
323 | #define AF_ROUTE 17 /* Internal Routing Protocol */ | |
324 | #define AF_LINK 18 /* Link layer interface */ | |
325 | #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ | |
326 | #define AF_COIP 20 /* connection-oriented IP, aka ST II */ | |
327 | #define AF_CNT 21 /* Computer Network Technology */ | |
328 | #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ | |
329 | #define AF_IPX 23 /* Novell Internet Protocol */ | |
330 | #define AF_SIP 24 /* Simple Internet Protocol */ | |
331 | #define pseudo_AF_PIP 25 /* Help Identify PIP packets */ | |
9bccf70c A |
332 | #ifdef __APPLE__ |
333 | /*define pseudo_AF_BLUE 26 Identify packets for Blue Box - Not used */ | |
1c79356b | 334 | #define AF_NDRV 27 /* Network Driver 'raw' access */ |
9bccf70c | 335 | #endif |
1c79356b A |
336 | #define AF_ISDN 28 /* Integrated Services Digital Network*/ |
337 | #define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ | |
338 | #define pseudo_AF_KEY 29 /* Internal key-management function */ | |
2d21ac55 | 339 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b | 340 | #define AF_INET6 30 /* IPv6 */ |
2d21ac55 | 341 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b | 342 | #define AF_NATM 31 /* native ATM access */ |
9bccf70c A |
343 | #ifdef __APPLE__ |
344 | #define AF_SYSTEM 32 /* Kernel event messages */ | |
1c79356b | 345 | #define AF_NETBIOS 33 /* NetBIOS */ |
0b4e3aa0 | 346 | #define AF_PPP 34 /* PPP communication protocol */ |
9bccf70c A |
347 | #else |
348 | #define AF_ATM 30 /* ATM */ | |
349 | #endif | |
350 | #define pseudo_AF_HDRCMPLT 35 /* Used by BPF to not rewrite headers | |
351 | * in interface output routine | |
352 | */ | |
91447636 A |
353 | #ifdef PRIVATE |
354 | #define AF_AFP 36 /* Used by AFP */ | |
355 | #else | |
356 | #define AF_RESERVED_36 36 /* Reserved for internal usage */ | |
357 | #endif | |
358 | ||
9bccf70c A |
359 | #ifndef __APPLE__ |
360 | #define AF_NETGRAPH 32 /* Netgraph sockets */ | |
361 | #endif | |
b0d623f7 A |
362 | #define AF_IEEE80211 37 /* IEEE 802.11 protocol */ |
363 | #define AF_MAX 38 | |
2d21ac55 | 364 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
365 | |
366 | /* | |
91447636 | 367 | * [XSI] Structure used by kernel to store most addresses. |
1c79356b A |
368 | */ |
369 | struct sockaddr { | |
91447636 A |
370 | __uint8_t sa_len; /* total length */ |
371 | sa_family_t sa_family; /* [XSI] address family */ | |
372 | char sa_data[14]; /* [XSI] addr value (actually larger) */ | |
1c79356b | 373 | }; |
91447636 | 374 | |
2d21ac55 | 375 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
376 | #define SOCK_MAXADDRLEN 255 /* longest possible addresses */ |
377 | ||
378 | /* | |
379 | * Structure used by kernel to pass protocol | |
380 | * information in raw sockets. | |
381 | */ | |
382 | struct sockproto { | |
91447636 A |
383 | __uint16_t sp_family; /* address family */ |
384 | __uint16_t sp_protocol; /* protocol */ | |
1c79356b | 385 | }; |
2d21ac55 | 386 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE)*/ |
1c79356b | 387 | |
1c79356b | 388 | /* |
9bccf70c | 389 | * RFC 2553: protocol-independent placeholder for socket addresses |
1c79356b | 390 | */ |
9bccf70c | 391 | #define _SS_MAXSIZE 128 |
91447636 A |
392 | #define _SS_ALIGNSIZE (sizeof(__int64_t)) |
393 | #define _SS_PAD1SIZE \ | |
394 | (_SS_ALIGNSIZE - sizeof(__uint8_t) - sizeof(sa_family_t)) | |
395 | #define _SS_PAD2SIZE \ | |
396 | (_SS_MAXSIZE - sizeof(__uint8_t) - sizeof(sa_family_t) - \ | |
1c79356b A |
397 | _SS_PAD1SIZE - _SS_ALIGNSIZE) |
398 | ||
91447636 A |
399 | /* |
400 | * [XSI] sockaddr_storage | |
401 | */ | |
1c79356b | 402 | struct sockaddr_storage { |
91447636 A |
403 | __uint8_t ss_len; /* address length */ |
404 | sa_family_t ss_family; /* [XSI] address family */ | |
9bccf70c | 405 | char __ss_pad1[_SS_PAD1SIZE]; |
91447636 | 406 | __int64_t __ss_align; /* force structure storage alignment */ |
9bccf70c | 407 | char __ss_pad2[_SS_PAD2SIZE]; |
1c79356b | 408 | }; |
1c79356b A |
409 | |
410 | /* | |
411 | * Protocol families, same as address families for now. | |
412 | */ | |
413 | #define PF_UNSPEC AF_UNSPEC | |
414 | #define PF_LOCAL AF_LOCAL | |
415 | #define PF_UNIX PF_LOCAL /* backward compatibility */ | |
416 | #define PF_INET AF_INET | |
1c79356b A |
417 | #define PF_IMPLINK AF_IMPLINK |
418 | #define PF_PUP AF_PUP | |
419 | #define PF_CHAOS AF_CHAOS | |
420 | #define PF_NS AF_NS | |
421 | #define PF_ISO AF_ISO | |
422 | #define PF_OSI AF_ISO | |
423 | #define PF_ECMA AF_ECMA | |
424 | #define PF_DATAKIT AF_DATAKIT | |
425 | #define PF_CCITT AF_CCITT | |
426 | #define PF_SNA AF_SNA | |
427 | #define PF_DECnet AF_DECnet | |
428 | #define PF_DLI AF_DLI | |
429 | #define PF_LAT AF_LAT | |
430 | #define PF_HYLINK AF_HYLINK | |
431 | #define PF_APPLETALK AF_APPLETALK | |
432 | #define PF_ROUTE AF_ROUTE | |
433 | #define PF_LINK AF_LINK | |
434 | #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ | |
435 | #define PF_COIP AF_COIP | |
436 | #define PF_CNT AF_CNT | |
437 | #define PF_SIP AF_SIP | |
438 | #define PF_IPX AF_IPX /* same format as AF_NS */ | |
439 | #define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ | |
440 | #define PF_PIP pseudo_AF_PIP | |
9bccf70c | 441 | #ifdef __APPLE__ |
1c79356b | 442 | #define PF_NDRV AF_NDRV |
9bccf70c | 443 | #endif |
1c79356b A |
444 | #define PF_ISDN AF_ISDN |
445 | #define PF_KEY pseudo_AF_KEY | |
446 | #define PF_INET6 AF_INET6 | |
447 | #define PF_NATM AF_NATM | |
9bccf70c | 448 | #ifdef __APPLE__ |
1c79356b A |
449 | #define PF_SYSTEM AF_SYSTEM |
450 | #define PF_NETBIOS AF_NETBIOS | |
0b4e3aa0 | 451 | #define PF_PPP AF_PPP |
91447636 A |
452 | #ifdef PRIVATE |
453 | #define PF_AFP AF_AFP | |
454 | #else | |
455 | #define PF_RESERVED_36 AF_RESERVED_36 | |
456 | #endif | |
457 | ||
9bccf70c A |
458 | #else |
459 | #define PF_ATM AF_ATM | |
460 | #define PF_NETGRAPH AF_NETGRAPH | |
461 | #endif | |
1c79356b A |
462 | |
463 | #define PF_MAX AF_MAX | |
464 | ||
91447636 A |
465 | /* |
466 | * These do not have socket-layer support: | |
467 | */ | |
468 | #define PF_VLAN ((uint32_t)0x766c616e) /* 'vlan' */ | |
469 | #define PF_BOND ((uint32_t)0x626f6e64) /* 'bond' */ | |
6d2010ae A |
470 | #ifdef KERNEL_PRIVATE |
471 | #define PF_BRIDGE ((uint32_t)0x62726467) /* 'brdg' */ | |
472 | #endif /* KERNEL_PRIVATE */ | |
91447636 | 473 | |
1c79356b A |
474 | /* |
475 | * Definitions for network related sysctl, CTL_NET. | |
476 | * | |
477 | * Second level is protocol family. | |
478 | * Third level is protocol number. | |
479 | * | |
480 | * Further levels are defined by the individual families below. | |
481 | */ | |
2d21ac55 | 482 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b | 483 | #define NET_MAXID AF_MAX |
2d21ac55 | 484 | #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ |
91447636 A |
485 | |
486 | #ifdef KERNEL_PRIVATE | |
1c79356b A |
487 | #define CTL_NET_NAMES { \ |
488 | { 0, 0 }, \ | |
489 | { "local", CTLTYPE_NODE }, \ | |
490 | { "inet", CTLTYPE_NODE }, \ | |
491 | { "implink", CTLTYPE_NODE }, \ | |
492 | { "pup", CTLTYPE_NODE }, \ | |
493 | { "chaos", CTLTYPE_NODE }, \ | |
494 | { "xerox_ns", CTLTYPE_NODE }, \ | |
495 | { "iso", CTLTYPE_NODE }, \ | |
496 | { "emca", CTLTYPE_NODE }, \ | |
497 | { "datakit", CTLTYPE_NODE }, \ | |
498 | { "ccitt", CTLTYPE_NODE }, \ | |
499 | { "ibm_sna", CTLTYPE_NODE }, \ | |
500 | { "decnet", CTLTYPE_NODE }, \ | |
501 | { "dec_dli", CTLTYPE_NODE }, \ | |
502 | { "lat", CTLTYPE_NODE }, \ | |
503 | { "hylink", CTLTYPE_NODE }, \ | |
504 | { "appletalk", CTLTYPE_NODE }, \ | |
505 | { "route", CTLTYPE_NODE }, \ | |
506 | { "link_layer", CTLTYPE_NODE }, \ | |
507 | { "xtp", CTLTYPE_NODE }, \ | |
508 | { "coip", CTLTYPE_NODE }, \ | |
509 | { "cnt", CTLTYPE_NODE }, \ | |
510 | { "rtip", CTLTYPE_NODE }, \ | |
511 | { "ipx", CTLTYPE_NODE }, \ | |
512 | { "sip", CTLTYPE_NODE }, \ | |
513 | { "pip", CTLTYPE_NODE }, \ | |
9bccf70c A |
514 | { 0, 0 }, \ |
515 | { "ndrv", CTLTYPE_NODE }, \ | |
1c79356b A |
516 | { "isdn", CTLTYPE_NODE }, \ |
517 | { "key", CTLTYPE_NODE }, \ | |
518 | { "inet6", CTLTYPE_NODE }, \ | |
519 | { "natm", CTLTYPE_NODE }, \ | |
9bccf70c A |
520 | { "sys", CTLTYPE_NODE }, \ |
521 | { "netbios", CTLTYPE_NODE }, \ | |
522 | { "ppp", CTLTYPE_NODE }, \ | |
523 | { "hdrcomplete", CTLTYPE_NODE }, \ | |
1c79356b | 524 | } |
2d21ac55 | 525 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 526 | |
2d21ac55 | 527 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
528 | /* |
529 | * PF_ROUTE - Routing table | |
530 | * | |
531 | * Three additional levels are defined: | |
532 | * Fourth: address family, 0 is wildcard | |
533 | * Fifth: type of info, defined below | |
534 | * Sixth: flag(s) to mask with for NET_RT_FLAGS | |
535 | */ | |
6d2010ae A |
536 | #define NET_RT_DUMP 1 /* dump; may limit to a.f. */ |
537 | #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ | |
538 | #define NET_RT_IFLIST 3 /* survey interface list */ | |
539 | #define NET_RT_STAT 4 /* routing statistics */ | |
540 | #define NET_RT_TRASH 5 /* routes not in table but not freed */ | |
541 | #define NET_RT_IFLIST2 6 /* interface list with addresses */ | |
542 | #define NET_RT_DUMP2 7 /* dump; may limit to a.f. */ | |
543 | #ifdef PRIVATE | |
544 | #define NET_RT_DUMPX 8 /* private */ | |
545 | #define NET_RT_DUMPX_FLAGS 9 /* private */ | |
546 | #endif /* PRIVATE */ | |
547 | #define NET_RT_MAXID 10 | |
2d21ac55 | 548 | #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ |
91447636 A |
549 | |
550 | #ifdef KERNEL_PRIVATE | |
1c79356b A |
551 | #define CTL_NET_RT_NAMES { \ |
552 | { 0, 0 }, \ | |
553 | { "dump", CTLTYPE_STRUCT }, \ | |
554 | { "flags", CTLTYPE_STRUCT }, \ | |
555 | { "iflist", CTLTYPE_STRUCT }, \ | |
91447636 A |
556 | { "stat", CTLTYPE_STRUCT }, \ |
557 | { "trash", CTLTYPE_INT }, \ | |
558 | { "iflist2", CTLTYPE_STRUCT }, \ | |
559 | { "dump2", CTLTYPE_STRUCT }, \ | |
6d2010ae A |
560 | { "dumpx", CTLTYPE_STRUCT }, \ |
561 | { "dumpx_flags", CTLTYPE_STRUCT }, \ | |
1c79356b A |
562 | } |
563 | ||
2d21ac55 | 564 | #endif /* KERNEL_PRIVATE */ |
91447636 | 565 | |
1c79356b A |
566 | /* |
567 | * Maximum queue length specifiable by listen. | |
568 | */ | |
569 | #define SOMAXCONN 128 | |
570 | ||
571 | /* | |
91447636 | 572 | * [XSI] Message header for recvmsg and sendmsg calls. |
1c79356b A |
573 | * Used value-result for recvmsg, value only for sendmsg. |
574 | */ | |
575 | struct msghdr { | |
91447636 A |
576 | void *msg_name; /* [XSI] optional address */ |
577 | socklen_t msg_namelen; /* [XSI] size of address */ | |
578 | struct iovec *msg_iov; /* [XSI] scatter/gather array */ | |
579 | int msg_iovlen; /* [XSI] # elements in msg_iov */ | |
580 | void *msg_control; /* [XSI] ancillary data, see below */ | |
581 | socklen_t msg_controllen; /* [XSI] ancillary data buffer len */ | |
582 | int msg_flags; /* [XSI] flags on received message */ | |
583 | }; | |
584 | ||
91447636 | 585 | #ifdef KERNEL |
b0d623f7 A |
586 | /* |
587 | * In-kernel representation of "struct msghdr" from | |
588 | * userspace. Has enough precision for 32-bit or | |
589 | * 64-bit clients, but does not need to be packed. | |
91447636 | 590 | */ |
91447636 A |
591 | |
592 | struct user_msghdr { | |
593 | user_addr_t msg_name; /* optional address */ | |
55e303ae | 594 | socklen_t msg_namelen; /* size of address */ |
b0d623f7 A |
595 | user_addr_t msg_iov; /* scatter/gather array */ |
596 | int msg_iovlen; /* # elements in msg_iov */ | |
597 | user_addr_t msg_control; /* ancillary data, see below */ | |
598 | socklen_t msg_controllen; /* ancillary data buffer len */ | |
599 | int msg_flags; /* flags on received message */ | |
600 | }; | |
601 | ||
602 | /* | |
603 | * LP64 user version of struct msghdr. | |
604 | * WARNING - keep in sync with struct msghdr | |
605 | */ | |
606 | ||
607 | struct user64_msghdr { | |
608 | user64_addr_t msg_name; /* optional address */ | |
609 | socklen_t msg_namelen; /* size of address */ | |
610 | user64_addr_t msg_iov; /* scatter/gather array */ | |
91447636 | 611 | int msg_iovlen; /* # elements in msg_iov */ |
b0d623f7 | 612 | user64_addr_t msg_control; /* ancillary data, see below */ |
55e303ae A |
613 | socklen_t msg_controllen; /* ancillary data buffer len */ |
614 | int msg_flags; /* flags on received message */ | |
1c79356b A |
615 | }; |
616 | ||
b0d623f7 A |
617 | /* |
618 | * ILP32 user version of struct msghdr. | |
619 | * WARNING - keep in sync with struct msghdr | |
620 | */ | |
621 | ||
622 | struct user32_msghdr { | |
623 | user32_addr_t msg_name; /* optional address */ | |
624 | socklen_t msg_namelen; /* size of address */ | |
625 | user32_addr_t msg_iov; /* scatter/gather array */ | |
626 | int msg_iovlen; /* # elements in msg_iov */ | |
627 | user32_addr_t msg_control; /* ancillary data, see below */ | |
628 | socklen_t msg_controllen; /* ancillary data buffer len */ | |
629 | int msg_flags; /* flags on received message */ | |
630 | }; | |
631 | ||
91447636 A |
632 | #endif // KERNEL |
633 | ||
1c79356b A |
634 | #define MSG_OOB 0x1 /* process out-of-band data */ |
635 | #define MSG_PEEK 0x2 /* peek at incoming message */ | |
636 | #define MSG_DONTROUTE 0x4 /* send without using routing tables */ | |
637 | #define MSG_EOR 0x8 /* data completes record */ | |
638 | #define MSG_TRUNC 0x10 /* data discarded before delivery */ | |
639 | #define MSG_CTRUNC 0x20 /* control data lost before delivery */ | |
640 | #define MSG_WAITALL 0x40 /* wait for full request or error */ | |
2d21ac55 | 641 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
642 | #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ |
643 | #define MSG_EOF 0x100 /* data completes connection */ | |
9bccf70c | 644 | #ifdef __APPLE__ |
6d2010ae A |
645 | #ifndef PRIVATE |
646 | #ifdef __APPLE_API_OBSOLETE | |
647 | #define MSG_WAITSTREAM 0x200 /* wait up to full request.. may return partial */ | |
648 | #endif | |
649 | #else | |
55e303ae | 650 | #define MSG_WAITSTREAM 0x200 /* wait up to full request.. may return partial */ |
6d2010ae | 651 | #endif |
1c79356b A |
652 | #define MSG_FLUSH 0x400 /* Start of 'hold' seq; dump so_temp */ |
653 | #define MSG_HOLD 0x800 /* Hold frag in so_temp */ | |
654 | #define MSG_SEND 0x1000 /* Send the packet in so_temp */ | |
655 | #define MSG_HAVEMORE 0x2000 /* Data ready to be read */ | |
656 | #define MSG_RCVMORE 0x4000 /* Data remains in current pkt */ | |
9bccf70c | 657 | #endif |
2d21ac55 A |
658 | #ifdef KERNEL_PRIVATE |
659 | #define MSG_COMPAT 0x8000 /* deprecated */ | |
660 | #endif /* KERNEL_PRIVATE */ | |
4a249263 | 661 | #define MSG_NEEDSA 0x10000 /* Fail receive if socket address cannot be allocated */ |
91447636 A |
662 | #ifdef KERNEL_PRIVATE |
663 | #define MSG_NBIO 0x20000 /* FIONBIO mode, used by fifofs */ | |
664 | #endif | |
665 | #ifdef KERNEL | |
666 | #define MSG_USEUPCALL 0x80000000 /* Inherit upcall in sock_accept */ | |
667 | #endif | |
2d21ac55 | 668 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
669 | |
670 | /* | |
671 | * Header for ancillary data objects in msg_control buffer. | |
672 | * Used for additional information with/about a datagram | |
673 | * not expressible by flags. The format is a sequence | |
674 | * of message elements headed by cmsghdr structures. | |
675 | */ | |
676 | struct cmsghdr { | |
91447636 A |
677 | socklen_t cmsg_len; /* [XSI] data byte count, including hdr */ |
678 | int cmsg_level; /* [XSI] originating protocol */ | |
679 | int cmsg_type; /* [XSI] protocol-specific type */ | |
680 | /* followed by unsigned char cmsg_data[]; */ | |
1c79356b A |
681 | }; |
682 | ||
2d21ac55 | 683 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c A |
684 | #ifndef __APPLE__ |
685 | /* | |
686 | * While we may have more groups than this, the cmsgcred struct must | |
687 | * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow | |
688 | * this. | |
689 | */ | |
690 | #define CMGROUP_MAX 16 | |
1c79356b | 691 | |
9bccf70c A |
692 | /* |
693 | * Credentials structure, used to verify the identity of a peer | |
694 | * process that has sent us a message. This is allocated by the | |
695 | * peer process but filled in by the kernel. This prevents the | |
696 | * peer from lying about its identity. (Note that cmcred_groups[0] | |
697 | * is the effective GID.) | |
1c79356b | 698 | */ |
9bccf70c A |
699 | struct cmsgcred { |
700 | pid_t cmcred_pid; /* PID of sending process */ | |
701 | uid_t cmcred_uid; /* real UID of sending process */ | |
702 | uid_t cmcred_euid; /* effective UID of sending process */ | |
703 | gid_t cmcred_gid; /* real GID of sending process */ | |
704 | short cmcred_ngroups; /* number or groups */ | |
705 | gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ | |
706 | }; | |
707 | #endif | |
2d21ac55 | 708 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
9bccf70c A |
709 | |
710 | /* given pointer to struct cmsghdr, return pointer to data */ | |
91447636 | 711 | #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ |
cf7d32b8 | 712 | __DARWIN_ALIGN32(sizeof(struct cmsghdr))) |
1c79356b | 713 | |
b0d623f7 A |
714 | /* |
715 | * RFC 2292 requires to check msg_controllen, in case that the kernel returns | |
716 | * an empty list for some reasons. | |
717 | */ | |
718 | #define CMSG_FIRSTHDR(mhdr) \ | |
719 | ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ | |
720 | (struct cmsghdr *)(mhdr)->msg_control : \ | |
721 | (struct cmsghdr *)0L) | |
722 | ||
1c79356b | 723 | |
b0d623f7 A |
724 | /* |
725 | * Given pointer to struct cmsghdr, return pointer to next cmsghdr | |
726 | * RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) | |
727 | */ | |
728 | #define CMSG_NXTHDR(mhdr, cmsg) \ | |
729 | ((char *)(cmsg) == (char *)0L ? CMSG_FIRSTHDR(mhdr) : \ | |
730 | ((((unsigned char *)(cmsg) + \ | |
731 | __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len) + \ | |
732 | __DARWIN_ALIGN32(sizeof(struct cmsghdr))) > \ | |
733 | ((unsigned char *)(mhdr)->msg_control + \ | |
734 | (mhdr)->msg_controllen)) ? \ | |
735 | (struct cmsghdr *)0L /* NULL */ : \ | |
6d2010ae | 736 | (struct cmsghdr *)(void *)((unsigned char *)(cmsg) + \ |
b0d623f7 | 737 | __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len)))) |
1c79356b | 738 | |
2d21ac55 | 739 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c | 740 | /* RFC 2292 additions */ |
cf7d32b8 A |
741 | #define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) |
742 | #define CMSG_LEN(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + (l)) | |
9bccf70c A |
743 | |
744 | #ifdef KERNEL | |
b0d623f7 | 745 | #define CMSG_ALIGN(n) __DARWIN_ALIGN32(n) |
9bccf70c | 746 | #endif |
2d21ac55 | 747 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
748 | |
749 | /* "Socket"-level control message types: */ | |
6d2010ae | 750 | #define SCM_RIGHTS 0x01 /* access rights (array of int) */ |
2d21ac55 | 751 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
6d2010ae A |
752 | #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ |
753 | #define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ | |
754 | #define SCM_TIMESTAMP_MONOTONIC 0x04 /* timestamp (uint64_t) */ | |
1c79356b | 755 | |
2d21ac55 | 756 | #ifdef KERNEL_PRIVATE |
1c79356b | 757 | /* |
2d21ac55 | 758 | * 4.3 compat sockaddr (deprecated) |
1c79356b A |
759 | */ |
760 | struct osockaddr { | |
91447636 | 761 | __uint16_t sa_family; /* address family */ |
1c79356b A |
762 | char sa_data[14]; /* up to 14 bytes of direct address */ |
763 | }; | |
764 | ||
765 | /* | |
2d21ac55 | 766 | * 4.3-compat message header (deprecated) |
1c79356b A |
767 | */ |
768 | struct omsghdr { | |
91447636 A |
769 | void *msg_name; /* optional address */ |
770 | socklen_t msg_namelen; /* size of address */ | |
771 | struct iovec *msg_iov; /* scatter/gather array */ | |
772 | int msg_iovlen; /* # elements in msg_iov */ | |
773 | void *msg_accrights; /* access rights sent/rcvd */ | |
774 | int msg_accrightslen; | |
1c79356b | 775 | }; |
2d21ac55 A |
776 | #endif /* KERNEL_PRIVATE */ |
777 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ | |
1c79356b A |
778 | |
779 | /* | |
780 | * howto arguments for shutdown(2), specified by Posix.1g. | |
781 | */ | |
782 | #define SHUT_RD 0 /* shut down the reading side */ | |
783 | #define SHUT_WR 1 /* shut down the writing side */ | |
784 | #define SHUT_RDWR 2 /* shut down both sides */ | |
785 | ||
2d21ac55 | 786 | #if !defined(_POSIX_C_SOURCE) |
1c79356b A |
787 | /* |
788 | * sendfile(2) header/trailer struct | |
789 | */ | |
790 | struct sf_hdtr { | |
791 | struct iovec *headers; /* pointer to an array of header struct iovec's */ | |
792 | int hdr_cnt; /* number of header iovec's */ | |
793 | struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ | |
794 | int trl_cnt; /* number of trailer iovec's */ | |
795 | }; | |
2d21ac55 A |
796 | |
797 | #ifdef KERNEL | |
798 | ||
b0d623f7 | 799 | /* In-kernel representation */ |
2d21ac55 | 800 | struct user_sf_hdtr { |
b0d623f7 | 801 | user_addr_t headers; /* pointer to an array of header struct iovec's */ |
2d21ac55 | 802 | int hdr_cnt; /* number of header iovec's */ |
b0d623f7 | 803 | user_addr_t trailers; /* pointer to an array of trailer struct iovec's */ |
2d21ac55 A |
804 | int trl_cnt; /* number of trailer iovec's */ |
805 | }; | |
806 | ||
b0d623f7 A |
807 | /* LP64 user version of struct sf_hdtr */ |
808 | struct user64_sf_hdtr { | |
809 | user64_addr_t headers; /* pointer to an array of header struct iovec's */ | |
810 | int hdr_cnt; /* number of header iovec's */ | |
811 | user64_addr_t trailers; /* pointer to an array of trailer struct iovec's */ | |
812 | int trl_cnt; /* number of trailer iovec's */ | |
813 | }; | |
814 | ||
815 | /* ILP32 user version of struct sf_hdtr */ | |
816 | struct user32_sf_hdtr { | |
817 | user32_addr_t headers; /* pointer to an array of header struct iovec's */ | |
818 | int hdr_cnt; /* number of header iovec's */ | |
819 | user32_addr_t trailers; /* pointer to an array of trailer struct iovec's */ | |
820 | int trl_cnt; /* number of trailer iovec's */ | |
821 | }; | |
2d21ac55 A |
822 | |
823 | #endif /* KERNEL */ | |
824 | ||
91447636 | 825 | #endif /* !_POSIX_C_SOURCE */ |
1c79356b A |
826 | |
827 | #ifndef KERNEL | |
1c79356b | 828 | __BEGIN_DECLS |
91447636 | 829 | int accept(int, struct sockaddr * __restrict, socklen_t * __restrict) |
2d21ac55 | 830 | __DARWIN_ALIAS_C(accept); |
91447636 | 831 | int bind(int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS(bind); |
2d21ac55 | 832 | int connect(int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS_C( connect); |
91447636 A |
833 | int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict) |
834 | __DARWIN_ALIAS(getpeername); | |
835 | int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict) | |
836 | __DARWIN_ALIAS(getsockname); | |
837 | int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); | |
838 | int listen(int, int) __DARWIN_ALIAS(listen); | |
2d21ac55 | 839 | ssize_t recv(int, void *, size_t, int) __DARWIN_ALIAS_C(recv); |
91447636 | 840 | ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, |
2d21ac55 A |
841 | socklen_t * __restrict) __DARWIN_ALIAS_C(recvfrom); |
842 | ssize_t recvmsg(int, struct msghdr *, int) __DARWIN_ALIAS_C(recvmsg); | |
843 | ssize_t send(int, const void *, size_t, int) __DARWIN_ALIAS_C(send); | |
844 | ssize_t sendmsg(int, const struct msghdr *, int) __DARWIN_ALIAS_C(sendmsg); | |
91447636 | 845 | ssize_t sendto(int, const void *, size_t, |
2d21ac55 | 846 | int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS_C(sendto); |
91447636 A |
847 | int setsockopt(int, int, int, const void *, socklen_t); |
848 | int shutdown(int, int); | |
6d2010ae | 849 | int sockatmark(int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); |
91447636 A |
850 | int socket(int, int, int); |
851 | int socketpair(int, int, int, int *) __DARWIN_ALIAS(socketpair); | |
91447636 | 852 | |
2d21ac55 A |
853 | #if !defined(_POSIX_C_SOURCE) |
854 | int sendfile(int, int, off_t, off_t *, struct sf_hdtr *, int); | |
91447636 | 855 | #endif /* !_POSIX_C_SOURCE */ |
2d21ac55 A |
856 | |
857 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) | |
858 | void pfctlinput(int, struct sockaddr *); | |
859 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ | |
1c79356b | 860 | __END_DECLS |
1c79356b | 861 | #endif /* !KERNEL */ |
9bccf70c | 862 | |
91447636 A |
863 | #ifdef KERNEL |
864 | #include <sys/kpi_socket.h> | |
865 | #endif | |
866 | ||
1c79356b | 867 | #endif /* !_SYS_SOCKET_H_ */ |