]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
39037602 | 2 | * Copyright (c) 2000-2016 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
39037602 | 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. | |
39037602 | 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. | |
39037602 | 17 | * |
2d21ac55 A |
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. | |
39037602 | 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> |
39037602 | 78 | #include <net/net_kev.h> |
1c79356b | 79 | |
6d2010ae A |
80 | #ifdef PRIVATE |
81 | #include <sys/param.h> | |
39236c6e | 82 | #include <uuid/uuid.h> |
6d2010ae A |
83 | #endif /* PRIVATE */ |
84 | ||
39236c6e | 85 | #ifndef KERNEL |
6d2010ae A |
86 | #include <Availability.h> |
87 | #endif | |
88 | ||
1c79356b A |
89 | /* |
90 | * Definitions related to sockets: types, address families, options. | |
91 | */ | |
92 | ||
9bccf70c A |
93 | /* |
94 | * Data types. | |
95 | */ | |
91447636 | 96 | |
39236c6e A |
97 | #include <sys/_types/_gid_t.h> |
98 | #include <sys/_types/_off_t.h> | |
99 | #include <sys/_types/_pid_t.h> | |
100 | #include <sys/_types/_sa_family_t.h> | |
101 | #include <sys/_types/_socklen_t.h> | |
91447636 A |
102 | |
103 | /* XXX Not explicitly defined by POSIX, but function return types are */ | |
39236c6e | 104 | #include <sys/_types/_size_t.h> |
39037602 | 105 | |
91447636 | 106 | /* XXX Not explicitly defined by POSIX, but function return types are */ |
39236c6e | 107 | #include <sys/_types/_ssize_t.h> |
91447636 A |
108 | |
109 | /* | |
110 | * [XSI] The iovec structure shall be defined as described in <sys/uio.h>. | |
111 | */ | |
39236c6e | 112 | #include <sys/_types/_iovec_t.h> |
6d2010ae | 113 | |
1c79356b A |
114 | /* |
115 | * Types | |
116 | */ | |
117 | #define SOCK_STREAM 1 /* stream socket */ | |
118 | #define SOCK_DGRAM 2 /* datagram socket */ | |
119 | #define SOCK_RAW 3 /* raw-protocol interface */ | |
2d21ac55 | 120 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b | 121 | #define SOCK_RDM 4 /* reliably-delivered message */ |
2d21ac55 | 122 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
123 | #define SOCK_SEQPACKET 5 /* sequenced packet stream */ |
124 | ||
125 | /* | |
126 | * Option flags per-socket. | |
127 | */ | |
128 | #define SO_DEBUG 0x0001 /* turn on debugging info recording */ | |
129 | #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ | |
130 | #define SO_REUSEADDR 0x0004 /* allow local address reuse */ | |
131 | #define SO_KEEPALIVE 0x0008 /* keep connections alive */ | |
132 | #define SO_DONTROUTE 0x0010 /* just use interface addresses */ | |
133 | #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ | |
2d21ac55 | 134 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b | 135 | #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ |
39037602 | 136 | #define SO_LINGER 0x0080 /* linger on close if data present (in ticks) */ |
91447636 | 137 | #else |
39037602 | 138 | #define SO_LINGER 0x1080 /* linger on close if data present (in seconds) */ |
2d21ac55 | 139 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b | 140 | #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ |
2d21ac55 | 141 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
142 | #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ |
143 | #define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ | |
39037602 | 144 | #define SO_TIMESTAMP_MONOTONIC 0x0800 /* Monotonically increasing timestamp on rcvd dgram */ |
9bccf70c A |
145 | #ifndef __APPLE__ |
146 | #define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ | |
147 | #else | |
39037602 | 148 | #define SO_DONTTRUNC 0x2000 /* APPLE: Retain unread data */ |
1c79356b | 149 | /* (ATOMIC proto) */ |
39037602 A |
150 | #define SO_WANTMORE 0x4000 /* APPLE: Give hint when more data ready */ |
151 | #define SO_WANTOOBFLAG 0x8000 /* APPLE: Want OOB in MSG_FLAG on receive */ | |
316670eb | 152 | |
fe8ab488 A |
153 | #ifdef PRIVATE |
154 | #define SO_NOWAKEFROMSLEEP 0x10000 /* Don't wake for traffic to this socket */ | |
39037602 | 155 | #define SO_NOAPNFALLBK 0x20000 /* Don't attempt APN fallback for the socket */ |
fe8ab488 A |
156 | #endif |
157 | ||
316670eb | 158 | #endif /* (!__APPLE__) */ |
2d21ac55 | 159 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
160 | |
161 | /* | |
162 | * Additional options, not kept in so_options. | |
163 | */ | |
39037602 A |
164 | #define SO_SNDBUF 0x1001 /* send buffer size */ |
165 | #define SO_RCVBUF 0x1002 /* receive buffer size */ | |
166 | #define SO_SNDLOWAT 0x1003 /* send low-water mark */ | |
167 | #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ | |
168 | #define SO_SNDTIMEO 0x1005 /* send timeout */ | |
169 | #define SO_RCVTIMEO 0x1006 /* receive timeout */ | |
1c79356b A |
170 | #define SO_ERROR 0x1007 /* get error status and clear */ |
171 | #define SO_TYPE 0x1008 /* get socket type */ | |
2d21ac55 | 172 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
39037602 A |
173 | #define SO_LABEL 0x1010 /* socket's MAC label */ |
174 | #define SO_PEERLABEL 0x1011 /* socket's peer MAC label */ | |
9bccf70c | 175 | #ifdef __APPLE__ |
39037602 A |
176 | #define SO_NREAD 0x1020 /* APPLE: get 1st-packet byte count */ |
177 | #define SO_NKE 0x1021 /* APPLE: Install socket-level NKE */ | |
178 | #define SO_NOSIGPIPE 0x1022 /* APPLE: No SIGPIPE on EPIPE */ | |
179 | #define SO_NOADDRERR 0x1023 /* APPLE: Returns EADDRNOTAVAIL when src is not available anymore */ | |
180 | #define SO_NWRITE 0x1024 /* APPLE: Get number of bytes currently in send socket buffer */ | |
181 | #define SO_REUSESHAREUID 0x1025 /* APPLE: Allow reuse of port/socket by different userids */ | |
2d21ac55 | 182 | #ifdef __APPLE_API_PRIVATE |
39037602 | 183 | #define SO_NOTIFYCONFLICT 0x1026 /* APPLE: send notification if there is a bind on a port which is already in use */ |
4a3eedf9 | 184 | #define SO_UPCALLCLOSEWAIT 0x1027 /* APPLE: block on close until an upcall returns */ |
2d21ac55 | 185 | #endif |
39037602 | 186 | #define SO_LINGER_SEC 0x1080 /* linger on close if data present (in seconds) */ |
39236c6e A |
187 | #ifdef PRIVATE |
188 | #define SO_RESTRICTIONS 0x1081 /* APPLE: deny flag set */ | |
189 | #define SO_RESTRICT_DENY_IN 0x1 /* deny inbound (trapdoor) */ | |
190 | #define SO_RESTRICT_DENY_OUT 0x2 /* deny outbound (trapdoor) */ | |
191 | #define SO_RESTRICT_DENY_CELLULAR 0x4 /* deny use of cellular (trapdoor) */ | |
39037602 | 192 | #define SO_RESTRICT_DENY_EXPENSIVE 0x8 /* deny use of expensive if (trapdoor) */ |
39236c6e | 193 | #endif /* PRIVATE */ |
39037602 A |
194 | #define SO_RANDOMPORT 0x1082 /* APPLE: request local port randomization */ |
195 | #define SO_NP_EXTENSIONS 0x1083 /* To turn off some POSIX behavior */ | |
9bccf70c | 196 | #endif |
6d2010ae | 197 | |
2d21ac55 A |
198 | #ifdef PRIVATE |
199 | #define SO_EXECPATH 0x1085 /* Application Firewall Socket option */ | |
39037602 | 200 | |
316670eb A |
201 | /* |
202 | * Traffic service class definitions (lowest to highest): | |
203 | * | |
204 | * SO_TC_BK_SYS | |
205 | * "Background System-Initiated", high delay tolerant, high loss | |
206 | * tolerant, elastic flow, variable size & long-lived. E.g: system- | |
207 | * initiated iCloud synching or Time Capsule backup, for which there | |
208 | * is no progress feedbacks. | |
209 | * | |
210 | * SO_TC_BK | |
211 | * "Background", user-initiated, high delay tolerant, high loss tolerant, | |
212 | * elastic flow, variable size. E.g. user-initiated iCloud synching or | |
213 | * Time Capsule backup; or traffics of background applications, for which | |
214 | * there is some progress feedbacks. | |
215 | * | |
216 | * SO_TC_BE | |
217 | * "Best Effort", unclassified/standard. This is the default service | |
218 | * class; pretty much a mix of everything. | |
219 | * | |
220 | * SO_TC_RD | |
221 | * "Responsive Data", a notch higher than "Best Effort", medium delay | |
222 | * tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email, | |
223 | * instant messaging, for which there is a sense of interactivity and | |
224 | * urgency (user waiting for output). | |
225 | * | |
226 | * SO_TC_OAM | |
227 | * "Operations, Administration, and Management", medium delay tolerant, | |
228 | * low-medium loss tolerant, elastic & inelastic flows, variable size. | |
229 | * E.g. VPN tunnels. | |
230 | * | |
231 | * SO_TC_AV | |
232 | * "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium | |
233 | * loss tolerant, elastic flow, constant packet interval, variable rate & | |
234 | * size. E.g. AirPlay playback (both video and audio). | |
235 | * | |
236 | * SO_TC_RV | |
237 | * "Responsive Multimedia Audio/Video", low delay tolerant, low-medium | |
238 | * loss tolerant, elastic flow, variable packet interval, rate and size. | |
239 | * E.g. AirPlay mirroring, screen sharing. | |
240 | * | |
241 | * SO_TC_VI | |
242 | * "Interactive Video", low delay tolerant, low-medium loss tolerant, | |
243 | * elastic flow, constant packet interval, variable rate & size. E.g. | |
244 | * FaceTime video. | |
245 | * | |
246 | * SO_TC_VO | |
247 | * "Interactive Voice", low delay tolerant, low loss tolerant, inelastic | |
248 | * flow, constant packet rate, somewhat fixed size. E.g. VoIP including | |
249 | * FaceTime audio. | |
250 | * | |
251 | * SO_TC_CTL | |
252 | * "Network Control", low delay tolerant, low loss tolerant, inelastic | |
253 | * flow, rate is bursty but short, variable size. E.g. DNS queries; | |
254 | * certain types of locally-originated ICMP, ICMPv6; IGMP/MLD join/leave, | |
255 | * ARP. | |
256 | */ | |
39037602 A |
257 | #define SO_TRAFFIC_CLASS 0x1086 /* Traffic service class (int) */ |
258 | #define SO_TC_BK_SYS 100 /* lowest class */ | |
259 | #define SO_TC_BK 200 | |
260 | #define SO_TC_BE 0 | |
261 | #define SO_TC_RD 300 | |
262 | #define SO_TC_OAM 400 | |
263 | #define SO_TC_AV 500 | |
264 | #define SO_TC_RV 600 | |
265 | #define SO_TC_VI 700 | |
266 | #define SO_TC_VO 800 | |
267 | #define SO_TC_CTL 900 /* highest class */ | |
268 | #define SO_TC_MAX 10 /* Total # of traffic classes */ | |
316670eb | 269 | #ifdef XNU_KERNEL_PRIVATE |
39037602 A |
270 | #define _SO_TC_BK 1 /* deprecated */ |
271 | #define _SO_TC_VI 2 /* deprecated */ | |
272 | #define _SO_TC_VO 3 /* deprecated */ | |
273 | #define _SO_TC_MAX 4 /* deprecated */ | |
316670eb A |
274 | |
275 | #define SO_VALID_TC(c) \ | |
276 | (c == SO_TC_BK_SYS || c == SO_TC_BK || c == SO_TC_BE || \ | |
277 | c == SO_TC_RD || c == SO_TC_OAM || c == SO_TC_AV || \ | |
39037602 A |
278 | c == SO_TC_RV || c == SO_TC_VI || c == SO_TC_VO || \ |
279 | c == SO_TC_CTL) | |
280 | ||
281 | #define SO_TC_UNSPEC ((int)-1) /* Traffic class not specified */ | |
282 | ||
283 | #define SO_TC_SIG SO_TC_VI /* to be removed XXX */ | |
284 | ||
285 | #define SOTCIX_BK_SYS 0 | |
286 | #define SOTCIX_BK 1 | |
287 | #define SOTCIX_BE 2 | |
288 | #define SOTCIX_RD 3 | |
289 | #define SOTCIX_OAM 4 | |
290 | #define SOTCIX_AV 5 | |
291 | #define SOTCIX_RV 6 | |
292 | #define SOTCIX_VI 7 | |
293 | #define SOTCIX_VO 8 | |
294 | #define SOTCIX_CTL 9 | |
316670eb | 295 | #endif /* XNU_KERNEL_PRIVATE */ |
6d2010ae | 296 | |
39037602 A |
297 | /* Background socket configuration flags */ |
298 | #define TRAFFIC_MGT_SO_BACKGROUND 0x0001 /* background socket */ | |
299 | #define TRAFFIC_MGT_TCP_RECVBG 0x0002 /* Only TCP sockets, receiver throttling */ | |
6d2010ae | 300 | |
39037602 A |
301 | #define SO_RECV_TRAFFIC_CLASS 0x1087 /* Receive traffic class (bool) */ |
302 | #define SO_TRAFFIC_CLASS_DBG 0x1088 /* Debug traffic class (struct so_tcdbg) */ | |
303 | #define SO_TRAFFIC_CLASS_STATS 0x1089 /* Traffic class statistics */ | |
304 | #define SO_PRIVILEGED_TRAFFIC_CLASS 0x1090 /* Privileged traffic class (bool) */ | |
6d2010ae A |
305 | #define SO_DEFUNCTOK 0x1100 /* can be defunct'd */ |
306 | #define SO_ISDEFUNCT 0x1101 /* get defunct status */ | |
316670eb A |
307 | |
308 | #define SO_OPPORTUNISTIC 0x1102 /* deprecated; use SO_TRAFFIC_CLASS */ | |
309 | ||
310 | /* | |
311 | * SO_FLUSH flushes any unsent data generated by a given socket. It takes | |
312 | * an integer parameter, which can be any of the SO_TC traffic class values, | |
313 | * or the special SO_TC_ALL value. | |
314 | */ | |
315 | #define SO_FLUSH 0x1103 /* flush unsent data (int) */ | |
316 | #define SO_TC_ALL (-1) | |
317 | ||
318 | #define SO_RECV_ANYIF 0x1104 /* unrestricted inbound processing */ | |
39236c6e | 319 | #define SO_TRAFFIC_MGT_BACKGROUND 0x1105 /* Background traffic management */ |
39037602 | 320 | |
39236c6e A |
321 | #define SO_FLOW_DIVERT_TOKEN 0x1106 /* flow divert token */ |
322 | ||
323 | #define SO_DELEGATED 0x1107 /* set socket as delegate (pid_t) */ | |
324 | #define SO_DELEGATED_UUID 0x1108 /* set socket as delegate (uuid_t) */ | |
fe8ab488 A |
325 | #define SO_NECP_ATTRIBUTES 0x1109 /* NECP socket attributes (domain, account, etc.) */ |
326 | #define SO_CFIL_SOCK_ID 0x1110 /* get content filter socket ID (cfil_sock_id_t) */ | |
327 | #if MPTCP | |
39037602 | 328 | #define SO_MPTCP_FASTJOIN 0x1111 /* fast join MPTCP */ |
fe8ab488 | 329 | #endif /* MPTCP */ |
6d2010ae | 330 | #endif /* PRIVATE */ |
39037602 | 331 | #define SO_NUMRCVPKT 0x1112 /* number of datagrams in receive socket buffer */ |
3e170ce0 A |
332 | #ifdef PRIVATE |
333 | #define SO_AWDL_UNRESTRICTED 0x1113 /* try to use AWDL in restricted mode */ | |
39037602 | 334 | #define SO_EXTENDED_BK_IDLE 0x1114 /* extended time to keep socket idle after app is suspended (int) */ |
490019cf | 335 | #define SO_MARK_CELLFALLBACK 0x1115 /* Mark as initiated by cell fallback */ |
3e170ce0 | 336 | #endif /* PRIVATE */ |
fe8ab488 | 337 | |
39037602 A |
338 | /* |
339 | * Network Service Type for option SO_NET_SERVICE_TYPE | |
340 | * | |
341 | * The vast majority of sockets should use Best Effort that is the default | |
342 | * Network Service Type. Other Network Service Types have to be used only if | |
343 | * the traffic actually matches the description of the Network Service Type. | |
344 | * | |
345 | * Network Service Types do not represent priorities but rather describe | |
346 | * different categories of delay, jitter and loss parameters. | |
347 | * Those parameters may influence protocols from layer 4 protocols like TCP | |
348 | * to layer 2 protocols like Wi-Fi. The Network Service Type can determine | |
349 | * how the traffic is queued and scheduled by the host networking stack and | |
350 | * by other entities on the network like switches and routers. For example | |
351 | * for Wi-Fi, the Network Service Type can select the marking of the | |
352 | * layer 2 packet with the appropriate WMM Access Category. | |
353 | * | |
354 | * There is no point in attempting to game the system and use | |
355 | * a Network Service Type that does not correspond to the actual | |
356 | * traffic characteristic but one that seems to have a higher precedence. | |
357 | * The reason is that for service classes that have lower tolerance | |
358 | * for delay and jitter, the queues size is lower than for service | |
359 | * classes that are more tolerant to delay and jitter. | |
360 | * | |
361 | * For example using a voice service type for bulk data transfer will lead | |
362 | * to disastrous results as soon as congestion happens because the voice | |
363 | * queue overflows and packets get dropped. This is not only bad for the bulk | |
364 | * data transfer but it is also bad for VoIP apps that legitimately are using | |
365 | * the voice service type. | |
366 | * | |
367 | * The characteristics of the Network Service Types are based on the service | |
368 | * classes defined in RFC 4594 "Configuration Guidelines for DiffServ Service | |
369 | * Classes" | |
370 | * | |
371 | * When system detects the outgoing interface belongs to a DiffServ domain | |
372 | * that follows the recommendation of the IETF draft "Guidelines for DiffServ to | |
373 | * IEEE 802.11 Mapping", the packet will marked at layer 3 with a DSCP value | |
374 | * that corresponds to Network Service Type. | |
375 | * | |
376 | * NET_SERVICE_TYPE_BE | |
377 | * "Best Effort", unclassified/standard. This is the default service | |
378 | * class and cover the majority of the traffic. | |
379 | * | |
380 | * NET_SERVICE_TYPE_BK | |
381 | * "Background", high delay tolerant, loss tolerant. elastic flow, | |
382 | * variable size & long-lived. E.g: non-interactive network bulk transfer | |
383 | * like synching or backup. | |
384 | * | |
385 | * NET_SERVICE_TYPE_RD | |
386 | * "Responsive Data", a notch higher than "Best Effort", medium delay | |
387 | * tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email, | |
388 | * instant messaging, for which there is a sense of interactivity and | |
389 | * urgency (user waiting for output). | |
390 | * | |
391 | * NET_SERVICE_TYPE_OAM | |
392 | * "Operations, Administration, and Management", medium delay tolerant, | |
393 | * low-medium loss tolerant, elastic & inelastic flows, variable size. | |
394 | * E.g. VPN tunnels. | |
395 | * | |
396 | * NET_SERVICE_TYPE_AV | |
397 | * "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium | |
398 | * loss tolerant, elastic flow, constant packet interval, variable rate | |
399 | * and size. E.g. video and audio playback with buffering. | |
400 | * | |
401 | * NET_SERVICE_TYPE_RV | |
402 | * "Responsive Multimedia Audio/Video", low delay tolerant, low-medium | |
403 | * loss tolerant, elastic flow, variable packet interval, rate and size. | |
404 | * E.g. screen sharing. | |
405 | * | |
406 | * NET_SERVICE_TYPE_VI | |
407 | * "Interactive Video", low delay tolerant, low-medium loss tolerant, | |
408 | * elastic flow, constant packet interval, variable rate & size. E.g. | |
409 | * video telephony. | |
410 | * | |
411 | * NET_SERVICE_TYPE_SIG | |
412 | * "Signaling", low delay tolerant, low loss tolerant, inelastic flow, | |
413 | * jitter tolerant, rate is bursty but short, variable size. E.g. SIP. | |
414 | * | |
415 | * NET_SERVICE_TYPE_VO | |
416 | * "Interactive Voice", very low delay tolerant, very low loss tolerant, | |
417 | * inelastic flow, constant packet rate, somewhat fixed size. | |
418 | * E.g. VoIP. | |
419 | */ | |
420 | #define SO_NET_SERVICE_TYPE 0x1116 /* Network service type */ | |
421 | ||
422 | #define NET_SERVICE_TYPE_BE 0 /* Best effort */ | |
423 | #define NET_SERVICE_TYPE_BK 1 /* Background system initiated */ | |
424 | #define NET_SERVICE_TYPE_SIG 2 /* Signaling */ | |
425 | #define NET_SERVICE_TYPE_VI 3 /* Interactive Video */ | |
426 | #define NET_SERVICE_TYPE_VO 4 /* Interactive Voice */ | |
427 | #define NET_SERVICE_TYPE_RV 5 /* Responsive Multimedia Audio/Video */ | |
428 | #define NET_SERVICE_TYPE_AV 6 /* Multimedia Audio/Video Streaming */ | |
429 | #define NET_SERVICE_TYPE_OAM 7 /* Operations, Administration, and Management */ | |
430 | #define NET_SERVICE_TYPE_RD 8 /* Responsive Data */ | |
431 | ||
432 | #if PRIVATE | |
433 | #define SO_QOSMARKING_POLICY_OVERRIDE 0x1117 /* int */ | |
434 | #define SO_INTCOPROC_ALLOW 0x1118 /* Try to use internal co-processor interfaces. */ | |
435 | ||
436 | #define _NET_SERVICE_TYPE_COUNT 9 | |
437 | #define _NET_SERVICE_TYPE_UNSPEC ((int)-1) | |
438 | ||
439 | #define IS_VALID_NET_SERVICE_TYPE(c) \ | |
440 | (c >= NET_SERVICE_TYPE_BE && c <= NET_SERVICE_TYPE_RD) | |
441 | ||
442 | extern const int sotc_by_netservicetype[_NET_SERVICE_TYPE_COUNT]; | |
443 | ||
444 | /* | |
445 | * Facility to pass Network Service Type values using SO_TRAFFIC_CLASS | |
446 | * Mostly useful to simplify implementation of frameworks to adopt the new | |
447 | * Network Service Type values for Signaling. | |
448 | */ | |
449 | #define SO_TC_NET_SERVICE_OFFSET 10000 | |
450 | #define SO_TC_NETSVC_SIG (SO_TC_NET_SERVICE_OFFSET + NET_SERVICE_TYPE_SIG) | |
451 | #endif /* PRIVATE */ | |
452 | ||
453 | #define SO_NETSVC_MARKING_LEVEL 0x1119 /* Get QoS marking in effect for socket */ | |
454 | ||
455 | #define NETSVC_MRKNG_UNKNOWN 0 /* The outgoing network interface is not known */ | |
456 | #define NETSVC_MRKNG_LVL_L2 1 /* Default marking at layer 2 (for example Wi-Fi WMM) */ | |
457 | #define NETSVC_MRKNG_LVL_L3L2_ALL 2 /* Layer 3 DSCP marking and layer 2 marking for all Network Service Types */ | |
458 | #define NETSVC_MRKNG_LVL_L3L2_BK 3 /* The system policy limits layer 3 DSCP marking and layer 2 marking | |
459 | * to background Network Service Types */ | |
460 | ||
3e170ce0 A |
461 | typedef __uint32_t sae_associd_t; |
462 | #define SAE_ASSOCID_ANY 0 | |
463 | #define SAE_ASSOCID_ALL ((sae_associd_t)(-1ULL)) | |
464 | ||
465 | typedef __uint32_t sae_connid_t; | |
466 | #define SAE_CONNID_ANY 0 | |
467 | #define SAE_CONNID_ALL ((sae_connid_t)(-1ULL)) | |
468 | ||
469 | /* connectx() flag parameters */ | |
39037602 A |
470 | #define CONNECT_RESUME_ON_READ_WRITE 0x1 /* resume connect() on read/write */ |
471 | #define CONNECT_DATA_IDEMPOTENT 0x2 /* data is idempotent */ | |
3e170ce0 A |
472 | |
473 | /* sockaddr endpoints */ | |
474 | typedef struct sa_endpoints { | |
39037602 A |
475 | unsigned int sae_srcif; /* optional source interface */ |
476 | const struct sockaddr *sae_srcaddr; /* optional source address */ | |
477 | socklen_t sae_srcaddrlen; /* size of source address */ | |
478 | const struct sockaddr *sae_dstaddr; /* destination address */ | |
479 | socklen_t sae_dstaddrlen; /* size of destination address */ | |
3e170ce0 | 480 | } sa_endpoints_t; |
2d21ac55 | 481 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
91447636 | 482 | |
1c79356b A |
483 | /* |
484 | * Structure used for manipulating linger option. | |
485 | */ | |
486 | struct linger { | |
487 | int l_onoff; /* option on/off */ | |
488 | int l_linger; /* linger time */ | |
489 | }; | |
490 | ||
9bccf70c A |
491 | #ifndef __APPLE__ |
492 | struct accept_filter_arg { | |
493 | char af_name[16]; | |
494 | char af_arg[256-16]; | |
495 | }; | |
496 | #endif | |
497 | ||
b0d623f7 A |
498 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
499 | #ifdef __APPLE__ | |
500 | ||
501 | /* | |
39037602 | 502 | * Structure to control non-portable Sockets extension to POSIX |
b0d623f7 A |
503 | */ |
504 | struct so_np_extensions { | |
505 | u_int32_t npx_flags; | |
506 | u_int32_t npx_mask; | |
507 | }; | |
508 | ||
39037602 | 509 | #define SONPX_SETOPTSHUT 0x000000001 /* flag for allowing setsockopt after shutdown */ |
b0d623f7 A |
510 | |
511 | ||
512 | #ifdef KERNEL_PRIVATE | |
39037602 A |
513 | #define SONPX_MASK_VALID (SONPX_SETOPTSHUT) |
514 | #define IS_SO_TC_BACKGROUND(_tc_) ((_tc_) == SO_TC_BK || (_tc_) == SO_TC_BK_SYS) | |
515 | #define IS_SO_TC_BACKGROUNDSYSTEM(_tc_) ((_tc_) == SO_TC_BK_SYS) | |
316670eb | 516 | #endif /* KERNEL_PRIVATE */ |
b0d623f7 A |
517 | |
518 | #endif | |
519 | #endif | |
520 | ||
1c79356b A |
521 | /* |
522 | * Level number for (get/set)sockopt() to apply to socket itself. | |
523 | */ | |
524 | #define SOL_SOCKET 0xffff /* options for socket level */ | |
525 | ||
2d21ac55 | 526 | |
1c79356b A |
527 | /* |
528 | * Address families. | |
529 | */ | |
530 | #define AF_UNSPEC 0 /* unspecified */ | |
91447636 | 531 | #define AF_UNIX 1 /* local to host (pipes) */ |
2d21ac55 | 532 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
91447636 | 533 | #define AF_LOCAL AF_UNIX /* backward compatibility */ |
2d21ac55 | 534 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b | 535 | #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ |
2d21ac55 | 536 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
537 | #define AF_IMPLINK 3 /* arpanet imp addresses */ |
538 | #define AF_PUP 4 /* pup protocols: e.g. BSP */ | |
539 | #define AF_CHAOS 5 /* mit CHAOS protocols */ | |
540 | #define AF_NS 6 /* XEROX NS protocols */ | |
541 | #define AF_ISO 7 /* ISO protocols */ | |
542 | #define AF_OSI AF_ISO | |
9bccf70c | 543 | #define AF_ECMA 8 /* European computer manufacturers */ |
1c79356b A |
544 | #define AF_DATAKIT 9 /* datakit protocols */ |
545 | #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ | |
546 | #define AF_SNA 11 /* IBM SNA */ | |
39037602 A |
547 | #define AF_DECnet 12 /* DECnet */ |
548 | #define AF_DLI 13 /* DEC Direct data link interface */ | |
549 | #define AF_LAT 14 /* LAT */ | |
1c79356b A |
550 | #define AF_HYLINK 15 /* NSC Hyperchannel */ |
551 | #define AF_APPLETALK 16 /* Apple Talk */ | |
552 | #define AF_ROUTE 17 /* Internal Routing Protocol */ | |
553 | #define AF_LINK 18 /* Link layer interface */ | |
554 | #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ | |
555 | #define AF_COIP 20 /* connection-oriented IP, aka ST II */ | |
556 | #define AF_CNT 21 /* Computer Network Technology */ | |
39037602 | 557 | #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ |
1c79356b A |
558 | #define AF_IPX 23 /* Novell Internet Protocol */ |
559 | #define AF_SIP 24 /* Simple Internet Protocol */ | |
39037602 A |
560 | #define pseudo_AF_PIP 25 /* Help Identify PIP packets */ |
561 | #define AF_NDRV 27 /* Network Driver 'raw' access */ | |
562 | #define AF_ISDN 28 /* Integrated Services Digital Network */ | |
1c79356b A |
563 | #define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ |
564 | #define pseudo_AF_KEY 29 /* Internal key-management function */ | |
2d21ac55 | 565 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b | 566 | #define AF_INET6 30 /* IPv6 */ |
2d21ac55 | 567 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b | 568 | #define AF_NATM 31 /* native ATM access */ |
39037602 A |
569 | #define AF_SYSTEM 32 /* Kernel event messages */ |
570 | #define AF_NETBIOS 33 /* NetBIOS */ | |
571 | #define AF_PPP 34 /* PPP communication protocol */ | |
572 | #define pseudo_AF_HDRCMPLT 35 /* Used by BPF to not rewrite headers | |
573 | in interface output routine */ | |
91447636 | 574 | #ifdef PRIVATE |
39037602 | 575 | #define AF_AFP 36 /* Used by AFP */ |
91447636 | 576 | #else |
39037602 | 577 | #define AF_RESERVED_36 36 /* Reserved for internal usage */ |
91447636 | 578 | #endif |
39037602 A |
579 | #define AF_IEEE80211 37 /* IEEE 802.11 protocol */ |
580 | #define AF_UTUN 38 | |
39236c6e A |
581 | #ifdef PRIVATE |
582 | #define AF_MULTIPATH 39 | |
583 | #endif /* PRIVATE */ | |
584 | #define AF_MAX 40 | |
2d21ac55 | 585 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
586 | |
587 | /* | |
91447636 | 588 | * [XSI] Structure used by kernel to store most addresses. |
1c79356b A |
589 | */ |
590 | struct sockaddr { | |
91447636 A |
591 | __uint8_t sa_len; /* total length */ |
592 | sa_family_t sa_family; /* [XSI] address family */ | |
593 | char sa_data[14]; /* [XSI] addr value (actually larger) */ | |
1c79356b | 594 | }; |
91447636 | 595 | |
2d21ac55 | 596 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
597 | #define SOCK_MAXADDRLEN 255 /* longest possible addresses */ |
598 | ||
599 | /* | |
600 | * Structure used by kernel to pass protocol | |
601 | * information in raw sockets. | |
602 | */ | |
603 | struct sockproto { | |
91447636 A |
604 | __uint16_t sp_family; /* address family */ |
605 | __uint16_t sp_protocol; /* protocol */ | |
1c79356b | 606 | }; |
39037602 | 607 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b | 608 | |
1c79356b | 609 | /* |
9bccf70c | 610 | * RFC 2553: protocol-independent placeholder for socket addresses |
1c79356b | 611 | */ |
9bccf70c | 612 | #define _SS_MAXSIZE 128 |
91447636 A |
613 | #define _SS_ALIGNSIZE (sizeof(__int64_t)) |
614 | #define _SS_PAD1SIZE \ | |
615 | (_SS_ALIGNSIZE - sizeof(__uint8_t) - sizeof(sa_family_t)) | |
616 | #define _SS_PAD2SIZE \ | |
617 | (_SS_MAXSIZE - sizeof(__uint8_t) - sizeof(sa_family_t) - \ | |
1c79356b A |
618 | _SS_PAD1SIZE - _SS_ALIGNSIZE) |
619 | ||
91447636 A |
620 | /* |
621 | * [XSI] sockaddr_storage | |
622 | */ | |
1c79356b | 623 | struct sockaddr_storage { |
91447636 A |
624 | __uint8_t ss_len; /* address length */ |
625 | sa_family_t ss_family; /* [XSI] address family */ | |
9bccf70c | 626 | char __ss_pad1[_SS_PAD1SIZE]; |
91447636 | 627 | __int64_t __ss_align; /* force structure storage alignment */ |
9bccf70c | 628 | char __ss_pad2[_SS_PAD2SIZE]; |
1c79356b | 629 | }; |
1c79356b | 630 | |
39236c6e A |
631 | #ifdef BSD_KERNEL_PRIVATE |
632 | #include <sys/queue.h> | |
633 | ||
634 | struct sockaddr_entry { | |
635 | TAILQ_ENTRY(sockaddr_entry) se_link; | |
636 | struct sockaddr *se_addr; | |
637 | uint32_t se_flags; | |
638 | }; | |
639 | ||
640 | #define SEF_ATTACHED 1 /* attached to sockaddr_list */ | |
641 | ||
642 | struct sockaddr_list { | |
643 | TAILQ_HEAD(, sockaddr_entry) sl_head; | |
644 | uint32_t sl_cnt; | |
645 | ||
646 | }; | |
647 | #endif /* BSD_KERNEL_PRIVATE */ | |
648 | ||
1c79356b A |
649 | /* |
650 | * Protocol families, same as address families for now. | |
651 | */ | |
652 | #define PF_UNSPEC AF_UNSPEC | |
653 | #define PF_LOCAL AF_LOCAL | |
654 | #define PF_UNIX PF_LOCAL /* backward compatibility */ | |
655 | #define PF_INET AF_INET | |
1c79356b A |
656 | #define PF_IMPLINK AF_IMPLINK |
657 | #define PF_PUP AF_PUP | |
658 | #define PF_CHAOS AF_CHAOS | |
659 | #define PF_NS AF_NS | |
660 | #define PF_ISO AF_ISO | |
661 | #define PF_OSI AF_ISO | |
662 | #define PF_ECMA AF_ECMA | |
663 | #define PF_DATAKIT AF_DATAKIT | |
664 | #define PF_CCITT AF_CCITT | |
665 | #define PF_SNA AF_SNA | |
39037602 A |
666 | #define PF_DECnet AF_DECnet |
667 | #define PF_DLI AF_DLI | |
668 | #define PF_LAT AF_LAT | |
1c79356b A |
669 | #define PF_HYLINK AF_HYLINK |
670 | #define PF_APPLETALK AF_APPLETALK | |
671 | #define PF_ROUTE AF_ROUTE | |
672 | #define PF_LINK AF_LINK | |
673 | #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ | |
674 | #define PF_COIP AF_COIP | |
675 | #define PF_CNT AF_CNT | |
676 | #define PF_SIP AF_SIP | |
677 | #define PF_IPX AF_IPX /* same format as AF_NS */ | |
39037602 A |
678 | #define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ |
679 | #define PF_PIP pseudo_AF_PIP | |
680 | #define PF_NDRV AF_NDRV | |
1c79356b A |
681 | #define PF_ISDN AF_ISDN |
682 | #define PF_KEY pseudo_AF_KEY | |
683 | #define PF_INET6 AF_INET6 | |
684 | #define PF_NATM AF_NATM | |
39037602 A |
685 | #define PF_SYSTEM AF_SYSTEM |
686 | #define PF_NETBIOS AF_NETBIOS | |
687 | #define PF_PPP AF_PPP | |
91447636 | 688 | #ifdef PRIVATE |
39037602 | 689 | #define PF_AFP AF_AFP |
91447636 | 690 | #else |
39037602 | 691 | #define PF_RESERVED_36 AF_RESERVED_36 |
91447636 | 692 | #endif |
39037602 | 693 | #define PF_UTUN AF_UTUN |
39236c6e A |
694 | #ifdef PRIVATE |
695 | #define PF_MULTIPATH AF_MULTIPATH | |
696 | #endif /* PRIVATE */ | |
1c79356b A |
697 | #define PF_MAX AF_MAX |
698 | ||
91447636 A |
699 | /* |
700 | * These do not have socket-layer support: | |
701 | */ | |
702 | #define PF_VLAN ((uint32_t)0x766c616e) /* 'vlan' */ | |
39037602 | 703 | #define PF_BOND ((uint32_t)0x626f6e64) /* 'bond' */ |
6d2010ae | 704 | #ifdef KERNEL_PRIVATE |
39037602 | 705 | #define PF_BRIDGE ((uint32_t)0x62726467) /* 'brdg' */ |
6d2010ae | 706 | #endif /* KERNEL_PRIVATE */ |
91447636 | 707 | |
1c79356b A |
708 | /* |
709 | * Definitions for network related sysctl, CTL_NET. | |
710 | * | |
711 | * Second level is protocol family. | |
712 | * Third level is protocol number. | |
713 | * | |
714 | * Further levels are defined by the individual families below. | |
715 | */ | |
2d21ac55 | 716 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
39037602 | 717 | #define NET_MAXID AF_MAX |
2d21ac55 | 718 | #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ |
91447636 A |
719 | |
720 | #ifdef KERNEL_PRIVATE | |
39037602 | 721 | #define CTL_NET_NAMES { \ |
1c79356b A |
722 | { 0, 0 }, \ |
723 | { "local", CTLTYPE_NODE }, \ | |
724 | { "inet", CTLTYPE_NODE }, \ | |
725 | { "implink", CTLTYPE_NODE }, \ | |
726 | { "pup", CTLTYPE_NODE }, \ | |
727 | { "chaos", CTLTYPE_NODE }, \ | |
728 | { "xerox_ns", CTLTYPE_NODE }, \ | |
729 | { "iso", CTLTYPE_NODE }, \ | |
730 | { "emca", CTLTYPE_NODE }, \ | |
731 | { "datakit", CTLTYPE_NODE }, \ | |
732 | { "ccitt", CTLTYPE_NODE }, \ | |
733 | { "ibm_sna", CTLTYPE_NODE }, \ | |
734 | { "decnet", CTLTYPE_NODE }, \ | |
735 | { "dec_dli", CTLTYPE_NODE }, \ | |
736 | { "lat", CTLTYPE_NODE }, \ | |
737 | { "hylink", CTLTYPE_NODE }, \ | |
738 | { "appletalk", CTLTYPE_NODE }, \ | |
739 | { "route", CTLTYPE_NODE }, \ | |
740 | { "link_layer", CTLTYPE_NODE }, \ | |
741 | { "xtp", CTLTYPE_NODE }, \ | |
742 | { "coip", CTLTYPE_NODE }, \ | |
743 | { "cnt", CTLTYPE_NODE }, \ | |
744 | { "rtip", CTLTYPE_NODE }, \ | |
745 | { "ipx", CTLTYPE_NODE }, \ | |
746 | { "sip", CTLTYPE_NODE }, \ | |
747 | { "pip", CTLTYPE_NODE }, \ | |
9bccf70c A |
748 | { 0, 0 }, \ |
749 | { "ndrv", CTLTYPE_NODE }, \ | |
1c79356b A |
750 | { "isdn", CTLTYPE_NODE }, \ |
751 | { "key", CTLTYPE_NODE }, \ | |
752 | { "inet6", CTLTYPE_NODE }, \ | |
753 | { "natm", CTLTYPE_NODE }, \ | |
9bccf70c A |
754 | { "sys", CTLTYPE_NODE }, \ |
755 | { "netbios", CTLTYPE_NODE }, \ | |
756 | { "ppp", CTLTYPE_NODE }, \ | |
757 | { "hdrcomplete", CTLTYPE_NODE }, \ | |
1c79356b | 758 | } |
2d21ac55 | 759 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 760 | |
2d21ac55 | 761 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
762 | /* |
763 | * PF_ROUTE - Routing table | |
764 | * | |
765 | * Three additional levels are defined: | |
766 | * Fourth: address family, 0 is wildcard | |
767 | * Fifth: type of info, defined below | |
768 | * Sixth: flag(s) to mask with for NET_RT_FLAGS | |
769 | */ | |
39037602 A |
770 | #define NET_RT_DUMP 1 /* dump; may limit to a.f. */ |
771 | #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ | |
772 | #define NET_RT_IFLIST 3 /* survey interface list */ | |
773 | #define NET_RT_STAT 4 /* routing statistics */ | |
774 | #define NET_RT_TRASH 5 /* routes not in table but not freed */ | |
775 | #define NET_RT_IFLIST2 6 /* interface list with addresses */ | |
776 | #define NET_RT_DUMP2 7 /* dump; may limit to a.f. */ | |
6d2010ae A |
777 | #ifdef PRIVATE |
778 | #define NET_RT_DUMPX 8 /* private */ | |
779 | #define NET_RT_DUMPX_FLAGS 9 /* private */ | |
780 | #endif /* PRIVATE */ | |
781 | #define NET_RT_MAXID 10 | |
2d21ac55 | 782 | #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ |
91447636 A |
783 | |
784 | #ifdef KERNEL_PRIVATE | |
39037602 | 785 | #define CTL_NET_RT_NAMES { \ |
1c79356b A |
786 | { 0, 0 }, \ |
787 | { "dump", CTLTYPE_STRUCT }, \ | |
788 | { "flags", CTLTYPE_STRUCT }, \ | |
789 | { "iflist", CTLTYPE_STRUCT }, \ | |
91447636 A |
790 | { "stat", CTLTYPE_STRUCT }, \ |
791 | { "trash", CTLTYPE_INT }, \ | |
792 | { "iflist2", CTLTYPE_STRUCT }, \ | |
39037602 A |
793 | { "dump2", CTLTYPE_STRUCT }, \ |
794 | { "dumpx", CTLTYPE_STRUCT }, \ | |
795 | { "dumpx_flags", CTLTYPE_STRUCT }, \ | |
1c79356b A |
796 | } |
797 | ||
2d21ac55 | 798 | #endif /* KERNEL_PRIVATE */ |
91447636 | 799 | |
1c79356b A |
800 | /* |
801 | * Maximum queue length specifiable by listen. | |
802 | */ | |
803 | #define SOMAXCONN 128 | |
804 | ||
805 | /* | |
91447636 | 806 | * [XSI] Message header for recvmsg and sendmsg calls. |
1c79356b A |
807 | * Used value-result for recvmsg, value only for sendmsg. |
808 | */ | |
809 | struct msghdr { | |
91447636 A |
810 | void *msg_name; /* [XSI] optional address */ |
811 | socklen_t msg_namelen; /* [XSI] size of address */ | |
812 | struct iovec *msg_iov; /* [XSI] scatter/gather array */ | |
813 | int msg_iovlen; /* [XSI] # elements in msg_iov */ | |
814 | void *msg_control; /* [XSI] ancillary data, see below */ | |
815 | socklen_t msg_controllen; /* [XSI] ancillary data buffer len */ | |
816 | int msg_flags; /* [XSI] flags on received message */ | |
817 | }; | |
818 | ||
fe8ab488 A |
819 | #ifdef PRIVATE |
820 | /* | |
821 | * Extended version for sendmsg_x() and recvmsg_x() calls | |
822 | * | |
823 | * For recvmsg_x(), the size of the data received is given by the field | |
824 | * msg_datalen. | |
825 | * | |
39037602 | 826 | * For sendmsg_x(), the size of the data to send is given by the length of |
fe8ab488 A |
827 | * the iovec array -- like sendmsg(). The field msg_datalen is ignored. |
828 | */ | |
829 | struct msghdr_x { | |
830 | void *msg_name; /* optional address */ | |
831 | socklen_t msg_namelen; /* size of address */ | |
832 | struct iovec *msg_iov; /* scatter/gather array */ | |
833 | int msg_iovlen; /* # elements in msg_iov */ | |
834 | void *msg_control; /* ancillary data, see below */ | |
835 | socklen_t msg_controllen; /* ancillary data buffer len */ | |
836 | int msg_flags; /* flags on received message */ | |
837 | size_t msg_datalen; /* byte length of buffer in msg_iov */ | |
838 | }; | |
839 | #endif /* PRIVATE */ | |
840 | ||
841 | #ifdef XNU_KERNEL_PRIVATE | |
b0d623f7 A |
842 | /* |
843 | * In-kernel representation of "struct msghdr" from | |
844 | * userspace. Has enough precision for 32-bit or | |
845 | * 64-bit clients, but does not need to be packed. | |
91447636 | 846 | */ |
91447636 A |
847 | |
848 | struct user_msghdr { | |
849 | user_addr_t msg_name; /* optional address */ | |
55e303ae | 850 | socklen_t msg_namelen; /* size of address */ |
b0d623f7 A |
851 | user_addr_t msg_iov; /* scatter/gather array */ |
852 | int msg_iovlen; /* # elements in msg_iov */ | |
853 | user_addr_t msg_control; /* ancillary data, see below */ | |
854 | socklen_t msg_controllen; /* ancillary data buffer len */ | |
855 | int msg_flags; /* flags on received message */ | |
856 | }; | |
857 | ||
858 | /* | |
859 | * LP64 user version of struct msghdr. | |
860 | * WARNING - keep in sync with struct msghdr | |
861 | */ | |
862 | ||
863 | struct user64_msghdr { | |
864 | user64_addr_t msg_name; /* optional address */ | |
865 | socklen_t msg_namelen; /* size of address */ | |
866 | user64_addr_t msg_iov; /* scatter/gather array */ | |
91447636 | 867 | int msg_iovlen; /* # elements in msg_iov */ |
b0d623f7 | 868 | user64_addr_t msg_control; /* ancillary data, see below */ |
55e303ae A |
869 | socklen_t msg_controllen; /* ancillary data buffer len */ |
870 | int msg_flags; /* flags on received message */ | |
1c79356b A |
871 | }; |
872 | ||
b0d623f7 A |
873 | /* |
874 | * ILP32 user version of struct msghdr. | |
875 | * WARNING - keep in sync with struct msghdr | |
876 | */ | |
877 | ||
878 | struct user32_msghdr { | |
879 | user32_addr_t msg_name; /* optional address */ | |
880 | socklen_t msg_namelen; /* size of address */ | |
881 | user32_addr_t msg_iov; /* scatter/gather array */ | |
882 | int msg_iovlen; /* # elements in msg_iov */ | |
883 | user32_addr_t msg_control; /* ancillary data, see below */ | |
884 | socklen_t msg_controllen; /* ancillary data buffer len */ | |
885 | int msg_flags; /* flags on received message */ | |
886 | }; | |
887 | ||
fe8ab488 A |
888 | /* |
889 | * In-kernel representation of "struct msghdr_x" from | |
890 | * userspace. Has enough precision for 32-bit or | |
891 | * 64-bit clients, but does not need to be packed. | |
892 | */ | |
893 | ||
894 | struct user_msghdr_x { | |
895 | user_addr_t msg_name; /* optional address */ | |
896 | socklen_t msg_namelen; /* size of address */ | |
897 | user_addr_t msg_iov; /* scatter/gather array */ | |
898 | int msg_iovlen; /* # elements in msg_iov */ | |
899 | user_addr_t msg_control; /* ancillary data, see below */ | |
900 | socklen_t msg_controllen; /* ancillary data buffer len */ | |
901 | int msg_flags; /* flags on received message */ | |
902 | size_t msg_datalen; /* byte length of buffer in msg_iov */ | |
903 | }; | |
904 | ||
905 | /* | |
906 | * LP64 user version of struct msghdr_x | |
907 | * WARNING - keep in sync with struct msghdr_x | |
908 | */ | |
909 | ||
910 | struct user64_msghdr_x { | |
911 | user64_addr_t msg_name; /* optional address */ | |
912 | socklen_t msg_namelen; /* size of address */ | |
913 | user64_addr_t msg_iov; /* scatter/gather array */ | |
914 | int msg_iovlen; /* # elements in msg_iov */ | |
915 | user64_addr_t msg_control; /* ancillary data, see below */ | |
916 | socklen_t msg_controllen; /* ancillary data buffer len */ | |
917 | int msg_flags; /* flags on received message */ | |
918 | user64_size_t msg_datalen; /* byte length of buffer in msg_iov */ | |
919 | }; | |
920 | ||
921 | /* | |
922 | * ILP32 user version of struct msghdr_x | |
923 | * WARNING - keep in sync with struct msghdr_x | |
924 | */ | |
925 | ||
926 | struct user32_msghdr_x { | |
927 | user32_addr_t msg_name; /* optional address */ | |
928 | socklen_t msg_namelen; /* size of address */ | |
929 | user32_addr_t msg_iov; /* scatter/gather array */ | |
930 | int msg_iovlen; /* # elements in msg_iov */ | |
931 | user32_addr_t msg_control; /* ancillary data, see below */ | |
932 | socklen_t msg_controllen; /* ancillary data buffer len */ | |
933 | int msg_flags; /* flags on received message */ | |
934 | user32_size_t msg_datalen; /* byte length of buffer in msg_iov */ | |
935 | }; | |
936 | ||
3e170ce0 A |
937 | /* |
938 | * In-kernel representation of "struct sa_endpoints" from | |
939 | * userspace. Has enough precision for 32-bit or | |
940 | * 64-bit clients, but does not need to be packed. | |
941 | */ | |
942 | ||
943 | struct user_sa_endpoints { | |
944 | unsigned int sae_srcif; /* optional source interface */ | |
945 | user_addr_t sae_srcaddr; /* optional source address */ | |
946 | socklen_t sae_srcaddrlen; /* size of source address */ | |
947 | user_addr_t sae_dstaddr; /* destination address */ | |
948 | socklen_t sae_dstaddrlen; /* size of destination address */ | |
949 | }; | |
950 | ||
951 | /* | |
952 | * LP64 user version of struct sa_endpoints | |
953 | * WARNING - keep in sync with struct sa_endpoints | |
954 | */ | |
955 | ||
956 | struct user64_sa_endpoints { | |
957 | unsigned int sae_srcif; /* optional source interface */ | |
958 | user64_addr_t sae_srcaddr; /* optional source address */ | |
959 | socklen_t sae_srcaddrlen; /* size of source address */ | |
960 | user64_addr_t sae_dstaddr; /* destination address */ | |
961 | socklen_t sae_dstaddrlen; /* size of destination address */ | |
962 | }; | |
963 | ||
964 | /* | |
965 | * ILP32 user version of struct sa_endpoints | |
966 | * WARNING - keep in sync with struct sa_endpoints | |
967 | */ | |
968 | ||
969 | struct user32_sa_endpoints { | |
970 | unsigned int sae_srcif; /* optional source interface */ | |
971 | user32_addr_t sae_srcaddr; /* optional source address */ | |
972 | socklen_t sae_srcaddrlen; /* size of source address */ | |
973 | user32_addr_t sae_dstaddr; /* destination address */ | |
974 | socklen_t sae_dstaddrlen; /* size of destination address */ | |
975 | }; | |
976 | ||
fe8ab488 | 977 | #endif /* XNU_KERNEL_PRIVATE */ |
91447636 | 978 | |
1c79356b A |
979 | #define MSG_OOB 0x1 /* process out-of-band data */ |
980 | #define MSG_PEEK 0x2 /* peek at incoming message */ | |
981 | #define MSG_DONTROUTE 0x4 /* send without using routing tables */ | |
982 | #define MSG_EOR 0x8 /* data completes record */ | |
983 | #define MSG_TRUNC 0x10 /* data discarded before delivery */ | |
984 | #define MSG_CTRUNC 0x20 /* control data lost before delivery */ | |
985 | #define MSG_WAITALL 0x40 /* wait for full request or error */ | |
2d21ac55 | 986 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
987 | #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ |
988 | #define MSG_EOF 0x100 /* data completes connection */ | |
9bccf70c | 989 | #ifdef __APPLE__ |
6d2010ae A |
990 | #ifndef PRIVATE |
991 | #ifdef __APPLE_API_OBSOLETE | |
39037602 | 992 | #define MSG_WAITSTREAM 0x200 /* wait up to full request.. may return partial */ |
6d2010ae A |
993 | #endif |
994 | #else | |
39037602 | 995 | #define MSG_WAITSTREAM 0x200 /* wait up to full request.. may return partial */ |
6d2010ae | 996 | #endif |
39037602 A |
997 | #define MSG_FLUSH 0x400 /* Start of 'hold' seq; dump so_temp */ |
998 | #define MSG_HOLD 0x800 /* Hold frag in so_temp */ | |
999 | #define MSG_SEND 0x1000 /* Send the packet in so_temp */ | |
1000 | #define MSG_HAVEMORE 0x2000 /* Data ready to be read */ | |
1001 | #define MSG_RCVMORE 0x4000 /* Data remains in current pkt */ | |
9bccf70c | 1002 | #endif |
2d21ac55 | 1003 | #ifdef KERNEL_PRIVATE |
39037602 | 1004 | #define MSG_COMPAT 0x8000 /* deprecated */ |
2d21ac55 | 1005 | #endif /* KERNEL_PRIVATE */ |
39037602 | 1006 | #define MSG_NEEDSA 0x10000 /* Fail receive if socket address cannot be allocated */ |
91447636 | 1007 | #ifdef KERNEL_PRIVATE |
39037602 A |
1008 | #define MSG_NBIO 0x20000 /* FIONBIO mode, used by fifofs */ |
1009 | #define MSG_SKIPCFIL 0x40000 /* skip pass content filter */ | |
91447636 A |
1010 | #endif |
1011 | #ifdef KERNEL | |
39037602 | 1012 | #define MSG_USEUPCALL 0x80000000 /* Inherit upcall in sock_accept */ |
91447636 | 1013 | #endif |
2d21ac55 | 1014 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
1015 | |
1016 | /* | |
1017 | * Header for ancillary data objects in msg_control buffer. | |
1018 | * Used for additional information with/about a datagram | |
1019 | * not expressible by flags. The format is a sequence | |
1020 | * of message elements headed by cmsghdr structures. | |
1021 | */ | |
1022 | struct cmsghdr { | |
91447636 A |
1023 | socklen_t cmsg_len; /* [XSI] data byte count, including hdr */ |
1024 | int cmsg_level; /* [XSI] originating protocol */ | |
1025 | int cmsg_type; /* [XSI] protocol-specific type */ | |
1026 | /* followed by unsigned char cmsg_data[]; */ | |
1c79356b A |
1027 | }; |
1028 | ||
2d21ac55 | 1029 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c A |
1030 | #ifndef __APPLE__ |
1031 | /* | |
1032 | * While we may have more groups than this, the cmsgcred struct must | |
1033 | * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow | |
1034 | * this. | |
39037602 A |
1035 | */ |
1036 | #define CMGROUP_MAX 16 | |
1c79356b | 1037 | |
9bccf70c A |
1038 | /* |
1039 | * Credentials structure, used to verify the identity of a peer | |
1040 | * process that has sent us a message. This is allocated by the | |
1041 | * peer process but filled in by the kernel. This prevents the | |
1042 | * peer from lying about its identity. (Note that cmcred_groups[0] | |
1043 | * is the effective GID.) | |
1c79356b | 1044 | */ |
9bccf70c A |
1045 | struct cmsgcred { |
1046 | pid_t cmcred_pid; /* PID of sending process */ | |
1047 | uid_t cmcred_uid; /* real UID of sending process */ | |
1048 | uid_t cmcred_euid; /* effective UID of sending process */ | |
1049 | gid_t cmcred_gid; /* real GID of sending process */ | |
1050 | short cmcred_ngroups; /* number or groups */ | |
1051 | gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ | |
1052 | }; | |
1053 | #endif | |
2d21ac55 | 1054 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
9bccf70c A |
1055 | |
1056 | /* given pointer to struct cmsghdr, return pointer to data */ | |
91447636 | 1057 | #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ |
39037602 | 1058 | __DARWIN_ALIGN32(sizeof(struct cmsghdr))) |
1c79356b | 1059 | |
b0d623f7 A |
1060 | /* |
1061 | * RFC 2292 requires to check msg_controllen, in case that the kernel returns | |
1062 | * an empty list for some reasons. | |
1063 | */ | |
39037602 A |
1064 | #define CMSG_FIRSTHDR(mhdr) \ |
1065 | ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ | |
1066 | (struct cmsghdr *)(mhdr)->msg_control : \ | |
1067 | (struct cmsghdr *)0L) | |
b0d623f7 | 1068 | |
1c79356b | 1069 | |
39037602 | 1070 | /* |
b0d623f7 A |
1071 | * Given pointer to struct cmsghdr, return pointer to next cmsghdr |
1072 | * RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) | |
1073 | */ | |
1074 | #define CMSG_NXTHDR(mhdr, cmsg) \ | |
1075 | ((char *)(cmsg) == (char *)0L ? CMSG_FIRSTHDR(mhdr) : \ | |
39037602 | 1076 | ((((unsigned char *)(cmsg) + \ |
b0d623f7 A |
1077 | __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len) + \ |
1078 | __DARWIN_ALIGN32(sizeof(struct cmsghdr))) > \ | |
1079 | ((unsigned char *)(mhdr)->msg_control + \ | |
39037602 A |
1080 | (mhdr)->msg_controllen)) ? \ |
1081 | (struct cmsghdr *)0L /* NULL */ : \ | |
1082 | (struct cmsghdr *)(void *)((unsigned char *)(cmsg) + \ | |
1083 | __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len)))) | |
1c79356b | 1084 | |
2d21ac55 | 1085 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c | 1086 | /* RFC 2292 additions */ |
cf7d32b8 A |
1087 | #define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) |
1088 | #define CMSG_LEN(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + (l)) | |
9bccf70c A |
1089 | |
1090 | #ifdef KERNEL | |
b0d623f7 | 1091 | #define CMSG_ALIGN(n) __DARWIN_ALIGN32(n) |
9bccf70c | 1092 | #endif |
2d21ac55 | 1093 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
1094 | |
1095 | /* "Socket"-level control message types: */ | |
6d2010ae | 1096 | #define SCM_RIGHTS 0x01 /* access rights (array of int) */ |
2d21ac55 | 1097 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
6d2010ae A |
1098 | #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ |
1099 | #define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ | |
39037602 | 1100 | #define SCM_TIMESTAMP_MONOTONIC 0x04 /* timestamp (uint64_t) */ |
1c79356b | 1101 | |
39236c6e | 1102 | #ifdef PRIVATE |
39037602 A |
1103 | #define SCM_SEQNUM 0x05 /* TCP unordered recv seq no */ |
1104 | #define SCM_MSG_PRIORITY 0x06 /* TCP unordered snd priority */ | |
39236c6e A |
1105 | #endif /* PRIVATE */ |
1106 | ||
2d21ac55 | 1107 | #ifdef KERNEL_PRIVATE |
1c79356b | 1108 | /* |
2d21ac55 | 1109 | * 4.3 compat sockaddr (deprecated) |
1c79356b A |
1110 | */ |
1111 | struct osockaddr { | |
91447636 | 1112 | __uint16_t sa_family; /* address family */ |
1c79356b A |
1113 | char sa_data[14]; /* up to 14 bytes of direct address */ |
1114 | }; | |
1115 | ||
1116 | /* | |
2d21ac55 | 1117 | * 4.3-compat message header (deprecated) |
1c79356b A |
1118 | */ |
1119 | struct omsghdr { | |
91447636 A |
1120 | void *msg_name; /* optional address */ |
1121 | socklen_t msg_namelen; /* size of address */ | |
1122 | struct iovec *msg_iov; /* scatter/gather array */ | |
1123 | int msg_iovlen; /* # elements in msg_iov */ | |
1124 | void *msg_accrights; /* access rights sent/rcvd */ | |
1125 | int msg_accrightslen; | |
1c79356b | 1126 | }; |
316670eb A |
1127 | |
1128 | #define SA(s) ((struct sockaddr *)(void *)(s)) | |
2d21ac55 A |
1129 | #endif /* KERNEL_PRIVATE */ |
1130 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ | |
1c79356b A |
1131 | |
1132 | /* | |
1133 | * howto arguments for shutdown(2), specified by Posix.1g. | |
1134 | */ | |
1135 | #define SHUT_RD 0 /* shut down the reading side */ | |
1136 | #define SHUT_WR 1 /* shut down the writing side */ | |
1137 | #define SHUT_RDWR 2 /* shut down both sides */ | |
1138 | ||
2d21ac55 | 1139 | #if !defined(_POSIX_C_SOURCE) |
1c79356b A |
1140 | /* |
1141 | * sendfile(2) header/trailer struct | |
1142 | */ | |
1143 | struct sf_hdtr { | |
1144 | struct iovec *headers; /* pointer to an array of header struct iovec's */ | |
1145 | int hdr_cnt; /* number of header iovec's */ | |
1146 | struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ | |
1147 | int trl_cnt; /* number of trailer iovec's */ | |
1148 | }; | |
2d21ac55 A |
1149 | |
1150 | #ifdef KERNEL | |
1151 | ||
b0d623f7 | 1152 | /* In-kernel representation */ |
2d21ac55 | 1153 | struct user_sf_hdtr { |
b0d623f7 | 1154 | user_addr_t headers; /* pointer to an array of header struct iovec's */ |
2d21ac55 | 1155 | int hdr_cnt; /* number of header iovec's */ |
b0d623f7 | 1156 | user_addr_t trailers; /* pointer to an array of trailer struct iovec's */ |
2d21ac55 A |
1157 | int trl_cnt; /* number of trailer iovec's */ |
1158 | }; | |
1159 | ||
b0d623f7 A |
1160 | /* LP64 user version of struct sf_hdtr */ |
1161 | struct user64_sf_hdtr { | |
1162 | user64_addr_t headers; /* pointer to an array of header struct iovec's */ | |
1163 | int hdr_cnt; /* number of header iovec's */ | |
1164 | user64_addr_t trailers; /* pointer to an array of trailer struct iovec's */ | |
1165 | int trl_cnt; /* number of trailer iovec's */ | |
1166 | }; | |
1167 | ||
1168 | /* ILP32 user version of struct sf_hdtr */ | |
1169 | struct user32_sf_hdtr { | |
1170 | user32_addr_t headers; /* pointer to an array of header struct iovec's */ | |
1171 | int hdr_cnt; /* number of header iovec's */ | |
1172 | user32_addr_t trailers; /* pointer to an array of trailer struct iovec's */ | |
1173 | int trl_cnt; /* number of trailer iovec's */ | |
1174 | }; | |
2d21ac55 A |
1175 | |
1176 | #endif /* KERNEL */ | |
1177 | ||
91447636 | 1178 | #endif /* !_POSIX_C_SOURCE */ |
1c79356b | 1179 | |
39236c6e A |
1180 | #ifdef PRIVATE |
1181 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) | |
39236c6e A |
1182 | |
1183 | /* | |
1184 | * Structure for SIOCGASSOCIDS | |
1185 | */ | |
1186 | struct so_aidreq { | |
1187 | __uint32_t sar_cnt; /* number of associations */ | |
3e170ce0 | 1188 | sae_associd_t *sar_aidp; /* array of association IDs */ |
39236c6e A |
1189 | }; |
1190 | ||
1191 | #ifdef BSD_KERNEL_PRIVATE | |
1192 | struct so_aidreq32 { | |
1193 | __uint32_t sar_cnt; | |
1194 | user32_addr_t sar_aidp; | |
1195 | }; | |
1196 | ||
1197 | struct so_aidreq64 { | |
1198 | __uint32_t sar_cnt; | |
1199 | user64_addr_t sar_aidp __attribute__((aligned(8))); | |
1200 | }; | |
1201 | #endif /* BSD_KERNEL_PRIVATE */ | |
1202 | ||
1203 | /* | |
1204 | * Structure for SIOCGCONNIDS | |
1205 | */ | |
1206 | struct so_cidreq { | |
3e170ce0 | 1207 | sae_associd_t scr_aid; /* association ID */ |
39236c6e | 1208 | __uint32_t scr_cnt; /* number of connections */ |
3e170ce0 | 1209 | sae_connid_t *scr_cidp; /* array of connection IDs */ |
39236c6e A |
1210 | }; |
1211 | ||
1212 | #ifdef BSD_KERNEL_PRIVATE | |
1213 | struct so_cidreq32 { | |
3e170ce0 | 1214 | sae_associd_t scr_aid; |
39236c6e A |
1215 | __uint32_t scr_cnt; |
1216 | user32_addr_t scr_cidp; | |
1217 | }; | |
1218 | ||
1219 | struct so_cidreq64 { | |
3e170ce0 | 1220 | sae_associd_t scr_aid; |
39236c6e A |
1221 | __uint32_t scr_cnt; |
1222 | user64_addr_t scr_cidp __attribute__((aligned(8))); | |
1223 | }; | |
1224 | #endif /* BSD_KERNEL_PRIVATE */ | |
1225 | ||
1226 | /* | |
1227 | * Structure for SIOCGCONNINFO | |
1228 | */ | |
1229 | struct so_cinforeq { | |
3e170ce0 | 1230 | sae_connid_t scir_cid; /* connection ID */ |
39236c6e A |
1231 | __uint32_t scir_flags; /* see flags below */ |
1232 | __uint32_t scir_ifindex; /* (last) outbound interface */ | |
1233 | __int32_t scir_error; /* most recent error */ | |
1234 | struct sockaddr *scir_src; /* source address */ | |
1235 | socklen_t scir_src_len; /* source address len */ | |
1236 | struct sockaddr *scir_dst; /* destination address */ | |
1237 | socklen_t scir_dst_len; /* destination address len */ | |
1238 | __uint32_t scir_aux_type; /* aux data type (CIAUX) */ | |
1239 | void *scir_aux_data; /* aux data */ | |
1240 | __uint32_t scir_aux_len; /* aux data len */ | |
1241 | }; | |
1242 | ||
1243 | #ifdef BSD_KERNEL_PRIVATE | |
1244 | struct so_cinforeq32 { | |
3e170ce0 | 1245 | sae_connid_t scir_cid; |
39236c6e A |
1246 | __uint32_t scir_flags; |
1247 | __uint32_t scir_ifindex; | |
1248 | __int32_t scir_error; | |
1249 | user32_addr_t scir_src; | |
1250 | socklen_t scir_src_len; | |
1251 | user32_addr_t scir_dst; | |
1252 | socklen_t scir_dst_len; | |
1253 | __uint32_t scir_aux_type; | |
1254 | user32_addr_t scir_aux_data; | |
1255 | __uint32_t scir_aux_len; | |
1256 | }; | |
1257 | ||
1258 | struct so_cinforeq64 { | |
3e170ce0 | 1259 | sae_connid_t scir_cid; |
39236c6e A |
1260 | __uint32_t scir_flags; |
1261 | __uint32_t scir_ifindex; | |
1262 | __int32_t scir_error; | |
1263 | user64_addr_t scir_src __attribute__((aligned(8))); | |
1264 | socklen_t scir_src_len; | |
1265 | user64_addr_t scir_dst __attribute__((aligned(8))); | |
1266 | socklen_t scir_dst_len; | |
1267 | __uint32_t scir_aux_type; | |
1268 | user64_addr_t scir_aux_data __attribute__((aligned(8))); | |
1269 | __uint32_t scir_aux_len; | |
1270 | }; | |
1271 | #endif /* BSD_KERNEL_PRIVATE */ | |
1272 | ||
1273 | /* valid connection info flags */ | |
1274 | #define CIF_CONNECTING 0x1 /* connection was attempted */ | |
1275 | #define CIF_CONNECTED 0x2 /* connection is established */ | |
1276 | #define CIF_DISCONNECTING 0x4 /* disconnection was attempted */ | |
1277 | #define CIF_DISCONNECTED 0x8 /* has been disconnected */ | |
1278 | #define CIF_BOUND_IF 0x10 /* bound to an interface */ | |
1279 | #define CIF_BOUND_IP 0x20 /* bound to a src address */ | |
1280 | #define CIF_BOUND_PORT 0x40 /* bound to a src port */ | |
1281 | #define CIF_PREFERRED 0x80 /* connection is primary/preferred */ | |
1282 | #define CIF_MP_CAPABLE 0x100 /* supports multipath protocol */ | |
1283 | #define CIF_MP_READY 0x200 /* multipath protocol confirmed */ | |
1284 | #define CIF_MP_DEGRADED 0x400 /* has lost its multipath capability */ | |
39037602 | 1285 | #define CIF_MP_ACTIVE 0x800 /* this is the active subflow */ |
39236c6e A |
1286 | |
1287 | /* valid connection info auxiliary data types */ | |
1288 | #define CIAUX_TCP 0x1 /* TCP auxiliary data (conninfo_tcp_t) */ | |
1289 | ||
1290 | /* | |
1291 | * Structure for SIOC{S,G}CONNORDER | |
1292 | */ | |
1293 | struct so_cordreq { | |
3e170ce0 | 1294 | sae_connid_t sco_cid; /* connection ID */ |
39236c6e A |
1295 | __uint32_t sco_rank; /* rank (0 means unspecified) */ |
1296 | }; | |
1297 | ||
39236c6e A |
1298 | /* |
1299 | * Common structure for KEV_NETPOLICY_SUBCLASS | |
1300 | */ | |
1301 | struct netpolicy_event_data { | |
1302 | __uint64_t eupid; /* effective unique PID */ | |
1303 | pid_t epid; /* effective PID */ | |
1304 | #if !defined(__LP64__) | |
1305 | __uint32_t pad; | |
1306 | #endif /* __LP64__ */ | |
1307 | uuid_t euuid; /* effective UUID */ | |
1308 | }; | |
1309 | ||
1310 | /* | |
1311 | * NETPOLICY_IFDENIED event structure | |
1312 | */ | |
1313 | struct kev_netpolicy_ifdenied { | |
1314 | struct netpolicy_event_data ev_data; | |
39037602 | 1315 | __uint32_t ev_if_functional_type; |
39236c6e A |
1316 | }; |
1317 | ||
fe8ab488 A |
1318 | /* |
1319 | * Common structure for KEV_SOCKET_SUBCLASS | |
1320 | */ | |
1321 | struct kev_socket_event_data { | |
1322 | struct sockaddr_storage kev_sockname; | |
1323 | struct sockaddr_storage kev_peername; | |
1324 | }; | |
1325 | ||
1326 | struct kev_socket_closed { | |
1327 | struct kev_socket_event_data ev_data; | |
1328 | }; | |
1329 | ||
39037602 A |
1330 | /* |
1331 | * Network Service Type to DiffServ Code Point mapping | |
1332 | */ | |
1333 | struct netsvctype_dscp_map { | |
1334 | int netsvctype; | |
1335 | u_int8_t dscp; /* 6 bits diffserv code point */ | |
1336 | }; | |
1337 | ||
39236c6e A |
1338 | #ifndef KERNEL |
1339 | __BEGIN_DECLS | |
3e170ce0 A |
1340 | |
1341 | extern int peeloff(int s, sae_associd_t); | |
39236c6e | 1342 | extern int socket_delegate(int, int, int, pid_t); |
fe8ab488 A |
1343 | |
1344 | /* | |
1345 | * recvmsg_x() is a system call similar to recvmsg(2) to receive | |
1346 | * several datagrams at once in the array of message headers "msgp". | |
1347 | * | |
1348 | * recvmsg_x() can be used only with protocols handlers that have been specially | |
3e170ce0 | 1349 | * modified to support sending and receiving several datagrams at once. |
39037602 | 1350 | * |
fe8ab488 A |
1351 | * The size of the array "msgp" is given by the argument "cnt". |
1352 | * | |
1353 | * The "flags" arguments supports only the value MSG_DONTWAIT. | |
39037602 | 1354 | * |
fe8ab488 A |
1355 | * Each member of "msgp" array is of type "struct msghdr_x". |
1356 | * | |
1357 | * The "msg_iov" and "msg_iovlen" are input parameters that describe where to | |
1358 | * store a datagram in a scatter gather locations of buffers -- see recvmsg(2). | |
1359 | * On output the field "msg_datalen" gives the length of the received datagram. | |
1360 | * | |
1361 | * The field "msg_flags" must be set to zero on input. On output, "msg_flags" | |
1362 | * may have MSG_TRUNC set to indicate the trailing portion of the datagram was | |
1363 | * discarded because the datagram was larger than the buffer supplied. | |
1364 | * recvmsg_x() returns as soon as a datagram is truncated. | |
1365 | * | |
1366 | * recvmsg_x() may return with less than "cnt" datagrams received based on | |
1367 | * the low water mark and the amount of data pending in the socket buffer. | |
1368 | * | |
3e170ce0 | 1369 | * recvmsg_x() returns the number of datagrams that have been received, |
39037602 | 1370 | * or -1 if an error occurred. |
fe8ab488 A |
1371 | * |
1372 | * NOTE: This a private system call, the API is subject to change. | |
1373 | */ | |
1374 | ssize_t recvmsg_x(int s, const struct msghdr_x *msgp, u_int cnt, int flags); | |
1375 | ||
1376 | /* | |
1377 | * sendmsg_x() is a system call similar to send(2) to send | |
1378 | * several datagrams at once in the array of message headers "msgp". | |
1379 | * | |
1380 | * sendmsg_x() can be used only with protocols handlers that have been specially | |
3e170ce0 | 1381 | * modified to support sending and receiving several datagrams at once. |
39037602 | 1382 | * |
fe8ab488 A |
1383 | * The size of the array "msgp" is given by the argument "cnt". |
1384 | * | |
1385 | * The "flags" arguments supports only the value MSG_DONTWAIT. | |
39037602 | 1386 | * |
fe8ab488 A |
1387 | * Each member of "msgp" array is of type "struct msghdr_x". |
1388 | * | |
1389 | * The "msg_iov" and "msg_iovlen" are input parameters that specify the | |
1390 | * data to be sent in a scatter gather locations of buffers -- see sendmsg(2). | |
1391 | * | |
1392 | * sendmsg_x() fails with EMSGSIZE if the sum of the length of the datagrams | |
1393 | * is greater than the high water mark. | |
1394 | * | |
1395 | * Address and ancillary data are not supported so the following fields | |
1396 | * must be set to zero on input: | |
1397 | * "msg_name", "msg_namelen", "msg_control" and "msg_controllen". | |
1398 | * | |
39037602 | 1399 | * The field "msg_flags" and "msg_datalen" must be set to zero on input. |
fe8ab488 A |
1400 | * |
1401 | * sendmsg_x() returns the number of datagrams that have been sent, | |
39037602 | 1402 | * or -1 if an error occurred. |
fe8ab488 A |
1403 | * |
1404 | * NOTE: This a private system call, the API is subject to change. | |
1405 | */ | |
1406 | ssize_t sendmsg_x(int s, const struct msghdr_x *msgp, u_int cnt, int flags); | |
39236c6e A |
1407 | __END_DECLS |
1408 | #endif /* !KERNEL */ | |
1409 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ | |
1410 | #endif /* PRIVATE */ | |
1411 | ||
1c79356b | 1412 | #ifndef KERNEL |
1c79356b | 1413 | __BEGIN_DECLS |
3e170ce0 | 1414 | |
91447636 | 1415 | int accept(int, struct sockaddr * __restrict, socklen_t * __restrict) |
2d21ac55 | 1416 | __DARWIN_ALIAS_C(accept); |
91447636 | 1417 | int bind(int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS(bind); |
39037602 | 1418 | int connect(int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS_C(connect); |
91447636 A |
1419 | int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict) |
1420 | __DARWIN_ALIAS(getpeername); | |
1421 | int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict) | |
1422 | __DARWIN_ALIAS(getsockname); | |
1423 | int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); | |
1424 | int listen(int, int) __DARWIN_ALIAS(listen); | |
2d21ac55 | 1425 | ssize_t recv(int, void *, size_t, int) __DARWIN_ALIAS_C(recv); |
91447636 | 1426 | ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, |
2d21ac55 A |
1427 | socklen_t * __restrict) __DARWIN_ALIAS_C(recvfrom); |
1428 | ssize_t recvmsg(int, struct msghdr *, int) __DARWIN_ALIAS_C(recvmsg); | |
1429 | ssize_t send(int, const void *, size_t, int) __DARWIN_ALIAS_C(send); | |
1430 | ssize_t sendmsg(int, const struct msghdr *, int) __DARWIN_ALIAS_C(sendmsg); | |
91447636 | 1431 | ssize_t sendto(int, const void *, size_t, |
2d21ac55 | 1432 | int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS_C(sendto); |
91447636 A |
1433 | int setsockopt(int, int, int, const void *, socklen_t); |
1434 | int shutdown(int, int); | |
6d2010ae | 1435 | int sockatmark(int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); |
91447636 A |
1436 | int socket(int, int, int); |
1437 | int socketpair(int, int, int, int *) __DARWIN_ALIAS(socketpair); | |
91447636 | 1438 | |
2d21ac55 A |
1439 | #if !defined(_POSIX_C_SOURCE) |
1440 | int sendfile(int, int, off_t, off_t *, struct sf_hdtr *, int); | |
91447636 | 1441 | #endif /* !_POSIX_C_SOURCE */ |
2d21ac55 A |
1442 | |
1443 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) | |
1444 | void pfctlinput(int, struct sockaddr *); | |
39037602 | 1445 | int connectx(int, const sa_endpoints_t *, sae_associd_t, unsigned int, |
3e170ce0 | 1446 | const struct iovec *, unsigned int, size_t *, sae_connid_t *); |
39037602 | 1447 | int disconnectx(int, sae_associd_t, sae_connid_t); |
2d21ac55 | 1448 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b | 1449 | __END_DECLS |
1c79356b | 1450 | #endif /* !KERNEL */ |
9bccf70c | 1451 | |
91447636 A |
1452 | #ifdef KERNEL |
1453 | #include <sys/kpi_socket.h> | |
1454 | #endif | |
1455 | ||
1c79356b | 1456 | #endif /* !_SYS_SOCKET_H_ */ |