IPv6-adjustments

This commit is contained in:
Daniel Stenberg
2001-02-21 17:15:09 +00:00
parent 46e0937263
commit da06a6e7e3
4 changed files with 28 additions and 25 deletions

View File

@@ -1058,7 +1058,7 @@ again:;
* previous lookup. * previous lookup.
*/ */
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
res = conn->res; res = conn->hp;
#else #else
he = conn->hp; he = conn->hp;
#endif #endif

View File

@@ -390,7 +390,7 @@ static const short yycheck[] = { 0,
56 56
}; };
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "/usr/local/share/bison.simple" #line 3 "/usr/lib/bison.simple"
/* This file comes from bison-1.28. */ /* This file comes from bison-1.28. */
/* Skeleton output parser for bison, /* Skeleton output parser for bison,
@@ -604,7 +604,7 @@ __yy_memcpy (char *to, char *from, unsigned int count)
#endif #endif
#endif #endif
#line 217 "/usr/local/share/bison.simple" #line 217 "/usr/lib/bison.simple"
/* The user can define YYPARSE_PARAM as the name of an argument to be passed /* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *. into yyparse. The argument should have type void *.
@@ -1295,7 +1295,7 @@ case 50:
break;} break;}
} }
/* the action file gets copied in in place of this dollarsign */ /* the action file gets copied in in place of this dollarsign */
#line 543 "/usr/local/share/bison.simple" #line 543 "/usr/lib/bison.simple"
yyvsp -= yylen; yyvsp -= yylen;
yyssp -= yylen; yyssp -= yylen;

View File

@@ -547,8 +547,8 @@ CURLcode curl_disconnect(CURLconnect *c_connect)
free(conn->proto.generic); free(conn->proto.generic);
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
if(conn->res) /* host name info */ if(conn->hp) /* host name info */
freeaddrinfo(conn->res); freeaddrinfo(conn->hp);
#else #else
if(conn->hostent_buf) /* host name info */ if(conn->hostent_buf) /* host name info */
free(conn->hostent_buf); free(conn->hostent_buf);
@@ -708,6 +708,9 @@ static CURLcode ConnectPlease(struct UrlData *data,
conn->hp->h_addr, conn->hp->h_length); conn->hp->h_addr, conn->hp->h_length);
conn->serv_addr.sin_family = conn->hp->h_addrtype; conn->serv_addr.sin_family = conn->hp->h_addrtype;
conn->serv_addr.sin_port = htons(data->port); conn->serv_addr.sin_port = htons(data->port);
#else
/* IPv6-style */
struct addrinfo *ai;
#endif #endif
#if !defined(WIN32)||defined(__CYGWIN32__) #if !defined(WIN32)||defined(__CYGWIN32__)
@@ -836,21 +839,22 @@ static CURLcode ConnectPlease(struct UrlData *data,
* Connect to server/proxy * Connect to server/proxy
*************************************************************/ *************************************************************/
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
data->firstsocket = -1; conn->firstsocket = -1;
for (ai = conn->res; ai; ai = ai->ai_next) { for (ai = conn->hp; ai; ai = ai->ai_next) {
data->firstsocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); conn->firstsocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (data->firstsocket < 0) if (conn->firstsocket < 0)
continue; continue;
if (connect(data->firstsocket, ai->ai_addr, ai->ai_addrlen) < 0) { if (connect(conn->firstsocket, ai->ai_addr, ai->ai_addrlen) < 0) {
close(data->firstsocket); close(conn->firstsocket);
data->firstsocket = -1; conn->firstsocket = -1;
continue; continue;
} }
break; break;
} }
if (data->firstsocket < 0) { conn->ai = ai;
if (conn->firstsocket < 0) {
failf(data, strerror(errno)); failf(data, strerror(errno));
return CURLE_COULDNT_CONNECT; return CURLE_COULDNT_CONNECT;
} }
@@ -923,9 +927,6 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
struct sigaction sigact; struct sigaction sigact;
#endif #endif
int urllen; int urllen;
#ifdef ENABLE_IPV6
struct addrinfo *ai;
#endif
/************************************************************* /*************************************************************
* Check input data * Check input data
@@ -1562,17 +1563,16 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
data->port = data->remote_port; /* it is the same port */ data->port = data->remote_port; /* it is the same port */
/* Resolve target host right on */ /* Resolve target host right on */
if(!conn->hp) {
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
if(!conn->res)
/* it might already be set if reusing a connection */ /* it might already be set if reusing a connection */
conn->res = Curl_getaddrinfo(data, conn->name, data->port); conn->hp = Curl_getaddrinfo(data, conn->name, data->port);
if(!conn->res)
#else #else
if(!conn->hp)
/* it might already be set if reusing a connection */ /* it might already be set if reusing a connection */
conn->hp = Curl_gethost(data, conn->name, &conn->hostent_buf); conn->hp = Curl_gethost(data, conn->name, &conn->hostent_buf);
if(!conn->hp)
#endif #endif
}
if(!conn->hp)
{ {
failf(data, "Couldn't resolve host '%s'", conn->name); failf(data, "Couldn't resolve host '%s'", conn->name);
return CURLE_COULDNT_RESOLVE_HOST; return CURLE_COULDNT_RESOLVE_HOST;
@@ -1702,6 +1702,8 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
#else #else
const int niflags = NI_NUMERICHOST; const int niflags = NI_NUMERICHOST;
#endif #endif
struct addrinfo *ai = conn->ai;
if (getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, sizeof(hbuf), NULL, 0, if (getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, sizeof(hbuf), NULL, 0,
niflags)) { niflags)) {
snprintf(hbuf, sizeof(hbuf), "?"); snprintf(hbuf, sizeof(hbuf), "?");
@@ -1751,8 +1753,8 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
if(conn->path) if(conn->path)
free(conn->path); free(conn->path);
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
if(conn->res) if(conn->hp)
freeaddrinfo(conn->res); freeaddrinfo(conn->hp);
#else #else
if(conn->hostent_buf) if(conn->hostent_buf)
free(conn->hostent_buf); free(conn->hostent_buf);

View File

@@ -218,7 +218,8 @@ struct connectdata {
#define PROT_FILE (1<<8) #define PROT_FILE (1<<8)
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
struct addrinfo *res; struct addrinfo *hp; /* host info pointer list */
struct addrinfo *ai; /* the particular host we use */
#else #else
char *hostent_buf; /* pointer to allocated memory for name info */ char *hostent_buf; /* pointer to allocated memory for name info */
struct hostent *hp; struct hostent *hp;