diff options
author | Johannes Berg <johannes.berg@intel.com> | 2011-07-18 18:08:35 +0200 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-07-19 16:49:58 -0400 |
commit | 34850ab25d74ab4eead62c3b4a9e8036a25cc669 (patch) | |
tree | c1aa56f2d94851804969b71523ade13bb9db693c /net/wireless/util.c | |
parent | 0b5dd734d3545a9833c0bceeed5088ad9a1ca5e3 (diff) |
cfg80211: allow userspace to control supported rates in scan
Some P2P scans are not allowed to advertise
11b rates, but that is a rather special case
so instead of having that, allow userspace
to request the rate sets (per band) that are
advertised in scan probe request frames.
Since it's needed in two places now, factor
out some common code parsing a rate array.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/util.c')
-rw-r--r-- | net/wireless/util.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/net/wireless/util.c b/net/wireless/util.c index 4d7b83fbc32f..a329429bfdd8 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -1006,3 +1006,38 @@ int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev, return -EBUSY; } + +int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, + const u8 *rates, unsigned int n_rates, + u32 *mask) +{ + int i, j; + + if (n_rates == 0 || n_rates > NL80211_MAX_SUPP_RATES) + return -EINVAL; + + *mask = 0; + + for (i = 0; i < n_rates; i++) { + int rate = (rates[i] & 0x7f) * 5; + bool found = false; + + for (j = 0; j < sband->n_bitrates; j++) { + if (sband->bitrates[j].bitrate == rate) { + found = true; + *mask |= BIT(j); + break; + } + } + if (!found) + return -EINVAL; + } + + /* + * mask must have at least one bit set here since we + * didn't accept a 0-length rates array nor allowed + * entries in the array that didn't exist + */ + + return 0; +} |