+#ifdef PRIVATE
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+typedef __uint32_t associd_t;
+#define ASSOCID_ANY 0
+#define ASSOCID_ALL ((associd_t)(-1ULL))
+
+typedef __uint32_t connid_t;
+#define CONNID_ANY 0
+#define CONNID_ALL ((connid_t)(-1ULL))
+
+/*
+ * Structure for SIOCGASSOCIDS
+ */
+struct so_aidreq {
+ __uint32_t sar_cnt; /* number of associations */
+ associd_t *sar_aidp; /* array of association IDs */
+};
+
+#ifdef BSD_KERNEL_PRIVATE
+struct so_aidreq32 {
+ __uint32_t sar_cnt;
+ user32_addr_t sar_aidp;
+};
+
+struct so_aidreq64 {
+ __uint32_t sar_cnt;
+ user64_addr_t sar_aidp __attribute__((aligned(8)));
+};
+#endif /* BSD_KERNEL_PRIVATE */
+
+/*
+ * Structure for SIOCGCONNIDS
+ */
+struct so_cidreq {
+ associd_t scr_aid; /* association ID */
+ __uint32_t scr_cnt; /* number of connections */
+ connid_t *scr_cidp; /* array of connection IDs */
+};
+
+#ifdef BSD_KERNEL_PRIVATE
+struct so_cidreq32 {
+ associd_t scr_aid;
+ __uint32_t scr_cnt;
+ user32_addr_t scr_cidp;
+};
+
+struct so_cidreq64 {
+ associd_t scr_aid;
+ __uint32_t scr_cnt;
+ user64_addr_t scr_cidp __attribute__((aligned(8)));
+};
+#endif /* BSD_KERNEL_PRIVATE */
+
+/*
+ * Structure for SIOCGCONNINFO
+ */
+struct so_cinforeq {
+ connid_t scir_cid; /* connection ID */
+ __uint32_t scir_flags; /* see flags below */
+ __uint32_t scir_ifindex; /* (last) outbound interface */
+ __int32_t scir_error; /* most recent error */
+ struct sockaddr *scir_src; /* source address */
+ socklen_t scir_src_len; /* source address len */
+ struct sockaddr *scir_dst; /* destination address */
+ socklen_t scir_dst_len; /* destination address len */
+ __uint32_t scir_aux_type; /* aux data type (CIAUX) */
+ void *scir_aux_data; /* aux data */
+ __uint32_t scir_aux_len; /* aux data len */
+};
+
+#ifdef BSD_KERNEL_PRIVATE
+struct so_cinforeq32 {
+ connid_t scir_cid;
+ __uint32_t scir_flags;
+ __uint32_t scir_ifindex;
+ __int32_t scir_error;
+ user32_addr_t scir_src;
+ socklen_t scir_src_len;
+ user32_addr_t scir_dst;
+ socklen_t scir_dst_len;
+ __uint32_t scir_aux_type;
+ user32_addr_t scir_aux_data;
+ __uint32_t scir_aux_len;
+};
+
+struct so_cinforeq64 {
+ connid_t scir_cid;
+ __uint32_t scir_flags;
+ __uint32_t scir_ifindex;
+ __int32_t scir_error;
+ user64_addr_t scir_src __attribute__((aligned(8)));
+ socklen_t scir_src_len;
+ user64_addr_t scir_dst __attribute__((aligned(8)));
+ socklen_t scir_dst_len;
+ __uint32_t scir_aux_type;
+ user64_addr_t scir_aux_data __attribute__((aligned(8)));
+ __uint32_t scir_aux_len;
+};
+#endif /* BSD_KERNEL_PRIVATE */
+
+/* valid connection info flags */
+#define CIF_CONNECTING 0x1 /* connection was attempted */
+#define CIF_CONNECTED 0x2 /* connection is established */
+#define CIF_DISCONNECTING 0x4 /* disconnection was attempted */
+#define CIF_DISCONNECTED 0x8 /* has been disconnected */
+#define CIF_BOUND_IF 0x10 /* bound to an interface */
+#define CIF_BOUND_IP 0x20 /* bound to a src address */
+#define CIF_BOUND_PORT 0x40 /* bound to a src port */
+#define CIF_PREFERRED 0x80 /* connection is primary/preferred */
+#define CIF_MP_CAPABLE 0x100 /* supports multipath protocol */
+#define CIF_MP_READY 0x200 /* multipath protocol confirmed */
+#define CIF_MP_DEGRADED 0x400 /* has lost its multipath capability */
+#define CIF_MP_ACTIVE 0x800 /* this is the active subflow */
+
+/* valid connection info auxiliary data types */
+#define CIAUX_TCP 0x1 /* TCP auxiliary data (conninfo_tcp_t) */
+
+/*
+ * Structure for SIOC{S,G}CONNORDER
+ */
+struct so_cordreq {
+ connid_t sco_cid; /* connection ID */
+ __uint32_t sco_rank; /* rank (0 means unspecified) */
+};
+
+/*
+ * Network policy subclass (of KEV_NETWORK_CLASS)
+ */
+#define KEV_NETPOLICY_SUBCLASS 3
+
+#define KEV_NETPOLICY_IFDENIED 1 /* denied access to interface */
+
+/*
+ * Common structure for KEV_NETPOLICY_SUBCLASS
+ */
+struct netpolicy_event_data {
+ __uint64_t eupid; /* effective unique PID */
+ pid_t epid; /* effective PID */
+#if !defined(__LP64__)
+ __uint32_t pad;
+#endif /* __LP64__ */
+ uuid_t euuid; /* effective UUID */
+};
+
+/*
+ * NETPOLICY_IFDENIED event structure
+ */
+struct kev_netpolicy_ifdenied {
+ struct netpolicy_event_data ev_data;
+};
+
+/*
+ * Socket subclass (of KEV_NETWORK_CLASS)
+ */
+#define KEV_SOCKET_SUBCLASS 4
+
+/*
+ * Events for KEV_SOCKET_SUBCLASS of KEV_NETWORK_CLASS
+ */
+#define KEV_SOCKET_CLOSED 1 /* completely closed by protocol */
+
+/*
+ * Common structure for KEV_SOCKET_SUBCLASS
+ */
+struct kev_socket_event_data {
+ struct sockaddr_storage kev_sockname;
+ struct sockaddr_storage kev_peername;
+};
+
+struct kev_socket_closed {
+ struct kev_socket_event_data ev_data;
+};
+
+#ifndef KERNEL
+__BEGIN_DECLS
+extern int connectx(int s, struct sockaddr *, socklen_t, struct sockaddr *,
+ socklen_t, __uint32_t, associd_t, connid_t *);
+extern int disconnectx(int s, associd_t, connid_t);
+extern int peeloff(int s, associd_t);
+extern int socket_delegate(int, int, int, pid_t);
+
+/*
+ * recvmsg_x() is a system call similar to recvmsg(2) to receive
+ * several datagrams at once in the array of message headers "msgp".
+ *
+ * recvmsg_x() can be used only with protocols handlers that have been specially
+ * modified to handle sending and receiving several datagrams at once.
+ *
+ * The size of the array "msgp" is given by the argument "cnt".
+ *
+ * The "flags" arguments supports only the value MSG_DONTWAIT.
+ *
+ * Each member of "msgp" array is of type "struct msghdr_x".
+ *
+ * The "msg_iov" and "msg_iovlen" are input parameters that describe where to
+ * store a datagram in a scatter gather locations of buffers -- see recvmsg(2).
+ * On output the field "msg_datalen" gives the length of the received datagram.
+ *
+ * The field "msg_flags" must be set to zero on input. On output, "msg_flags"
+ * may have MSG_TRUNC set to indicate the trailing portion of the datagram was
+ * discarded because the datagram was larger than the buffer supplied.
+ * recvmsg_x() returns as soon as a datagram is truncated.
+ *
+ * recvmsg_x() may return with less than "cnt" datagrams received based on
+ * the low water mark and the amount of data pending in the socket buffer.
+ *
+ * Address and ancillary data are not supported so the following fields
+ * must be set to zero on input:
+ * "msg_name", "msg_namelen", "msg_control" and "msg_controllen".
+ *
+ * recvmsg_x() returns the number of datagrams that have been received ,
+ * or -1 if an error occurred.
+ *
+ * NOTE: This a private system call, the API is subject to change.
+ */
+ssize_t recvmsg_x(int s, const struct msghdr_x *msgp, u_int cnt, int flags);
+
+/*
+ * sendmsg_x() is a system call similar to send(2) to send
+ * several datagrams at once in the array of message headers "msgp".
+ *
+ * sendmsg_x() can be used only with protocols handlers that have been specially
+ * modified to support to handle sending and receiving several datagrams at once.
+ *
+ * The size of the array "msgp" is given by the argument "cnt".
+ *
+ * The "flags" arguments supports only the value MSG_DONTWAIT.
+ *
+ * Each member of "msgp" array is of type "struct msghdr_x".
+ *
+ * The "msg_iov" and "msg_iovlen" are input parameters that specify the
+ * data to be sent in a scatter gather locations of buffers -- see sendmsg(2).
+ *
+ * sendmsg_x() fails with EMSGSIZE if the sum of the length of the datagrams
+ * is greater than the high water mark.
+ *
+ * Address and ancillary data are not supported so the following fields
+ * must be set to zero on input:
+ * "msg_name", "msg_namelen", "msg_control" and "msg_controllen".
+ *
+ * The field "msg_flags" and "msg_datalen" must be set to zero on input.
+ *
+ * sendmsg_x() returns the number of datagrams that have been sent,
+ * or -1 if an error occurred.
+ *
+ * NOTE: This a private system call, the API is subject to change.
+ */
+ssize_t sendmsg_x(int s, const struct msghdr_x *msgp, u_int cnt, int flags);
+__END_DECLS
+#endif /* !KERNEL */
+#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
+#endif /* PRIVATE */
+