From 63f6c1d280228ac377c5cdd0bb53e14061e8dde9 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 13 Dec 2018 15:23:29 -0800 Subject: [PATCH] DTLS Nonblocking Updates 1. Add error code for trying to retransmit a flight when transmitting the flight hasn't finished. 2. Add function to retransmit the stored flight without updating the timeout count. --- src/internal.c | 3 +++ src/ssl.c | 21 +++++++++++++++++++++ wolfssl/error-ssl.h | 1 + wolfssl/ssl.h | 1 + 4 files changed, 26 insertions(+) diff --git a/src/internal.c b/src/internal.c index 3082e3bf5..dc3e0d7d6 100644 --- a/src/internal.c +++ b/src/internal.c @@ -15836,6 +15836,9 @@ const char* wolfSSL_ERR_reason_error_string(unsigned long e) case EXT_MISSING: return "Required TLS extension missing"; + case DTLS_RETX_OVER_TX: + return "DTLS interrupting flight transmit with retransmit"; + default : return "unknown error number"; } diff --git a/src/ssl.c b/src/ssl.c index 1757b3fa5..755fe567a 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -8827,6 +8827,27 @@ int wolfSSL_dtls_got_timeout(WOLFSSL* ssl) return result; } + +/* retransmit all the saves messages, WOLFSSL_SUCCESS on ok */ +int wolfSSL_dtls_retransmit(WOLFSSL* ssl) +{ + WOLFSSL_ENTER("wolfSSL_dtls_retransmit()"); + + if (ssl == NULL) + return WOLFSSL_FATAL_ERROR; + + if (!ssl->options.handShakeDone) { + int result = DtlsMsgPoolSend(ssl, 0); + if (result < 0) { + ssl->error = result; + WOLFSSL_ERROR(result); + return WOLFSSL_FATAL_ERROR; + } + } + + return 0; +} + #endif /* DTLS */ #endif /* LEANPSK */ diff --git a/wolfssl/error-ssl.h b/wolfssl/error-ssl.h index 1fd9520f3..827ae0272 100644 --- a/wolfssl/error-ssl.h +++ b/wolfssl/error-ssl.h @@ -163,6 +163,7 @@ enum wolfSSL_ErrorCodes { EXT_MISSING = -428, /* Required extension not found */ UNSUPPORTED_EXTENSION = -429, /* TLSX not requested by client */ PRF_MISSING = -430, /* PRF not compiled in */ + DTLS_RETX_OVER_TX = -431, /* Retransmit DTLS flight over */ /* add strings to wolfSSL_ERR_reason_error_string in internal.c !!!!! */ /* begin negotiation parameter errors */ diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 898680453..75a4b9558 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -723,6 +723,7 @@ WOLFSSL_API int wolfSSL_dtls_get_current_timeout(WOLFSSL* ssl); WOLFSSL_API int wolfSSL_dtls_set_timeout_init(WOLFSSL* ssl, int); WOLFSSL_API int wolfSSL_dtls_set_timeout_max(WOLFSSL* ssl, int); WOLFSSL_API int wolfSSL_dtls_got_timeout(WOLFSSL* ssl); +WOLFSSL_API int wolfSSL_dtls_retransmit(WOLFSSL*); WOLFSSL_API int wolfSSL_dtls(WOLFSSL* ssl); WOLFSSL_API int wolfSSL_dtls_set_peer(WOLFSSL*, void*, unsigned int);