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