summaryrefslogtreecommitdiff
path: root/libc/inet
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2010-01-25 06:12:08 +0100
committerCarmelo Amoroso <carmelo.amoroso@st.com>2010-01-25 06:16:56 +0100
commit74ca0c98cb8b4e6f75858ca2b2746744f2558493 (patch)
tree2999b63239b319ac416e5af7ee4a1e5a80a3ad11 /libc/inet
parente64b864d6d4e020a94d3931704ccea50d1a20b82 (diff)
parentc4b750195714ec7c10aa4de15610c5aae0751c1c (diff)
Merge branch 'master' into nptl
Conflicts: libc/inet/Makefile.in libc/inet/hostid.c Synchronise nptl branch with master branch @ c4b750195714ec7c10aa4de15610c5aae0751c1c Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/inet')
-rw-r--r--libc/inet/Makefile.in53
-rw-r--r--libc/inet/_res_state.c2
-rw-r--r--libc/inet/closenameservers.c2
-rw-r--r--libc/inet/decodea.c2
-rw-r--r--libc/inet/decoded.c2
-rw-r--r--libc/inet/decodeh.c2
-rw-r--r--libc/inet/decodep.c2
-rw-r--r--libc/inet/decodeq.c2
-rw-r--r--libc/inet/dnslookup.c2
-rw-r--r--libc/inet/encodea.c2
-rw-r--r--libc/inet/encoded.c2
-rw-r--r--libc/inet/encodeh.c2
-rw-r--r--libc/inet/encodep.c2
-rw-r--r--libc/inet/encodeq.c2
-rw-r--r--libc/inet/formquery.c2
-rw-r--r--libc/inet/get_hosts_byaddr_r.c2
-rw-r--r--libc/inet/get_hosts_byname_r.c2
-rw-r--r--libc/inet/gethostbyaddr.c2
-rw-r--r--libc/inet/gethostbyaddr_r.c2
-rw-r--r--libc/inet/gethostbyname.c2
-rw-r--r--libc/inet/gethostbyname2.c2
-rw-r--r--libc/inet/gethostbyname2_r.c2
-rw-r--r--libc/inet/gethostbyname_r.c2
-rw-r--r--libc/inet/gethostent.c2
-rw-r--r--libc/inet/gethostent_r.c2
-rw-r--r--libc/inet/getnameinfo.c2
-rw-r--r--libc/inet/getproto.c2
-rw-r--r--libc/inet/hostid.c67
-rw-r--r--libc/inet/lengthd.c2
-rw-r--r--libc/inet/lengthq.c2
-rw-r--r--libc/inet/ns_name.c2
-rw-r--r--libc/inet/opennameservers.c2
-rw-r--r--libc/inet/read_etc_hosts_r.c2
-rw-r--r--libc/inet/res_comp.c2
-rw-r--r--libc/inet/res_init.c2
-rw-r--r--libc/inet/res_query.c2
-rw-r--r--libc/inet/resolv.c2
37 files changed, 82 insertions, 108 deletions
diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in
index 81319452f..702642f00 100644
--- a/libc/inet/Makefile.in
+++ b/libc/inet/Makefile.in
@@ -12,61 +12,48 @@ include $(top_srcdir)libc/inet/rpc/Makefile.in
INET_DIR := $(top_srcdir)libc/inet
INET_OUT := $(top_builddir)libc/inet
-CSRC :=
-ifneq ($(UCLIBC_HAS_CRYPT_IMPL)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
+CFLAGS-inet := -DRESOLVER="\"resolv.c\""
+CSRC-y :=
# des uses ntohl
-CSRC += ntohl.c
-endif
-ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC += getservice.c getproto.c hostid.c getnetent.c getnetbynm.c getnetbyad.c \
+CSRC-$(findstring y,$(UCLIBC_HAS_CRYPT_IMPL)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += ntohl.c
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
+ getservice.c getproto.c hostid.c getnetent.c getnetbynm.c getnetbyad.c \
inet_net.c herror.c if_index.c gai_strerror.c getaddrinfo.c \
ifaddrs.c ntop.c
-endif
-ifeq ($(UCLIBC_HAS_IPV6),y)
-CSRC += in6_addr.c
-endif
-
+CSRC-$(UCLIBC_HAS_IPV6) += in6_addr.c
# multi source addr.c
-addr_CSRC := \
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
inet_aton.c inet_addr.c inet_ntoa.c inet_makeaddr.c \
inet_lnaof.c inet_netof.c
-ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC += $(addr_CSRC)
-endif
-
# multi source resolv.c
-resolv_CSRC += \
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
encodeh.c decodeh.c encoded.c decoded.c \
encodeq.c encodea.c \
+ read_etc_hosts_r.c \
dnslookup.c opennameservers.c closenameservers.c \
- read_etc_hosts_r.c get_hosts_byaddr_r.c get_hosts_byname_r.c \
getnameinfo.c \
- gethostbyaddr_r.c gethostbyname_r.c gethostbyname2_r.c gethostent_r.c \
- gethostbyaddr.c gethostbyname.c gethostbyname2.c gethostent.c \
+ gethostent.c gethostent_r.c
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
+ get_hosts_byaddr_r.c get_hosts_byname_r.c \
+ gethostbyaddr_r.c gethostbyname_r.c gethostbyname2_r.c \
+ gethostbyaddr.c gethostbyname.c gethostbyname2.c
+CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
res_init.c res_query.c res_comp.c ns_name.c \
_res_state.c
-ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC += $(resolv_CSRC)
## # unused ATM
-## CSRC += encodep.c decodep.c formquery.c
-endif
-
+## CSRC-y += encodep.c decodep.c formquery.c
# multi source socketcalls.c
socketcalls_CSRC += \
accept.c bind.c connect.c getpeername.c getsockname.c \
getsockopt.c listen.c recv.c recvfrom.c recvmsg.c send.c sendmsg.c \
sendto.c setsockopt.c shutdown.c socket.c socketpair.c
-ifeq ($(UCLIBC_HAS_SOCKET),y)
-CSRC += $(socketcalls_CSRC) opensock.c
-endif
+CSRC-$(UCLIBC_HAS_SOCKET) += $(socketcalls_CSRC) opensock.c
-ifneq ($(UCLIBC_HAS_SOCKET)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC += ethers.c ether_addr.c
-endif
+CSRC-$(findstring y,$(UCLIBC_HAS_SOCKET)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += ethers.c ether_addr.c
-INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC))
-INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC))
+INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC-y))
+INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC-y))
libc-y += $(INET_OBJ)
diff --git a/libc/inet/_res_state.c b/libc/inet/_res_state.c
index 8ca4ac192..dc0d89f40 100644
--- a/libc/inet/_res_state.c
+++ b/libc/inet/_res_state.c
@@ -5,4 +5,4 @@
*/
#define L_res_state
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/closenameservers.c b/libc/inet/closenameservers.c
index ca4dae3fb..65889a79a 100644
--- a/libc/inet/closenameservers.c
+++ b/libc/inet/closenameservers.c
@@ -5,4 +5,4 @@
*/
#define L_closenameservers
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decodea.c b/libc/inet/decodea.c
index 409a97843..112d5d9e0 100644
--- a/libc/inet/decodea.c
+++ b/libc/inet/decodea.c
@@ -5,4 +5,4 @@
*/
#define L_decodea
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decoded.c b/libc/inet/decoded.c
index 73849ef5f..378cbfad7 100644
--- a/libc/inet/decoded.c
+++ b/libc/inet/decoded.c
@@ -5,4 +5,4 @@
*/
#define L_decoded
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decodeh.c b/libc/inet/decodeh.c
index 86681fa88..7744287f6 100644
--- a/libc/inet/decodeh.c
+++ b/libc/inet/decodeh.c
@@ -5,4 +5,4 @@
*/
#define L_decodeh
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decodep.c b/libc/inet/decodep.c
index 40b0bda0d..0e946e01f 100644
--- a/libc/inet/decodep.c
+++ b/libc/inet/decodep.c
@@ -5,4 +5,4 @@
*/
#define L_decodep
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decodeq.c b/libc/inet/decodeq.c
index a6109677e..9e36b95d4 100644
--- a/libc/inet/decodeq.c
+++ b/libc/inet/decodeq.c
@@ -5,4 +5,4 @@
*/
#define L_decodeq
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/dnslookup.c b/libc/inet/dnslookup.c
index 4ffc34f0a..b9f59a2ff 100644
--- a/libc/inet/dnslookup.c
+++ b/libc/inet/dnslookup.c
@@ -5,4 +5,4 @@
*/
#define L_dnslookup
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encodea.c b/libc/inet/encodea.c
index 628f9bad5..b42ee4a79 100644
--- a/libc/inet/encodea.c
+++ b/libc/inet/encodea.c
@@ -5,4 +5,4 @@
*/
#define L_encodea
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encoded.c b/libc/inet/encoded.c
index d60618771..27f92becd 100644
--- a/libc/inet/encoded.c
+++ b/libc/inet/encoded.c
@@ -5,4 +5,4 @@
*/
#define L_encoded
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encodeh.c b/libc/inet/encodeh.c
index 1d5488017..6a69a948b 100644
--- a/libc/inet/encodeh.c
+++ b/libc/inet/encodeh.c
@@ -5,4 +5,4 @@
*/
#define L_encodeh
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encodep.c b/libc/inet/encodep.c
index d2f248b40..d298c2131 100644
--- a/libc/inet/encodep.c
+++ b/libc/inet/encodep.c
@@ -5,4 +5,4 @@
*/
#define L_encodep
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encodeq.c b/libc/inet/encodeq.c
index be1a3123b..5555aa548 100644
--- a/libc/inet/encodeq.c
+++ b/libc/inet/encodeq.c
@@ -5,4 +5,4 @@
*/
#define L_encodeq
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/formquery.c b/libc/inet/formquery.c
index 2c53e33de..4bc0ebe3f 100644
--- a/libc/inet/formquery.c
+++ b/libc/inet/formquery.c
@@ -5,4 +5,4 @@
*/
#define L_formquery
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/get_hosts_byaddr_r.c b/libc/inet/get_hosts_byaddr_r.c
index c377aec13..eeac8907f 100644
--- a/libc/inet/get_hosts_byaddr_r.c
+++ b/libc/inet/get_hosts_byaddr_r.c
@@ -5,4 +5,4 @@
*/
#define L_get_hosts_byaddr_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/get_hosts_byname_r.c b/libc/inet/get_hosts_byname_r.c
index 7ad1e3fa5..caad0bcc7 100644
--- a/libc/inet/get_hosts_byname_r.c
+++ b/libc/inet/get_hosts_byname_r.c
@@ -5,4 +5,4 @@
*/
#define L_get_hosts_byname_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyaddr.c b/libc/inet/gethostbyaddr.c
index ae8a543e5..dc16dd9eb 100644
--- a/libc/inet/gethostbyaddr.c
+++ b/libc/inet/gethostbyaddr.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyaddr
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyaddr_r.c b/libc/inet/gethostbyaddr_r.c
index 6235c82e1..6e27e6207 100644
--- a/libc/inet/gethostbyaddr_r.c
+++ b/libc/inet/gethostbyaddr_r.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyaddr_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyname.c b/libc/inet/gethostbyname.c
index 3d46ab015..9c9e9ca03 100644
--- a/libc/inet/gethostbyname.c
+++ b/libc/inet/gethostbyname.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyname
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyname2.c b/libc/inet/gethostbyname2.c
index 685801642..5b9e74ba0 100644
--- a/libc/inet/gethostbyname2.c
+++ b/libc/inet/gethostbyname2.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyname2
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyname2_r.c b/libc/inet/gethostbyname2_r.c
index 06d058ae7..0de0dd5e1 100644
--- a/libc/inet/gethostbyname2_r.c
+++ b/libc/inet/gethostbyname2_r.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyname2_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyname_r.c b/libc/inet/gethostbyname_r.c
index fc9e56da5..4b34f8d17 100644
--- a/libc/inet/gethostbyname_r.c
+++ b/libc/inet/gethostbyname_r.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyname_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostent.c b/libc/inet/gethostent.c
index 16133c0e4..64c183177 100644
--- a/libc/inet/gethostent.c
+++ b/libc/inet/gethostent.c
@@ -5,4 +5,4 @@
*/
#define L_gethostent
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostent_r.c b/libc/inet/gethostent_r.c
index aeade155d..48225d7fa 100644
--- a/libc/inet/gethostent_r.c
+++ b/libc/inet/gethostent_r.c
@@ -5,4 +5,4 @@
*/
#define L_gethostent_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/getnameinfo.c b/libc/inet/getnameinfo.c
index fbfd3ede1..86edc51f3 100644
--- a/libc/inet/getnameinfo.c
+++ b/libc/inet/getnameinfo.c
@@ -5,4 +5,4 @@
*/
#define L_getnameinfo
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/getproto.c b/libc/inet/getproto.c
index c297a6549..bf7c09371 100644
--- a/libc/inet/getproto.c
+++ b/libc/inet/getproto.c
@@ -144,7 +144,7 @@ int getprotoent_r(struct protoent *result_buf,
}
again:
if ((p = fgets(line, BUFSIZ, protof)) == NULL) {
- rv=TRY_AGAIN;
+ rv=ENOENT;
goto DONE;
}
diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c
index c6d6204ae..90b22ae7a 100644
--- a/libc/inet/hostid.c
+++ b/libc/inet/hostid.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
@@ -6,17 +7,15 @@
#define __FORCE_GLIBC
#include <features.h>
-#include <stdio.h>
-#include <string.h>
#include <errno.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <fcntl.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netdb.h>
#include <not-cancel.h>
-
#define HOSTID "/etc/hostid"
#ifdef __USE_BSD
@@ -36,23 +35,23 @@ int sethostid(long int new_id)
}
#endif
+#define _addr(a) (((struct sockaddr_in*)a->ai_addr)->sin_addr.s_addr)
long int gethostid(void)
{
- char host[MAXHOSTNAMELEN + 1];
- int fd, id;
+ char host[HOST_NAME_MAX + 1];
+ int fd, id = 0;
/* If hostid was already set then we can return that value.
* It is not an error if we cannot read this file. It is not even an
* error if we cannot read all the bytes, we just carry on trying...
*/
fd = open_not_cancel_2(HOSTID, O_RDONLY);
- if (fd >= 0 && read_not_cancel(fd, &id, sizeof(id)))
- {
- close_not_cancel_no_status (fd);
- return id;
+ if (fd >= 0) {
+ int i = read_not_cancel(fd, &id, sizeof(id));
+ close_not_cancel_no_status(fd);
+ if (i > 0)
+ return id;
}
- if (fd >= 0) close_not_cancel_no_status (fd);
-
/* Try some methods of returning a unique 32 bit id. Clearly IP
* numbers, if on the internet, will have a unique address. If they
* are not on the internet then we can return 0 which means they should
@@ -64,32 +63,18 @@ long int gethostid(void)
* setting one anyway.
* Mitch
*/
- if (gethostname(host, MAXHOSTNAMELEN) >= 0 && *host) {
- struct hostent *hp;
- struct in_addr in;
- struct hostent ghbn_h;
- char ghbn_buf[sizeof(struct in_addr) +
- sizeof(struct in_addr *)*2 +
- sizeof(char *)*((2 + 5/*MAX_ALIASES*/ +
- 1)/*ALIAS_DIM*/) +
- 256/*namebuffer*/ + 32/* margin */];
- int ghbn_errno;
-
- /* replace gethostbyname() with gethostbyname_r() - ron@zing.net */
- /*if ((hp = gethostbyname(host)) == (struct hostent *)NULL)*/
- gethostbyname_r(host, &ghbn_h, ghbn_buf, sizeof(ghbn_buf), &hp, &ghbn_errno);
-
- if (hp == NULL) {
- /* This is not a error if we get here, as all it means is that
- * this host is not on a network and/or they have not
- * configured their network properly. So we return the unset
- * hostid which should be 0, meaning that they should set it !!
- */
- return 0;
+ if (gethostname(host, HOST_NAME_MAX) >= 0 && *host) {
+ struct addrinfo hints, *results, *addr;
+ memset(&hints, 0, sizeof(struct addrinfo));
+ if (!getaddrinfo(host, NULL, &hints, &results)) {
+ for (addr = results; addr; addr = results->ai_next) {
+ /* Just so it doesn't look exactly like the
+ IP addr */
+ id = _addr(addr) << 16 | _addr(addr) >> 16;
+ break;
+ }
+ freeaddrinfo(results);
}
- memcpy(&in, hp->h_addr, hp->h_length);
- /* Just so it doesn't look exactly like the IP addr */
- return (in.s_addr<<16 | in.s_addr>>16);
}
- return 0;
+ return id;
}
diff --git a/libc/inet/lengthd.c b/libc/inet/lengthd.c
index 07c7fc6f1..d2db685b9 100644
--- a/libc/inet/lengthd.c
+++ b/libc/inet/lengthd.c
@@ -5,4 +5,4 @@
*/
#define L_lengthd
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/lengthq.c b/libc/inet/lengthq.c
index e62e6f25a..beeafc1d2 100644
--- a/libc/inet/lengthq.c
+++ b/libc/inet/lengthq.c
@@ -5,4 +5,4 @@
*/
#define L_lengthq
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/ns_name.c b/libc/inet/ns_name.c
index 158a1a331..9df9464a3 100644
--- a/libc/inet/ns_name.c
+++ b/libc/inet/ns_name.c
@@ -5,4 +5,4 @@
*/
#define L_ns_name
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/opennameservers.c b/libc/inet/opennameservers.c
index effd10800..576c8cae3 100644
--- a/libc/inet/opennameservers.c
+++ b/libc/inet/opennameservers.c
@@ -5,4 +5,4 @@
*/
#define L_opennameservers
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/read_etc_hosts_r.c b/libc/inet/read_etc_hosts_r.c
index 6504e541f..1ec74a50d 100644
--- a/libc/inet/read_etc_hosts_r.c
+++ b/libc/inet/read_etc_hosts_r.c
@@ -5,4 +5,4 @@
*/
#define L_read_etc_hosts_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/res_comp.c b/libc/inet/res_comp.c
index 8aee6b17c..51ea4f2e6 100644
--- a/libc/inet/res_comp.c
+++ b/libc/inet/res_comp.c
@@ -5,4 +5,4 @@
*/
#define L_res_comp
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/res_init.c b/libc/inet/res_init.c
index 09caf4927..b1a175752 100644
--- a/libc/inet/res_init.c
+++ b/libc/inet/res_init.c
@@ -5,4 +5,4 @@
*/
#define L_res_init
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/res_query.c b/libc/inet/res_query.c
index c662510e6..f3e569fad 100644
--- a/libc/inet/res_query.c
+++ b/libc/inet/res_query.c
@@ -5,4 +5,4 @@
*/
#define L_res_query
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index abb84df79..4087f8db8 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1539,7 +1539,9 @@ FILE * __open_etc_hosts(void)
{
FILE * fp;
if ((fp = fopen("/etc/hosts", "r")) == NULL) {
+#ifdef FALLBACK_TO_CONFIG_RESOLVCONF
fp = fopen("/etc/config/hosts", "r");
+#endif
}
return fp;
}