From 6e3451a40a05be3b40e5695b69b91e7c4432a07c Mon Sep 17 00:00:00 2001 From: Filip Matusiak <filip.matusiak@iopsys.eu> Date: Tue, 22 Oct 2024 15:52:57 +0200 Subject: [PATCH] steer: set active mode in nbr_req for current BSS of the STA --- src/agent.c | 13 +++++++++---- src/wifi.h | 1 + src/wifi_ubus.c | 17 ++++++++++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/agent.c b/src/agent.c index 83b959224..d869b66ae 100644 --- a/src/agent.c +++ b/src/agent.c @@ -1057,7 +1057,7 @@ static int update_sta_entry(struct netif_ap *vif, struct wifi_sta *e) } static int agent_req_beacon_metrics(struct agent *a, - struct netif_ap *ap, uint8_t *sta_addr, uint8_t opclass, + struct netif_ap *ap, struct sta *s, uint8_t opclass, uint8_t channel, uint8_t *bssid, uint8_t reporting_detail, uint8_t ssid_len, char *ssid, uint8_t num_report, uint8_t *report, uint8_t num_element, uint8_t *element) @@ -1066,7 +1066,7 @@ static int agent_req_beacon_metrics(struct agent *a, trace("agent: %s: --->\n", __func__); - if (!sta_addr) + if (!s && !hwaddr_is_zero(s->macaddr)) return -1; param.opclass = opclass; @@ -1079,8 +1079,13 @@ static int agent_req_beacon_metrics(struct agent *a, param.report = report; param.num_element = num_element; param.element = element; + if (!memcmp(s->vif->bssid, bssid, 6)) + /* For current BSS set active mode */ + param.mode = WIFI_BCNREQ_MODE_ACTIVE; + else + param.mode = WIFI_BCNREQ_MODE_PASSIVE; - return wifi_req_neighbor(ap->name, sta_addr, ¶m); + return wifi_req_neighbor(ap->name, s->macaddr, ¶m); } static void wifi_sta_bcn_req(atimer_t *t) @@ -1097,7 +1102,7 @@ static void wifi_sta_bcn_req(atimer_t *t) /* LIFO */ breq = &s->bcn_req_queue[s->sta_bcn_req_nr - 1]; - agent_req_beacon_metrics(a, breq->ap, s->macaddr, + agent_req_beacon_metrics(a, breq->ap, s, breq->opclass, breq->channel, breq->bssid, breq->reporting_detail, breq->ssid_len, breq->ssid, 0, NULL, diff --git a/src/wifi.h b/src/wifi.h index 7d4239279..ea4ebabd0 100644 --- a/src/wifi.h +++ b/src/wifi.h @@ -35,6 +35,7 @@ struct wifi_radio_status { }; struct wifi_request_neighbor_param { + enum wifi_bcnreq_mode mode; uint8_t opclass; uint8_t channel; uint8_t *bssid; diff --git a/src/wifi_ubus.c b/src/wifi_ubus.c index 5c0fb5987..1ddb25c98 100644 --- a/src/wifi_ubus.c +++ b/src/wifi_ubus.c @@ -1745,6 +1745,17 @@ out: return ret; } +static const char* wifi_bcnreq_mode2str(enum wifi_bcnreq_mode mode) +{ + if (mode == WIFI_BCNREQ_MODE_ACTIVE) + return "active"; + + if (mode == WIFI_BCNREQ_MODE_TABLE) + return "table"; + + return "passive"; +} + int wifi_ubus_req_neighbor(struct ubus_context *ubus_ctx, const char *ifname, uint8_t *sta, struct wifi_request_neighbor_param *param) { @@ -1783,9 +1794,9 @@ int wifi_ubus_req_neighbor(struct ubus_context *ubus_ctx, const char *ifname, blobmsg_add_string(&bb, "bssid", bssid_macstr); } - /* TODO: revisit */ - /* Set mode to PASSIVE/100ms explicitly */ - blobmsg_add_string(&bb, "mode", "passive"); + blobmsg_add_string(&bb, "mode", wifi_bcnreq_mode2str(param->mode)); + + /* TODO: revisit; 100ms is set explicitly */ blobmsg_add_u32(&bb, "duration", 100); if (param->reporting_detail) -- GitLab