diff options
Diffstat (limited to 'libs/libcurl/src/curl_addrinfo.c')
-rw-r--r-- | libs/libcurl/src/curl_addrinfo.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/libs/libcurl/src/curl_addrinfo.c b/libs/libcurl/src/curl_addrinfo.c index 1f895263c8..f169932275 100644 --- a/libs/libcurl/src/curl_addrinfo.c +++ b/libs/libcurl/src/curl_addrinfo.c @@ -50,8 +50,9 @@ #include <stddef.h>
#include "curl_addrinfo.h"
-#include "inet_pton.h"
-#include "warnless.h"
+#include "fake_addrinfo.h"
+#include "curlx/inet_pton.h"
+#include "curlx/warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -118,7 +119,7 @@ Curl_getaddrinfo_ex(const char *nodename, *result = NULL; /* assume failure */
- error = getaddrinfo(nodename, servname, hints, &aihead);
+ error = CURL_GETADDRINFO(nodename, servname, hints, &aihead);
if(error)
return error;
@@ -184,7 +185,7 @@ Curl_getaddrinfo_ex(const char *nodename, /* destroy the addrinfo list */
if(aihead)
- freeaddrinfo(aihead);
+ CURL_FREEADDRINFO(aihead);
/* if we failed, also destroy the Curl_addrinfo list */
if(error) {
@@ -217,7 +218,7 @@ Curl_getaddrinfo_ex(const char *nodename, *
* This function returns a pointer to the first element of a newly allocated
* Curl_addrinfo struct linked list filled with the data of a given hostent.
- * Curl_addrinfo is meant to work like the addrinfo struct does for a IPv6
+ * Curl_addrinfo is meant to work like the addrinfo struct does for an IPv6
* stack, but usable also for IPv4, all hosts and environments.
*
* The memory allocated by this function *MUST* be free'd later on calling
@@ -318,11 +319,7 @@ Curl_he2ai(const struct hostent *he, int port) addr = (void *)ai->ai_addr; /* storage area for this info */
memcpy(&addr->sin_addr, curr, sizeof(struct in_addr));
-#ifdef __MINGW32__
- addr->sin_family = (short)(he->h_addrtype);
-#else
addr->sin_family = (CURL_SA_FAMILY_T)(he->h_addrtype);
-#endif
addr->sin_port = htons((unsigned short)port);
break;
@@ -331,11 +328,7 @@ Curl_he2ai(const struct hostent *he, int port) addr6 = (void *)ai->ai_addr; /* storage area for this info */
memcpy(&addr6->sin6_addr, curr, sizeof(struct in6_addr));
-#ifdef __MINGW32__
- addr6->sin6_family = (short)(he->h_addrtype);
-#else
addr6->sin6_family = (CURL_SA_FAMILY_T)(he->h_addrtype);
-#endif
addr6->sin6_port = htons((unsigned short)port);
break;
#endif
@@ -438,13 +431,13 @@ Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port) struct Curl_addrinfo *Curl_str2addr(char *address, int port)
{
struct in_addr in;
- if(Curl_inet_pton(AF_INET, address, &in) > 0)
+ if(curlx_inet_pton(AF_INET, address, &in) > 0)
/* This is a dotted IP address 123.123.123.123-style */
return Curl_ip2addr(AF_INET, &in, address, port);
#ifdef USE_IPV6
{
struct in6_addr in6;
- if(Curl_inet_pton(AF_INET6, address, &in6) > 0)
+ if(curlx_inet_pton(AF_INET6, address, &in6) > 0)
/* This is a dotted IPv6 address ::1-style */
return Curl_ip2addr(AF_INET6, &in6, address, port);
}
@@ -475,7 +468,7 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, sa_un = (void *) ai->ai_addr;
sa_un->sun_family = AF_UNIX;
- /* sun_path must be able to store the NUL-terminated path */
+ /* sun_path must be able to store the null-terminated path */
path_len = strlen(path) + 1;
if(path_len > sizeof(sa_un->sun_path)) {
free(ai);
@@ -516,8 +509,16 @@ curl_dbg_freeaddrinfo(struct addrinfo *freethis, source, line, (void *)freethis);
#ifdef USE_LWIPSOCK
lwip_freeaddrinfo(freethis);
+#elif defined(USE_FAKE_GETADDRINFO)
+ {
+ const char *env = getenv("CURL_DNS_SERVER");
+ if(env)
+ r_freeaddrinfo(freethis);
+ else
+ freeaddrinfo(freethis);
+ }
#else
- (freeaddrinfo)(freethis);
+ freeaddrinfo(freethis);
#endif
}
#endif /* defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO) */
@@ -534,15 +535,22 @@ curl_dbg_freeaddrinfo(struct addrinfo *freethis, int
curl_dbg_getaddrinfo(const char *hostname,
- const char *service,
- const struct addrinfo *hints,
- struct addrinfo **result,
- int line, const char *source)
+ const char *service,
+ const struct addrinfo *hints,
+ struct addrinfo **result,
+ int line, const char *source)
{
#ifdef USE_LWIPSOCK
int res = lwip_getaddrinfo(hostname, service, hints, result);
+#elif defined(USE_FAKE_GETADDRINFO)
+ int res;
+ const char *env = getenv("CURL_DNS_SERVER");
+ if(env)
+ res = r_getaddrinfo(hostname, service, hints, result);
+ else
+ res = getaddrinfo(hostname, service, hints, result);
#else
- int res = (getaddrinfo)(hostname, service, hints, result);
+ int res = getaddrinfo(hostname, service, hints, result);
#endif
if(0 == res)
/* success */
|