Skip to content

Commit

Permalink
Merge 82232a7 into 5a0fa3d
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google authored Feb 12, 2021
2 parents 5a0fa3d + 82232a7 commit 1012601
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/app/CommandSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace chip {
namespace app {

CHIP_ERROR CommandSender::SendCommandRequest(NodeId aNodeId)
CHIP_ERROR CommandSender::SendCommandRequest(NodeId aNodeId, Transport::AdminId aAdminId)
{
CHIP_ERROR err = CHIP_NO_ERROR;

Expand All @@ -42,7 +42,7 @@ CHIP_ERROR CommandSender::SendCommandRequest(NodeId aNodeId)
// 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 }, this);
mpExchangeCtx = mpExchangeMgr->NewContext({ aNodeId, 0, aAdminId }, this);
VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY);
mpExchangeCtx->SetResponseTimeout(CHIP_INVOKE_COMMAND_RSP_TIMEOUT);

Expand Down
2 changes: 1 addition & 1 deletion src/app/CommandSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace app {
class DLL_EXPORT DLL_EXPORT CommandSender : public Command, public Messaging::ExchangeDelegate
{
public:
CHIP_ERROR SendCommandRequest(NodeId aNodeId);
CHIP_ERROR SendCommandRequest(NodeId aNodeId, Transport::AdminId aAdminId);

void OnMessageReceived(Messaging::ExchangeContext * apEc, const PacketHeader & aPacketHeader,
const PayloadHeader & aPayloadHeader, System::PacketBufferHandle aPayload) override;
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/integration/chip_im_initiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ CHIP_ERROR SendCommandRequest(void)
err = gpCommandSender->AddCommand(CommandParams);
SuccessOrExit(err);

err = gpCommandSender->SendCommandRequest(chip::kTestDeviceNodeId);
err = gpCommandSender->SendCommandRequest(chip::kTestDeviceNodeId, gAdminId);
SuccessOrExit(err);

if (err == CHIP_NO_ERROR)
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 @@ -75,7 +75,7 @@ EmberStatus chipSendUnicast(NodeId destination, EmberApsFrame * apsFrame, uint16
buffer->SetDataLength(dataLength);

// TODO: temprary create a handle from node id, will be fix in PR 3602
CHIP_ERROR err = SessionManager().SendMessage({ destination, Transport::kAnyKeyId }, std::move(buffer));
CHIP_ERROR err = SessionManager().SendMessage({ destination, Transport::kAnyKeyId, 0}, std::move(buffer));
if (err != CHIP_NO_ERROR)
{
// FIXME: Figure out better translations between our error types?
Expand Down
2 changes: 1 addition & 1 deletion src/controller/CHIPDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ CHIP_ERROR Device::SendCommands()
bool loadedSecureSession = false;
ReturnErrorOnFailure(LoadSecureSessionParametersIfNeeded(loadedSecureSession));
VerifyOrReturnError(mCommandSender != nullptr, CHIP_ERROR_INCORRECT_STATE);
return mCommandSender->SendCommandRequest(mDeviceId);
return mCommandSender->SendCommandRequest(mDeviceId, mAdminId);
}

CHIP_ERROR Device::SendMessage(System::PacketBufferHandle buffer)
Expand Down
4 changes: 2 additions & 2 deletions src/messaging/tests/MessagingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ CHIP_ERROR MessagingContext::Shutdown()
Messaging::ExchangeContext * MessagingContext::NewExchangeToPeer(Messaging::ExchangeDelegate * delegate)
{
// TODO: temprary create a SecureSessionHandle from node id, will be fix in PR 3602
return mExchangeManager.NewContext({ GetDestinationNodeId(), GetPeerKeyId() }, delegate);
return mExchangeManager.NewContext({ GetDestinationNodeId(), GetPeerKeyId(), GetAdminId() }, delegate);
}

Messaging::ExchangeContext * MessagingContext::NewExchangeToLocal(Messaging::ExchangeDelegate * delegate)
{
// TODO: temprary create a SecureSessionHandle from node id, will be fix in PR 3602
return mExchangeManager.NewContext({ GetSourceNodeId(), GetLocalKeyId() }, delegate);
return mExchangeManager.NewContext({ GetSourceNodeId(), GetLocalKeyId(), GetAdminId() }, delegate);
}

} // namespace Test
Expand Down
1 change: 1 addition & 0 deletions src/messaging/tests/MessagingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class MessagingContext : public IOContext

static constexpr uint16_t GetLocalKeyId() { return 1; }
static constexpr uint16_t GetPeerKeyId() { return 2; }
static constexpr uint16_t GetAdminId() { return 0; }

SecureSessionMgr & GetSecureSessionManager() { return mSecureSessionMgr; }
Messaging::ExchangeManager & GetExchangeManager() { return mExchangeManager; }
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/tests/echo/echo_requester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ int main(int argc, char * argv[])
SuccessOrExit(err);

// TODO: temprary create a SecureSessionHandle from node id to unblock end-to-end test. Complete solution is tracked in PR:4451
err = gEchoClient.Init(&gExchangeManager, { chip::kTestDeviceNodeId, 0 });
err = gEchoClient.Init(&gExchangeManager, { chip::kTestDeviceNodeId, 0, gAdminId });
SuccessOrExit(err);

// Arrange to get a callback whenever an Echo Response is received.
Expand Down
3 changes: 2 additions & 1 deletion src/transport/RendezvousSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ void RendezvousSession::InitPairingSessionHandle()
{
ReleasePairingSessionHandle();
mPairingSessionHandle = chip::Platform::New<SecureSessionHandle>(mPairingSession.PeerConnection().GetPeerNodeId(),
mPairingSession.PeerConnection().GetPeerKeyID());
mPairingSession.PeerConnection().GetPeerKeyID(),
mPairingSession.PeerConnection().GetAdminId());
}

void RendezvousSession::ReleasePairingSessionHandle()
Expand Down
2 changes: 1 addition & 1 deletion src/transport/SecureSessionMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void SecureSessionMgr::HandleConnectionExpired(const Transport::PeerConnectionSt

if (mCB != nullptr)
{
mCB->OnConnectionExpired({ state.GetPeerNodeId(), state.GetPeerKeyID() }, this);
mCB->OnConnectionExpired({ state.GetPeerNodeId(), state.GetPeerKeyID(), state.GetAdminId() }, this);
}

mTransportMgr->Disconnect(state.GetPeerAddress());
Expand Down
1 change: 0 additions & 1 deletion src/transport/SecureSessionMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class SecureSessionHandle
{
public:
SecureSessionHandle() : mPeerNodeId(kAnyNodeId), mPeerKeyId(0), mAdmin(Transport::kUndefinedAdminId) {}
SecureSessionHandle(NodeId peerNodeId, uint16_t peerKeyId) : mPeerNodeId(peerNodeId), mPeerKeyId(peerKeyId) {}
SecureSessionHandle(NodeId peerNodeId, uint16_t peerKeyId, Transport::AdminId admin) :
mPeerNodeId(peerNodeId), mPeerKeyId(peerKeyId), mAdmin(admin)
{}
Expand Down

0 comments on commit 1012601

Please sign in to comment.