mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-02-14 17:51:51 +00:00
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:
parent
829fa0faed
commit
b7e3d6f34d
4 changed files with 31 additions and 24 deletions
|
@ -174,7 +174,7 @@ void send_beacon_requests(ap *a, int id) {
|
||||||
// Go through clients
|
// Go through clients
|
||||||
while (i != NULL && mac_is_equal_bb(i->bssid_addr, a->bssid_addr)) {
|
while (i != NULL && mac_is_equal_bb(i->bssid_addr, a->bssid_addr)) {
|
||||||
if (dawnlog_showing(DAWNLOG_DEBUG))
|
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,
|
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_PASSIVE),
|
||||||
!!(i->rrm_enabled_capa & WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE),
|
!!(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)
|
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;
|
return kick;
|
||||||
}
|
}
|
||||||
|
@ -508,7 +508,7 @@ int kick_clients(struct dawn_mac bssid_mac, uint32_t id) {
|
||||||
int do_kick = 0;
|
int do_kick = 0;
|
||||||
|
|
||||||
if (mac_find_entry(j->client_addr)) {
|
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 {
|
else {
|
||||||
do_kick = better_ap_available(kicking_ap, j->client_addr, &kick_nr_list);
|
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
|
// + ping pong behavior of clients will be reduced
|
||||||
j->kick_count++;
|
j->kick_count++;
|
||||||
if (j->kick_count < dawn_metric.min_number_to_kick) {
|
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);
|
dawn_metric.min_number_to_kick);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float rx_rate, tx_rate;
|
float rx_rate, tx_rate;
|
||||||
bool have_bandwidth_iwinfo = get_bandwidth_iwinfo(j->client_addr, &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) {
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -545,14 +545,14 @@ int kick_clients(struct dawn_mac bssid_mac, uint32_t id) {
|
||||||
// <= 6MBits <- probably no transmission
|
// <= 6MBits <- probably no transmission
|
||||||
// tx_rate has always some weird value so don't use ist
|
// tx_rate has always some weird value so don't use ist
|
||||||
if (have_bandwidth_iwinfo && rx_rate > dawn_metric.bandwidth_threshold) {
|
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
|
else
|
||||||
{
|
{
|
||||||
if (have_bandwidth_iwinfo)
|
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
|
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);
|
MAC2STR(j->client_addr.u8), dawn_metric.bandwidth_threshold);
|
||||||
|
|
||||||
print_client_entry(DAWNLOG_TRACE, j);
|
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) {
|
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.
|
// 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);
|
print_client_entry(DAWNLOG_TRACE, j);
|
||||||
del_client_interface(id, j->client_addr, 0, 1, 0);
|
del_client_interface(id, j->client_addr, 0, 1, 0);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
print_client_entry(DAWNLOG_TRACE, j);
|
||||||
// set kick counter to 0 again
|
// set kick counter to 0 again
|
||||||
j->kick_count = 0;
|
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);
|
dawn_mutex_lock(&client_array_mutex);
|
||||||
|
|
||||||
while (*i != NULL ) {
|
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)) {
|
if (((*i)->time < current_time - threshold) && !client_array_get_client_for_bssid((*i)->bssid_addr, (*i)->client_addr)) {
|
||||||
probe_entry* victim = *i;
|
probe_entry* victim = *i;
|
||||||
|
|
||||||
|
@ -1168,7 +1169,9 @@ client* client_array_update_entry(client* entry, time_t expiry) {
|
||||||
|
|
||||||
entry->time = 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...");
|
dawnlog_debug_func("Replacing entry...");
|
||||||
// Swap entries if same BSSID + MAC...
|
// Swap entries if same BSSID + MAC...
|
||||||
|
|
|
@ -303,10 +303,10 @@ int handle_network_msg(char* msg) {
|
||||||
dawn_mutex_require(&probe_array_mutex);
|
dawn_mutex_require(&probe_array_mutex);
|
||||||
if (entry != insert_to_probe_array(entry, false, true, false, time(0))) // use 802.11k values
|
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",
|
dawnlog_info("Remote PROBE updated client / BSSID = " MACSTR " / " MACSTR " \n",
|
||||||
MAC2STR(entry->client_addr.u8), MAC2STR(entry->bssid_addr.u8));
|
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);
|
dawn_free(entry);
|
||||||
entry = NULL;
|
entry = NULL;
|
||||||
}
|
}
|
||||||
|
@ -664,7 +664,7 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct blobmsg_policy uci_table_policy[__UCI_TABLE_MAX] = {
|
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_METRIC] = {.name = "metric", .type = BLOBMSG_TYPE_TABLE},
|
||||||
[UCI_TABLE_TIMES] = {.name = "times", .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;
|
int band;
|
||||||
|
|
||||||
blobmsg_parse(uci_band_metric_policy, __UCI_BAND_METRIC_MAX, tb_band_metric,
|
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++) {
|
for (band = 0; band < __DAWN_BAND_MAX; band++) {
|
||||||
if (!strcmp(band_name, band_config_name[band]))
|
if (!strcmp(band_name, band_config_name[band]))
|
||||||
|
|
|
@ -811,14 +811,17 @@ static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *data_str = blobmsg_format_json(msg, 1);
|
|
||||||
dawn_regmem(data_str);
|
|
||||||
|
|
||||||
struct blob_buf b = {0};
|
struct blob_buf b = {0};
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
dawn_regmem(&b);
|
dawn_regmem(&b);
|
||||||
|
|
||||||
|
char* data_str = blobmsg_format_json(msg, 1);
|
||||||
|
dawn_regmem(data_str);
|
||||||
|
|
||||||
blobmsg_add_json_from_string(&b, 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, "collision_domain", network_config.collision_domain);
|
||||||
blobmsg_add_u32(&b, "bandwidth", network_config.bandwidth);
|
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();
|
print_ap_array();
|
||||||
dawn_mutex_unlock(&ap_array_mutex);
|
dawn_mutex_unlock(&ap_array_mutex);
|
||||||
|
|
||||||
dawn_free(data_str);
|
|
||||||
data_str = NULL;
|
|
||||||
|
|
||||||
blob_buf_free(&b);
|
blob_buf_free(&b);
|
||||||
dawn_unregmem(&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);
|
uloop_timeout_set(&hostapd_timer, timeout_config.update_hostapd * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ubus_set_nr(){
|
void ubus_set_nr() {
|
||||||
dawnlog_debug_func("Entering...");
|
dawnlog_debug_func("Entering...");
|
||||||
|
|
||||||
struct hostapd_sock_entry *sub;
|
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) {
|
static int mac_is_in_entry_list(const struct dawn_mac mac, const struct mac_entry_s *list) {
|
||||||
dawnlog_debug_func("Entering...");
|
dawnlog_debug_func("Entering...");
|
||||||
|
|
||||||
for (const struct mac_entry_s *i = list; i; i = i->next_mac)
|
while (list)
|
||||||
if (mac_is_equal_bb(i->mac, mac))
|
{
|
||||||
|
if (mac_is_equal_bb(list->mac, mac))
|
||||||
return 1;
|
return 1;
|
||||||
|
list = list->next_mac;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue