From 5d8df44a3a60381c4e8f51ce81e5d2b2f0c4c75e Mon Sep 17 00:00:00 2001 From: Ian Clowes Date: Sat, 2 Apr 2022 17:33:45 +0100 Subject: [PATCH] treewide: code and documentation cleanup Tidy up a few bits of code - nothing very significant. Documentation fixes and updates [cleanup commit message] Signed-off-by: Nick Hainke --- CONFIGURE.md | 5 ++--- DEVELOPER.md | 6 ++---- INSTALL.md | 1 - README.md | 5 ++--- src/storage/datastorage.c | 2 -- src/utils/dawn_iwinfo.c | 6 ++---- src/utils/ubus.c | 13 ++++++++++--- 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/CONFIGURE.md b/CONFIGURE.md index 1ca250c..661b8c2 100644 --- a/CONFIGURE.md +++ b/CONFIGURE.md @@ -27,11 +27,11 @@ remove any items that are no longer used. To do this: ubus call dawn reload_config The configuration file on the original DAWN instance should -now have newly written sections containing only current parameter values. +now have newly written sections containing only current parameter values. You can also start two instances of DAWN with an empty configuration file then use this method to write the default configuration for the relevant sections. - + ## What Can Be Configured? The parameters that control DAWN are listed alphabetically below. This section describes how they are grouped to provide various features. @@ -286,4 +286,3 @@ grep 'CONFIG-H:' `find . -type f -name "*.[ch]"`|sed 's/^.*CONFIG-.: *\(.*\)$/|\ |Parameter|Purpose|Notes [Default is bracketed]| |---------|-------|-----| |hostapd_dir|Path to hostapd runtime information|[/var/run/hostapd]| - diff --git a/DEVELOPER.md b/DEVELOPER.md index 273f040..e124f6f 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -7,8 +7,7 @@ DAWN collects and shares information about the APs and clients in the network by using several standard components. The below assumes it is running on an OpenWrt device. -![OpenWrtInANuthshell](https://raw.githubusercontent.com/PolynomialDivision -/upload_stuff/master/dawn_pictures/openwrt_in_a_nutshell_dawn.png) +![OpenWrtInANuthshell](https://raw.githubusercontent.com/PolynomialDivision/upload_stuff/master/dawn_pictures/openwrt_in_a_nutshell_dawn.png) Information about capability of the AP and current clients is discovered via the hostapd and iwinfo. The task to do this is scheduled by a timer. @@ -105,7 +104,7 @@ Now you need to clone DAWN, e.g. into your home directory You must then add a symlink. In the OpenWrt branch do something like - ln -s ~/DAWN/.git/ ~openwrt/feeds/packages/net/dawn/git-src + ln -s ~/DAWN/.git/ ~/openwrt/feeds/packages/net/dawn/git-src Now compile dawn @@ -179,4 +178,3 @@ algorithms to ensure that expected behaviour occurs. At the time of writing a number of *.script files exist that can be passed to test_storage, but these haven't necessarily been maintained as the code has evolved from when they were originally written. - diff --git a/INSTALL.md b/INSTALL.md index 710fe39..890fdd4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -147,4 +147,3 @@ kicking_threshold parameter. } } } - diff --git a/README.md b/README.md index 2d5923c..745190c 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Top tip from the [configuration guide](CONFIGURE.md): ## How DAWN Works Each DAWN instance gathers information about two types of client: those that are currently connected to the host AP, plus those querying whether -to connect. It then shares that information with other DAWN instances. +to connect. It then shares that information with other DAWN instances. Each then has a view of how well any AP can "see" each client device, and that then allows DAWN to steer a client to a different AP when appropriate. @@ -68,9 +68,8 @@ that adds some DAWN information to the management interface of an OpenWrt device NB: As of early-2022 it hasn't had the developer attention it needs recently, so may not be working as well as you might like. - + ## Developers If you want to use versions of DAWN that are not fully packaged yet or to work on a fork of the code yourself then see the [Developer Guide](DEVELOPER.md). - diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index 75abbf0..f75dc5b 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -16,8 +16,6 @@ struct network_config_s network_config; struct time_config_s timeout_config; struct local_config_s local_config; -#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] - static client* client_array_get_client_for_bssid(struct dawn_mac bssid_mac, struct dawn_mac client_mac); static int compare_station_count(ap* ap_entry_own, ap* ap_entry_to_compare, struct dawn_mac client_addr); diff --git a/src/utils/dawn_iwinfo.c b/src/utils/dawn_iwinfo.c index c3b6a5d..e1fe1bd 100644 --- a/src/utils/dawn_iwinfo.c +++ b/src/utils/dawn_iwinfo.c @@ -5,8 +5,6 @@ #include "datastorage.h" #include "dawn_iwinfo.h" -#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] - char hostapd_dir_glob[HOSTAPD_DIR_LEN]; int call_iwinfo(char *client_addr); @@ -182,7 +180,7 @@ int get_rssi(const char *ifname, struct dawn_mac client_addr) { iwinfo_finish(); return INT_MIN; } else if (len <= 0) { - dawnlog_warning("No station connected\n"); + dawnlog_trace("No station connected to %s\n", ifname); iwinfo_finish(); return INT_MIN; } @@ -238,7 +236,7 @@ int get_expected_throughput(const char *ifname, struct dawn_mac client_addr) { iwinfo_finish(); return INT_MIN; } else if (len <= 0) { - dawnlog_warning("No station connected\n"); + dawnlog_trace("No station connected to %s\n", ifname); iwinfo_finish(); return INT_MIN; } diff --git a/src/utils/ubus.c b/src/utils/ubus.c index b1088b2..d6d498b 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -707,11 +707,11 @@ static int hostapd_notify(struct ubus_context* ctx_local, struct ubus_object* ob dawnlog_debug_func("Entering..."); - if (dawnlog_showing(DAWNLOG_DEBUG)) + if (dawnlog_showing(DAWNLOG_TRACE)) { char* str = blobmsg_format_json(msg, true); dawn_regmem(str); - dawnlog_info("hostapd sent %s = %s\n", method, str); + dawnlog_trace("hostapd sent %s = %s\n", method, str); dawn_free(str); str = NULL; } @@ -1572,7 +1572,15 @@ static int get_network(struct ubus_context *ctx_local, struct ubus_object *obj, blob_buf_init(&b, 0); dawn_regmem(&b); + + dawn_mutex_lock(&ap_array_mutex); + dawn_mutex_lock(&client_array_mutex); + build_network_overview(&b); + + dawn_mutex_unlock(&client_array_mutex); + dawn_mutex_unlock(&ap_array_mutex); + ret = ubus_send_reply(ctx_local, req, b.head); if (ret) dawnlog_error("Failed to send network overview: %s\n", ubus_strerror(ret)); @@ -2061,7 +2069,6 @@ int build_hearing_map_sort_client(struct blob_buf *b) { } -// FIXME: Should we have more mutex protection while accessing these lists? int build_network_overview(struct blob_buf *b) { dawnlog_debug_func("Entering...");