Skip to content

Commit

Permalink
app: Use SessionHandle instead of node id for IM APIs (#10916)
Browse files Browse the repository at this point in the history
app: Use SessionHandle instead of node id for IM APIs
  • Loading branch information
kghost authored and pull[bot] committed Nov 18, 2022
1 parent 6ecabef commit 8688153
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 61 deletions.
2 changes: 2 additions & 0 deletions src/app/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ CHIP_ERROR CommandHandler::SendCommandResponse()
ReturnErrorOnFailure(Finalize(commandPacket));
ReturnErrorOnFailure(
mpExchangeCtx->SendMessage(Protocols::InteractionModel::MsgType::InvokeCommandResponse, std::move(commandPacket)));
// The ExchangeContext is automatically freed here, and it makes mpExchangeCtx be temporarily dangling, but in
// all cases, we are going to call Close immediately after this function, which nulls out mpExchangeCtx.

MoveToState(CommandState::CommandSent);

Expand Down
5 changes: 2 additions & 3 deletions src/app/CommandSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ CommandSender::CommandSender(Callback * apCallback, Messaging::ExchangeManager *
mpCallback(apCallback), mpExchangeMgr(apExchangeMgr)
{}

CHIP_ERROR CommandSender::SendCommandRequest(NodeId aNodeId, FabricIndex aFabricIndex, Optional<SessionHandle> secureSession,
System::Clock::Timeout timeout)
CHIP_ERROR CommandSender::SendCommandRequest(SessionHandle session, System::Clock::Timeout timeout)
{
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferHandle commandPacket;
Expand All @@ -48,7 +47,7 @@ CHIP_ERROR CommandSender::SendCommandRequest(NodeId aNodeId, FabricIndex aFabric
SuccessOrExit(err);

// Create a new exchange context.
mpExchangeCtx = mpExchangeMgr->NewContext(secureSession.ValueOr(SessionHandle(aNodeId, 1, 1, aFabricIndex)), this);
mpExchangeCtx = mpExchangeMgr->NewContext(session, this);
VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY);

mpExchangeCtx->SetResponseTimeout(timeout);
Expand Down
5 changes: 1 addition & 4 deletions src/app/CommandSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ class CommandSender final : public Command, public Messaging::ExchangeDelegate
return FinishCommand(/* aEndDataStruct = */ false);
}

// TODO: issue #6792 - the secure session parameter should be made non-optional and passed by reference.
//
// Sends a queued up command request to the target encapsulated by the secureSession handle.
//
// Upon successful return from this call, all subsequent errors that occur during this interaction
Expand All @@ -155,8 +153,7 @@ class CommandSender final : public Command, public Messaging::ExchangeDelegate
// Client can specify the maximum time to wait for response (in milliseconds) via timeout parameter.
// Default timeout value will be used otherwise.
//
CHIP_ERROR SendCommandRequest(NodeId aNodeId, FabricIndex aFabricIndex, Optional<SessionHandle> secureSession,
System::Clock::Timeout timeout = kImMessageTimeout);
CHIP_ERROR SendCommandRequest(SessionHandle session, System::Clock::Timeout timeout = kImMessageTimeout);

private:
// ExchangeDelegate interface implementation. Private so people won't
Expand Down
10 changes: 4 additions & 6 deletions src/app/WriteClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ void WriteClient::ClearState()
MoveToState(State::Uninitialized);
}

CHIP_ERROR WriteClient::SendWriteRequest(NodeId aNodeId, FabricIndex aFabricIndex, Optional<SessionHandle> apSecureSession,
System::Clock::Timeout timeout)
CHIP_ERROR WriteClient::SendWriteRequest(SessionHandle session, System::Clock::Timeout timeout)
{
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferHandle packet;
Expand All @@ -258,7 +257,7 @@ CHIP_ERROR WriteClient::SendWriteRequest(NodeId aNodeId, FabricIndex aFabricInde
ClearExistingExchangeContext();

// Create a new exchange context.
mpExchangeCtx = mpExchangeMgr->NewContext(apSecureSession.ValueOr(SessionHandle(aNodeId, 1, 1, aFabricIndex)), this);
mpExchangeCtx = mpExchangeMgr->NewContext(session, this);
VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY);
mpExchangeCtx->SetResponseTimeout(timeout);

Expand Down Expand Up @@ -372,10 +371,9 @@ CHIP_ERROR WriteClient::ProcessAttributeStatusIB(AttributeStatusIB::Parser & aAt
return err;
}

CHIP_ERROR WriteClientHandle::SendWriteRequest(NodeId aNodeId, FabricIndex aFabricIndex, Optional<SessionHandle> apSecureSession,
System::Clock::Timeout timeout)
CHIP_ERROR WriteClientHandle::SendWriteRequest(SessionHandle session, System::Clock::Timeout timeout)
{
CHIP_ERROR err = mpWriteClient->SendWriteRequest(aNodeId, aFabricIndex, apSecureSession, timeout);
CHIP_ERROR err = mpWriteClient->SendWriteRequest(session, timeout);

if (err == CHIP_NO_ERROR)
{
Expand Down
6 changes: 2 additions & 4 deletions src/app/WriteClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ class WriteClient : public Messaging::ExchangeDelegate
* If SendWriteRequest is never called, or the call fails, the API
* consumer is responsible for calling Shutdown on the WriteClient.
*/
CHIP_ERROR SendWriteRequest(NodeId aNodeId, FabricIndex aFabricIndex, Optional<SessionHandle> apSecureSession,
System::Clock::Timeout timeout);
CHIP_ERROR SendWriteRequest(SessionHandle session, System::Clock::Timeout timeout);

/**
* Initialize the client object. Within the lifetime
Expand Down Expand Up @@ -225,8 +224,7 @@ class WriteClientHandle
* Finalize the message and send it to the desired node. The underlying write object will always be released, and the user
* should not use this object after calling this function.
*/
CHIP_ERROR SendWriteRequest(NodeId aNodeId, FabricIndex aFabricIndex, Optional<SessionHandle> apSecureSession,
System::Clock::Timeout timeout = kImMessageTimeout);
CHIP_ERROR SendWriteRequest(SessionHandle session, System::Clock::Timeout timeout = kImMessageTimeout);

/**
* Encode an attribute value that can be directly encoded using TLVWriter::Put
Expand Down
38 changes: 14 additions & 24 deletions src/app/tests/TestCommandInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ using TestContext = chip::Test::AppContext;
namespace chip {

namespace {
FabricIndex gFabricIndex = 0;
bool isCommandDispatched = false;

bool sendResponse = true;
Expand Down Expand Up @@ -288,7 +287,7 @@ void TestCommandInteraction::TestCommandSenderWithWrongState(nlTestSuite * apSui
app::CommandSender commandSender(&mockCommandSenderDelegate, &ctx.GetExchangeManager());
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

err = commandSender.SendCommandRequest(kTestDeviceNodeId, gFabricIndex, Optional<SessionHandle>::Missing());
err = commandSender.SendCommandRequest(ctx.GetSessionBobToAlice());
NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_INCORRECT_STATE);
}

Expand All @@ -303,11 +302,9 @@ void TestCommandInteraction::TestCommandHandlerWithWrongState(nlTestSuite * apSu
err = commandHandler.PrepareCommand(commandPathParams);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

auto exchangeCtx = ctx.GetExchangeManager().NewContext(SessionHandle(0, 0, 0, 0), nullptr);
commandHandler.mpExchangeCtx = exchangeCtx;
TestExchangeDelegate delegate;
commandHandler.mpExchangeCtx->SetDelegate(&delegate);
err = commandHandler.SendCommandResponse();
commandHandler.mpExchangeCtx = ctx.NewExchangeToAlice(&delegate);
err = commandHandler.SendCommandResponse();

NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_INCORRECT_STATE);
}
Expand All @@ -322,8 +319,7 @@ void TestCommandInteraction::TestCommandSenderWithSendCommand(nlTestSuite * apSu
System::PacketBufferHandle buf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize);

AddCommandDataIB(apSuite, apContext, &commandSender, false);
err =
commandSender.SendCommandRequest(0 /* nodeid */, 0 /* fabricindex */, Optional<SessionHandle>(ctx.GetSessionBobToAlice()));
err = commandSender.SendCommandRequest(ctx.GetSessionBobToAlice());
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

GenerateReceivedCommand(apSuite, apContext, buf, true /*aNeedCommandData*/);
Expand All @@ -340,17 +336,15 @@ void TestCommandInteraction::TestCommandHandlerWithSendEmptyCommand(nlTestSuite
app::CommandHandler commandHandler(&mockCommandHandlerDelegate);
System::PacketBufferHandle commandDatabuf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize);

auto exchangeCtx = ctx.GetExchangeManager().NewContext(SessionHandle(0, 0, 0, 0), nullptr);
commandHandler.mpExchangeCtx = exchangeCtx;

TestExchangeDelegate delegate;
commandHandler.mpExchangeCtx->SetDelegate(&delegate);
err = commandHandler.PrepareCommand(commandPathParams);
commandHandler.mpExchangeCtx = ctx.NewExchangeToAlice(&delegate);
err = commandHandler.PrepareCommand(commandPathParams);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
err = commandHandler.FinishCommand();
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
err = commandHandler.SendCommandResponse();
NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_NOT_CONNECTED);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
commandHandler.Close();
}

void TestCommandInteraction::TestCommandSenderWithProcessReceivedMsg(nlTestSuite * apSuite, void * apContext)
Expand All @@ -374,11 +368,8 @@ void TestCommandInteraction::ValidateCommandHandlerWithSendCommand(nlTestSuite *
app::CommandHandler commandHandler(&mockCommandHandlerDelegate);
System::PacketBufferHandle commandPacket;

auto exchangeCtx = ctx.GetExchangeManager().NewContext(SessionHandle(0, 0, 0, 0), nullptr);

commandHandler.mpExchangeCtx = exchangeCtx;
TestExchangeDelegate delegate;
commandHandler.mpExchangeCtx->SetDelegate(&delegate);
commandHandler.mpExchangeCtx = ctx.NewExchangeToAlice(&delegate);

AddCommandDataIB(apSuite, apContext, &commandHandler, aNeedStatusCode);
err = commandHandler.Finalize(commandPacket);
Expand Down Expand Up @@ -422,9 +413,8 @@ void TestCommandInteraction::TestCommandHandlerCommandDataEncoding(nlTestSuite *
app::CommandHandler commandHandler(nullptr);
System::PacketBufferHandle commandPacket;

commandHandler.mpExchangeCtx = ctx.GetExchangeManager().NewContext(SessionHandle(0, 0, 0, 0), nullptr);
TestExchangeDelegate delegate;
commandHandler.mpExchangeCtx->SetDelegate(&delegate);
commandHandler.mpExchangeCtx = ctx.NewExchangeToAlice(&delegate);

auto path = MakeTestCommandPath();

Expand Down Expand Up @@ -503,7 +493,7 @@ void TestCommandInteraction::TestCommandSenderCommandSuccessResponseFlow(nlTestS
app::CommandSender commandSender(&mockCommandSenderDelegate, &ctx.GetExchangeManager());

AddCommandDataIB(apSuite, apContext, &commandSender, false);
err = commandSender.SendCommandRequest(0, 0, Optional<SessionHandle>(ctx.GetSessionBobToAlice()));
err = commandSender.SendCommandRequest(ctx.GetSessionBobToAlice());
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite,
mockCommandSenderDelegate.onResponseCalledTimes == 1 && mockCommandSenderDelegate.onFinalCalledTimes == 1 &&
Expand All @@ -522,7 +512,7 @@ void TestCommandInteraction::TestCommandSenderCommandSpecificResponseFlow(nlTest
app::CommandSender commandSender(&mockCommandSenderDelegate, &ctx.GetExchangeManager());

AddCommandDataIB(apSuite, apContext, &commandSender, false, kTestCommandIdCommandSpecificResponse);
err = commandSender.SendCommandRequest(0, 0, Optional<SessionHandle>(ctx.GetSessionBobToAlice()));
err = commandSender.SendCommandRequest(ctx.GetSessionBobToAlice());
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite,
mockCommandSenderDelegate.onResponseCalledTimes == 1 && mockCommandSenderDelegate.onFinalCalledTimes == 1 &&
Expand All @@ -541,7 +531,7 @@ void TestCommandInteraction::TestCommandSenderCommandFailureResponseFlow(nlTestS
app::CommandSender commandSender(&mockCommandSenderDelegate, &ctx.GetExchangeManager());

AddCommandDataIB(apSuite, apContext, &commandSender, false, kTestNonExistCommandId);
err = commandSender.SendCommandRequest(0, 0, Optional<SessionHandle>(ctx.GetSessionBobToAlice()));
err = commandSender.SendCommandRequest(ctx.GetSessionBobToAlice());
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(apSuite,
mockCommandSenderDelegate.onResponseCalledTimes == 0 && mockCommandSenderDelegate.onFinalCalledTimes == 1 &&
Expand All @@ -568,7 +558,7 @@ void TestCommandInteraction::TestCommandSenderAbruptDestruction(nlTestSuite * ap
app::CommandSender commandSender(&mockCommandSenderDelegate, &ctx.GetExchangeManager());

AddCommandDataIB(apSuite, apContext, &commandSender, false, kTestCommandIdCommandSpecificResponse);
err = commandSender.SendCommandRequest(0, 0, Optional<SessionHandle>(ctx.GetSessionBobToAlice()));
err = commandSender.SendCommandRequest(ctx.GetSessionBobToAlice());
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

//
Expand Down
11 changes: 3 additions & 8 deletions src/app/tests/TestWriteInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ void TestWriteInteraction::TestWriteClient(nlTestSuite * apSuite, void * apConte
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
AddAttributeDataElement(apSuite, apContext, writeClientHandle);

SessionHandle session = ctx.GetSessionBobToAlice();
err = writeClientHandle.SendWriteRequest(ctx.GetAliceNodeId(), ctx.GetFabricIndex(), Optional<SessionHandle>::Value(session));
err = writeClientHandle.SendWriteRequest(ctx.GetSessionBobToAlice());
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
// The internal WriteClient should be nullptr once we SendWriteRequest.
NL_TEST_ASSERT(apSuite, nullptr == writeClientHandle.mpWriteClient);
Expand Down Expand Up @@ -317,9 +316,7 @@ void TestWriteInteraction::TestWriteRoundtripWithClusterObjects(nlTestSuite * ap

NL_TEST_ASSERT(apSuite, callback.mOnSuccessCalled == 0);

SessionHandle session = ctx.GetSessionBobToAlice();

err = writeClient.SendWriteRequest(ctx.GetAliceNodeId(), ctx.GetFabricIndex(), Optional<SessionHandle>::Value(session));
err = writeClient.SendWriteRequest(ctx.GetSessionBobToAlice());
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

NL_TEST_ASSERT(apSuite, callback.mOnSuccessCalled == 1);
Expand Down Expand Up @@ -370,9 +367,7 @@ void TestWriteInteraction::TestWriteRoundtrip(nlTestSuite * apSuite, void * apCo

NL_TEST_ASSERT(apSuite, callback.mOnSuccessCalled == 0 && callback.mOnErrorCalled == 0 && callback.mOnDoneCalled == 0);

SessionHandle session = ctx.GetSessionBobToAlice();

err = writeClient.SendWriteRequest(ctx.GetAliceNodeId(), ctx.GetFabricIndex(), Optional<SessionHandle>::Value(session));
err = writeClient.SendWriteRequest(ctx.GetSessionBobToAlice());
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

NL_TEST_ASSERT(apSuite, callback.mOnSuccessCalled == 1 && callback.mOnErrorCalled == 0 && callback.mOnDoneCalled == 1);
Expand Down
10 changes: 4 additions & 6 deletions src/app/tests/integration/chip_im_initiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ CHIP_ERROR SendCommandRequest(std::unique_ptr<chip::app::CommandSender> && comma
err = commandSender->FinishCommand();
SuccessOrExit(err);

err = commandSender->SendCommandRequest(chip::kTestDeviceNodeId, gFabricIndex, chip::Optional<chip::SessionHandle>::Missing(),
gMessageTimeout);
err = commandSender->SendCommandRequest(gSessionManager.FindSecureSessionForNode(chip::kTestDeviceNodeId), gMessageTimeout);
SuccessOrExit(err);

gCommandCount++;
Expand Down Expand Up @@ -284,8 +283,7 @@ CHIP_ERROR SendBadCommandRequest(std::unique_ptr<chip::app::CommandSender> && co
err = commandSender->FinishCommand();
SuccessOrExit(err);

err = commandSender->SendCommandRequest(chip::kTestDeviceNodeId, gFabricIndex, chip::Optional<chip::SessionHandle>::Missing(),
gMessageTimeout);
err = commandSender->SendCommandRequest(gSessionManager.FindSecureSessionForNode(chip::kTestDeviceNodeId), gMessageTimeout);
SuccessOrExit(err);
gCommandCount++;
commandSender.release();
Expand Down Expand Up @@ -359,8 +357,8 @@ CHIP_ERROR SendWriteRequest(chip::app::WriteClientHandle & apWriteClient)

SuccessOrExit(err = writer->PutBoolean(chip::TLV::ContextTag(chip::app::AttributeDataElement::kCsTag_Data), true));
SuccessOrExit(err = apWriteClient->FinishAttribute());
SuccessOrExit(err = apWriteClient.SendWriteRequest(chip::kTestDeviceNodeId, gFabricIndex,
chip::Optional<chip::SessionHandle>::Missing(), gMessageTimeout));
SuccessOrExit(
err = apWriteClient.SendWriteRequest(gSessionManager.FindSecureSessionForNode(chip::kTestDeviceNodeId), gMessageTimeout));

gWriteCount++;

Expand Down
10 changes: 8 additions & 2 deletions src/controller/CHIPDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ CHIP_ERROR Device::SendCommands(app::CommandSender * commandObj)
{
bool loadedSecureSession = false;
ReturnErrorOnFailure(LoadSecureSessionParametersIfNeeded(loadedSecureSession));
VerifyOrReturnError(mState == ConnectionState::SecureConnected, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(GetSecureSession().HasValue(), CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(commandObj != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
return commandObj->SendCommandRequest(mDeviceId, mFabricIndex, mSecureSession);
return commandObj->SendCommandRequest(mSecureSession.Value());
}

CHIP_ERROR Device::Serialize(SerializedDevice & output)
Expand Down Expand Up @@ -761,6 +763,8 @@ CHIP_ERROR Device::SendReadAttributeRequest(app::AttributePathParams aPath, Call
aPath.mNodeId = GetDeviceId();

ReturnErrorOnFailure(LoadSecureSessionParametersIfNeeded(loadedSecureSession));
VerifyOrReturnError(mState == ConnectionState::SecureConnected, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(GetSecureSession().HasValue(), CHIP_ERROR_INCORRECT_STATE);

if (onSuccessCallback != nullptr || onFailureCallback != nullptr)
{
Expand Down Expand Up @@ -828,14 +832,16 @@ CHIP_ERROR Device::SendWriteAttributeRequest(app::WriteClientHandle aHandle, Cal
CHIP_ERROR err = CHIP_NO_ERROR;

ReturnErrorOnFailure(LoadSecureSessionParametersIfNeeded(loadedSecureSession));
VerifyOrReturnError(mState == ConnectionState::SecureConnected, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(GetSecureSession().HasValue(), CHIP_ERROR_INCORRECT_STATE);

app::WriteClient * writeClient = aHandle.Get();

if (onSuccessCallback != nullptr || onFailureCallback != nullptr)
{
AddIMResponseHandler(writeClient, onSuccessCallback, onFailureCallback);
}
if ((err = aHandle.SendWriteRequest(GetDeviceId(), 0, mSecureSession)) != CHIP_NO_ERROR)
if ((err = aHandle.SendWriteRequest(mSecureSession.Value())) != CHIP_NO_ERROR)
{
CancelIMResponseHandler(writeClient);
}
Expand Down
3 changes: 1 addition & 2 deletions src/controller/InvokeInteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ CHIP_ERROR InvokeCommandRequest(Messaging::ExchangeManager * aExchangeMgr, Sessi
VerifyOrReturnError(commandSender != nullptr, CHIP_ERROR_NO_MEMORY);

ReturnErrorOnFailure(commandSender->AddRequestData(commandPath, requestCommandData));
ReturnErrorOnFailure(commandSender->SendCommandRequest(sessionHandle.GetPeerNodeId(), sessionHandle.GetFabricIndex(),
Optional<SessionHandle>(sessionHandle)));
ReturnErrorOnFailure(commandSender->SendCommandRequest(sessionHandle));

//
// We've effectively transfered ownership of the above allocated objects to CommandSender, and we need to wait for it to call us
Expand Down
3 changes: 1 addition & 2 deletions src/controller/WriteInteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ CHIP_ERROR WriteAttribute(Messaging::ExchangeManager * aExchangeMgr, SessionHand
ReturnErrorOnFailure(handle.EncodeAttributeWritePayload(
chip::app::AttributePathParams(endpointId, AttributeInfo::GetClusterId(), AttributeInfo::GetAttributeId()),
requestCommandData));
ReturnErrorOnFailure(handle.SendWriteRequest(sessionHandle.GetPeerNodeId(), sessionHandle.GetFabricIndex(),
chip::Optional<chip::SessionHandle>(sessionHandle)));
ReturnErrorOnFailure(handle.SendWriteRequest(sessionHandle));

callback.release();
return CHIP_NO_ERROR;
Expand Down
8 changes: 8 additions & 0 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,4 +592,12 @@ SecureSession * SessionManager::GetSecureSession(SessionHandle session)
}
}

SessionHandle SessionManager::FindSecureSessionForNode(NodeId peerNodeId)
{
SecureSession * session = mPeerConnections.FindSecureSession(peerNodeId, nullptr);
VerifyOrDie(session != nullptr);
return SessionHandle(session->GetPeerNodeId(), session->GetLocalSessionId(), session->GetPeerSessionId(),
session->GetFabricIndex());
}

} // namespace chip
Loading

0 comments on commit 8688153

Please sign in to comment.