diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 22:45:27 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 22:45:27 +0000 |
commit | 9adc6ced4fcab4d8a068874c55d5f563ce9e62f9 (patch) | |
tree | 586266ceaeff8f26c8f08b24b2ad0df1630097e6 /libbb | |
parent | 448f0241e06e7df2003b7f8afcf01e7406762b4e (diff) | |
download | busybox-w32-9adc6ced4fcab4d8a068874c55d5f563ce9e62f9.tar.gz busybox-w32-9adc6ced4fcab4d8a068874c55d5f563ce9e62f9.tar.bz2 busybox-w32-9adc6ced4fcab4d8a068874c55d5f563ce9e62f9.zip |
ping6: stop using xgethostbyname2, remove it from libbb.
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/Kbuild | 1 | ||||
-rw-r--r-- | libbb/xconnect.c | 27 | ||||
-rw-r--r-- | libbb/xgethostbyname2.c | 23 |
3 files changed, 24 insertions, 27 deletions
diff --git a/libbb/Kbuild b/libbb/Kbuild index 1e6b5fea7..a53b17f44 100644 --- a/libbb/Kbuild +++ b/libbb/Kbuild | |||
@@ -92,7 +92,6 @@ lib-y += xconnect.o | |||
92 | lib-y += xfuncs.o | 92 | lib-y += xfuncs.o |
93 | lib-y += xgetcwd.o | 93 | lib-y += xgetcwd.o |
94 | lib-y += xgethostbyname.o | 94 | lib-y += xgethostbyname.o |
95 | lib-y += xgethostbyname2.o | ||
96 | lib-y += xreadlink.o | 95 | lib-y += xreadlink.o |
97 | 96 | ||
98 | # conditionally compiled objects: | 97 | # conditionally compiled objects: |
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 188837e36..61fe7fd6c 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -114,7 +114,10 @@ void set_nport(len_and_sockaddr *lsa, unsigned port) | |||
114 | /* host: "1.2.3.4[:port]", "www.google.com[:port]" | 114 | /* host: "1.2.3.4[:port]", "www.google.com[:port]" |
115 | * port: if neither of above specifies port # | 115 | * port: if neither of above specifies port # |
116 | */ | 116 | */ |
117 | static len_and_sockaddr* str2sockaddr(const char *host, int port, int ai_flags) | 117 | static len_and_sockaddr* str2sockaddr( |
118 | const char *host, int port, | ||
119 | USE_FEATURE_IPV6(sa_family_t af,) | ||
120 | int ai_flags) | ||
118 | { | 121 | { |
119 | int rc; | 122 | int rc; |
120 | len_and_sockaddr *r; // = NULL; | 123 | len_and_sockaddr *r; // = NULL; |
@@ -147,9 +150,10 @@ static len_and_sockaddr* str2sockaddr(const char *host, int port, int ai_flags) | |||
147 | } | 150 | } |
148 | 151 | ||
149 | memset(&hint, 0 , sizeof(hint)); | 152 | memset(&hint, 0 , sizeof(hint)); |
150 | /* hint.ai_family = AF_UNSPEC; - zero anyway */ | ||
151 | #if !ENABLE_FEATURE_IPV6 | 153 | #if !ENABLE_FEATURE_IPV6 |
152 | hint.ai_family = AF_INET; /* do not try to find IPv6 */ | 154 | hint.ai_family = AF_INET; /* do not try to find IPv6 */ |
155 | #else | ||
156 | hint.ai_family = af; | ||
153 | #endif | 157 | #endif |
154 | /* Needed. Or else we will get each address thrice (or more) | 158 | /* Needed. Or else we will get each address thrice (or more) |
155 | * for each possible socket type (tcp,udp,raw...): */ | 159 | * for each possible socket type (tcp,udp,raw...): */ |
@@ -165,15 +169,25 @@ static len_and_sockaddr* str2sockaddr(const char *host, int port, int ai_flags) | |||
165 | freeaddrinfo(result); | 169 | freeaddrinfo(result); |
166 | return r; | 170 | return r; |
167 | } | 171 | } |
172 | #if !ENABLE_FEATURE_IPV6 | ||
173 | #define str2sockaddr(host, port, af, ai_flags) str2sockaddr(host, port, ai_flags) | ||
174 | #endif | ||
175 | |||
176 | #if ENABLE_FEATURE_IPV6 | ||
177 | len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af) | ||
178 | { | ||
179 | return str2sockaddr(host, port, af, 0); | ||
180 | } | ||
181 | #endif | ||
168 | 182 | ||
169 | len_and_sockaddr* host2sockaddr(const char *host, int port) | 183 | len_and_sockaddr* host2sockaddr(const char *host, int port) |
170 | { | 184 | { |
171 | return str2sockaddr(host, port, 0); | 185 | return str2sockaddr(host, port, AF_UNSPEC, 0); |
172 | } | 186 | } |
173 | 187 | ||
174 | static len_and_sockaddr* dotted2sockaddr(const char *host, int port) | 188 | static len_and_sockaddr* dotted2sockaddr(const char *host, int port) |
175 | { | 189 | { |
176 | return str2sockaddr(host, port, NI_NUMERICHOST); | 190 | return str2sockaddr(host, port, AF_UNSPEC, NI_NUMERICHOST); |
177 | } | 191 | } |
178 | 192 | ||
179 | int xsocket_stream(len_and_sockaddr **lsap) | 193 | int xsocket_stream(len_and_sockaddr **lsap) |
@@ -282,6 +296,11 @@ char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen) | |||
282 | return sockaddr2str(sa, salen, 0); | 296 | return sockaddr2str(sa, salen, 0); |
283 | } | 297 | } |
284 | 298 | ||
299 | char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa, socklen_t salen) | ||
300 | { | ||
301 | return sockaddr2str(sa, salen, IGNORE_PORT); | ||
302 | } | ||
303 | |||
285 | char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t salen) | 304 | char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t salen) |
286 | { | 305 | { |
287 | return sockaddr2str(sa, salen, NI_NAMEREQD | IGNORE_PORT); | 306 | return sockaddr2str(sa, salen, NI_NAMEREQD | IGNORE_PORT); |
diff --git a/libbb/xgethostbyname2.c b/libbb/xgethostbyname2.c index 83d538669..7af2f75fb 100644 --- a/libbb/xgethostbyname2.c +++ b/libbb/xgethostbyname2.c | |||
@@ -1,22 +1 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | /* TO DELETE */ | |
2 | /* | ||
3 | * Mini xgethostbyname2 implementation. | ||
4 | * | ||
5 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
6 | */ | ||
7 | |||
8 | #include <netdb.h> | ||
9 | #include "libbb.h" | ||
10 | |||
11 | |||
12 | #ifdef CONFIG_FEATURE_IPV6 | ||
13 | struct hostent *xgethostbyname2(const char *name, int af) | ||
14 | { | ||
15 | struct hostent *retval; | ||
16 | |||
17 | if ((retval = gethostbyname2(name, af)) == NULL) | ||
18 | bb_herror_msg_and_die("%s", name); | ||
19 | |||
20 | return retval; | ||
21 | } | ||
22 | #endif | ||