diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-14 10:18:33 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-14 10:18:33 +0000 |
commit | 9d6c46955fb51d7867e0d8d0ed94006ab72e4821 (patch) | |
tree | ab5d74afb28887ad9ce249e6ba0e1c69844e64e6 | |
parent | 8d0a734d91ff197a86ce0b8fc892e24a15783395 (diff) | |
download | busybox-w32-9d6c46955fb51d7867e0d8d0ed94006ab72e4821.tar.gz busybox-w32-9d6c46955fb51d7867e0d8d0ed94006ab72e4821.tar.bz2 busybox-w32-9d6c46955fb51d7867e0d8d0ed94006ab72e4821.zip |
Introduce FEATURE_PREFER_IPV4_ADDRESS. If selected, we have:
function old new delta
str2sockaddr 328 344 +16
-rw-r--r-- | libbb/xconnect.c | 19 | ||||
-rw-r--r-- | networking/Config.in | 15 |
2 files changed, 31 insertions, 3 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index cb5ac2c8e..91c12f4d3 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -125,6 +125,7 @@ USE_FEATURE_IPV6(sa_family_t af,) | |||
125 | int rc; | 125 | int rc; |
126 | len_and_sockaddr *r = NULL; | 126 | len_and_sockaddr *r = NULL; |
127 | struct addrinfo *result = NULL; | 127 | struct addrinfo *result = NULL; |
128 | struct addrinfo *used_res; | ||
128 | const char *org_host = host; /* only for error msg */ | 129 | const char *org_host = host; /* only for error msg */ |
129 | const char *cp; | 130 | const char *cp; |
130 | struct addrinfo hint; | 131 | struct addrinfo hint; |
@@ -169,9 +170,21 @@ USE_FEATURE_IPV6(sa_family_t af,) | |||
169 | xfunc_die(); | 170 | xfunc_die(); |
170 | goto ret; | 171 | goto ret; |
171 | } | 172 | } |
172 | r = xmalloc(offsetof(len_and_sockaddr, sa) + result->ai_addrlen); | 173 | used_res = result; |
173 | r->len = result->ai_addrlen; | 174 | #if ENABLE_FEATURE_PREFER_IPV4_ADDRESS |
174 | memcpy(&r->sa, result->ai_addr, result->ai_addrlen); | 175 | while (1) { |
176 | if (used_res->ai_family == AF_INET) | ||
177 | break; | ||
178 | used_res = used_res->ai_next; | ||
179 | if (!used_res) { | ||
180 | used_res = result; | ||
181 | break; | ||
182 | } | ||
183 | } | ||
184 | #endif | ||
185 | r = xmalloc(offsetof(len_and_sockaddr, sa) + used_res->ai_addrlen); | ||
186 | r->len = used_res->ai_addrlen; | ||
187 | memcpy(&r->sa, used_res->ai_addr, used_res->ai_addrlen); | ||
175 | set_nport(r, htons(port)); | 188 | set_nport(r, htons(port)); |
176 | ret: | 189 | ret: |
177 | freeaddrinfo(result); | 190 | freeaddrinfo(result); |
diff --git a/networking/Config.in b/networking/Config.in index b5b4597c4..b50aacf9f 100644 --- a/networking/Config.in +++ b/networking/Config.in | |||
@@ -12,6 +12,21 @@ config FEATURE_IPV6 | |||
12 | Enable IPv6 support in busybox. | 12 | Enable IPv6 support in busybox. |
13 | This adds IPv6 support in the networking applets. | 13 | This adds IPv6 support in the networking applets. |
14 | 14 | ||
15 | config FEATURE_PREFER_IPV4_ADDRESS | ||
16 | bool "Preferentially use IPv4 addresses from DNS queries" | ||
17 | default y | ||
18 | depends on FEATURE_IPV6 | ||
19 | help | ||
20 | Use IPv4 address of network host if it has one. | ||
21 | |||
22 | If this option is off, the first returned address will be used. | ||
23 | This may cause problems when your DNS server is IPv6-capable and | ||
24 | is returning IPv6 host addresses too. If IPv6 address | ||
25 | precedes IPv4 one in DNS reply, busybox network applets | ||
26 | (e.g. wget) will use IPv6 address. On an IPv6-incapable host | ||
27 | or network applets will fail to connect to the host | ||
28 | using IPv6 address. | ||
29 | |||
15 | config VERBOSE_RESOLUTION_ERRORS | 30 | config VERBOSE_RESOLUTION_ERRORS |
16 | bool "Verbose resolution errors" | 31 | bool "Verbose resolution errors" |
17 | default n | 32 | default n |