mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Merge pull request #24 from berlin-open-wireless-lab/hotfix/improve_calculation_function
Hotfix/improve calculation function
This commit is contained in:
commit
488a49475d
2 changed files with 29 additions and 8 deletions
|
@ -133,6 +133,7 @@ int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[], int automat
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mac_is_equal(bssid_addr, probe_array[j].bssid_addr)) {
|
if (mac_is_equal(bssid_addr, probe_array[j].bssid_addr)) {
|
||||||
|
printf("Calculating own score!\n");
|
||||||
own_score = eval_probe_metric(probe_array[j]);
|
own_score = eval_probe_metric(probe_array[j]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -145,17 +146,28 @@ int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[], int automat
|
||||||
|
|
||||||
int k;
|
int k;
|
||||||
for (k = i; k <= probe_entry_last; 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;
|
break;
|
||||||
}
|
}
|
||||||
if (!mac_is_equal(bssid_addr, probe_array[k].bssid_addr) &&
|
|
||||||
own_score <
|
if(mac_is_equal(bssid_addr, probe_array[k].bssid_addr))
|
||||||
eval_probe_metric(probe_array[k])) // that's wrong! find client_entry OR write things in probe array struct!
|
{
|
||||||
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
if ( dawn_metric.use_station_count && !mac_is_equal(bssid_addr, probe_array[k].bssid_addr) &&
|
if (dawn_metric.use_station_count && own_score == score_to_compare)
|
||||||
own_score == eval_probe_metric(probe_array[k]))
|
|
||||||
{
|
{
|
||||||
// if ap have same value but station count is different...
|
// if ap have same value but station count is different...
|
||||||
return compare_station_count(bssid_addr, probe_array[k].bssid_addr, automatic_kick);
|
return compare_station_count(bssid_addr, probe_array[k].bssid_addr, automatic_kick);
|
||||||
|
@ -171,6 +183,10 @@ int kick_client(struct client_s client_entry) {
|
||||||
void kick_clients(uint8_t bssid[], uint32_t id) {
|
void kick_clients(uint8_t bssid[], uint32_t id) {
|
||||||
pthread_mutex_lock(&client_array_mutex);
|
pthread_mutex_lock(&client_array_mutex);
|
||||||
pthread_mutex_lock(&probe_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
|
// Seach for BSSID
|
||||||
int i;
|
int i;
|
||||||
|
@ -200,8 +216,10 @@ void kick_clients(uint8_t bssid[], uint32_t id) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int do_kick = kick_client(client_array[j]);
|
||||||
|
|
||||||
// better ap available
|
// better ap available
|
||||||
if (kick_client(client_array[j]) > 0) {
|
if (do_kick > 0) {
|
||||||
printf("Better AP available. Kicking client:\n");
|
printf("Better AP available. Kicking client:\n");
|
||||||
print_client_entry(client_array[j]);
|
print_client_entry(client_array[j]);
|
||||||
printf("Check if client is active receiving!\n");
|
printf("Check if client is active receiving!\n");
|
||||||
|
@ -228,7 +246,7 @@ void kick_clients(uint8_t bssid[], uint32_t id) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// no entry in probe array for own bssid
|
// 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");
|
printf("No Information about client. Force reconnect:\n");
|
||||||
print_client_entry(client_array[j]);
|
print_client_entry(client_array[j]);
|
||||||
del_client_interface(id, client_array[j].client_addr, 0, 0, 0);
|
del_client_interface(id, client_array[j].client_addr, 0, 0, 0);
|
||||||
|
@ -240,6 +258,8 @@ void kick_clients(uint8_t bssid[], uint32_t id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("---------------------------\n");
|
||||||
|
|
||||||
pthread_mutex_unlock(&probe_array_mutex);
|
pthread_mutex_unlock(&probe_array_mutex);
|
||||||
pthread_mutex_unlock(&client_array_mutex);
|
pthread_mutex_unlock(&client_array_mutex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -619,6 +619,7 @@ static int ubus_get_clients() {
|
||||||
|
|
||||||
void update_clients(struct uloop_timeout *t) {
|
void update_clients(struct uloop_timeout *t) {
|
||||||
ubus_get_clients();
|
ubus_get_clients();
|
||||||
|
// maybe to much?! don't set timer again...
|
||||||
uloop_timeout_set(&client_timer, timeout_config.update_client * 1000);
|
uloop_timeout_set(&client_timer, timeout_config.update_client * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue