diff --git a/src/core/thread/indirect_sender.cpp b/src/core/thread/indirect_sender.cpp index b465c8de8..500d3179b 100644 --- a/src/core/thread/indirect_sender.cpp +++ b/src/core/thread/indirect_sender.cpp @@ -371,7 +371,7 @@ uint16_t IndirectSender::PrepareDataFrame(Mac::TxFrame &aFrame, Child &aChild, M if (ip6Header.GetDestination().IsLinkLocalUnicast()) { - Get().GetMacDestinationAddress(ip6Header.GetDestination(), macAddrs.mDestination); + macAddrs.mDestination.SetExtendedFromIid(ip6Header.GetDestination().GetIid()); } else { diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index ae126fedd..60e7ce684 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -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().IsRoutingLocator(aIp6Addr)) - { - aMacAddr.SetShort(aIp6Addr.GetIid().GetLocator()); - } - else - { - aMacAddr.SetExtendedFromIid(aIp6Addr.GetIid()); - } -} - Mac::TxFrame *MeshForwarder::HandleFrameRequest(Mac::TxFrames &aTxFrames) { Mac::TxFrame *frame = nullptr; diff --git a/src/core/thread/mesh_forwarder.hpp b/src/core/thread/mesh_forwarder.hpp index 4a27db389..22dd6be10 100644 --- a/src/core/thread/mesh_forwarder.hpp +++ b/src/core/thread/mesh_forwarder.hpp @@ -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);