Skip to content

Commit a97fa5b

Browse files
authored
[router-table] rename FindNextHopOf() to FindNextHopTowards() (openthread#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.
1 parent d145aaf commit a97fa5b

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/core/thread/mle_ftd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,7 @@ void Mle::HandleTimeTick(void)
17991799
continue;
18001800
}
18011801

1802-
if (IsLeader() && (mRouterTable.FindNextHopOf(router) == nullptr) &&
1802+
if (IsLeader() && (mRouterTable.FindNextHopTowards(router) == nullptr) &&
18031803
(mRouterTable.GetLinkCost(router) >= kMaxRouteCost) && (age >= kMaxLeaderToRouterTimeout))
18041804
{
18051805
LogInfo("Router 0x%04x ID timeout expired (no route)", router.GetRloc16());

src/core/thread/router_table.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,10 @@ const Router *RouterTable::FindRouterByRloc16(uint16_t aRloc16) const
317317
return FindRouterById(Mle::RouterIdFromRloc16(aRloc16));
318318
}
319319

320-
const Router *RouterTable::FindNextHopOf(const Router &aRouter) const { return FindRouterById(aRouter.GetNextHop()); }
320+
const Router *RouterTable::FindNextHopTowards(const Router &aRouter) const
321+
{
322+
return FindRouterById(aRouter.GetNextHop());
323+
}
321324

322325
Router *RouterTable::FindRouter(const Mac::ExtAddress &aExtAddress)
323326
{
@@ -431,7 +434,7 @@ void RouterTable::GetNextHopAndPathCost(uint16_t aDestRloc16, uint16_t &aNextHop
431434
}
432435

433436
router = FindRouterById(Mle::RouterIdFromRloc16(aDestRloc16));
434-
nextHop = (router != nullptr) ? FindNextHopOf(*router) : nullptr;
437+
nextHop = (router != nullptr) ? FindNextHopTowards(*router) : nullptr;
435438

436439
if (Get<Mle::Mle>().IsChild())
437440
{
@@ -663,7 +666,7 @@ void RouterTable::UpdateRoutes(const Mle::RouteTlv &aRouteTlv, uint8_t aNeighbor
663666
continue;
664667
}
665668

666-
nextHop = FindNextHopOf(*router);
669+
nextHop = FindNextHopTowards(*router);
667670

668671
cost = aRouteTlv.GetRouteCost(index);
669672
cost = (cost == 0) ? Mle::kMaxRouteCost : cost;

src/core/thread/router_table.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,22 +242,22 @@ class RouterTable : public InstanceLocator, private NonCopyable
242242
const Router *FindRouterByRloc16(uint16_t aRloc16) const;
243243

244244
/**
245-
* Finds the router that is the next hop of a given router.
245+
* Finds the router that is the next hop towards a given router.
246246
*
247-
* @param[in] aRouter The router to find next hop of.
247+
* @param[in] aRouter The destination router.
248248
*
249249
* @returns A pointer to the router or `nullptr` if the router could not be found.
250250
*/
251-
Router *FindNextHopOf(const Router &aRouter) { return AsNonConst(AsConst(this)->FindNextHopOf(aRouter)); }
251+
Router *FindNextHopTowards(const Router &aRouter) { return AsNonConst(AsConst(this)->FindNextHopTowards(aRouter)); }
252252

253253
/**
254-
* Finds the router that is the next hop of a given router.
254+
* Finds the router that is the next hop towards a given router.
255255
*
256-
* @param[in] aRouter The router to find next hop of.
256+
* @param[in] aRouter The destination router.
257257
*
258258
* @returns A pointer to the router or `nullptr` if the router could not be found.
259259
*/
260-
const Router *FindNextHopOf(const Router &aRouter) const;
260+
const Router *FindNextHopTowards(const Router &aRouter) const;
261261

262262
/**
263263
* Find the router for a given MAC Extended Address.

0 commit comments

Comments
 (0)