diff mbox series

[3/4] scan: add flag if BSS load was advertised

Message ID 20240515122221.333230-3-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series [1/4] nl80211util: add ATTR_SURVEY_INFO to parse_attrs | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood May 15, 2024, 12:22 p.m. UTC
For ranking purposes the utilization was defaulted to a valid (127)
which would not change the rank if that IE was not found in the
scan results. Historically this was printed (debug) as part of the
scan results but that was removed as it was somewhat confusing. i.e.
did the AP _really_ have a utilization of 127? or was the IE not
found?

Since it is useful to see the BSS load if that is advertised add a
flag to the scan_bss struct to indicate if the IE was present which
can be checked.
---
 src/scan.c | 14 ++++++++------
 src/scan.h |  1 +
 2 files changed, 9 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/src/scan.c b/src/scan.c
index 8699fe3e..555ab88e 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -1344,6 +1344,8 @@  static bool scan_parse_bss_information_elements(struct scan_bss *bss,
 						NULL) < 0)
 				l_warn("Unable to parse BSS Load IE for "
 					MAC, MAC_STR(bss->addr));
+			else
+				bss->have_utilization = true;
 
 			break;
 		case IE_TYPE_VENDOR_SPECIFIC:
@@ -1533,7 +1535,6 @@  static struct scan_bss *scan_parse_attr_bss(struct l_genl_attr *attr,
 	size_t beacon_ies_len;
 
 	bss = l_new(struct scan_bss, 1);
-	bss->utilization = 127;
 	bss->source_frame = SCAN_BSS_BEACON;
 
 	while (l_genl_attr_next(attr, &type, &len, &data)) {
@@ -1704,10 +1705,12 @@  static void scan_bss_compute_rank(struct scan_bss *bss)
 		rank *= RANK_6G_FACTOR;
 
 	/* Rank loaded APs lower and lightly loaded APs higher */
-	if (bss->utilization >= 192)
-		rank *= RANK_HIGH_UTILIZATION_FACTOR;
-	else if (bss->utilization <= 63)
-		rank *= RANK_LOW_UTILIZATION_FACTOR;
+	if (bss->have_utilization) {
+		if (bss->utilization >= 192)
+			rank *= RANK_HIGH_UTILIZATION_FACTOR;
+		else if (bss->utilization <= 63)
+			rank *= RANK_LOW_UTILIZATION_FACTOR;
+	}
 
 	if (bss->have_snr) {
 		if (bss->snr <= 15)
@@ -1734,7 +1737,6 @@  struct scan_bss *scan_bss_new_from_probe_req(const struct mmpdu_header *mpdu,
 
 	bss = l_new(struct scan_bss, 1);
 	memcpy(bss->addr, mpdu->address_2, 6);
-	bss->utilization = 127;
 	bss->source_frame = SCAN_BSS_PROBE_REQ;
 	bss->frequency = frequency;
 	bss->signal_strength = rssi;
diff --git a/src/scan.h b/src/scan.h
index 0bfc9e47..06753b82 100644
--- a/src/scan.h
+++ b/src/scan.h
@@ -91,6 +91,7 @@  struct scan_bss {
 	bool sae_pw_id_used : 1;
 	bool sae_pw_id_exclusive : 1;
 	bool have_snr : 1;
+	bool have_utilization : 1;
 };
 
 struct scan_parameters {