Skip to content

Commit

Permalink
[mle] add ConnectivityTlv::IsSingleton() (openthread#10329)
Browse files Browse the repository at this point in the history
This is used to simplify `Mle::HandleParentResponse()`.
  • Loading branch information
abtink authored Jun 4, 2024
1 parent e1918b3 commit b4ec4ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/thread/mle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3224,7 +3224,7 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo)
case kBetterPartition:
VerifyOrExit(!isPartitionIdSame);

VerifyOrExit(MleRouter::ComparePartitions(connectivityTlv.GetActiveRouters() <= 1, leaderData,
VerifyOrExit(MleRouter::ComparePartitions(connectivityTlv.IsSingleton(), leaderData,
Get<MleRouter>().IsSingleton(), mLeaderData) > 0);
break;
}
Expand All @@ -3243,7 +3243,7 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo)
#if OPENTHREAD_FTD
if (IsFullThreadDevice())
{
compare = MleRouter::ComparePartitions(connectivityTlv.GetActiveRouters() <= 1, leaderData,
compare = MleRouter::ComparePartitions(connectivityTlv.IsSingleton(), leaderData,
mParentCandidate.mIsSingleton, mParentCandidate.mLeaderData);
}

Expand Down Expand Up @@ -3305,7 +3305,7 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo)
mParentCandidate.mSedBufferSize = connectivityTlv.GetSedBufferSize();
mParentCandidate.mSedDatagramCount = connectivityTlv.GetSedDatagramCount();
mParentCandidate.mLeaderData = leaderData;
mParentCandidate.mIsSingleton = connectivityTlv.GetActiveRouters() <= 1;
mParentCandidate.mIsSingleton = connectivityTlv.IsSingleton();
mParentCandidate.mLinkMargin = linkMargin;

exit:
Expand Down
9 changes: 9 additions & 0 deletions src/core/thread/mle_tlvs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,15 @@ class ConnectivityTlv : public Tlv, public TlvInfo<Tlv::kConnectivity>
*/
uint8_t GetActiveRouters(void) const { return mActiveRouters; }

/**
* Indicates whether or not the partition is a singleton based on Active Routers value.
*
* @retval TRUE The partition is a singleton.
* @retval FALSE The partition is not a singleton.
*
*/
bool IsSingleton(void) const { return (mActiveRouters <= 1); }

/**
* Sets the Active Routers value.
*
Expand Down

0 comments on commit b4ec4ce

Please sign in to comment.