Skip to content

Commit

Permalink
[ncp] fix get property handler of SRP SERVER (openthread#10967)
Browse files Browse the repository at this point in the history
This commit fixes the wrong implementation of the GetProperty handler
of `SPINEL_PROP_SRP_SERVER_ENABLED` and
`SPINEL_PROP_SRP_SERVER_AUTO_ENABLE_MODE`.

In GetProperty handlers only the body should be written. It doesn't
need to and shouldn't call `BeginFrame` and `EndFrame`. If using
`BeginFrame` here, it will get an error of INVALID_STATE.
  • Loading branch information
Irving-cl authored Nov 25, 2024
1 parent 4b9134d commit 147de7e
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/ncp/ncp_base_ftd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1523,16 +1523,9 @@ template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_SRP_SERVER_ENABLED>(v

template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_SRP_SERVER_ENABLED>(void)
{
otError error = OT_ERROR_NONE;
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
otSrpServerState srpServerState = otSrpServerGetState(mInstance);

SuccessOrExit(error = mEncoder.BeginFrame(header, SPINEL_CMD_PROP_VALUE_IS, SPINEL_PROP_SRP_SERVER_ENABLED));
SuccessOrExit(error = mEncoder.WriteBool(srpServerState != OT_SRP_SERVER_STATE_DISABLED));
SuccessOrExit(error = mEncoder.EndFrame());

exit:
return error;
return mEncoder.WriteBool(srpServerState != OT_SRP_SERVER_STATE_DISABLED);
}

#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
Expand All @@ -1550,16 +1543,7 @@ template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_SRP_SERVER_AUTO_ENABL

template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_SRP_SERVER_AUTO_ENABLE_MODE>(void)
{
otError error = OT_ERROR_NONE;
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;

SuccessOrExit(error =
mEncoder.BeginFrame(header, SPINEL_CMD_PROP_VALUE_IS, SPINEL_PROP_SRP_SERVER_AUTO_ENABLE_MODE));
SuccessOrExit(error = mEncoder.WriteBool(otSrpServerIsAutoEnableMode(mInstance)));
SuccessOrExit(error = mEncoder.EndFrame());

exit:
return error;
return mEncoder.WriteBool(otSrpServerIsAutoEnableMode(mInstance));
}
#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
#endif // OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
Expand Down

0 comments on commit 147de7e

Please sign in to comment.