From 9569a87ca5c36423be7e38c9925cb42ba0d32ae1 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 19 Dec 2017 10:48:59 +0100 Subject: [PATCH 1/3] add debug msgs --- src/storage/datastorage.c | 6 ++++++ src/utils/ubus.c | 1 + 2 files changed, 7 insertions(+) diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index 2dd33de..1cbcf86 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -171,6 +171,10 @@ int kick_client(struct client_s client_entry) { void kick_clients(uint8_t bssid[], uint32_t id) { pthread_mutex_lock(&client_array_mutex); pthread_mutex_lock(&probe_array_mutex); + printf("-------- KICKING CLIENS!!!---------\n"); + char mac_buf_ap[20]; + sprintf(mac_buf_ap, MACSTR, MAC2STR(bssid)); + printf("EVAL %s\n", mac_buf_ap); // Seach for BSSID int i; @@ -240,6 +244,8 @@ void kick_clients(uint8_t bssid[], uint32_t id) { } } + printf("---------------------------\n"); + pthread_mutex_unlock(&probe_array_mutex); pthread_mutex_unlock(&client_array_mutex); } diff --git a/src/utils/ubus.c b/src/utils/ubus.c index bd2ada9..5017262 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -619,6 +619,7 @@ static int ubus_get_clients() { void update_clients(struct uloop_timeout *t) { ubus_get_clients(); + // maybe to much?! don't set timer again... uloop_timeout_set(&client_timer, timeout_config.update_client * 1000); } From 8b1d45a80de7194fbf499b10f0123bf6344d8a7a Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 19 Dec 2017 13:21:28 +0100 Subject: [PATCH 2/3] improve device function --- files/dawn.config | 2 +- src/storage/datastorage.c | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/files/dawn.config b/files/dawn.config index a204eb8..74f0c5e 100644 --- a/files/dawn.config +++ b/files/dawn.config @@ -32,6 +32,6 @@ config settings metric option low_rssi_val '-80' option chan_util_val '140' option max_chan_util_val '170' - option min_probe_count '4' + option min_probe_count '0' option bandwith_threshold '6' option use_station_count '1' diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index 1cbcf86..2149cfa 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -133,6 +133,7 @@ int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[], int automat break; } if (mac_is_equal(bssid_addr, probe_array[j].bssid_addr)) { + printf("Calculating own score!\n"); own_score = eval_probe_metric(probe_array[j]); break; } @@ -145,17 +146,28 @@ int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[], int automat int k; for (k = i; k <= probe_entry_last; k++) { - if (!mac_is_equal(probe_array[k].client_addr, client_addr)) { + int score_to_compare; + + if (!mac_is_equal(probe_array[k].client_addr, client_addr)) + { break; } - if (!mac_is_equal(bssid_addr, probe_array[k].bssid_addr) && - own_score < - eval_probe_metric(probe_array[k])) // that's wrong! find client_entry OR write things in probe array struct! + + if(mac_is_equal(bssid_addr, probe_array[k].bssid_addr)) + { + printf("Own Score! Skipping!\n"); + print_probe_entry(probe_array[k]); + continue; + } + + printf("Calculating score to compare!\n"); + score_to_compare = eval_probe_metric(probe_array[k]); + + if(own_score < score_to_compare) { return 1; } - if ( dawn_metric.use_station_count && !mac_is_equal(bssid_addr, probe_array[k].bssid_addr) && - own_score == eval_probe_metric(probe_array[k])) + if (dawn_metric.use_station_count && own_score == score_to_compare) { // if ap have same value but station count is different... return compare_station_count(bssid_addr, probe_array[k].bssid_addr, automatic_kick); @@ -204,8 +216,10 @@ void kick_clients(uint8_t bssid[], uint32_t id) { } + int do_kick = kick_client(client_array[j]); + // better ap available - if (kick_client(client_array[j]) > 0) { + if (do_kick > 0) { printf("Better AP available. Kicking client:\n"); print_client_entry(client_array[j]); printf("Check if client is active receiving!\n"); @@ -232,7 +246,7 @@ void kick_clients(uint8_t bssid[], uint32_t id) { break; // no entry in probe array for own bssid - } else if (kick_client(client_array[j]) == -1) { + } else if (do_kick == -1) { printf("No Information about client. Force reconnect:\n"); print_client_entry(client_array[j]); del_client_interface(id, client_array[j].client_addr, 0, 0, 0); From c22b499e0ce0a7a4f18682427ccb615e7108d428 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 19 Dec 2017 13:49:37 +0100 Subject: [PATCH 3/3] reset files/ --- files/dawn.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/dawn.config b/files/dawn.config index 74f0c5e..a204eb8 100644 --- a/files/dawn.config +++ b/files/dawn.config @@ -32,6 +32,6 @@ config settings metric option low_rssi_val '-80' option chan_util_val '140' option max_chan_util_val '170' - option min_probe_count '0' + option min_probe_count '4' option bandwith_threshold '6' option use_station_count '1'