mirror of https://github.com/wolfSSL/wolfssl.git
commit
a0d6afbb04
|
@ -947,6 +947,7 @@ __SUNPRO_CC
|
|||
__SVR4
|
||||
__TI_COMPILER_VERSION__
|
||||
__TURBOC__
|
||||
__UNIX__
|
||||
__USE_GNU
|
||||
__USE_MISC
|
||||
__USE_XOPEN2K
|
||||
|
|
|
@ -2427,12 +2427,15 @@ target_include_directories(wolfssl
|
|||
|
||||
target_link_libraries(wolfssl PUBLIC ${WOLFSSL_LINK_LIBS})
|
||||
|
||||
if (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "^MSYS" OR ${CMAKE_SYSTEM_NAME} MATCHES "^MINGW")
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "OpenWatcom")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_link_libraries(wolfssl PUBLIC ws2_32 crypt32)
|
||||
endif()
|
||||
elseif (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "^MSYS" OR ${CMAKE_SYSTEM_NAME} MATCHES "^MINGW")
|
||||
# For Windows link required libraries
|
||||
message("Building on Windows/MSYS/MINGW")
|
||||
target_link_libraries(wolfssl PUBLIC
|
||||
ws2_32 crypt32 advapi32)
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "OpenWatcom")
|
||||
elseif(APPLE)
|
||||
message("Building on Apple")
|
||||
if(WOLFSSL_SYS_CA_CERTS)
|
||||
|
|
|
@ -1251,6 +1251,9 @@ int wolfIO_SendTo(SOCKET_T sd, WOLFSSL_BIO_ADDR *addr, char *buf, int sz, int wr
|
|||
ret = ioctlsocket(sockfd, FIONBIO, &blocking);
|
||||
if (ret == SOCKET_ERROR)
|
||||
ret = WOLFSSL_FATAL_ERROR;
|
||||
#elif defined(__WATCOMC__) && defined(__OS2__)
|
||||
if (ioctl(sockfd, FIONBIO, &non_blocking) == -1)
|
||||
ret = WOLFSSL_FATAL_ERROR;
|
||||
#else
|
||||
ret = fcntl(sockfd, F_GETFL, 0);
|
||||
if (ret >= 0) {
|
||||
|
@ -1290,9 +1293,9 @@ int wolfIO_SendTo(SOCKET_T sd, WOLFSSL_BIO_ADDR *addr, char *buf, int sz, int wr
|
|||
|
||||
ret = select(nfds, &rfds, &wfds, NULL, &timeout);
|
||||
if (ret == 0) {
|
||||
#ifdef DEBUG_HTTP
|
||||
#ifdef DEBUG_HTTP
|
||||
fprintf(stderr, "Timeout: %d\n", ret);
|
||||
#endif
|
||||
#endif
|
||||
return HTTP_TIMEOUT;
|
||||
}
|
||||
else if (ret > 0) {
|
||||
|
|
|
@ -14997,6 +14997,14 @@ void bench_sphincsKeySign(byte level, byte optim)
|
|||
return (double)us / 1000000.0;
|
||||
}
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
|
||||
#include <time.h>
|
||||
WC_INLINE double current_time(int reset)
|
||||
{
|
||||
(void)reset;
|
||||
return ((double)clock())/CLOCKS_PER_SEC;
|
||||
}
|
||||
#else
|
||||
|
||||
#include <time.h>
|
||||
|
|
|
@ -85,11 +85,50 @@
|
|||
#endif /* HAVE_ECC */
|
||||
#endif /*HAVE_PK_CALLBACKS */
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#ifdef __WATCOMC__
|
||||
#define SNPRINTF snprintf
|
||||
#if defined(__NT__)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <process.h>
|
||||
#ifdef TEST_IPV6 /* don't require newer SDK for IPV4 */
|
||||
#include <wspiapi.h>
|
||||
#endif
|
||||
#define SOCKET_T SOCKET
|
||||
#define XSLEEP_MS(t) Sleep(t)
|
||||
#elif defined(__OS2__)
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <tcpustd.h>
|
||||
#define SOCKET_T int
|
||||
#elif defined(__UNIX__)
|
||||
#include <string.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/tcp.h>
|
||||
#ifndef WOLFSSL_NDS
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#ifdef HAVE_PTHREAD
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#define SOCKET_T int
|
||||
#ifndef SO_NOSIGPIPE
|
||||
#include <signal.h> /* ignore SIGPIPE */
|
||||
#endif
|
||||
|
||||
#define XSLEEP_MS(m) \
|
||||
{ \
|
||||
struct timespec req = { (m)/1000, ((m) % 1000) * 1000 }; \
|
||||
nanosleep( &req, NULL ); \
|
||||
}
|
||||
#endif
|
||||
#elif defined(USE_WINDOWS_API)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <process.h>
|
||||
#ifdef TEST_IPV6 /* don't require newer SDK for IPV4 */
|
||||
#include <ws2tcpip.h>
|
||||
#include <wspiapi.h>
|
||||
#endif
|
||||
#define SOCKET_T SOCKET
|
||||
|
@ -1429,7 +1468,7 @@ static WC_INLINE void tcp_socket(SOCKET_T* sockfd, int udp, int sctp)
|
|||
err_sys_with_errno("socket failed\n");
|
||||
}
|
||||
|
||||
#ifndef USE_WINDOWS_API
|
||||
#if !defined(USE_WINDOWS_API) && !defined(__WATCOMC__) && !defined(__OS2__)
|
||||
#ifdef SO_NOSIGPIPE
|
||||
{
|
||||
int on = 1;
|
||||
|
@ -1457,7 +1496,7 @@ static WC_INLINE void tcp_socket(SOCKET_T* sockfd, int udp, int sctp)
|
|||
err_sys_with_errno("setsockopt TCP_NODELAY failed\n");
|
||||
}
|
||||
#endif
|
||||
#endif /* USE_WINDOWS_API */
|
||||
#endif /* !defined(USE_WINDOWS_API) && !defined(__WATCOMC__) && ... */
|
||||
}
|
||||
|
||||
#if defined(WOLFSSL_WOLFSENTRY_HOOKS) && defined(WOLFSENTRY_H)
|
||||
|
@ -1801,6 +1840,10 @@ static WC_INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
|
|||
|| defined (WOLFSSL_TIRTOS)|| defined(WOLFSSL_VXWORKS) \
|
||||
|| defined(WOLFSSL_ZEPHYR)
|
||||
/* non blocking not supported, for now */
|
||||
#elif defined(__WATCOMC__) && defined(__OS2__)
|
||||
int blocking = 1;
|
||||
if (ioctl(*sockfd, FIONBIO, &blocking) == -1)
|
||||
err_sys_with_errno("ioctl failed");
|
||||
#else
|
||||
int flags = fcntl(*sockfd, F_GETFL, 0);
|
||||
if (flags < 0)
|
||||
|
@ -1822,6 +1865,10 @@ static WC_INLINE void tcp_set_blocking(SOCKET_T* sockfd)
|
|||
|| defined (WOLFSSL_TIRTOS)|| defined(WOLFSSL_VXWORKS) \
|
||||
|| defined(WOLFSSL_ZEPHYR)
|
||||
/* non blocking not supported, for now */
|
||||
#elif defined(__WATCOMC__) && defined(__OS2__)
|
||||
int blocking = 0;
|
||||
if (ioctl(*sockfd, FIONBIO, &blocking) == -1)
|
||||
err_sys_with_errno("ioctl failed");
|
||||
#else
|
||||
int flags = fcntl(*sockfd, F_GETFL, 0);
|
||||
if (flags < 0)
|
||||
|
|
|
@ -287,7 +287,8 @@ typedef byte ecc_oid_t;
|
|||
#endif
|
||||
|
||||
|
||||
#if !defined(WOLFSSL_ECC_CURVE_STATIC) && defined(USE_WINDOWS_API)
|
||||
#if !defined(WOLFSSL_ECC_CURVE_STATIC) && defined(USE_WINDOWS_API) && \
|
||||
!defined(__WATCOMC__)
|
||||
/* MSC does something different with the pointers to the arrays than GCC,
|
||||
* and it causes the FIPS checksum to fail. In the case of windows builds,
|
||||
* store everything as arrays instead of pointers to strings. */
|
||||
|
|
|
@ -922,6 +922,13 @@ typedef struct w64wrapper {
|
|||
/* use only Thread Safe version of strtok */
|
||||
#if defined(USE_WOLF_STRTOK)
|
||||
#define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr))
|
||||
#elif defined(__WATCOMC__)
|
||||
#if __WATCOMC__ < 1300
|
||||
#define USE_WOLF_STRTOK
|
||||
#define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr))
|
||||
#else
|
||||
#define XSTRTOK(s1,d,ptr) strtok_r((s1),(d),(ptr))
|
||||
#endif
|
||||
#elif defined(USE_WINDOWS_API) || defined(INTIME_RTOS)
|
||||
#define XSTRTOK(s1,d,ptr) strtok_s((s1),(d),(ptr))
|
||||
#else
|
||||
|
@ -1503,6 +1510,7 @@ typedef struct w64wrapper {
|
|||
#define WOLFSSL_THREAD __stdcall
|
||||
#define WOLFSSL_THREAD_NO_JOIN _WCCALLBACK
|
||||
#elif defined(__OS2__)
|
||||
#define WOLFSSL_THREAD_VOID_RETURN
|
||||
typedef void THREAD_RETURN;
|
||||
typedef TID THREAD_TYPE;
|
||||
typedef struct COND_TYPE {
|
||||
|
|
|
@ -51,8 +51,15 @@
|
|||
#define WOLFSSL_LOCAL
|
||||
#endif /* HAVE_VISIBILITY */
|
||||
#else /* BUILDING_WOLFSSL */
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || \
|
||||
defined(_WIN32_WCE) || defined(__WATCOMC__)
|
||||
#if defined(__WATCOMC__)
|
||||
#if defined(WOLFSSL_DLL) && defined(__NT__)
|
||||
#define WOLFSSL_API __declspec(dllimport)
|
||||
#else
|
||||
#define WOLFSSL_API
|
||||
#endif
|
||||
#define WOLFSSL_LOCAL
|
||||
#elif defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || \
|
||||
defined(_WIN32_WCE)
|
||||
#if defined(WOLFSSL_DLL)
|
||||
#define WOLFSSL_API __declspec(dllimport)
|
||||
#else
|
||||
|
|
|
@ -120,13 +120,31 @@
|
|||
#endif
|
||||
|
||||
/* THREADING/MUTEX SECTION */
|
||||
#if defined(__WATCOMC__)
|
||||
#if !defined(SINGLE_THREADED)
|
||||
#if defined(SINGLE_THREADED) && defined(NO_FILESYSTEM)
|
||||
/* No system headers required for build. */
|
||||
#elif defined(__WATCOMC__)
|
||||
#if defined(SINGLE_THREADED)
|
||||
#if defined(USE_WINDOWS_API)
|
||||
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
|
||||
#include <windows.h>
|
||||
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
|
||||
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header */
|
||||
#ifndef WOLFSSL_USER_IO
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h> /* required for InetPton */
|
||||
#endif
|
||||
#elif defined(__OS2__)
|
||||
#include <os2.h>
|
||||
#endif
|
||||
#else
|
||||
#if defined(USE_WINDOWS_API)
|
||||
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
|
||||
#include <windows.h>
|
||||
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header */
|
||||
#include <process.h>
|
||||
#ifndef WOLFSSL_USER_IO
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h> /* required for InetPton */
|
||||
#endif
|
||||
#elif defined(__OS2__)
|
||||
#define INCL_DOSSEMAPHORES
|
||||
#define INCL_DOSPROCESS
|
||||
|
@ -140,17 +158,7 @@
|
|||
#include <pthread.h>
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#if defined(USE_WINDOWS_API)
|
||||
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file */
|
||||
#include <windows.h>
|
||||
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
|
||||
#elif defined(__OS2__)
|
||||
#include <os2.h>
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(SINGLE_THREADED) && defined(NO_FILESYSTEM)
|
||||
/* No system headers required for build. */
|
||||
#elif defined(USE_WINDOWS_API)
|
||||
#if defined(WOLFSSL_PTHREADS)
|
||||
#include <pthread.h>
|
||||
|
@ -164,7 +172,7 @@
|
|||
#if !defined(WOLFSSL_SGX) && !defined(WOLFSSL_NOT_WINDOWS_API)
|
||||
#define _WINSOCKAPI_ /* block inclusion of winsock.h header file. */
|
||||
#include <windows.h>
|
||||
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
|
||||
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header */
|
||||
#ifndef WOLFSSL_USER_IO
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h> /* required for InetPton */
|
||||
|
@ -926,7 +934,25 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||
|
||||
#if !defined(NO_WOLFSSL_DIR)\
|
||||
&& !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
|
||||
#if defined(USE_WINDOWS_API)
|
||||
#if defined(__WATCOMC__)
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#define XWRITE write
|
||||
#define XREAD read
|
||||
#define XCLOSE close
|
||||
#define XSTAT stat
|
||||
#define XS_ISREG(s) S_ISREG(s)
|
||||
#if defined(__UNIX__)
|
||||
#include <dirent.h>
|
||||
#define SEPARATOR_CHAR ':'
|
||||
#else
|
||||
#include <direct.h>
|
||||
#define SEPARATOR_CHAR ';'
|
||||
#endif
|
||||
#if defined(__NT__)
|
||||
#define XALTHOMEVARNAME "USERPROFILE"
|
||||
#endif
|
||||
#elif defined(USE_WINDOWS_API)
|
||||
#include <io.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef XSTAT
|
||||
|
@ -964,9 +990,7 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||
#define SEPARATOR_CHAR ':'
|
||||
|
||||
#else
|
||||
#ifndef NO_WOLFSSL_DIR
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#define XWRITE write
|
||||
|
|
109
wolfssl/wolfio.h
109
wolfssl/wolfio.h
|
@ -57,7 +57,32 @@
|
|||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef USE_WINDOWS_API
|
||||
#if defined(__WATCOMC__)
|
||||
#if defined(__NT__)
|
||||
#elif defined(__OS2__)
|
||||
#include <errno.h>
|
||||
#include <os2.h>
|
||||
#include <sys/types.h>
|
||||
#include <os2/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <nerrno.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
typedef int socklen_t;
|
||||
#elif defined(__LINUX__)
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#define XFCNTL(fd, flag, block) fcntl((fd), (flag), (block))
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#elif defined(USE_WINDOWS_API)
|
||||
#else
|
||||
#if defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)
|
||||
/* lwIP needs to be configured to use sockets API in this mode */
|
||||
/* LWIP_SOCKET 1 in lwip/opt.h or in build */
|
||||
|
@ -152,26 +177,6 @@
|
|||
#include <fclfcntl.h>
|
||||
#elif defined(WOLFSSL_EMNET)
|
||||
#include <IP/IP.h>
|
||||
#elif defined(__WATCOMC__)
|
||||
#if defined(__OS2__)
|
||||
#include <errno.h>
|
||||
#include <os2.h>
|
||||
#include <sys/types.h>
|
||||
#include <os2/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <nerrno.h>
|
||||
|
||||
typedef int socklen_t;
|
||||
#elif defined(__LINUX__)
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#elif !defined(WOLFSSL_NO_SOCK)
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
@ -224,7 +229,40 @@
|
|||
#define SOCKET_RECEIVING 1
|
||||
#define SOCKET_SENDING 2
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#ifdef __WATCOMC__
|
||||
#if defined(__NT__)
|
||||
/* no epipe yet */
|
||||
#ifndef WSAEPIPE
|
||||
#define WSAEPIPE -12345
|
||||
#endif
|
||||
#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define SOCKET_EAGAIN WSAETIMEDOUT
|
||||
#define SOCKET_ETIMEDOUT WSAETIMEDOUT
|
||||
#define SOCKET_ECONNRESET WSAECONNRESET
|
||||
#define SOCKET_EINTR WSAEINTR
|
||||
#define SOCKET_EPIPE WSAEPIPE
|
||||
#define SOCKET_ECONNREFUSED WSAENOTCONN
|
||||
#define SOCKET_ECONNABORTED WSAECONNABORTED
|
||||
#elif defined(__OS2__)
|
||||
#define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK
|
||||
#define SOCKET_EAGAIN SOCEAGAIN
|
||||
#define SOCKET_ETIMEDOUT SOCETIMEDOUT
|
||||
#define SOCKET_ECONNRESET SOCECONNRESET
|
||||
#define SOCKET_EINTR SOCEINTR
|
||||
#define SOCKET_EPIPE SOCEPIPE
|
||||
#define SOCKET_ECONNREFUSED SOCECONNREFUSED
|
||||
#define SOCKET_ECONNABORTED SOCECONNABORTED
|
||||
#elif defined(__UNIX__)
|
||||
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
|
||||
#define SOCKET_EAGAIN EAGAIN
|
||||
#define SOCKET_ETIMEDOUT ETIMEDOUT
|
||||
#define SOCKET_ECONNRESET ECONNRESET
|
||||
#define SOCKET_EINTR EINTR
|
||||
#define SOCKET_EPIPE EPIPE
|
||||
#define SOCKET_ECONNREFUSED ECONNREFUSED
|
||||
#define SOCKET_ECONNABORTED ECONNABORTED
|
||||
#endif
|
||||
#elif defined(USE_WINDOWS_API)
|
||||
/* no epipe yet */
|
||||
#ifndef WSAEPIPE
|
||||
#define WSAEPIPE -12345
|
||||
|
@ -856,21 +894,36 @@ WOLFSSL_API void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
|
|||
|
||||
|
||||
#ifndef XINET_NTOP
|
||||
#define XINET_NTOP(a,b,c,d) inet_ntop((a),(b),(c),(d))
|
||||
#ifdef USE_WINDOWS_API /* Windows-friendly definition */
|
||||
#undef XINET_NTOP
|
||||
#if defined(__WATCOMC__)
|
||||
#if defined(__OS2__) || defined(__NT__) && \
|
||||
(NTDDI_VERSION >= NTDDI_VISTA)
|
||||
#define XINET_NTOP(a,b,c,d) inet_ntop((a),(b),(c),(d))
|
||||
#else
|
||||
#define XINET_NTOP(a,b,c,d) \
|
||||
strncpy((c),inet_ntoa(*(unsigned *)(b)),(d))
|
||||
#endif
|
||||
#elif defined(USE_WINDOWS_API) /* Windows-friendly definition */
|
||||
#define XINET_NTOP(a,b,c,d) InetNtop((a),(b),(c),(d))
|
||||
#else
|
||||
#define XINET_NTOP(a,b,c,d) inet_ntop((a),(b),(c),(d))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef XINET_PTON
|
||||
#define XINET_PTON(a,b,c) inet_pton((a),(b),(c))
|
||||
#ifdef USE_WINDOWS_API /* Windows-friendly definition */
|
||||
#undef XINET_PTON
|
||||
#if defined(__WATCOMC__)
|
||||
#if defined(__OS2__) || defined(__NT__) && \
|
||||
(NTDDI_VERSION >= NTDDI_VISTA)
|
||||
#define XINET_PTON(a,b,c) inet_pton((a),(b),(c))
|
||||
#else
|
||||
#define XINET_PTON(a,b,c) *(unsigned *)(c) = inet_addr((b))
|
||||
#endif
|
||||
#elif defined(USE_WINDOWS_API) /* Windows-friendly definition */
|
||||
#if defined(__MINGW64__) && !defined(UNICODE)
|
||||
#define XINET_PTON(a,b,c) InetPton((a),(b),(c))
|
||||
#else
|
||||
#define XINET_PTON(a,b,c) InetPton((a),(PCWSTR)(b),(c))
|
||||
#endif
|
||||
#else
|
||||
#define XINET_PTON(a,b,c) inet_pton((a),(b),(c))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue