PageRenderTime 69ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 1ms

/drivers/staging/rtl8723au/core/rtw_mlme_ext.c

http://github.com/mirrors/linux-2.6
C | 6187 lines | 4556 code | 1132 blank | 499 comment | 894 complexity | eadf830d0512b176f49eec5fbcf30820 MD5 | raw file
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. ******************************************************************************/
  15. #define _RTW_MLME_EXT_C_
  16. #include <osdep_service.h>
  17. #include <drv_types.h>
  18. #include <wifi.h>
  19. #include <rtw_mlme_ext.h>
  20. #include <wlan_bssdef.h>
  21. #include <mlme_osdep.h>
  22. #include <recv_osdep.h>
  23. #include <linux/ieee80211.h>
  24. #include <rtl8723a_hal.h>
  25. static int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  26. static int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  27. static int OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  28. static int OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  29. static int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  30. static int OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  31. static int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  32. static int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  33. static int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  34. static int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  35. static int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  36. static int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  37. static int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  38. static int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  39. static int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  40. static int on_action_public23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  41. static int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  42. static int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  43. static int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  44. static void issue_assocreq(struct rtw_adapter *padapter);
  45. static void issue_probereq(struct rtw_adapter *padapter,
  46. struct cfg80211_ssid *pssid, u8 *da);
  47. static int issue_probereq_ex(struct rtw_adapter *padapter,
  48. struct cfg80211_ssid *pssid,
  49. u8 *da, int try_cnt, int wait_ms);
  50. static void issue_probersp(struct rtw_adapter *padapter, unsigned char *da);
  51. static void issue_auth(struct rtw_adapter *padapter, struct sta_info *psta,
  52. unsigned short status);
  53. static int issue_deauth_ex(struct rtw_adapter *padapter, u8 *da,
  54. unsigned short reason, int try_cnt, int wait_ms);
  55. static void start_clnt_assoc(struct rtw_adapter *padapter);
  56. static void start_clnt_auth(struct rtw_adapter *padapter);
  57. static void start_clnt_join(struct rtw_adapter *padapter);
  58. static void start_create_ibss(struct rtw_adapter *padapter);
  59. static struct wlan_bssid_ex *collect_bss_info(struct rtw_adapter *padapter,
  60. struct recv_frame *precv_frame);
  61. #ifdef CONFIG_8723AU_AP_MODE
  62. static int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
  63. static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status,
  64. struct sta_info *pstat, u16 pkt_type);
  65. #endif
  66. static struct mlme_handler mlme_sta_tbl[]={
  67. {"OnAssocReq23a", &OnAssocReq23a},
  68. {"OnAssocRsp23a", &OnAssocRsp23a},
  69. {"OnReAssocReq", &OnAssocReq23a},
  70. {"OnReAssocRsp", &OnAssocRsp23a},
  71. {"OnProbeReq23a", &OnProbeReq23a},
  72. {"OnProbeRsp23a", &OnProbeRsp23a},
  73. /*----------------------------------------------------------
  74. below 2 are reserved
  75. -----------------------------------------------------------*/
  76. {"DoReserved23a", &DoReserved23a},
  77. {"DoReserved23a", &DoReserved23a},
  78. {"OnBeacon23a", &OnBeacon23a},
  79. {"OnATIM", &OnAtim23a},
  80. {"OnDisassoc23a", &OnDisassoc23a},
  81. {"OnAuth23a", &OnAuth23aClient23a},
  82. {"OnDeAuth23a", &OnDeAuth23a},
  83. {"OnAction23a", &OnAction23a},
  84. };
  85. static struct action_handler OnAction23a_tbl[]={
  86. {WLAN_CATEGORY_SPECTRUM_MGMT, "ACTION_SPECTRUM_MGMT", on_action_spct23a},
  87. {WLAN_CATEGORY_QOS, "ACTION_QOS", &OnAction23a_qos},
  88. {WLAN_CATEGORY_DLS, "ACTION_DLS", &OnAction23a_dls},
  89. {WLAN_CATEGORY_BACK, "ACTION_BACK", &OnAction23a_back23a},
  90. {WLAN_CATEGORY_PUBLIC, "ACTION_PUBLIC", on_action_public23a},
  91. {WLAN_CATEGORY_HT, "ACTION_HT", &OnAction23a_ht},
  92. {WLAN_CATEGORY_SA_QUERY, "ACTION_SA_QUERY", &DoReserved23a},
  93. {WLAN_CATEGORY_WMM, "ACTION_WMM", &OnAction23a_wmm},
  94. {WLAN_CATEGORY_VENDOR_SPECIFIC, "ACTION_P2P", &OnAction23a_p2p},
  95. };
  96. static u8 null_addr[ETH_ALEN]= {0, 0, 0, 0, 0, 0};
  97. /**************************************************
  98. OUI definitions for the vendor specific IE
  99. ***************************************************/
  100. unsigned char WMM_OUI23A[] = {0x00, 0x50, 0xf2, 0x02};
  101. unsigned char WPS_OUI23A[] = {0x00, 0x50, 0xf2, 0x04};
  102. unsigned char P2P_OUI23A[] = {0x50, 0x6F, 0x9A, 0x09};
  103. unsigned char WFD_OUI23A[] = {0x50, 0x6F, 0x9A, 0x0A};
  104. unsigned char WMM_INFO_OUI23A[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01};
  105. unsigned char WMM_PARA_OUI23A[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};
  106. static unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20};
  107. /********************************************************
  108. MCS rate definitions
  109. *********************************************************/
  110. unsigned char MCS_rate_2R23A[16] = {
  111. 0xff, 0xff, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0,
  112. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
  113. unsigned char MCS_rate_1R23A[16] = {
  114. 0xff, 0x00, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0,
  115. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
  116. /********************************************************
  117. ChannelPlan definitions
  118. *********************************************************/
  119. static struct rt_channel_plan_2g RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = {
  120. /* 0x00, RT_CHANNEL_DOMAIN_2G_WORLD , Passive scan CH 12, 13 */
  121. {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
  122. /* 0x01, RT_CHANNEL_DOMAIN_2G_ETSI1 */
  123. {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
  124. /* 0x02, RT_CHANNEL_DOMAIN_2G_FCC1 */
  125. {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11},
  126. /* 0x03, RT_CHANNEL_DOMAIN_2G_MIKK1 */
  127. {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14},
  128. /* 0x04, RT_CHANNEL_DOMAIN_2G_ETSI2 */
  129. {{10, 11, 12, 13}, 4},
  130. /* 0x05, RT_CHANNEL_DOMAIN_2G_NULL */
  131. {{}, 0},
  132. };
  133. static struct rt_channel_plan_5g RTW_ChannelPlan5G[RT_CHANNEL_DOMAIN_5G_MAX] = {
  134. /* 0x00, RT_CHANNEL_DOMAIN_5G_NULL */
  135. {{}, 0},
  136. /* 0x01, RT_CHANNEL_DOMAIN_5G_ETSI1 */
  137. {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
  138. 116, 120, 124, 128, 132, 136, 140}, 19},
  139. /* 0x02, RT_CHANNEL_DOMAIN_5G_ETSI2 */
  140. {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
  141. 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165}, 24},
  142. /* 0x03, RT_CHANNEL_DOMAIN_5G_ETSI3 */
  143. {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
  144. 116, 120, 124, 128, 132, 149, 153, 157, 161, 165}, 22},
  145. /* 0x04, RT_CHANNEL_DOMAIN_5G_FCC1 */
  146. {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
  147. 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165}, 24},
  148. /* 0x05, RT_CHANNEL_DOMAIN_5G_FCC2 */
  149. {{36, 40, 44, 48, 149, 153, 157, 161, 165}, 9},
  150. /* 0x06, RT_CHANNEL_DOMAIN_5G_FCC3 */
  151. {{36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 13},
  152. /* 0x07, RT_CHANNEL_DOMAIN_5G_FCC4 */
  153. {{36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161}, 12},
  154. /* 0x08, RT_CHANNEL_DOMAIN_5G_FCC5 */
  155. {{149, 153, 157, 161, 165}, 5},
  156. /* 0x09, RT_CHANNEL_DOMAIN_5G_FCC6 */
  157. {{36, 40, 44, 48, 52, 56, 60, 64}, 8},
  158. /* 0x0A, RT_CHANNEL_DOMAIN_5G_FCC7_IC1 */
  159. {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
  160. 116, 136, 140, 149, 153, 157, 161, 165}, 20},
  161. /* 0x0B, RT_CHANNEL_DOMAIN_5G_KCC1 */
  162. {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
  163. 116, 120, 124, 149, 153, 157, 161, 165}, 20},
  164. /* 0x0C, RT_CHANNEL_DOMAIN_5G_MKK1 */
  165. {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
  166. 116, 120, 124, 128, 132, 136, 140}, 19},
  167. /* 0x0D, RT_CHANNEL_DOMAIN_5G_MKK2 */
  168. {{36, 40, 44, 48, 52, 56, 60, 64}, 8},
  169. /* 0x0E, RT_CHANNEL_DOMAIN_5G_MKK3 */
  170. {{100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}, 11},
  171. /* 0x0F, RT_CHANNEL_DOMAIN_5G_NCC1 */
  172. {{56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149,
  173. 153, 157, 161, 165}, 15},
  174. /* 0x10, RT_CHANNEL_DOMAIN_5G_NCC2 */
  175. {{56, 60, 64, 149, 153, 157, 161, 165}, 8},
  176. /* Driver self defined for old channel plan Compatible,
  177. Remember to modify if have new channel plan definition ===== */
  178. /* 0x11, RT_CHANNEL_DOMAIN_5G_FCC */
  179. {{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112,
  180. 116, 132, 136, 140, 149, 153, 157, 161, 165}, 21},
  181. /* 0x12, RT_CHANNEL_DOMAIN_5G_JAPAN_NO_DFS */
  182. {{36, 40, 44, 48}, 4},
  183. /* 0x13, RT_CHANNEL_DOMAIN_5G_FCC4_NO_DFS */
  184. {{36, 40, 44, 48, 149, 153, 157, 161}, 8},
  185. };
  186. static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = {
  187. /* 0x00 ~ 0x1F , Old Define ===== */
  188. {0x02, 0x11}, /* 0x00, RT_CHANNEL_DOMAIN_FCC */
  189. {0x02, 0x0A}, /* 0x01, RT_CHANNEL_DOMAIN_IC */
  190. {0x01, 0x01}, /* 0x02, RT_CHANNEL_DOMAIN_ETSI */
  191. {0x01, 0x00}, /* 0x03, RT_CHANNEL_DOMAIN_SPAIN */
  192. {0x01, 0x00}, /* 0x04, RT_CHANNEL_DOMAIN_FRANCE */
  193. {0x03, 0x00}, /* 0x05, RT_CHANNEL_DOMAIN_MKK */
  194. {0x03, 0x00}, /* 0x06, RT_CHANNEL_DOMAIN_MKK1 */
  195. {0x01, 0x09}, /* 0x07, RT_CHANNEL_DOMAIN_ISRAEL */
  196. {0x03, 0x09}, /* 0x08, RT_CHANNEL_DOMAIN_TELEC */
  197. {0x03, 0x00}, /* 0x09, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN */
  198. {0x00, 0x00}, /* 0x0A, RT_CHANNEL_DOMAIN_WORLD_WIDE_13 */
  199. {0x02, 0x0F}, /* 0x0B, RT_CHANNEL_DOMAIN_TAIWAN */
  200. {0x01, 0x08}, /* 0x0C, RT_CHANNEL_DOMAIN_CHINA */
  201. {0x02, 0x06}, /* 0x0D, RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO */
  202. {0x02, 0x0B}, /* 0x0E, RT_CHANNEL_DOMAIN_KOREA */
  203. {0x02, 0x09}, /* 0x0F, RT_CHANNEL_DOMAIN_TURKEY */
  204. {0x01, 0x01}, /* 0x10, RT_CHANNEL_DOMAIN_JAPAN */
  205. {0x02, 0x05}, /* 0x11, RT_CHANNEL_DOMAIN_FCC_NO_DFS */
  206. {0x01, 0x12}, /* 0x12, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */
  207. {0x00, 0x04}, /* 0x13, RT_CHANNEL_DOMAIN_WORLD_WIDE_5G */
  208. {0x02, 0x10}, /* 0x14, RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS */
  209. {0x00, 0x12}, /* 0x15, RT_CHANNEL_DOMAIN_ETSI_NO_DFS */
  210. {0x00, 0x13}, /* 0x16, RT_CHANNEL_DOMAIN_KOREA_NO_DFS */
  211. {0x03, 0x12}, /* 0x17, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */
  212. {0x05, 0x08}, /* 0x18, RT_CHANNEL_DOMAIN_PAKISTAN_NO_DFS */
  213. {0x02, 0x08}, /* 0x19, RT_CHANNEL_DOMAIN_TAIWAN2_NO_DFS */
  214. {0x00, 0x00}, /* 0x1A, */
  215. {0x00, 0x00}, /* 0x1B, */
  216. {0x00, 0x00}, /* 0x1C, */
  217. {0x00, 0x00}, /* 0x1D, */
  218. {0x00, 0x00}, /* 0x1E, */
  219. {0x05, 0x04}, /* 0x1F, RT_CHANNEL_DOMAIN_WORLD_WIDE_ONLY_5G */
  220. /* 0x20 ~ 0x7F , New Define ===== */
  221. {0x00, 0x00}, /* 0x20, RT_CHANNEL_DOMAIN_WORLD_NULL */
  222. {0x01, 0x00}, /* 0x21, RT_CHANNEL_DOMAIN_ETSI1_NULL */
  223. {0x02, 0x00}, /* 0x22, RT_CHANNEL_DOMAIN_FCC1_NULL */
  224. {0x03, 0x00}, /* 0x23, RT_CHANNEL_DOMAIN_MKK1_NULL */
  225. {0x04, 0x00}, /* 0x24, RT_CHANNEL_DOMAIN_ETSI2_NULL */
  226. {0x02, 0x04}, /* 0x25, RT_CHANNEL_DOMAIN_FCC1_FCC1 */
  227. {0x00, 0x01}, /* 0x26, RT_CHANNEL_DOMAIN_WORLD_ETSI1 */
  228. {0x03, 0x0C}, /* 0x27, RT_CHANNEL_DOMAIN_MKK1_MKK1 */
  229. {0x00, 0x0B}, /* 0x28, RT_CHANNEL_DOMAIN_WORLD_KCC1 */
  230. {0x00, 0x05}, /* 0x29, RT_CHANNEL_DOMAIN_WORLD_FCC2 */
  231. {0x00, 0x00}, /* 0x2A, */
  232. {0x00, 0x00}, /* 0x2B, */
  233. {0x00, 0x00}, /* 0x2C, */
  234. {0x00, 0x00}, /* 0x2D, */
  235. {0x00, 0x00}, /* 0x2E, */
  236. {0x00, 0x00}, /* 0x2F, */
  237. {0x00, 0x06}, /* 0x30, RT_CHANNEL_DOMAIN_WORLD_FCC3 */
  238. {0x00, 0x07}, /* 0x31, RT_CHANNEL_DOMAIN_WORLD_FCC4 */
  239. {0x00, 0x08}, /* 0x32, RT_CHANNEL_DOMAIN_WORLD_FCC5 */
  240. {0x00, 0x09}, /* 0x33, RT_CHANNEL_DOMAIN_WORLD_FCC6 */
  241. {0x02, 0x0A}, /* 0x34, RT_CHANNEL_DOMAIN_FCC1_FCC7 */
  242. {0x00, 0x02}, /* 0x35, RT_CHANNEL_DOMAIN_WORLD_ETSI2 */
  243. {0x00, 0x03}, /* 0x36, RT_CHANNEL_DOMAIN_WORLD_ETSI3 */
  244. {0x03, 0x0D}, /* 0x37, RT_CHANNEL_DOMAIN_MKK1_MKK2 */
  245. {0x03, 0x0E}, /* 0x38, RT_CHANNEL_DOMAIN_MKK1_MKK3 */
  246. {0x02, 0x0F}, /* 0x39, RT_CHANNEL_DOMAIN_FCC1_NCC1 */
  247. {0x00, 0x00}, /* 0x3A, */
  248. {0x00, 0x00}, /* 0x3B, */
  249. {0x00, 0x00}, /* 0x3C, */
  250. {0x00, 0x00}, /* 0x3D, */
  251. {0x00, 0x00}, /* 0x3E, */
  252. {0x00, 0x00}, /* 0x3F, */
  253. {0x02, 0x10}, /* 0x40, RT_CHANNEL_DOMAIN_FCC1_NCC2 */
  254. {0x03, 0x00}, /* 0x41, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G */
  255. };
  256. static struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE =
  257. {0x03, 0x02}; /* use the conbination for max channel numbers */
  258. static void dummy_event_callback(struct rtw_adapter *adapter, const u8 *pbuf)
  259. {
  260. }
  261. static struct fwevent wlanevents[] =
  262. {
  263. {0, &dummy_event_callback}, /*0*/
  264. {0, NULL},
  265. {0, NULL},
  266. {0, NULL},
  267. {0, NULL},
  268. {0, NULL},
  269. {0, NULL},
  270. {0, NULL},
  271. {0, &rtw_survey_event_cb23a}, /*8*/
  272. {sizeof (struct surveydone_event), &rtw_surveydone_event_callback23a},
  273. {0, &rtw23a_joinbss_event_cb}, /*10*/
  274. {sizeof(struct stassoc_event), &rtw_stassoc_event_callback23a},
  275. {sizeof(struct stadel_event), &rtw_stadel_event_callback23a},
  276. {0, &dummy_event_callback},
  277. {0, &dummy_event_callback},
  278. {0, NULL}, /*15*/
  279. {0, NULL},
  280. {0, NULL},
  281. {0, NULL},
  282. {0, &dummy_event_callback},
  283. {0, NULL}, /*20*/
  284. {0, NULL},
  285. {0, NULL},
  286. {0, &dummy_event_callback},
  287. {0, NULL},
  288. };
  289. static void rtw_correct_TSF(struct rtw_adapter *padapter)
  290. {
  291. hw_var_set_correct_tsf(padapter);
  292. }
  293. static void
  294. rtw_update_TSF(struct mlme_ext_priv *pmlmeext, struct ieee80211_mgmt *mgmt)
  295. {
  296. pmlmeext->TSFValue = get_unaligned_le64(&mgmt->u.beacon.timestamp);
  297. }
  298. /*
  299. * Search the @param channel_num in given @param channel_set
  300. * @ch_set: the given channel set
  301. * @ch: the given channel number
  302. *
  303. * return the index of channel_num in channel_set, -1 if not found
  304. */
  305. int rtw_ch_set_search_ch23a(struct rt_channel_info *ch_set, const u32 ch)
  306. {
  307. int i;
  308. for (i = 0; ch_set[i]. ChannelNum != 0; i++) {
  309. if (ch == ch_set[i].ChannelNum)
  310. break;
  311. }
  312. if (i >= ch_set[i].ChannelNum)
  313. return -1;
  314. return i;
  315. }
  316. /****************************************************************************
  317. Following are the initialization functions for WiFi MLME
  318. *****************************************************************************/
  319. int init_hw_mlme_ext23a(struct rtw_adapter *padapter)
  320. {
  321. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  322. set_channel_bwmode23a(padapter, pmlmeext->cur_channel,
  323. pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
  324. return _SUCCESS;
  325. }
  326. static void init_mlme_ext_priv23a_value(struct rtw_adapter *padapter)
  327. {
  328. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  329. struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
  330. unsigned char mixed_datarate[NumRates] = {
  331. _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_,
  332. _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_,
  333. _48M_RATE_, _54M_RATE_, 0xff};
  334. unsigned char mixed_basicrate[NumRates] = {
  335. _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_,
  336. _12M_RATE_, _24M_RATE_, 0xff,};
  337. atomic_set(&pmlmeext->event_seq, 0);
  338. /* reset to zero when disconnect at client mode */
  339. pmlmeext->mgnt_seq = 0;
  340. pmlmeext->cur_channel = padapter->registrypriv.channel;
  341. pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20;
  342. pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
  343. pmlmeext->retry = 0;
  344. pmlmeext->cur_wireless_mode = padapter->registrypriv.wireless_mode;
  345. memcpy(pmlmeext->datarate, mixed_datarate, NumRates);
  346. memcpy(pmlmeext->basicrate, mixed_basicrate, NumRates);
  347. if (pmlmeext->cur_channel > 14)
  348. pmlmeext->tx_rate = IEEE80211_OFDM_RATE_6MB;
  349. else
  350. pmlmeext->tx_rate = IEEE80211_CCK_RATE_1MB;
  351. pmlmeext->sitesurvey_res.state = SCAN_DISABLE;
  352. pmlmeext->sitesurvey_res.channel_idx = 0;
  353. pmlmeext->sitesurvey_res.bss_cnt = 0;
  354. pmlmeext->scan_abort = false;
  355. pmlmeinfo->state = MSR_NOLINK;
  356. pmlmeinfo->reauth_count = 0;
  357. pmlmeinfo->reassoc_count = 0;
  358. pmlmeinfo->link_count = 0;
  359. pmlmeinfo->auth_seq = 0;
  360. pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open;
  361. pmlmeinfo->key_index = 0;
  362. pmlmeinfo->iv = 0;
  363. pmlmeinfo->enc_algo = 0;
  364. pmlmeinfo->authModeToggle = 0;
  365. memset(pmlmeinfo->chg_txt, 0, 128);
  366. pmlmeinfo->slotTime = SHORT_SLOT_TIME;
  367. pmlmeinfo->preamble_mode = PREAMBLE_AUTO;
  368. pmlmeinfo->dialogToken = 0;
  369. pmlmeext->action_public_rxseq = 0xffff;
  370. pmlmeext->action_public_dialog_token = 0xff;
  371. }
  372. static int has_channel(struct rt_channel_info *channel_set,
  373. u8 chanset_size, u8 chan) {
  374. int i;
  375. for (i = 0; i < chanset_size; i++) {
  376. if (channel_set[i].ChannelNum == chan)
  377. return 1;
  378. }
  379. return 0;
  380. }
  381. static void init_channel_list(struct rtw_adapter *padapter,
  382. struct rt_channel_info *channel_set,
  383. u8 chanset_size,
  384. struct p2p_channels *channel_list)
  385. {
  386. struct p2p_oper_class_map op_class[] = {
  387. { IEEE80211G, 81, 1, 13, 1, BW20 },
  388. { IEEE80211G, 82, 14, 14, 1, BW20 },
  389. { IEEE80211A, 115, 36, 48, 4, BW20 },
  390. { IEEE80211A, 116, 36, 44, 8, BW40PLUS },
  391. { IEEE80211A, 117, 40, 48, 8, BW40MINUS },
  392. { IEEE80211A, 124, 149, 161, 4, BW20 },
  393. { IEEE80211A, 125, 149, 169, 4, BW20 },
  394. { IEEE80211A, 126, 149, 157, 8, BW40PLUS },
  395. { IEEE80211A, 127, 153, 161, 8, BW40MINUS },
  396. { -1, 0, 0, 0, 0, BW20 }
  397. };
  398. int cla, op;
  399. cla = 0;
  400. for (op = 0; op_class[op].op_class; op++) {
  401. u8 ch;
  402. struct p2p_oper_class_map *o = &op_class[op];
  403. struct p2p_reg_class *reg = NULL;
  404. for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) {
  405. if (!has_channel(channel_set, chanset_size, ch))
  406. continue;
  407. if ((0 == padapter->registrypriv.ht_enable) &&
  408. (o->inc == 8))
  409. continue;
  410. if ((0 == (padapter->registrypriv.cbw40_enable & BIT(1))) &&
  411. ((BW40MINUS == o->bw) || (BW40PLUS == o->bw)))
  412. continue;
  413. if (reg == NULL) {
  414. reg = &channel_list->reg_class[cla];
  415. cla++;
  416. reg->reg_class = o->op_class;
  417. reg->channels = 0;
  418. }
  419. reg->channel[reg->channels] = ch;
  420. reg->channels++;
  421. }
  422. }
  423. channel_list->reg_classes = cla;
  424. }
  425. static u8 init_channel_set(struct rtw_adapter *padapter, u8 cplan,
  426. struct rt_channel_info *c_set)
  427. {
  428. u8 i, ch_size = 0;
  429. u8 b5GBand = false, b2_4GBand = false;
  430. u8 Index2G = 0, Index5G = 0;
  431. memset(c_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM);
  432. if (cplan >= RT_CHANNEL_DOMAIN_MAX &&
  433. cplan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) {
  434. DBG_8723A("ChannelPlan ID %x error !!!!!\n", cplan);
  435. return ch_size;
  436. }
  437. if (padapter->registrypriv.wireless_mode & WIRELESS_11G) {
  438. b2_4GBand = true;
  439. if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan)
  440. Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G;
  441. else
  442. Index2G = RTW_ChannelPlanMap[cplan].Index2G;
  443. }
  444. if (padapter->registrypriv.wireless_mode & WIRELESS_11A) {
  445. b5GBand = true;
  446. if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan)
  447. Index5G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index5G;
  448. else
  449. Index5G = RTW_ChannelPlanMap[cplan].Index5G;
  450. }
  451. if (b2_4GBand) {
  452. for (i = 0; i < RTW_ChannelPlan2G[Index2G].Len; i++) {
  453. c_set[ch_size].ChannelNum =
  454. RTW_ChannelPlan2G[Index2G].Channel[i];
  455. if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == cplan) ||
  456. /* Channel 1~11 is active, and 12~14 is passive */
  457. RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == cplan) {
  458. if (c_set[ch_size].ChannelNum >= 1 &&
  459. c_set[ch_size].ChannelNum <= 11)
  460. c_set[ch_size].ScanType = SCAN_ACTIVE;
  461. else if (c_set[ch_size].ChannelNum >= 12 &&
  462. c_set[ch_size].ChannelNum <= 14)
  463. c_set[ch_size].ScanType = SCAN_PASSIVE;
  464. } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == cplan ||
  465. RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan ||
  466. RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) {
  467. /* channel 12~13, passive scan */
  468. if (c_set[ch_size].ChannelNum <= 11)
  469. c_set[ch_size].ScanType = SCAN_ACTIVE;
  470. else
  471. c_set[ch_size].ScanType = SCAN_PASSIVE;
  472. } else
  473. c_set[ch_size].ScanType = SCAN_ACTIVE;
  474. ch_size++;
  475. }
  476. }
  477. if (b5GBand) {
  478. for (i = 0; i < RTW_ChannelPlan5G[Index5G].Len; i++) {
  479. if (RTW_ChannelPlan5G[Index5G].Channel[i] <= 48 ||
  480. RTW_ChannelPlan5G[Index5G].Channel[i] >= 149) {
  481. c_set[ch_size].ChannelNum =
  482. RTW_ChannelPlan5G[Index5G].Channel[i];
  483. if (RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan) {
  484. /* passive scan for all 5G channels */
  485. c_set[ch_size].ScanType =
  486. SCAN_PASSIVE;
  487. } else
  488. c_set[ch_size].ScanType =
  489. SCAN_ACTIVE;
  490. DBG_8723A("%s(): channel_set[%d].ChannelNum = "
  491. "%d\n", __func__, ch_size,
  492. c_set[ch_size].ChannelNum);
  493. ch_size++;
  494. }
  495. }
  496. }
  497. return ch_size;
  498. }
  499. int init_mlme_ext_priv23a(struct rtw_adapter *padapter)
  500. {
  501. struct registry_priv *pregistrypriv = &padapter->registrypriv;
  502. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  503. struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
  504. struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
  505. pmlmeext->padapter = padapter;
  506. init_mlme_ext_priv23a_value(padapter);
  507. pmlmeinfo->bAcceptAddbaReq = pregistrypriv->bAcceptAddbaReq;
  508. init_mlme_ext_timer23a(padapter);
  509. #ifdef CONFIG_8723AU_AP_MODE
  510. init_mlme_ap_info23a(padapter);
  511. #endif
  512. pmlmeext->max_chan_nums = init_channel_set(padapter,
  513. pmlmepriv->ChannelPlan,
  514. pmlmeext->channel_set);
  515. init_channel_list(padapter, pmlmeext->channel_set,
  516. pmlmeext->max_chan_nums, &pmlmeext->channel_list);
  517. pmlmeext->chan_scan_time = SURVEY_TO;
  518. pmlmeext->mlmeext_init = true;
  519. pmlmeext->active_keep_alive_check = true;
  520. return _SUCCESS;
  521. }
  522. void free_mlme_ext_priv23a (struct mlme_ext_priv *pmlmeext)
  523. {
  524. struct rtw_adapter *padapter = pmlmeext->padapter;
  525. if (!padapter)
  526. return;
  527. if (padapter->bDriverStopped == true) {
  528. del_timer_sync(&pmlmeext->survey_timer);
  529. del_timer_sync(&pmlmeext->link_timer);
  530. /* del_timer_sync(&pmlmeext->ADDBA_timer); */
  531. }
  532. }
  533. static void
  534. _mgt_dispatcher23a(struct rtw_adapter *padapter, struct mlme_handler *ptable,
  535. struct recv_frame *precv_frame)
  536. {
  537. struct sk_buff *skb = precv_frame->pkt;
  538. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  539. if (ptable->func) {
  540. /* receive the frames that ra(a1) is my address
  541. or ra(a1) is bc address. */
  542. if (!ether_addr_equal(hdr->addr1, myid(&padapter->eeprompriv))&&
  543. !is_broadcast_ether_addr(hdr->addr1))
  544. return;
  545. ptable->func(padapter, precv_frame);
  546. }
  547. }
  548. void mgt_dispatcher23a(struct rtw_adapter *padapter,
  549. struct recv_frame *precv_frame)
  550. {
  551. struct mlme_handler *ptable;
  552. #ifdef CONFIG_8723AU_AP_MODE
  553. struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
  554. #endif /* CONFIG_8723AU_AP_MODE */
  555. struct sk_buff *skb = precv_frame->pkt;
  556. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
  557. struct sta_info *psta;
  558. u16 stype;
  559. int index;
  560. if (!ieee80211_is_mgmt(mgmt->frame_control))
  561. return;
  562. /* receive the frames that ra(a1) is my address or ra(a1) is
  563. bc address. */
  564. if (!ether_addr_equal(mgmt->da, myid(&padapter->eeprompriv)) &&
  565. !is_broadcast_ether_addr(mgmt->da))
  566. return;
  567. ptable = mlme_sta_tbl;
  568. stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
  569. index = stype >> 4;
  570. if (index > 13) {
  571. RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
  572. "Currently we do not support reserved sub-fr-type =%d\n",
  573. index);
  574. return;
  575. }
  576. ptable += index;
  577. psta = rtw_get_stainfo23a(&padapter->stapriv, mgmt->sa);
  578. if (psta) {
  579. if (ieee80211_has_retry(mgmt->frame_control)) {
  580. if (precv_frame->attrib.seq_num ==
  581. psta->RxMgmtFrameSeqNum) {
  582. /* drop the duplicate management frame */
  583. DBG_8723A("Drop duplicate management frame "
  584. "with seq_num = %d.\n",
  585. precv_frame->attrib.seq_num);
  586. return;
  587. }
  588. }
  589. psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num;
  590. }
  591. #ifdef CONFIG_8723AU_AP_MODE
  592. switch (stype) {
  593. case IEEE80211_STYPE_AUTH:
  594. if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
  595. ptable->func = &OnAuth23a;
  596. else
  597. ptable->func = &OnAuth23aClient23a;
  598. /* pass through */
  599. case IEEE80211_STYPE_ASSOC_REQ:
  600. case IEEE80211_STYPE_REASSOC_REQ:
  601. _mgt_dispatcher23a(padapter, ptable, precv_frame);
  602. break;
  603. case IEEE80211_STYPE_PROBE_REQ:
  604. if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
  605. _mgt_dispatcher23a(padapter, ptable, precv_frame);
  606. else
  607. _mgt_dispatcher23a(padapter, ptable, precv_frame);
  608. break;
  609. case IEEE80211_STYPE_BEACON:
  610. _mgt_dispatcher23a(padapter, ptable, precv_frame);
  611. break;
  612. case IEEE80211_STYPE_ACTION:
  613. /* if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) */
  614. _mgt_dispatcher23a(padapter, ptable, precv_frame);
  615. break;
  616. default:
  617. _mgt_dispatcher23a(padapter, ptable, precv_frame);
  618. break;
  619. }
  620. #else
  621. _mgt_dispatcher23a(padapter, ptable, precv_frame);
  622. #endif
  623. }
  624. /****************************************************************************
  625. Following are the callback functions for each subtype of the management frames
  626. *****************************************************************************/
  627. static int
  628. OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
  629. {
  630. const u8 *ie;
  631. struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
  632. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  633. struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
  634. struct wlan_bssid_ex *cur = &pmlmeinfo->network;
  635. struct sk_buff *skb = precv_frame->pkt;
  636. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
  637. int len = skb->len;
  638. if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
  639. return _SUCCESS;
  640. if (!check_fwstate(pmlmepriv, _FW_LINKED) &&
  641. !check_fwstate(pmlmepriv,
  642. WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE))
  643. return _SUCCESS;
  644. if (unlikely(!ieee80211_is_probe_req(mgmt->frame_control))) {
  645. printk(KERN_WARNING "%s: Received non probe request frame\n",
  646. __func__);
  647. return _FAIL;
  648. }
  649. len -= offsetof(struct ieee80211_mgmt, u.probe_req.variable);
  650. ie = cfg80211_find_ie(WLAN_EID_SSID, mgmt->u.probe_req.variable, len);
  651. /* check (wildcard) SSID */
  652. if (!ie)
  653. goto out;
  654. if ((ie[1] && memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) ||
  655. (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) {
  656. return _SUCCESS;
  657. }
  658. if (check_fwstate(pmlmepriv, _FW_LINKED) &&
  659. pmlmepriv->cur_network.join_res)
  660. issue_probersp(padapter, mgmt->sa);
  661. out:
  662. return _SUCCESS;
  663. }
  664. static int
  665. OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
  666. {
  667. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  668. if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
  669. report_survey_event23a(padapter, precv_frame);
  670. return _SUCCESS;
  671. }
  672. return _SUCCESS;
  673. }
  674. static int
  675. OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
  676. {
  677. int cam_idx;
  678. struct sta_info *psta;
  679. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  680. struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
  681. struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
  682. struct sta_priv *pstapriv = &padapter->stapriv;
  683. struct sk_buff *skb = precv_frame->pkt;
  684. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
  685. int pkt_len = skb->len;
  686. struct wlan_bssid_ex *pbss;
  687. int ret = _SUCCESS;
  688. u8 *p, *pie;
  689. int pie_len;
  690. u32 ielen = 0;
  691. pie = mgmt->u.beacon.variable;
  692. pie_len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable);
  693. p = rtw_get_ie23a(pie, WLAN_EID_EXT_SUPP_RATES, &ielen, pie_len);
  694. if (p && ielen > 0) {
  695. if (p[1 + ielen] == 0x2D && p[2 + ielen] != 0x2D) {
  696. /* Invalid value 0x2D is detected in Extended Supported
  697. * Rates (ESR) IE. Try to fix the IE length to avoid
  698. * failed Beacon parsing.
  699. */
  700. DBG_8723A("[WIFIDBG] Error in ESR IE is detected in "
  701. "Beacon of BSSID: %pM. Fix the length of "
  702. "ESR IE to avoid failed Beacon parsing.\n",
  703. mgmt->bssid);
  704. p[1] = ielen - 1;
  705. }
  706. }
  707. if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
  708. report_survey_event23a(padapter, precv_frame);
  709. return _SUCCESS;
  710. }
  711. if (!ether_addr_equal(mgmt->bssid,
  712. get_my_bssid23a(&pmlmeinfo->network)))
  713. goto out;
  714. if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
  715. /* we should update current network before auth,
  716. or some IE is wrong */
  717. pbss = collect_bss_info(padapter, precv_frame);
  718. if (pbss) {
  719. update_network23a(&pmlmepriv->cur_network.network, pbss,
  720. padapter, true);
  721. rtw_get_bcn_info23a(&pmlmepriv->cur_network);
  722. kfree(pbss);
  723. }
  724. /* check the vendor of the assoc AP */
  725. pmlmeinfo->assoc_AP_vendor =
  726. check_assoc_AP23a((u8 *)&mgmt->u.beacon, pkt_len -
  727. offsetof(struct ieee80211_mgmt, u));
  728. /* update TSF Value */
  729. rtw_update_TSF(pmlmeext, mgmt);
  730. /* start auth */
  731. start_clnt_auth(padapter);
  732. return _SUCCESS;
  733. }
  734. if (((pmlmeinfo->state & 0x03) == MSR_AP) &&
  735. (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
  736. psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
  737. if (psta) {
  738. ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len);
  739. if (ret != _SUCCESS) {
  740. DBG_8723A_LEVEL(_drv_always_, "ap has changed, "
  741. "disconnect now\n");
  742. receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535);
  743. return _SUCCESS;
  744. }
  745. /* update WMM, ERP in the beacon */
  746. /* todo: the timer is used instead of
  747. the number of the beacon received */
  748. if ((sta_rx_pkts(psta) & 0xf) == 0) {
  749. /* DBG_8723A("update_bcn_info\n"); */
  750. update_beacon23a_info(padapter, mgmt,
  751. pkt_len, psta);
  752. }
  753. }
  754. } else if ((pmlmeinfo->state&0x03) == MSR_ADHOC) {
  755. psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
  756. if (psta) {
  757. /* update WMM, ERP in the beacon */
  758. /* todo: the timer is used instead of the
  759. number of the beacon received */
  760. if ((sta_rx_pkts(psta) & 0xf) == 0) {
  761. /* DBG_8723A("update_bcn_info\n"); */
  762. update_beacon23a_info(padapter, mgmt,
  763. pkt_len, psta);
  764. }
  765. } else {
  766. /* allocate a new CAM entry for IBSS station */
  767. cam_idx = allocate_fw_sta_entry23a(padapter);
  768. if (cam_idx == NUM_STA)
  769. goto out;
  770. /* get supported rate */
  771. if (update_sta_support_rate23a(padapter, pie, pie_len,
  772. cam_idx) == _FAIL) {
  773. pmlmeinfo->FW_sta_info[cam_idx].status = 0;
  774. goto out;
  775. }
  776. /* update TSF Value */
  777. rtw_update_TSF(pmlmeext, mgmt);
  778. /* report sta add event */
  779. report_add_sta_event23a(padapter, mgmt->sa,
  780. cam_idx);
  781. }
  782. }
  783. out:
  784. return _SUCCESS;
  785. }
  786. #ifdef CONFIG_8723AU_AP_MODE
  787. static int
  788. OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
  789. {
  790. static struct sta_info stat;
  791. struct sta_info *pstat = NULL;
  792. struct sta_priv *pstapriv = &padapter->stapriv;
  793. struct security_priv *psecuritypriv = &padapter->securitypriv;
  794. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  795. struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
  796. struct sk_buff *skb = precv_frame->pkt;
  797. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
  798. u8 *pframe;
  799. const u8 *p;
  800. unsigned char *sa;
  801. u16 auth_mode, seq, algorithm;
  802. int status, len = skb->len;
  803. if ((pmlmeinfo->state & 0x03) != MSR_AP)
  804. return _FAIL;
  805. DBG_8723A("+OnAuth23a\n");
  806. sa = mgmt->sa;
  807. auth_mode = psecuritypriv->dot11AuthAlgrthm;
  808. pframe = mgmt->u.auth.variable;
  809. len = skb->len - offsetof(struct ieee80211_mgmt, u.auth.variable);
  810. seq = le16_to_cpu(mgmt->u.auth.auth_transaction);
  811. algorithm = le16_to_cpu(mgmt->u.auth.auth_alg);
  812. DBG_8723A("auth alg =%x, seq =%X\n", algorithm, seq);
  813. if (auth_mode == 2 &&
  814. psecuritypriv->dot11PrivacyAlgrthm != WLAN_CIPHER_SUITE_WEP40 &&
  815. psecuritypriv->dot11PrivacyAlgrthm != WLAN_CIPHER_SUITE_WEP104)
  816. auth_mode = 0;
  817. /* rx a shared-key auth but shared not enabled, or */
  818. /* rx a open-system auth but shared-key is enabled */
  819. if ((algorithm != WLAN_AUTH_OPEN && auth_mode == 0) ||
  820. (algorithm == WLAN_AUTH_OPEN && auth_mode == 1)) {
  821. DBG_8723A("auth rejected due to bad alg [alg =%d, auth_mib "
  822. "=%d] %02X%02X%02X%02X%02X%02X\n",
  823. algorithm, auth_mode,
  824. sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
  825. status = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
  826. goto auth_fail;
  827. }
  828. if (rtw_access_ctrl23a(padapter, sa) == false) {
  829. status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
  830. goto auth_fail;
  831. }
  832. pstat = rtw_get_stainfo23a(pstapriv, sa);
  833. if (!pstat) {
  834. /* allocate a new one */
  835. DBG_8723A("going to alloc stainfo for sa =%pM\n", sa);
  836. pstat = rtw_alloc_stainfo23a(pstapriv, sa, GFP_ATOMIC);
  837. if (!pstat) {
  838. DBG_8723A(" Exceed the upper limit of supported "
  839. "clients...\n");
  840. status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
  841. goto auth_fail;
  842. }
  843. pstat->state = WIFI_FW_AUTH_NULL;
  844. pstat->auth_seq = 0;
  845. /* pstat->flags = 0; */
  846. /* pstat->capability = 0; */
  847. } else {
  848. spin_lock_bh(&pstapriv->asoc_list_lock);
  849. if (!list_empty(&pstat->asoc_list)) {
  850. list_del_init(&pstat->asoc_list);
  851. pstapriv->asoc_list_cnt--;
  852. if (pstat->expire_to > 0) {
  853. /* TODO: STA re_auth within expire_to */
  854. }
  855. }
  856. spin_unlock_bh(&pstapriv->asoc_list_lock);
  857. if (seq == 1) {
  858. /* TODO: STA re_auth and auth timeout */
  859. }
  860. }
  861. spin_lock_bh(&pstapriv->auth_list_lock);
  862. if (list_empty(&pstat->auth_list)) {
  863. list_add_tail(&pstat->auth_list, &pstapriv->auth_list);
  864. pstapriv->auth_list_cnt++;
  865. }
  866. spin_unlock_bh(&pstapriv->auth_list_lock);
  867. if (pstat->auth_seq == 0)
  868. pstat->expire_to = pstapriv->auth_to;
  869. if ((pstat->auth_seq + 1) != seq) {
  870. DBG_8723A("(1)auth rejected because out of seq [rx_seq =%d, "
  871. "exp_seq =%d]!\n", seq, pstat->auth_seq+1);
  872. status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
  873. goto auth_fail;
  874. }
  875. if (algorithm == WLAN_AUTH_OPEN && (auth_mode == 0 || auth_mode == 2)) {
  876. if (seq == 1) {
  877. pstat->state &= ~WIFI_FW_AUTH_NULL;
  878. pstat->state |= WIFI_FW_AUTH_SUCCESS;
  879. pstat->expire_to = pstapriv->assoc_to;
  880. pstat->authalg = algorithm;
  881. } else {
  882. DBG_8723A("(2)auth rejected because out of seq "
  883. "[rx_seq =%d, exp_seq =%d]!\n",
  884. seq, pstat->auth_seq+1);
  885. status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
  886. goto auth_fail;
  887. }
  888. } else { /* shared system or auto authentication */
  889. if (seq == 1) {
  890. /* prepare for the challenging txt... */
  891. pstat->state &= ~WIFI_FW_AUTH_NULL;
  892. pstat->state |= WIFI_FW_AUTH_STATE;
  893. pstat->authalg = algorithm;
  894. pstat->auth_seq = 2;
  895. } else if (seq == 3) {
  896. /* checking for challenging txt... */
  897. DBG_8723A("checking for challenging txt...\n");
  898. p = cfg80211_find_ie(WLAN_EID_CHALLENGE, pframe, len);
  899. if (!p || p[1] <= 0) {
  900. DBG_8723A("auth rejected because challenge "
  901. "failure!(1)\n");
  902. status = WLAN_STATUS_CHALLENGE_FAIL;
  903. goto auth_fail;
  904. }
  905. if (!memcmp(p + 2, pstat->chg_txt, 128)) {
  906. pstat->state &= ~WIFI_FW_AUTH_STATE;
  907. pstat->state |= WIFI_FW_AUTH_SUCCESS;
  908. /* challenging txt is correct... */
  909. pstat->expire_to = pstapriv->assoc_to;
  910. } else {
  911. DBG_8723A("auth rejected because challenge "
  912. "failure!\n");
  913. status = WLAN_STATUS_CHALLENGE_FAIL;
  914. goto auth_fail;
  915. }
  916. } else {
  917. DBG_8723A("(3)auth rejected because out of seq "
  918. "[rx_seq =%d, exp_seq =%d]!\n",
  919. seq, pstat->auth_seq+1);
  920. status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
  921. goto auth_fail;
  922. }
  923. }
  924. /* Now, we are going to issue_auth... */
  925. pstat->auth_seq = seq + 1;
  926. issue_auth(padapter, pstat, WLAN_STATUS_SUCCESS);
  927. if (pstat->state & WIFI_FW_AUTH_SUCCESS)
  928. pstat->auth_seq = 0;
  929. return _SUCCESS;
  930. auth_fail:
  931. if (pstat)
  932. rtw_free_stainfo23a(padapter, pstat);
  933. pstat = &stat;
  934. memset((char *)pstat, '\0', sizeof(stat));
  935. pstat->auth_seq = 2;
  936. ether_addr_copy(pstat->hwaddr, sa);
  937. issue_auth(padapter, pstat, (unsigned short)status);
  938. return _FAIL;
  939. }
  940. #endif
  941. static int
  942. OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
  943. {
  944. unsigned int seq, status, algthm;
  945. unsigned int go2asoc = 0;
  946. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  947. struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
  948. struct sk_buff *skb = precv_frame->pkt;
  949. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
  950. const u8 *p;
  951. u8 *pie;
  952. int plen = skb->len;
  953. DBG_8723A("%s\n", __func__);
  954. /* check A1 matches or not */
  955. if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da))
  956. return _SUCCESS;
  957. if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE))
  958. return _SUCCESS;
  959. pie = mgmt->u.auth.variable;
  960. plen -= offsetof(struct ieee80211_mgmt, u.auth.variable);
  961. algthm = le16_to_cpu(mgmt->u.auth.auth_alg);
  962. seq = le16_to_cpu(mgmt->u.auth.auth_transaction);
  963. status = le16_to_cpu(mgmt->u.auth.status_code);
  964. if (status) {
  965. DBG_8723A("clnt auth fail, status: %d\n", status);
  966. /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */
  967. if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) {
  968. if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
  969. pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open;
  970. else
  971. pmlmeinfo->auth_algo = dot11AuthAlgrthm_Shared;
  972. /* pmlmeinfo->reauth_count = 0; */
  973. }
  974. set_link_timer(pmlmeext, 1);
  975. goto authclnt_fail;
  976. }
  977. if (seq == 2) {
  978. if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) {
  979. /* legendary shared system */
  980. p = cfg80211_find_ie(WLAN_EID_CHALLENGE, pie, plen);
  981. if (!p) {
  982. /* DBG_8723A("marc: no challenge text?\n"); */
  983. goto authclnt_fail;
  984. }
  985. memcpy((void *)(pmlmeinfo->chg_txt), p + 2, p[1]);
  986. pmlmeinfo->auth_seq = 3;
  987. issue_auth(padapter, NULL, 0);
  988. set_link_timer(pmlmeext, REAUTH_TO);
  989. return _SUCCESS;
  990. } else {
  991. /* open system */
  992. go2asoc = 1;
  993. }
  994. } else if (seq == 4) {
  995. if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
  996. go2asoc = 1;
  997. else
  998. goto authclnt_fail;
  999. } else {
  1000. /* this is also illegal */
  1001. /* DBG_8723A("marc: clnt auth failed due to illegal seq =%x\n",
  1002. seq); */
  1003. goto authclnt_fail;
  1004. }
  1005. if (go2asoc) {
  1006. DBG_8723A_LEVEL(_drv_always_, "auth success, start assoc\n");
  1007. start_clnt_assoc(padapter);
  1008. return _SUCCESS;
  1009. }
  1010. authclnt_fail:
  1011. /* pmlmeinfo->state &= ~(WIFI_FW_AUTH_STATE); */
  1012. return _FAIL;
  1013. }
  1014. #ifdef CONFIG_8723AU_AP_MODE
  1015. static int rtw_validate_vendor_specific_ies(const u8 *pos, int elen)
  1016. {
  1017. unsigned int oui;
  1018. /* first 3 bytes in vendor specific information element are the IEEE
  1019. * OUI of the vendor. The following byte is used a vendor specific
  1020. * sub-type. */
  1021. if (elen < 4) {
  1022. DBG_8723A("short vendor specific information element "
  1023. "ignored (len =%i)\n", elen);
  1024. return -EINVAL;
  1025. }
  1026. oui = RTW_GET_BE24(pos);
  1027. switch (oui) {
  1028. case WLAN_OUI_MICROSOFT:
  1029. /* Microsoft/Wi-Fi information elements are further typed and
  1030. * subtyped */
  1031. switch (pos[3]) {
  1032. case WLAN_OUI_TYPE_MICROSOFT_WPA:
  1033. /* Microsoft OUI (00:50:F2) with OUI Type 1:
  1034. * real WPA information element */
  1035. break;
  1036. case WLAN_OUI_TYPE_MICROSOFT_WMM:
  1037. if (elen < 5) {
  1038. DBG_8723A("short WME information element "
  1039. "ignored (len =%i)\n", elen);
  1040. return -EINVAL;
  1041. }
  1042. switch (pos[4]) {
  1043. case WME_OUI_SUBTYPE_INFORMATION_ELEMENT:
  1044. case WME_OUI_SUBTYPE_PARAMETER_ELEMENT:
  1045. break;
  1046. case WME_OUI_SUBTYPE_TSPEC_ELEMENT:
  1047. break;
  1048. default:
  1049. DBG_8723A("unknown WME information element "
  1050. "ignored (subtype =%d len =%i)\n",
  1051. pos[4], elen);
  1052. return -EINVAL;
  1053. }
  1054. break;
  1055. case WLAN_OUI_TYPE_MICROSOFT_WPS:
  1056. /* Wi-Fi Protected Setup (WPS) IE */
  1057. break;
  1058. default:
  1059. DBG_8723A("Unknown Microsoft information element "
  1060. "ignored (type =%d len =%i)\n",
  1061. pos[3], elen);
  1062. return -EINVAL;
  1063. }
  1064. break;
  1065. case OUI_BROADCOM:
  1066. switch (pos[3]) {
  1067. case VENDOR_HT_CAPAB_OUI_TYPE:
  1068. break;
  1069. default:
  1070. DBG_8723A("Unknown Broadcom information element "
  1071. "ignored (type =%d len =%i)\n", pos[3], elen);
  1072. return -EINVAL;
  1073. }
  1074. break;
  1075. default:
  1076. DBG_8723A("unknown vendor specific information element "
  1077. "ignored (vendor OUI %02x:%02x:%02x len =%i)\n",
  1078. pos[0], pos[1], pos[2], elen);
  1079. return -EINVAL;
  1080. }
  1081. return 0;
  1082. }
  1083. static int rtw_validate_frame_ies(const u8 *start, uint len)
  1084. {
  1085. const u8 *pos = start;
  1086. int left = len;
  1087. int unknown = 0;
  1088. while (left >= 2) {
  1089. u8 id, elen;
  1090. id = *pos++;
  1091. elen = *pos++;
  1092. left -= 2;
  1093. if (elen > left) {
  1094. DBG_8723A("%s: IEEE 802.11 failed (id =%d elen =%d "
  1095. "left =%i)\n", __func__, id, elen, left);
  1096. return -EINVAL;
  1097. }
  1098. switch (id) {
  1099. case WLAN_EID_SSID:
  1100. case WLAN_EID_SUPP_RATES:
  1101. case WLAN_EID_FH_PARAMS:
  1102. case WLAN_EID_DS_PARAMS:
  1103. case WLAN_EID_CF_PARAMS:
  1104. case WLAN_EID_TIM:
  1105. case WLAN_EID_IBSS_PARAMS:
  1106. case WLAN_EID_CHALLENGE:
  1107. case WLAN_EID_ERP_INFO:
  1108. case WLAN_EID_EXT_SUPP_RATES:
  1109. break;
  1110. case WLAN_EID_VENDOR_SPECIFIC:
  1111. if (rtw_validate_vendor_specific_ies(pos, elen))
  1112. unknown++;
  1113. break;
  1114. case WLAN_EID_RSN:
  1115. case WLAN_EID_PWR_CAPABILITY:
  1116. case WLAN_EID_SUPPORTED_CHANNELS:
  1117. case WLAN_EID_MOBILITY_DOMAIN:
  1118. case WLAN_EID_FAST_BSS_TRANSITION:
  1119. case WLAN_EID_TIMEOUT_INTERVAL:
  1120. case WLAN_EID_HT_CAPABILITY:
  1121. case WLAN_EID_HT_OPERATION:
  1122. default:
  1123. unknown++;
  1124. DBG_8723A("%s IEEE 802.11 ignored unknown element "
  1125. "(id =%d elen =%d)\n", __func__, id, elen);
  1126. break;
  1127. }
  1128. left -= elen;
  1129. pos += elen;
  1130. }
  1131. if (left)
  1132. return -EINVAL;
  1133. return 0;
  1134. }
  1135. #endif
  1136. static int
  1137. OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
  1138. {
  1139. #ifdef CONFIG_8723AU_AP_MODE
  1140. u16 capab_info, listen_interval;
  1141. struct sta_info *pstat;
  1142. unsigned char reassoc;
  1143. int i, wpa_ie_len, left;
  1144. unsigned char supportRate[16];
  1145. int supportRateNum;
  1146. unsigned short status = WLAN_STATUS_SUCCESS;
  1147. struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
  1148. struct security_priv *psecuritypriv = &padapter->securitypriv;
  1149. struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
  1150. struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
  1151. struct wlan_bssid_ex *cur = &pmlmeinfo->network;
  1152. struct sta_priv *pstapriv = &padapter->stapriv;
  1153. struct sk_buff *skb = precv_frame->pkt;
  1154. struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
  1155. const u8 *pos, *p, *wpa_ie, *wps_ie;
  1156. u8 *pframe = skb->data;
  1157. uint pkt_len = skb->len;
  1158. int r;
  1159. if ((pmlmeinfo->state & 0x03) != MSR_AP)
  1160. return _FAIL;
  1161. left = pkt_len - sizeof(struct ieee80211_hdr_3addr);
  1162. if (ieee80211_is_assoc_req(mgmt->frame_control)) {
  1163. reassoc = 0;
  1164. pos = mgmt->u.assoc_req.variable;
  1165. left -= offsetof(struct ieee80211_mgmt, u.assoc_req.variable);
  1166. } else { /* WIFI_REASSOCREQ */
  1167. reassoc = 1;
  1168. pos = mgmt->u.reassoc_req.variable;
  1169. left -= offsetof(struct ieee80211_mgmt, u.reassoc_req.variable);
  1170. }
  1171. if (left < 0) {
  1172. DBG_8723A("handle_assoc(reassoc =%d) - too short payload "
  1173. "(len =%lu)\n", reassoc, (unsigned long)pkt_len);
  1174. return _FAIL;
  1175. }
  1176. pstat = rtw_get_stainfo23a(pstapriv, mgmt->sa);
  1177. if (!pstat) {
  1178. status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA;
  1179. goto asoc_class2_error;
  1180. }
  1181. /* These two are located at the same offsets whether it's an
  1182. * assoc_req or a reassoc_req */
  1183. capab_info = get_unaligned_le16(&mgmt->u.assoc_req.capab_info);
  1184. listen_interval =
  1185. get_unaligned_le16(&mgmt->u.assoc_req.listen_interval);
  1186. DBG_8723A("%s\n", __func__);
  1187. /* check if this stat has been successfully authenticated/assocated */
  1188. if (!(pstat->state & WIFI_FW_AUTH_SUCCESS)) {
  1189. if (!(pstat->state & WIFI_FW_ASSOC_SUCCESS)) {
  1190. status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA;
  1191. goto asoc_class2_error;
  1192. } else {
  1193. pstat->state &= (~WIFI_FW_ASSOC_SUCCESS);
  1194. pstat->state |= WIFI_FW_ASSOC_STATE;
  1195. }
  1196. } else {
  1197. pstat->state &= (~WIFI_FW_AUTH_SUCCESS);
  1198. pstat->state |= WIFI_FW_ASSOC_STATE;
  1199. }
  1200. pstat->capability = capab_info;
  1201. /* now parse all ieee802_11 ie to point to elems */
  1202. if (rtw_validate_frame_ies(pos, left)) {
  1203. DBG_8723A("STA %pM sent invalid association request\n",
  1204. pstat->hwaddr);
  1205. status = WLAN_STATUS_UNSPECIFIED_FAILURE;
  1206. goto OnAssocReq23aFail;
  1207. }
  1208. /* now we should check all the fields... */
  1209. /* checking SSID */
  1210. p = cfg80211_find_ie(WLAN_EID_SSID, pos, left);
  1211. if (!p || p[1] == 0) {
  1212. /* broadcast ssid, however it is not allowed in assocreq */
  1213. DBG_8723A("STA %pM sent invalid association request lacking an SSID\n",
  1214. pstat->hwaddr);
  1215. status = WLAN_STATUS_UNSPECIFIED_FAILURE;
  1216. goto OnAssocReq23aFail;
  1217. } else {
  1218. /* check if ssid match */
  1219. if (memcmp(p + 2, cur->Ssid.ssid, cur->Ssid.ssid_len))
  1220. status = WLAN_STATUS_UNSPECIFIED_FAILURE;
  1221. if (p[1] != cur->Ssid.ssid_len)
  1222. status = WLAN_STATUS_UNSPECIFIED_FAILURE;
  1223. }
  1224. if (status != WLAN_STATUS_SUCCESS)
  1225. goto OnAssocReq23aFail;
  1226. /* check if the supported rate is ok */
  1227. p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, pos, left);
  1228. if (!p) {
  1229. DBG_8723A("Rx a sta assoc-req which supported rate is "
  1230. "empty!\n");
  1231. /* use our own rate set as statoin used */
  1232. /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */
  1233. /* supportRateNum = AP_BSSRATE_LEN; */
  1234. status = WLAN_STATUS_UNSPECIFIED_FAILURE;
  1235. goto OnAssocReq23aFail;
  1236. } else {
  1237. memcpy(supportRate, p + 2, p[1]);
  1238. supportRateNum = p[1];
  1239. p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, pos, left);
  1240. if (p) {
  1241. if (supportRateNum <= sizeof(supportRate)) {
  1242. memcpy(supportRate+supportRateNum, p + 2, p[1]);
  1243. supportRateNum += p[1];
  1244. }
  1245. }
  1246. }
  1247. /* todo: mask supportRate between AP & STA -> move to update raid */
  1248. /* get_matched_rate(pmlmeext, supportRate, &supportRateNum, 0); */
  1249. /* update station supportRate */
  1250. pstat->bssratelen = supportRateNum;
  1251. memcpy(pstat->bssrateset, supportRate, supportRateNum);
  1252. Update23aTblForSoftAP(pstat->bssrateset, pstat->bssratelen);
  1253. /* check RSN/WPA/WPS */
  1254. pstat->dot8021xalg = 0;
  1255. pstat->wpa_psk = 0;
  1256. pstat->wpa_group_cipher = 0;
  1257. pstat->wpa2_group_cipher = 0;
  1258. pstat->wpa_pairwise_cipher = 0;
  1259. pstat->wpa2_pairwise_cipher = 0;
  1260. memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie));
  1261. wpa_ie = cfg80211_find_ie(WLAN_EID_RSN, pos, left);
  1262. if (!wpa_ie)
  1263. wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
  1264. WLAN_OUI_TYPE_MICROSOFT_WPA,
  1265. pos, left);
  1266. if (wpa_ie) {
  1267. int group_cipher = 0, pairwise_cipher = 0;
  1268. wpa_ie_len = wpa_ie[1];
  1269. if (psecuritypriv->wpa_psk & BIT(1)) {
  1270. r = rtw_parse_wpa2_ie23a(wpa_ie, wpa_ie_len + 2,
  1271. &group_cipher,
  1272. &pairwise_cipher, NULL);
  1273. if (r == _SUCCESS) {
  1274. pstat->dot8021xalg = 1;/* psk, todo:802.1x */
  1275. pstat->wpa_psk |= BIT(1);
  1276. pstat->wpa2_group_cipher = group_cipher &
  1277. psecuritypriv->wpa2_group_cipher;
  1278. pstat->wpa2_pairwise_cipher = pairwise_cipher &
  1279. psecuritypriv->wpa2_pairwise_cipher;
  1280. } else
  1281. status = WLAN_STATUS_INVALID_IE;
  1282. } else if (psecuritypriv->wpa_psk & BIT(0)) {
  1283. r = rtw_parse_wpa_ie23a(wpa_ie, wpa_ie_len + 2,
  1284. &group_cipher, &pairwise_cipher,
  1285. NULL);
  1286. if (r == _SUCCESS) {
  1287. pstat->dot8021xalg = 1;/* psk, todo:802.1x */
  1288. pstat->wpa_psk |= BIT(0);
  1289. pstat->wpa_group_cipher = group_cipher &
  1290. psecuritypriv->wpa_group_cipher;
  1291. pstat->wpa_pairwise_cipher = pairwise_cipher &
  1292. psecuritypriv->wpa_pairwise_cipher;
  1293. } else
  1294. status = WLAN_STATUS_INVALID_IE;
  1295. } else {
  1296. wpa_ie = NULL;
  1297. wpa_ie_len = 0;
  1298. }
  1299. if (wpa_ie && status == WLAN_STATUS_SUCCESS) {
  1300. if (!pstat->wpa_group_cipher)
  1301. status = WLAN_STATUS_INVALID_GROUP_CIPHER;
  1302. if (!pstat->wpa_pairwise_cipher)
  1303. status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER;
  1304. }
  1305. }
  1306. if (status != WLAN_STATUS_SUCCESS)
  1307. goto OnAssocReq23aFail;
  1308. pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS);
  1309. wps_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
  1310. WLAN_OUI_TYPE_MICROSOFT_WPS,
  1311. pos, left);
  1312. if (!wpa_ie) {
  1313. if (wps_ie) {
  1314. DBG_8723A("STA included WPS IE in (Re)Association "
  1315. "Request - assume WPS is used\n");
  1316. pstat->flags |= WLAN_STA_WPS;
  1317. } else {
  1318. DBG_8723A("STA did not include WPA/RSN IE in (Re)"
  1319. "Association Request - possible WPS use\n");
  1320. pstat->flags |= WLAN_STA_MAYBE_WPS;
  1321. }
  1322. } else {
  1323. int copy_len;
  1324. if (psecuritypriv->wpa_psk == 0) {
  1325. DBG_8723A("STA %pM: WPA/RSN IE in association request, but AP don't support WPA/RSN\n",
  1326. pstat->hwaddr);
  1327. status = WLAN_STATUS_INVALID_IE;
  1328. goto OnAssocReq23aFail;
  1329. }
  1330. if (wps_ie) {
  1331. DBG_8723A("STA included WPS IE in (Re)Association "
  1332. "Request - WPS is used\n");
  1333. pstat->flags |= WLAN_STA_WPS;
  1334. copy_len = 0;
  1335. } else {
  1336. copy_len = ((wpa_ie_len + 2) > sizeof(pstat->wpa_ie)) ?
  1337. sizeof(pstat->wpa_ie) : (wpa_ie_len + 2);
  1338. }
  1339. if (copy_len > 0)
  1340. memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len);
  1341. }
  1342. /* check if there is WMM IE & support WWM-PS */
  1343. pstat->flags &= ~WLAN_STA_WME;
  1344. pstat->qos_option = 0;
  1345. pstat->qos_info = 0;
  1346. pstat->has_legacy_ac = true;
  1347. pstat->uapsd_vo = 0;
  1348. pstat->uapsd_vi = 0;
  1349. pstat->uapsd_be = 0;
  1350. pstat->uapsd_bk = 0;
  1351. if (pmlmepriv->qos_option) {
  1352. const u8 *end = pos + left;
  1353. p = pos;
  1354. for (;;) {
  1355. left = end - p;
  1356. p = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
  1357. WLAN_OUI_TYPE_MICROSOFT_WMM,
  1358. p, left);
  1359. if (p) {
  1360. pstat->flags |= WLAN_STA_WME;
  1361. pstat->qos_option = 1;
  1362. pstat->qos_info = *(p + 8);
  1363. pstat->max_sp_len =
  1364. (pstat->qos_info >> 5) & 0x3;
  1365. if ((pstat->qos_info & 0xf) != 0xf)
  1366. pstat->has_legacy_ac = true;
  1367. else
  1368. pstat->has_legacy_ac = false;
  1369. if (pstat->qos_info & 0xf) {
  1370. if (pstat->qos_info & BIT(0))
  1371. pstat->uapsd_vo = BIT(0)|BIT(1);
  1372. else
  1373. pstat->uapsd_vo = 0;
  1374. if (pstat->qos_info & BIT(1))
  1375. pstat->uapsd_vi = BIT(0)|BIT(1);
  1376. else
  1377. pstat->uapsd_vi = 0;
  1378. if (pstat->qos_info & BIT(2))
  1379. pstat->uapsd_bk = BIT(0)|BIT(1);
  1380. else
  1381. pstat->uapsd_bk = 0;
  1382. if (pstat->qos_info & BIT(3))
  1383. pstat->uapsd_be = BIT(0)|BIT(1);
  1384. else
  1385. pstat->uapsd_be = 0;
  1386. break;
  1387. }
  1388. } else {
  1389. break;
  1390. }
  1391. p = p + p[1] + 2;
  1392. }
  1393. }
  1394. /* save HT capabilities in the sta object */
  1395. memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap));
  1396. p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pos, left);
  1397. if (p && p[1] >= sizeof(struct ieee80211_ht_cap)) {
  1398. pstat->flags |= WLAN_STA_HT;
  1399. pstat->flags |= WLAN_STA_WME;
  1400. memcpy(&pstat->htpriv.ht_cap, p + 2,
  1401. sizeof(struct ieee80211_ht_cap));
  1402. } else
  1403. pstat->flags &= ~WLAN_STA_HT;
  1404. if (!pmlmepriv->htpriv.ht_option && pstat->flags & WLAN_STA_HT){
  1405. status = WLAN_STATUS_UNSPECIFIED_FAILURE;
  1406. goto On

Large files files are truncated, but you can click here to view the full file