forked from wolfSSL/wolfssl
Fix TCP with Timeout
wolfSSL remains agnostic to network socket behavior be it blocking or non-blocking. The non-blocking flag was meant for the default EmbedRecvFrom() callback for use with UDP to assist the timing of the handshake. 1. Deprecate wolfSSL_set_using_nonblock() and wolfSSL_get_using_nonblock() for use with TLS sockets. They become don't-cares when used with TLS sessions. 2. Added functions wolfSSL_dtls_set_using_nonblock() and wolfSSL_dtls_get_using_nonblock(). 3. Removed a test case from EmbedReceive() that only applied to UDP. 4. Removed the checks for non-blocking sockets from EmbedReceive(). 5. Socket timeouts only apply to DTLS sessions.
This commit is contained in:
53
src/ssl.c
53
src/ssl.c
@@ -737,14 +737,6 @@ int wolfSSL_get_fd(const WOLFSSL* ssl)
|
||||
}
|
||||
|
||||
|
||||
int wolfSSL_get_using_nonblock(WOLFSSL* ssl)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_get_using_nonblock");
|
||||
WOLFSSL_LEAVE("wolfSSL_get_using_nonblock", ssl->options.usingNonblock);
|
||||
return ssl->options.usingNonblock;
|
||||
}
|
||||
|
||||
|
||||
int wolfSSL_dtls(WOLFSSL* ssl)
|
||||
{
|
||||
return ssl->options.dtls;
|
||||
@@ -752,13 +744,6 @@ int wolfSSL_dtls(WOLFSSL* ssl)
|
||||
|
||||
|
||||
#ifndef WOLFSSL_LEANPSK
|
||||
void wolfSSL_set_using_nonblock(WOLFSSL* ssl, int nonblock)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_set_using_nonblock");
|
||||
ssl->options.usingNonblock = (nonblock != 0);
|
||||
}
|
||||
|
||||
|
||||
int wolfSSL_dtls_set_peer(WOLFSSL* ssl, void* peer, unsigned int peerSz)
|
||||
{
|
||||
#ifdef WOLFSSL_DTLS
|
||||
@@ -8273,13 +8258,47 @@ int wolfSSL_set_cipher_list(WOLFSSL* ssl, const char* list)
|
||||
}
|
||||
|
||||
|
||||
int wolfSSL_dtls_get_using_nonblock(WOLFSSL* ssl)
|
||||
{
|
||||
int useNb = 0;
|
||||
|
||||
WOLFSSL_ENTER("wolfSSL_dtls_get_using_nonblock");
|
||||
if (ssl->options.dtls) {
|
||||
#ifdef WOLFSSL_DTLS
|
||||
useNb = ssl->options.dtlsUseNonblock;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
WOLFSSL_MSG("wolfSSL_dtls_get_using_nonblock() is "
|
||||
"DEPRECATED for non-DTLS use.");
|
||||
}
|
||||
return useNb;
|
||||
}
|
||||
|
||||
|
||||
#ifndef WOLFSSL_LEANPSK
|
||||
|
||||
void wolfSSL_dtls_set_using_nonblock(WOLFSSL* ssl, int nonblock)
|
||||
{
|
||||
(void)nonblock;
|
||||
|
||||
WOLFSSL_ENTER("wolfSSL_dtls_set_using_nonblock");
|
||||
if (ssl->options.dtls) {
|
||||
#ifdef WOLFSSL_DTLS
|
||||
ssl->options.dtlsUseNonblock = (nonblock != 0);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
WOLFSSL_MSG("wolfSSL_dtls_set_using_nonblock() is "
|
||||
"DEPRECATED for non-DTLS use.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef WOLFSSL_DTLS
|
||||
|
||||
int wolfSSL_dtls_get_current_timeout(WOLFSSL* ssl)
|
||||
{
|
||||
(void)ssl;
|
||||
|
||||
return ssl->dtls_timeout;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user