forked from wolfSSL/wolfssl
add user setting for dtls recv timeout init value
This commit is contained in:
@@ -661,7 +661,10 @@ enum Misc {
|
|||||||
CLIENT_HELLO_FIRST = 35, /* Protocol + RAN_LEN + sizeof(id_len) */
|
CLIENT_HELLO_FIRST = 35, /* Protocol + RAN_LEN + sizeof(id_len) */
|
||||||
MAX_SUITE_NAME = 48, /* maximum length of cipher suite string */
|
MAX_SUITE_NAME = 48, /* maximum length of cipher suite string */
|
||||||
DEFAULT_TIMEOUT = 500, /* default resumption timeout in seconds */
|
DEFAULT_TIMEOUT = 500, /* default resumption timeout in seconds */
|
||||||
DTLS_DEFAULT_TIMEOUT = 1, /* default timeout for DTLS receive */
|
|
||||||
|
DTLS_TIMEOUT_INIT = 1, /* default timeout init for DTLS receive */
|
||||||
|
DTLS_TIMEOUT_MAX = 64, /* default max timeout for DTLS receive */
|
||||||
|
DTLS_TIMEOUT_MULTIPLIER = 2, /* default timeout multiplier for DTLS recv */
|
||||||
|
|
||||||
MAX_PSK_ID_LEN = 128, /* max psk identity/hint supported */
|
MAX_PSK_ID_LEN = 128, /* max psk identity/hint supported */
|
||||||
MAX_PSK_KEY_LEN = 64, /* max psk key supported */
|
MAX_PSK_KEY_LEN = 64, /* max psk key supported */
|
||||||
@@ -1667,7 +1670,8 @@ struct CYASSL {
|
|||||||
byte didStreamInit; /* for stream init and end */
|
byte didStreamInit; /* for stream init and end */
|
||||||
#endif
|
#endif
|
||||||
#ifdef CYASSL_DTLS
|
#ifdef CYASSL_DTLS
|
||||||
int dtls_timeout;
|
int dtls_timeout_init; /* starting timeout vaule */
|
||||||
|
int dtls_timeout; /* current timeout value, changes */
|
||||||
DtlsPool* dtls_pool;
|
DtlsPool* dtls_pool;
|
||||||
DtlsMsg* dtls_msg_list;
|
DtlsMsg* dtls_msg_list;
|
||||||
void* IOCB_CookieCtx; /* gen cookie ctx */
|
void* IOCB_CookieCtx; /* gen cookie ctx */
|
||||||
|
@@ -254,6 +254,7 @@ CYASSL_API int CyaSSL_set_cipher_list(CYASSL*, const char*);
|
|||||||
|
|
||||||
/* Nonblocking DTLS helper functions */
|
/* Nonblocking DTLS helper functions */
|
||||||
CYASSL_API int CyaSSL_dtls_get_current_timeout(CYASSL* ssl);
|
CYASSL_API int CyaSSL_dtls_get_current_timeout(CYASSL* ssl);
|
||||||
|
CYASSL_API int CyaSSL_dtls_set_timeout_init(CYASSL* ssl, int);
|
||||||
CYASSL_API int CyaSSL_dtls_got_timeout(CYASSL* ssl);
|
CYASSL_API int CyaSSL_dtls_got_timeout(CYASSL* ssl);
|
||||||
CYASSL_API int CyaSSL_dtls(CYASSL* ssl);
|
CYASSL_API int CyaSSL_dtls(CYASSL* ssl);
|
||||||
|
|
||||||
|
@@ -1346,7 +1346,8 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx)
|
|||||||
ssl->keys.dtls_epoch = 0;
|
ssl->keys.dtls_epoch = 0;
|
||||||
ssl->keys.dtls_peer_epoch = 0;
|
ssl->keys.dtls_peer_epoch = 0;
|
||||||
ssl->keys.dtls_expected_peer_epoch = 0;
|
ssl->keys.dtls_expected_peer_epoch = 0;
|
||||||
ssl->dtls_timeout = DTLS_DEFAULT_TIMEOUT;
|
ssl->dtls_timeout_init = DTLS_TIMEOUT_INIT;
|
||||||
|
ssl->dtls_timeout = ssl->dtls_timeout_init;
|
||||||
ssl->dtls_pool = NULL;
|
ssl->dtls_pool = NULL;
|
||||||
ssl->dtls_msg_list = NULL;
|
ssl->dtls_msg_list = NULL;
|
||||||
#endif
|
#endif
|
||||||
@@ -1798,15 +1799,15 @@ void DtlsPoolReset(CYASSL* ssl)
|
|||||||
}
|
}
|
||||||
pool->used = 0;
|
pool->used = 0;
|
||||||
}
|
}
|
||||||
ssl->dtls_timeout = DTLS_DEFAULT_TIMEOUT;
|
ssl->dtls_timeout = ssl->dtls_timeout_init;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DtlsPoolTimeout(CYASSL* ssl)
|
int DtlsPoolTimeout(CYASSL* ssl)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
if (ssl->dtls_timeout < 64) {
|
if (ssl->dtls_timeout < DTLS_TIMEOUT_MAX) {
|
||||||
ssl->dtls_timeout *= 2;
|
ssl->dtls_timeout *= DTLS_TIMEOUT_MULTIPLIER;
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
16
src/ssl.c
16
src/ssl.c
@@ -3545,6 +3545,22 @@ int CyaSSL_dtls_get_current_timeout(CYASSL* ssl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* user may need to alter init dtls recv timeout, SSL_SUCCESS on ok */
|
||||||
|
int CyaSSL_dtls_set_timeout_init(CYASSL* ssl, int timeout)
|
||||||
|
{
|
||||||
|
if (ssl == NULL || timeout < 0)
|
||||||
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
|
#ifdef CYASSL_DTLS
|
||||||
|
ssl->dtls_timeout_init = timeout;
|
||||||
|
|
||||||
|
return SSL_SUCCESS;
|
||||||
|
#else
|
||||||
|
return NOT_COMPILED_IN;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int CyaSSL_dtls_got_timeout(CYASSL* ssl)
|
int CyaSSL_dtls_got_timeout(CYASSL* ssl)
|
||||||
{
|
{
|
||||||
#ifdef CYASSL_DTLS
|
#ifdef CYASSL_DTLS
|
||||||
|
Reference in New Issue
Block a user