From 80da0397d183764b0d8ccb36c3dfa0f94fa98701 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 8 Dec 2022 17:55:47 -0800 Subject: [PATCH] [mle] remember current RLOC16 in a member variable (#8499) This commit updates `Mle` to store the current RLOC16 in a member variable `mRloc16` (in addition to setting it on `Mac` as device's short address). This allows `Mle::GetRloc16()` to be defined as an inline method instead of using `Get().GetShortAddress()`. --- src/core/thread/mle.cpp | 5 +++-- src/core/thread/mle.hpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 587af99fe..47fa980fa 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -97,6 +97,7 @@ Mle::Mle(Instance &aInstance) #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE , mCslTimeout(OPENTHREAD_CONFIG_CSL_TIMEOUT) #endif + , mRloc16(Mac::kShortAddrInvalid) , mPreviousParentRloc(Mac::kShortAddrInvalid) #if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE , mParentSearch(aInstance) @@ -398,6 +399,7 @@ void Mle::Restore(void) #endif { Get().SetShortAddress(networkInfo.GetRloc16()); + mRloc16 = networkInfo.GetRloc16(); } Get().SetExtAddress(networkInfo.GetExtAddress()); @@ -984,8 +986,6 @@ exit: Get().Signal(kEventThreadMeshLocalAddrChanged); } -uint16_t Mle::GetRloc16(void) const { return Get().GetShortAddress(); } - void Mle::SetRloc16(uint16_t aRloc16) { uint16_t oldRloc16 = GetRloc16(); @@ -1003,6 +1003,7 @@ void Mle::SetRloc16(uint16_t aRloc16) } Get().SetShortAddress(aRloc16); + mRloc16 = aRloc16; if (aRloc16 != Mac::kShortAddrInvalid) { diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index 8ddf74151..aeef59981 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -495,7 +495,7 @@ public: * @returns The RLOC16 assigned to the Thread interface. * */ - uint16_t GetRloc16(void) const; + uint16_t GetRloc16(void) const { return mRloc16; } /** * This method returns a reference to the RLOC assigned to the Thread interface. @@ -2019,6 +2019,7 @@ private: uint32_t mCslTimeout; #endif + uint16_t mRloc16; uint16_t mPreviousParentRloc; #if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE