spectmgmt.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * spectrum management
  3. *
  4. * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi>
  5. * Copyright 2002-2005, Instant802 Networks, Inc.
  6. * Copyright 2005-2006, Devicescape Software, Inc.
  7. * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
  8. * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
  9. * Copyright 2007-2008, Intel Corporation
  10. * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/ieee80211.h>
  17. #include <net/cfg80211.h>
  18. #include <net/mac80211.h>
  19. #include "ieee80211_i.h"
  20. #include "sta_info.h"
  21. #include "wme.h"
  22. static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_data *sdata,
  23. struct ieee80211_msrment_ie *request_ie,
  24. const u8 *da, const u8 *bssid,
  25. u8 dialog_token)
  26. {
  27. struct ieee80211_local *local = sdata->local;
  28. struct sk_buff *skb;
  29. struct ieee80211_mgmt *msr_report;
  30. skb = dev_alloc_skb(sizeof(*msr_report) + local->hw.extra_tx_headroom +
  31. sizeof(struct ieee80211_msrment_ie));
  32. if (!skb)
  33. return;
  34. skb_reserve(skb, local->hw.extra_tx_headroom);
  35. msr_report = (struct ieee80211_mgmt *)skb_put(skb, 24);
  36. memset(msr_report, 0, 24);
  37. memcpy(msr_report->da, da, ETH_ALEN);
  38. memcpy(msr_report->sa, sdata->vif.addr, ETH_ALEN);
  39. memcpy(msr_report->bssid, bssid, ETH_ALEN);
  40. msr_report->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  41. IEEE80211_STYPE_ACTION);
  42. skb_put(skb, 1 + sizeof(msr_report->u.action.u.measurement));
  43. msr_report->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT;
  44. msr_report->u.action.u.measurement.action_code =
  45. WLAN_ACTION_SPCT_MSR_RPRT;
  46. msr_report->u.action.u.measurement.dialog_token = dialog_token;
  47. msr_report->u.action.u.measurement.element_id = WLAN_EID_MEASURE_REPORT;
  48. msr_report->u.action.u.measurement.length =
  49. sizeof(struct ieee80211_msrment_ie);
  50. memset(&msr_report->u.action.u.measurement.msr_elem, 0,
  51. sizeof(struct ieee80211_msrment_ie));
  52. msr_report->u.action.u.measurement.msr_elem.token = request_ie->token;
  53. msr_report->u.action.u.measurement.msr_elem.mode |=
  54. IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED;
  55. msr_report->u.action.u.measurement.msr_elem.type = request_ie->type;
  56. ieee80211_tx_skb(sdata, skb);
  57. }
  58. void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
  59. struct ieee80211_mgmt *mgmt,
  60. size_t len)
  61. {
  62. /*
  63. * Ignoring measurement request is spec violation.
  64. * Mandatory measurements must be reported optional
  65. * measurements might be refused or reported incapable
  66. * For now just refuse
  67. * TODO: Answer basic measurement as unmeasured
  68. */
  69. ieee80211_send_refuse_measurement_request(sdata,
  70. &mgmt->u.action.u.measurement.msr_elem,
  71. mgmt->sa, mgmt->bssid,
  72. mgmt->u.action.u.measurement.dialog_token);
  73. }