diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-12-07 18:19:09 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-12-07 18:19:09 +0000 |
commit | 41b035e634135310bca3381877120981d7b248a4 (patch) | |
tree | e05f0c2fb59f973a8c78705f39c34cf6b9abbb7b /libc/inet/resolv.c | |
parent | 9fc2d4d9d14ffaa511d029c2a5b889b56ced0e26 (diff) |
patch from Jari Korva <jpkorva@iki.fi>:
- fixes endianness bug in gethostbyaddr() (i386 worked fine, while m68k
didn't: 192.168.160.162 was queried with 192.168.160.162.in-addr.arpa
while it should have been 162.160.168.192.ip-addr.arpa)
- contains missing pieces from my previous getnameinfo() patch:
now it actually compiles!
Diffstat (limited to 'libc/inet/resolv.c')
-rw-r--r-- | libc/inet/resolv.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index 710b35937..69fa1c148 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -59,6 +59,8 @@ #include <netdb.h> #include <ctype.h> #include <arpa/nameser.h> +#include <sys/utsname.h> +#include <sys/un.h> #define MAX_RECURSE 5 #define REPLY_TIMEOUT 10 @@ -1238,15 +1240,14 @@ struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type) memset(&h, 0, sizeof(h)); if(type == AF_INET) { + unsigned char *tmp_addr = (unsigned char *)addr; + memcpy(&in.s_addr, addr, len); addr_list[0] = ∈ - sprintf(namebuf, "%d.%d.%d.%d.in-addr.arpa", - (in.s_addr >> 24) & 0xff, - (in.s_addr >> 16) & 0xff, - (in.s_addr >> 8) & 0xff, - (in.s_addr >> 0) & 0xff); + sprintf(namebuf, "%u.%u.%u.%u.in-addr.arpa", + tmp_addr[3], tmp_addr[2], tmp_addr[1], tmp_addr[0]); #ifdef __UCLIBC_HAS_IPV6__ } else { memcpy(&in6.s6_addr, addr, len); @@ -1436,6 +1437,10 @@ struct hostent * get_hosts_byaddr(const char * addr, int len, int type) #ifdef L_getnameinfo +#ifndef min +# define min(x,y) (((x) > (y)) ? (y) : (x)) +#endif /* min */ + int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags) @@ -1510,7 +1515,6 @@ int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, #ifdef __UCLIBC_HAS_IPV6__ if (sa->sa_family == AF_INET6) { const struct sockaddr_in6 *sin6p; - uint32_t scopeid; sin6p = (const struct sockaddr_in6 *) sa; @@ -1518,6 +1522,7 @@ int getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, (const void *) &sin6p->sin6_addr, host, hostlen); #if 0 /* Does scope id need to be supported? */ + uint32_t scopeid; scopeid = sin6p->sin6_scope_id; if (scopeid != 0) { /* Buffer is >= IFNAMSIZ+1. */ |