diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2010-03-30 17:18:03 +0200 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2010-03-30 17:24:16 +0200 |
commit | bbfd5def3f8b17a6381f9394e77c60a808df7a59 (patch) | |
tree | df807f43f2ab5d30e16d3d95d9098bf4236f7c3b | |
parent | 255b5de8a0195caa2fb02b720912f630ff2518a6 (diff) |
resolv: DEBUG-print nameserver we talk to
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r-- | libc/inet/resolv.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index 0a6fd7aaf..056539f6e 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -1348,8 +1348,24 @@ int attribute_hidden __dns_lookup(const char *name, packet_len = i + j; /* send packet */ - DPRINTF("On try %d, sending query to port %d\n", - retries_left, NAMESERVER_PORT); +#ifdef DEBUG + { + const socklen_t plen = sa.sa.sa_family == AF_INET ? INET_ADDRSTRLEN : INET6_ADDRSTRLEN; + char *pbuf = malloc(plen); + if (pbuf == NULL) ;/* nothing */ +#ifdef __UCLIBC_HAS_IPV6__ + else if (sa.sa.sa_family == AF_INET6) + pbuf = (char*)inet_ntop(AF_INET6, &sa.sa6.sin6_addr, pbuf, plen); +#endif +#ifdef __UCLIBC_HAS_IPV4__ + else if (sa.sa.sa_family == AF_INET) + pbuf = (char*)inet_ntop(AF_INET, &sa.sa4.sin_addr, pbuf, plen); +#endif + DPRINTF("On try %d, sending query to %s, port %d\n", + retries_left, pbuf, NAMESERVER_PORT); + free(pbuf); + } +#endif fd = socket(sa.sa.sa_family, SOCK_DGRAM, IPPROTO_UDP); if (fd < 0) /* paranoia */ goto try_next_server; |