VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.5/include/internal/sockets.h@ 104305

Last change on this file since 104305 was 104078, checked in by vboxsync, 11 months ago

openssl-3.1.5: Applied and adjusted our OpenSSL changes to 3.1.4. bugref:10638

File size: 5.3 KB
Line 
1/*
2 * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
10#ifndef OSSL_INTERNAL_SOCKETS_H
11# define OSSL_INTERNAL_SOCKETS_H
12# pragma once
13
14# include <openssl/opensslconf.h>
15
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
27# ifdef OPENSSL_NO_SOCK
28
29# elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
30# if defined(__DJGPP__)
31# define WATT32
32# define WATT32_NO_OLDIES
33# include <sys/socket.h>
34# include <sys/un.h>
35# include <tcp.h>
36# include <netdb.h>
37# include <arpa/inet.h>
38# include <netinet/tcp.h>
39# elif defined(_WIN32_WCE) && _WIN32_WCE<410
40# define getservbyname _masked_declaration_getservbyname
41# endif
42# if !defined(IPPROTO_IP)
43 /* winsock[2].h was included already? */
44# include <winsock.h>
45# endif
46# ifdef getservbyname
47 /* this is used to be wcecompat/include/winsock_extras.h */
48# undef getservbyname
49struct servent *PASCAL getservbyname(const char *, const char *);
50# endif
51
52# ifdef _WIN64
53/*
54 * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
55 * the value constitutes an index in per-process table of limited size
56 * and not a real pointer. And we also depend on fact that all processors
57 * Windows run on happen to be two's-complement, which allows to
58 * interchange INVALID_SOCKET and -1.
59 */
60# define socket(d,t,p) ((int)socket(d,t,p))
61# define accept(s,f,l) ((int)accept(s,f,l))
62# endif
63
64# else
65
66# ifndef NO_SYS_PARAM_H
67# include <sys/param.h>
68# endif
69# ifdef OPENSSL_SYS_VXWORKS
70# include <time.h>
71# endif
72
73# include <netdb.h>
74# if defined(OPENSSL_SYS_VMS_NODECC)
75# include <socket.h>
76# include <in.h>
77# include <inet.h>
78# else
79# include <sys/socket.h>
80# if !defined(NO_SYS_UN_H) && defined(AF_UNIX) && !defined(OPENSSL_NO_UNIX_SOCK)
81# include <sys/un.h>
82# ifndef UNIX_PATH_MAX
83# define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
84# endif
85# endif
86# ifdef FILIO_H
87# include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */
88# endif
89# include <netinet/in.h>
90# include <arpa/inet.h>
91# include <netinet/tcp.h>
92# endif
93
94# ifdef OPENSSL_SYS_AIX
95# include <sys/select.h>
96# endif
97
98# ifndef VMS
99# include <sys/ioctl.h>
100# else
101# if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
102 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
103# include <sys/ioctl.h>
104# endif
105# include <unixio.h>
106# if defined(TCPIP_TYPE_SOCKETSHR)
107# include <socketshr.h>
108# endif
109# endif
110
111# ifndef INVALID_SOCKET
112# define INVALID_SOCKET (-1)
113# endif
114# endif
115
116/*
117 * Some IPv6 implementations are broken, you can disable them in known
118 * bad versions.
119 */
120# if !defined(OPENSSL_USE_IPV6)
121# if defined(AF_INET6)
122# define OPENSSL_USE_IPV6 1
123# else
124# define OPENSSL_USE_IPV6 0
125# endif
126# endif
127
128/*
129 * Some platforms define AF_UNIX, but don't support it
130 */
131# if !defined(OPENSSL_NO_UNIX_SOCK)
132# if !defined(AF_UNIX) || defined(NO_SYS_UN_H)
133# define OPENSSL_NO_UNIX_SOCK
134# endif
135# endif
136
137# define get_last_socket_error() errno
138# define clear_socket_error() errno=0
139
140# if defined(OPENSSL_SYS_WINDOWS)
141# undef get_last_socket_error
142# undef clear_socket_error
143# define get_last_socket_error() WSAGetLastError()
144# define clear_socket_error() WSASetLastError(0)
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(__DJGPP__)
148# define closesocket(s) close_s(s)
149# define readsocket(s,b,n) read_s(s,b,n)
150# define writesocket(s,b,n) send(s,b,n,0)
151# elif defined(OPENSSL_SYS_VMS)
152# define ioctlsocket(a,b,c) ioctl(a,b,c)
153# define closesocket(s) close(s)
154# define readsocket(s,b,n) recv((s),(b),(n),0)
155# define writesocket(s,b,n) send((s),(b),(n),0)
156# elif defined(OPENSSL_SYS_VXWORKS)
157# define ioctlsocket(a,b,c) ioctl((a),(b),(int)(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),(char *)(b),(n))
161# elif defined(OPENSSL_SYS_TANDEM)
162# if defined(OPENSSL_TANDEM_FLOSS)
163# include <floss.h(floss_read, floss_write)>
164# define readsocket(s,b,n) floss_read((s),(b),(n))
165# define writesocket(s,b,n) floss_write((s),(b),(n))
166# else
167# define readsocket(s,b,n) read((s),(b),(n))
168# define writesocket(s,b,n) write((s),(b),(n))
169# endif
170# define ioctlsocket(a,b,c) ioctl(a,b,c)
171# define closesocket(s) close(s)
172# else
173# define ioctlsocket(a,b,c) ioctl(a,b,c)
174# define closesocket(s) close(s)
175# define readsocket(s,b,n) read((s),(b),(n))
176# define writesocket(s,b,n) write((s),(b),(n))
177# endif
178
179/* also in apps/include/apps.h */
180# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
181# define openssl_fdset(a, b) FD_SET((unsigned int)(a), b)
182# else
183# define openssl_fdset(a, b) FD_SET(a, b)
184# endif
185
186#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette