mirror of
https://github.com/espressif/openthread.git
synced 2026-08-15 23:27:47 +00:00
[mle] add ConnectivityTlv::IsSingleton() (#10329)
This is used to simplify `Mle::HandleParentResponse()`.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user