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>
This commit is contained in:
committed by
John W. Linville
parent
0b5dd734d3
commit
34850ab25d
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user