All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH v2 3/7] network: use WPA version and privacy for ranking
Date: Fri, 07 May 2021 13:26:16 -0700	[thread overview]
Message-ID: <20210507202620.93540-3-prestwoj@gmail.com> (raw)
In-Reply-To: <20210507202620.93540-1-prestwoj@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1559 bytes --]

These ranking factors were moved out of scan.c and into
network.c as they are more relevant for network ranking
than BSS ranking.
---
 src/network.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/network.c b/src/network.c
index 5bd57777..feedf99f 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1446,6 +1446,10 @@ int network_rank_compare(const void *a, const void *b, void *user)
 
 void network_rank_update(struct network *network, bool connected)
 {
+	static const double RANK_RSNE_FACTOR = 1.2;
+	static const double RANK_WPA_FACTOR = 1.0;
+	static const double RANK_OPEN_FACTOR = 0.5;
+	static const double RANK_NO_PRIVACY_FACTOR = 0.5;
 	/*
 	 * Theoretically there may be difference between the BSS selection
 	 * here and in network_bss_select but those should be rare cases.
@@ -1485,6 +1489,21 @@ void network_rank_update(struct network *network, bool connected)
 		network->rank = rankmod_table[n] * best_bss->rank + USHRT_MAX;
 	} else
 		network->rank = best_bss->rank;
+
+	/*
+	 * Prefer RSNE first, WPA second.  Open networks are much less
+	 * desirable.
+	 */
+	if (best_bss->rsne)
+		network->rank *= RANK_RSNE_FACTOR;
+	else if (best_bss->wpa)
+		network->rank *= RANK_WPA_FACTOR;
+	else
+		network->rank *= RANK_OPEN_FACTOR;
+
+	/* We prefer networks with CAP PRIVACY */
+	if (!(best_bss->capability & IE_BSS_CAP_PRIVACY))
+		network->rank *= RANK_NO_PRIVACY_FACTOR;
 }
 
 static void network_unset_hotspot(struct network *network, void *user_data)
-- 
2.31.1

  parent reply	other threads:[~2021-05-07 20:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 20:26 [PATCH v2 1/7] ie: fix ie_parse_data_rates to handle NULL James Prestwood
2021-05-07 20:26 ` [PATCH v2 2/7] scan: rework BSS ranking James Prestwood
2021-05-19 15:00   ` Denis Kenzior
2021-05-07 20:26 ` James Prestwood [this message]
2021-05-07 20:26 ` [PATCH v2 4/7] station: autoconnect based on network, not BSS James Prestwood
2021-05-07 20:26 ` [PATCH v2 5/7] netdev: introduce [General].RoamThreshold5G James Prestwood
2021-05-07 20:26 ` [PATCH v2 6/7] doc: document [General].RoamThreshold5G James Prestwood
2021-05-10 15:13   ` Denis Kenzior
2021-05-07 20:26 ` [PATCH v2 7/7] test-runner: remove stale file after test James Prestwood
2021-05-10 15:09 ` [PATCH v2 1/7] ie: fix ie_parse_data_rates to handle NULL Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210507202620.93540-3-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.