Skip to content

Commit ffbd7d3

Browse files
committed
Changes for large Packetbuffer allocation to support TCP payloads
Changes to internal checks in SystemPacketBuffer. Update the length encoding for TCP payloads during send and receive. Max size config for large packetbuffer size limit in SystemPacketBuffer.h. Define Max application payload size for large buffers Close the connection to peer if a message is received with length exceeding the amount supported by the local node. Test modifications for chainedbuffer receives for TCP. - Add test for Buffer length greater than MRP max size. - Disable TCP on nrfconnect platform because of resource requirements. Stack allocations for large buffer with default size is exceeding limits. Disabling the Test file altogether for this platform would prevent all tests from running. Instead, only disabling TCP on nrfConnect for now, since it is unused. Fixes Issues #31779, #33307.
1 parent 5656870 commit ffbd7d3

14 files changed

+145
-76
lines changed

config/nrfconnect/chip-module/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ matter_add_gn_arg_bool ("chip_enable_nfc" CONFIG_CHIP_NF
129129
matter_add_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR)
130130
matter_add_gn_arg_bool ("chip_persist_subscriptions" CONFIG_CHIP_PERSISTENT_SUBSCRIPTIONS)
131131
matter_add_gn_arg_bool ("chip_monolithic_tests" CONFIG_CHIP_BUILD_TESTS)
132-
matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS)
132+
matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" FALSE)
133133
matter_add_gn_arg_bool ("chip_error_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 1)
134134
matter_add_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3)
135135
matter_add_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4)

src/inet/TCPEndPoint.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class DLL_EXPORT TCPEndPoint : public EndPointBasis<TCPEndPoint>
522522
/**
523523
* Size of the largest TCP packet that can be received.
524524
*/
525-
constexpr static size_t kMaxReceiveMessageSize = System::PacketBuffer::kMaxSizeWithoutReserve;
525+
constexpr static size_t kMaxReceiveMessageSize = System::PacketBuffer::kMaxAllocSize;
526526

527527
protected:
528528
friend class TCPTest;

src/inet/TCPEndPointImplSockets.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -947,10 +947,9 @@ void TCPEndPointImplSockets::ReceiveData()
947947
{
948948
VerifyOrDie(rcvLen > 0);
949949
size_t newDataLength = rcvBuf->DataLength() + static_cast<size_t>(rcvLen);
950-
VerifyOrDie(CanCastTo<uint16_t>(newDataLength));
951950
if (isNewBuf)
952951
{
953-
rcvBuf->SetDataLength(static_cast<uint16_t>(newDataLength));
952+
rcvBuf->SetDataLength(newDataLength);
954953
rcvBuf.RightSize();
955954
if (mRcvQueue.IsNull())
956955
{
@@ -963,7 +962,7 @@ void TCPEndPointImplSockets::ReceiveData()
963962
}
964963
else
965964
{
966-
rcvBuf->SetDataLength(static_cast<uint16_t>(newDataLength), mRcvQueue);
965+
rcvBuf->SetDataLength(newDataLength, mRcvQueue);
967966
}
968967
}
969968
}

src/system/SystemConfig.h

+18
Original file line numberDiff line numberDiff line change
@@ -788,3 +788,21 @@ struct LwIPEvent;
788788
#define CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD 0
789789
#endif
790790
#endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_EVENTFD
791+
792+
/**
793+
* @def CHIP_SYSTEM_CONFIG_MAX_LARGE_BUFFER_SIZE_BYTES
794+
*
795+
* @brief Maximum buffer allocation size of a 'Large' message
796+
*
797+
* This is the default maximum capacity (including both data and reserve
798+
* space) of a large PacketBuffer(exceeding the IPv6 MTU of 1280 bytes).
799+
* This shall be used over transports, such as TCP, that support large
800+
* payload transfers. Fetching of large command responses or wildcard
801+
* subscription responses may leverage this increased bandwidth transfer.
802+
* Individual systems may override this size based on their requirements.
803+
* Data transfers over MRP should not be using this size for allocating
804+
* buffers as they are restricted by the IPv6 MTU.
805+
*/
806+
#ifndef CHIP_SYSTEM_CONFIG_MAX_LARGE_BUFFER_SIZE_BYTES
807+
#define CHIP_SYSTEM_CONFIG_MAX_LARGE_BUFFER_SIZE_BYTES (64000)
808+
#endif

src/system/SystemPacketBuffer.cpp

+27-11
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,21 @@ PacketBufferHandle PacketBufferHandle::New(size_t aAvailableSize, uint16_t aRese
515515
// Setting a static upper bound on the maximum buffer size allocation for regular sized messages (not large).
516516
static_assert(PacketBuffer::kMaxSizeWithoutReserve <= UINT16_MAX, "kMaxSizeWithoutReserve should not exceed UINT16_MAX.");
517517

518+
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
519+
// Setting a static upper bound on the maximum buffer size allocation for
520+
// large messages.
521+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
522+
// LwIP based systems are internally limited to using a u16_t type as the size of a buffer.
523+
static_assert(PacketBuffer::kLargeBufMaxSizeWithoutReserve <= UINT16_MAX,
524+
"In LwIP, max size for Large payload buffers cannot exceed UINT16_MAX!");
525+
#else
526+
// Messages over TCP are framed using a length field that is 32 bits in
527+
// length.
528+
static_assert(PacketBuffer::kLargeBufMaxSizeWithoutReserve <= UINT32_MAX,
529+
"Max size for Large payload buffers cannot exceed UINT32_MAX");
530+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
531+
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
532+
518533
// Ensure that aAvailableSize is bound within a max and is not big enough to cause overflow during
519534
// subsequent addition of all the sizes.
520535
if (aAvailableSize > UINT32_MAX)
@@ -547,7 +562,11 @@ PacketBufferHandle PacketBufferHandle::New(size_t aAvailableSize, uint16_t aRese
547562
#if CHIP_SYSTEM_CONFIG_USE_LWIP
548563
// LwIP based APIs have a maximum buffer size of UINT16_MAX. Ensure that
549564
// limit is met during allocation.
550-
VerifyOrDieWithMsg(sumOfAvailAndReserved < UINT16_MAX, chipSystemLayer, "LwIP based systems can handle only up to UINT16_MAX!");
565+
if (sumOfAvailAndReserved > UINT16_MAX)
566+
{
567+
ChipLogError(chipSystemLayer, "LwIP based systems can handle only up to UINT16_MAX!");
568+
return PacketBufferHandle();
569+
}
551570
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
552571

553572
// sumOfAvailAndReserved is no larger than sumOfSizes, which we checked can be cast to
@@ -557,7 +576,7 @@ PacketBufferHandle PacketBufferHandle::New(size_t aAvailableSize, uint16_t aRese
557576

558577
CHIP_SYSTEM_FAULT_INJECT(FaultInjection::kFault_PacketBufferNew, return PacketBufferHandle());
559578

560-
if (lAllocSize > PacketBuffer::kMaxSizeWithoutReserve)
579+
if (lAllocSize > PacketBuffer::kMaxAllocSize)
561580
{
562581
ChipLogError(chipSystemLayer, "PacketBuffer: allocation exceeding buffer capacity limits.");
563582
return PacketBufferHandle();
@@ -621,18 +640,15 @@ PacketBufferHandle PacketBufferHandle::New(size_t aAvailableSize, uint16_t aRese
621640
PacketBufferHandle PacketBufferHandle::NewWithData(const void * aData, size_t aDataSize, size_t aAdditionalSize,
622641
uint16_t aReservedSize)
623642
{
624-
if (aDataSize > UINT16_MAX)
625-
{
626-
ChipLogError(chipSystemLayer, "PacketBuffer: allocation too large.");
627-
return PacketBufferHandle();
628-
}
629643
// Since `aDataSize` fits in uint16_t, the sum `aDataSize + aAdditionalSize` will not overflow.
630644
// `New()` will only return a non-null buffer if the total allocation size does not overflow.
631645
PacketBufferHandle buffer = New(aDataSize + aAdditionalSize, aReservedSize);
632646
if (buffer.mBuffer != nullptr)
633647
{
634648
memcpy(buffer.mBuffer->payload, aData, aDataSize);
635649
#if CHIP_SYSTEM_CONFIG_USE_LWIP
650+
// Checks in the New() call catches buffer allocations greater
651+
// than UINT16_MAX for LwIP based platforms.
636652
buffer.mBuffer->len = buffer.mBuffer->tot_len = static_cast<uint16_t>(aDataSize);
637653
#else
638654
buffer.mBuffer->len = buffer.mBuffer->tot_len = aDataSize;
@@ -755,18 +771,18 @@ PacketBufferHandle PacketBufferHandle::CloneData() const
755771
size_t originalDataSize = original->MaxDataLength();
756772
uint16_t originalReservedSize = original->ReservedSize();
757773

758-
if (originalDataSize + originalReservedSize > PacketBuffer::kMaxSizeWithoutReserve)
774+
if (originalDataSize + originalReservedSize > PacketBuffer::kMaxAllocSize)
759775
{
760776
// The original memory allocation may have provided a larger block than requested (e.g. when using a shared pool),
761777
// and in particular may have provided a larger block than we are able to request from PackBufferHandle::New().
762778
// It is a genuine error if that extra space has been used.
763-
if (originalReservedSize + original->DataLength() > PacketBuffer::kMaxSizeWithoutReserve)
779+
if (originalReservedSize + original->DataLength() > PacketBuffer::kMaxAllocSize)
764780
{
765781
return PacketBufferHandle();
766782
}
767783
// Otherwise, reduce the requested data size. This subtraction can not underflow because the above test
768-
// guarantees originalReservedSize <= PacketBuffer::kMaxSizeWithoutReserve.
769-
originalDataSize = PacketBuffer::kMaxSizeWithoutReserve - originalReservedSize;
784+
// guarantees originalReservedSize <= PacketBuffer::kMaxAllocSize.
785+
originalDataSize = PacketBuffer::kMaxAllocSize - originalReservedSize;
770786
}
771787

772788
PacketBufferHandle clone = PacketBufferHandle::New(originalDataSize, originalReservedSize);

src/system/SystemPacketBuffer.h

+22-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class DLL_EXPORT PacketBuffer : private pbuf
119119

120120
public:
121121
/**
122-
* The maximum size buffer an application can allocate with no protocol header reserve.
122+
* The maximum size of a regular buffer an application can allocate with no protocol header reserve.
123123
*/
124124
#if CHIP_SYSTEM_CONFIG_USE_LWIP
125125
static constexpr size_t kMaxSizeWithoutReserve = LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE);
@@ -134,10 +134,30 @@ class DLL_EXPORT PacketBuffer : private pbuf
134134
static constexpr uint16_t kDefaultHeaderReserve = CHIP_SYSTEM_CONFIG_HEADER_RESERVE_SIZE;
135135

136136
/**
137-
* The maximum size buffer an application can allocate with the default protocol header reserve.
137+
* The maximum size of a regular buffer an application can allocate with the default protocol header reserve.
138138
*/
139139
static constexpr size_t kMaxSize = kMaxSizeWithoutReserve - kDefaultHeaderReserve;
140140

141+
/**
142+
* The maximum size of a large buffer(> IPv6 MTU) that an application can allocate with no protocol header reserve.
143+
*/
144+
static constexpr size_t kLargeBufMaxSizeWithoutReserve = CHIP_SYSTEM_CONFIG_MAX_LARGE_BUFFER_SIZE_BYTES;
145+
146+
/**
147+
* The maximum size of a large buffer(> IPv6 MTU) that an application can allocate with the default protocol header reserve.
148+
*/
149+
static constexpr size_t kLargeBufMaxSize = kLargeBufMaxSizeWithoutReserve - kDefaultHeaderReserve;
150+
151+
/**
152+
* Unified constant(both regular and large buffers) for the maximum size that an application can allocate with no
153+
* protocol header reserve.
154+
*/
155+
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
156+
static constexpr size_t kMaxAllocSize = kLargeBufMaxSizeWithoutReserve;
157+
#else
158+
static constexpr size_t kMaxAllocSize = kMaxSizeWithoutReserve;
159+
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
160+
141161
/**
142162
* Return the size of the allocation including the reserved and payload data spaces but not including space
143163
* allocated for the PacketBuffer structure.

src/system/tests/TestSystemPacketBuffer.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckNew)
309309
{
310310
const PacketBufferHandle buffer = PacketBufferHandle::New(0, config.reserved_size);
311311

312-
if (config.reserved_size > PacketBuffer::kMaxSizeWithoutReserve)
312+
if (config.reserved_size > PacketBuffer::kMaxAllocSize)
313313
{
314314
EXPECT_TRUE(buffer.IsNull());
315315
continue;
@@ -1605,7 +1605,8 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckHandleRightSize)
16051605

16061606
TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckHandleCloneData)
16071607
{
1608-
uint8_t lPayload[2 * PacketBuffer::kMaxSizeWithoutReserve];
1608+
uint8_t lPayload[2 * PacketBuffer::kMaxAllocSize];
1609+
16091610
for (uint8_t & payload : lPayload)
16101611
{
16111612
payload = static_cast<uint8_t>(random());
@@ -1684,7 +1685,7 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckHandleCloneData)
16841685
// This is only testable on heap allocation configurations, where pbuf records the allocation size and we can manually
16851686
// construct an oversize buffer.
16861687

1687-
constexpr uint16_t kOversizeDataSize = PacketBuffer::kMaxSizeWithoutReserve + 99;
1688+
constexpr size_t kOversizeDataSize = PacketBuffer::kMaxAllocSize + 99;
16881689
PacketBuffer * p = reinterpret_cast<PacketBuffer *>(chip::Platform::MemoryAlloc(kStructureSize + kOversizeDataSize));
16891690
ASSERT_NE(p, nullptr);
16901691

@@ -1698,15 +1699,16 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckHandleCloneData)
16981699
PacketBufferHandle handle = PacketBufferHandle::Adopt(p);
16991700

17001701
// Fill the buffer to maximum and verify that it can be cloned.
1702+
size_t maxSize = PacketBuffer::kMaxAllocSize;
17011703

1702-
memset(handle->Start(), 1, PacketBuffer::kMaxSizeWithoutReserve);
1703-
handle->SetDataLength(PacketBuffer::kMaxSizeWithoutReserve);
1704-
EXPECT_EQ(handle->DataLength(), PacketBuffer::kMaxSizeWithoutReserve);
1704+
memset(handle->Start(), 1, maxSize);
1705+
handle->SetDataLength(maxSize);
1706+
EXPECT_EQ(handle->DataLength(), maxSize);
17051707

17061708
PacketBufferHandle clone = handle.CloneData();
17071709
ASSERT_FALSE(clone.IsNull());
1708-
EXPECT_EQ(clone->DataLength(), PacketBuffer::kMaxSizeWithoutReserve);
1709-
EXPECT_EQ(memcmp(handle->Start(), clone->Start(), PacketBuffer::kMaxSizeWithoutReserve), 0);
1710+
EXPECT_EQ(clone->DataLength(), maxSize);
1711+
EXPECT_EQ(memcmp(handle->Start(), clone->Start(), maxSize), 0);
17101712

17111713
// Overfill the buffer and verify that it can not be cloned.
17121714
memset(handle->Start(), 2, kOversizeDataSize);

src/transport/SecureMessageCodec.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ CHIP_ERROR Encrypt(const CryptoContext & context, CryptoContext::ConstNonceView
4141
{
4242
VerifyOrReturnError(!msgBuf.IsNull(), CHIP_ERROR_INVALID_ARGUMENT);
4343
VerifyOrReturnError(!msgBuf->HasChainedBuffer(), CHIP_ERROR_INVALID_MESSAGE_LENGTH);
44-
VerifyOrReturnError(msgBuf->TotalLength() <= kMaxAppMessageLen, CHIP_ERROR_MESSAGE_TOO_LONG);
4544

4645
ReturnErrorOnFailure(payloadHeader.EncodeBeforeData(msgBuf));
4746

src/transport/SessionManager.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,15 @@ CHIP_ERROR SessionManager::PrepareMessage(const SessionHandle & sessionHandle, P
201201
packetHeader.SetSecureSessionControlMsg(true);
202202
}
203203

204+
if (sessionHandle->AllowsLargePayload())
205+
{
206+
VerifyOrReturnError(message->TotalLength() <= kMaxLargeAppMessageLen, CHIP_ERROR_MESSAGE_TOO_LONG);
207+
}
208+
else
209+
{
210+
VerifyOrReturnError(message->TotalLength() <= kMaxAppMessageLen, CHIP_ERROR_MESSAGE_TOO_LONG);
211+
}
212+
204213
#if CHIP_PROGRESS_LOGGING
205214
NodeId destination;
206215
FabricIndex fabricIndex;

src/transport/raw/MessageHeader.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ static constexpr size_t kMaxPacketBufferApplicationPayloadAndMICSizeBytes = Syst
6060

6161
static constexpr size_t kMaxApplicationPayloadAndMICSizeBytes =
6262
min(kMaxPerSpecApplicationPayloadAndMICSizeBytes, kMaxPacketBufferApplicationPayloadAndMICSizeBytes);
63-
6463
} // namespace detail
6564

6665
static constexpr size_t kMaxTagLen = 16;
@@ -74,6 +73,16 @@ static constexpr size_t kMaxAppMessageLen = detail::kMaxApplicationPayloadAndMIC
7473

7574
static constexpr uint16_t kMsgUnicastSessionIdUnsecured = 0x0000;
7675

76+
// Minimum header size of TCP + IPv6 without options.
77+
static constexpr size_t kMaxTCPAndIPHeaderSizeBytes = 60;
78+
79+
// Max space for the Application Payload and MIC for large packet buffers
80+
// This is the size _excluding_ the header reserve.
81+
static constexpr size_t kMaxLargeApplicationPayloadAndMICSizeBytes =
82+
System::PacketBuffer::kLargeBufMaxSize - kMaxTCPAndIPHeaderSizeBytes;
83+
84+
static constexpr size_t kMaxLargeAppMessageLen = kMaxLargeApplicationPayloadAndMICSizeBytes - kMaxTagLen;
85+
7786
typedef int PacketHeaderFlags;
7887

7988
namespace Header {

src/transport/raw/TCP.cpp

+15-13
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ namespace {
3939

4040
using namespace chip::Encoding;
4141

42-
// Packets start with a 16-bit size
43-
constexpr size_t kPacketSizeBytes = 2;
42+
// Packets start with a 32-bit size field.
43+
constexpr size_t kPacketSizeBytes = 4;
4444

45-
// TODO: Actual limit may be lower (spec issue #2119)
46-
constexpr uint16_t kMaxMessageSize = static_cast<uint16_t>(System::PacketBuffer::kMaxSizeWithoutReserve - kPacketSizeBytes);
45+
static_assert(System::PacketBuffer::kLargeBufMaxSizeWithoutReserve >= kPacketSizeBytes, "Large buffer allocation should be large enough to hold the length field");
46+
47+
constexpr uint32_t kMaxTCPMessageSize =
48+
static_cast<uint32_t>(System::PacketBuffer::kLargeBufMaxSizeWithoutReserve - kPacketSizeBytes);
4749

4850
constexpr int kListenBacklogSize = 2;
4951

@@ -197,21 +199,21 @@ ActiveTCPConnectionState * TCPBase::FindInUseConnection(const Inet::TCPEndPoint
197199
CHIP_ERROR TCPBase::SendMessage(const Transport::PeerAddress & address, System::PacketBufferHandle && msgBuf)
198200
{
199201
// Sent buffer data format is:
200-
// - packet size as a uint16_t
202+
// - packet size as a uint32_t
201203
// - actual data
202204

203205
VerifyOrReturnError(address.GetTransportType() == Type::kTcp, CHIP_ERROR_INVALID_ARGUMENT);
204206
VerifyOrReturnError(mState == TCPState::kInitialized, CHIP_ERROR_INCORRECT_STATE);
205-
VerifyOrReturnError(kPacketSizeBytes + msgBuf->DataLength() <= std::numeric_limits<uint16_t>::max(),
207+
VerifyOrReturnError(kPacketSizeBytes + msgBuf->DataLength() <= System::PacketBuffer::kLargeBufMaxSizeWithoutReserve,
206208
CHIP_ERROR_INVALID_ARGUMENT);
207209

208-
// The check above about kPacketSizeBytes + msgBuf->DataLength() means it definitely fits in uint16_t.
210+
static_assert(kPacketSizeBytes <= UINT16_MAX);
209211
VerifyOrReturnError(msgBuf->EnsureReservedSize(static_cast<uint16_t>(kPacketSizeBytes)), CHIP_ERROR_NO_MEMORY);
210212

211213
msgBuf->SetStart(msgBuf->Start() - kPacketSizeBytes);
212214

213215
uint8_t * output = msgBuf->Start();
214-
LittleEndian::Write16(output, static_cast<uint16_t>(msgBuf->DataLength() - kPacketSizeBytes));
216+
LittleEndian::Write32(output, static_cast<uint32_t>(msgBuf->DataLength() - kPacketSizeBytes));
215217

216218
// Reuse existing connection if one exists, otherwise a new one
217219
// will be established
@@ -324,11 +326,11 @@ CHIP_ERROR TCPBase::ProcessReceivedBuffer(Inet::TCPEndPoint * endPoint, const Pe
324326
{
325327
return err;
326328
}
327-
uint16_t messageSize = LittleEndian::Get16(messageSizeBuf);
328-
if (messageSize >= kMaxMessageSize)
329+
uint32_t messageSize = LittleEndian::Get32(messageSizeBuf);
330+
if (messageSize >= kMaxTCPMessageSize)
329331
{
330-
331-
// This message is too long for upper layers.
332+
// Message is too big for node to process. Disconnect with peer.
333+
CloseConnectionInternal(state, CHIP_ERROR_MESSAGE_TOO_LONG, SuppressCallback::No);
332334
return CHIP_ERROR_MESSAGE_TOO_LONG;
333335
}
334336
// The subtraction will not underflow because we successfully read kPacketSizeBytes.
@@ -344,7 +346,7 @@ CHIP_ERROR TCPBase::ProcessReceivedBuffer(Inet::TCPEndPoint * endPoint, const Pe
344346
return CHIP_NO_ERROR;
345347
}
346348

347-
CHIP_ERROR TCPBase::ProcessSingleMessage(const PeerAddress & peerAddress, ActiveTCPConnectionState * state, uint16_t messageSize)
349+
CHIP_ERROR TCPBase::ProcessSingleMessage(const PeerAddress & peerAddress, ActiveTCPConnectionState * state, size_t messageSize)
348350
{
349351
// We enter with `state->mReceived` containing at least one full message, perhaps in a chain.
350352
// `state->mReceived->Start()` currently points to the message data.

src/transport/raw/TCP.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class DLL_EXPORT TCPBase : public Base
258258
* is no other data).
259259
* @param[in] messageSize Size of the single message.
260260
*/
261-
CHIP_ERROR ProcessSingleMessage(const PeerAddress & peerAddress, ActiveTCPConnectionState * state, uint16_t messageSize);
261+
CHIP_ERROR ProcessSingleMessage(const PeerAddress & peerAddress, ActiveTCPConnectionState * state, size_t messageSize);
262262

263263
/**
264264
* Initiate a connection to the given peer. On connection completion,
@@ -306,10 +306,6 @@ class DLL_EXPORT TCPBase : public Base
306306
// giving up.
307307
uint32_t mConnectTimeout = CHIP_CONFIG_TCP_CONNECT_TIMEOUT_MSECS;
308308

309-
// The max payload size of data over a TCP connection that is transmissible
310-
// at a time.
311-
uint32_t mMaxTCPPayloadSize = CHIP_CONFIG_MAX_TCP_PAYLOAD_SIZE_BYTES;
312-
313309
// Number of active and 'pending connection' endpoints
314310
size_t mUsedEndPointCount = 0;
315311

src/transport/raw/TCPConfig.h

-9
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ namespace chip {
6363
#define CHIP_CONFIG_MAX_TCP_PENDING_PACKETS 4
6464
#endif
6565

66-
/**
67-
* @def CHIP_CONFIG_MAX_TCP_PAYLOAD_SIZE_BYTES
68-
*
69-
* @brief Maximum payload size of a message over a TCP connection
70-
*/
71-
#ifndef CHIP_CONFIG_MAX_TCP_PAYLOAD_SIZE_BYTES
72-
#define CHIP_CONFIG_MAX_TCP_PAYLOAD_SIZE_BYTES 1000000
73-
#endif
74-
7566
/**
7667
* @def CHIP_CONFIG_TCP_CONNECT_TIMEOUT_MSECS
7768
*

0 commit comments

Comments
 (0)