When capturing from multiple interfaces, indicate this in the window

title of the wireshark main window.

svn path=/trunk/; revision=37289
This commit is contained in:
Michael Tüxen 2011-05-19 12:19:03 +00:00
parent 1d19739c9f
commit 307d7e8c3c
4 changed files with 45 additions and 4 deletions

View File

@ -133,6 +133,7 @@ gboolean
capture_start(capture_options *capture_opts)
{
gboolean ret;
guint i;
GString *source = g_string_new("");
if (capture_opts->state != CAPTURE_STOPPED)
@ -144,9 +145,32 @@ capture_start(capture_options *capture_opts)
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ...");
g_string_printf(source, "%s", get_iface_description(capture_opts));
if(capture_opts->cfilter && capture_opts->cfilter[0]) {
g_string_append_printf(source, " (%s)", capture_opts->cfilter);
#ifdef _WIN32
if (capture_opts->ifaces->len < 2) {
#else
if (capture_opts->ifaces->len < 4) {
#endif
for (i = 0; i < capture_opts->ifaces->len; i++) {
interface_options interface_opts;
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
if (i > 0) {
if (capture_opts->ifaces->len > 2) {
g_string_append_printf(source, ",");
}
g_string_append_printf(source, " ");
if (i == capture_opts->ifaces->len - 1) {
g_string_append_printf(source, "and ");
}
}
g_string_append_printf(source, "%s", get_iface_description_for_interface(capture_opts, i));
if ((interface_opts.cfilter != NULL) &&
(strlen(interface_opts.cfilter) > 0)) {
g_string_append_printf(source, " (%s)", interface_opts.cfilter);
}
}
} else {
g_string_append_printf(source, "%u interfaces", capture_opts->ifaces->len);
}
cf_set_tempfile_source(capture_opts->cf, source->str);
g_string_free(source, TRUE);

View File

@ -408,4 +408,20 @@ get_iface_description(capture_options *capture_opts)
return(capture_opts->iface_descr);
}
const char *
get_iface_description_for_interface(capture_options *capture_opts, guint i)
{
interface_options interface_opts;
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
if (!interface_opts.descr && interface_opts.name) {
interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
}
capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, i);
g_array_insert_val(capture_opts->ifaces, i, interface_opts);
return (interface_opts.descr);
}
#endif /* HAVE_LIBPCAP */

View File

@ -97,5 +97,6 @@ char *build_capture_combo_name(GList *if_list, gchar *if_name);
* @return A pointer to capture_ops->iface_descr
*/
const char *get_iface_description(capture_options *capture_opts);
const char *get_iface_description_for_interface(capture_options *capture_opts, guint i);
#endif

View File

@ -1522,7 +1522,7 @@ main_capture_set_main_window_title(capture_options *capture_opts)
GString *title = g_string_new("");
g_string_append(title, "Capturing ");
if(capture_opts->iface) {
if (capture_opts->ifaces->len > 0) {
g_string_append_printf(title, "from %s ", cf_get_tempfile_source(capture_opts->cf));
}
set_main_window_name(title->str);