Change mode config parameter from int to string

This renames "mode" to "rrm_mode", and its type from int to string.
This way, we can set the correct mode for a probe request from the STA
reported capabilities, along with the preferred order of modes, set by
the "rrm_mode" uci config.

rrm_mode is a string of possible mode letters:
'p' = passive report
'a' = active report
'b' or 't' = beacon table report.

Setting rrm_mode='pat', will try to send passive reports, if available;
if not, it will try an active report, using a beacon table if all else
fails.

If you don't include a letter, the corresponding report type will be
disabled.  An empty string will disable beacon reports.  Unrecognized
letters are ignored, as well as repeated modes.  If the configuration is
not present, a default value of 'pat' will be used.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
This commit is contained in:
Eneas U de Queiroz 2021-07-27 16:52:19 -03:00 committed by Polynomdivision
parent 276ca169a7
commit 009aab9ca4
7 changed files with 163 additions and 29 deletions

View file

@ -11,7 +11,7 @@
#include "test_storage.h"
/*** Test Stub Functions - Called by SUT ***/
void ubus_send_beacon_report(struct dawn_mac client, int id)
void ubus_send_beacon_report(client *c, int id)
{
printf("send_beacon_report() was called...\n");
}
@ -148,7 +148,7 @@ static int array_auto_helper(int action, int i0, int i1)
while (cont) {
struct dawn_mac this_mac;
uint64_t mac_src = m;
uint64_t mac_src = m;
memcpy(&this_mac.u8, &mac_src, ETH_ALEN < sizeof (uint64_t) ? ETH_ALEN : sizeof (uint64_t));
switch (action & ~HELPER_ACTION_MASK)
{
@ -320,6 +320,44 @@ static int load_time(time_t* v, char* s)
return ret;
}
static int get_rrm_mode_val(char mode);
static int get_rrm_mode_val(char mode) {
switch (tolower(mode)) {
case 'a':
return WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE;
break;
case 'p':
return WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE;
break;
case 'b':
case 't':
return WLAN_RRM_CAPS_BEACON_REPORT_TABLE;
break;
}
return 0;
}
static int parse_rrm_mode(int *rrm_mode_order, const char *mode_string);
static int parse_rrm_mode(int *rrm_mode_order, const char *mode_string) {
int len, mode_val;
int mask = 0, order = 0, pos = 0;
if (!mode_string)
mode_string = DEFAULT_RRM_MODE_ORDER;
len = strlen(mode_string);
while (order < __RRM_BEACON_RQST_MODE_MAX) {
if (pos >= len) {
rrm_mode_order[order++] = 0;
} else {
mode_val = get_rrm_mode_val(mode_string[pos++]);
if (mode_val && !(mask & mode_val))
mask |= (rrm_mode_order[order++] = mode_val);
}
}
return mask;
}
static int consume_actions(int argc, char* argv[], int harness_verbosity);
static int consume_actions(int argc, char* argv[], int harness_verbosity)
@ -618,7 +656,12 @@ static int consume_actions(int argc, char* argv[], int harness_verbosity)
dawn_metric.kicking = 0;
dawn_metric.op_class = 0;
dawn_metric.duration = 0;
dawn_metric.mode = 0;
dawn_metric.rrm_mode_mask = WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE |
WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE |
WLAN_RRM_CAPS_BEACON_REPORT_TABLE;
dawn_metric.rrm_mode_order[0] = WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE;
dawn_metric.rrm_mode_order[1] = WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE;
dawn_metric.rrm_mode_order[2] = WLAN_RRM_CAPS_BEACON_REPORT_TABLE;
dawn_metric.scan_channel = 0;
}
else if (!strncmp(fn, "ap_weight=", 10)) load_int(&dawn_metric.ap_weight, fn + 10);
@ -651,7 +694,7 @@ static int consume_actions(int argc, char* argv[], int harness_verbosity)
else if (!strncmp(fn, "kicking=", 8)) load_int(&dawn_metric.kicking, fn + 8);
else if (!strncmp(fn, "op_class=", 9)) load_int(&dawn_metric.op_class, fn + 9);
else if (!strncmp(fn, "duration=", 9)) load_int(&dawn_metric.duration, fn + 9);
else if (!strncmp(fn, "mode=", 5)) load_int(&dawn_metric.mode, fn + 5);
else if (!strncmp(fn, "rrm_mode=", 9)) dawn_metric.rrm_mode_mask = parse_rrm_mode(dawn_metric.rrm_mode_order, fn + 9);
else if (!strncmp(fn, "scan_channel=", 13)) load_int(&dawn_metric.scan_channel, fn + 13);
else {
printf("ERROR: Loading DAWN control metrics, but don't recognise assignment \"%s\"\n", fn);