Skip to content

Commit

Permalink
[dataset] use IsActiveDataset()/IsPendingDataset() for type checks (o…
Browse files Browse the repository at this point in the history
  • Loading branch information
abtink authored Apr 18, 2024
1 parent be7d36e commit fa64771
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/core/meshcop/dataset_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ void DatasetManager::HandleDatasetUpdated(void)

void DatasetManager::SignalDatasetChange(void) const
{
Get<Notifier>().Signal(mLocal.GetType() == Dataset::kActive ? kEventActiveDatasetChanged
: kEventPendingDatasetChanged);
Get<Notifier>().Signal(IsActiveDataset() ? kEventActiveDatasetChanged : kEventPendingDatasetChanged);
}

Error DatasetManager::GetChannelMask(Mac::ChannelMask &aChannelMask) const
Expand Down Expand Up @@ -407,7 +406,7 @@ void DatasetManager::SendGetResponse(const Coap::Message &aRequest,

SuccessOrExit(error = Get<Tmf::Agent>().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:
Expand Down
8 changes: 4 additions & 4 deletions src/core/meshcop/dataset_manager_ftd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActiveTimestampTlv>(aMessage, activeTimestamp));

if (GetType() == Dataset::kPending)
if (IsPendingDataset())
{
Timestamp pendingTimestamp;

Expand Down Expand Up @@ -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<ActiveDatasetManager>().GetTimestamp();
Expand All @@ -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)
{
Expand All @@ -184,7 +184,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo
IgnoreError(Get<ActiveDatasetManager>().Read(dataset));
}

if (GetType() == Dataset::kPending || !doesAffectConnectivity)
if (IsPendingDataset() || !doesAffectConnectivity)
{
offset = aMessage.GetOffset();

Expand Down

0 comments on commit fa64771

Please sign in to comment.