ot::SettingsBase class
Defines the base class used by `Settings` and `Settings::ChildInfoIterator`. Provides structure definitions for different settings keys.
Syntax
class SettingsBase : public InstanceLocator
{
protected:
enum Action : uint8_t
{
kActionRead,
kActionSave,
kActionResave,
kActionDelete,
#if OPENTHREAD_FTD
kActionAdd,
kActionRemove,
kActionDeleteAll,
#endif
};
public:
enum Key : uint16_t
{
kKeyActiveDataset = OT_SETTINGS_KEY_ACTIVE_DATASET,
kKeyPendingDataset = OT_SETTINGS_KEY_PENDING_DATASET,
kKeyNetworkInfo = OT_SETTINGS_KEY_NETWORK_INFO,
kKeyParentInfo = OT_SETTINGS_KEY_PARENT_INFO,
kKeyChildInfo = OT_SETTINGS_KEY_CHILD_INFO,
kKeySlaacIidSecretKey = OT_SETTINGS_KEY_SLAAC_IID_SECRET_KEY,
kKeyDadInfo = OT_SETTINGS_KEY_DAD_INFO,
kKeySrpEcdsaKey = OT_SETTINGS_KEY_SRP_ECDSA_KEY,
kKeySrpClientInfo = OT_SETTINGS_KEY_SRP_CLIENT_INFO,
kKeySrpServerInfo = OT_SETTINGS_KEY_SRP_SERVER_INFO,
kKeyBrUlaPrefix = OT_SETTINGS_KEY_BR_ULA_PREFIX,
kKeyBrOnLinkPrefixes = OT_SETTINGS_KEY_BR_ON_LINK_PREFIXES,
kKeyBorderAgentId = OT_SETTINGS_KEY_BORDER_AGENT_ID,
};
static constexpr Key kLastKey = kKeyBorderAgentId;
static_assert(static_cast<uint16_t>(kLastKey) < static_cast<uint16_t>(OT_SETTINGS_KEY_VENDOR_RESERVED_MIN),
"Core settings keys overlap with vendor reserved keys");
OT_TOOL_PACKED_BEGIN
class NetworkInfo : private Clearable<NetworkInfo>
{
friend class Settings;
friend class Clearable<NetworkInfo>;
public:
static constexpr Key kKey = kKeyNetworkInfo;
void Init(void)
{
Clear();
SetVersion(kThreadVersion1p1);
}
uint8_t GetRole(void) const { return mRole; }
void SetRole(uint8_t aRole) { mRole = aRole; }
uint8_t GetDeviceMode(void) const { return mDeviceMode; }
void SetDeviceMode(uint8_t aDeviceMode) { mDeviceMode = aDeviceMode; }
uint16_t GetRloc16(void) const { return LittleEndian::HostSwap16(mRloc16); }
void SetRloc16(uint16_t aRloc16) { mRloc16 = LittleEndian::HostSwap16(aRloc16); }
uint32_t GetKeySequence(void) const { return LittleEndian::HostSwap32(mKeySequence); }
void SetKeySequence(uint32_t aKeySequence) { mKeySequence = LittleEndian::HostSwap32(aKeySequence); }
uint32_t GetMleFrameCounter(void) const { return LittleEndian::HostSwap32(mMleFrameCounter); }
void SetMleFrameCounter(uint32_t aMleFrameCounter)
{
mMleFrameCounter = LittleEndian::HostSwap32(aMleFrameCounter);
}
uint32_t GetMacFrameCounter(void) const { return LittleEndian::HostSwap32(mMacFrameCounter); }
void SetMacFrameCounter(uint32_t aMacFrameCounter)
{
mMacFrameCounter = LittleEndian::HostSwap32(aMacFrameCounter);
}
uint32_t GetPreviousPartitionId(void) const { return LittleEndian::HostSwap32(mPreviousPartitionId); }
void SetPreviousPartitionId(uint32_t aPreviousPartitionId)
{
mPreviousPartitionId = LittleEndian::HostSwap32(aPreviousPartitionId);
}
const Mac::ExtAddress &GetExtAddress(void) const { return mExtAddress; }
void SetExtAddress(const Mac::ExtAddress &aExtAddress) { mExtAddress = aExtAddress; }
const Ip6::InterfaceIdentifier &GetMeshLocalIid(void) const { return mMlIid; }
void SetMeshLocalIid(const Ip6::InterfaceIdentifier &aMeshLocalIid) { mMlIid = aMeshLocalIid; }
uint16_t GetVersion(void) const { return LittleEndian::HostSwap16(mVersion); }
void SetVersion(uint16_t aVersion) { mVersion = LittleEndian::HostSwap16(aVersion); }
private:
void Log(Action aAction) const;
uint8_t mRole;
uint8_t mDeviceMode;
uint16_t mRloc16;
uint32_t mKeySequence;
uint32_t mMleFrameCounter;
uint32_t mMacFrameCounter;
uint32_t mPreviousPartitionId;
Mac::ExtAddress mExtAddress;
Ip6::InterfaceIdentifier mMlIid;
uint16_t mVersion;
} OT_TOOL_PACKED_END;
OT_TOOL_PACKED_BEGIN
class ParentInfo : private Clearable<ParentInfo>
{
friend class Settings;
friend class Clearable<ParentInfo>;
public:
static constexpr Key kKey = kKeyParentInfo;
void Init(void)
{
Clear();
SetVersion(kThreadVersion1p1);
}
const Mac::ExtAddress &GetExtAddress(void) const { return mExtAddress; }
void SetExtAddress(const Mac::ExtAddress &aExtAddress) { mExtAddress = aExtAddress; }
uint16_t GetVersion(void) const { return LittleEndian::HostSwap16(mVersion); }
void SetVersion(uint16_t aVersion) { mVersion = LittleEndian::HostSwap16(aVersion); }
private:
void Log(Action aAction) const;
Mac::ExtAddress mExtAddress;
uint16_t mVersion;
} OT_TOOL_PACKED_END;
#if OPENTHREAD_FTD
OT_TOOL_PACKED_BEGIN
class ChildInfo
{
friend class Settings;
public:
static constexpr Key kKey = kKeyChildInfo;
void Init(void)
{
ClearAllBytes(*this);
SetVersion(kThreadVersion1p1);
}
const Mac::ExtAddress &GetExtAddress(void) const { return mExtAddress; }
void SetExtAddress(const Mac::ExtAddress &aExtAddress) { mExtAddress = aExtAddress; }
uint32_t GetTimeout(void) const { return LittleEndian::HostSwap32(mTimeout); }
void SetTimeout(uint32_t aTimeout) { mTimeout = LittleEndian::HostSwap32(aTimeout); }
uint16_t GetRloc16(void) const { return LittleEndian::HostSwap16(mRloc16); }
void SetRloc16(uint16_t aRloc16) { mRloc16 = LittleEndian::HostSwap16(aRloc16); }
uint8_t GetMode(void) const { return mMode; }
void SetMode(uint8_t aMode) { mMode = aMode; }
uint16_t GetVersion(void) const { return LittleEndian::HostSwap16(mVersion); }
void SetVersion(uint16_t aVersion) { mVersion = LittleEndian::HostSwap16(aVersion); }
private:
void Log(Action aAction) const;
Mac::ExtAddress mExtAddress;
uint32_t mTimeout;
uint16_t mRloc16;
uint8_t mMode;
uint16_t mVersion;
} OT_TOOL_PACKED_END;
#endif
#if OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
class SlaacIidSecretKey
{
public:
static constexpr Key kKey = kKeySlaacIidSecretKey;
typedef Utils::Slaac::IidSecretKey ValueType;
private:
SlaacIidSecretKey(void) = default;
};
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
OT_TOOL_PACKED_BEGIN
class DadInfo : private Clearable<DadInfo>
{
friend class Settings;
friend class Clearable<DadInfo>;
public:
static constexpr Key kKey = kKeyDadInfo;
void Init(void) { Clear(); }
uint8_t GetDadCounter(void) const { return mDadCounter; }
void SetDadCounter(uint8_t aDadCounter) { mDadCounter = aDadCounter; }
private:
void Log(Action aAction) const;
uint8_t mDadCounter;
} OT_TOOL_PACKED_END;
#endif
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
class BrUlaPrefix
{
public:
static constexpr Key kKey = kKeyBrUlaPrefix;
typedef Ip6::Prefix ValueType;
private:
BrUlaPrefix(void) = default;
};
OT_TOOL_PACKED_BEGIN
class BrOnLinkPrefix : public Clearable<BrOnLinkPrefix>
{
friend class Settings;
public:
static constexpr Key kKey = kKeyBrOnLinkPrefixes;
void Init(void) { Clear(); }
const Ip6::Prefix &GetPrefix(void) const { return mPrefix; }
void SetPrefix(const Ip6::Prefix &aPrefix) { mPrefix = aPrefix; }
uint32_t GetLifetime(void) const { return mLifetime; }
void SetLifetime(uint32_t aLifetime) { mLifetime = aLifetime; }
private:
void Log(const char *aActionText) const;
Ip6::Prefix mPrefix;
uint32_t mLifetime;
} OT_TOOL_PACKED_END;
#endif
#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
class SrpEcdsaKey
{
public:
static constexpr Key kKey = kKeySrpEcdsaKey;
typedef Crypto::Ecdsa::P256::KeyPair ValueType;
private:
SrpEcdsaKey(void) = default;
};
#if OPENTHREAD_CONFIG_SRP_CLIENT_SAVE_SELECTED_SERVER_ENABLE
OT_TOOL_PACKED_BEGIN
class SrpClientInfo : private Clearable<SrpClientInfo>
{
friend class Settings;
friend class Clearable<SrpClientInfo>;
public:
static constexpr Key kKey = kKeySrpClientInfo;
void Init(void) { Clear(); }
const Ip6::Address &GetServerAddress(void) const { return mServerAddress; }
void SetServerAddress(const Ip6::Address &aAddress) { mServerAddress = aAddress; }
uint16_t GetServerPort(void) const { return LittleEndian::HostSwap16(mServerPort); }
void SetServerPort(uint16_t aPort) { mServerPort = LittleEndian::HostSwap16(aPort); }
private:
void Log(Action aAction) const;
Ip6::Address mServerAddress;
uint16_t mServerPort;
} OT_TOOL_PACKED_END;
#endif
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE && OPENTHREAD_CONFIG_SRP_SERVER_PORT_SWITCH_ENABLE
OT_TOOL_PACKED_BEGIN
class SrpServerInfo : private Clearable<SrpServerInfo>
{
friend class Settings;
friend class Clearable<SrpServerInfo>;
public:
static constexpr Key kKey = kKeySrpServerInfo;
void Init(void) { Clear(); }
uint16_t GetPort(void) const { return LittleEndian::HostSwap16(mPort); }
void SetPort(uint16_t aPort) { mPort = LittleEndian::HostSwap16(aPort); }
private:
void Log(Action aAction) const;
uint16_t mPort;
} OT_TOOL_PACKED_END;
#endif
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE && OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE
class BorderAgentId
{
friend class Settings;
public:
static constexpr Key kKey = kKeyBorderAgentId;
typedef MeshCoP::BorderAgent::Id ValueType;
private:
static void Log(Action aAction, const MeshCoP::BorderAgent::Id &aId);
BorderAgentId(void) = delete;
};
#endif
protected:
explicit SettingsBase(Instance &aInstance)
: InstanceLocator(aInstance)
{
}
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
static void LogPrefix(Action aAction, Key aKey, const Ip6::Prefix &aPrefix);
#endif
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_WARN)
static const char *KeyToString(Key aKey);
#endif
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
static const char *ActionToString(Action aAction);
#endif
};
Fields
Methods
LogPrefix()
KeyToString()
ActionToString()
![]()
class ChildInfoIterator : public SettingsBase, public Unequatable<ChildInfoIterator>
ot::SettingsBase inherits 2 classess and is inherited by 1 classes:
![]()
ot::SettingsBase