Add a few more menu items.
[obnox/wireshark/wip.git] / capture.c
index e45fde9313d2282c82334eb9cf83c3e724aca9d6..22bab8dd94b53a246ae6843af4b578e1b703c499 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -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);
@@ -469,20 +493,27 @@ capture_input_error_message(capture_options *capture_opts, char *error_msg, char
    capture filter when starting/running the capture.
  */
 void
-capture_input_cfilter_error_message(capture_options *capture_opts, char *error_message)
+capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char *error_message)
 {
-  dfilter_t   *rfcode = NULL;
-  gchar *safe_cfilter = simple_dialog_format_message(capture_opts->cfilter);
-  gchar *safe_cfilter_error_msg = simple_dialog_format_message(error_message);
+  dfilter_t *rfcode = NULL;
+  gchar *safe_cfilter;
+  gchar *safe_descr;
+  gchar *safe_cfilter_error_msg;
+  interface_options interface_opts;
 
   g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture filter error message from child: \"%s\"", error_message);
 
   g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
+  g_assert(i < capture_opts->ifaces->len);
 
+  interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
+  safe_cfilter = simple_dialog_format_message(interface_opts.cfilter);
+  safe_descr = simple_dialog_format_message(interface_opts.descr);
+  safe_cfilter_error_msg = simple_dialog_format_message(error_message);
   /* Did the user try a display filter? */
-  if (dfilter_compile(capture_opts->cfilter, &rfcode) && rfcode != NULL) {
+  if (dfilter_compile(interface_opts.cfilter, &rfcode) && rfcode != NULL) {
     simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-      "%sInvalid capture filter: \"%s\"!%s\n"
+      "%sInvalid capture filter \"%s\" for interface %s!%s\n"
       "\n"
       "That string looks like a valid display filter; however, it isn't a valid\n"
       "capture filter (%s).\n"
@@ -491,19 +522,20 @@ capture_input_cfilter_error_message(capture_options *capture_opts, char *error_m
       "so you can't use most display filter expressions as capture filters.\n"
       "\n"
       "See the User's Guide for a description of the capture filter syntax.",
-      simple_dialog_primary_start(), safe_cfilter,
+      simple_dialog_primary_start(), safe_cfilter, safe_descr,
       simple_dialog_primary_end(), safe_cfilter_error_msg);
       dfilter_free(rfcode);
   } else {
     simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-      "%sInvalid capture filter: \"%s\"!%s\n"
+      "%sInvalid capture filter \"%s\" for interface %s!%s\n"
       "\n"
       "That string isn't a valid capture filter (%s).\n"
       "See the User's Guide for a description of the capture filter syntax.",
-      simple_dialog_primary_start(), safe_cfilter,
+      simple_dialog_primary_start(), safe_cfilter, safe_descr,
       simple_dialog_primary_end(), safe_cfilter_error_msg);
   }
   g_free(safe_cfilter_error_msg);
+  g_free(safe_descr);
   g_free(safe_cfilter);
 
   /* the capture child will close the sync_pipe if required, nothing to do for now */
@@ -581,6 +613,7 @@ capture_input_closed(capture_options *capture_opts, gchar *msg)
           /* Exit by leaving the main loop, so that any quit functions
              we registered get called. */
           main_window_quit();
+         break;
         }
 
     } else {
@@ -663,9 +696,11 @@ capture_stat_start(GList *if_list) {
         /* Initialize the cache */
         for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
             if_info = if_entry->data;
-            sc_item = g_malloc0(sizeof(if_stat_cache_item_t));
-            sc_item->name = g_strdup(if_info->name);
-            sc->cache_list = g_list_append(sc->cache_list, sc_item);
+            if (if_info) {
+                sc_item = g_malloc0(sizeof(if_stat_cache_item_t));
+                sc_item->name = g_strdup(if_info->name);
+                sc->cache_list = g_list_append(sc->cache_list, sc_item);
+            }
         }
     }
     return sc;