Skip to content

Commit

Permalink
Address review comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Sep 20, 2023
1 parent 8a94b07 commit e44a10b
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ CHIP_ERROR SessionManager::PrepareMessage(const SessionHandle & sessionHandle, P
FabricIndex fabricIndex;
#endif // CHIP_PROGRESS_LOGGING

PeerAddress destination_address;

switch (sessionHandle->GetSessionType())
{
case Transport::Session::SessionType::kGroupOutgoing: {
Expand All @@ -184,7 +186,7 @@ CHIP_ERROR SessionManager::PrepareMessage(const SessionHandle & sessionHandle, P
return CHIP_ERROR_INTERNAL;
}

PeerAddress destination_address = Transport::PeerAddress::Multicast(fabric->GetFabricId(), groupSession->GetGroupId());
destination_address = Transport::PeerAddress::Multicast(fabric->GetFabricId(), groupSession->GetGroupId());

// Trace before any encryption
MATTER_LOG_MESSAGE_SEND(chip::Tracing::OutgoingMessageType::kGroupMessage, &payloadHeader, &packetHeader,
Expand Down Expand Up @@ -224,7 +226,7 @@ CHIP_ERROR SessionManager::PrepareMessage(const SessionHandle & sessionHandle, P
.SetSessionId(session->GetPeerSessionId()) //
.SetSessionType(Header::SessionType::kUnicastSession);

PeerAddress destination_address = session->GetPeerAddress();
destination_address = session->GetPeerAddress();

// Trace before any encryption
MATTER_LOG_MESSAGE_SEND(chip::Tracing::OutgoingMessageType::kSecureSession, &payloadHeader, &packetHeader,
Expand Down Expand Up @@ -259,8 +261,8 @@ CHIP_ERROR SessionManager::PrepareMessage(const SessionHandle & sessionHandle, P
break;
}

auto unauthenticated = sessionHandle->AsUnauthenticatedSession();
PeerAddress destination_address = unauthenticated->GetPeerAddress();
auto unauthenticated = sessionHandle->AsUnauthenticatedSession();
destination_address = unauthenticated->GetPeerAddress();

// Trace after all headers are settled.
MATTER_LOG_MESSAGE_SEND(chip::Tracing::OutgoingMessageType::kUnauthenticated, &payloadHeader, &packetHeader,
Expand Down Expand Up @@ -305,29 +307,7 @@ CHIP_ERROR SessionManager::PrepareMessage(const SessionHandle & sessionHandle, P
}

char addressStr[Transport::PeerAddress::kMaxToStringSize] = { 0 };
switch (sessionHandle->GetSessionType())
{
case Transport::Session::SessionType::kGroupOutgoing: {
// We already checked above that we have a fabric entry for our fabric
// index.
auto * groupSession = sessionHandle->AsOutgoingGroupSession();
auto * fabricInfo = mFabricTable->FindFabricWithIndex(fabricIndex);
auto multicastAddress = Transport::PeerAddress::Multicast(fabricInfo->GetFabricId(), groupSession->GetGroupId());
multicastAddress.ToString(addressStr);
break;
}
case Transport::Session::SessionType::kSecure: {
sessionHandle->AsSecureSession()->GetPeerAddress().ToString(addressStr);
break;
}
case Transport::Session::SessionType::kUnauthenticated: {
sessionHandle->AsUnauthenticatedSession()->GetPeerAddress().ToString(addressStr);
break;
}
default:
// Note: We checked above that we are one of these three session types.
break;
}
destination_address.ToString(addressStr);

//
// Legend that can be used to decode this log line can be found in messaging/README.md
Expand Down

0 comments on commit e44a10b

Please sign in to comment.