From 520366715393653253e8467cd736fc62156398b3 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Fri, 17 Nov 2023 12:43:12 -0500 Subject: [PATCH] Allow plumbing of `SessionParameters` from `Session` (#30525) * Change plumbing from remoteMRP to remoteSessionParameters * Restyled by clang-format * Update test to use SetRemoteSessionParameters * Minor fix --------- Co-authored-by: Restyled.io --- src/messaging/tests/MessagingContext.cpp | 16 ++--- .../tests/TestAbortExchangesForFabric.cpp | 4 +- .../tests/TestReliableMessageProtocol.cpp | 64 +++++++++---------- src/protocols/secure_channel/CASESession.cpp | 6 +- src/protocols/secure_channel/PASESession.cpp | 6 +- .../secure_channel/PairingSession.cpp | 2 +- src/protocols/secure_channel/PairingSession.h | 1 + .../secure_channel/tests/TestPASESession.cpp | 22 ++++--- src/transport/GroupSession.h | 8 +-- src/transport/SecureSession.cpp | 12 ++-- src/transport/SecureSession.h | 18 +++--- src/transport/Session.h | 17 +++-- src/transport/UnauthenticatedSessionTable.h | 16 +++-- 13 files changed, 101 insertions(+), 91 deletions(-) diff --git a/src/messaging/tests/MessagingContext.cpp b/src/messaging/tests/MessagingContext.cpp index a7cf5369cccef1..3073d7490c8280 100644 --- a/src/messaging/tests/MessagingContext.cpp +++ b/src/messaging/tests/MessagingContext.cpp @@ -105,10 +105,10 @@ void MessagingContext::SetMRPMode(MRPMode mode) { if (mode == MRPMode::kDefault) { - mSessionBobToAlice->AsSecureSession()->SetRemoteMRPConfig(GetDefaultMRPConfig()); - mSessionAliceToBob->AsSecureSession()->SetRemoteMRPConfig(GetDefaultMRPConfig()); - mSessionCharlieToDavid->AsSecureSession()->SetRemoteMRPConfig(GetDefaultMRPConfig()); - mSessionDavidToCharlie->AsSecureSession()->SetRemoteMRPConfig(GetDefaultMRPConfig()); + mSessionBobToAlice->AsSecureSession()->SetRemoteSessionParameters(GetDefaultMRPConfig()); + mSessionAliceToBob->AsSecureSession()->SetRemoteSessionParameters(GetDefaultMRPConfig()); + mSessionCharlieToDavid->AsSecureSession()->SetRemoteSessionParameters(GetDefaultMRPConfig()); + mSessionDavidToCharlie->AsSecureSession()->SetRemoteSessionParameters(GetDefaultMRPConfig()); #if CONFIG_BUILD_FOR_HOST_UNIT_TEST ClearLocalMRPConfigOverride(); @@ -132,13 +132,13 @@ void MessagingContext::SetMRPMode(MRPMode mode) VerifyOrDie(false); #endif - mSessionBobToAlice->AsSecureSession()->SetRemoteMRPConfig(ReliableMessageProtocolConfig( + mSessionBobToAlice->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig( MessagingContext::kResponsiveIdleRetransTimeout, MessagingContext::kResponsiveActiveRetransTimeout)); - mSessionAliceToBob->AsSecureSession()->SetRemoteMRPConfig(ReliableMessageProtocolConfig( + mSessionAliceToBob->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig( MessagingContext::kResponsiveIdleRetransTimeout, MessagingContext::kResponsiveActiveRetransTimeout)); - mSessionCharlieToDavid->AsSecureSession()->SetRemoteMRPConfig(ReliableMessageProtocolConfig( + mSessionCharlieToDavid->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig( MessagingContext::kResponsiveIdleRetransTimeout, MessagingContext::kResponsiveActiveRetransTimeout)); - mSessionDavidToCharlie->AsSecureSession()->SetRemoteMRPConfig(ReliableMessageProtocolConfig( + mSessionDavidToCharlie->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig( MessagingContext::kResponsiveIdleRetransTimeout, MessagingContext::kResponsiveActiveRetransTimeout)); } } diff --git a/src/messaging/tests/TestAbortExchangesForFabric.cpp b/src/messaging/tests/TestAbortExchangesForFabric.cpp index 257f95bfb76ade..5bf92fb69b30d7 100644 --- a/src/messaging/tests/TestAbortExchangesForFabric.cpp +++ b/src/messaging/tests/TestAbortExchangesForFabric.cpp @@ -163,10 +163,10 @@ void CommonCheckAbortAllButOneExchange(nlTestSuite * inSuite, TestContext & ctx, const auto & sessionHandle1 = session1.Get(); const auto & sessionHandle2 = session2.Get(); - session1->AsSecureSession()->SetRemoteMRPConfig(ReliableMessageProtocolConfig( + session1->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig( Test::MessagingContext::kResponsiveIdleRetransTimeout, Test::MessagingContext::kResponsiveActiveRetransTimeout)); - session1Reply->AsSecureSession()->SetRemoteMRPConfig(ReliableMessageProtocolConfig( + session1Reply->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig( Test::MessagingContext::kResponsiveIdleRetransTimeout, Test::MessagingContext::kResponsiveActiveRetransTimeout)); NL_TEST_ASSERT(inSuite, session1); diff --git a/src/messaging/tests/TestReliableMessageProtocol.cpp b/src/messaging/tests/TestReliableMessageProtocol.cpp index 6d4e53ecbca962..6ef5f796abc25d 100644 --- a/src/messaging/tests/TestReliableMessageProtocol.cpp +++ b/src/messaging/tests/TestReliableMessageProtocol.cpp @@ -395,10 +395,10 @@ void TestReliableMessageProtocol::CheckResendApplicationMessage(nlTestSuite * in ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ System::Clock::Timestamp(300), // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL System::Clock::Timestamp(300), // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); // Let's drop the initial message auto & loopback = ctx.GetLoopback(); @@ -508,10 +508,10 @@ void TestReliableMessageProtocol::CheckCloseExchangeAndResendApplicationMessage( ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 64_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 64_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); // Let's drop the initial message auto & loopback = ctx.GetLoopback(); @@ -567,10 +567,10 @@ void TestReliableMessageProtocol::CheckFailedMessageRetainOnSend(nlTestSuite * i ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 64_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 64_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); mockSender.mMessageDispatch.mRetainMessageOnSend = false; // Let's drop the initial message @@ -657,10 +657,10 @@ void TestReliableMessageProtocol::CheckResendApplicationMessageWithPeerExchange( ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 64_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 64_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); // Let's drop the initial message auto & loopback = ctx.GetLoopback(); @@ -719,10 +719,10 @@ void TestReliableMessageProtocol::CheckDuplicateMessageClosedExchange(nlTestSuit ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 64_ms32, // CHIP_CONFIG_RMP_DEFAULT_INITIAL_RETRY_INTERVAL 64_ms32, // CHIP_CONFIG_RMP_DEFAULT_ACTIVE_RETRY_INTERVAL - }); + })); // Let's not drop the message. Expectation is that it is received by the peer, but the ack is dropped auto & loopback = ctx.GetLoopback(); @@ -786,10 +786,10 @@ void TestReliableMessageProtocol::CheckDuplicateOldMessageClosedExchange(nlTestS ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 64_ms32, // CHIP_CONFIG_RMP_DEFAULT_INITIAL_RETRY_INTERVAL 64_ms32, // CHIP_CONFIG_RMP_DEFAULT_ACTIVE_RETRY_INTERVAL - }); + })); // Let's not drop the message. Expectation is that it is received by the peer, but the ack is dropped auto & loopback = ctx.GetLoopback(); @@ -887,10 +887,10 @@ void TestReliableMessageProtocol::CheckResendSessionEstablishmentMessageWithPeer ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 64_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 64_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); // Let's drop the initial message auto & loopback = inctx.GetLoopback(); @@ -951,10 +951,10 @@ void TestReliableMessageProtocol::CheckDuplicateMessage(nlTestSuite * inSuite, v ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 64_ms32, // CHIP_CONFIG_RMP_DEFAULT_INITIAL_RETRY_INTERVAL 64_ms32, // CHIP_CONFIG_RMP_DEFAULT_ACTIVE_RETRY_INTERVAL - }); + })); // Let's not drop the message. Expectation is that it is received by the peer, but the ack is dropped auto & loopback = ctx.GetLoopback(); @@ -1453,10 +1453,10 @@ void TestReliableMessageProtocol::CheckLostResponseWithPiggyback(nlTestSuite * i NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 0); // Make sure that we resend our message before the other side does. - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 64_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 64_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); // We send a message, the other side sends an application-level response // (which is lost), then we do a retransmit that is acked, then the other @@ -1491,10 +1491,10 @@ void TestReliableMessageProtocol::CheckLostResponseWithPiggyback(nlTestSuite * i // Make sure receiver resends after sender does, and there's enough of a gap // that we are very unlikely to actually trigger the resends on the receiver // when we trigger the resends on the sender. - mockReceiver.mExchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + mockReceiver.mExchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 256_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 256_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); // Now send a message from the other side, but drop it. loopback.mNumMessagesToDrop = 1; @@ -1601,10 +1601,10 @@ void TestReliableMessageProtocol::CheckIsPeerActiveNotInitiator(nlTestSuite * in mockSender.mTestSuite = inSuite; - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 1000_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 1000_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); @@ -1655,10 +1655,10 @@ void TestReliableMessageProtocol::CheckIsPeerActiveNotInitiator(nlTestSuite * in NL_TEST_ASSERT(inSuite, !exchange->HasReceivedAtLeastOneMessage()); NL_TEST_ASSERT(inSuite, mockReceiver.mExchange->HasReceivedAtLeastOneMessage()); - mockReceiver.mExchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + mockReceiver.mExchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 1000_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 100_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); mockReceiver.mRetainExchange = false; mockSender.mRetainExchange = false; @@ -1870,10 +1870,10 @@ void TestReliableMessageProtocol::CheckApplicationResponseDelayed(nlTestSuite * ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 30_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 30_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); constexpr uint32_t kMaxMRPTransmits = 5; // Counting the initial message. @@ -1932,10 +1932,10 @@ void TestReliableMessageProtocol::CheckApplicationResponseDelayed(nlTestSuite * loopback.mNumMessagesToDrop = kMaxMRPTransmits - 1; loopback.mDroppedMessageCount = 0; - mockReceiver.mExchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + mockReceiver.mExchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 30_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 30_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD)); NL_TEST_ASSERT(inSuite, !buffer.IsNull()); @@ -2032,10 +2032,10 @@ void TestReliableMessageProtocol::CheckApplicationResponseNeverComes(nlTestSuite ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); NL_TEST_ASSERT(inSuite, rm != nullptr); - exchange->GetSessionHandle()->AsSecureSession()->SetRemoteMRPConfig({ + exchange->GetSessionHandle()->AsSecureSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 30_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 30_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); constexpr uint32_t kMaxMRPTransmits = 5; // Counting the initial message. @@ -2133,8 +2133,8 @@ void TestReliableMessageProtocol::CheckApplicationResponseNeverComes(nlTestSuite int TestReliableMessageProtocol::InitializeTestCase(void * inContext) { TestContext & ctx = *static_cast(inContext); - ctx.GetSessionAliceToBob()->AsSecureSession()->SetRemoteMRPConfig(GetLocalMRPConfig().ValueOr(GetDefaultMRPConfig())); - ctx.GetSessionBobToAlice()->AsSecureSession()->SetRemoteMRPConfig(GetLocalMRPConfig().ValueOr(GetDefaultMRPConfig())); + ctx.GetSessionAliceToBob()->AsSecureSession()->SetRemoteSessionParameters(GetLocalMRPConfig().ValueOr(GetDefaultMRPConfig())); + ctx.GetSessionBobToAlice()->AsSecureSession()->SetRemoteSessionParameters(GetLocalMRPConfig().ValueOr(GetDefaultMRPConfig())); return SUCCESS; } diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index 57375646a202b2..6e51d000e3822c 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -1135,7 +1135,7 @@ CHIP_ERROR CASESession::HandleSigma2Resume(System::PacketBufferHandle && msg) if (tlvReader.Next() != CHIP_END_OF_TLV) { SuccessOrExit(err = DecodeMRPParametersIfPresent(TLV::ContextTag(4), tlvReader)); - mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig(GetRemoteMRPConfig()); + mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters(GetRemoteSessionParameters()); } ChipLogDetail(SecureChannel, "Peer assigned session session ID %d", responderSessionId); @@ -1328,7 +1328,7 @@ CHIP_ERROR CASESession::HandleSigma2(System::PacketBufferHandle && msg) if (tlvReader.Next() != CHIP_END_OF_TLV) { SuccessOrExit(err = DecodeMRPParametersIfPresent(TLV::ContextTag(kTag_Sigma2_ResponderMRPParams), tlvReader)); - mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig(GetRemoteMRPConfig()); + mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters(GetRemoteSessionParameters()); } exit: @@ -2017,7 +2017,7 @@ CHIP_ERROR CASESession::ParseSigma1(TLV::ContiguousBufferTLVReader & tlvReader, if (err == CHIP_NO_ERROR && tlvReader.GetTag() == ContextTag(kInitiatorMRPParamsTag)) { ReturnErrorOnFailure(DecodeMRPParametersIfPresent(TLV::ContextTag(kInitiatorMRPParamsTag), tlvReader)); - mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig(GetRemoteMRPConfig()); + mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters(GetRemoteSessionParameters()); err = tlvReader.Next(); } diff --git a/src/protocols/secure_channel/PASESession.cpp b/src/protocols/secure_channel/PASESession.cpp index 8e2f27f176cfca..28979dc69e021d 100644 --- a/src/protocols/secure_channel/PASESession.cpp +++ b/src/protocols/secure_channel/PASESession.cpp @@ -355,7 +355,7 @@ CHIP_ERROR PASESession::HandlePBKDFParamRequest(System::PacketBufferHandle && ms if (tlvReader.Next() != CHIP_END_OF_TLV) { SuccessOrExit(err = DecodeMRPParametersIfPresent(TLV::ContextTag(5), tlvReader)); - mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig(GetRemoteMRPConfig()); + mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters(GetRemoteSessionParameters()); } err = SendPBKDFParamResponse(ByteSpan(initiatorRandom), hasPBKDFParameters); @@ -474,7 +474,7 @@ CHIP_ERROR PASESession::HandlePBKDFParamResponse(System::PacketBufferHandle && m if (tlvReader.Next() != CHIP_END_OF_TLV) { SuccessOrExit(err = DecodeMRPParametersIfPresent(TLV::ContextTag(5), tlvReader)); - mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig(GetRemoteMRPConfig()); + mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters(GetRemoteSessionParameters()); } // TODO - Add a unit test that exercises mHavePBKDFParameters path @@ -499,7 +499,7 @@ CHIP_ERROR PASESession::HandlePBKDFParamResponse(System::PacketBufferHandle && m if (tlvReader.Next() != CHIP_END_OF_TLV) { SuccessOrExit(err = DecodeMRPParametersIfPresent(TLV::ContextTag(5), tlvReader)); - mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig(GetRemoteMRPConfig()); + mExchangeCtxt->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters(GetRemoteSessionParameters()); } } diff --git a/src/protocols/secure_channel/PairingSession.cpp b/src/protocols/secure_channel/PairingSession.cpp index d3c6e96c1ef8bd..63a1701e66541f 100644 --- a/src/protocols/secure_channel/PairingSession.cpp +++ b/src/protocols/secure_channel/PairingSession.cpp @@ -48,7 +48,7 @@ CHIP_ERROR PairingSession::ActivateSecureSession(const Transport::PeerAddress & // Call Activate last, otherwise errors on anything after would lead to // a partially valid session. - secureSession->Activate(GetLocalScopedNodeId(), GetPeer(), GetPeerCATs(), peerSessionId, GetRemoteMRPConfig()); + secureSession->Activate(GetLocalScopedNodeId(), GetPeer(), GetPeerCATs(), peerSessionId, GetRemoteSessionParameters()); ChipLogDetail(Inet, "New secure session activated for device " ChipLogFormatScopedNodeId ", LSID:%d PSID:%d!", ChipLogValueScopedNodeId(GetPeer()), secureSession->GetLocalSessionId(), peerSessionId); diff --git a/src/protocols/secure_channel/PairingSession.h b/src/protocols/secure_channel/PairingSession.h index 039705efa16745..844fa33a41ae68 100644 --- a/src/protocols/secure_channel/PairingSession.h +++ b/src/protocols/secure_channel/PairingSession.h @@ -98,6 +98,7 @@ class DLL_EXPORT PairingSession : public SessionDelegate virtual CHIP_ERROR DeriveSecureSession(CryptoContext & session) const = 0; const ReliableMessageProtocolConfig & GetRemoteMRPConfig() const { return mRemoteSessionParams.GetMRPConfig(); } + const SessionParameters & GetRemoteSessionParameters() const { return mRemoteSessionParams; } void SetRemoteMRPConfig(const ReliableMessageProtocolConfig & config) { mRemoteSessionParams.SetMRPConfig(config); } /** diff --git a/src/protocols/secure_channel/tests/TestPASESession.cpp b/src/protocols/secure_channel/tests/TestPASESession.cpp index 96035793dc0fd7..b22a899f7225d0 100644 --- a/src/protocols/secure_channel/tests/TestPASESession.cpp +++ b/src/protocols/secure_channel/tests/TestPASESession.cpp @@ -259,15 +259,17 @@ void SecurePairingHandshakeTestCommon(nlTestSuite * inSuite, void * inContext, S // Adding an if-else to avoid affecting non-ICD tests #if CHIP_CONFIG_ENABLE_ICD_SERVER == 1 // Increase local MRP retry intervals to take into account the increase response delay from an ICD - contextCommissioner->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig({ - 1000_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL - 1000_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + contextCommissioner->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters( + ReliableMessageProtocolConfig({ + 1000_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL + 1000_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL + })); #else // CHIP_CONFIG_ENABLE_ICD_SERVER != 1 - contextCommissioner->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig({ - 64_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL - 64_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + contextCommissioner->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters( + ReliableMessageProtocolConfig({ + 64_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL + 64_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL + })); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER } @@ -455,10 +457,10 @@ void SecurePairingFailedHandshake(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, rm != nullptr); NL_TEST_ASSERT(inSuite, rc != nullptr); - contextCommissioner->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteMRPConfig({ + contextCommissioner->GetSessionHandle()->AsUnauthenticatedSession()->SetRemoteSessionParameters(ReliableMessageProtocolConfig({ 64_ms32, // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL 64_ms32, // CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL - }); + })); NL_TEST_ASSERT(inSuite, ctx.GetExchangeManager().RegisterUnsolicitedMessageHandlerForType( diff --git a/src/transport/GroupSession.h b/src/transport/GroupSession.h index bd3ab1931c2c7c..608bc78891b0e0 100644 --- a/src/transport/GroupSession.h +++ b/src/transport/GroupSession.h @@ -59,9 +59,9 @@ class IncomingGroupSession : public Session, public ReferenceCounted #include #include +#include #include namespace chip { @@ -191,13 +192,15 @@ class Session virtual bool IsActiveSession() const = 0; - virtual ScopedNodeId GetPeer() const = 0; - virtual ScopedNodeId GetLocalScopedNodeId() const = 0; - virtual Access::SubjectDescriptor GetSubjectDescriptor() const = 0; - virtual bool RequireMRP() const = 0; - virtual const ReliableMessageProtocolConfig & GetRemoteMRPConfig() const = 0; - virtual System::Clock::Timestamp GetMRPBaseTimeout() const = 0; - virtual System::Clock::Milliseconds32 GetAckTimeout() const = 0; + virtual ScopedNodeId GetPeer() const = 0; + virtual ScopedNodeId GetLocalScopedNodeId() const = 0; + virtual Access::SubjectDescriptor GetSubjectDescriptor() const = 0; + virtual bool RequireMRP() const = 0; + virtual const SessionParameters & GetRemoteSessionParameters() const = 0; + virtual System::Clock::Timestamp GetMRPBaseTimeout() const = 0; + virtual System::Clock::Milliseconds32 GetAckTimeout() const = 0; + + const ReliableMessageProtocolConfig & GetRemoteMRPConfig() const { return GetRemoteSessionParameters().GetMRPConfig(); } // Returns a suggested timeout value based on the round-trip time it takes for the peer at the other end of the session to // receive a message, process it and send it back. This is computed based on the session type, the type of transport, sleepy diff --git a/src/transport/UnauthenticatedSessionTable.h b/src/transport/UnauthenticatedSessionTable.h index 1a698db312d52e..9b6d3e30e4f9fb 100644 --- a/src/transport/UnauthenticatedSessionTable.h +++ b/src/transport/UnauthenticatedSessionTable.h @@ -49,7 +49,7 @@ class UnauthenticatedSession : public Session, public ReferenceCounted