[mdns] change SetEnabled() to be idempotent (#11690)

This commit changes the `SetEnabled()` API to return `kErrorNone` when
the component is already in the requested state (enabled or
disabled). Previously, the method would return `kErrorAlready` in
this scenario. Making this API idempotent simplifies caller logic, as
they no longer need to handle the `kErrorAlready` case.
This commit is contained in:
Abtin Keshavarzian
2025-07-09 13:16:37 -07:00
committed by GitHub
parent 852e5ac04b
commit d2d644d470
4 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ extern "C" {
*
* @note This number versions both OpenThread platform and user APIs.
*/
#define OPENTHREAD_API_VERSION (518)
#define OPENTHREAD_API_VERSION (519)
/**
* @addtogroup api-instance
+1 -1
View File
@@ -170,7 +170,7 @@ typedef struct otMdnsLocalHostAddress
* @param[in] aInfraIfIndex The network interface index for mDNS operation. Value is ignored when disabling
*
* @retval OT_ERROR_NONE Enabled or disabled the mDNS module successfully.
* @retval OT_ERROR_ALREADY mDNS is already enabled on an enable request or is already disabled on a disable request.
* @retval OT_ERROR_FAILED Failed to enable/disable mDNS.
*/
otError otMdnsSetEnabled(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex);
+1 -1
View File
@@ -119,7 +119,7 @@ Error Core::SetEnabled(bool aEnable, uint32_t aInfraIfIndex, Requester aRequeste
mAutoEnable = false;
}
VerifyOrExit(aEnable != mIsEnabled, error = kErrorAlready);
VerifyOrExit(aEnable != mIsEnabled);
mIsEnabled = aEnable;
mInfraIfIndex = aInfraIfIndex;
-1
View File
@@ -175,7 +175,6 @@ public:
* @param[in] aInfraIfIndex The network interface index for mDNS operation. Value is ignored when disabling.
*
* @retval kErrorNone Enabled or disabled the mDNS module successfully.
* @retval kErrorAlready mDNS is already enabled on an enable request, or is already disabled on a disable request.
* @retval kErrorFailed Failed to enable/disable mDNS.
*/
Error SetEnabled(bool aEnable, uint32_t aInfraIfIndex)