mirror of
https://github.com/curl/curl.git
synced 2025-04-12 16:20:35 +08:00
parent
ae5e57c304
commit
06eb208126
@ -257,6 +257,9 @@ static CURLcode bindlocal(struct Curl_easy *data,
|
||||
#ifdef IP_BIND_ADDRESS_NO_PORT
|
||||
int on = 1;
|
||||
#endif
|
||||
#ifndef ENABLE_IPV6
|
||||
(void)scope;
|
||||
#endif
|
||||
|
||||
/*************************************************************
|
||||
* Select device to bind socket to
|
||||
@ -314,8 +317,11 @@ static CURLcode bindlocal(struct Curl_easy *data,
|
||||
}
|
||||
#endif
|
||||
|
||||
switch(Curl_if2ip(af, scope, conn->scope_id, dev,
|
||||
myhost, sizeof(myhost))) {
|
||||
switch(Curl_if2ip(af,
|
||||
#ifdef ENABLE_IPV6
|
||||
scope, conn->scope_id,
|
||||
#endif
|
||||
dev, myhost, sizeof(myhost))) {
|
||||
case IF2IP_NOT_FOUND:
|
||||
if(is_interface) {
|
||||
/* Do not fall back to treating it as a host name */
|
||||
|
@ -1029,8 +1029,11 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
|
||||
if(*addr != '\0') {
|
||||
/* attempt to get the address of the given interface name */
|
||||
switch(Curl_if2ip(conn->ip_addr->ai_family,
|
||||
#ifdef ENABLE_IPV6
|
||||
Curl_ipv6_scope(conn->ip_addr->ai_addr),
|
||||
conn->scope_id, addr, hbuf, sizeof(hbuf))) {
|
||||
conn->scope_id,
|
||||
#endif
|
||||
addr, hbuf, sizeof(hbuf))) {
|
||||
case IF2IP_NOT_FOUND:
|
||||
/* not an interface, use the given string as host name instead */
|
||||
host = addr;
|
||||
|
36
lib/if2ip.c
36
lib/if2ip.c
@ -92,19 +92,19 @@ unsigned int Curl_ipv6_scope(const struct sockaddr *sa)
|
||||
|
||||
#if defined(HAVE_GETIFADDRS)
|
||||
|
||||
if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
|
||||
unsigned int local_scope_id, const char *interf,
|
||||
if2ip_result_t Curl_if2ip(int af,
|
||||
#ifdef ENABLE_IPV6
|
||||
unsigned int remote_scope,
|
||||
unsigned int local_scope_id,
|
||||
#endif
|
||||
const char *interf,
|
||||
char *buf, int buf_size)
|
||||
{
|
||||
struct ifaddrs *iface, *head;
|
||||
if2ip_result_t res = IF2IP_NOT_FOUND;
|
||||
|
||||
#ifndef ENABLE_IPV6
|
||||
(void) remote_scope;
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) || \
|
||||
!defined(ENABLE_IPV6)
|
||||
#if defined(ENABLE_IPV6) && \
|
||||
!defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
|
||||
(void) local_scope_id;
|
||||
#endif
|
||||
|
||||
@ -177,8 +177,12 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
|
||||
|
||||
#elif defined(HAVE_IOCTL_SIOCGIFADDR)
|
||||
|
||||
if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
|
||||
unsigned int local_scope_id, const char *interf,
|
||||
if2ip_result_t Curl_if2ip(int af,
|
||||
#ifdef ENABLE_IPV6
|
||||
unsigned int remote_scope,
|
||||
unsigned int local_scope_id,
|
||||
#endif
|
||||
const char *interf,
|
||||
char *buf, int buf_size)
|
||||
{
|
||||
struct ifreq req;
|
||||
@ -188,8 +192,10 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
|
||||
size_t len;
|
||||
const char *r;
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
(void)remote_scope;
|
||||
(void)local_scope_id;
|
||||
#endif
|
||||
|
||||
if(!interf || (af != AF_INET))
|
||||
return IF2IP_NOT_FOUND;
|
||||
@ -226,13 +232,19 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
|
||||
|
||||
#else
|
||||
|
||||
if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
|
||||
unsigned int local_scope_id, const char *interf,
|
||||
if2ip_result_t Curl_if2ip(int af,
|
||||
#ifdef ENABLE_IPV6
|
||||
unsigned int remote_scope,
|
||||
unsigned int local_scope_id,
|
||||
#endif
|
||||
const char *interf,
|
||||
char *buf, int buf_size)
|
||||
{
|
||||
(void) af;
|
||||
#ifdef ENABLE_IPV6
|
||||
(void) remote_scope;
|
||||
(void) local_scope_id;
|
||||
#endif
|
||||
(void) interf;
|
||||
(void) buf;
|
||||
(void) buf_size;
|
||||
|
@ -42,8 +42,12 @@ typedef enum {
|
||||
IF2IP_FOUND = 2 /* The address has been stored in "buf" */
|
||||
} if2ip_result_t;
|
||||
|
||||
if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
|
||||
unsigned int local_scope_id, const char *interf,
|
||||
if2ip_result_t Curl_if2ip(int af,
|
||||
#ifdef ENABLE_IPV6
|
||||
unsigned int remote_scope,
|
||||
unsigned int local_scope_id,
|
||||
#endif
|
||||
const char *interf,
|
||||
char *buf, int buf_size);
|
||||
|
||||
#ifdef __INTERIX
|
||||
|
@ -155,7 +155,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
||||
char *argptr;
|
||||
CURLcode result = CURLE_OK;
|
||||
long arg;
|
||||
#ifdef ENABLE_IPV6
|
||||
unsigned long uarg;
|
||||
#endif
|
||||
curl_off_t bigsize;
|
||||
|
||||
switch(option) {
|
||||
@ -2533,6 +2535,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
case CURLOPT_ADDRESS_SCOPE:
|
||||
/*
|
||||
* Use this scope id when using IPv6
|
||||
@ -2546,6 +2549,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
||||
#endif
|
||||
data->set.scope_id = (unsigned int)uarg;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case CURLOPT_PROTOCOLS:
|
||||
/* set the bitmask for the protocols that are allowed to be used for the
|
||||
|
@ -2109,9 +2109,11 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
conn->host.name = conn->host.rawalloc;
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
if(data->set.scope_id)
|
||||
/* Override any scope that was set above. */
|
||||
conn->scope_id = data->set.scope_id;
|
||||
#endif
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
@ -940,8 +940,9 @@ struct connectdata {
|
||||
cache entry remains locked. It gets unlocked in multi_done() */
|
||||
struct Curl_addrinfo *ip_addr;
|
||||
struct Curl_addrinfo *tempaddr[2]; /* for happy eyeballs */
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
unsigned int scope_id; /* Scope id for IPv6 */
|
||||
#endif
|
||||
|
||||
enum {
|
||||
TRNSPRT_TCP = 3,
|
||||
@ -1743,7 +1744,9 @@ struct UserDefined {
|
||||
long ssh_auth_types; /* allowed SSH auth types */
|
||||
char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
|
||||
struct curl_blob *blobs[BLOB_LAST];
|
||||
#ifdef ENABLE_IPV6
|
||||
unsigned int scope_id; /* Scope id for IPv6 */
|
||||
#endif
|
||||
long allowed_protocols;
|
||||
long redir_protocols;
|
||||
long mime_options; /* Mime option flags. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user