Skip to content

Commit

Permalink
[dbus] add retain_active_session option for deactivate API
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzhyang committed Oct 15, 2024
1 parent 3e9be20 commit dda477d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
18 changes: 8 additions & 10 deletions src/dbus/server/dbus_thread_object_rcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2009,21 +2009,19 @@ void DBusThreadObjectRcp::DeactivateEphemeralKeyModeHandler(DBusRequest &aReques
{
otError error = OT_ERROR_NONE;
auto threadHelper = mHost.GetThreadHelper();
bool retain_active_session;
auto args = std::tie(retain_active_session);

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

switch (otBorderAgentGetState(threadHelper->GetInstance()))
SuccessOrExit(DBusMessageToTuple(*aRequest.GetMessage(), args), error = OT_ERROR_INVALID_ARGS);

if (!retain_active_session)
{
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;
otBorderAgentDisconnect(threadHelper->GetInstance());
}
otBorderAgentClearEphemeralKey(threadHelper->GetInstance());
otbrLogInfo("Deactivated Ephemeral Key Mode. BA state: %s", otBorderAgentGetState(threadHelper->GetInstance()));

exit:
aRequest.ReplyOtResult(error);
Expand Down
9 changes: 8 additions & 1 deletion src/dbus/server/introspect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,15 @@
<arg name="epskc" type="s" direction="out"/>
</method>

<!-- DeactivateEphemeralKeyMode: Deactivate ePSKc mode. -->
<!-- DeactivateEphemeralKeyMode: Deactivate ePSKc mode.
@retain_active_session:
"false" - Default value. Disconnects the Border Agent from any active secure sessions.
Ephemeral key would be cleared after the session is disconnected.
"true" - Clears ephemeral key only when Border Agent state is running
and no active session established.
-->
<method name="DeactivateEphemeralKeyMode">
<arg name="retain_active_session" type="b" direction="in"/>
</method>

<!-- MeshLocalPrefix: The /64 mesh-local prefix. -->
Expand Down

0 comments on commit dda477d

Please sign in to comment.