diff options
author | Andrew Dodd <atd7@cornell.edu> | 2013-02-16 18:50:12 -0500 |
---|---|---|
committer | Andrew Dodd <atd7@cornell.edu> | 2013-02-27 09:19:15 -0500 |
commit | 3cedbff33e9884fdf3f7aaaa83ab9774d8145d1f (patch) | |
tree | c150f93f01c3e33e310abdb7495c8f3c26ae73e3 /net/wireless/util.c | |
parent | 78eca744f2700e1bb0d4ac93c944329d82006e16 (diff) | |
download | kernel_samsung_smdk4412-3cedbff33e9884fdf3f7aaaa83ab9774d8145d1f.zip kernel_samsung_smdk4412-3cedbff33e9884fdf3f7aaaa83ab9774d8145d1f.tar.gz kernel_samsung_smdk4412-3cedbff33e9884fdf3f7aaaa83ab9774d8145d1f.tar.bz2 |
wireless backport from 3.4
Courtesy of Brian Beloshapka (bbelos)
Change-Id: I4b0a8d591bfe57c9f69943ecaf2fa80e772fde8e
Diffstat (limited to 'net/wireless/util.c')
-rw-r--r-- | net/wireless/util.c | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/net/wireless/util.c b/net/wireless/util.c index 4435a9a..ebc7d09 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -150,12 +150,19 @@ void ieee80211_set_bitrate_flags(struct wiphy *wiphy) set_mandatory_flags_band(wiphy->bands[band], band); } +bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher) +{ + int i; + for (i = 0; i < wiphy->n_cipher_suites; i++) + if (cipher == wiphy->cipher_suites[i]) + return true; + return false; +} + int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, struct key_params *params, int key_idx, bool pairwise, const u8 *mac_addr) { - int i; - if (key_idx > 5) return -EINVAL; @@ -199,6 +206,10 @@ int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, if (params->key_len != WLAN_KEY_LEN_AES_CMAC) return -EINVAL; break; + case WLAN_CIPHER_SUITE_SMS4: + if (params->key_len != WLAN_KEY_LEN_WAPI_SMS4) + return -EINVAL; + break; default: /* * We don't know anything about this algorithm, @@ -225,10 +236,7 @@ int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev, } } - for (i = 0; i < rdev->wiphy.n_cipher_suites; i++) - if (params->cipher == rdev->wiphy.cipher_suites[i]) - break; - if (i == rdev->wiphy.n_cipher_suites) + if (!cfg80211_supported_cipher_suite(&rdev->wiphy, params->cipher)) return -EINVAL; return 0; @@ -1027,3 +1035,40 @@ 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 (!sband) + return -EINVAL; + + 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; +} |