mirror of
https://github.com/espressif/openthread.git
synced 2026-07-24 13:04:07 +00:00
[network-data] add IncrementVersionAndStableVersion() (#4781)
This commit replaces `IncrementStableVersion()` with a new method `IncrementVersionAndStableVersion()` which increments both version and stable version. It helps simplify its use by other modules and also ensures stable version is not updated without version. This commit also adds a common private `IncrementVersions()` used by other methods in `NetworkData::Leader`.
This commit is contained in:
committed by
GitHub
parent
03aba30cd5
commit
74ff650cf1
@@ -163,11 +163,7 @@ otError DatasetManager::Save(const Dataset &aDataset)
|
||||
mLocal.Save(aDataset);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
if (Get<Mle::MleRouter>().GetRole() == OT_DEVICE_ROLE_LEADER)
|
||||
{
|
||||
Get<NetworkData::Leader>().IncrementVersion();
|
||||
Get<NetworkData::Leader>().IncrementStableVersion();
|
||||
}
|
||||
Get<NetworkData::Leader>().IncrementVersionAndStableVersion();
|
||||
#endif
|
||||
}
|
||||
else if (compare < 0)
|
||||
@@ -201,8 +197,7 @@ otError DatasetManager::Save(const otOperationalDataset &aDataset)
|
||||
|
||||
case OT_DEVICE_ROLE_LEADER:
|
||||
Restore();
|
||||
Get<NetworkData::Leader>().IncrementVersion();
|
||||
Get<NetworkData::Leader>().IncrementStableVersion();
|
||||
Get<NetworkData::Leader>().IncrementVersionAndStableVersion();
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -242,8 +242,7 @@ otError DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInf
|
||||
}
|
||||
|
||||
SuccessOrExit(Save(dataset));
|
||||
Get<NetworkData::Leader>().IncrementVersion();
|
||||
Get<NetworkData::Leader>().IncrementStableVersion();
|
||||
Get<NetworkData::Leader>().IncrementVersionAndStableVersion();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -94,17 +94,27 @@ void Leader::IncrementVersion(void)
|
||||
{
|
||||
if (Get<Mle::MleRouter>().GetRole() == OT_DEVICE_ROLE_LEADER)
|
||||
{
|
||||
mVersion++;
|
||||
Get<Notifier>().Signal(OT_CHANGED_THREAD_NETDATA);
|
||||
IncrementVersions(/* aIncludeStable */ false);
|
||||
}
|
||||
}
|
||||
|
||||
void Leader::IncrementStableVersion(void)
|
||||
void Leader::IncrementVersionAndStableVersion(void)
|
||||
{
|
||||
if (Get<Mle::MleRouter>().GetRole() == OT_DEVICE_ROLE_LEADER)
|
||||
{
|
||||
IncrementVersions(/* aIncludeStable */ true);
|
||||
}
|
||||
}
|
||||
|
||||
void Leader::IncrementVersions(bool aIncludeStable)
|
||||
{
|
||||
if (aIncludeStable)
|
||||
{
|
||||
mStableVersion++;
|
||||
}
|
||||
|
||||
mVersion++;
|
||||
Get<Notifier>().Signal(OT_CHANGED_THREAD_NETDATA);
|
||||
}
|
||||
|
||||
uint32_t Leader::GetContextIdReuseDelay(void) const
|
||||
@@ -125,15 +135,7 @@ void Leader::RemoveBorderRouter(uint16_t aRloc16, MatchMode aMatchMode)
|
||||
RlocLookup(aRloc16, rlocIn, rlocStable, mTlvs, mLength, aMatchMode);
|
||||
VerifyOrExit(rlocIn);
|
||||
RemoveRloc(aRloc16, aMatchMode);
|
||||
|
||||
mVersion++;
|
||||
|
||||
if (rlocStable)
|
||||
{
|
||||
mStableVersion++;
|
||||
}
|
||||
|
||||
Get<Notifier>().Signal(OT_CHANGED_THREAD_NETDATA);
|
||||
IncrementVersions(rlocStable);
|
||||
|
||||
exit:
|
||||
return;
|
||||
@@ -759,15 +761,7 @@ otError Leader::RegisterNetworkData(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aT
|
||||
}
|
||||
|
||||
SuccessOrExit(error = AddNetworkData(aTlvs, aTlvsLength, oldTlvs, oldTlvsLength));
|
||||
|
||||
mVersion++;
|
||||
|
||||
if (rlocStable)
|
||||
{
|
||||
mStableVersion++;
|
||||
}
|
||||
|
||||
Get<Notifier>().Signal(OT_CHANGED_THREAD_NETDATA);
|
||||
IncrementVersions(rlocStable);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -1160,9 +1154,7 @@ void Leader::FreeContext(uint8_t aContextId)
|
||||
otLogInfoNetData("Free Context Id = %d", aContextId);
|
||||
RemoveContext(aContextId);
|
||||
mContextUsed &= ~(1 << aContextId);
|
||||
mVersion++;
|
||||
mStableVersion++;
|
||||
Get<Notifier>().Signal(OT_CHANGED_THREAD_NETDATA);
|
||||
IncrementVersions(/* aIncludeStable */ true);
|
||||
}
|
||||
|
||||
void Leader::StartContextReuseTimer(uint8_t aContextId)
|
||||
|
||||
@@ -108,10 +108,10 @@ public:
|
||||
void IncrementVersion(void);
|
||||
|
||||
/**
|
||||
* This method increments the Thread Network Data stable version.
|
||||
* This method increments both the Thread Network Data version and stable version.
|
||||
*
|
||||
*/
|
||||
void IncrementStableVersion(void);
|
||||
void IncrementVersionAndStableVersion(void);
|
||||
|
||||
/**
|
||||
* This method returns CONTEXT_ID_RESUSE_DELAY value.
|
||||
@@ -230,6 +230,7 @@ private:
|
||||
void SendCommissioningSetResponse(const Coap::Message & aRequest,
|
||||
const Ip6::MessageInfo & aMessageInfo,
|
||||
MeshCoP::StateTlv::State aState);
|
||||
void IncrementVersions(bool aIncludeStable);
|
||||
|
||||
/**
|
||||
* Thread Specification Constants.
|
||||
|
||||
Reference in New Issue
Block a user