diff options
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 */ } |