Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 1/4] wiphy: add wiphy_can_offload API
Date: Wed, 03 Mar 2021 09:47:27 -0800	[thread overview]
Message-ID: <20210303174730.6738-1-prestwoj@gmail.com> (raw)

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

This checks if offload is an available extended feature and
compatible with the desired BSS. It is also conditional on
the [General].PreferOffload setting which, for now, is being
added as a 'hidden' developer feature (not documented).
---
 src/wiphy.c | 33 +++++++++++++++++++++++++++++++++
 src/wiphy.h |  1 +
 2 files changed, 34 insertions(+)

diff --git a/src/wiphy.c b/src/wiphy.c
index 3adc5669..2493e8eb 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -412,6 +412,39 @@ bool wiphy_can_randomize_mac_addr(struct wiphy *wiphy)
 	return wiphy_has_feature(wiphy, NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR);
 }
 
+bool wiphy_can_offload(struct wiphy *wiphy, struct scan_bss *bss)
+{
+	struct ie_rsn_info rsn_info;
+	int r;
+	bool prefer_offload = false;
+
+	if (!wiphy_has_ext_feature(wiphy,
+				NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK))
+		return false;
+
+	if (!l_settings_get_bool(iwd_get_config(), "General", "PreferOffload",
+				&prefer_offload) || !prefer_offload)
+		return false;
+
+	memset(&rsn_info, 0, sizeof(rsn_info));
+	r = scan_bss_get_rsn_info(bss, &rsn_info);
+
+	if (r < 0)
+		return false;
+
+	/*
+	 * For now offload is only allowed on PSK networks.
+	 */
+	switch (rsn_info.akm_suites) {
+	case IE_RSN_AKM_SUITE_PSK:
+	case IE_RSN_AKM_SUITE_PSK_SHA256:
+		return true;
+	default:
+		return false;
+	}
+}
+
+
 bool wiphy_rrm_capable(struct wiphy *wiphy)
 {
 	if (wiphy_has_feature(wiphy,
diff --git a/src/wiphy.h b/src/wiphy.h
index 50c8c936..016e5879 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -80,6 +80,7 @@ const struct scan_freq_set *wiphy_get_supported_freqs(
 						const struct wiphy *wiphy);
 bool wiphy_can_connect(struct wiphy *wiphy, struct scan_bss *bss);
 bool wiphy_can_randomize_mac_addr(struct wiphy *wiphy);
+bool wiphy_can_offload(struct wiphy *wiphy, struct scan_bss *bss);
 bool wiphy_rrm_capable(struct wiphy *wiphy);
 bool wiphy_has_feature(struct wiphy *wiphy, uint32_t feature);
 bool wiphy_has_ext_feature(struct wiphy *wiphy, uint32_t feature);
-- 
2.26.2

             reply	other threads:[~2021-03-03 17:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 17:47 James Prestwood [this message]
2021-03-03 17:47 ` [PATCH 2/4] handshake: add offload member James Prestwood
2021-03-03 20:42   ` Denis Kenzior
2021-03-03 17:47 ` [PATCH 3/4] station: set handshake offload if supported James Prestwood
2021-03-03 20:50   ` Denis Kenzior
2021-03-03 17:47 ` [PATCH 4/4] netdev: offload handshake when requested James Prestwood
2021-03-03 20:41 ` [PATCH 1/4] wiphy: add wiphy_can_offload API 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=20210303174730.6738-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox