add BIO_socket_wait(), BIO_wait(), and BIO_connect_retry() improving timeout support
[openssl.git] / include / internal / sockets.h
index cc45424a02f4a01eeade2eb6a3eb922e43920a6e..97ae2f6dcdd2f9fcf04d0decec5164a59ed22e49 100644 (file)
@@ -1,14 +1,15 @@
 /*
- * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
 
 
-#ifndef HEADER_OPENSSL_SOCKETS
+#ifndef OSSL_INTERNAL_SOCKETS_H
+# define OSSL_INTERNAL_SOCKETS_H
 
 # if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
 #  define NO_SYS_PARAM_H
@@ -71,11 +72,7 @@ struct servent *PASCAL getservbyname(const char *, const char *);
 #  else
 #   include <sys/socket.h>
 #   ifndef NO_SYS_UN_H
-#    ifdef OPENSSL_SYS_VXWORKS
-#     include <streams/un.h>
-#    else
-#     include <sys/un.h>
-#    endif
+#    include <sys/un.h>
 #    ifndef UNIX_PATH_MAX
 #     define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
 #    endif
@@ -92,10 +89,6 @@ struct servent *PASCAL getservbyname(const char *, const char *);
 #   include <sys/select.h>
 #  endif
 
-#  ifdef __QNX__
-#   include <sys/select.h>
-#  endif
-
 #  ifndef VMS
 #   include <sys/ioctl.h>
 #  else
@@ -115,48 +108,55 @@ struct servent *PASCAL getservbyname(const char *, const char *);
 # endif
 
 /*
- * Some IPv6 implementations are broken, disable them in known bad versions.
+ * Some IPv6 implementations are broken, you can disable them in known
+ * bad versions.
  */
 # if !defined(OPENSSL_USE_IPV6)
-#  if defined(AF_INET6) && !defined(NETWARE_CLIB)
+#  if defined(AF_INET6)
 #   define OPENSSL_USE_IPV6 1
 #  else
 #   define OPENSSL_USE_IPV6 0
 #  endif
 # endif
 
-#endif
+# define get_last_socket_error() errno
+# define clear_socket_error()    errno=0
+
+# if defined(OPENSSL_SYS_WINDOWS)
+#  undef get_last_socket_error
+#  undef clear_socket_error
+#  define get_last_socket_error() WSAGetLastError()
+#  define clear_socket_error()    WSASetLastError(0)
+#  define readsocket(s,b,n)       recv((s),(b),(n),0)
+#  define writesocket(s,b,n)      send((s),(b),(n),0)
+# elif defined(__DJGPP__)
+#  define WATT32
+#  define WATT32_NO_OLDIES
+#  define closesocket(s)          close_s(s)
+#  define readsocket(s,b,n)       read_s(s,b,n)
+#  define writesocket(s,b,n)      send(s,b,n,0)
+# elif defined(OPENSSL_SYS_VMS)
+#  define ioctlsocket(a,b,c)      ioctl(a,b,c)
+#  define closesocket(s)          close(s)
+#  define readsocket(s,b,n)       recv((s),(b),(n),0)
+#  define writesocket(s,b,n)      send((s),(b),(n),0)
+# elif defined(OPENSSL_SYS_VXWORKS)
+#  define ioctlsocket(a,b,c)          ioctl((a),(b),(int)(c))
+#  define closesocket(s)              close(s)
+#  define readsocket(s,b,n)           read((s),(b),(n))
+#  define writesocket(s,b,n)          write((s),(char *)(b),(n))
+# else
+#  define ioctlsocket(a,b,c)      ioctl(a,b,c)
+#  define closesocket(s)          close(s)
+#  define readsocket(s,b,n)       read((s),(b),(n))
+#  define writesocket(s,b,n)      write((s),(b),(n))
+# endif
 
-#define get_last_socket_error() errno
-#define clear_socket_error()    errno=0
-
-#if defined(OPENSSL_SYS_WINDOWS)
-# undef get_last_socket_error
-# undef clear_socket_error
-# define get_last_socket_error() WSAGetLastError()
-# define clear_socket_error()    WSASetLastError(0)
-# define readsocket(s,b,n)       recv((s),(b),(n),0)
-# define writesocket(s,b,n)      send((s),(b),(n),0)
-#elif defined(__DJGPP__)
-# define WATT32
-# define WATT32_NO_OLDIES
-# define closesocket(s)          close_s(s)
-# define readsocket(s,b,n)       read_s(s,b,n)
-# define writesocket(s,b,n)      send(s,b,n,0)
-#elif defined(OPENSSL_SYS_VMS)
-# define ioctlsocket(a,b,c)      ioctl(a,b,c)
-# define closesocket(s)          close(s)
-# define readsocket(s,b,n)       recv((s),(b),(n),0)
-# define writesocket(s,b,n)      send((s),(b),(n),0)
-#elif defined(OPENSSL_SYS_VXWORKS)
-# define ioctlsocket(a,b,c)          ioctl((a),(b),(int)(c))
-# define closesocket(s)              close(s)
-# define readsocket(s,b,n)           read((s),(b),(n))
-# define writesocket(s,b,n)          write((s),(char *)(b),(n))
-#else
-# define ioctlsocket(a,b,c)      ioctl(a,b,c)
-# define closesocket(s)          close(s)
-# define readsocket(s,b,n)       read((s),(b),(n))
-# define writesocket(s,b,n)      write((s),(b),(n))
-#endif
+/* also in apps/include/apps.h */
+# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
+#  define openssl_fdset(a,b) FD_SET((unsigned int)a, b)
+# else
+#  define openssl_fdset(a,b) FD_SET(a, b)
+# endif
 
+#endif