Skip to content

Commit

Permalink
[border-agent] add error reply for DeactivateEphemeralKeyMode dbus API (
Browse files Browse the repository at this point in the history
  • Loading branch information
mia1yang authored Sep 20, 2024
1 parent 99440e2 commit 0cb3d3c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/dbus/server/dbus_thread_object_rcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,22 @@ void DBusThreadObjectRcp::DeactivateEphemeralKeyModeHandler(DBusRequest &aReques
otError error = OT_ERROR_NONE;
auto threadHelper = mHost.GetThreadHelper();

otBorderAgentClearEphemeralKey(threadHelper->GetInstance());
VerifyOrExit(mBorderAgent.GetEphemeralKeyEnabled(), error = OT_ERROR_NOT_CAPABLE);

switch (otBorderAgentGetState(threadHelper->GetInstance()))
{
case OT_BORDER_AGENT_STATE_STOPPED:
error = OT_ERROR_FAILED;
break;
case OT_BORDER_AGENT_STATE_ACTIVE:
error = OT_ERROR_INVALID_STATE;
break;
case OT_BORDER_AGENT_STATE_STARTED:
otBorderAgentClearEphemeralKey(threadHelper->GetInstance());
break;
}

exit:
aRequest.ReplyOtResult(error);
}

Expand All @@ -2022,6 +2037,8 @@ void DBusThreadObjectRcp::ActivateEphemeralKeyModeHandler(DBusRequest &aRequest)
auto args = std::tie(lifetime);
std::string ePskc;

VerifyOrExit(mBorderAgent.GetEphemeralKeyEnabled(), error = OT_ERROR_NOT_CAPABLE);

SuccessOrExit(DBusMessageToTuple(*aRequest.GetMessage(), args), error = OT_ERROR_INVALID_ARGS);

SuccessOrExit(mBorderAgent.CreateEphemeralKey(ePskc), error = OT_ERROR_INVALID_ARGS);
Expand Down

0 comments on commit 0cb3d3c

Please sign in to comment.