Hide hidden devices in "Capture Interfaces" dialog.
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 31 Jan 2008 16:47:05 +0000 (16:47 +0000)
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 31 Jan 2008 16:47:05 +0000 (16:47 +0000)
Added a function to check for hidden devices, which also work correctly
for plumbed devices on solaris.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24231 f5534014-38df-0310-8fa8-9805f1628bb7

capture_ui_utils.c
epan/libwireshark.def
epan/prefs.c
epan/prefs.h
gtk/capture_if_dlg.c

index aaa20eeb79b86acd6756deaa9ea821b35221307a..0c58a0ccd1cbfc0973649660435f89e03b6a1ebb 100644 (file)
@@ -226,9 +226,7 @@ build_capture_combo_list(GList *if_list, gboolean do_hide)
 
       /* Is this interface hidden and, if so, should we include it
          anyway? */
-      if (prefs.capture_devices_hide == NULL ||
-         strstr(prefs.capture_devices_hide, if_info->name) == NULL ||
-         !do_hide) {
+      if (!prefs_is_capture_device_hidden(if_info->name) || !do_hide) {
        /* It's not hidden, or it is but we should include it in the list. */
 
        /* Do we have a user-supplied description? */
index 55e6ed71111a34f86d3cc76bb2372aa25e2f3880..d15de9d97b9ac7e6d3039d3dbf0e05002e8786d2 100644 (file)
@@ -560,6 +560,7 @@ postseq_cleanup_all_protocols
 prefs                           DATA
 prefs_apply
 prefs_apply_all
+prefs_is_capture_device_hidden
 prefs_find_module
 prefs_get_title_by_name
 prefs_is_registered_protocol
index e57f4646890a86bc4993a00b8069de4a273dade0..c5591d52b314dea083d02bf03369e7e69132b57d 100644 (file)
@@ -1555,6 +1555,30 @@ prefs_set_pref(char *prefarg)
        return ret;
 }
 
+/*
+ * Returns TRUE if the given device is hidden
+ */
+gboolean
+prefs_is_capture_device_hidden(const char *name)
+{
+       gchar *tok, *devices;
+       size_t len;
+
+       if (prefs.capture_devices_hide && name) {
+               devices = g_strdup (prefs.capture_devices_hide);
+               len = strlen (name);
+               for (tok = strtok (devices, ","); tok; tok = strtok(NULL, ",")) {
+                       if (strlen (tok) == len && strcmp (name, tok) == 0) {
+                               g_free (devices);
+                               return TRUE;
+                       }
+               }
+               g_free (devices);
+       }
+
+       return FALSE;
+}
+
 #define PRS_PRINT_FMT                    "print.format"
 #define PRS_PRINT_DEST                   "print.destination"
 #define PRS_PRINT_FILE                   "print.file"
index 1d4af9713e393afd73fdb6790faae68efe4ba799..b3397aff5a9eca303b2ce601a35fabd10c8bcd1a 100644 (file)
@@ -417,4 +417,9 @@ typedef enum {
 
 extern prefs_set_pref_e prefs_set_pref(char *prefarg);
 
+/*
+ * Returns TRUE if the given device is hidden
+ */
+extern gboolean prefs_is_capture_device_hidden(const char *name);
+
 #endif /* prefs.h */
index 53ea74f31655eb0eb798609d1c11146e4f612e0c..073433ace829033bffa0ec8393c73875ac3c7404 100644 (file)
@@ -528,6 +528,12 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
   for(ifs = 0; (curr = g_list_nth(if_list, ifs)); ifs++) {
       g_string_assign(if_tool_str, "");
       if_info = curr->data;
+
+      /* Continue if capture device is hidden */
+      if (prefs_is_capture_device_hidden(if_info->name)) {
+          continue;
+      }
+
       if_dlg_data = g_malloc0(sizeof(if_dlg_data_t));
       if_dlg_data->if_info = *if_info;