improve debug msgs

This commit is contained in:
PolynomialDivision 2017-10-23 15:23:12 +02:00
parent 6ac15a5bac
commit c41ff502b4
2 changed files with 14 additions and 14 deletions

View file

@ -141,7 +141,6 @@ void kick_clients(uint8_t bssid[], uint32_t id) {
int rssi = get_rssi_from_iwinfo(client_array[j].client_addr); int rssi = get_rssi_from_iwinfo(client_array[j].client_addr);
if(rssi != INT_MIN) if(rssi != INT_MIN)
{ {
printf("UPDATING RSSI!!!\n");
pthread_mutex_unlock(&probe_array_mutex); pthread_mutex_unlock(&probe_array_mutex);
if(probe_array_update_rssi(client_array[j].bssid_addr, client_array[j].client_addr, rssi)) 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) { if (kick_client(client_array[j]) > 0) {
// TODO: Better debug output printf("Better AP available. Kicking client:\n");
printf("KICKING CLIENT!!!!!!!!!!!!!\n"); print_client_entry(client_array[j]);
del_client_interface(id, client_array[j].client_addr, 5, 1, 60000); 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) { } else if (kick_client(client_array[j]) == -1) {
printf("Force client to reconnect!!!!!!!!!!!!!\n"); printf("No Information about client. Force reconnect:\n");
printf("TRY TO READ RSSI!\n"); 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);
// ap is best
} else { } else {
printf("STAAAY CLIENT!!!!!!!!!!!!!\n"); printf("AP is best. Client will stay:\n");
print_client_entry(client_array[j]);
} }
} }

View file

@ -22,12 +22,11 @@ int get_rssi_from_iwinfo(__uint8_t* client_addr)
int call_iwinfo(char* client_addr) int call_iwinfo(char* client_addr)
{ {
// TODO: REFACTOR THIS! USE NET LINK... LOOK AT IWINFO
FILE *fp; FILE *fp;
char path[1035]; char path[1035];
/* Open the command for reading. */
// TODO: refactor this
int rssi = INT_MIN; int rssi = INT_MIN;
int command_length = 68; int command_length = 68;
char iwinfo_command[command_length]; char iwinfo_command[command_length];
@ -38,7 +37,6 @@ int call_iwinfo(char* client_addr)
iwinfo_command[command_length - 1] = '\0'; iwinfo_command[command_length - 1] = '\0';
printf("iwinfo command:\n%s\n", iwinfo_command); printf("iwinfo command:\n%s\n", iwinfo_command);
fp = popen(iwinfo_command, "r"); fp = popen(iwinfo_command, "r");
if (fp == NULL) { if (fp == NULL) {
printf("Failed to run command\n" ); printf("Failed to run command\n" );
@ -65,14 +63,11 @@ int parse_rssi(char* iwinfo_string)
int rssi = INT_MIN; int rssi = INT_MIN;
if(p_1 != NULL && p_2 != NULL) 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); int length = (int) (p_2 - p_1);
char dest[length + 1]; char dest[length + 1];
memcpy(dest, p_1, (int) (p_2 - p_1)); memcpy(dest, p_1, (int) (p_2 - p_1));
dest[length] = '\0'; dest[length] = '\0';
rssi = atoi(dest); rssi = atoi(dest);
printf("After cutting:\n%s\nInt:%d\n", dest, rssi);
} }
return rssi; return rssi;
} }