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