diff --git a/src/include/datastorage.h b/src/include/datastorage.h index 58d83c4..d1576c9 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -203,6 +203,8 @@ int build_hearing_map_sort_client(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 */ // ---------------- Defines ------------------- diff --git a/src/include/ubus.h b/src/include/ubus.h index b06c916..b30fe8d 100644 --- a/src/include/ubus.h +++ b/src/include/ubus.h @@ -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); +int send_set_probe(uint8_t client_addr[]); + #endif diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index 0fe44d0..9d1ba64 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -430,6 +430,8 @@ void kick_clients(uint8_t bssid[], uint32_t id) { // here we should send a messsage to set the probe.count for all aps to the min that there is no delay between switching + send_set_probe(client_array[j].client_addr); + del_client_interface(id, client_array[j].client_addr, 5, 1, 1000); client_array_delete(client_array[j]); @@ -609,7 +611,7 @@ probe_entry probe_array_delete(probe_entry entry) { return tmp; } -int probe_array_set_probe_count(uint8_t bssid_addr[], uint8_t client_addr[], uint32_t probe_count) { +int probe_array_set_all_probe_count(uint8_t client_addr[], uint32_t probe_count) { int updated = 0; @@ -617,14 +619,15 @@ int probe_array_set_probe_count(uint8_t bssid_addr[], uint8_t client_addr[], uin return 0; } - pthread_mutex_lock(&probe_array_mutex); for (int i = 0; i <= probe_entry_last; i++) { - if (mac_is_equal(bssid_addr, probe_array[i].bssid_addr) && - mac_is_equal(client_addr, probe_array[i].client_addr)) { - probe_array[i].signal = rssi; - updated = 1; - ubus_send_probe_via_network(probe_array[i]); + if(mac_is_greater(client_addr, probe_array[i].client_addr)) + { + break; + } + + if (mac_is_equal(client_addr, probe_array[i].client_addr)) { + probe_array[i].counter = probe_count; } } pthread_mutex_unlock(&probe_array_mutex); diff --git a/src/utils/ubus.c b/src/utils/ubus.c index d2b198e..4910338 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -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 blob_attr *msg); +static int handle_set_probe(struct blob_attr *msg); + int hostapd_array_check_id(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; } +static int handle_set_probe(struct blob_attr *msg) { + + hostapd_notify_entry notify_req; + parse_to_hostapd_notify(msg, ¬ify_req); + + client client_entry; + memcpy(client_entry.bssid_addr, client_entry.bssid_addr, sizeof(uint8_t) * ETH_ALEN ); + memcpy(client_entry.client_addr, client_entry.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) { //printf("HANDLING NETWORK MSG: %s\n", msg); @@ -485,6 +501,12 @@ int handle_network_msg(char* msg) } else if (strncmp(method, "deauth", 5) == 0) { printf("METHOD DEAUTH\n"); handle_deauth_req(data_buf.head); + } else if (strncmp(method, "setprobe", 5) == 0) { + printf("SET PROBE!\n"); + handle_set_probe(data_buf.head); + } + + /* hostapd_notify_entry 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); client_array_delete(client_entry); pthread_mutex_unlock(&client_array_mutex);*/ - } + //} //free(method); //free(data); //printf("HANDLING FINISHED NETWORK MSG!\n"); @@ -889,6 +911,20 @@ int ubus_send_probe_via_network(struct probe_entry_s probe_entry) { 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, "set_probe"); + + return 0; +} + enum { MAC_ADDR, __ADD_DEL_MAC_MAX