From dda477d1485272e09fe111c2ab561d456e3a86c4 Mon Sep 17 00:00:00 2001 From: yuzyang Date: Sat, 12 Oct 2024 03:09:30 +0000 Subject: [PATCH] [dbus] add `retain_active_session` option for deactivate API --- src/dbus/server/dbus_thread_object_rcp.cpp | 18 ++++++++---------- src/dbus/server/introspect.xml | 9 ++++++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/dbus/server/dbus_thread_object_rcp.cpp b/src/dbus/server/dbus_thread_object_rcp.cpp index ce73356639c..95e01e7318e 100644 --- a/src/dbus/server/dbus_thread_object_rcp.cpp +++ b/src/dbus/server/dbus_thread_object_rcp.cpp @@ -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); diff --git a/src/dbus/server/introspect.xml b/src/dbus/server/introspect.xml index 21b358e51e3..369665710d1 100644 --- a/src/dbus/server/introspect.xml +++ b/src/dbus/server/introspect.xml @@ -246,8 +246,15 @@ - + +