Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DnsQuery by
Diff: DnsQuery.h
- Revision:
- 10:0fe2c42a0261
- Parent:
- 9:16e5208cc4ef
- Child:
- 18:2cb1fffed50c
--- a/DnsQuery.h	Sun Feb 28 11:23:59 2016 -0600
+++ b/DnsQuery.h	Sun Feb 28 22:07:29 2016 -0600
@@ -18,43 +18,24 @@
 #ifndef __DNSQUERY_H__
 #define __DNSQUERY_H__
 
+#include "NetworkInterface.h"
 #include "UDPSocket.h"
 
 
-class DnsQuery
-{
-public:
-    /** Constructor to instantiate a DnsQuery object.
-      * @param wifi : A valid pointer to a UDP socket
-      */
-    DnsQuery(UDPSocket* sock,const char* hostname, char* ipaddress);
- 
-   
-private:   
-    /** Function gethostbyname implements the functionality to query a domain name server for an IP-Address of a given hostname.
-      * @param hostname : the hostname of interest as a string - format must be without http:// or www. IE google.com, mbed.org, etc
-      * @param ipaddress : a reference to a IPADDRESS_t object which will receive the resolved IP Address of the host in question.
-      * @returns true if successful, or false otherwise.
-      */
-    bool getHostByName(const char* hostname, char* ipaddress);
-    /** Checks if string is an IP address
-     *  @param hostname String to check
-     *  @return True if hostname is an IP addrss
-     */
-    bool isIP(const char* hostname) const;
-    /** Function gethostbyname implements the functionality to query a domain name server for an IP-Address of a given hostname.
-      * @param hostname : the hostname of interest as a string.
-      * @param ipaddress : a reference to a IPADDRESS_t object which will receive the resolved IP Address of the host in question.
-      * @returns true if successful, or false otherwise.
-      */
-    bool getIP(const char* hostname, char* ipaddress);
-    bool resolve(uint8_t *resp, char* ipaddress);
-    bool parseRR(uint8_t *resp, int& c, char* adr );
+/** Function dnsQuery implements the functionality to query a domain name 
+  * server for an IP-Address of a given hostname.
+  * @param iface : Network interface to use for DNS resolution.
+  * @param sock : Previously opened socket to use for DNS resolution.
+  * @param hostname : The hostname of interest as a string.
+  *     Format must be without http:// or www. IE google.com, mbed.org, etc.
+  *     If a standard IP Address is passed, it will be copied into ip unmodified.
+  * @param ipaddress : A reference to a IPADDRESS_t object which will receive 
+  *     the resolved IP Address of the host in question.
+  * @returns 0 on succes, NS_DNS_FAILURE if host is not found,
+  *     or a negative value for other errors.
+  */
+int32_t dnsQuery(NetworkInterface *iface, const char *host, char *ip);
+int32_t dnsQuery(UDPSocket *sock, const char *host, char *ip);
 
-protected:
-    const char* _dnsip;
-    char* _string_ip;
-    UDPSocket* socket;
-};
 
 #endif // __DNSQUERY_H__
    