+
+#ifdef PRIVATE
+#define SO_EXECPATH 0x1085 /* Application Firewall Socket option */
+
+/*
+ * Traffic service class definitions (lowest to highest):
+ *
+ * SO_TC_BK_SYS
+ * "Background System-Initiated", high delay tolerant, high loss
+ * tolerant, elastic flow, variable size & long-lived. E.g: system-
+ * initiated iCloud synching or Time Capsule backup, for which there
+ * is no progress feedbacks.
+ *
+ * SO_TC_BK
+ * "Background", user-initiated, high delay tolerant, high loss tolerant,
+ * elastic flow, variable size. E.g. user-initiated iCloud synching or
+ * Time Capsule backup; or traffics of background applications, for which
+ * there is some progress feedbacks.
+ *
+ * SO_TC_BE
+ * "Best Effort", unclassified/standard. This is the default service
+ * class; pretty much a mix of everything.
+ *
+ * SO_TC_RD
+ * "Responsive Data", a notch higher than "Best Effort", medium delay
+ * tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email,
+ * instant messaging, for which there is a sense of interactivity and
+ * urgency (user waiting for output).
+ *
+ * SO_TC_OAM
+ * "Operations, Administration, and Management", medium delay tolerant,
+ * low-medium loss tolerant, elastic & inelastic flows, variable size.
+ * E.g. VPN tunnels.
+ *
+ * SO_TC_AV
+ * "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium
+ * loss tolerant, elastic flow, constant packet interval, variable rate &
+ * size. E.g. AirPlay playback (both video and audio).
+ *
+ * SO_TC_RV
+ * "Responsive Multimedia Audio/Video", low delay tolerant, low-medium
+ * loss tolerant, elastic flow, variable packet interval, rate and size.
+ * E.g. AirPlay mirroring, screen sharing.
+ *
+ * SO_TC_VI
+ * "Interactive Video", low delay tolerant, low-medium loss tolerant,
+ * elastic flow, constant packet interval, variable rate & size. E.g.
+ * FaceTime video.
+ *
+ * SO_TC_VO
+ * "Interactive Voice", low delay tolerant, low loss tolerant, inelastic
+ * flow, constant packet rate, somewhat fixed size. E.g. VoIP including
+ * FaceTime audio.
+ *
+ * SO_TC_CTL
+ * "Network Control", low delay tolerant, low loss tolerant, inelastic
+ * flow, rate is bursty but short, variable size. E.g. DNS queries;
+ * certain types of locally-originated ICMP, ICMPv6; IGMP/MLD join/leave,
+ * ARP.
+ */
+#define SO_TRAFFIC_CLASS 0x1086 /* Traffic service class (int) */
+#define SO_TC_BK_SYS 100 /* lowest class */
+#define SO_TC_BK 200
+#define SO_TC_BE 0
+#define SO_TC_RD 300
+#define SO_TC_OAM 400
+#define SO_TC_AV 500
+#define SO_TC_RV 600
+#define SO_TC_VI 700
+#define SO_TC_VO 800
+#define SO_TC_CTL 900 /* highest class */
+#define SO_TC_MAX 10 /* Total # of traffic classes */
+#ifdef XNU_KERNEL_PRIVATE
+#define _SO_TC_BK 1 /* deprecated */
+#define _SO_TC_VI 2 /* deprecated */
+#define _SO_TC_VO 3 /* deprecated */
+#define _SO_TC_MAX 4 /* deprecated */
+
+#define SO_VALID_TC(c) \
+ (c == SO_TC_BK_SYS || c == SO_TC_BK || c == SO_TC_BE || \
+ c == SO_TC_RD || c == SO_TC_OAM || c == SO_TC_AV || \
+ c == SO_TC_RV || c == SO_TC_VI || c == SO_TC_VO || \
+ c == SO_TC_CTL)
+
+#define SO_TC_UNSPEC ((int)-1) /* Traffic class not specified */
+
+#define SO_TC_SIG SO_TC_VI /* to be removed XXX */
+
+#define SOTCIX_BK_SYS 0
+#define SOTCIX_BK 1
+#define SOTCIX_BE 2
+#define SOTCIX_RD 3
+#define SOTCIX_OAM 4
+#define SOTCIX_AV 5
+#define SOTCIX_RV 6
+#define SOTCIX_VI 7
+#define SOTCIX_VO 8
+#define SOTCIX_CTL 9
+#endif /* XNU_KERNEL_PRIVATE */
+
+/* Background socket configuration flags */
+#define TRAFFIC_MGT_SO_BACKGROUND 0x0001 /* background socket */
+#define TRAFFIC_MGT_TCP_RECVBG 0x0002 /* Only TCP sockets, receiver throttling */
+
+#define SO_RECV_TRAFFIC_CLASS 0x1087 /* Receive traffic class (bool) */
+#define SO_TRAFFIC_CLASS_DBG 0x1088 /* Debug traffic class (struct so_tcdbg) */
+#define SO_TRAFFIC_CLASS_STATS 0x1089 /* Traffic class statistics */
+#define SO_PRIVILEGED_TRAFFIC_CLASS 0x1090 /* Privileged traffic class (bool) */
+#define SO_DEFUNCTIT 0x1091 /* Defunct a socket (only in internal builds) */
+#define SO_DEFUNCTOK 0x1100 /* can be defunct'd */
+#define SO_ISDEFUNCT 0x1101 /* get defunct status */
+
+#define SO_OPPORTUNISTIC 0x1102 /* deprecated; use SO_TRAFFIC_CLASS */
+
+/*
+ * SO_FLUSH flushes any unsent data generated by a given socket. It takes
+ * an integer parameter, which can be any of the SO_TC traffic class values,
+ * or the special SO_TC_ALL value.
+ */
+#define SO_FLUSH 0x1103 /* flush unsent data (int) */
+#define SO_TC_ALL (-1)
+
+#define SO_RECV_ANYIF 0x1104 /* unrestricted inbound processing */
+#define SO_TRAFFIC_MGT_BACKGROUND 0x1105 /* Background traffic management */
+
+#define SO_FLOW_DIVERT_TOKEN 0x1106 /* flow divert token */
+
+#define SO_DELEGATED 0x1107 /* set socket as delegate (pid_t) */
+#define SO_DELEGATED_UUID 0x1108 /* set socket as delegate (uuid_t) */
+#define SO_NECP_ATTRIBUTES 0x1109 /* NECP socket attributes (domain, account, etc.) */
+#define SO_CFIL_SOCK_ID 0x1110 /* get content filter socket ID (cfil_sock_id_t) */
+#define SO_NECP_CLIENTUUID 0x1111 /* NECP Client uuid */
+#endif /* PRIVATE */
+#define SO_NUMRCVPKT 0x1112 /* number of datagrams in receive socket buffer */
+#ifdef PRIVATE
+#define SO_AWDL_UNRESTRICTED 0x1113 /* try to use AWDL in restricted mode */
+#define SO_EXTENDED_BK_IDLE 0x1114 /* extended time to keep socket idle after app is suspended (int) */
+#define SO_MARK_CELLFALLBACK 0x1115 /* Mark as initiated by cell fallback */
+#endif /* PRIVATE */
+
+/*
+ * Network Service Type for option SO_NET_SERVICE_TYPE
+ *
+ * The vast majority of sockets should use Best Effort that is the default
+ * Network Service Type. Other Network Service Types have to be used only if
+ * the traffic actually matches the description of the Network Service Type.
+ *
+ * Network Service Types do not represent priorities but rather describe
+ * different categories of delay, jitter and loss parameters.
+ * Those parameters may influence protocols from layer 4 protocols like TCP
+ * to layer 2 protocols like Wi-Fi. The Network Service Type can determine
+ * how the traffic is queued and scheduled by the host networking stack and
+ * by other entities on the network like switches and routers. For example
+ * for Wi-Fi, the Network Service Type can select the marking of the
+ * layer 2 packet with the appropriate WMM Access Category.
+ *
+ * There is no point in attempting to game the system and use
+ * a Network Service Type that does not correspond to the actual
+ * traffic characteristic but one that seems to have a higher precedence.
+ * The reason is that for service classes that have lower tolerance
+ * for delay and jitter, the queues size is lower than for service
+ * classes that are more tolerant to delay and jitter.
+ *
+ * For example using a voice service type for bulk data transfer will lead
+ * to disastrous results as soon as congestion happens because the voice
+ * queue overflows and packets get dropped. This is not only bad for the bulk
+ * data transfer but it is also bad for VoIP apps that legitimately are using
+ * the voice service type.
+ *
+ * The characteristics of the Network Service Types are based on the service
+ * classes defined in RFC 4594 "Configuration Guidelines for DiffServ Service
+ * Classes"
+ *
+ * When system detects the outgoing interface belongs to a DiffServ domain
+ * that follows the recommendation of the IETF draft "Guidelines for DiffServ to
+ * IEEE 802.11 Mapping", the packet will marked at layer 3 with a DSCP value
+ * that corresponds to Network Service Type.
+ *
+ * NET_SERVICE_TYPE_BE
+ * "Best Effort", unclassified/standard. This is the default service
+ * class and cover the majority of the traffic.
+ *
+ * NET_SERVICE_TYPE_BK
+ * "Background", high delay tolerant, loss tolerant. elastic flow,
+ * variable size & long-lived. E.g: non-interactive network bulk transfer
+ * like synching or backup.
+ *
+ * NET_SERVICE_TYPE_RD
+ * "Responsive Data", a notch higher than "Best Effort", medium delay
+ * tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email,
+ * instant messaging, for which there is a sense of interactivity and
+ * urgency (user waiting for output).
+ *
+ * NET_SERVICE_TYPE_OAM
+ * "Operations, Administration, and Management", medium delay tolerant,
+ * low-medium loss tolerant, elastic & inelastic flows, variable size.
+ * E.g. VPN tunnels.
+ *
+ * NET_SERVICE_TYPE_AV
+ * "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium
+ * loss tolerant, elastic flow, constant packet interval, variable rate
+ * and size. E.g. video and audio playback with buffering.
+ *
+ * NET_SERVICE_TYPE_RV
+ * "Responsive Multimedia Audio/Video", low delay tolerant, low-medium
+ * loss tolerant, elastic flow, variable packet interval, rate and size.
+ * E.g. screen sharing.
+ *
+ * NET_SERVICE_TYPE_VI
+ * "Interactive Video", low delay tolerant, low-medium loss tolerant,
+ * elastic flow, constant packet interval, variable rate & size. E.g.
+ * video telephony.
+ *
+ * NET_SERVICE_TYPE_SIG
+ * "Signaling", low delay tolerant, low loss tolerant, inelastic flow,
+ * jitter tolerant, rate is bursty but short, variable size. E.g. SIP.
+ *
+ * NET_SERVICE_TYPE_VO
+ * "Interactive Voice", very low delay tolerant, very low loss tolerant,
+ * inelastic flow, constant packet rate, somewhat fixed size.
+ * E.g. VoIP.
+ */
+#define SO_NET_SERVICE_TYPE 0x1116 /* Network service type */
+
+#define NET_SERVICE_TYPE_BE 0 /* Best effort */
+#define NET_SERVICE_TYPE_BK 1 /* Background system initiated */
+#define NET_SERVICE_TYPE_SIG 2 /* Signaling */
+#define NET_SERVICE_TYPE_VI 3 /* Interactive Video */
+#define NET_SERVICE_TYPE_VO 4 /* Interactive Voice */
+#define NET_SERVICE_TYPE_RV 5 /* Responsive Multimedia Audio/Video */
+#define NET_SERVICE_TYPE_AV 6 /* Multimedia Audio/Video Streaming */
+#define NET_SERVICE_TYPE_OAM 7 /* Operations, Administration, and Management */
+#define NET_SERVICE_TYPE_RD 8 /* Responsive Data */
+
+#if PRIVATE
+#define SO_QOSMARKING_POLICY_OVERRIDE 0x1117 /* int */
+#define SO_INTCOPROC_ALLOW 0x1118 /* Try to use internal co-processor interfaces. */
+
+#define _NET_SERVICE_TYPE_COUNT 9
+#define _NET_SERVICE_TYPE_UNSPEC ((int)-1)
+
+#define IS_VALID_NET_SERVICE_TYPE(c) \
+ (c >= NET_SERVICE_TYPE_BE && c <= NET_SERVICE_TYPE_RD)
+
+extern const int sotc_by_netservicetype[_NET_SERVICE_TYPE_COUNT];
+
+/*
+ * Facility to pass Network Service Type values using SO_TRAFFIC_CLASS
+ * Mostly useful to simplify implementation of frameworks to adopt the new
+ * Network Service Type values for Signaling.
+ */
+#define SO_TC_NET_SERVICE_OFFSET 10000
+#define SO_TC_NETSVC_SIG (SO_TC_NET_SERVICE_OFFSET + NET_SERVICE_TYPE_SIG)
+#endif /* PRIVATE */
+
+#define SO_NETSVC_MARKING_LEVEL 0x1119 /* Get QoS marking in effect for socket */
+
+#define NETSVC_MRKNG_UNKNOWN 0 /* The outgoing network interface is not known */
+#define NETSVC_MRKNG_LVL_L2 1 /* Default marking at layer 2 (for example Wi-Fi WMM) */
+#define NETSVC_MRKNG_LVL_L3L2_ALL 2 /* Layer 3 DSCP marking and layer 2 marking for all Network Service Types */
+#define NETSVC_MRKNG_LVL_L3L2_BK 3 /* The system policy limits layer 3 DSCP marking and layer 2 marking
+ * to background Network Service Types */
+
+typedef __uint32_t sae_associd_t;
+#define SAE_ASSOCID_ANY 0
+#define SAE_ASSOCID_ALL ((sae_associd_t)(-1ULL))
+
+typedef __uint32_t sae_connid_t;
+#define SAE_CONNID_ANY 0
+#define SAE_CONNID_ALL ((sae_connid_t)(-1ULL))
+
+/* connectx() flag parameters */
+#define CONNECT_RESUME_ON_READ_WRITE 0x1 /* resume connect() on read/write */
+#define CONNECT_DATA_IDEMPOTENT 0x2 /* data is idempotent */
+#define CONNECT_DATA_AUTHENTICATED 0x4 /* data includes security that replaces the TFO-cookie */
+
+/* sockaddr endpoints */
+typedef struct sa_endpoints {
+ unsigned int sae_srcif; /* optional source interface */
+ const struct sockaddr *sae_srcaddr; /* optional source address */
+ socklen_t sae_srcaddrlen; /* size of source address */
+ const struct sockaddr *sae_dstaddr; /* destination address */
+ socklen_t sae_dstaddrlen; /* size of destination address */
+} sa_endpoints_t;
+#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */