local-node: save latest bss-transition-response
authorDavid Bauer <mail@david-bauer.net>
Sun, 23 Jan 2022 20:39:55 +0000 (21:39 +0100)
committerDavid Bauer <mail@david-bauer.net>
Fri, 4 Feb 2022 22:34:25 +0000 (23:34 +0100)
Save the latest BSS-transition management response received from a STA.
This information can later be used to prevent kicking STAs when they
rejected a transition request.

Signed-off-by: David Bauer <mail@david-bauer.net>
local_node.c
usteer.h

index 29eb33db125d33f45b1242db19efdb162a8eaaab..9f4a2df41c997f2d43c9366996a56099ffc259c6 100644 (file)
@@ -143,6 +143,46 @@ usteer_handle_bss_tm_query(struct usteer_local_node *ln, struct blob_attr *msg)
        return 1;
 }
 
+static int
+usteer_handle_bss_tm_response(struct usteer_local_node *ln, struct blob_attr *msg)
+{
+       enum {
+               BSS_TM_RESPONSE_ADDRESS,
+               BSS_TM_RESPONSE_STATUS_CODE,
+               __BSS_TM_RESPONSE_MAX
+       };
+       struct blobmsg_policy policy[__BSS_TM_RESPONSE_MAX] = {
+               [BSS_TM_RESPONSE_ADDRESS] = { .name = "address", .type = BLOBMSG_TYPE_STRING },
+               [BSS_TM_RESPONSE_STATUS_CODE] = { .name = "status-code", .type = BLOBMSG_TYPE_INT8 },
+       };
+       struct blob_attr *tb[__BSS_TM_RESPONSE_MAX];
+       struct sta_info *si;
+       struct sta *sta;
+       uint8_t *sta_addr;
+
+       blobmsg_parse(policy, __BSS_TM_RESPONSE_MAX, tb, blob_data(msg), blob_len(msg));
+
+       if (!tb[BSS_TM_RESPONSE_ADDRESS] || !tb[BSS_TM_RESPONSE_STATUS_CODE])
+               return 0;
+
+       sta_addr = (uint8_t *) ether_aton(blobmsg_get_string(tb[BSS_TM_RESPONSE_ADDRESS]));
+       if (!sta_addr)
+               return 0;
+
+       sta = usteer_sta_get(sta_addr, false);
+       if (!sta)
+               return 0;
+
+       si = usteer_sta_info_get(sta, &ln->node, false);
+       if (!si)
+               return 0;
+
+       si->bss_transition_response.status_code = blobmsg_get_u8(tb[BSS_TM_RESPONSE_STATUS_CODE]);
+       si->bss_transition_response.timestamp = current_time;
+
+       return 0;
+}
+
 static int
 usteer_local_node_handle_beacon_report(struct usteer_local_node *ln, struct blob_attr *msg)
 {
@@ -228,6 +268,8 @@ usteer_handle_event(struct ubus_context *ctx, struct ubus_object *obj,
 
        if(!strcmp(method, "bss-transition-query")) {
                return usteer_handle_bss_tm_query(ln, msg);
+       } else if(!strcmp(method, "bss-transition-response")) {
+               return usteer_handle_bss_tm_response(ln, msg);
        } else if(!strcmp(method, "beacon-report")) {
                return usteer_local_node_handle_beacon_report(ln, msg);
        }
index 2f74a01c662e716fddb744b48312ad85a147ca56..39412bb86890d3a5ca8ad43847908bee494064f7 100644 (file)
--- a/usteer.h
+++ b/usteer.h
@@ -245,6 +245,11 @@ struct sta_info {
        uint64_t roam_scan_start;
        uint64_t roam_scan_timeout_start;
 
+       struct {
+               uint8_t status_code;
+               uint64_t timestamp;
+       } bss_transition_response;
+
        int kick_count;
 
        uint32_t below_min_snr;