Fixed compile issues with example server/client. Fixed issue with using XMALLOC/XFREE being used in examples. Fixed issue with "int select_ret" declaration scope. Fixed issue with test.h HAVE_SESSION_TICKET "static rng" name.

This commit is contained in:
David Garske 2015-10-15 13:42:41 -07:00
parent d3584979a0
commit 10eab5047a
3 changed files with 16 additions and 16 deletions

View File

@ -191,8 +191,8 @@ int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
conn_time = current_time() - start;
/* Allocate TX/RX buffers */
tx_buffer = (char*)XMALLOC(TEST_BUFFER_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
rx_buffer = (char*)XMALLOC(TEST_BUFFER_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
tx_buffer = (char*)malloc(TEST_BUFFER_SIZE);
rx_buffer = (char*)malloc(TEST_BUFFER_SIZE);
if(tx_buffer && rx_buffer) {
WC_RNG rng;
@ -211,7 +211,7 @@ int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
/* Perform TX and RX of bytes */
xfer_bytes = 0;
while(throughput > xfer_bytes) {
int len, rx_pos;
int len, rx_pos, select_ret;
/* Determine packet size */
len = min(TEST_BUFFER_SIZE, throughput - xfer_bytes);
@ -226,7 +226,7 @@ int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
tx_time += current_time() - start;
/* Perform RX */
int select_ret = tcp_select(sockfd, 1); /* Timeout=1 second */
select_ret = tcp_select(sockfd, 1); /* Timeout=1 second */
if (select_ret == TEST_RECV_READY) {
start = current_time();
rx_pos = 0;
@ -260,10 +260,10 @@ int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
}
}
else {
err_sys("Buffer alloc failed");
err_sys("Client buffer malloc failed");
}
if(tx_buffer) XFREE(tx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if(rx_buffer) XFREE(rx_buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if(tx_buffer) free(tx_buffer);
if(rx_buffer) free(rx_buffer);
}
else {
err_sys("wolfSSL_connect failed");

View File

@ -123,7 +123,7 @@ static void NonBlockingSSL_Accept(SSL* ssl)
int ServerEchoData(SSL* ssl, int clientfd, int echoData, int throughput)
{
int ret = 0;
char* buffer = (char*)XMALLOC(TEST_BUFFER_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
char* buffer = (char*)malloc(TEST_BUFFER_SIZE);
if(buffer) {
double start, rx_time = 0, tx_time = 0;
int xfer_bytes = 0;
@ -162,7 +162,7 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int throughput)
xfer_bytes += len;
}
}
XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
free(buffer);
if(throughput) {
printf("wolfSSL Server Benchmark %d bytes\n"
@ -175,7 +175,7 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int throughput)
}
}
else {
err_sys("Server buffer XMALLOC failed");
err_sys("Server buffer malloc failed");
}
return EXIT_SUCCESS;

View File

@ -1938,17 +1938,17 @@ static INLINE const char* mymktemp(char *tempfn, int len, int num)
} key_ctx;
static key_ctx myKey_ctx;
static WC_RNG rng;
static WC_RNG myKey_rng;
static INLINE int TicketInit(void)
{
int ret = wc_InitRng(&rng);
int ret = wc_InitRng(&myKey_rng);
if (ret != 0) return ret;
ret = wc_RNG_GenerateBlock(&rng, myKey_ctx.key, sizeof(myKey_ctx.key));
ret = wc_RNG_GenerateBlock(&myKey_rng, myKey_ctx.key, sizeof(myKey_ctx.key));
if (ret != 0) return ret;
ret = wc_RNG_GenerateBlock(&rng, myKey_ctx.name,sizeof(myKey_ctx.name));
ret = wc_RNG_GenerateBlock(&myKey_rng, myKey_ctx.name,sizeof(myKey_ctx.name));
if (ret != 0) return ret;
return 0;
@ -1956,7 +1956,7 @@ static INLINE const char* mymktemp(char *tempfn, int len, int num)
static INLINE void TicketCleanup(void)
{
wc_FreeRng(&rng);
wc_FreeRng(&myKey_rng);
}
static INLINE int myTicketEncCb(WOLFSSL* ssl,
@ -1978,7 +1978,7 @@ static INLINE const char* mymktemp(char *tempfn, int len, int num)
if (enc) {
XMEMCPY(key_name, myKey_ctx.name, WOLFSSL_TICKET_NAME_SZ);
ret = wc_RNG_GenerateBlock(&rng, iv, WOLFSSL_TICKET_IV_SZ);
ret = wc_RNG_GenerateBlock(&myKey_rng, iv, WOLFSSL_TICKET_IV_SZ);
if (ret != 0) return WOLFSSL_TICKET_RET_REJECT;
/* build aad from key name, iv, and length */