device: Modify signature of device_set_scan_results

WSC was using this to set the scan results.  However it never needed the
autoconnect paths, so modify the signature to make this explicit.
This commit is contained in:
Denis Kenzior 2018-09-01 14:56:33 -05:00
parent 345485c506
commit 977b817f3c
3 changed files with 13 additions and 15 deletions

View File

@ -321,7 +321,8 @@ static bool bss_match(const void *a, const void *b)
* Used when scan results were obtained; either from passive scan running
* inside device.c or active scans running in other state machines, e.g. wsc.c
*/
void device_set_scan_results(struct device *device, struct l_queue *bss_list)
void device_set_scan_results(struct device *device, struct l_queue *bss_list,
bool add_to_autoconnect)
{
struct network *network;
const struct l_queue_entry *bss_entry;
@ -342,13 +343,8 @@ void device_set_scan_results(struct device *device, struct l_queue *bss_list)
struct scan_bss *bss = bss_entry->data;
struct network *network = add_seen_bss(device, bss);
if (!network)
continue;
if (device->state != DEVICE_STATE_AUTOCONNECT)
continue;
add_autoconnect_bss(device, network, bss);
if (network && add_to_autoconnect)
add_autoconnect_bss(device, network, bss);
}
if (device->connected_bss) {
@ -374,9 +370,6 @@ void device_set_scan_results(struct device *device, struct l_queue *bss_list)
l_queue_destroy(device->old_bss_list, bss_free);
device->old_bss_list = NULL;
if (device->state == DEVICE_STATE_AUTOCONNECT)
device_autoconnect_next(device);
}
static bool new_scan_results(uint32_t wiphy_id, uint32_t ifindex, int err,
@ -384,6 +377,7 @@ static bool new_scan_results(uint32_t wiphy_id, uint32_t ifindex, int err,
{
struct device *device = userdata;
struct l_dbus *dbus = dbus_get_bus();
bool autoconnect = device->state == DEVICE_STATE_AUTOCONNECT;
if (device->scanning) {
device->scanning = false;
@ -398,7 +392,10 @@ static bool new_scan_results(uint32_t wiphy_id, uint32_t ifindex, int err,
if (netdev_get_iftype(device->netdev) != NETDEV_IFTYPE_STATION)
return false;
device_set_scan_results(device, bss_list);
device_set_scan_results(device, bss_list, autoconnect);
if (autoconnect)
device_autoconnect_next(device);
return true;
}

View File

@ -53,7 +53,8 @@ uint32_t device_add_state_watch(struct device *device,
device_destroy_func_t destroy);
bool device_remove_state_watch(struct device *device, uint32_t id);
void device_set_scan_results(struct device *device, struct l_queue *bss_list);
void device_set_scan_results(struct device *device, struct l_queue *bss_list,
bool add_to_autoconnect);
struct network *device_network_find(struct device *device, const char *ssid,
enum security security);

View File

@ -666,7 +666,7 @@ static bool push_button_scan_results(uint32_t wiphy_id, uint32_t ifindex,
}
wsc_cancel_scan(wsc);
device_set_scan_results(wsc->device, bss_list);
device_set_scan_results(wsc->device, bss_list, false);
l_debug("Found AP to connect to: %s",
util_address_to_string(target->addr));
@ -813,7 +813,7 @@ static bool pin_scan_results(uint32_t wiphy_id, uint32_t ifindex, int err,
}
wsc_cancel_scan(wsc);
device_set_scan_results(wsc->device, bss_list);
device_set_scan_results(wsc->device, bss_list, false);
l_debug("Found AP to connect to: %s",
util_address_to_string(target->addr));