From 3c1dd5155de10ae7b791b0a2f8c7e323a3c0323d Mon Sep 17 00:00:00 2001 From: David Bauer Date: Mon, 20 Dec 2021 22:32:00 +0100 Subject: [PATCH] policy: export snr_to_signal to other source files Export snr_to_signal to other source files. This will be necessary to determine reported signal strengths from beacon-report throughout the code base. Signed-off-by: David Bauer --- policy.c | 16 ++++++++-------- usteer.h | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/policy.c b/policy.c index 4ed85a1..2b94d87 100644 --- a/policy.c +++ b/policy.c @@ -129,8 +129,8 @@ find_better_candidate(struct sta_info *si_ref, struct uevent *ev, uint32_t requi return NULL; } -static int -snr_to_signal(struct usteer_node *node, int snr) +int +usteer_snr_to_signal(struct usteer_node *node, int snr) { int noise = -95; @@ -161,10 +161,10 @@ usteer_check_request(struct sta_info *si, enum usteer_event_type type) * * Otherwise, the client potentially ends up in a assoc - kick loop. */ - if (config.min_snr && si->signal < snr_to_signal(si->node, config.min_snr)) { + if (config.min_snr && si->signal < usteer_snr_to_signal(si->node, config.min_snr)) { ev.reason = UEV_REASON_LOW_SIGNAL; ev.threshold.cur = si->signal; - ev.threshold.ref = snr_to_signal(si->node, config.min_snr); + ev.threshold.ref = usteer_snr_to_signal(si->node, config.min_snr); ret = false; goto out; } else if (!config.assoc_steering) { @@ -172,7 +172,7 @@ usteer_check_request(struct sta_info *si, enum usteer_event_type type) } } - min_signal = snr_to_signal(si->node, config.min_connect_snr); + min_signal = usteer_snr_to_signal(si->node, config.min_connect_snr); if (si->signal < min_signal) { ev.reason = UEV_REASON_LOW_SIGNAL; ev.threshold.cur = si->signal; @@ -265,7 +265,7 @@ usteer_roam_trigger_sm(struct sta_info *si) }; int min_signal; - min_signal = snr_to_signal(si->node, config.roam_trigger_snr); + min_signal = usteer_snr_to_signal(si->node, config.roam_trigger_snr); switch (si->roam_state) { case ROAM_TRIGGER_SCAN: @@ -345,7 +345,7 @@ usteer_local_node_roam_check(struct usteer_local_node *ln, struct uevent *ev) return; usteer_update_time(); - min_signal = snr_to_signal(&ln->node, min_signal); + min_signal = usteer_snr_to_signal(&ln->node, min_signal); list_for_each_entry(si, &ln->node.sta_info, node_list) { if (si->connected != STA_CONNECTED || si->signal >= min_signal || @@ -375,7 +375,7 @@ usteer_local_node_snr_kick(struct usteer_local_node *ln) if (!config.min_snr) return; - min_signal = snr_to_signal(&ln->node, config.min_snr); + min_signal = usteer_snr_to_signal(&ln->node, config.min_snr); ev.threshold.ref = min_signal; list_for_each_entry(si, &ln->node.sta_info, node_list) { diff --git a/usteer.h b/usteer.h index 5376707..7bf6aa3 100644 --- a/usteer.h +++ b/usteer.h @@ -262,6 +262,8 @@ void usteer_init_defaults(void); bool usteer_handle_sta_event(struct usteer_node *node, const uint8_t *addr, enum usteer_event_type type, int freq, int signal); +int usteer_snr_to_signal(struct usteer_node *node, int snr); + void usteer_local_nodes_init(struct ubus_context *ctx); void usteer_local_node_kick(struct usteer_local_node *ln); -- 2.30.2