treewide: cleanup code

- Revise some messages so meaning is clearer
- Fix some whitespace, etc
- Simplify a coiuple of small functions

[cleanup commit message]
Signed-off-by: Nick Hainke <vincent@systemli.org>
This commit is contained in:
Ian Clowes 2022-01-31 11:42:07 +00:00 committed by Nick Hainke
parent 829fa0faed
commit b7e3d6f34d
4 changed files with 31 additions and 24 deletions

View file

@ -174,7 +174,7 @@ void send_beacon_requests(ap *a, int id) {
// Go through clients
while (i != NULL && mac_is_equal_bb(i->bssid_addr, a->bssid_addr)) {
if (dawnlog_showing(DAWNLOG_DEBUG))
dawnlog_debug("Station " MACSTR ": rrm_enabled_capa=%02x: PASSIVE=%d, ACTIVE=%d, TABLE=%d\n",
dawnlog_debug("Client " MACSTR ": rrm_enabled_capa=%02x: PASSIVE=%d, ACTIVE=%d, TABLE=%d\n",
MAC2STR(i->client_addr.u8), i->rrm_enabled_capa,
!!(i->rrm_enabled_capa & WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE),
!!(i->rrm_enabled_capa & WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE),
@ -476,7 +476,7 @@ int better_ap_available(ap *kicking_ap, struct dawn_mac client_mac, struct kicki
}
if (neighbor_report != NULL)
dawnlog_info("Station " MACSTR ": Compared %d alternate AP candidates\n", MAC2STR(client_mac.u8), ap_count);
dawnlog_info("Client " MACSTR ": Compared %d alternate AP candidates\n", MAC2STR(client_mac.u8), ap_count);
return kick;
}
@ -508,7 +508,7 @@ int kick_clients(struct dawn_mac bssid_mac, uint32_t id) {
int do_kick = 0;
if (mac_find_entry(j->client_addr)) {
dawnlog_info("Station " MACSTR ": Suppressing check due to MAC list entry\n", MAC2STR(j->client_addr.u8));
dawnlog_info("Client " MACSTR ": Suppressing check due to MAC list entry\n", MAC2STR(j->client_addr.u8));
}
else {
do_kick = better_ap_available(kicking_ap, j->client_addr, &kick_nr_list);
@ -530,14 +530,14 @@ int kick_clients(struct dawn_mac bssid_mac, uint32_t id) {
// + ping pong behavior of clients will be reduced
j->kick_count++;
if (j->kick_count < dawn_metric.min_number_to_kick) {
dawnlog_info("Station " MACSTR ": kickcount %d below threshold of %d!\n", MAC2STR(j->client_addr.u8), j->kick_count,
dawnlog_info("Client " MACSTR ": kickcount %d below threshold of %d!\n", MAC2STR(j->client_addr.u8), j->kick_count,
dawn_metric.min_number_to_kick);
}
else {
float rx_rate, tx_rate;
bool have_bandwidth_iwinfo = get_bandwidth_iwinfo(j->client_addr, &rx_rate, &tx_rate);
if (!have_bandwidth_iwinfo && dawn_metric.bandwidth_threshold > 0) {
dawnlog_info("Station " MACSTR ": No active transmission data for client. Don't kick!\n", MAC2STR(j->client_addr.u8));
dawnlog_info("Client " MACSTR ": No active transmission data for client. Don't kick!\n", MAC2STR(j->client_addr.u8));
}
else
{
@ -545,14 +545,14 @@ int kick_clients(struct dawn_mac bssid_mac, uint32_t id) {
// <= 6MBits <- probably no transmission
// tx_rate has always some weird value so don't use ist
if (have_bandwidth_iwinfo && rx_rate > dawn_metric.bandwidth_threshold) {
dawnlog_info("Station " MACSTR ": Client is probably in active transmission. Don't kick! RxRate is: %f\n", MAC2STR(j->client_addr.u8), rx_rate);
dawnlog_info("Client " MACSTR ": Client is probably in active transmission. Don't kick! RxRate is: %f\n", MAC2STR(j->client_addr.u8), rx_rate);
}
else
{
if (have_bandwidth_iwinfo)
dawnlog_always("Station " MACSTR ": Kicking as probably NOT in active transmission. RxRate is: %f\n", MAC2STR(j->client_addr.u8), rx_rate);
dawnlog_always("Client " MACSTR ": Kicking as probably NOT in active transmission. RxRate is: %f\n", MAC2STR(j->client_addr.u8), rx_rate);
else
dawnlog_always("Station " MACSTR ": Kicking as no active transmission data for client, but bandwidth_threshold=%d is OK.\n",
dawnlog_always("Client " MACSTR ": Kicking as no active transmission data for client, but bandwidth_threshold=%d is OK.\n",
MAC2STR(j->client_addr.u8), dawn_metric.bandwidth_threshold);
print_client_entry(DAWNLOG_TRACE, j);
@ -593,12 +593,12 @@ int kick_clients(struct dawn_mac bssid_mac, uint32_t id) {
}
else if (do_kick == -1) {
// FIXME: Causes clients to be kicked until first probe is received, which is a bit brutal for pre-802.11k clients.
dawnlog_info("Station " MACSTR ": No Information about client. Force reconnect:\n", MAC2STR(j->client_addr.u8));
dawnlog_info("Client " MACSTR ": No Information about client. Force reconnect:\n", MAC2STR(j->client_addr.u8));
print_client_entry(DAWNLOG_TRACE, j);
del_client_interface(id, j->client_addr, 0, 1, 0);
}
else {
dawnlog_info("Station " MACSTR ": Current AP is best. Client will stay:\n", MAC2STR(j->client_addr.u8));
dawnlog_info("Client " MACSTR ": Current AP is best. Client will stay:\n", MAC2STR(j->client_addr.u8));
print_client_entry(DAWNLOG_TRACE, j);
// set kick counter to 0 again
j->kick_count = 0;
@ -1120,6 +1120,7 @@ void remove_old_probe_entries(time_t current_time, long long int threshold) {
dawn_mutex_lock(&client_array_mutex);
while (*i != NULL ) {
// FIXME: Why do we not delete the old probe just because it is a client? Maybe because legacy devices are slow to send another?
if (((*i)->time < current_time - threshold) && !client_array_get_client_for_bssid((*i)->bssid_addr, (*i)->client_addr)) {
probe_entry* victim = *i;
@ -1168,7 +1169,9 @@ client* client_array_update_entry(client* entry, time_t expiry) {
entry->time = expiry;
if (*entry_pos && mac_compare_bb(entry->bssid_addr, (*entry_pos)->bssid_addr) == 0 && mac_compare_bb(entry->client_addr, (*entry_pos)->client_addr) == 0)
if (*entry_pos != NULL &&
mac_compare_bb(entry->bssid_addr, (*entry_pos)->bssid_addr) == 0 &&
mac_compare_bb(entry->client_addr, (*entry_pos)->client_addr) == 0)
{
dawnlog_debug_func("Replacing entry...");
// Swap entries if same BSSID + MAC...

View file

@ -303,10 +303,10 @@ int handle_network_msg(char* msg) {
dawn_mutex_require(&probe_array_mutex);
if (entry != insert_to_probe_array(entry, false, true, false, time(0))) // use 802.11k values
{
// insert found an existing entry, rather than linking in our new one
dawnlog_info("Remote PROBE updated client / BSSID = " MACSTR " / " MACSTR " \n",
MAC2STR(entry->client_addr.u8), MAC2STR(entry->bssid_addr.u8));
// insert found an existing entry, rather than linking in our new one
dawn_free(entry);
entry = NULL;
}
@ -664,7 +664,7 @@ enum {
};
static const struct blobmsg_policy uci_table_policy[__UCI_TABLE_MAX] = {
[UCI_CONFIG_VERSION ] = {.name = "version", .type = BLOBMSG_TYPE_STRING},
[UCI_CONFIG_VERSION] = {.name = "version", .type = BLOBMSG_TYPE_STRING},
[UCI_TABLE_METRIC] = {.name = "metric", .type = BLOBMSG_TYPE_TABLE},
[UCI_TABLE_TIMES] = {.name = "times", .type = BLOBMSG_TYPE_TABLE}
};
@ -803,7 +803,7 @@ static int handle_uci_config(struct blob_attr* msg) {
int band;
blobmsg_parse(uci_band_metric_policy, __UCI_BAND_METRIC_MAX, tb_band_metric,
blobmsg_data(attr), blobmsg_len(attr));
blobmsg_data(attr), blobmsg_len(attr));
for (band = 0; band < __DAWN_BAND_MAX; band++) {
if (!strcmp(band_name, band_config_name[band]))

View file

@ -811,14 +811,17 @@ static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_
return;
}
char *data_str = blobmsg_format_json(msg, 1);
dawn_regmem(data_str);
struct blob_buf b = {0};
blob_buf_init(&b, 0);
dawn_regmem(&b);
char* data_str = blobmsg_format_json(msg, 1);
dawn_regmem(data_str);
blobmsg_add_json_from_string(&b, data_str);
dawn_free(data_str);
data_str = NULL;
blobmsg_add_u32(&b, "collision_domain", network_config.collision_domain);
blobmsg_add_u32(&b, "bandwidth", network_config.bandwidth);
@ -852,9 +855,6 @@ static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_
print_ap_array();
dawn_mutex_unlock(&ap_array_mutex);
dawn_free(data_str);
data_str = NULL;
blob_buf_free(&b);
dawn_unregmem(&b);
@ -1078,7 +1078,7 @@ void update_hostapd_sockets(struct uloop_timeout *t) {
uloop_timeout_set(&hostapd_timer, timeout_config.update_hostapd * 1000);
}
void ubus_set_nr(){
void ubus_set_nr() {
dawnlog_debug_func("Entering...");
struct hostapd_sock_entry *sub;
@ -2053,9 +2053,13 @@ static void blobmsg_add_nr(struct blob_buf* b_local, ap* i) {
static int mac_is_in_entry_list(const struct dawn_mac mac, const struct mac_entry_s *list) {
dawnlog_debug_func("Entering...");
for (const struct mac_entry_s *i = list; i; i = i->next_mac)
if (mac_is_equal_bb(i->mac, mac))
while (list)
{
if (mac_is_equal_bb(list->mac, mac))
return 1;
list = list->next_mac;
}
return 0;
}