From: David Bauer Date: Sun, 23 Jan 2022 20:39:55 +0000 (+0100) Subject: local-node: save latest bss-transition-response X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3c0cd982d52643fc9581242864f7d4864f647e5c;p=project%2Fusteer.git local-node: save latest bss-transition-response 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 --- diff --git a/local_node.c b/local_node.c index 29eb33d..9f4a2df 100644 --- a/local_node.c +++ b/local_node.c @@ -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); } diff --git a/usteer.h b/usteer.h index 2f74a01..39412bb 100644 --- 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;