Change beacon request fields to appropriate values

This changes the op_class, channel, and SSID fields used to send a
beacon request.  Op_class and channel were set from the UCI config file,
but they are dependent on the band being used--they define the frequency
used.  The values can be taken from the AP's own neighbor report.

The SSID was set with a blank string, which would return beacons from
any SSID.  Since we only care about our own SSID, there's no need to
waste resorces with reports from other SSIDs.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
This commit is contained in:
Eneas U de Queiroz 2021-07-26 15:06:28 -03:00 committed by Polynomdivision
parent 009aab9ca4
commit 3ba0fa4947
7 changed files with 20 additions and 36 deletions

View file

@ -153,11 +153,9 @@ struct probe_metric_s uci_get_dawn_metric() {
ret.min_kick_count = uci_lookup_option_int(uci_ctx, s, "min_number_to_kick");
ret.chan_util_avg_period = uci_lookup_option_int(uci_ctx, s, "chan_util_avg_period");
ret.set_hostapd_nr = uci_lookup_option_int(uci_ctx, s, "set_hostapd_nr");
ret.op_class = uci_lookup_option_int(uci_ctx, s, "op_class");
ret.duration = uci_lookup_option_int(uci_ctx, s, "duration");
ret.rrm_mode_mask = parse_rrm_mode(ret.rrm_mode_order,
uci_lookup_option_string(uci_ctx, s, "rrm_mode"));
ret.scan_channel = uci_lookup_option_int(uci_ctx, s, "scan_channel");
return ret;
}
}

View file

@ -519,8 +519,10 @@ int parse_to_clients(struct blob_attr* msg, int do_kick, uint32_t id) {
}
ap_entry->op_class = ap_entry->channel = 0;
if (tb[CLIENT_TABLE_NEIGHBOR]) {
strncpy(ap_entry->neighbor_report, blobmsg_get_string(tb[CLIENT_TABLE_NEIGHBOR]), NEIGHBOR_REPORT_LEN);
sscanf(ap_entry->neighbor_report + NR_OP_CLASS, "%2x%2x", &ap_entry->op_class, &ap_entry->channel);
}
else {
ap_entry->neighbor_report[0] = '\0';
@ -584,10 +586,8 @@ enum {
UCI_MIN_NUMBER_TO_KICK,
UCI_CHAN_UTIL_AVG_PERIOD,
UCI_SET_HOSTAPD_NR,
UCI_OP_CLASS,
UCI_DURATION,
UCI_RRM_MODE,
UCI_SCAN_CHANNEL,
__UCI_METIC_MAX
};
@ -637,10 +637,8 @@ static const struct blobmsg_policy uci_metric_policy[__UCI_METIC_MAX] = {
[UCI_MIN_NUMBER_TO_KICK] = {.name = "min_number_to_kick", .type = BLOBMSG_TYPE_INT32},
[UCI_CHAN_UTIL_AVG_PERIOD] = {.name = "chan_util_avg_period", .type = BLOBMSG_TYPE_INT32},
[UCI_SET_HOSTAPD_NR] = {.name = "set_hostapd_nr", .type = BLOBMSG_TYPE_INT32},
[UCI_OP_CLASS] = {.name = "op_class", .type = BLOBMSG_TYPE_INT32},
[UCI_DURATION] = {.name = "duration", .type = BLOBMSG_TYPE_INT32},
[UCI_RRM_MODE] = {.name = "rrm_mode", .type = BLOBMSG_TYPE_STRING},
[UCI_SCAN_CHANNEL] = {.name = "scan_channel", .type = BLOBMSG_TYPE_INT32},
};
static const struct blobmsg_policy uci_times_policy[__UCI_TIMES_MAX] = {
@ -746,18 +744,12 @@ static int handle_uci_config(struct blob_attr* msg) {
sprintf(cmd_buffer, "dawn.@metric[0].set_hostapd_nr=%d", blobmsg_get_u32(tb_metric[UCI_SET_HOSTAPD_NR]));
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.@metric[0].op_class=%d", blobmsg_get_u32(tb_metric[UCI_OP_CLASS]));
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.@metric[0].duration=%d", blobmsg_get_u32(tb_metric[UCI_DURATION]));
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.@metric[0].rrm_mode=%s", blobmsg_get_string(tb_metric[UCI_RRM_MODE]));
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.@metric[0].scan_channel=%d", blobmsg_get_u32(tb_metric[UCI_SCAN_CHANNEL]));
uci_set_network(cmd_buffer);
struct blob_attr* tb_times[__UCI_TIMES_MAX];
blobmsg_parse(uci_times_policy, __UCI_TIMES_MAX, tb_times, blobmsg_data(tb[UCI_TABLE_TIMES]), blobmsg_len(tb[UCI_TABLE_TIMES]));

View file

@ -815,25 +815,25 @@ static int get_mode_from_capability(int capability) {
return -1;
}
void ubus_send_beacon_report(client *c, int id)
void ubus_send_beacon_report(client *c, ap *a, int id)
{
printf("Crafting Beacon Report\n");
int timeout = 1;
blob_buf_init(&b_beacon, 0);
blobmsg_add_macaddr(&b_beacon, "addr", c->client_addr);
blobmsg_add_u32(&b_beacon, "op_class", dawn_metric.op_class);
blobmsg_add_u32(&b_beacon, "channel", dawn_metric.scan_channel);
blobmsg_add_u32(&b_beacon, "op_class", a->op_class);
blobmsg_add_u32(&b_beacon, "channel", a->channel);
blobmsg_add_u32(&b_beacon, "duration", dawn_metric.duration);
blobmsg_add_u32(&b_beacon, "mode", get_mode_from_capability(c->rrm_enabled_capa));
printf("Adding string\n");
blobmsg_add_string(&b_beacon, "ssid", "");
blobmsg_add_string(&b_beacon, "ssid", (char*)a->ssid);
printf("Invoking beacon report!\n");
ubus_invoke(ctx, id, "rrm_beacon_req", b_beacon.head, NULL, NULL, timeout * 1000);
}
void update_beacon_reports(struct uloop_timeout *t) {
ap *a;
if(!timeout_config.update_beacon_reports) // if 0 just return
{
return;
@ -842,9 +842,9 @@ void update_beacon_reports(struct uloop_timeout *t) {
struct hostapd_sock_entry *sub;
list_for_each_entry(sub, &hostapd_sock_list, list)
{
if (sub->subscribed) {
if (sub->subscribed && (a = ap_array_get_ap(sub->bssid_addr, (uint8_t*)sub->ssid))) {
printf("Sending beacon report Sub!\n");
send_beacon_reports(sub->bssid_addr, sub->id);
send_beacon_reports(a, sub->id);
}
}
uloop_timeout_set(&beacon_reports_timer, timeout_config.update_beacon_reports * 1000);
@ -1397,10 +1397,8 @@ int uci_send_via_network()
blobmsg_add_u32(&b, "min_number_to_kick", dawn_metric.min_kick_count);
blobmsg_add_u32(&b, "chan_util_avg_period", dawn_metric.chan_util_avg_period);
blobmsg_add_u32(&b, "set_hostapd_nr", dawn_metric.set_hostapd_nr);
blobmsg_add_u32(&b, "op_class", dawn_metric.op_class);
blobmsg_add_u32(&b, "duration", dawn_metric.duration);
blobmsg_add_string(&b, "rrm_mode", get_rrm_mode_string(dawn_metric.rrm_mode_order));
blobmsg_add_u32(&b, "scan_channel", dawn_metric.scan_channel);
blobmsg_close_table(&b, metric);
times = blobmsg_open_table(&b, "times");