aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-22 22:45:27 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-22 22:45:27 +0000
commit9adc6ced4fcab4d8a068874c55d5f563ce9e62f9 (patch)
tree586266ceaeff8f26c8f08b24b2ad0df1630097e6 /libbb
parent448f0241e06e7df2003b7f8afcf01e7406762b4e (diff)
downloadbusybox-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/Kbuild1
-rw-r--r--libbb/xconnect.c27
-rw-r--r--libbb/xgethostbyname2.c23
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
92lib-y += xfuncs.o 92lib-y += xfuncs.o
93lib-y += xgetcwd.o 93lib-y += xgetcwd.o
94lib-y += xgethostbyname.o 94lib-y += xgethostbyname.o
95lib-y += xgethostbyname2.o
96lib-y += xreadlink.o 95lib-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 */
117static len_and_sockaddr* str2sockaddr(const char *host, int port, int ai_flags) 117static len_and_sockaddr* str2sockaddr(
118 const char *host, int port,
119USE_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
177len_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
169len_and_sockaddr* host2sockaddr(const char *host, int port) 183len_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
174static len_and_sockaddr* dotted2sockaddr(const char *host, int port) 188static 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
179int xsocket_stream(len_and_sockaddr **lsap) 193int 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
299char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa, socklen_t salen)
300{
301 return sockaddr2str(sa, salen, IGNORE_PORT);
302}
303
285char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t salen) 304char* 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
13struct 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