2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/rsn.c#2 $
6 \brief This file including the 802.11i, wpa and wpa2(rsn) related function.
8 This file provided the macros and functions library support the wpa/rsn ie parsing,
9 cipher and AKM check to help the AP seleced deciding, tkip mic error handler and rsn PMKID support.
17 * 07 17 2012 yuche.tsai
19 * Compile no error before trial run.
21 * 03 09 2012 chinglan.wang
23 * Fix the condition error.
27 * Snc CFG80211 modification for ICS migration from branch 2.2.
31 * Sync CFG80211 modification from branch 2,2.
34 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
35 * modify the xlog related code.
38 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
39 * change the debug module level.
42 * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
43 * adding the 802.11w related function and define .
45 * 03 17 2011 chinglan.wang
46 * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
50 * [WCXRP00000432] [MT6620 Wi-Fi][Driver] Add STA privacy check at hotspot mode
51 * adding the code for check STA privacy bit at AP mode, .
53 * 12 24 2010 chinglan.wang
55 * [MT6620][Wi-Fi] Modify the key management in the driver for WPS function.
58 * [WCXRP00000260] [MT6620 Wi-Fi][Driver][Firmware] Create V1.1 branch for both firmware and driver
59 * create branch for Wi-Fi driver v1.1
62 * [WCXRP00000165] [MT6620 Wi-Fi] [Pre-authentication] Assoc req rsn ie use wrong pmkid value
63 * fixed the.pmkid value mismatch issue
66 * [WCXRP00000124] [MT6620 Wi-Fi] [Driver] Support the dissolve P2P Group
67 * Refine the HT rate disallow TKIP pairwise cipher .
70 * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T and replaced by ENUM_NETWORK_TYPE_INDEX_T only
71 * remove ENUM_NETWORK_TYPE_T definitions
73 * 09 29 2010 yuche.tsai
75 * Fix compile error, remove unused pointer in rsnGenerateRSNIE().
79 * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
83 * [WCXRP00005002][MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning.
87 * let the p2p can set the privacy bit at beacon and rsn ie at assoc req at key handshake state.
91 * remove non-used code.
95 * adding the tx pkt call back handle for countermeasure.
99 * .support the Wi-Fi RSN
103 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
106 * [WPD00003840][MT6620 5931] Security migration
107 * modify some code for concurrent network.
110 * [WPD00003833][MT6620 and MT5931] Driver migration
111 * [WPD00003833][MT6620 and MT5931] Driver migration
112 * enable RX management frame handling.
115 * [WPD00003840][MT6620 5931] Security migration
116 * consdier the concurrent network setting.
119 * [WPD00003840][MT6620 5931] Security migration
120 * [WPD00003840] [MT6620 5931] Security migration
121 * migration from firmware.
124 * [BORA00000637][MT6620 Wi-Fi] [Bug] WPA2 pre-authentication timer not correctly initialize
125 * not indiate pmkid candidate while no new one scaned.
128 * [BORA00000637][MT6620 Wi-Fi] [Bug] WPA2 pre-authentication timer not correctly initialize
129 * adjsut the pre-authentication code.
132 * [BORA00000637][MT6620 Wi-Fi] [Bug] WPA2 pre-authentication timer not correctly initialize
133 * move the AIS specific variable for security to AIS specific structure.
136 * [BORA00000637][MT6620 Wi-Fi] [Bug] WPA2 pre-authentication timer not correctly initialize
137 * Fixed the pre-authentication timer not correctly init issue, and modify the security related callback function prototype.
140 * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
141 * add and fixed some security function.
143 * 12 18 2009 cm.chang
144 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
147 * Dec 8 2009 mtk01088
148 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
151 * Dec 7 2009 mtk01088
152 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
153 * using the Rx0 port to indicate event
155 * Dec 4 2009 mtk01088
156 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
157 * refine the code for generate the WPA/RSN IE for assoc req
159 * Dec 3 2009 mtk01088
160 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
161 * adjust code for pmkid event
163 * Dec 1 2009 mtk01088
164 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
165 * adding the code for event (mic error and pmkid indicate) and do some function rename
167 * Nov 23 2009 mtk01088
168 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
169 * adding some security function
171 * Nov 19 2009 mtk01088
172 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
173 * adding some security feature, including pmkid
175 * Nov 18 2009 mtk01088
176 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
181 /*******************************************************************************
182 * C O M P I L E R F L A G S
183 ********************************************************************************
186 /*******************************************************************************
187 * E X T E R N A L R E F E R E N C E S
188 ********************************************************************************
192 #if CFG_RSN_MIGRATION
194 //extern PHY_ATTRIBUTE_T rPhyAttributes[];
196 /*******************************************************************************
198 ********************************************************************************
201 /*******************************************************************************
203 ********************************************************************************
206 /*******************************************************************************
207 * P U B L I C D A T A
208 ********************************************************************************
211 /*******************************************************************************
212 * P R I V A T E D A T A
213 ********************************************************************************
216 /*******************************************************************************
218 ********************************************************************************
221 /*******************************************************************************
222 * F U N C T I O N D E C L A R A T I O N S
223 ********************************************************************************
226 /*******************************************************************************
228 ********************************************************************************
231 /*----------------------------------------------------------------------------*/
233 * \brief This routine is called to parse RSN IE.
235 * \param[in] prInfoElem Pointer to the RSN IE
236 * \param[out] prRsnInfo Pointer to the BSSDescription structure to store the
237 ** RSN information from the given RSN IE
239 * \retval TRUE - Succeeded
240 * \retval FALSE - Failed
242 /*----------------------------------------------------------------------------*/
245 IN P_ADAPTER_T prAdapter,
246 IN P_RSN_INFO_ELEM_T prInfoElem,
247 OUT P_RSN_INFO_T prRsnInfo
251 INT_32 u4RemainRsnIeLen;
254 UINT_32 u4GroupSuite = RSN_CIPHER_SUITE_CCMP;
255 UINT_16 u2PairSuiteCount = 0;
256 UINT_16 u2AuthSuiteCount = 0;
257 PUINT_8 pucPairSuite = NULL;
258 PUINT_8 pucAuthSuite = NULL;
261 DEBUGFUNC("rsnParseRsnIE");
266 /* Verify the length of the RSN IE. */
267 if (prInfoElem->ucLength < 2) {
268 DBGLOG(RSN, TRACE, ("RSN IE length too short (length=%d)\n", prInfoElem->ucLength));
272 /* Check RSN version: currently, we only support version 1. */
273 WLAN_GET_FIELD_16(&prInfoElem->u2Version, &u2Version);
274 if (u2Version != 1) {
275 DBGLOG(RSN, TRACE,("Unsupported RSN IE version: %d\n", u2Version));
279 cp = (PUCHAR) &prInfoElem->u4GroupKeyCipherSuite;
280 u4RemainRsnIeLen = (INT_32) prInfoElem->ucLength - 2;
283 if (u4RemainRsnIeLen == 0) {
287 /* Parse the Group Key Cipher Suite field. */
288 if (u4RemainRsnIeLen < 4) {
289 DBGLOG(RSN, TRACE, ("Fail to parse RSN IE in group cipher suite (IE len: %d)\n",
290 prInfoElem->ucLength));
294 WLAN_GET_FIELD_32(cp, &u4GroupSuite);
296 u4RemainRsnIeLen -= 4;
298 if (u4RemainRsnIeLen == 0) {
302 /* Parse the Pairwise Key Cipher Suite Count field. */
303 if (u4RemainRsnIeLen < 2) {
304 DBGLOG(RSN, TRACE,("Fail to parse RSN IE in pairwise cipher suite count (IE len: %d)\n",
305 prInfoElem->ucLength));
309 WLAN_GET_FIELD_16(cp, &u2PairSuiteCount);
311 u4RemainRsnIeLen -= 2;
313 /* Parse the Pairwise Key Cipher Suite List field. */
314 i = (UINT_32) u2PairSuiteCount * 4;
315 if (u4RemainRsnIeLen < (INT_32) i) {
316 DBGLOG(RSN, TRACE,("Fail to parse RSN IE in pairwise cipher suite list (IE len: %d)\n",
317 prInfoElem->ucLength));
324 u4RemainRsnIeLen -= (INT_32) i;
326 if (u4RemainRsnIeLen == 0) {
330 /* Parse the Authentication and Key Management Cipher Suite Count field. */
331 if (u4RemainRsnIeLen < 2) {
332 DBGLOG(RSN, TRACE,("Fail to parse RSN IE in auth & key mgt suite count (IE len: %d)\n",
333 prInfoElem->ucLength));
337 WLAN_GET_FIELD_16(cp, &u2AuthSuiteCount);
339 u4RemainRsnIeLen -= 2;
341 /* Parse the Authentication and Key Management Cipher Suite List
343 i = (UINT_32) u2AuthSuiteCount * 4;
344 if (u4RemainRsnIeLen < (INT_32) i) {
345 DBGLOG(RSN, TRACE, ("Fail to parse RSN IE in auth & key mgt suite list (IE len: %d)\n",
346 prInfoElem->ucLength));
353 u4RemainRsnIeLen -= (INT_32) i;
355 if (u4RemainRsnIeLen == 0) {
359 /* Parse the RSN u2Capabilities field. */
360 if (u4RemainRsnIeLen < 2) {
361 DBGLOG(RSN, TRACE, ("Fail to parse RSN IE in RSN capabilities (IE len: %d)\n",
362 prInfoElem->ucLength));
366 WLAN_GET_FIELD_16(cp, &u2Cap);
369 /* Save the RSN information for the BSS. */
370 prRsnInfo->ucElemId = ELEM_ID_RSN;
372 prRsnInfo->u2Version = u2Version;
374 prRsnInfo->u4GroupKeyCipherSuite = u4GroupSuite;
376 DBGLOG(RSN, LOUD, ("RSN: version %d, group key cipher suite %02x-%02x-%02x-%02x\n",
377 u2Version, (UCHAR) (u4GroupSuite & 0x000000FF),
378 (UCHAR) ((u4GroupSuite >> 8) & 0x000000FF),
379 (UCHAR) ((u4GroupSuite >> 16) & 0x000000FF),
380 (UCHAR) ((u4GroupSuite >> 24) & 0x000000FF)));
383 /* The information about the pairwise key cipher suites is present. */
384 if (u2PairSuiteCount > MAX_NUM_SUPPORTED_CIPHER_SUITES) {
385 u2PairSuiteCount = MAX_NUM_SUPPORTED_CIPHER_SUITES;
388 prRsnInfo->u4PairwiseKeyCipherSuiteCount = (UINT_32) u2PairSuiteCount;
390 for (i = 0; i < (UINT_32) u2PairSuiteCount; i++) {
391 WLAN_GET_FIELD_32(pucPairSuite,
392 &prRsnInfo->au4PairwiseKeyCipherSuite[i]);
395 DBGLOG(RSN, LOUD, ("RSN: pairwise key cipher suite [%d]: %02x-%02x-%02x-%02x\n",
396 (UINT_8)i, (UCHAR) (prRsnInfo->au4PairwiseKeyCipherSuite[i] & 0x000000FF),
397 (UCHAR) ((prRsnInfo->au4PairwiseKeyCipherSuite[i] >> 8) & 0x000000FF),
398 (UCHAR) ((prRsnInfo->au4PairwiseKeyCipherSuite[i] >> 16) & 0x000000FF),
399 (UCHAR) ((prRsnInfo->au4PairwiseKeyCipherSuite[i] >> 24) & 0x000000FF)));
403 /* The information about the pairwise key cipher suites is not present.
404 Use the default chipher suite for RSN: CCMP. */
405 prRsnInfo->u4PairwiseKeyCipherSuiteCount = 1;
406 prRsnInfo->au4PairwiseKeyCipherSuite[0] = RSN_CIPHER_SUITE_CCMP;
408 DBGLOG(RSN, LOUD, ("RSN: pairwise key cipher suite: %02x-%02x-%02x-%02x (default)\n",
409 (UCHAR) (prRsnInfo->au4PairwiseKeyCipherSuite[0] & 0x000000FF),
410 (UCHAR) ((prRsnInfo->au4PairwiseKeyCipherSuite[0] >> 8) & 0x000000FF),
411 (UCHAR) ((prRsnInfo->au4PairwiseKeyCipherSuite[0] >> 16) & 0x000000FF),
412 (UCHAR) ((prRsnInfo->au4PairwiseKeyCipherSuite[0] >> 24) & 0x000000FF)));
416 /* The information about the authentication and key management suites
418 if (u2AuthSuiteCount > MAX_NUM_SUPPORTED_AKM_SUITES) {
419 u2AuthSuiteCount = MAX_NUM_SUPPORTED_AKM_SUITES;
422 prRsnInfo->u4AuthKeyMgtSuiteCount = (UINT_32) u2AuthSuiteCount;
424 for (i = 0; i < (UINT_32) u2AuthSuiteCount; i++) {
425 WLAN_GET_FIELD_32(pucAuthSuite, &prRsnInfo->au4AuthKeyMgtSuite[i]);
428 DBGLOG(RSN, LOUD, ("RSN: AKM suite [%d]: %02x-%02x-%02x-%02x\n",
429 (UINT_8)i, (UCHAR) (prRsnInfo->au4AuthKeyMgtSuite[i] & 0x000000FF),
430 (UCHAR) ((prRsnInfo->au4AuthKeyMgtSuite[i] >> 8) & 0x000000FF),
431 (UCHAR) ((prRsnInfo->au4AuthKeyMgtSuite[i] >> 16) & 0x000000FF),
432 (UCHAR) ((prRsnInfo->au4AuthKeyMgtSuite[i] >> 24) & 0x000000FF)));
436 /* The information about the authentication and key management suites
437 is not present. Use the default AKM suite for RSN. */
438 prRsnInfo->u4AuthKeyMgtSuiteCount = 1;
439 prRsnInfo->au4AuthKeyMgtSuite[0] = RSN_AKM_SUITE_802_1X;
441 DBGLOG(RSN, LOUD, ("RSN: AKM suite: %02x-%02x-%02x-%02x (default)\n",
442 (UCHAR) (prRsnInfo->au4AuthKeyMgtSuite[0] & 0x000000FF),
443 (UCHAR) ((prRsnInfo->au4AuthKeyMgtSuite[0] >> 8) & 0x000000FF),
444 (UCHAR) ((prRsnInfo->au4AuthKeyMgtSuite[0] >> 16) & 0x000000FF),
445 (UCHAR) ((prRsnInfo->au4AuthKeyMgtSuite[0] >> 24) & 0x000000FF)));
448 prRsnInfo->u2RsnCap = u2Cap;
449 #if CFG_SUPPORT_802_11W
450 prRsnInfo->fgRsnCapPresent = TRUE;
452 DBGLOG(RSN, LOUD, ("RSN cap: 0x%04x\n", prRsnInfo->u2RsnCap));
455 } /* rsnParseRsnIE */
458 /*----------------------------------------------------------------------------*/
460 * \brief This routine is called to parse WPA IE.
462 * \param[in] prInfoElem Pointer to the WPA IE.
463 * \param[out] prWpaInfo Pointer to the BSSDescription structure to store the
464 * WPA information from the given WPA IE.
466 * \retval TRUE Succeeded.
467 * \retval FALSE Failed.
469 /*----------------------------------------------------------------------------*/
472 IN P_ADAPTER_T prAdapter,
473 IN P_WPA_INFO_ELEM_T prInfoElem,
474 OUT P_RSN_INFO_T prWpaInfo
478 INT_32 u4RemainWpaIeLen;
481 UINT_32 u4GroupSuite = WPA_CIPHER_SUITE_TKIP;
482 UINT_16 u2PairSuiteCount = 0;
483 UINT_16 u2AuthSuiteCount = 0;
484 PUCHAR pucPairSuite = NULL;
485 PUCHAR pucAuthSuite = NULL;
487 BOOLEAN fgCapPresent = FALSE;
489 DEBUGFUNC("rsnParseWpaIE");
494 /* Verify the length of the WPA IE. */
495 if (prInfoElem->ucLength < 6) {
496 DBGLOG(RSN, TRACE,("WPA IE length too short (length=%d)\n", prInfoElem->ucLength));
500 /* Check WPA version: currently, we only support version 1. */
501 WLAN_GET_FIELD_16(&prInfoElem->u2Version, &u2Version);
502 if (u2Version != 1) {
503 DBGLOG(RSN, TRACE, ("Unsupported WPA IE version: %d\n", u2Version));
507 cp = (PUCHAR) &prInfoElem->u4GroupKeyCipherSuite;
508 u4RemainWpaIeLen = (INT_32) prInfoElem->ucLength - 6;
511 if (u4RemainWpaIeLen == 0) {
519 PairwiseSuite: 4 * pairSuiteCount
521 AuthSuite : 4 * authSuiteCount
524 /* Parse the Group Key Cipher Suite field. */
525 if (u4RemainWpaIeLen < 4) {
526 DBGLOG(RSN, TRACE,("Fail to parse WPA IE in group cipher suite (IE len: %d)\n",
527 prInfoElem->ucLength));
531 WLAN_GET_FIELD_32(cp, &u4GroupSuite);
533 u4RemainWpaIeLen -= 4;
535 if (u4RemainWpaIeLen == 0) {
539 /* Parse the Pairwise Key Cipher Suite Count field. */
540 if (u4RemainWpaIeLen < 2) {
541 DBGLOG(RSN, TRACE,("Fail to parse WPA IE in pairwise cipher suite count (IE len: %d)\n",
542 prInfoElem->ucLength));
546 WLAN_GET_FIELD_16(cp, &u2PairSuiteCount);
548 u4RemainWpaIeLen -= 2;
550 /* Parse the Pairwise Key Cipher Suite List field. */
551 i = (UINT_32) u2PairSuiteCount * 4;
552 if (u4RemainWpaIeLen < (INT_32) i) {
553 DBGLOG(RSN, TRACE,("Fail to parse WPA IE in pairwise cipher suite list (IE len: %d)\n",
554 prInfoElem->ucLength));
561 u4RemainWpaIeLen -= (INT_32) i;
563 if (u4RemainWpaIeLen == 0) {
567 /* Parse the Authentication and Key Management Cipher Suite Count
569 if (u4RemainWpaIeLen < 2) {
570 DBGLOG(RSN, TRACE,("Fail to parse WPA IE in auth & key mgt suite count (IE len: %d)\n",
571 prInfoElem->ucLength));
575 WLAN_GET_FIELD_16(cp, &u2AuthSuiteCount);
577 u4RemainWpaIeLen -= 2;
579 /* Parse the Authentication and Key Management Cipher Suite List
581 i = (UINT_32) u2AuthSuiteCount * 4;
582 if (u4RemainWpaIeLen < (INT_32) i) {
583 DBGLOG(RSN, TRACE, ("Fail to parse WPA IE in auth & key mgt suite list (IE len: %d)\n",
584 prInfoElem->ucLength));
591 u4RemainWpaIeLen -= (INT_32) i;
593 if (u4RemainWpaIeLen == 0) {
597 /* Parse the WPA u2Capabilities field. */
598 if (u4RemainWpaIeLen < 2) {
599 DBGLOG(RSN, TRACE, ("Fail to parse WPA IE in WPA capabilities (IE len: %d)\n",
600 prInfoElem->ucLength));
605 WLAN_GET_FIELD_16(cp, &u2Cap);
606 u4RemainWpaIeLen -= 2;
609 /* Save the WPA information for the BSS. */
611 prWpaInfo->ucElemId = ELEM_ID_WPA;
613 prWpaInfo->u2Version = u2Version;
615 prWpaInfo->u4GroupKeyCipherSuite = u4GroupSuite;
617 DBGLOG(RSN, LOUD, ("WPA: version %d, group key cipher suite %02x-%02x-%02x-%02x\n",
618 u2Version, (UCHAR) (u4GroupSuite & 0x000000FF),
619 (UCHAR) ((u4GroupSuite >> 8) & 0x000000FF),
620 (UCHAR) ((u4GroupSuite >> 16) & 0x000000FF),
621 (UCHAR) ((u4GroupSuite >> 24) & 0x000000FF)));
624 /* The information about the pairwise key cipher suites is present. */
625 if (u2PairSuiteCount > MAX_NUM_SUPPORTED_CIPHER_SUITES) {
626 u2PairSuiteCount = MAX_NUM_SUPPORTED_CIPHER_SUITES;
629 prWpaInfo->u4PairwiseKeyCipherSuiteCount = (UINT_32) u2PairSuiteCount;
631 for (i = 0; i < (UINT_32) u2PairSuiteCount; i++) {
632 WLAN_GET_FIELD_32(pucPairSuite,
633 &prWpaInfo->au4PairwiseKeyCipherSuite[i]);
636 DBGLOG(RSN, LOUD, ("WPA: pairwise key cipher suite [%d]: %02x-%02x-%02x-%02x\n",
637 (UINT_8)i, (UCHAR) (prWpaInfo->au4PairwiseKeyCipherSuite[i] & 0x000000FF),
638 (UCHAR) ((prWpaInfo->au4PairwiseKeyCipherSuite[i] >> 8) & 0x000000FF),
639 (UCHAR) ((prWpaInfo->au4PairwiseKeyCipherSuite[i] >> 16) & 0x000000FF),
640 (UCHAR) ((prWpaInfo->au4PairwiseKeyCipherSuite[i] >> 24) & 0x000000FF)));
644 /* The information about the pairwise key cipher suites is not present.
645 Use the default chipher suite for WPA: TKIP. */
646 prWpaInfo->u4PairwiseKeyCipherSuiteCount = 1;
647 prWpaInfo->au4PairwiseKeyCipherSuite[0] = WPA_CIPHER_SUITE_TKIP;
649 DBGLOG(RSN, LOUD, ("WPA: pairwise key cipher suite: %02x-%02x-%02x-%02x (default)\n",
650 (UCHAR) (prWpaInfo->au4PairwiseKeyCipherSuite[0] & 0x000000FF),
651 (UCHAR) ((prWpaInfo->au4PairwiseKeyCipherSuite[0] >> 8) & 0x000000FF),
652 (UCHAR) ((prWpaInfo->au4PairwiseKeyCipherSuite[0] >> 16) & 0x000000FF),
653 (UCHAR) ((prWpaInfo->au4PairwiseKeyCipherSuite[0] >> 24) & 0x000000FF)));
657 /* The information about the authentication and key management suites
659 if (u2AuthSuiteCount > MAX_NUM_SUPPORTED_AKM_SUITES) {
660 u2AuthSuiteCount = MAX_NUM_SUPPORTED_AKM_SUITES;
663 prWpaInfo->u4AuthKeyMgtSuiteCount = (UINT_32) u2AuthSuiteCount;
665 for (i = 0; i < (UINT_32) u2AuthSuiteCount; i++) {
666 WLAN_GET_FIELD_32(pucAuthSuite, &prWpaInfo->au4AuthKeyMgtSuite[i]);
669 DBGLOG(RSN, LOUD, ("WPA: AKM suite [%d]: %02x-%02x-%02x-%02x\n",
670 (UINT_8)i, (UCHAR) (prWpaInfo->au4AuthKeyMgtSuite[i] & 0x000000FF),
671 (UCHAR) ((prWpaInfo->au4AuthKeyMgtSuite[i] >> 8) & 0x000000FF),
672 (UCHAR) ((prWpaInfo->au4AuthKeyMgtSuite[i] >> 16) & 0x000000FF),
673 (UCHAR) ((prWpaInfo->au4AuthKeyMgtSuite[i] >> 24) & 0x000000FF)));
677 /* The information about the authentication and key management suites
678 is not present. Use the default AKM suite for WPA. */
679 prWpaInfo->u4AuthKeyMgtSuiteCount = 1;
680 prWpaInfo->au4AuthKeyMgtSuite[0] = WPA_AKM_SUITE_802_1X;
682 DBGLOG(RSN, LOUD, ("WPA: AKM suite: %02x-%02x-%02x-%02x (default)\n",
683 (UCHAR) (prWpaInfo->au4AuthKeyMgtSuite[0] & 0x000000FF),
684 (UCHAR) ((prWpaInfo->au4AuthKeyMgtSuite[0] >> 8) & 0x000000FF),
685 (UCHAR) ((prWpaInfo->au4AuthKeyMgtSuite[0] >> 16) & 0x000000FF),
686 (UCHAR) ((prWpaInfo->au4AuthKeyMgtSuite[0] >> 24) & 0x000000FF)));
690 prWpaInfo->fgRsnCapPresent = TRUE;
691 prWpaInfo->u2RsnCap = u2Cap;
692 DBGLOG(RSN, LOUD, ("WPA: RSN cap: 0x%04x\n", prWpaInfo->u2RsnCap));
695 prWpaInfo->fgRsnCapPresent = FALSE;
696 prWpaInfo->u2RsnCap = 0;
700 } /* rsnParseWpaIE */
703 /*----------------------------------------------------------------------------*/
705 * \brief This routine is called to search the desired pairwise
706 * cipher suite from the MIB Pairwise Cipher Suite
707 * configuration table.
709 * \param[in] u4Cipher The desired pairwise cipher suite to be searched
710 * \param[out] pu4Index Pointer to the index of the desired pairwise cipher in
713 * \retval TRUE - The desired pairwise cipher suite is found in the table.
714 * \retval FALSE - The desired pairwise cipher suite is not found in the
717 /*----------------------------------------------------------------------------*/
719 rsnSearchSupportedCipher (
720 IN P_ADAPTER_T prAdapter,
722 OUT PUINT_32 pu4Index
726 P_DOT11_RSNA_CONFIG_PAIRWISE_CIPHERS_ENTRY prEntry;
728 DEBUGFUNC("rsnSearchSupportedCipher");
732 for (i = 0; i < MAX_NUM_SUPPORTED_CIPHER_SUITES; i++) {
733 prEntry = &prAdapter->rMib.dot11RSNAConfigPairwiseCiphersTable[i];
734 if (prEntry->dot11RSNAConfigPairwiseCipher == u4Cipher &&
735 prEntry->dot11RSNAConfigPairwiseCipherEnabled) {
741 } /* rsnSearchSupportedCipher */
743 /*----------------------------------------------------------------------------*/
745 * \brief Whether BSS RSN is matched from upper layer set.
747 * \param[in] prAdapter Pointer to the Adapter structure, BSS RSN Information
751 /*----------------------------------------------------------------------------*/
754 IN P_ADAPTER_T prAdapter,
755 IN P_RSN_INFO_T prBssRsnInfo
760 DEBUGFUNC("rsnIsSuitableBSS");
764 if((prAdapter->rWifiVar.rConnSettings.rRsnInfo.u4GroupKeyCipherSuite & 0x000000FF) != \
765 GET_SELECTOR_TYPE(prBssRsnInfo->u4GroupKeyCipherSuite)){
766 DBGLOG(RSN, TRACE, ("Break by GroupKeyCipherSuite\n"));
769 for(i = 0; i < prBssRsnInfo->u4PairwiseKeyCipherSuiteCount; i++){
770 if(((prAdapter->rWifiVar.rConnSettings.rRsnInfo.au4PairwiseKeyCipherSuite[0] & 0x000000FF) != \
771 GET_SELECTOR_TYPE(prBssRsnInfo->au4PairwiseKeyCipherSuite[i]))
772 && (i == prBssRsnInfo->u4PairwiseKeyCipherSuiteCount - 1) ){
773 DBGLOG(RSN, TRACE, ("Break by PairwiseKeyCipherSuite\n"));
777 for(i = 0; i < prBssRsnInfo->u4AuthKeyMgtSuiteCount; i++){
778 if(((prAdapter->rWifiVar.rConnSettings.rRsnInfo.au4AuthKeyMgtSuite[0] & 0x000000FF) != \
779 GET_SELECTOR_TYPE(prBssRsnInfo->au4AuthKeyMgtSuite[0]))
780 && (i == prBssRsnInfo->u4AuthKeyMgtSuiteCount - 1)){
781 DBGLOG(RSN, TRACE, ("Break by AuthKeyMgtSuite \n"));
792 /*----------------------------------------------------------------------------*/
795 * \brief This routine is called to search the desired
796 * authentication and key management (AKM) suite from the
797 * MIB Authentication and Key Management Suites table.
799 * \param[in] u4AkmSuite The desired AKM suite to be searched
800 * \param[out] pu4Index Pointer to the index of the desired AKM suite in the
803 * \retval TRUE The desired AKM suite is found in the table.
804 * \retval FALSE The desired AKM suite is not found in the table.
808 /*----------------------------------------------------------------------------*/
811 IN P_ADAPTER_T prAdapter,
812 IN UINT_32 u4AkmSuite,
813 OUT PUINT_32 pu4Index
817 P_DOT11_RSNA_CONFIG_AUTHENTICATION_SUITES_ENTRY prEntry;
819 DEBUGFUNC("rsnSearchAKMSuite");
823 for (i = 0; i < MAX_NUM_SUPPORTED_AKM_SUITES; i++) {
824 prEntry = &prAdapter->rMib.dot11RSNAConfigAuthenticationSuitesTable[i];
825 if (prEntry->dot11RSNAConfigAuthenticationSuite == u4AkmSuite &&
826 prEntry->dot11RSNAConfigAuthenticationSuiteEnabled) {
832 } /* rsnSearchAKMSuite */
835 /*----------------------------------------------------------------------------*/
837 * \brief This routine is called to perform RSNA or TSN policy
838 * selection for a given BSS.
840 * \param[in] prBss Pointer to the BSS description
842 * \retval TRUE - The RSNA/TSN policy selection for the given BSS is
843 * successful. The selected pairwise and group cipher suites
844 * are returned in the BSS description.
845 * \retval FALSE - The RSNA/TSN policy selection for the given BSS is failed.
846 * The driver shall not attempt to join the given BSS.
848 * \note The Encrypt status matched score will save to bss for final ap select.
850 /*----------------------------------------------------------------------------*/
852 rsnPerformPolicySelection (
853 IN P_ADAPTER_T prAdapter,
854 IN P_BSS_DESC_T prBss
857 #if CFG_SUPPORT_802_11W
863 BOOLEAN fgSuiteSupported;
864 UINT_32 u4PairwiseCipher = 0;
865 UINT_32 u4GroupCipher = 0;
866 UINT_32 u4AkmSuite = 0;
867 P_RSN_INFO_T prBssRsnInfo;
868 ENUM_NETWORK_TYPE_INDEX_T eNetwotkType;
869 BOOLEAN fgIsWpsActive = (BOOLEAN)FALSE;
871 DEBUGFUNC("rsnPerformPolicySelection");
875 DBGLOG(RSN, TRACE, ("rsnPerformPolicySelection\n"));
877 eNetwotkType = NETWORK_TYPE_AIS_INDEX;
879 prBss->u4RsnSelectedPairwiseCipher = 0;
880 prBss->u4RsnSelectedGroupCipher = 0;
881 prBss->u4RsnSelectedAKMSuite = 0;
882 prBss->ucEncLevel = 0;
885 fgIsWpsActive = kalWSCGetActiveState(prAdapter->prGlueInfo);
887 /* CR1640, disable the AP select privacy check */
888 if ( fgIsWpsActive &&
889 (prAdapter->rWifiVar.rConnSettings.eAuthMode < AUTH_MODE_WPA) &&
890 (prAdapter->rWifiVar.rConnSettings.eOPMode == NET_TYPE_INFRA)) {
891 DBGLOG(RSN, TRACE,("-- Skip the Protected BSS check\n"));
896 /* Protection is not required in this BSS. */
897 if ((prBss->u2CapInfo & CAP_INFO_PRIVACY) == 0 ) {
899 if (secEnabledInAis(prAdapter) == FALSE) {
900 DBGLOG(RSN, TRACE,("-- No Protected BSS\n"));
904 DBGLOG(RSN, TRACE,("-- Protected BSS\n"));
909 /* Protection is required in this BSS. */
910 if ((prBss->u2CapInfo & CAP_INFO_PRIVACY) != 0) {
911 if (secEnabledInAis(prAdapter) == FALSE) {
912 DBGLOG(RSN, TRACE,("-- Protected BSS\n"));
917 if (prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA ||
918 prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA_PSK ||
919 prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA_NONE) {
921 if (prBss->fgIEWPA) {
922 prBssRsnInfo = &prBss->rWPAInfo;
925 DBGLOG(RSN, TRACE, ("WPA Information Element does not exist.\n"));
929 else if (prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA2 ||
930 prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA2_PSK) {
932 if (prBss->fgIERSN) {
933 prBssRsnInfo = &prBss->rRSNInfo;
936 DBGLOG(RSN, TRACE, ("RSN Information Element does not exist.\n"));
940 else if (prAdapter->rWifiVar.rConnSettings.eEncStatus != ENUM_ENCRYPTION1_ENABLED) {
941 /* If the driver is configured to use WEP only, ignore this BSS. */
942 DBGLOG(RSN, TRACE, ("-- Not WEP-only legacy BSS\n"));
945 else if (prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION1_ENABLED) {
946 /* If the driver is configured to use WEP only, use this BSS. */
947 DBGLOG(RSN, TRACE, ("-- WEP-only legacy BSS\n"));
951 if(!rsnIsSuitableBSS(prAdapter, prBssRsnInfo))
953 DBGLOG(RSN, TRACE, ("RSN info check no matched\n"));
957 if (prBssRsnInfo->u4PairwiseKeyCipherSuiteCount == 1 &&
958 GET_SELECTOR_TYPE(prBssRsnInfo->au4PairwiseKeyCipherSuite[0]) ==
960 /* Since the pairwise cipher use the same cipher suite as the group
961 cipher in the BSS, we check the group cipher suite against the
962 current encryption status. */
963 fgSuiteSupported = FALSE;
965 switch (prBssRsnInfo->u4GroupKeyCipherSuite) {
966 case WPA_CIPHER_SUITE_CCMP:
967 case RSN_CIPHER_SUITE_CCMP:
968 if (prAdapter->rWifiVar.rConnSettings.eEncStatus ==
969 ENUM_ENCRYPTION3_ENABLED) {
970 fgSuiteSupported = TRUE;
974 case WPA_CIPHER_SUITE_TKIP:
975 case RSN_CIPHER_SUITE_TKIP:
976 if (prAdapter->rWifiVar.rConnSettings.eEncStatus ==
977 ENUM_ENCRYPTION2_ENABLED) {
978 fgSuiteSupported = TRUE;
982 case WPA_CIPHER_SUITE_WEP40:
983 case WPA_CIPHER_SUITE_WEP104:
984 if (prAdapter->rWifiVar.rConnSettings.eEncStatus ==
985 ENUM_ENCRYPTION1_ENABLED) {
986 fgSuiteSupported = TRUE;
991 if (fgSuiteSupported) {
992 u4PairwiseCipher = WPA_CIPHER_SUITE_NONE;
993 u4GroupCipher = prBssRsnInfo->u4GroupKeyCipherSuite;
997 DBGLOG(RSN, TRACE, ("Inproper encryption status %d for group-key-only BSS\n",
998 prAdapter->rWifiVar.rConnSettings.eEncStatus));
1003 fgSuiteSupported = FALSE;
1005 DBGLOG(RSN, TRACE, ("eEncStatus %d %d 0x%x\n", prAdapter->rWifiVar.rConnSettings.eEncStatus,
1006 prBssRsnInfo->u4PairwiseKeyCipherSuiteCount,
1007 prBssRsnInfo->au4PairwiseKeyCipherSuite[0]));
1008 /* Select pairwise/group ciphers */
1009 switch (prAdapter->rWifiVar.rConnSettings.eEncStatus)
1011 case ENUM_ENCRYPTION3_ENABLED:
1012 for (i = 0; i < prBssRsnInfo->u4PairwiseKeyCipherSuiteCount; i++) {
1013 if (GET_SELECTOR_TYPE(prBssRsnInfo->au4PairwiseKeyCipherSuite[i])
1014 == CIPHER_SUITE_CCMP) {
1015 u4PairwiseCipher = prBssRsnInfo->au4PairwiseKeyCipherSuite[i];
1018 u4GroupCipher = prBssRsnInfo->u4GroupKeyCipherSuite;
1021 case ENUM_ENCRYPTION2_ENABLED:
1022 for (i = 0; i < prBssRsnInfo->u4PairwiseKeyCipherSuiteCount; i++) {
1023 if (GET_SELECTOR_TYPE(prBssRsnInfo->au4PairwiseKeyCipherSuite[i])
1024 == CIPHER_SUITE_TKIP) {
1025 u4PairwiseCipher = prBssRsnInfo->au4PairwiseKeyCipherSuite[i];
1028 if (GET_SELECTOR_TYPE(prBssRsnInfo->u4GroupKeyCipherSuite) ==
1029 CIPHER_SUITE_CCMP) {
1030 DBGLOG(RSN, TRACE, ("Cannot join CCMP BSS\n"));
1033 u4GroupCipher = prBssRsnInfo->u4GroupKeyCipherSuite;
1037 case ENUM_ENCRYPTION1_ENABLED:
1038 for (i = 0; i < prBssRsnInfo->u4PairwiseKeyCipherSuiteCount; i++) {
1039 if (GET_SELECTOR_TYPE(prBssRsnInfo->au4PairwiseKeyCipherSuite[i])
1040 == CIPHER_SUITE_WEP40 ||
1041 GET_SELECTOR_TYPE(prBssRsnInfo->au4PairwiseKeyCipherSuite[i])
1042 == CIPHER_SUITE_WEP104) {
1043 u4PairwiseCipher = prBssRsnInfo->au4PairwiseKeyCipherSuite[i];
1046 if (GET_SELECTOR_TYPE(prBssRsnInfo->u4GroupKeyCipherSuite) ==
1047 CIPHER_SUITE_CCMP ||
1048 GET_SELECTOR_TYPE(prBssRsnInfo->u4GroupKeyCipherSuite) ==
1049 CIPHER_SUITE_TKIP) {
1050 DBGLOG(RSN, TRACE, ("Cannot join CCMP/TKIP BSS\n"));
1053 u4GroupCipher = prBssRsnInfo->u4GroupKeyCipherSuite;
1062 /* Exception handler */
1063 /* If we cannot find proper pairwise and group cipher suites to join the
1064 BSS, do not check the supported AKM suites. */
1065 if (u4PairwiseCipher == 0 || u4GroupCipher == 0) {
1066 DBGLOG(RSN, TRACE, ("Failed to select pairwise/group cipher (0x%08lx/0x%08lx)\n",
1067 u4PairwiseCipher, u4GroupCipher));
1071 #if CFG_ENABLE_WIFI_DIRECT
1072 if ((prAdapter->fgIsP2PRegistered) &&
1073 (eNetwotkType == NETWORK_TYPE_P2P_INDEX)) {
1074 if (u4PairwiseCipher != RSN_CIPHER_SUITE_CCMP ||
1075 u4GroupCipher != RSN_CIPHER_SUITE_CCMP ||
1076 u4AkmSuite != RSN_AKM_SUITE_PSK) {
1077 DBGLOG(RSN, TRACE, ("Failed to select pairwise/group cipher for P2P network (0x%08lx/0x%08lx)\n",
1078 u4PairwiseCipher, u4GroupCipher));
1084 #if CFG_ENABLE_BT_OVER_WIFI
1085 if (eNetwotkType == NETWORK_TYPE_BOW_INDEX) {
1086 if (u4PairwiseCipher != RSN_CIPHER_SUITE_CCMP ||
1087 u4GroupCipher != RSN_CIPHER_SUITE_CCMP ||
1088 u4AkmSuite != RSN_AKM_SUITE_PSK) {
1090 DBGLOG(RSN, TRACE, ("Failed to select pairwise/group cipher for BT over Wi-Fi network (0x%08lx/0x%08lx)\n",
1091 u4PairwiseCipher, u4GroupCipher));
1097 /* Verify if selected pairwisse cipher is supported */
1098 fgSuiteSupported = rsnSearchSupportedCipher(prAdapter, u4PairwiseCipher, &i);
1100 /* Verify if selected group cipher is supported */
1101 if (fgSuiteSupported) {
1102 fgSuiteSupported = rsnSearchSupportedCipher(prAdapter, u4GroupCipher, &i);
1105 if (!fgSuiteSupported) {
1106 DBGLOG(RSN, TRACE, ("Failed to support selected pairwise/group cipher (0x%08lx/0x%08lx)\n",
1107 u4PairwiseCipher, u4GroupCipher));
1112 /* If the driver cannot support any authentication suites advertised in
1113 the given BSS, we fail to perform RSNA policy selection. */
1114 /* Attempt to find any overlapping supported AKM suite. */
1115 #if CFG_SUPPORT_802_11W
1117 for (i = (prBssRsnInfo->u4AuthKeyMgtSuiteCount - 1); i >= 0; i--)
1119 for (i = 0; i < prBssRsnInfo->u4AuthKeyMgtSuiteCount; i++)
1122 if (rsnSearchAKMSuite(prAdapter,
1123 prBssRsnInfo->au4AuthKeyMgtSuite[i],
1125 u4AkmSuite = prBssRsnInfo->au4AuthKeyMgtSuite[i];
1130 if (u4AkmSuite == 0) {
1131 DBGLOG(RSN, TRACE, ("Cannot support any AKM suites\n"));
1135 DBGLOG(RSN, TRACE, ("Selected pairwise/group cipher: %02x-%02x-%02x-%02x/%02x-%02x-%02x-%02x\n",
1136 (UINT_8) (u4PairwiseCipher & 0x000000FF),
1137 (UINT_8) ((u4PairwiseCipher >> 8) & 0x000000FF),
1138 (UINT_8) ((u4PairwiseCipher >> 16) & 0x000000FF),
1139 (UINT_8) ((u4PairwiseCipher >> 24) & 0x000000FF),
1140 (UINT_8) (u4GroupCipher & 0x000000FF),
1141 (UINT_8) ((u4GroupCipher >> 8) & 0x000000FF),
1142 (UINT_8) ((u4GroupCipher >> 16) & 0x000000FF),
1143 (UINT_8) ((u4GroupCipher >> 24) & 0x000000FF)));
1145 DBGLOG(RSN, TRACE, ("Selected AKM suite: %02x-%02x-%02x-%02x\n",
1146 (UINT_8) (u4AkmSuite & 0x000000FF),
1147 (UINT_8) ((u4AkmSuite >> 8) & 0x000000FF),
1148 (UINT_8) ((u4AkmSuite >> 16) & 0x000000FF),
1149 (UINT_8) ((u4AkmSuite >> 24) & 0x000000FF)));
1151 #if CFG_SUPPORT_802_11W
1152 DBGLOG(RSN, TRACE, ("MFP setting = %d\n ", kalGetMfpSetting(prAdapter->prGlueInfo)));
1154 if (kalGetMfpSetting(prAdapter->prGlueInfo) == RSN_AUTH_MFP_REQUIRED) {
1155 if (!prBssRsnInfo->fgRsnCapPresent) {
1156 DBGLOG(RSN, TRACE, ("Skip RSN IE, No MFP Required Capability.\n"));
1159 else if (!(prBssRsnInfo->u2RsnCap & ELEM_WPA_CAP_MFPC)) {
1160 DBGLOG(RSN, TRACE, ("Skip RSN IE, No MFP Required\n"));
1163 prAdapter->rWifiVar.rAisSpecificBssInfo.fgMgmtProtection = TRUE;
1165 else if (kalGetMfpSetting(prAdapter->prGlueInfo) == RSN_AUTH_MFP_OPTIONAL) {
1166 if (prBssRsnInfo->u2RsnCap && ((prBssRsnInfo->u2RsnCap & ELEM_WPA_CAP_MFPR) ||
1167 (prBssRsnInfo->u2RsnCap & ELEM_WPA_CAP_MFPC))) {
1168 prAdapter->rWifiVar.rAisSpecificBssInfo.fgMgmtProtection = TRUE;
1171 prAdapter->rWifiVar.rAisSpecificBssInfo.fgMgmtProtection = FALSE;
1175 if (prBssRsnInfo->fgRsnCapPresent && (prBssRsnInfo->u2RsnCap & ELEM_WPA_CAP_MFPR)) {
1176 DBGLOG(RSN, TRACE, ("Skip RSN IE, No MFP Required Capability\n"));
1179 prAdapter->rWifiVar.rAisSpecificBssInfo.fgMgmtProtection = FALSE;
1181 DBGLOG(RSN, TRACE, ("fgMgmtProtection = %d\n ", prAdapter->rWifiVar.rAisSpecificBssInfo.fgMgmtProtection));
1184 if (GET_SELECTOR_TYPE(u4GroupCipher) == CIPHER_SUITE_CCMP){
1185 prBss->ucEncLevel = 3;
1187 else if (GET_SELECTOR_TYPE(u4GroupCipher) == CIPHER_SUITE_TKIP){
1188 prBss->ucEncLevel = 2;
1190 else if (GET_SELECTOR_TYPE(u4GroupCipher) == CIPHER_SUITE_WEP40 ||
1191 GET_SELECTOR_TYPE(u4GroupCipher) == CIPHER_SUITE_WEP104) {
1192 prBss->ucEncLevel = 1;
1197 prBss->u4RsnSelectedPairwiseCipher = u4PairwiseCipher;
1198 prBss->u4RsnSelectedGroupCipher = u4GroupCipher;
1199 prBss->u4RsnSelectedAKMSuite = u4AkmSuite;
1203 } /* rsnPerformPolicySelection */
1206 /*----------------------------------------------------------------------------*/
1208 * \brief This routine is called to generate WPA IE for beacon frame.
1210 * \param[in] pucIeStartAddr Pointer to put the generated WPA IE.
1212 * \return The append WPA-None IE length
1214 * Called by: JOIN module, compose beacon IE
1216 /*----------------------------------------------------------------------------*/
1218 rsnGenerateWpaNoneIE (
1219 IN P_ADAPTER_T prAdapter,
1220 IN P_MSDU_INFO_T prMsduInfo
1224 P_WPA_INFO_ELEM_T prWpaIE;
1226 UINT_16 u2SuiteCount;
1228 UINT_8 ucExpendedLen = 0;
1230 ENUM_NETWORK_TYPE_INDEX_T eNetworkId;
1232 DEBUGFUNC("rsnGenerateWpaNoneIE");
1236 if (prAdapter->rWifiVar.rConnSettings.eAuthMode != AUTH_MODE_WPA_NONE) {
1240 eNetworkId = (ENUM_NETWORK_TYPE_INDEX_T)prMsduInfo->ucNetworkType;
1242 if (eNetworkId != NETWORK_TYPE_AIS_INDEX)
1245 pucBuffer = (PUINT_8)((UINT_32)prMsduInfo->prPacket +
1246 (UINT_32)prMsduInfo->u2FrameLength);
1250 prWpaIE = (P_WPA_INFO_ELEM_T)(pucBuffer);
1252 /* Start to construct a WPA IE. */
1253 /* Fill the Element ID field. */
1254 prWpaIE->ucElemId = ELEM_ID_WPA;
1256 /* Fill the OUI and OUI Type fields. */
1257 prWpaIE->aucOui[0] = 0x00;
1258 prWpaIE->aucOui[1] = 0x50;
1259 prWpaIE->aucOui[2] = 0xF2;
1260 prWpaIE->ucOuiType = VENDOR_OUI_TYPE_WPA;
1262 /* Fill the Version field. */
1263 WLAN_SET_FIELD_16(&prWpaIE->u2Version, 1); /* version 1 */
1266 /* Fill the Pairwise Key Cipher Suite List field. */
1268 cp = (PUINT_8)&prWpaIE->aucPairwiseKeyCipherSuite1[0];
1270 if (rsnSearchSupportedCipher(prAdapter, WPA_CIPHER_SUITE_CCMP, &i)) {
1271 u4Suite = WPA_CIPHER_SUITE_CCMP;
1273 else if (rsnSearchSupportedCipher(prAdapter, WPA_CIPHER_SUITE_TKIP, &i)) {
1274 u4Suite = WPA_CIPHER_SUITE_TKIP;
1276 else if (rsnSearchSupportedCipher(prAdapter, WPA_CIPHER_SUITE_WEP104, &i)) {
1277 u4Suite = WPA_CIPHER_SUITE_WEP104;
1279 else if (rsnSearchSupportedCipher(prAdapter, WPA_CIPHER_SUITE_WEP40, &i)) {
1280 u4Suite = WPA_CIPHER_SUITE_WEP40;
1283 u4Suite = WPA_CIPHER_SUITE_TKIP;
1286 WLAN_SET_FIELD_32(cp, u4Suite);
1291 /* Fill the Group Key Cipher Suite field as the same in pair-wise key. */
1292 WLAN_SET_FIELD_32(&prWpaIE->u4GroupKeyCipherSuite, u4Suite);
1295 /* Fill the Pairwise Key Cipher Suite Count field. */
1296 WLAN_SET_FIELD_16(&prWpaIE->u2PairwiseKeyCipherSuiteCount, u2SuiteCount);
1301 /* Fill the Authentication and Key Management Suite List field. */
1305 if (rsnSearchAKMSuite(prAdapter, WPA_AKM_SUITE_802_1X, &i)) {
1306 u4Suite = WPA_AKM_SUITE_802_1X;
1308 else if (rsnSearchAKMSuite(prAdapter, WPA_AKM_SUITE_PSK, &i)) {
1309 u4Suite = WPA_AKM_SUITE_PSK;
1312 u4Suite = WPA_AKM_SUITE_NONE;
1315 /* This shall be the only avaiable value for current implementation */
1316 ASSERT(u4Suite == WPA_AKM_SUITE_NONE);
1318 WLAN_SET_FIELD_32(cp, u4Suite);
1323 /* Fill the Authentication and Key Management Suite Count field. */
1324 WLAN_SET_FIELD_16(cp2, u2SuiteCount);
1327 /* Fill the Length field. */
1328 prWpaIE->ucLength = (UINT_8)ucExpendedLen;
1330 /* Increment the total IE length for the Element ID and Length fields. */
1331 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1333 } /* rsnGenerateWpaNoneIE */
1336 /*----------------------------------------------------------------------------*/
1339 * \brief This routine is called to generate WPA IE for
1340 * associate request frame.
1342 * \param[in] prCurrentBss The Selected BSS description
1344 * \retval The append WPA IE length
1347 * Called by: AIS module, Associate request
1349 /*----------------------------------------------------------------------------*/
1352 IN P_ADAPTER_T prAdapter,
1353 IN P_MSDU_INFO_T prMsduInfo
1358 ENUM_NETWORK_TYPE_INDEX_T eNetworkId;
1360 DEBUGFUNC("rsnGenerateWPAIE");
1364 pucBuffer = (PUINT_8)((UINT_32)prMsduInfo->prPacket +
1365 (UINT_32)prMsduInfo->u2FrameLength);
1369 eNetworkId = (ENUM_NETWORK_TYPE_INDEX_T)prMsduInfo->ucNetworkType;
1371 //if (eNetworkId != NETWORK_TYPE_AIS_INDEX)
1374 #if CFG_ENABLE_WIFI_DIRECT
1375 if ((1 /* prCurrentBss->fgIEWPA */ &&
1376 ((prAdapter->fgIsP2PRegistered) &&
1377 (eNetworkId == NETWORK_TYPE_P2P_INDEX) &&
1378 (kalP2PGetTkipCipher(prAdapter->prGlueInfo)))) ||
1379 ((prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA) ||
1380 (prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA_PSK)))
1382 if ((1 /* prCurrentBss->fgIEWPA */ &&
1383 ((prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA) ||
1384 (prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA_PSK))))
1387 /* Construct a WPA IE for association request frame. */
1388 WPA_IE(pucBuffer)->ucElemId = ELEM_ID_WPA;
1389 WPA_IE(pucBuffer)->ucLength = ELEM_ID_WPA_LEN_FIXED;
1390 WPA_IE(pucBuffer)->aucOui[0] = 0x00;
1391 WPA_IE(pucBuffer)->aucOui[1] = 0x50;
1392 WPA_IE(pucBuffer)->aucOui[2] = 0xF2;
1393 WPA_IE(pucBuffer)->ucOuiType = VENDOR_OUI_TYPE_WPA;
1394 WLAN_SET_FIELD_16(&WPA_IE(pucBuffer)->u2Version, 1);
1396 #if CFG_ENABLE_WIFI_DIRECT
1397 if (prAdapter->fgIsP2PRegistered && eNetworkId == NETWORK_TYPE_P2P_INDEX)
1399 WLAN_SET_FIELD_32(&WPA_IE(pucBuffer)->u4GroupKeyCipherSuite, WPA_CIPHER_SUITE_TKIP);
1403 WLAN_SET_FIELD_32(&WPA_IE(pucBuffer)->u4GroupKeyCipherSuite,
1404 prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].u4RsnSelectedGroupCipher);
1406 cp = (PUCHAR) &WPA_IE(pucBuffer)->aucPairwiseKeyCipherSuite1[0];
1408 WLAN_SET_FIELD_16(&WPA_IE(pucBuffer)->u2PairwiseKeyCipherSuiteCount, 1);
1409 #if CFG_ENABLE_WIFI_DIRECT
1410 if (prAdapter->fgIsP2PRegistered && eNetworkId == NETWORK_TYPE_P2P_INDEX)
1412 WLAN_SET_FIELD_32(cp, WPA_CIPHER_SUITE_TKIP);
1416 WLAN_SET_FIELD_32(cp, prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].u4RsnSelectedPairwiseCipher);
1419 WLAN_SET_FIELD_16(cp, 1);
1421 #if CFG_ENABLE_WIFI_DIRECT
1422 if (prAdapter->fgIsP2PRegistered && eNetworkId == NETWORK_TYPE_P2P_INDEX)
1424 WLAN_SET_FIELD_32(cp, WPA_AKM_SUITE_PSK);
1428 WLAN_SET_FIELD_32(cp, prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].u4RsnSelectedAKMSuite);
1431 WPA_IE(pucBuffer)->ucLength = ELEM_ID_WPA_LEN_FIXED;
1433 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1436 } /* rsnGenerateWPAIE */
1439 /*----------------------------------------------------------------------------*/
1442 * \brief This routine is called to generate RSN IE for
1443 * associate request frame.
1445 * \param[in] prMsduInfo The Selected BSS description
1447 * \retval The append RSN IE length
1450 * Called by: AIS module, P2P module, BOW module Associate request
1452 /*----------------------------------------------------------------------------*/
1455 IN P_ADAPTER_T prAdapter,
1456 IN P_MSDU_INFO_T prMsduInfo
1461 //UINT_8 ucExpendedLen = 0;
1463 ENUM_NETWORK_TYPE_INDEX_T eNetworkId;
1464 P_STA_RECORD_T prStaRec;
1466 DEBUGFUNC("rsnGenerateRSNIE");
1470 pucBuffer = (PUINT_8)((UINT_32)prMsduInfo->prPacket +
1471 (UINT_32)prMsduInfo->u2FrameLength);
1475 /* Todo:: network id */
1476 eNetworkId = (ENUM_NETWORK_TYPE_INDEX_T)prMsduInfo->ucNetworkType;
1479 #if CFG_ENABLE_WIFI_DIRECT
1480 ((prAdapter->fgIsP2PRegistered) &&
1481 (eNetworkId == NETWORK_TYPE_P2P_INDEX) &&
1482 (kalP2PGetCcmpCipher(prAdapter->prGlueInfo))) ||
1484 #if CFG_ENABLE_BT_OVER_WIFI
1485 (eNetworkId == NETWORK_TYPE_BOW_INDEX) ||
1487 (eNetworkId == NETWORK_TYPE_AIS_INDEX /* prCurrentBss->fgIERSN */ &&
1488 ((prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA2) ||
1489 (prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA2_PSK))))
1491 /* Construct a RSN IE for association request frame. */
1492 RSN_IE(pucBuffer)->ucElemId = ELEM_ID_RSN;
1493 RSN_IE(pucBuffer)->ucLength = ELEM_ID_RSN_LEN_FIXED;
1494 WLAN_SET_FIELD_16(&RSN_IE(pucBuffer)->u2Version, 1); // Version
1495 WLAN_SET_FIELD_32(&RSN_IE(pucBuffer)->u4GroupKeyCipherSuite,
1496 prAdapter->rWifiVar.arBssInfo[eNetworkId].u4RsnSelectedGroupCipher); // Group key suite
1497 cp = (PUCHAR) &RSN_IE(pucBuffer)->aucPairwiseKeyCipherSuite1[0];
1498 WLAN_SET_FIELD_16(&RSN_IE(pucBuffer)->u2PairwiseKeyCipherSuiteCount, 1);
1499 WLAN_SET_FIELD_32(cp, prAdapter->rWifiVar.arBssInfo[eNetworkId].u4RsnSelectedPairwiseCipher);
1501 WLAN_SET_FIELD_16(cp, 1); // AKM suite count
1503 WLAN_SET_FIELD_32(cp, prAdapter->rWifiVar.arBssInfo[eNetworkId].u4RsnSelectedAKMSuite); // AKM suite
1505 WLAN_SET_FIELD_16(cp, prAdapter->rWifiVar.arBssInfo[eNetworkId].u2RsnSelectedCapInfo); // Capabilities
1506 #if CFG_SUPPORT_802_11W
1507 if (eNetworkId == NETWORK_TYPE_AIS_INDEX && prAdapter->rWifiVar.rAisSpecificBssInfo.fgMgmtProtection) {
1508 if (kalGetMfpSetting(prAdapter->prGlueInfo) == RSN_AUTH_MFP_REQUIRED) {
1509 WLAN_SET_FIELD_16(cp, ELEM_WPA_CAP_MFPC | ELEM_WPA_CAP_MFPR); // Capabilities
1511 else if (kalGetMfpSetting(prAdapter->prGlueInfo) == RSN_AUTH_MFP_OPTIONAL) {
1512 WLAN_SET_FIELD_16(cp, ELEM_WPA_CAP_MFPC); // Capabilities
1518 if (eNetworkId == NETWORK_TYPE_AIS_INDEX)
1519 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
1521 if (eNetworkId == NETWORK_TYPE_AIS_INDEX &&
1522 rsnSearchPmkidEntry(prAdapter, prStaRec->aucMacAddr, &u4Entry)) {
1523 //DBGLOG(RSN, TRACE, ("Add Pmk at assoc req\n"));
1524 //DBGLOG(RSN, TRACE, ("addr " MACSTR" PMKID "MACSTR"\n",
1525 // MAC2STR(prAdapter->rWifiVar.rAisSpecificBssInfo.arPmkidCache[u4Entry].rBssidInfo.arBSSID), MAC2STR(prAdapter->rWifiVar.rAisSpecificBssInfo.arPmkidCache[u4Entry].rBssidInfo.arPMKID)));
1526 if (prAdapter->rWifiVar.rAisSpecificBssInfo.arPmkidCache[u4Entry].fgPmkidExist) {
1527 RSN_IE(pucBuffer)->ucLength = 38;
1528 WLAN_SET_FIELD_16(cp, 1); // PMKID count
1530 DBGLOG(RSN, TRACE, ("BSSID "MACSTR" ind=%d\n", MAC2STR(prStaRec->aucMacAddr), u4Entry));
1531 DBGLOG(RSN, TRACE, ("use PMKID "MACSTR"\n", MAC2STR(prAdapter->rWifiVar.rAisSpecificBssInfo.arPmkidCache[u4Entry].rBssidInfo.arPMKID)));
1532 kalMemCopy(cp, (PVOID)prAdapter->rWifiVar.rAisSpecificBssInfo.arPmkidCache[u4Entry].rBssidInfo.arPMKID,
1533 sizeof(PARAM_PMKID_VALUE));
1534 //ucExpendedLen = 40;
1537 WLAN_SET_FIELD_16(cp, 0); // PMKID count
1538 //ucExpendedLen = ELEM_ID_RSN_LEN_FIXED + 2;
1539 #if CFG_SUPPORT_802_11W
1541 RSN_IE(pucBuffer)->ucLength += 2;
1546 WLAN_SET_FIELD_16(cp, 0); // PMKID count
1547 //ucExpendedLen = ELEM_ID_RSN_LEN_FIXED + 2;
1548 #if CFG_SUPPORT_802_11W
1550 RSN_IE(pucBuffer)->ucLength += 2;
1554 #if CFG_SUPPORT_802_11W
1555 if ((eNetworkId == NETWORK_TYPE_AIS_INDEX) && (kalGetMfpSetting(prAdapter->prGlueInfo) != RSN_AUTH_MFP_DISABLED) /* (mgmt_group_cipher == WPA_CIPHER_AES_128_CMAC) */ ) {
1556 WLAN_SET_FIELD_32(cp, RSN_CIPHER_SUITE_AES_128_CMAC);
1558 RSN_IE(pucBuffer)->ucLength += 4;
1561 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1564 } /* rsnGenerateRSNIE */
1566 /*----------------------------------------------------------------------------*/
1568 * \brief Parse the given IE buffer and check if it is WFA IE and return Type and
1569 * SubType for further process.
1571 * \param[in] pucBuf Pointer to the buffer of WFA Information Element.
1572 * \param[out] pucOuiType Pointer to the storage of OUI Type.
1573 * \param[out] pu2SubTypeVersion Pointer to the storage of OUI SubType and Version.
1575 * \retval TRUE Parse IE ok
1576 * \retval FALSE Parse IE fail
1578 /*----------------------------------------------------------------------------*/
1580 rsnParseCheckForWFAInfoElem (
1581 IN P_ADAPTER_T prAdapter,
1583 OUT PUINT_8 pucOuiType,
1584 OUT PUINT_16 pu2SubTypeVersion
1587 UINT_8 aucWfaOui[] = VENDOR_OUI_WFA;
1592 ASSERT(pu2SubTypeVersion);
1593 prWfaIE = (P_IE_WFA_T)pucBuf;
1596 if (IE_LEN(pucBuf) <= ELEM_MIN_LEN_WFA_OUI_TYPE_SUBTYPE) {
1599 else if (prWfaIE->aucOui[0] != aucWfaOui[0] ||
1600 prWfaIE->aucOui[1] != aucWfaOui[1] ||
1601 prWfaIE->aucOui[2] != aucWfaOui[2]) {
1605 *pucOuiType = prWfaIE->ucOuiType;
1606 WLAN_GET_FIELD_16(&prWfaIE->aucOuiSubTypeVersion[0], pu2SubTypeVersion);
1614 } /* end of rsnParseCheckForWFAInfoElem() */
1617 /*----------------------------------------------------------------------------*/
1619 * \brief Parse the given IE buffer and check if it is RSN IE with CCMP PSK
1621 * \param[in] prAdapter Pointer to Adapter
1622 * \param[in] prSwRfb Pointer to the rx buffer
1623 * \param[in] pIE Pointer rthe buffer of Information Element.
1624 * \param[out] prStatusCode Pointer to the return status code.
1628 /*----------------------------------------------------------------------------*/
1630 rsnParserCheckForRSNCCMPPSK(
1631 P_ADAPTER_T prAdapter,
1632 P_RSN_INFO_ELEM_T prIe,
1633 PUINT_16 pu2StatusCode
1641 ASSERT(pu2StatusCode);
1643 *pu2StatusCode = STATUS_CODE_INVALID_INFO_ELEMENT;
1645 if (rsnParseRsnIE(prAdapter, prIe, &rRsnIe)) {
1646 if ((rRsnIe.u4PairwiseKeyCipherSuiteCount != 1) || (rRsnIe.au4PairwiseKeyCipherSuite[0] != RSN_CIPHER_SUITE_CCMP)) {
1647 *pu2StatusCode = STATUS_CODE_INVALID_PAIRWISE_CIPHER;
1650 if ((rRsnIe.u4GroupKeyCipherSuite != RSN_CIPHER_SUITE_CCMP)) {
1651 *pu2StatusCode = STATUS_CODE_INVALID_GROUP_CIPHER;
1654 if ((rRsnIe.u4AuthKeyMgtSuiteCount != 1) || (rRsnIe.au4AuthKeyMgtSuite[0] != RSN_AKM_SUITE_PSK)) {
1655 *pu2StatusCode = STATUS_CODE_INVALID_AKMP;
1659 DBGLOG(RSN, TRACE, ("RSN with CCMP-PSK\n" ));
1660 *pu2StatusCode = WLAN_STATUS_SUCCESS;
1666 /*----------------------------------------------------------------------------*/
1668 * \brief This routine is called to generate an authentication event to NDIS.
1670 * \param[in] u4Flags Authentication event: \n
1671 * PARAM_AUTH_REQUEST_REAUTH 0x01 \n
1672 * PARAM_AUTH_REQUEST_KEYUPDATE 0x02 \n
1673 * PARAM_AUTH_REQUEST_PAIRWISE_ERROR 0x06 \n
1674 * PARAM_AUTH_REQUEST_GROUP_ERROR 0x0E \n
1678 /*----------------------------------------------------------------------------*/
1680 rsnGenMicErrorEvent (
1681 IN P_ADAPTER_T prAdapter,
1685 P_PARAM_AUTH_EVENT_T prAuthEvent;
1687 DEBUGFUNC("rsnGenMicErrorEvent");
1689 prAuthEvent = (P_PARAM_AUTH_EVENT_T)prAdapter->aucIndicationEventBuffer;
1691 /* Status type: Authentication Event */
1692 prAuthEvent->rStatus.eStatusType = ENUM_STATUS_TYPE_AUTHENTICATION;
1694 /* Authentication request */
1695 prAuthEvent->arRequest[0].u4Length = sizeof(PARAM_AUTH_REQUEST_T);
1696 kalMemCopy((PVOID)prAuthEvent->arRequest[0].arBssid, (PVOID)prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].aucBSSID, MAC_ADDR_LEN);
1698 if (fgFlags == TRUE)
1699 prAuthEvent->arRequest[0].u4Flags = PARAM_AUTH_REQUEST_GROUP_ERROR;
1701 prAuthEvent->arRequest[0].u4Flags = PARAM_AUTH_REQUEST_PAIRWISE_ERROR;
1703 kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
1704 WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
1706 sizeof(PARAM_STATUS_INDICATION_T) + sizeof(PARAM_AUTH_REQUEST_T));
1708 } /* rsnGenMicErrorEvent */
1711 /*----------------------------------------------------------------------------*/
1713 * \brief This routine is called to handle TKIP MIC failures.
1715 * \param[in] adapter_p Pointer to the adapter object data area.
1716 * \param[in] prSta Pointer to the STA which occur MIC Error
1717 * \param[in] fgErrorKeyType type of error key
1721 /*----------------------------------------------------------------------------*/
1723 rsnTkipHandleMICFailure (
1724 IN P_ADAPTER_T prAdapter,
1725 IN P_STA_RECORD_T prSta,
1726 IN BOOLEAN fgErrorKeyType
1729 //UINT_32 u4RsnaCurrentMICFailTime;
1730 //P_AIS_SPECIFIC_BSS_INFO_T prAisSpecBssInfo;
1732 DEBUGFUNC("rsnTkipHandleMICFailure");
1736 rsnGenMicErrorEvent(prAdapter,/* prSta,*/ fgErrorKeyType);
1738 /* Generate authentication request event. */
1739 DBGLOG(RSN, INFO, ("Generate TKIP MIC error event (type: 0%d)\n",
1744 prAisSpecBssInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
1746 /* Record the MIC error occur time. */
1747 GET_CURRENT_SYSTIME(&u4RsnaCurrentMICFailTime);
1749 /* Generate authentication request event. */
1750 DBGLOG(RSN, INFO, ("Generate TKIP MIC error event (type: 0%d)\n",
1753 /* If less than 60 seconds have passed since a previous TKIP MIC failure,
1754 disassociate from the AP and wait for 60 seconds before (re)associating
1755 with the same AP. */
1756 if (prAisSpecBssInfo->u4RsnaLastMICFailTime != 0 &&
1757 !CHECK_FOR_TIMEOUT(u4RsnaCurrentMICFailTime,
1758 prAisSpecBssInfo->u4RsnaLastMICFailTime,
1759 SEC_TO_SYSTIME(TKIP_COUNTERMEASURE_SEC))) {
1760 /* If less than 60 seconds expired since last MIC error, we have to
1763 DBGLOG(RSN, INFO, ("Start blocking traffic!\n"));
1764 rsnGenMicErrorEvent( prAdapter,/* prSta,*/ fgErrorKeyType);
1766 secFsmEventStartCounterMeasure(prAdapter, prSta);
1769 rsnGenMicErrorEvent( prAdapter,/* prSta,*/ fgErrorKeyType);
1770 DBGLOG(RSN, INFO, ("First TKIP MIC error!\n"));
1773 COPY_SYSTIME(prAisSpecBssInfo->u4RsnaLastMICFailTime, u4RsnaCurrentMICFailTime);
1775 } /* rsnTkipHandleMICFailure */
1778 /*----------------------------------------------------------------------------*/
1780 * \brief This function is called to select a list of BSSID from
1781 * the scan results for PMKID candidate list.
1783 * \param[in] prBssDesc the BSS Desc at scan result list
1784 * \param[out] pu4CandidateCount Pointer to the number of selected candidates.
1785 * It is set to zero if no BSSID matches our requirement.
1789 /*----------------------------------------------------------------------------*/
1791 rsnSelectPmkidCandidateList (
1792 IN P_ADAPTER_T prAdapter,
1793 IN P_BSS_DESC_T prBssDesc
1796 P_CONNECTION_SETTINGS_T prConnSettings;
1797 P_AIS_BSS_INFO_T prAisBssInfo;
1799 DEBUGFUNC("rsnSelectPmkidCandidateList");
1803 prConnSettings = &prAdapter->rWifiVar.rConnSettings;
1804 prAisBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
1806 /* Search a BSS with the same SSID from the given BSS description set. */
1807 //DBGLOG(RSN, TRACE, ("Check scan result ["MACSTR"]\n",
1808 // MAC2STR(prBssDesc->aucBSSID)));
1810 if (UNEQUAL_SSID(prBssDesc->aucSSID, prBssDesc->ucSSIDLen,
1811 prConnSettings->aucSSID, prConnSettings->ucSSIDLen)) {
1812 DBGLOG(RSN, TRACE, ("-- SSID not matched\n"));
1817 if ((prBssDesc->u2BSSBasicRateSet &
1818 ~(rPhyAttributes[prAisBssInfo->ePhyType].u2SupportedRateSet)) ||
1819 prBssDesc->fgIsUnknownBssBasicRate) {
1820 DBGLOG(RSN, TRACE, ("-- Rate set not matched\n"));
1824 if (/* prBssDesc->u4RsnSelectedPairwiseCipher != prAisBssInfo->u4RsnSelectedPairwiseCipher ||*/
1825 prBssDesc->u4RsnSelectedGroupCipher != prAisBssInfo->u4RsnSelectedGroupCipher /*||
1826 prBssDesc->u4RsnSelectedAKMSuite != prAisBssInfo->u4RsnSelectedAKMSuite */) {
1827 DBGLOG(RSN, TRACE, ("-- Encrypt status not matched for PMKID \n"));
1832 rsnUpdatePmkidCandidateList(prAdapter, prBssDesc);
1834 } /* rsnSelectPmkidCandidateList */
1837 /*----------------------------------------------------------------------------*/
1839 * \brief This function is called to select a list of BSSID from
1840 * the scan results for PMKID candidate list.
1842 * \param[in] prBssDesc the BSS DESC at scan result list
1846 /*----------------------------------------------------------------------------*/
1848 rsnUpdatePmkidCandidateList (
1849 IN P_ADAPTER_T prAdapter,
1850 IN P_BSS_DESC_T prBssDesc
1854 P_CONNECTION_SETTINGS_T prConnSettings;
1855 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecBssInfo;
1857 DEBUGFUNC("rsnUpdatePmkidCandidateList");
1861 prConnSettings = &prAdapter->rWifiVar.rConnSettings;
1862 prAisSpecBssInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
1864 if (UNEQUAL_SSID(prBssDesc->aucSSID, prBssDesc->ucSSIDLen,
1865 prConnSettings->aucSSID, prConnSettings->ucSSIDLen)) {
1866 DBGLOG(RSN, TRACE, ("-- SSID not matched\n"));
1870 for (i = 0; i < CFG_MAX_PMKID_CACHE; i++) {
1871 if (EQUAL_MAC_ADDR(prBssDesc->aucBSSID, prAisSpecBssInfo->arPmkidCandicate[i].aucBssid))
1875 /* If the number of selected BSSID exceed MAX_NUM_PMKID_CACHE(16),
1876 then we only store MAX_NUM_PMKID_CACHE(16) in PMKID cache */
1877 if ((prAisSpecBssInfo->u4PmkidCandicateCount + 1) > CFG_MAX_PMKID_CACHE) {
1878 prAisSpecBssInfo->u4PmkidCandicateCount --;
1881 i = prAisSpecBssInfo->u4PmkidCandicateCount;
1883 COPY_MAC_ADDR((PVOID)prAisSpecBssInfo->arPmkidCandicate[i].aucBssid,
1884 (PVOID)prBssDesc->aucBSSID);
1886 if (prBssDesc->u2RsnCap & MASK_RSNIE_CAP_PREAUTH) {
1887 prAisSpecBssInfo->arPmkidCandicate[i].u4PreAuthFlags = 1;
1888 DBGLOG(RSN, TRACE, ("Add " MACSTR " with pre-auth to candidate list\n",
1889 MAC2STR(prAisSpecBssInfo->arPmkidCandicate[i].aucBssid)));
1892 prAisSpecBssInfo->arPmkidCandicate[i].u4PreAuthFlags = 0;
1893 DBGLOG(RSN, TRACE, ("Add " MACSTR " without pre-auth to candidate list\n",
1894 MAC2STR(prAisSpecBssInfo->arPmkidCandicate[i].aucBssid)));
1897 prAisSpecBssInfo->u4PmkidCandicateCount ++;
1899 } /* rsnUpdatePmkidCandidateList */
1902 /*----------------------------------------------------------------------------*/
1904 * \brief This routine is called to search the desired entry in
1905 * PMKID cache according to the BSSID
1907 * \param[in] pucBssid Pointer to the BSSID
1908 * \param[out] pu4EntryIndex Pointer to place the found entry index
1910 * \retval TRUE, if found one entry for specified BSSID
1911 * \retval FALSE, if not found
1913 /*----------------------------------------------------------------------------*/
1915 rsnSearchPmkidEntry (
1916 IN P_ADAPTER_T prAdapter,
1917 IN PUINT_8 pucBssid,
1918 OUT PUINT_32 pu4EntryIndex
1922 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecBssInfo;
1924 DEBUGFUNC("rsnSearchPmkidEntry");
1927 ASSERT(pu4EntryIndex);
1929 prAisSpecBssInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
1931 if (prAisSpecBssInfo->u4PmkidCacheCount > CFG_MAX_PMKID_CACHE) {
1935 ASSERT(prAisSpecBssInfo->u4PmkidCacheCount <= CFG_MAX_PMKID_CACHE);
1937 /* Search for desired BSSID */
1938 for (i = 0; i < prAisSpecBssInfo->u4PmkidCacheCount; i++) {
1939 if (!kalMemCmp(prAisSpecBssInfo->arPmkidCache[i].rBssidInfo.arBSSID, pucBssid,
1945 /* If desired BSSID is found, then set the PMKID */
1946 if (i < prAisSpecBssInfo->u4PmkidCacheCount) {
1953 } /* rsnSearchPmkidEntry */
1956 /*----------------------------------------------------------------------------*/
1958 * \brief This routine is called to check if there is difference
1959 * between PMKID candicate list and PMKID cache. If there
1960 * is new candicate that no cache entry is available, then
1961 * add a new entry for the new candicate in the PMKID cache
1962 * and set the PMKID indication flag to TRUE.
1964 * \retval TRUE, if new member in the PMKID candicate list
1965 * \retval FALSe, if no new member in the PMKID candicate list
1967 /*----------------------------------------------------------------------------*/
1969 rsnCheckPmkidCandicate (
1970 IN P_ADAPTER_T prAdapter
1973 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecBssInfo;
1974 UINT_32 i; // Index for PMKID candicate
1975 UINT_32 j; // Indix for PMKID cache
1976 BOOLEAN status = FALSE;
1978 DEBUGFUNC("rsnCheckPmkidCandicate");
1980 prAisSpecBssInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
1982 /* Check for each candicate */
1983 for (i = 0; i < prAisSpecBssInfo->u4PmkidCandicateCount; i++) {
1984 for (j = 0; j < prAisSpecBssInfo->u4PmkidCacheCount; j++) {
1985 if (!kalMemCmp(prAisSpecBssInfo->arPmkidCache[j].rBssidInfo.arBSSID,
1986 prAisSpecBssInfo->arPmkidCandicate[i].aucBssid,
1988 //DBGLOG(RSN, TRACE, (MACSTR" at PMKID cache!!\n", MAC2STR(prAisSpecBssInfo->arPmkidCandicate[i].aucBssid)));
1993 /* No entry found in PMKID cache for the candicate, add new one */
1994 if (j == prAisSpecBssInfo->u4PmkidCacheCount && prAisSpecBssInfo->u4PmkidCacheCount < CFG_MAX_PMKID_CACHE) {
1995 DBGLOG(RSN, TRACE, ("Add "MACSTR" to PMKID cache!!\n", MAC2STR(prAisSpecBssInfo->arPmkidCandicate[i].aucBssid)));
1996 kalMemCopy((PVOID)prAisSpecBssInfo->arPmkidCache[prAisSpecBssInfo->u4PmkidCacheCount].rBssidInfo.arBSSID,
1997 (PVOID)prAisSpecBssInfo->arPmkidCandicate[i].aucBssid,
1999 prAisSpecBssInfo->arPmkidCache[prAisSpecBssInfo->u4PmkidCacheCount].fgPmkidExist = FALSE;
2000 prAisSpecBssInfo->u4PmkidCacheCount++;
2007 } /* rsnCheckPmkidCandicate */
2010 /*----------------------------------------------------------------------------*/
2012 * \brief This function is called to wait a duration to indicate the pre-auth AP candicate
2016 /*----------------------------------------------------------------------------*/
2018 rsnIndicatePmkidCand (
2019 IN P_ADAPTER_T prAdapter,
2023 DBGLOG(RSN, EVENT, ("Security - Time to indicate the PMKID cand.\n"));
2025 /* If the authentication mode is WPA2 and indication PMKID flag
2026 is available, then we indicate the PMKID candidate list to NDIS and
2027 clear the flag, indicatePMKID */
2029 if (prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX].eConnectionState == PARAM_MEDIA_STATE_CONNECTED &&
2030 prAdapter->rWifiVar.rConnSettings.eAuthMode == AUTH_MODE_WPA2) {
2031 rsnGeneratePmkidIndication(prAdapter);
2035 } /* end of rsnIndicatePmkidCand() */
2038 /*----------------------------------------------------------------------------*/
2040 * \brief This routine is called to check the BSS Desc at scan result
2041 * with pre-auth cap at wpa2 mode. If there
2042 * is candicate that no cache entry is available, then
2043 * add a new entry for the new candicate in the PMKID cache
2044 * and set the PMKID indication flag to TRUE.
2046 * \param[in] prBss The BSS Desc at scan result
2050 /*----------------------------------------------------------------------------*/
2052 rsnCheckPmkidCache (
2053 IN P_ADAPTER_T prAdapter,
2054 IN P_BSS_DESC_T prBss
2057 P_AIS_BSS_INFO_T prAisBssInfo;
2058 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecBssInfo;
2059 P_CONNECTION_SETTINGS_T prConnSettings;
2061 DEBUGFUNC("rsnCheckPmkidCandicate");
2065 prConnSettings = &prAdapter->rWifiVar.rConnSettings;
2066 prAisBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
2067 prAisSpecBssInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
2069 if ((prAisBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) &&
2070 (prConnSettings->eAuthMode == AUTH_MODE_WPA2)) {
2071 rsnSelectPmkidCandidateList(prAdapter, prBss);
2073 /* Set indication flag of PMKID to TRUE, and then connHandleNetworkConnection()
2074 will indicate this later */
2075 if (rsnCheckPmkidCandicate(prAdapter)) {
2076 DBGLOG(RSN, TRACE, ("Prepare a timer to indicate candidate PMKID Candidate\n"));
2077 cnmTimerStopTimer(prAdapter, &prAisSpecBssInfo->rPreauthenticationTimer);
2078 cnmTimerStartTimer(prAdapter, &prAisSpecBssInfo->rPreauthenticationTimer,
2079 SEC_TO_MSEC(WAIT_TIME_IND_PMKID_CANDICATE_SEC));
2085 /*----------------------------------------------------------------------------*/
2087 * \brief This routine is called to generate an PMKID candidate list
2088 * indication to NDIS.
2090 * \param[in] prAdapter Pointer to the adapter object data area.
2091 * \param[in] u4Flags PMKID candidate list event:
2092 * PARAM_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
2096 /*----------------------------------------------------------------------------*/
2098 rsnGeneratePmkidIndication (
2099 IN P_ADAPTER_T prAdapter
2102 P_PARAM_STATUS_INDICATION_T prStatusEvent;
2103 P_PARAM_PMKID_CANDIDATE_LIST_T prPmkidEvent;
2104 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecificBssInfo;
2105 UINT_8 i, j = 0, count = 0;
2106 UINT_32 u4LenOfUsedBuffer;
2108 DEBUGFUNC("rsnGeneratePmkidIndication");
2113 (P_PARAM_STATUS_INDICATION_T)prAdapter->aucIndicationEventBuffer;
2115 /* Status type: PMKID Candidatelist Event */
2116 prStatusEvent->eStatusType = ENUM_STATUS_TYPE_CANDIDATE_LIST;
2117 ASSERT(prStatusEvent);
2119 prPmkidEvent = (P_PARAM_PMKID_CANDIDATE_LIST_T)(&prStatusEvent->eStatusType + 1);
2120 ASSERT(prPmkidEvent);
2122 prAisSpecificBssInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
2123 ASSERT(prAisSpecificBssInfo);
2125 for (i = 0; i < prAisSpecificBssInfo->u4PmkidCandicateCount; i++) {
2126 for (j = 0; j < prAisSpecificBssInfo->u4PmkidCacheCount; j++) {
2127 if (EQUAL_MAC_ADDR( prAisSpecificBssInfo->arPmkidCache[j].rBssidInfo.arBSSID,
2128 prAisSpecificBssInfo->arPmkidCandicate[i].aucBssid) &&
2129 (prAisSpecificBssInfo->arPmkidCache[j].fgPmkidExist == TRUE)){
2133 if (count >= CFG_MAX_PMKID_CACHE) {
2137 if (j == prAisSpecificBssInfo->u4PmkidCacheCount) {
2138 kalMemCopy((PVOID)prPmkidEvent->arCandidateList[count].arBSSID,
2139 (PVOID)prAisSpecificBssInfo->arPmkidCandicate[i].aucBssid,
2140 PARAM_MAC_ADDR_LEN);
2141 prPmkidEvent->arCandidateList[count].u4Flags =
2142 prAisSpecificBssInfo->arPmkidCandicate[i].u4PreAuthFlags;
2143 DBGLOG(RSN, TRACE, (MACSTR" %d\n", MAC2STR(prPmkidEvent->arCandidateList[count].arBSSID),
2144 prPmkidEvent->arCandidateList[count].u4Flags));
2149 /* PMKID Candidate List */
2150 prPmkidEvent->u4Version = 1;
2151 prPmkidEvent->u4NumCandidates = count;
2152 DBGLOG(RSN, TRACE, ("rsnGeneratePmkidIndication #%d\n", prPmkidEvent->u4NumCandidates));
2153 u4LenOfUsedBuffer = sizeof(ENUM_STATUS_TYPE_T) + (2 * sizeof(UINT_32)) +
2154 (count * sizeof(PARAM_PMKID_CANDIDATE_T));
2155 //dumpMemory8((PUINT_8)prAdapter->aucIndicationEventBuffer, u4LenOfUsedBuffer);
2157 kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
2158 WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
2159 (PVOID) prAdapter->aucIndicationEventBuffer,
2162 } /* rsnGeneratePmkidIndication */
2165 #if CFG_SUPPORT_WPS2
2166 /*----------------------------------------------------------------------------*/
2169 * \brief This routine is called to generate WSC IE for
2170 * associate request frame.
2172 * \param[in] prCurrentBss The Selected BSS description
2174 * \retval The append WSC IE length
2177 * Called by: AIS module, Associate request
2179 /*----------------------------------------------------------------------------*/
2182 IN P_ADAPTER_T prAdapter,
2183 IN P_MSDU_INFO_T prMsduInfo
2191 if (prMsduInfo->ucNetworkType != NETWORK_TYPE_AIS_INDEX)
2194 pucBuffer = (PUINT_8)((UINT_32)prMsduInfo->prPacket +
2195 (UINT_32)prMsduInfo->u2FrameLength);
2197 /* ASSOC INFO IE ID: 221 :0xDD */
2198 if (prAdapter->prGlueInfo->u2WSCAssocInfoIELen) {
2199 kalMemCopy(pucBuffer, &prAdapter->prGlueInfo->aucWSCAssocInfoIE, prAdapter->prGlueInfo->u2WSCAssocInfoIELen);
2200 prMsduInfo->u2FrameLength += prAdapter->prGlueInfo->u2WSCAssocInfoIELen;
2207 #if CFG_SUPPORT_802_11W
2209 /*----------------------------------------------------------------------------*/
2211 * \brief to check if the Bip Key installed or not
2220 /*----------------------------------------------------------------------------*/
2222 rsnCheckBipKeyInstalled (
2223 IN P_ADAPTER_T prAdapter,
2224 IN P_STA_RECORD_T prStaRec
2227 if (prStaRec && prStaRec->ucNetTypeIndex == (UINT_8)NETWORK_TYPE_AIS_INDEX)
2228 return prAdapter->rWifiVar.rAisSpecificBssInfo.fgBipKeyInstalled;
2233 /*----------------------------------------------------------------------------*/
2236 * \brief This routine is called to check the Sa query timeout.
2240 * Called by: AIS module, Handle by Sa Quert timeout
2242 /*----------------------------------------------------------------------------*/
2244 rsnCheckSaQueryTimeout (
2245 IN P_ADAPTER_T prAdapter
2248 P_AIS_SPECIFIC_BSS_INFO_T prBssSpecInfo;
2251 prBssSpecInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
2252 ASSERT(prBssSpecInfo);
2254 GET_CURRENT_SYSTIME(&now);
2256 if (CHECK_FOR_TIMEOUT(now,
2257 prBssSpecInfo->u4SaQueryStart,
2258 TU_TO_MSEC(1000))) {
2259 LOG_FUNC("association SA Query timed out\n");
2261 prBssSpecInfo->ucSaQueryTimedOut = 1;
2262 kalMemFree(prBssSpecInfo->pucSaQueryTransId, VIR_MEM_TYPE, prBssSpecInfo->u4SaQueryCount * ACTION_SA_QUERY_TR_ID_LEN);
2263 prBssSpecInfo->pucSaQueryTransId = NULL;
2264 prBssSpecInfo->u4SaQueryCount = 0;
2265 cnmTimerStopTimer(prAdapter, &prBssSpecInfo->rSaQueryTimer);
2267 kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
2268 WLAN_STATUS_MEDIA_DISCONNECT,
2278 /*----------------------------------------------------------------------------*/
2281 * \brief This routine is called to start the 802.11w sa query timer.
2285 * Called by: AIS module, Handle Rx mgmt request
2287 /*----------------------------------------------------------------------------*/
2288 void rsnStartSaQueryTimer (
2289 IN P_ADAPTER_T prAdapter
2292 P_BSS_INFO_T prBssInfo;
2293 P_AIS_SPECIFIC_BSS_INFO_T prBssSpecInfo;
2294 P_MSDU_INFO_T prMsduInfo;
2295 P_ACTION_SA_QUERY_FRAME prTxFrame;
2296 UINT_16 u2PayloadLen;
2297 PUINT_8 pucTmp = NULL;
2298 UINT_8 ucTransId[ACTION_SA_QUERY_TR_ID_LEN];
2300 prBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
2303 prBssSpecInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
2304 ASSERT(prBssSpecInfo);
2306 LOG_FUNC("MFP: Start Sa Query\n");
2308 if (prBssSpecInfo->u4SaQueryCount > 0 &&
2309 rsnCheckSaQueryTimeout(prAdapter)) {
2310 LOG_FUNC("MFP: u4SaQueryCount count =%d\n", prBssSpecInfo->u4SaQueryCount);
2314 prMsduInfo = (P_MSDU_INFO_T) cnmMgtPktAlloc(prAdapter,
2315 MAC_TX_RESERVED_FIELD + PUBLIC_ACTION_MAX_LEN);
2320 prTxFrame = (P_ACTION_SA_QUERY_FRAME)
2321 ((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
2323 prTxFrame->u2FrameCtrl = MAC_FRAME_ACTION;
2324 prTxFrame->u2FrameCtrl |= MASK_FC_PROTECTED_FRAME;
2326 COPY_MAC_ADDR(prTxFrame->aucDestAddr, prBssInfo->aucBSSID);
2327 COPY_MAC_ADDR(prTxFrame->aucSrcAddr, prBssInfo->aucOwnMacAddr);
2328 COPY_MAC_ADDR(prTxFrame->aucBSSID, prBssInfo->aucBSSID);
2330 prTxFrame->ucCategory = CATEGORY_SA_QUERT_ACTION;
2331 prTxFrame->ucAction = ACTION_SA_QUERY_REQUEST;
2333 if (prBssSpecInfo->u4SaQueryCount == 0) {
2334 GET_CURRENT_SYSTIME(&prBssSpecInfo->u4SaQueryStart);
2337 if (prBssSpecInfo->u4SaQueryCount) {
2338 pucTmp = kalMemAlloc(prBssSpecInfo->u4SaQueryCount * ACTION_SA_QUERY_TR_ID_LEN, VIR_MEM_TYPE);
2340 DBGLOG(RSN, INFO, ("MFP: Fail to alloc tmp buffer for backup sa query id\n"));
2343 kalMemCopy(pucTmp, prBssSpecInfo->pucSaQueryTransId, prBssSpecInfo->u4SaQueryCount * ACTION_SA_QUERY_TR_ID_LEN);
2346 kalMemFree(prBssSpecInfo->pucSaQueryTransId, VIR_MEM_TYPE, prBssSpecInfo->u4SaQueryCount * ACTION_SA_QUERY_TR_ID_LEN);
2348 ucTransId[0] = (UINT_8)(kalRandomNumber() & 0xFF);
2349 ucTransId[1] = (UINT_8)(kalRandomNumber() & 0xFF);
2351 kalMemCopy(prTxFrame->ucTransId, ucTransId, ACTION_SA_QUERY_TR_ID_LEN);
2353 prBssSpecInfo->u4SaQueryCount++;
2355 prBssSpecInfo->pucSaQueryTransId = kalMemAlloc(prBssSpecInfo->u4SaQueryCount * ACTION_SA_QUERY_TR_ID_LEN, VIR_MEM_TYPE);
2356 if (!prBssSpecInfo->pucSaQueryTransId) {
2357 DBGLOG(RSN, INFO, ("MFP: Fail to alloc buffer for sa query id list\n"));
2362 kalMemCopy(prBssSpecInfo->pucSaQueryTransId, pucTmp, (prBssSpecInfo->u4SaQueryCount - 1) * ACTION_SA_QUERY_TR_ID_LEN);
2363 kalMemCopy(&prBssSpecInfo->pucSaQueryTransId[(prBssSpecInfo->u4SaQueryCount - 1) * ACTION_SA_QUERY_TR_ID_LEN],
2364 ucTransId, ACTION_SA_QUERY_TR_ID_LEN);
2365 kalMemFree(pucTmp, VIR_MEM_TYPE, (prBssSpecInfo->u4SaQueryCount - 1) * ACTION_SA_QUERY_TR_ID_LEN);
2368 kalMemCopy(prBssSpecInfo->pucSaQueryTransId, ucTransId, ACTION_SA_QUERY_TR_ID_LEN);
2371 u2PayloadLen = 2 + ACTION_SA_QUERY_TR_ID_LEN;
2373 //4 Update information of MSDU_INFO_T
2374 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_MGMT; /* Management frame */
2375 prMsduInfo->ucStaRecIndex = prBssInfo->prStaRecOfAP->ucIndex;
2376 prMsduInfo->ucNetworkType = prBssInfo->ucNetTypeIndex;
2377 prMsduInfo->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN;
2378 prMsduInfo->fgIs802_1x = FALSE;
2379 prMsduInfo->fgIs802_11 = TRUE;
2380 prMsduInfo->u2FrameLength = WLAN_MAC_MGMT_HEADER_LEN + u2PayloadLen;
2381 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
2382 prMsduInfo->pfTxDoneHandler = NULL;
2383 prMsduInfo->fgIsBasicRate = FALSE;
2385 //4 Enqueue the frame to send this action frame.
2386 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
2388 DBGLOG(RSN, TRACE, ("Set SA Query timer %d (%d sec)\n", prBssSpecInfo->u4SaQueryCount, prBssInfo->u2ObssScanInterval));
2390 cnmTimerStartTimer(prAdapter, &prBssSpecInfo->rSaQueryTimer,
2396 /*----------------------------------------------------------------------------*/
2399 * \brief This routine is called to start the 802.11w sa query.
2403 * Called by: AIS module, Handle Rx mgmt request
2405 /*----------------------------------------------------------------------------*/
2406 void rsnStartSaQuery (
2407 IN P_ADAPTER_T prAdapter
2410 rsnStartSaQueryTimer(prAdapter);
2414 /*----------------------------------------------------------------------------*/
2417 * \brief This routine is called to stop the 802.11w sa query.
2421 * Called by: AIS module, Handle Rx mgmt request
2423 /*----------------------------------------------------------------------------*/
2424 void rsnStopSaQuery (
2425 IN P_ADAPTER_T prAdapter
2428 P_AIS_SPECIFIC_BSS_INFO_T prBssSpecInfo;
2430 prBssSpecInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
2431 ASSERT(prBssSpecInfo);
2433 cnmTimerStopTimer(prAdapter, &prBssSpecInfo->rSaQueryTimer);
2434 kalMemFree(prBssSpecInfo->pucSaQueryTransId, VIR_MEM_TYPE, prBssSpecInfo->u4SaQueryCount * ACTION_SA_QUERY_TR_ID_LEN);
2435 prBssSpecInfo->pucSaQueryTransId = NULL;
2436 prBssSpecInfo->u4SaQueryCount = 0;
2439 /*----------------------------------------------------------------------------*/
2442 * \brief This routine is called to process the 802.11w sa query action frame.
2446 * Called by: AIS module, Handle Rx mgmt request
2448 /*----------------------------------------------------------------------------*/
2451 IN P_ADAPTER_T prAdapter,
2452 IN P_SW_RFB_T prSwRfb
2455 P_BSS_INFO_T prBssInfo;
2456 P_MSDU_INFO_T prMsduInfo;
2457 P_ACTION_SA_QUERY_FRAME prRxFrame = NULL;
2458 UINT_16 u2PayloadLen;
2459 P_STA_RECORD_T prStaRec;
2460 P_ACTION_SA_QUERY_FRAME prTxFrame;
2462 prBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
2465 prRxFrame = (P_ACTION_SA_QUERY_FRAME)prSwRfb->pvHeader;
2469 prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
2471 DBGLOG(RSN, TRACE, ("IEEE 802.11: Received SA Query Request from "
2472 MACSTR"\n", MAC2STR(prStaRec->aucMacAddr)));
2474 DBGLOG_MEM8(RSN, TRACE, prRxFrame->ucTransId,
2475 ACTION_SA_QUERY_TR_ID_LEN);
2477 if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) == PARAM_MEDIA_STATE_DISCONNECTED) {
2478 DBGLOG(RSN, TRACE, ("IEEE 802.11: Ignore SA Query Request "
2479 "from unassociated STA " MACSTR"\n", MAC2STR(prStaRec->aucMacAddr)));
2482 DBGLOG(RSN, TRACE, ("IEEE 802.11: Sending SA Query Response to "
2483 MACSTR"\n", MAC2STR(prStaRec->aucMacAddr)));
2485 prMsduInfo = (P_MSDU_INFO_T) cnmMgtPktAlloc(prAdapter,
2486 MAC_TX_RESERVED_FIELD + PUBLIC_ACTION_MAX_LEN);
2491 prTxFrame = (P_ACTION_SA_QUERY_FRAME)
2492 ((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
2494 prTxFrame->u2FrameCtrl = MAC_FRAME_ACTION;
2495 /* SA Query always with protected */
2496 prTxFrame->u2FrameCtrl |= MASK_FC_PROTECTED_FRAME;
2498 COPY_MAC_ADDR(prTxFrame->aucDestAddr, prBssInfo->aucBSSID);
2499 COPY_MAC_ADDR(prTxFrame->aucSrcAddr, prBssInfo->aucOwnMacAddr);
2500 COPY_MAC_ADDR(prTxFrame->aucBSSID, prBssInfo->aucBSSID);
2502 prTxFrame->ucCategory = CATEGORY_SA_QUERT_ACTION;
2503 prTxFrame->ucAction = ACTION_SA_QUERY_RESPONSE;
2505 kalMemCopy(prTxFrame->ucTransId,
2506 prRxFrame->ucTransId,
2507 ACTION_SA_QUERY_TR_ID_LEN);
2509 u2PayloadLen = 2 + ACTION_SA_QUERY_TR_ID_LEN;
2511 //4 Update information of MSDU_INFO_T
2512 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_MGMT; /* Management frame */
2513 prMsduInfo->ucStaRecIndex = prBssInfo->prStaRecOfAP->ucIndex;
2514 prMsduInfo->ucNetworkType = prBssInfo->ucNetTypeIndex;
2515 prMsduInfo->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN;
2516 prMsduInfo->fgIs802_1x = FALSE;
2517 prMsduInfo->fgIs802_11 = TRUE;
2518 prMsduInfo->u2FrameLength = WLAN_MAC_MGMT_HEADER_LEN + u2PayloadLen;
2519 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
2520 prMsduInfo->pfTxDoneHandler = NULL;
2521 prMsduInfo->fgIsBasicRate = FALSE;
2523 //4 Enqueue the frame to send this action frame.
2524 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
2529 /*----------------------------------------------------------------------------*/
2532 * \brief This routine is called to process the 802.11w sa query action frame.
2536 * Called by: AIS module, Handle Rx mgmt request
2538 /*----------------------------------------------------------------------------*/
2541 IN P_ADAPTER_T prAdapter,
2542 IN P_SW_RFB_T prSwRfb
2545 P_AIS_SPECIFIC_BSS_INFO_T prBssSpecInfo;
2546 P_ACTION_SA_QUERY_FRAME prRxFrame;
2547 P_STA_RECORD_T prStaRec;
2550 prBssSpecInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
2551 ASSERT(prBssSpecInfo);
2553 prRxFrame = (P_ACTION_SA_QUERY_FRAME) prSwRfb->pvHeader;
2554 prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
2556 if (prSwRfb->u2PacketLen < ACTION_SA_QUERY_TR_ID_LEN) {
2557 DBGLOG(RSN, TRACE, ("IEEE 802.11: Too short SA Query Action "
2558 "frame (len=%lu)\n", (unsigned long) prSwRfb->u2PacketLen));
2562 if (prRxFrame->ucAction == ACTION_SA_QUERY_REQUEST) {
2563 rsnSaQueryRequest(prAdapter, prSwRfb);
2567 if (prRxFrame->ucAction != ACTION_SA_QUERY_RESPONSE) {
2568 DBGLOG(RSN, TRACE, ("IEEE 802.11: Unexpected SA Query "
2569 "Action %d\n", prRxFrame->ucAction));
2573 DBGLOG(RSN, TRACE, ("IEEE 802.11: Received SA Query Response from "
2574 MACSTR"\n", MAC2STR(prStaRec->aucMacAddr)));
2576 DBGLOG_MEM8(RSN, TRACE, prRxFrame->ucTransId,
2577 ACTION_SA_QUERY_TR_ID_LEN);
2579 /* MLME-SAQuery.confirm */
2581 for (i = 0; i < prBssSpecInfo->u4SaQueryCount; i++) {
2582 if (kalMemCmp(prBssSpecInfo->pucSaQueryTransId +
2583 i * ACTION_SA_QUERY_TR_ID_LEN,
2584 prRxFrame->ucTransId,
2585 ACTION_SA_QUERY_TR_ID_LEN) == 0)
2589 if (i >= prBssSpecInfo->u4SaQueryCount) {
2590 DBGLOG(RSN, TRACE, ("IEEE 802.11: No matching SA Query "
2591 "transaction identifier found\n"));
2595 DBGLOG(RSN, TRACE, ("Reply to pending SA Query received\n"));
2597 rsnStopSaQuery(prAdapter);
2601 /*----------------------------------------------------------------------------*/
2604 * \brief This routine is called to process the 802.11w mgmt frame.
2608 * Called by: AIS module, Handle Rx mgmt request
2610 /*----------------------------------------------------------------------------*/
2613 IN P_ADAPTER_T prAdapter,
2614 IN P_SW_RFB_T prSwRfb,
2618 P_HIF_RX_HEADER_T prHifRxHdr;
2619 BOOLEAN fgUnicast = TRUE;
2620 BOOLEAN fgRobustAction = FALSE;
2622 prHifRxHdr = prSwRfb->prHifRxHdr;
2624 if ((HIF_RX_HDR_GET_NETWORK_IDX(prHifRxHdr) == NETWORK_TYPE_AIS_INDEX) &&
2625 prAdapter->rWifiVar.rAisSpecificBssInfo.fgMgmtProtection /* Use MFP */) {
2627 P_WLAN_ASSOC_REQ_FRAME_T prAssocReqFrame;
2628 prAssocReqFrame = (P_WLAN_ASSOC_REQ_FRAME_T) prSwRfb->pvHeader;
2630 if (prAssocReqFrame->aucDestAddr[0] & BIT(0))
2633 LOG_FUNC("QM RX MGT: rsnCheckRxMgmt = %d 0x%x %d ucSubtype=%x\n", fgUnicast, prHifRxHdr->ucReserved, (prHifRxHdr->ucReserved & CONTROL_FLAG_UC_MGMT_NO_ENC), ucSubtype);
2635 if (prHifRxHdr->ucReserved & CONTROL_FLAG_UC_MGMT_NO_ENC) {
2636 /* "Dropped unprotected Robust Action frame from an MFP STA" */
2637 /* exclude Public Action */
2638 if (ucSubtype == 13 /* 0x1011: MAC_FRAME_ACTION */)
2640 UINT_8 ucAction = *prSwRfb->pucRecvBuff;
2641 if (ucAction != CATEGORY_PUBLIC_ACTION && ucAction != CATEGORY_HT_ACTION) {
2642 #if DBG && CFG_RX_PKTS_DUMP
2643 LOG_FUNC("QM RX MGT: UnProtected Robust Action frame = %d\n", ucAction);
2645 fgRobustAction = TRUE;
2649 if (fgUnicast && ((ucSubtype == 10 /* 0x1010: MAC_FRAME_DISASSOC */) || (ucSubtype == 12 /* 0x1100: MAC_FRAME_DEAUTH */))) {
2650 LOG_FUNC("QM RX MGT: rsnStartSaQuery\n");
2651 /* MFP test plan 5.3.3.5 */
2652 rsnStartSaQuery(prAdapter);
2658 if (fgUnicast && ((ucSubtype == MAC_FRAME_DISASSOC) || (ucSubtype == MAC_FRAME_DEAUTH))) {
2659 /* This done by function handler */
2660 //kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
2661 // WLAN_STATUS_MEDIA_DISCONNECT,