[meshcop] rename dataset managers (#7630)

This commit renames dataset managers ActiveDataset and PendingDataset
to ActiveDatasetManager and PendingDatasetManager for readability.
This commit is contained in:
Yakun Xu
2022-04-25 12:49:08 -07:00
committed by GitHub
parent 092be22333
commit 9a2d84a4b7
16 changed files with 159 additions and 153 deletions
+17 -17
View File
@@ -44,63 +44,63 @@ using namespace ot;
bool otDatasetIsCommissioned(otInstance *aInstance)
{
return AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().IsCommissioned();
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().IsCommissioned();
}
otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset)
{
OT_ASSERT(aDataset != nullptr);
return AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().Read(AsCoreType(aDataset));
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Read(AsCoreType(aDataset));
}
otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset)
{
OT_ASSERT(aDataset != nullptr);
return AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().Read(*aDataset);
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Read(*aDataset);
}
otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset)
{
OT_ASSERT(aDataset != nullptr);
return AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().Save(AsCoreType(aDataset));
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Save(AsCoreType(aDataset));
}
otError otDatasetSetActiveTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset)
{
OT_ASSERT(aDataset != nullptr);
return AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().Save(*aDataset);
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Save(*aDataset);
}
otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDataset)
{
OT_ASSERT(aDataset != nullptr);
return AsCoreType(aInstance).Get<MeshCoP::PendingDataset>().Read(AsCoreType(aDataset));
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Read(AsCoreType(aDataset));
}
otError otDatasetGetPendingTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset)
{
OT_ASSERT(aDataset != nullptr);
return AsCoreType(aInstance).Get<MeshCoP::PendingDataset>().Read(*aDataset);
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Read(*aDataset);
}
otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset)
{
OT_ASSERT(aDataset != nullptr);
return AsCoreType(aInstance).Get<MeshCoP::PendingDataset>().Save(AsCoreType(aDataset));
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Save(AsCoreType(aDataset));
}
otError otDatasetSetPendingTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset)
{
OT_ASSERT(aDataset != nullptr);
return AsCoreType(aInstance).Get<MeshCoP::PendingDataset>().Save(*aDataset);
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Save(*aDataset);
}
otError otDatasetSendMgmtActiveGet(otInstance * aInstance,
@@ -109,8 +109,8 @@ otError otDatasetSendMgmtActiveGet(otInstance * aInstan
uint8_t aLength,
const otIp6Address * aAddress)
{
return AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().SendGetRequest(AsCoreType(aDatasetComponents), aTlvTypes,
aLength, aAddress);
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().SendGetRequest(AsCoreType(aDatasetComponents),
aTlvTypes, aLength, aAddress);
}
otError otDatasetSendMgmtActiveSet(otInstance * aInstance,
@@ -120,8 +120,8 @@ otError otDatasetSendMgmtActiveSet(otInstance * aInstance,
otDatasetMgmtSetCallback aCallback,
void * aContext)
{
return AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().SendSetRequest(AsCoreType(aDataset), aTlvs, aLength,
aCallback, aContext);
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().SendSetRequest(AsCoreType(aDataset), aTlvs,
aLength, aCallback, aContext);
}
otError otDatasetSendMgmtPendingGet(otInstance * aInstance,
@@ -130,8 +130,8 @@ otError otDatasetSendMgmtPendingGet(otInstance * aInsta
uint8_t aLength,
const otIp6Address * aAddress)
{
return AsCoreType(aInstance).Get<MeshCoP::PendingDataset>().SendGetRequest(AsCoreType(aDatasetComponents),
aTlvTypes, aLength, aAddress);
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().SendGetRequest(AsCoreType(aDatasetComponents),
aTlvTypes, aLength, aAddress);
}
otError otDatasetSendMgmtPendingSet(otInstance * aInstance,
@@ -141,8 +141,8 @@ otError otDatasetSendMgmtPendingSet(otInstance * aInstance,
otDatasetMgmtSetCallback aCallback,
void * aContext)
{
return AsCoreType(aInstance).Get<MeshCoP::PendingDataset>().SendSetRequest(AsCoreType(aDataset), aTlvs, aLength,
aCallback, aContext);
return AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().SendSetRequest(AsCoreType(aDataset), aTlvs,
aLength, aCallback, aContext);
}
#if OPENTHREAD_FTD
+1 -1
View File
@@ -44,7 +44,7 @@ using namespace ot;
otError otDatasetCreateNewNetwork(otInstance *aInstance, otOperationalDataset *aDataset)
{
return AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().CreateNewNetwork(AsCoreType(aDataset));
return AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().CreateNewNetwork(AsCoreType(aDataset));
}
uint32_t otDatasetGetDelayTimerMinimal(otInstance *aInstance)
+4 -4
View File
@@ -77,8 +77,8 @@ otError otLinkSetChannel(otInstance *aInstance, uint8_t aChannel)
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
SuccessOrExit(error = instance.Get<Mac::Mac>().SetPanChannel(aChannel));
instance.Get<MeshCoP::ActiveDataset>().Clear();
instance.Get<MeshCoP::PendingDataset>().Clear();
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
instance.Get<MeshCoP::PendingDatasetManager>().Clear();
exit:
return error;
@@ -141,8 +141,8 @@ otError otLinkSetPanId(otInstance *aInstance, otPanId aPanId)
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
instance.Get<Mac::Mac>().SetPanId(aPanId);
instance.Get<MeshCoP::ActiveDataset>().Clear();
instance.Get<MeshCoP::PendingDataset>().Clear();
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
instance.Get<MeshCoP::PendingDatasetManager>().Clear();
exit:
return error;
+10 -10
View File
@@ -72,8 +72,8 @@ otError otThreadSetExtendedPanId(otInstance *aInstance, const otExtendedPanId *a
prefix.SetFromExtendedPanId(extPanId);
instance.Get<Mle::MleRouter>().SetMeshLocalPrefix(prefix);
instance.Get<MeshCoP::ActiveDataset>().Clear();
instance.Get<MeshCoP::PendingDataset>().Clear();
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
instance.Get<MeshCoP::PendingDatasetManager>().Clear();
exit:
return error;
@@ -123,8 +123,8 @@ otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey)
instance.Get<KeyManager>().SetNetworkKey(AsCoreType(aKey));
instance.Get<MeshCoP::ActiveDataset>().Clear();
instance.Get<MeshCoP::PendingDataset>().Clear();
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
instance.Get<MeshCoP::PendingDatasetManager>().Clear();
exit:
return error;
@@ -141,8 +141,8 @@ otError otThreadSetNetworkKeyRef(otInstance *aInstance, otNetworkKeyRef aKeyRef)
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
instance.Get<KeyManager>().SetNetworkKeyRef((aKeyRef));
instance.Get<MeshCoP::ActiveDataset>().Clear();
instance.Get<MeshCoP::PendingDataset>().Clear();
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
instance.Get<MeshCoP::PendingDatasetManager>().Clear();
exit:
return error;
@@ -171,8 +171,8 @@ otError otThreadSetMeshLocalPrefix(otInstance *aInstance, const otMeshLocalPrefi
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
AsCoreType(aInstance).Get<Mle::MleRouter>().SetMeshLocalPrefix(AsCoreType(aMeshLocalPrefix));
AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().Clear();
AsCoreType(aInstance).Get<MeshCoP::PendingDataset>().Clear();
AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Clear();
AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Clear();
exit:
return error;
@@ -210,8 +210,8 @@ otError otThreadSetNetworkName(otInstance *aInstance, const char *aNetworkName)
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
error = AsCoreType(aInstance).Get<MeshCoP::NetworkNameManager>().SetNetworkName(aNetworkName);
AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().Clear();
AsCoreType(aInstance).Get<MeshCoP::PendingDataset>().Clear();
AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Clear();
AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Clear();
exit:
return error;
+4 -4
View File
@@ -296,8 +296,8 @@ otError otThreadSetPskc(otInstance *aInstance, const otPskc *aPskc)
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
AsCoreType(aInstance).Get<KeyManager>().SetPskc(AsCoreType(aPskc));
AsCoreType(aInstance).Get<MeshCoP::ActiveDataset>().Clear();
AsCoreType(aInstance).Get<MeshCoP::PendingDataset>().Clear();
AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Clear();
AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Clear();
exit:
return error;
@@ -313,8 +313,8 @@ otError otThreadSetPskcRef(otInstance *aInstance, otPskcRef aKeyRef)
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
instance.Get<KeyManager>().SetPskcRef(aKeyRef);
instance.Get<MeshCoP::ActiveDataset>().Clear();
instance.Get<MeshCoP::PendingDataset>().Clear();
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
instance.Get<MeshCoP::PendingDatasetManager>().Clear();
exit:
return error;
+2 -2
View File
@@ -713,12 +713,12 @@ template <> inline MeshCoP::NetworkNameManager &Instance::Get(void)
return mThreadNetif.mNetworkNameManager;
}
template <> inline MeshCoP::ActiveDataset &Instance::Get(void)
template <> inline MeshCoP::ActiveDatasetManager &Instance::Get(void)
{
return mThreadNetif.mActiveDataset;
}
template <> inline MeshCoP::PendingDataset &Instance::Get(void)
template <> inline MeshCoP::PendingDatasetManager &Instance::Get(void)
{
return mThreadNetif.mPendingDataset;
}
+40 -34
View File
@@ -268,7 +268,7 @@ void DatasetManager::SendSet(void)
Dataset pendingDataset;
Timestamp timestamp;
IgnoreError(Get<PendingDataset>().Read(pendingDataset));
IgnoreError(Get<PendingDatasetManager>().Read(pendingDataset));
if ((pendingDataset.GetTimestamp(Dataset::kActive, timestamp) == kErrorNone) &&
(Timestamp::Compare(&timestamp, mLocal.GetTimestamp()) == 0))
@@ -656,22 +656,22 @@ exit:
return error;
}
ActiveDataset::ActiveDataset(Instance &aInstance)
: DatasetManager(aInstance, Dataset::kActive, ActiveDataset::HandleTimer)
, mResourceGet(UriPath::kActiveGet, &ActiveDataset::HandleGet, this)
ActiveDatasetManager::ActiveDatasetManager(Instance &aInstance)
: DatasetManager(aInstance, Dataset::kActive, ActiveDatasetManager::HandleTimer)
, mResourceGet(UriPath::kActiveGet, &ActiveDatasetManager::HandleGet, this)
#if OPENTHREAD_FTD
, mResourceSet(UriPath::kActiveSet, &ActiveDataset::HandleSet, this)
, mResourceSet(UriPath::kActiveSet, &ActiveDatasetManager::HandleSet, this)
#endif
{
Get<Tmf::Agent>().AddResource(mResourceGet);
}
bool ActiveDataset::IsPartiallyComplete(void) const
bool ActiveDatasetManager::IsPartiallyComplete(void) const
{
return mLocal.IsSaved() && !mTimestampValid;
}
bool ActiveDataset::IsCommissioned(void) const
bool ActiveDatasetManager::IsCommissioned(void) const
{
Dataset::Info datasetInfo;
bool isValid = false;
@@ -685,7 +685,10 @@ exit:
return isValid;
}
Error ActiveDataset::Save(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint8_t aLength)
Error ActiveDatasetManager::Save(const Timestamp &aTimestamp,
const Message & aMessage,
uint16_t aOffset,
uint8_t aLength)
{
Error error = kErrorNone;
Dataset dataset;
@@ -698,39 +701,39 @@ exit:
return error;
}
void ActiveDataset::HandleGet(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
void ActiveDatasetManager::HandleGet(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
{
static_cast<ActiveDataset *>(aContext)->HandleGet(AsCoapMessage(aMessage), AsCoreType(aMessageInfo));
static_cast<ActiveDatasetManager *>(aContext)->HandleGet(AsCoapMessage(aMessage), AsCoreType(aMessageInfo));
}
void ActiveDataset::HandleGet(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo) const
void ActiveDatasetManager::HandleGet(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo) const
{
DatasetManager::HandleGet(aMessage, aMessageInfo);
}
void ActiveDataset::HandleTimer(Timer &aTimer)
void ActiveDatasetManager::HandleTimer(Timer &aTimer)
{
aTimer.Get<ActiveDataset>().HandleTimer();
aTimer.Get<ActiveDatasetManager>().HandleTimer();
}
PendingDataset::PendingDataset(Instance &aInstance)
: DatasetManager(aInstance, Dataset::kPending, PendingDataset::HandleTimer)
, mDelayTimer(aInstance, PendingDataset::HandleDelayTimer)
, mResourceGet(UriPath::kPendingGet, &PendingDataset::HandleGet, this)
PendingDatasetManager::PendingDatasetManager(Instance &aInstance)
: DatasetManager(aInstance, Dataset::kPending, PendingDatasetManager::HandleTimer)
, mDelayTimer(aInstance, PendingDatasetManager::HandleDelayTimer)
, mResourceGet(UriPath::kPendingGet, &PendingDatasetManager::HandleGet, this)
#if OPENTHREAD_FTD
, mResourceSet(UriPath::kPendingSet, &PendingDataset::HandleSet, this)
, mResourceSet(UriPath::kPendingSet, &PendingDatasetManager::HandleSet, this)
#endif
{
Get<Tmf::Agent>().AddResource(mResourceGet);
}
void PendingDataset::Clear(void)
void PendingDatasetManager::Clear(void)
{
DatasetManager::Clear();
mDelayTimer.Stop();
}
void PendingDataset::ClearNetwork(void)
void PendingDatasetManager::ClearNetwork(void)
{
Dataset dataset;
@@ -739,7 +742,7 @@ void PendingDataset::ClearNetwork(void)
IgnoreError(DatasetManager::Save(dataset));
}
Error PendingDataset::Save(const Dataset::Info &aDatasetInfo)
Error PendingDatasetManager::Save(const Dataset::Info &aDatasetInfo)
{
Error error;
@@ -750,7 +753,7 @@ exit:
return error;
}
Error PendingDataset::Save(const otOperationalDatasetTlvs &aDataset)
Error PendingDatasetManager::Save(const otOperationalDatasetTlvs &aDataset)
{
Error error;
@@ -761,7 +764,7 @@ exit:
return error;
}
Error PendingDataset::Save(const Dataset &aDataset)
Error PendingDatasetManager::Save(const Dataset &aDataset)
{
Error error;
@@ -772,7 +775,10 @@ exit:
return error;
}
Error PendingDataset::Save(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint8_t aLength)
Error PendingDatasetManager::Save(const Timestamp &aTimestamp,
const Message & aMessage,
uint16_t aOffset,
uint8_t aLength)
{
Error error = kErrorNone;
Dataset dataset;
@@ -786,7 +792,7 @@ exit:
return error;
}
void PendingDataset::StartDelayTimer(void)
void PendingDatasetManager::StartDelayTimer(void)
{
DelayTimerTlv *delayTimer;
Dataset dataset;
@@ -810,12 +816,12 @@ void PendingDataset::StartDelayTimer(void)
}
}
void PendingDataset::HandleDelayTimer(Timer &aTimer)
void PendingDatasetManager::HandleDelayTimer(Timer &aTimer)
{
aTimer.Get<PendingDataset>().HandleDelayTimer();
aTimer.Get<PendingDatasetManager>().HandleDelayTimer();
}
void PendingDataset::HandleDelayTimer(void)
void PendingDatasetManager::HandleDelayTimer(void)
{
DelayTimerTlv *delayTimer;
Dataset dataset;
@@ -840,7 +846,7 @@ void PendingDataset::HandleDelayTimer(void)
dataset.ConvertToActive();
Get<ActiveDataset>().Save(dataset);
Get<ActiveDatasetManager>().Save(dataset);
Clear();
@@ -848,19 +854,19 @@ exit:
return;
}
void PendingDataset::HandleGet(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
void PendingDatasetManager::HandleGet(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
{
static_cast<PendingDataset *>(aContext)->HandleGet(AsCoapMessage(aMessage), AsCoreType(aMessageInfo));
static_cast<PendingDatasetManager *>(aContext)->HandleGet(AsCoapMessage(aMessage), AsCoreType(aMessageInfo));
}
void PendingDataset::HandleGet(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo) const
void PendingDatasetManager::HandleGet(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo) const
{
DatasetManager::HandleGet(aMessage, aMessageInfo);
}
void PendingDataset::HandleTimer(Timer &aTimer)
void PendingDatasetManager::HandleTimer(Timer &aTimer)
{
aTimer.Get<PendingDataset>().HandleTimer();
aTimer.Get<PendingDatasetManager>().HandleTimer();
}
} // namespace MeshCoP
+6 -6
View File
@@ -363,16 +363,16 @@ private:
void * mMgmtSetCallbackContext;
};
class ActiveDataset : public DatasetManager, private NonCopyable
class ActiveDatasetManager : public DatasetManager, private NonCopyable
{
public:
/**
* This constructor initializes the ActiveDataset object.
* This constructor initializes the ActiveDatasetManager object.
*
* @param[in] aInstance A reference to the OpenThread instance.
*
*/
explicit ActiveDataset(Instance &aInstance);
explicit ActiveDatasetManager(Instance &aInstance);
/**
* This method indicates whether the Active Dataset is partially complete.
@@ -505,16 +505,16 @@ private:
#endif
};
class PendingDataset : public DatasetManager, private NonCopyable
class PendingDatasetManager : public DatasetManager, private NonCopyable
{
public:
/**
* This constructor initializes the PendingDataset object.
* This constructor initializes the PendingDatasetManager object.
*
* @param[in] aInstance A reference to the OpenThread instance.
*
*/
explicit PendingDataset(Instance &aInstance);
explicit PendingDatasetManager(Instance &aInstance);
/**
* This method clears the Pending Operational Dataset.
+15 -15
View File
@@ -159,7 +159,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo
if (GetType() == Dataset::kPending && (!hasNetworkKey || !doesAffectNetworkKey))
{
// no change to network key, active timestamp must be ahead
const Timestamp *localActiveTimestamp = Get<ActiveDataset>().GetTimestamp();
const Timestamp *localActiveTimestamp = Get<ActiveDatasetManager>().GetTimestamp();
VerifyOrExit(Timestamp::Compare(&activeTimestamp, localActiveTimestamp) > 0);
}
@@ -184,7 +184,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo
{
// Thread specification allows partial dataset changes for MGMT_ACTIVE_SET.req/MGMT_PENDING_SET.req
// from Commissioner based on existing active dataset.
IgnoreError(Get<ActiveDataset>().Read(dataset));
IgnoreError(Get<ActiveDatasetManager>().Read(dataset));
}
if (GetType() == Dataset::kPending || !doesAffectConnectivity)
@@ -232,7 +232,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo
}
else
{
Get<PendingDataset>().ApplyActiveDataset(activeTimestamp, aMessage);
Get<PendingDatasetManager>().ApplyActiveDataset(activeTimestamp, aMessage);
}
state = StateTlv::kAccept;
@@ -298,7 +298,7 @@ exit:
return error;
}
Error ActiveDataset::GenerateLocal(void)
Error ActiveDatasetManager::GenerateLocal(void)
{
Error error = kErrorNone;
Dataset dataset;
@@ -396,23 +396,23 @@ exit:
return error;
}
void ActiveDataset::StartLeader(void)
void ActiveDatasetManager::StartLeader(void)
{
IgnoreError(GenerateLocal());
Get<Tmf::Agent>().AddResource(mResourceSet);
}
void ActiveDataset::StopLeader(void)
void ActiveDatasetManager::StopLeader(void)
{
Get<Tmf::Agent>().RemoveResource(mResourceSet);
}
void ActiveDataset::HandleSet(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
void ActiveDatasetManager::HandleSet(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
{
static_cast<ActiveDataset *>(aContext)->HandleSet(AsCoapMessage(aMessage), AsCoreType(aMessageInfo));
static_cast<ActiveDatasetManager *>(aContext)->HandleSet(AsCoapMessage(aMessage), AsCoreType(aMessageInfo));
}
void ActiveDataset::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
void ActiveDatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
SuccessOrExit(DatasetManager::HandleSet(aMessage, aMessageInfo));
IgnoreError(ApplyConfiguration());
@@ -421,23 +421,23 @@ exit:
return;
}
void PendingDataset::StartLeader(void)
void PendingDatasetManager::StartLeader(void)
{
StartDelayTimer();
Get<Tmf::Agent>().AddResource(mResourceSet);
}
void PendingDataset::StopLeader(void)
void PendingDatasetManager::StopLeader(void)
{
Get<Tmf::Agent>().RemoveResource(mResourceSet);
}
void PendingDataset::HandleSet(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
void PendingDatasetManager::HandleSet(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
{
static_cast<PendingDataset *>(aContext)->HandleSet(AsCoapMessage(aMessage), AsCoreType(aMessageInfo));
static_cast<PendingDatasetManager *>(aContext)->HandleSet(AsCoapMessage(aMessage), AsCoreType(aMessageInfo));
}
void PendingDataset::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
void PendingDatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
SuccessOrExit(DatasetManager::HandleSet(aMessage, aMessageInfo));
StartDelayTimer();
@@ -446,7 +446,7 @@ exit:
return;
}
void PendingDataset::ApplyActiveDataset(const Timestamp &aTimestamp, Coap::Message &aMessage)
void PendingDatasetManager::ApplyActiveDataset(const Timestamp &aTimestamp, Coap::Message &aMessage)
{
uint16_t offset = aMessage.GetOffset();
Dataset dataset;
+6 -6
View File
@@ -113,7 +113,7 @@ void DatasetUpdater::PreparePendingDataset(void)
IgnoreError(mDataset->Read(0, requestedDataset));
error = Get<ActiveDataset>().Read(dataset);
error = Get<ActiveDatasetManager>().Read(dataset);
if (error != kErrorNone)
{
@@ -139,9 +139,9 @@ void DatasetUpdater::PreparePendingDataset(void)
{
Timestamp timestamp;
if (Get<PendingDataset>().GetTimestamp() != nullptr)
if (Get<PendingDatasetManager>().GetTimestamp() != nullptr)
{
timestamp = *Get<PendingDataset>().GetTimestamp();
timestamp = *Get<PendingDatasetManager>().GetTimestamp();
}
timestamp.AdvanceRandomTicks();
@@ -154,7 +154,7 @@ void DatasetUpdater::PreparePendingDataset(void)
tlv->GetTimestamp().AdvanceRandomTicks();
}
SuccessOrExit(error = Get<PendingDataset>().Save(dataset));
SuccessOrExit(error = Get<PendingDatasetManager>().Save(dataset));
exit:
if (error != kErrorNone)
@@ -187,7 +187,7 @@ void DatasetUpdater::HandleNotifierEvents(Events aEvents)
IgnoreError(mDataset->Read(0, requestedDataset));
if (aEvents.Contains(kEventActiveDatasetChanged) && Get<ActiveDataset>().Read(dataset) == kErrorNone)
if (aEvents.Contains(kEventActiveDatasetChanged) && Get<ActiveDatasetManager>().Read(dataset) == kErrorNone)
{
if (requestedDataset.IsSubsetOf(dataset))
{
@@ -199,7 +199,7 @@ void DatasetUpdater::HandleNotifierEvents(Events aEvents)
}
}
if (aEvents.Contains(kEventPendingDatasetChanged) && Get<PendingDataset>().Read(dataset) == kErrorNone)
if (aEvents.Contains(kEventPendingDatasetChanged) && Get<PendingDatasetManager>().Read(dataset) == kErrorNone)
{
if (!requestedDataset.IsSubsetOf(dataset))
{
+1 -1
View File
@@ -581,7 +581,7 @@ void Joiner::HandleJoinerEntrust(Coap::Message &aMessage, const Ip6::MessageInfo
datasetInfo.SetChannel(Get<Mac::Mac>().GetPanChannel());
datasetInfo.SetPanId(Get<Mac::Mac>().GetPanId());
IgnoreError(Get<ActiveDataset>().Save(datasetInfo));
IgnoreError(Get<ActiveDatasetManager>().Save(datasetInfo));
LogInfo("Joiner successful!");
+1 -1
View File
@@ -331,7 +331,7 @@ Coap::Message *JoinerRouter::PrepareJoinerEntrustMessage(void)
networkName.SetNetworkName(Get<NetworkNameManager>().GetNetworkName().GetAsData());
SuccessOrExit(error = networkName.AppendTo(*message));
IgnoreError(Get<ActiveDataset>().Read(dataset));
IgnoreError(Get<ActiveDatasetManager>().Read(dataset));
if ((tlv = dataset.GetTlv<ActiveTimestampTlv>()) != nullptr)
{
+1 -1
View File
@@ -252,7 +252,7 @@ void AnnounceSender::HandleActiveDatasetChanged(void)
{
Mac::ChannelMask channelMask;
SuccessOrExit(Get<MeshCoP::ActiveDataset>().GetChannelMask(channelMask));
SuccessOrExit(Get<MeshCoP::ActiveDatasetManager>().GetChannelMask(channelMask));
VerifyOrExit(!channelMask.IsEmpty());
VerifyOrExit(channelMask != GetChannelMask());
+27 -27
View File
@@ -244,8 +244,8 @@ void Mle::Stop(StopMode aMode)
{
if (aMode == kUpdateNetworkDatasets)
{
Get<MeshCoP::ActiveDataset>().HandleDetach();
Get<MeshCoP::PendingDataset>().HandleDetach();
Get<MeshCoP::ActiveDatasetManager>().HandleDetach();
Get<MeshCoP::PendingDatasetManager>().HandleDetach();
}
VerifyOrExit(!IsDisabled());
@@ -315,8 +315,8 @@ void Mle::Restore(void)
Settings::NetworkInfo networkInfo;
Settings::ParentInfo parentInfo;
IgnoreError(Get<MeshCoP::ActiveDataset>().Restore());
IgnoreError(Get<MeshCoP::PendingDataset>().Restore());
IgnoreError(Get<MeshCoP::ActiveDatasetManager>().Restore());
IgnoreError(Get<MeshCoP::PendingDatasetManager>().Restore());
#if OPENTHREAD_CONFIG_DUA_ENABLE
Get<DuaManager>().Restore();
@@ -481,7 +481,7 @@ Error Mle::BecomeDetached(void)
// not in reattach stage after reset
if (mReattachState == kReattachStop)
{
Get<MeshCoP::PendingDataset>().HandleDetach();
Get<MeshCoP::PendingDatasetManager>().HandleDetach();
}
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
@@ -521,7 +521,7 @@ void Mle::Attach(AttachMode aMode)
if (mReattachState == kReattachStart)
{
if (Get<MeshCoP::ActiveDataset>().Restore() == kErrorNone)
if (Get<MeshCoP::ActiveDatasetManager>().Restore() == kErrorNone)
{
mReattachState = kReattachActive;
}
@@ -1458,7 +1458,7 @@ Error Mle::AppendXtalAccuracy(Message &aMessage)
Error Mle::AppendActiveTimestamp(Message &aMessage)
{
Error error = kErrorNone;
const MeshCoP::Timestamp *timestamp = Get<MeshCoP::ActiveDataset>().GetTimestamp();
const MeshCoP::Timestamp *timestamp = Get<MeshCoP::ActiveDatasetManager>().GetTimestamp();
VerifyOrExit(timestamp != nullptr);
error = Tlv::Append<ActiveTimestampTlv>(aMessage, *timestamp);
@@ -1470,7 +1470,7 @@ exit:
Error Mle::AppendPendingTimestamp(Message &aMessage)
{
Error error = kErrorNone;
const MeshCoP::Timestamp *timestamp = Get<MeshCoP::PendingDataset>().GetTimestamp();
const MeshCoP::Timestamp *timestamp = Get<MeshCoP::PendingDatasetManager>().GetTimestamp();
VerifyOrExit(timestamp != nullptr && timestamp->GetSeconds() != 0);
error = Tlv::Append<PendingTimestampTlv>(aMessage, *timestamp);
@@ -1910,9 +1910,9 @@ bool Mle::PrepareAnnounceState(void)
Mac::ChannelMask channelMask;
VerifyOrExit(!IsChild() && (mReattachState == kReattachStop) &&
(Get<MeshCoP::ActiveDataset>().IsPartiallyComplete() || !IsFullThreadDevice()));
(Get<MeshCoP::ActiveDatasetManager>().IsPartiallyComplete() || !IsFullThreadDevice()));
if (Get<MeshCoP::ActiveDataset>().GetChannelMask(channelMask) != kErrorNone)
if (Get<MeshCoP::ActiveDatasetManager>().GetChannelMask(channelMask) != kErrorNone)
{
channelMask = Get<Mac::Mac>().GetSupportedChannelMask();
}
@@ -1936,9 +1936,9 @@ uint32_t Mle::Reattach(void)
if (mReattachState == kReattachActive)
{
if (Get<MeshCoP::PendingDataset>().Restore() == kErrorNone)
if (Get<MeshCoP::PendingDatasetManager>().Restore() == kErrorNone)
{
IgnoreError(Get<MeshCoP::PendingDataset>().ApplyConfiguration());
IgnoreError(Get<MeshCoP::PendingDatasetManager>().ApplyConfiguration());
mReattachState = kReattachPending;
SetAttachState(kAttachStateStart);
delay = 1 + Random::NonCrypto::GetUint32InRange(0, kAttachStartJitter);
@@ -1951,7 +1951,7 @@ uint32_t Mle::Reattach(void)
else if (mReattachState == kReattachPending)
{
mReattachState = kReattachStop;
IgnoreError(Get<MeshCoP::ActiveDataset>().Restore());
IgnoreError(Get<MeshCoP::ActiveDatasetManager>().Restore());
}
VerifyOrExit(mReattachState == kReattachStop);
@@ -2617,7 +2617,7 @@ Error Mle::GetNextAnnouceChannel(uint8_t &aChannel) const
Mac::ChannelMask channelMask;
if (Get<MeshCoP::ActiveDataset>().GetChannelMask(channelMask) != kErrorNone)
if (Get<MeshCoP::ActiveDatasetManager>().GetChannelMask(channelMask) != kErrorNone)
{
channelMask = Get<Mac::Mac>().GetSupportedChannelMask();
}
@@ -3221,7 +3221,7 @@ Error Mle::HandleLeaderData(RxInfo &aRxInfo)
case kErrorNone:
hasActiveTimestamp = true;
timestamp = Get<MeshCoP::ActiveDataset>().GetTimestamp();
timestamp = Get<MeshCoP::ActiveDatasetManager>().GetTimestamp();
// if received timestamp does not match the local value and message does not contain the dataset,
// send MLE Data Request
@@ -3246,7 +3246,7 @@ Error Mle::HandleLeaderData(RxInfo &aRxInfo)
case kErrorNone:
hasPendingTimestamp = true;
timestamp = Get<MeshCoP::PendingDataset>().GetTimestamp();
timestamp = Get<MeshCoP::PendingDatasetManager>().GetTimestamp();
// if received timestamp does not match the local value and message does not contain the dataset,
// send MLE Data Request
@@ -3291,8 +3291,8 @@ Error Mle::HandleLeaderData(RxInfo &aRxInfo)
if (activeDatasetOffset > 0)
{
IgnoreError(aRxInfo.mMessage.Read(activeDatasetOffset, tlv));
IgnoreError(Get<MeshCoP::ActiveDataset>().Save(activeTimestamp, aRxInfo.mMessage,
activeDatasetOffset + sizeof(tlv), tlv.GetLength()));
IgnoreError(Get<MeshCoP::ActiveDatasetManager>().Save(
activeTimestamp, aRxInfo.mMessage, activeDatasetOffset + sizeof(tlv), tlv.GetLength()));
}
}
@@ -3302,8 +3302,8 @@ Error Mle::HandleLeaderData(RxInfo &aRxInfo)
if (pendingDatasetOffset > 0)
{
IgnoreError(aRxInfo.mMessage.Read(pendingDatasetOffset, tlv));
IgnoreError(Get<MeshCoP::PendingDataset>().Save(pendingTimestamp, aRxInfo.mMessage,
pendingDatasetOffset + sizeof(tlv), tlv.GetLength()));
IgnoreError(Get<MeshCoP::PendingDatasetManager>().Save(
pendingTimestamp, aRxInfo.mMessage, pendingDatasetOffset + sizeof(tlv), tlv.GetLength()));
}
}
}
@@ -3690,8 +3690,8 @@ void Mle::HandleChildIdResponse(RxInfo &aRxInfo)
if (Tlv::FindTlvOffset(aRxInfo.mMessage, Tlv::kActiveDataset, offset) == kErrorNone)
{
IgnoreError(aRxInfo.mMessage.Read(offset, tlv));
SuccessOrExit(error = Get<MeshCoP::ActiveDataset>().Save(timestamp, aRxInfo.mMessage, offset + sizeof(tlv),
tlv.GetLength()));
SuccessOrExit(error = Get<MeshCoP::ActiveDatasetManager>().Save(timestamp, aRxInfo.mMessage,
offset + sizeof(tlv), tlv.GetLength()));
}
break;
@@ -3705,7 +3705,7 @@ void Mle::HandleChildIdResponse(RxInfo &aRxInfo)
// clear Pending Dataset if device succeed to reattach using stored Pending Dataset
if (mReattachState == kReattachPending)
{
Get<MeshCoP::PendingDataset>().Clear();
Get<MeshCoP::PendingDatasetManager>().Clear();
}
// Pending Timestamp
@@ -3716,13 +3716,13 @@ void Mle::HandleChildIdResponse(RxInfo &aRxInfo)
if (Tlv::FindTlvOffset(aRxInfo.mMessage, Tlv::kPendingDataset, offset) == kErrorNone)
{
IgnoreError(aRxInfo.mMessage.Read(offset, tlv));
IgnoreError(Get<MeshCoP::PendingDataset>().Save(timestamp, aRxInfo.mMessage, offset + sizeof(tlv),
tlv.GetLength()));
IgnoreError(Get<MeshCoP::PendingDatasetManager>().Save(timestamp, aRxInfo.mMessage, offset + sizeof(tlv),
tlv.GetLength()));
}
break;
case kErrorNotFound:
Get<MeshCoP::PendingDataset>().ClearNetwork();
Get<MeshCoP::PendingDatasetManager>().ClearNetwork();
break;
default:
@@ -4033,7 +4033,7 @@ void Mle::HandleAnnounce(RxInfo &aRxInfo)
SuccessOrExit(error = Tlv::Find<ActiveTimestampTlv>(aRxInfo.mMessage, timestamp));
SuccessOrExit(error = Tlv::Find<PanIdTlv>(aRxInfo.mMessage, panId));
localTimestamp = Get<MeshCoP::ActiveDataset>().GetTimestamp();
localTimestamp = Get<MeshCoP::ActiveDatasetManager>().GetTimestamp();
if (MeshCoP::Timestamp::Compare(&timestamp, localTimestamp) > 0)
{
+13 -13
View File
@@ -228,7 +228,7 @@ Error MleRouter::BecomeLeader(void)
uint8_t maxRouterId;
#endif
VerifyOrExit(!Get<MeshCoP::ActiveDataset>().IsPartiallyComplete(), error = kErrorInvalidState);
VerifyOrExit(!Get<MeshCoP::ActiveDatasetManager>().IsPartiallyComplete(), error = kErrorInvalidState);
VerifyOrExit(!IsDisabled(), error = kErrorInvalidState);
VerifyOrExit(!IsLeader(), error = kErrorNone);
VerifyOrExit(IsRouterEligible(), error = kErrorNotCapable);
@@ -277,8 +277,8 @@ void MleRouter::StopLeader(void)
{
Get<Tmf::Agent>().RemoveResource(mAddressSolicit);
Get<Tmf::Agent>().RemoveResource(mAddressRelease);
Get<MeshCoP::ActiveDataset>().StopLeader();
Get<MeshCoP::PendingDataset>().StopLeader();
Get<MeshCoP::ActiveDatasetManager>().StopLeader();
Get<MeshCoP::PendingDatasetManager>().StopLeader();
StopAdvertiseTrickleTimer();
Get<NetworkData::Leader>().Stop();
Get<ThreadNetif>().UnsubscribeAllRoutersMulticast();
@@ -401,8 +401,8 @@ void MleRouter::SetStateRouter(uint16_t aRloc16)
void MleRouter::SetStateLeader(uint16_t aRloc16)
{
IgnoreError(Get<MeshCoP::ActiveDataset>().Restore());
IgnoreError(Get<MeshCoP::PendingDataset>().Restore());
IgnoreError(Get<MeshCoP::ActiveDatasetManager>().Restore());
IgnoreError(Get<MeshCoP::PendingDatasetManager>().Restore());
SetRloc16(aRloc16);
SetRole(kRoleLeader);
@@ -420,8 +420,8 @@ void MleRouter::SetStateLeader(uint16_t aRloc16)
Get<TimeTicker>().RegisterReceiver(TimeTicker::kMleRouter);
Get<NetworkData::Leader>().Start();
Get<MeshCoP::ActiveDataset>().StartLeader();
Get<MeshCoP::PendingDataset>().StartLeader();
Get<MeshCoP::ActiveDatasetManager>().StartLeader();
Get<MeshCoP::PendingDatasetManager>().StartLeader();
Get<Tmf::Agent>().AddResource(mAddressSolicit);
Get<Tmf::Agent>().AddResource(mAddressRelease);
Get<Ip6::Ip6>().SetForwardingEnabled(true);
@@ -2295,7 +2295,7 @@ void MleRouter::HandleChildIdRequest(RxInfo &aRxInfo)
{
case kErrorNone:
needsActiveDatasetTlv =
(MeshCoP::Timestamp::Compare(&timestamp, Get<MeshCoP::ActiveDataset>().GetTimestamp()) != 0);
(MeshCoP::Timestamp::Compare(&timestamp, Get<MeshCoP::ActiveDatasetManager>().GetTimestamp()) != 0);
break;
case kErrorNotFound:
break;
@@ -2309,7 +2309,7 @@ void MleRouter::HandleChildIdRequest(RxInfo &aRxInfo)
{
case kErrorNone:
needsPendingDatasetTlv =
(MeshCoP::Timestamp::Compare(&timestamp, Get<MeshCoP::PendingDataset>().GetTimestamp()) != 0);
(MeshCoP::Timestamp::Compare(&timestamp, Get<MeshCoP::PendingDatasetManager>().GetTimestamp()) != 0);
break;
case kErrorNotFound:
break;
@@ -2759,7 +2759,7 @@ void MleRouter::HandleDataRequest(RxInfo &aRxInfo)
switch (Tlv::Find<ActiveTimestampTlv>(aRxInfo.mMessage, timestamp))
{
case kErrorNone:
if (MeshCoP::Timestamp::Compare(&timestamp, Get<MeshCoP::ActiveDataset>().GetTimestamp()) == 0)
if (MeshCoP::Timestamp::Compare(&timestamp, Get<MeshCoP::ActiveDatasetManager>().GetTimestamp()) == 0)
{
break;
}
@@ -2778,7 +2778,7 @@ void MleRouter::HandleDataRequest(RxInfo &aRxInfo)
switch (Tlv::Find<PendingTimestampTlv>(aRxInfo.mMessage, timestamp))
{
case kErrorNone:
if (MeshCoP::Timestamp::Compare(&timestamp, Get<MeshCoP::PendingDataset>().GetTimestamp()) == 0)
if (MeshCoP::Timestamp::Compare(&timestamp, Get<MeshCoP::PendingDatasetManager>().GetTimestamp()) == 0)
{
break;
}
@@ -4246,12 +4246,12 @@ Error MleRouter::AppendRoute(Message &aMessage, Neighbor *aNeighbor)
Error MleRouter::AppendActiveDataset(Message &aMessage)
{
return Get<MeshCoP::ActiveDataset>().AppendMleDatasetTlv(aMessage);
return Get<MeshCoP::ActiveDatasetManager>().AppendMleDatasetTlv(aMessage);
}
Error MleRouter::AppendPendingDataset(Message &aMessage)
{
return Get<MeshCoP::PendingDataset>().AppendMleDatasetTlv(aMessage);
return Get<MeshCoP::PendingDatasetManager>().AppendMleDatasetTlv(aMessage);
}
bool MleRouter::HasMinDowngradeNeighborRouters(void)
+11 -11
View File
@@ -199,17 +199,17 @@ private:
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
Sntp::Client mSntpClient;
#endif
MeshCoP::ActiveDataset mActiveDataset;
MeshCoP::PendingDataset mPendingDataset;
MeshCoP::ExtendedPanIdManager mExtendedPanIdManager;
MeshCoP::NetworkNameManager mNetworkNameManager;
Ip6::Filter mIp6Filter;
KeyManager mKeyManager;
Lowpan::Lowpan mLowpan;
Mac::Mac mMac;
MeshForwarder mMeshForwarder;
Mle::MleRouter mMleRouter;
Mle::DiscoverScanner mDiscoverScanner;
MeshCoP::ActiveDatasetManager mActiveDataset;
MeshCoP::PendingDatasetManager mPendingDataset;
MeshCoP::ExtendedPanIdManager mExtendedPanIdManager;
MeshCoP::NetworkNameManager mNetworkNameManager;
Ip6::Filter mIp6Filter;
KeyManager mKeyManager;
Lowpan::Lowpan mLowpan;
Mac::Mac mMac;
MeshForwarder mMeshForwarder;
Mle::MleRouter mMleRouter;
Mle::DiscoverScanner mDiscoverScanner;
#if OPENTHREAD_CONFIG_MULTI_RADIO
RadioSelector mRadioSelector;
#endif