1
Index: trunk/lib/hostares.c
2
===================================================================
3
--- trunk.orig/lib/hostares.c 2008-06-27 03:51:47.000000000 +0200
4
+++ trunk/lib/hostares.c 2008-07-11 01:30:24.000000000 +0200
6
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
7
* KIND, either express or implied.
9
- * $Id: hostares.c,v 1.37 2008-04-29 04:18:02 yangtse Exp $
10
+ * $Id: hostares.c,v 1.38 2008-07-09 18:39:49 bagder Exp $
11
***************************************************************************/
18
+#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
20
+ * Curl_ip2addr6() takes an ipv6 internet address as input parameter
21
+ * together with a pointer to the string version of the address, and it
22
+ * returns a Curl_addrinfo chain filled in correctly with information for this
25
+ * The input parameters ARE NOT checked for validity but they are expected
26
+ * to have been checked already when this is called.
28
+Curl_addrinfo *Curl_ip2addr6(struct in6_addr *in,
29
+ const char *hostname, int port)
33
+#if defined(VMS) && defined(__INITIAL_POINTER_SIZE) && \
34
+ (__INITIAL_POINTER_SIZE == 64)
35
+#pragma pointer_size save
36
+#pragma pointer_size short
37
+#pragma message disable PTRMISMATCH
41
+ struct in6_addr *addrentry;
43
+ struct hostent hostentry;
44
+ char *h_addr_list[2];
45
+ struct in6_addr addrentry;
48
+ struct namebuf6 *buf = malloc(sizeof (struct namebuf6) + strlen(hostname));
53
+ h = &buf->hostentry;
54
+ h->h_addr_list = &buf->h_addr_list[0];
55
+ addrentry = &buf->addrentry;
56
+ memcpy(addrentry, in, sizeof (*in));
57
+ h->h_addr_list[0] = (char*)addrentry;
58
+ h->h_addr_list[1] = NULL; /* terminate list of entries */
59
+ h->h_name = &buf->hostname[0];
60
+ h->h_aliases = NULL;
61
+ h->h_addrtype = AF_INET6;
63
+ /* Now store the dotted version of the address */
64
+ strcpy (h->h_name, hostname);
66
+#if defined(VMS) && defined(__INITIAL_POINTER_SIZE) && \
67
+ (__INITIAL_POINTER_SIZE == 64)
68
+#pragma pointer_size restore
69
+#pragma message enable PTRMISMATCH
72
+ ai = Curl_he2ai(h, port);
78
+#endif /* CURLRES_IPV6 */
83
* Curl_getaddrinfo() - when using ares
87
struct SessionHandle *data = conn->data;
88
in_addr_t in = inet_addr(hostname);
90
+ int family = PF_INET;
91
+#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
92
+ struct in6_addr in6;
93
+#endif /* CURLRES_IPV6 */
96
if(in != CURL_INADDR_NONE) {
98
return Curl_ip2addr(in, hostname, port);
101
+#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
102
+ if (inet_pton (AF_INET6, hostname, &in6) > 0) {
103
+ /* This must be an IPv6 address literal. */
104
+ return Curl_ip2addr6(&in6, hostname, port);
107
+ switch(data->set.ip_version) {
108
+ case CURL_IPRESOLVE_V4:
111
+ default: /* by default we try ipv6, as PF_UNSPEC isn't supported by (c-)ares */
112
+ case CURL_IPRESOLVE_V6:
116
+#endif /* CURLRES_IPV6 */
118
bufp = strdup(hostname);
122
conn->async.dns = NULL; /* clear */
124
/* areschannel is already setup in the Curl_open() function */
125
- ares_gethostbyname(data->state.areschannel, hostname, PF_INET,
126
+ ares_gethostbyname(data->state.areschannel, hostname, family,
127
(ares_host_callback)Curl_addrinfo4_callback, conn);
129
*waitp = TRUE; /* please wait for the response */
130
Index: trunk/lib/hostip4.c
131
===================================================================
132
--- trunk.orig/lib/hostip4.c 2008-06-27 03:51:47.000000000 +0200
133
+++ trunk/lib/hostip4.c 2008-07-11 01:31:01.000000000 +0200
135
* | (__| |_| | _ <| |___
136
* \___|\___/|_| \_\_____|
138
- * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
139
+ * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
141
* This software is licensed as described in the file COPYING, which
142
* you should have received as part of this distribution. The terms
144
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
145
* KIND, either express or implied.
147
- * $Id: hostip4.c,v 1.42 2007-11-07 09:21:35 bagder Exp $
148
+ * $Id: hostip4.c,v 1.43 2008-07-09 18:39:49 bagder Exp $
149
***************************************************************************/
153
#endif /* CURLRES_SYNCH */
154
#endif /* CURLRES_IPV4 */
157
- * Curl_he2ai() translates from a hostent struct to a Curl_addrinfo struct.
158
- * The Curl_addrinfo is meant to work like the addrinfo struct does for IPv6
159
- * stacks, but for all hosts and environments.
161
- * Curl_addrinfo defined in "lib/hostip.h"
163
- * struct Curl_addrinfo {
168
- * socklen_t ai_addrlen; * Follow rfc3493 struct addrinfo *
169
- * char *ai_canonname;
170
- * struct sockaddr *ai_addr;
171
- * struct Curl_addrinfo *ai_next;
174
- * hostent defined in <netdb.h>
178
- * char **h_aliases;
181
- * char **h_addr_list;
184
- * for backward compatibility:
186
- * #define h_addr h_addr_list[0]
189
-Curl_addrinfo *Curl_he2ai(const struct hostent *he, int port)
192
- Curl_addrinfo *prevai = NULL;
193
- Curl_addrinfo *firstai = NULL;
194
- struct sockaddr_in *addr;
196
- struct in_addr *curr;
199
- /* no input == no output! */
202
- for(i=0; (curr = (struct in_addr *)he->h_addr_list[i]) != NULL; i++) {
204
- ai = calloc(1, sizeof(Curl_addrinfo) + sizeof(struct sockaddr_in));
210
- /* store the pointer we want to return from this function */
214
- /* make the previous entry point to this */
215
- prevai->ai_next = ai;
217
- ai->ai_family = AF_INET; /* we only support this */
219
- /* we return all names as STREAM, so when using this address for TFTP
220
- the type must be ignored and conn->socktype be used instead! */
221
- ai->ai_socktype = SOCK_STREAM;
223
- ai->ai_addrlen = sizeof(struct sockaddr_in);
224
- /* make the ai_addr point to the address immediately following this struct
225
- and use that area to store the address */
226
- ai->ai_addr = (struct sockaddr *) ((char*)ai + sizeof(Curl_addrinfo));
228
- /* FIXME: need to free this eventually */
229
- ai->ai_canonname = strdup(he->h_name);
231
- /* leave the rest of the struct filled with zero */
233
- addr = (struct sockaddr_in *)ai->ai_addr; /* storage area for this info */
235
- memcpy((char *)&(addr->sin_addr), curr, sizeof(struct in_addr));
236
- addr->sin_family = (unsigned short)(he->h_addrtype);
237
- addr->sin_port = htons((unsigned short)port);
244
Index: trunk/lib/hostip.h
245
===================================================================
246
--- trunk.orig/lib/hostip.h 2008-06-27 03:51:47.000000000 +0200
247
+++ trunk/lib/hostip.h 2008-07-11 01:30:55.000000000 +0200
249
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
250
* KIND, either express or implied.
252
- * $Id: hostip.h,v 1.61 2008-01-15 22:44:12 bagder Exp $
253
+ * $Id: hostip.h,v 1.62 2008-07-09 18:39:49 bagder Exp $
254
***************************************************************************/
260
typedef struct addrinfo Curl_addrinfo;
262
+Curl_addrinfo *Curl_ip2addr6(struct in6_addr *in,
263
+ const char *hostname, int port);
266
/* OK, so some ipv4-only include tree probably have the addrinfo struct, but
267
to work even on those that don't, we provide our own look-alike! */
269
===================================================================
270
--- trunk.orig/CHANGES 2008-07-11 01:26:35.000000000 +0200
271
+++ trunk/CHANGES 2008-07-11 01:32:29.000000000 +0200
274
Version 7.18.2 (4 June 2008)
276
+Daniel Stenberg (9 Jul 2008)
277
+- Andreas Schuldei improved Phil Blundell's patch for IPv6 using c-ares, and I
278
+ edited it slightly. Now you should be able to use IPv6 addresses fine even
279
+ with libcurl built to use c-ares.
281
Daniel Fandrich (3 Jun 2008)
282
- Fixed a problem where telnet data would be lost if an EWOULDBLOCK
283
condition were encountered.
284
Index: trunk/RELEASE-NOTES
285
===================================================================
286
--- trunk.orig/RELEASE-NOTES 2008-07-11 01:26:49.000000000 +0200
287
+++ trunk/RELEASE-NOTES 2008-07-11 01:35:17.000000000 +0200
289
o curl can now run on Symbian OS
290
o curl -w redirect_url and CURLINFO_REDIRECT_URL
291
o added curl_easy_send() and curl_easy_recv()
292
+ o c-ares powered libcurls can resolve/use IPv6 addresses
294
This release includes the following bugfixes:
297
David Shaw, Norbert Frese, Bart Whiteley, Jean-Francois Bertrand, Ben Van Hof,
298
Yuriy Sosov, Christopher Palow, Yang Tse, Liam Healy, Nikolai Kondrashov,
299
David Rosenstrauch, Andreas Faerber, Scott McCreary, Jeff Weber, Emil Romanus
300
+ Rolland Dudemaine, Phil Blundell, Scott Barrett, Andreas Schuldei
302
- Thanks! (and sorry if I forgot to mention someone)
303
+ Thanks! (and sorry if I forgot to mention someone)
304
Index: trunk/lib/hostip.c
305
===================================================================
306
--- trunk.orig/lib/hostip.c 2008-07-11 01:25:33.000000000 +0200
307
+++ trunk/lib/hostip.c 2008-07-11 01:30:45.000000000 +0200
309
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
310
* KIND, either express or implied.
312
- * $Id: hostip.c,v 1.191 2008-03-11 22:55:24 bagder Exp $
313
+ * $Id: hostip.c,v 1.192 2008-07-09 18:39:49 bagder Exp $
314
***************************************************************************/
318
#endif /* CURLRES_ADDRINFO_COPY */
320
/***********************************************************************
321
- * Only for plain-ipv4 and c-ares builds
322
+ * Only for plain-ipv4 and c-ares builds (NOTE: c-ares builds can be IPv6
324
**********************************************************************/
326
#if defined(CURLRES_IPV4) || defined(CURLRES_ARES)
327
@@ -630,6 +631,118 @@
331
-#endif /* CURLRES_IPV4 || CURLRES_ARES */
334
+ * Curl_he2ai() translates from a hostent struct to a Curl_addrinfo struct.
335
+ * The Curl_addrinfo is meant to work like the addrinfo struct does for IPv6
336
+ * stacks, but for all hosts and environments.
338
+ * Curl_addrinfo defined in "lib/hostip.h"
340
+ * struct Curl_addrinfo {
345
+ * socklen_t ai_addrlen; * Follow rfc3493 struct addrinfo *
346
+ * char *ai_canonname;
347
+ * struct sockaddr *ai_addr;
348
+ * struct Curl_addrinfo *ai_next;
351
+ * hostent defined in <netdb.h>
355
+ * char **h_aliases;
358
+ * char **h_addr_list;
361
+ * for backward compatibility:
363
+ * #define h_addr h_addr_list[0]
366
+Curl_addrinfo *Curl_he2ai(const struct hostent *he, int port)
369
+ Curl_addrinfo *prevai = NULL;
370
+ Curl_addrinfo *firstai = NULL;
371
+ struct sockaddr_in *addr;
373
+ struct sockaddr_in6 *addr6;
374
+#endif /* CURLRES_IPV6 */
376
+ struct in_addr *curr;
379
+ /* no input == no output! */
382
+ for(i=0; (curr = (struct in_addr *)he->h_addr_list[i]) != NULL; i++) {
386
+ if (he->h_addrtype == AF_INET6)
387
+ ss_size = sizeof (struct sockaddr_in6);
389
+#endif /* CURLRES_IPV6 */
390
+ ss_size = sizeof (struct sockaddr_in);
392
+ ai = calloc(1, sizeof(Curl_addrinfo) + ss_size);
398
+ /* store the pointer we want to return from this function */
402
+ /* make the previous entry point to this */
403
+ prevai->ai_next = ai;
405
+ ai->ai_family = he->h_addrtype;
407
+ /* we return all names as STREAM, so when using this address for TFTP
408
+ the type must be ignored and conn->socktype be used instead! */
409
+ ai->ai_socktype = SOCK_STREAM;
411
+ ai->ai_addrlen = ss_size;
412
+ /* make the ai_addr point to the address immediately following this struct
413
+ and use that area to store the address */
414
+ ai->ai_addr = (struct sockaddr *) ((char*)ai + sizeof(Curl_addrinfo));
416
+ /* need to free this eventually */
417
+ ai->ai_canonname = strdup(he->h_name);
419
+ /* leave the rest of the struct filled with zero */
421
+ switch (ai->ai_family) {
423
+ addr = (struct sockaddr_in *)ai->ai_addr; /* storage area for this info */
425
+ memcpy((char *)&(addr->sin_addr), curr, sizeof(struct in_addr));
426
+ addr->sin_family = (unsigned short)(he->h_addrtype);
427
+ addr->sin_port = htons((unsigned short)port);
432
+ addr6 = (struct sockaddr_in6 *)ai->ai_addr; /* storage area for this info */
434
+ memcpy((char *)&(addr6->sin6_addr), curr, sizeof(struct in6_addr));
435
+ addr6->sin6_family = (unsigned short)(he->h_addrtype);
436
+ addr6->sin6_port = htons((unsigned short)port);
438
+#endif /* CURLRES_IPV6 */
446
+#endif /* CURLRES_IPV4 || CURLRES_ARES */