diff options
author | Johannes Berg <johannes.berg@intel.com> | 2013-02-14 18:09:01 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-03-06 10:35:39 -0500 |
commit | ff276691e9f13bc1619cc8f091fb887c2b4f98a1 (patch) | |
tree | 13f16186f9eff3d4fb18272b71c4d0d6fb2c6e72 /net | |
parent | 984c311b0918248e0835334c41cb16856f3c5697 (diff) |
cfg80211: unify station WME parsing
Instead of copying the code, create a new function
to parse the station's WME information.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/wireless/nl80211.c | 53 |
1 files changed, 19 insertions, 34 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 3b82f95b1a7c..9e7c10420da8 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -3359,21 +3359,13 @@ nl80211_sta_wme_policy[NL80211_STA_WME_MAX + 1] __read_mostly = { | |||
3359 | [NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 }, | 3359 | [NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 }, |
3360 | }; | 3360 | }; |
3361 | 3361 | ||
3362 | static int nl80211_set_station_tdls(struct genl_info *info, | 3362 | static int nl80211_parse_sta_wme(struct genl_info *info, |
3363 | struct station_parameters *params) | 3363 | struct station_parameters *params) |
3364 | { | 3364 | { |
3365 | struct nlattr *tb[NL80211_STA_WME_MAX + 1]; | 3365 | struct nlattr *tb[NL80211_STA_WME_MAX + 1]; |
3366 | struct nlattr *nla; | 3366 | struct nlattr *nla; |
3367 | int err; | 3367 | int err; |
3368 | 3368 | ||
3369 | /* Dummy STA entry gets updated once the peer capabilities are known */ | ||
3370 | if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) | ||
3371 | params->ht_capa = | ||
3372 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); | ||
3373 | if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) | ||
3374 | params->vht_capa = | ||
3375 | nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); | ||
3376 | |||
3377 | /* parse WME attributes if present */ | 3369 | /* parse WME attributes if present */ |
3378 | if (!info->attrs[NL80211_ATTR_STA_WME]) | 3370 | if (!info->attrs[NL80211_ATTR_STA_WME]) |
3379 | return 0; | 3371 | return 0; |
@@ -3401,6 +3393,20 @@ static int nl80211_set_station_tdls(struct genl_info *info, | |||
3401 | return 0; | 3393 | return 0; |
3402 | } | 3394 | } |
3403 | 3395 | ||
3396 | static int nl80211_set_station_tdls(struct genl_info *info, | ||
3397 | struct station_parameters *params) | ||
3398 | { | ||
3399 | /* Dummy STA entry gets updated once the peer capabilities are known */ | ||
3400 | if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) | ||
3401 | params->ht_capa = | ||
3402 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); | ||
3403 | if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) | ||
3404 | params->vht_capa = | ||
3405 | nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); | ||
3406 | |||
3407 | return nl80211_parse_sta_wme(info, params); | ||
3408 | } | ||
3409 | |||
3404 | static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) | 3410 | static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) |
3405 | { | 3411 | { |
3406 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 3412 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
@@ -3674,30 +3680,9 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) | |||
3674 | return -EINVAL; | 3680 | return -EINVAL; |
3675 | } | 3681 | } |
3676 | 3682 | ||
3677 | if (info->attrs[NL80211_ATTR_STA_WME]) { | 3683 | err = nl80211_parse_sta_wme(info, ¶ms); |
3678 | struct nlattr *tb[NL80211_STA_WME_MAX + 1]; | 3684 | if (err) |
3679 | struct nlattr *nla; | 3685 | return err; |
3680 | |||
3681 | nla = info->attrs[NL80211_ATTR_STA_WME]; | ||
3682 | err = nla_parse_nested(tb, NL80211_STA_WME_MAX, nla, | ||
3683 | nl80211_sta_wme_policy); | ||
3684 | if (err) | ||
3685 | return err; | ||
3686 | |||
3687 | if (tb[NL80211_STA_WME_UAPSD_QUEUES]) | ||
3688 | params.uapsd_queues = | ||
3689 | nla_get_u8(tb[NL80211_STA_WME_UAPSD_QUEUES]); | ||
3690 | if (params.uapsd_queues & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) | ||
3691 | return -EINVAL; | ||
3692 | |||
3693 | if (tb[NL80211_STA_WME_MAX_SP]) | ||
3694 | params.max_sp = nla_get_u8(tb[NL80211_STA_WME_MAX_SP]); | ||
3695 | |||
3696 | if (params.max_sp & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) | ||
3697 | return -EINVAL; | ||
3698 | |||
3699 | params.sta_modify_mask |= STATION_PARAM_APPLY_UAPSD; | ||
3700 | } | ||
3701 | 3686 | ||
3702 | if (parse_station_flags(info, dev->ieee80211_ptr->iftype, ¶ms)) | 3687 | if (parse_station_flags(info, dev->ieee80211_ptr->iftype, ¶ms)) |
3703 | return -EINVAL; | 3688 | return -EINVAL; |