2 * Dialog box for name resolution preferences
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include "nameres_prefs.h"
33 #include "gtkglobals.h"
34 #include <epan/addr_resolv.h>
35 #include <epan/prefs.h>
36 #include "prefs_dlg.h"
40 #include "compat_macros.h"
42 #define M_RESOLVE_KEY "m_resolve"
43 #define N_RESOLVE_KEY "n_resolve"
44 #define T_RESOLVE_KEY "t_resolve"
46 # define C_RESOLVE_KEY "c_resolve"
47 # define RESOLVE_CONCURRENCY_KEY "resolve_concurrency"
48 #endif /* HAVE_GNU_ADNS */
51 # define RESOLV_TABLE_ROWS 5
53 # define RESOLV_TABLE_ROWS 3
54 #endif /* HAVE_GNU_ADNS */
56 nameres_prefs_show(void)
58 GtkWidget *main_tb, *main_vb;
59 GtkWidget *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
60 GtkTooltips *tooltips = gtk_tooltips_new();
62 GtkWidget *c_resolv_cb, *resolv_concurrency_te;
63 char concur_str[10+1];
64 #endif /* HAVE_GNU_ADNS */
67 * XXX - it would be nice if the current setting of the resolver
68 * flags could be different from the preference flags, so that
69 * the preference flags would represent what the user *typically*
70 * wants, but they could override them for particular captures
71 * without a subsequent editing of the preferences recording the
72 * temporary settings as permanent preferences.
74 prefs.name_resolve = g_resolv_flags;
76 /* Main vertical box */
77 main_vb = gtk_vbox_new(FALSE, 7);
78 gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
81 main_tb = gtk_table_new(RESOLV_TABLE_ROWS, 3, FALSE);
82 gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
83 gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
84 gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
85 gtk_widget_show(main_tb);
86 OBJECT_SET_DATA(main_tb, E_TOOLTIPS_KEY, tooltips);
88 /* Resolve MAC addresses */
89 m_resolv_cb = create_preference_check_button(main_tb, 0,
90 "Enable MAC name resolution:", "e.g. Ethernet address to manufacturer name",
91 prefs.name_resolve & RESOLV_MAC);
92 OBJECT_SET_DATA(main_vb, M_RESOLVE_KEY, m_resolv_cb);
94 /* Resolve network addresses */
95 n_resolv_cb = create_preference_check_button(main_tb, 1,
96 "Enable network name resolution:", "e.g. IP address to DNS name (hostname)",
97 prefs.name_resolve & RESOLV_NETWORK);
98 OBJECT_SET_DATA(main_vb, N_RESOLVE_KEY, n_resolv_cb);
100 /* Resolve transport addresses */
101 t_resolv_cb = create_preference_check_button(main_tb, 2,
102 "Enable transport name resolution:", "e.g. TCP/UDP port to service name",
103 prefs.name_resolve & RESOLV_TRANSPORT);
104 OBJECT_SET_DATA(main_vb, T_RESOLVE_KEY, t_resolv_cb);
107 /* Enable concurrent (asynchronous) DNS lookups */
108 c_resolv_cb = create_preference_check_button(main_tb, 3,
109 "Enable concurrent DNS name resolution:", "be sure to enable network name resolution",
110 prefs.name_resolve & RESOLV_CONCURRENT);
111 OBJECT_SET_DATA(main_vb, C_RESOLVE_KEY, c_resolv_cb);
113 /* Max concurrent requests */
114 g_snprintf(concur_str, 10+1, "%d", prefs.name_resolve_concurrency);
115 resolv_concurrency_te = create_preference_entry(main_tb, 4,
116 "Maximum concurrent requests:", "maximum parallel running DNS requests", concur_str);
117 OBJECT_SET_DATA(main_vb, RESOLVE_CONCURRENCY_KEY, resolv_concurrency_te);
119 #endif /* HAVE_GNU_ADNS */
121 /* Show 'em what we got */
122 gtk_widget_show_all(main_vb);
128 nameres_prefs_fetch(GtkWidget *w)
130 GtkWidget *m_resolv_cb, *n_resolv_cb, *t_resolv_cb;
132 GtkWidget *c_resolv_cb, *resolv_concurrency_te;
133 #endif /* HAVE_GNU_ADNS */
135 m_resolv_cb = (GtkWidget *)OBJECT_GET_DATA(w, M_RESOLVE_KEY);
136 n_resolv_cb = (GtkWidget *)OBJECT_GET_DATA(w, N_RESOLVE_KEY);
137 t_resolv_cb = (GtkWidget *)OBJECT_GET_DATA(w, T_RESOLVE_KEY);
139 c_resolv_cb = (GtkWidget *)OBJECT_GET_DATA(w, C_RESOLVE_KEY);
141 resolv_concurrency_te = (GtkWidget *)OBJECT_GET_DATA(w, RESOLVE_CONCURRENCY_KEY);
142 #endif /* HAVE_GNU_ADNS */
144 prefs.name_resolve = RESOLV_NONE;
145 prefs.name_resolve |= (GTK_TOGGLE_BUTTON (m_resolv_cb)->active ? RESOLV_MAC : RESOLV_NONE);
146 prefs.name_resolve |= (GTK_TOGGLE_BUTTON (n_resolv_cb)->active ? RESOLV_NETWORK : RESOLV_NONE);
147 prefs.name_resolve |= (GTK_TOGGLE_BUTTON (t_resolv_cb)->active ? RESOLV_TRANSPORT : RESOLV_NONE);
149 prefs.name_resolve |= (GTK_TOGGLE_BUTTON (c_resolv_cb)->active ? RESOLV_CONCURRENT : RESOLV_NONE);
151 prefs.name_resolve_concurrency = strtol (gtk_entry_get_text(
152 GTK_ENTRY(resolv_concurrency_te)), NULL, 10);
153 #endif /* HAVE_GNU_ADNS */
157 nameres_prefs_apply(GtkWidget *w _U_)
160 * XXX - force a regeneration of the protocol list if this has
163 g_resolv_flags = prefs.name_resolve;
164 menu_name_resolution_changed();
168 nameres_prefs_destroy(GtkWidget *w _U_)