From fa6477197c61a7e69e47e9e8dd9a032cd38a709b Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 18 Apr 2024 10:18:38 -0700 Subject: [PATCH] [dataset] use `IsActiveDataset()/IsPendingDataset()` for type checks (#10040) --- src/core/meshcop/dataset_manager.cpp | 5 ++--- src/core/meshcop/dataset_manager_ftd.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/meshcop/dataset_manager.cpp b/src/core/meshcop/dataset_manager.cpp index 83854f02def4..0ac60c030372 100644 --- a/src/core/meshcop/dataset_manager.cpp +++ b/src/core/meshcop/dataset_manager.cpp @@ -216,8 +216,7 @@ void DatasetManager::HandleDatasetUpdated(void) void DatasetManager::SignalDatasetChange(void) const { - Get().Signal(mLocal.GetType() == Dataset::kActive ? kEventActiveDatasetChanged - : kEventPendingDatasetChanged); + Get().Signal(IsActiveDataset() ? kEventActiveDatasetChanged : kEventPendingDatasetChanged); } Error DatasetManager::GetChannelMask(Mac::ChannelMask &aChannelMask) const @@ -407,7 +406,7 @@ void DatasetManager::SendGetResponse(const Coap::Message &aRequest, SuccessOrExit(error = Get().SendMessage(*message, aMessageInfo)); - LogInfo("sent %s dataset get response to %s", (GetType() == Dataset::kActive ? "active" : "pending"), + LogInfo("sent %s dataset get response to %s", IsActiveDataset() ? "active" : "pending", aMessageInfo.GetPeerAddr().ToString().AsCString()); exit: diff --git a/src/core/meshcop/dataset_manager_ftd.cpp b/src/core/meshcop/dataset_manager_ftd.cpp index 897af1a4e175..d0ac9c346289 100644 --- a/src/core/meshcop/dataset_manager_ftd.cpp +++ b/src/core/meshcop/dataset_manager_ftd.cpp @@ -104,7 +104,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo // verify the request includes a timestamp that is ahead of the locally stored value SuccessOrExit(Tlv::Find(aMessage, activeTimestamp)); - if (GetType() == Dataset::kPending) + if (IsPendingDataset()) { Timestamp pendingTimestamp; @@ -155,7 +155,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo } // check active timestamp rollback - if (GetType() == Dataset::kPending && (!hasNetworkKey || !doesAffectNetworkKey)) + if (IsPendingDataset() && (!hasNetworkKey || !doesAffectNetworkKey)) { // no change to network key, active timestamp must be ahead const Timestamp *localActiveTimestamp = Get().GetTimestamp(); @@ -175,7 +175,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo } // verify an MGMT_ACTIVE_SET.req from a Commissioner does not affect connectivity - VerifyOrExit(!isUpdateFromCommissioner || GetType() == Dataset::kPending || !doesAffectConnectivity); + VerifyOrExit(!isUpdateFromCommissioner || IsPendingDataset() || !doesAffectConnectivity); if (isUpdateFromCommissioner) { @@ -184,7 +184,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo IgnoreError(Get().Read(dataset)); } - if (GetType() == Dataset::kPending || !doesAffectConnectivity) + if (IsPendingDataset() || !doesAffectConnectivity) { offset = aMessage.GetOffset();