From ec1a5b15455c2c0bd5535d5257b2513804140747 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 30 Jun 2017 15:57:44 +0200 Subject: iface_lists: select interfaces via command line (option -i) The "wireshark -i lo" option somehow did not mark interfaces as selected. It turns out that the "-i" option populates the "ifaces" array during option parsing, but we must also set the "selected" property in the "all_ifaces" array in function "scan_local_interfaces". Bug: 13865 Fixes: v2.3.0rc0-2812-g40a5fb567a ("Restore interface selection after interface refresh") Change-Id: Iacfeaf14efe2696f37f0e021259c59fb677de435 Reviewed-on: https://code.wireshark.org/review/22478 Reviewed-by: Peter Wu Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- ui/iface_lists.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/iface_lists.c b/ui/iface_lists.c index d60c72903b..5b36104050 100644 --- a/ui/iface_lists.c +++ b/ui/iface_lists.c @@ -57,8 +57,9 @@ if_list_comparator_alph(const void *first_arg, const void *second_arg) /* * Try to populate the given device with options (like capture filter) from * the capture options that are in use for an existing capture interface. + * Returns TRUE if the interface is selected for capture and FALSE otherwise. */ -static void +static gboolean fill_from_ifaces (interface_t *device) { interface_options interface_opts; @@ -82,8 +83,9 @@ fill_from_ifaces (interface_t *device) if (interface_opts.linktype != -1) { device->active_dlt = interface_opts.linktype; } - return; + return TRUE; } + return FALSE; } /* @@ -309,9 +311,9 @@ scan_local_interfaces(void (*update_cb)(void)) #endif /* Copy interface options for active capture devices. */ - fill_from_ifaces(&device); + gboolean selected = fill_from_ifaces(&device); /* Restore device selection (for next capture). */ - if (!device.selected && g_hash_table_lookup(selected_devices, device.name)) { + if (!device.selected && (selected || g_hash_table_lookup(selected_devices, device.name))) { device.selected = TRUE; global_capture_opts.num_selected++; } -- cgit v1.2.1