2 * Copyright 1995-2018 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_INTERNAL_SOCKETS
12 # define HEADER_INTERNAL_SOCKETS
14 # if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
15 # define NO_SYS_PARAM_H
20 # ifdef OPENSSL_SYS_VMS
21 # define NO_SYS_PARAM_H
25 # ifdef OPENSSL_NO_SOCK
27 # elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
28 # if defined(__DJGPP__)
29 # include <sys/socket.h>
33 # elif defined(_WIN32_WCE) && _WIN32_WCE<410
34 # define getservbyname _masked_declaration_getservbyname
36 # if !defined(IPPROTO_IP)
37 /* winsock[2].h was included already? */
41 /* this is used to be wcecompat/include/winsock_extras.h */
43 struct servent *PASCAL getservbyname(const char *, const char *);
48 * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
49 * the value constitutes an index in per-process table of limited size
50 * and not a real pointer. And we also depend on fact that all processors
51 * Windows run on happen to be two's-complement, which allows to
52 * interchange INVALID_SOCKET and -1.
54 # define socket(d,t,p) ((int)socket(d,t,p))
55 # define accept(s,f,l) ((int)accept(s,f,l))
60 # ifndef NO_SYS_PARAM_H
61 # include <sys/param.h>
63 # ifdef OPENSSL_SYS_VXWORKS
68 # if defined(OPENSSL_SYS_VMS_NODECC)
73 # include <sys/socket.h>
75 # ifdef OPENSSL_SYS_VXWORKS
76 # include <streams/un.h>
80 # ifndef UNIX_PATH_MAX
81 # define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
85 # include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */
87 # include <netinet/in.h>
88 # include <arpa/inet.h>
89 # include <netinet/tcp.h>
92 # ifdef OPENSSL_SYS_AIX
93 # include <sys/select.h>
97 # include <sys/select.h>
101 # include <sys/ioctl.h>
103 # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
104 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
105 # include <sys/ioctl.h>
108 # if defined(TCPIP_TYPE_SOCKETSHR)
109 # include <socketshr.h>
113 # ifndef INVALID_SOCKET
114 # define INVALID_SOCKET (-1)
119 * Some IPv6 implementations are broken, you can disable them in known
122 # if !defined(OPENSSL_USE_IPV6)
123 # if defined(AF_INET6)
124 # define OPENSSL_USE_IPV6 1
126 # 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))