Do not use functions for remote capture on local interfaces.
[obnox/wireshark/wip.git] / gtk / capture_dlg.c
index 2e5ef7e7713516f90c20c69797c8532ad6d554d2..52bfaa8be87810dffbffe33fa511d6bd0c52a337 100644 (file)
@@ -185,7 +185,7 @@ capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
 static void
 capture_prep_interface_changed_cb(GtkWidget *entry, gpointer parent_w);
 
-static void
+static gboolean
 capture_dlg_prep(gpointer parent_w);
 
 
@@ -288,7 +288,19 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
     /*
      * Try to get the list of known interfaces.
      */
+#ifdef HAVE_PCAP_REMOTE
+    if (global_capture_opts.src_type == CAPTURE_IFREMOTE)
+      if_list = get_remote_interface_list(global_capture_opts.remote_host,
+                                         global_capture_opts.remote_port,
+                                         global_capture_opts.auth_type,
+                                         global_capture_opts.auth_username,
+                                         global_capture_opts.auth_password,
+                                         &err, NULL);
+    else
+      if_list = capture_interface_list(&err, NULL);
+#else
     if_list = capture_interface_list(&err, NULL);
+#endif
     if (if_list != NULL) {
       /*
        * We have the list - check it.
@@ -671,7 +683,7 @@ update_interface_list()
                         global_capture_opts.auth_password,
                         &err, &err_str);
     else
-        if_list = get_interface_list(&err, &err_str);
+        if_list = capture_interface_list(&err, &err_str);
 
     if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
         simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
@@ -1005,7 +1017,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
                     global_capture_opts.auth_password,
                     &err, &err_str);
   else
-      if_list = get_interface_list(&err, &err_str);
+      if_list = capture_interface_list(&err, &err_str);
 #else
   if_list = capture_interface_list(&err, &err_str);
 #endif
@@ -1103,6 +1115,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
   gtk_box_pack_start(GTK_BOX(capture_vb), if_ip_hb, FALSE, FALSE, 0);
 
   if_ip_eb = gtk_event_box_new();
+  gtk_event_box_set_visible_window (GTK_EVENT_BOX(if_ip_eb), FALSE);
   gtk_box_pack_start(GTK_BOX(if_ip_hb), if_ip_eb, TRUE, TRUE, 6);
   gtk_tooltips_set_tip(tooltips, if_ip_eb, "Lists the IP address(es) "
                       "assigned to the selected interface.  If there are "
@@ -1863,16 +1876,25 @@ capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
   }
 #endif
 
-  /* get the values and close the options dialog */
   if(cap_open_w) {
-    capture_dlg_prep(cap_open_w);
+    /*
+     * There's an options dialog; get the values from it and close it.
+     */
+    gboolean success;
+
+    success = capture_dlg_prep(cap_open_w);
     window_destroy(GTK_WIDGET(cap_open_w));
+    if (!success)
+      return;  /* error in options dialog */
   }
 
   if (global_capture_opts.iface == NULL) {
-    gchar *if_device = g_strdup(prefs.capture_device);
-    if_name = g_strdup(get_if_name(if_device));
-    g_free (if_device);
+    if (prefs.capture_device == NULL) {
+      simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+        "You didn't specify an interface on which to capture packets.");
+      return;
+    }
+    if_name = g_strdup(get_if_name(prefs.capture_device));
   } else {
     if_name = g_strdup(global_capture_opts.iface);
   }
@@ -1956,7 +1978,7 @@ capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
 
 
 /* convert dialog settings into capture_opts values */
-static void
+static gboolean
 capture_dlg_prep(gpointer parent_w) {
   GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te, *filter_cm,
             *file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
@@ -2044,7 +2066,7 @@ capture_dlg_prep(gpointer parent_w) {
     simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
       "You didn't specify an interface on which to capture packets.");
     g_free(entry_text);
-    return;
+    return FALSE;
   }
   if (global_capture_opts.iface)
     g_free(global_capture_opts.iface);
@@ -2212,7 +2234,7 @@ capture_dlg_prep(gpointer parent_w) {
           "%sMultiple files: Requested filesize too large!%s\n\n"
           "The setting \"Next file every x byte(s)\" can't be greater than %u bytes (2GB).", 
           simple_dialog_primary_start(), simple_dialog_primary_end(), G_MAXINT);
-        return;
+        return FALSE;
       }
     }
 
@@ -2222,7 +2244,7 @@ capture_dlg_prep(gpointer parent_w) {
         "%sMultiple files: No capture file name given!%s\n\n"
         "You must specify a filename if you want to use multiple files.",
         simple_dialog_primary_start(), simple_dialog_primary_end());
-      return;
+      return FALSE;
     } else if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
       simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
         "%sMultiple files: No file limit given!%s\n\n"
@@ -2231,7 +2253,7 @@ capture_dlg_prep(gpointer parent_w) {
         simple_dialog_primary_start(), simple_dialog_primary_end());
       g_free(global_capture_opts.save_file);
       global_capture_opts.save_file = NULL;
-      return;
+      return FALSE;
     }
   } else {
     global_capture_opts.has_autostop_filesize =
@@ -2246,10 +2268,11 @@ capture_dlg_prep(gpointer parent_w) {
           "%sStop Capture: Requested filesize too large!%s\n\n"
           "The setting \"... after x byte(s)\" can't be greater than %u bytes (2GB).", 
           simple_dialog_primary_start(), simple_dialog_primary_end(), G_MAXINT);
-        return;
+        return FALSE;
       }
     }
   } /* multi_files_on */
+  return TRUE;
 }
 
 /* user requested to destroy the dialog */