Skip to content

Commit

Permalink
Add API to invalid sessions/exchanges for UpdateNOC command
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost committed Jun 9, 2022
1 parent ac8bdbf commit 2f2fb5f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/messaging/ExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,16 @@ void ExchangeManager::CloseAllContextsForDelegate(const ExchangeDelegate * deleg
});
}

void ExchangeManager::AbortExchangeForNodeExceptOne(const ScopedNodeId & node, ExchangeContext * stay)
{
mContextPool.ForEachActiveObject([&](auto * ec) {
if (ec != stay && ec->HasSessionHandle() && ec->GetSessionHandle()->GetPeer() == node)
{
ec->Abort();
}
return Loop::Continue;
});
}

} // namespace Messaging
} // namespace chip
3 changes: 3 additions & 0 deletions src/messaging/ExchangeMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ class DLL_EXPORT ExchangeManager : public SessionMessageDelegate
*/
void CloseAllContextsForDelegate(const ExchangeDelegate * delegate);

// This API is used by UpdateNOC command, to invalid all exchanges except the given one.
void AbortExchangeForNodeExceptOne(const ScopedNodeId & node, ExchangeContext * stay);

SessionManager * GetSessionManager() const { return mSessionManager; }

ReliableMessageMgr * GetReliableMessageMgr() { return &mReliableMessageMgr; };
Expand Down
11 changes: 11 additions & 0 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,17 @@ void SessionManager::ExpireAllPASEPairings()
});
}

void SessionManager::ReleaseSessionForNodeExceptOne(const ScopedNodeId & node, const SessionHandle & stay)
{
mSecureSessions.ForEachSession([&](auto session) {
if (session->GetPeer() == node && session != stay->AsSecureSession())
{
session->MarkForRemoval();
}
return Loop::Continue;
});
}

Optional<SessionHandle> SessionManager::AllocateSession(SecureSession::Type secureSessionType)
{
return mSecureSessions.CreateNewSecureSession(secureSessionType);
Expand Down
3 changes: 3 additions & 0 deletions src/transport/SessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ class DLL_EXPORT SessionManager : public TransportMgrDelegate
void ExpireAllPairingsForFabric(FabricIndex fabric);
void ExpireAllPASEPairings();

// This API is used by UpdateNOC command, to invalid all sessions except the given one.
void ReleaseSessionForNodeExceptOne(const ScopedNodeId & node, const SessionHandle & stay);

/**
* @brief
* Return the System Layer pointer used by current SessionManager.
Expand Down

0 comments on commit 2f2fb5f

Please sign in to comment.