@@ -496,7 +496,7 @@ CHIP_ERROR Engine::BuildAndSendSingleReportData(ReadHandler * apReadHandler)
496
496
uint16_t reservedSize = 0 ;
497
497
bool hasMoreChunks = false ;
498
498
bool needCloseReadHandler = false ;
499
- size_t maxSduSize = 0 ;
499
+ size_t reportBufferMaxSize = 0 ;
500
500
501
501
// Reserved size for the MoreChunks boolean flag, which takes up 1 byte for the control tag and 1 byte for the context tag.
502
502
const uint32_t kReservedSizeForMoreChunksFlag = 1 + 1 ;
@@ -514,16 +514,14 @@ CHIP_ERROR Engine::BuildAndSendSingleReportData(ReadHandler * apReadHandler)
514
514
VerifyOrExit (apReadHandler != nullptr , err = CHIP_ERROR_INVALID_ARGUMENT);
515
515
VerifyOrExit (apReadHandler->GetSession () != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
516
516
517
- // Depending on whether the session supports large payload or not, the
518
- // appropriate max size would be returned for the Report buffer.
519
- maxSduSize = apReadHandler->GetReportBufferMaxSize ();
517
+ reportBufferMaxSize = apReadHandler->GetReportBufferMaxSize ();
520
518
521
- bufHandle = System::PacketBufferHandle::New (maxSduSize );
519
+ bufHandle = System::PacketBufferHandle::New (reportBufferMaxSize );
522
520
VerifyOrExit (!bufHandle.IsNull (), err = CHIP_ERROR_NO_MEMORY);
523
521
524
- if (bufHandle->AvailableDataLength () > maxSduSize )
522
+ if (bufHandle->AvailableDataLength () > reportBufferMaxSize )
525
523
{
526
- reservedSize = static_cast <uint16_t >(bufHandle->AvailableDataLength () - maxSduSize );
524
+ reservedSize = static_cast <uint16_t >(bufHandle->AvailableDataLength () - reportBufferMaxSize );
527
525
}
528
526
529
527
reportDataWriter.Init (std::move (bufHandle));
@@ -532,8 +530,8 @@ CHIP_ERROR Engine::BuildAndSendSingleReportData(ReadHandler * apReadHandler)
532
530
reportDataWriter.ReserveBuffer (mReservedSize );
533
531
#endif
534
532
535
- // Always limit the size of the generated packet to fit within kMaxSecureSduLengthBytes regardless of the available buffer
536
- // capacity.
533
+ // Always limit the size of the generated packet to fit within the max size returned by the ReadHandler regardless
534
+ // of the available buffer capacity.
537
535
// Also, we need to reserve some extra space for the MIC field.
538
536
reportDataWriter.ReserveBuffer (static_cast <uint32_t >(reservedSize + chip::Crypto::CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES));
539
537
0 commit comments