examples: allow bidirectional shutdown in UDP

This commit allows the examples to perform a bidirectional shutdown also when
using UDP. It is useful to test DTLS retransmission.

Signed-off-by: Marco Oliverio <marco@wolfssl.com>
This commit is contained in:
Juliusz Sosinowicz
2022-04-06 22:14:42 +02:00
committed by Marco Oliverio
parent d133fa6143
commit 257c55a311
2 changed files with 27 additions and 11 deletions

View File

@ -4059,17 +4059,22 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
}
#endif
if (dtlsUDP == 0) { /* don't send alert after "break" command */
ret = wolfSSL_shutdown(ssl);
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
if (tcp_select(sockfd, DEFAULT_TIMEOUT_SEC) == TEST_RECV_READY) {
ret = wolfSSL_shutdown(ssl); /* bidirectional shutdown */
if (ret == WOLFSSL_SUCCESS)
printf("Bidirectional shutdown complete\n");
ret = wolfSSL_shutdown(ssl);
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
while (tcp_select(wolfSSL_get_fd(ssl), DEFAULT_TIMEOUT_SEC) ==
TEST_RECV_READY) {
ret = wolfSSL_shutdown(ssl); /* bidirectional shutdown */
if (ret == WOLFSSL_SUCCESS) {
printf("Bidirectional shutdown complete\n");
break;
}
if (ret != WOLFSSL_SUCCESS)
else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
printf("Bidirectional shutdown failed\n");
break;
}
}
if (ret != WOLFSSL_SUCCESS)
printf("Bidirectional shutdown failed\n");
}
#if defined(ATOMIC_USER) && !defined(WOLFSSL_AEAD_ONLY)
if (atomicUser)

View File

@ -3356,9 +3356,20 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
ret = SSL_shutdown(ssl);
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
ret = SSL_shutdown(ssl); /* bidirectional shutdown */
if (ret == WOLFSSL_SUCCESS)
printf("Bidirectional shutdown complete\n");
while (tcp_select(wolfSSL_get_fd(ssl), DEFAULT_TIMEOUT_SEC) ==
TEST_RECV_READY) {
ret = wolfSSL_shutdown(ssl); /* bidirectional shutdown */
if (ret == WOLFSSL_SUCCESS) {
printf("Bidirectional shutdown complete\n");
break;
}
else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
printf("Bidirectional shutdown failed\n");
break;
}
}
if (ret != WOLFSSL_SUCCESS)
printf("Bidirectional shutdown failed\n");
}
/* display collected statistics */