diff mbox

[RFC,4/4] scan: Use specified legacy rateset in probe requests.

Message ID 1444928885-4909-4-git-send-email-greearb@candelatech.com
State RFC
Headers show

Commit Message

Ben Greear Oct. 15, 2015, 5:08 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

If user has specified a legacy rateset, then use that in
probe requests so that the proper rates are advertised on
the air.

Could do the same with HT/VHT rates someday perhaps.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 src/drivers/driver_nl80211_scan.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox

Patch

diff --git a/src/drivers/driver_nl80211_scan.c b/src/drivers/driver_nl80211_scan.c
index 4b762ea..1a64cbe 100644
--- a/src/drivers/driver_nl80211_scan.c
+++ b/src/drivers/driver_nl80211_scan.c
@@ -111,6 +111,8 @@  nl80211_scan_common(struct i802_bss *bss, u8 cmd,
 	struct nl_msg *msg;
 	size_t i;
 	u32 scan_flags = 0;
+	struct nlattr *nlrates;
+	unsigned char rates[12];
 
 	msg = nl80211_cmd_msg(bss, 0, cmd);
 	if (!msg)
@@ -133,6 +135,30 @@  nl80211_scan_common(struct i802_bss *bss, u8 cmd,
 		nla_nest_end(msg, ssids);
 	}
 
+	i = nl80211_build_legacy_rateset(bss->adv_legacy_rates, 0, rates);
+	if (bss->adv_legacy_rates & (1<<31)) {
+		/* User has specified a legacy rateset, use it. */
+		nlrates = nla_nest_start(msg, NL80211_ATTR_SCAN_SUPP_RATES);
+		if (!nlrates)
+			goto fail;
+
+		if (nla_put(msg, NL80211_BAND_2GHZ, i, rates))
+			goto fail;
+
+		/* If only /b rates are set, then we will just ignore
+                 * setting 5Ghz at all and assume that other config will keep
+                 * us from trying to use that band.
+		 */
+		if (bss->adv_legacy_rates & 0xFF0) {
+			i = nl80211_build_legacy_rateset(bss->adv_legacy_rates, 1, rates);
+			if (nla_put(msg, NL80211_BAND_5GHZ, i, rates))
+				goto fail;
+		}
+
+		/* TODO:  Someday pay attention to individual HT/VHT rates as well? */
+		nla_nest_end(msg, nlrates);
+	}
+
 	if (params->extra_ies) {
 		wpa_hexdump(MSG_MSGDUMP, "nl80211: Scan extra IEs",
 			    params->extra_ies, params->extra_ies_len);