[dns-client] add arg validation on ResolveService() (#6194)

This commit is contained in:
Jonathan Hui
2021-02-23 11:01:04 -08:00
committed by GitHub
parent 95b2a8b98f
commit f57c5e2370
4 changed files with 26 additions and 19 deletions
+9 -8
View File
@@ -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,
+1 -1
View File
@@ -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
+7 -1
View File
@@ -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
+9 -9
View File
@@ -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,