Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove address argument on ExchangeManager::OnMessageReceived #17583

Merged
merged 1 commit into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ void ExchangeContext::NotifyResponseTimeout()
MessageHandled();
}

CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const PayloadHeader & payloadHeader,
const Transport::PeerAddress & peerAddress, MessageFlags msgFlags,
CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const PayloadHeader & payloadHeader, MessageFlags msgFlags,
PacketBufferHandle && msgBuf)
{
// We hold a reference to the ExchangeContext here to
Expand Down Expand Up @@ -457,8 +456,7 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload
MessageHandled();
});

ReturnErrorOnFailure(
mDispatch.OnMessageReceived(messageCounter, payloadHeader, peerAddress, msgFlags, GetReliableMessageContext()));
ReturnErrorOnFailure(mDispatch.OnMessageReceived(messageCounter, payloadHeader, msgFlags, GetReliableMessageContext()));

if (IsAckPending() && !mDelegate)
{
Expand Down
4 changes: 1 addition & 3 deletions src/messaging/ExchangeContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ class DLL_EXPORT ExchangeContext : public ReliableMessageContext,
*
* @param[in] messageCounter The message counter of the packet.
* @param[in] payloadHeader A reference to the PayloadHeader object.
* @param[in] peerAddress The address of the sender
* @param[in] msgFlags The message flags corresponding to the received message
* @param[in] msgBuf A handle to the packet buffer holding the CHIP message.
*
Expand All @@ -144,8 +143,7 @@ class DLL_EXPORT ExchangeContext : public ReliableMessageContext,
* @retval #CHIP_NO_ERROR if the CHIP layer successfully delivered the message up to the
* protocol layer.
*/
CHIP_ERROR HandleMessage(uint32_t messageCounter, const PayloadHeader & payloadHeader,
const Transport::PeerAddress & peerAddress, MessageFlags msgFlags,
CHIP_ERROR HandleMessage(uint32_t messageCounter, const PayloadHeader & payloadHeader, MessageFlags msgFlags,
System::PacketBufferHandle && msgBuf);

ExchangeDelegate * GetDelegate() const { return mDelegate; }
Expand Down
3 changes: 1 addition & 2 deletions src/messaging/ExchangeMessageDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ CHIP_ERROR ExchangeMessageDispatch::SendMessage(SessionManager * sessionManager,
}

CHIP_ERROR ExchangeMessageDispatch::OnMessageReceived(uint32_t messageCounter, const PayloadHeader & payloadHeader,
const Transport::PeerAddress & peerAddress, MessageFlags msgFlags,
ReliableMessageContext * reliableMessageContext)
MessageFlags msgFlags, ReliableMessageContext * reliableMessageContext)
{
ReturnErrorCodeIf(!MessagePermitted(payloadHeader.GetProtocolID().GetProtocolId(), payloadHeader.GetMessageType()),
CHIP_ERROR_INVALID_ARGUMENT);
Expand Down
3 changes: 1 addition & 2 deletions src/messaging/ExchangeMessageDispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class ExchangeMessageDispatch
CHIP_ERROR SendMessage(SessionManager * sessionManager, const SessionHandle & session, uint16_t exchangeId, bool isInitiator,
ReliableMessageContext * reliableMessageContext, bool isReliableTransmission, Protocols::Id protocol,
uint8_t type, System::PacketBufferHandle && message);
CHIP_ERROR OnMessageReceived(uint32_t messageCounter, const PayloadHeader & payloadHeader,
const Transport::PeerAddress & peerAddress, MessageFlags msgFlags,
CHIP_ERROR OnMessageReceived(uint32_t messageCounter, const PayloadHeader & payloadHeader, MessageFlags msgFlags,
ReliableMessageContext * reliableMessageContext);

protected:
Expand Down
8 changes: 4 additions & 4 deletions src/messaging/ExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ CHIP_ERROR ExchangeManager::UnregisterUMH(Protocols::Id protocolId, int16_t msgT
}

void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const PayloadHeader & payloadHeader,
const SessionHandle & session, const Transport::PeerAddress & source,
DuplicateMessage isDuplicate, System::PacketBufferHandle && msgBuf)
const SessionHandle & session, DuplicateMessage isDuplicate,
System::PacketBufferHandle && msgBuf)
{
UnsolicitedMessageHandlerSlot * matchingUMH = nullptr;

Expand Down Expand Up @@ -219,7 +219,7 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const
ChipLogValueExchange(ec), ec->GetDelegate());

// Matched ExchangeContext; send to message handler.
ec->HandleMessage(packetHeader.GetMessageCounter(), payloadHeader, source, msgFlags, std::move(msgBuf));
ec->HandleMessage(packetHeader.GetMessageCounter(), payloadHeader, msgFlags, std::move(msgBuf));
found = true;
return Loop::Break;
}
Expand Down Expand Up @@ -317,7 +317,7 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const
return;
}

CHIP_ERROR err = ec->HandleMessage(packetHeader.GetMessageCounter(), payloadHeader, source, msgFlags, std::move(msgBuf));
CHIP_ERROR err = ec->HandleMessage(packetHeader.GetMessageCounter(), payloadHeader, msgFlags, std::move(msgBuf));
if (err != CHIP_NO_ERROR)
{
// Using same error message for all errors to reduce code size.
Expand Down
4 changes: 1 addition & 3 deletions src/messaging/ExchangeMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <messaging/ReliableMessageMgr.h>
#include <protocols/Protocols.h>
#include <transport/SessionManager.h>
#include <transport/TransportMgr.h>

namespace chip {
namespace Messaging {
Expand Down Expand Up @@ -240,8 +239,7 @@ class DLL_EXPORT ExchangeManager : public SessionMessageDelegate
CHIP_ERROR UnregisterUMH(Protocols::Id protocolId, int16_t msgType);

void OnMessageReceived(const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, const SessionHandle & session,
const Transport::PeerAddress & source, DuplicateMessage isDuplicate,
System::PacketBufferHandle && msgBuf) override;
DuplicateMessage isDuplicate, System::PacketBufferHandle && msgBuf) override;
};

} // namespace Messaging
Expand Down
6 changes: 3 additions & 3 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ void SessionManager::UnauthenticatedMessageDispatch(const PacketHeader & packetH
if (mCB != nullptr)
{
CHIP_TRACE_MESSAGE_RECEIVED(payloadHeader, packetHeader, unsecuredSession, peerAddress, msg->Start(), msg->TotalLength());
mCB->OnMessageReceived(packetHeader, payloadHeader, session, peerAddress, isDuplicate, std::move(msg));
mCB->OnMessageReceived(packetHeader, payloadHeader, session, isDuplicate, std::move(msg));
}
}

Expand Down Expand Up @@ -631,7 +631,7 @@ void SessionManager::SecureUnicastMessageDispatch(const PacketHeader & packetHea
if (mCB != nullptr)
{
CHIP_TRACE_MESSAGE_RECEIVED(payloadHeader, packetHeader, secureSession, peerAddress, msg->Start(), msg->TotalLength());
mCB->OnMessageReceived(packetHeader, payloadHeader, session.Value(), peerAddress, isDuplicate, std::move(msg));
mCB->OnMessageReceived(packetHeader, payloadHeader, session.Value(), isDuplicate, std::move(msg));
}
}

Expand Down Expand Up @@ -763,7 +763,7 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & packetHeade
Transport::IncomingGroupSession groupSession(groupContext.group_id, groupContext.fabric_index,
packetHeader.GetSourceNodeId().Value());
CHIP_TRACE_MESSAGE_RECEIVED(payloadHeader, packetHeader, &groupSession, peerAddress, msg->Start(), msg->TotalLength());
mCB->OnMessageReceived(packetHeader, payloadHeader, SessionHandle(groupSession), peerAddress,
mCB->OnMessageReceived(packetHeader, payloadHeader, SessionHandle(groupSession),
SessionMessageDelegate::DuplicateMessage::No, std::move(msg));
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/transport/SessionMessageDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ class DLL_EXPORT SessionMessageDelegate
* @param packetHeader The message header
* @param payloadHeader The payload header
* @param session The handle to the secure session
* @param source The sender's address
* @param isDuplicate The message is a duplicate of previously received message
* @param msgBuf The received message
*/
virtual void OnMessageReceived(const PacketHeader & packetHeader, const PayloadHeader & payloadHeader,
const SessionHandle & session, const Transport::PeerAddress & source,
DuplicateMessage isDuplicate, System::PacketBufferHandle && msgBuf) = 0;
const SessionHandle & session, DuplicateMessage isDuplicate,
System::PacketBufferHandle && msgBuf) = 0;
};

} // namespace chip
3 changes: 1 addition & 2 deletions src/transport/tests/TestSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class TestSessMgrCallback : public SessionMessageDelegate
{
public:
void OnMessageReceived(const PacketHeader & header, const PayloadHeader & payloadHeader, const SessionHandle & session,
const Transport::PeerAddress & source, DuplicateMessage isDuplicate,
System::PacketBufferHandle && msgBuf) override
DuplicateMessage isDuplicate, System::PacketBufferHandle && msgBuf) override
{
size_t data_len = msgBuf->DataLength();

Expand Down