From: David Bauer Date: Sun, 28 Nov 2021 22:20:48 +0000 (+0100) Subject: sta: uniform disconnect state handling X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=55e98d852c03a22cdbcd9fddbbdc86ed8b3b13e1;p=project%2Fusteer.git sta: uniform disconnect state handling Logic for handling STA transition to disconnected state is present multiple times. Create a new method to remove duplicate code. Signed-off-by: David Bauer --- diff --git a/local_node.c b/local_node.c index fb881d1..eb57bfb 100644 --- a/local_node.c +++ b/local_node.c @@ -249,8 +249,7 @@ usteer_local_node_set_assoc(struct usteer_local_node *ln, struct blob_attr *cl) if (si->connected != STA_DISCONNECTED) continue; - si->connected = STA_NOT_CONNECTED; - usteer_sta_info_update_timeout(si, config.local_sta_timeout); + usteer_sta_disconnected(si); MSG(VERBOSE, "station "MAC_ADDR_FMT" disconnected from node %s\n", MAC_ADDR_DATA(si->sta->addr), usteer_node_name(node)); } diff --git a/sta.c b/sta.c index 9ddd81e..0ec6a8a 100644 --- a/sta.c +++ b/sta.c @@ -105,8 +105,7 @@ usteer_sta_info_get(struct sta *sta, struct usteer_node *node, bool *create) *create = true; /* Node is by default not connected. */ - si->connected = STA_NOT_CONNECTED; - usteer_sta_info_update_timeout(si, config.local_sta_timeout); + usteer_sta_disconnected(si); return si; } @@ -145,6 +144,12 @@ usteer_sta_get(const uint8_t *addr, bool create) return sta; } +void usteer_sta_disconnected(struct sta_info *si) +{ + si->connected = STA_NOT_CONNECTED; + usteer_sta_info_update_timeout(si, config.local_sta_timeout); +} + void usteer_sta_info_update(struct sta_info *si, int signal, bool avg) { diff --git a/ubus.c b/ubus.c index 1a78bbf..83a7558 100644 --- a/ubus.c +++ b/ubus.c @@ -578,7 +578,7 @@ void usteer_ubus_kick_client(struct sta_info *si) blobmsg_add_u32(&b, "reason", config.load_kick_reason_code); blobmsg_add_u8(&b, "deauth", 1); ubus_invoke(ubus_ctx, ln->obj_id, "del_client", b.head, NULL, 0, 100); - si->connected = STA_NOT_CONNECTED; + usteer_sta_disconnected(si); si->roam_kick = current_time; } diff --git a/usteer.h b/usteer.h index dd4ea0e..5376707 100644 --- a/usteer.h +++ b/usteer.h @@ -275,6 +275,7 @@ struct sta_info *usteer_sta_info_get(struct sta *sta, struct usteer_node *node, bool usteer_sta_supports_beacon_measurement_mode(struct sta *sta, enum usteer_beacon_measurement_mode mode); +void usteer_sta_disconnected(struct sta_info *si); void usteer_sta_info_update_timeout(struct sta_info *si, int timeout); void usteer_sta_info_update(struct sta_info *si, int signal, bool avg);