diff --git a/src/core/thread/mesh_forwarder_ftd.cpp b/src/core/thread/mesh_forwarder_ftd.cpp index d4911b9a8..e69f200a9 100644 --- a/src/core/thread/mesh_forwarder_ftd.cpp +++ b/src/core/thread/mesh_forwarder_ftd.cpp @@ -522,7 +522,7 @@ Error MeshForwarder::UpdateIp6RouteFtd(const Ip6::Header &aIp6Header, Message &a if (aloc16 == Mle::kAloc16Leader) { - mMeshDest = Mle::Rloc16FromRouterId(mle.GetLeaderId()); + mMeshDest = mle.GetLeaderRloc16(); } else if (aloc16 <= Mle::kAloc16DhcpAgentEnd) { diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 34cfaf904..b3ba28076 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -1004,7 +1004,7 @@ Error Mle::GetLeaderAddress(Ip6::Address &aAddress) const VerifyOrExit(GetRloc16() != Mac::kShortAddrInvalid, error = kErrorDetached); - aAddress.SetToRoutingLocator(mMeshLocalPrefix, Rloc16FromRouterId(mLeaderData.GetLeaderRouterId())); + aAddress.SetToRoutingLocator(mMeshLocalPrefix, GetLeaderRloc16()); exit: return error; diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index ad1b5b448..6c407cbed 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -547,6 +547,14 @@ public: */ uint8_t GetLeaderId(void) const { return mLeaderData.GetLeaderRouterId(); } + /** + * Returns the RLOC16 of the Leader. + * + * @returns The RLOC16 of the Leader. + * + */ + uint16_t GetLeaderRloc16(void) const { return Rloc16FromRouterId(GetLeaderId()); } + /** * Retrieves the Leader's RLOC. * diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 73e5e1563..df6c28903 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -958,7 +958,7 @@ Error MleRouter::HandleLinkAccept(RxInfo &aRxInfo, bool aRequest) router = mRouterTable.FindRouterById(routerId); VerifyOrExit(router != nullptr); - if (mLeaderData.GetLeaderRouterId() == RouterIdFromRloc16(GetRloc16())) + if (GetLeaderRloc16() == GetRloc16()) { SetStateLeader(GetRloc16(), kRestoringLeaderRoleAfterReset); } diff --git a/src/core/thread/network_data_service.cpp b/src/core/thread/network_data_service.cpp index 77ff48597..dbd8be7b0 100644 --- a/src/core/thread/network_data_service.cpp +++ b/src/core/thread/network_data_service.cpp @@ -152,7 +152,7 @@ bool Manager::IsBackboneRouterPreferredTo(const ServerTlv &aSer const BackboneRouter::ServerData &aOtherServerData) const { bool isPreferred; - uint16_t leaderRloc16 = Mle::Rloc16FromRouterId(Get().GetLeaderId()); + uint16_t leaderRloc16 = Get().GetLeaderRloc16(); VerifyOrExit(aServerTlv.GetServer16() != leaderRloc16, isPreferred = true); VerifyOrExit(aOtherServerTlv.GetServer16() != leaderRloc16, isPreferred = false); diff --git a/src/core/thread/router_table.cpp b/src/core/thread/router_table.cpp index 1302ce788..7117e5c94 100644 --- a/src/core/thread/router_table.cpp +++ b/src/core/thread/router_table.cpp @@ -396,10 +396,7 @@ uint8_t RouterTable::GetPathCost(uint16_t aDestRloc16) const return pathCost; } -uint8_t RouterTable::GetPathCostToLeader(void) const -{ - return GetPathCost(Mle::Rloc16FromRouterId(Get().GetLeaderId())); -} +uint8_t RouterTable::GetPathCostToLeader(void) const { return GetPathCost(Get().GetLeaderRloc16()); } void RouterTable::GetNextHopAndPathCost(uint16_t aDestRloc16, uint16_t &aNextHopRloc16, uint8_t &aPathCost) const {