Skip to content

Commit 8dce4be

Browse files
add monitor subject check for subscription activation
If caseTag for current subscription does not match with the one set in ICDManagementCluster::RegisterClient for check-in, when receiving check-in message, OnActiveModeNotification would do nothing for current subscription.
1 parent e49f9a6 commit 8dce4be

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

src/app/InteractionModelEngine.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1069,14 +1069,18 @@ void InteractionModelEngine::OnResponseTimeout(Messaging::ExchangeContext * ec)
10691069
}
10701070

10711071
#if CHIP_CONFIG_ENABLE_READ_CLIENT
1072-
void InteractionModelEngine::OnActiveModeNotification(ScopedNodeId aPeer)
1072+
void InteractionModelEngine::OnActiveModeNotification(ScopedNodeId aPeer, uint64_t aMonitoredSubject)
10731073
{
10741074
for (ReadClient * pListItem = mpActiveReadClientList; pListItem != nullptr;)
10751075
{
10761076
auto pNextItem = pListItem->GetNextClient();
10771077
// It is possible that pListItem is destroyed by the app in OnActiveModeNotification.
10781078
// Get the next item before invoking `OnActiveModeNotification`.
1079-
if (ScopedNodeId(pListItem->GetPeerNodeId(), pListItem->GetFabricIndex()) == aPeer)
1079+
// If caseTag for current subscription does not match with the one set in ICDManagementCluster::RegisterClient for check-in,
1080+
// when receiving check-in message, OnActiveModeNotification would do nothing for current subscription.
1081+
if (ScopedNodeId(pListItem->GetPeerNodeId(), pListItem->GetFabricIndex()) == aPeer &&
1082+
pListItem->GetSubjectDescriptor().HasValue() && pListItem->GetSubjectDescriptor().cats.CheckSubjectAgainstCATs(aMonitoredSubject) &&
1083+
pListItem->GetSubjectDescriptor().subject == aMonitoredSubject)
10801084
{
10811085
pListItem->OnActiveModeNotification();
10821086
}

src/app/InteractionModelEngine.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
238238
*
239239
* See ReadClient::OnActiveModeNotification
240240
*/
241-
void OnActiveModeNotification(ScopedNodeId aPeer);
241+
void OnActiveModeNotification(ScopedNodeId aPeer, uint64_t aMonitoredSubject);
242242

243243
/**
244244
* Used to notify when a peer becomes LIT ICD or vice versa.

src/app/ReadClient.h

+6
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ class ReadClient : public Messaging::ExchangeDelegate
509509
*/
510510
Optional<System::Clock::Timeout> GetSubscriptionTimeout();
511511

512+
Optional<Access::SubjectDescriptor> GetSubjectDescriptor() const
513+
{
514+
VerifyOrReturnValue(mReadPrepareParams.mSessionHolder, NullOptional);
515+
return MakeOptional(mReadPrepareParams.mSessionHolder->AsSecureSession()->GetSubjectDescriptor());
516+
}
517+
512518
private:
513519
friend class TestReadInteraction;
514520
friend class InteractionModelEngine;

src/app/icd/client/CheckInHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ CHIP_ERROR CheckInHandler::OnMessageReceived(Messaging::ExchangeContext * ec, co
138138
mpICDClientStorage->StoreEntry(clientInfo);
139139
mpCheckInDelegate->OnCheckInComplete(clientInfo);
140140
#if CHIP_CONFIG_ENABLE_READ_CLIENT
141-
mpImEngine->OnActiveModeNotification(clientInfo.peer_node);
141+
mpImEngine->OnActiveModeNotification(clientInfo.peer_node, clientInfo.monitored_subject);
142142
#endif // CHIP_CONFIG_ENABLE_READ_CLIENT
143143
}
144144

src/app/icd/client/RefreshKeySender.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ CHIP_ERROR RefreshKeySender::RegisterClientWithNewKey(Messaging::ExchangeManager
6969

7070
mpCheckInDelegate->OnCheckInComplete(mICDClientInfo);
7171
#if CHIP_CONFIG_ENABLE_READ_CLIENT
72-
mpImEngine->OnActiveModeNotification(mICDClientInfo.peer_node);
72+
mpImEngine->OnActiveModeNotification(mICDClientInfo.peer_node, mICDClientInfo.monitored_subject);
7373
#endif // CHIP_CONFIG_ENABLE_READ_CLIENT
7474
mpCheckInDelegate->OnKeyRefreshDone(this, CHIP_NO_ERROR);
7575
};

src/controller/tests/data_model/TestRead.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2330,7 +2330,7 @@ TEST_F(TestRead, TestSubscribe_OnActiveModeNotification)
23302330
GetLoopback().mNumMessagesToDrop = 0;
23312331
callback.ClearCounters();
23322332
InteractionModelEngine::GetInstance()->OnActiveModeNotification(
2333-
ScopedNodeId(readClient.GetPeerNodeId(), readClient.GetFabricIndex()));
2333+
ScopedNodeId(readClient.GetPeerNodeId(), readClient.GetFabricIndex()), readClient.GetSubjectDescriptor().Value().subject);
23342334
EXPECT_EQ(callback.mOnResubscriptionsAttempted, 1);
23352335
EXPECT_EQ(callback.mLastError, CHIP_ERROR_TIMEOUT);
23362336

@@ -2393,7 +2393,7 @@ TEST_F(TestRead, TestSubscribeFailed_OnActiveModeNotification)
23932393
GetLoopback().mNumMessagesToDrop = 0;
23942394
callback.ClearCounters();
23952395
InteractionModelEngine::GetInstance()->OnActiveModeNotification(
2396-
ScopedNodeId(readClient.GetPeerNodeId(), readClient.GetFabricIndex()));
2396+
ScopedNodeId(readClient.GetPeerNodeId(), readClient.GetFabricIndex()), readClient.GetSubjectDescriptor().Value().subject);
23972397
//
23982398
// Drive servicing IO till we have established a subscription.
23992399
//

0 commit comments

Comments
 (0)