interface id is 32-bit, not 64-bit.
[obnox/wireshark/wip.git] / capture_ui_utils.c
index c8f9be7dc851ff27db79bb57331bc7e3aac88466..48bca7a31b5d89204d9d4a37e37a86a48b95ee09 100644 (file)
@@ -38,6 +38,9 @@
 #include "epan/ex-opt.h"
 #include "capture_ifinfo.h"
 #include "capture_ui_utils.h"
+#include "ui/simple_dialog.h"
+#include "wiretap/wtap.h"
+#include "epan/to_str.h"
 
 /*
  * Find user-specified capture device description that matches interface
@@ -172,7 +175,7 @@ get_interface_descriptive_name(const char *if_name)
        one from the OS or libpcap? */
     descr = NULL;
     if_list = capture_interface_list(&err, NULL);
-    if (if_list != NULL && if_name != NULL) {
+    if (if_list != NULL) {
       if_entry = if_list;
       do {
         if_info = if_entry->data;
@@ -203,19 +206,19 @@ get_interface_descriptive_name(const char *if_name)
 static if_info_t *
 search_info(GList *if_list, gchar *if_name)
 {
-    GList *if_entry;
-    if_info_t *if_info;
+  GList *if_entry;
+  if_info_t *if_info;
 
 
-    for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
-        if_info = if_entry->data;
+  for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
+    if_info = if_entry->data;
 
-        if(strcmp(if_name, if_info->name) == 0) {
-            return if_info;
-        }
+    if(strcmp(if_name, if_info->name) == 0) {
+      return if_info;
     }
+  }
 
-    return NULL;
+  return NULL;
 }
 
 
@@ -223,32 +226,31 @@ search_info(GList *if_list, gchar *if_name)
 char *
 build_capture_combo_name(GList *if_list, gchar *if_name)
 {
-    gchar *descr;
-    char *if_string;
-    if_info_t *if_info;
-
-
-       /* Do we have a user-supplied description? */
-       descr = capture_dev_user_descr_find(if_name);
-       if (descr != NULL) {
-         /* Yes, we have a user-supplied description; use it. */
-         if_string = g_strdup_printf("%s: %s", descr, if_name);
-         g_free(descr);
-       } else {
-         /* No, we don't have a user-supplied description; did we get
-            one from the OS or libpcap? */
-      if_info = search_info(if_list, if_name);
-         if (if_info && if_info->description != NULL) {
-           /* Yes - use it. */
-           if_string = g_strdup_printf("%s: %s", if_info->description,
-                                       if_info->name);
-         } else {
-           /* No. */
-           if_string = g_strdup(if_name);
-         }
-       }
+  gchar *descr;
+  char *if_string;
+  if_info_t *if_info;
+
+  /* Do we have a user-supplied description? */
+  descr = capture_dev_user_descr_find(if_name);
+  if (descr != NULL) {
+    /* Yes, we have a user-supplied description; use it. */
+    if_string = g_strdup_printf("%s: %s", descr, if_name);
+    g_free(descr);
+  } else {
+    /* No, we don't have a user-supplied description; did we get
+     one from the OS or libpcap? */
+    if_info = search_info(if_list, if_name);
+    if (if_info != NULL && if_info->description != NULL) {
+      /* Yes - use it. */
+      if_string = g_strdup_printf("%s: %s", if_info->description,
+                                  if_info->name);
+    } else {
+      /* No. */
+      if_string = g_strdup(if_name);
+    }
+  }
 
-    return if_string;
+  return if_string;
 }
 
 
@@ -396,17 +398,26 @@ get_if_name(const char *if_text)
   return if_name;
 }
 
-/*  Return capture_opts->iface_descr (after setting it if it is not set)
- *  This is necessary because capture_opts.c can't set iface_descr (at least
+/*  Return interface_opts->descr (after setting it if it is not set)
+ *  This is necessary because capture_opts.c can't set descr (at least
  *  not without adding significant dependencies there).
  */
 const char *
-get_iface_description(capture_options *capture_opts)
+get_iface_description_for_interface(capture_options *capture_opts, guint i)
 {
-       if (!capture_opts->iface_descr && capture_opts->iface)
-               capture_opts->iface_descr = get_interface_descriptive_name(capture_opts->iface);
-
-       return(capture_opts->iface_descr);
-
+  interface_options interface_opts;
+
+  if (i < capture_opts->ifaces->len) {
+    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);
+  } else {
+    return (NULL);
+  }
 }
+
 #endif /* HAVE_LIBPCAP */