mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 07:07:47 +00:00
[dataset] add ApplyConfiguration() overload without default parameter (#10013)
This commit is contained in:
@@ -509,7 +509,14 @@ void Dataset::RemoveTlv(Tlv *aTlv)
|
||||
}
|
||||
}
|
||||
|
||||
Error Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsNetworkKeyUpdated) const
|
||||
Error Dataset::ApplyConfiguration(Instance &aInstance) const
|
||||
{
|
||||
bool isNetworkKeyUpdated;
|
||||
|
||||
return ApplyConfiguration(aInstance, isNetworkKeyUpdated);
|
||||
}
|
||||
|
||||
Error Dataset::ApplyConfiguration(Instance &aInstance, bool &aIsNetworkKeyUpdated) const
|
||||
{
|
||||
Mac::Mac &mac = aInstance.Get<Mac::Mac>();
|
||||
KeyManager &keyManager = aInstance.Get<KeyManager>();
|
||||
@@ -517,10 +524,7 @@ Error Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsNetworkKeyUpdate
|
||||
|
||||
VerifyOrExit(IsValid(), error = kErrorParse);
|
||||
|
||||
if (aIsNetworkKeyUpdated)
|
||||
{
|
||||
*aIsNetworkKeyUpdated = false;
|
||||
}
|
||||
aIsNetworkKeyUpdated = false;
|
||||
|
||||
for (const Tlv *cur = GetTlvsStart(); cur < GetTlvsEnd(); cur = cur->GetNext())
|
||||
{
|
||||
@@ -559,9 +563,9 @@ Error Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsNetworkKeyUpdate
|
||||
|
||||
keyManager.GetNetworkKey(networkKey);
|
||||
|
||||
if (aIsNetworkKeyUpdated && (cur->ReadValueAs<NetworkKeyTlv>() != networkKey))
|
||||
if (cur->ReadValueAs<NetworkKeyTlv>() != networkKey)
|
||||
{
|
||||
*aIsNetworkKeyUpdated = true;
|
||||
aIsNetworkKeyUpdated = true;
|
||||
}
|
||||
|
||||
keyManager.SetNetworkKey(cur->ReadValueAs<NetworkKeyTlv>());
|
||||
@@ -569,11 +573,9 @@ Error Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsNetworkKeyUpdate
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
case Tlv::kPskc:
|
||||
keyManager.SetPskc(cur->ReadValueAs<PskcTlv>());
|
||||
break;
|
||||
|
||||
#endif
|
||||
|
||||
case Tlv::kMeshLocalPrefix:
|
||||
|
||||
@@ -886,13 +886,24 @@ public:
|
||||
* Applies the Active or Pending Dataset to the Thread interface.
|
||||
*
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
* @param[out] aIsNetworkKeyUpdated A pointer to where to place whether network key was updated.
|
||||
*
|
||||
* @retval kErrorNone Successfully applied configuration.
|
||||
* @retval kErrorParse The dataset has at least one TLV with invalid format.
|
||||
*
|
||||
*/
|
||||
Error ApplyConfiguration(Instance &aInstance, bool *aIsNetworkKeyUpdated = nullptr) const;
|
||||
Error ApplyConfiguration(Instance &aInstance) const;
|
||||
|
||||
/**
|
||||
* Applies the Active or Pending Dataset to the Thread interface.
|
||||
*
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
* @param[out] aIsNetworkKeyUpdated Variable to return whether network key was updated.
|
||||
*
|
||||
* @retval kErrorNone Successfully applied configuration, @p aIsNetworkKeyUpdated is changed.
|
||||
* @retval kErrorParse The dataset has at least one TLV with invalid format.
|
||||
*
|
||||
*/
|
||||
Error ApplyConfiguration(Instance &aInstance, bool &aIsNetworkKeyUpdated) const;
|
||||
|
||||
/**
|
||||
* Converts a Pending Dataset to an Active Dataset.
|
||||
|
||||
@@ -124,7 +124,7 @@ Error DatasetManager::Save(const Dataset &aDataset)
|
||||
|
||||
if (IsActiveDataset())
|
||||
{
|
||||
SuccessOrExit(error = aDataset.ApplyConfiguration(GetInstance(), &isNetworkKeyUpdated));
|
||||
SuccessOrExit(error = aDataset.ApplyConfiguration(GetInstance(), isNetworkKeyUpdated));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user