3 * DNS - host name to IP address resolver.
9 * This file implements a DNS host name to IP address resolver.
11 * Port to lwIP from uIP
12 * by Jim Pettinato April 2007
14 * uIP version Copyright (c) 2002-2003, Adam Dunkels.
15 * All rights reserved.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. The name of the author may not be used to endorse or promote
26 * products derived from this software without specific prior
29 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
30 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
35 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
37 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
38 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 * The lwIP DNS resolver functions are used to lookup a host name and
45 * map it to a numerical IP address. It maintains a list of resolved
46 * hostnames that can be queried with the dns_lookup() function.
47 * New hostnames can be resolved using the dns_query() function.
49 * The lwIP version of the resolver also adds a non-blocking version of
50 * gethostbyname() that will work with a raw API application. This function
51 * checks for an IP address string first and converts it if it is valid.
52 * gethostbyname() then does a dns_lookup() to see if the name is
53 * already in the table. If so, the IP is returned. If not, a query is
54 * issued and the function returns with a ERR_INPROGRESS status. The app
55 * using the dns client must then go into a waiting state.
57 * Once a hostname has been resolved (or found to be non-existent),
58 * the resolver code calls a specified callback function (which
59 * must be implemented by the module that uses the resolver).
62 /*-----------------------------------------------------------------------------
63 * RFC 1035 - Domain names - implementation and specification
64 * RFC 2181 - Clarifications to the DNS Specification
65 *----------------------------------------------------------------------------*/
67 /** @todo: define good default values (rfc compliance) */
68 /** @todo: improve answer parsing, more checkings... */
69 /** @todo: check RFC1035 - 7.3. Processing responses */
71 /*-----------------------------------------------------------------------------
73 *----------------------------------------------------------------------------*/
77 #if LWIP_DNS /* don't build if not configured for use in lwipopts.h */
85 /** DNS server IP address */
86 #ifndef DNS_SERVER_ADDRESS
87 #define DNS_SERVER_ADDRESS inet_addr("208.67.222.222") /* resolver1.opendns.com */
90 /** DNS server port address */
91 #ifndef DNS_SERVER_PORT
92 #define DNS_SERVER_PORT 53
95 /** DNS maximum number of retries when asking for a name, before "timeout". */
96 #ifndef DNS_MAX_RETRIES
97 #define DNS_MAX_RETRIES 4
100 /** DNS resource record max. TTL (one week as default) */
102 #define DNS_MAX_TTL 604800
105 /* DNS protocol flags */
106 #define DNS_FLAG1_RESPONSE 0x80
107 #define DNS_FLAG1_OPCODE_STATUS 0x10
108 #define DNS_FLAG1_OPCODE_INVERSE 0x08
109 #define DNS_FLAG1_OPCODE_STANDARD 0x00
110 #define DNS_FLAG1_AUTHORATIVE 0x04
111 #define DNS_FLAG1_TRUNC 0x02
112 #define DNS_FLAG1_RD 0x01
113 #define DNS_FLAG2_RA 0x80
114 #define DNS_FLAG2_ERR_MASK 0x0f
115 #define DNS_FLAG2_ERR_NONE 0x00
116 #define DNS_FLAG2_ERR_NAME 0x03
118 /* DNS protocol states */
119 #define DNS_STATE_UNUSED 0
120 #define DNS_STATE_NEW 1
121 #define DNS_STATE_ASKING 2
122 #define DNS_STATE_DONE 3
124 #ifdef PACK_STRUCT_USE_INCLUDES
125 # include "arch/bpstruct.h"
128 /** DNS message header */
137 } PACK_STRUCT_STRUCT;
139 #ifdef PACK_STRUCT_USE_INCLUDES
140 # include "arch/epstruct.h"
143 #ifdef PACK_STRUCT_USE_INCLUDES
144 # include "arch/bpstruct.h"
147 /** DNS query message structure */
149 /* DNS query record starts with either a domain name or a pointer
150 to a name already present somewhere in the packet. */
153 } PACK_STRUCT_STRUCT;
155 #ifdef PACK_STRUCT_USE_INCLUDES
156 # include "arch/epstruct.h"
159 #ifdef PACK_STRUCT_USE_INCLUDES
160 # include "arch/bpstruct.h"
163 /** DNS answer message structure */
165 /* DNS answer record starts with either a domain name or a pointer
166 to a name already present somewhere in the packet. */
171 } PACK_STRUCT_STRUCT;
173 #ifdef PACK_STRUCT_USE_INCLUDES
174 # include "arch/epstruct.h"
177 /** DNS table entry */
178 struct dns_table_entry {
186 char name[DNS_MAX_NAME_LENGTH];
187 struct ip_addr ipaddr;
188 /* pointer to callback on DNS query done */
189 dns_found_callback found;
194 /* forward declarations */
195 static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port);
196 static void dns_check_entries(void);
198 /*-----------------------------------------------------------------------------
200 *----------------------------------------------------------------------------*/
203 static struct udp_pcb *dns_pcb;
204 static u8_t dns_seqno;
205 static struct dns_table_entry dns_table[DNS_TABLE_SIZE];
206 static struct ip_addr dns_servers[DNS_MAX_SERVERS];
208 #if (DNS_USES_STATIC_BUF == 1)
209 static u8_t dns_payload[DNS_MSG_SIZE];
210 #endif /* (DNS_USES_STATIC_BUF == 1) */
213 * Initialize the resolver: set up the UDP pcb and configure the default server
214 * (DNS_SERVER_ADDRESS).
219 struct ip_addr dnsserver;
221 /* initialize default DNS server address */
222 dnsserver.addr = DNS_SERVER_ADDRESS;
224 LWIP_DEBUGF(DNS_DEBUG, ("dns_init: initializing\n"));
226 /* if dns client not yet initialized... */
227 if (dns_pcb == NULL) {
230 if (dns_pcb != NULL) {
231 /* initialize DNS table not needed (initialized to zero since it is a
232 * global variable) */
233 LWIP_ASSERT("For implicit initialization to work, DNS_STATE_UNUSED needs to be 0",
234 DNS_STATE_UNUSED == 0);
236 /* initialize DNS client */
237 udp_bind(dns_pcb, IP_ADDR_ANY, 0);
238 udp_recv(dns_pcb, dns_recv, NULL);
240 /* initialize default DNS primary server */
241 dns_setserver(0, &dnsserver);
247 * Initialize one of the DNS servers.
249 * @param numdns the index of the DNS server to set must be < DNS_MAX_SERVERS
250 * @param dnsserver IP address of the DNS server to set
253 dns_setserver(u8_t numdns, struct ip_addr *dnsserver)
255 if ((numdns < DNS_MAX_SERVERS) && (dns_pcb != NULL) &&
256 (dnsserver != NULL) && (dnsserver->addr !=0 )) {
257 dns_servers[numdns] = (*dnsserver);
262 * Obtain one of the currently configured DNS server.
264 * @param numdns the index of the DNS server
265 * @return IP address of the indexed DNS server or "ip_addr_any" if the DNS
266 * server has not been configured.
269 dns_getserver(u8_t numdns)
271 if (numdns < DNS_MAX_SERVERS) {
272 return dns_servers[numdns];
279 * The DNS resolver client timer - handle retries and timeouts and should
280 * be called every DNS_TMR_INTERVAL milliseconds (every second by default).
285 if (dns_pcb != NULL) {
286 LWIP_DEBUGF(DNS_DEBUG, ("dns_tmr: dns_check_entries\n"));
292 * Look up a hostname in the array of known hostnames.
294 * @note This function only looks in the internal array of known
295 * hostnames, it does not send out a query for the hostname if none
296 * was found. The function dns_enqueue() can be used to send a query
299 * @param name the hostname to look up
300 * @return the hostname's IP address, as u32_t (instead of struct ip_addr to
301 * better check for failure: != 0) or 0 if the hostname was not found
302 * in the cached dns_table.
305 dns_lookup(const char *name)
309 /* Walk through name list, return entry if found. If not, return NULL. */
310 for (i = 0; i < DNS_TABLE_SIZE; ++i) {
311 if ((dns_table[i].state == DNS_STATE_DONE) &&
312 (strcmp(name, dns_table[i].name) == 0)) {
313 LWIP_DEBUGF(DNS_DEBUG, ("dns_lookup: \"%s\": found = ", name));
314 ip_addr_debug_print(DNS_DEBUG, &(dns_table[i].ipaddr));
315 LWIP_DEBUGF(DNS_DEBUG, ("\n"));
316 return dns_table[i].ipaddr.addr;
323 #if DNS_DOES_NAME_CHECK
325 * Compare the "dotted" name "query" with the encoded name "response"
326 * to make sure an answer from the DNS server matches the current dns_table
327 * entry (otherwise, answers might arrive late for hostname not on the list
330 * @param query hostname (not encoded) from the dns_table
331 * @param response encoded hostname in the DNS response
332 * @return 0: names equal; 1: names differ
335 dns_compare_name(unsigned char *query, unsigned char *response)
341 /** @see RFC 1035 - 4.1.4. Message compression */
342 if ((n & 0xc0) == 0xc0) {
343 /* Compressed name */
346 /* Not compressed name */
348 if ((*query) != (*response)) {
357 } while (*response != 0);
361 #endif /* DNS_DOES_NAME_CHECK */
364 * Walk through a compact encoded DNS name and return the end of the name.
366 * @param query encoded DNS name in the DNS server response
367 * @return end of the name
369 static unsigned char *
370 dns_parse_name(unsigned char *query)
376 /** @see RFC 1035 - 4.1.4. Message compression */
377 if ((n & 0xc0) == 0xc0) {
378 /* Compressed name */
381 /* Not compressed name */
387 } while (*query != 0);
393 * Send a DNS query packet.
395 * @param numdns index of the DNS server in the dns_servers table
396 * @param name hostname to query
397 * @param id index of the hostname in dns_table, used as transaction ID in the
399 * @return ERR_OK if packet is sent; an err_t indicating the problem otherwise
402 dns_send(u8_t numdns, const char* name, u8_t id)
406 struct dns_query qry;
409 const char *pHostname;
412 LWIP_DEBUGF(DNS_DEBUG, ("dns_send: dns_servers[%"U16_F"] \"%s\": request\n",
413 (u16_t)(numdns), name));
414 LWIP_ASSERT("dns server out of array", numdns < DNS_MAX_SERVERS);
415 LWIP_ASSERT("dns server has no IP address set", dns_servers[numdns].addr != 0);
417 /* if here, we have either a new query or a retry on a previous query to process */
418 p = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dns_hdr) + DNS_MAX_NAME_LENGTH +
419 sizeof(struct dns_query), PBUF_RAM);
421 LWIP_ASSERT("pbuf must be in one piece", p->next == NULL);
422 /* fill dns header */
423 hdr = (struct dns_hdr*)p->payload;
424 memset(hdr, 0, sizeof(struct dns_hdr));
426 hdr->flags1 = DNS_FLAG1_RD;
427 hdr->numquestions = htons(1);
428 query = (char*)hdr + sizeof(struct dns_hdr);
432 /* convert hostname into suitable query format. */
437 for(n = 0; *pHostname != '.' && *pHostname != 0; ++pHostname) {
443 } while(*pHostname != 0);
447 qry.type = htons(DNS_RRTYPE_A);
448 qry.class = htons(DNS_RRCLASS_IN);
449 MEMCPY( query, &qry, sizeof(struct dns_query));
451 /* resize pbuf to the exact dns query */
452 pbuf_realloc(p, (query + sizeof(struct dns_query)) - ((char*)(p->payload)));
454 /* connect to the server for faster receiving */
455 udp_connect(dns_pcb, &dns_servers[numdns], DNS_SERVER_PORT);
456 /* send dns packet */
457 err = udp_sendto(dns_pcb, p, &dns_servers[numdns], DNS_SERVER_PORT);
469 * dns_check_entry() - see if pEntry has not yet been queried and, if so, sends out a query.
470 * Check an entry in the dns_table:
471 * - send out query for new entries
472 * - retry old pending entries on timeout (also with different servers)
473 * - remove completed entries from the table if their TTL has expired
475 * @param i index of the dns_table entry to check
478 dns_check_entry(u8_t i)
480 struct dns_table_entry *pEntry = &dns_table[i];
482 LWIP_ASSERT("array index out of bounds", i < DNS_TABLE_SIZE);
484 switch(pEntry->state) {
486 case DNS_STATE_NEW: {
487 /* initialize new entry */
488 pEntry->state = DNS_STATE_ASKING;
493 /* send DNS packet for this entry */
494 dns_send(pEntry->numdns, pEntry->name, i);
498 case DNS_STATE_ASKING: {
499 if (--pEntry->tmr == 0) {
500 if (++pEntry->retries == DNS_MAX_RETRIES) {
501 if ((pEntry->numdns+1<DNS_MAX_SERVERS) && (dns_servers[pEntry->numdns+1].addr!=0)) {
502 /* change of server */
508 LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": timeout\n", pEntry->name));
509 /* call specified callback function if provided */
511 (*pEntry->found)(pEntry->name, NULL, pEntry->arg);
512 /* flush this entry */
513 pEntry->state = DNS_STATE_UNUSED;
514 pEntry->found = NULL;
519 /* wait longer for the next retry */
520 pEntry->tmr = pEntry->retries;
522 /* send DNS packet for this entry */
523 dns_send(pEntry->numdns, pEntry->name, i);
528 case DNS_STATE_DONE: {
529 /* if the time to live is nul */
530 if (--pEntry->ttl == 0) {
531 LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", pEntry->name));
532 /* flush this entry */
533 pEntry->state = DNS_STATE_UNUSED;
534 pEntry->found = NULL;
538 case DNS_STATE_UNUSED:
542 LWIP_ASSERT("unknown dns_table entry state:", 0);
548 * Call dns_check_entry for each entry in dns_table - check all entries.
551 dns_check_entries(void)
555 for (i = 0; i < DNS_TABLE_SIZE; ++i) {
561 * Receive input function for DNS response packets arriving for the dns UDP pcb.
566 dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
571 struct dns_answer ans;
572 struct dns_table_entry *pEntry;
573 u8_t nquestions, nanswers;
574 #if (DNS_USES_STATIC_BUF == 0)
575 u8_t dns_payload[DNS_MSG_SIZE];
576 #endif /* (DNS_USES_STATIC_BUF == 0) */
577 #if (DNS_USES_STATIC_BUF == 2)
579 #endif /* (DNS_USES_STATIC_BUF == 2) */
581 LWIP_UNUSED_ARG(arg);
582 LWIP_UNUSED_ARG(pcb);
583 LWIP_UNUSED_ARG(addr);
584 LWIP_UNUSED_ARG(port);
586 /* is the dns message too big ? */
587 if (p->tot_len > DNS_MSG_SIZE) {
588 LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf too big\n"));
589 /* free pbuf and return */
593 /* is the dns message big enough ? */
594 if (p->tot_len < (sizeof(struct dns_hdr) + sizeof(struct dns_query) + sizeof(struct dns_answer))) {
595 LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf too small\n"));
596 /* free pbuf and return */
600 #if (DNS_USES_STATIC_BUF == 2)
601 dns_payload = mem_malloc(p->tot_len);
602 if (dns_payload == NULL) {
603 LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: mem_malloc error\n"));
604 /* free pbuf and return */
607 #endif /* (DNS_USES_STATIC_BUF == 2) */
609 /* copy dns payload inside static buffer for processing */
610 if (pbuf_copy_partial(p, dns_payload, p->tot_len, 0) == p->tot_len) {
611 /* The ID in the DNS header should be our entry into the name table. */
612 hdr = (struct dns_hdr*)dns_payload;
614 if (i < DNS_TABLE_SIZE) {
615 pEntry = &dns_table[i];
616 if(pEntry->state == DNS_STATE_ASKING) {
617 /* This entry is now completed. */
618 pEntry->state = DNS_STATE_DONE;
619 pEntry->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
621 /* We only care about the question(s) and the answers. The authrr
622 and the extrarr are simply discarded. */
623 nquestions = htons(hdr->numquestions);
624 nanswers = htons(hdr->numanswers);
626 /* Check for error. If so, call callback to inform. */
627 if (((hdr->flags1 & DNS_FLAG1_RESPONSE) == 0) || (pEntry->err != 0) || (nquestions != 1)) {
628 LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in flags\n", pEntry->name));
629 /* call callback to indicate error, clean up memory and return */
633 #if DNS_DOES_NAME_CHECK
634 /* Check if the name in the "question" part match with the name in the entry. */
635 if (dns_compare_name((unsigned char *)(pEntry->name), (unsigned char *)dns_payload + sizeof(struct dns_hdr)) != 0) {
636 LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response not match to query\n", pEntry->name));
637 /* call callback to indicate error, clean up memory and return */
640 #endif /* DNS_DOES_NAME_CHECK */
642 /* Skip the name in the "question" part */
643 pHostname = (char *) dns_parse_name((unsigned char *)dns_payload + sizeof(struct dns_hdr)) + sizeof(struct dns_query);
645 while(nanswers > 0) {
646 /* skip answer resource record's host name */
647 pHostname = (char *) dns_parse_name((unsigned char *)pHostname);
649 /* Check for IP address type and Internet class. Others are discarded. */
650 MEMCPY(&ans, pHostname, sizeof(struct dns_answer));
651 if((ntohs(ans.type) == DNS_RRTYPE_A) && (ntohs(ans.class) == DNS_RRCLASS_IN) && (ntohs(ans.len) == sizeof(struct ip_addr)) ) {
652 /* read the answer resource record's TTL, and maximize it if needed */
653 pEntry->ttl = ntohl(ans.ttl);
654 if (pEntry->ttl > DNS_MAX_TTL) {
655 pEntry->ttl = DNS_MAX_TTL;
657 /* read the IP address after answer resource record's header */
658 MEMCPY( &(pEntry->ipaddr), (pHostname+sizeof(struct dns_answer)), sizeof(struct ip_addr));
659 LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response = ", pEntry->name));
660 ip_addr_debug_print(DNS_DEBUG, (&(pEntry->ipaddr)));
661 LWIP_DEBUGF(DNS_DEBUG, ("\n"));
662 /* call specified callback function if provided */
664 (*pEntry->found)(pEntry->name, &pEntry->ipaddr, pEntry->arg);
666 /* deallocate memory and return */
669 pHostname = pHostname + sizeof(struct dns_answer) + htons(ans.len);
673 LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in response\n", pEntry->name));
674 /* call callback to indicate error, clean up memory and return */
680 /* deallocate memory and return */
684 /* ERROR: call specified callback function with NULL as name to indicate an error */
686 (*pEntry->found)(pEntry->name, NULL, pEntry->arg);
688 /* flush this entry */
689 pEntry->state = DNS_STATE_UNUSED;
690 pEntry->found = NULL;
693 #if (DNS_USES_STATIC_BUF == 2)
694 /* free dns buffer */
695 mem_free(dns_payload);
696 #endif /* (DNS_USES_STATIC_BUF == 2) */
705 * Queues a new hostname to resolve and sends out a DNS query for that hostname
707 * @param name the hostname that is to be queried
708 * @param found a callback founction to be called on success, failure or timeout
709 * @param callback_arg argument to pass to the callback function
710 * @return @return a err_t return code.
713 dns_enqueue(const char *name, dns_found_callback found, void *callback_arg)
717 struct dns_table_entry *pEntry = NULL;
719 /* search an unused entry, or the oldest one */
721 for (i = 0; i < DNS_TABLE_SIZE; ++i) {
722 pEntry = &dns_table[i];
723 /* is it an unused entry ? */
724 if (pEntry->state == DNS_STATE_UNUSED)
727 /* check if this is the oldest completed entry */
728 if (pEntry->state == DNS_STATE_DONE) {
729 if ((dns_seqno - pEntry->seqno) > lseq) {
730 lseq = dns_seqno - pEntry->seqno;
736 /* if we don't have found an unused entry, use the oldest completed one */
737 if (i == DNS_TABLE_SIZE) {
738 if ((lseqi >= DNS_TABLE_SIZE) || (dns_table[lseqi].state != DNS_STATE_DONE)) {
739 /* no entry can't be used now, table is full */
740 LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": DNS entries table is full\n", name));
743 /* use the oldest completed one */
745 pEntry = &dns_table[i];
750 LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": use DNS entry %"U16_F"\n", name, (u16_t)(i)));
753 pEntry->state = DNS_STATE_NEW;
754 pEntry->seqno = dns_seqno++;
755 pEntry->found = found;
756 pEntry->arg = callback_arg;
757 strcpy(pEntry->name, name);
759 /* force to send query without waiting timer */
762 /* dns query is enqueued */
763 return ERR_INPROGRESS;
767 * Resolve a hostname (string) into an IP address.
768 * NON-BLOCKING callback version for use with raw API!!!
770 * Returns immediately with one of err_t return codes:
771 * - ERR_OK if hostname is a valid IP address string or the host
772 * name is already in the local names table.
773 * - ERR_INPROGRESS enqueue a request to be sent to the DNS server
774 * for resolution if no errors are present.
776 * @param hostname the hostname that is to be queried
777 * @param addr pointer to a struct ip_addr where to store the address if it is already
778 * cached in the dns_table (only valid if ERR_OK is returned!)
779 * @param found a callback function to be called on success, failure or timeout (only if
780 * ERR_INPROGRESS is returned!)
781 * @param callback_arg argument to pass to the callback function
782 * @return a err_t return code.
785 dns_gethostbyname(const char *hostname, struct ip_addr *addr, dns_found_callback found,
788 /* not initialized or no valid server yet, or invalid addr pointer
789 * or invalid hostname or invalid hostname length */
790 if ((dns_pcb == NULL) || (addr == NULL) ||
791 (!hostname) || (!hostname[0]) ||
792 (strlen(hostname) >= DNS_MAX_NAME_LENGTH)) {
797 if (strcmp(hostname,"localhost")==0) {
798 addr->addr = INADDR_LOOPBACK;
801 #endif /* LWIP_HAVE_LOOPIF */
803 /* host name already in octet notation? set ip addr and return ERR_OK
804 * already have this address cached? */
805 if (((addr->addr = inet_addr(hostname)) != INADDR_NONE) ||
806 ((addr->addr = dns_lookup(hostname)) != 0)) {
810 /* queue query with specified callback */
811 return dns_enqueue(hostname, found, callback_arg);
814 #endif /* LWIP_DNS */