aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am6
-rw-r--r--acinclude.m441
-rw-r--r--configure.in20
-rw-r--r--epan/acinclude.m433
-rw-r--r--epan/configure.in11
-rw-r--r--epan/epan.c5
-rw-r--r--epan/resolv.c148
-rw-r--r--epan/resolv.h20
-rw-r--r--gtk/main.c7
-rw-r--r--tethereal.c7
10 files changed, 279 insertions, 19 deletions
diff --git a/Makefile.am b/Makefile.am
index ea8a971a6b..0bca0082d3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.580 2003/04/30 23:21:19 guy Exp $
+# $Id: Makefile.am,v 1.581 2003/05/04 18:50:51 gerald Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@@ -821,7 +821,7 @@ ethereal_LDADD = \
$(ethereal_additional_libs) \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
- @PCAP_LIBS@ @GTK_LIBS@
+ @PCAP_LIBS@ @GTK_LIBS@ @ADNS_LIBS@
TETHEREAL_TAP_SRC = \
tap-dcerpcstat.c \
@@ -863,7 +863,7 @@ tethereal_LDADD = \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
@GLIB_LIBS@ -lm \
- @PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@
+ @PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@ @ADNS_LIBS@
if ENABLE_STATIC
tethereal_LDFLAGS = -Wl,-static -all-static
diff --git a/acinclude.m4 b/acinclude.m4
index 6e948fb2c6..e842228ce3 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -2,7 +2,7 @@ dnl Macros that test for specific features.
dnl This file is part of the Autoconf packaging for Ethereal.
dnl Copyright (C) 1998-2000 by Gerald Combs.
dnl
-dnl $Id: acinclude.m4,v 1.53 2003/02/28 06:04:30 guy Exp $
+dnl $Id: acinclude.m4,v 1.54 2003/05/04 18:50:51 gerald Exp $
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
@@ -679,3 +679,42 @@ AC_DEFUN([AC_ETHEREAL_GNU_SED_CHECK],
HAVE_GNU_SED=no
fi
])
+
+#
+# AC_ETHEREAL_ADNS_CHECK
+#
+AC_DEFUN(AC_ETHEREAL_ADNS_CHECK,
+[
+ want_adns=defaultyes
+
+ AC_ARG_WITH(adns,
+ [ --with-adns=DIR use GNU ADNS, located in directory DIR.], [
+ if test "x$withval" = "xno"; then
+ want_adns=no
+ elif test "x$withval" = "xyes"; then
+ want_adns=yes
+ elif test -d "$withval"; then
+ want_adns=yes
+ AC_ETHEREAL_ADD_DASH_L(LDFLAGS, ${withval}/lib)
+ fi
+ ])
+
+ if test "x$want_adns" = "xdefaultyes"; then
+ want_adns=yes
+ withval=/usr/local
+ if test -d "$withval"; then
+ AC_ETHEREAL_ADD_DASH_L(LDFLAGS, ${withval}/lib)
+ fi
+ fi
+
+ if test "x$want_adns" = "xyes"; then
+ AC_CHECK_LIB(adns, adns_init,
+ [
+ ADNS_LIBS=-ladns
+ AC_DEFINE(HAVE_GNU_ADNS, 1, [Define to use GNU ADNS library])
+ ],,
+ )
+ else
+ AC_MSG_RESULT(not required)
+ fi
+])
diff --git a/configure.in b/configure.in
index c632db26da..d0082fa09c 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-# $Id: configure.in,v 1.205 2003/05/01 03:09:51 gerald Exp $
+# $Id: configure.in,v 1.206 2003/05/04 18:50:51 gerald Exp $
dnl
dnl Process this file with autoconf 2.13 or later to produce a
dnl configure script; 2.12 doesn't generate a "configure" script that
@@ -617,6 +617,17 @@ fi
AC_SUBST(SNMP_LIBS)
+dnl ADNS Check
+ADNS_LIBS=''
+AC_MSG_CHECKING(whether to use the GNU ADNS library if available)
+if test "x$enable_adns" = "xno" ; then
+ AC_MSG_RESULT(no)
+else
+ AC_MSG_RESULT(yes)
+ AC_ETHEREAL_ADNS_CHECK
+fi
+AC_SUBST(ADNS_LIBS)
+
dnl Checks for typedefs, structures, and compiler characteristics.
# AC_C_CONST
@@ -791,6 +802,12 @@ else
zlib_message="yes"
fi
+if test "x$want_adns" = "xno" ; then
+ adns_message="no"
+else
+ adns_message="yes"
+fi
+
if test "x$NETSNMPCONFIG" != "xno" -a "x$NETSNMPCONFIG" != "x" -a -x "$NETSNMPCONFIG" ; then
snmp_libs_message="yes (net-snmp)"
elif test "x$SNMP_LIBS" = "x" ; then
@@ -815,5 +832,6 @@ echo " Use plugins : $have_plugins"
echo " Use GTK+ v2 library : $enable_gtk2"
echo " Use pcap library : $want_pcap"
echo " Use zlib library : $zlib_message"
+echo " Use GNU ADNS library : $adns_message"
echo " Use IPv6 name resolution : $enable_ipv6"
echo " Use UCD SNMP/NET-SNMP library : $snmp_libs_message"
diff --git a/epan/acinclude.m4 b/epan/acinclude.m4
index 0febc2f26f..f10c9aa048 100644
--- a/epan/acinclude.m4
+++ b/epan/acinclude.m4
@@ -2,7 +2,7 @@ dnl Macros that test for specific features.
dnl This file is part of the Autoconf packaging for Ethereal.
dnl Copyright (C) 1998-2000 by Gerald Combs.
dnl
-dnl $Id: acinclude.m4,v 1.1 2001/07/13 01:34:13 guy Exp $
+dnl $Id: acinclude.m4,v 1.2 2003/05/04 18:50:53 gerald Exp $
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
@@ -148,3 +148,34 @@ yes
fi
AC_MSG_RESULT(["$v6type, $v6lib"])
])
+
+#
+# AC_ETHEREAL_ADNS_CHECK
+#
+AC_DEFUN(AC_ETHEREAL_ADNS_CHECK,
+[
+ want_adns=defaultyes
+
+ AC_ARG_WITH(adns,
+ [ --with-adns=DIR use GNU ADNS, located in directory DIR.], [
+ if test "x$withval" = "xno"; then
+ want_adns=no
+ elif test "x$withval" = "xyes"; then
+ want_adns=yes
+ elif test -d "$withval"; then
+ want_adns=yes
+ fi
+ ])
+
+ if test "x$want_adns" = "xdefaultyes"; then
+ want_adns=yes
+ fi
+
+ if test "x$want_adns" = "xyes"; then
+ AC_CHECK_LIB(adns, adns_init,
+ AC_DEFINE(HAVE_GNU_ADNS, 1, [Define to use GNU ADNS library]),,
+ )
+ else
+ AC_MSG_RESULT(not required)
+ fi
+])
diff --git a/epan/configure.in b/epan/configure.in
index 94074a08cc..ad4f15dd78 100644
--- a/epan/configure.in
+++ b/epan/configure.in
@@ -1,4 +1,4 @@
-# $Id: configure.in,v 1.42 2003/05/01 03:09:54 gerald Exp $
+# $Id: configure.in,v 1.43 2003/05/04 18:50:53 gerald Exp $
dnl
dnl Process this file with autoconf 2.13 or later to produce a
dnl configure script; 2.12 doesn't generate a "configure" script that
@@ -219,6 +219,15 @@ AC_CHECK_FUNC(strptime, ,
[AC_DEFINE(NEED_STRPTIME_H, 1, [Define if strptime.h needs to be included])
])
+dnl ADNS Check
+AC_MSG_CHECKING(whether to use the GNU ADNS library if available)
+if test "x$enable_adns" = "xno" ; then
+ AC_MSG_RESULT(no)
+else
+ AC_MSG_RESULT(yes)
+ AC_ETHEREAL_ADNS_CHECK
+fi
+
#
# Check whether GLib modules are supported, to determine whether we
# can support plugins.
diff --git a/epan/epan.c b/epan/epan.c
index 47586113dd..27fcb91177 100644
--- a/epan/epan.c
+++ b/epan/epan.c
@@ -1,6 +1,6 @@
/* epan.h
*
- * $Id: epan.c,v 1.22 2002/10/22 08:22:05 guy Exp $
+ * $Id: epan.c,v 1.23 2003/05/04 18:50:53 gerald Exp $
*
* Ethereal Protocol Analyzer Library
*/
@@ -19,6 +19,7 @@
#include "packet.h"
#include "column-utils.h"
#include "../tap.h"
+#include "resolv.h"
/*
* XXX - this takes the plugin directory as an argument, because
@@ -53,6 +54,7 @@ epan_init(const char *plugin_dir, void (register_all_protocols)(void),
packet_init();
dfilter_init();
final_registration_all_protocols();
+ host_name_lookup_init();
}
void
@@ -64,6 +66,7 @@ epan_cleanup(void)
frame_data_cleanup();
tvbuff_cleanup();
except_deinit();
+ host_name_lookup_cleanup();
}
void
diff --git a/epan/resolv.c b/epan/resolv.c
index aa301be2ba..e016af2b59 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.30 2003/01/26 19:35:29 deniel Exp $
+ * $Id: resolv.c,v 1.31 2003/05/04 18:50:53 gerald Exp $
*
* Laurent Deniel <laurent.deniel@free.fr>
*
@@ -77,6 +77,11 @@
# include "inet_v6defs.h"
#endif
+#ifdef HAVE_GNU_ADNS
+# include <errno.h>
+# include <adns.h>
+#endif
+
#include "packet.h"
#include "ipv6-utils.h"
#include "resolv.h"
@@ -182,6 +187,29 @@ gchar *g_ipxnets_path = NULL; /* global ipxnets file */
gchar *g_pipxnets_path = NULL; /* personal ipxnets file */
/* first resolving call */
+/* GNU ADNS */
+
+#ifdef HAVE_GNU_ADNS
+
+adns_state ads;
+
+/* XXX - Create a preference for this */
+#define ADNS_MAX_CONCURRENCY 500
+int adns_currently_queued = 0;
+
+typedef struct _adns_queue_msg
+{
+ gboolean submitted;
+ guint32 ip4_addr;
+ struct e_in6_addr ip6_addr;
+ int type;
+ adns_query query;
+} adns_queue_msg_t;
+
+GList *adns_queue_head = NULL;
+
+#endif /* HAVE_GNU_ADNS */
+
/*
* Local function definitions
*/
@@ -250,6 +278,7 @@ static guchar *serv_name_lookup(guint port, port_type proto)
} /* serv_name_lookup */
+
#ifdef AVOID_DNS_TIMEOUT
#define DNS_TIMEOUT 2 /* max sec per call */
@@ -267,6 +296,9 @@ static guchar *host_name_lookup(guint addr, gboolean *found)
int hash_idx;
hashname_t * volatile tp;
struct hostent *hostp;
+#ifdef HAVE_GNU_ADNS
+ adns_queue_msg_t *qmsg;
+#endif
*found = TRUE;
@@ -296,6 +328,18 @@ static guchar *host_name_lookup(guint addr, gboolean *found)
tp->addr = addr;
tp->next = NULL;
+#ifdef HAVE_GNU_ADNS
+ qmsg = g_malloc(sizeof(adns_queue_msg_t));
+ qmsg->type = AF_INET;
+ qmsg->ip4_addr = addr;
+ qmsg->submitted = FALSE;
+ adns_queue_head = g_list_append(adns_queue_head, (gpointer) qmsg);
+
+ tp->is_dummy_entry = TRUE;
+ ip_to_str_buf((guint8 *)&addr, tp->name);
+ return tp->name;
+#else
+
/*
* 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
@@ -303,28 +347,38 @@ static guchar *host_name_lookup(guint addr, gboolean *found)
* name.
*/
if (addr != 0 && (g_resolv_flags & RESOLV_NETWORK)) {
-#ifdef AVOID_DNS_TIMEOUT
+ /* Use async DNS if possible, else fall back to timeouts,
+ * else call gethostbyaddr and hope for the best
+ */
+
+# ifdef AVOID_DNS_TIMEOUT
/* Quick hack to avoid DNS/YP timeout */
if (!setjmp(hostname_env)) {
signal(SIGALRM, abort_network_query);
alarm(DNS_TIMEOUT);
-#endif
+# endif /* AVOID_DNS_TIMEOUT */
+
hostp = gethostbyaddr((char *)&addr, 4, AF_INET);
-#ifdef AVOID_DNS_TIMEOUT
+
+# ifdef AVOID_DNS_TIMEOUT
alarm(0);
-#endif
+# endif /* AVOID_DNS_TIMEOUT */
+
if (hostp != NULL) {
strncpy(tp->name, hostp->h_name, MAXNAMELEN);
tp->name[MAXNAMELEN-1] = '\0';
tp->is_dummy_entry = FALSE;
return tp->name;
}
-#ifdef AVOID_DNS_TIMEOUT
+
+# ifdef AVOID_DNS_TIMEOUT
}
-#endif
+# endif /* AVOID_DNS_TIMEOUT */
+
}
+#endif /* HAVE_GNU_ADNS */
/* unknown host or DNS timeout */
@@ -1367,6 +1421,86 @@ static guint ipxnet_addr_lookup(const guchar *name, gboolean *success)
* External Functions
*/
+#ifdef HAVE_GNU_ADNS
+
+void
+host_name_lookup_init() {
+ /* XXX - Any flags we should be using? */
+ /* XXX - We could provide config settings for DNS servers, and
+ pass them to ADNS with adns_init_strcfg */
+ adns_init(&ads, 0, 0 /*0=>stderr*/);
+ adns_currently_queued = 0;
+}
+
+/* XXX - The ADNS "documentation" isn't very clear:
+ * - Do we need to keep our query structures around?
+ */
+gint
+host_name_lookup_process(gpointer data _U_) {
+ adns_queue_msg_t *almsg;
+ GList *cur;
+ char addr_str[] = "111.222.333.444.in-addr.arpa.";
+ guint8 *addr_bytes;
+ adns_answer *ans;
+ int ret;
+ gboolean dequeue;
+
+ adns_queue_head = g_list_first(adns_queue_head);
+
+ cur = adns_queue_head;
+ while (cur && adns_currently_queued < ADNS_MAX_CONCURRENCY) {
+ almsg = (adns_queue_msg_t *) adns_queue_head->data;
+ if (! almsg->submitted && almsg->type == AF_INET) {
+ addr_bytes = (guint8 *) &almsg->ip4_addr;
+ sprintf(addr_str, "%u.%u.%u.%u.in-addr.arpa.", addr_bytes[3],
+ addr_bytes[2], addr_bytes[1], addr_bytes[0]);
+ adns_submit (ads, addr_str, adns_r_ptr, 0, NULL, &almsg->query);
+ almsg->submitted = TRUE;
+ adns_currently_queued++;
+ }
+ cur = cur->next;
+ }
+
+ cur = adns_queue_head;
+ while (cur) {
+ dequeue = FALSE;
+ almsg = (adns_queue_msg_t *) cur->data;
+ if (almsg->submitted) {
+ ret = adns_check(ads, &almsg->query, &ans, NULL);
+ if (ret == 0) {
+ if (ans->status == adns_s_ok) {
+ add_host_name(almsg->ip4_addr, *ans->rrs.str);
+ }
+ dequeue = TRUE;
+ }
+ }
+ cur = cur->next;
+ if (dequeue) {
+ adns_queue_head = g_list_remove(adns_queue_head, (void *) almsg);
+ g_free(almsg);
+ adns_currently_queued--;
+ }
+ }
+
+ return 1;
+}
+
+void
+host_name_lookup_cleanup() {
+ void *qdata;
+
+ adns_queue_head = g_list_first(adns_queue_head);
+ while (adns_queue_head) {
+ qdata = adns_queue_head->data;
+ adns_queue_head = g_list_remove(adns_queue_head, qdata);
+ g_free(qdata);
+ }
+
+ adns_finish(ads);
+}
+
+#endif /* HAVE_GNU_ADNS */
+
extern guchar *get_hostname(guint addr)
{
gboolean found;
diff --git a/epan/resolv.h b/epan/resolv.h
index 261248c0df..500ac4705f 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.10 2003/01/26 19:35:29 deniel Exp $
+ * $Id: resolv.h,v 1.11 2003/05/04 18:50:54 gerald Exp $
*
* Laurent Deniel <laurent.deniel@free.fr>
*
@@ -66,10 +66,16 @@ extern guchar *get_tcp_port(guint port);
/* get_sctp_port returns the SCTP port name or "%u" if not found */
extern guchar *get_sctp_port(guint port);
+/* host_name_lookup_init fires up an ADNS socket if we're using ADNS */
+extern void host_name_lookup_init();
+
+/* host_name_lookup_cleanup cleans up an ADNS socket if we're using ADNS */
+extern void host_name_lookup_cleanup();
+
/* get_hostname returns the host name or "%d.%d.%d.%d" if not found */
extern guchar *get_hostname(guint addr);
-/* get_hostname returns the host name, or numeric addr if not found */
+/* get_hostname6 returns the host name, or numeric addr if not found */
struct e_in6_addr;
const guchar* get_hostname6(struct e_in6_addr *ad);
@@ -114,4 +120,14 @@ gboolean get_host_ipaddr(const char *host, guint32 *addrp);
*/
gboolean get_host_ipaddr6(const char *host, struct e_in6_addr *addrp);
+/*
+ * Asynchronous host name lookup initialization, processing, and cleanup
+ */
+
+#ifdef HAVE_GNU_ADNS
+void host_name_lookup_init();
+gint host_name_lookup_process(gpointer data);
+void host_name_lookup_cleanup();
+#endif
+
#endif /* __RESOLV_H__ */
diff --git a/gtk/main.c b/gtk/main.c
index 9d49a2b26d..28dfaa9fc0 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.292 2003/05/03 00:48:37 guy Exp $
+ * $Id: main.c,v 1.293 2003/05/04 18:50:56 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1526,6 +1526,11 @@ main(int argc, char *argv[])
gtk_timeout_add(3000, (GtkFunction)update_cb,(gpointer)NULL);
#endif /* !WIN32 && GTK2 && G_THREADS_ENABLED */
+#if HAVE_GNU_ADNS
+ gtk_timeout_add(750, (GtkFunction) host_name_lookup_process, NULL);
+#endif
+
+
/* Set the current locale according to the program environment.
* We haven't localized anything, but some GTK widgets are localized
* (the file selection dialogue, for example).
diff --git a/tethereal.c b/tethereal.c
index 36b16bbbad..0456a72d8f 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1,6 +1,6 @@
/* tethereal.c
*
- * $Id: tethereal.c,v 1.181 2003/04/23 03:50:59 guy Exp $
+ * $Id: tethereal.c,v 1.182 2003/05/04 18:50:51 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1765,6 +1765,11 @@ wtap_dispatch_cb_print(guchar *user, const struct wtap_pkthdr *phdr,
fill_in_fdata(&fdata, cf, phdr, offset);
+ /* Grab any resolved addresses */
+ if (g_resolv_flags) {
+ host_name_lookup_process(NULL);
+ }
+
passed = TRUE;
if (cf->rfcode || verbose || num_tap_filters!=0)
create_proto_tree = TRUE;