[dataset] returns OT_ERROR_REJECTED when MGMT_SET is rejected by leader (#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.
This commit is contained in:
Kangping
2023-11-06 11:21:45 -08:00
committed by GitHub
parent f889bf9f2e
commit 74061eebd4
+6 -3
View File
@@ -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;