summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko2007-01-22 22:45:27 +0000
committerDenis Vlasenko2007-01-22 22:45:27 +0000
commit9adc6ced4fcab4d8a068874c55d5f563ce9e62f9 (patch)
tree586266ceaeff8f26c8f08b24b2ad0df1630097e6 /libbb
parent448f0241e06e7df2003b7f8afcf01e7406762b4e (diff)
downloadbusybox-9adc6ced4fcab4d8a068874c55d5f563ce9e62f9.zip
busybox-9adc6ced4fcab4d8a068874c55d5f563ce9e62f9.tar.gz
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 1e6b5fe..a53b17f 100644
--- a/libbb/Kbuild
+++ b/libbb/Kbuild
@@ -92,7 +92,6 @@ lib-y += xconnect.o
lib-y += xfuncs.o
lib-y += xgetcwd.o
lib-y += xgethostbyname.o
-lib-y += xgethostbyname2.o
lib-y += xreadlink.o
# conditionally compiled objects:
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 188837e..61fe7fd 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -114,7 +114,10 @@ void set_nport(len_and_sockaddr *lsa, unsigned port)
/* host: "1.2.3.4[:port]", "www.google.com[:port]"
* port: if neither of above specifies port #
*/
-static len_and_sockaddr* str2sockaddr(const char *host, int port, int ai_flags)
+static len_and_sockaddr* str2sockaddr(
+ const char *host, int port,
+USE_FEATURE_IPV6(sa_family_t af,)
+ int ai_flags)
{
int rc;
len_and_sockaddr *r; // = NULL;
@@ -147,9 +150,10 @@ static len_and_sockaddr* str2sockaddr(const char *host, int port, int ai_flags)
}
memset(&hint, 0 , sizeof(hint));
- /* hint.ai_family = AF_UNSPEC; - zero anyway */
#if !ENABLE_FEATURE_IPV6
hint.ai_family = AF_INET; /* do not try to find IPv6 */
+#else
+ hint.ai_family = af;
#endif
/* Needed. Or else we will get each address thrice (or more)
* 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)
freeaddrinfo(result);
return r;
}
+#if !ENABLE_FEATURE_IPV6
+#define str2sockaddr(host, port, af, ai_flags) str2sockaddr(host, port, ai_flags)
+#endif
+
+#if ENABLE_FEATURE_IPV6
+len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af)
+{
+ return str2sockaddr(host, port, af, 0);
+}
+#endif
len_and_sockaddr* host2sockaddr(const char *host, int port)
{
- return str2sockaddr(host, port, 0);
+ return str2sockaddr(host, port, AF_UNSPEC, 0);
}
static len_and_sockaddr* dotted2sockaddr(const char *host, int port)
{
- return str2sockaddr(host, port, NI_NUMERICHOST);
+ return str2sockaddr(host, port, AF_UNSPEC, NI_NUMERICHOST);
}
int xsocket_stream(len_and_sockaddr **lsap)
@@ -282,6 +296,11 @@ char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen)
return sockaddr2str(sa, salen, 0);
}
+char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa, socklen_t salen)
+{
+ return sockaddr2str(sa, salen, IGNORE_PORT);
+}
+
char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t salen)
{
return sockaddr2str(sa, salen, NI_NAMEREQD | IGNORE_PORT);
diff --git a/libbb/xgethostbyname2.c b/libbb/xgethostbyname2.c
index 83d5386..7af2f75 100644
--- a/libbb/xgethostbyname2.c
+++ b/libbb/xgethostbyname2.c
@@ -1,22 +1 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Mini xgethostbyname2 implementation.
- *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
- */
-
-#include <netdb.h>
-#include "libbb.h"
-
-
-#ifdef CONFIG_FEATURE_IPV6
-struct hostent *xgethostbyname2(const char *name, int af)
-{
- struct hostent *retval;
-
- if ((retval = gethostbyname2(name, af)) == NULL)
- bb_herror_msg_and_die("%s", name);
-
- return retval;
-}
-#endif
+/* TO DELETE */