diff options
Diffstat (limited to 'epan')
-rw-r--r-- | epan/resolv.c | 17 | ||||
-rw-r--r-- | epan/resolv.h | 9 |
2 files changed, 24 insertions, 2 deletions
diff --git a/epan/resolv.c b/epan/resolv.c index cd5612c597..72f0cbbb20 100644 --- a/epan/resolv.c +++ b/epan/resolv.c @@ -1,7 +1,7 @@ /* resolv.c * Routines for network object lookup * - * $Id: resolv.c,v 1.43 2004/05/20 13:43:14 ulfl Exp $ + * $Id: resolv.c,v 1.44 2004/06/25 07:00:54 jmayer Exp $ * * Laurent Deniel <laurent.deniel@free.fr> * @@ -1898,3 +1898,18 @@ gboolean get_host_ipaddr6(const char *host, struct e_in6_addr *addrp) return FALSE; } + +/* + * Find out whether a hostname resolves to an ip or ipv6 address + * Return "ip6" if it is IPv6, "ip" otherwise (including the case + * that we don't know) + */ +const char* host_ip_af(const char *host) +{ +#ifdef HAVE_GETHOSTBYNAME2 + struct hostent *h; + return (h = gethostbyname2(host, AF_INET6)) && h->h_addrtype == AF_INET6 ? "ip6" : "ip"; +#else + return "ip"; +#endif +} diff --git a/epan/resolv.h b/epan/resolv.h index 1eef0da6fc..8d5c810111 100644 --- a/epan/resolv.h +++ b/epan/resolv.h @@ -1,7 +1,7 @@ /* resolv.h * Definitions for network object lookup * - * $Id: resolv.h,v 1.17 2004/05/09 10:03:40 guy Exp $ + * $Id: resolv.h,v 1.18 2004/06/25 07:00:54 jmayer Exp $ * * Laurent Deniel <laurent.deniel@free.fr> * @@ -131,4 +131,11 @@ gboolean get_host_ipaddr(const char *host, guint32 *addrp); */ gboolean get_host_ipaddr6(const char *host, struct e_in6_addr *addrp); +/* + * Find out whether a hostname resolves to an ip or ipv6 address + * Return "ip6" if it is IPv6, "ip" otherwise (including the case + * that we don't know) + */ +const char* host_ip_af(const char *host); + #endif /* __RESOLV_H__ */ |