uap_event.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Marvell Wireless LAN device driver: AP event handling
  3. *
  4. * Copyright (C) 2012, Marvell International Ltd.
  5. *
  6. * This software file (the "File") is distributed by Marvell International
  7. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  8. * (the "License"). You may use, redistribute and/or modify this File in
  9. * accordance with the terms and conditions of the License, a copy of which
  10. * is available by writing to the Free Software Foundation, Inc.,
  11. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
  12. * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  13. *
  14. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  16. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  17. * this warranty disclaimer.
  18. */
  19. #include "decl.h"
  20. #include "main.h"
  21. /*
  22. * This function handles AP interface specific events generated by firmware.
  23. *
  24. * Event specific routines are called by this function based
  25. * upon the generated event cause.
  26. *
  27. *
  28. * Events supported for AP -
  29. * - EVENT_UAP_STA_ASSOC
  30. * - EVENT_UAP_STA_DEAUTH
  31. * - EVENT_UAP_BSS_ACTIVE
  32. * - EVENT_UAP_BSS_START
  33. * - EVENT_UAP_BSS_IDLE
  34. * - EVENT_UAP_MIC_COUNTERMEASURES:
  35. */
  36. int mwifiex_process_uap_event(struct mwifiex_private *priv)
  37. {
  38. struct mwifiex_adapter *adapter = priv->adapter;
  39. int len;
  40. u32 eventcause = adapter->event_cause;
  41. struct station_info sinfo;
  42. struct mwifiex_assoc_event *event;
  43. switch (eventcause) {
  44. case EVENT_UAP_STA_ASSOC:
  45. memset(&sinfo, 0, sizeof(sinfo));
  46. event = (struct mwifiex_assoc_event *)
  47. (adapter->event_body + MWIFIEX_UAP_EVENT_EXTRA_HEADER);
  48. if (le16_to_cpu(event->type) == TLV_TYPE_UAP_MGMT_FRAME) {
  49. len = -1;
  50. if (ieee80211_is_assoc_req(event->frame_control))
  51. len = 0;
  52. else if (ieee80211_is_reassoc_req(event->frame_control))
  53. /* There will be ETH_ALEN bytes of
  54. * current_ap_addr before the re-assoc ies.
  55. */
  56. len = ETH_ALEN;
  57. if (len != -1) {
  58. sinfo.filled = STATION_INFO_ASSOC_REQ_IES;
  59. sinfo.assoc_req_ies = &event->data[len];
  60. len = (u8 *)sinfo.assoc_req_ies -
  61. (u8 *)&event->frame_control;
  62. sinfo.assoc_req_ies_len =
  63. le16_to_cpu(event->len) - (u16)len;
  64. }
  65. }
  66. cfg80211_new_sta(priv->netdev, event->sta_addr, &sinfo,
  67. GFP_KERNEL);
  68. break;
  69. case EVENT_UAP_STA_DEAUTH:
  70. cfg80211_del_sta(priv->netdev, adapter->event_body +
  71. MWIFIEX_UAP_EVENT_EXTRA_HEADER, GFP_KERNEL);
  72. break;
  73. case EVENT_UAP_BSS_IDLE:
  74. priv->media_connected = false;
  75. break;
  76. case EVENT_UAP_BSS_ACTIVE:
  77. priv->media_connected = true;
  78. break;
  79. case EVENT_UAP_BSS_START:
  80. dev_dbg(adapter->dev, "AP EVENT: event id: %#x\n", eventcause);
  81. memcpy(priv->netdev->dev_addr, adapter->event_body + 2,
  82. ETH_ALEN);
  83. break;
  84. case EVENT_UAP_MIC_COUNTERMEASURES:
  85. /* For future development */
  86. dev_dbg(adapter->dev, "AP EVENT: event id: %#x\n", eventcause);
  87. break;
  88. default:
  89. dev_dbg(adapter->dev, "event: unknown event id: %#x\n",
  90. eventcause);
  91. break;
  92. }
  93. return 0;
  94. }