aboutsummaryrefslogtreecommitdiffstats
path: root/ui/iface_lists.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2015-12-02 09:13:40 +0100
committerStig Bjørlykke <stig@bjorlykke.org>2015-12-02 11:33:24 +0000
commit92a2661d949b1fed78affd87c6e80b537ce49dfe (patch)
tree448cebb1d9c2169087b7d6e3d3c20022487b518d /ui/iface_lists.c
parent631172f2f4046255a78a5628b5499f38054039bb (diff)
ui: Update interfaces when when changing profile.
The interfaces preferences are different for each profile so ensure we update the interface settings when changing profile. This bug was introduced in version 1.8.0. Change-Id: Icf22670875e01bab6204c300ddc7fb8aeb3dcecf Reviewed-on: https://code.wireshark.org/review/12363 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'ui/iface_lists.c')
-rw-r--r--ui/iface_lists.c71
1 files changed, 50 insertions, 21 deletions
diff --git a/ui/iface_lists.c b/ui/iface_lists.c
index bd8dd4a905..be9c8bfaf1 100644
--- a/ui/iface_lists.c
+++ b/ui/iface_lists.c
@@ -54,6 +54,33 @@ if_list_comparator_alph(const void *first_arg, const void *second_arg)
}
}
+static void
+fill_from_ifaces (interface_t *device)
+{
+ interface_options interface_opts;
+ guint i;
+
+ for (i = 0; i < global_capture_opts.ifaces->len; i++) {
+ interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
+ if (strcmp(interface_opts.name, device->name) != 0) {
+ continue;
+ }
+
+#if defined(HAVE_PCAP_CREATE)
+ device->buffer = interface_opts.buffer_size;
+ device->monitor_mode_enabled = interface_opts.monitor_mode;
+#endif
+ device->pmode = interface_opts.promisc_mode;
+ device->has_snaplen = interface_opts.has_snaplen;
+ device->snaplen = interface_opts.snaplen;
+ device->cfilter = g_strdup(interface_opts.cfilter);
+ if (interface_opts.linktype != -1) {
+ device->active_dlt = interface_opts.linktype;
+ }
+ return;
+ }
+}
+
/*
* Fetch the list of local interfaces with capture_interface_list()
* and set the list of "all interfaces" in *capture_opts to include
@@ -257,27 +284,7 @@ scan_local_interfaces(void (*update_cb)(void))
}
#endif
- if (global_capture_opts.ifaces->len > 0) {
- for (j = 0; j < global_capture_opts.ifaces->len; j++) {
- interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j);
- if (strcmp(interface_opts.name, device.name) == 0) {
-#if defined(HAVE_PCAP_CREATE)
- device.buffer = interface_opts.buffer_size;
- device.monitor_mode_enabled = interface_opts.monitor_mode;
-#endif
- device.pmode = interface_opts.promisc_mode;
- device.has_snaplen = interface_opts.has_snaplen;
- device.snaplen = interface_opts.snaplen;
- device.cfilter = g_strdup(interface_opts.cfilter);
- if (interface_opts.linktype != -1) {
- device.active_dlt = interface_opts.linktype;
- }
- device.selected = TRUE;
- global_capture_opts.num_selected++;
- break;
- }
- }
- }
+ fill_from_ifaces(&device);
#ifdef HAVE_EXTCAP
/* Extcap devices start with no cached args */
@@ -415,6 +422,28 @@ hide_interface(gchar* new_hide)
g_list_free(hidden_devices);
g_free(new_hide);
}
+
+void
+update_local_interfaces(void)
+{
+ interface_t device;
+ gchar *descr;
+ guint i;
+
+ for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
+ device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
+ device.type = capture_dev_user_linktype_find(device.name);
+ g_free (device.display_name);
+ descr = capture_dev_user_descr_find(device.name);
+ device.display_name = get_iface_display_name(descr, &device.if_info);
+ g_free (descr);
+ device.hidden = prefs_is_capture_device_hidden(device.name);
+ fill_from_ifaces(&device);
+
+ global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
+ g_array_insert_val(global_capture_opts.all_ifaces, i, device);
+ }
+}
#endif /* HAVE_LIBPCAP */
/*