diff --git a/src/core/api/border_router_api.cpp b/src/core/api/border_router_api.cpp index 12d463116..d90893192 100644 --- a/src/core/api/border_router_api.cpp +++ b/src/core/api/border_router_api.cpp @@ -74,7 +74,8 @@ otError otBorderRoutingGetNat64Prefix(otInstance *aInstance, otIp6Prefix *aPrefi otError otBorderRouterGetNetData(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength) { - return AsCoreType(aInstance).Get().CopyNetworkData(aStable, aData, *aDataLength); + return AsCoreType(aInstance).Get().CopyNetworkData( + aStable ? NetworkData::kStableSubset : NetworkData::kFullSet, aData, *aDataLength); } otError otBorderRouterAddOnMeshPrefix(otInstance *aInstance, const otBorderRouterConfig *aConfig) diff --git a/src/core/api/netdata_api.cpp b/src/core/api/netdata_api.cpp index de2424250..e64664515 100644 --- a/src/core/api/netdata_api.cpp +++ b/src/core/api/netdata_api.cpp @@ -42,7 +42,8 @@ using namespace ot; otError otNetDataGet(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength) { - return AsCoreType(aInstance).Get().CopyNetworkData(aStable, aData, *aDataLength); + return AsCoreType(aInstance).Get().CopyNetworkData( + aStable ? NetworkData::kStableSubset : NetworkData::kFullSet, aData, *aDataLength); } otError otNetDataGetNextOnMeshPrefix(otInstance * aInstance, @@ -85,12 +86,12 @@ exit: uint8_t otNetDataGetVersion(otInstance *aInstance) { - return AsCoreType(aInstance).Get().GetLeaderData().GetDataVersion(); + return AsCoreType(aInstance).Get().GetLeaderData().GetDataVersion(NetworkData::kFullSet); } uint8_t otNetDataGetStableVersion(otInstance *aInstance) { - return AsCoreType(aInstance).Get().GetLeaderData().GetStableDataVersion(); + return AsCoreType(aInstance).Get().GetLeaderData().GetDataVersion(NetworkData::kStableSubset); } otError otNetDataSteeringDataCheckJoiner(otInstance *aInstance, const otExtAddress *aEui64) diff --git a/src/core/api/server_api.cpp b/src/core/api/server_api.cpp index bf08e9c86..b1712f103 100644 --- a/src/core/api/server_api.cpp +++ b/src/core/api/server_api.cpp @@ -44,7 +44,8 @@ using namespace ot; otError otServerGetNetDataLocal(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength) { - return AsCoreType(aInstance).Get().CopyNetworkData(aStable, aData, *aDataLength); + return AsCoreType(aInstance).Get().CopyNetworkData( + aStable ? NetworkData::kStableSubset : NetworkData::kFullSet, aData, *aDataLength); } otError otServerAddService(otInstance *aInstance, const otServiceConfig *aConfig) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 6f8f72c5f..d95b8eada 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -1002,8 +1002,8 @@ exit: const LeaderData &Mle::GetLeaderData(void) { - mLeaderData.SetDataVersion(Get().GetVersion()); - mLeaderData.SetStableDataVersion(Get().GetStableVersion()); + mLeaderData.SetDataVersion(Get().GetVersion(NetworkData::kFullSet)); + mLeaderData.SetStableDataVersion(Get().GetVersion(NetworkData::kStableSubset)); return mLeaderData; } @@ -1166,8 +1166,8 @@ Error Mle::AppendLeaderData(Message &aMessage) { LeaderDataTlv leaderDataTlv; - mLeaderData.SetDataVersion(Get().GetVersion()); - mLeaderData.SetStableDataVersion(Get().GetStableVersion()); + mLeaderData.SetDataVersion(Get().GetVersion(NetworkData::kFullSet)); + mLeaderData.SetStableDataVersion(Get().GetVersion(NetworkData::kStableSubset)); leaderDataTlv.Init(); leaderDataTlv.Set(mLeaderData); @@ -1188,7 +1188,7 @@ exit: return error; } -Error Mle::AppendNetworkData(Message &aMessage, bool aStableOnly) +Error Mle::AppendNetworkData(Message &aMessage, NetworkData::Type aType) { Error error = kErrorNone; uint8_t networkData[NetworkData::NetworkData::kMaxSize]; @@ -1197,7 +1197,7 @@ Error Mle::AppendNetworkData(Message &aMessage, bool aStableOnly) VerifyOrExit(!mRetrieveNewNetworkData, error = kErrorInvalidState); length = sizeof(networkData); - IgnoreError(Get().CopyNetworkData(aStableOnly, networkData, length)); + IgnoreError(Get().CopyNetworkData(aType, networkData, length)); error = Tlv::Append(aMessage, networkData, length); @@ -3140,16 +3140,8 @@ exit: bool Mle::IsNetworkDataNewer(const LeaderData &aLeaderData) { - int8_t diff; - - if (IsFullNetworkData()) - { - diff = static_cast(aLeaderData.GetDataVersion() - Get().GetVersion()); - } - else - { - diff = static_cast(aLeaderData.GetStableDataVersion() - Get().GetStableVersion()); - } + int8_t diff = static_cast(aLeaderData.GetDataVersion(GetNetworkDataType()) - + Get().GetVersion(GetNetworkDataType())); return (diff > 0); } @@ -3242,9 +3234,9 @@ Error Mle::HandleLeaderData(const Message &aMessage, const Ip6::MessageInfo &aMe if (Tlv::FindTlvOffset(aMessage, Tlv::kNetworkData, networkDataOffset) == kErrorNone) { - error = - Get().SetNetworkData(leaderData.GetDataVersion(), leaderData.GetStableDataVersion(), - !IsFullNetworkData(), aMessage, networkDataOffset); + error = Get().SetNetworkData(leaderData.GetDataVersion(NetworkData::kFullSet), + leaderData.GetDataVersion(NetworkData::kStableSubset), + GetNetworkDataType(), aMessage, networkDataOffset); SuccessOrExit(error); } else @@ -3740,9 +3732,9 @@ void Mle::HandleChildIdResponse(const Message & aMessage, mParent.SetRloc16(sourceAddress); - IgnoreError(Get().SetNetworkData(leaderData.GetDataVersion(), - leaderData.GetStableDataVersion(), !IsFullNetworkData(), - aMessage, networkDataOffset)); + IgnoreError(Get().SetNetworkData(leaderData.GetDataVersion(NetworkData::kFullSet), + leaderData.GetDataVersion(NetworkData::kStableSubset), + GetNetworkDataType(), aMessage, networkDataOffset)); SetStateChild(shortAddress); diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index 796fb554c..c2f0193fc 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -50,6 +50,7 @@ #include "thread/mle_tlvs.hpp" #include "thread/mle_types.hpp" #include "thread/neighbor_table.hpp" +#include "thread/network_data_types.hpp" #include "thread/topology.hpp" namespace ot { @@ -307,14 +308,6 @@ public: */ bool IsFullThreadDevice(void) const { return mDeviceMode.IsFullThreadDevice(); } - /** - * This method indicates whether or not the device requests Full Network Data. - * - * @returns TRUE if requests Full Network Data, FALSE otherwise. - * - */ - bool IsFullNetworkData(void) const { return mDeviceMode.IsFullNetworkData(); } - /** * This method indicates whether or not the device is a Minimal End Device. * @@ -323,6 +316,14 @@ public: */ bool IsMinimalEndDevice(void) const { return mDeviceMode.IsMinimalEndDevice(); } + /** + * This method gets the Network Data type (full set or stable subset) that this device requests. + * + * @returns The Network Data type requested by this device. + * + */ + NetworkData::Type GetNetworkDataType(void) const { return mDeviceMode.GetNetworkDataType(); } + /** * This method returns a pointer to the Mesh Local Prefix. * @@ -1122,13 +1123,13 @@ protected: * This method appends a Network Data TLV to the message. * * @param[in] aMessage A reference to the message. - * @param[in] aStableOnly TRUE to append stable data, FALSE otherwise. + * @param[in] aType The Network Data type to append, full set or stable subset. * * @retval kErrorNone Successfully appended the Network Data TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Network Data TLV. * */ - Error AppendNetworkData(Message &aMessage, bool aStableOnly); + Error AppendNetworkData(Message &aMessage, NetworkData::Type aType); /** * This method appends a TLV Request TLV to a message. diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index c3dcb7f6c..9365b9af0 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -965,7 +965,8 @@ Error MleRouter::HandleLinkAccept(const Message & aMessage, VerifyOrExit(leaderData.GetPartitionId() == mLeaderData.GetPartitionId()); if (mRetrieveNewNetworkData || - (static_cast(leaderData.GetDataVersion() - Get().GetVersion()) > 0)) + (static_cast(leaderData.GetDataVersion(NetworkData::kFullSet) - + Get().GetVersion(NetworkData::kFullSet)) > 0)) { IgnoreError(SendDataRequest(aMessageInfo.GetPeerAddr(), dataRequestTlvs, sizeof(dataRequestTlvs), 0)); } @@ -2360,15 +2361,7 @@ void MleRouter::HandleChildIdRequest(const Message & aMessage, child->ClearLastRxFragmentTag(); #endif - if (mode.IsFullNetworkData()) - { - child->SetNetworkDataVersion(mLeaderData.GetDataVersion()); - } - else - { - child->SetNetworkDataVersion(mLeaderData.GetStableDataVersion()); - } - + child->SetNetworkDataVersion(mLeaderData.GetDataVersion(mode.GetNetworkDataType())); child->ClearRequestTlvs(); for (numTlvs = 0; numTlvs < requestedTlvs.mNumTlvs; numTlvs++) @@ -2497,14 +2490,7 @@ void MleRouter::HandleChildUpdateRequest(const Message &aMessage, const Ip6::Mes switch (ReadLeaderData(aMessage, leaderData)) { case kErrorNone: - if (child->IsFullNetworkData()) - { - child->SetNetworkDataVersion(leaderData.GetDataVersion()); - } - else - { - child->SetNetworkDataVersion(leaderData.GetStableDataVersion()); - } + child->SetNetworkDataVersion(leaderData.GetDataVersion(child->GetNetworkDataType())); break; case kErrorNotFound: break; @@ -2742,14 +2728,7 @@ void MleRouter::HandleChildUpdateResponse(const Message & aMessage, switch (ReadLeaderData(aMessage, leaderData)) { case kErrorNone: - if (child->IsFullNetworkData()) - { - child->SetNetworkDataVersion(leaderData.GetDataVersion()); - } - else - { - child->SetNetworkDataVersion(leaderData.GetStableDataVersion()); - } + child->SetNetworkDataVersion(leaderData.GetDataVersion(child->GetNetworkDataType())); break; case kErrorNotFound: break; @@ -2857,23 +2836,12 @@ void MleRouter::SynchronizeChildNetworkData(void) for (Child &child : Get().Iterate(Child::kInStateValid)) { - uint8_t version; - if (child.IsRxOnWhenIdle()) { continue; } - if (child.IsFullNetworkData()) - { - version = Get().GetVersion(); - } - else - { - version = Get().GetStableVersion(); - } - - if (child.GetNetworkDataVersion() == version) + if (child.GetNetworkDataVersion() == Get().GetVersion(child.GetNetworkDataType())) { continue; } @@ -3136,7 +3104,7 @@ Error MleRouter::SendChildIdResponse(Child &aChild) switch (aChild.GetRequestTlv(i)) { case Tlv::kNetworkData: - SuccessOrExit(error = AppendNetworkData(*message, !aChild.IsFullNetworkData())); + SuccessOrExit(error = AppendNetworkData(*message, aChild.GetNetworkDataType())); break; case Tlv::kRoute: @@ -3219,7 +3187,7 @@ Error MleRouter::SendChildUpdateRequest(Child &aChild) SuccessOrExit(error = AppendHeader(*message, kCommandChildUpdateRequest)); SuccessOrExit(error = AppendSourceAddress(*message)); SuccessOrExit(error = AppendLeaderData(*message)); - SuccessOrExit(error = AppendNetworkData(*message, !aChild.IsFullNetworkData())); + SuccessOrExit(error = AppendNetworkData(*message, aChild.GetNetworkDataType())); SuccessOrExit(error = AppendActiveTimestamp(*message)); SuccessOrExit(error = AppendPendingTimestamp(*message)); @@ -3279,7 +3247,7 @@ void MleRouter::SendChildUpdateResponse(Child * aChild, break; case Tlv::kNetworkData: - SuccessOrExit(error = AppendNetworkData(*message, !aChild->IsFullNetworkData())); + SuccessOrExit(error = AppendNetworkData(*message, aChild->GetNetworkDataType())); SuccessOrExit(error = AppendActiveTimestamp(*message)); SuccessOrExit(error = AppendPendingTimestamp(*message)); break; @@ -3341,7 +3309,6 @@ void MleRouter::SendDataResponse(const Ip6::Address &aDestination, Error error = kErrorNone; Message * message = nullptr; Neighbor *neighbor; - bool stableOnly; if (mRetrieveNewNetworkData) { @@ -3362,9 +3329,9 @@ void MleRouter::SendDataResponse(const Ip6::Address &aDestination, switch (aTlvs[i]) { case Tlv::kNetworkData: - neighbor = mNeighborTable.FindNeighbor(aDestination); - stableOnly = neighbor != nullptr ? !neighbor->IsFullNetworkData() : false; - SuccessOrExit(error = AppendNetworkData(*message, stableOnly)); + neighbor = mNeighborTable.FindNeighbor(aDestination); + SuccessOrExit(error = AppendNetworkData(*message, (neighbor != nullptr) ? neighbor->GetNetworkDataType() + : NetworkData::kFullSet)); break; case Tlv::kActiveDataset: diff --git a/src/core/thread/mle_tlvs.hpp b/src/core/thread/mle_tlvs.hpp index 1ca11f3a2..25934beaf 100644 --- a/src/core/thread/mle_tlvs.hpp +++ b/src/core/thread/mle_tlvs.hpp @@ -692,8 +692,8 @@ public: { mPartitionId = HostSwap32(aLeaderData.GetPartitionId()); mWeighting = aLeaderData.GetWeighting(); - mDataVersion = aLeaderData.GetDataVersion(); - mStableDataVersion = aLeaderData.GetStableDataVersion(); + mDataVersion = aLeaderData.GetDataVersion(NetworkData::kFullSet); + mStableDataVersion = aLeaderData.GetDataVersion(NetworkData::kStableSubset); mLeaderRouterId = aLeaderData.GetLeaderRouterId(); } diff --git a/src/core/thread/mle_types.cpp b/src/core/thread/mle_types.cpp index d62bab32c..68feab7f2 100644 --- a/src/core/thread/mle_types.cpp +++ b/src/core/thread/mle_types.cpp @@ -42,7 +42,7 @@ void DeviceMode::Get(ModeConfig &aModeConfig) const { aModeConfig.mRxOnWhenIdle = IsRxOnWhenIdle(); aModeConfig.mDeviceType = IsFullThreadDevice(); - aModeConfig.mNetworkData = IsFullNetworkData(); + aModeConfig.mNetworkData = (GetNetworkDataType() == NetworkData::kFullSet); } void DeviceMode::Set(const ModeConfig &aModeConfig) @@ -58,7 +58,7 @@ DeviceMode::InfoString DeviceMode::ToString(void) const InfoString string; string.Append("rx-on:%s ftd:%s full-net:%s", ToYesNo(IsRxOnWhenIdle()), ToYesNo(IsFullThreadDevice()), - ToYesNo(IsFullNetworkData())); + ToYesNo(GetNetworkDataType() == NetworkData::kFullSet)); return string; } diff --git a/src/core/thread/mle_types.hpp b/src/core/thread/mle_types.hpp index 2f8ffce11..f939836ae 100644 --- a/src/core/thread/mle_types.hpp +++ b/src/core/thread/mle_types.hpp @@ -50,6 +50,7 @@ #include "common/string.hpp" #include "mac/mac_types.hpp" #include "net/ip6_address.hpp" +#include "thread/network_data_types.hpp" namespace ot { namespace Mle { @@ -380,13 +381,15 @@ public: bool IsFullThreadDevice(void) const { return (mMode & kModeFullThreadDevice) != 0; } /** - * This method indicates whether or not the device requests Full Network Data. + * This method gets the Network Data type (full set or stable subset) that the device requests. * - * @retval TRUE If the device requests Full Network Data. - * @retval FALSE If the device does not request Full Network Data (only stable Network Data). + * @returns The Network Data type requested by this device. * */ - bool IsFullNetworkData(void) const { return (mMode & kModeFullNetworkData) != 0; } + NetworkData::Type GetNetworkDataType(void) const + { + return (mMode & kModeFullNetworkData) ? NetworkData::kFullSet : NetworkData::kStableSubset; + } /** * This method indicates whether or not the device is a Minimal End Device. @@ -482,12 +485,17 @@ public: void SetWeighting(uint8_t aWeighting) { mWeighting = aWeighting; } /** - * This method returns the Data Version value. + * This method returns the Data Version value for a type (full set or stable subset). * - * @returns The Data Version value. + * @param[in] aType The Network Data type (full set or stable subset). + * + * @returns The Data Version value for @p aType. * */ - uint8_t GetDataVersion(void) const { return mDataVersion; } + uint8_t GetDataVersion(NetworkData::Type aType) const + { + return (aType == NetworkData::kFullSet) ? mDataVersion : mStableDataVersion; + } /** * This method sets the Data Version value. @@ -497,14 +505,6 @@ public: */ void SetDataVersion(uint8_t aVersion) { mDataVersion = aVersion; } - /** - * This method returns the Stable Data Version value. - * - * @returns The Stable Data Version value. - * - */ - uint8_t GetStableDataVersion(void) const { return mStableDataVersion; } - /** * This method sets the Stable Data Version value. * diff --git a/src/core/thread/network_data.cpp b/src/core/thread/network_data.cpp index 700c45575..94e61c930 100644 --- a/src/core/thread/network_data.cpp +++ b/src/core/thread/network_data.cpp @@ -47,19 +47,19 @@ namespace ot { namespace NetworkData { -Error NetworkData::CopyNetworkData(bool aStable, uint8_t *aData, uint8_t &aDataLength) const +Error NetworkData::CopyNetworkData(Type aType, uint8_t *aData, uint8_t &aDataLength) const { Error error; MutableNetworkData netDataCopy(GetInstance(), aData, 0, aDataLength); - SuccessOrExit(error = CopyNetworkData(aStable, netDataCopy)); + SuccessOrExit(error = CopyNetworkData(aType, netDataCopy)); aDataLength = netDataCopy.GetLength(); exit: return error; } -Error NetworkData::CopyNetworkData(bool aStable, MutableNetworkData &aNetworkData) const +Error NetworkData::CopyNetworkData(Type aType, MutableNetworkData &aNetworkData) const { Error error = kErrorNone; @@ -68,7 +68,7 @@ Error NetworkData::CopyNetworkData(bool aStable, MutableNetworkData &aNetworkDat memcpy(aNetworkData.GetBytes(), mTlvs, mLength); aNetworkData.SetLength(mLength); - if (aStable) + if (aType == kStableSubset) { aNetworkData.RemoveTemporaryData(); } diff --git a/src/core/thread/network_data.hpp b/src/core/thread/network_data.hpp index dc6649251..37e78bef1 100644 --- a/src/core/thread/network_data.hpp +++ b/src/core/thread/network_data.hpp @@ -168,28 +168,28 @@ public: /** * This method provides full or stable copy of the Thread Network Data. * - * @param[in] aStable TRUE when copying the stable version, FALSE when copying the full version. + * @param[in] aType The Network Data type to copy, the full set or stable subset. * @param[out] aData A pointer to the data buffer to copy the Network Data into. * @param[inout] aDataLength On entry, size of the data buffer pointed to by @p aData. * On exit, number of copied bytes. * - * @retval kErrorNone Successfully copied full Thread Network Data. + * @retval kErrorNone Successfully copied Thread Network Data. * @retval kErrorNoBufs Not enough space in @p aData to fully copy Thread Network Data. * */ - Error CopyNetworkData(bool aStable, uint8_t *aData, uint8_t &aDataLength) const; + Error CopyNetworkData(Type aType, uint8_t *aData, uint8_t &aDataLength) const; /** * This method provides full or stable copy of the Thread Network Data. * - * @param[in] aStable TRUE when copying the stable version, FALSE when copying the full version. + * @param[in] aType The Network Data type to copy, the full set or stable subset. * @param[out] aNetworkData A reference to a `MutableNetworkData` to copy the Network Data into. * - * @retval kErrorNone Successfully copied full Thread Network Data. + * @retval kErrorNone Successfully copied Thread Network Data. * @retval kErrorNoBufs Not enough space in @p aNetworkData to fully copy Thread Network Data. * */ - Error CopyNetworkData(bool aStable, MutableNetworkData &aNetworkData) const; + Error CopyNetworkData(Type aType, MutableNetworkData &aNetworkData) const; /** * This method provides the next On Mesh prefix in the Thread Network Data. diff --git a/src/core/thread/network_data_leader.cpp b/src/core/thread/network_data_leader.cpp index 9ff6ac3e1..53c5e4b24 100644 --- a/src/core/thread/network_data_leader.cpp +++ b/src/core/thread/network_data_leader.cpp @@ -346,7 +346,7 @@ Error LeaderBase::DefaultRouteLookup(const PrefixTlv &aPrefix, uint16_t *aRloc16 Error LeaderBase::SetNetworkData(uint8_t aVersion, uint8_t aStableVersion, - bool aStableOnly, + Type aType, const Message &aMessage, uint16_t aMessageOffset) { @@ -363,7 +363,7 @@ Error LeaderBase::SetNetworkData(uint8_t aVersion, mVersion = aVersion; mStableVersion = aStableVersion; - if (aStableOnly) + if (aType == kStableSubset) { RemoveTemporaryData(); } diff --git a/src/core/thread/network_data_leader.hpp b/src/core/thread/network_data_leader.hpp index 5badcbd16..b9a712417 100644 --- a/src/core/thread/network_data_leader.hpp +++ b/src/core/thread/network_data_leader.hpp @@ -85,20 +85,14 @@ public: void Reset(void); /** - * This method returns the Thread Network Data version. + * This method returns the Data Version value for a type (full set or stable subset). * - * @returns The Thread Network Data version. + * @param[in] aType The Network Data type (full set or stable subset). + * + * @returns The Data Version value for @p aType. * */ - uint8_t GetVersion(void) const { return mVersion; } - - /** - * This method returns the Thread Network Data stable version. - * - * @returns The Thread Network Data stable version. - * - */ - uint8_t GetStableVersion(void) const { return mStableVersion; } + uint8_t GetVersion(Type aType) const { return (aType == kFullSet) ? mVersion : mStableVersion; } /** * This method retrieves the 6LoWPAN Context information based on a given IPv6 address. @@ -157,7 +151,7 @@ public: * * @param[in] aVersion The Version value. * @param[in] aStableVersion The Stable Version value. - * @param[in] aStableOnly TRUE if storing only the stable data, FALSE otherwise. + * @param[in] aType The Network Data type to set, the full set or stable subset. * @param[in] aMessage A reference to the MLE message. * @param[in] aMessageOffset The offset in @p aMessage for the Network Data TLV. * @@ -167,7 +161,7 @@ public: */ Error SetNetworkData(uint8_t aVersion, uint8_t aStableVersion, - bool aStableOnly, + Type aType, const Message &aMessage, uint16_t aMessageOffset); diff --git a/src/core/thread/network_data_types.hpp b/src/core/thread/network_data_types.hpp index 1d8dac963..4ca8b56ca 100644 --- a/src/core/thread/network_data_types.hpp +++ b/src/core/thread/network_data_types.hpp @@ -68,6 +68,16 @@ class HasRouteEntry; class ServiceTlv; class ServerTlv; +/** + * This enumeration represents the Network Data type. + * + */ +enum Type : uint8_t +{ + kFullSet, ///< Full Network Data set. + kStableSubset, ///< Stable Network Data subset. +}; + /** * This enumeration type represents the route preference values as a signed integer (per RFC-4191). * diff --git a/src/core/thread/network_diagnostic.cpp b/src/core/thread/network_diagnostic.cpp index 7e11b5ebb..e4a6c6acd 100644 --- a/src/core/thread/network_diagnostic.cpp +++ b/src/core/thread/network_diagnostic.cpp @@ -346,8 +346,8 @@ Error NetworkDiagnostic::FillRequestedTlvs(const Message & aRequest, tlv.Init(); tlv.SetPartitionId(leaderData.GetPartitionId()); tlv.SetWeighting(leaderData.GetWeighting()); - tlv.SetDataVersion(leaderData.GetDataVersion()); - tlv.SetStableDataVersion(leaderData.GetStableDataVersion()); + tlv.SetDataVersion(leaderData.GetDataVersion(NetworkData::kFullSet)); + tlv.SetStableDataVersion(leaderData.GetDataVersion(NetworkData::kStableSubset)); tlv.SetLeaderRouterId(leaderData.GetLeaderRouterId()); SuccessOrExit(error = tlv.AppendTo(aResponse)); @@ -646,7 +646,7 @@ static inline void ParseMode(const Mle::DeviceMode &aMode, otLinkModeConfig &aLi { aLinkModeConfig.mRxOnWhenIdle = aMode.IsRxOnWhenIdle(); aLinkModeConfig.mDeviceType = aMode.IsFullThreadDevice(); - aLinkModeConfig.mNetworkData = aMode.IsFullNetworkData(); + aLinkModeConfig.mNetworkData = (aMode.GetNetworkDataType() == NetworkData::kFullSet); } static inline void ParseConnectivity(const ConnectivityTlv & aConnectivityTlv, diff --git a/src/core/thread/topology.cpp b/src/core/thread/topology.cpp index 4ca8402e1..b03abf337 100644 --- a/src/core/thread/topology.cpp +++ b/src/core/thread/topology.cpp @@ -79,7 +79,7 @@ void Neighbor::Info::SetFrom(const Neighbor &aNeighbor) mMessageErrorRate = aNeighbor.GetLinkInfo().GetMessageErrorRate(); mRxOnWhenIdle = aNeighbor.IsRxOnWhenIdle(); mFullThreadDevice = aNeighbor.IsFullThreadDevice(); - mFullNetworkData = aNeighbor.IsFullNetworkData(); + mFullNetworkData = (aNeighbor.GetNetworkDataType() == NetworkData::kFullSet); } void Neighbor::Init(Instance &aInstance) @@ -242,7 +242,7 @@ void Child::Info::SetFrom(const Child &aChild) mVersion = aChild.GetVersion(); mRxOnWhenIdle = aChild.IsRxOnWhenIdle(); mFullThreadDevice = aChild.IsFullThreadDevice(); - mFullNetworkData = aChild.IsFullNetworkData(); + mFullNetworkData = (aChild.GetNetworkDataType() == NetworkData::kFullSet); mIsStateRestoring = aChild.IsStateRestoring(); #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE mIsCslSynced = aChild.IsCslSynchronized(); diff --git a/src/core/thread/topology.hpp b/src/core/thread/topology.hpp index a307f1c8c..d4858e082 100644 --- a/src/core/thread/topology.hpp +++ b/src/core/thread/topology.hpp @@ -56,6 +56,7 @@ #include "thread/link_quality.hpp" #include "thread/mle_tlvs.hpp" #include "thread/mle_types.hpp" +#include "thread/network_data_types.hpp" #include "thread/radio_selector.hpp" namespace ot { @@ -353,12 +354,12 @@ public: bool IsFullThreadDevice(void) const { return GetDeviceMode().IsFullThreadDevice(); } /** - * This method indicates whether or not the device requests Full Network Data. + * This method gets the Network Data type (full set or stable subset) that the device requests. * - * @returns TRUE if requests Full Network Data, FALSE otherwise. + * @returns The Network Data type. * */ - bool IsFullNetworkData(void) const { return GetDeviceMode().IsFullNetworkData(); } + NetworkData::Type GetNetworkDataType(void) const { return GetDeviceMode().GetNetworkDataType(); } /** * This method sets all bytes of the Extended Address to zero. diff --git a/src/core/utils/history_tracker.cpp b/src/core/utils/history_tracker.cpp index f590217fd..fd4b9d48d 100644 --- a/src/core/utils/history_tracker.cpp +++ b/src/core/utils/history_tracker.cpp @@ -345,7 +345,7 @@ void HistoryTracker::RecordNetworkDataChange(void) } } - SuccessOrAssert(Get().CopyNetworkData(/* aSatble */ false, mPreviousNetworkData)); + SuccessOrAssert(Get().CopyNetworkData(NetworkData::kFullSet, mPreviousNetworkData)); } void HistoryTracker::RecordOnMeshPrefixEvent(NetDataEvent aEvent, const NetworkData::OnMeshPrefixConfig &aPrefix) diff --git a/src/core/utils/otns.cpp b/src/core/utils/otns.cpp index 40f5a49c6..7bcd13d91 100644 --- a/src/core/utils/otns.cpp +++ b/src/core/utils/otns.cpp @@ -155,7 +155,7 @@ void Otns::EmitTransmit(const Mac::TxFrame &aFrame) void Otns::EmitDeviceMode(Mle::DeviceMode aMode) { EmitStatus("mode=%s%s%s", aMode.IsRxOnWhenIdle() ? "r" : "", aMode.IsFullThreadDevice() ? "d" : "", - aMode.IsFullNetworkData() ? "n" : ""); + (aMode.GetNetworkDataType() == NetworkData::kFullSet) ? "n" : ""); } void Otns::EmitCoapSend(const Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo) diff --git a/tests/unit/test_lowpan.cpp b/tests/unit/test_lowpan.cpp index 41adda9fa..0da7b2fce 100644 --- a/tests/unit/test_lowpan.cpp +++ b/tests/unit/test_lowpan.cpp @@ -129,7 +129,7 @@ static void Init(void) SuccessOrQuit(message->AppendBytes(mockNetworkData, sizeof(mockNetworkData))); - IgnoreError(sInstance->Get().SetNetworkData(0, 0, true, *message, 0)); + IgnoreError(sInstance->Get().SetNetworkData(0, 0, NetworkData::kStableSubset, *message, 0)); } /**