Index: docs/libcurl/curl_easy_setopt.3 =================================================================== RCS file: /cvsroot/curl/curl/docs/libcurl/curl_easy_setopt.3,v retrieving revision 1.223 diff -u -r1.223 curl_easy_setopt.3 --- docs/libcurl/curl_easy_setopt.3 10 Jul 2008 22:24:11 -0000 1.223 +++ docs/libcurl/curl_easy_setopt.3 11 Jul 2008 10:18:04 -0000 @@ -547,6 +547,9 @@ without delay. This is less efficient than sending larger amounts of data at a time, and can contribute to congestion on the network if overdone. +.IP CURLOPT_ADDRESS_SCOPE +Pass an unsigned int specifying the scope_id value to use when +connecting to IPv6 link-local or site-local addresses. .SH NAMES and PASSWORDS OPTIONS (Authentication) .IP CURLOPT_NETRC This parameter controls the preference of libcurl between using user names and Index: include/curl/curl.h =================================================================== RCS file: /cvsroot/curl/curl/include/curl/curl.h,v retrieving revision 1.359 diff -u -r1.359 curl.h --- include/curl/curl.h 3 Jul 2008 06:56:03 -0000 1.359 +++ include/curl/curl.h 11 Jul 2008 10:18:04 -0000 @@ -1211,6 +1211,9 @@ /* Issuer certificate */ CINIT(ISSUERCERT, OBJECTPOINT, 170), + /* Address scope */ + CINIT(ADDRESS_SCOPE, LONG, 171), + CURLOPT_LASTENTRY /* the last unused */ } CURLoption; Index: lib/connect.c =================================================================== RCS file: /cvsroot/curl/curl/lib/connect.c,v retrieving revision 1.194 diff -u -r1.194 connect.c --- lib/connect.c 8 Jun 2008 15:52:03 -0000 1.194 +++ lib/connect.c 11 Jul 2008 10:18:04 -0000 @@ -775,6 +775,15 @@ *connected = FALSE; /* default is not connected */ +#ifdef CURLRES_IPV6 + if (conn->scope + && addr->family == AF_INET6) + { + struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)&addr->addr; + in6->sin6_scope_id = conn->scope; + } +#endif + /* FIXME: do we have Curl_printable_address-like with struct sockaddr* as argument? */ #if defined(HAVE_SYS_UN_H) && defined(AF_UNIX) Index: lib/url.c =================================================================== RCS file: /cvsroot/curl/curl/lib/url.c,v retrieving revision 1.720 diff -u -r1.720 url.c --- lib/url.c 11 Jul 2008 09:18:30 -0000 1.720 +++ lib/url.c 11 Jul 2008 10:18:05 -0000 @@ -2091,6 +2091,10 @@ } break; + case CURLOPT_ADDRESS_SCOPE: + data->set.scope = va_arg(param, unsigned int); + break; + default: /* unknown tag and its companion, just ignore: */ result = CURLE_FAILED_INIT; /* correct this */ @@ -3080,6 +3084,24 @@ path[0] = '/'; } + if (conn->host.name[0] == '[' && !data->state.this_is_a_follow) { + /* This looks like an IPv6 address literal. See if there is an address scope. */ + char *percent = strstr (conn->host.name, "%25"); + if (percent) { + char *endp; + conn->scope = strtoul (percent + 3, &endp, 10); + if (*endp == ']') { + /* The address scope was well formed. Knock it out of the hostname. */ + strcpy (percent, "]"); + } + } + } + + if (data->set.scope) { + /* Override any scope that was set above. */ + conn->scope = data->set.scope; + } + /* * So if the URL was A://B/C, * conn->protostr is A Index: lib/urldata.h =================================================================== RCS file: /cvsroot/curl/curl/lib/urldata.h,v retrieving revision 1.382 diff -u -r1.382 urldata.h --- lib/urldata.h 3 Jul 2008 06:56:04 -0000 1.382 +++ lib/urldata.h 11 Jul 2008 10:18:05 -0000 @@ -903,6 +903,8 @@ set. */ char *ip_addr_str; + unsigned int scope; /* address scope for IPv6 */ + char protostr[16]; /* store the protocol string in this buffer */ int socktype; /* SOCK_STREAM or SOCK_DGRAM */ @@ -1477,6 +1479,7 @@ bool proxy_transfer_mode; /* set transfer mode (;type=) when doing FTP via an HTTP proxy */ char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */ + unsigned int scope; /* address scope for IPv6 */ }; struct Names {