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

@ -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");