Skip to content

Commit

Permalink
Increase ICD Monitoring buffer size to fit maximum size entry
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Sep 23, 2024
1 parent 8750c55 commit c189be6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/app/icd/server/ICDMonitoringTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using SymmetricKeystore = SessionKeystore;

namespace chip {

inline constexpr size_t kICDMonitoringBufferSize = 60;
inline constexpr size_t kICDMonitoringBufferSize = 63;

struct ICDMonitoringEntry : public PersistentData<kICDMonitoringBufferSize>
{
Expand Down Expand Up @@ -129,8 +129,7 @@ struct ICDMonitoringTable
{
ICDMonitoringTable(PersistentStorageDelegate & storage, FabricIndex fabric, uint16_t limit,
Crypto::SymmetricKeystore * symmetricKeystore) :
mStorage(&storage),
mFabric(fabric), mLimit(limit), mSymmetricKeystore(symmetricKeystore)
mStorage(&storage), mFabric(fabric), mLimit(limit), mSymmetricKeystore(symmetricKeystore)
{}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/app/icd/server/tests/TestICDMonitoringTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ constexpr uint64_t kClientNodeId13 = 0x100003;
constexpr uint64_t kClientNodeId21 = 0x200001;
constexpr uint64_t kClientNodeId22 = 0x200002;

constexpr uint64_t kClientNodeMaxValue = std::numeric_limits<uint64_t>::max();

constexpr uint8_t kKeyBuffer0a[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
constexpr uint8_t kKeyBuffer0b[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
Expand Down Expand Up @@ -98,6 +100,20 @@ TEST(TestICDMonitoringTable, TestEntryAssignationOverload)
EXPECT_TRUE(entry2.IsKeyEquivalent(ByteSpan(kKeyBuffer1a)));
}

TEST(TestICDMonitoringTable, TestEntryMaximumSize)
{
TestPersistentStorageDelegate storage;
TestSessionKeystoreImpl keystore;
ICDMonitoringTable table(storage, kTestFabricIndex1, kMaxTestClients1, &keystore);

ICDMonitoringEntry entry(&keystore);
entry.checkInNodeID = kClientNodeMaxValue;
entry.monitoredSubject = kClientNodeMaxValue;
entry.clientType = ClientTypeEnum::kPermanent;
EXPECT_EQ(CHIP_NO_ERROR, entry.SetKey(ByteSpan(kKeyBuffer1a)));
EXPECT_EQ(CHIP_NO_ERROR, table.Set(0, entry));
}

TEST(TestICDMonitoringTable, TestEntryKeyFunctions)
{
TestSessionKeystoreImpl keystore;
Expand Down

0 comments on commit c189be6

Please sign in to comment.