diff --git a/include/openthread/dns_client.h b/include/openthread/dns_client.h index fcfc3f7fa..04450ce1c 100644 --- a/include/openthread/dns_client.h +++ b/include/openthread/dns_client.h @@ -434,15 +434,16 @@ typedef void (*otDnsServiceCallback)(otError aError, const otDnsServiceResponse * the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The * unspecified fields are then replaced by the values from the default config. * - * @param[in] aInstance A pointer to an OpenThread instance. - * @param[in] aInstanceLabel The service instance label. - * @param[in] aServiceName The service name (together with @p aInstanceLabel form full instance name). - * @param[in] aCallback A function pointer that shall be called on response reception or time-out. - * @param[in] aContext A pointer to arbitrary context information. - * @param[in] aConfig A pointer to the config to use for this query. + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aInstanceLabel The service instance label. + * @param[in] aServiceName The service name (together with @p aInstanceLabel form full instance name). + * @param[in] aCallback A function pointer that shall be called on response reception or time-out. + * @param[in] aContext A pointer to arbitrary context information. + * @param[in] aConfig A pointer to the config to use for this query. * - * @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status. - * @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query. + * @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status. + * @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query. + * @retval OT_ERROR_INVALID_ARGS @p aInstanceLabel is NULL. * */ otError otDnsClientResolveService(otInstance * aInstance, diff --git a/include/openthread/instance.h b/include/openthread/instance.h index 3ed2ef1d1..adb550206 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (77) +#define OPENTHREAD_API_VERSION (78) /** * @addtogroup api-instance diff --git a/src/core/net/dns_client.cpp b/src/core/net/dns_client.cpp index 447d7e1cb..82695baf8 100644 --- a/src/core/net/dns_client.cpp +++ b/src/core/net/dns_client.cpp @@ -514,12 +514,18 @@ otError Client::ResolveService(const char * aInstanceLabel, const QueryConfig *aConfig) { QueryInfo info; + otError error; + + VerifyOrExit(aInstanceLabel != nullptr, error = OT_ERROR_INVALID_ARGS); info.Clear(); info.mQueryType = kServiceQuery; info.mCallback.mServiceCallback = aCallback; - return StartQuery(info, aConfig, aInstanceLabel, aServiceName, aContext); + error = StartQuery(info, aConfig, aInstanceLabel, aServiceName, aContext); + +exit: + return error; } #endif // OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE diff --git a/src/core/net/dns_client.hpp b/src/core/net/dns_client.hpp index 3dd67126a..875288334 100644 --- a/src/core/net/dns_client.hpp +++ b/src/core/net/dns_client.hpp @@ -586,17 +586,17 @@ public: * The @p aConfig can be nullptr. In this case the default config (from `GetDefaultConfig()`) will be used as * the config for this query. In a non-nullptr @p aConfig, some of the fields can be left unspecified (value zero). * The unspecified fields are then replaced by the values from the default config. - * - * @param[in] aServerSockAddr The server socket address. - * @param[in] aInstanceLabel The service instance label. - * @param[in] aServiceName The service name (together with @p aInstanceLabel form full instance name). - * @param[in] aCallback A function pointer that shall be called on response reception or time-out. - * @param[in] aContext A pointer to arbitrary context information. - * @param[in] aConfig The config to use for this query. + * @param[in] aServerSockAddr The server socket address. + * @param[in] aInstanceLabel The service instance label. + * @param[in] aServiceName The service name (together with @p aInstanceLabel form full instance name). + * @param[in] aCallback A function pointer that shall be called on response reception or time-out. + * @param[in] aContext A pointer to arbitrary context information. + * @param[in] aConfig The config to use for this query. * - * @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status. - * @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query. + * @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status. + * @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query. + * @retval OT_ERROR_INVALID_ARGS @p aInstanceLabel is `nullptr`. * */ otError ResolveService(const char * aInstanceLabel,