mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
DTLS Message Grouping
Flush output buffer when we suspect that the grouped messages may exceed MTU.
This commit is contained in:
committed by
Unknown
parent
d2542dcf38
commit
4e60e4b3b7
@@ -7317,10 +7317,11 @@ int DtlsMsgPoolSend(WOLFSSL* ssl, int sendOnlyFirstPacket)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
XMEMCPY(ssl->buffers.outputBuffer.buffer,
|
XMEMCPY(ssl->buffers.outputBuffer.buffer +
|
||||||
|
ssl->buffers.outputBuffer.idx +
|
||||||
|
ssl->buffers.outputBuffer.length,
|
||||||
pool->buf, pool->sz);
|
pool->buf, pool->sz);
|
||||||
ssl->buffers.outputBuffer.idx = 0;
|
ssl->buffers.outputBuffer.length += pool->sz;
|
||||||
ssl->buffers.outputBuffer.length = pool->sz;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Handle sending packets from previous epoch */
|
/* Handle sending packets from previous epoch */
|
||||||
@@ -7377,11 +7378,9 @@ int DtlsMsgPoolSend(WOLFSSL* ssl, int sendOnlyFirstPacket)
|
|||||||
ssl->buffers.outputBuffer.length += sendSz;
|
ssl->buffers.outputBuffer.length += sendSz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!ssl->options.groupMessages)
|
||||||
ret = SendBuffered(ssl);
|
ret = SendBuffered(ssl);
|
||||||
if (ret < 0) {
|
|
||||||
WOLFSSL_ERROR(ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* on server side, retransmission is being triggered only by sending
|
* on server side, retransmission is being triggered only by sending
|
||||||
@@ -7392,14 +7391,15 @@ int DtlsMsgPoolSend(WOLFSSL* ssl, int sendOnlyFirstPacket)
|
|||||||
* be enough to do the trick.
|
* be enough to do the trick.
|
||||||
*/
|
*/
|
||||||
if (sendOnlyFirstPacket &&
|
if (sendOnlyFirstPacket &&
|
||||||
ssl->options.side == WOLFSSL_SERVER_END) {
|
ssl->options.side == WOLFSSL_SERVER_END)
|
||||||
|
|
||||||
pool = NULL;
|
pool = NULL;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
pool = pool->next;
|
pool = pool->next;
|
||||||
ssl->dtls_tx_msg = pool;
|
ssl->dtls_tx_msg = pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret == 0 && ssl->options.groupMessages)
|
||||||
|
ret = SendBuffered(ssl);
|
||||||
}
|
}
|
||||||
|
|
||||||
WOLFSSL_LEAVE("DtlsMsgPoolSend()", ret);
|
WOLFSSL_LEAVE("DtlsMsgPoolSend()", ret);
|
||||||
@@ -8339,7 +8339,10 @@ int GrowInputBuffer(WOLFSSL* ssl, int size, int usedLength)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* check available size into output buffer, make room if needed */
|
/* Check available size into output buffer, make room if needed.
|
||||||
|
* This function needs to be called before anything gets put
|
||||||
|
* into the output buffers since it flushes pending data if it
|
||||||
|
* predicts that the msg will exceed MTU. */
|
||||||
int CheckAvailableSize(WOLFSSL *ssl, int size)
|
int CheckAvailableSize(WOLFSSL *ssl, int size)
|
||||||
{
|
{
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
@@ -8347,6 +8350,18 @@ int CheckAvailableSize(WOLFSSL *ssl, int size)
|
|||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_DTLS
|
||||||
|
if (size + ssl->buffers.outputBuffer.length - ssl->buffers.outputBuffer.idx
|
||||||
|
> ssl->dtls_expected_rx) {
|
||||||
|
int ret;
|
||||||
|
WOLFSSL_MSG("CheckAvailableSize() flushing buffer "
|
||||||
|
"to make room for new message");
|
||||||
|
if ((ret = SendBuffered(ssl)) != 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ssl->buffers.outputBuffer.bufferSize - ssl->buffers.outputBuffer.length
|
if (ssl->buffers.outputBuffer.bufferSize - ssl->buffers.outputBuffer.length
|
||||||
< (word32)size) {
|
< (word32)size) {
|
||||||
if (GrowOutputBuffer(ssl, size) < 0)
|
if (GrowOutputBuffer(ssl, size) < 0)
|
||||||
|
Reference in New Issue
Block a user