mirror of
https://github.com/espressif/openthread.git
synced 2026-08-16 23:57:46 +00:00
[mle] add RouterTable::LogRouteTable() (#8189)
This commit updates the logging format of the route table. It adds `LogRouteTable()` method in `RouterTable`.
This commit is contained in:
@@ -1602,24 +1602,11 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId)
|
||||
ResetAdvertiseInterval();
|
||||
}
|
||||
|
||||
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
|
||||
|
||||
VerifyOrExit(changed);
|
||||
LogInfo("Route table updated");
|
||||
|
||||
for (Router &router : Get<RouterTable>().Iterate())
|
||||
if (changed)
|
||||
{
|
||||
LogInfo(" %04x -> %04x, cost:%d %d, lqin:%d, lqout:%d, link:%s", router.GetRloc16(),
|
||||
(router.GetNextHop() == kInvalidRouterId) ? 0xffff : Rloc16FromRouterId(router.GetNextHop()),
|
||||
router.GetCost(), mRouterTable.GetLinkCost(router), router.GetLinkQualityIn(),
|
||||
router.GetLinkQualityOut(),
|
||||
router.GetRloc16() == GetRloc16() ? "device" : ToYesNo(router.IsStateValid()));
|
||||
Get<RouterTable>().LogRouteTable();
|
||||
}
|
||||
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(changed);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -550,6 +550,47 @@ exit:
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
|
||||
void RouterTable::LogRouteTable(void)
|
||||
{
|
||||
static constexpr uint16_t kStringSize = 128;
|
||||
|
||||
LogInfo("Route table");
|
||||
|
||||
for (Router &router : Iterate())
|
||||
{
|
||||
String<kStringSize> string;
|
||||
|
||||
string.Append(" %2d 0x%04x", router.GetRouterId(), router.GetRloc16());
|
||||
|
||||
if (router.GetRloc16() == Get<Mle::Mle>().GetRloc16())
|
||||
{
|
||||
string.Append(" - me");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (router.IsStateValid())
|
||||
{
|
||||
string.Append(" - nbr{lq[i/o]:%d/%d cost:%d}", router.GetLinkQualityIn(), router.GetLinkQualityOut(),
|
||||
GetLinkCost(router));
|
||||
}
|
||||
|
||||
if (router.GetNextHop() != Mle::kInvalidRouterId)
|
||||
{
|
||||
string.Append(" - nexthop{%d cost:%d}", router.GetNextHop(), router.GetCost());
|
||||
}
|
||||
}
|
||||
|
||||
if (router.GetRouterId() == Get<Mle::Mle>().GetLeaderId())
|
||||
{
|
||||
string.Append(" - leader");
|
||||
}
|
||||
|
||||
LogInfo("%s", string.AsCString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace ot
|
||||
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
@@ -344,6 +344,16 @@ public:
|
||||
Error SetRouterIdRange(uint8_t aMinRouterId, uint8_t aMaxRouterId);
|
||||
#endif
|
||||
|
||||
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
|
||||
/**
|
||||
* This method logs the route table.
|
||||
*
|
||||
*/
|
||||
void LogRouteTable(void);
|
||||
#else
|
||||
void LogRouteTable(void) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
class IteratorBuilder : public InstanceLocator
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user