From a97fa5bd3251c9cf3b8abe0fdabbc065dea8f4a6 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 29 Apr 2026 15:45:14 -0700 Subject: [PATCH] [router-table] rename `FindNextHopOf()` to `FindNextHopTowards()` (#13008) This commit renames the `RouterTable::FindNextHopOf()` method to `RouterTable::FindNextHopTowards()` to more accurately reflect its purpose: finding the next hop on the path towards a given destination router. --- src/core/thread/mle_ftd.cpp | 2 +- src/core/thread/router_table.cpp | 9 ++++++--- src/core/thread/router_table.hpp | 12 ++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/core/thread/mle_ftd.cpp b/src/core/thread/mle_ftd.cpp index fb65a9aea..a9ec6efe1 100644 --- a/src/core/thread/mle_ftd.cpp +++ b/src/core/thread/mle_ftd.cpp @@ -1799,7 +1799,7 @@ void Mle::HandleTimeTick(void) continue; } - if (IsLeader() && (mRouterTable.FindNextHopOf(router) == nullptr) && + if (IsLeader() && (mRouterTable.FindNextHopTowards(router) == nullptr) && (mRouterTable.GetLinkCost(router) >= kMaxRouteCost) && (age >= kMaxLeaderToRouterTimeout)) { LogInfo("Router 0x%04x ID timeout expired (no route)", router.GetRloc16()); diff --git a/src/core/thread/router_table.cpp b/src/core/thread/router_table.cpp index 523990b99..30f454f03 100644 --- a/src/core/thread/router_table.cpp +++ b/src/core/thread/router_table.cpp @@ -317,7 +317,10 @@ const Router *RouterTable::FindRouterByRloc16(uint16_t aRloc16) const return FindRouterById(Mle::RouterIdFromRloc16(aRloc16)); } -const Router *RouterTable::FindNextHopOf(const Router &aRouter) const { return FindRouterById(aRouter.GetNextHop()); } +const Router *RouterTable::FindNextHopTowards(const Router &aRouter) const +{ + return FindRouterById(aRouter.GetNextHop()); +} Router *RouterTable::FindRouter(const Mac::ExtAddress &aExtAddress) { @@ -431,7 +434,7 @@ void RouterTable::GetNextHopAndPathCost(uint16_t aDestRloc16, uint16_t &aNextHop } router = FindRouterById(Mle::RouterIdFromRloc16(aDestRloc16)); - nextHop = (router != nullptr) ? FindNextHopOf(*router) : nullptr; + nextHop = (router != nullptr) ? FindNextHopTowards(*router) : nullptr; if (Get().IsChild()) { @@ -663,7 +666,7 @@ void RouterTable::UpdateRoutes(const Mle::RouteTlv &aRouteTlv, uint8_t aNeighbor continue; } - nextHop = FindNextHopOf(*router); + nextHop = FindNextHopTowards(*router); cost = aRouteTlv.GetRouteCost(index); cost = (cost == 0) ? Mle::kMaxRouteCost : cost; diff --git a/src/core/thread/router_table.hpp b/src/core/thread/router_table.hpp index a379c75e4..33711cdfe 100644 --- a/src/core/thread/router_table.hpp +++ b/src/core/thread/router_table.hpp @@ -242,22 +242,22 @@ public: const Router *FindRouterByRloc16(uint16_t aRloc16) const; /** - * Finds the router that is the next hop of a given router. + * Finds the router that is the next hop towards a given router. * - * @param[in] aRouter The router to find next hop of. + * @param[in] aRouter The destination router. * * @returns A pointer to the router or `nullptr` if the router could not be found. */ - Router *FindNextHopOf(const Router &aRouter) { return AsNonConst(AsConst(this)->FindNextHopOf(aRouter)); } + Router *FindNextHopTowards(const Router &aRouter) { return AsNonConst(AsConst(this)->FindNextHopTowards(aRouter)); } /** - * Finds the router that is the next hop of a given router. + * Finds the router that is the next hop towards a given router. * - * @param[in] aRouter The router to find next hop of. + * @param[in] aRouter The destination router. * * @returns A pointer to the router or `nullptr` if the router could not be found. */ - const Router *FindNextHopOf(const Router &aRouter) const; + const Router *FindNextHopTowards(const Router &aRouter) const; /** * Find the router for a given MAC Extended Address.