From b6b1ec10cf24000149915f50c0a1f44d6ae788b9 Mon Sep 17 00:00:00 2001 From: Polynomialdivision Date: Mon, 26 Nov 2018 15:38:49 +0100 Subject: [PATCH] add ap_weight for an ap --- files/dawn.config | 1 + src/include/datastorage.h | 2 ++ src/storage/datastorage.c | 2 ++ src/utils/dawn_uci.c | 1 + src/utils/ubus.c | 12 ++++++++++-- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/files/dawn.config b/files/dawn.config index 411eda7..24d80d2 100644 --- a/files/dawn.config +++ b/files/dawn.config @@ -26,6 +26,7 @@ config times option update_chan_util '5' config metric + option ap_weight '0' option ht_support '0' option vht_support '0' option no_ht_support '0' diff --git a/src/include/datastorage.h b/src/include/datastorage.h index 8bbf805..00b6632 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -36,6 +36,7 @@ struct probe_metric_s dawn_metric; // ---------------- Structs ---------------- struct probe_metric_s { + int ap_weight; int ht_support; int vht_support; int no_ht_support; @@ -198,6 +199,7 @@ typedef struct ap_s { uint8_t ssid[SSID_MAX_LEN]; uint32_t collision_domain; uint32_t bandwidth; + uint32_t ap_weight; } ap; // ---------------- Defines ---------------- diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index bfa2c55..b64c5bc 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -242,6 +242,8 @@ int eval_probe_metric(struct probe_entry_s probe_entry) { score += !probe_entry.vht_capabilities && !ap_entry.vht_support ? dawn_metric.no_vht_support : 0; score += ap_entry.channel_utilization <= dawn_metric.chan_util_val ? dawn_metric.chan_util : 0; score += ap_entry.channel_utilization > dawn_metric.max_chan_util_val ? dawn_metric.max_chan_util : 0; + + score += ap_entry.ap_weight; } score += (probe_entry.freq > 5000) ? dawn_metric.freq : 0; diff --git a/src/utils/dawn_uci.c b/src/utils/dawn_uci.c index 7f08d29..2d56338 100644 --- a/src/utils/dawn_uci.c +++ b/src/utils/dawn_uci.c @@ -49,6 +49,7 @@ struct probe_metric_s uci_get_dawn_metric() { struct uci_section *s = uci_to_section(e); if (strcmp(s->type, "metric") == 0) { + ret.ap_weight = uci_lookup_option_int(uci_ctx, s, "ap_weight"); ret.kicking = uci_lookup_option_int(uci_ctx, s, "kicking"); ret.ht_support = uci_lookup_option_int(uci_ctx, s, "ht_support"); ret.vht_support = uci_lookup_option_int(uci_ctx, s, "vht_support"); diff --git a/src/utils/ubus.c b/src/utils/ubus.c index d20a79b..40fb9f8 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -152,6 +152,7 @@ enum { CLIENT_TABLE_NUM_STA, CLIENT_TABLE_COL_DOMAIN, CLIENT_TABLE_BANDWIDTH, + CLIENT_TABLE_WEIGHT, __CLIENT_TABLE_MAX, }; @@ -166,6 +167,7 @@ static const struct blobmsg_policy client_table_policy[__CLIENT_TABLE_MAX] = { [CLIENT_TABLE_NUM_STA] = {.name = "num_sta", .type = BLOBMSG_TYPE_INT32}, [CLIENT_TABLE_COL_DOMAIN] = {.name = "collision_domain", .type = BLOBMSG_TYPE_INT32}, [CLIENT_TABLE_BANDWIDTH] = {.name = "bandwidth", .type = BLOBMSG_TYPE_INT32}, + [CLIENT_TABLE_WEIGHT] = {.name = "ap_weight", .type = BLOBMSG_TYPE_INT32}, }; enum { @@ -825,6 +827,12 @@ int parse_to_clients(struct blob_attr *msg, int do_kick, uint32_t id) { ap_entry.station_count = num_stations; + if (tb[CLIENT_TABLE_WEIGHT]) { + ap_entry.ap_weight = blobmsg_get_u32(tb[CLIENT_TABLE_WEIGHT]); + } else { + ap_entry.ap_weight = 0; + } + insert_to_ap_array(ap_entry); if (do_kick && dawn_metric.kicking) { @@ -868,6 +876,8 @@ static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_ blobmsg_add_u8(&b_domain, "ht_supported", entry->ht_support); blobmsg_add_u8(&b_domain, "vht_supported", entry->vht_support); + blobmsg_add_u32(&b_domain, "ap_weight", dawn_metric.ap_weight); + //int channel_util = get_channel_utilization(entry->iface_name, &entry->last_channel_time, &entry->last_channel_time_busy); blobmsg_add_u32(&b_domain, "channel_utilization", entry->chan_util_average); @@ -878,8 +888,6 @@ static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_ print_ap_array(); free(data_str); - - } static int ubus_get_clients() {