All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH 4/4] scan: Separate cck rates attr creation into logical block
Date: Fri, 08 Nov 2019 17:04:02 -0500	[thread overview]
Message-ID: <20191108220402.10282-4-tim.a.kourt@linux.intel.com> (raw)
In-Reply-To: <20191108220402.10282-1-tim.a.kourt@linux.intel.com>

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

---
 src/scan.c | 82 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 42 insertions(+), 40 deletions(-)

diff --git a/src/scan.c b/src/scan.c
index a3d6e5d8..f99ad1e7 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -308,6 +308,45 @@ static void scan_build_attr_ie(struct l_genl_msg *msg,
 	l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, iov_elems);
 }
 
+static void scan_build_attr_tx_no_cck_rates(struct l_genl_msg *msg,
+							struct scan_context *sc)
+{
+	static const uint8_t b_rates[] = { 2, 4, 11, 22 };
+	uint8_t *scan_rates;
+	const uint8_t *supported;
+	unsigned int num_supported;
+	unsigned int count;
+	unsigned int i;
+
+	l_genl_msg_append_attr(msg, NL80211_ATTR_TX_NO_CCK_RATE, 0, NULL);
+
+	/*
+	 * Assume if we're sending the probe requests at OFDM bit
+	 * rates we don't want to advertise support for 802.11b rates.
+	 */
+	if (L_WARN_ON(!(supported = wiphy_get_supported_rates(sc->wiphy,
+							NL80211_BAND_2GHZ,
+							&num_supported))))
+		return;
+
+	scan_rates = l_malloc(num_supported);
+
+	for (count = 0, i = 0; i < num_supported; i++)
+		if (!memchr(b_rates, supported[i], L_ARRAY_SIZE(b_rates)))
+			scan_rates[count++] = supported[i];
+
+	if (L_WARN_ON(!count)) {
+		l_free(scan_rates);
+		return;
+	}
+
+	l_genl_msg_enter_nested(msg, NL80211_ATTR_SCAN_SUPP_RATES);
+	l_genl_msg_append_attr(msg, NL80211_BAND_2GHZ, count, scan_rates);
+	l_genl_msg_leave_nested(msg);
+
+	l_free(scan_rates);
+}
+
 static bool scan_mac_address_randomization_is_disabled(void)
 {
 	const struct l_settings *config = iwd_get_config();
@@ -338,6 +377,9 @@ static struct l_genl_msg *scan_build_cmd(struct scan_context *sc,
 	if (params->freqs)
 		scan_build_attr_scan_frequencies(msg, params->freqs);
 
+	if (params->no_cck_rates)
+		scan_build_attr_tx_no_cck_rates(msg, sc);
+
 	if (params->flush && !ignore_flush_flag)
 		flags |= NL80211_SCAN_FLAG_FLUSH;
 
@@ -357,46 +399,6 @@ static struct l_genl_msg *scan_build_cmd(struct scan_context *sc,
 	if (flags)
 		l_genl_msg_append_attr(msg, NL80211_ATTR_SCAN_FLAGS, 4, &flags);
 
-	if (params->no_cck_rates) {
-		static const uint8_t b_rates[] = { 2, 4, 11, 22 };
-		uint8_t *scan_rates;
-		const uint8_t *supported;
-		unsigned int num_supported;
-		unsigned int count;
-		unsigned int i;
-
-		l_genl_msg_append_attr(msg, NL80211_ATTR_TX_NO_CCK_RATE, 0,
-					NULL);
-
-		/*
-		 * Assume if we're sending the probe requests at OFDM bit
-		 * rates we don't want to advertise support for 802.11b rates.
-		 */
-		if (L_WARN_ON(!(supported = wiphy_get_supported_rates(sc->wiphy,
-							NL80211_BAND_2GHZ,
-							&num_supported))))
-			goto done;
-
-		scan_rates = l_malloc(num_supported);
-
-		for (count = 0, i = 0; i < num_supported; i++)
-			if (!memchr(b_rates, supported[i],
-						L_ARRAY_SIZE(b_rates)))
-				scan_rates[count++] = supported[i];
-
-		if (L_WARN_ON(!count)) {
-			l_free(scan_rates);
-			goto done;
-		}
-
-		l_genl_msg_enter_nested(msg, NL80211_ATTR_SCAN_SUPP_RATES);
-		l_genl_msg_append_attr(msg, NL80211_BAND_2GHZ,
-							count, scan_rates);
-		l_genl_msg_leave_nested(msg);
-		l_free(scan_rates);
-	}
-
-done:
 	return msg;
 }
 
-- 
2.21.0

  parent reply	other threads:[~2019-11-08 22:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-08 22:03 [PATCH 1/4] scan: Improve comment Tim Kourt
2019-11-08 22:04 ` [PATCH 2/4] scan: Fix bit checking for interworking Tim Kourt
2019-11-08 22:04 ` [PATCH 3/4] scan: Separate IE attr creation into logical block Tim Kourt
2019-11-08 22:04 ` Tim Kourt [this message]
2019-11-09  2:06   ` [PATCH 4/4] scan: Separate cck rates " Marcel Holtmann
2019-11-09  2:40     ` Denis Kenzior
2019-11-09  3:21       ` Marcel Holtmann
2019-11-09  3:33         ` Denis Kenzior
2019-11-09  3:42           ` Marcel Holtmann
2019-11-09  3:46             ` Denis Kenzior
2019-11-09  3:08   ` Denis Kenzior
2019-11-09  3:06 ` [PATCH 1/4] scan: Improve comment 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=20191108220402.10282-4-tim.a.kourt@linux.intel.com \
    --to=tim.a.kourt@linux.intel.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.