5
5
* | (__| |_| | _ <| |___
6
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
8
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
10
10
* This software is licensed as described in the file COPYING, which
11
11
* you should have received as part of this distribution. The terms
18
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
* KIND, either express or implied.
21
* $Id: hostares.c,v 1.37 2008-04-29 04:18:02 yangtse Exp $
21
* $Id: hostares.c,v 1.46 2009-01-31 20:25:56 bagder Exp $
22
22
***************************************************************************/
314
307
struct SessionHandle *data = conn->data;
315
in_addr_t in = inet_addr(hostname);
309
int family = PF_INET;
310
#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
312
#endif /* CURLRES_IPV6 */
319
if(in != CURL_INADDR_NONE) {
315
/* First check if this is an IPv4 address string */
316
if(Curl_inet_pton(AF_INET, hostname, &in) > 0) {
320
317
/* This is a dotted IP address 123.123.123.123-style */
321
return Curl_ip2addr(in, hostname, port);
318
return Curl_ip2addr(AF_INET, &in, hostname, port);
321
#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
322
/* Otherwise, check if this is an IPv6 address string */
323
if (Curl_inet_pton (AF_INET6, hostname, &in6) > 0) {
324
/* This must be an IPv6 address literal. */
325
return Curl_ip2addr(AF_INET6, &in6, hostname, port);
328
switch(data->set.ip_version) {
330
#if ARES_VERSION >= 0x010601
331
family = PF_UNSPEC; /* supported by c-ares since 1.6.1, so for older
332
c-ares versions this just falls through and defaults
336
case CURL_IPRESOLVE_V4:
339
case CURL_IPRESOLVE_V6:
343
#endif /* CURLRES_IPV6 */
324
345
bufp = strdup(hostname);
332
353
conn->async.dns = NULL; /* clear */
334
355
/* areschannel is already setup in the Curl_open() function */
335
ares_gethostbyname(data->state.areschannel, hostname, PF_INET,
356
ares_gethostbyname(data->state.areschannel, hostname, family,
336
357
(ares_host_callback)Curl_addrinfo4_callback, conn);
338
359
*waitp = TRUE; /* please wait for the response */