mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-04 05:04:41 +02:00
Add some more debug logging for DTLS retransmission support.
This commit is contained in:
@@ -6003,8 +6003,12 @@ int DtlsMsgPoolSave(WOLFSSL* ssl, const byte* data, word32 dataSz)
|
|||||||
DtlsMsg* item;
|
DtlsMsg* item;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ssl->dtls_tx_msg_list_sz > DTLS_POOL_SZ)
|
WOLFSSL_ENTER("DtlsMsgPoolSave()");
|
||||||
|
|
||||||
|
if (ssl->dtls_tx_msg_list_sz > DTLS_POOL_SZ) {
|
||||||
|
WOLFSSL_ERROR(DTLS_POOL_SZ_E);
|
||||||
return DTLS_POOL_SZ_E;
|
return DTLS_POOL_SZ_E;
|
||||||
|
}
|
||||||
|
|
||||||
item = DtlsMsgNew(dataSz, ssl->heap);
|
item = DtlsMsgNew(dataSz, ssl->heap);
|
||||||
|
|
||||||
@@ -6027,6 +6031,7 @@ int DtlsMsgPoolSave(WOLFSSL* ssl, const byte* data, word32 dataSz)
|
|||||||
else
|
else
|
||||||
ret = MEMORY_E;
|
ret = MEMORY_E;
|
||||||
|
|
||||||
|
WOLFSSL_LEAVE("DtlsMsgPoolSave()", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6039,6 +6044,7 @@ int DtlsMsgPoolTimeout(WOLFSSL* ssl)
|
|||||||
ssl->dtls_timeout *= DTLS_TIMEOUT_MULTIPLIER;
|
ssl->dtls_timeout *= DTLS_TIMEOUT_MULTIPLIER;
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
WOLFSSL_LEAVE("DtlsMsgPoolTimeout()", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6047,6 +6053,7 @@ int DtlsMsgPoolTimeout(WOLFSSL* ssl)
|
|||||||
* value. */
|
* value. */
|
||||||
void DtlsMsgPoolReset(WOLFSSL* ssl)
|
void DtlsMsgPoolReset(WOLFSSL* ssl)
|
||||||
{
|
{
|
||||||
|
WOLFSSL_ENTER("DtlsMsgPoolReset()");
|
||||||
if (ssl->dtls_tx_msg_list) {
|
if (ssl->dtls_tx_msg_list) {
|
||||||
DtlsMsgListDelete(ssl->dtls_tx_msg_list, ssl->heap);
|
DtlsMsgListDelete(ssl->dtls_tx_msg_list, ssl->heap);
|
||||||
ssl->dtls_tx_msg_list = NULL;
|
ssl->dtls_tx_msg_list = NULL;
|
||||||
@@ -6080,6 +6087,8 @@ int DtlsMsgPoolSend(WOLFSSL* ssl, int sendOnlyFirstPacket)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
DtlsMsg* pool = ssl->dtls_tx_msg_list;
|
DtlsMsg* pool = ssl->dtls_tx_msg_list;
|
||||||
|
|
||||||
|
WOLFSSL_ENTER("DtlsMsgPoolSend()");
|
||||||
|
|
||||||
if (pool != NULL) {
|
if (pool != NULL) {
|
||||||
|
|
||||||
while (pool != NULL) {
|
while (pool != NULL) {
|
||||||
@@ -6098,8 +6107,10 @@ int DtlsMsgPoolSend(WOLFSSL* ssl, int sendOnlyFirstPacket)
|
|||||||
|
|
||||||
WriteSEQ(ssl, epochOrder, dtls->sequence_number);
|
WriteSEQ(ssl, epochOrder, dtls->sequence_number);
|
||||||
DtlsSEQIncrement(ssl, epochOrder);
|
DtlsSEQIncrement(ssl, epochOrder);
|
||||||
if ((ret = CheckAvailableSize(ssl, pool->sz)) != 0)
|
if ((ret = CheckAvailableSize(ssl, pool->sz)) != 0) {
|
||||||
|
WOLFSSL_ERROR(ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
XMEMCPY(ssl->buffers.outputBuffer.buffer,
|
XMEMCPY(ssl->buffers.outputBuffer.buffer,
|
||||||
pool->buf, pool->sz);
|
pool->buf, pool->sz);
|
||||||
@@ -6115,21 +6126,26 @@ int DtlsMsgPoolSend(WOLFSSL* ssl, int sendOnlyFirstPacket)
|
|||||||
inputSz = pool->sz;
|
inputSz = pool->sz;
|
||||||
sendSz = inputSz + MAX_MSG_EXTRA;
|
sendSz = inputSz + MAX_MSG_EXTRA;
|
||||||
|
|
||||||
if ((ret = CheckAvailableSize(ssl, sendSz)) != 0)
|
if ((ret = CheckAvailableSize(ssl, sendSz)) != 0) {
|
||||||
|
WOLFSSL_ERROR(ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
output = ssl->buffers.outputBuffer.buffer +
|
output = ssl->buffers.outputBuffer.buffer +
|
||||||
ssl->buffers.outputBuffer.length;
|
ssl->buffers.outputBuffer.length;
|
||||||
sendSz = BuildMessage(ssl, output, sendSz, input, inputSz,
|
sendSz = BuildMessage(ssl, output, sendSz, input, inputSz,
|
||||||
handshake, 0, 0, 0);
|
handshake, 0, 0, 0);
|
||||||
if (sendSz < 0)
|
if (sendSz < 0) {
|
||||||
|
WOLFSSL_ERROR(BUILD_MSG_ERROR);
|
||||||
return BUILD_MSG_ERROR;
|
return BUILD_MSG_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ssl->buffers.outputBuffer.length += sendSz;
|
ssl->buffers.outputBuffer.length += sendSz;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SendBuffered(ssl);
|
ret = SendBuffered(ssl);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
WOLFSSL_ERROR(ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6151,6 +6167,7 @@ int DtlsMsgPoolSend(WOLFSSL* ssl, int sendOnlyFirstPacket)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WOLFSSL_LEAVE("DtlsMsgPoolSend()", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7094,6 +7111,7 @@ static int GetRecordHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
if (IsDtlsNotSctpMode(ssl) &&
|
if (IsDtlsNotSctpMode(ssl) &&
|
||||||
(!DtlsCheckWindow(ssl) ||
|
(!DtlsCheckWindow(ssl) ||
|
||||||
(ssl->options.handShakeDone && ssl->keys.curEpoch == 0))) {
|
(ssl->options.handShakeDone && ssl->keys.curEpoch == 0))) {
|
||||||
|
WOLFSSL_LEAVE("GetRecordHeader()", SEQUENCE_ERROR);
|
||||||
return SEQUENCE_ERROR;
|
return SEQUENCE_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -7186,8 +7204,10 @@ static int GetDtlsHandShakeHeader(WOLFSSL* ssl, const byte* input,
|
|||||||
word32 idx = *inOutIdx;
|
word32 idx = *inOutIdx;
|
||||||
|
|
||||||
*inOutIdx += HANDSHAKE_HEADER_SZ + DTLS_HANDSHAKE_EXTRA;
|
*inOutIdx += HANDSHAKE_HEADER_SZ + DTLS_HANDSHAKE_EXTRA;
|
||||||
if (*inOutIdx > totalSz)
|
if (*inOutIdx > totalSz) {
|
||||||
|
WOLFSSL_ERROR(BUFFER_E);
|
||||||
return BUFFER_E;
|
return BUFFER_E;
|
||||||
|
}
|
||||||
|
|
||||||
*type = input[idx++];
|
*type = input[idx++];
|
||||||
c24to32(input + idx, size);
|
c24to32(input + idx, size);
|
||||||
@@ -7203,8 +7223,10 @@ static int GetDtlsHandShakeHeader(WOLFSSL* ssl, const byte* input,
|
|||||||
if (ssl->curRL.pvMajor != ssl->version.major ||
|
if (ssl->curRL.pvMajor != ssl->version.major ||
|
||||||
ssl->curRL.pvMinor != ssl->version.minor) {
|
ssl->curRL.pvMinor != ssl->version.minor) {
|
||||||
|
|
||||||
if (*type != client_hello && *type != hello_verify_request)
|
if (*type != client_hello && *type != hello_verify_request) {
|
||||||
|
WOLFSSL_ERROR(VERSION_ERROR);
|
||||||
return VERSION_ERROR;
|
return VERSION_ERROR;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
WOLFSSL_MSG("DTLS Handshake ignoring hello or verify version");
|
WOLFSSL_MSG("DTLS Handshake ignoring hello or verify version");
|
||||||
}
|
}
|
||||||
@@ -11247,6 +11269,8 @@ static int DtlsMsgDrain(WOLFSSL* ssl)
|
|||||||
DtlsMsg* item = ssl->dtls_rx_msg_list;
|
DtlsMsg* item = ssl->dtls_rx_msg_list;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
WOLFSSL_ENTER("DtlsMsgDrain()");
|
||||||
|
|
||||||
/* While there is an item in the store list, and it is the expected
|
/* While there is an item in the store list, and it is the expected
|
||||||
* message, and it is complete, and there hasn't been an error in the
|
* message, and it is complete, and there hasn't been an error in the
|
||||||
* last message... */
|
* last message... */
|
||||||
@@ -11270,6 +11294,7 @@ static int DtlsMsgDrain(WOLFSSL* ssl)
|
|||||||
ssl->dtls_rx_msg_list_sz--;
|
ssl->dtls_rx_msg_list_sz--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WOLFSSL_LEAVE("DtlsMsgDrain()", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11297,12 +11322,16 @@ static int DoDtlsHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|||||||
|
|
||||||
/* parse header */
|
/* parse header */
|
||||||
if (GetDtlsHandShakeHeader(ssl, input, inOutIdx, &type,
|
if (GetDtlsHandShakeHeader(ssl, input, inOutIdx, &type,
|
||||||
&size, &fragOffset, &fragSz, totalSz) != 0)
|
&size, &fragOffset, &fragSz, totalSz) != 0) {
|
||||||
|
WOLFSSL_ERROR(PARSE_ERROR);
|
||||||
return PARSE_ERROR;
|
return PARSE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* check that we have complete fragment */
|
/* check that we have complete fragment */
|
||||||
if (*inOutIdx + fragSz > totalSz)
|
if (*inOutIdx + fragSz > totalSz) {
|
||||||
|
WOLFSSL_ERROR(INCOMPLETE_DATA);
|
||||||
return INCOMPLETE_DATA;
|
return INCOMPLETE_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check the handshake sequence number first. If out of order,
|
/* Check the handshake sequence number first. If out of order,
|
||||||
* add the current message to the list. If the message is in order,
|
* add the current message to the list. If the message is in order,
|
||||||
@@ -11347,6 +11376,7 @@ static int DoDtlsHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|||||||
*inOutIdx += fragSz;
|
*inOutIdx += fragSz;
|
||||||
if(type == finished ) {
|
if(type == finished ) {
|
||||||
if (*inOutIdx + ssl->keys.padSz > totalSz) {
|
if (*inOutIdx + ssl->keys.padSz > totalSz) {
|
||||||
|
WOLFSSL_ERROR(BUFFER_E);
|
||||||
return BUFFER_E;
|
return BUFFER_E;
|
||||||
}
|
}
|
||||||
*inOutIdx += ssl->keys.padSz;
|
*inOutIdx += ssl->keys.padSz;
|
||||||
@@ -13177,8 +13207,10 @@ int ProcessReply(WOLFSSL* ssl)
|
|||||||
ret = BUFFER_ERROR;
|
ret = BUFFER_ERROR;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (ret != 0)
|
if (ret != 0) {
|
||||||
|
WOLFSSL_ERROR(ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case change_cipher_spec:
|
case change_cipher_spec:
|
||||||
|
@@ -8768,6 +8768,8 @@ int wolfSSL_dtls_get_current_timeout(WOLFSSL* ssl)
|
|||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
if (ssl)
|
if (ssl)
|
||||||
timeout = ssl->dtls_timeout;
|
timeout = ssl->dtls_timeout;
|
||||||
|
|
||||||
|
WOLFSSL_LEAVE("wolfSSL_dtls_get_current_timeout()", timeout);
|
||||||
return timeout;
|
return timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8810,6 +8812,7 @@ int wolfSSL_dtls_set_timeout_max(WOLFSSL* ssl, int timeout)
|
|||||||
int wolfSSL_dtls_got_timeout(WOLFSSL* ssl)
|
int wolfSSL_dtls_got_timeout(WOLFSSL* ssl)
|
||||||
{
|
{
|
||||||
int result = WOLFSSL_SUCCESS;
|
int result = WOLFSSL_SUCCESS;
|
||||||
|
WOLFSSL_ENTER("wolfSSL_dtls_got_timeout()");
|
||||||
|
|
||||||
if (ssl == NULL)
|
if (ssl == NULL)
|
||||||
return WOLFSSL_FATAL_ERROR;
|
return WOLFSSL_FATAL_ERROR;
|
||||||
@@ -8819,6 +8822,8 @@ int wolfSSL_dtls_got_timeout(WOLFSSL* ssl)
|
|||||||
|
|
||||||
result = WOLFSSL_FATAL_ERROR;
|
result = WOLFSSL_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WOLFSSL_LEAVE("wolfSSL_dtls_got_timeout()", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user