Skip to content

Commit

Permalink
[mle] track LeaderCost in Parent class (#8052)
Browse files Browse the repository at this point in the history
  • Loading branch information
abtink authored Aug 22, 2022
1 parent 96bba36 commit b8b88d9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/core/thread/mle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ Mle::Mle(Instance &aInstance)
, mAttachTimer(aInstance, Mle::HandleAttachTimer)
, mDelayedResponseTimer(aInstance, Mle::HandleDelayedResponseTimer)
, mMessageTransmissionTimer(aInstance, Mle::HandleMessageTransmissionTimer)
, mParentLeaderCost(0)
, mAttachMode(kAnyPartition)
, mParentPriority(0)
, mParentLinkQuality3(0)
Expand Down Expand Up @@ -3259,6 +3258,7 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo)
mParentCandidate.SetLinkQualityOut(LinkQualityInfo::ConvertLinkMarginToLinkQuality(linkMarginFromTlv));
mParentCandidate.SetState(Neighbor::kStateParentResponse);
mParentCandidate.SetKeySequence(aRxInfo.mKeySequence);
mParentCandidate.SetLeaderCost(connectivity.GetLeaderCost());
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
mParentCandidate.SetCslAccuracy(cslAccuracy);
#endif
Expand All @@ -3267,7 +3267,6 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo)
mParentLinkQuality3 = connectivity.GetLinkQuality3();
mParentLinkQuality2 = connectivity.GetLinkQuality2();
mParentLinkQuality1 = connectivity.GetLinkQuality1();
mParentLeaderCost = connectivity.GetLeaderCost();
mParentSedBufferSize = connectivity.GetSedBufferSize();
mParentSedDatagramCount = connectivity.GetSedDatagramCount();
mParentLeaderData = leaderData;
Expand Down
1 change: 0 additions & 1 deletion src/core/thread/mle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,6 @@ class Mle : public InstanceLocator, private NonCopyable
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).
uint8_t mParentLeaderCost;

private:
static constexpr uint8_t kMleHopLimit = 255;
Expand Down
2 changes: 1 addition & 1 deletion src/core/thread/mle_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3876,7 +3876,7 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Message * aMessage,
if (leader != router)
{
// Keep route path to the Leader reported by the parent before it is updated.
leader->SetCost(mParentLeaderCost);
leader->SetCost(mParent.GetLeaderCost());
leader->SetNextHop(RouterIdFromRloc16(mParent.GetRloc16()));
}

Expand Down
17 changes: 17 additions & 0 deletions src/core/thread/topology.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,22 @@ class Parent : public Router
*/
void Clear(void);

/**
* This method gets route cost from parent to leader.
*
* @returns The route cost from parent to leader
*
*/
uint8_t GetLeaderCost(void) const { return mLeaderCost; }

/**
* This method sets route cost from parent to leader.
*
* @param[in] aLaderConst The route cost.
*
*/
void SetLeaderCost(uint8_t aLeaderCost) { mLeaderCost = aLeaderCost; }

#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
/**
* This method gets the CSL accuracy (clock accuracy and uncertainty).
Expand All @@ -1506,6 +1522,7 @@ class Parent : public Router
#endif

private:
uint8_t mLeaderCost;
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
Mac::CslAccuracy mCslAccuracy; // CSL accuracy (clock accuracy in ppm and uncertainty).
#endif
Expand Down

0 comments on commit b8b88d9

Please sign in to comment.