summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/prefs.c20
-rw-r--r--epan/prefs.h2
-rw-r--r--gtk/main.c28
-rw-r--r--gtk/prefs_dlg.c22
-rw-r--r--gtk/prefs_rtp_player.c59
-rw-r--r--gtk/prefs_rtp_player.h8
6 files changed, 97 insertions, 42 deletions
diff --git a/epan/prefs.c b/epan/prefs.c
index e5429433ec..b6a641af5d 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -1189,7 +1189,8 @@ init_prefs(void) {
prefs.name_resolve = RESOLV_ALL ^ RESOLV_NETWORK;
prefs.name_resolve_concurrency = 500;
-/* set the default values for the rtp player dialog box */
+/* set the default values for the tap/statistics dialog box */
+ prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
prefs.display_hidden_proto_items = FALSE;
@@ -1564,7 +1565,7 @@ prefs_set_pref(char *prefarg)
*colonp = ':';
return PREFS_SET_SYNTAX_ERR;
}
- if (strcmp(prefarg, "uat")) {
+ if (strcmp(prefarg, "uat")) {
ret = set_pref(prefarg, p, NULL);
} else {
ret = prefs_set_uat_pref(p) ? PREFS_SET_OK : PREFS_SET_SYNTAX_ERR;
@@ -1672,7 +1673,8 @@ prefs_is_capture_device_hidden(const char *name)
#define BLUE_COMPONENT(x) (guint16) ( (((x) & 0xff) * 65535 / 255))
/* values for the rtp player preferences dialog box */
-#define PRS_RTP_PLAYER_MAX_VISIBLE "rtp_player.max_visible"
+#define PRS_TAP_UPDATE_INTERVAL "taps.update_interval"
+#define PRS_RTP_PLAYER_MAX_VISIBLE "taps.rtp_player_max_visible"
#define PRS_DISPLAY_HIDDEN_PROTO_ITEMS "packet_list.display_hidden_proto_items"
@@ -2080,8 +2082,12 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
}
} else if (strcmp(pref_name, PRS_NAME_RESOLVE_CONCURRENCY) == 0) {
prefs.name_resolve_concurrency = strtol(value, NULL, 10);
- } else if (strcmp(pref_name, PRS_RTP_PLAYER_MAX_VISIBLE) == 0) {
+ } else if ((strcmp(pref_name, PRS_RTP_PLAYER_MAX_VISIBLE) == 0) ||
+ (strcmp(pref_name, "rtp_player.max_visible") == 0)) {
+ /* ... also accepting old name for this preference */
prefs.rtp_player_max_visible = strtol(value, NULL, 10);
+ } else if (strcmp(pref_name, PRS_TAP_UPDATE_INTERVAL) == 0) {
+ prefs.tap_update_interval = strtol(value, NULL, 10);
} else if (strcmp(pref_name, PRS_DISPLAY_HIDDEN_PROTO_ITEMS) == 0) {
prefs.display_hidden_proto_items = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
} else {
@@ -2852,8 +2858,12 @@ write_prefs(char **pf_path_return)
fprintf(pf, PRS_NAME_RESOLVE_CONCURRENCY ": %d\n",
prefs.name_resolve_concurrency);
- fprintf(pf, "\n####### RTP Player ########\n");
+ fprintf(pf, "\n####### Taps/Statistics ########\n");
+ fprintf(pf, "\n# Tap update interval in ms.\n");
+ fprintf(pf, "# An integer value greater between 100 and 10000.\n");
+ fprintf(pf, PRS_TAP_UPDATE_INTERVAL ": %d\n",
+ prefs.tap_update_interval);
fprintf(pf, "\n# Maximum visible channels in RTP Player window.\n");
fprintf(pf, "# An integer value greater than 0.\n");
fprintf(pf, PRS_RTP_PLAYER_MAX_VISIBLE ": %d\n",
diff --git a/epan/prefs.h b/epan/prefs.h
index 778bb03e48..e544a9915e 100644
--- a/epan/prefs.h
+++ b/epan/prefs.h
@@ -40,6 +40,7 @@
#define MAX_VAL_LEN 1024
#define RTP_PLAYER_DEFAULT_VISIBLE 4
+#define TAP_UPDATE_DEFAULT_INTERVAL 3000
/*
* Convert a string listing name resolution types to a bitmask of
@@ -148,6 +149,7 @@ typedef struct _e_prefs {
gboolean capture_auto_scroll;
gboolean capture_show_info;
guint rtp_player_max_visible;
+ guint tap_update_interval;
gboolean display_hidden_proto_items;
} e_prefs;
diff --git a/gtk/main.c b/gtk/main.c
index add5721731..635c9fe648 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -200,6 +200,8 @@ int airpcap_dll_ret_val = -1;
GString *comp_info_str, *runtime_info_str;
gboolean have_capture_file = FALSE; /* XXX - is there an equivalent in cfile? */
+guint tap_update_timer_id;
+
#ifdef _WIN32
static gboolean has_console; /* TRUE if app has console */
static void destroy_console(void);
@@ -1071,6 +1073,16 @@ update_cb(gpointer data _U_)
draw_tap_listeners(FALSE);
return 1;
}
+
+/* Restart the tap update display timer with new configured interval */
+void reset_tap_update_timer(void)
+{
+#if defined(_WIN32) || ! defined USE_THREADS
+ gtk_timeout_remove(tap_update_timer_id);
+ tap_update_timer_id = gtk_timeout_add(prefs.tap_update_interval, (GtkFunction)update_cb,(gpointer)NULL);
+#endif
+}
+
#else
/* if these three functions are copied to gtk1 Wireshark, since gtk1 does not
@@ -1094,13 +1106,16 @@ update_thread(gpointer data _U_)
g_static_mutex_unlock(&update_thread_mutex);
g_thread_yield();
g_get_current_time(&tv2);
- if( ((tv1.tv_sec + 2) * 1000000 + tv1.tv_usec) >
+
+ /* Assuming it took less than configured time to update tap listeners... */
+ if( (tv1.tv_sec * 1000000 + tv1.tv_usec + prefs.tap_update_interval * 1000) >
(tv2.tv_sec * 1000000 + tv2.tv_usec) ){
- g_usleep(((tv1.tv_sec + 2) * 1000000 + tv1.tv_usec) -
+ /* Wait for remainder of configured time */
+ g_usleep((tv1.tv_sec * 1000000 + tv1.tv_usec + prefs.tap_update_interval * 1000) -
(tv2.tv_sec * 1000000 + tv2.tv_usec));
}
- }
- return NULL;
+
+ return NULL;
}
#endif
void
@@ -1994,6 +2009,8 @@ main(int argc, char *argv[])
We must do that before we read the preferences as well. */
prefs_register_modules();
+ prefs = read_configuration_files (&gdp_path, &dp_path);
+
/* multithread support currently doesn't seem to work in win32 gtk2.0.6 */
#if !defined(_WIN32) && defined(G_THREADS_ENABLED) && defined USE_THREADS
{
@@ -2005,7 +2022,7 @@ main(int argc, char *argv[])
}
#else /* !_WIN32 && G_THREADS_ENABLED && USE_THREADS */
/* this is to keep tap extensions updating once every 3 seconds */
- gtk_timeout_add(3000, (GtkFunction)update_cb,(gpointer)NULL);
+ tap_update_timer_id = gtk_timeout_add(prefs->tap_update_interval, (GtkFunction)update_cb,(gpointer)NULL);
#endif /* !_WIN32 && G_THREADS_ENABLED && USE_THREADS */
#if HAVE_GNU_ADNS
@@ -2014,7 +2031,6 @@ main(int argc, char *argv[])
splash_update(RA_CONFIGURATION, NULL, (gpointer)splash_win);
- prefs = read_configuration_files (&gdp_path, &dp_path);
/* Read the (static part) of the recent file. Only the static part of it will be read, */
/* as we don't have the gui now to fill the recent lists which is done in the dynamic part. */
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 16b1ab3fc5..49f2a4cdc8 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -96,7 +96,7 @@ static void prefs_tree_select_cb(GtkTreeSelection *, gpointer);
#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_RTP_PLAYER_PAGE_KEY "rtp_player_options_page"
+#define E_TAPS_PAGE_KEY "taps_options_page"
#define E_PROTOCOLS_PAGE_KEY "protocols_options_page"
/*
@@ -586,13 +586,11 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
prefs_tree_page_add(label_str, cts.page, store, NULL, FALSE);
cts.page++;
-#ifdef HAVE_LIBPORTAUDIO
- /* RTP player prefs */
- g_strlcpy(label_str, "RTP Player", MAX_TREE_NODE_NAME_LEN);
- prefs_nb_page_add(prefs_nb, label_str, rtp_player_prefs_show(), E_RTP_PLAYER_PAGE_KEY);
+ /* TAPS player prefs */
+ g_strlcpy(label_str, "Taps/Statistics", MAX_TREE_NODE_NAME_LEN);
+ prefs_nb_page_add(prefs_nb, label_str, stats_prefs_show(), E_TAPS_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, NULL, FALSE);
cts.page++;
-#endif
/* Registered prefs */
cts.notebook = prefs_nb;
@@ -1264,9 +1262,7 @@ prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
#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));
-#ifdef HAVE_LIBPORTAUDIO
- rtp_player_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_RTP_PLAYER_PAGE_KEY));
-#endif
+ stats_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_TAPS_PAGE_KEY));
protocols_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_PROTOCOLS_PAGE_KEY));
prefs_modules_foreach(module_prefs_fetch, must_redissect);
@@ -1303,9 +1299,7 @@ prefs_main_apply_all(GtkWidget *dlg, gboolean redissect)
#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));
-#ifdef HAVE_LIBPORTAUDIO
- rtp_player_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_RTP_PLAYER_PAGE_KEY));
-#endif
+ stats_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_TAPS_PAGE_KEY));
protocols_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_PROTOCOLS_PAGE_KEY));
/* show/hide the Save button - depending on setting */
@@ -1349,9 +1343,7 @@ prefs_main_destroy_all(GtkWidget *dlg)
#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));
-#ifdef HAVE_LIBPORTAUDIO
- rtp_player_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_RTP_PLAYER_PAGE_KEY));
-#endif
+ stats_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_TAPS_PAGE_KEY));
/* Free up the saved preferences (both for "prefs" and for registered
preferences). */
diff --git a/gtk/prefs_rtp_player.c b/gtk/prefs_rtp_player.c
index e9f7599fc7..8323c2b10c 100644
--- a/gtk/prefs_rtp_player.c
+++ b/gtk/prefs_rtp_player.c
@@ -1,5 +1,5 @@
-/* rtp_player_prefs.c
- * Dialog box for RTP player preferences
+/* tap_prefs.c
+ * Dialog box for tap/statistics preferences
*
* $Id$
*
@@ -34,17 +34,25 @@
#include "gtk/prefs_rtp_player.h"
#include "gtk/prefs_dlg.h"
+#define TAP_UPDATE_INTERVAL_KEY "update_interval"
-#define RTP_PLAYER_MAX_VISIBLE_KEY "max_visible"
+#define RTP_PLAYER_MAX_VISIBLE_KEY "rtp_player_max_visible"
#define RTP_PLAYER_TABLE_ROWS 6
+static char update_interval_str[128] = "";
static char max_visible_str[128] = "";
+extern void reset_tap_update_timer(void);
+
GtkWidget*
-rtp_player_prefs_show(void)
+stats_prefs_show(void)
{
GtkWidget *main_tb, *main_vb;
+ GtkWidget *tap_update_interval_te;
+#ifdef HAVE_LIBPORTAUDIO
GtkWidget *rtp_player_max_visible_te;
+#endif
+
GtkTooltips *tooltips = gtk_tooltips_new();
int pos = 0;
@@ -53,14 +61,25 @@ rtp_player_prefs_show(void)
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
/* Main table */
- main_tb = gtk_table_new(RTP_PLAYER_TABLE_ROWS, 1, FALSE);
+ main_tb = gtk_table_new(RTP_PLAYER_TABLE_ROWS, 2, FALSE);
gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
gtk_widget_show(main_tb);
g_object_set_data(G_OBJECT(main_tb), E_TOOLTIPS_KEY, tooltips);
- /* Max visable channels in RTP Player */
+ /* Tap update gap in ms */
+ tap_update_interval_te = create_preference_entry(main_tb, pos++,
+ "Tap update interval in ms:",
+ "Determines time between tap updates.", max_visible_str);
+ g_snprintf(update_interval_str, 128, "%d", prefs.tap_update_interval);
+ gtk_entry_set_text(GTK_ENTRY(tap_update_interval_te), update_interval_str);
+ gtk_tooltips_set_tip(tooltips, tap_update_interval_te,
+ "Gap in milliseconds between updates to taps is defined here", NULL);
+ g_object_set_data(G_OBJECT(main_vb), TAP_UPDATE_INTERVAL_KEY, tap_update_interval_te);
+
+#ifdef HAVE_LIBPORTAUDIO
+ /* Max visible channels in RTP Player */
rtp_player_max_visible_te = create_preference_entry(main_tb, pos++,
"Max visible channels in RTP Player:",
"Determines maximum height of RTP Player window.", max_visible_str);
@@ -69,6 +88,7 @@ rtp_player_prefs_show(void)
gtk_tooltips_set_tip(tooltips, rtp_player_max_visible_te,
"Maximum height of RTP Player window is defined here.", NULL);
g_object_set_data(G_OBJECT(main_vb), RTP_PLAYER_MAX_VISIBLE_KEY, rtp_player_max_visible_te);
+#endif
/* Show 'em what we got */
gtk_widget_show_all(main_vb);
@@ -77,28 +97,43 @@ rtp_player_prefs_show(void)
}
void
-rtp_player_prefs_fetch(GtkWidget *w _U_)
+stats_prefs_fetch(GtkWidget *w _U_)
{
+ GtkWidget *tap_update_interval_te;
+#ifdef HAVE_LIBPORTAUDIO
GtkWidget *rtp_player_max_visible_te;
+#endif
- rtp_player_max_visible_te = (GtkWidget *)g_object_get_data(G_OBJECT(w), RTP_PLAYER_MAX_VISIBLE_KEY);
+ /* Tap update interval */
+ tap_update_interval_te = (GtkWidget *)g_object_get_data(G_OBJECT(w), TAP_UPDATE_INTERVAL_KEY);
+ prefs.tap_update_interval = strtol(gtk_entry_get_text(
+ GTK_ENTRY(tap_update_interval_te)), NULL, 10);
+
+ /* Test for a sane tap update interval */
+ if (prefs.tap_update_interval < 100 || prefs.tap_update_interval > 10000) {
+ prefs.tap_update_interval = 3000;
+ }
+#ifdef HAVE_LIBPORTAUDIO
+ /* Max RTP channels */
+ rtp_player_max_visible_te = (GtkWidget *)g_object_get_data(G_OBJECT(w), RTP_PLAYER_MAX_VISIBLE_KEY);
prefs.rtp_player_max_visible = strtol(gtk_entry_get_text(
GTK_ENTRY(rtp_player_max_visible_te)), NULL, 10);
- /* Test for a minimum sane max channels */
-
+ /* Test for a sane max channels entry */
if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
+#endif
}
void
-rtp_player_prefs_apply(GtkWidget *w _U_)
+stats_prefs_apply(GtkWidget *w _U_)
{
+ reset_tap_update_timer();
}
void
-rtp_player_prefs_destroy(GtkWidget *w _U_)
+stats_prefs_destroy(GtkWidget *w _U_)
{
}
diff --git a/gtk/prefs_rtp_player.h b/gtk/prefs_rtp_player.h
index 2b0e4be110..c879efe075 100644
--- a/gtk/prefs_rtp_player.h
+++ b/gtk/prefs_rtp_player.h
@@ -34,24 +34,24 @@
*
* @return the new preferences page
*/
-GtkWidget *rtp_player_prefs_show(void);
+GtkWidget *stats_prefs_show(void);
/** Fetch preference values from page.
*
* @param widget widget from rtp_player_prefs_show()
*/
-void rtp_player_prefs_fetch(GtkWidget *widget);
+void stats_prefs_fetch(GtkWidget *widget);
/** Apply preference values from page.
*
* @param widget widget from rtp_player_prefs_show()
*/
-void rtp_player_prefs_apply(GtkWidget *widget);
+void stats_prefs_apply(GtkWidget *widget);
/** Destroy preference values from page.
*
* @param widget widget from rtp_player_prefs_show()
*/
-void rtp_player_prefs_destroy(GtkWidget *widget);
+void stats_prefs_destroy(GtkWidget *widget);
#endif