nl80211.c (b9243ab0c9e3e4dbd54ae8f44cf0cdb5838c8746) nl80211.c (d1e33e654ef6bb3dee766353ed9dd31e7dcb8a94)
1/*
2 * This is the new netlink-based wireless configuration interface.
3 *
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
5 */
6
7#include <linux/if.h>
8#include <linux/module.h>

--- 7298 unchanged lines hidden (view full) ---

7307 }
7308
7309 return true;
7310}
7311
7312static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = {
7313 [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY,
7314 .len = NL80211_MAX_SUPP_RATES },
1/*
2 * This is the new netlink-based wireless configuration interface.
3 *
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
5 */
6
7#include <linux/if.h>
8#include <linux/module.h>

--- 7298 unchanged lines hidden (view full) ---

7307 }
7308
7309 return true;
7310}
7311
7312static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = {
7313 [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY,
7314 .len = NL80211_MAX_SUPP_RATES },
7315 [NL80211_TXRATE_MCS] = { .type = NLA_BINARY,
7316 .len = NL80211_MAX_SUPP_HT_RATES },
7315 [NL80211_TXRATE_HT] = { .type = NLA_BINARY,
7316 .len = NL80211_MAX_SUPP_HT_RATES },
7317};
7318
7319static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
7320 struct genl_info *info)
7321{
7322 struct nlattr *tb[NL80211_TXRATE_MAX + 1];
7323 struct cfg80211_registered_device *rdev = info->user_ptr[0];
7324 struct cfg80211_bitrate_mask mask;

--- 9 unchanged lines hidden (view full) ---

7334 /* Default to all rates enabled */
7335 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
7336 sband = rdev->wiphy.bands[i];
7337
7338 if (!sband)
7339 continue;
7340
7341 mask.control[i].legacy = (1 << sband->n_bitrates) - 1;
7317};
7318
7319static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
7320 struct genl_info *info)
7321{
7322 struct nlattr *tb[NL80211_TXRATE_MAX + 1];
7323 struct cfg80211_registered_device *rdev = info->user_ptr[0];
7324 struct cfg80211_bitrate_mask mask;

--- 9 unchanged lines hidden (view full) ---

7334 /* Default to all rates enabled */
7335 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
7336 sband = rdev->wiphy.bands[i];
7337
7338 if (!sband)
7339 continue;
7340
7341 mask.control[i].legacy = (1 << sband->n_bitrates) - 1;
7342 memcpy(mask.control[i].mcs,
7342 memcpy(mask.control[i].ht_mcs,
7343 sband->ht_cap.mcs.rx_mask,
7343 sband->ht_cap.mcs.rx_mask,
7344 sizeof(mask.control[i].mcs));
7344 sizeof(mask.control[i].ht_mcs));
7345 }
7346
7347 /* if no rates are given set it back to the defaults */
7348 if (!info->attrs[NL80211_ATTR_TX_RATES])
7349 goto out;
7350
7351 /*
7352 * The nested attribute uses enum nl80211_band as the index. This maps

--- 14 unchanged lines hidden (view full) ---

7367 mask.control[band].legacy = rateset_to_mask(
7368 sband,
7369 nla_data(tb[NL80211_TXRATE_LEGACY]),
7370 nla_len(tb[NL80211_TXRATE_LEGACY]));
7371 if ((mask.control[band].legacy == 0) &&
7372 nla_len(tb[NL80211_TXRATE_LEGACY]))
7373 return -EINVAL;
7374 }
7345 }
7346
7347 /* if no rates are given set it back to the defaults */
7348 if (!info->attrs[NL80211_ATTR_TX_RATES])
7349 goto out;
7350
7351 /*
7352 * The nested attribute uses enum nl80211_band as the index. This maps

--- 14 unchanged lines hidden (view full) ---

7367 mask.control[band].legacy = rateset_to_mask(
7368 sband,
7369 nla_data(tb[NL80211_TXRATE_LEGACY]),
7370 nla_len(tb[NL80211_TXRATE_LEGACY]));
7371 if ((mask.control[band].legacy == 0) &&
7372 nla_len(tb[NL80211_TXRATE_LEGACY]))
7373 return -EINVAL;
7374 }
7375 if (tb[NL80211_TXRATE_MCS]) {
7375 if (tb[NL80211_TXRATE_HT]) {
7376 if (!ht_rateset_to_mask(
7377 sband,
7376 if (!ht_rateset_to_mask(
7377 sband,
7378 nla_data(tb[NL80211_TXRATE_MCS]),
7379 nla_len(tb[NL80211_TXRATE_MCS]),
7380 mask.control[band].mcs))
7378 nla_data(tb[NL80211_TXRATE_HT]),
7379 nla_len(tb[NL80211_TXRATE_HT]),
7380 mask.control[band].ht_mcs))
7381 return -EINVAL;
7382 }
7383
7384 if (mask.control[band].legacy == 0) {
7385 /* don't allow empty legacy rates if HT
7386 * is not even supported. */
7387 if (!rdev->wiphy.bands[band]->ht_cap.ht_supported)
7388 return -EINVAL;
7389
7390 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
7381 return -EINVAL;
7382 }
7383
7384 if (mask.control[band].legacy == 0) {
7385 /* don't allow empty legacy rates if HT
7386 * is not even supported. */
7387 if (!rdev->wiphy.bands[band]->ht_cap.ht_supported)
7388 return -EINVAL;
7389
7390 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
7391 if (mask.control[band].mcs[i])
7391 if (mask.control[band].ht_mcs[i])
7392 break;
7393
7394 /* legacy and mcs rates may not be both empty */
7395 if (i == IEEE80211_HT_MCS_MASK_LEN)
7396 return -EINVAL;
7397 }
7398 }
7399

--- 4101 unchanged lines hidden ---
7392 break;
7393
7394 /* legacy and mcs rates may not be both empty */
7395 if (i == IEEE80211_HT_MCS_MASK_LEN)
7396 return -EINVAL;
7397 }
7398 }
7399

--- 4101 unchanged lines hidden ---