aboutsummaryrefslogtreecommitdiff
path: root/lib/hostip4.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-07-09 18:39:49 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-07-09 18:39:49 +0000
commit0cd8840dbaf662ee59573be86fe6550a1b5cbf97 (patch)
treeafeeb1408ce03e1848e9ed2c6593cf5cc2aba587 /lib/hostip4.c
parentd4b253ba3ec87e1d703910bdb278d142e6e6abf8 (diff)
- Andreas Schuldei improved Phil Blundell's patch for IPv6 using c-ares, and I
edited it slightly. Now you should be able to use IPv6 addresses fine even with libcurl built to use c-ares.
Diffstat (limited to 'lib/hostip4.c')
-rw-r--r--lib/hostip4.c90
1 files changed, 1 insertions, 89 deletions
diff --git a/lib/hostip4.c b/lib/hostip4.c
index 4016227de..b3c358838 100644
--- a/lib/hostip4.c
+++ b/lib/hostip4.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -307,91 +307,3 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
#endif /* CURLRES_SYNCH */
#endif /* CURLRES_IPV4 */
-/*
- * Curl_he2ai() translates from a hostent struct to a Curl_addrinfo struct.
- * The Curl_addrinfo is meant to work like the addrinfo struct does for IPv6
- * stacks, but for all hosts and environments.
- *
- * Curl_addrinfo defined in "lib/hostip.h"
- *
- * struct Curl_addrinfo {
- * int ai_flags;
- * int ai_family;
- * int ai_socktype;
- * int ai_protocol;
- * socklen_t ai_addrlen; * Follow rfc3493 struct addrinfo *
- * char *ai_canonname;
- * struct sockaddr *ai_addr;
- * struct Curl_addrinfo *ai_next;
- * };
- *
- * hostent defined in <netdb.h>
- *
- * struct hostent {
- * char *h_name;
- * char **h_aliases;
- * int h_addrtype;
- * int h_length;
- * char **h_addr_list;
- * };
- *
- * for backward compatibility:
- *
- * #define h_addr h_addr_list[0]
- */
-
-Curl_addrinfo *Curl_he2ai(const struct hostent *he, int port)
-{
- Curl_addrinfo *ai;
- Curl_addrinfo *prevai = NULL;
- Curl_addrinfo *firstai = NULL;
- struct sockaddr_in *addr;
- int i;
- struct in_addr *curr;
-
- if(!he)
- /* no input == no output! */
- return NULL;
-
- for(i=0; (curr = (struct in_addr *)he->h_addr_list[i]) != NULL; i++) {
-
- ai = calloc(1, sizeof(Curl_addrinfo) + sizeof(struct sockaddr_in));
-
- if(!ai)
- break;
-
- if(!firstai)
- /* store the pointer we want to return from this function */
- firstai = ai;
-
- if(prevai)
- /* make the previous entry point to this */
- prevai->ai_next = ai;
-
- ai->ai_family = AF_INET; /* we only support this */
-
- /* we return all names as STREAM, so when using this address for TFTP
- the type must be ignored and conn->socktype be used instead! */
- ai->ai_socktype = SOCK_STREAM;
-
- ai->ai_addrlen = sizeof(struct sockaddr_in);
- /* make the ai_addr point to the address immediately following this struct
- and use that area to store the address */
- ai->ai_addr = (struct sockaddr *) ((char*)ai + sizeof(Curl_addrinfo));
-
- /* FIXME: need to free this eventually */
- ai->ai_canonname = strdup(he->h_name);
-
- /* leave the rest of the struct filled with zero */
-
- addr = (struct sockaddr_in *)ai->ai_addr; /* storage area for this info */
-
- memcpy((char *)&(addr->sin_addr), curr, sizeof(struct in_addr));
- addr->sin_family = (unsigned short)(he->h_addrtype);
- addr->sin_port = htons((unsigned short)port);
-
- prevai = ai;
- }
- return firstai;
-}
-