Skip to content

Commit

Permalink
[dataset] returns OT_ERROR_REJECTED when MGMT_SET is rejected by lead…
Browse files Browse the repository at this point in the history
…er (openthread#9582)

The current code won't return a failure error code when a MGMT_SET
request is rejected by the leader, so the client doesn't know whether
the operation succeed or not.

This commit fixes this issue by converting the REJECTED state to the
OT_ERROR_REJECTED error code which is propagated back via the
otDatasetMgmtSetCallback callback.
  • Loading branch information
wgtdkp authored Nov 6, 2023
1 parent f889bf9 commit 74061ee
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/meshcop/dataset_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,18 @@ void DatasetManager::HandleMgmtSetResponse(Coap::Message *aMessage, const Ip6::M
OT_UNUSED_VARIABLE(aMessageInfo);

Error error;
uint8_t state;
uint8_t state = StateTlv::kPending;

SuccessOrExit(error = aError);
VerifyOrExit(Tlv::Find<StateTlv>(*aMessage, state) == kErrorNone && state != StateTlv::kPending,
error = kErrorParse);
if (state == StateTlv::kReject)
{
error = kErrorRejected;
}

exit:
LogInfo("MGMT_SET finished: %s",
error == kErrorNone ? StateTlv::StateToString(static_cast<StateTlv::State>(state)) : ErrorToString(error));
LogInfo("MGMT_SET finished: %s", error == kErrorNone ? "Accepted" : ErrorToString(error));

mMgmtPending = false;

Expand Down

0 comments on commit 74061ee

Please sign in to comment.