From a0718d90b1d3d4a63a83aea8b9f99985f4729126 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 18 Aug 2022 23:01:26 -0700 Subject: [PATCH] [mle] define `DetachGraecfuly` variables as `private` (#8044) This commit changes the definitions (member variables, constants, and methods) related to graceful detach mechanism to be `private` instead of `protected` since they are only accessed/used by the `Mle` and not by its sub-class `MleRouter`. --- src/core/thread/mle.cpp | 6 +++--- src/core/thread/mle.hpp | 22 +++++++--------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index f5d44043e..a84eaf81e 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -83,10 +83,7 @@ Mle::Mle(Instance &aInstance) , mAttachTimer(aInstance, Mle::HandleAttachTimer) , mDelayedResponseTimer(aInstance, Mle::HandleDelayedResponseTimer) , mMessageTransmissionTimer(aInstance, Mle::HandleMessageTransmissionTimer) - , mDetachGracefullyTimer(aInstance, Mle::HandleDetachGracefullyTimer) , mParentLeaderCost(0) - , mDetachGracefullyCallback(nullptr) - , mDetachGracefullyContext(nullptr) , mAttachMode(kAnyPartition) , mParentPriority(0) , mParentLinkQuality3(0) @@ -116,6 +113,9 @@ Mle::Mle(Instance &aInstance) , mAlternateChannel(0) , mAlternatePanId(Mac::kPanIdBroadcast) , mAlternateTimestamp(0) + , mDetachGracefullyTimer(aInstance, Mle::HandleDetachGracefullyTimer) + , mDetachGracefullyCallback(nullptr) + , mDetachGracefullyContext(nullptr) , mParentResponseCb(nullptr) , mParentResponseCbContext(nullptr) { diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index 342cfa22d..590274613 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -1770,15 +1770,6 @@ protected: #endif - /** - * This method indicates whether the device is detaching gracefully. - * - * @retval TRUE Detaching is in progress. - * @retval FALSE Not detaching. - * - */ - bool IsDetachingGracefully(void) { return mDetachGracefullyTimer.IsRunning(); } - Ip6::Netif::UnicastAddress mLeaderAloc; ///< Leader anycast locator LeaderData mLeaderData; ///< Last received Leader Data TLV. @@ -1796,14 +1787,8 @@ protected: TimerMilli mAttachTimer; ///< The timer for driving the attach process. TimerMilli mDelayedResponseTimer; ///< The timer to delay MLE responses. TimerMilli mMessageTransmissionTimer; ///< The timer for (re-)sending of MLE messages (e.g. Child Update). - TimerMilli mDetachGracefullyTimer; uint8_t mParentLeaderCost; - otDetachGracefullyCallback mDetachGracefullyCallback; - void * mDetachGracefullyContext; - - static constexpr uint32_t kDetachGracefullyTimeout = 1000; - private: static constexpr uint8_t kMleHopLimit = 255; static constexpr uint8_t kMleSecurityTagSize = 4; // Security tag size in bytes. @@ -1829,6 +1814,8 @@ private: static constexpr uint8_t kNextAttachCycleTotalParentRequests = 2; static constexpr uint8_t kNextAttachCycleNumParentRequestToRouters = 1; + static constexpr uint32_t kDetachGracefullyTimeout = 1000; + enum StartMode : uint8_t // Used in `Start()`. { kNormalAttach, @@ -1976,6 +1963,7 @@ private: void ReestablishLinkWithNeighbor(Neighbor &aNeighbor); static void HandleDetachGracefullyTimer(Timer &aTimer); void HandleDetachGracefullyTimer(void); + bool IsDetachingGracefully(void) { return mDetachGracefullyTimer.IsRunning(); } Error SendChildUpdateRequest(bool aAppendChallenge, uint32_t aTimeout); #if OPENTHREAD_FTD @@ -2111,6 +2099,10 @@ private: Ip6::Netif::MulticastAddress mLinkLocalAllThreadNodes; Ip6::Netif::MulticastAddress mRealmLocalAllThreadNodes; + TimerMilli mDetachGracefullyTimer; + otDetachGracefullyCallback mDetachGracefullyCallback; + void * mDetachGracefullyContext; + otThreadParentResponseCallback mParentResponseCb; void * mParentResponseCbContext; };