2 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #ifndef HEADER_OPENSSL_SOCKETS
13 # ifdef OPENSSL_NO_SOCK
15 # elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
16 # if !defined(__DJGPP__)
17 # if defined(_WIN32_WCE) && _WIN32_WCE<410
18 # define getservbyname _masked_declaration_getservbyname
20 # if !defined(IPPROTO_IP)
21 /* winsock[2].h was included already? */
25 /* this is used to be wcecompat/include/winsock_extras.h */
27 struct servent *PASCAL getservbyname(const char *, const char *);
32 * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
33 * the value constitutes an index in per-process table of limited size
34 * and not a real pointer. And we also depend on fact that all processors
35 * Windows run on happen to be two's-complement, which allows to
36 * interchange INVALID_SOCKET and -1.
38 # define socket(d,t,p) ((int)socket(d,t,p))
39 # define accept(s,f,l) ((int)accept(s,f,l))
46 # ifndef NO_SYS_PARAM_H
47 # include <sys/param.h>
49 # ifdef OPENSSL_SYS_VXWORKS
54 # if defined(OPENSSL_SYS_VMS_NODECC)
59 # include <sys/socket.h>
61 # ifdef OPENSSL_SYS_VXWORKS
62 # include <streams/un.h>
66 # ifndef UNIX_PATH_MAX
67 # define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
71 # include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */
73 # include <netinet/in.h>
74 # include <arpa/inet.h>
75 # include <netinet/tcp.h>
78 # ifdef OPENSSL_SYS_AIX
79 # include <sys/select.h>
83 # include <sys/select.h>
87 # include <sys/ioctl.h>
89 # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
90 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
91 # include <sys/ioctl.h>
94 # if defined(TCPIP_TYPE_SOCKETSHR)
95 # include <socketshr.h>
99 # ifndef INVALID_SOCKET
100 # define INVALID_SOCKET (-1)
105 * Some IPv6 implementations are broken, disable them in known bad versions.
107 # if !defined(OPENSSL_USE_IPV6)
108 # if defined(AF_INET6) && !defined(NETWARE_CLIB)
109 # define OPENSSL_USE_IPV6 1
111 # define OPENSSL_USE_IPV6 0
117 #define get_last_socket_error() errno
118 #define clear_socket_error() errno=0
120 #if defined(OPENSSL_SYS_WINDOWS)
121 # undef get_last_socket_error
122 # undef clear_socket_error
123 # define get_last_socket_error() WSAGetLastError()
124 # define clear_socket_error() WSASetLastError(0)
125 # define readsocket(s,b,n) recv((s),(b),(n),0)
126 # define writesocket(s,b,n) send((s),(b),(n),0)
127 #elif defined(__DJGPP__)
129 # define WATT32_NO_OLDIES
130 # define closesocket(s) close_s(s)
131 # define readsocket(s,b,n) read_s(s,b,n)
132 # define writesocket(s,b,n) send(s,b,n,0)
133 #elif defined(OPENSSL_SYS_VMS)
134 # define ioctlsocket(a,b,c) ioctl(a,b,c)
135 # define closesocket(s) close(s)
136 # define readsocket(s,b,n) recv((s),(b),(n),0)
137 # define writesocket(s,b,n) send((s),(b),(n),0)
138 #elif defined(OPENSSL_SYS_VXWORKS)
139 # define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
140 # define closesocket(s) close(s)
141 # define readsocket(s,b,n) read((s),(b),(n))
142 # define writesocket(s,b,n) write((s),(char *)(b),(n))
144 # define ioctlsocket(a,b,c) ioctl(a,b,c)
145 # define closesocket(s) close(s)
146 # define readsocket(s,b,n) read((s),(b),(n))
147 # define writesocket(s,b,n) write((s),(b),(n))