diff options
author | Jouni Malinen <j@w1.fi> | 2014-01-14 17:01:44 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2014-02-04 15:48:09 -0500 |
commit | 664834dee63c55188093bb5f295283c7693003d6 (patch) | |
tree | 434f04f54dc845a0b6cde5c8f685cb6eae7e43a1 /net/wireless | |
parent | b43504cf75b8b8773ee70c90bcd691282e151b9a (diff) |
cfg80211: Clean up connect params and channel fetching
Addition of the frequency hints showed up couple of places in cfg80211
where pointers could be marked const and a shared function could be used
to fetch a valid channel.
Signed-off-by: Jouni Malinen <j@w1.fi>
[fix mwifiex]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/nl80211.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index b2ac1410b113..09b6da8ffdfe 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -857,6 +857,19 @@ static int nl80211_key_allowed(struct wireless_dev *wdev) | |||
857 | return 0; | 857 | return 0; |
858 | } | 858 | } |
859 | 859 | ||
860 | static struct ieee80211_channel *nl80211_get_valid_chan(struct wiphy *wiphy, | ||
861 | struct nlattr *tb) | ||
862 | { | ||
863 | struct ieee80211_channel *chan; | ||
864 | |||
865 | if (tb == NULL) | ||
866 | return NULL; | ||
867 | chan = ieee80211_get_channel(wiphy, nla_get_u32(tb)); | ||
868 | if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) | ||
869 | return NULL; | ||
870 | return chan; | ||
871 | } | ||
872 | |||
860 | static int nl80211_put_iftypes(struct sk_buff *msg, u32 attr, u16 ifmodes) | 873 | static int nl80211_put_iftypes(struct sk_buff *msg, u32 attr, u16 ifmodes) |
861 | { | 874 | { |
862 | struct nlattr *nl_modes = nla_nest_start(msg, attr); | 875 | struct nlattr *nl_modes = nla_nest_start(msg, attr); |
@@ -6199,9 +6212,9 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) | |||
6199 | return -EOPNOTSUPP; | 6212 | return -EOPNOTSUPP; |
6200 | 6213 | ||
6201 | bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); | 6214 | bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); |
6202 | chan = ieee80211_get_channel(&rdev->wiphy, | 6215 | chan = nl80211_get_valid_chan(&rdev->wiphy, |
6203 | nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ])); | 6216 | info->attrs[NL80211_ATTR_WIPHY_FREQ]); |
6204 | if (!chan || (chan->flags & IEEE80211_CHAN_DISABLED)) | 6217 | if (!chan) |
6205 | return -EINVAL; | 6218 | return -EINVAL; |
6206 | 6219 | ||
6207 | ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); | 6220 | ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); |
@@ -6354,9 +6367,9 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) | |||
6354 | 6367 | ||
6355 | bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); | 6368 | bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); |
6356 | 6369 | ||
6357 | chan = ieee80211_get_channel(&rdev->wiphy, | 6370 | chan = nl80211_get_valid_chan(&rdev->wiphy, |
6358 | nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ])); | 6371 | info->attrs[NL80211_ATTR_WIPHY_FREQ]); |
6359 | if (!chan || (chan->flags & IEEE80211_CHAN_DISABLED)) | 6372 | if (!chan) |
6360 | return -EINVAL; | 6373 | return -EINVAL; |
6361 | 6374 | ||
6362 | ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); | 6375 | ssid = nla_data(info->attrs[NL80211_ATTR_SSID]); |
@@ -7013,19 +7026,14 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) | |||
7013 | } | 7026 | } |
7014 | 7027 | ||
7015 | if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { | 7028 | if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { |
7016 | connect.channel = | 7029 | connect.channel = nl80211_get_valid_chan( |
7017 | ieee80211_get_channel(wiphy, | 7030 | wiphy, info->attrs[NL80211_ATTR_WIPHY_FREQ]); |
7018 | nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ])); | 7031 | if (!connect.channel) |
7019 | if (!connect.channel || | ||
7020 | connect.channel->flags & IEEE80211_CHAN_DISABLED) | ||
7021 | return -EINVAL; | 7032 | return -EINVAL; |
7022 | } else if (info->attrs[NL80211_ATTR_WIPHY_FREQ_HINT]) { | 7033 | } else if (info->attrs[NL80211_ATTR_WIPHY_FREQ_HINT]) { |
7023 | connect.channel_hint = | 7034 | connect.channel_hint = nl80211_get_valid_chan( |
7024 | ieee80211_get_channel(wiphy, | 7035 | wiphy, info->attrs[NL80211_ATTR_WIPHY_FREQ_HINT]); |
7025 | nla_get_u32( | 7036 | if (!connect.channel_hint) |
7026 | info->attrs[NL80211_ATTR_WIPHY_FREQ_HINT])); | ||
7027 | if (!connect.channel_hint || | ||
7028 | connect.channel_hint->flags & IEEE80211_CHAN_DISABLED) | ||
7029 | return -EINVAL; | 7037 | return -EINVAL; |
7030 | } | 7038 | } |
7031 | 7039 | ||