commit 0be5beffc84aef9d2269e009caf8ffbd14049f7a
parent 3fde169001bda81b380503aeddc4393990ba551c
Author: James Prestwood <prestwoj@gmail.com>
Date: Fri, 7 May 2021 13:26:16 -0700
network: use WPA version and privacy for ranking
These ranking factors were moved out of scan.c and into
network.c as they are more relevant for network ranking
than BSS ranking.
Diffstat:
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/network.c b/src/network.c
@@ -1452,6 +1452,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.
@@ -1491,6 +1495,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)