[mesh-forwarder] simplify destination MAC address determination (#11391)

This commit simplifies the process of determining the destination MAC
address. Specifically, when the destination is a link-local unicast
address, the MAC address is derived directly from its Interface
Identifier (IID). This commit replaces and removes the
`GetMacDestinationAddress()` method, with the calling code now
directly determining the destination MAC address.
This commit is contained in:
Abtin Keshavarzian
2025-04-03 08:32:10 -07:00
committed by GitHub
parent 37b417a3ee
commit e4339c5939
3 changed files with 8 additions and 21 deletions
+1 -1
View File
@@ -371,7 +371,7 @@ uint16_t IndirectSender::PrepareDataFrame(Mac::TxFrame &aFrame, Child &aChild, M
if (ip6Header.GetDestination().IsLinkLocalUnicast())
{
Get<MeshForwarder>().GetMacDestinationAddress(ip6Header.GetDestination(), macAddrs.mDestination);
macAddrs.mDestination.SetExtendedFromIid(ip6Header.GetDestination().GetIid());
}
else
{
+7 -19
View File
@@ -632,9 +632,13 @@ Error MeshForwarder::UpdateIp6Route(Message &aMessage)
if (mle.IsDisabled() || mle.IsDetached())
{
if (ip6Header.GetDestination().IsLinkLocalUnicastOrMulticast())
if (ip6Header.GetDestination().IsLinkLocalMulticast())
{
GetMacDestinationAddress(ip6Header.GetDestination(), mMacAddrs.mDestination);
mMacAddrs.mDestination.SetShort(Mac::kShortAddrBroadcast);
}
else if (ip6Header.GetDestination().IsLinkLocalUnicast())
{
mMacAddrs.mDestination.SetExtendedFromIid(ip6Header.GetDestination().GetIid());
}
else
{
@@ -661,7 +665,7 @@ Error MeshForwarder::UpdateIp6Route(Message &aMessage)
}
else if (ip6Header.GetDestination().IsLinkLocalUnicast())
{
GetMacDestinationAddress(ip6Header.GetDestination(), mMacAddrs.mDestination);
mMacAddrs.mDestination.SetExtendedFromIid(ip6Header.GetDestination().GetIid());
}
else if (mle.IsMinimalEndDevice())
{
@@ -708,22 +712,6 @@ void MeshForwarder::GetMacSourceAddress(const Ip6::Address &aIp6Addr, Mac::Addre
}
}
void MeshForwarder::GetMacDestinationAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr)
{
if (aIp6Addr.IsMulticast())
{
aMacAddr.SetShort(Mac::kShortAddrBroadcast);
}
else if (Get<Mle::MleRouter>().IsRoutingLocator(aIp6Addr))
{
aMacAddr.SetShort(aIp6Addr.GetIid().GetLocator());
}
else
{
aMacAddr.SetExtendedFromIid(aIp6Addr.GetIid());
}
}
Mac::TxFrame *MeshForwarder::HandleFrameRequest(Mac::TxFrames &aTxFrames)
{
Mac::TxFrame *frame = nullptr;
-1
View File
@@ -491,7 +491,6 @@ private:
Error CheckReachability(uint16_t aMeshDest, const Ip6::Header &aIp6Header);
void UpdateRoutes(RxInfo &aRxInfo);
Error FrameToMessage(RxInfo &aRxInfo, uint16_t aDatagramSize, Message *&aMessage);
void GetMacDestinationAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr);
void GetMacSourceAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr);
Message *PrepareNextDirectTransmission(void);
void HandleMesh(RxInfo &aRxInfo);