aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/util.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2011-07-18 12:08:35 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-07-19 16:49:58 -0400
commit34850ab25d74ab4eead62c3b4a9e8036a25cc669 (patch)
treec1aa56f2d94851804969b71523ade13bb9db693c /net/wireless/util.c
parent0b5dd734d3545a9833c0bceeed5088ad9a1ca5e3 (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.c35
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,
1006 1006
1007 return -EBUSY; 1007 return -EBUSY;
1008} 1008}
1009
1010int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
1011 const u8 *rates, unsigned int n_rates,
1012 u32 *mask)
1013{
1014 int i, j;
1015
1016 if (n_rates == 0 || n_rates > NL80211_MAX_SUPP_RATES)
1017 return -EINVAL;
1018
1019 *mask = 0;
1020
1021 for (i = 0; i < n_rates; i++) {
1022 int rate = (rates[i] & 0x7f) * 5;
1023 bool found = false;
1024
1025 for (j = 0; j < sband->n_bitrates; j++) {
1026 if (sband->bitrates[j].bitrate == rate) {
1027 found = true;
1028 *mask |= BIT(j);
1029 break;
1030 }
1031 }
1032 if (!found)
1033 return -EINVAL;
1034 }
1035
1036 /*
1037 * mask must have at least one bit set here since we
1038 * didn't accept a 0-length rates array nor allowed
1039 * entries in the array that didn't exist
1040 */
1041
1042 return 0;
1043}