mirror of
https://github.com/espressif/openthread.git
synced 2026-08-14 06:37:46 +00:00
Fix routing cost comparison issue when chosing BR (#1759)
* Fix routing cost comparison issue when chosing BR * remove extra space * update for comments
This commit is contained in:
@@ -3376,6 +3376,26 @@ exit:
|
||||
return rval;
|
||||
}
|
||||
|
||||
uint8_t MleRouter::GetCost(uint16_t aRloc16)
|
||||
{
|
||||
uint8_t routerId = GetRouterId(aRloc16);
|
||||
uint8_t cost = GetLinkCost(routerId);
|
||||
Router *router = GetRouter(routerId);
|
||||
uint8_t routeCost;
|
||||
|
||||
VerifyOrExit(router != NULL && GetRouter(router->GetNextHop()) != NULL);
|
||||
|
||||
routeCost = GetRouteCost(aRloc16) + GetLinkCost(GetRouter(routerId)->GetNextHop());
|
||||
|
||||
if (cost > routeCost)
|
||||
{
|
||||
cost = routeCost;
|
||||
}
|
||||
|
||||
exit:
|
||||
return cost;
|
||||
}
|
||||
|
||||
uint8_t MleRouter::GetRouteCost(uint16_t aRloc16) const
|
||||
{
|
||||
uint8_t rval = kMaxRouteCost;
|
||||
|
||||
@@ -264,6 +264,16 @@ public:
|
||||
*/
|
||||
uint8_t GetLinkCost(uint8_t aRouterId);
|
||||
|
||||
/**
|
||||
* This method returns the minimum cost to the given router.
|
||||
*
|
||||
* @param[in] aRloc16 The short address of the given router.
|
||||
*
|
||||
* @returns The minimum cost to the given router (via direct link or forwarding).
|
||||
*
|
||||
*/
|
||||
uint8_t GetCost(uint16_t aRloc16);
|
||||
|
||||
/**
|
||||
* This method returns the ROUTER_SELECTION_JITTER value.
|
||||
*
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
|
||||
uint8_t GetRouteCost(uint16_t) const { return 0; }
|
||||
uint8_t GetLinkCost(uint16_t) { return 0; }
|
||||
uint8_t GetCost(uint16_t) { return 0; }
|
||||
|
||||
uint8_t GetRouterIdSequence(void) const { return 0; }
|
||||
|
||||
|
||||
@@ -329,8 +329,7 @@ ThreadError LeaderBase::ExternalRouteLookup(uint8_t aDomainId, const Ip6::Addres
|
||||
if (rvalRoute == NULL ||
|
||||
entry->GetPreference() > rvalRoute->GetPreference() ||
|
||||
(entry->GetPreference() == rvalRoute->GetPreference() &&
|
||||
mNetif.GetMle().GetRouteCost(entry->GetRloc()) <
|
||||
mNetif.GetMle().GetRouteCost(rvalRoute->GetRloc())))
|
||||
mNetif.GetMle().GetCost(entry->GetRloc()) < mNetif.GetMle().GetCost(rvalRoute->GetRloc())))
|
||||
{
|
||||
rvalRoute = entry;
|
||||
rval_plen = static_cast<uint8_t>(plen);
|
||||
@@ -387,7 +386,7 @@ ThreadError LeaderBase::DefaultRouteLookup(PrefixTlv &aPrefix, uint16_t *aRloc16
|
||||
if (route == NULL ||
|
||||
entry->GetPreference() > route->GetPreference() ||
|
||||
(entry->GetPreference() == route->GetPreference() &&
|
||||
mNetif.GetMle().GetRouteCost(entry->GetRloc()) < mNetif.GetMle().GetRouteCost(route->GetRloc())))
|
||||
mNetif.GetMle().GetCost(entry->GetRloc()) < mNetif.GetMle().GetCost(route->GetRloc())))
|
||||
{
|
||||
route = entry;
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ class otCli:
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def remove_prefix(self, prefix):
|
||||
cmd = ' prefix remove ' + prefix
|
||||
cmd = 'prefix remove ' + prefix
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user