summaryrefslogtreecommitdiff
path: root/libc/inet/resolv.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-06-03 08:11:56 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-06-03 08:11:56 +0000
commit4cc4b30426c5e5a0ecf912791e3f27312438d10e (patch)
tree81c31f4bde953f135d9e63582b162c17cc173f10 /libc/inet/resolv.c
parent1f124eb0280a5009f1265a9dca49fdb0d95b845e (diff)
- adds several config-options to allow for turning off certain features
like o UCLIBC_HAS_GNU_ERROR o UCLIBC_HAS_BSD_ERR o UCLIBC_HAS_PTY o UCLIBC_HAS_GETPT (1) o UCLIBC_SYSCALL_STUBS o UCLIBC_SYSCALL_STUB_WARNING o UCLIBC_LINUX_SPECIFIC (2) o UCLIBC_BSD_SPECIFIC (3) o UCLIBC_NTP_LEGACY (4) o UCLIBC_SV4_DEPRECATED (5) o UCLIBC_HAVE_REALTIME (6) o UCLIBC_HAVE_ADVANCED_REALTIME (7) o UCLIBC_HAVE_EPOLL (8) o UCLIBC_HAVE_XATTR (9) o UCLIBC_HAVE_PROFILING (10) (1) make non-standard getpt optional and implement standard posix_openpt (2) fstatfs(), inotify_*(), ioperm(), iopl(), madvise(), modify_ldt(), personality() ppoll(), setresuid() (3) mincore(), getdomainname(), setdomainname() (4) ntp_adjtime(), ntp_gettime() aliases (5) ustat() [use statfs(2) in your code instead] (6) All marked as "(REALTIME)" in SUSv3 (7) All marked as "(ADVANCED REALTIME)" in SUSv3 (8) epoll_create(), epoll_ctl(), epoll_wait() (9) all Extended Attributes (10) helpers for gcc's -finstrument-functions - Fixes _dl_exit() - Implements sleep(3) for !UCLIBC_HAVE_REALTIME - Implements usleep(3) for !UCLIBC_HAVE_REALTIME - adds #warning about incorrect posix_fadvise{,64}() - removes unused and unwanted uselib() Net outcome is that an allnoconfig with HAVE_SHARED is now about 88k instead of formerly 130k.
Diffstat (limited to 'libc/inet/resolv.c')
-rw-r--r--libc/inet/resolv.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 9776fa4a7..ce19c8698 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -187,7 +187,6 @@ libc_hidden_proto(fopen)
libc_hidden_proto(fclose)
libc_hidden_proto(random)
libc_hidden_proto(getservbyport)
-libc_hidden_proto(getdomainname)
libc_hidden_proto(uname)
libc_hidden_proto(inet_addr)
libc_hidden_proto(inet_aton)
@@ -218,11 +217,12 @@ libc_hidden_proto(fprintf)
libc_hidden_proto(__h_errno_location)
#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_proto(__ctype_b_loc)
-#elif __UCLIBC_HAS_CTYPE_TABLES__
+#elif defined __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_b)
#endif
libc_hidden_proto(__uc_malloc)
-
+int __libc_getdomainname(char *name, size_t len);
+libc_hidden_proto(__libc_getdomainname)
#define MAX_RECURSE 5
@@ -747,12 +747,14 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
unsigned char * packet = malloc(PACKETSZ);
char *dns, *lookup = malloc(MAXDNAME);
int variant = -1;
- struct sockaddr_in sa;
int local_ns = -1, local_id = -1;
#ifdef __UCLIBC_HAS_IPV6__
bool v6;
struct sockaddr_in6 sa6;
#endif
+#ifdef __UCLIBC_HAS_IPV4__
+ struct sockaddr_in sa;
+#endif
fd = -1;
@@ -840,6 +842,7 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
rc = connect(fd, (struct sockaddr *) &sa6, sizeof(sa6));
} else {
#endif
+#ifdef __UCLIBC_HAS_IPV4__
sa.sin_family = AF_INET;
sa.sin_port = htons(NAMESERVER_PORT);
__UCLIBC_MUTEX_LOCK(__resolv_lock);
@@ -848,6 +851,7 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
sa.sin_addr.s_addr = inet_addr(dns);
__UCLIBC_MUTEX_UNLOCK(__resolv_lock);
rc = connect(fd, (struct sockaddr *) &sa, sizeof(sa));
+#endif
#ifdef __UCLIBC_HAS_IPV6__
}
#endif
@@ -1853,15 +1857,19 @@ int getnameinfo(const struct sockaddr *sa, socklen_t addrlen, char *host,
ok = sa->sa_family;
if (ok == AF_LOCAL) /* valid */;
+#ifdef __UCLIBC_HAS_IPV4__
else if (ok == AF_INET) {
if (addrlen < sizeof (struct sockaddr_in))
goto BAD_FAM;
+ }
+#endif
#ifdef __UCLIBC_HAS_IPV6__
- } else if (ok == AF_INET6) {
+ else if (ok == AF_INET6) {
if (addrlen < sizeof (struct sockaddr_in6))
goto BAD_FAM;
+ }
#endif /* __UCLIBC_HAS_IPV6__ */
- } else
+ else
BAD_FAM:
return EAI_FAMILY;
@@ -1878,15 +1886,19 @@ BAD_FAM:
h = gethostbyaddr ((const void *)
&(((const struct sockaddr_in6 *) sa)->sin6_addr),
sizeof(struct in6_addr), AF_INET6);
- else
#endif /* __UCLIBC_HAS_IPV6__ */
+#if defined __UCLIBC_HAS_IPV6__ && defined __UCLIBC_HAS_IPV4__
+ else
+#endif
+#ifdef __UCLIBC_HAS_IPV4__
h = gethostbyaddr ((const void *) &(((const struct sockaddr_in *)sa)->sin_addr),
sizeof(struct in_addr), AF_INET);
+#endif /* __UCLIBC_HAS_IPV4__ */
if (h) {
char *c;
if ((flags & NI_NOFQDN)
- && (getdomainname (domain, sizeof(domain)) == 0)
+ && (__libc_getdomainname (domain, sizeof(domain)) == 0)
&& (c = strstr (h->h_name, domain))
&& (c != h->h_name) && (*(--c) == '.')) {
strncpy (host, h->h_name,
@@ -1952,11 +1964,16 @@ BAD_FAM:
memcpy (host + real_hostlen, scopebuf, scopelen + 1);
}
#endif
- } else
+ }
#endif /* __UCLIBC_HAS_IPV6__ */
+#if defined __UCLIBC_HAS_IPV6__ && defined __UCLIBC_HAS_IPV4__
+ else
+#endif /* __UCLIBC_HAS_IPV6__ && defined __UCLIBC_HAS_IPV4__ */
+#if defined __UCLIBC_HAS_IPV4__
c = inet_ntop (AF_INET, (const void *)
&(((const struct sockaddr_in *) sa)->sin_addr),
host, hostlen);
+#endif /* __UCLIBC_HAS_IPV4__ */
if (c == NULL) {
errno = serrno;
@@ -2752,3 +2769,4 @@ int ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
}
libc_hidden_def(ns_name_unpack)
#endif /* L_ns_name */
+/* vi: set sw=4 ts=4: */