mirror of
https://github.com/espressif/openthread.git
synced 2026-08-11 05:07:47 +00:00
[dataset] add 'Info' and 'Components' types (#5733)
This commit adds `Dataset::Info` and `Dataset::Components` types mirroring `otOperationalDataset` & `otOperationalDatasetComponents` definitions and providing helper methods to get/set different fields in the dataset.
This commit is contained in:
@@ -44,17 +44,9 @@ using namespace ot;
|
||||
|
||||
bool otDatasetIsCommissioned(otInstance *aInstance)
|
||||
{
|
||||
otOperationalDataset dataset;
|
||||
bool rval = false;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
SuccessOrExit(otDatasetGetActive(aInstance, &dataset));
|
||||
|
||||
rval = ((dataset.mComponents.mIsMasterKeyPresent) && (dataset.mComponents.mIsNetworkNamePresent) &&
|
||||
(dataset.mComponents.mIsExtendedPanIdPresent) && (dataset.mComponents.mIsPanIdPresent) &&
|
||||
(dataset.mComponents.mIsChannelPresent));
|
||||
|
||||
exit:
|
||||
return rval;
|
||||
return instance.Get<MeshCoP::ActiveDataset>().IsCommissioned();
|
||||
}
|
||||
|
||||
otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset)
|
||||
@@ -63,7 +55,7 @@ otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset
|
||||
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
|
||||
return instance.Get<MeshCoP::ActiveDataset>().Read(*aDataset);
|
||||
return instance.Get<MeshCoP::ActiveDataset>().Read(*static_cast<MeshCoP::Dataset::Info *>(aDataset));
|
||||
}
|
||||
|
||||
otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset)
|
||||
@@ -81,7 +73,7 @@ otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aD
|
||||
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
|
||||
return instance.Get<MeshCoP::ActiveDataset>().Save(*aDataset);
|
||||
return instance.Get<MeshCoP::ActiveDataset>().Save(*static_cast<const MeshCoP::Dataset::Info *>(aDataset));
|
||||
}
|
||||
|
||||
otError otDatasetSetActiveTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset)
|
||||
@@ -99,7 +91,7 @@ otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDatase
|
||||
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
|
||||
return instance.Get<MeshCoP::PendingDataset>().Read(*aDataset);
|
||||
return instance.Get<MeshCoP::PendingDataset>().Read(*static_cast<MeshCoP::Dataset::Info *>(aDataset));
|
||||
}
|
||||
|
||||
otError otDatasetGetPendingTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset)
|
||||
@@ -117,7 +109,7 @@ otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *a
|
||||
|
||||
OT_ASSERT(aDataset != nullptr);
|
||||
|
||||
return instance.Get<MeshCoP::PendingDataset>().Save(*aDataset);
|
||||
return instance.Get<MeshCoP::PendingDataset>().Save(*static_cast<const MeshCoP::Dataset::Info *>(aDataset));
|
||||
}
|
||||
|
||||
otError otDatasetSetPendingTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset)
|
||||
@@ -137,7 +129,8 @@ otError otDatasetSendMgmtActiveGet(otInstance * aInstan
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.Get<MeshCoP::ActiveDataset>().SendGetRequest(*aDatasetComponents, aTlvTypes, aLength, aAddress);
|
||||
return instance.Get<MeshCoP::ActiveDataset>().SendGetRequest(
|
||||
*static_cast<const MeshCoP::Dataset::Components *>(aDatasetComponents), aTlvTypes, aLength, aAddress);
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtActiveSet(otInstance * aInstance,
|
||||
@@ -147,7 +140,8 @@ otError otDatasetSendMgmtActiveSet(otInstance * aInstance,
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.Get<MeshCoP::ActiveDataset>().SendSetRequest(*aDataset, aTlvs, aLength);
|
||||
return instance.Get<MeshCoP::ActiveDataset>().SendSetRequest(*static_cast<const MeshCoP::Dataset::Info *>(aDataset),
|
||||
aTlvs, aLength);
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtPendingGet(otInstance * aInstance,
|
||||
@@ -158,7 +152,8 @@ otError otDatasetSendMgmtPendingGet(otInstance * aInsta
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.Get<MeshCoP::PendingDataset>().SendGetRequest(*aDatasetComponents, aTlvTypes, aLength, aAddress);
|
||||
return instance.Get<MeshCoP::PendingDataset>().SendGetRequest(
|
||||
*static_cast<const MeshCoP::Dataset::Components *>(aDatasetComponents), aTlvTypes, aLength, aAddress);
|
||||
}
|
||||
|
||||
otError otDatasetSendMgmtPendingSet(otInstance * aInstance,
|
||||
@@ -168,7 +163,8 @@ otError otDatasetSendMgmtPendingSet(otInstance * aInstance,
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.Get<MeshCoP::PendingDataset>().SendSetRequest(*aDataset, aTlvs, aLength);
|
||||
return instance.Get<MeshCoP::PendingDataset>().SendSetRequest(
|
||||
*static_cast<const MeshCoP::Dataset::Info *>(aDataset), aTlvs, aLength);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
@@ -46,7 +46,7 @@ otError otDatasetCreateNewNetwork(otInstance *aInstance, otOperationalDataset *a
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.Get<MeshCoP::ActiveDataset>().CreateNewNetwork(*aDataset);
|
||||
return instance.Get<MeshCoP::ActiveDataset>().CreateNewNetwork(*static_cast<MeshCoP::Dataset::Info *>(aDataset));
|
||||
}
|
||||
|
||||
uint32_t otDatasetGetDelayTimerMinimal(otInstance *aInstance)
|
||||
|
||||
@@ -48,6 +48,53 @@
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
|
||||
otError Dataset::Info::GenerateRandom(Instance &aInstance)
|
||||
{
|
||||
otError error;
|
||||
Mac::ChannelMask supportedChannels = aInstance.Get<Mac::Mac>().GetSupportedChannelMask();
|
||||
Mac::ChannelMask preferredChannels(aInstance.Get<Radio>().GetPreferredChannelMask());
|
||||
|
||||
// If the preferred channel mask is not empty, select a random
|
||||
// channel from it, otherwise choose one from the supported
|
||||
// channel mask.
|
||||
|
||||
preferredChannels.Intersect(supportedChannels);
|
||||
|
||||
if (preferredChannels.IsEmpty())
|
||||
{
|
||||
preferredChannels = supportedChannels;
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
||||
mActiveTimestamp = 1;
|
||||
mChannel = preferredChannels.ChooseRandomChannel();
|
||||
mChannelMask = supportedChannels.GetMask();
|
||||
mSecurityPolicy.mFlags = aInstance.Get<KeyManager>().GetSecurityPolicyFlags();
|
||||
mPanId = Mac::GenerateRandomPanId();
|
||||
|
||||
SuccessOrExit(error = static_cast<MasterKey &>(mMasterKey).GenerateRandom());
|
||||
SuccessOrExit(error = static_cast<Pskc &>(mPskc).GenerateRandom());
|
||||
SuccessOrExit(error = Random::Crypto::FillBuffer(mExtendedPanId.m8, sizeof(mExtendedPanId.m8)));
|
||||
SuccessOrExit(error = static_cast<Ip6::NetworkPrefix &>(mMeshLocalPrefix).GenerateRandomUla());
|
||||
|
||||
snprintf(mNetworkName.m8, sizeof(mNetworkName), "OpenThread-%04x", mPanId);
|
||||
|
||||
mComponents.mIsActiveTimestampPresent = true;
|
||||
mComponents.mIsMasterKeyPresent = true;
|
||||
mComponents.mIsNetworkNamePresent = true;
|
||||
mComponents.mIsExtendedPanIdPresent = true;
|
||||
mComponents.mIsMeshLocalPrefixPresent = true;
|
||||
mComponents.mIsPanIdPresent = true;
|
||||
mComponents.mIsChannelPresent = true;
|
||||
mComponents.mIsPskcPresent = true;
|
||||
mComponents.mIsSecurityPolicyPresent = true;
|
||||
mComponents.mIsChannelMaskPresent = true;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Dataset::Dataset(Type aType)
|
||||
: mUpdateTime(0)
|
||||
, mLength(0)
|
||||
@@ -80,84 +127,70 @@ const Tlv *Dataset::GetTlv(Tlv::Type aType) const
|
||||
return Tlv::FindTlv(mTlvs, mLength, aType);
|
||||
}
|
||||
|
||||
void Dataset::ConvertTo(otOperationalDataset &aDataset) const
|
||||
void Dataset::ConvertTo(Info &aDatasetInfo) const
|
||||
{
|
||||
memset(&aDataset, 0, sizeof(aDataset));
|
||||
aDatasetInfo.Clear();
|
||||
|
||||
for (const Tlv *cur = GetTlvsStart(); cur < GetTlvsEnd(); cur = cur->GetNext())
|
||||
{
|
||||
switch (cur->GetType())
|
||||
{
|
||||
case Tlv::kActiveTimestamp:
|
||||
aDataset.mActiveTimestamp = static_cast<const ActiveTimestampTlv *>(cur)->GetSeconds();
|
||||
aDataset.mComponents.mIsActiveTimestampPresent = true;
|
||||
aDatasetInfo.SetActiveTimestamp(static_cast<const ActiveTimestampTlv *>(cur)->GetSeconds());
|
||||
break;
|
||||
|
||||
case Tlv::kChannel:
|
||||
aDataset.mChannel = static_cast<const ChannelTlv *>(cur)->GetChannel();
|
||||
aDataset.mComponents.mIsChannelPresent = true;
|
||||
aDatasetInfo.SetChannel(static_cast<const ChannelTlv *>(cur)->GetChannel());
|
||||
break;
|
||||
|
||||
case Tlv::kChannelMask:
|
||||
{
|
||||
uint32_t mask;
|
||||
uint32_t mask = static_cast<const ChannelMaskTlv *>(cur)->GetChannelMask();
|
||||
|
||||
if ((mask = static_cast<const ChannelMaskTlv *>(cur)->GetChannelMask()) != 0)
|
||||
if (mask != 0)
|
||||
{
|
||||
aDataset.mChannelMask = mask;
|
||||
aDataset.mComponents.mIsChannelMaskPresent = true;
|
||||
aDatasetInfo.SetChannelMask(mask);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Tlv::kDelayTimer:
|
||||
aDataset.mDelay = static_cast<const DelayTimerTlv *>(cur)->GetDelayTimer();
|
||||
aDataset.mComponents.mIsDelayPresent = true;
|
||||
aDatasetInfo.SetDelay(static_cast<const DelayTimerTlv *>(cur)->GetDelayTimer());
|
||||
break;
|
||||
|
||||
case Tlv::kExtendedPanId:
|
||||
aDataset.mExtendedPanId = static_cast<const ExtendedPanIdTlv *>(cur)->GetExtendedPanId();
|
||||
aDataset.mComponents.mIsExtendedPanIdPresent = true;
|
||||
aDatasetInfo.SetExtendedPanId(static_cast<const ExtendedPanIdTlv *>(cur)->GetExtendedPanId());
|
||||
break;
|
||||
|
||||
case Tlv::kMeshLocalPrefix:
|
||||
aDataset.mMeshLocalPrefix = static_cast<const MeshLocalPrefixTlv *>(cur)->GetMeshLocalPrefix();
|
||||
aDataset.mComponents.mIsMeshLocalPrefixPresent = true;
|
||||
aDatasetInfo.SetMeshLocalPrefix(static_cast<const MeshLocalPrefixTlv *>(cur)->GetMeshLocalPrefix());
|
||||
break;
|
||||
|
||||
case Tlv::kNetworkMasterKey:
|
||||
aDataset.mMasterKey = static_cast<const NetworkMasterKeyTlv *>(cur)->GetNetworkMasterKey();
|
||||
aDataset.mComponents.mIsMasterKeyPresent = true;
|
||||
aDatasetInfo.SetMasterKey(static_cast<const NetworkMasterKeyTlv *>(cur)->GetNetworkMasterKey());
|
||||
break;
|
||||
|
||||
case Tlv::kNetworkName:
|
||||
IgnoreError(static_cast<Mac::NetworkName &>(aDataset.mNetworkName)
|
||||
.Set(static_cast<const NetworkNameTlv *>(cur)->GetNetworkName()));
|
||||
aDataset.mComponents.mIsNetworkNamePresent = true;
|
||||
aDatasetInfo.SetNetworkName(static_cast<const NetworkNameTlv *>(cur)->GetNetworkName());
|
||||
break;
|
||||
|
||||
case Tlv::kPanId:
|
||||
aDataset.mPanId = static_cast<const PanIdTlv *>(cur)->GetPanId();
|
||||
aDataset.mComponents.mIsPanIdPresent = true;
|
||||
aDatasetInfo.SetPanId(static_cast<const PanIdTlv *>(cur)->GetPanId());
|
||||
break;
|
||||
|
||||
case Tlv::kPendingTimestamp:
|
||||
aDataset.mPendingTimestamp = static_cast<const PendingTimestampTlv *>(cur)->GetSeconds();
|
||||
aDataset.mComponents.mIsPendingTimestampPresent = true;
|
||||
aDatasetInfo.SetPendingTimestamp(static_cast<const PendingTimestampTlv *>(cur)->GetSeconds());
|
||||
break;
|
||||
|
||||
case Tlv::kPskc:
|
||||
aDataset.mPskc = static_cast<const PskcTlv *>(cur)->GetPskc();
|
||||
aDataset.mComponents.mIsPskcPresent = true;
|
||||
aDatasetInfo.SetPskc(static_cast<const PskcTlv *>(cur)->GetPskc());
|
||||
break;
|
||||
|
||||
case Tlv::kSecurityPolicy:
|
||||
{
|
||||
const SecurityPolicyTlv *tlv = static_cast<const SecurityPolicyTlv *>(cur);
|
||||
aDataset.mSecurityPolicy.mRotationTime = tlv->GetRotationTime();
|
||||
aDataset.mSecurityPolicy.mFlags = tlv->GetFlags();
|
||||
aDataset.mComponents.mIsSecurityPolicyPresent = true;
|
||||
const SecurityPolicyTlv *tlv = static_cast<const SecurityPolicyTlv *>(cur);
|
||||
aDatasetInfo.SetSecurityPolicy(tlv->GetRotationTime(), tlv->GetFlags());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -193,87 +226,87 @@ void Dataset::SetFrom(const otOperationalDatasetTlvs &aDataset)
|
||||
memcpy(mTlvs, aDataset.mTlvs, mLength);
|
||||
}
|
||||
|
||||
otError Dataset::SetFrom(const otOperationalDataset &aDataset)
|
||||
otError Dataset::SetFrom(const Info &aDatasetInfo)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aDataset.mComponents.mIsActiveTimestampPresent)
|
||||
if (aDatasetInfo.IsActiveTimestampPresent())
|
||||
{
|
||||
ActiveTimestampTlv tlv;
|
||||
tlv.Init();
|
||||
tlv.SetSeconds(aDataset.mActiveTimestamp);
|
||||
tlv.SetSeconds(aDatasetInfo.GetActiveTimestamp());
|
||||
tlv.SetTicks(0);
|
||||
IgnoreError(SetTlv(tlv));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsPendingTimestampPresent)
|
||||
if (aDatasetInfo.IsPendingTimestampPresent())
|
||||
{
|
||||
PendingTimestampTlv tlv;
|
||||
tlv.Init();
|
||||
tlv.SetSeconds(aDataset.mPendingTimestamp);
|
||||
tlv.SetSeconds(aDatasetInfo.GetPendingTimestamp());
|
||||
tlv.SetTicks(0);
|
||||
IgnoreError(SetTlv(tlv));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsDelayPresent)
|
||||
if (aDatasetInfo.IsDelayPresent())
|
||||
{
|
||||
IgnoreError(SetTlv(Tlv::kDelayTimer, aDataset.mDelay));
|
||||
IgnoreError(SetTlv(Tlv::kDelayTimer, aDatasetInfo.GetDelay()));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsChannelPresent)
|
||||
if (aDatasetInfo.IsChannelPresent())
|
||||
{
|
||||
ChannelTlv tlv;
|
||||
tlv.Init();
|
||||
tlv.SetChannel(aDataset.mChannel);
|
||||
tlv.SetChannel(aDatasetInfo.GetChannel());
|
||||
IgnoreError(SetTlv(tlv));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsChannelMaskPresent)
|
||||
if (aDatasetInfo.IsChannelMaskPresent())
|
||||
{
|
||||
ChannelMaskTlv tlv;
|
||||
tlv.Init();
|
||||
tlv.SetChannelMask(aDataset.mChannelMask);
|
||||
tlv.SetChannelMask(aDatasetInfo.GetChannelMask());
|
||||
IgnoreError(SetTlv(tlv));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsExtendedPanIdPresent)
|
||||
if (aDatasetInfo.IsExtendedPanIdPresent())
|
||||
{
|
||||
IgnoreError(SetTlv(Tlv::kExtendedPanId, aDataset.mExtendedPanId));
|
||||
IgnoreError(SetTlv(Tlv::kExtendedPanId, aDatasetInfo.GetExtendedPanId()));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsMeshLocalPrefixPresent)
|
||||
if (aDatasetInfo.IsMeshLocalPrefixPresent())
|
||||
{
|
||||
IgnoreError(SetTlv(Tlv::kMeshLocalPrefix, aDataset.mMeshLocalPrefix));
|
||||
IgnoreError(SetTlv(Tlv::kMeshLocalPrefix, aDatasetInfo.GetMeshLocalPrefix()));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsMasterKeyPresent)
|
||||
if (aDatasetInfo.IsMasterKeyPresent())
|
||||
{
|
||||
IgnoreError(SetTlv(Tlv::kNetworkMasterKey, aDataset.mMasterKey));
|
||||
IgnoreError(SetTlv(Tlv::kNetworkMasterKey, aDatasetInfo.GetMasterKey()));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsNetworkNamePresent)
|
||||
if (aDatasetInfo.IsNetworkNamePresent())
|
||||
{
|
||||
Mac::NameData nameData = static_cast<const Mac::NetworkName &>(aDataset.mNetworkName).GetAsData();
|
||||
Mac::NameData nameData = aDatasetInfo.GetNetworkName().GetAsData();
|
||||
|
||||
IgnoreError(SetTlv(Tlv::kNetworkName, nameData.GetBuffer(), nameData.GetLength()));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsPanIdPresent)
|
||||
if (aDatasetInfo.IsPanIdPresent())
|
||||
{
|
||||
IgnoreError(SetTlv(Tlv::kPanId, aDataset.mPanId));
|
||||
IgnoreError(SetTlv(Tlv::kPanId, aDatasetInfo.GetPanId()));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsPskcPresent)
|
||||
if (aDatasetInfo.IsPskcPresent())
|
||||
{
|
||||
IgnoreError(SetTlv(Tlv::kPskc, aDataset.mPskc));
|
||||
IgnoreError(SetTlv(Tlv::kPskc, aDatasetInfo.GetPskc()));
|
||||
}
|
||||
|
||||
if (aDataset.mComponents.mIsSecurityPolicyPresent)
|
||||
if (aDatasetInfo.IsSecurityPolicyPresent())
|
||||
{
|
||||
SecurityPolicyTlv tlv;
|
||||
tlv.Init();
|
||||
tlv.SetRotationTime(aDataset.mSecurityPolicy.mRotationTime);
|
||||
tlv.SetFlags(aDataset.mSecurityPolicy.mFlags);
|
||||
tlv.SetRotationTime(aDatasetInfo.GetSecurityPolicy().mRotationTime);
|
||||
tlv.SetFlags(aDatasetInfo.GetSecurityPolicy().mFlags);
|
||||
IgnoreError(SetTlv(tlv));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +39,13 @@
|
||||
|
||||
#include <openthread/dataset.h>
|
||||
|
||||
#include "common/clearable.hpp"
|
||||
#include "common/locator.hpp"
|
||||
#include "common/message.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "common/type_traits.hpp"
|
||||
#include "meshcop/meshcop_tlvs.hpp"
|
||||
#include "thread/mle_types.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace MeshCoP {
|
||||
@@ -74,6 +76,527 @@ public:
|
||||
kPending, ///< Pending Dataset
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents presence of different components in Active or Pending Operational Dataset.
|
||||
*
|
||||
*/
|
||||
class Components : public otOperationalDatasetComponents, public Clearable<Components>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This method indicates whether or not the Active Timestamp is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Active Timestamp is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsActiveTimestampPresent(void) const { return mIsActiveTimestampPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Pending Timestamp is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Pending Timestamp is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsPendingTimestampPresent(void) const { return mIsPendingTimestampPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Network Master Key is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Network Master Key is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsMasterKeyPresent(void) const { return mIsMasterKeyPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Network Name is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Network Name is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsNetworkNamePresent(void) const { return mIsNetworkNamePresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Extended PAN ID is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Extended PAN ID is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsExtendedPanIdPresent(void) const { return mIsExtendedPanIdPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Mesh Local Prefix is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Mesh Local Prefix is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsMeshLocalPrefixPresent(void) const { return mIsMeshLocalPrefixPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Delay Timer is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Delay Timer is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsDelayPresent(void) const { return mIsDelayPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the PAN ID is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if PAN ID is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsPanIdPresent(void) const { return mIsPanIdPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Channel is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Channel is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsChannelPresent(void) const { return mIsChannelPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the PSKc is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if PSKc is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsPskcPresent(void) const { return mIsPskcPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Security Policy is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Security Policy is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsSecurityPolicyPresent(void) const { return mIsSecurityPolicyPresent; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Channel Mask is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Channel Mask is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsChannelMaskPresent(void) const { return mIsChannelMaskPresent; }
|
||||
};
|
||||
|
||||
/**
|
||||
* This type represents the information about the fields contained an Active or Pending Operational Dataset.
|
||||
*
|
||||
*/
|
||||
class Info : public otOperationalDataset, public Clearable<Info>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This method indicates whether or not the Active Timestamp is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Active Timestamp is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsActiveTimestampPresent(void) const { return mComponents.mIsActiveTimestampPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Active Timestamp in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Active Timestamp component is present in the Dataset, otherwise its behavior is
|
||||
* undefined.
|
||||
*
|
||||
* @returns The Active Timestamp in the Dataset.
|
||||
*
|
||||
*/
|
||||
uint64_t GetActiveTimestamp(void) const { return mActiveTimestamp; }
|
||||
|
||||
/**
|
||||
* This method sets the Active Timestamp in the Dataset.
|
||||
*
|
||||
* @param[in] aTimestamp A Timestamp value.
|
||||
*
|
||||
*/
|
||||
void SetActiveTimestamp(uint64_t aTimestamp)
|
||||
{
|
||||
mActiveTimestamp = aTimestamp;
|
||||
mComponents.mIsActiveTimestampPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Pending Timestamp is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Pending Timestamp is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsPendingTimestampPresent(void) const { return mComponents.mIsPendingTimestampPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Pending Timestamp in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Pending Timestamp component is present in the Dataset, otherwise its behavior
|
||||
* is undefined.
|
||||
*
|
||||
* @returns The Pending Timestamp in the Dataset.
|
||||
*
|
||||
*/
|
||||
uint64_t GetPendingTimestamp(void) const { return mPendingTimestamp; }
|
||||
|
||||
/**
|
||||
* This method sets the Pending Timestamp in the Dataset.
|
||||
*
|
||||
* @param[in] aTimestamp A Timestamp value.
|
||||
*
|
||||
*/
|
||||
void SetPendingTimestamp(uint64_t aTimestamp)
|
||||
{
|
||||
mPendingTimestamp = aTimestamp;
|
||||
mComponents.mIsPendingTimestampPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Network Master Key is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Network Master Key is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsMasterKeyPresent(void) const { return mComponents.mIsMasterKeyPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Network Master Key in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Network Master Key component is present in the Dataset, otherwise its behavior
|
||||
* is undefined.
|
||||
*
|
||||
* @returns The Network Master Key in the Dataset.
|
||||
*
|
||||
*/
|
||||
const MasterKey &GetMasterKey(void) const { return static_cast<const MasterKey &>(mMasterKey); }
|
||||
|
||||
/**
|
||||
* This method sets the Network Master Key in the Dataset.
|
||||
*
|
||||
* @param[in] aMasterKey A Master Key.
|
||||
*
|
||||
*/
|
||||
void SetMasterKey(const MasterKey &aMasterKey)
|
||||
{
|
||||
mMasterKey = aMasterKey;
|
||||
mComponents.mIsMasterKeyPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a reference to the Network Master Key in the Dataset to be updated by caller.
|
||||
*
|
||||
* @returns A reference to the Network Master Key in the Dataset.
|
||||
*
|
||||
*/
|
||||
MasterKey &UpdateMasterKey(void)
|
||||
{
|
||||
mComponents.mIsMasterKeyPresent = true;
|
||||
return static_cast<MasterKey &>(mMasterKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Network Name is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Network Name is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsNetworkNamePresent(void) const { return mComponents.mIsNetworkNamePresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Network Name in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Network Name component is present in the Dataset, otherwise its behavior is
|
||||
* undefined.
|
||||
*
|
||||
* @returns The Network Name in the Dataset.
|
||||
*
|
||||
*/
|
||||
const Mac::NetworkName &GetNetworkName(void) const
|
||||
{
|
||||
return static_cast<const Mac::NetworkName &>(mNetworkName);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the Network Name in the Dataset.
|
||||
*
|
||||
* @param[in] aNetworkNameData A Network Name Data.
|
||||
*
|
||||
*/
|
||||
void SetNetworkName(const Mac::NameData &aNetworkNameData)
|
||||
{
|
||||
IgnoreError(static_cast<Mac::NetworkName &>(mNetworkName).Set(aNetworkNameData));
|
||||
mComponents.mIsNetworkNamePresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Extended PAN ID is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Extended PAN ID is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsExtendedPanIdPresent(void) const { return mComponents.mIsExtendedPanIdPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Extended PAN ID in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Extended PAN ID component is present in the Dataset, otherwise its behavior is
|
||||
* undefined.
|
||||
*
|
||||
* @returns The Extended PAN ID in the Dataset.
|
||||
*
|
||||
*/
|
||||
const Mac::ExtendedPanId &GetExtendedPanId(void) const
|
||||
{
|
||||
return static_cast<const Mac::ExtendedPanId &>(mExtendedPanId);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the Extended PAN ID in the Dataset.
|
||||
*
|
||||
* @param[in] aExtendedPanId An Extended PAN ID.
|
||||
*
|
||||
*/
|
||||
void SetExtendedPanId(const Mac::ExtendedPanId &aExtendedPanId)
|
||||
{
|
||||
mExtendedPanId = aExtendedPanId;
|
||||
mComponents.mIsExtendedPanIdPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Mesh Local Prefix is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Mesh Local Prefix is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsMeshLocalPrefixPresent(void) const { return mComponents.mIsMeshLocalPrefixPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Mesh Local Prefix in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Mesh Local Prefix component is present in the Dataset, otherwise its behavior
|
||||
* is undefined.
|
||||
*
|
||||
* @returns The Mesh Local Prefix in the Dataset.
|
||||
*
|
||||
*/
|
||||
const Mle::MeshLocalPrefix &GetMeshLocalPrefix(void) const
|
||||
{
|
||||
return static_cast<const Mle::MeshLocalPrefix &>(mMeshLocalPrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the Mesh Local Prefix in the Dataset.
|
||||
*
|
||||
* @param[in] aMeshLocalPrefix A Mesh Local Prefix.
|
||||
*
|
||||
*/
|
||||
void SetMeshLocalPrefix(const Mle::MeshLocalPrefix &aMeshLocalPrefix)
|
||||
{
|
||||
mMeshLocalPrefix = aMeshLocalPrefix;
|
||||
mComponents.mIsMeshLocalPrefixPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Delay Timer is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Delay Timer is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsDelayPresent(void) const { return mComponents.mIsDelayPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Delay Timer in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Delay Timer component is present in the Dataset, otherwise its behavior is
|
||||
* undefined.
|
||||
*
|
||||
* @returns The Delay Timer in the Dataset.
|
||||
*
|
||||
*/
|
||||
uint32_t GetDelay(void) const { return mDelay; }
|
||||
|
||||
/**
|
||||
* This method sets the Delay Timer in the Dataset.
|
||||
*
|
||||
* @param[in] aDely A Delay value.
|
||||
*
|
||||
*/
|
||||
void SetDelay(uint32_t aDelay)
|
||||
{
|
||||
mDelay = aDelay;
|
||||
mComponents.mIsDelayPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the PAN ID is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if PAN ID is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsPanIdPresent(void) const { return mComponents.mIsPanIdPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the PAN ID in the Dataset.
|
||||
*
|
||||
* This method MUST be used when PAN ID component is present in the Dataset, otherwise its behavior is
|
||||
* undefined.
|
||||
*
|
||||
* @returns The PAN ID in the Dataset.
|
||||
*
|
||||
*/
|
||||
Mac::PanId GetPanId(void) const { return mPanId; }
|
||||
|
||||
/**
|
||||
* This method sets the PAN ID in the Dataset.
|
||||
*
|
||||
* @param[in] aPanId A PAN ID.
|
||||
*
|
||||
*/
|
||||
void SetPanId(Mac::PanId aPanId)
|
||||
{
|
||||
mPanId = aPanId;
|
||||
mComponents.mIsPanIdPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Channel is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Channel is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsChannelPresent(void) const { return mComponents.mIsChannelPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Channel in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Channel component is present in the Dataset, otherwise its behavior is
|
||||
* undefined.
|
||||
*
|
||||
* @returns The Channel in the Dataset.
|
||||
*
|
||||
*/
|
||||
uint16_t GetChannel(void) const { return mChannel; }
|
||||
|
||||
/**
|
||||
* This method sets the Channel in the Dataset.
|
||||
*
|
||||
* @param[in] aChannel A Channel.
|
||||
*
|
||||
*/
|
||||
void SetChannel(uint16_t aChannel)
|
||||
{
|
||||
mChannel = aChannel;
|
||||
mComponents.mIsChannelPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the PSKc is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if PSKc is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsPskcPresent(void) const { return mComponents.mIsPskcPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the PSKc in the Dataset.
|
||||
*
|
||||
* This method MUST be used when PSKc component is present in the Dataset, otherwise its behavior is undefined.
|
||||
*
|
||||
* @returns The PSKc in the Dataset.
|
||||
*
|
||||
*/
|
||||
const Pskc &GetPskc(void) const { return static_cast<const Pskc &>(mPskc); }
|
||||
|
||||
/**
|
||||
* This method set the PSKc in the Dataset.
|
||||
*
|
||||
* @param[in] aPskc A PSKc value.
|
||||
*
|
||||
*/
|
||||
void SetPskc(const Pskc &aPskc)
|
||||
{
|
||||
mPskc = aPskc;
|
||||
mComponents.mIsPskcPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Security Policy is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Security Policy is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsSecurityPolicyPresent(void) const { return mComponents.mIsSecurityPolicyPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Security Policy in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Security Policy component is present in the Dataset, otherwise its behavior is
|
||||
* undefined.
|
||||
*
|
||||
* @returns The Security Policy in the Dataset.
|
||||
*
|
||||
*/
|
||||
const otSecurityPolicy &GetSecurityPolicy(void) const { return mSecurityPolicy; }
|
||||
|
||||
/**
|
||||
* This method sets the Security Policy in the Dataset.
|
||||
*
|
||||
* @param[in] aRotationTime A value for Key Rotation (in units of hours).
|
||||
* @param[in] aFlags Security policy flags
|
||||
*
|
||||
*/
|
||||
void SetSecurityPolicy(uint16_t aRotationTime, uint8_t aFlags)
|
||||
{
|
||||
mSecurityPolicy.mRotationTime = aRotationTime;
|
||||
mSecurityPolicy.mFlags = aFlags;
|
||||
mComponents.mIsSecurityPolicyPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the Channel Mask is present in the Dataset.
|
||||
*
|
||||
* @returns TRUE if Channel Mask is present, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsChannelMaskPresent(void) const { return mComponents.mIsChannelMaskPresent; }
|
||||
|
||||
/**
|
||||
* This method gets the Channel Mask in the Dataset.
|
||||
*
|
||||
* This method MUST be used when Channel Mask component is present in the Dataset, otherwise its behavior is
|
||||
* undefined.
|
||||
*
|
||||
* @returns The Channel Mask in the Dataset.
|
||||
*
|
||||
*/
|
||||
otChannelMask GetChannelMask(void) const { return mChannelMask; }
|
||||
|
||||
/**
|
||||
* This method sets the Channel Mask in the Dataset.
|
||||
*
|
||||
* @param[in] aChannelMask A Channel Mask value.
|
||||
*
|
||||
*/
|
||||
void SetChannelMask(otChannelMask aChannelMask)
|
||||
{
|
||||
mChannelMask = aChannelMask;
|
||||
mComponents.mIsChannelMaskPresent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method populates the Dataset with random fields.
|
||||
*
|
||||
* The Master Key, PSKc, Mesh Local Prefix, PAN ID, and Extended PAN ID are generated randomly (crypto-secure)
|
||||
* with Network Name set to "OpenThread-%04x" with PAN ID appended as hex. The Channel is chosen randomly from
|
||||
* radio's preferred channel mask, Channel Mask is set from radio's supported mask, and Security Policy Flags
|
||||
* from current `KeyManager` value.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If the Dataset was generated successfully.
|
||||
*
|
||||
*/
|
||||
otError GenerateRandom(Instance &aInstance);
|
||||
};
|
||||
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
@@ -157,10 +680,10 @@ public:
|
||||
/**
|
||||
* This method converts the TLV representation to structure representation.
|
||||
*
|
||||
* @param[out] aDataset A reference to `otOperationalDataset` to output the Dataset.
|
||||
* @param[out] aDatasetInfo A reference to `Info` object to output the Dataset.
|
||||
*
|
||||
*/
|
||||
void ConvertTo(otOperationalDataset &aDataset) const;
|
||||
void ConvertTo(Info &aDatasetInfo) const;
|
||||
|
||||
/**
|
||||
* This method converts the TLV representation to structure representation.
|
||||
@@ -280,13 +803,13 @@ public:
|
||||
/**
|
||||
* This method sets the Dataset from a given structure representation.
|
||||
*
|
||||
* @param[in] aDataset The input Dataset as otOperationalDataset.
|
||||
* @param[in] aDatasetInfo The input Dataset as `Dataset::Info`.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Dataset.
|
||||
* @retval OT_ERROR_INVALID_ARGS Dataset is missing Active and/or Pending Timestamp.
|
||||
*
|
||||
*/
|
||||
otError SetFrom(const otOperationalDataset &aDataset);
|
||||
otError SetFrom(const Info &aDatasetInfo);
|
||||
|
||||
/**
|
||||
* This method sets the Dataset using @p aDataset.
|
||||
|
||||
@@ -126,15 +126,15 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError DatasetLocal::Read(otOperationalDataset &aDataset) const
|
||||
otError DatasetLocal::Read(Dataset::Info &aDatasetInfo) const
|
||||
{
|
||||
Dataset dataset(mType);
|
||||
otError error;
|
||||
|
||||
memset(&aDataset, 0, sizeof(aDataset));
|
||||
aDatasetInfo.Clear();
|
||||
|
||||
SuccessOrExit(error = Read(dataset));
|
||||
dataset.ConvertTo(aDataset);
|
||||
dataset.ConvertTo(aDatasetInfo);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -154,12 +154,12 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError DatasetLocal::Save(const otOperationalDataset &aDataset)
|
||||
otError DatasetLocal::Save(const Dataset::Info &aDatasetInfo)
|
||||
{
|
||||
otError error;
|
||||
Dataset dataset(mType);
|
||||
|
||||
SuccessOrExit(error = dataset.SetFrom(aDataset));
|
||||
SuccessOrExit(error = dataset.SetFrom(aDatasetInfo));
|
||||
SuccessOrExit(error = Save(dataset));
|
||||
|
||||
exit:
|
||||
|
||||
@@ -115,13 +115,13 @@ public:
|
||||
/**
|
||||
* This method retrieves the dataset from non-volatile memory.
|
||||
*
|
||||
* @param[out] aDataset Where to place the dataset.
|
||||
* @param[out] aDatasetInfo Where to place the dataset as `Dataset::Info`.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the dataset.
|
||||
* @retval OT_ERROR_NOT_FOUND There is no corresponding dataset stored in non-volatile memory.
|
||||
*
|
||||
*/
|
||||
otError Read(otOperationalDataset &aDataset) const;
|
||||
otError Read(Dataset::Info &aDatasetInfo) const;
|
||||
|
||||
/**
|
||||
* This method retrieves the dataset from non-volatile memory.
|
||||
@@ -145,15 +145,19 @@ public:
|
||||
/**
|
||||
* This method stores the dataset into non-volatile memory.
|
||||
*
|
||||
* @param[in] aDatasetInfo The Dataset to save as `Dataset::Info`.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully saved the dataset.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
|
||||
*
|
||||
*/
|
||||
otError Save(const otOperationalDataset &aDataset);
|
||||
otError Save(const Dataset::Info &aDatasetInfo);
|
||||
|
||||
/**
|
||||
* This method stores the dataset into non-volatile memory.
|
||||
*
|
||||
* @param[in] aDataset The Dataset to save as `otOperationalDatasetTlvs`.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully saved the dataset.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
|
||||
*
|
||||
@@ -163,6 +167,8 @@ public:
|
||||
/**
|
||||
* This method stores the dataset into non-volatile memory.
|
||||
*
|
||||
* @param[in] aDataset The Dataset to save.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully saved the dataset.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
|
||||
*
|
||||
|
||||
@@ -177,11 +177,11 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError DatasetManager::Save(const otOperationalDataset &aDataset)
|
||||
otError DatasetManager::Save(const Dataset::Info &aDatasetInfo)
|
||||
{
|
||||
otError error;
|
||||
|
||||
SuccessOrExit(error = mLocal.Save(aDataset));
|
||||
SuccessOrExit(error = mLocal.Save(aDatasetInfo));
|
||||
HandleDatasetUpdated();
|
||||
|
||||
exit:
|
||||
@@ -443,19 +443,19 @@ exit:
|
||||
FreeMessageOnError(message, error);
|
||||
}
|
||||
|
||||
otError DatasetManager::AppendDatasetToMessage(const otOperationalDataset &aDataset, Message &aMessage) const
|
||||
otError DatasetManager::AppendDatasetToMessage(const Dataset::Info &aDatasetInfo, Message &aMessage) const
|
||||
{
|
||||
otError error;
|
||||
Dataset dataset(GetType());
|
||||
|
||||
SuccessOrExit(error = dataset.SetFrom(aDataset));
|
||||
SuccessOrExit(error = dataset.SetFrom(aDatasetInfo));
|
||||
error = aMessage.AppendBytes(dataset.GetBytes(), dataset.GetSize());
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset, const uint8_t *aTlvs, uint8_t aLength)
|
||||
otError DatasetManager::SendSetRequest(const Dataset::Info &aDatasetInfo, const uint8_t *aTlvs, uint8_t aLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
Coap::Message * message;
|
||||
@@ -493,7 +493,8 @@ otError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset, con
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
|
||||
SuccessOrExit(error = AppendDatasetToMessage(aDataset, *message));
|
||||
|
||||
SuccessOrExit(error = AppendDatasetToMessage(aDatasetInfo, *message));
|
||||
|
||||
if (aLength > 0)
|
||||
{
|
||||
@@ -518,10 +519,10 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError DatasetManager::SendGetRequest(const otOperationalDatasetComponents &aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress) const
|
||||
otError DatasetManager::SendGetRequest(const Dataset::Components &aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress) const
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
Coap::Message * message;
|
||||
@@ -532,62 +533,62 @@ otError DatasetManager::SendGetRequest(const otOperationalDatasetComponents &aDa
|
||||
|
||||
length = 0;
|
||||
|
||||
if (aDatasetComponents.mIsActiveTimestampPresent)
|
||||
if (aDatasetComponents.IsActiveTimestampPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kActiveTimestamp;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsPendingTimestampPresent)
|
||||
if (aDatasetComponents.IsPendingTimestampPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kPendingTimestamp;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsMasterKeyPresent)
|
||||
if (aDatasetComponents.IsMasterKeyPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kNetworkMasterKey;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsNetworkNamePresent)
|
||||
if (aDatasetComponents.IsNetworkNamePresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kNetworkName;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsExtendedPanIdPresent)
|
||||
if (aDatasetComponents.IsExtendedPanIdPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kExtendedPanId;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsMeshLocalPrefixPresent)
|
||||
if (aDatasetComponents.IsMeshLocalPrefixPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kMeshLocalPrefix;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsDelayPresent)
|
||||
if (aDatasetComponents.IsDelayPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kDelayTimer;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsPanIdPresent)
|
||||
if (aDatasetComponents.IsPanIdPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kPanId;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsChannelPresent)
|
||||
if (aDatasetComponents.IsChannelPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kChannel;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsPskcPresent)
|
||||
if (aDatasetComponents.IsPskcPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kPskc;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsSecurityPolicyPresent)
|
||||
if (aDatasetComponents.IsSecurityPolicyPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kSecurityPolicy;
|
||||
}
|
||||
|
||||
if (aDatasetComponents.mIsChannelMaskPresent)
|
||||
if (aDatasetComponents.IsChannelMaskPresent())
|
||||
{
|
||||
datasetTlvs[length++] = Tlv::kChannelMask;
|
||||
}
|
||||
@@ -654,6 +655,20 @@ bool ActiveDataset::IsPartiallyComplete(void) const
|
||||
return mLocal.IsSaved() && !mTimestampValid;
|
||||
}
|
||||
|
||||
bool ActiveDataset::IsCommissioned(void) const
|
||||
{
|
||||
Dataset::Info datasetInfo;
|
||||
bool isValid = false;
|
||||
|
||||
SuccessOrExit(Read(datasetInfo));
|
||||
|
||||
isValid = (datasetInfo.IsMasterKeyPresent() && datasetInfo.IsNetworkNamePresent() &&
|
||||
datasetInfo.IsExtendedPanIdPresent() && datasetInfo.IsPanIdPresent() && datasetInfo.IsChannelPresent());
|
||||
|
||||
exit:
|
||||
return isValid;
|
||||
}
|
||||
|
||||
otError ActiveDataset::Save(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint8_t aLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
@@ -709,11 +724,11 @@ void PendingDataset::ClearNetwork(void)
|
||||
IgnoreError(DatasetManager::Save(dataset));
|
||||
}
|
||||
|
||||
otError PendingDataset::Save(const otOperationalDataset &aDataset)
|
||||
otError PendingDataset::Save(const Dataset::Info &aDatasetInfo)
|
||||
{
|
||||
otError error;
|
||||
|
||||
SuccessOrExit(error = DatasetManager::Save(aDataset));
|
||||
SuccessOrExit(error = DatasetManager::Save(aDatasetInfo));
|
||||
StartDelayTimer();
|
||||
|
||||
exit:
|
||||
|
||||
@@ -96,13 +96,13 @@ public:
|
||||
/**
|
||||
* This method retrieves the dataset from non-volatile memory.
|
||||
*
|
||||
* @param[out] aDataset Where to place the dataset.
|
||||
* @param[out] aDatasetInfo Where to place the dataset (as `Dataset::Info`).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully retrieved the dataset.
|
||||
* @retval OT_ERROR_NOT_FOUND There is no corresponding dataset stored in non-volatile memory.
|
||||
*
|
||||
*/
|
||||
otError Read(otOperationalDataset &aDataset) const { return mLocal.Read(aDataset); }
|
||||
otError Read(Dataset::Info &aDatasetInfo) const { return mLocal.Read(aDatasetInfo); }
|
||||
|
||||
/**
|
||||
* This method retrieves the dataset from non-volatile memory.
|
||||
@@ -146,15 +146,15 @@ public:
|
||||
/**
|
||||
* This method sends a MGMT_SET request to the Leader.
|
||||
*
|
||||
* @param[in] aDataset The Operational Dataset.
|
||||
* @param[in] aTlvs Any additional raw TLVs to include.
|
||||
* @param[in] aLength Number of bytes in @p aTlvs.
|
||||
* @param[in] aDatasetInfo The Operational Dataset.
|
||||
* @param[in] aTlvs Any additional raw TLVs to include.
|
||||
* @param[in] aLength Number of bytes in @p aTlvs.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully send the meshcop dataset command.
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
otError SendSetRequest(const otOperationalDataset &aDataset, const uint8_t *aTlvs, uint8_t aLength);
|
||||
otError SendSetRequest(const Dataset::Info &aDatasetInfo, const uint8_t *aTlvs, uint8_t aLength);
|
||||
|
||||
/**
|
||||
* This method sends a MGMT_GET request.
|
||||
@@ -168,10 +168,10 @@ public:
|
||||
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
|
||||
*
|
||||
*/
|
||||
otError SendGetRequest(const otOperationalDatasetComponents &aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress) const;
|
||||
otError SendGetRequest(const Dataset::Components &aDatasetComponents,
|
||||
const uint8_t * aTlvTypes,
|
||||
uint8_t aLength,
|
||||
const otIp6Address * aAddress) const;
|
||||
#if OPENTHREAD_FTD
|
||||
/**
|
||||
* This method appends the MLE Dataset TLV but excluding MeshCoP Sub Timestamp TLV.
|
||||
@@ -253,13 +253,13 @@ protected:
|
||||
/**
|
||||
* This method saves the Operational Dataset in non-volatile memory.
|
||||
*
|
||||
* @param[in] aDataset The Operational Dataset.
|
||||
* @param[in] aDatasetInfo The Operational Dataset as `Dataset::Info`.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully saved the dataset.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
|
||||
*
|
||||
*/
|
||||
otError Save(const otOperationalDataset &aDataset);
|
||||
otError Save(const Dataset::Info &aDatasetInfo);
|
||||
|
||||
/**
|
||||
* This method saves the Operational Dataset in non-volatile memory.
|
||||
@@ -338,7 +338,7 @@ private:
|
||||
bool IsPendingDataset(void) const { return GetType() == Dataset::kPending; }
|
||||
void SignalDatasetChange(void) const;
|
||||
void HandleDatasetUpdated(void);
|
||||
otError AppendDatasetToMessage(const otOperationalDataset &aDataset, Message &aMessage) const;
|
||||
otError AppendDatasetToMessage(const Dataset::Info &aDatasetInfo, Message &aMessage) const;
|
||||
void SendSet(void);
|
||||
void SendGetResponse(const Coap::Message & aRequest,
|
||||
const Ip6::MessageInfo &aMessageInfo,
|
||||
@@ -351,7 +351,7 @@ private:
|
||||
|
||||
enum
|
||||
{
|
||||
kMaxDatasetTlvs = 16, // Maximum number of TLVs in an `otOperationalDataset`.
|
||||
kMaxDatasetTlvs = 16, // Maximum number of TLVs in a Dataset.
|
||||
kDelayNoBufs = 1000, // Milliseconds
|
||||
};
|
||||
|
||||
@@ -382,6 +382,15 @@ public:
|
||||
*/
|
||||
bool IsPartiallyComplete(void) const;
|
||||
|
||||
/**
|
||||
* This method indicates whether or not a valid network is present in the Active Operational Dataset.
|
||||
*
|
||||
* @retval TRUE if a valid network is present in the Active Dataset.
|
||||
* @retval FALSE if a valid network is not present in the Active Dataset.
|
||||
*
|
||||
*/
|
||||
bool IsCommissioned(void) const;
|
||||
|
||||
/**
|
||||
* This method clears the Active Operational Dataset.
|
||||
*
|
||||
@@ -415,13 +424,13 @@ public:
|
||||
/**
|
||||
* This method sets the Operational Dataset in non-volatile memory.
|
||||
*
|
||||
* @param[in] aDataset The Operational Dataset.
|
||||
* @param[in] aDatasetInfo The Operational Dataset as `Dataset::Info`.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully saved the dataset.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
|
||||
*
|
||||
*/
|
||||
otError Save(const otOperationalDataset &aDataset) { return DatasetManager::Save(aDataset); }
|
||||
otError Save(const Dataset::Info &aDatasetInfo) { return DatasetManager::Save(aDatasetInfo); }
|
||||
|
||||
/**
|
||||
* This method sets the Operational Dataset in non-volatile memory.
|
||||
@@ -439,13 +448,13 @@ public:
|
||||
/**
|
||||
* This method creates a new Operational Dataset to use when forming a new network.
|
||||
*
|
||||
* @param[out] aDataset The Operational Dataset.
|
||||
* @param[out] aDatasetInfo The Operational Dataset as `Dataset::Info`.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully created a new Operational Dataset.
|
||||
* @retval OT_ERROR_FAILED Failed to generate random values for new parameters.
|
||||
*
|
||||
*/
|
||||
otError CreateNewNetwork(otOperationalDataset &aDataset);
|
||||
otError CreateNewNetwork(Dataset::Info &aDatasetInfo) { return aDatasetInfo.GenerateRandom(GetInstance()); }
|
||||
|
||||
/**
|
||||
* This method starts the Leader functions for maintaining the Active Operational Dataset.
|
||||
@@ -521,13 +530,13 @@ public:
|
||||
*
|
||||
* This method also starts the Delay Timer.
|
||||
*
|
||||
* @param[in] aDataset The Operational Dataset.
|
||||
* @param[in] aDatasetInfo The Operational Dataset as `Dataset::Info`.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully saved the dataset.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
|
||||
*
|
||||
*/
|
||||
otError Save(const otOperationalDataset &aDataset);
|
||||
otError Save(const Dataset::Info &aDatasetInfo);
|
||||
|
||||
/**
|
||||
* This method saves the Operational Dataset in non-volatile memory.
|
||||
|
||||
@@ -304,57 +304,6 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError ActiveDataset::CreateNewNetwork(otOperationalDataset &aDataset)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
Mac::ChannelMask supportedChannels = Get<Mac::Mac>().GetSupportedChannelMask();
|
||||
Mac::ChannelMask preferredChannels(Get<Radio>().GetPreferredChannelMask());
|
||||
|
||||
memset(&aDataset, 0, sizeof(aDataset));
|
||||
|
||||
aDataset.mActiveTimestamp = 1;
|
||||
|
||||
SuccessOrExit(error = static_cast<MasterKey &>(aDataset.mMasterKey).GenerateRandom());
|
||||
SuccessOrExit(error = static_cast<Pskc &>(aDataset.mPskc).GenerateRandom());
|
||||
SuccessOrExit(error = Random::Crypto::FillBuffer(aDataset.mExtendedPanId.m8, sizeof(aDataset.mExtendedPanId)));
|
||||
|
||||
SuccessOrExit(error = static_cast<Ip6::NetworkPrefix &>(aDataset.mMeshLocalPrefix).GenerateRandomUla());
|
||||
|
||||
aDataset.mSecurityPolicy.mFlags = Get<KeyManager>().GetSecurityPolicyFlags();
|
||||
|
||||
// If the preferred channel mask is not empty, select a random
|
||||
// channel from it, otherwise choose one from the supported
|
||||
// channel mask.
|
||||
|
||||
preferredChannels.Intersect(supportedChannels);
|
||||
|
||||
if (preferredChannels.IsEmpty())
|
||||
{
|
||||
preferredChannels = supportedChannels;
|
||||
}
|
||||
|
||||
aDataset.mChannel = preferredChannels.ChooseRandomChannel();
|
||||
aDataset.mChannelMask = supportedChannels.GetMask();
|
||||
|
||||
aDataset.mPanId = Mac::GenerateRandomPanId();
|
||||
|
||||
snprintf(aDataset.mNetworkName.m8, sizeof(aDataset.mNetworkName), "OpenThread-%04x", aDataset.mPanId);
|
||||
|
||||
aDataset.mComponents.mIsActiveTimestampPresent = true;
|
||||
aDataset.mComponents.mIsMasterKeyPresent = true;
|
||||
aDataset.mComponents.mIsNetworkNamePresent = true;
|
||||
aDataset.mComponents.mIsExtendedPanIdPresent = true;
|
||||
aDataset.mComponents.mIsMeshLocalPrefixPresent = true;
|
||||
aDataset.mComponents.mIsPanIdPresent = true;
|
||||
aDataset.mComponents.mIsChannelPresent = true;
|
||||
aDataset.mComponents.mIsPskcPresent = true;
|
||||
aDataset.mComponents.mIsSecurityPolicyPresent = true;
|
||||
aDataset.mComponents.mIsChannelMaskPresent = true;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError ActiveDataset::GenerateLocal(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
@@ -559,26 +559,23 @@ void Joiner::HandleJoinerEntrust(void *aContext, otMessage *aMessage, const otMe
|
||||
|
||||
void Joiner::HandleJoinerEntrust(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
otError error;
|
||||
otOperationalDataset dataset;
|
||||
otError error;
|
||||
Dataset::Info datasetInfo;
|
||||
|
||||
VerifyOrExit(mState == kStateEntrust && aMessage.IsConfirmablePostRequest(), error = OT_ERROR_DROP);
|
||||
|
||||
otLogInfoMeshCoP("Joiner received entrust");
|
||||
otLogCertMeshCoP("[THCI] direction=recv | type=JOIN_ENT.ntf");
|
||||
|
||||
memset(&dataset, 0, sizeof(dataset));
|
||||
datasetInfo.Clear();
|
||||
|
||||
SuccessOrExit(error = Tlv::FindTlv(aMessage, Tlv::kNetworkMasterKey, &dataset.mMasterKey, sizeof(MasterKey)));
|
||||
dataset.mComponents.mIsMasterKeyPresent = true;
|
||||
SuccessOrExit(
|
||||
error = Tlv::FindTlv(aMessage, Tlv::kNetworkMasterKey, &datasetInfo.UpdateMasterKey(), sizeof(MasterKey)));
|
||||
|
||||
dataset.mChannel = Get<Mac::Mac>().GetPanChannel();
|
||||
dataset.mComponents.mIsChannelPresent = true;
|
||||
datasetInfo.SetChannel(Get<Mac::Mac>().GetPanChannel());
|
||||
datasetInfo.SetPanId(Get<Mac::Mac>().GetPanId());
|
||||
|
||||
dataset.mPanId = Get<Mac::Mac>().GetPanId();
|
||||
dataset.mComponents.mIsPanIdPresent = true;
|
||||
|
||||
IgnoreError(Get<MeshCoP::ActiveDataset>().Save(dataset));
|
||||
IgnoreError(Get<MeshCoP::ActiveDataset>().Save(datasetInfo));
|
||||
|
||||
otLogInfoMeshCoP("Joiner successful!");
|
||||
|
||||
|
||||
@@ -95,11 +95,11 @@ exit:
|
||||
|
||||
void ChannelManager::PreparePendingDataset(void)
|
||||
{
|
||||
uint64_t pendingTimestamp = 0;
|
||||
uint64_t pendingActiveTimestamp = 0;
|
||||
uint32_t delayInMs = Time::SecToMsec(static_cast<uint32_t>(mDelay));
|
||||
otOperationalDataset dataset;
|
||||
otError error;
|
||||
uint64_t pendingTimestamp = 0;
|
||||
uint64_t pendingActiveTimestamp = 0;
|
||||
uint32_t delayInMs = Time::SecToMsec(static_cast<uint32_t>(mDelay));
|
||||
MeshCoP::Dataset::Info dataset;
|
||||
otError error;
|
||||
|
||||
VerifyOrExit(mState == kStateChangeRequested);
|
||||
|
||||
@@ -107,9 +107,9 @@ void ChannelManager::PreparePendingDataset(void)
|
||||
|
||||
if (Get<MeshCoP::PendingDataset>().Read(dataset) == OT_ERROR_NONE)
|
||||
{
|
||||
if (dataset.mComponents.mIsPendingTimestampPresent)
|
||||
if (dataset.IsPendingTimestampPresent())
|
||||
{
|
||||
pendingTimestamp = dataset.mPendingTimestamp;
|
||||
pendingTimestamp = dataset.GetPendingTimestamp();
|
||||
}
|
||||
|
||||
// We check whether the Pending Dataset is changing the
|
||||
@@ -117,14 +117,13 @@ void ChannelManager::PreparePendingDataset(void)
|
||||
// should match and delay should be less than the requested
|
||||
// delay).
|
||||
|
||||
if (dataset.mComponents.mIsChannelPresent && (mChannel == dataset.mChannel) &&
|
||||
dataset.mComponents.mIsDelayPresent && (dataset.mDelay <= delayInMs) &&
|
||||
dataset.mComponents.mIsActiveTimestampPresent)
|
||||
if (dataset.IsChannelPresent() && (mChannel == dataset.GetChannel()) && dataset.IsDelayPresent() &&
|
||||
(dataset.GetDelay() <= delayInMs) && dataset.IsActiveTimestampPresent())
|
||||
{
|
||||
// We save the active timestamp to later check and ensure it
|
||||
// is ahead of current ActiveDataset timestamp.
|
||||
|
||||
pendingActiveTimestamp = dataset.mActiveTimestamp;
|
||||
pendingActiveTimestamp = dataset.GetActiveTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +161,7 @@ void ChannelManager::PreparePendingDataset(void)
|
||||
|
||||
if (pendingActiveTimestamp != 0)
|
||||
{
|
||||
if (dataset.mActiveTimestamp < pendingActiveTimestamp)
|
||||
if (dataset.GetActiveTimestamp() < pendingActiveTimestamp)
|
||||
{
|
||||
otLogInfoUtil("ChannelManager: Pending Dataset is valid for change channel to %d", mChannel);
|
||||
mState = kStateSentMgmtPendingDataset;
|
||||
@@ -181,7 +180,7 @@ void ChannelManager::PreparePendingDataset(void)
|
||||
|
||||
if (mActiveTimestamp != 0)
|
||||
{
|
||||
if (dataset.mActiveTimestamp >= mActiveTimestamp)
|
||||
if (dataset.GetActiveTimestamp() >= mActiveTimestamp)
|
||||
{
|
||||
otLogInfoUtil("ChannelManager: Canceling channel change to %d since current ActiveDataset is more recent",
|
||||
mChannel);
|
||||
@@ -191,17 +190,14 @@ void ChannelManager::PreparePendingDataset(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
mActiveTimestamp = dataset.mActiveTimestamp + 1 + Random::NonCrypto::GetUint32InRange(0, kMaxTimestampIncrease);
|
||||
mActiveTimestamp =
|
||||
dataset.GetActiveTimestamp() + 1 + Random::NonCrypto::GetUint32InRange(0, kMaxTimestampIncrease);
|
||||
}
|
||||
|
||||
dataset.mActiveTimestamp = mActiveTimestamp;
|
||||
dataset.mComponents.mIsActiveTimestampPresent = true;
|
||||
dataset.mChannel = mChannel;
|
||||
dataset.mComponents.mIsChannelPresent = true;
|
||||
dataset.mPendingTimestamp = pendingTimestamp;
|
||||
dataset.mComponents.mIsPendingTimestampPresent = true;
|
||||
dataset.mDelay = delayInMs;
|
||||
dataset.mComponents.mIsDelayPresent = true;
|
||||
dataset.SetActiveTimestamp(mActiveTimestamp);
|
||||
dataset.SetChannel(mChannel);
|
||||
dataset.SetPendingTimestamp(pendingTimestamp);
|
||||
dataset.SetDelay(delayInMs);
|
||||
|
||||
error = Get<MeshCoP::PendingDataset>().SendSetRequest(dataset, nullptr, 0);
|
||||
|
||||
|
||||
@@ -672,7 +672,7 @@ otError RadioSpinel<InterfaceType, ProcessContextType>::ThreadDatasetHandler(con
|
||||
opDataset.mActiveTimestamp = 0;
|
||||
opDataset.mComponents.mIsActiveTimestampPresent = true;
|
||||
|
||||
SuccessOrExit(error = dataset.SetFrom(opDataset));
|
||||
SuccessOrExit(error = dataset.SetFrom(static_cast<MeshCoP::Dataset::Info &>(opDataset)));
|
||||
SuccessOrExit(error = otPlatSettingsSet(
|
||||
mInstance, isActive ? SettingsBase::kKeyActiveDataset : SettingsBase::kKeyPendingDataset,
|
||||
dataset.GetBytes(), dataset.GetSize()));
|
||||
|
||||
Reference in New Issue
Block a user