mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 17:37:46 +00:00
[mle] limit number of child-router links a REED / FED maintains (#3358)
This commit is contained in:
@@ -1662,6 +1662,16 @@
|
||||
#define OPENTHREAD_CONFIG_MLE_PARTITION_MERGE_MARGIN_MIN 10
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS
|
||||
*
|
||||
* Specifies the desired number of router links that a REED / FED attempts to maintain.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS
|
||||
#define OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
|
||||
*
|
||||
|
||||
@@ -1352,7 +1352,8 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa
|
||||
}
|
||||
}
|
||||
else if (IsFullThreadDevice() && (router->GetState() != Neighbor::kStateValid) &&
|
||||
(router->GetState() != Neighbor::kStateLinkRequest))
|
||||
(router->GetState() != Neighbor::kStateLinkRequest) &&
|
||||
(mRouterTable.GetActiveLinkCount() < OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS))
|
||||
{
|
||||
router->SetExtAddress(macAddr);
|
||||
router->GetLinkInfo().Clear();
|
||||
|
||||
@@ -335,6 +335,28 @@ void RouterTable::RemoveNeighbor(Router &aRouter)
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t RouterTable::GetActiveLinkCount(void) const
|
||||
{
|
||||
uint8_t activeLinks = 0;
|
||||
|
||||
for (int i = 0; i < Mle::kMaxRouters; i++)
|
||||
{
|
||||
const Router &cur = mRouters[i];
|
||||
|
||||
if (cur.GetRloc16() == 0xffff)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (cur.GetState() == Neighbor::kStateValid)
|
||||
{
|
||||
activeLinks++;
|
||||
}
|
||||
}
|
||||
|
||||
return activeLinks;
|
||||
}
|
||||
|
||||
Router *RouterTable::GetNeighbor(uint16_t aRloc16)
|
||||
{
|
||||
Router *router = NULL;
|
||||
|
||||
@@ -176,6 +176,14 @@ public:
|
||||
*/
|
||||
uint8_t GetActiveRouterCount(void) const { return mActiveRouterCount; }
|
||||
|
||||
/**
|
||||
* This method returns the number of active links with neighboring routers.
|
||||
*
|
||||
* @returns The number of active links with neighboring routers.
|
||||
*
|
||||
*/
|
||||
uint8_t GetActiveLinkCount(void) const;
|
||||
|
||||
/**
|
||||
* This method returns the leader in the Thread network.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user