From Michael Mann:

Generic preferences implementation - Printing and Name Resolution.

svn path=/trunk/; revision=43579
This commit is contained in:
Anders Broman 2012-07-06 04:48:36 +00:00
parent 4c647041d4
commit c19583b72c
25 changed files with 495 additions and 398 deletions

View File

@ -154,6 +154,100 @@ static gboolean cap_order = TRUE; /* Report if packets are in chronolo
static gboolean cap_file_hashes = TRUE; /* Calculate file hashes */ static gboolean cap_file_hashes = TRUE; /* Calculate file hashes */
#endif #endif
#define USE_GOPTION = 1
#ifdef USE_GOPTION
static gboolean cap_help = FALSE;
static gboolean table_report = FALSE;
static GOptionEntry general_entries[] =
{
/* General */
{ "type", 't', 0, G_OPTION_ARG_NONE, &cap_file_type,
"display the capture file type", NULL },
{ "Encapsulation", 'E', 0, G_OPTION_ARG_NONE, &cap_file_encap,
"display the capture file encapsulation", NULL },
#ifdef HAVE_LIBGCRYPT
{ "Hash", 'H', 0, G_OPTION_ARG_NONE, &cap_file_hashes,
"display the SHA1, RMD160, and MD5 hashes of the file", NULL },
#endif /* HAVE_LIBGCRYPT */
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
};
static GOptionEntry size_entries[] =
{
/* Size */
{ "packets", 'c', 0, G_OPTION_ARG_NONE, &cap_packet_count,
"display the number of packets", NULL },
{ "size", 's', 0, G_OPTION_ARG_NONE, &cap_file_size,
"display the size of the file (in bytes)", NULL },
{ "tot-len-of-pkts", 'd', 0, G_OPTION_ARG_NONE, &cap_data_size,
"display the total length of all packets (in bytes)", NULL },
{ "snap", 'l', 0, G_OPTION_ARG_NONE, &cap_snaplen,
"display the packet size limit (snapshot length)", NULL },
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
};
static GOptionEntry time_entries[] =
{
/* Time */
{ "duration", 'u', 0, G_OPTION_ARG_NONE, &cap_duration,
"display the capture duration (in seconds)", NULL },
{ "start", 'a', 0, G_OPTION_ARG_NONE, &cap_start_time,
"display the capture start time", NULL },
{ "end", 'e', 0, G_OPTION_ARG_NONE, &cap_end_time,
"display the capture end time", NULL },
{ "cron", 'o', 0, G_OPTION_ARG_NONE, &cap_order,
"display the capture file chronological status (True/False)", NULL },
{ "start-end-time-sec", 'S', 0, G_OPTION_ARG_NONE, &time_as_secs,
"display start and end times as seconds", NULL },
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
};
static GOptionEntry stats_entries[] =
{
/* Statistics */
{ "bytes", 'y', 0, G_OPTION_ARG_NONE, &cap_data_rate_byte,
"display average data rate (in bytes/s)", NULL },
{ "bits", 'i', 0, G_OPTION_ARG_NONE, &cap_data_rate_bit,
"display average data rate (in bits/s)", NULL },
{ "packet-bytes", 'z', 0, G_OPTION_ARG_NONE, &cap_packet_size,
"display average packet size (in bytes)", NULL },
{ "packets", 'x', 0, G_OPTION_ARG_NONE, &cap_packet_rate,
"display average packet rate (in packets/s)", NULL },
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
};
static GOptionEntry output_format_entries[] =
{
/* Output format */
{ "long", 'L', 0, G_OPTION_ARG_NONE, &long_report,
"generate long report (default)", NULL },
{ "Table", 'T', 0, G_OPTION_ARG_NONE, &table_report,
"generate table report", NULL },
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
};
static GOptionEntry table_report_entries[] =
{
/* Table report */
{ "header-rec", 'R', 0, G_OPTION_ARG_NONE, &table_report_header,
"generate header record (default)", NULL },
{ "no-table", 'r', 0, G_OPTION_ARG_NONE, &table_report_header,
"do not generate header record", NULL },
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
};
static GOptionEntry misc_entries[] =
{
{ "helpcompat", 'h', 0, G_OPTION_ARG_NONE, &cap_help,
"display help", NULL },
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
};
GOptionContext *ctx;
GOptionGroup *general_grp, *size_grp, *time_grp, *stats_grp, *output_grp, *table_report_grp;
GError *parse_err = NULL;
#endif /* USE_GOPTION */
#ifdef HAVE_LIBGCRYPT #ifdef HAVE_LIBGCRYPT
#define HASH_SIZE_SHA1 20 #define HASH_SIZE_SHA1 20
#define HASH_SIZE_RMD160 20 #define HASH_SIZE_RMD160 20
@ -217,6 +311,7 @@ typedef struct _capture_info {
int *encap_counts; /* array of per_packet encap counts; array has one entry per wtap_encap type */ int *encap_counts; /* array of per_packet encap counts; array has one entry per wtap_encap type */
} capture_info; } capture_info;
static void static void
enable_all_infos(void) enable_all_infos(void)
{ {
@ -950,7 +1045,54 @@ main(int argc, char *argv[])
#endif #endif
/* Process the options */ /* Process the options */
#ifdef USE_GOPTION
ctx = g_option_context_new(" <infile> ... - print information about capture file(s)");
general_grp = g_option_group_new("gen", "General infos:",
"Show general options", NULL, NULL);
size_grp = g_option_group_new("size", "Size infos:",
"Show size options", NULL, NULL);
time_grp = g_option_group_new("time", "Time infos:",
"Show time options", NULL, NULL);
stats_grp = g_option_group_new("stats", "Statistics infos:",
"Show statistics options", NULL, NULL);
output_grp = g_option_group_new("output", "Output format:",
"Show output format options", NULL, NULL);
table_report_grp = g_option_group_new("table", "Table report options:",
"Show table report options", NULL, NULL);
g_option_group_add_entries(general_grp, general_entries);
g_option_group_add_entries(size_grp, size_entries);
g_option_group_add_entries(time_grp, time_entries);
g_option_group_add_entries(stats_grp, stats_entries);
g_option_group_add_entries(output_grp, output_format_entries);
g_option_group_add_entries(table_report_grp, table_report_entries);
g_option_context_add_main_entries(ctx, misc_entries, NULL);
g_option_context_add_group(ctx, general_grp);
g_option_context_add_group(ctx, size_grp);
g_option_context_add_group(ctx, time_grp);
g_option_context_add_group(ctx, stats_grp);
g_option_context_add_group(ctx, output_grp);
g_option_context_add_group(ctx, table_report_grp);
/* There's probably a better way to do this, but this works for now.
GOptions displays the name in argv[0] as the name of the
application. This is reasonable, but because we actually have a
script wrapper that calls the executable. The name that gets
displayed is not exactly the same as the command the user used
ran.
*/
argv[0] = "capinfos";
;
if( !g_option_context_parse(ctx, &argc, &argv, &parse_err) ) {
if(parse_err) g_print ("option parsing failed: %s\n", parse_err->message);
g_print("%s", g_option_context_get_help (ctx, TRUE, NULL));
exit(1);
}
if( cap_help || (argc < 2) ) {
g_print("%s", g_option_context_get_help (ctx, FALSE, NULL));
exit(0);
}
g_option_context_free(ctx);
#endif /* USE_GOPTION */
while ((opt = getopt(argc, argv, "tEcs" FILE_HASH_OPT "dluaeyizvhxoCALTRrSNqQBmb")) !=-1) { while ((opt = getopt(argc, argv, "tEcs" FILE_HASH_OPT "dluaeyizvhxoCALTRrSNqQBmb")) !=-1) {
switch (opt) { switch (opt) {

View File

@ -104,7 +104,7 @@ PROCESSOR_ARCHITECTURE=amd64
# "Microsoft Visual Studio 2010" # "Microsoft Visual Studio 2010"
# Visual C++ 10.0, _MSC_VER 1600, msvcr100.dll # Visual C++ 10.0, _MSC_VER 1600, msvcr100.dll
#MSVC_VARIANT=MSVC2010 MSVC_VARIANT=MSVC2010
# "Microsoft Visual C++ 2010 Express Edition" # "Microsoft Visual C++ 2010 Express Edition"
# Visual C++ 10.0, _MSC_VER 1600, msvcr100.dll # Visual C++ 10.0, _MSC_VER 1600, msvcr100.dll

View File

@ -286,7 +286,8 @@ static void add_serv_port_cb(const guint32 port);
/* /*
* Flag controlling what names to resolve. * Flag controlling what names to resolve.
*/ */
guint32 gbl_resolv_flags; e_addr_resolve gbl_resolv_flags = {TRUE, FALSE, TRUE, TRUE};
static guint name_resolve_concurrency = 500;
/* /*
* Global variables (can be changed in GUI sections) * Global variables (can be changed in GUI sections)
@ -362,7 +363,7 @@ typedef struct _async_dns_queue_msg
#endif /* HAVE_C_ARES */ #endif /* HAVE_C_ARES */
#ifdef ASYNC_DNS #ifdef ASYNC_DNS
static gboolean async_dns_initialized = FALSE; static gboolean async_dns_initialized = FALSE;
static int async_dns_in_flight = 0; static guint async_dns_in_flight = 0;
static GList *async_dns_queue_head = NULL; static GList *async_dns_queue_head = NULL;
/* push a dns request */ /* push a dns request */
@ -656,7 +657,7 @@ static gchar
tp->port = port; tp->port = port;
tp->next = NULL; tp->next = NULL;
if (!(gbl_resolv_flags & RESOLV_TRANSPORT) || if ((!gbl_resolv_flags.transport_name) ||
(servp = getservbyport(g_htons(port), serv_proto)) == NULL) { (servp = getservbyport(g_htons(port), serv_proto)) == NULL) {
/* unknown port */ /* unknown port */
guint32_to_str_buf(port, tp->name, MAXNAMELEN); guint32_to_str_buf(port, tp->name, MAXNAMELEN);
@ -799,8 +800,8 @@ host_lookup(const guint addr, const gboolean resolve, gboolean *found)
if (resolve) { if (resolve) {
tp->resolve = TRUE; tp->resolve = TRUE;
#ifdef ASYNC_DNS #ifdef ASYNC_DNS
if ((gbl_resolv_flags & RESOLV_CONCURRENT) && if (gbl_resolv_flags.concurrent_dns &&
prefs.name_resolve_concurrency > 0 && name_resolve_concurrency > 0 &&
async_dns_initialized) { async_dns_initialized) {
add_async_dns_ipv4(AF_INET, addr); add_async_dns_ipv4(AF_INET, addr);
/* XXX found is set to TRUE, which seems a bit odd, but I'm not /* XXX found is set to TRUE, which seems a bit odd, but I'm not
@ -817,7 +818,7 @@ host_lookup(const guint addr, const gboolean resolve, gboolean *found)
* botch, we don't try to translate an all-zero IP address to a host * botch, we don't try to translate an all-zero IP address to a host
* name. * name.
*/ */
if (addr != 0 && (gbl_resolv_flags & RESOLV_NETWORK)) { if (addr != 0 && gbl_resolv_flags.network_name) {
/* Use async DNS if possible, else fall back to timeouts, /* Use async DNS if possible, else fall back to timeouts,
* else call gethostbyaddr and hope for the best * else call gethostbyaddr and hope for the best
*/ */
@ -908,8 +909,8 @@ host_lookup6(const struct e_in6_addr *addr, const gboolean resolve, gboolean *fo
#ifdef INET6 #ifdef INET6
#ifdef HAVE_C_ARES #ifdef HAVE_C_ARES
if ((gbl_resolv_flags & RESOLV_CONCURRENT) && if ((gbl_resolv_flags.concurrent_dns) &&
prefs.name_resolve_concurrency > 0 && name_resolve_concurrency > 0 &&
async_dns_initialized) { async_dns_initialized) {
caqm = g_malloc(sizeof(async_dns_queue_msg_t)); caqm = g_malloc(sizeof(async_dns_queue_msg_t));
caqm->family = AF_INET6; caqm->family = AF_INET6;
@ -2377,6 +2378,42 @@ subnet_name_lookup_init(void)
* External Functions * External Functions
*/ */
void
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",
&gbl_resolv_flags.mac_name);
prefs_register_bool_preference(nameres, "network_name",
"Enable network name resolution",
"e.g. IP address to DNS name (hostname)",
&gbl_resolv_flags.network_name);
prefs_register_bool_preference(nameres, "transport_name",
"Enable transport name resolution",
"e.g. TCP/UDP port to service name",
&gbl_resolv_flags.transport_name);
#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",
&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);
#else
prefs_register_static_text_preference(nameres, "no_concurrent_dns",
"Enable concurrent DNS name resolution: N/A",
"Support for this feature was not compiled into this version of Wireshark");
#endif
}
void void
host_name_lookup_init(void) { host_name_lookup_init(void) {
char *hostspath; char *hostspath;
@ -2492,7 +2529,7 @@ host_name_lookup_process(gpointer data _U_) {
async_dns_queue_head = g_list_first(async_dns_queue_head); async_dns_queue_head = g_list_first(async_dns_queue_head);
while (async_dns_queue_head != NULL && async_dns_in_flight <= prefs.name_resolve_concurrency) { while (async_dns_queue_head != NULL && async_dns_in_flight <= name_resolve_concurrency) {
caqm = (async_dns_queue_msg_t *) async_dns_queue_head->data; caqm = (async_dns_queue_msg_t *) async_dns_queue_head->data;
async_dns_queue_head = g_list_remove(async_dns_queue_head, (void *) caqm); async_dns_queue_head = g_list_remove(async_dns_queue_head, (void *) caqm);
if (caqm->family == AF_INET) { if (caqm->family == AF_INET) {
@ -2636,7 +2673,7 @@ const gchar *
get_hostname(const guint addr) get_hostname(const guint addr)
{ {
gboolean found; gboolean found;
gboolean resolve = gbl_resolv_flags & RESOLV_NETWORK; gboolean resolve = gbl_resolv_flags.network_name;
hashipv4_t *tp = host_lookup(addr, resolve, &found); hashipv4_t *tp = host_lookup(addr, resolve, &found);
if (!resolve) if (!resolve)
@ -2651,7 +2688,7 @@ const gchar *
get_hostname6(const struct e_in6_addr *addr) get_hostname6(const struct e_in6_addr *addr)
{ {
gboolean found; gboolean found;
gboolean resolve = gbl_resolv_flags & RESOLV_NETWORK; gboolean resolve = gbl_resolv_flags.network_name;
hashipv6_t *tp = host_lookup6(addr, resolve, &found); hashipv6_t *tp = host_lookup6(addr, resolve, &found);
if (!resolve) if (!resolve)
@ -2794,7 +2831,7 @@ gchar *
get_udp_port(guint port) get_udp_port(guint port)
{ {
if (!(gbl_resolv_flags & RESOLV_TRANSPORT)) { if (!gbl_resolv_flags.transport_name) {
return ep_utoa(port); return ep_utoa(port);
} }
@ -2806,7 +2843,7 @@ gchar *
get_dccp_port(guint port) get_dccp_port(guint port)
{ {
if (!(gbl_resolv_flags & RESOLV_TRANSPORT)) { if (!gbl_resolv_flags.transport_name) {
return ep_utoa(port); return ep_utoa(port);
} }
@ -2819,7 +2856,7 @@ gchar *
get_tcp_port(guint port) get_tcp_port(guint port)
{ {
if (!(gbl_resolv_flags & RESOLV_TRANSPORT)) { if (!gbl_resolv_flags.transport_name) {
return ep_utoa(port); return ep_utoa(port);
} }
@ -2831,7 +2868,7 @@ gchar *
get_sctp_port(guint port) get_sctp_port(guint port)
{ {
if (!(gbl_resolv_flags & RESOLV_TRANSPORT)) { if (!gbl_resolv_flags.transport_name) {
return ep_utoa(port); return ep_utoa(port);
} }
@ -2894,7 +2931,7 @@ gchar *
get_ether_name(const guint8 *addr) get_ether_name(const guint8 *addr)
{ {
hashether_t *tp; hashether_t *tp;
gboolean resolve = (gbl_resolv_flags & RESOLV_MAC) != 0; gboolean resolve = gbl_resolv_flags.mac_name;
if (resolve && !eth_resolution_initialized) { if (resolve && !eth_resolution_initialized) {
initialize_ethers(); initialize_ethers();
@ -2917,7 +2954,7 @@ get_ether_name_if_known(const guint8 *addr)
/* Initialize ether structs if we're the first /* Initialize ether structs if we're the first
* ether-related function called */ * ether-related function called */
if (!(gbl_resolv_flags & RESOLV_MAC)) if (!gbl_resolv_flags.mac_name)
return NULL; return NULL;
if (!eth_resolution_initialized) { if (!eth_resolution_initialized) {
@ -2962,7 +2999,7 @@ add_ether_byip(const guint ip, const guint8 *eth)
gboolean found; gboolean found;
/* first check that IP address can be resolved */ /* first check that IP address can be resolved */
if (!(gbl_resolv_flags & RESOLV_NETWORK)) if (!gbl_resolv_flags.network_name)
return; return;
if ((host = host_name_lookup(ip, &found)) == NULL) if ((host = host_name_lookup(ip, &found)) == NULL)
@ -2979,7 +3016,7 @@ const gchar *
get_ipxnet_name(const guint32 addr) get_ipxnet_name(const guint32 addr)
{ {
if (!(gbl_resolv_flags & RESOLV_NETWORK)) { if (!gbl_resolv_flags.network_name) {
return ipxnet_to_str_punct(addr, '\0'); return ipxnet_to_str_punct(addr, '\0');
} }
@ -3018,12 +3055,12 @@ get_manuf_name(const guint8 *addr)
gchar *cur; gchar *cur;
hashmanuf_t *mtp; hashmanuf_t *mtp;
if ((gbl_resolv_flags & RESOLV_MAC) && !eth_resolution_initialized) { if (gbl_resolv_flags.mac_name && !eth_resolution_initialized) {
initialize_ethers(); initialize_ethers();
eth_resolution_initialized = TRUE; eth_resolution_initialized = TRUE;
} }
if (!(gbl_resolv_flags & RESOLV_MAC) || ((mtp = manuf_name_lookup(addr)) == NULL)) { if (!gbl_resolv_flags.mac_name || ((mtp = manuf_name_lookup(addr)) == NULL)) {
cur=ep_strdup_printf("%02x:%02x:%02x", addr[0], addr[1], addr[2]); cur=ep_strdup_printf("%02x:%02x:%02x", addr[0], addr[1], addr[2]);
return cur; return cur;
} }
@ -3094,12 +3131,12 @@ get_eui64_name(const guint64 addr_eui64)
/* Copy and convert the address to network byte order. */ /* Copy and convert the address to network byte order. */
*(guint64 *)(void *)(addr) = pntoh64(&(addr_eui64)); *(guint64 *)(void *)(addr) = pntoh64(&(addr_eui64));
if ((gbl_resolv_flags & RESOLV_MAC) && !eth_resolution_initialized) { if (gbl_resolv_flags.mac_name && !eth_resolution_initialized) {
initialize_ethers(); initialize_ethers();
eth_resolution_initialized = TRUE; eth_resolution_initialized = TRUE;
} }
if (!(gbl_resolv_flags & RESOLV_MAC) || ((mtp = manuf_name_lookup(addr)) == NULL)) { if (!gbl_resolv_flags.mac_name || ((mtp = manuf_name_lookup(addr)) == NULL)) {
cur=ep_strdup_printf("%02x:%02x:%02x%02x:%02x:%02x%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]); cur=ep_strdup_printf("%02x:%02x:%02x%02x:%02x:%02x%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]);
return cur; return cur;
} }
@ -3177,14 +3214,14 @@ get_host_ipaddr(const char *host, guint32 *addrp)
* less-than-4 octet notation. * less-than-4 octet notation.
*/ */
if (!inet_aton(host, &ipaddr)) { if (!inet_aton(host, &ipaddr)) {
if (! (gbl_resolv_flags & RESOLV_NETWORK)) { if (!gbl_resolv_flags.network_name) {
return FALSE; return FALSE;
} }
/* It's not a valid dotted-quad IP address; is it a valid /* It's not a valid dotted-quad IP address; is it a valid
* host name? */ * host name? */
#ifdef HAVE_C_ARES #ifdef HAVE_C_ARES
if (! (gbl_resolv_flags & RESOLV_CONCURRENT) || if (! (gbl_resolv_flags.concurrent_dns) ||
prefs.name_resolve_concurrency < 1 || name_resolve_concurrency < 1 ||
! async_dns_initialized) { ! async_dns_initialized) {
return FALSE; return FALSE;
} }
@ -3253,14 +3290,14 @@ get_host_ipaddr6(const char *host, struct e_in6_addr *addrp)
if (inet_pton(AF_INET6, host, addrp) == 1) if (inet_pton(AF_INET6, host, addrp) == 1)
return TRUE; return TRUE;
if (! (gbl_resolv_flags & RESOLV_NETWORK)) { if (!gbl_resolv_flags.network_name) {
return FALSE; return FALSE;
} }
/* try FQDN */ /* try FQDN */
#ifdef HAVE_C_ARES #ifdef HAVE_C_ARES
if (! (gbl_resolv_flags & RESOLV_CONCURRENT) || if (! (gbl_resolv_flags.concurrent_dns) ||
prefs.name_resolve_concurrency < 1 || name_resolve_concurrency < 1 ||
! async_dns_initialized) { ! async_dns_initialized) {
return FALSE; return FALSE;
} }

View File

@ -45,22 +45,17 @@ extern "C" {
#define MAXNAMELEN 64 /* max name length (hostname and port name) */ #define MAXNAMELEN 64 /* max name length (hostname and port name) */
#endif #endif
typedef struct _e_addr_resolve {
gboolean mac_name;
gboolean network_name;
gboolean transport_name;
gboolean concurrent_dns;
} e_addr_resolve;
/* /*
* Flag controlling what names to resolve. * Flag controlling what names to resolve.
*/ */
WS_VAR_IMPORT guint32 gbl_resolv_flags; WS_VAR_IMPORT e_addr_resolve gbl_resolv_flags;
/* 32 types are sufficient (as are 640k of RAM) */
/* FIXME: Maybe MANUF/m, IP/i, IP6/6, IPX/x, UDP+TCP/t etc would be
more useful/consistent */
#define RESOLV_NONE 0x0
#define RESOLV_MAC 0x1
#define RESOLV_NETWORK 0x2
#define RESOLV_TRANSPORT 0x4
#define RESOLV_CONCURRENT 0x8
#define RESOLV_ALL_ADDRS (RESOLV_MAC|RESOLV_NETWORK|RESOLV_TRANSPORT)
#define RESOLV_ALL 0xFFFFFFFF
/* global variables */ /* global variables */
@ -69,10 +64,7 @@ extern gchar *g_ipxnets_path;
extern gchar *g_pethers_path; extern gchar *g_pethers_path;
extern gchar *g_pipxnets_path; extern gchar *g_pipxnets_path;
/* Functions in resolv.c */ /* Functions in addr_resolv.c */
/* Set the flags controlling what names to resolve */
extern void resolv_set_flags(guint32 flags);
/* /*
* get_udp_port() returns the port name corresponding to that UDP port, * get_udp_port() returns the port name corresponding to that UDP port,
@ -122,6 +114,10 @@ void get_addr_name_buf(const address *addr, gchar *buf, gsize size);
* Asynchronous host name lookup initialization, processing, and cleanup * Asynchronous host name lookup initialization, processing, and cleanup
*/ */
/* Setup name resolution preferences */
typedef struct pref_module module_t;
extern void addr_resolve_pref_init(module_t *nameres);
/* host_name_lookup_init fires up an ADNS socket if we're using ADNS */ /* host_name_lookup_init fires up an ADNS socket if we're using ADNS */
extern void host_name_lookup_init(void); extern void host_name_lookup_init(void);

View File

@ -141,15 +141,12 @@ static void geoip_db_path_free_cb(void* p) {
* Initialize GeoIP lookups * Initialize GeoIP lookups
*/ */
void void
geoip_db_init(void) { geoip_db_pref_init(module_t *nameres)
guint i; {
static uat_field_t geoip_db_paths_fields[] = { static uat_field_t geoip_db_paths_fields[] = {
UAT_FLD_DIRECTORYNAME(geoip_mod, path, "GeoIP Database Directory", "The GeoIP database directory path"), UAT_FLD_DIRECTORYNAME(geoip_mod, path, "GeoIP Database Directory", "The GeoIP database directory path"),
UAT_END_FIELDS UAT_END_FIELDS
}; };
char* geoip_load_error = NULL;
geoip_dat_arr = g_array_new(FALSE, FALSE, sizeof(GeoIP *));
geoip_db_paths_uat = uat_new("GeoIP Database Paths", geoip_db_paths_uat = uat_new("GeoIP Database Paths",
sizeof(geoip_db_path_t), sizeof(geoip_db_path_t),
@ -165,13 +162,23 @@ geoip_db_init(void) {
NULL, NULL,
geoip_db_paths_fields); geoip_db_paths_fields);
uat_load(geoip_db_paths_uat, &geoip_load_error); prefs_register_uat_preference(nameres,
"geoip_db_paths",
if (geoip_load_error) { "GeoIP database directories",
report_failure("Error loading GeoIP database path table: %s", geoip_load_error); "Search paths for GeoIP address mapping databases.\n"
return; "Wireshark will look in each directory for files beginning\n"
"with \"Geo\" and ending with \".dat\".\n"
"You must restart Wireshark for these changes to take\n"
"effect.",
geoip_db_paths_uat);
} }
void
geoip_db_init(void) {
guint i;
geoip_dat_arr = g_array_new(FALSE, FALSE, sizeof(GeoIP *));
for (i = 0; i < num_geoip_db_paths; i++) { for (i = 0; i < num_geoip_db_paths; i++) {
if (geoip_db_paths[i].path) { if (geoip_db_paths[i].path) {
geoip_dat_scan_dir(geoip_db_paths[i].path); geoip_dat_scan_dir(geoip_db_paths[i].path);

View File

@ -28,6 +28,7 @@
#define __GEOIP_DB_H__ #define __GEOIP_DB_H__
#include <epan/ipv6-utils.h> #include <epan/ipv6-utils.h>
#include <epan/prefs.h>
/* Fake databases to make lat/lon values available */ /* Fake databases to make lat/lon values available */
/* XXX - find a better way to interface */ /* XXX - find a better way to interface */
@ -39,6 +40,7 @@
* Init function called from epan.h * Init function called from epan.h
*/ */
extern void geoip_db_init(void); extern void geoip_db_init(void);
extern void geoip_db_pref_init(module_t *nameres);
/** /**
* Number of databases we have loaded * Number of databases we have loaded

View File

@ -46,6 +46,8 @@
#include <smi.h> #include <smi.h>
static gboolean oids_init_done = FALSE; static gboolean oids_init_done = FALSE;
static gboolean load_smi_modules = FALSE;
static gboolean suppress_smi_errors = FALSE;
#endif #endif
#define D(level,args) do if (debuglevel >= level) { printf args; printf("\n"); fflush(stdout); } while(0) #define D(level,args) do if (debuglevel >= level) { printf args; printf("\n"); fflush(stdout); } while(0)
@ -514,61 +516,9 @@ static void register_mibs(void) {
int proto_mibs = -1; int proto_mibs = -1;
GArray* hfa = g_array_new(FALSE,TRUE,sizeof(hf_register_info)); GArray* hfa = g_array_new(FALSE,TRUE,sizeof(hf_register_info));
GArray* etta = g_array_new(FALSE,TRUE,sizeof(gint*)); GArray* etta = g_array_new(FALSE,TRUE,sizeof(gint*));
static uat_field_t smi_fields[] = {
UAT_FLD_CSTRING(smi_mod,name,"Module name","The module's name"),
UAT_END_FIELDS
};
static uat_field_t smi_paths_fields[] = {
UAT_FLD_DIRECTORYNAME(smi_mod,name,"Directory path","The directory name"),
UAT_END_FIELDS
};
char* smi_load_error = NULL;
gchar* path_str; gchar* path_str;
smi_modules_uat = uat_new("SMI Modules", if (!load_smi_modules) {
sizeof(smi_module_t),
"smi_modules",
FALSE,
(void*)&smi_modules,
&num_smi_modules,
UAT_CAT_GENERAL,
"ChSNMPSMIModules",
smi_mod_copy_cb,
NULL,
smi_mod_free_cb,
restart_needed_warning,
smi_fields);
smi_paths_uat = uat_new("SMI Paths",
sizeof(smi_module_t),
"smi_paths",
FALSE,
(void*)&smi_paths,
&num_smi_paths,
UAT_CAT_GENERAL,
"ChSNMPSMIPaths",
smi_mod_copy_cb,
NULL,
smi_mod_free_cb,
restart_needed_warning,
smi_paths_fields);
uat_load(smi_modules_uat, &smi_load_error);
if (smi_load_error) {
report_failure("Error Loading SMI Modules Table: %s",smi_load_error);
return;
}
uat_load(smi_paths_uat, &smi_load_error);
if (smi_load_error) {
report_failure("Error Loading SMI Paths Table: %s",smi_load_error);
return;
}
if (!prefs.load_smi_modules) {
D(1,("OID resolution not enabled")); D(1,("OID resolution not enabled"));
return; return;
} }
@ -607,7 +557,7 @@ static void register_mibs(void) {
} }
if (smi_errors->len) { if (smi_errors->len) {
if (!prefs.suppress_smi_errors) { if (!suppress_smi_errors) {
report_failure("The following errors were found while loading the MIBS:\n%s\n\n" report_failure("The following errors were found while loading the MIBS:\n%s\n\n"
"The Current Path is: %s\n\nYou can avoid this error message " "The Current Path is: %s\n\nYou can avoid this error message "
"by removing the missing MIB modules at Edit -> Preferences" "by removing the missing MIB modules at Edit -> Preferences"
@ -631,7 +581,7 @@ static void register_mibs(void) {
* Currently there is no such version. :-( * Currently there is no such version. :-(
*/ */
if (smiModule->conformance == 1) { if (smiModule->conformance == 1) {
if (!prefs.suppress_smi_errors) { if (!suppress_smi_errors) {
report_failure("Stopped processing module %s due to " report_failure("Stopped processing module %s due to "
"error(s) to prevent potential crash in libsmi.\n" "error(s) to prevent potential crash in libsmi.\n"
"Module's conformance level: %d.\n" "Module's conformance level: %d.\n"
@ -768,22 +718,104 @@ static void register_mibs(void) {
} }
#endif #endif
void oid_pref_init(module_t *nameres)
{
static uat_field_t smi_fields[] = {
UAT_FLD_CSTRING(smi_mod,name,"Module name","The module's name"),
UAT_END_FIELDS
};
static uat_field_t smi_paths_fields[] = {
UAT_FLD_DIRECTORYNAME(smi_mod,name,"Directory path","The directory name"),
UAT_END_FIELDS
};
#ifdef HAVE_LIBSMI
prefs_register_bool_preference(nameres, "load_smi_modules",
"Enable OID resolution",
"You must restart Wireshark for this change to take effect",
&load_smi_modules);
prefs_register_bool_preference(nameres, "suppress_smi_errors",
"Suppress SMI errors",
"Some errors can be ignored. If unsure, set to false.",
&suppress_smi_errors);
smi_paths_uat = uat_new("SMI Paths",
sizeof(smi_module_t),
"smi_paths",
FALSE,
(void*)&smi_paths,
&num_smi_paths,
UAT_CAT_GENERAL,
"ChSNMPSMIPaths",
smi_mod_copy_cb,
NULL,
smi_mod_free_cb,
restart_needed_warning,
smi_paths_fields);
prefs_register_uat_preference(nameres,
"smi_paths",
"SMI (MIB and PIB) paths",
"Search paths for SMI (MIB and PIB) modules. You must\n"
"restart Wireshark for these changes to take effect.",
smi_paths_uat);
smi_modules_uat = uat_new("SMI Modules",
sizeof(smi_module_t),
"smi_modules",
FALSE,
(void*)&smi_modules,
&num_smi_modules,
UAT_CAT_GENERAL,
"ChSNMPSMIModules",
smi_mod_copy_cb,
NULL,
smi_mod_free_cb,
restart_needed_warning,
smi_fields);
prefs_register_uat_preference(nameres,
"smi_modules",
"SMI (MIB and PIB) modules",
"List of enabled SMI (MIB and PIB) modules. You must\n"
"restart Wireshark for these changes to take effect.",
smi_modules_uat);
#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");
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");
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");
#endif
}
void oids_init(void) { void oids_init(void) {
if (load_smi_modules) {
#ifdef HAVE_LIBSMI #ifdef HAVE_LIBSMI
register_mibs(); register_mibs();
#else #else
D(1,("libsmi disabled oid resolution not enabled")); D(1,("libsmi disabled oid resolution not enabled"));
#endif #endif
} }
}
void oids_cleanup(void) { void oids_cleanup(void) {
if (load_smi_modules) {
#ifdef HAVE_LIBSMI #ifdef HAVE_LIBSMI
unregister_mibs(); unregister_mibs();
#else #else
D(1,("libsmi disabled oid resolution not enabled")); D(1,("libsmi disabled oid resolution not enabled"));
#endif #endif
} }
}
const char* oid_subid2string(guint32* subids, guint len) { const char* oid_subid2string(guint32* subids, guint len) {
char* s = ep_alloc0(((len)*11)+1); char* s = ep_alloc0(((len)*11)+1);
@ -1123,7 +1155,7 @@ oid_get_default_mib_path(void) {
path_str = g_string_new(""); path_str = g_string_new("");
if (!prefs.load_smi_modules) { if (!load_smi_modules) {
D(1,("OID resolution not enabled")); D(1,("OID resolution not enabled"));
return path_str->str; return path_str->str;
} }

View File

@ -28,6 +28,7 @@
#define __OIDS_H__ #define __OIDS_H__
#include <epan/ftypes/ftypes.h> #include <epan/ftypes/ftypes.h>
#include <epan/prefs.h>
/** /**
*@file *@file
*/ */
@ -106,6 +107,7 @@ typedef struct _oid_info_t {
/** init funcion called from epan.h */ /** init funcion called from epan.h */
extern void oids_init(void); extern void oids_init(void);
extern void oid_pref_init(module_t *nameres);
/** init funcion called from epan.h */ /** init funcion called from epan.h */
extern void oids_cleanup(void); extern void oids_cleanup(void);

View File

@ -42,6 +42,7 @@
#include <epan/address.h> #include <epan/address.h>
#include <epan/addr_resolv.h> #include <epan/addr_resolv.h>
#include <epan/oids.h> #include <epan/oids.h>
#include <epan/geoip_db.h>
#include <epan/packet.h> #include <epan/packet.h>
#include <epan/prefs.h> #include <epan/prefs.h>
#include <epan/proto.h> #include <epan/proto.h>
@ -315,7 +316,8 @@ prefs_register_module_or_subtree(module_t *parent, const char *name,
/* /*
* Register that a protocol has preferences. * Register that a protocol has preferences.
*/ */
module_t *protocols_module; module_t *protocols_module = NULL;
module_t *stats_module = NULL;
module_t * module_t *
prefs_register_protocol(int id, void (*apply_cb)(void)) prefs_register_protocol(int id, void (*apply_cb)(void))
@ -339,7 +341,6 @@ prefs_register_protocol(int id, void (*apply_cb)(void))
proto_get_protocol_name(id), apply_cb); proto_get_protocol_name(id), apply_cb);
} }
module_t * module_t *
prefs_register_protocol_subtree(const char *subtree, int id, void (*apply_cb)(void)) prefs_register_protocol_subtree(const char *subtree, int id, void (*apply_cb)(void))
{ {
@ -931,6 +932,23 @@ prefs_pref_foreach(module_t *module, pref_cb callback, gpointer user_data)
return 0; return 0;
} }
static const enum_val_t print_format_vals[] = {
{ "text", "Plain Text", PR_FMT_TEXT },
{ "postscript", "Postscript", PR_FMT_PS },
{ NULL, NULL, 0 }
};
static const enum_val_t print_dest_vals[] = {
#ifdef _WIN32
/* "PR_DEST_CMD" means "to printer" on Windows */
{ "command", "Printer", PR_DEST_CMD },
#else
{ "command", "Command", PR_DEST_CMD },
#endif
{ "file", "File", PR_DEST_FILE },
{ NULL, NULL, 0 }
};
static void stats_callback(void) static void stats_callback(void)
{ {
/* Test for a sane tap update interval */ /* Test for a sane tap update interval */
@ -952,30 +970,61 @@ static void stats_callback(void)
void void
prefs_register_modules(void) prefs_register_modules(void)
{ {
module_t* stats; module_t *printing, *nameres_module;
if (protocols_module != NULL) { if (protocols_module != NULL) {
/* Already setup preferences */ /* Already setup preferences */
return; return;
} }
stats = prefs_register_module(NULL, "statistics", "Statistics", /* Name Resolution */
nameres_module = prefs_register_module(NULL, "nameres", "Name Resolution",
"Name Resolution", NULL);
addr_resolve_pref_init(nameres_module);
oid_pref_init(nameres_module);
geoip_db_pref_init(nameres_module);
/* Printing */
printing = prefs_register_module(NULL, "print", "Printing",
"Printing", NULL);
prefs_register_enum_preference(printing, "format",
"Format", "Can be one of \"text\" or \"postscript\"",
&prefs.pr_format, print_format_vals, TRUE);
prefs_register_enum_preference(printing, "destination",
"Print to", "Can be one of \"command\" or \"file\"",
&prefs.pr_dest, print_dest_vals, TRUE);
#ifndef _WIN32
prefs_register_string_preference(printing, "command", "Command",
"Output gets piped to this command when the destination is set to \"command\"", &prefs.pr_cmd);
#endif
prefs_register_filename_preference(printing, "file", "File",
"This is the file that gets written to when the destination is set to \"file\"", &prefs.pr_file);
/* Statistics */
stats_module = prefs_register_module(NULL, "statistics", "Statistics",
"Statistics", &stats_callback); "Statistics", &stats_callback);
prefs_register_uint_preference(stats, "update_interval", prefs_register_uint_preference(stats_module, "update_interval",
"Tap update interval in ms", "Tap update interval in ms",
"Determines time between tap updates", "Determines time between tap updates",
10, 10,
&prefs.tap_update_interval); &prefs.tap_update_interval);
#ifdef HAVE_LIBPORTAUDIO #ifdef HAVE_LIBPORTAUDIO
prefs_register_uint_preference(stats, "rtp_player_max_visible", prefs_register_uint_preference(stats_module, "rtp_player_max_visible",
"Max visible channels in RTP Player", "Max visible channels in RTP Player",
"Determines maximum height of RTP Player window", "Determines maximum height of RTP Player window",
10, 10,
&prefs.rtp_player_max_visible); &prefs.rtp_player_max_visible);
#endif #endif
/* Protocols */
protocols_module = prefs_register_module(NULL, "protocols", "Protocols", protocols_module = prefs_register_module(NULL, "protocols", "Protocols",
"Protocols", NULL); "Protocols", NULL);
@ -1456,12 +1505,6 @@ init_prefs(void)
prefs.capture_auto_scroll = TRUE; prefs.capture_auto_scroll = TRUE;
prefs.capture_show_info = FALSE; prefs.capture_show_info = FALSE;
/* set the default values for the name resolution dialog box */
prefs.name_resolve = RESOLV_ALL ^ RESOLV_NETWORK;
prefs.name_resolve_concurrency = 500;
prefs.load_smi_modules = FALSE;
prefs.suppress_smi_errors = FALSE;
/* set the default values for the tap/statistics dialog box */ /* set the default values for the tap/statistics dialog box */
prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL; prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE; prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
@ -1616,9 +1659,7 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
FILE *pf; FILE *pf;
/* clean up libsmi structures before reading prefs */ /* clean up libsmi structures before reading prefs */
if (prefs.load_smi_modules) {
oids_cleanup(); oids_cleanup();
}
init_prefs(); init_prefs();
@ -1719,9 +1760,7 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
} }
/* load SMI modules if needed */ /* load SMI modules if needed */
if (prefs.load_smi_modules) {
oids_init(); oids_init();
}
return &prefs; return &prefs;
} }
@ -2081,10 +2120,6 @@ prefs_capture_device_monitor_mode(const char *name)
return FALSE; return FALSE;
} }
#define PRS_PRINT_FMT "print.format"
#define PRS_PRINT_DEST "print.destination"
#define PRS_PRINT_FILE "print.file"
#define PRS_PRINT_CMD "print.command"
#define PRS_COL_HIDDEN "column.hidden" #define PRS_COL_HIDDEN "column.hidden"
#define PRS_COL_FMT "column.format" #define PRS_COL_FMT "column.format"
#define PRS_STREAM_CL_FG "stream.client.fg" #define PRS_STREAM_CL_FG "stream.client.fg"
@ -2179,58 +2214,27 @@ prefs_capture_device_monitor_mode(const char *name)
static const gchar *pr_formats[] = { "text", "postscript" }; static const gchar *pr_formats[] = { "text", "postscript" };
static const gchar *pr_dests[] = { "command", "file" }; static const gchar *pr_dests[] = { "command", "file" };
typedef struct {
char letter;
guint32 value;
} name_resolve_opt_t;
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])
static const char *
name_resolve_to_string(guint32 name_resolve)
{
static char string[N_NAME_RESOLVE_OPT+1];
char *p;
unsigned int i;
gboolean all_opts_set = TRUE;
if (name_resolve == RESOLV_NONE)
return "FALSE";
p = &string[0];
for (i = 0; i < N_NAME_RESOLVE_OPT; i++) {
if (name_resolve & name_resolve_opt[i].value)
*p++ = name_resolve_opt[i].letter;
else
all_opts_set = FALSE;
}
*p = '\0';
if (all_opts_set)
return "TRUE";
return string;
}
char char
string_to_name_resolve(char *string, guint32 *name_resolve) string_to_name_resolve(char *string, e_addr_resolve *name_resolve)
{ {
char c; char c;
unsigned int i;
*name_resolve = 0; memset(name_resolve, 0, sizeof(e_addr_resolve));
while ((c = *string++) != '\0') { while ((c = *string++) != '\0') {
for (i = 0; i < N_NAME_RESOLVE_OPT; i++) { switch (c) {
if (c == name_resolve_opt[i].letter) { case 'm':
*name_resolve |= name_resolve_opt[i].value; name_resolve->mac_name = TRUE;
break; break;
} case 'n':
} name_resolve->network_name = TRUE;
if (i == N_NAME_RESOLVE_OPT) { break;
case 't':
name_resolve->transport_name = TRUE;
break;
case 'C':
name_resolve->concurrent_dns = TRUE;
break;
default:
/* /*
* Unrecognized letter. * Unrecognized letter.
*/ */
@ -2240,6 +2244,7 @@ string_to_name_resolve(char *string, guint32 *name_resolve)
return '\0'; return '\0';
} }
static void static void
try_convert_to_custom_column(gpointer *el_data) try_convert_to_custom_column(gpointer *el_data)
{ {
@ -2303,29 +2308,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_,
pref_t *pref; pref_t *pref;
gboolean had_a_dot; gboolean had_a_dot;
if (strcmp(pref_name, PRS_PRINT_FMT) == 0) { if (strcmp(pref_name, PRS_COL_HIDDEN) == 0) {
if (strcmp(value, pr_formats[PR_FMT_TEXT]) == 0) {
prefs.pr_format = PR_FMT_TEXT;
} else if (strcmp(value, pr_formats[PR_FMT_PS]) == 0) {
prefs.pr_format = PR_FMT_PS;
} else {
return PREFS_SET_SYNTAX_ERR;
}
} else if (strcmp(pref_name, PRS_PRINT_DEST) == 0) {
if (strcmp(value, pr_dests[PR_DEST_CMD]) == 0) {
prefs.pr_dest = PR_DEST_CMD;
} else if (strcmp(value, pr_dests[PR_DEST_FILE]) == 0) {
prefs.pr_dest = PR_DEST_FILE;
} else {
return PREFS_SET_SYNTAX_ERR;
}
} else if (strcmp(pref_name, PRS_PRINT_FILE) == 0) {
g_free(prefs.pr_file);
prefs.pr_file = g_strdup(value);
} else if (strcmp(pref_name, PRS_PRINT_CMD) == 0) {
g_free(prefs.pr_cmd);
prefs.pr_cmd = g_strdup(value);
} else if (strcmp(pref_name, PRS_COL_HIDDEN) == 0) {
g_free(cols_hidden_list); g_free(cols_hidden_list);
cols_hidden_list = g_strdup(value); cols_hidden_list = g_strdup(value);
/* /*
@ -2681,30 +2664,6 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_,
} else if (strcmp(pref_name, PRS_CAP_SYNTAX_CHECK_FILTER) == 0) { } else if (strcmp(pref_name, PRS_CAP_SYNTAX_CHECK_FILTER) == 0) {
/* Obsolete preference. */ /* Obsolete preference. */
; ;
/* handle the global options */
} else if (strcmp(pref_name, PRS_NAME_RESOLVE) == 0 ||
strcmp(pref_name, PRS_CAP_NAME_RESOLVE) == 0) {
/*
* "TRUE" and "FALSE", for backwards compatibility, are synonyms for
* RESOLV_ALL and RESOLV_NONE.
*
* Otherwise, we treat it as a list of name types we want to resolve.
*/
if (g_ascii_strcasecmp(value, "true") == 0)
prefs.name_resolve = RESOLV_ALL;
else if (g_ascii_strcasecmp(value, "false") == 0)
prefs.name_resolve = RESOLV_NONE;
else {
prefs.name_resolve = RESOLV_NONE; /* start out with none set */
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 if (strcmp(pref_name, PRS_NAME_RESOLVE_LOAD_SMI_MODULES) == 0) {
prefs.load_smi_modules = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
} else if (strcmp(pref_name, PRS_NAME_RESOLVE_SUPPRESS_SMI_ERRORS) == 0) {
prefs.suppress_smi_errors = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
} else { } else {
/* To which module does this preference belong? */ /* To which module does this preference belong? */
module = NULL; module = NULL;
@ -3739,63 +3698,13 @@ write_prefs(char **pf_path_return)
fprintf(pf, PRS_CAP_SHOW_INFO ": %s\n", fprintf(pf, PRS_CAP_SHOW_INFO ": %s\n",
prefs.capture_show_info == TRUE ? "TRUE" : "FALSE"); prefs.capture_show_info == TRUE ? "TRUE" : "FALSE");
fprintf (pf, "\n######## Printing ########\n");
fprintf (pf, "\n# Can be one of \"text\" or \"postscript\".\n");
if (prefs.pr_format == default_prefs.pr_format)
fprintf(pf, "#");
fprintf (pf, "print.format: %s\n", pr_formats[prefs.pr_format]);
fprintf (pf, "\n# Can be one of \"command\" or \"file\".\n");
if (prefs.pr_dest == default_prefs.pr_dest)
fprintf(pf, "#");
fprintf (pf, "print.destination: %s\n", pr_dests[prefs.pr_dest]);
fprintf (pf, "\n# This is the file that gets written to when the "
"destination is set to \"file\"\n");
if (strcmp(prefs.pr_file, default_prefs.pr_file) == 0)
fprintf(pf, "#");
fprintf (pf, "%s: %s\n", PRS_PRINT_FILE, prefs.pr_file);
fprintf (pf, "\n# Output gets piped to this command when the destination "
"is set to \"command\"\n");
if (strcmp(prefs.pr_cmd, default_prefs.pr_cmd) == 0)
fprintf(pf, "#");
fprintf (pf, "%s: %s\n", PRS_PRINT_CMD, prefs.pr_cmd);
fprintf(pf, "\n####### Name Resolution ########\n");
fprintf(pf, "\n# Resolve addresses to names?\n");
fprintf(pf, "# TRUE or FALSE (case-insensitive), or a list of address types to resolve.\n");
if (prefs.name_resolve == default_prefs.name_resolve)
fprintf(pf, "#");
fprintf(pf, PRS_NAME_RESOLVE ": %s\n",
name_resolve_to_string(prefs.name_resolve));
fprintf(pf, "\n# Name resolution concurrency.\n");
fprintf(pf, "# A decimal number.\n");
if (prefs.name_resolve_concurrency == default_prefs.name_resolve_concurrency)
fprintf(pf, "#");
fprintf(pf, PRS_NAME_RESOLVE_CONCURRENCY ": %d\n",
prefs.name_resolve_concurrency);
fprintf(pf, "\n# Load SMI modules?\n");
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
if (prefs.load_smi_modules == default_prefs.load_smi_modules)
fprintf(pf, "#");
fprintf(pf, PRS_NAME_RESOLVE_LOAD_SMI_MODULES ": %s\n",
prefs.load_smi_modules == TRUE ? "TRUE" : "FALSE");
fprintf(pf, "\n# Suppress SMI errors?\n");
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
if (prefs.suppress_smi_errors == default_prefs.suppress_smi_errors)
fprintf(pf, "#");
fprintf(pf, PRS_NAME_RESOLVE_SUPPRESS_SMI_ERRORS ": %s\n",
prefs.suppress_smi_errors == TRUE ? "TRUE" : "FALSE");
/* /*
* XXX - The following members are intentionally not written here because * XXX - The following members are intentionally not written here because
* they are handled within the 'generic' preference handling: * they are handled within the 'generic' preference handling:
* pr_format
* pr_dest
* pr_file
* pr_cmd
* tap_update_interval * tap_update_interval
* rtp_player_max_visible * rtp_player_max_visible
*/ */
@ -3842,8 +3751,6 @@ copy_prefs(e_prefs *dest, e_prefs *src)
fmt_data *src_cfmt, *dest_cfmt; fmt_data *src_cfmt, *dest_cfmt;
GList *entry; GList *entry;
dest->pr_format = src->pr_format;
dest->pr_dest = src->pr_dest;
dest->pr_file = g_strdup(src->pr_file); dest->pr_file = g_strdup(src->pr_file);
dest->pr_cmd = g_strdup(src->pr_cmd); dest->pr_cmd = g_strdup(src->pr_cmd);
dest->col_list = NULL; dest->col_list = NULL;
@ -3917,11 +3824,12 @@ copy_prefs(e_prefs *dest, e_prefs *src)
dest->capture_real_time = src->capture_real_time; dest->capture_real_time = src->capture_real_time;
dest->capture_auto_scroll = src->capture_auto_scroll; dest->capture_auto_scroll = src->capture_auto_scroll;
dest->capture_show_info = src->capture_show_info; dest->capture_show_info = src->capture_show_info;
dest->name_resolve = src->name_resolve;
dest->name_resolve_concurrency = src->name_resolve_concurrency;
/* /*
* XXX - The following members are intentionally not copied because they * XXX - The following members are intentionally not copied because they
* are handled within the 'generic' preference handling: * are handled within the 'generic' preference handling:
* pr_format
* pr_dest
* tap_update_interval * tap_update_interval
* rtp_player_max_visible * rtp_player_max_visible
* display_hidden_proto_items * display_hidden_proto_items

View File

@ -35,6 +35,7 @@ extern "C" {
#include <epan/params.h> #include <epan/params.h>
#include <epan/range.h> #include <epan/range.h>
#include <epan/addr_resolv.h>
#define PR_DEST_CMD 0 #define PR_DEST_CMD 0
#define PR_DEST_FILE 1 #define PR_DEST_FILE 1
@ -54,7 +55,7 @@ extern "C" {
* Set "*name_resolve" to the bitmask, and return '\0', on success; * Set "*name_resolve" to the bitmask, and return '\0', on success;
* return the bad character in the string on error. * return the bad character in the string on error.
*/ */
char string_to_name_resolve(char *string, guint32 *name_resolve); char string_to_name_resolve(char *string, e_addr_resolve *name_resolve);
/* /*
* Modes for the starting directory in File Open dialogs. * Modes for the starting directory in File Open dialogs.
@ -153,10 +154,6 @@ typedef struct _e_prefs {
layout_pane_content_e gui_layout_content_2; layout_pane_content_e gui_layout_content_2;
layout_pane_content_e gui_layout_content_3; layout_pane_content_e gui_layout_content_3;
gint console_log_level; gint console_log_level;
guint32 name_resolve;
gint name_resolve_concurrency;
gboolean load_smi_modules;
gboolean suppress_smi_errors;
gchar *capture_device; gchar *capture_device;
gchar *capture_devices_linktypes; gchar *capture_devices_linktypes;
gchar *capture_devices_descr; gchar *capture_devices_descr;

View File

@ -542,9 +542,6 @@ main(int argc, char *argv[])
pf_path = NULL; pf_path = NULL;
} }
/* Set the name resolution code's flags from the preferences. */
gbl_resolv_flags = prefs_p->name_resolve;
/* Read the disabled protocols file. */ /* Read the disabled protocols file. */
read_disabled_protos_list(&gdp_path, &gdp_open_errno, &gdp_read_errno, read_disabled_protos_list(&gdp_path, &gdp_open_errno, &gdp_read_errno,
&dp_path, &dp_open_errno, &dp_read_errno); &dp_path, &dp_open_errno, &dp_read_errno);
@ -619,11 +616,12 @@ main(int argc, char *argv[])
line_buffered = TRUE; line_buffered = TRUE;
break; break;
case 'n': /* No name resolution */ case 'n': /* No name resolution */
gbl_resolv_flags = RESOLV_NONE; gbl_resolv_flags.mac_name = FALSE;
gbl_resolv_flags.network_name = FALSE;
gbl_resolv_flags.transport_name = FALSE;
gbl_resolv_flags.concurrent_dns = FALSE;
break; break;
case 'N': /* Select what types of addresses/port #s to resolve */ case 'N': /* Select what types of addresses/port #s to resolve */
if (gbl_resolv_flags == RESOLV_ALL)
gbl_resolv_flags = RESOLV_NONE;
badopt = string_to_name_resolve(optarg, &gbl_resolv_flags); badopt = string_to_name_resolve(optarg, &gbl_resolv_flags);
if (badopt != '\0') { if (badopt != '\0') {
cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'", cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'",

View File

@ -1045,9 +1045,6 @@ main(int argc, char *argv[])
pf_path = NULL; pf_path = NULL;
} }
/* Set the name resolution code's flags from the preferences. */
gbl_resolv_flags = prefs_p->name_resolve;
/* Read the disabled protocols file. */ /* Read the disabled protocols file. */
read_disabled_protos_list(&gdp_path, &gdp_open_errno, &gdp_read_errno, read_disabled_protos_list(&gdp_path, &gdp_open_errno, &gdp_read_errno,
&dp_path, &dp_open_errno, &dp_read_errno); &dp_path, &dp_open_errno, &dp_read_errno);
@ -1215,11 +1212,12 @@ main(int argc, char *argv[])
#endif #endif
break; break;
case 'n': /* No name resolution */ case 'n': /* No name resolution */
gbl_resolv_flags = RESOLV_NONE; gbl_resolv_flags.mac_name = FALSE;
gbl_resolv_flags.network_name = FALSE;
gbl_resolv_flags.transport_name = FALSE;
gbl_resolv_flags.concurrent_dns = FALSE;
break; break;
case 'N': /* Select what types of addresses/port #s to resolve */ case 'N': /* Select what types of addresses/port #s to resolve */
if (gbl_resolv_flags == RESOLV_ALL)
gbl_resolv_flags = RESOLV_NONE;
badopt = string_to_name_resolve(optarg, &gbl_resolv_flags); badopt = string_to_name_resolve(optarg, &gbl_resolv_flags);
if (badopt != '\0') { if (badopt != '\0') {
cmdarg_err("-N specifies unknown resolving option '%c';", cmdarg_err("-N specifies unknown resolving option '%c';",
@ -2513,7 +2511,8 @@ process_packet_first_pass(capture_file *cf,
run a read filter, or we're going to process taps, set up to run a read filter, or we're going to process taps, set up to
do a dissection and do so. */ do a dissection and do so. */
if (do_dissection) { if (do_dissection) {
if (gbl_resolv_flags) if (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns)
/* Grab any resolved addresses */ /* Grab any resolved addresses */
host_name_lookup_process(NULL); host_name_lookup_process(NULL);
@ -2572,7 +2571,8 @@ process_packet_second_pass(capture_file *cf, frame_data *fdata,
run a read filter, or we're going to process taps, set up to run a read filter, or we're going to process taps, set up to
do a dissection and do so. */ do a dissection and do so. */
if (do_dissection) { if (do_dissection) {
if (gbl_resolv_flags) if (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns)
/* Grab any resolved addresses */ /* Grab any resolved addresses */
host_name_lookup_process(NULL); host_name_lookup_process(NULL);
@ -3026,7 +3026,8 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr,
run a read filter, or we're going to process taps, set up to run a read filter, or we're going to process taps, set up to
do a dissection and do so. */ do a dissection and do so. */
if (do_dissection) { if (do_dissection) {
if (print_packet_info && gbl_resolv_flags) if (print_packet_info && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns))
/* Grab any resolved addresses */ /* Grab any resolved addresses */
host_name_lookup_process(NULL); host_name_lookup_process(NULL);

View File

@ -96,8 +96,6 @@ set(WIRESHARK_GTK_SRC
prefs_filter_expressions.c prefs_filter_expressions.c
prefs_gui.c prefs_gui.c
prefs_layout.c prefs_layout.c
prefs_nameres.c
prefs_print.c
prefs_stream.c prefs_stream.c
print_dlg.c print_dlg.c
profile_dlg.c profile_dlg.c

View File

@ -121,8 +121,6 @@ WIRESHARK_GTK_SRC = \
prefs_filter_expressions.c \ prefs_filter_expressions.c \
prefs_gui.c \ prefs_gui.c \
prefs_layout.c \ prefs_layout.c \
prefs_nameres.c \
prefs_print.c \
prefs_stream.c \ prefs_stream.c \
print_dlg.c \ print_dlg.c \
profile_dlg.c \ profile_dlg.c \
@ -324,8 +322,6 @@ noinst_HEADERS = \
prefs_filter_expressions.h \ prefs_filter_expressions.h \
prefs_gui.h \ prefs_gui.h \
prefs_layout.h \ prefs_layout.h \
prefs_nameres.h \
prefs_print.h \
prefs_stream.h \ prefs_stream.h \
profile_dlg.h \ profile_dlg.h \
proto_dlg.h \ proto_dlg.h \

View File

@ -4072,21 +4072,21 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
m_resolv_cb = gtk_check_button_new_with_mnemonic( m_resolv_cb = gtk_check_button_new_with_mnemonic(
"Enable _MAC name resolution"); "Enable _MAC name resolution");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_resolv_cb), gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_resolv_cb),
gbl_resolv_flags & RESOLV_MAC); gbl_resolv_flags.mac_name);
gtk_widget_set_tooltip_text(m_resolv_cb, "Perform MAC layer name resolution while capturing."); gtk_widget_set_tooltip_text(m_resolv_cb, "Perform MAC layer name resolution while capturing.");
gtk_container_add(GTK_CONTAINER(resolv_vb), m_resolv_cb); gtk_container_add(GTK_CONTAINER(resolv_vb), m_resolv_cb);
n_resolv_cb = gtk_check_button_new_with_mnemonic( n_resolv_cb = gtk_check_button_new_with_mnemonic(
"Enable _network name resolution"); "Enable _network name resolution");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(n_resolv_cb), gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(n_resolv_cb),
gbl_resolv_flags & RESOLV_NETWORK); gbl_resolv_flags.network_name);
gtk_widget_set_tooltip_text(n_resolv_cb, "Perform network layer name resolution while capturing."); gtk_widget_set_tooltip_text(n_resolv_cb, "Perform network layer name resolution while capturing.");
gtk_container_add(GTK_CONTAINER(resolv_vb), n_resolv_cb); gtk_container_add(GTK_CONTAINER(resolv_vb), n_resolv_cb);
t_resolv_cb = gtk_check_button_new_with_mnemonic( t_resolv_cb = gtk_check_button_new_with_mnemonic(
"Enable _transport name resolution"); "Enable _transport name resolution");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t_resolv_cb), gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t_resolv_cb),
gbl_resolv_flags & RESOLV_TRANSPORT); gbl_resolv_flags.transport_name);
gtk_widget_set_tooltip_text(t_resolv_cb, gtk_widget_set_tooltip_text(t_resolv_cb,
"Perform transport layer name resolution while capturing."); "Perform transport layer name resolution while capturing.");
gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb); gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb);
@ -4386,17 +4386,17 @@ capture_dlg_prep(gpointer parent_w) {
!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb)); !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hide_info_cb));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb))) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
gbl_resolv_flags |= RESOLV_MAC; gbl_resolv_flags.mac_name = TRUE;
else else
gbl_resolv_flags &= ~RESOLV_MAC; gbl_resolv_flags.mac_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb))) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
gbl_resolv_flags |= RESOLV_NETWORK; gbl_resolv_flags.network_name = TRUE;
else else
gbl_resolv_flags &= ~RESOLV_NETWORK; gbl_resolv_flags.network_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb))) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
gbl_resolv_flags |= RESOLV_TRANSPORT; gbl_resolv_flags.transport_name = TRUE;
else else
gbl_resolv_flags &= ~RESOLV_TRANSPORT; gbl_resolv_flags.transport_name = FALSE;
global_capture_opts.has_ring_num_files = global_capture_opts.has_ring_num_files =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb)); gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ringbuffer_nbf_cb));

View File

@ -512,18 +512,18 @@ file_open_cmd(GtkWidget *w)
/* resolve buttons */ /* resolve buttons */
m_resolv_cb = gtk_check_button_new_with_mnemonic("Enable _MAC name resolution"); m_resolv_cb = gtk_check_button_new_with_mnemonic("Enable _MAC name resolution");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_resolv_cb), gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_resolv_cb),
gbl_resolv_flags & RESOLV_MAC); gbl_resolv_flags.mac_name);
gtk_box_pack_start(GTK_BOX(main_vb), m_resolv_cb, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(main_vb), m_resolv_cb, FALSE, FALSE, 0);
gtk_widget_show(m_resolv_cb); gtk_widget_show(m_resolv_cb);
n_resolv_cb = gtk_check_button_new_with_mnemonic("Enable _network name resolution"); n_resolv_cb = gtk_check_button_new_with_mnemonic("Enable _network name resolution");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(n_resolv_cb), gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(n_resolv_cb),
gbl_resolv_flags & RESOLV_NETWORK); gbl_resolv_flags.network_name);
gtk_box_pack_start(GTK_BOX(main_vb), n_resolv_cb, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(main_vb), n_resolv_cb, FALSE, FALSE, 0);
gtk_widget_show(n_resolv_cb); gtk_widget_show(n_resolv_cb);
t_resolv_cb = gtk_check_button_new_with_mnemonic("Enable _transport name resolution"); t_resolv_cb = gtk_check_button_new_with_mnemonic("Enable _transport name resolution");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t_resolv_cb), gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t_resolv_cb),
gbl_resolv_flags & RESOLV_TRANSPORT); gbl_resolv_flags.transport_name);
gtk_box_pack_start(GTK_BOX(main_vb), t_resolv_cb, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(main_vb), t_resolv_cb, FALSE, FALSE, 0);
gtk_widget_show(t_resolv_cb); gtk_widget_show(t_resolv_cb);
@ -580,17 +580,17 @@ file_open_cmd(GtkWidget *w)
/* Set the global resolving variable */ /* Set the global resolving variable */
gbl_resolv_flags = prefs.name_resolve; gbl_resolv_flags = prefs.name_resolve;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb))) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_resolv_cb)))
gbl_resolv_flags |= RESOLV_MAC; gbl_resolv_flags.mac_name = TRUE;
else else
gbl_resolv_flags &= ~RESOLV_MAC; gbl_resolv_flags.mac_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb))) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(n_resolv_cb)))
gbl_resolv_flags |= RESOLV_NETWORK; gbl_resolv_flags.network_name = TRUE;
else else
gbl_resolv_flags &= ~RESOLV_NETWORK; gbl_resolv_flags.network_name = FALSE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb))) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(t_resolv_cb)))
gbl_resolv_flags |= RESOLV_TRANSPORT; gbl_resolv_flags.transport_name = TRUE;
else else
gbl_resolv_flags &= ~RESOLV_TRANSPORT; gbl_resolv_flags.transport_name = FALSE;
/* We've crossed the Rubicon; get rid of the file selection box. */ /* We've crossed the Rubicon; get rid of the file selection box. */
window_destroy(GTK_WIDGET(file_open_w)); window_destroy(GTK_WIDGET(file_open_w));

View File

@ -916,8 +916,11 @@ void expand_tree_cb(GtkWidget *widget _U_, gpointer data _U_) {
} }
void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_) { void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_) {
if (cfile.edt->tree) e_addr_resolve resolv_flags = {TRUE, TRUE, TRUE, TRUE};
proto_tree_draw_resolve(cfile.edt->tree, tree_view_gbl, RESOLV_ALL);
if (cfile.edt->tree) {
proto_tree_draw_resolve(cfile.edt->tree, tree_view_gbl, resolv_flags);
}
} }
/* Update main window items based on whether there's a capture in progress. */ /* Update main window items based on whether there's a capture in progress. */
@ -2665,11 +2668,12 @@ main(int argc, char *argv[])
prefs_p->gui_font_name = g_strdup(optarg); prefs_p->gui_font_name = g_strdup(optarg);
break; break;
case 'n': /* No name resolution */ case 'n': /* No name resolution */
gbl_resolv_flags = RESOLV_NONE; gbl_resolv_flags.mac_name = FALSE;
gbl_resolv_flags.network_name = FALSE;
gbl_resolv_flags.transport_name = FALSE;
gbl_resolv_flags.concurrent_dns = FALSE;
break; break;
case 'N': /* Select what types of addresses/port #s to resolve */ case 'N': /* Select what types of addresses/port #s to resolve */
if (gbl_resolv_flags == RESOLV_ALL)
gbl_resolv_flags = RESOLV_NONE;
badopt = string_to_name_resolve(optarg, &gbl_resolv_flags); badopt = string_to_name_resolve(optarg, &gbl_resolv_flags);
if (badopt != '\0') { if (badopt != '\0') {
cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'", cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'",
@ -3854,9 +3858,6 @@ prefs_to_capture_opts(void)
global_capture_opts.real_time_mode = prefs.capture_real_time; global_capture_opts.real_time_mode = prefs.capture_real_time;
auto_scroll_live = prefs.capture_auto_scroll; auto_scroll_live = prefs.capture_auto_scroll;
#endif /* HAVE_LIBPCAP */ #endif /* HAVE_LIBPCAP */
/* Set the name resolution code's flags from the preferences. */
gbl_resolv_flags = prefs.name_resolve;
} }
static void copy_global_profile (const gchar *profile_name) static void copy_global_profile (const gchar *profile_name)

View File

@ -152,7 +152,7 @@ static void set_menu_sensitivity (GtkUIManager *ui_manager, const gchar *, gint)
#if !defined(WANT_PACKET_EDITOR) || !defined(HAVE_LIBPCAP) #if !defined(WANT_PACKET_EDITOR) || !defined(HAVE_LIBPCAP)
static void set_menu_visible(GtkUIManager *ui_manager, const gchar *path, gint val); static void set_menu_visible(GtkUIManager *ui_manager, const gchar *path, gint val);
#endif #endif
static void name_resolution_cb(GtkWidget *w, gpointer d, gint action); static void name_resolution_cb(GtkWidget *w, gpointer d, gboolean* res_flag);
static void colorize_cb(GtkWidget *w, gpointer d); static void colorize_cb(GtkWidget *w, gpointer d);
@ -727,7 +727,7 @@ view_menu_en_for_MAC_cb(GtkAction *action _U_, gpointer user_data)
if (!widget){ if (!widget){
g_warning("view_menu_en_for_MAC_cb: No widget found"); g_warning("view_menu_en_for_MAC_cb: No widget found");
}else{ }else{
name_resolution_cb( widget , user_data, RESOLV_MAC); name_resolution_cb( widget , user_data, &gbl_resolv_flags.mac_name);
} }
} }
@ -738,7 +738,7 @@ view_menu_en_for_network_cb(GtkAction *action _U_, gpointer user_data)
if (!widget){ if (!widget){
g_warning("view_menu_en_for_network_cb: No widget found"); g_warning("view_menu_en_for_network_cb: No widget found");
}else{ }else{
name_resolution_cb( widget , user_data, RESOLV_NETWORK); name_resolution_cb( widget , user_data, &gbl_resolv_flags.network_name);
} }
} }
@ -749,7 +749,7 @@ view_menu_en_for_transport_cb(GtkAction *action _U_, gpointer user_data)
if (!widget){ if (!widget){
g_warning("view_menu_en_for_transport_cb: No widget found"); g_warning("view_menu_en_for_transport_cb: No widget found");
}else{ }else{
name_resolution_cb( widget , user_data, RESOLV_TRANSPORT); name_resolution_cb( widget , user_data, &gbl_resolv_flags.transport_name);
} }
} }
@ -4301,29 +4301,29 @@ menu_name_resolution_changed(void)
if(!menu){ if(!menu){
g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforMACLayer"); g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforMACLayer");
} }
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags & RESOLV_MAC); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags.mac_name);
menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforNetworkLayer"); menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforNetworkLayer");
if(!menu){ if(!menu){
g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforNetworkLayer"); g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforNetworkLayer");
} }
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags & RESOLV_NETWORK); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags.network_name);
menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforTransportLayer"); menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforTransportLayer");
if(!menu){ if(!menu){
g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforTransportLayer"); g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforTransportLayer");
} }
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags & RESOLV_TRANSPORT); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags.transport_name);
} }
static void static void
name_resolution_cb(GtkWidget *w, gpointer d _U_, gint action) name_resolution_cb(GtkWidget *w, gpointer d _U_, gboolean* res_flag)
{ {
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))) { if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))) {
gbl_resolv_flags |= action; *res_flag = TRUE;
} else { } else {
gbl_resolv_flags &= ~action; *res_flag = FALSE;
} }
} }
@ -4889,7 +4889,8 @@ set_menus_for_selected_packet(capture_file *cf)
set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/PrepareaFilter", set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/PrepareaFilter",
frame_selected); frame_selected);
set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName", set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName",
frame_selected && (gbl_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS); frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns));
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowTCPStream", set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowTCPStream",
frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE); frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowUDPStream", set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowUDPStream",
@ -4899,7 +4900,8 @@ set_menus_for_selected_packet(capture_file *cf)
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/DecodeAs", set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/DecodeAs",
frame_selected && decode_as_ok()); frame_selected && decode_as_ok());
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/ResolveName", set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/ResolveName",
frame_selected && (gbl_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS); frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns));
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ToolsMenu/FirewallACLRules", set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ToolsMenu/FirewallACLRules",
frame_selected); frame_selected);
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/TCPStreamGraphMenu", set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/TCPStreamGraphMenu",

View File

@ -75,9 +75,9 @@ man_addr_resolv_ok (GtkWidget *w _U_, gpointer data _U_)
resolv_cb = g_object_get_data (G_OBJECT(man_addr_resolv_dlg), "resolv"); resolv_cb = g_object_get_data (G_OBJECT(man_addr_resolv_dlg), "resolv");
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolv_cb)); active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolv_cb));
if (!(gbl_resolv_flags & RESOLV_NETWORK) && active) { if (!gbl_resolv_flags.network_name && active) {
/* Name resolution for Network Layer activated */ /* Name resolution for Network Layer activated */
gbl_resolv_flags |= RESOLV_NETWORK; gbl_resolv_flags.network_name = TRUE;
menu_name_resolution_changed (); menu_name_resolution_changed ();
redissect = TRUE; redissect = TRUE;
} }
@ -152,8 +152,8 @@ manual_addr_resolv_dlg (GtkWidget *w _U_, gpointer data)
gtk_container_add (GTK_CONTAINER(vbox), sep); gtk_container_add (GTK_CONTAINER(vbox), sep);
resolv_cb = gtk_check_button_new_with_mnemonic ("Enable network name resolution"); resolv_cb = gtk_check_button_new_with_mnemonic ("Enable network name resolution");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(resolv_cb), gbl_resolv_flags & RESOLV_NETWORK); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(resolv_cb), gbl_resolv_flags.network_name);
gtk_widget_set_sensitive (resolv_cb, !(gbl_resolv_flags & RESOLV_NETWORK)); gtk_widget_set_sensitive (resolv_cb, !gbl_resolv_flags.network_name);
gtk_widget_set_tooltip_text(resolv_cb, "Perform network layer name resolution."); gtk_widget_set_tooltip_text(resolv_cb, "Perform network layer name resolution.");
g_object_set_data (G_OBJECT(man_addr_resolv_dlg), "resolv", resolv_cb); g_object_set_data (G_OBJECT(man_addr_resolv_dlg), "resolv", resolv_cb);

View File

@ -2132,7 +2132,7 @@ expand_finfos(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointe
} }
void void
proto_tree_draw_resolve(proto_tree *protocol_tree, GtkWidget *tree_view, guint32 resolv) proto_tree_draw_resolve(proto_tree *protocol_tree, GtkWidget *tree_view, e_addr_resolve resolv)
{ {
ProtoTreeModel *model; ProtoTreeModel *model;

View File

@ -192,7 +192,7 @@ extern GtkWidget * proto_tree_view_new(e_prefs *prefs, GtkWidget **tree_view_p);
*/ */
extern void proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view); extern void proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view);
extern void proto_tree_draw_resolve(proto_tree *protocol_tree, GtkWidget *tree_view, guint32 resolv); extern void proto_tree_draw_resolve(proto_tree *protocol_tree, GtkWidget *tree_view, e_addr_resolve resolv);
/** Expand the whole tree view. /** Expand the whole tree view.
* *

View File

@ -44,12 +44,10 @@
#include "ui/gtk/prefs_column.h" #include "ui/gtk/prefs_column.h"
#include "ui/gtk/prefs_dlg.h" #include "ui/gtk/prefs_dlg.h"
#include "ui/gtk/prefs_filter_expressions.h" #include "ui/gtk/prefs_filter_expressions.h"
#include "ui/gtk/prefs_print.h"
#include "ui/gtk/prefs_stream.h" #include "ui/gtk/prefs_stream.h"
#include "ui/gtk/prefs_gui.h" #include "ui/gtk/prefs_gui.h"
#include "ui/gtk/prefs_layout.h" #include "ui/gtk/prefs_layout.h"
#include "ui/gtk/prefs_capture.h" #include "ui/gtk/prefs_capture.h"
#include "ui/gtk/prefs_nameres.h"
#include "ui/gtk/gui_utils.h" #include "ui/gtk/gui_utils.h"
#include "ui/gtk/dlg_utils.h" #include "ui/gtk/dlg_utils.h"
#include "ui/gtk/stock_icons.h" #include "ui/gtk/stock_icons.h"
@ -95,7 +93,6 @@ static GtkWidget *create_preference_filename_entry(GtkWidget *, int,
#define E_GUI_FONT_PAGE_KEY "gui_font_options_page" #define E_GUI_FONT_PAGE_KEY "gui_font_options_page"
#define E_GUI_COLORS_PAGE_KEY "gui_colors_options_page" #define E_GUI_COLORS_PAGE_KEY "gui_colors_options_page"
#define E_CAPTURE_PAGE_KEY "capture_options_page" #define E_CAPTURE_PAGE_KEY "capture_options_page"
#define E_PRINT_PAGE_KEY "printer_options_page"
#define E_NAMERES_PAGE_KEY "nameres_options_page" #define E_NAMERES_PAGE_KEY "nameres_options_page"
#define E_FILTER_EXPRESSIONS_PAGE_KEY "filter_expressions_page" #define E_FILTER_EXPRESSIONS_PAGE_KEY "filter_expressions_page"
@ -623,18 +620,6 @@ prefs_page_cb(GtkWidget *w _U_, gpointer dummy _U_, PREFS_PAGE_E prefs_page)
prefs_tree_page_add(label_str, cts.page, store, NULL); prefs_tree_page_add(label_str, cts.page, store, NULL);
cts.page++; cts.page++;
/* Name resolution prefs */
g_strlcpy(label_str, "Name Resolution", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, nameres_prefs_show(), E_NAMERES_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, NULL);
cts.page++;
/* Printing prefs */
g_strlcpy(label_str, "Printing", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, printer_prefs_show(), E_PRINT_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, NULL);
cts.page++;
/* Registered prefs */ /* Registered prefs */
cts.notebook = prefs_nb; cts.notebook = prefs_nb;
cts.store = store; cts.store = store;
@ -1346,8 +1331,6 @@ prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
} }
#endif /* _WIN32 */ #endif /* _WIN32 */
#endif /* HAVE_LIBPCAP */ #endif /* HAVE_LIBPCAP */
printer_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_PRINT_PAGE_KEY));
nameres_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_NAMERES_PAGE_KEY));
filter_expressions_prefs_fetch(g_object_get_data(G_OBJECT(dlg), filter_expressions_prefs_fetch(g_object_get_data(G_OBJECT(dlg),
E_FILTER_EXPRESSIONS_PAGE_KEY)); E_FILTER_EXPRESSIONS_PAGE_KEY));
prefs_modules_foreach(module_prefs_fetch, must_redissect); prefs_modules_foreach(module_prefs_fetch, must_redissect);
@ -1383,8 +1366,6 @@ prefs_main_apply_all(GtkWidget *dlg, gboolean redissect)
} }
#endif /* _WIN32 */ #endif /* _WIN32 */
#endif /* HAVE_LIBPCAP */ #endif /* HAVE_LIBPCAP */
printer_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_PRINT_PAGE_KEY));
nameres_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_NAMERES_PAGE_KEY));
/* show/hide the Save button - depending on setting */ /* show/hide the Save button - depending on setting */
save_bt = g_object_get_data(G_OBJECT(prefs_w), E_PREFSW_SAVE_BT_KEY); save_bt = g_object_get_data(G_OBJECT(prefs_w), E_PREFSW_SAVE_BT_KEY);
@ -1425,8 +1406,6 @@ prefs_main_destroy_all(GtkWidget *dlg)
} }
#endif /* _WIN32 */ #endif /* _WIN32 */
#endif /* HAVE_LIBPCAP */ #endif /* HAVE_LIBPCAP */
printer_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_PRINT_PAGE_KEY));
nameres_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_NAMERES_PAGE_KEY));
/* Free up the saved preferences (both for "prefs" and for registered /* Free up the saved preferences (both for "prefs" and for registered
preferences). */ preferences). */

View File

@ -54,7 +54,7 @@ struct proto_tree_model {
int with_hidden; int with_hidden;
gboolean resolv_forced; gboolean resolv_forced;
guint32 resolv_flags; e_addr_resolve resolv_flags;
}; };
#include "proto_tree_model.h" #include "proto_tree_model.h"
@ -202,7 +202,7 @@ proto_tree_model_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint col
{ {
g_value_init(value, G_TYPE_STRING); g_value_init(value, G_TYPE_STRING);
if (model->resolv_forced) { if (model->resolv_forced) {
guint32 old_flags = gbl_resolv_flags; e_addr_resolve old_flags = gbl_resolv_flags;
gbl_resolv_flags = model->resolv_flags; gbl_resolv_flags = model->resolv_flags;
g_value_take_string(value, fi_get_string(fi)); g_value_take_string(value, fi_get_string(fi));
@ -455,7 +455,7 @@ proto_tree_model_get_type(void)
} }
void void
proto_tree_model_force_resolv(ProtoTreeModel *model, guint32 flags) proto_tree_model_force_resolv(ProtoTreeModel *model, e_addr_resolve flags)
{ {
model->resolv_forced = TRUE; model->resolv_forced = TRUE;
model->resolv_flags = flags; model->resolv_flags = flags;

View File

@ -37,6 +37,6 @@ typedef struct proto_tree_model ProtoTreeModel;
GType proto_tree_model_get_type(void); GType proto_tree_model_get_type(void);
ProtoTreeModel *proto_tree_model_new(proto_tree *protocol_tree, int display_hidden_proto_items); ProtoTreeModel *proto_tree_model_new(proto_tree *protocol_tree, int display_hidden_proto_items);
void proto_tree_model_force_resolv(ProtoTreeModel *model, guint32 resolv_flags); void proto_tree_model_force_resolv(ProtoTreeModel *model, e_addr_resolve resolv_flags);
#endif /* __PROTO_TREE_MODEL_H__ */ #endif /* __PROTO_TREE_MODEL_H__ */

View File

@ -1612,11 +1612,11 @@ open_file_hook_proc(HWND of_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
/* Fill in our resolution values */ /* Fill in our resolution values */
cur_ctrl = GetDlgItem(of_hwnd, EWFD_MAC_NR_CB); cur_ctrl = GetDlgItem(of_hwnd, EWFD_MAC_NR_CB);
SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags & RESOLV_MAC, 0); SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags.mac_name, 0);
cur_ctrl = GetDlgItem(of_hwnd, EWFD_NET_NR_CB); cur_ctrl = GetDlgItem(of_hwnd, EWFD_NET_NR_CB);
SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags & RESOLV_NETWORK, 0); SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags.network_name, 0);
cur_ctrl = GetDlgItem(of_hwnd, EWFD_TRANS_NR_CB); cur_ctrl = GetDlgItem(of_hwnd, EWFD_TRANS_NR_CB);
SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags & RESOLV_TRANSPORT, 0); SendMessage(cur_ctrl, BM_SETCHECK, gbl_resolv_flags.transport_name, 0);
preview_set_filename(of_hwnd, NULL); preview_set_filename(of_hwnd, NULL);
break; break;
@ -1630,16 +1630,15 @@ open_file_hook_proc(HWND of_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
dfilter_str = filter_tb_get(cur_ctrl); dfilter_str = filter_tb_get(cur_ctrl);
/* Fetch our resolution values */ /* Fetch our resolution values */
gbl_resolv_flags = prefs.name_resolve & RESOLV_CONCURRENT;
cur_ctrl = GetDlgItem(of_hwnd, EWFD_MAC_NR_CB); cur_ctrl = GetDlgItem(of_hwnd, EWFD_MAC_NR_CB);
if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED) if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
gbl_resolv_flags |= RESOLV_MAC; gbl_resolv_flags.mac_name = TRUE;
cur_ctrl = GetDlgItem(of_hwnd, EWFD_NET_NR_CB); cur_ctrl = GetDlgItem(of_hwnd, EWFD_NET_NR_CB);
if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED) if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
gbl_resolv_flags |= RESOLV_NETWORK; gbl_resolv_flags.network_name = TRUE;
cur_ctrl = GetDlgItem(of_hwnd, EWFD_TRANS_NR_CB); cur_ctrl = GetDlgItem(of_hwnd, EWFD_TRANS_NR_CB);
if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED) if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
gbl_resolv_flags |= RESOLV_TRANSPORT; gbl_resolv_flags.transport_name = TRUE;
break; break;
case CDN_SELCHANGE: case CDN_SELCHANGE:
/* This _almost_ works correctly. We need to handle directory /* This _almost_ works correctly. We need to handle directory