[mle] change IsFullThreadDevice to IsRouterEligible where appropriate (#4363)

This commit is contained in:
Jonathan Hui
2019-12-03 09:28:35 +08:00
parent e2723f6c05
commit 2a94525196
2 changed files with 4 additions and 8 deletions
+3 -6
View File
@@ -376,10 +376,7 @@ bool MleRouter::HandleAdvertiseTimer(void)
{
bool continueTrickle = true;
if (!IsFullThreadDevice())
{
ExitNow(continueTrickle = false);
}
VerifyOrExit(IsRouterEligible(), continueTrickle = false);
SendAdvertisement();
@@ -1077,7 +1074,7 @@ bool MleRouter::IsSingleton(void)
{
bool rval = true;
if (IsAttached() && IsFullThreadDevice())
if (IsAttached() && IsRouterEligible())
{
// not a singleton if any other routers exist
if (mRouterTable.GetActiveRouterCount() > 1)
@@ -2653,7 +2650,7 @@ otError MleRouter::HandleDiscoveryRequest(const Message &aMessage, const Ip6::Me
LogMleMessage("Receive Discovery Request", aMessageInfo.GetPeerAddr());
// only Routers and REEDs respond
VerifyOrExit(IsFullThreadDevice(), error = OT_ERROR_INVALID_STATE);
VerifyOrExit(IsRouterEligible(), error = OT_ERROR_INVALID_STATE);
// find MLE Discovery TLV
VerifyOrExit(Tlv::GetOffset(aMessage, Tlv::kDiscovery, offset) == OT_ERROR_NONE, error = OT_ERROR_PARSE);
+1 -2
View File
@@ -356,8 +356,7 @@ otError Local::SendServerDataNotification(void)
#if OPENTHREAD_FTD
// Don't send this Server Data Notification if the device is going to upgrade to Router
if (Get<Mle::MleRouter>().IsFullThreadDevice() && Get<Mle::MleRouter>().IsRouterEligible() &&
(Get<Mle::MleRouter>().GetRole() < OT_DEVICE_ROLE_ROUTER) &&
if (Get<Mle::MleRouter>().IsRouterEligible() && (Get<Mle::MleRouter>().GetRole() < OT_DEVICE_ROLE_ROUTER) &&
(Get<RouterTable>().GetActiveRouterCount() < Get<Mle::MleRouter>().GetRouterUpgradeThreshold()))
{
ExitNow(error = OT_ERROR_INVALID_STATE);