]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/sys/socket.h
xnu-3247.1.106.tar.gz
[apple/xnu.git] / bsd / sys / socket.h
index d58bdd7b54734942bd3a5511c367a239c8532ce3..8afe6c4daa073bcb7c698b965d6045a28289372d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2014 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2015 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -329,12 +329,33 @@ struct so_tcdbg {
 #if MPTCP
 #define SO_MPTCP_FASTJOIN      0x1111  /* fast join MPTCP */
 #endif /* MPTCP */
-
-#define        SO_AWDL_UNRESTRICTED    0x1113  /* try to use AWDL in restricted mode */
 #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) */
+#endif /* PRIVATE */
 
+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 */
+
+/* sockaddr endpoints */
+typedef struct sa_endpoints {
+       unsigned int    sae_srcif;      /* optional source interface */
+       struct sockaddr *sae_srcaddr;   /* optional source address */
+       socklen_t       sae_srcaddrlen; /* size of source address */
+       struct sockaddr *sae_dstaddr;   /* destination address */
+       socklen_t       sae_dstaddrlen; /* size of destination address */
+} sa_endpoints_t;
 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
 
 /*
@@ -369,6 +390,7 @@ struct so_np_extensions {
 #ifdef KERNEL_PRIVATE
 #define SONPX_MASK_VALID               (SONPX_SETOPTSHUT)
 #define IS_SO_TC_BACKGROUND(_tc_) ((_tc_) == SO_TC_BK || (_tc_) == SO_TC_BK_SYS)
+#define IS_SO_TC_BACKGROUNDSYSTEM(_tc_) ((_tc_) == SO_TC_BK_SYS)
 #endif /* KERNEL_PRIVATE */
 
 #endif
@@ -791,6 +813,46 @@ struct user32_msghdr_x {
        user32_size_t   msg_datalen;    /* byte length of buffer in msg_iov */
 };
 
+/*
+ * In-kernel representation of "struct sa_endpoints" from
+ * userspace. Has enough precision for 32-bit or
+ * 64-bit clients, but does not need to be packed.
+ */
+
+struct user_sa_endpoints {
+       unsigned int    sae_srcif;      /* optional source interface */
+       user_addr_t     sae_srcaddr;    /* optional source address */
+       socklen_t       sae_srcaddrlen; /* size of source address */
+       user_addr_t     sae_dstaddr;    /* destination address */
+       socklen_t       sae_dstaddrlen; /* size of destination address */
+};
+
+/*
+ * LP64 user version of struct sa_endpoints
+ * WARNING - keep in sync with struct sa_endpoints
+ */
+
+struct user64_sa_endpoints {
+       unsigned int    sae_srcif;      /* optional source interface */
+       user64_addr_t   sae_srcaddr;    /* optional source address */
+       socklen_t       sae_srcaddrlen; /* size of source address */
+       user64_addr_t   sae_dstaddr;    /* destination address */
+       socklen_t       sae_dstaddrlen; /* size of destination address */
+};
+
+/*
+ * ILP32 user version of struct sa_endpoints
+ * WARNING - keep in sync with struct sa_endpoints
+ */
+
+struct user32_sa_endpoints {
+       unsigned int    sae_srcif;      /* optional source interface */
+       user32_addr_t   sae_srcaddr;    /* optional source address */
+       socklen_t       sae_srcaddrlen; /* size of source address */
+       user32_addr_t   sae_dstaddr;    /* destination address */
+       socklen_t       sae_dstaddrlen; /* size of destination address */
+};
+
 #endif /* XNU_KERNEL_PRIVATE */
 
 #define        MSG_OOB         0x1             /* process out-of-band data */
@@ -996,20 +1058,13 @@ struct user32_sf_hdtr {
 
 #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 */
+       sae_associd_t   *sar_aidp;      /* array of association IDs */
 };
 
 #ifdef BSD_KERNEL_PRIVATE
@@ -1028,20 +1083,20 @@ struct so_aidreq64 {
  * Structure for SIOCGCONNIDS
  */
 struct so_cidreq {
-       associd_t       scr_aid;        /* association ID */
+       sae_associd_t   scr_aid;        /* association ID */
        __uint32_t      scr_cnt;        /* number of connections */
-       connid_t        *scr_cidp;      /* array of connection IDs */
+       sae_connid_t    *scr_cidp;      /* array of connection IDs */
 };
 
 #ifdef BSD_KERNEL_PRIVATE
 struct so_cidreq32 {
-       associd_t       scr_aid;
+       sae_associd_t   scr_aid;
        __uint32_t      scr_cnt;
        user32_addr_t   scr_cidp;
 };
 
 struct so_cidreq64 {
-       associd_t       scr_aid;
+       sae_associd_t   scr_aid;
        __uint32_t      scr_cnt;
        user64_addr_t   scr_cidp __attribute__((aligned(8)));
 };
@@ -1051,7 +1106,7 @@ struct so_cidreq64 {
  * Structure for SIOCGCONNINFO
  */
 struct so_cinforeq {
-       connid_t        scir_cid;               /* connection ID */
+       sae_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 */
@@ -1066,7 +1121,7 @@ struct so_cinforeq {
 
 #ifdef BSD_KERNEL_PRIVATE
 struct so_cinforeq32 {
-       connid_t        scir_cid;
+       sae_connid_t    scir_cid;
        __uint32_t      scir_flags;
        __uint32_t      scir_ifindex;
        __int32_t       scir_error;
@@ -1080,7 +1135,7 @@ struct so_cinforeq32 {
 };
 
 struct so_cinforeq64 {
-       connid_t        scir_cid;
+       sae_connid_t    scir_cid;
        __uint32_t      scir_flags;
        __uint32_t      scir_ifindex;
        __int32_t       scir_error;
@@ -1115,7 +1170,7 @@ struct so_cinforeq64 {
  * Structure for SIOC{S,G}CONNORDER
  */
 struct so_cordreq {
-       connid_t        sco_cid;                /* connection ID */
+       sae_connid_t    sco_cid;                /* connection ID */
        __uint32_t      sco_rank;               /* rank (0 means unspecified) */
 };
 
@@ -1169,10 +1224,8 @@ struct kev_socket_closed {
 
 #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 peeloff(int s, sae_associd_t);
 extern int socket_delegate(int, int, int, pid_t);
 
 /*
@@ -1180,7 +1233,7 @@ extern int socket_delegate(int, int, int, pid_t);
  * 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.
+ * modified to support sending and receiving several datagrams at once.
  * 
  * The size of the array "msgp" is given by the argument "cnt".
  *
@@ -1200,11 +1253,7 @@ extern int socket_delegate(int, int, int, pid_t);
  * 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 ,
+ * 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.
@@ -1216,7 +1265,7 @@ ssize_t recvmsg_x(int s, const struct msghdr_x *msgp, u_int cnt, int flags);
  * 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.
+ * modified to support sending and receiving several datagrams at once.
  * 
  * The size of the array "msgp" is given by the argument "cnt".
  *
@@ -1249,6 +1298,7 @@ __END_DECLS
 
 #ifndef        KERNEL
 __BEGIN_DECLS
+
 int    accept(int, struct sockaddr * __restrict, socklen_t * __restrict)
                __DARWIN_ALIAS_C(accept);
 int    bind(int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS(bind);
@@ -1279,6 +1329,9 @@ int       sendfile(int, int, off_t, off_t *, struct sf_hdtr *, int);
 
 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
 void   pfctlinput(int, struct sockaddr *);
+int connectx(int , const sa_endpoints_t *, sae_associd_t, unsigned int,
+    const struct iovec *, unsigned int, size_t *, sae_connid_t *);
+int disconnectx(int , sae_associd_t, sae_connid_t);
 #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
 __END_DECLS
 #endif /* !KERNEL */