diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index ce091d9..25efcb3 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -141,7 +141,6 @@ void kick_clients(uint8_t bssid[], uint32_t id) { int rssi = get_rssi_from_iwinfo(client_array[j].client_addr); if(rssi != INT_MIN) { - printf("UPDATING RSSI!!!\n"); pthread_mutex_unlock(&probe_array_mutex); if(probe_array_update_rssi(client_array[j].bssid_addr, client_array[j].client_addr, rssi)) { @@ -151,16 +150,22 @@ void kick_clients(uint8_t bssid[], uint32_t id) { } + // better ap available if (kick_client(client_array[j]) > 0) { - // TODO: Better debug output - printf("KICKING CLIENT!!!!!!!!!!!!!\n"); + printf("Better AP available. Kicking client:\n"); + print_client_entry(client_array[j]); del_client_interface(id, client_array[j].client_addr, 5, 1, 60000); + + // no entry in probe array for own bssid } else if (kick_client(client_array[j]) == -1) { - printf("Force client to reconnect!!!!!!!!!!!!!\n"); - printf("TRY TO READ RSSI!\n"); - //del_client_interface(id, client_array[j].client_addr, 0, 0, 0); + 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); + + // ap is best } else { - printf("STAAAY CLIENT!!!!!!!!!!!!!\n"); + printf("AP is best. Client will stay:\n"); + print_client_entry(client_array[j]); } } diff --git a/src/utils/rssi.c b/src/utils/rssi.c index 8523849..0e54c93 100644 --- a/src/utils/rssi.c +++ b/src/utils/rssi.c @@ -22,12 +22,11 @@ int get_rssi_from_iwinfo(__uint8_t* client_addr) int call_iwinfo(char* client_addr) { + // TODO: REFACTOR THIS! USE NET LINK... LOOK AT IWINFO + FILE *fp; char path[1035]; - /* Open the command for reading. */ - - // TODO: refactor this int rssi = INT_MIN; int command_length = 68; char iwinfo_command[command_length]; @@ -38,7 +37,6 @@ int call_iwinfo(char* client_addr) iwinfo_command[command_length - 1] = '\0'; printf("iwinfo command:\n%s\n", iwinfo_command); - fp = popen(iwinfo_command, "r"); if (fp == NULL) { printf("Failed to run command\n" ); @@ -65,14 +63,11 @@ int parse_rssi(char* iwinfo_string) int rssi = INT_MIN; if(p_1 != NULL && p_2 != NULL) { - printf("Found substring: %s", p_2); - printf("Length: %d\n", p_2 - p_1); int length = (int) (p_2 - p_1); char dest[length + 1]; memcpy(dest, p_1, (int) (p_2 - p_1)); dest[length] = '\0'; rssi = atoi(dest); - printf("After cutting:\n%s\nInt:%d\n", dest, rssi); } return rssi; } \ No newline at end of file