From 2a945251967bca92be6cae0f927e799eb6bc8645 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 26 Nov 2019 14:11:13 -0800 Subject: [PATCH] [mle] change IsFullThreadDevice to IsRouterEligible where appropriate (#4363) --- src/core/thread/mle_router.cpp | 9 +++------ src/core/thread/network_data_local.cpp | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index e883ac342..0ddc1cbb2 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -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); diff --git a/src/core/thread/network_data_local.cpp b/src/core/thread/network_data_local.cpp index 48c977705..26970ba4c 100644 --- a/src/core/thread/network_data_local.cpp +++ b/src/core/thread/network_data_local.cpp @@ -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().IsFullThreadDevice() && Get().IsRouterEligible() && - (Get().GetRole() < OT_DEVICE_ROLE_ROUTER) && + if (Get().IsRouterEligible() && (Get().GetRole() < OT_DEVICE_ROLE_ROUTER) && (Get().GetActiveRouterCount() < Get().GetRouterUpgradeThreshold())) { ExitNow(error = OT_ERROR_INVALID_STATE);