From 915c0105267a9685d3fa1bc915dc08bbb5883d55 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 20 Oct 2012 13:47:30 +0000 Subject: DNS fixes from Darcy Gong (part 1 of 2) git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5235 42af7a65-404d-4744-a932-0658087f49c3 --- apps/netutils/webclient/webclient.c | 56 +------------------------------------ 1 file changed, 1 insertion(+), 55 deletions(-) (limited to 'apps/netutils/webclient/webclient.c') diff --git a/apps/netutils/webclient/webclient.c b/apps/netutils/webclient/webclient.c index 5a84c4fd1..8ce7b93a0 100644 --- a/apps/netutils/webclient/webclient.c +++ b/apps/netutils/webclient/webclient.c @@ -167,60 +167,6 @@ static char *wget_strcpy(char *dest, const char *src) return dest + len; } -/**************************************************************************** - * Name: wget_resolvehost - ****************************************************************************/ - -static inline int wget_resolvehost(const char *hostname, in_addr_t *ipaddr) -{ -#ifdef CONFIG_HAVE_GETHOSTBYNAME - - struct hostent *he; - - nvdbg("Getting address of %s\n", hostname); - he = gethostbyname(hostname); - if (!he) - { - ndbg("gethostbyname failed: %d\n", h_errno); - return ERROR; - } - - nvdbg("Using IP address %04x%04x\n", (uint16_t)he->h_addr[1], (uint16_t)he->h_addr[0]); - memcpy(ipaddr, he->h_addr, sizeof(in_addr_t)); - return OK; - -#else - -# ifdef CONFIG_NET_IPv6 - struct sockaddr_in6 addr; -# else - struct sockaddr_in addr; -# endif - - /* First check if the host is an IP address. */ - - if (!uiplib_ipaddrconv(hostname, (uint8_t*)ipaddr)) - { - /* 'host' does not point to a valid address string. Try to resolve - * the host name to an IP address. - */ - - if (resolv_query(hostname, &addr) < 0) - { - /* Needs to set the errno here */ - - return ERROR; - } - - /* Save the host address -- Needs fixed for IPv6 */ - - *ipaddr = addr.sin_addr.s_addr; - } - return OK; - -#endif -} - /**************************************************************************** * Name: wget_parsestatus ****************************************************************************/ @@ -465,7 +411,7 @@ int wget(FAR const char *url, FAR char *buffer, int buflen, server.sin_family = AF_INET; server.sin_port = htons(ws.port); - ret = wget_resolvehost(ws.hostname, &server.sin_addr.s_addr); + ret = dns_gethostip(ws.hostname, &server.sin_addr.s_addr); if (ret < 0) { /* Could not resolve host (or malformed IP address) */ -- cgit v1.2.3