fix warnings around clang-diagnostic-embedded-directive and readability-uppercase-literal-suffix; update wolfSentry integration for upcoming release 0.8.0.

pull/5957/head
Daniel Pouzzner 2023-01-05 00:13:17 -06:00
parent adb406e1ee
commit 43265669c6
5 changed files with 120 additions and 40 deletions

View File

@ -799,20 +799,19 @@ doExit:
if (exitWithRet)
return err;
printf(
#if !defined(__MINGW32__)
"wolfSSL Client Benchmark %zu bytes\n"
#ifdef __MINGW32__
#define SIZE_FMT "%d"
#define SIZE_TYPE int
#else
"wolfSSL Client Benchmark %d bytes\n"
#define SIZE_FMT "%zu"
#define SIZE_TYPE size_t
#endif
printf(
"wolfSSL Client Benchmark " SIZE_FMT " bytes\n"
"\tConnect %8.3f ms\n"
"\tTX %8.3f ms (%8.3f MBps)\n"
"\tRX %8.3f ms (%8.3f MBps)\n",
#if !defined(__MINGW32__)
throughput,
#else
(int)throughput,
#endif
(SIZE_TYPE)throughput,
conn_time * 1000,
tx_time * 1000, throughput / tx_time / 1024 / 1024,
rx_time * 1000, throughput / rx_time / 1024 / 1024
@ -4456,7 +4455,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
exit:
#ifdef WOLFSSL_WOLFSENTRY_HOOKS
wolfsentry_ret = wolfsentry_shutdown(&wolfsentry);
wolfsentry_ret =
wolfsentry_shutdown(WOLFSENTRY_CONTEXT_ARGS_OUT_EX(&wolfsentry));
if (wolfsentry_ret < 0) {
fprintf(stderr,
"wolfsentry_shutdown() returned " WOLFSENTRY_ERROR_FMT "\n",

View File

@ -499,19 +499,18 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
free(buffer);
if (throughput) {
#ifdef __MINGW32__
#define SIZE_FMT "%d"
#define SIZE_TYPE int
#else
#define SIZE_FMT "%zu"
#define SIZE_TYPE size_t
#endif
printf(
#if !defined(__MINGW32__)
"wolfSSL Server Benchmark %zu bytes\n"
#else
"wolfSSL Server Benchmark %d bytes\n"
#endif
"wolfSSL Server Benchmark " SIZE_FMT " bytes\n"
"\tRX %8.3f ms (%8.3f MBps)\n"
"\tTX %8.3f ms (%8.3f MBps)\n",
#if !defined(__MINGW32__)
throughput,
#else
(int)throughput,
#endif
(SIZE_TYPE)throughput,
rx_time * 1000, throughput / rx_time / 1024 / 1024,
tx_time * 1000, throughput / tx_time / 1024 / 1024
);
@ -3715,7 +3714,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
exit:
#ifdef WOLFSSL_WOLFSENTRY_HOOKS
wolfsentry_ret = wolfsentry_shutdown(&wolfsentry);
wolfsentry_ret =
wolfsentry_shutdown(WOLFSENTRY_CONTEXT_ARGS_OUT_EX(&wolfsentry));
if (wolfsentry_ret < 0) {
fprintf(stderr,
"wolfsentry_shutdown() returned " WOLFSENTRY_ERROR_FMT "\n",

View File

@ -1293,7 +1293,7 @@ static const char* bench_result_words2[][5] = {
/* maximum runtime for each benchmark */
#ifndef BENCH_MIN_RUNTIME_SEC
#define BENCH_MIN_RUNTIME_SEC 1.0f
#define BENCH_MIN_RUNTIME_SEC 1.0F
#endif
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)

View File

@ -13830,11 +13830,13 @@ int GetFormattedTime(void* currTime, byte* buf, word32 len)
return BUFFER_E;
}
ret = XSPRINTF((char*)buf,
#else
ret = XSNPRINTF((char*)buf, len,
#endif
"%02d%02d%02d%02d%02d%02dZ", year, mon, day,
hour, mini, sec);
#else
ret = XSNPRINTF((char*)buf, len,
"%02d%02d%02d%02d%02d%02dZ", year, mon, day,
hour, mini, sec);
#endif
}
else {
/* GeneralizedTime */
@ -13850,11 +13852,13 @@ int GetFormattedTime(void* currTime, byte* buf, word32 len)
return BUFFER_E;
}
ret = XSPRINTF((char*)buf,
#else
ret = XSNPRINTF((char*)buf, len,
#endif
"%4d%02d%02d%02d%02d%02dZ", year, mon, day,
hour, mini, sec);
#else
ret = XSNPRINTF((char*)buf, len,
"%4d%02d%02d%02d%02d%02dZ", year, mon, day,
hour, mini, sec);
#endif
}
return ret;

View File

@ -1414,6 +1414,16 @@ static WC_INLINE void tcp_socket(SOCKET_T* sockfd, int udp, int sctp)
#include <wolfsentry/wolfsentry_json.h>
#endif
#if defined(WOLFSENTRY_VERSION_GE)
#if WOLFSENTRY_VERSION_GE(0, 8, 0)
#define HAVE_WOLFSENTRY_API_0v8
#endif
#endif
#ifndef HAVE_WOLFSENTRY_API_0v8
#define WOLFSENTRY_CONTEXT_ARGS_OUT_EX(x) (x)
#endif
struct wolfsentry_data {
WOLFSENTRY_SOCKADDR(128) remote;
WOLFSENTRY_SOCKADDR(128) local;
@ -1517,11 +1527,21 @@ static int wolfSentry_NetworkFilterCallback(
wolfsentry_errcode_t ret;
wolfsentry_action_res_t action_results;
#if defined(WOLFSENTRY_THREADSAFE) && defined(HAVE_WOLFSENTRY_API_0v8)
WOLFSENTRY_THREAD_HEADER(WOLFSENTRY_THREAD_FLAG_NONE);
if (WOLFSENTRY_THREAD_GET_ERROR < 0) {
fprintf(stderr, "wolfsentry thread init error: "
WOLFSENTRY_ERROR_FMT "\n",
WOLFSENTRY_ERROR_FMT_ARGS(WOLFSENTRY_THREAD_GET_ERROR));
return WOLFSSL_FAILURE;
}
#endif /* WOLFSENTRY_THREADSAFE && HAVE_WOLFSENTRY_API_0v8 */
if ((data = wolfSSL_get_ex_data(ssl, wolfsentry_data_index)) == NULL)
return WOLFSSL_FAILURE;
ret = wolfsentry_route_event_dispatch(
_wolfsentry,
WOLFSENTRY_CONTEXT_ARGS_OUT_EX(_wolfsentry),
(const struct wolfsentry_sockaddr *)&data->remote,
(const struct wolfsentry_sockaddr *)&data->local,
data->flags,
@ -1562,6 +1582,14 @@ static int wolfSentry_NetworkFilterCallback(
*decision == WOLFSSL_NETFILTER_PASS ? "PASS" :
"???");
#if defined(WOLFSENTRY_THREADSAFE) && defined(HAVE_WOLFSENTRY_API_0v8)
ret = WOLFSENTRY_THREAD_TAILER(WOLFSENTRY_THREAD_FLAG_NONE);
if (ret < 0) {
fprintf(stderr, "wolfsentry thread exit error: "
WOLFSENTRY_ERROR_FMT "\n", WOLFSENTRY_ERROR_FMT_ARGS(ret));
}
#endif
return WOLFSSL_SUCCESS;
}
@ -1571,8 +1599,25 @@ static int wolfsentry_setup(
wolfsentry_route_flags_t route_flags)
{
wolfsentry_errcode_t ret;
#ifdef HAVE_WOLFSENTRY_API_0v8
#ifdef WOLFSENTRY_THREADSAFE
WOLFSENTRY_THREAD_HEADER(WOLFSENTRY_THREAD_FLAG_NONE);
if (WOLFSENTRY_THREAD_GET_ERROR < 0) {
fprintf(stderr, "wolfsentry thread init error: "
WOLFSENTRY_ERROR_FMT "\n",
WOLFSENTRY_ERROR_FMT_ARGS(WOLFSENTRY_THREAD_GET_ERROR));
err_sys("unable to initialize wolfSentry thread context");
}
#endif
ret = wolfsentry_init(wolfsentry_build_settings,
WOLFSENTRY_CONTEXT_ARGS_OUT_EX(NULL /* hpi */),
NULL /* default config */,
_wolfsentry);
#else
ret = wolfsentry_init(NULL /* hpi */, NULL /* default config */,
_wolfsentry);
#endif
if (ret < 0) {
fprintf(stderr, "wolfsentry_init() returned " WOLFSENTRY_ERROR_FMT "\n",
WOLFSENTRY_ERROR_FMT_ARGS(ret));
@ -1597,7 +1642,7 @@ static int wolfsentry_setup(
}
if ((ret = wolfsentry_config_json_init(
*_wolfsentry,
WOLFSENTRY_CONTEXT_ARGS_OUT_EX(*_wolfsentry),
WOLFSENTRY_CONFIG_LOAD_FLAG_NONE,
&jps)) < 0) {
fprintf(stderr, "wolfsentry_config_json_init() returned "
@ -1633,14 +1678,15 @@ static int wolfsentry_setup(
{
struct wolfsentry_route_table *table;
if ((ret = wolfsentry_route_get_main_table(*_wolfsentry,
&table)) < 0)
if ((ret = wolfsentry_route_get_main_table(
WOLFSENTRY_CONTEXT_ARGS_OUT_EX(*_wolfsentry),
&table)) < 0)
{
fprintf(stderr, "wolfsentry_route_get_main_table() returned "
WOLFSENTRY_ERROR_FMT "\n",
WOLFSENTRY_ERROR_FMT_ARGS(ret));
if (ret < 0)
return ret;
}
if (WOLFSENTRY_MASKIN_BITS(route_flags, WOLFSENTRY_ROUTE_FLAG_DIRECTION_OUT)) {
WOLFSENTRY_SOCKADDR(128) remote, local;
@ -1648,7 +1694,8 @@ static int wolfsentry_setup(
wolfsentry_action_res_t action_results;
if ((ret = wolfsentry_route_table_default_policy_set(
*_wolfsentry, table,
WOLFSENTRY_CONTEXT_ARGS_OUT_EX(*_wolfsentry),
table,
WOLFSENTRY_ACTION_RES_ACCEPT))
< 0) {
fprintf(stderr,
@ -1671,7 +1718,8 @@ static int wolfsentry_setup(
#endif
if ((ret = wolfsentry_route_insert
(*_wolfsentry, NULL /* caller_context */,
(WOLFSENTRY_CONTEXT_ARGS_OUT_EX(*_wolfsentry),
NULL /* caller_context */,
(const struct wolfsentry_sockaddr *)&remote,
(const struct wolfsentry_sockaddr *)&local,
route_flags |
@ -1696,7 +1744,7 @@ static int wolfsentry_setup(
wolfsentry_action_res_t action_results;
if ((ret = wolfsentry_route_table_default_policy_set(
*_wolfsentry, table,
WOLFSENTRY_CONTEXT_ARGS_OUT_EX(*_wolfsentry), table,
WOLFSENTRY_ACTION_RES_REJECT|WOLFSENTRY_ACTION_RES_STOP))
< 0) {
fprintf(stderr,
@ -1719,8 +1767,10 @@ static int wolfsentry_setup(
#endif
if ((ret = wolfsentry_route_insert
(*_wolfsentry, NULL /* caller_context */,
(const struct wolfsentry_sockaddr *)&remote, (const struct wolfsentry_sockaddr *)&local,
(WOLFSENTRY_CONTEXT_ARGS_OUT_EX(*_wolfsentry),
NULL /* caller_context */,
(const struct wolfsentry_sockaddr *)&remote,
(const struct wolfsentry_sockaddr *)&local,
route_flags |
WOLFSENTRY_ROUTE_FLAG_GREENLISTED |
WOLFSENTRY_ROUTE_FLAG_PARENT_EVENT_WILDCARD |
@ -1740,6 +1790,14 @@ static int wolfsentry_setup(
}
}
#if defined(WOLFSENTRY_THREADSAFE) && defined(HAVE_WOLFSENTRY_API_0v8)
ret = WOLFSENTRY_THREAD_TAILER(WOLFSENTRY_THREAD_FLAG_NONE);
if (ret < 0) {
fprintf(stderr, "wolfsentry thread exit error: "
WOLFSENTRY_ERROR_FMT "\n", WOLFSENTRY_ERROR_FMT_ARGS(ret));
}
#endif
return 0;
}
@ -1759,6 +1817,16 @@ static WC_INLINE int tcp_connect_with_wolfSentry(
wolfsentry_action_res_t action_results;
wolfSSL_netfilter_decision_t decision;
#if defined(WOLFSENTRY_THREADSAFE) && defined(HAVE_WOLFSENTRY_API_0v8)
WOLFSENTRY_THREAD_HEADER(WOLFSENTRY_THREAD_FLAG_NONE);
if (WOLFSENTRY_THREAD_GET_ERROR < 0) {
fprintf(stderr, "wolfsentry thread init error: "
WOLFSENTRY_ERROR_FMT "\n",
WOLFSENTRY_ERROR_FMT_ARGS(WOLFSENTRY_THREAD_GET_ERROR));
err_sys("unable to initialize wolfSentry thread context");
}
#endif
build_addr(&remote_addr, ip, port, udp, sctp);
{
@ -1780,7 +1848,7 @@ static WC_INLINE int tcp_connect_with_wolfSentry(
}
ret = wolfsentry_route_event_dispatch(
_wolfsentry,
WOLFSENTRY_CONTEXT_ARGS_OUT_EX(_wolfsentry),
(const struct wolfsentry_sockaddr *)&wolfsentry_data->remote,
(const struct wolfsentry_sockaddr *)&wolfsentry_data->local,
wolfsentry_data->flags,
@ -1834,6 +1902,14 @@ static WC_INLINE int tcp_connect_with_wolfSentry(
err_sys_with_errno("tcp connect failed");
}
#if defined(WOLFSENTRY_THREADSAFE) && defined(HAVE_WOLFSENTRY_API_0v8)
ret = WOLFSENTRY_THREAD_TAILER(WOLFSENTRY_THREAD_FLAG_NONE);
if (ret < 0) {
fprintf(stderr, "wolfsentry thread exit error: "
WOLFSENTRY_ERROR_FMT "\n", WOLFSENTRY_ERROR_FMT_ARGS(ret));
}
#endif
return WOLFSSL_SUCCESS;
}