Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 39 additions & 18 deletions examples/benchmark/tls_bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ Or
/* WOLFSSL_MAX_MTU in internal.h */
#define TEST_DTLS_PACKET_SIZE (1500)
#else
/* MAX_UDP_SIZE in interna.h */
#define TEST_DTLS_PACKET_SIZE (8092)
/* Must fit in one DTLS record: WOLFSSL_MAX_MTU (1400) - MAX_MSG_EXTRA (~102).
* Define WOLFSSL_DTLS_MTU and call wolfSSL_dtls_set_mtu() to use larger
* packets; or build with WOLFSSL_NO_DTLS_SIZE_CHECK to auto-fragment. */
#define TEST_DTLS_PACKET_SIZE (1200)
#endif
#endif

Expand Down Expand Up @@ -1304,27 +1306,31 @@ static int SetupSocketAndListen(int* listenFd, word32 port, int doDTLS)
fprintf(stderr, "ERROR: failed to create the socket\n");
return -1;
}
}

/* allow reuse */
if (setsockopt(*listenFd, SOL_SOCKET, SO_REUSEADDR,
&optval, sizeof(optval)) == -1) {
fprintf(stderr, "setsockopt SO_REUSEADDR failed\n");
return -1;
}

/* Listen for the client. */
if (bind(*listenFd, (struct sockaddr*)&servAddr,
sizeof(servAddr)) == -1) {
fprintf(stderr, "ERROR: failed to bind\n");
return -1;
}
/* allow reuse */
if (setsockopt(*listenFd, SOL_SOCKET, SO_REUSEADDR,
&optval, sizeof(optval)) == -1) {
fprintf(stderr, "setsockopt SO_REUSEADDR failed\n");
return -1;
}

if (listen(*listenFd, 5) != 0) {
fprintf(stderr, "ERROR: failed to listen\n");
if (bind(*listenFd, (struct sockaddr*)&servAddr,
sizeof(servAddr)) == -1) {
fprintf(stderr, "ERROR: failed to bind\n");
return -1;
}

#ifdef WOLFSSL_DTLS
if (!doDTLS)
#endif
{
if (listen(*listenFd, 5) != 0) {
fprintf(stderr, "ERROR: failed to listen\n");
return -1;
}
}

#ifdef BENCH_USE_NONBLOCK
if (SetSocketNonBlocking(*listenFd) != 0) {
return -1;
Expand Down Expand Up @@ -2119,7 +2125,14 @@ int bench_tls(void* args)
}
}
#endif
fprintf(stderr, "Running TLS Benchmarks...\n");
#ifdef WOLFSSL_DTLS
if (doDTLS) {
fprintf(stderr, "Running DTLS Benchmarks...\n");
} else
#endif
{
fprintf(stderr, "Running TLS Benchmarks...\n");
}

/* parse by : */
while ((cipher != NULL) && (cipher[0] != '\0')) {
Expand All @@ -2135,6 +2148,14 @@ int bench_tls(void* args)
fprintf(stderr, "Cipher: %s\n", cipher);
}

#if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_DTLS13)
if (doDTLS && XSTRNCMP(cipher, "TLS13", 5) == 0) {
/* DTLS 1.3 not compiled in; skip TLS 1.3 ciphers */
cipher = (next_cipher != NULL) ? (next_cipher + 1) : NULL;
continue;
}
#endif

#if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
for (group_index = 0; groups[group_index].name != NULL; group_index++) {
const char *gname = theadInfo[0].group == 0 ? "N/A"
Expand Down
Loading