diff options
author | Jeff Morriss <jeff.morriss.ws@gmail.com> | 2015-02-25 20:40:55 -0500 |
---|---|---|
committer | Jeff Morriss <jeff.morriss.ws@gmail.com> | 2015-02-27 21:09:11 +0000 |
commit | e5e8af9c71ce47cd2342135ad941b144bfb864ec (patch) | |
tree | aa6ea05acae1ee51eabf467b6c09706185231356 /epan/addr_resolv.c | |
parent | 2d4817966ee88d2b163dca46e4df75e8f6262b7a (diff) |
Restore synchronous name resolution (revert SVN rev52115).
These gethostbyaddr() calls should be changed to getaddrinfo() but only in
master.
Change-Id: I7e2d31ceb0e072beb7f324336d7b145c3adbe3a0
Reviewed-on: https://code.wireshark.org/review/7402
Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r-- | epan/addr_resolv.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index 5795fb06c9..6776001e31 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -857,6 +857,7 @@ static hashipv4_t * host_lookup(const guint addr, gboolean *found) { hashipv4_t * volatile tp; + struct hostent *hostp; *found = TRUE; @@ -891,6 +892,25 @@ try_resolv: } #endif /* ASYNC_DNS */ + /* + * The Windows "gethostbyaddr()" insists on translating 0.0.0.0 to + * the name of the host on which it's running; to work around that + * botch, we don't try to translate an all-zero IP address to a host + * name. + */ + if (addr != 0) { + /* Use async DNS if possible, else fall back to timeouts, + * else call gethostbyaddr and hope for the best + */ + + hostp = gethostbyaddr((const char *)&addr, 4, AF_INET); + + if (hostp != NULL && hostp->h_name[0] != '\0') { + g_strlcpy(tp->name, hostp->h_name, MAXNAMELEN); + return tp; + } + } + /* unknown host or DNS timeout */ } @@ -922,6 +942,7 @@ host_lookup6(const struct e_in6_addr *addr, gboolean *found) #ifdef HAVE_C_ARES async_dns_queue_msg_t *caqm; #endif /* HAVE_C_ARES */ + struct hostent *hostp; #endif /* INET6 */ *found = TRUE; @@ -971,6 +992,13 @@ try_resolv: } #endif /* HAVE_C_ARES */ + /* Quick hack to avoid DNS/YP timeout */ + hostp = gethostbyaddr((const char *)addr, sizeof(*addr), AF_INET6); + + if (hostp != NULL && hostp->h_name[0] != '\0') { + g_strlcpy(tp->name, hostp->h_name, MAXNAMELEN); + return tp; + } #endif /* INET6 */ } |