From 73c79989676f5b89f4547f4effc4497f5aaeea44 Mon Sep 17 00:00:00 2001 From: twy_2000 Date: Wed, 20 May 2020 16:11:14 +0800 Subject: [PATCH 1/3] ubus: make decide_function consist with configuration in luci-app-dawn, if eval_probe_req is not ticked, eval_probe_req would be -1. however, in c language, !(-1) is false. Since only zero in if statement is false, non-zero number is true. --- src/storage/datastorage.c | 4 ++-- src/utils/ubus.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index c18dc6e..62a6efc 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -427,7 +427,7 @@ int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[], char* neigh //return 1; } - if (dawn_metric.use_station_count && own_score == score_to_compare && score_to_compare > max_score) { + if (dawn_metric.use_station_count > 0 && own_score == score_to_compare && score_to_compare > max_score) { // only compare if score is bigger or equal 0 if (own_score >= 0) { @@ -1421,4 +1421,4 @@ void print_ap_array() { print_ap_entry(ap_array[i]); } printf("------------------\n"); -} \ No newline at end of file +} diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 41f4533..b65b671 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -358,15 +358,15 @@ static int decide_function(probe_entry *prob_req, int req_type) { return 0; } - if (req_type == REQ_TYPE_PROBE && !dawn_metric.eval_probe_req) { + if (req_type == REQ_TYPE_PROBE && dawn_metric.eval_probe_req <= 0) { return 1; } - if (req_type == REQ_TYPE_AUTH && !dawn_metric.eval_auth_req) { + if (req_type == REQ_TYPE_AUTH && dawn_metric.eval_auth_req <= 0) { return 1; } - if (req_type == REQ_TYPE_ASSOC && !dawn_metric.eval_assoc_req) { + if (req_type == REQ_TYPE_ASSOC && dawn_metric.eval_assoc_req <= 0) { return 1; } From 2d1a6f9c0cc9dfa9e00a7b34541a7c5c3848e6f4 Mon Sep 17 00:00:00 2001 From: twy_2000 Date: Thu, 21 May 2020 12:47:56 +0800 Subject: [PATCH 2/3] ubus: filter out global interface --- src/utils/ubus.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/ubus.c b/src/utils/ubus.c index b65b671..1bde922 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -1673,6 +1673,8 @@ void subscribe_to_new_interfaces(const char *hostapd_sock_path) { while ((entry = readdir(dirp)) != NULL) { if (entry->d_type == DT_SOCK) { bool do_subscribe = true; + if (strcmp(entry->d_name, "global") == 0) + continue; list_for_each_entry(sub, &hostapd_sock_list, list) { if (strncmp(sub->iface_name, entry->d_name, MAX_INTERFACE_NAME) == 0) { From 3a6ef899983421ede69bd640741670328fc74cd0 Mon Sep 17 00:00:00 2001 From: Polynomialdivision Date: Sun, 24 May 2020 15:10:22 +0200 Subject: [PATCH 3/3] ubus: addd empty aps It was requested that DAWN should show the whole network, even if no client is connected to an AP. --- src/storage/datastorage.c | 72 +++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index 62a6efc..5ad20a2 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -200,46 +200,47 @@ int build_network_overview(struct blob_buf *b) { blob_buf_init(b, 0); int m; for (m = 0; m <= ap_entry_last; m++) { - if (m > 0) { - if (strcmp((char *) ap_array[m].ssid, (char *) ap_array[m - 1].ssid) == 0) { - continue; - } + bool add_ssid = false; + bool close_ssid = false; + + if (m == 0 || strcmp((char *) ap_array[m].ssid, (char *) ap_array[m - 1].ssid) != 0) { + add_ssid = true; } - ssid_list = blobmsg_open_table(b, (char *) ap_array[m].ssid); + if (m >= ap_entry_last || strcmp((char *) ap_array[m].ssid, (char *) ap_array[m + 1].ssid) != 0) { + close_ssid = true; + } - int i; - for (i = 0; i <= client_entry_last; i++) { - ap ap_entry_i = ap_array_get_ap(client_array[i].bssid_addr); + if(add_ssid) + { + ssid_list = blobmsg_open_table(b, (char *) ap_array[m].ssid); + } + sprintf(ap_mac_buf, MACSTR, MAC2STR(ap_array[m].bssid_addr)); + ap_list = blobmsg_open_table(b, ap_mac_buf); - if (strcmp((char *) ap_entry_i.ssid, (char *) ap_array[m].ssid) != 0) { - continue; + blobmsg_add_u32(b, "freq", ap_array[m].freq); + blobmsg_add_u32(b, "channel_utilization", ap_array[m].channel_utilization); + blobmsg_add_u32(b, "num_sta", ap_array[m].station_count); + blobmsg_add_u8(b, "ht_support", ap_array[m].ht_support); + blobmsg_add_u8(b, "vht_support", ap_array[m].vht_support); + + char *nr; + nr = blobmsg_alloc_string_buffer(b, "neighbor_report", NEIGHBOR_REPORT_LEN); + sprintf(nr, "%s", ap_array[m].neighbor_report); + blobmsg_add_string_buffer(b); + + int k; + for (k = 0; k <= client_entry_last; k++) { + + if (mac_is_greater(ap_array[m].bssid_addr, client_array[k].bssid_addr)) + { + break; } - int k; - sprintf(ap_mac_buf, MACSTR, MAC2STR(client_array[i].bssid_addr)); - ap_list = blobmsg_open_table(b, ap_mac_buf); - - blobmsg_add_u32(b, "freq", ap_entry_i.freq); - blobmsg_add_u32(b, "channel_utilization", ap_entry_i.channel_utilization); - blobmsg_add_u32(b, "num_sta", ap_entry_i.station_count); - blobmsg_add_u8(b, "ht_support", ap_entry_i.ht_support); - blobmsg_add_u8(b, "vht_support", ap_entry_i.vht_support); - - char *nr; - nr = blobmsg_alloc_string_buffer(b, "neighbor_report", NEIGHBOR_REPORT_LEN); - sprintf(nr, "%s", ap_entry_i.neighbor_report); - blobmsg_add_string_buffer(b); - - for (k = i; k <= client_entry_last; k++) { - if (!mac_is_equal(client_array[k].bssid_addr, client_array[i].bssid_addr)) { - i = k - 1; - break; - } else if (k == client_entry_last) { - i = k; - } + if (mac_is_equal(ap_array[m].bssid_addr, client_array[k].bssid_addr)) { sprintf(client_mac_buf, MACSTR, MAC2STR(client_array[k].client_addr)); client_list = blobmsg_open_table(b, client_mac_buf); + if(strlen(client_array[k].signature) != 0) { char *s; @@ -262,9 +263,12 @@ int build_network_overview(struct blob_buf *b) { } blobmsg_close_table(b, client_list); } - blobmsg_close_table(b, ap_list); } - blobmsg_close_table(b, ssid_list); + blobmsg_close_table(b, ap_list); + if(close_ssid) + { + blobmsg_close_table(b, ssid_list); + } } return 0; }