Merge branch 'master' of github.com:cyassl/cyassl

This commit is contained in:
toddouska 2013-05-02 11:35:56 -07:00
commit a7228d0463
8 changed files with 69 additions and 29 deletions

15
README
View File

@ -35,7 +35,20 @@ before calling SSL_new(); Though it's not recommended.
*** end Notes ***
CyaSSL Release 2.6.0 (04/15/2013)
CyaSSL Release 2.x.x (TBA)
When compiling with Mingw, libtool may give the following warning due to
path conversion errors:
libtool: link: Could not determine host file name corresponding to **
libtool: link: Continuing, but uninstalled executables may not work.
If so, examples and testsuite will have problems when run, showing an
error while loading shared libraries. To resolve, please run "make install".
************** CyaSSL Release 2.6.0 (04/15/2013)
Release 2.6.0 CyaSSL has bug fixes and new features including:
- DTLS 1.2 support including AEAD ciphers

View File

@ -1276,6 +1276,12 @@ fi])
AX_HARDEN_CC_COMPILER_FLAGS
# link to ws2_32 if on mingw
case $host_os in
*mingw32)
LDFLAGS="$LDFLAGS -lws2_32" ;;
esac
# add user C_EXTRA_FLAGS back
CFLAGS="$CFLAGS $USER_C_EXTRA_FLAGS"
OPTION_FLAGS="$USER_C_EXTRA_FLAGS $AM_CFLAGS"

View File

@ -17,7 +17,7 @@
#include <ws2tcpip.h>
#include <wspiapi.h>
#endif
#define SOCKET_T unsigned int
#define SOCKET_T SOCKET
#define SNPRINTF _snprintf
#else
#include <string.h>
@ -91,7 +91,7 @@
typedef void* THREAD_TYPE;
#define CYASSL_THREAD
#else
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
typedef void* THREAD_RETURN;
typedef pthread_t THREAD_TYPE;
#define CYASSL_THREAD
@ -99,7 +99,7 @@
#define WAIT_OBJECT_0 0L
#else
typedef unsigned int THREAD_RETURN;
typedef HANDLE THREAD_TYPE;
typedef intptr_t THREAD_TYPE;
#define CYASSL_THREAD __stdcall
#endif
#endif
@ -139,7 +139,7 @@
typedef struct tcp_ready {
int ready; /* predicate */
int port;
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_t mutex;
pthread_cond_t cond;
#endif
@ -423,8 +423,13 @@ static INLINE void tcp_socket(SOCKET_T* sockfd, int udp)
else
*sockfd = socket(AF_INET_V, SOCK_STREAM, 0);
#ifdef USE_WINDOWS_API
if (*sockfd == INVALID_SOCKET)
err_sys("socket failed\n");
#else
if (*sockfd < 0)
err_sys("socket failed\n");
#endif
#ifndef USE_WINDOWS_API
#ifdef SO_NOSIGPIPE
@ -569,8 +574,8 @@ static INLINE int udp_read_connect(SOCKET_T sockfd)
return sockfd;
}
static INLINE void udp_accept(SOCKET_T* sockfd, int* clientfd, int useAnyAddr,
int port, func_args* args)
static INLINE void udp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
int useAnyAddr, int port, func_args* args)
{
SOCKADDR_IN_T addr;
@ -605,7 +610,7 @@ static INLINE void udp_accept(SOCKET_T* sockfd, int* clientfd, int useAnyAddr,
}
#endif
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__)
/* signal ready to accept data */
{
tcp_ready* ready = args->signal;
@ -620,8 +625,9 @@ static INLINE void udp_accept(SOCKET_T* sockfd, int* clientfd, int useAnyAddr,
*clientfd = udp_read_connect(*sockfd);
}
static INLINE void tcp_accept(SOCKET_T* sockfd, int* clientfd, func_args* args,
int port, int useAnyAddr, int udp)
static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
func_args* args, int port, int useAnyAddr,
int udp)
{
SOCKADDR_IN_T client;
socklen_t client_len = sizeof(client);
@ -633,7 +639,7 @@ static INLINE void tcp_accept(SOCKET_T* sockfd, int* clientfd, func_args* args,
tcp_listen(sockfd, &port, useAnyAddr, udp);
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__)
/* signal ready to tcp_accept */
{
tcp_ready* ready = args->signal;
@ -647,8 +653,13 @@ static INLINE void tcp_accept(SOCKET_T* sockfd, int* clientfd, func_args* args,
*clientfd = accept(*sockfd, (struct sockaddr*)&client,
(ACCEPT_THIRD_T)&client_len);
#ifdef USE_WINDOWS_API
if (*clientfd == INVALID_SOCKET)
err_sys("tcp accept failed");
#else
if (*clientfd == -1)
err_sys("tcp accept failed");
#endif
}
@ -657,6 +668,8 @@ static INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
#ifdef USE_WINDOWS_API
unsigned long blocking = 1;
int ret = ioctlsocket(*sockfd, FIONBIO, &blocking);
if (ret == SOCKET_ERROR)
err_sys("ioctlsocket failed");
#else
int flags = fcntl(*sockfd, F_GETFL, 0);
if (flags < 0)
@ -1198,7 +1211,7 @@ static INLINE void StackSizeCheck(func_args* args, thread_func tf)
#endif /* HAVE_STACK_SIZE */
#ifdef __hpux__
#if defined(__hpux__) || defined(__MINGW32__)
/* HP/UX doesn't have strsep, needed by test/suites.c */
static INLINE char* strsep(char **stringp, const char *delim)

View File

@ -42,7 +42,7 @@
static void SignalReady(void* args, int port)
{
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__)
/* signal ready to tcp_accept */
func_args* server_args = (func_args*)args;
tcp_ready* ready = server_args->signal;

View File

@ -116,7 +116,7 @@ static void Usage(void)
THREAD_RETURN CYASSL_THREAD server_test(void* args)
{
SOCKET_T sockfd = 0;
int clientfd = 0;
SOCKET_T clientfd = 0;
SSL_METHOD* method = 0;
SSL_CTX* ctx = 0;

View File

@ -591,7 +591,7 @@ static int test_CyaSSL_read_write(void)
THREAD_RETURN CYASSL_THREAD test_server_nofail(void* args)
{
SOCKET_T sockfd = 0;
int clientfd = 0;
SOCKET_T clientfd = 0;
CYASSL_METHOD* method = 0;
CYASSL_CTX* ctx = 0;

View File

@ -57,7 +57,7 @@ int main(int argc, char** argv)
void wait_tcp_ready(func_args* args)
{
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_lock(&args->signal->mutex);
if (!args->signal->ready)
@ -65,13 +65,15 @@ void wait_tcp_ready(func_args* args)
args->signal->ready = 0; /* reset */
pthread_mutex_unlock(&args->signal->mutex);
#else
(void)args;
#endif
}
void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
{
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_create(thread, 0, fun, args);
return;
#else
@ -82,12 +84,12 @@ void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
void join_thread(THREAD_TYPE thread)
{
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_join(thread, 0);
#else
int res = WaitForSingleObject(thread, INFINITE);
int res = WaitForSingleObject((HANDLE)thread, INFINITE);
assert(res == WAIT_OBJECT_0);
res = CloseHandle(thread);
res = CloseHandle((HANDLE)thread);
assert(res);
#endif
}
@ -97,7 +99,7 @@ void InitTcpReady(tcp_ready* ready)
{
ready->ready = 0;
ready->port = 0;
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_init(&ready->mutex, 0);
pthread_cond_init(&ready->cond, 0);
#endif
@ -106,8 +108,10 @@ void InitTcpReady(tcp_ready* ready)
void FreeTcpReady(tcp_ready* ready)
{
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_destroy(&ready->mutex);
pthread_cond_destroy(&ready->cond);
#else
(void)ready;
#endif
}

View File

@ -222,7 +222,7 @@ void simple_test(func_args* args)
void wait_tcp_ready(func_args* args)
{
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_lock(&args->signal->mutex);
if (!args->signal->ready)
@ -230,13 +230,15 @@ void wait_tcp_ready(func_args* args)
args->signal->ready = 0; /* reset */
pthread_mutex_unlock(&args->signal->mutex);
#else
(void)args;
#endif
}
void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
{
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_create(thread, 0, fun, args);
return;
#else
@ -247,12 +249,12 @@ void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
void join_thread(THREAD_TYPE thread)
{
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_join(thread, 0);
#else
int res = WaitForSingleObject(thread, INFINITE);
int res = WaitForSingleObject((HANDLE)thread, INFINITE);
assert(res == WAIT_OBJECT_0);
res = CloseHandle(thread);
res = CloseHandle((HANDLE)thread);
assert(res);
#endif
}
@ -262,7 +264,7 @@ void InitTcpReady(tcp_ready* ready)
{
ready->ready = 0;
ready->port = 0;
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_init(&ready->mutex, 0);
pthread_cond_init(&ready->cond, 0);
#endif
@ -271,9 +273,11 @@ void InitTcpReady(tcp_ready* ready)
void FreeTcpReady(tcp_ready* ready)
{
#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_destroy(&ready->mutex);
pthread_cond_destroy(&ready->cond);
#else
(void)ready;
#endif
}