-static void notify_bss_changes(struct wpa_supplicant *wpa_s,
- u8 (*prev_bssids)[ETH_ALEN], int prev_num,
- struct wpa_scan_results *new)
-{
- int new_num, i, j;
-
- new_num = new != NULL ? new->num : 0;
- if (prev_bssids == NULL)
- prev_num = 0;
-
- for (i = 0; i < prev_num; i++) {
- for (j = 0; j < new_num; j++) {
- if (!os_memcmp(prev_bssids[i], new->res[j]->bssid,
- ETH_ALEN))
- break;
- }
- if (j == new_num)
- wpas_notify_bss_removed(wpa_s, prev_bssids[i]);
- }
- for (i = 0; i < new_num; i++) {
- for (j = 0; j < prev_num; j++) {
- if (!os_memcmp(new->res[i]->bssid, prev_bssids[j],
- ETH_ALEN))
- break;
- }
- if (j == prev_num)
- wpas_notify_bss_added(wpa_s, new->res[i]->bssid);
- }
-}
-
-
-/**
- * wpa_supplicant_get_scan_results - Get scan results
- * @wpa_s: Pointer to wpa_supplicant data
- * Returns: 0 on success, -1 on failure
- *
- * This function is request the current scan results from the driver and stores
- * a local copy of the results in wpa_s->scan_res.
- */
-int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s)
-{
- int ret, i, prev_scan_res_num;
- u8 (*prev_scan_bssids)[ETH_ALEN];
-
- prev_scan_res_num = wpa_s->scan_res ? wpa_s->scan_res->num : 0;
- prev_scan_bssids = os_malloc(prev_scan_res_num * ETH_ALEN);
-
- if (prev_scan_bssids) {
- for (i = 0; i < prev_scan_res_num; i++) {
- os_memcpy(prev_scan_bssids[i],
- wpa_s->scan_res->res[i]->bssid, ETH_ALEN);
- }
- } else {
- wpa_printf(MSG_WARNING, "Not enough memory for old scan "
- "results list");
- prev_scan_res_num = 0;
- }
-
- wpa_scan_results_free(wpa_s->scan_res);
- if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
- wpa_s->scan_res = ieee80211_sta_get_scan_results(wpa_s);
- else
- wpa_s->scan_res = wpa_drv_get_scan_results2(wpa_s);
- if (wpa_s->scan_res == NULL) {
- wpa_printf(MSG_DEBUG, "Failed to get scan results");
- ret = -1;
- } else {
- ret = 0;
- wpa_scan_sort_results(wpa_s->scan_res);
- }
-
- notify_bss_changes(wpa_s, prev_scan_bssids, prev_scan_res_num,
- wpa_s->scan_res);
- os_free(prev_scan_bssids);
-
- return ret;
-}
-
-