From 81ccfcfe6e8f3c01eb9e92b72f10950f0eb81406 Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Fri, 4 Feb 2022 09:11:59 -0500 Subject: [PATCH] [Group] Remove MessagePermitted bypass for group message (#14717) * removed MessagePermitted bypass * PR comments --- src/messaging/ExchangeContext.cpp | 8 ++------ src/messaging/ExchangeMessageDispatch.cpp | 2 +- src/messaging/tests/TestReliableMessageProtocol.cpp | 1 - src/transport/SessionManager.cpp | 3 +++ 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/messaging/ExchangeContext.cpp b/src/messaging/ExchangeContext.cpp index 1bcc0579e621d3..25ab5cc1bbc165 100644 --- a/src/messaging/ExchangeContext.cpp +++ b/src/messaging/ExchangeContext.cpp @@ -448,12 +448,8 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload MessageHandled(); }); - // TODO : Remove this bypass for group as to perform the MessagePermitted function Issue # 12101 - if (!IsGroupExchangeContext()) - { - ReturnErrorOnFailure( - mDispatch.OnMessageReceived(messageCounter, payloadHeader, peerAddress, msgFlags, GetReliableMessageContext())); - } + ReturnErrorOnFailure( + mDispatch.OnMessageReceived(messageCounter, payloadHeader, peerAddress, msgFlags, GetReliableMessageContext())); if (IsAckPending() && !mDelegate) { diff --git a/src/messaging/ExchangeMessageDispatch.cpp b/src/messaging/ExchangeMessageDispatch.cpp index 7eb4bc7ad4076a..7ca2e5b59901c9 100644 --- a/src/messaging/ExchangeMessageDispatch.cpp +++ b/src/messaging/ExchangeMessageDispatch.cpp @@ -120,7 +120,7 @@ CHIP_ERROR ExchangeMessageDispatch::OnMessageReceived(uint32_t messageCounter, c ReturnErrorCodeIf(!MessagePermitted(payloadHeader.GetProtocolID().GetProtocolId(), payloadHeader.GetMessageType()), CHIP_ERROR_INVALID_ARGUMENT); - if (IsReliableTransmissionAllowed()) + if (IsReliableTransmissionAllowed() && !reliableMessageContext->GetExchangeContext()->IsGroupExchangeContext()) { if (!msgFlags.Has(MessageFlagValues::kDuplicateMessage) && payloadHeader.IsAckMsg() && payloadHeader.GetAckMessageCounter().HasValue()) diff --git a/src/messaging/tests/TestReliableMessageProtocol.cpp b/src/messaging/tests/TestReliableMessageProtocol.cpp index 6941514d5db33f..06cad50c24efca 100644 --- a/src/messaging/tests/TestReliableMessageProtocol.cpp +++ b/src/messaging/tests/TestReliableMessageProtocol.cpp @@ -330,7 +330,6 @@ void CheckFailedMessageRetainOnSend(nlTestSuite * inSuite, void * inContext) }); mockSender.mMessageDispatch.mRetainMessageOnSend = false; - // Let's drop the initial message gLoopback.mSentMessageCount = 0; gLoopback.mNumMessagesToDrop = 1; diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index 518cc1ebbc9ddc..07684077880c93 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -604,6 +604,8 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & packetHeade // MCSP check if (packetHeader.IsValidMCSPMsg()) { + // TODO: When MCSP Msg, create Secure Session instead of a Group session + // TODO // if (packetHeader.GetDestinationNodeId().Value() == ThisDeviceNodeID) // { @@ -638,6 +640,7 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & packetHeade if (mCB != nullptr) { + // TODO : When MCSP is done, clean up session creation logique Optional session = CreateGroupSession(groupContext.group_id, groupContext.fabric_index); VerifyOrReturn(session.HasValue(), ChipLogError(Inet, "Error when creating group session handle."));