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 # if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
14 # define NO_SYS_PARAM_H
19 # ifdef OPENSSL_SYS_VMS
20 # define NO_SYS_PARAM_H
24 # ifdef OPENSSL_NO_SOCK
26 # elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
27 # if defined(__DJGPP__)
28 # include <sys/socket.h>
32 # elif defined(_WIN32_WCE) && _WIN32_WCE<410
33 # define getservbyname _masked_declaration_getservbyname
35 # if !defined(IPPROTO_IP)
36 /* winsock[2].h was included already? */
40 /* this is used to be wcecompat/include/winsock_extras.h */
42 struct servent *PASCAL getservbyname(const char *, const char *);
47 * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
48 * the value constitutes an index in per-process table of limited size
49 * and not a real pointer. And we also depend on fact that all processors
50 * Windows run on happen to be two's-complement, which allows to
51 * interchange INVALID_SOCKET and -1.
53 # define socket(d,t,p) ((int)socket(d,t,p))
54 # define accept(s,f,l) ((int)accept(s,f,l))
59 # ifndef NO_SYS_PARAM_H
60 # include <sys/param.h>
62 # ifdef OPENSSL_SYS_VXWORKS
67 # if defined(OPENSSL_SYS_VMS_NODECC)
72 # include <sys/socket.h>
74 # ifdef OPENSSL_SYS_VXWORKS
75 # include <streams/un.h>
79 # ifndef UNIX_PATH_MAX
80 # define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
84 # include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */
86 # include <netinet/in.h>
87 # include <arpa/inet.h>
88 # include <netinet/tcp.h>
91 # ifdef OPENSSL_SYS_AIX
92 # include <sys/select.h>
96 # include <sys/select.h>
100 # include <sys/ioctl.h>
102 # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
103 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
104 # include <sys/ioctl.h>
107 # if defined(TCPIP_TYPE_SOCKETSHR)
108 # include <socketshr.h>
112 # ifndef INVALID_SOCKET
113 # define INVALID_SOCKET (-1)
118 * Some IPv6 implementations are broken, disable them in known bad versions.
120 # if !defined(OPENSSL_USE_IPV6)
121 # if defined(AF_INET6) && !defined(NETWARE_CLIB)
122 # define OPENSSL_USE_IPV6 1
124 # define OPENSSL_USE_IPV6 0
130 #define get_last_socket_error() errno
131 #define clear_socket_error() errno=0
133 #if defined(OPENSSL_SYS_WINDOWS)
134 # undef get_last_socket_error
135 # undef clear_socket_error
136 # define get_last_socket_error() WSAGetLastError()
137 # define clear_socket_error() WSASetLastError(0)
138 # define readsocket(s,b,n) recv((s),(b),(n),0)
139 # define writesocket(s,b,n) send((s),(b),(n),0)
140 #elif defined(__DJGPP__)
142 # define WATT32_NO_OLDIES
143 # define closesocket(s) close_s(s)
144 # define readsocket(s,b,n) read_s(s,b,n)
145 # define writesocket(s,b,n) send(s,b,n,0)
146 #elif defined(OPENSSL_SYS_VMS)
147 # define ioctlsocket(a,b,c) ioctl(a,b,c)
148 # define closesocket(s) close(s)
149 # define readsocket(s,b,n) recv((s),(b),(n),0)
150 # define writesocket(s,b,n) send((s),(b),(n),0)
151 #elif defined(OPENSSL_SYS_VXWORKS)
152 # define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
153 # define closesocket(s) close(s)
154 # define readsocket(s,b,n) read((s),(b),(n))
155 # define writesocket(s,b,n) write((s),(char *)(b),(n))
157 # define ioctlsocket(a,b,c) ioctl(a,b,c)
158 # define closesocket(s) close(s)
159 # define readsocket(s,b,n) read((s),(b),(n))
160 # define writesocket(s,b,n) write((s),(b),(n))