From 5fd1083d147fa1887705130a094d69d149bfa71b Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 13 Dec 2019 14:36:32 -0800 Subject: [PATCH] [topology] move IsStateValidOrAttaching to Neighbor (#4419) --- src/core/thread/topology.cpp | 24 ++++++++++++------------ src/core/thread/topology.hpp | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/core/thread/topology.cpp b/src/core/thread/topology.cpp index d30ad790b..42469293e 100644 --- a/src/core/thread/topology.cpp +++ b/src/core/thread/topology.cpp @@ -41,18 +41,7 @@ namespace ot { -void Neighbor::GenerateChallenge(void) -{ - Random::Crypto::FillBuffer(mValidPending.mPending.mChallenge, sizeof(mValidPending.mPending.mChallenge)); -} - -void Child::Clear(void) -{ - memset(reinterpret_cast(this), 0, sizeof(Child)); - SetState(kStateInvalid); -} - -bool Child::IsStateValidOrAttaching(void) const +bool Neighbor::IsStateValidOrAttaching(void) const { bool rval = false; @@ -75,6 +64,17 @@ bool Child::IsStateValidOrAttaching(void) const return rval; } +void Neighbor::GenerateChallenge(void) +{ + Random::Crypto::FillBuffer(mValidPending.mPending.mChallenge, sizeof(mValidPending.mPending.mChallenge)); +} + +void Child::Clear(void) +{ + memset(reinterpret_cast(this), 0, sizeof(Child)); + SetState(kStateInvalid); +} + void Child::ClearIp6Addresses(void) { memset(mMeshLocalIid, 0, sizeof(mMeshLocalIid)); diff --git a/src/core/thread/topology.hpp b/src/core/thread/topology.hpp index e883a4a61..4a8667369 100644 --- a/src/core/thread/topology.hpp +++ b/src/core/thread/topology.hpp @@ -157,6 +157,17 @@ public: */ bool IsStateValidOrRestoring(void) const { return (mState == kStateValid) || IsStateRestoring(); } + /** + * This method indicates if the neighbor state is valid, attaching, or restored. + * + * The states `kStateRestored`, `kStateChildIdRequest`, `kStateChildUpdateRequest`, `kStateValid`, and + * `kStateLinkRequest` are considered as valid, attaching, or restored. + * + * @returns TRUE if the neighbor state is valid, attaching, or restored, FALSE otherwise. + * + */ + bool IsStateValidOrAttaching(void) const; + /** * This method gets the device mode flags. * @@ -480,17 +491,6 @@ public: */ void Clear(void); - /** - * This method indicates if the child state is valid or being attached or being restored. - * - * The states `kStateRestored`, `kStateChildIdRequest`, `kStateChildUpdateRequest`, `kStateValid`, (and - * `kStateLinkRequest) are considered as attached or being restored. - * - * @returns TRUE if the child is attached or being restored. - * - */ - bool IsStateValidOrAttaching(void) const; - /** * This method clears the IPv6 address list for the child. *