diff options
Diffstat (limited to 'lib/asyn-thread.c')
| -rw-r--r-- | lib/asyn-thread.c | 27 | 
1 files changed, 17 insertions, 10 deletions
| diff --git a/lib/asyn-thread.c b/lib/asyn-thread.c index 3341686d9..38cde5df7 100644 --- a/lib/asyn-thread.c +++ b/lib/asyn-thread.c @@ -22,9 +22,6 @@  #include "setup.h" -#include <string.h> -#include <errno.h> -  #ifdef HAVE_SYS_SOCKET_H  #include <sys/socket.h>  #endif @@ -37,16 +34,12 @@  #ifdef HAVE_ARPA_INET_H  #include <arpa/inet.h>  #endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h>     /* required for free() prototypes */ -#endif  #ifdef HAVE_UNISTD_H  #include <unistd.h>     /* for the close() proto */  #endif  #ifdef __VMS  #include <in.h>  #include <inet.h> -#include <stdlib.h>  #endif  #if defined(USE_THREADS_POSIX) @@ -421,7 +414,7 @@ static bool init_resolve_thread (struct connectdata *conn,     socket error string function can be used for this pupose. */  static const char *gai_strerror(int ecode)  { -  switch (ecode){ +  switch (ecode) {    case EAI_AGAIN:      return "The name could not be resolved at this time";    case EAI_BADFLAGS: @@ -633,14 +626,28 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,                                           int *waitp)  {    struct addrinfo hints; +  struct in_addr in;    Curl_addrinfo *res;    int error;    char sbuf[NI_MAXSERV];    int pf = PF_INET; +#ifdef CURLRES_IPV6 +  struct in6_addr in6; +#endif /* CURLRES_IPV6 */    *waitp = 0; /* default to synchronous response */ -#ifndef CURLRES_IPV4 +  /* First check if this is an IPv4 address string */ +  if(Curl_inet_pton(AF_INET, hostname, &in) > 0) +    /* This is a dotted IP address 123.123.123.123-style */ +    return Curl_ip2addr(AF_INET, &in, hostname, port); + +#ifdef CURLRES_IPV6 +  /* check if this is an IPv6 address string */ +  if(Curl_inet_pton (AF_INET6, hostname, &in6) > 0) +    /* This is an IPv6 address literal */ +    return Curl_ip2addr(AF_INET6, &in6, hostname, port); +    /*     * Check if a limited name resolve has been requested.     */ @@ -660,7 +667,7 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,      /* the stack seems to be a non-ipv6 one */      pf = PF_INET; -#endif /* !CURLRES_IPV4 */ +#endif /* CURLRES_IPV6 */    memset(&hints, 0, sizeof(hints));    hints.ai_family = pf; | 
