From b36b511a1d16206957d2513b52d949fa4abe6835 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Mon, 25 Dec 2017 12:10:44 +0100 Subject: [PATCH] fix station count compare --- src/storage/datastorage.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index f21757e..c45aa2a 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -239,10 +239,20 @@ int compare_station_count(uint8_t *bssid_addr_own, uint8_t *bssid_addr_to_compar && mac_is_equal(ap_entry_to_compre.bssid_addr, bssid_addr_to_compare) ) { printf("Comparing own %d to %d\n", ap_entry_own.station_count, ap_entry_to_compre.station_count); + + if (automatic_kick) { return ((int)ap_entry_own.station_count - 1) > (int)ap_entry_to_compre.station_count; } else { - return (int)ap_entry_own.station_count > (int)ap_entry_to_compre.station_count; + + int sta_count_to_compare = ap_entry_to_compre.station_count; + if(is_connected(bssid_addr_to_compare, client_addr)) + { + printf("IS ALREADY CONNECTED! DECREASE COUNTER!!!\n"); + sta_count_to_compare--; + } + + return (int)ap_entry_own.station_count > sta_count_to_compare; } /* @@ -325,7 +335,7 @@ int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[], int automat if (dawn_metric.use_station_count && own_score == score_to_compare) { // if ap have same value but station count is different... - if (compare_station_count(bssid_addr, probe_array[k].bssid_addr, NULL, automatic_kick)) { + if (compare_station_count(bssid_addr, probe_array[k].bssid_addr, probe_array[k].client_addr, automatic_kick)) { return 1; }