---
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