]>
Commit | Line | Data |
---|---|---|
0e97f1e1 | 1 | /* |
fecb3aae | 2 | * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. |
0e97f1e1 | 3 | * |
48f4ad77 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
0e97f1e1 RS |
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 | |
8 | */ | |
9 | ||
ae4186b0 DMSP |
10 | #ifndef OSSL_INTERNAL_SOCKETS_H |
11 | # define OSSL_INTERNAL_SOCKETS_H | |
3a111aad | 12 | # pragma once |
0e97f1e1 | 13 | |
fea55908 RL |
14 | # include <openssl/opensslconf.h> |
15 | ||
9a5d80cb RL |
16 | # if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) |
17 | # define NO_SYS_PARAM_H | |
18 | # endif | |
19 | # ifdef WIN32 | |
20 | # define NO_SYS_UN_H | |
21 | # endif | |
22 | # ifdef OPENSSL_SYS_VMS | |
23 | # define NO_SYS_PARAM_H | |
24 | # define NO_SYS_UN_H | |
25 | # endif | |
26 | ||
0e97f1e1 RS |
27 | # ifdef OPENSSL_NO_SOCK |
28 | ||
29 | # elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) | |
9a5d80cb RL |
30 | # if defined(__DJGPP__) |
31 | # include <sys/socket.h> | |
32 | # include <sys/un.h> | |
33 | # include <tcp.h> | |
34 | # include <netdb.h> | |
b9b211fc JMG |
35 | # include <arpa/inet.h> |
36 | # include <netinet/tcp.h> | |
9a5d80cb RL |
37 | # elif defined(_WIN32_WCE) && _WIN32_WCE<410 |
38 | # define getservbyname _masked_declaration_getservbyname | |
39 | # endif | |
40 | # if !defined(IPPROTO_IP) | |
41 | /* winsock[2].h was included already? */ | |
42 | # include <winsock.h> | |
43 | # endif | |
44 | # ifdef getservbyname | |
0e97f1e1 | 45 | /* this is used to be wcecompat/include/winsock_extras.h */ |
9a5d80cb | 46 | # undef getservbyname |
0e97f1e1 | 47 | struct servent *PASCAL getservbyname(const char *, const char *); |
9a5d80cb | 48 | # endif |
0e97f1e1 | 49 | |
9a5d80cb | 50 | # ifdef _WIN64 |
0e97f1e1 RS |
51 | /* |
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. | |
57 | */ | |
9a5d80cb RL |
58 | # define socket(d,t,p) ((int)socket(d,t,p)) |
59 | # define accept(s,f,l) ((int)accept(s,f,l)) | |
0e97f1e1 RS |
60 | # endif |
61 | ||
62 | # else | |
63 | ||
64 | # ifndef NO_SYS_PARAM_H | |
65 | # include <sys/param.h> | |
66 | # endif | |
67 | # ifdef OPENSSL_SYS_VXWORKS | |
68 | # include <time.h> | |
69 | # endif | |
70 | ||
71 | # include <netdb.h> | |
72 | # if defined(OPENSSL_SYS_VMS_NODECC) | |
73 | # include <socket.h> | |
74 | # include <in.h> | |
75 | # include <inet.h> | |
76 | # else | |
77 | # include <sys/socket.h> | |
78 | # ifndef NO_SYS_UN_H | |
5c8b7b4c | 79 | # include <sys/un.h> |
0e97f1e1 RS |
80 | # ifndef UNIX_PATH_MAX |
81 | # define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path) | |
82 | # endif | |
83 | # endif | |
84 | # ifdef FILIO_H | |
85 | # include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */ | |
86 | # endif | |
87 | # include <netinet/in.h> | |
88 | # include <arpa/inet.h> | |
89 | # include <netinet/tcp.h> | |
90 | # endif | |
91 | ||
92 | # ifdef OPENSSL_SYS_AIX | |
93 | # include <sys/select.h> | |
94 | # endif | |
95 | ||
0e97f1e1 RS |
96 | # ifndef VMS |
97 | # include <sys/ioctl.h> | |
98 | # else | |
99 | # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000) | |
100 | /* ioctl is only in VMS > 7.0 and when socketshr is not used */ | |
101 | # include <sys/ioctl.h> | |
102 | # endif | |
103 | # include <unixio.h> | |
104 | # if defined(TCPIP_TYPE_SOCKETSHR) | |
105 | # include <socketshr.h> | |
106 | # endif | |
107 | # endif | |
108 | ||
109 | # ifndef INVALID_SOCKET | |
110 | # define INVALID_SOCKET (-1) | |
111 | # endif | |
112 | # endif | |
113 | ||
114 | /* | |
617b49db RS |
115 | * Some IPv6 implementations are broken, you can disable them in known |
116 | * bad versions. | |
0e97f1e1 RS |
117 | */ |
118 | # if !defined(OPENSSL_USE_IPV6) | |
a5a0f328 RS |
119 | # if defined(AF_INET6) |
120 | # define OPENSSL_USE_IPV6 1 | |
121 | # else | |
122 | # define OPENSSL_USE_IPV6 0 | |
123 | # endif | |
0e97f1e1 RS |
124 | # endif |
125 | ||
384cdd46 RL |
126 | # define get_last_socket_error() errno |
127 | # define clear_socket_error() errno=0 | |
128 | ||
129 | # if defined(OPENSSL_SYS_WINDOWS) | |
130 | # undef get_last_socket_error | |
131 | # undef clear_socket_error | |
132 | # define get_last_socket_error() WSAGetLastError() | |
133 | # define clear_socket_error() WSASetLastError(0) | |
134 | # define readsocket(s,b,n) recv((s),(b),(n),0) | |
135 | # define writesocket(s,b,n) send((s),(b),(n),0) | |
136 | # elif defined(__DJGPP__) | |
137 | # define WATT32 | |
138 | # define WATT32_NO_OLDIES | |
139 | # define closesocket(s) close_s(s) | |
140 | # define readsocket(s,b,n) read_s(s,b,n) | |
141 | # define writesocket(s,b,n) send(s,b,n,0) | |
142 | # elif defined(OPENSSL_SYS_VMS) | |
143 | # define ioctlsocket(a,b,c) ioctl(a,b,c) | |
144 | # define closesocket(s) close(s) | |
145 | # define readsocket(s,b,n) recv((s),(b),(n),0) | |
146 | # define writesocket(s,b,n) send((s),(b),(n),0) | |
147 | # elif defined(OPENSSL_SYS_VXWORKS) | |
148 | # define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c)) | |
149 | # define closesocket(s) close(s) | |
150 | # define readsocket(s,b,n) read((s),(b),(n)) | |
151 | # define writesocket(s,b,n) write((s),(char *)(b),(n)) | |
cdb5129e | 152 | # elif defined(OPENSSL_SYS_TANDEM) |
08073700 RB |
153 | # if defined(OPENSSL_TANDEM_FLOSS) |
154 | # include <floss.h(floss_read, floss_write)> | |
155 | # define readsocket(s,b,n) floss_read((s),(b),(n)) | |
156 | # define writesocket(s,b,n) floss_write((s),(b),(n)) | |
157 | # else | |
158 | # define readsocket(s,b,n) read((s),(b),(n)) | |
159 | # define writesocket(s,b,n) write((s),(b),(n)) | |
160 | # endif | |
161 | # define ioctlsocket(a,b,c) ioctl(a,b,c) | |
162 | # define closesocket(s) close(s) | |
384cdd46 RL |
163 | # else |
164 | # define ioctlsocket(a,b,c) ioctl(a,b,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),(b),(n)) | |
168 | # endif | |
0e97f1e1 | 169 | |
bcbb30af DDO |
170 | /* also in apps/include/apps.h */ |
171 | # if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE) | |
8c10e1b6 | 172 | # define openssl_fdset(a, b) FD_SET((unsigned int)(a), b) |
bcbb30af | 173 | # else |
8c10e1b6 | 174 | # define openssl_fdset(a, b) FD_SET(a, b) |
bcbb30af DDO |
175 | # endif |
176 | ||
0e97f1e1 | 177 | #endif |