From 8cc3f0b0c5f468916027d5e5ef0ef4b4948b2455 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 26 Dec 2017 14:55:16 +0100 Subject: [PATCH 1/8] bla --- src/storage/datastorage.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index be06846..0fe44d0 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -427,6 +427,9 @@ void kick_clients(uint8_t bssid[], uint32_t id) { } 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 + del_client_interface(id, client_array[j].client_addr, 5, 1, 1000); client_array_delete(client_array[j]); @@ -606,6 +609,29 @@ 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 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(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]); + } + } + 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 updated = 0; From fbc3659920eb09f1985da6ee169fcb4813237627 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 26 Dec 2017 19:22:31 +0100 Subject: [PATCH 2/8] add set probecount --- src/include/datastorage.h | 2 ++ src/include/ubus.h | 2 ++ src/storage/datastorage.c | 17 ++++++++++------- src/utils/ubus.c | 38 +++++++++++++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 8 deletions(-) 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 From 08f22537f015ec2d3c23b848d83fe51278ad3546 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 26 Dec 2017 20:29:37 +0100 Subject: [PATCH 3/8] fix setprobe --- src/utils/ubus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 4910338..7845fc3 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -920,7 +920,7 @@ int send_set_probe(uint8_t client_addr[]) 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"); + send_blob_attr_via_network(b_probe.head, "setprobe"); return 0; } From e8b43ebbb60452f9768974214ae41a4bc8b7dd7f Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 26 Dec 2017 21:58:43 +0100 Subject: [PATCH 4/8] test set function --- src/storage/datastorage.c | 10 +++++----- src/utils/ubus.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index 9d1ba64..8ff6693 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -621,13 +621,13 @@ int probe_array_set_all_probe_count(uint8_t client_addr[], uint32_t probe_count) pthread_mutex_lock(&probe_array_mutex); for (int i = 0; i <= probe_entry_last; i++) { - if(mac_is_greater(client_addr, probe_array[i].client_addr)) - { - break; - } - 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); diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 7845fc3..0c8fd28 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -415,8 +415,8 @@ static int handle_deauth_req(struct blob_attr *msg) { 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 ); + 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 ); pthread_mutex_lock(&client_array_mutex); client_array_delete(client_entry); @@ -433,8 +433,11 @@ static int handle_set_probe(struct blob_attr *msg) { 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 ); + 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 ); + + printf("SETTING CLIENT MACS ENTRY!!!!\n"); + print_client_entry(client_entry); probe_array_set_all_probe_count(client_entry.client_addr, dawn_metric.min_probe_count); @@ -502,7 +505,7 @@ int handle_network_msg(char* msg) printf("METHOD DEAUTH\n"); handle_deauth_req(data_buf.head); } else if (strncmp(method, "setprobe", 5) == 0) { - printf("SET PROBE!\n"); + printf("HANDLING SET PROBE!\n"); handle_set_probe(data_buf.head); } @@ -981,6 +984,24 @@ static int get_hearing_map(struct ubus_context *ctx, struct ubus_object *obj, build_hearing_map_sort_client(&b); ubus_send_reply(ctx, req, b.head); + + int tmp_int_mac[ETH_ALEN]; + uint8_t tmp_mac[ETH_ALEN]; + sscanf("10:0B:A9:6D:33:90", MACSTR, STR2MAC(tmp_int_mac)); + for (int i = 0; i < ETH_ALEN; ++i) + tmp_mac[i] = (uint8_t) tmp_int_mac[i]; + + char mac_buf_target[20]; + sprintf(mac_buf_target, MACSTR, MAC2STR(tmp_mac)); + printf("SETTING PROBE COUNT OF MAC!!! %s\n", mac_buf_target); + + + + printf("SENDING MAP!\n"); + + + send_set_probe(tmp_mac); + return 0; } From 0d5c1bef11886d51f5c26d72280d039621e91814 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 26 Dec 2017 23:46:44 +0100 Subject: [PATCH 5/8] remove debug --- src/storage/datastorage.c | 2 +- src/utils/ubus.c | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index 8ff6693..e9636e3 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -429,7 +429,7 @@ 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 - + // 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); diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 0c8fd28..eb3d0b2 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -436,9 +436,6 @@ static int handle_set_probe(struct blob_attr *msg) { 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 ); - printf("SETTING CLIENT MACS ENTRY!!!!\n"); - print_client_entry(client_entry); - probe_array_set_all_probe_count(client_entry.client_addr, dawn_metric.min_probe_count); return 0; @@ -984,24 +981,6 @@ static int get_hearing_map(struct ubus_context *ctx, struct ubus_object *obj, build_hearing_map_sort_client(&b); ubus_send_reply(ctx, req, b.head); - - int tmp_int_mac[ETH_ALEN]; - uint8_t tmp_mac[ETH_ALEN]; - sscanf("10:0B:A9:6D:33:90", MACSTR, STR2MAC(tmp_int_mac)); - for (int i = 0; i < ETH_ALEN; ++i) - tmp_mac[i] = (uint8_t) tmp_int_mac[i]; - - char mac_buf_target[20]; - sprintf(mac_buf_target, MACSTR, MAC2STR(tmp_mac)); - printf("SETTING PROBE COUNT OF MAC!!! %s\n", mac_buf_target); - - - - printf("SENDING MAP!\n"); - - - send_set_probe(tmp_mac); - return 0; } From 9f969e41acc19a5a6c29e166abc2fde825c6af78 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Fri, 29 Dec 2017 22:28:51 +0100 Subject: [PATCH 6/8] update remove clients to 15 --- files/dawn.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/dawn.config b/files/dawn.config index 5feddda..5f4ae03 100644 --- a/files/dawn.config +++ b/files/dawn.config @@ -13,7 +13,7 @@ config hostapd config times option update_client '10' - option remove_client '120' + option remove_client '15' option remove_probe '120' option remove_ap '460' option update_hostapd '10' From b65652c92a73e36d62b5152cb2d4fd1c3971286e Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Fri, 29 Dec 2017 22:29:53 +0100 Subject: [PATCH 7/8] set min probe count to 0 --- files/dawn.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/dawn.config b/files/dawn.config index 5f4ae03..983afc8 100644 --- a/files/dawn.config +++ b/files/dawn.config @@ -32,7 +32,7 @@ config metric option low_rssi_val '-80' option chan_util_val '140' option max_chan_util_val '170' - option min_probe_count '4' + option min_probe_count '0' option bandwith_threshold '6' option use_station_count '1' option eval_probe_req '1' \ No newline at end of file From 3b380a5fd9eb80873ca9b1487d1641fdf152c6f0 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Fri, 29 Dec 2017 22:51:10 +0100 Subject: [PATCH 8/8] correct remove function --- src/storage/datastorage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index e9636e3..220a799 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -547,7 +547,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]; }