@@ -42,6 +42,23 @@ class DNS {
4242 */
4343 virtual nsapi_error_t gethostbyname (const char *host,
4444 SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL ) = 0;
45+
46+ /* * Translate a hostname to the multiple IP addresses with specific version using network interface name.
47+ *
48+ * The hostname may be either a domain name or an IP address. If the
49+ * hostname is an IP address, no network transactions will be performed.
50+ *
51+ * If no stack-specific DNS resolution is provided, the hostname
52+ * will be resolve using a UDP socket on the stack.
53+ *
54+ * @param hostname Hostname to resolve.
55+ * @param hints Pointer to a SocketAddress with query parameters.
56+ * @param res Pointer to a SocketAddress array to store the result..
57+ * @param interface_name Network interface name
58+ * @return number of results on success, negative error code on failure.
59+ */
60+ virtual nsapi_error_t getaddrinfo (const char *hostname, SocketAddress *hints, SocketAddress **res, const char *interface_name = NULL ) = 0;
61+
4562 /* * Hostname translation callback for gethostbyname_async.
4663 *
4764 * The callback is called after DNS resolution completes, or a failure occurs.
@@ -83,6 +100,33 @@ class DNS {
83100 virtual nsapi_value_or_error_t gethostbyname_async (const char *host, hostbyname_cb_t callback, nsapi_version_t version = NSAPI_UNSPEC,
84101 const char *interface_name = NULL ) = 0;
85102
103+ /* * Translate a hostname to the multiple IP addresses (asynchronous)
104+ *
105+ * The hostname may be either a domain name or an IP address. If the
106+ * hostname is an IP address, no network transactions will be performed.
107+ *
108+ * If no stack-specific DNS resolution is provided, the hostname
109+ * will be resolved using a UDP socket on the stack.
110+ *
111+ * The call is non-blocking. The result of the DNS operation is returned by the callback.
112+ * If this function returns failure, the callback will not be called. If it is successful,
113+ * (the IP address was found from the DNS cache), the callback will be called
114+ * before the function returns.
115+ *
116+ * @param host Hostname to resolve.
117+ * @addr_count number of expected IP addresses.
118+ * @param callback Callback that is called to return the result.
119+ * @param version IP version of address to resolve. NSAPI_UNSPEC indicates that the
120+ * version is chosen by the stack (defaults to NSAPI_UNSPEC).
121+ * @param interface_name Network interface name
122+ * @return NSAPI_ERROR_OK on immediate success,
123+ * negative error code on immediate failure or
124+ * a positive unique ID that represents the hostname translation operation
125+ * and can be passed to cancel.
126+ */
127+ virtual nsapi_value_or_error_t getaddrinfo_async (const char *host, hostbyname_cb_t callback, nsapi_version_t version = NSAPI_UNSPEC,
128+ const char *interface_name = NULL ) = 0;
129+
86130 /* * Cancel asynchronous hostname translation.
87131 *
88132 * When translation is canceled, callback is not called.
0 commit comments