Merge branch 'master' into feature/use_notify

This commit is contained in:
PolynomialDivision 2017-12-30 15:28:49 +01:00
commit 966619612e
6 changed files with 82 additions and 11 deletions

View file

@ -13,7 +13,7 @@ config hostapd
config times config times
option update_client '10' option update_client '10'
option remove_client '120' option remove_client '15'
option remove_probe '120' option remove_probe '120'
option remove_ap '460' option remove_ap '460'
option update_hostapd '10' option update_hostapd '10'
@ -24,7 +24,7 @@ config metric
option no_ht_support '0' option no_ht_support '0'
option no_vht_support '0' option no_vht_support '0'
option rssi '0' option rssi '0'
option low_rssi '0' option low_rssi '-500'
option freq '100' option freq '100'
option chan_util '0' option chan_util '0'
option max_chan_util '0' option max_chan_util '0'

View file

@ -1,2 +0,0 @@
a4:2b:b0:de:f1:fd
f0:79:60:1c:26:f0

View file

@ -203,6 +203,8 @@ int build_hearing_map_sort_client(struct blob_buf *b);
int build_network_overview(struct blob_buf *b); int build_network_overview(struct blob_buf *b);
int probe_array_set_all_probe_count(uint8_t client_addr[], uint32_t probe_count);
/* Utils */ /* Utils */
// ---------------- Defines ------------------- // ---------------- Defines -------------------

View file

@ -40,4 +40,6 @@ int send_blob_attr_via_network(struct blob_attr *msg, char* method);
void blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const uint8_t *addr); void blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const uint8_t *addr);
int send_set_probe(uint8_t client_addr[]);
#endif #endif

View file

@ -190,6 +190,7 @@ int build_network_overview(struct blob_buf *b)
int k; int k;
sprintf(ap_mac_buf, MACSTR, MAC2STR(client_array[i].bssid_addr)); sprintf(ap_mac_buf, MACSTR, MAC2STR(client_array[i].bssid_addr));
ap_list = blobmsg_open_table(b, ap_mac_buf); ap_list = blobmsg_open_table(b, ap_mac_buf);
printf("AP MAC BUF: %s\n", ap_mac_buf);
for (k = i; i <= client_entry_last; k++){ for (k = i; i <= client_entry_last; k++){
if(!mac_is_equal(client_array[k].bssid_addr, client_array[i].bssid_addr)) if(!mac_is_equal(client_array[k].bssid_addr, client_array[i].bssid_addr))
{ {
@ -232,6 +233,9 @@ int eval_probe_metric(struct probe_entry_s probe_entry) {
score += (probe_entry.signal >= dawn_metric.rssi_val) ? dawn_metric.rssi : 0; score += (probe_entry.signal >= dawn_metric.rssi_val) ? dawn_metric.rssi : 0;
score += (probe_entry.signal <= dawn_metric.low_rssi_val) ? dawn_metric.low_rssi : 0; score += (probe_entry.signal <= dawn_metric.low_rssi_val) ? dawn_metric.low_rssi : 0;
if(score < 0)
score = 0;
printf("SCORE: %d of:\n", score); printf("SCORE: %d of:\n", score);
print_probe_entry(probe_entry); print_probe_entry(probe_entry);
@ -427,6 +431,11 @@ void kick_clients(uint8_t bssid[], uint32_t id) {
} }
printf("Client is probably NOT in active transmisison. KICK! RxRate is: %f\n", rx_rate); printf("Client is probably NOT in active transmisison. KICK! RxRate is: %f\n", rx_rate);
// here we should send a messsage to set the probe.count for all aps to the min that there is no delay between switching
// the hearing map is full...
send_set_probe(client_array[j].client_addr);
del_client_interface(id, client_array[j].client_addr, 5, 1, 1000); del_client_interface(id, client_array[j].client_addr, 5, 1, 1000);
client_array_delete(client_array[j]); client_array_delete(client_array[j]);
@ -542,7 +551,7 @@ client *client_array_delete(client entry) {
} }
} }
for (int j = i; j <= client_entry_last; j++) { for (int j = i; j < client_entry_last; j++) {
client_array[j] = client_array[j + 1]; client_array[j] = client_array[j + 1];
} }
@ -596,7 +605,7 @@ probe_entry probe_array_delete(probe_entry entry) {
} }
} }
for (int j = i; j <= probe_entry_last; j++) { for (int j = i; j < probe_entry_last; j++) {
probe_array[j] = probe_array[j + 1]; probe_array[j] = probe_array[j + 1];
} }
@ -606,6 +615,30 @@ probe_entry probe_array_delete(probe_entry entry) {
return tmp; return tmp;
} }
int probe_array_set_all_probe_count(uint8_t client_addr[], uint32_t probe_count) {
int updated = 0;
if (probe_entry_last == -1) {
return 0;
}
pthread_mutex_lock(&probe_array_mutex);
for (int i = 0; i <= probe_entry_last; i++) {
if (mac_is_equal(client_addr, probe_array[i].client_addr)) {
printf("SETTING MAC!!!\n");
probe_array[i].counter = probe_count;
}else if(!mac_is_greater(client_addr, probe_array[i].client_addr))
{
printf("MAC NOT FOUND!!!\n");
break;
}
}
pthread_mutex_unlock(&probe_array_mutex);
return updated;
}
int probe_array_update_rssi(uint8_t bssid_addr[], uint8_t client_addr[], uint32_t rssi) { int probe_array_update_rssi(uint8_t bssid_addr[], uint8_t client_addr[], uint32_t rssi) {
int updated = 0; int updated = 0;
@ -765,7 +798,7 @@ ap ap_array_delete(ap entry) {
} }
} }
for (int j = i; j <= ap_entry_last; j++) { for (int j = i; j < ap_entry_last; j++) {
ap_array[j] = ap_array[j + 1]; ap_array[j] = ap_array[j + 1];
} }
@ -776,7 +809,7 @@ ap ap_array_delete(ap entry) {
} }
void remove_old_client_entries(time_t current_time, long long int threshold) { void remove_old_client_entries(time_t current_time, long long int threshold) {
for (int i = 0; i < client_entry_last; i++) { for (int i = 0; i <= client_entry_last; i++) {
if (client_array[i].time < current_time - threshold) { if (client_array[i].time < current_time - threshold) {
client_array_delete(client_array[i]); client_array_delete(client_array[i]);
} }
@ -784,7 +817,7 @@ void remove_old_client_entries(time_t current_time, long long int threshold) {
} }
void remove_old_probe_entries(time_t current_time, long long int threshold) { void remove_old_probe_entries(time_t current_time, long long int threshold) {
for (int i = 0; i < probe_entry_last; i++) { for (int i = 0; i <= probe_entry_last; i++) {
if (probe_array[i].time < current_time - threshold) { if (probe_array[i].time < current_time - threshold) {
if (!is_connected(probe_array[i].bssid_addr, probe_array[i].client_addr)) if (!is_connected(probe_array[i].bssid_addr, probe_array[i].client_addr))
probe_array_delete(probe_array[i]); probe_array_delete(probe_array[i]);
@ -793,7 +826,7 @@ void remove_old_probe_entries(time_t current_time, long long int threshold) {
} }
void remove_old_ap_entries(time_t current_time, long long int threshold) { void remove_old_ap_entries(time_t current_time, long long int threshold) {
for (int i = 0; i < ap_entry_last; i++) { for (int i = 0; i <= ap_entry_last; i++) {
if (ap_array[i].time < current_time - threshold) { if (ap_array[i].time < current_time - threshold) {
ap_array_delete(ap_array[i]); ap_array_delete(ap_array[i]);
} }

View file

@ -181,6 +181,8 @@ static int get_network(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct ubus_request_data *req, const char *method,
struct blob_attr *msg); struct blob_attr *msg);
static int handle_set_probe(struct blob_attr *msg);
int hostapd_array_check_id(uint32_t id); int hostapd_array_check_id(uint32_t id);
void hostapd_array_insert(uint32_t id); void hostapd_array_insert(uint32_t id);
@ -425,6 +427,20 @@ static int handle_deauth_req(struct blob_attr *msg) {
return 0; return 0;
} }
static int handle_set_probe(struct blob_attr *msg) {
hostapd_notify_entry notify_req;
parse_to_hostapd_notify(msg, &notify_req);
client client_entry;
memcpy(client_entry.bssid_addr, notify_req.bssid_addr, sizeof(uint8_t) * ETH_ALEN );
memcpy(client_entry.client_addr, notify_req.client_addr, sizeof(uint8_t) * ETH_ALEN );
probe_array_set_all_probe_count(client_entry.client_addr, dawn_metric.min_probe_count);
return 0;
}
int handle_network_msg(char* msg) int handle_network_msg(char* msg)
{ {
//printf("HANDLING NETWORK MSG: %s\n", msg); //printf("HANDLING NETWORK MSG: %s\n", msg);
@ -485,6 +501,12 @@ int handle_network_msg(char* msg)
} else if (strncmp(method, "deauth", 5) == 0) { } else if (strncmp(method, "deauth", 5) == 0) {
printf("METHOD DEAUTH\n"); printf("METHOD DEAUTH\n");
handle_deauth_req(data_buf.head); handle_deauth_req(data_buf.head);
} else if (strncmp(method, "setprobe", 5) == 0) {
printf("HANDLING SET PROBE!\n");
handle_set_probe(data_buf.head);
}
/* /*
hostapd_notify_entry entry; hostapd_notify_entry entry;
parse_to_hostapd_notify(data_buf.head, &entry); parse_to_hostapd_notify(data_buf.head, &entry);
@ -496,7 +518,7 @@ int handle_network_msg(char* msg)
pthread_mutex_lock(&client_array_mutex); pthread_mutex_lock(&client_array_mutex);
client_array_delete(client_entry); client_array_delete(client_entry);
pthread_mutex_unlock(&client_array_mutex);*/ pthread_mutex_unlock(&client_array_mutex);*/
} //}
//free(method); //free(method);
//free(data); //free(data);
//printf("HANDLING FINISHED NETWORK MSG!\n"); //printf("HANDLING FINISHED NETWORK MSG!\n");
@ -891,6 +913,20 @@ int ubus_send_probe_via_network(struct probe_entry_s probe_entry) {
return 0; return 0;
} }
int send_set_probe(uint8_t client_addr[])
{
printf("SENDING SET PROBE VIA NETWORK!\n");
blob_buf_init(&b_probe, 0);
blobmsg_add_macaddr(&b_probe, "bssid", client_addr);
blobmsg_add_macaddr(&b_probe, "address", client_addr);
send_blob_attr_via_network(b_probe.head, "setprobe");
return 0;
}
enum { enum {
MAC_ADDR, MAC_ADDR,
__ADD_DEL_MAC_MAX __ADD_DEL_MAC_MAX