mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
Review cleanups.
This commit is contained in:
@ -32,6 +32,11 @@
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
|
||||
/* Build Options:
|
||||
* WOLFSSL_SNIFFER_NO_RECOVERY: Do not track missed data count.
|
||||
*/
|
||||
|
||||
|
||||
/* xctime */
|
||||
#ifndef XCTIME
|
||||
#define XCTIME ctime
|
||||
@ -693,9 +698,7 @@ static int GetDevId(void)
|
||||
|
||||
void ssl_InitSniffer(void)
|
||||
{
|
||||
int devId;
|
||||
|
||||
devId = GetDevId();
|
||||
int devId = GetDevId();
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (wolfAsync_DevOpen(&devId) < 0) {
|
||||
@ -711,16 +714,15 @@ void ssl_InitSniffer(void)
|
||||
|
||||
void ssl_InitSniffer_ex2(int threadNum)
|
||||
{
|
||||
int devId;
|
||||
|
||||
devId = GetDevId();
|
||||
int devId = GetDevId();
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#ifndef WC_NO_ASYNC_THREADING
|
||||
if (wolfAsync_DevOpenThread(&devId,&threadNum) < 0) {
|
||||
if (wolfAsync_DevOpenThread(&devId,&threadNum) < 0)
|
||||
#else
|
||||
if (wolfAsync_DevOpen(&devId) < 0) {
|
||||
if (wolfAsync_DevOpen(&devId) < 0)
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr, "Async device open failed\nRunning without async\n");
|
||||
devId = INVALID_DEVID;
|
||||
}
|
||||
@ -6518,6 +6520,7 @@ static int ssl_DecodePacketInternal(const byte* packet, int length, int isChain,
|
||||
SnifferSession* session = NULL;
|
||||
void* vChain = NULL;
|
||||
word32 chainSz = 0;
|
||||
|
||||
if (isChain) {
|
||||
#ifdef WOLFSSL_SNIFFER_CHAIN_INPUT
|
||||
struct iovec* chain;
|
||||
|
@ -34,13 +34,21 @@
|
||||
#include <wolfssl/wolfcrypt/memory.h>
|
||||
#endif
|
||||
|
||||
#ifdef THREADED_SNIFFTEST
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Build Options:
|
||||
* THREADED_SNIFFTEST: Enable threaded version of the sniffer test
|
||||
*/
|
||||
|
||||
|
||||
/* For windows tests force sniffer build option on */
|
||||
#ifdef _WIN32
|
||||
#define WOLFSSL_SNIFFER
|
||||
#endif
|
||||
|
||||
#ifdef THREADED_SNIFFTEST
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_SNIFFER
|
||||
#ifndef NO_MAIN_DRIVER
|
||||
@ -497,7 +505,7 @@ static THREAD_LS_T SnifferPacket asyncQueue[WOLF_ASYNC_MAX_PENDING];
|
||||
static int SnifferAsyncQueueAdd(int lastRet, void* chain, int chainSz,
|
||||
int isChain, int packetNumber)
|
||||
{
|
||||
int ret = MEMORY_E, i, length;
|
||||
int ret, i, length;
|
||||
byte* packet;
|
||||
|
||||
#ifdef WOLFSSL_SNIFFER_CHAIN_INPUT
|
||||
@ -516,6 +524,7 @@ static int SnifferAsyncQueueAdd(int lastRet, void* chain, int chainSz,
|
||||
}
|
||||
|
||||
/* find first free idx */
|
||||
ret = MEMORY_E;
|
||||
for (i=0; i<WOLF_ASYNC_MAX_PENDING; i++) {
|
||||
if (asyncQueue[i].packet == NULL) {
|
||||
if (ret == MEMORY_E) {
|
||||
@ -647,9 +656,7 @@ static int ssl_Init_SnifferWorker(SnifferWorker* worker, int port,
|
||||
|
||||
worker->head = (SnifferPacket*)XMALLOC(sizeof(SnifferPacket), NULL,
|
||||
DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if (worker->head == NULL) {
|
||||
XFREE(worker->head, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return MEMORY_E;
|
||||
}
|
||||
|
||||
@ -670,6 +677,7 @@ static void ssl_Free_SnifferWorker(SnifferWorker* worker)
|
||||
|
||||
if (worker->head) {
|
||||
XFREE(worker->head, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
worker->head = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -680,13 +688,16 @@ static int SnifferWorkerPacketAdd(SnifferWorker* worker, int lastRet,
|
||||
|
||||
newEntry = (SnifferPacket*)XMALLOC(sizeof(SnifferPacket), NULL,
|
||||
DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if (newEntry == NULL) {
|
||||
return MEMORY_E;
|
||||
}
|
||||
XMEMSET(newEntry, 0, sizeof(SnifferPacket));
|
||||
newEntry->packet = (byte*)XMALLOC(length, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (newEntry == NULL || newEntry->packet == NULL) {
|
||||
XFREE(newEntry->packet, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (newEntry->packet == NULL) {
|
||||
XFREE(newEntry, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return MEMORY_E;
|
||||
}
|
||||
|
||||
/* Set newEntry fields to input values */
|
||||
XMEMCPY(newEntry->packet, packet, length);
|
||||
newEntry->length = length;
|
||||
@ -787,23 +798,19 @@ static int DecodePacket(byte* packet, int length, int packetNumber, char err[])
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_SNIFFER_CHAIN_INPUT) && \
|
||||
defined(WOLFSSL_SNIFFER_STORE_DATA_CB)
|
||||
defined(WOLFSSL_SNIFFER_STORE_DATA_CB)
|
||||
ret = ssl_DecodePacketWithChainSessionInfoStoreData(chain, chainSz,
|
||||
&data, &sslInfo, err);
|
||||
#elif defined(WOLFSSL_SNIFFER_CHAIN_INPUT)
|
||||
(void)sslInfo;
|
||||
ret = ssl_DecodePacketWithChain(chain, chainSz, &data, err);
|
||||
#else
|
||||
#if defined(WOLFSSL_SNIFFER_STORE_DATA_CB)
|
||||
#elif defined(WOLFSSL_SNIFFER_STORE_DATA_CB)
|
||||
ret = ssl_DecodePacketWithSessionInfoStoreData(packet,
|
||||
length, &data, &sslInfo, err);
|
||||
#else
|
||||
ret = ssl_DecodePacketWithSessionInfo(packet, length, &data,
|
||||
&sslInfo, err);
|
||||
#endif
|
||||
(void)chain;
|
||||
(void)chainSz;
|
||||
#endif
|
||||
|
||||
if (ret < 0) {
|
||||
printf("ssl_Decode ret = %d, %s on packet number %d\n", ret, err,
|
||||
@ -823,6 +830,8 @@ defined(WOLFSSL_SNIFFER_STORE_DATA_CB)
|
||||
}
|
||||
|
||||
(void)isChain;
|
||||
(void)chain;
|
||||
(void)chainSz;
|
||||
|
||||
return hadBadPacket;
|
||||
}
|
||||
|
Reference in New Issue
Block a user