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 <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Peter Wu 2017-06-30 15:57:44 +02:00 committed by Michael Mann
parent d30887d289
commit ec1a5b1545
1 changed files with 6 additions and 4 deletions

View File

@ -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++;
}