diff --git a/src/device.c b/src/device.c index d2cfd933..c4b9e56b 100644 --- a/src/device.c +++ b/src/device.c @@ -316,14 +316,9 @@ void device_set_scan_results(struct device *device, struct l_queue *bss_list) struct network *network; const struct l_queue_entry *bss_entry; struct timespec now; - struct l_dbus *dbus = dbus_get_bus(); clock_gettime(CLOCK_REALTIME, &now); - device->scanning = false; - l_dbus_property_changed(dbus, device_get_path(device), - IWD_DEVICE_INTERFACE, "Scanning"); - device->old_bss_list = device->bss_list; device->bss_list = bss_list; @@ -367,12 +362,21 @@ void device_set_scan_results(struct device *device, struct l_queue *bss_list) device_autoconnect_next(device); } -static bool new_scan_results(uint32_t wiphy_id, uint32_t ifindex, +static bool new_scan_results(uint32_t wiphy_id, uint32_t ifindex, int err, struct l_queue *bss_list, void *userdata) { struct device *device = userdata; + struct l_dbus *dbus = dbus_get_bus(); + + device->scanning = false; + l_dbus_property_changed(dbus, device_get_path(device), + IWD_DEVICE_INTERFACE, "Scanning"); + + if (err) + return false; device_set_scan_results(device, bss_list); + return true; } @@ -670,7 +674,7 @@ static void device_roam_scan_triggered(int err, void *user_data) } static bool device_roam_scan_notify(uint32_t wiphy_id, uint32_t ifindex, - struct l_queue *bss_list, + int err, struct l_queue *bss_list, void *userdata) { struct device *device = userdata; @@ -685,6 +689,12 @@ static bool device_roam_scan_notify(uint32_t wiphy_id, uint32_t ifindex, struct timespec now; bool seen = false; + if (err) { + device_roam_failed(device); + + return false; + } + /* * Do not call device_set_scan_results because this may have been * a partial scan. We could at most update the current networks' BSS diff --git a/src/scan.c b/src/scan.c index be490c1e..a1fb4114 100644 --- a/src/scan.c +++ b/src/scan.c @@ -982,7 +982,7 @@ static void get_scan_callback(struct l_genl_msg *msg, void *user_data) } static void scan_finished(struct scan_context *sc, uint32_t wiphy, - struct l_queue *bss_list) + int err, struct l_queue *bss_list) { struct scan_request *sr; scan_notify_func_t callback = NULL; @@ -1014,13 +1014,9 @@ static void scan_finished(struct scan_context *sc, uint32_t wiphy, sc->sp.triggered = false; } - if (callback) { - if (!bss_list) - bss_list = l_queue_new(); - - new_owner = callback(wiphy, sc->ifindex, + if (callback) + new_owner = callback(wiphy, sc->ifindex, err, bss_list, userdata); - } if (destroy) destroy(userdata); @@ -1045,7 +1041,7 @@ static void get_scan_done(void *user) sc = l_queue_find(scan_contexts, scan_context_match, L_UINT_TO_PTR(results->ifindex)); if (sc) - scan_finished(sc, results->wiphy, results->bss_list); + scan_finished(sc, results->wiphy, 0, results->bss_list); else l_queue_destroy(results->bss_list, (l_queue_destroy_func_t) scan_bss_free); @@ -1173,7 +1169,7 @@ static void scan_notify(struct l_genl_msg *msg, void *user_data) break; case NL80211_CMD_SCAN_ABORTED: - scan_finished(sc, attr_wiphy, NULL); + scan_finished(sc, attr_wiphy, -ECANCELED, NULL); break; } diff --git a/src/scan.h b/src/scan.h index d656d476..1a323655 100644 --- a/src/scan.h +++ b/src/scan.h @@ -33,7 +33,7 @@ enum scan_state { typedef void (*scan_func_t)(struct l_genl_msg *msg, void *user_data); typedef void (*scan_trigger_func_t)(int, void *); -typedef bool (*scan_notify_func_t)(uint32_t wiphy, uint32_t ifindex, +typedef bool (*scan_notify_func_t)(uint32_t wiphy, uint32_t ifindex, int err, struct l_queue *bss_list, void *userdata); typedef void (*scan_destroy_func_t)(void *userdata); diff --git a/src/wsc.c b/src/wsc.c index 5c84f77a..64d0673a 100644 --- a/src/wsc.c +++ b/src/wsc.c @@ -554,7 +554,8 @@ static void pin_timeout(struct l_timeout *timeout, void *user_data) } static bool push_button_scan_results(uint32_t wiphy_id, uint32_t ifindex, - struct l_queue *bss_list, void *userdata) + int err, struct l_queue *bss_list, + void *userdata) { struct wsc *wsc = userdata; struct scan_bss *bss_2g; @@ -565,6 +566,14 @@ static bool push_button_scan_results(uint32_t wiphy_id, uint32_t ifindex, const struct l_queue_entry *bss_entry; struct wsc_probe_response probe_response; + if (err) { + wsc_cancel_scan(wsc); + dbus_pending_reply(&wsc->pending, + dbus_error_failed(wsc->pending)); + + return false; + } + bss_2g = NULL; bss_5g = NULL; @@ -702,7 +711,7 @@ static bool authorized_macs_contains(const uint8_t *authorized_macs, return false; } -static bool pin_scan_results(uint32_t wiphy_id, uint32_t ifindex, +static bool pin_scan_results(uint32_t wiphy_id, uint32_t ifindex, int err, struct l_queue *bss_list, void *userdata) { static const uint8_t wildcard_address[] = @@ -712,6 +721,14 @@ static bool pin_scan_results(uint32_t wiphy_id, uint32_t ifindex, const struct l_queue_entry *bss_entry; struct wsc_probe_response probe_response; + if (err) { + wsc_cancel_scan(wsc); + dbus_pending_reply(&wsc->pending, + dbus_error_failed(wsc->pending)); + + return false; + } + wsc->scan_id = 0; for (bss_entry = l_queue_get_entries(bss_list); bss_entry;