[tcp] implement TCP Circular Send Buffer (#7867)

This commit is contained in:
Sam Kumar
2022-09-19 10:30:48 -07:00
committed by Jonathan Hui
parent 5b430bf80b
commit 19f9ba20a3
10 changed files with 479 additions and 8 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (244)
#define OPENTHREAD_API_VERSION (245)
/**
* @addtogroup api-instance
+18 -7
View File
@@ -88,10 +88,10 @@ extern "C" {
*/
typedef struct otTcpCircularSendBuffer
{
const uint8_t *mDataBuffer; ///< Pointer to data in the circular send buffer
size_t mCapacity; ///< Length of the circular send buffer
size_t mStartIndex; ///< Index of the first valid byte in the send buffer
size_t mCapacityUsed; ///< Number of bytes stored in the send buffer
uint8_t *mDataBuffer; ///< Pointer to data in the circular send buffer
size_t mCapacity; ///< Length of the circular send buffer
size_t mStartIndex; ///< Index of the first valid byte in the send buffer
size_t mCapacityUsed; ///< Number of bytes stored in the send buffer
otLinkedBuffer mSendLinks[2];
uint8_t mFirstSendLinkIndex;
@@ -107,6 +107,15 @@ typedef struct otTcpCircularSendBuffer
*/
void otTcpCircularSendBufferInitialize(otTcpCircularSendBuffer *aSendBuffer, void *aDataBuffer, size_t aCapacity);
/**
* This enumeration defines flags passed to @p otTcpCircularSendBufferWrite.
*
*/
enum
{
OT_TCP_CIRCULAR_SEND_BUFFER_WRITE_MORE_TO_COME = 1 << 0,
};
/**
* Sends out data on a TCP endpoint, using the provided TCP circular send
* buffer to manage buffering.
@@ -136,15 +145,17 @@ void otTcpCircularSendBufferInitialize(otTcpCircularSendBuffer *aSendBuffer, voi
* @param[in] aLength The length of the data pointed to by @p aData to copy into the TCP circular send buffer.
* @param[out] aWritten Populated with the amount of data copied into the send buffer, which might be less than
* @p aLength if the send buffer reaches capacity.
* @param[in] aFlags Flags specifying options for this operation (see enumeration above).
*
* @returns OT_ERROR_NONE Successfully copied data into the send buffer and sent it on the TCP endpoint.
* @returns OT_ERROR_FAILED Failed to send out data on the TCP endpoint.
*/
otError otTcpCircularSendBufferWrite(otTcpEndpoint * aEndpoint,
otTcpCircularSendBuffer *aSendBuffer,
void * aData,
const void * aData,
size_t aLength,
size_t * aWritten);
size_t * aWritten,
uint32_t aFlags);
/**
* Performs circular-send-buffer-specific handling in the otTcpForwardProgress
@@ -175,7 +186,7 @@ void otTcpCircularSendBufferHandleForwardProgress(otTcpCircularSendBuffer *aSend
*
* @return The amount of free space in the send buffer.
*/
size_t otTcpCircularSendBufferFreeSpace(otTcpCircularSendBuffer *aSendBuffer);
size_t otTcpCircularSendBufferGetFreeSpace(const otTcpCircularSendBuffer *aSendBuffer);
/**
* Forcibly discards all data in the circular send buffer.