Add a new name resolution option: whether or not use the configured (in the OS)
name resolver (e.g., DNS) to resolve network names.  When this option is disabled
but network name resolution is enabled then Wireshark will resolve only those
names that it can from local sources.  This includes (at least, AFAIK):

- name resolutions that Wireshark picks up on from DNS packets it decodes
- the "user hosts file" (~/.wireshark/hosts on *NIX)
- what Wireshark reads out of capture file (the PCAPNG name resolution block)

This new preference defaults to "use external resolvers" for backward
compatibility (so people turning on network name resolution will get the old
behavior).

This option can be set via Edit->Preferences and on the command line; there
remain several UIs (e.g., the "open capture file" dialog, the
View->Name Resolution menu, etc.) that don't have the new option yet.


Also expand on the "description" for the name resolution preferences: these
are used not only in the tooltips but are also written to the preferences
file.  The previous text didn't include enough context when written do the
preferences file.

svn path=/trunk/; revision=43605
This commit is contained in:
Jeff Morriss 2012-07-08 01:31:48 +00:00
parent 10fa9baef2
commit 8f12c9d7d7
8 changed files with 61 additions and 50 deletions

View File

@ -157,6 +157,9 @@ B<m> to enable MAC address resolution
B<n> to enable network address resolution
B<N> to enable using external resolvers (e.g., DNS) for network address
resolution
B<t> to enable transport-layer port number resolution
B<C> to enable concurrent (asynchronous) DNS lookups

View File

@ -526,6 +526,9 @@ B<m> to enable MAC address resolution
B<n> to enable network address resolution
B<N> to enable using external resolvers (e.g., DNS) for network address
resolution
B<t> to enable transport-layer port number resolution
B<C> to enable concurrent (asynchronous) DNS lookups

View File

@ -454,6 +454,9 @@ B<m> to enable MAC address resolution
B<n> to enable network address resolution
B<N> to enable using external resolvers (e.g., DNS) for network address
resolution
B<t> to enable transport-layer port number resolution
B<C> to enable concurrent (asynchronous) DNS lookups

View File

@ -286,7 +286,7 @@ static void add_serv_port_cb(const guint32 port);
/*
* Flag controlling what names to resolve.
*/
e_addr_resolve gbl_resolv_flags = {TRUE, FALSE, TRUE, TRUE};
e_addr_resolve gbl_resolv_flags = {TRUE, FALSE, TRUE, TRUE, TRUE};
#if defined(HAVE_C_ARES) || defined(HAVE_GNU_ADNS)
static guint name_resolve_concurrency = 500;
#endif
@ -768,7 +768,7 @@ new_ipv4(const guint addr)
}
static hashipv4_t *
host_lookup(const guint addr, const gboolean resolve, gboolean *found)
host_lookup(const guint addr, gboolean *found)
{
int hash_idx;
hashipv4_t * volatile tp;
@ -800,7 +800,7 @@ host_lookup(const guint addr, const gboolean resolve, gboolean *found)
}
}
if (resolve) {
if (gbl_resolv_flags.use_external_net_name_resolver) {
tp->resolve = TRUE;
#ifdef ASYNC_DNS
if (gbl_resolv_flags.concurrent_dns &&
@ -844,16 +844,7 @@ host_lookup(const guint addr, const gboolean resolve, gboolean *found)
fill_dummy_ip4(addr, tp);
return tp;
} /* host_name_lookup */
static gchar *
host_name_lookup(const guint addr, gboolean *found)
{
hashipv4_t *tp;
tp = host_lookup(addr, TRUE, found);
return tp->name;
}
} /* host_lookup */
/* --------------- */
static hashipv6_t *
@ -870,7 +861,7 @@ new_ipv6(const struct e_in6_addr *addr)
/* ------------------------------------ */
static hashipv6_t *
host_lookup6(const struct e_in6_addr *addr, const gboolean resolve, gboolean *found)
host_lookup6(const struct e_in6_addr *addr, gboolean *found)
{
int hash_idx;
hashipv6_t * volatile tp;
@ -907,7 +898,7 @@ host_lookup6(const struct e_in6_addr *addr, const gboolean resolve, gboolean *fo
}
}
if (resolve) {
if (gbl_resolv_flags.use_external_net_name_resolver) {
tp->resolve = TRUE;
#ifdef INET6
@ -953,16 +944,6 @@ host_lookup6(const struct e_in6_addr *addr, const gboolean resolve, gboolean *fo
} /* host_lookup6 */
#if 0
static gchar *
host_name_lookup6(struct e_in6_addr *addr, gboolean *found)
{
hashipv6_t *tp;
tp = host_lookup6(addr, TRUE, found);
return tp->name;
}
#endif
static const gchar *
solve_address_to_name(const address *addr)
{
@ -2386,34 +2367,45 @@ addr_resolve_pref_init(module_t *nameres)
{
prefs_register_bool_preference(nameres, "mac_name",
"Enable MAC name resolution",
"e.g. Ethernet address to manufacturer name",
"Resolve Ethernet MAC address to manufacturer names",
&gbl_resolv_flags.mac_name);
prefs_register_bool_preference(nameres, "network_name",
"Enable network name resolution",
"e.g. IP address to DNS name (hostname)",
"Resolve IP addresses into host names",
&gbl_resolv_flags.network_name);
prefs_register_bool_preference(nameres, "transport_name",
"Enable transport name resolution",
"e.g. TCP/UDP port to service name",
"Resolve TCP/UDP ports into service names",
&gbl_resolv_flags.transport_name);
prefs_register_bool_preference(nameres, "use_external_name_resolver",
"Use external network name resolver",
"Use the (system's) configured name resolver"
" (e.g., DNS) to resolve network names."
" Only applies when network name resolution"
" is enabled",
&gbl_resolv_flags.use_external_net_name_resolver);
#if defined(HAVE_C_ARES) || defined(HAVE_GNU_ADNS)
prefs_register_bool_preference(nameres, "concurrent_dns",
"Enable concurrent DNS name resolution",
"be sure to enable network name resolution",
"Enable concurrent DNS name resolution. Only"
" applies when network name resolution is"
" enabled",
&gbl_resolv_flags.concurrent_dns);
prefs_register_uint_preference(nameres, "name_resolve_concurrency",
"Maximum concurrent requests",
"maximum parallel running DNS requests",
10,
&name_resolve_concurrency);
prefs_register_uint_preference(nameres, "name_resolve_concurrency",
"Maximum concurrent requests",
"Maximum parallel running DNS requests",
10,
&name_resolve_concurrency);
#else
prefs_register_static_text_preference(nameres, "no_concurrent_dns",
prefs_register_static_text_preference(nameres, "concurrent_dns",
"Enable concurrent DNS name resolution: N/A",
"Support for this feature was not compiled into this version of Wireshark");
"Support for concurrent DNS name resolution was not"
" compiled into this version of Wireshark");
#endif
}
@ -2677,10 +2669,13 @@ const gchar *
get_hostname(const guint addr)
{
gboolean found;
gboolean resolve = gbl_resolv_flags.network_name;
hashipv4_t *tp = host_lookup(addr, resolve, &found);
if (!resolve)
/* XXX why do we call this if we're not resolving? To create hash entries?
* Why?
*/
hashipv4_t *tp = host_lookup(addr, &found);
if (!gbl_resolv_flags.network_name)
return tp->ip;
return tp->name;
@ -2692,10 +2687,13 @@ const gchar *
get_hostname6(const struct e_in6_addr *addr)
{
gboolean found;
gboolean resolve = gbl_resolv_flags.network_name;
hashipv6_t *tp = host_lookup6(addr, resolve, &found);
if (!resolve)
/* XXX why do we call this if we're not resolving? To create hash entries?
* Why?
*/
hashipv6_t *tp = host_lookup6(addr, &found);
if (!gbl_resolv_flags.network_name)
return tp->ip6;
return tp->name;
@ -2998,21 +2996,21 @@ get_ether_addr(const gchar *name)
void
add_ether_byip(const guint ip, const guint8 *eth)
{
gchar *host;
gboolean found;
hashipv4_t *tp;
/* first check that IP address can be resolved */
if (!gbl_resolv_flags.network_name)
return;
if ((host = host_name_lookup(ip, &found)) == NULL)
tp = host_lookup(ip, &found);
if (tp->name == NULL)
return;
/* ok, we can add this entry in the ethers hashtable */
if (found)
add_eth_name(eth, host);
add_eth_name(eth, tp->name);
} /* add_ether_byip */

View File

@ -50,6 +50,7 @@ typedef struct _e_addr_resolve {
gboolean network_name;
gboolean transport_name;
gboolean concurrent_dns;
gboolean use_external_net_name_resolver;
} e_addr_resolve;
/*

View File

@ -799,15 +799,15 @@ void oid_pref_init(module_t *nameres)
#else
prefs_register_static_text_preference(nameres, "load_smi_modules_static",
"Enable OID resolution: N/A",
"Support for this feature was not compiled into this version of Wireshark");
"Support for OID resolution was not compiled into this version of Wireshark");
prefs_register_static_text_preference(nameres, "suppress_smi_errors_static",
"Suppress SMI errors: N/A",
"Support for this feature was not compiled into this version of Wireshark");
"Support for OID resolution was not compiled into this version of Wireshark");
prefs_register_static_text_preference(nameres, "smi_module_path",
"SMI (MIB and PIB) modules and paths: N/A",
"Support for this feature was not compiled into this version of Wireshark");
"Support for OID resolution was not compiled into this version of Wireshark");
#endif
}

View File

@ -2259,6 +2259,9 @@ string_to_name_resolve(char *string, e_addr_resolve *name_resolve)
case 'n':
name_resolve->network_name = TRUE;
break;
case 'N':
name_resolve->use_external_net_name_resolver = TRUE;
break;
case 't':
name_resolve->transport_name = TRUE;
break;

View File

@ -916,7 +916,7 @@ void expand_tree_cb(GtkWidget *widget _U_, gpointer data _U_) {
}
void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_) {
static const e_addr_resolve resolv_flags = {TRUE, TRUE, TRUE, TRUE};
static const e_addr_resolve resolv_flags = {TRUE, TRUE, TRUE, TRUE, TRUE};
if (cfile.edt->tree) {
proto_tree_draw_resolve(cfile.edt->tree, tree_view_gbl, &resolv_flags);