]>
git.ipfire.org Git - thirdparty/openssl.git/blob - include/internal/sockets.h
2 * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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
10 #ifndef OSSL_INTERNAL_SOCKETS_H
11 # define OSSL_INTERNAL_SOCKETS_H
14 # include <openssl/opensslconf.h>
16 # if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
17 # define NO_SYS_PARAM_H
22 # ifdef OPENSSL_SYS_VMS
23 # define NO_SYS_PARAM_H
27 # ifdef OPENSSL_NO_SOCK
29 # elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
30 # if defined(__DJGPP__)
31 # include <sys/socket.h>
35 # include <arpa/inet.h>
36 # include <netinet/tcp.h>
37 # elif defined(_WIN32_WCE) && _WIN32_WCE<410
38 # define getservbyname _masked_declaration_getservbyname
40 # if !defined(IPPROTO_IP)
41 /* winsock[2].h was included already? */
45 /* this is used to be wcecompat/include/winsock_extras.h */
47 struct servent
*PASCAL
getservbyname(const char *, const char *);
52 * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
53 * the value constitutes an index in per-process table of limited size
54 * and not a real pointer. And we also depend on fact that all processors
55 * Windows run on happen to be two's-complement, which allows to
56 * interchange INVALID_SOCKET and -1.
58 # define socket(d,t,p) ((int)socket(d,t,p))
59 # define accept(s,f,l) ((int)accept(s,f,l))
63 # if defined(__APPLE__)
65 * This must be defined before including <netinet/in6.h> to get
68 # define __APPLE_USE_RFC_3542
71 # ifndef NO_SYS_PARAM_H
72 # include <sys/param.h>
74 # ifdef OPENSSL_SYS_VXWORKS
79 # if defined(OPENSSL_SYS_VMS_NODECC)
84 # include <sys/socket.h>
85 # if !defined(NO_SYS_UN_H) && defined(AF_UNIX) && !defined(OPENSSL_NO_UNIX_SOCK)
87 # ifndef UNIX_PATH_MAX
88 # define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
92 # include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */
94 # include <netinet/in.h>
95 # include <arpa/inet.h>
96 # include <netinet/tcp.h>
99 # ifdef OPENSSL_SYS_AIX
100 # include <sys/select.h>
104 # include <sys/ioctl.h>
106 # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
107 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
108 # include <sys/ioctl.h>
111 # if defined(TCPIP_TYPE_SOCKETSHR)
112 # include <socketshr.h>
116 # ifndef INVALID_SOCKET
117 # define INVALID_SOCKET (-1)
122 * Some IPv6 implementations are broken, you can disable them in known
125 # if !defined(OPENSSL_USE_IPV6)
126 # if defined(AF_INET6)
127 # define OPENSSL_USE_IPV6 1
129 # define OPENSSL_USE_IPV6 0
134 * Some platforms define AF_UNIX, but don't support it
136 # if !defined(OPENSSL_NO_UNIX_SOCK)
137 # if !defined(AF_UNIX) || defined(NO_SYS_UN_H)
138 # define OPENSSL_NO_UNIX_SOCK
142 # define get_last_socket_error() errno
143 # define clear_socket_error() errno=0
145 # if defined(OPENSSL_SYS_WINDOWS)
146 # undef get_last_socket_error
147 # undef clear_socket_error
148 # define get_last_socket_error() WSAGetLastError()
149 # define clear_socket_error() WSASetLastError(0)
150 # define readsocket(s,b,n) recv((s),(b),(n),0)
151 # define writesocket(s,b,n) send((s),(b),(n),0)
152 # elif defined(__DJGPP__)
154 # define WATT32_NO_OLDIES
155 # define closesocket(s) close_s(s)
156 # define readsocket(s,b,n) read_s(s,b,n)
157 # define writesocket(s,b,n) send(s,b,n,0)
158 # elif defined(OPENSSL_SYS_VMS)
159 # define ioctlsocket(a,b,c) ioctl(a,b,c)
160 # define closesocket(s) close(s)
161 # define readsocket(s,b,n) recv((s),(b),(n),0)
162 # define writesocket(s,b,n) send((s),(b),(n),0)
163 # elif defined(OPENSSL_SYS_VXWORKS)
164 # define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
165 # define closesocket(s) close(s)
166 # define readsocket(s,b,n) read((s),(b),(n))
167 # define writesocket(s,b,n) write((s),(char *)(b),(n))
168 # elif defined(OPENSSL_SYS_TANDEM)
169 # if defined(OPENSSL_TANDEM_FLOSS)
170 # include <floss.h(floss_read, floss_write)>
171 # define readsocket(s,b,n) floss_read((s),(b),(n))
172 # define writesocket(s,b,n) floss_write((s),(b),(n))
174 # define readsocket(s,b,n) read((s),(b),(n))
175 # define writesocket(s,b,n) write((s),(b),(n))
177 # define ioctlsocket(a,b,c) ioctl(a,b,c)
178 # define closesocket(s) close(s)
180 # define ioctlsocket(a,b,c) ioctl(a,b,c)
181 # define closesocket(s) close(s)
182 # define readsocket(s,b,n) read((s),(b),(n))
183 # define writesocket(s,b,n) write((s),(b),(n))
186 /* also in apps/include/apps.h */
187 # if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
188 # define openssl_fdset(a, b) FD_SET((unsigned int)(a), b)
190 # define openssl_fdset(a, b) FD_SET(a, b)