From c48baa00ffc96c0b2035a960571b96a8062ba352 Mon Sep 17 00:00:00 2001 From: yunhanw Date: Wed, 6 Dec 2023 10:20:02 -0800 Subject: [PATCH] Revert "[ICD] Store UserActiveModeTriggerHint and instruction into ICD storage (#30770)" This reverts commit d809f32b012263b3981617d96c87cbad7a21df70. --- .../icd/client/DefaultICDClientStorage.cpp | 32 ++----------------- src/app/icd/client/DefaultICDClientStorage.h | 17 ++++------ src/app/icd/client/ICDClientInfo.h | 30 +++++------------ src/app/tests/TestDefaultICDClientStorage.cpp | 16 +++------- 4 files changed, 21 insertions(+), 74 deletions(-) diff --git a/src/app/icd/client/DefaultICDClientStorage.cpp b/src/app/icd/client/DefaultICDClientStorage.cpp index 324532750b8c1a..70b2aa035af5a3 100644 --- a/src/app/icd/client/DefaultICDClientStorage.cpp +++ b/src/app/icd/client/DefaultICDClientStorage.cpp @@ -258,27 +258,8 @@ CHIP_ERROR DefaultICDClientStorage::Load(FabricIndex fabricIndex, std::vector(strlen(clientInfo.user_active_mode_trigger_instruction)))); - } - ByteSpan buf(clientInfo.shared_key.As()); ReturnErrorOnFailure(writer.Put(TLV::ContextTag(ClientInfoTag::kSharedKey), buf)); ReturnErrorOnFailure(writer.EndContainer(ICDClientInfoContainerType)); diff --git a/src/app/icd/client/DefaultICDClientStorage.h b/src/app/icd/client/DefaultICDClientStorage.h index f71d89d0072aa7..83729dced069b1 100644 --- a/src/app/icd/client/DefaultICDClientStorage.h +++ b/src/app/icd/client/DefaultICDClientStorage.h @@ -71,14 +71,12 @@ class DefaultICDClientStorage : public ICDClientStorage protected: enum class ClientInfoTag : uint8_t { - kPeerNodeId = 1, - kFabricIndex = 2, - kStartICDCounter = 3, - kOffset = 4, - kMonitoredSubject = 5, - kUserActiveModeTriggerHint = 6, - kUserActiveModeTriggerInstruction = 7, - kSharedKey = 8 + kPeerNodeId = 1, + kFabricIndex = 2, + kStartICDCounter = 3, + kOffset = 4, + kMonitoredSubject = 5, + kSharedKey = 6 }; enum class CounterTag : uint8_t @@ -106,8 +104,7 @@ class DefaultICDClientStorage : public ICDClientStorage { // All the fields added together return TLV::EstimateStructOverhead(sizeof(NodeId), sizeof(FabricIndex), sizeof(uint32_t), sizeof(uint32_t), - sizeof(uint64_t), sizeof(uint32_t), kUserActiveModeTriggerInstructionSize, - sizeof(Crypto::Symmetric128BitsKeyByteArray)); + sizeof(uint64_t), sizeof(Crypto::Symmetric128BitsKeyByteArray)); } static constexpr size_t MaxICDCounterSize() diff --git a/src/app/icd/client/ICDClientInfo.h b/src/app/icd/client/ICDClientInfo.h index 976af93576dddd..d55c3e535ea046 100644 --- a/src/app/icd/client/ICDClientInfo.h +++ b/src/app/icd/client/ICDClientInfo.h @@ -24,40 +24,26 @@ #include #include -namespace { -constexpr size_t kUserActiveModeTriggerInstructionSize = 128; -} // namespace - namespace chip { namespace app { struct ICDClientInfo { ScopedNodeId peer_node; - uint32_t start_icd_counter = 0; - uint32_t offset = 0; - uint64_t monitored_subject = static_cast(0); - uint32_t user_active_mode_trigger_hint = 0; - char user_active_mode_trigger_instruction[kUserActiveModeTriggerInstructionSize] = { 0 }; - bool has_instruction = false; - Crypto::Aes128BitsKeyHandle shared_key = Crypto::Aes128BitsKeyHandle(); + uint32_t start_icd_counter = 0; + uint32_t offset = 0; + uint64_t monitored_subject = static_cast(0); + Crypto::Aes128BitsKeyHandle shared_key = Crypto::Aes128BitsKeyHandle(); ICDClientInfo() {} ICDClientInfo(const ICDClientInfo & other) { *this = other; } ICDClientInfo & operator=(const ICDClientInfo & other) { - peer_node = other.peer_node; - start_icd_counter = other.start_icd_counter; - offset = other.offset; - monitored_subject = other.monitored_subject; - user_active_mode_trigger_hint = other.user_active_mode_trigger_hint; - if (other.has_instruction) - { - memcpy(user_active_mode_trigger_instruction, other.user_active_mode_trigger_instruction, - kUserActiveModeTriggerInstructionSize); - } - has_instruction = other.has_instruction; + peer_node = other.peer_node; + start_icd_counter = other.start_icd_counter; + offset = other.offset; + monitored_subject = other.monitored_subject; ByteSpan buf(other.shared_key.As()); memcpy(shared_key.AsMutable(), buf.data(), sizeof(Crypto::Symmetric128BitsKeyByteArray)); diff --git a/src/app/tests/TestDefaultICDClientStorage.cpp b/src/app/tests/TestDefaultICDClientStorage.cpp index 0eb17d97b70bd6..730747232455c6 100644 --- a/src/app/tests/TestDefaultICDClientStorage.cpp +++ b/src/app/tests/TestDefaultICDClientStorage.cpp @@ -70,16 +70,11 @@ void TestClientInfoCount(nlTestSuite * apSuite, void * apContext) // Write some ClientInfos and see the counts are correct ICDClientInfo clientInfo1; clientInfo1.peer_node = ScopedNodeId(nodeId1, fabricId); - char val[5] = "test"; ICDClientInfo clientInfo2; - clientInfo2.peer_node = ScopedNodeId(nodeId2, fabricId); - clientInfo2.user_active_mode_trigger_hint = 1; - memcpy(clientInfo2.user_active_mode_trigger_instruction, val, sizeof(val)); - clientInfo2.has_instruction = true; + clientInfo2.peer_node = ScopedNodeId(nodeId2, fabricId); ICDClientInfo clientInfo3; - clientInfo3.peer_node = ScopedNodeId(nodeId1, fabricId); - clientInfo3.user_active_mode_trigger_hint = 2; - err = manager.SetKey(clientInfo1, ByteSpan(kKeyBuffer1)); + clientInfo3.peer_node = ScopedNodeId(nodeId1, fabricId); + err = manager.SetKey(clientInfo1, ByteSpan(kKeyBuffer1)); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); err = manager.StoreEntry(clientInfo1); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); @@ -105,12 +100,9 @@ void TestClientInfoCount(nlTestSuite * apSuite, void * apContext) NL_TEST_ASSERT(apSuite, iterator->Next(clientInfo)); NL_TEST_ASSERT(apSuite, clientInfo.peer_node.GetNodeId() == nodeId2); - NL_TEST_ASSERT(apSuite, clientInfo.has_instruction); - NL_TEST_ASSERT(apSuite, strcmp(clientInfo.user_active_mode_trigger_instruction, val) == 0); NL_TEST_ASSERT(apSuite, iterator->Next(clientInfo)); NL_TEST_ASSERT(apSuite, clientInfo.peer_node.GetNodeId() == nodeId1); - NL_TEST_ASSERT(apSuite, clientInfo.user_active_mode_trigger_hint == 2); - NL_TEST_ASSERT(apSuite, !clientInfo.has_instruction); + iterator->Release(); // Delete all and verify iterator counts 0