[mle] add ConnectivityTlv::IsSingleton() (#10329)

This is used to simplify `Mle::HandleParentResponse()`.
This commit is contained in:
Abtin Keshavarzian
2024-06-03 18:25:54 -07:00
committed by GitHub
parent e1918b31c3
commit b4ec4ce365
2 changed files with 12 additions and 3 deletions
+3 -3
View File
@@ -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;
}
@@ -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);
}
@@ -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:
+9
View File
@@ -851,6 +851,15 @@ public:
*/
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.
*