forked from osmocom/wireshark
Add two preferences to control ADNS, one to enable/disable it and one to
set its concurrency level. Fix an ADNS queueing bug. svn path=/trunk/; revision=8063
This commit is contained in:
parent
7dd93bc1f6
commit
d98ee5ef39
|
@ -198,6 +198,7 @@ numbers turned off; the argument is a string that may contain the
|
|||
letters B<m> to enable MAC address resolution, B<n> to enable network
|
||||
address resolution, and B<t> to enable transport-layer port number
|
||||
resolution. This overrides B<-n> if both B<-N> and B<-n> are present.
|
||||
The letter B<C> enables concurrent (asynchronous) DNS lookups.
|
||||
|
||||
=item -o
|
||||
|
||||
|
|
|
@ -269,6 +269,7 @@ numbers turned off; the argument is a string that may contain the
|
|||
letters B<m> to enable MAC address resolution, B<n> to enable network
|
||||
address resolution, and B<t> to enable transport-layer port number
|
||||
resolution. This overrides B<-n> if both B<-N> and B<-n> are present.
|
||||
The letter B<C> enables concurrent (asynchronous) DNS lookups.
|
||||
|
||||
=item -o
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* resolv.c
|
||||
* Routines for network object lookup
|
||||
*
|
||||
* $Id: resolv.c,v 1.33 2003/05/15 07:44:54 guy Exp $
|
||||
* $Id: resolv.c,v 1.34 2003/07/22 03:14:30 gerald Exp $
|
||||
*
|
||||
* Laurent Deniel <laurent.deniel@free.fr>
|
||||
*
|
||||
|
@ -86,6 +86,7 @@
|
|||
#include "ipv6-utils.h"
|
||||
#include "resolv.h"
|
||||
#include "filesystem.h"
|
||||
#include "prefs.h"
|
||||
|
||||
#define ENAME_ETHERS "ethers"
|
||||
#define ENAME_IPXNETS "ipxnets"
|
||||
|
@ -193,8 +194,6 @@ gchar *g_pipxnets_path = NULL; /* personal ipxnets file */
|
|||
|
||||
adns_state ads;
|
||||
|
||||
/* XXX - Create a preference for this */
|
||||
#define ADNS_MAX_CONCURRENCY 500
|
||||
int adns_currently_queued = 0;
|
||||
|
||||
typedef struct _adns_queue_msg
|
||||
|
@ -329,15 +328,18 @@ static guchar *host_name_lookup(guint addr, gboolean *found)
|
|||
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);
|
||||
if (g_resolv_flags & RESOLV_CONCURRENT != 0 &&
|
||||
prefs.name_resolve_concurrency > 0) {
|
||||
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;
|
||||
tp->is_dummy_entry = TRUE;
|
||||
ip_to_str_buf((guint8 *)&addr, tp->name);
|
||||
return tp->name;
|
||||
}
|
||||
#else
|
||||
|
||||
/*
|
||||
|
@ -1445,8 +1447,8 @@ host_name_lookup_process(gpointer data _U_) {
|
|||
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;
|
||||
while (cur && adns_currently_queued <= prefs.name_resolve_concurrency) {
|
||||
almsg = (adns_queue_msg_t *) cur->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],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* resolv.h
|
||||
* Definitions for network object lookup
|
||||
*
|
||||
* $Id: resolv.h,v 1.13 2003/05/05 08:20:01 guy Exp $
|
||||
* $Id: resolv.h,v 1.14 2003/07/22 03:14:30 gerald Exp $
|
||||
*
|
||||
* Laurent Deniel <laurent.deniel@free.fr>
|
||||
*
|
||||
|
@ -43,6 +43,7 @@ extern guint32 g_resolv_flags;
|
|||
#define RESOLV_MAC 0x1
|
||||
#define RESOLV_NETWORK 0x2
|
||||
#define RESOLV_TRANSPORT 0x4
|
||||
#define RESOLV_CONCURRENT 0x8
|
||||
#define RESOLV_ALL 0xFFFFFFFF
|
||||
|
||||
/* global variables */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* file_dlg.c
|
||||
* Dialog boxes for handling files
|
||||
*
|
||||
* $Id: file_dlg.c,v 1.56 2003/07/18 20:55:11 oabad Exp $
|
||||
* $Id: file_dlg.c,v 1.57 2003/07/22 03:14:30 gerald Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -42,6 +42,7 @@
|
|||
#include "dlg_utils.h"
|
||||
#include "main.h"
|
||||
#include "compat_macros.h"
|
||||
#include "prefs.h"
|
||||
|
||||
static void file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs);
|
||||
static void file_open_destroy_cb(GtkWidget *win, gpointer user_data);
|
||||
|
@ -234,7 +235,7 @@ file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
|
|||
cfile.rfcode = rfcode;
|
||||
|
||||
/* Set the global resolving variable */
|
||||
g_resolv_flags = 0;
|
||||
g_resolv_flags = prefs.name_resolve & RESOLV_CONCURRENT;
|
||||
m_resolv_cb = OBJECT_GET_DATA(w, E_FILE_M_RESOLVE_KEY);
|
||||
g_resolv_flags |= GTK_TOGGLE_BUTTON (m_resolv_cb)->active ? RESOLV_MAC : RESOLV_NONE;
|
||||
n_resolv_cb = OBJECT_GET_DATA(w, E_FILE_N_RESOLVE_KEY);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* nameres_prefs.c
|
||||
* Dialog box for name resolution preferences
|
||||
*
|
||||
* $Id: nameres_prefs.c,v 1.7 2002/11/11 18:57:00 oabad Exp $
|
||||
* $Id: nameres_prefs.c,v 1.8 2003/07/22 03:14:31 gerald Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -41,13 +41,25 @@
|
|||
#define M_RESOLVE_KEY "m_resolve"
|
||||
#define N_RESOLVE_KEY "n_resolve"
|
||||
#define T_RESOLVE_KEY "t_resolve"
|
||||
#ifdef HAVE_GNU_ADNS
|
||||
# define C_RESOLVE_KEY "c_resolve"
|
||||
# define RESOLVE_CONCURRENCY_KEY "resolve_concurrency"
|
||||
#endif /* HAVE_GNU_ADNS */
|
||||
|
||||
#define RESOLV_TABLE_ROWS 3
|
||||
#ifdef HAVE_GNU_ADNS
|
||||
# define RESOLV_TABLE_ROWS 5
|
||||
#else
|
||||
# define RESOLV_TABLE_ROWS 3
|
||||
#endif /* HAVE_GNU_ADNS */
|
||||
GtkWidget*
|
||||
nameres_prefs_show(void)
|
||||
{
|
||||
GtkWidget *main_tb, *main_vb;
|
||||
GtkWidget *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
|
||||
#ifdef HAVE_GNU_ADNS
|
||||
GtkWidget *c_resolv_cb, *resolv_concurrency_te;
|
||||
char concur_str[10+1];
|
||||
#endif /* HAVE_GNU_ADNS */
|
||||
|
||||
/*
|
||||
* XXX - it would be nice if the current setting of the resolver
|
||||
|
@ -88,6 +100,21 @@ nameres_prefs_show(void)
|
|||
prefs.name_resolve & RESOLV_TRANSPORT);
|
||||
OBJECT_SET_DATA(main_vb, T_RESOLVE_KEY, t_resolv_cb);
|
||||
|
||||
#ifdef HAVE_GNU_ADNS
|
||||
/* Enable concurrent (asynchronous) DNS lookups */
|
||||
c_resolv_cb = create_preference_check_button(main_tb, 3,
|
||||
"Enable concurrent DNS name resolution:", NULL,
|
||||
prefs.name_resolve & RESOLV_CONCURRENT);
|
||||
OBJECT_SET_DATA(main_vb, C_RESOLVE_KEY, c_resolv_cb);
|
||||
|
||||
/* Max concurrent requests */
|
||||
sprintf(concur_str, "%d", prefs.name_resolve_concurrency);
|
||||
resolv_concurrency_te = create_preference_entry(main_tb, 4,
|
||||
"Maximum concurrent requests:", NULL, concur_str);
|
||||
OBJECT_SET_DATA(main_vb, RESOLVE_CONCURRENCY_KEY, resolv_concurrency_te);
|
||||
|
||||
#endif /* HAVE_GNU_ADNS */
|
||||
|
||||
/* Show 'em what we got */
|
||||
gtk_widget_show_all(main_vb);
|
||||
|
||||
|
@ -98,15 +125,29 @@ void
|
|||
nameres_prefs_fetch(GtkWidget *w)
|
||||
{
|
||||
GtkWidget *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
|
||||
#ifdef HAVE_GNU_ADNS
|
||||
GtkWidget *c_resolv_cb, *resolv_concurrency_te;
|
||||
#endif /* HAVE_GNU_ADNS */
|
||||
|
||||
m_resolv_cb = (GtkWidget *)OBJECT_GET_DATA(w, M_RESOLVE_KEY);
|
||||
n_resolv_cb = (GtkWidget *)OBJECT_GET_DATA(w, N_RESOLVE_KEY);
|
||||
t_resolv_cb = (GtkWidget *)OBJECT_GET_DATA(w, T_RESOLVE_KEY);
|
||||
#ifdef HAVE_GNU_ADNS
|
||||
c_resolv_cb = (GtkWidget *)OBJECT_GET_DATA(w, C_RESOLVE_KEY);
|
||||
|
||||
resolv_concurrency_te = (GtkWidget *)OBJECT_GET_DATA(w, RESOLVE_CONCURRENCY_KEY);
|
||||
#endif /* HAVE_GNU_ADNS */
|
||||
|
||||
prefs.name_resolve = RESOLV_NONE;
|
||||
prefs.name_resolve |= (GTK_TOGGLE_BUTTON (m_resolv_cb)->active ? RESOLV_MAC : RESOLV_NONE);
|
||||
prefs.name_resolve |= (GTK_TOGGLE_BUTTON (n_resolv_cb)->active ? RESOLV_NETWORK : RESOLV_NONE);
|
||||
prefs.name_resolve |= (GTK_TOGGLE_BUTTON (t_resolv_cb)->active ? RESOLV_TRANSPORT : RESOLV_NONE);
|
||||
#ifdef HAVE_GNU_ADNS
|
||||
prefs.name_resolve |= (GTK_TOGGLE_BUTTON (c_resolv_cb)->active ? RESOLV_CONCURRENT : RESOLV_NONE);
|
||||
|
||||
prefs.name_resolve_concurrency = strtol (gtk_entry_get_text(
|
||||
GTK_ENTRY(resolv_concurrency_te)), NULL, 10);
|
||||
#endif /* HAVE_GNU_ADNS */
|
||||
}
|
||||
|
||||
void
|
||||
|
|
21
prefs.c
21
prefs.c
|
@ -1,7 +1,7 @@
|
|||
/* prefs.c
|
||||
* Routines for handling preferences
|
||||
*
|
||||
* $Id: prefs.c,v 1.101 2003/05/15 07:44:53 guy Exp $
|
||||
* $Id: prefs.c,v 1.102 2003/07/22 03:14:28 gerald Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -978,11 +978,12 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
|
|||
prefs.gui_geometry_main_height = -1;
|
||||
|
||||
/* set the default values for the capture dialog box */
|
||||
prefs.capture_device = NULL;
|
||||
prefs.capture_prom_mode = TRUE;
|
||||
prefs.capture_real_time = FALSE;
|
||||
prefs.capture_auto_scroll = FALSE;
|
||||
prefs.name_resolve = RESOLV_ALL ^ RESOLV_NETWORK;
|
||||
prefs.capture_device = NULL;
|
||||
prefs.capture_prom_mode = TRUE;
|
||||
prefs.capture_real_time = FALSE;
|
||||
prefs.capture_auto_scroll = FALSE;
|
||||
prefs.name_resolve = RESOLV_ALL ^ RESOLV_NETWORK;
|
||||
prefs.name_resolve_concurrency = 500;
|
||||
}
|
||||
|
||||
/* Construct the pathname of the global preferences file. */
|
||||
|
@ -1247,6 +1248,7 @@ prefs_set_pref(char *prefarg)
|
|||
* over the place, so its name doesn't have two components.
|
||||
*/
|
||||
#define PRS_NAME_RESOLVE "name_resolve"
|
||||
#define PRS_NAME_RESOLVE_CONCURRENCY "name_resolve_concurrency"
|
||||
#define PRS_CAP_NAME_RESOLVE "capture.name_resolve"
|
||||
|
||||
/* values for the capture dialog box */
|
||||
|
@ -1271,6 +1273,7 @@ static name_resolve_opt_t name_resolve_opt[] = {
|
|||
{ 'm', RESOLV_MAC },
|
||||
{ 'n', RESOLV_NETWORK },
|
||||
{ 't', RESOLV_TRANSPORT },
|
||||
{ 'C', RESOLV_CONCURRENT },
|
||||
};
|
||||
|
||||
#define N_NAME_RESOLVE_OPT (sizeof name_resolve_opt / sizeof name_resolve_opt[0])
|
||||
|
@ -1536,6 +1539,8 @@ set_pref(gchar *pref_name, gchar *value)
|
|||
if (string_to_name_resolve(value, &prefs.name_resolve) != '\0')
|
||||
return PREFS_SET_SYNTAX_ERR;
|
||||
}
|
||||
} else if (strcmp(pref_name, PRS_NAME_RESOLVE_CONCURRENCY) == 0) {
|
||||
prefs.name_resolve_concurrency = strtol(value, NULL, 10);
|
||||
} else {
|
||||
/* To which module does this preference belong? */
|
||||
module = NULL;
|
||||
|
@ -2032,6 +2037,9 @@ write_prefs(char **pf_path_return)
|
|||
fprintf(pf, "\n# Resolve addresses to names? TRUE/FALSE/{list of address types to resolve}\n");
|
||||
fprintf(pf, PRS_NAME_RESOLVE ": %s\n",
|
||||
name_resolve_to_string(prefs.name_resolve));
|
||||
fprintf(pf, "\n# Name resolution concurrency Decimal integer.\n");
|
||||
fprintf(pf, PRS_NAME_RESOLVE_CONCURRENCY ": %d\n",
|
||||
prefs.name_resolve_concurrency);
|
||||
|
||||
/* write the capture options */
|
||||
if (prefs.capture_device != NULL) {
|
||||
|
@ -2108,6 +2116,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
|
|||
dest->capture_real_time = src->capture_real_time;
|
||||
dest->capture_auto_scroll = src->capture_auto_scroll;
|
||||
dest->name_resolve = src->name_resolve;
|
||||
dest->name_resolve_concurrency = src->name_resolve_concurrency;
|
||||
|
||||
}
|
||||
|
||||
|
|
3
prefs.h
3
prefs.h
|
@ -1,7 +1,7 @@
|
|||
/* prefs.h
|
||||
* Definitions for preference handling routines
|
||||
*
|
||||
* $Id: prefs.h,v 1.42 2002/12/20 01:48:54 guy Exp $
|
||||
* $Id: prefs.h,v 1.43 2003/07/22 03:14:28 gerald Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -69,6 +69,7 @@ typedef struct _e_prefs {
|
|||
gint gui_geometry_main_width;
|
||||
gint gui_geometry_main_height;
|
||||
guint32 name_resolve;
|
||||
gint name_resolve_concurrency;
|
||||
gchar *capture_device;
|
||||
gboolean capture_prom_mode;
|
||||
gboolean capture_real_time;
|
||||
|
|
Loading…
Reference in New Issue