Skip to content

Commit

Permalink
removed MessagePermitted bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Feb 2, 2022
1 parent 2a6dc3e commit 1626ecb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,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(), IsGroupExchangeContext()));

if (IsAckPending() && !mDelegate)
{
Expand Down
4 changes: 2 additions & 2 deletions src/messaging/ExchangeMessageDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ CHIP_ERROR ExchangeMessageDispatch::SendMessage(SessionManager * sessionManager,

CHIP_ERROR ExchangeMessageDispatch::OnMessageReceived(uint32_t messageCounter, const PayloadHeader & payloadHeader,
const Transport::PeerAddress & peerAddress, MessageFlags msgFlags,
ReliableMessageContext * reliableMessageContext)
ReliableMessageContext * reliableMessageContext, bool isGroupMessage)
{
ReturnErrorCodeIf(!MessagePermitted(payloadHeader.GetProtocolID().GetProtocolId(), payloadHeader.GetMessageType()),
CHIP_ERROR_INVALID_ARGUMENT);

if (IsReliableTransmissionAllowed())
if (IsReliableTransmissionAllowed() && !isGroupMessage)
{
if (!msgFlags.Has(MessageFlagValues::kDuplicateMessage) && payloadHeader.IsAckMsg() &&
payloadHeader.GetAckMessageCounter().HasValue())
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/ExchangeMessageDispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ExchangeMessageDispatch
uint8_t type, System::PacketBufferHandle && message);
CHIP_ERROR OnMessageReceived(uint32_t messageCounter, const PayloadHeader & payloadHeader,
const Transport::PeerAddress & peerAddress, MessageFlags msgFlags,
ReliableMessageContext * reliableMessageContext);
ReliableMessageContext * reliableMessageContext, bool isGroupMessage);

protected:
virtual bool MessagePermitted(uint16_t protocol, uint8_t type) = 0;
Expand Down
1 change: 0 additions & 1 deletion src/messaging/tests/TestReliableMessageProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,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)
// {
Expand Down Expand Up @@ -618,6 +620,7 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & packetHeade
if (mCB != nullptr)
{
// TODO : remove hard coded fabric index once GroupDataProvider->Decrypt is implemented
// TODO : When MCSP is done, clean up session creation logique
Optional<SessionHandle> session = CreateGroupSession(packetHeader.GetDestinationGroupId().Value(), 1);

VerifyOrReturn(session.HasValue(), ChipLogError(Inet, "Error when creating group session handle."));
Expand Down

0 comments on commit 1626ecb

Please sign in to comment.