aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/wnm_sta.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2014-11-22 14:33:57 (GMT)
committerJouni Malinen <j@w1.fi>2014-11-22 16:06:37 (GMT)
commitff2c5758bb404feabd69b68b4754e96120b6b863 (patch)
treee65c412bbc1cc838b46e960b7b5acf5476eb29ab /wpa_supplicant/wnm_sta.c
parent093226783dc78a7c80af516f2fe76909bda8b400 (diff)
downloadhostap-ff2c5758bb404feabd69b68b4754e96120b6b863.zip
hostap-ff2c5758bb404feabd69b68b4754e96120b6b863.tar.gz
hostap-ff2c5758bb404feabd69b68b4754e96120b6b863.tar.bz2
WNM: Order BSS transmission candidate entries based on preference
Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/wnm_sta.c')
-rw-r--r--wpa_supplicant/wnm_sta.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c
index 8dea07a..7b6a6cb 100644
--- a/wpa_supplicant/wnm_sta.c
+++ b/wpa_supplicant/wnm_sta.c
@@ -586,6 +586,35 @@ send_bss_resp_fail:
}
+static int cand_pref_compar(const void *a, const void *b)
+{
+ const struct neighbor_report *aa = a;
+ const struct neighbor_report *bb = b;
+
+ if (!aa->preference_present && !bb->preference_present)
+ return 0;
+ if (!aa->preference_present)
+ return 1;
+ if (!bb->preference_present)
+ return -1;
+ if (bb->preference > aa->preference)
+ return 1;
+ if (bb->preference < aa->preference)
+ return -1;
+ return 0;
+}
+
+
+static void wnm_sort_cand_list(struct wpa_supplicant *wpa_s)
+{
+ if (!wpa_s->wnm_neighbor_report_elements)
+ return;
+ qsort(wpa_s->wnm_neighbor_report_elements,
+ wpa_s->wnm_num_neighbor_report, sizeof(struct neighbor_report),
+ cand_pref_compar);
+}
+
+
static void wnm_dump_cand_list(struct wpa_supplicant *wpa_s)
{
unsigned int i;
@@ -707,6 +736,7 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
pos += len;
wpa_s->wnm_num_neighbor_report++;
}
+ wnm_sort_cand_list(wpa_s);
wnm_dump_cand_list(wpa_s);
valid_ms = valid_int * beacon_int * 128 / 125;
wpa_printf(MSG_DEBUG, "WNM: Candidate list valid for %u ms",