Skip to content

Commit

Permalink
webclient: use getaddrinfo to get IPv4 addresses on dual stack systems
Browse files Browse the repository at this point in the history
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
  • Loading branch information
juniskane authored and patacongo committed Apr 23, 2020
1 parent 51cbd42 commit f8f1697
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 97 deletions.
13 changes: 3 additions & 10 deletions include/netutils/webclient.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* apps/include/netutils/webclient.h
* apps/include/netutils/webclient.h
* Header file for the HTTP client
*
* Copyright (C) 2007, 2009, 2011, 2015 Gregory Nutt. All rights reserved.
Expand Down Expand Up @@ -46,9 +46,7 @@
* Included Files
****************************************************************************/

#ifndef CONFIG_WEBCLIENT_HOST
# include <nuttx/config.h>
#endif
#include <nuttx/config.h>
#include <sys/types.h>

/****************************************************************************
Expand Down Expand Up @@ -93,6 +91,7 @@
* of valid bytes is datend - offset.
* buflen - A pointer to the length of the buffer. If the callee wishes
* to change the size of the buffer, it may write to buflen.
* arg - User argument passed to callback.
*/

typedef void (*wget_callback_t)(FAR char **buffer, int offset,
Expand Down Expand Up @@ -125,12 +124,6 @@ int web_posts_strlen(FAR char **name, FAR char **value, int len);
* Description:
* Obtain the requested file from an HTTP server using the GET method.
*
* Note: If the function is passed a host name, it must already be in
* the resolver cache in order for the function to connect to the web
* server. It is therefore up to the calling module to implement the
* resolver calls and the signal handler used for reporting a resolve
* query answer.
*
* Input Parameters
* url - A pointer to a string containing either the full URL to
* the file to get (e.g., http://www.nutt.org/index.html, or
Expand Down
8 changes: 4 additions & 4 deletions netutils/ping/icmp_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ static inline uint16_t ping_newid(void)
* Name: ping_gethostip
*
* Description:
* Call gethostbyname() to get the IP address associated with a hostname.
* Call getaddrinfo() to get the IP address associated with a hostname.
*
* Input Parameters
* hostname - The host name to use in the nslookup.
* ipv4addr - The location to return the IPv4 address.
* destr - The location to return the IPv4 address.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
* Zero (OK) on success; ERROR on failure.
*
****************************************************************************/

Expand Down Expand Up @@ -136,7 +136,7 @@ static int ping_gethostip(FAR const char *hostname, FAR struct in_addr *dest)
#else /* CONFIG_LIBC_NETDB */
/* No host name support */

/* Convert strings to numeric IPv6 address */
/* Convert strings to numeric IPv4 address */

int ret = inet_pton(AF_INET, hostname, dest);

Expand Down
6 changes: 3 additions & 3 deletions netutils/ping/icmpv6_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ static inline uint16_t ping6_newid(void)
* Name: ping6_gethostip
*
* Description:
* Call gethostbyname() to get the IP address associated with a hostname.
* Call getaddrinfo() to get the IP address associated with a hostname.
*
* Input Parameters
* hostname - The host name to use in the nslookup.
* ipv4addr - The location to return the IPv4 address.
* dest - The location to return the IPv6 address.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
* Zero (OK) on success; ERROR on failure.
*
****************************************************************************/

Expand Down
Loading

0 comments on commit f8f1697

Please sign in to comment.