Skip to content

Commit

Permalink
Merge 9249355 into b7447ca
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost authored May 13, 2021
2 parents b7447ca + 9249355 commit 1865609
Show file tree
Hide file tree
Showing 42 changed files with 526 additions and 861 deletions.
2 changes: 1 addition & 1 deletion examples/shell/shell_common/cmd_send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ CHIP_ERROR SendMessage(streamer_t * stream)
}

// Create a new exchange context.
gExchangeCtx = gExchangeManager.NewContext({ kTestDeviceNodeId, 0, gAdminId }, &gMockAppDelegate);
gExchangeCtx = gExchangeManager.NewSecureContext({ kTestDeviceNodeId, 0, gAdminId }, &gMockAppDelegate);
VerifyOrExit(gExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY);

size = gSendArguments.GetPayloadSize();
Expand Down
2 changes: 1 addition & 1 deletion src/app/CommandSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CHIP_ERROR CommandSender::SendCommandRequest(NodeId aNodeId, Transport::AdminId
// Create a new exchange context.
// TODO: temprary create a SecureSessionHandle from node id, will be fix in PR 3602
// TODO: Hard code keyID to 0 to unblock IM end-to-end test. Complete solution is tracked in issue:4451
mpExchangeCtx = mpExchangeMgr->NewContext({ aNodeId, 0, aAdminId }, this);
mpExchangeCtx = mpExchangeMgr->NewSecureContext({ aNodeId, 0, aAdminId }, this);
VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY);
mpExchangeCtx->SetResponseTimeout(kImMessageTimeoutMsec);

Expand Down
2 changes: 1 addition & 1 deletion src/app/ReadClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ CHIP_ERROR ReadClient::SendReadRequest(NodeId aNodeId, Transport::AdminId aAdmin
SuccessOrExit(err);
}

mpExchangeCtx = mpExchangeMgr->NewContext({ aNodeId, 0, aAdminId }, this);
mpExchangeCtx = mpExchangeMgr->NewSecureContext({ aNodeId, 0, aAdminId }, this);
VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY);
mpExchangeCtx->SetResponseTimeout(kImMessageTimeoutMsec);

Expand Down
3 changes: 0 additions & 3 deletions src/app/server/RendezvousServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ CHIP_ERROR RendezvousServer::WaitForPairing(const RendezvousParameters & params,
strlen(kSpake2pKeyExchangeSalt), mNextKeyId++, this));
}

ReturnErrorOnFailure(mPairingSession.MessageDispatch().Init(transportMgr));
mPairingSession.MessageDispatch().SetPeerAddress(params.GetPeerAddress());

return CHIP_NO_ERROR;
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/TestCommandInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void TestCommandInteraction::TestCommandHandlerWithSendEmptyCommand(nlTestSuite
err = commandHandler.Init(&chip::gExchangeManager, nullptr);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

commandHandler.mpExchangeCtx = gExchangeManager.NewContext({ 0, 0, 0 }, nullptr);
commandHandler.mpExchangeCtx = gExchangeManager.NewSecureContext({ 0, 0, 0 }, nullptr);

TestExchangeDelegate delegate;
commandHandler.mpExchangeCtx->SetDelegate(&delegate);
Expand Down Expand Up @@ -242,7 +242,7 @@ void TestCommandInteraction::ValidateCommandHandlerWithSendCommand(nlTestSuite *
err = commandHandler.Init(&chip::gExchangeManager, nullptr);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

commandHandler.mpExchangeCtx = gExchangeManager.NewContext({ 0, 0, 0 }, nullptr);
commandHandler.mpExchangeCtx = gExchangeManager.NewSecureContext({ 0, 0, 0 }, nullptr);
TestExchangeDelegate delegate;
commandHandler.mpExchangeCtx->SetDelegate(&delegate);

Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestReportingEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void TestReportingEngine::TestBuildAndSendSingleReportData(nlTestSuite * apSuite

err = InteractionModelEngine::GetInstance()->Init(&gExchangeManager, nullptr);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
Messaging::ExchangeContext * exchangeCtx = gExchangeManager.NewContext({ 0, 0, 0 }, nullptr);
Messaging::ExchangeContext * exchangeCtx = gExchangeManager.NewSecureContext({ 0, 0, 0 }, nullptr);
TestExchangeDelegate delegate;
exchangeCtx->SetDelegate(&delegate);

Expand Down
2 changes: 1 addition & 1 deletion src/app/util/chip-message-send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ EmberStatus chipSendUnicast(NodeId destination, EmberApsFrame * apsFrame, uint16
return EMBER_DELIVERY_FAILED;
}

Messaging::ExchangeContext * exchange = exchangeMgr->NewContext({ destination, Transport::kAnyKeyId, 0 }, nullptr);
Messaging::ExchangeContext * exchange = exchangeMgr->NewSecureContext({ destination, Transport::kAnyKeyId, 0 }, nullptr);
if (exchange == nullptr)
{
return EMBER_DELIVERY_FAILED;
Expand Down
9 changes: 5 additions & 4 deletions src/channel/ChannelContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void ChannelContext::Start(const ChannelBuilder & builder)
ExchangeContext * ChannelContext::NewExchange(ExchangeDelegate * delegate)
{
assert(GetState() == ChannelState::kReady);
return mExchangeManager->NewContext(GetReadyVars().mSession, delegate);
return mExchangeManager->NewSecureContext(GetReadyVars().mSession, delegate);
}

bool ChannelContext::MatchNodeId(NodeId nodeId)
Expand Down Expand Up @@ -258,12 +258,13 @@ void ChannelContext::EnterCasePairingState()
auto & prepare = GetPrepareVars();
prepare.mCasePairingSession = Platform::New<CASESession>();

ExchangeContext * ctxt = mExchangeManager->NewContext(SecureSessionHandle(), prepare.mCasePairingSession);
VerifyOrReturn(ctxt != nullptr);

// TODO: currently only supports IP/UDP paring
Transport::PeerAddress addr;
addr.SetTransportType(Transport::Type::kUdp).SetIPAddress(prepare.mAddress);

ExchangeContext * ctxt = mExchangeManager->NewUnsecureContext(addr, prepare.mCasePairingSession);
VerifyOrReturn(ctxt != nullptr);

CHIP_ERROR err = prepare.mCasePairingSession->EstablishSession(addr, &prepare.mBuilder.GetOperationalCredentialSet(),
prepare.mBuilder.GetPeerNodeId(),
mExchangeManager->GetNextKeyId(), ctxt, this);
Expand Down
2 changes: 1 addition & 1 deletion src/controller/CHIPDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ CHIP_ERROR Device::SendMessage(Protocols::Id protocolId, uint8_t msgType, System

ReturnErrorOnFailure(LoadSecureSessionParametersIfNeeded(loadedSecureSession));

Messaging::ExchangeContext * exchange = mExchangeMgr->NewContext(mSecureSession, nullptr);
Messaging::ExchangeContext * exchange = mExchangeMgr->NewSecureContext(mSecureSession, nullptr);
VerifyOrReturnError(exchange != nullptr, CHIP_ERROR_NO_MEMORY);

if (!loadedSecureSession)
Expand Down
6 changes: 1 addition & 5 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,6 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam

mIsIPRendezvous = (params.GetPeerAddress().GetTransportType() != Transport::Type::kBle);

err = mPairingSession.MessageDispatch().Init(mTransportMgr);
SuccessOrExit(err);
mPairingSession.MessageDispatch().SetPeerAddress(params.GetPeerAddress());

device->Init(GetControllerDeviceInitParams(), mListenPort, remoteDeviceId, peerAddress, admin->GetAdminId());

mSystemLayer->StartTimer(kSessionEstablishmentTimeout, OnSessionEstablishmentTimeoutCallback, this);
Expand All @@ -825,7 +821,7 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam
}
}
#endif
exchangeCtxt = mExchangeMgr->NewContext(SecureSessionHandle(), &mPairingSession);
exchangeCtxt = mExchangeMgr->NewUnsecureContext(params.GetPeerAddress(), &mPairingSession);
VerifyOrExit(exchangeCtxt != nullptr, err = CHIP_ERROR_INTERNAL);

err = mPairingSession.Pair(params.GetPeerAddress(), params.GetSetupPINCode(), mNextKeyId++, exchangeCtxt, this);
Expand Down
74 changes: 0 additions & 74 deletions src/messaging/ApplicationExchangeDispatch.cpp

This file was deleted.

64 changes: 0 additions & 64 deletions src/messaging/ApplicationExchangeDispatch.h

This file was deleted.

4 changes: 0 additions & 4 deletions src/messaging/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ static_library("messaging") {
output_name = "libMessagingLayer"

sources = [
"ApplicationExchangeDispatch.cpp",
"ApplicationExchangeDispatch.h",
"ErrorCategory.cpp",
"ErrorCategory.h",
"ExchangeACL.h",
"ExchangeContext.cpp",
"ExchangeContext.h",
"ExchangeDelegate.h",
"ExchangeMessageDispatch.cpp",
"ExchangeMessageDispatch.h",
"ExchangeMgr.cpp",
"ExchangeMgr.h",
"ExchangeMgrDelegate.h",
Expand Down
Loading

0 comments on commit 1865609

Please sign in to comment.