aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/nl80211.c
diff options
context:
space:
mode:
authorSimon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>2013-06-14 08:15:19 -0400
committerJohannes Berg <johannes.berg@intel.com>2013-06-18 09:55:19 -0400
commita1193be83b4bb173228f04870afd6a4174b19130 (patch)
tree9f836467b3af7a96af461d4d8bf55c58a40acc0a /net/wireless/nl80211.c
parent38745c7414c0d9a0567c5b4a4e056c6b7f807179 (diff)
nl80211: use attributes to parse beacons
only the attributes are required and not the whole netlink info, as the function accesses the attributes only anyway. This makes it easier to parse nested beacon IEs later. Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r--net/wireless/nl80211.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index e4028197b75d..1c4f7daea6c7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2882,61 +2882,58 @@ static int nl80211_set_mac_acl(struct sk_buff *skb, struct genl_info *info)
2882 return err; 2882 return err;
2883} 2883}
2884 2884
2885static int nl80211_parse_beacon(struct genl_info *info, 2885static int nl80211_parse_beacon(struct nlattr *attrs[],
2886 struct cfg80211_beacon_data *bcn) 2886 struct cfg80211_beacon_data *bcn)
2887{ 2887{
2888 bool haveinfo = false; 2888 bool haveinfo = false;
2889 2889
2890 if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_BEACON_TAIL]) || 2890 if (!is_valid_ie_attr(attrs[NL80211_ATTR_BEACON_TAIL]) ||
2891 !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]) || 2891 !is_valid_ie_attr(attrs[NL80211_ATTR_IE]) ||
2892 !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE_PROBE_RESP]) || 2892 !is_valid_ie_attr(attrs[NL80211_ATTR_IE_PROBE_RESP]) ||
2893 !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE_ASSOC_RESP])) 2893 !is_valid_ie_attr(attrs[NL80211_ATTR_IE_ASSOC_RESP]))
2894 return -EINVAL; 2894 return -EINVAL;
2895 2895
2896 memset(bcn, 0, sizeof(*bcn)); 2896 memset(bcn, 0, sizeof(*bcn));
2897 2897
2898 if (info->attrs[NL80211_ATTR_BEACON_HEAD]) { 2898 if (attrs[NL80211_ATTR_BEACON_HEAD]) {
2899 bcn->head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]); 2899 bcn->head = nla_data(attrs[NL80211_ATTR_BEACON_HEAD]);
2900 bcn->head_len = nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]); 2900 bcn->head_len = nla_len(attrs[NL80211_ATTR_BEACON_HEAD]);
2901 if (!bcn->head_len) 2901 if (!bcn->head_len)
2902 return -EINVAL; 2902 return -EINVAL;
2903 haveinfo = true; 2903 haveinfo = true;
2904 } 2904 }
2905 2905
2906 if (info->attrs[NL80211_ATTR_BEACON_TAIL]) { 2906 if (attrs[NL80211_ATTR_BEACON_TAIL]) {
2907 bcn->tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]); 2907 bcn->tail = nla_data(attrs[NL80211_ATTR_BEACON_TAIL]);
2908 bcn->tail_len = 2908 bcn->tail_len = nla_len(attrs[NL80211_ATTR_BEACON_TAIL]);
2909 nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]);
2910 haveinfo = true; 2909 haveinfo = true;
2911 } 2910 }
2912 2911
2913 if (!haveinfo) 2912 if (!haveinfo)
2914 return -EINVAL; 2913 return -EINVAL;
2915 2914
2916 if (info->attrs[NL80211_ATTR_IE]) { 2915 if (attrs[NL80211_ATTR_IE]) {
2917 bcn->beacon_ies = nla_data(info->attrs[NL80211_ATTR_IE]); 2916 bcn->beacon_ies = nla_data(attrs[NL80211_ATTR_IE]);
2918 bcn->beacon_ies_len = nla_len(info->attrs[NL80211_ATTR_IE]); 2917 bcn->beacon_ies_len = nla_len(attrs[NL80211_ATTR_IE]);
2919 } 2918 }
2920 2919
2921 if (info->attrs[NL80211_ATTR_IE_PROBE_RESP]) { 2920 if (attrs[NL80211_ATTR_IE_PROBE_RESP]) {
2922 bcn->proberesp_ies = 2921 bcn->proberesp_ies =
2923 nla_data(info->attrs[NL80211_ATTR_IE_PROBE_RESP]); 2922 nla_data(attrs[NL80211_ATTR_IE_PROBE_RESP]);
2924 bcn->proberesp_ies_len = 2923 bcn->proberesp_ies_len =
2925 nla_len(info->attrs[NL80211_ATTR_IE_PROBE_RESP]); 2924 nla_len(attrs[NL80211_ATTR_IE_PROBE_RESP]);
2926 } 2925 }
2927 2926
2928 if (info->attrs[NL80211_ATTR_IE_ASSOC_RESP]) { 2927 if (attrs[NL80211_ATTR_IE_ASSOC_RESP]) {
2929 bcn->assocresp_ies = 2928 bcn->assocresp_ies =
2930 nla_data(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]); 2929 nla_data(attrs[NL80211_ATTR_IE_ASSOC_RESP]);
2931 bcn->assocresp_ies_len = 2930 bcn->assocresp_ies_len =
2932 nla_len(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]); 2931 nla_len(attrs[NL80211_ATTR_IE_ASSOC_RESP]);
2933 } 2932 }
2934 2933
2935 if (info->attrs[NL80211_ATTR_PROBE_RESP]) { 2934 if (attrs[NL80211_ATTR_PROBE_RESP]) {
2936 bcn->probe_resp = 2935 bcn->probe_resp = nla_data(attrs[NL80211_ATTR_PROBE_RESP]);
2937 nla_data(info->attrs[NL80211_ATTR_PROBE_RESP]); 2936 bcn->probe_resp_len = nla_len(attrs[NL80211_ATTR_PROBE_RESP]);
2938 bcn->probe_resp_len =
2939 nla_len(info->attrs[NL80211_ATTR_PROBE_RESP]);
2940 } 2937 }
2941 2938
2942 return 0; 2939 return 0;
@@ -3015,7 +3012,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
3015 !info->attrs[NL80211_ATTR_BEACON_HEAD]) 3012 !info->attrs[NL80211_ATTR_BEACON_HEAD])
3016 return -EINVAL; 3013 return -EINVAL;
3017 3014
3018 err = nl80211_parse_beacon(info, &params.beacon); 3015 err = nl80211_parse_beacon(info->attrs, &params.beacon);
3019 if (err) 3016 if (err)
3020 return err; 3017 return err;
3021 3018
@@ -3167,7 +3164,7 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info)
3167 if (!wdev->beacon_interval) 3164 if (!wdev->beacon_interval)
3168 return -EINVAL; 3165 return -EINVAL;
3169 3166
3170 err = nl80211_parse_beacon(info, &params); 3167 err = nl80211_parse_beacon(info->attrs, &params);
3171 if (err) 3168 if (err)
3172 return err; 3169 return err;
3173 3170