mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 20:54:41 +02:00
Merge pull request #5268 from anhu/micrium_dtls_guard
Fix missing WOLFSSL_DTLS guard in Micrium build
This commit is contained in:
70
src/wolfio.c
70
src/wolfio.c
@@ -2128,20 +2128,39 @@ int MicriumReceive(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
|||||||
NET_SOCK_RTN_CODE ret;
|
NET_SOCK_RTN_CODE ret;
|
||||||
NET_ERR err;
|
NET_ERR err;
|
||||||
|
|
||||||
#ifdef WOLFSSL_DTLS
|
#ifdef WOLFSSL_DTLS
|
||||||
{
|
{
|
||||||
int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
|
int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
|
||||||
if (wolfSSL_dtls(ssl)
|
/* Don't use ssl->options.handShakeDone since it is true even if
|
||||||
&& !wolfSSL_dtls_get_using_nonblock(ssl)
|
* we are in the process of renegotiation */
|
||||||
&& dtls_timeout != 0) {
|
byte doDtlsTimeout = ssl->options.handShakeState != HANDSHAKE_DONE;
|
||||||
|
#ifdef WOLFSSL_DTLS13
|
||||||
|
if (ssl->options.dtls && IsAtLeastTLSv1_3(ssl->version)) {
|
||||||
|
doDtlsTimeout =
|
||||||
|
doDtlsTimeout || ssl->dtls13Rtx.rtxRecords != NULL ||
|
||||||
|
(ssl->dtls13FastTimeout && ssl->dtls13Rtx.seenRecords != NULL);
|
||||||
|
}
|
||||||
|
#endif /* WOLFSSL_DTLS13 */
|
||||||
|
|
||||||
|
if (!doDtlsTimeout)
|
||||||
|
dtls_timeout = 0;
|
||||||
|
|
||||||
|
if (!wolfSSL_dtls_get_using_nonblock(ssl)) {
|
||||||
/* needs timeout in milliseconds */
|
/* needs timeout in milliseconds */
|
||||||
NetSock_CfgTimeoutRxQ_Set(sd, dtls_timeout * 1000, &err);
|
#ifdef WOLFSSL_DTLS13
|
||||||
|
if (wolfSSL_dtls13_use_quick_timeout(ssl) &&
|
||||||
|
IsAtLeastTLSv1_3(ssl->version)) {
|
||||||
|
dtls_timeout = (1000 * dtls_timeout) / 4;
|
||||||
|
} else
|
||||||
|
#endif /* WOLFSSL_DTLS13 */
|
||||||
|
dtls_timeout = 1000 * dtls_timeout;
|
||||||
|
NetSock_CfgTimeoutRxQ_Set(sd, dtls_timeout, &err);
|
||||||
if (err != NET_SOCK_ERR_NONE) {
|
if (err != NET_SOCK_ERR_NONE) {
|
||||||
WOLFSSL_MSG("NetSock_CfgTimeoutRxQ_Set failed");
|
WOLFSSL_MSG("NetSock_CfgTimeoutRxQ_Set failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = NetSock_RxData(sd, buf, sz, ssl->rflags, &err);
|
ret = NetSock_RxData(sd, buf, sz, ssl->rflags, &err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -2182,20 +2201,43 @@ int MicriumReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
|||||||
NET_SOCK_ADDR_LEN peerSz = sizeof(peer);
|
NET_SOCK_ADDR_LEN peerSz = sizeof(peer);
|
||||||
NET_SOCK_RTN_CODE ret;
|
NET_SOCK_RTN_CODE ret;
|
||||||
NET_ERR err;
|
NET_ERR err;
|
||||||
int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
|
|
||||||
|
|
||||||
WOLFSSL_ENTER("MicriumReceiveFrom()");
|
WOLFSSL_ENTER("MicriumReceiveFrom()");
|
||||||
|
|
||||||
if (ssl->options.handShakeDone)
|
#ifdef WOLFSSL_DTLS
|
||||||
dtls_timeout = 0;
|
{
|
||||||
|
int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
|
||||||
|
/* Don't use ssl->options.handShakeDone since it is true even if
|
||||||
|
* we are in the process of renegotiation */
|
||||||
|
byte doDtlsTimeout = ssl->options.handShakeState != HANDSHAKE_DONE;
|
||||||
|
|
||||||
if (!wolfSSL_dtls_get_using_nonblock(ssl)) {
|
#ifdef WOLFSSL_DTLS13
|
||||||
/* needs timeout in milliseconds */
|
if (ssl->options.dtls && IsAtLeastTLSv1_3(ssl->version)) {
|
||||||
NetSock_CfgTimeoutRxQ_Set(sd, dtls_timeout * 1000, &err);
|
doDtlsTimeout =
|
||||||
if (err != NET_SOCK_ERR_NONE) {
|
doDtlsTimeout || ssl->dtls13Rtx.rtxRecords != NULL ||
|
||||||
WOLFSSL_MSG("NetSock_CfgTimeoutRxQ_Set failed");
|
(ssl->dtls13FastTimeout && ssl->dtls13Rtx.seenRecords != NULL);
|
||||||
|
}
|
||||||
|
#endif /* WOLFSSL_DTLS13 */
|
||||||
|
|
||||||
|
if (!doDtlsTimeout)
|
||||||
|
dtls_timeout = 0;
|
||||||
|
|
||||||
|
if (!wolfSSL_dtls_get_using_nonblock(ssl)) {
|
||||||
|
/* needs timeout in milliseconds */
|
||||||
|
#ifdef WOLFSSL_DTLS13
|
||||||
|
if (wolfSSL_dtls13_use_quick_timeout(ssl) &&
|
||||||
|
IsAtLeastTLSv1_3(ssl->version)) {
|
||||||
|
dtls_timeout = (1000 * dtls_timeout) / 4;
|
||||||
|
} else
|
||||||
|
#endif /* WOLFSSL_DTLS13 */
|
||||||
|
dtls_timeout = 1000 * dtls_timeout;
|
||||||
|
NetSock_CfgTimeoutRxQ_Set(sd, dtls_timeout, &err);
|
||||||
|
if (err != NET_SOCK_ERR_NONE) {
|
||||||
|
WOLFSSL_MSG("NetSock_CfgTimeoutRxQ_Set failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* WOLFSSL_DTLS */
|
||||||
|
|
||||||
ret = NetSock_RxDataFrom(sd, buf, sz, ssl->rflags, &peer, &peerSz,
|
ret = NetSock_RxDataFrom(sd, buf, sz, ssl->rflags, &peer, &peerSz,
|
||||||
0, 0, 0, &err);
|
0, 0, 0, &err);
|
||||||
|
Reference in New Issue
Block a user