aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/nl80211.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-02-21 14:09:09 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-03-06 10:35:49 -0500
commitf62fab735e99af2190eba03f565adaca5c002882 (patch)
tree450eb619c553539cc7515b16499d77a698b17029 /net/wireless/nl80211.c
parentdd5ecfeac8d1a96d0aba6bbcaec431756f8d8854 (diff)
cfg80211: refactor association parameters
cfg80211_mlme_assoc() has grown far too many arguments, make the caller build almost all of the driver struct and pass that to the function instead. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r--net/wireless/nl80211.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6a5893f5e481..3acde3f88d3a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5984,16 +5984,10 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
5984{ 5984{
5985 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 5985 struct cfg80211_registered_device *rdev = info->user_ptr[0];
5986 struct net_device *dev = info->user_ptr[1]; 5986 struct net_device *dev = info->user_ptr[1];
5987 struct cfg80211_crypto_settings crypto;
5988 struct ieee80211_channel *chan; 5987 struct ieee80211_channel *chan;
5989 const u8 *bssid, *ssid, *ie = NULL, *prev_bssid = NULL; 5988 struct cfg80211_assoc_request req = {};
5990 int err, ssid_len, ie_len = 0; 5989 const u8 *bssid, *ssid;
5991 bool use_mfp = false; 5990 int err, ssid_len = 0;
5992 u32 flags = 0;
5993 struct ieee80211_ht_cap *ht_capa = NULL;
5994 struct ieee80211_ht_cap *ht_capa_mask = NULL;
5995 struct ieee80211_vht_cap *vht_capa = NULL;
5996 struct ieee80211_vht_cap *vht_capa_mask = NULL;
5997 5991
5998 if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) 5992 if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
5999 return -EINVAL; 5993 return -EINVAL;
@@ -6021,54 +6015,58 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
6021 ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); 6015 ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]);
6022 6016
6023 if (info->attrs[NL80211_ATTR_IE]) { 6017 if (info->attrs[NL80211_ATTR_IE]) {
6024 ie = nla_data(info->attrs[NL80211_ATTR_IE]); 6018 req.ie = nla_data(info->attrs[NL80211_ATTR_IE]);
6025 ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); 6019 req.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
6026 } 6020 }
6027 6021
6028 if (info->attrs[NL80211_ATTR_USE_MFP]) { 6022 if (info->attrs[NL80211_ATTR_USE_MFP]) {
6029 enum nl80211_mfp mfp = 6023 enum nl80211_mfp mfp =
6030 nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]); 6024 nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]);
6031 if (mfp == NL80211_MFP_REQUIRED) 6025 if (mfp == NL80211_MFP_REQUIRED)
6032 use_mfp = true; 6026 req.use_mfp = true;
6033 else if (mfp != NL80211_MFP_NO) 6027 else if (mfp != NL80211_MFP_NO)
6034 return -EINVAL; 6028 return -EINVAL;
6035 } 6029 }
6036 6030
6037 if (info->attrs[NL80211_ATTR_PREV_BSSID]) 6031 if (info->attrs[NL80211_ATTR_PREV_BSSID])
6038 prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]); 6032 req.prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]);
6039 6033
6040 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT])) 6034 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT]))
6041 flags |= ASSOC_REQ_DISABLE_HT; 6035 req.flags |= ASSOC_REQ_DISABLE_HT;
6042 6036
6043 if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) 6037 if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
6044 ht_capa_mask = 6038 memcpy(&req.ht_capa_mask,
6045 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]); 6039 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]),
6040 sizeof(req.ht_capa_mask));
6046 6041
6047 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) { 6042 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) {
6048 if (!ht_capa_mask) 6043 if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
6049 return -EINVAL; 6044 return -EINVAL;
6050 ht_capa = nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); 6045 memcpy(&req.ht_capa,
6046 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]),
6047 sizeof(req.ht_capa));
6051 } 6048 }
6052 6049
6053 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT])) 6050 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT]))
6054 flags |= ASSOC_REQ_DISABLE_VHT; 6051 req.flags |= ASSOC_REQ_DISABLE_VHT;
6055 6052
6056 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) 6053 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK])
6057 vht_capa_mask = 6054 memcpy(&req.vht_capa_mask,
6058 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]); 6055 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]),
6056 sizeof(req.vht_capa_mask));
6059 6057
6060 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) { 6058 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) {
6061 if (!vht_capa_mask) 6059 if (!info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK])
6062 return -EINVAL; 6060 return -EINVAL;
6063 vht_capa = nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); 6061 memcpy(&req.vht_capa,
6062 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]),
6063 sizeof(req.vht_capa));
6064 } 6064 }
6065 6065
6066 err = nl80211_crypto_settings(rdev, info, &crypto, 1); 6066 err = nl80211_crypto_settings(rdev, info, &req.crypto, 1);
6067 if (!err) 6067 if (!err)
6068 err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, 6068 err = cfg80211_mlme_assoc(rdev, dev, chan, bssid,
6069 ssid, ssid_len, ie, ie_len, use_mfp, 6069 ssid, ssid_len, &req);
6070 &crypto, flags, ht_capa, ht_capa_mask,
6071 vht_capa, vht_capa_mask);
6072 6070
6073 return err; 6071 return err;
6074} 6072}