Fix build with either NO_WOLFSSL_SERVER or NO_WOLFSSL_CLIENT defined.

This commit is contained in:
David Garske
2017-06-26 23:05:32 -07:00
parent 3bdf8b3cfd
commit 47cc3ffdbc
7 changed files with 148 additions and 122 deletions

View File

@@ -48,6 +48,8 @@
#include "examples/client/client.h"
#ifndef NO_WOLFSSL_CLIENT
#ifdef WOLFSSL_ASYNC_CRYPT
static int devId = INVALID_DEVID;
#endif
@@ -59,17 +61,36 @@
* test mode and (2) the testsuite which uses this code and sets up the correct
* port numbers when the internal thread using the server code using port 0. */
#ifdef WOLFSSL_CALLBACKS
int handShakeCB(HandShakeInfo*);
int timeoutCB(TimeoutInfo*);
Timeval timeout;
static int handShakeCB(HandShakeInfo* info)
{
(void)info;
return 0;
}
static int timeoutCB(TimeoutInfo* info)
{
(void)info;
return 0;
}
#endif
#ifdef HAVE_SESSION_TICKET
int sessionTicketCB(WOLFSSL*, const unsigned char*, int, void*);
static int sessionTicketCB(WOLFSSL* ssl,
const unsigned char* ticket, int ticketSz,
void* ctx)
{
(void)ssl;
(void)ticket;
printf("Session Ticket CB: ticketSz = %d, ctx = %s\n",
ticketSz, (char*)ctx);
return 0;
}
#endif
static int NonBlockingSSL_Connect(WOLFSSL* ssl)
{
int ret;
@@ -2292,6 +2313,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#endif
}
#endif /* !NO_WOLFSSL_CLIENT */
/* so overall tests can pull in test function */
#ifndef NO_MAIN_DRIVER
@@ -2312,10 +2335,12 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
wolfSSL_Init();
ChangeToWolfRoot();
#ifndef NO_WOLFSSL_CLIENT
#ifdef HAVE_STACK_SIZE
StackSizeCheck(&args, client_test);
#else
client_test(&args);
#endif
#endif
wolfSSL_Cleanup();
@@ -2331,38 +2356,3 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
char* myoptarg = NULL;
#endif /* NO_MAIN_DRIVER */
#ifdef WOLFSSL_CALLBACKS
int handShakeCB(HandShakeInfo* info)
{
(void)info;
return 0;
}
int timeoutCB(TimeoutInfo* info)
{
(void)info;
return 0;
}
#endif
#ifdef HAVE_SESSION_TICKET
int sessionTicketCB(WOLFSSL* ssl,
const unsigned char* ticket, int ticketSz,
void* ctx)
{
(void)ssl;
(void)ticket;
printf("Session Ticket CB: ticketSz = %d, ctx = %s\n",
ticketSz, (char*)ctx);
return 0;
}
#endif

View File

@@ -52,6 +52,8 @@
#include "examples/echoclient/echoclient.h"
#ifndef NO_WOLFSSL_CLIENT
#ifdef WOLFSSL_ASYNC_CRYPT
static int devId = INVALID_DEVID;
#endif
@@ -313,6 +315,7 @@ void echoclient_test(void* args)
((func_args*)args)->return_code = 0;
}
#endif /* !NO_WOLFSSL_CLIENT */
/* so overall tests can pull in test function */
#ifndef NO_MAIN_DRIVER
@@ -338,7 +341,9 @@ void echoclient_test(void* args)
#ifndef CYASSL_TIRTOS
ChangeToWolfRoot();
#endif
#ifndef NO_WOLFSSL_CLIENT
echoclient_test(&args);
#endif
CyaSSL_Cleanup();
@@ -351,5 +356,3 @@ void echoclient_test(void* args)
}
#endif /* NO_MAIN_DRIVER */

View File

@@ -53,6 +53,8 @@
#include "examples/echoserver/echoserver.h"
#ifndef NO_WOLFSSL_SERVER
#ifdef WOLFSSL_ASYNC_CRYPT
static int devId = INVALID_DEVID;
#endif
@@ -481,6 +483,8 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
#endif
}
#endif /* !NO_WOLFSSL_SERVER */
/* so overall tests can pull in test function */
#ifndef NO_MAIN_DRIVER
@@ -504,7 +508,9 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
CyaSSL_Debugging_ON();
#endif
ChangeToWolfRoot();
#ifndef NO_WOLFSSL_SERVER
echoserver_test(&args);
#endif
CyaSSL_Cleanup();
#ifdef HAVE_WNR
@@ -515,7 +521,4 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
return args.return_code;
}
#endif /* NO_MAIN_DRIVER */

View File

@@ -50,6 +50,8 @@
#include "examples/server/server.h"
#ifndef NO_WOLFSSL_SERVER
#ifdef WOLFSSL_ASYNC_CRYPT
static int devId = INVALID_DEVID;
#endif
@@ -59,16 +61,6 @@
* test.h will write the actual port number into the ready file for use
* by the client. */
#ifdef CYASSL_CALLBACKS
int srvHandShakeCB(HandShakeInfo*);
int srvTimeoutCB(TimeoutInfo*);
Timeval srvTo;
#endif
#ifndef NO_HANDSHAKE_DONE_CB
int myHsDoneCb(WOLFSSL* ssl, void* user_ctx);
#endif
static const char webServerMsg[] =
"HTTP/1.1 200 OK\n"
"Content-Type: text/html\n"
@@ -84,6 +76,38 @@ static const char webServerMsg[] =
"</html>\n";
int runWithErrors = 0; /* Used with -x flag to run err_sys vs. print errors */
#ifdef CYASSL_CALLBACKS
Timeval srvTo;
static int srvHandShakeCB(HandShakeInfo* info)
{
(void)info;
return 0;
}
static int srvTimeoutCB(TimeoutInfo* info)
{
(void)info;
return 0;
}
#endif
#ifndef NO_HANDSHAKE_DONE_CB
static int myHsDoneCb(WOLFSSL* ssl, void* user_ctx)
{
(void)user_ctx;
(void)ssl;
/* printf("Notified HandShake done\n"); */
/* return negative number to end TLS connection now */
return 0;
}
#endif
static void err_sys_ex(int out, const char* msg)
{
if (out == 1) { /* if server is running w/ -x flag, print error w/o exit */
@@ -1447,6 +1471,8 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
#endif
}
#endif /* !NO_WOLFSSL_SERVER */
/* so overall tests can pull in test function */
#ifndef NO_MAIN_DRIVER
@@ -1470,11 +1496,16 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
CyaSSL_Init();
ChangeToWolfRoot();
#ifndef NO_WOLFSSL_SERVER
#ifdef HAVE_STACK_SIZE
StackSizeCheck(&args, server_test);
#else
server_test(&args);
#endif
#else
printf("Server not compiled in!\n");
#endif
CyaSSL_Cleanup();
FreeTcpReady(&ready);
@@ -1490,35 +1521,3 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
char* myoptarg = NULL;
#endif /* NO_MAIN_DRIVER */
#ifdef CYASSL_CALLBACKS
int srvHandShakeCB(HandShakeInfo* info)
{
(void)info;
return 0;
}
int srvTimeoutCB(TimeoutInfo* info)
{
(void)info;
return 0;
}
#endif
#ifndef NO_HANDSHAKE_DONE_CB
int myHsDoneCb(WOLFSSL* ssl, void* user_ctx)
{
(void)user_ctx;
(void)ssl;
/* printf("Notified HandShake done\n"); */
/* return negative number to end TLS connection now */
return 0;
}
#endif