2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/assoc.c#3 $
6 \brief This file includes the association-related functions.
8 This file includes the association-related functions.
16 ** 07 27 2012 yuche.tsai
17 ** [ALPS00324337] [ALPS.JB][Hot-Spot] Driver update for Hot-Spot
18 ** Fix wifi direct connection issue.
20 * 07 17 2012 yuche.tsai
22 * Let netdev bring up.
24 * 07 17 2012 yuche.tsai
26 * Compile no error before trial run.
28 * 06 13 2012 yuche.tsai
30 * Update maintrunk driver.
31 * Add support for driver compose assoc request frame.
34 * [WCXRP00001245] [MT6620 Wi-Fi][Driver][Firmware] NPS Software Development
35 * add a pair of brace for compilation success.
38 * [WCXRP00001245] [MT6620 Wi-Fi][Driver][Firmware] NPS Software Development
39 * discussed with WH, privacy bit in associate response is not necessary to be checked, and identified as association failure when mismatching with beacon/probe response
42 * [WCXRP00001173] [MT6620 Wi-Fi][Driver] Adding the ICS Tethering WPA2-PSK supporting
51 * Sync CFG80211 modification from branch 2,2.
53 * 01 16 2012 yuche.tsai
55 * Update Driver for wifi driect gc join IE update issue.
58 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
59 * change the debug module level.
62 * [WCXRP00001058] [All Wi-Fi][Driver] Fix sta_rec's phyTypeSet and OBSS scan in AP mode
63 * Fix PhyTypeSet in STA_REC in AP mode
66 * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
67 * adding the 802.11w related function and define .
69 * 09 19 2011 yuche.tsai
71 * Fix KE when enable hot-spot & any one client connect to this hot-spot.
73 * 09 14 2011 yuche.tsai
75 * Add P2P IE in assoc response.
78 * [WCXRP00000855] [MT6620 Wi-Fi] [Driver] Workaround for Kingnet 710 AP wrong AID assignment
79 * Update workaround for Kingnet AP.
82 * [WCXRP00000855] [MT6620 Wi-Fi] [Driver] Workaround for Kingnet 710 AP wrong AID assignment
83 * Workaround for Kingnet 710 AP wrong AID assignment.
85 * 05 02 2011 eddie.chen
86 * [WCXRP00000603] [MT6620 Wi-Fi][DRV] Fix Klocwork warning[WCXRP00000672] [MT6620 Wi-Fi][FW] Fix the PS event allocation
87 * Check STA when rx assoc.
90 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
91 * Remove flag CFG_WIFI_DIRECT_MOVED.
93 * 03 19 2011 yuche.tsai
94 * [WCXRP00000581] [Volunteer Patch][MT6620][Driver] P2P IE in Assoc Req Issue
95 * Make assoc req to append P2P IE if wifi direct is enabled.
97 * 03 17 2011 chinglan.wang
98 * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
102 * [WCXRP00000530] [MT6620 Wi-Fi] [Driver] skip doing p2pRunEventAAAComplete after send assoc response Tx Done
103 * enable the protected while at P2P start GO, and skip some security check .
106 * [WCXRP00000545] [MT6620 Wi-Fi] [Driver] Fixed the p2p not enable, received a assoc rsp cause the rx assoc execute a null function
107 * Modify file for avoid assert at BOW recieve a assoc response frame but no p2p fucntion.
109 * 03 08 2011 terry.wu
110 * [WCXRP00000524] [MT6620 Wi-Fi][Driver] Fix p2p assoc request containing wrong IE format
111 * Fix p2p assoc request containing wrong IE format.
114 * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
115 * add code to let the beacon and probe response for Auto GO WSC .
117 * 02 15 2011 yuche.tsai
118 * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
119 * Fix RX disassoc issue under Hot-spot mode.
122 * [WCXRP00000432] [MT6620 Wi-Fi][Driver] Add STA privacy check at hotspot mode
123 * adding the code for check STA privacy bit at AP mode, .
125 * 02 08 2011 eddie.chen
126 * [WCXRP00000426] [MT6620 Wi-Fi][FW/Driver] Add STA aging timeout and defualtHwRatein AP mode
127 * Add event STA agint timeout
129 * 01 25 2011 yuche.tsai
130 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
131 * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
133 * 01 12 2011 yuche.tsai
134 * [WCXRP00000353] [Volunteer Patch][MT6620][Driver] Desired Non-HT Rate Set update when STA record is created under AP Mode.
135 * Update Phy Type Set. When legacy client is connected, it can use 11b rate,
136 * but if the P2P device is connected, 11b rate is not allowed.
138 * 01 11 2011 yuche.tsai
139 * [WCXRP00000353] [Volunteer Patch][MT6620][Driver] Desired Non-HT Rate Set update when STA record is created under AP Mode.
140 * Update Desired Non-HT Rate Set.
142 * 12 30 2010 eddie.chen
143 * [WCXRP00000322] Add WMM IE in beacon,
145 Add per station flow control when STA is in PS
148 * Recover the code that was coverwritted..
150 * 12 29 2010 eddie.chen
151 * [WCXRP00000322] Add WMM IE in beacon,
152 Add per station flow control when STA is in PS
154 * 1) PS flow control event
156 * 2) WMM IE in beacon, assoc resp, probe resp
159 * [WCXRP00000164] [MT6620 Wi-Fi][Driver] Support the p2p random SSID
160 * adding the p2p random ssid support.
163 * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
164 * use definition macro to replace hard-coded constant
168 * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
170 * 09 27 2010 chinghwa.yu
171 * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000065] Update BoW design and settings
172 * Update BCM/BoW design and settings.
174 * 09 16 2010 cm.chang
176 * Change conditional compiling options for BOW
178 * 09 03 2010 kevin.huang
180 * Refine #include sequence and solve recursive/nested #include issue
184 * adding the wapi support for integration test.
188 * eliminate klockwork errors
190 * 08 16 2010 yuche.tsai
192 * Add SSID IE in assoc req frame which is sent by P2P GC.
194 * 08 16 2010 kevin.huang
196 * Refine AAA functions
200 * surpress compilation warning.
204 * adding the wapi code.
206 * 07 09 2010 yarco.yang
208 * [MT6620 and MT5931] SW Migration: Add ADDBA support
212 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
215 * [WPD00003833][MT6620 and MT5931] Driver migration
216 * take use of RLM module for parsing/generating HT IEs for 11n capability
219 * [WPD00003833][MT6620 and MT5931] Driver migration
220 * comment out RSN IE generation by CFG_RSN_MIGRATION compilation flag.
223 * [WPD00003833][MT6620 and MT5931] Driver migration
224 * send MMPDU in basic rate.
227 * [WPD00003833][MT6620 and MT5931] Driver migration
228 * add scan_fsm into building.
231 * [WPD00003833][MT6620 and MT5931] Driver migration
232 * specify correct value for management frames.
234 * 06 18 2010 cm.chang
235 * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
236 * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
239 * [WPD00003840][MT6620 5931] Security migration
240 * migration from MT6620 firmware.
243 * [WPD00003833][MT6620 and MT5931] Driver migration
247 * [WPD00003833][MT6620 and MT5931] Driver migration
248 * add management dispatching function table.
251 * [WPD00003833][MT6620 and MT5931] Driver migration
252 * auth.c is migrated.
255 * [WPD00003833][MT6620 and MT5931] Driver migration
256 * 1) migrate assoc.c.
257 * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
258 * 3) add configuration options for CNM_MEM and RSN modules
259 * 4) add data path for management frames
260 * 5) eliminate rPacketInfo of MSDU_INFO_T
262 * 05 24 2010 kevin.huang
263 * [BORA00000794][WIFISYS][New Feature]Power Management Support
264 * Update assocProcessRxAssocReqFrame() to avoid redundant SSID IE {0,0} for IOT.
266 * 05 14 2010 kevin.huang
267 * [BORA00000794][WIFISYS][New Feature]Power Management Support
268 * Fix compile warning - macro > 10 line, initial value of an array
270 * 04 24 2010 cm.chang
271 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
272 * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
274 * 04 22 2010 cm.chang
275 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
276 * First draft code to support protection in AP mode
278 * 04 19 2010 kevin.huang
279 * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
280 * Add Beacon Timeout Support
281 * * * * * * * * and will send Null frame to diagnose connection
284 * [BORA00000680][MT6620] Support the statistic for Microsoft os query
285 * adding the wpa-none for ibss beacon.
287 * 03 25 2010 cm.chang
288 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
289 * Remove compiling warning
291 * 03 24 2010 cm.chang
292 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
293 * Not carry HT cap when being associated with b/g only AP
295 * 02 04 2010 kevin.huang
296 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
297 * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
300 * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
301 * fixed the compiling warning.u1rwduu`wvpghlqg|rm+vp
304 * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
305 * add and fixed some security function.
307 * 01 11 2010 kevin.huang
308 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
309 * Add Deauth and Disassoc Handler
311 * 01 07 2010 kevin.huang
312 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
313 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
314 * Update Assoc ID for PS
316 * 01 04 2010 tehuang.liu
317 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
318 * For working out the first connection Chariot-verified version
320 * 12 18 2009 cm.chang
321 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
324 * Dec 12 2009 mtk01104
325 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
326 * Use new constant definition ELEM_MAX_LEN_EXT_CAP
328 * Dec 9 2009 mtk01104
329 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
330 * Modify assoc req IE talbe for HT cap IE
332 * Dec 7 2009 mtk01461
333 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
334 * update the assocComposeReAssocReqFrameHeader() and fix the u2EstimatedFrameLen in assocSendReAssocReqFrame()
336 * Dec 7 2009 mtk01088
337 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
338 * remove some space line
340 * Dec 7 2009 mtk01088
341 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
342 * adding the sending disassoc frame function
344 * Dec 4 2009 mtk01088
345 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
346 * adding the txassocReq IE table, adding for WPA/RSN
348 * Dec 3 2009 mtk01461
349 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
350 * Fix eNetType not init in send AssocReq function
352 * Dec 3 2009 mtk01461
353 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
354 * Integrate the send Assoc with TXM
356 * Dec 1 2009 mtk01088
357 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
358 * adding the code to indicate the assoc request and assoc response (now disable)
360 * Nov 24 2009 mtk01461
361 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
362 * Remove unused variables
364 * Nov 23 2009 mtk01461
365 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
369 /*******************************************************************************
370 * C O M P I L E R F L A G S
371 ********************************************************************************
374 /*******************************************************************************
375 * E X T E R N A L R E F E R E N C E S
376 ********************************************************************************
380 /*******************************************************************************
382 ********************************************************************************
385 /*******************************************************************************
387 ********************************************************************************
390 /*******************************************************************************
391 * P U B L I C D A T A
392 ********************************************************************************
394 APPEND_VAR_IE_ENTRY_T txAssocReqIETable[] = {
395 { (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmReqGenerateHtCapIE },/* 45 */
397 { (ELEM_HDR_LEN + ELEM_MAX_LEN_WSC), NULL, rsnGenerateWSCIE }, /* 221 */
400 { (ELEM_HDR_LEN + ELEM_MAX_LEN_WAPI), NULL, wapiGenerateWAPIIE }, /* 68 */
402 #if CFG_RSN_MIGRATION
403 { (ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWPAIE }, /* 221 */
405 { (ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmReqGenerateExtCapIE }, /* 127 */
406 { (ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_INFO), NULL, mqmGenerateWmmInfoIE }, /* 221 */
407 #if CFG_RSN_MIGRATION
408 { (ELEM_HDR_LEN + ELEM_MAX_LEN_RSN), NULL, rsnGenerateRSNIE }, /* 48 */
413 VERIFY_IE_ENTRY_T rxAssocReqIETable[] = {
414 { ELEM_ID_RESERVED, NULL } /* 255 */
418 APPEND_VAR_IE_ENTRY_T txAssocRespIETable[] = {
419 { (ELEM_HDR_LEN + ELEM_MAX_LEN_ERP), NULL, rlmRspGenerateErpIE }, /* 42 */
420 { (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmRspGenerateHtCapIE }, /* 45 */
421 { (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP), NULL, rlmRspGenerateHtOpIE }, /* 61 */
422 #if CFG_ENABLE_WIFI_DIRECT
423 { (ELEM_HDR_LEN + ELEM_MAX_LEN_OBSS_SCAN), NULL, rlmRspGenerateObssScanIE }, /* 74 */
424 { (0), p2pFuncCalculateP2p_IELenForAssocRsp, p2pFuncGenerateP2p_IEForAssocRsp }, /* 221 */
426 { (0), wfdFuncCalculateWfdIELenForAssocRsp, wfdFuncGenerateWfdIEForAssocRsp }, /* 221 */
429 { (ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmRspGenerateExtCapIE }, /* 127 */
430 { (ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_PARAM), NULL, mqmGenerateWmmParamIE }, /* 221 */
432 { (0), p2pFuncCalculateWSC_IELenForAssocRsp, p2pFuncGenerateWSC_IEForAssocRsp } /* 221 */
437 /*******************************************************************************
438 * P R I V A T E D A T A
439 ********************************************************************************
442 /*******************************************************************************
444 ********************************************************************************
447 /*******************************************************************************
448 * F U N C T I O N D E C L A R A T I O N S
449 ********************************************************************************
452 /*******************************************************************************
454 ********************************************************************************
456 /*----------------------------------------------------------------------------*/
458 * @brief This function is used to compose the Capability Info Field.
460 * @param[in] prStaRec Pointer to the STA_RECORD_T
462 * @retval Capability Info Field
464 /*----------------------------------------------------------------------------*/
465 __KAL_INLINE__ UINT_16
466 assocBuildCapabilityInfo (
467 IN P_ADAPTER_T prAdapter,
468 IN P_STA_RECORD_T prStaRec
471 UINT_32 u4NonHTPhyType;
478 /* Set up our requested capabilities. */
479 u2CapInfo = CAP_INFO_ESS;
480 u2CapInfo |= CAP_CF_STA_NOT_POLLABLE;
482 if (prStaRec->u2CapInfo & CAP_INFO_PRIVACY) {
483 u2CapInfo |= CAP_INFO_PRIVACY;
488 if (prStaRec->fgHasBasicPhyType) {
489 u4NonHTPhyType = prStaRec->ucNonHTBasicPhyType;
491 if ( (rNonHTPhyAttributes[u4NonHTPhyType].fgIsShortPreambleOptionImplemented) &&
492 ( (prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_SHORT) || /* Short Preamble Option Enable is TRUE */
493 ((prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_AUTO) &&
494 (prStaRec->u2CapInfo & CAP_INFO_SHORT_PREAMBLE)) ) ) {
496 /* Case I: Implemented == TRUE and Short Preamble Option Enable == TRUE.
497 * Case II: Implemented == TRUE and Short Preamble == AUTO (depends on
498 * BSS_DESC_T's capability)
500 u2CapInfo |= CAP_INFO_SHORT_PREAMBLE;
503 #if CFG_SUPPORT_SPEC_MGMT /*Add for DFS support*/
504 /* Support 802.11h */
505 if(prAdapter->fgEnable5GBand == TRUE) {
506 u2CapInfo |= CAP_INFO_SPEC_MGT;
510 if (rNonHTPhyAttributes[u4NonHTPhyType].fgIsShortSlotTimeOptionImplemented &&
511 prAdapter->rWifiVar.fgIsShortSlotTimeOptionEnable) {
512 u2CapInfo |= CAP_INFO_SHORT_SLOT_TIME;
516 DBGLOG(SAA, LOUD, ("ASSOC REQ: Compose Capability = 0x%04x for Target BSS ["MACSTR"].\n",
517 u2CapInfo, MAC2STR(prStaRec->aucMacAddr)));
522 } /* end of assocBuildCapabilityInfo() */
525 /*----------------------------------------------------------------------------*/
527 * @brief This function is used to compose Common Information Elements for Association
530 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
534 /*----------------------------------------------------------------------------*/
536 assocBuildReAssocReqFrameCommonIEs (
537 IN P_ADAPTER_T prAdapter,
538 IN P_MSDU_INFO_T prMsduInfo
541 P_CONNECTION_SETTINGS_T prConnSettings;
542 P_STA_RECORD_T prStaRec;
544 UINT_16 u2SupportedRateSet;
545 UINT_8 aucAllSupportedRates[RATE_NUM] = {0};
546 UINT_8 ucAllSupportedRatesLen;
547 UINT_8 ucSupRatesLen;
548 UINT_8 ucExtSupRatesLen;
550 prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
552 ASSERT(prMsduInfo->eSrc == TX_PACKET_MGMT);
554 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
561 pucBuffer = (PUINT_8)((UINT_32)prMsduInfo->prPacket +
562 (UINT_32)prMsduInfo->u2FrameLength);
565 if (IS_STA_IN_AIS(prStaRec)) {
567 /* Fill the SSID element. */
568 SSID_IE(pucBuffer)->ucId = ELEM_ID_SSID;
570 /* NOTE(Kevin): We copy the SSID from CONNECTION_SETTINGS for the case of
571 * Passive Scan and the target BSS didn't broadcast SSID on its Beacon Frame.
574 COPY_SSID(SSID_IE(pucBuffer)->aucSSID,
575 SSID_IE(pucBuffer)->ucLength,
576 prConnSettings->aucSSID,
577 prConnSettings->ucSSIDLen);
579 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
580 pucBuffer += IE_SIZE(pucBuffer);
583 #if CFG_ENABLE_WIFI_DIRECT
584 else if((prAdapter->fgIsP2PRegistered) &&
585 (IS_STA_IN_P2P(prStaRec))) {
586 pucBuffer = p2pBuildReAssocReqFrameCommonIEs(prAdapter, prMsduInfo, pucBuffer);
589 #if CFG_ENABLE_BT_OVER_WIFI
590 else if (IS_STA_IN_BOW(prStaRec)) {
592 SSID_IE(pucBuffer)->ucId = ELEM_ID_SSID;
594 /* NOTE(Kevin): We copy the SSID from CONNECTION_SETTINGS for the case of
595 * Passive Scan and the target BSS didn't broadcast SSID on its Beacon Frame.
598 COPY_SSID(SSID_IE(pucBuffer)->aucSSID,
599 SSID_IE(pucBuffer)->ucLength,
600 prConnSettings->aucSSID,
601 prConnSettings->ucSSIDLen);
603 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
604 pucBuffer += IE_SIZE(pucBuffer);
609 /* TODO(Kevin): For other network */
612 /* NOTE(Kevin 2008/12/19): 16.3.6.3 MLME-ASSOCIATE.indication -
613 * SupportedRates - The set of data rates that are supported by the STA
614 * that is requesting association.
615 * Original(Portable Driver): Only send the Rates that we'll support.
616 * New: Send the Phy Rates if the result of following & operation == NULL.
618 //rateGetDataRatesFromRateSet((prBssDesc->u2OperationalRateSet &
619 // rPhyAttributes[prBssDesc->ePhyType].u2SupportedRateSet),
621 if (prStaRec->fgHasBasicPhyType) {
622 UINT_32 u4NonHTPhyType;
625 u4NonHTPhyType = prStaRec->ucNonHTBasicPhyType;
627 u2SupportedRateSet = (prStaRec->u2OperationalRateSet &
628 rNonHTPhyAttributes[u4NonHTPhyType].u2SupportedRateSet);
630 ASSERT(u2SupportedRateSet);
632 if (!u2SupportedRateSet) {
633 u2SupportedRateSet = rNonHTPhyAttributes[u4NonHTPhyType].u2SupportedRateSet;
636 /* TODO(Kevin): For P2P, we shouldn't send support rate set which contains 11b rate */
638 rateGetDataRatesFromRateSet(u2SupportedRateSet,
640 aucAllSupportedRates,
641 &ucAllSupportedRatesLen);
643 ucSupRatesLen = ((ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES) ?
644 ELEM_MAX_LEN_SUP_RATES : ucAllSupportedRatesLen);
646 ucExtSupRatesLen = ucAllSupportedRatesLen - ucSupRatesLen;
649 /* Fill the Supported Rates element. */
651 SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_SUP_RATES;
652 SUP_RATES_IE(pucBuffer)->ucLength = ucSupRatesLen;
653 kalMemCopy(SUP_RATES_IE(pucBuffer)->aucSupportedRates,
654 aucAllSupportedRates,
657 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
658 pucBuffer += IE_SIZE(pucBuffer);
662 /* Fill the Extended Supported Rates element. */
663 if (ucExtSupRatesLen) {
665 EXT_SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_EXTENDED_SUP_RATES;
666 EXT_SUP_RATES_IE(pucBuffer)->ucLength = ucExtSupRatesLen;
668 kalMemCopy(EXT_SUP_RATES_IE(pucBuffer)->aucExtSupportedRates,
669 &aucAllSupportedRates[ucSupRatesLen],
672 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
673 pucBuffer += IE_SIZE(pucBuffer);
676 /* 7.3.2.19 Supported Channels element*/
677 #if CFG_SUPPORT_DFS // Add for DFS support
678 if(prAdapter->fgEnable5GBand == TRUE) {
679 SUPPORTED_CHANNELS_IE(pucBuffer)->ucId = ELEM_ID_SUP_CHS;
680 SUPPORTED_CHANNELS_IE(pucBuffer)->ucLength = 8;
682 SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[0] = 36;
683 SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[1] = 4;
684 SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[2] = 52;
685 SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[3] = 4;
686 // Not China --- Start
687 //SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[4] = 100;
688 //SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[5] = 11;
690 SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[4] = 149;
691 SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[5] = 4;
692 SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[6] = 165;
693 SUPPORTED_CHANNELS_IE(pucBuffer)->ucChannelNum[7] = 1;
695 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
696 pucBuffer += IE_SIZE(pucBuffer);
702 } /* end of assocBuildReAssocReqFrameCommonIEs() */
705 /*----------------------------------------------------------------------------*/
707 * @brief This function will compose the (Re)Association Request frame header and
710 * @param[in] prStaRec Pointer to the STA_RECORD_T
711 * @param[in] pucBuffer Pointer to the frame buffer.
712 * @param[in] aucMACAddress Given Our MAC Address.
713 * @param[in out] pu2PayloadLen Return the length of the composed fixed fields
717 /*----------------------------------------------------------------------------*/
719 assocComposeReAssocReqFrameHeaderAndFF (
720 IN P_ADAPTER_T prAdapter,
721 IN P_STA_RECORD_T prStaRec,
722 IN PUINT_8 pucBuffer,
723 IN UINT_8 aucMACAddress[],
724 IN OUT PUINT_16 pu2PayloadLen
727 P_WLAN_ASSOC_REQ_FRAME_T prAssocFrame;
732 UINT_16 u2ListenInterval;
737 ASSERT(aucMACAddress);
738 ASSERT(pu2PayloadLen);
740 prAssocFrame = (P_WLAN_ASSOC_REQ_FRAME_T)pucBuffer;
741 fgIsReAssoc = prStaRec->fgIsReAssoc;
743 //4 <1> Compose the frame header of the (Re)Association Request frame.
744 /* Fill the Frame Control field. */
746 u2FrameCtrl = MAC_FRAME_REASSOC_REQ;
749 u2FrameCtrl = MAC_FRAME_ASSOC_REQ;
751 WLAN_SET_FIELD_16(&prAssocFrame->u2FrameCtrl, u2FrameCtrl);
753 /* Fill the DA field with Target BSSID. */
754 COPY_MAC_ADDR(prAssocFrame->aucDestAddr, prStaRec->aucMacAddr);
756 /* Fill the SA field with our MAC Address. */
757 COPY_MAC_ADDR(prAssocFrame->aucSrcAddr, aucMACAddress);
759 /* Fill the BSSID field with Target BSSID. */
760 COPY_MAC_ADDR(prAssocFrame->aucBSSID, prStaRec->aucMacAddr);
762 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
763 prAssocFrame->u2SeqCtrl = 0;
766 //4 <2> Compose the frame body's common fixed field part of the (Re)Association Request frame.
767 u2CapInfo = assocBuildCapabilityInfo(prAdapter, prStaRec);
769 /* Fill the Capability Information field. */
770 WLAN_SET_FIELD_16(&prAssocFrame->u2CapInfo, u2CapInfo);
773 /* Calculate the listen interval for the maximum power mode. Currently, we
774 set it to the value 2 times DTIM period. */
775 if (prStaRec->ucDTIMPeriod) {
776 u2ListenInterval = prStaRec->ucDTIMPeriod * DEFAULT_LISTEN_INTERVAL_BY_DTIM_PERIOD;
779 DBGLOG(SAA, TRACE, ("Use default listen interval\n"));
780 u2ListenInterval = DEFAULT_LISTEN_INTERVAL;
782 prStaRec->u2ListenInterval = u2ListenInterval;
784 /* Fill the Listen Interval field. */
785 WLAN_SET_FIELD_16(&prAssocFrame->u2ListenInterval, u2ListenInterval);
788 //4 <3> Compose the Current AP Address field for ReAssociation Request frame.
789 /* Fill the Current AP Address field. */
790 if (prStaRec->fgIsReAssoc) {
791 if (IS_STA_IN_AIS(prStaRec)) {
793 P_AIS_BSS_INFO_T prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
794 P_WLAN_REASSOC_REQ_FRAME_T prReAssocFrame =
795 (P_WLAN_REASSOC_REQ_FRAME_T)prAssocFrame;
797 COPY_MAC_ADDR(prReAssocFrame->aucCurrentAPAddr, prAisBssInfo->aucBSSID);
800 ASSERT(0); /* We don't support ReAssociation for other network */
803 *pu2PayloadLen = (CAP_INFO_FIELD_LEN +
804 LISTEN_INTERVAL_FIELD_LEN +
805 CURR_AP_ADDR_FIELD_LEN);
808 *pu2PayloadLen = (CAP_INFO_FIELD_LEN +
809 LISTEN_INTERVAL_FIELD_LEN);
813 } /* end of assocComposeReAssocReqFrame() */
816 /*----------------------------------------------------------------------------*/
818 * @brief This function will send the (Re)Association Request frame
820 * @param[in] prStaRec Pointer to the STA_RECORD_T
822 * @retval WLAN_STATUS_RESOURCES No available resource for frame composing.
823 * @retval WLAN_STATUS_SUCCESS Successfully send frame to TX Module
825 /*----------------------------------------------------------------------------*/
827 assocSendReAssocReqFrame (
828 IN P_ADAPTER_T prAdapter,
829 IN P_STA_RECORD_T prStaRec
832 P_MSDU_INFO_T prMsduInfo;
833 P_BSS_INFO_T prBssInfo;
835 UINT_16 u2PayloadLen;
836 UINT_16 u2EstimatedFrameLen;
837 UINT_16 u2EstimatedExtraIELen;
844 //4 <1> Allocate a PKT_INFO_T for Authentication Frame
845 fgIsReAssoc = prStaRec->fgIsReAssoc;
847 /* Init with MGMT Header Length + Length of Fixed Fields + Common IE Length */
849 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + \
850 WLAN_MAC_MGMT_HEADER_LEN + \
851 CAP_INFO_FIELD_LEN + \
852 LISTEN_INTERVAL_FIELD_LEN + \
853 CURR_AP_ADDR_FIELD_LEN + \
854 (ELEM_HDR_LEN + ELEM_MAX_LEN_SSID) + \
855 (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) + \
856 (ELEM_HDR_LEN + (RATE_NUM - ELEM_MAX_LEN_SUP_RATES));
859 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + \
860 WLAN_MAC_MGMT_HEADER_LEN + \
861 CAP_INFO_FIELD_LEN + \
862 LISTEN_INTERVAL_FIELD_LEN + \
863 (ELEM_HDR_LEN + ELEM_MAX_LEN_SSID) + \
864 (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) + \
865 (ELEM_HDR_LEN + (RATE_NUM - ELEM_MAX_LEN_SUP_RATES));
868 /* + Extra IE Length */
869 u2EstimatedExtraIELen = 0;
871 #if CFG_ENABLE_WIFI_DIRECT_CFG_80211 && CFG_ENABLE_WIFI_DIRECT
872 if (prStaRec->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
873 if ((prAdapter->fgIsP2PRegistered)) {
874 u2EstimatedExtraIELen = p2pCalculate_IEForAssocReq(prAdapter,
875 prStaRec->ucNetTypeIndex,
879 DBGLOG(P2P, TRACE, ("Function Linker Lost.\n"));
884 for (i = 0; i < sizeof(txAssocReqIETable)/sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
885 if (txAssocReqIETable[i].u2EstimatedFixedIELen != 0) {
886 u2EstimatedExtraIELen += txAssocReqIETable[i].u2EstimatedFixedIELen;
889 u2EstimatedExtraIELen += (UINT_16)txAssocReqIETable[i].pfnCalculateVariableIELen(prAdapter,
890 prStaRec->ucNetTypeIndex,
896 for (i = 0; i < sizeof(txAssocReqIETable)/sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
897 if (txAssocReqIETable[i].u2EstimatedFixedIELen != 0) {
898 u2EstimatedExtraIELen += txAssocReqIETable[i].u2EstimatedFixedIELen;
901 u2EstimatedExtraIELen += (UINT_16)txAssocReqIETable[i].pfnCalculateVariableIELen(prAdapter,
902 prStaRec->ucNetTypeIndex,
908 u2EstimatedFrameLen += u2EstimatedExtraIELen;
910 /* Allocate a MSDU_INFO_T */
911 if ( (prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
912 DBGLOG(SAA, WARN, ("No PKT_INFO_T for sending (Re)Assoc Request.\n"));
913 return WLAN_STATUS_RESOURCES;
916 //4 <2> Compose (Re)Association Request frame header and fixed fields in MSDU_INfO_T.
917 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
918 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
921 /* Compose Header and Fixed Field */
922 assocComposeReAssocReqFrameHeaderAndFF(prAdapter,
924 (PUINT_8)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
925 prBssInfo->aucOwnMacAddr,
928 //4 <3> Update information of MSDU_INFO_T
929 prMsduInfo->eSrc = TX_PACKET_MGMT;
930 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
931 prMsduInfo->ucStaRecIndex = prStaRec->ucIndex;
932 prMsduInfo->ucNetworkType = prStaRec->ucNetTypeIndex;
933 prMsduInfo->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN;
934 prMsduInfo->fgIs802_1x = FALSE;
935 prMsduInfo->fgIs802_11 = TRUE;
936 prMsduInfo->u2FrameLength = WLAN_MAC_MGMT_HEADER_LEN + u2PayloadLen;
937 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
938 prMsduInfo->pfTxDoneHandler = saaFsmRunEventTxDone;
939 prMsduInfo->fgIsBasicRate = TRUE;
941 //4 <4> Compose the frame body's IEs of the (Re)Association Request frame.
942 assocBuildReAssocReqFrameCommonIEs(prAdapter, prMsduInfo);
945 //4 <5> Compose IEs in MSDU_INFO_T
946 #if CFG_ENABLE_WIFI_DIRECT_CFG_80211 && CFG_ENABLE_WIFI_DIRECT
947 if (prStaRec->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
948 if ((prAdapter->fgIsP2PRegistered)) {
949 p2pGenerate_IEForAssocReq(prAdapter, prMsduInfo);
952 DBGLOG(P2P, TRACE, ("Function Linker Lost.\n"));
958 for (i = 0; i < sizeof(txAssocReqIETable)/sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
959 if (txAssocReqIETable[i].pfnAppendIE) {
960 txAssocReqIETable[i].pfnAppendIE(prAdapter, prMsduInfo);
966 for (i = 0; i < sizeof(txAssocReqIETable)/sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
967 if (txAssocReqIETable[i].pfnAppendIE) {
968 txAssocReqIETable[i].pfnAppendIE(prAdapter, prMsduInfo);
973 //4 <6> Update the (Re)association request information
974 if (IS_STA_IN_AIS(prStaRec)) {
975 P_WLAN_ASSOC_REQ_FRAME_T prAssocFrame;
977 prAssocFrame = (P_WLAN_ASSOC_REQ_FRAME_T)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
979 #if CFG_RSN_MIGRATION
980 kalUpdateReAssocReqInfo(prAdapter->prGlueInfo,
981 (PUINT_8)&prAssocFrame->u2CapInfo,
982 prMsduInfo->u2FrameLength - offsetof(WLAN_ASSOC_REQ_FRAME_T, u2CapInfo),
987 #if CFG_ENABLE_WIFI_DIRECT
988 if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
989 P_WLAN_ASSOC_REQ_FRAME_T prAssocFrame;
991 prAssocFrame = (P_WLAN_ASSOC_REQ_FRAME_T)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
994 kalP2PUpdateAssocInfo(
995 prAdapter->prGlueInfo,
996 (PUINT_8)&prAssocFrame->u2CapInfo,
997 prMsduInfo->u2FrameLength - offsetof(WLAN_ASSOC_REQ_FRAME_T, u2CapInfo),
1002 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
1004 //4 <6> Enqueue the frame to send this (Re)Association request frame.
1005 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
1007 return WLAN_STATUS_SUCCESS;
1008 } /* end of assocSendReAssocReqFrame() */
1011 /*----------------------------------------------------------------------------*/
1013 * @brief This function will strictly check the TX (Re)Association Request frame for
1014 * SAA event handling.
1016 * @param[in] prMsduInfo Pointer of MSDU_INFO_T
1018 * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
1019 * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
1021 /*----------------------------------------------------------------------------*/
1023 assocCheckTxReAssocReqFrame (
1024 IN P_ADAPTER_T prAdapter,
1025 IN P_MSDU_INFO_T prMsduInfo
1028 P_WLAN_ASSOC_REQ_FRAME_T prAssocReqFrame;
1029 P_STA_RECORD_T prStaRec;
1030 UINT_16 u2TxFrameCtrl;
1034 ASSERT(prMsduInfo->eSrc == TX_PACKET_MGMT);
1036 prAssocReqFrame = (P_WLAN_ASSOC_REQ_FRAME_T)(prMsduInfo->prPacket);
1037 ASSERT(prAssocReqFrame);
1039 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
1043 return WLAN_STATUS_INVALID_PACKET;
1046 //WLAN_GET_FIELD_16(&prAssocReqFrame->u2FrameCtrl, &u2TxFrameCtrl)
1047 u2TxFrameCtrl = prAssocReqFrame->u2FrameCtrl; // NOTE(Kevin): Optimized for ARM
1048 u2TxFrameCtrl &= MASK_FRAME_TYPE;
1049 if (prStaRec->fgIsReAssoc) {
1050 if (u2TxFrameCtrl != MAC_FRAME_REASSOC_REQ) {
1051 return WLAN_STATUS_FAILURE;
1055 if (u2TxFrameCtrl != MAC_FRAME_ASSOC_REQ) {
1056 return WLAN_STATUS_FAILURE;
1060 return WLAN_STATUS_SUCCESS;
1062 } /* end of assocCheckTxReAssocReqFrame() */
1065 /*----------------------------------------------------------------------------*/
1067 * @brief This function will strictly check the TX (Re)Association Response frame for
1068 * AAA event handling.
1070 * @param[in] prMsduInfo Pointer of MSDU_INFO_T
1072 * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
1073 * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
1075 /*----------------------------------------------------------------------------*/
1077 assocCheckTxReAssocRespFrame (
1078 IN P_ADAPTER_T prAdapter,
1079 IN P_MSDU_INFO_T prMsduInfo
1082 P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame;
1083 P_STA_RECORD_T prStaRec;
1084 UINT_16 u2TxFrameCtrl;
1088 ASSERT(prMsduInfo->eSrc == TX_PACKET_MGMT);
1090 prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T)(prMsduInfo->prPacket);
1091 ASSERT(prAssocRspFrame);
1093 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
1097 return WLAN_STATUS_INVALID_PACKET;
1100 //WLAN_GET_FIELD_16(&prAssocFrame->u2FrameCtrl, &u2TxFrameCtrl)
1101 u2TxFrameCtrl = prAssocRspFrame->u2FrameCtrl; // NOTE(Kevin): Optimized for ARM
1102 u2TxFrameCtrl &= MASK_FRAME_TYPE;
1103 if (prStaRec->fgIsReAssoc) {
1104 if (u2TxFrameCtrl != MAC_FRAME_REASSOC_RSP) {
1105 return WLAN_STATUS_FAILURE;
1109 if (u2TxFrameCtrl != MAC_FRAME_ASSOC_RSP) {
1110 return WLAN_STATUS_FAILURE;
1114 return WLAN_STATUS_SUCCESS;
1116 } /* end of assocCheckTxReAssocRespFrame() */
1119 /*----------------------------------------------------------------------------*/
1121 * @brief This function will validate the incoming (Re)Association Frame and take out
1124 * @param[in] prSwRfb Pointer to SW RFB data structure.
1125 * @param[out] pu2StatusCode Pointer to store the Status Code from Authentication.
1127 * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
1128 * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
1130 /*----------------------------------------------------------------------------*/
1132 assocCheckRxReAssocRspFrameStatus (
1133 IN P_ADAPTER_T prAdapter,
1134 IN P_SW_RFB_T prSwRfb,
1135 OUT PUINT_16 pu2StatusCode
1138 P_STA_RECORD_T prStaRec;
1139 P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame;
1140 UINT_16 u2RxFrameCtrl;
1141 UINT_16 u2RxCapInfo;
1142 UINT_16 u2RxStatusCode;
1143 UINT_16 u2RxAssocId;
1147 ASSERT(pu2StatusCode);
1149 if ((prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) < (CAP_INFO_FIELD_LEN +
1150 STATUS_CODE_FIELD_LEN +
1153 return WLAN_STATUS_FAILURE;
1156 DBGLOG(SAA, LOUD, ("prSwRfb->u2PayloadLength = %d\n", prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen));
1158 prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
1162 return WLAN_STATUS_INVALID_PACKET;
1165 //4 <1> locate the (Re)Assocation Resp Frame.
1166 prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T) prSwRfb->pvHeader;
1168 //4 <2> Parse the Header of (Re)Assocation Resp Frame.
1169 //WLAN_GET_FIELD_16(&prAssocRspFrame->u2FrameCtrl, &u2RxFrameCtrl);
1170 u2RxFrameCtrl = prAssocRspFrame->u2FrameCtrl; // NOTE(Kevin): Optimized for ARM
1171 u2RxFrameCtrl &= MASK_FRAME_TYPE;
1172 if (prStaRec->fgIsReAssoc) {
1173 if (u2RxFrameCtrl != MAC_FRAME_REASSOC_RSP) {
1174 return WLAN_STATUS_FAILURE;
1178 if (u2RxFrameCtrl != MAC_FRAME_ASSOC_RSP) {
1179 return WLAN_STATUS_FAILURE;
1183 //4 <3> Parse the Fixed Fields of (Re)Assocation Resp Frame Body.
1184 //WLAN_GET_FIELD_16(&prAssocRspFrame->u2CapInfo, &u2RxCapInfo);
1185 u2RxCapInfo = prAssocRspFrame->u2CapInfo; // NOTE(Kevin): Optimized for ARM
1187 //WLAN_GET_FIELD_16(&prAssocRspFrame->u2StatusCode, &u2RxStatusCode);
1188 u2RxStatusCode = prAssocRspFrame->u2StatusCode; // NOTE(Kevin): Optimized for ARM
1190 //4 <4> Check CAP_INFO
1191 /* NOTE(Kevin): CM suggest to add MGMT workaround for those APs didn't check
1192 * the CAP Privacy Bit to overcome a corner case that the Privacy Bit
1193 * of our SCAN result didn't consist with AP's Association Resp.
1195 if (u2RxStatusCode == STATUS_CODE_SUCCESSFUL) {
1196 #if CFG_SUPPORT_WAPI
1197 if (prAdapter->rWifiVar.rConnSettings.fgWapiMode) {
1198 /* WAPI AP allow the customer use WZC to join mode, the privacy bit is 0 */
1199 /* even at WAI & WAPI_PSK mode, but the assoc respose set the privacy bit set 1 */
1200 DBGLOG(SEC, TRACE, ("Workaround the WAPI AP allow the customer to use WZC to join\n"));
1204 #if CFG_ENABLE_WIFI_DIRECT
1205 if (prAdapter->fgIsP2PRegistered && 1) {
1206 /* Todo:: Fixed this */
1213 #if CFG_STRICT_CHECK_CAPINFO_PRIVACY
1214 if ((prStaRec->u2CapInfo & CAP_INFO_PRIVACY) ^ (u2RxCapInfo & CAP_INFO_PRIVACY)) {
1215 u2RxStatusCode = STATUS_CODE_CAP_NOT_SUPPORTED;
1220 if (u2RxStatusCode == STATUS_CODE_SUCCESSFUL) {
1221 #if CFG_RSN_MIGRATION
1222 /* Update the information in the structure used to query and set
1223 OID_802_11_ASSOCIATION_INFORMATION. */
1224 kalUpdateReAssocRspInfo(prAdapter->prGlueInfo,
1225 (PUINT_8)&prAssocRspFrame->u2CapInfo,
1226 (UINT_32)(prSwRfb->u2PacketLen));
1230 //4 <5> Update CAP_INFO and ASSOC_ID
1231 if (u2RxStatusCode == STATUS_CODE_SUCCESSFUL) {
1232 prStaRec->u2CapInfo = u2RxCapInfo;
1234 //WLAN_GET_FIELD_16(&prAssocRspFrame->u2AssocId, &u2RxAssocId);
1235 u2RxAssocId = prAssocRspFrame->u2AssocId; // NOTE(Kevin): Optimized for ARM
1237 /* 20110715 Workaround for Kingnet 710 AP (Realtek 8186)
1238 * This AP raises the bit 6&7 not bit 14&15 in AID field.
1239 * It cause wrong AID assignment.
1241 * Normal case: 0xC002(1100 0000 0000 0010) => 2
1242 * Kingnet 710: 0x00C2(0000 0000 1100 0010) => 194
1243 * workaround: mask bit 6&7 for this AP
1245 if((u2RxAssocId & BIT(6)) &&
1246 (u2RxAssocId & BIT(7)) &&
1247 !(u2RxAssocId & BITS(8, 15))) {
1248 prStaRec->u2AssocId = u2RxAssocId & ~BITS(6,7);
1250 prStaRec->u2AssocId = u2RxAssocId & ~AID_MSB;
1251 #if CFG_SUPPORT_802_11W
1252 if (prStaRec->ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) {
1253 P_AIS_SPECIFIC_BSS_INFO_T prBssSpecInfo;
1255 prBssSpecInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
1256 ASSERT(prBssSpecInfo);
1258 prBssSpecInfo->ucSaQueryTimedOut = 0;
1264 #if CFG_SUPPORT_802_11W
1265 if (u2RxStatusCode == STATUS_CODE_AUTH_ALGORITHM_NOT_SUPPORTED){
1266 DBGLOG(SAA, INFO, ("AP rejected due the authentication algorithm not support\n"));
1268 else if (u2RxStatusCode == STATUS_CODE_ASSOC_REJECTED_TEMPORARILY) {
1269 PUINT_8 pucIE, pucTime;
1271 UINT_16 u2Offset = 0;
1273 u2IELength = prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen;
1274 pucIE = (PUINT_8)((UINT_32)prSwRfb->pvHeader + prSwRfb->u2HeaderLen);
1276 IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
1277 if (ELEM_ID_TIMEOUT_INTERVAL == IE_ID(pucIE) && IE_LEN(pucIE) == 5) {
1278 pucTime = ((P_IE_HDR_T)pucIE)->aucInfo;
1279 if (pucTime[0] == ACTION_SA_TIMEOUT_ASSOC_COMEBACK) {
1281 WLAN_GET_FIELD_32(pucTime + 1, &tu);
1282 DBGLOG(SAA, INFO, ("AP rejected association temporarily; comeback duration %u TU "
1283 "(%u ms)\n", tu, TU_TO_MSEC(tu)));
1284 if (tu > TX_ASSOCIATION_RETRY_TIMEOUT_TU) {
1285 DBGLOG(SAA, INFO, ("Update timer based on comeback duration\n"));
1286 //ieee80211_reschedule_timer(wpa_s, ms);
1291 } /* end of IE_FOR_EACH */
1294 *pu2StatusCode = u2RxStatusCode;
1296 return WLAN_STATUS_SUCCESS;
1298 } /* end of assocCheckRxReAssocRspFrameStatus() */
1301 /*----------------------------------------------------------------------------*/
1303 * \brief This function will compose the Disassociation frame
1305 * @param[in] prStaRec Pointer to the STA_RECORD_T
1306 * @param[in] pucBuffer Pointer to the frame buffer.
1307 * @param[in] aucMACAddress Given Our MAC Address.
1308 * @param[in] u2ReasonCode The reason code of disassociation
1312 /*----------------------------------------------------------------------------*/
1314 assocComposeDisassocFrame (
1315 IN P_STA_RECORD_T prStaRec,
1316 IN PUINT_8 pucBuffer,
1317 IN UINT_8 aucMACAddress[],
1318 IN UINT_16 u2ReasonCode
1321 P_WLAN_DISASSOC_FRAME_T prDisAssocFrame;
1322 UINT_16 u2FrameCtrl;
1326 ASSERT(aucMACAddress);
1328 prDisAssocFrame = (P_WLAN_DISASSOC_FRAME_T)pucBuffer;
1330 //4 <1> Compose the frame header of the DisAssociation frame.
1331 /* Fill the Frame Control field. */
1332 u2FrameCtrl = MAC_FRAME_DISASSOC;
1334 WLAN_SET_FIELD_16(&prDisAssocFrame->u2FrameCtrl, u2FrameCtrl);
1336 /* Fill the DA field with Target BSSID. */
1337 COPY_MAC_ADDR(prDisAssocFrame->aucDestAddr, prStaRec->aucMacAddr);
1339 /* Fill the SA field with our MAC Address. */
1340 COPY_MAC_ADDR(prDisAssocFrame->aucSrcAddr, aucMACAddress);
1342 /* Fill the BSSID field with Target BSSID. */
1343 COPY_MAC_ADDR(prDisAssocFrame->aucBSSID, prStaRec->aucMacAddr);
1345 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
1346 prDisAssocFrame->u2SeqCtrl = 0;
1348 //4 <2> Compose the frame body's fixed field part of the Disassociation frame.
1349 /* Fill the Reason Code field. */
1350 WLAN_SET_FIELD_16(&prDisAssocFrame->u2ReasonCode, u2ReasonCode);
1353 } /* end of assocComposeDisassocFrame() */
1356 /*----------------------------------------------------------------------------*/
1358 * @brief This function will send the Disassociation frame
1360 * @param[in] prStaRec Pointer to the STA_RECORD_T
1361 * @param[in] u2ReasonCode The reason code of disassociation
1363 * @retval WLAN_STATUS_RESOURCES No available resource for frame composing.
1364 * @retval WLAN_STATUS_SUCCESS Successfully send frame to TX Module
1366 /*----------------------------------------------------------------------------*/
1368 assocSendDisAssocFrame (
1369 IN P_ADAPTER_T prAdapter,
1370 IN P_STA_RECORD_T prStaRec,
1371 IN UINT_16 u2ReasonCode
1374 PUINT_8 pucMacAddress;
1375 P_MSDU_INFO_T prMsduInfo;
1376 UINT_16 u2PayloadLen;
1377 UINT_16 u2EstimatedFrameLen;
1378 //UINT_32 u4Status = WLAN_STATUS_SUCCESS;
1383 //4 <1> Allocate a PKT_INFO_T for Disassociation Frame
1384 /* Init with MGMT Header Length + Length of Fixed Fields + IE Length */
1385 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + \
1386 WLAN_MAC_MGMT_HEADER_LEN + \
1387 REASON_CODE_FIELD_LEN;
1389 /* Allocate a MSDU_INFO_T */
1390 if ( (prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
1391 DBGLOG(SAA, WARN, ("No PKT_INFO_T for sending DisAssoc.\n"));
1392 return WLAN_STATUS_RESOURCES;
1395 //4 <2> Compose Disassociation frame header and fixed fields in MSDU_INfO_T.
1396 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
1398 pucMacAddress = prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex].aucOwnMacAddr;
1400 /* Compose Header and Fixed Field */
1401 assocComposeDisassocFrame(prStaRec,
1402 (PUINT_8)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
1406 #if CFG_SUPPORT_802_11W
1407 if (rsnCheckBipKeyInstalled(prAdapter, prStaRec)) {
1408 P_WLAN_DISASSOC_FRAME_T prDisassocFrame;
1410 prDisassocFrame = (P_WLAN_DEAUTH_FRAME_T)(PUINT_8)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
1412 prDisassocFrame->u2FrameCtrl |= MASK_FC_PROTECTED_FRAME;
1413 DBGLOG(TX, WARN, ("assocSendDisAssocFrame with protection\n"));
1417 u2PayloadLen = REASON_CODE_FIELD_LEN;
1419 //4 <3> Update information of MSDU_INFO_T
1420 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
1422 prMsduInfo->eSrc = TX_PACKET_MGMT;
1423 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
1424 prMsduInfo->ucStaRecIndex = prStaRec->ucIndex;
1425 prMsduInfo->ucNetworkType = prStaRec->ucNetTypeIndex;
1426 prMsduInfo->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN;
1427 prMsduInfo->fgIs802_1x = FALSE;
1428 prMsduInfo->fgIs802_11 = TRUE;
1429 prMsduInfo->u2FrameLength = WLAN_MAC_MGMT_HEADER_LEN + u2PayloadLen;
1430 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
1431 prMsduInfo->pfTxDoneHandler = NULL;
1432 prMsduInfo->fgIsBasicRate = TRUE;
1434 //4 <4> Enqueue the frame to send this (Re)Association request frame.
1435 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
1437 return WLAN_STATUS_SUCCESS;
1438 } /* end of assocSendDisAssocFrame() */
1441 /*----------------------------------------------------------------------------*/
1443 * @brief This function will parse and process the incoming Disassociation frame
1444 * if the given BSSID is matched.
1446 * @param[in] prSwRfb Pointer to SW RFB data structure.
1447 * @param[in] aucBSSID Given BSSID
1448 * @param[out] pu2ReasonCode Pointer to store the Reason Code from Deauthentication.
1450 * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
1451 * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
1453 /*----------------------------------------------------------------------------*/
1455 assocProcessRxDisassocFrame (
1456 IN P_ADAPTER_T prAdapter,
1457 IN P_SW_RFB_T prSwRfb,
1458 IN UINT_8 aucBSSID[],
1459 OUT PUINT_16 pu2ReasonCode
1462 P_WLAN_DISASSOC_FRAME_T prDisassocFrame;
1463 UINT_16 u2RxReasonCode;
1468 ASSERT(pu2ReasonCode);
1470 //4 <1> locate the Disassociation Frame.
1471 prDisassocFrame = (P_WLAN_DISASSOC_FRAME_T) prSwRfb->pvHeader;
1473 //4 <2> Parse the Header of Disassociation Frame.
1474 if ((prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) < REASON_CODE_FIELD_LEN) {
1476 return WLAN_STATUS_FAILURE;
1479 /* Check if this Disassoc Frame is coming from Target BSSID */
1480 if (UNEQUAL_MAC_ADDR(prDisassocFrame->aucBSSID, aucBSSID)) {
1481 DBGLOG(SAA, LOUD, ("Ignore Disassoc Frame from other BSS ["MACSTR"]\n",
1482 MAC2STR(prDisassocFrame->aucSrcAddr)));
1483 return WLAN_STATUS_FAILURE;
1486 //4 <3> Parse the Fixed Fields of Deauthentication Frame Body.
1487 WLAN_GET_FIELD_16(&prDisassocFrame->u2ReasonCode, &u2RxReasonCode);
1488 *pu2ReasonCode = u2RxReasonCode;
1490 return WLAN_STATUS_SUCCESS;
1492 } /* end of assocProcessRxDisassocFrame() */
1496 /*----------------------------------------------------------------------------*/
1498 * @brief This function will parse and process the incoming Association Req frame
1499 * and return a Status Code.
1501 * @param[in] prAdapter Pointer to the Adapter structure.
1502 * @param[in] prSwRfb Pointer to SW RFB data structure.
1503 * @param[out] pu2StatusCode Pointer to store the Status Code for carried in Association Response.
1505 * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
1506 * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
1508 /*----------------------------------------------------------------------------*/
1510 assocProcessRxAssocReqFrame (
1511 IN P_ADAPTER_T prAdapter,
1512 IN P_SW_RFB_T prSwRfb,
1513 OUT PUINT_16 pu2StatusCode
1516 P_WLAN_ASSOC_REQ_FRAME_T prAssocReqFrame;
1517 P_STA_RECORD_T prStaRec;
1518 P_BSS_INFO_T prBssInfo;
1519 P_IE_SSID_T prIeSsid = (P_IE_SSID_T)NULL;
1520 P_RSN_INFO_ELEM_T prIeRsn = (P_RSN_INFO_ELEM_T)NULL;
1521 P_IE_SUPPORTED_RATE_T prIeSupportedRate = (P_IE_SUPPORTED_RATE_T)NULL;
1522 P_IE_EXT_SUPPORTED_RATE_T prIeExtSupportedRate = (P_IE_EXT_SUPPORTED_RATE_T)NULL;
1523 PUINT_8 pucIE, pucIEStart;
1525 UINT_16 u2Offset = 0;
1526 UINT_16 u2StatusCode = STATUS_CODE_SUCCESSFUL;
1527 UINT_16 u2RxFrameCtrl;
1528 UINT_16 u2BSSBasicRateSet;
1529 BOOLEAN fgIsUnknownBssBasicRate;
1535 ASSERT(pu2StatusCode);
1537 prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
1539 if (prStaRec == NULL) {
1540 return WLAN_STATUS_FAILURE;
1543 //4 <1> locate the Association Req Frame.
1544 prAssocReqFrame = (P_WLAN_ASSOC_REQ_FRAME_T) prSwRfb->pvHeader;
1546 //4 <2> Parse the Header of Association Req Frame.
1547 if ((prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) <
1548 (CAP_INFO_FIELD_LEN + LISTEN_INTERVAL_FIELD_LEN)) {
1550 return WLAN_STATUS_FAILURE;
1553 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
1555 /* Check if this Disassoc Frame is coming from Target BSSID */
1556 if (UNEQUAL_MAC_ADDR(prAssocReqFrame->aucBSSID, prBssInfo->aucBSSID)) {
1557 return WLAN_STATUS_FAILURE; /* Just Ignore this MMPDU */
1560 //WLAN_GET_FIELD_16(&prAssocReqFrame->u2FrameCtrl, &u2RxFrameCtrl);
1561 u2RxFrameCtrl = prAssocReqFrame->u2FrameCtrl; // NOTE(Kevin): Optimized for ARM
1562 u2RxFrameCtrl &= MASK_FRAME_TYPE;
1563 if (MAC_FRAME_REASSOC_REQ == u2RxFrameCtrl) {
1564 prStaRec->fgIsReAssoc = TRUE;
1566 u2IELength = (prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) -
1567 (UINT_16)(OFFSET_OF(WLAN_REASSOC_REQ_FRAME_T, aucInfoElem[0]) - WLAN_MAC_MGMT_HEADER_LEN);
1569 pucIEStart = pucIE = ((P_WLAN_REASSOC_REQ_FRAME_T)(prSwRfb->pvHeader))->aucInfoElem;
1572 prStaRec->fgIsReAssoc = FALSE;
1574 u2IELength = (prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) -
1575 (UINT_16)(OFFSET_OF(WLAN_ASSOC_REQ_FRAME_T, aucInfoElem[0]) - WLAN_MAC_MGMT_HEADER_LEN);
1577 pucIEStart = pucIE = prAssocReqFrame->aucInfoElem;
1581 //4 <3> Parse the Fixed Fields of Assoc Req Frame Body.
1582 prStaRec->u2CapInfo = prAssocReqFrame->u2CapInfo;
1584 #if CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_HOTSPOT_PRIVACY_CHECK
1585 if (prAdapter->fgIsP2PRegistered && IS_STA_IN_P2P(prStaRec)) {
1586 if (((prStaRec->u2CapInfo & CAP_INFO_PRIVACY) &&
1587 !kalP2PGetCipher(prAdapter->prGlueInfo))) {
1588 u2StatusCode = STATUS_CODE_CAP_NOT_SUPPORTED;
1589 DBGLOG(RSN, TRACE, ("STA Assoc req privacy bit check fail\n"));
1590 return WLAN_STATUS_SUCCESS;
1595 prStaRec->u2ListenInterval = prAssocReqFrame->u2ListenInterval;
1596 prStaRec->ucPhyTypeSet = 0;
1598 /* Might be legacy client or p2p gc. */
1599 prStaRec->eStaType = STA_TYPE_LEGACY_CLIENT;
1601 //4 <4> Parse the IE of Assoc Req Frame Body.
1602 IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
1603 switch (IE_ID(pucIE)) {
1605 if ((!prIeSsid) && /* NOTE(Kevin): Get SSID once */
1606 (IE_LEN(pucIE) <= ELEM_MAX_LEN_SSID)) {
1607 prIeSsid = (P_IE_SSID_T)pucIE;
1611 case ELEM_ID_SUP_RATES:
1612 if ((!prIeSupportedRate) && (IE_LEN(pucIE) <= RATE_NUM)) {
1613 prIeSupportedRate = SUP_RATES_IE(pucIE);
1617 case ELEM_ID_EXTENDED_SUP_RATES:
1618 if (!prIeExtSupportedRate)
1619 prIeExtSupportedRate = EXT_SUP_RATES_IE(pucIE);
1621 case ELEM_ID_HT_CAP:
1622 prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_HT;
1623 kalMemCopy(&prStaRec->u2HtCapInfo, &(HT_CAP_IE(pucIE)->u2HtCapInfo), 2);
1626 #if CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_HOTSPOT_PRIVACY_CHECK
1627 if (prAdapter->fgIsP2PRegistered && IS_STA_IN_P2P(prStaRec)) {
1628 prIeRsn = RSN_IE(pucIE);
1629 rsnParserCheckForRSNCCMPPSK(prAdapter, prIeRsn, &u2StatusCode);
1630 if (u2StatusCode != STATUS_CODE_SUCCESSFUL) {
1631 *pu2StatusCode = u2StatusCode;
1632 return WLAN_STATUS_SUCCESS;
1637 case ELEM_ID_VENDOR:
1638 #if CFG_ENABLE_WIFI_DIRECT
1640 if ((prAdapter->fgIsP2PRegistered)) {
1641 UINT_8 ucOuiType = 0;
1643 p2pFuncParseCheckForP2PInfoElem(prAdapter, pucIE, &ucOuiType);
1645 if (ucOuiType == VENDOR_OUI_TYPE_P2P) {
1646 DBGLOG(P2P, TRACE, ("Target Client is a P2P group client\n"));
1647 prStaRec->eStaType = STA_TYPE_P2P_GC;
1654 for (i = 0; i < (sizeof(rxAssocReqIETable) / sizeof(VERIFY_IE_ENTRY_T)); i++) {
1656 if ((IE_ID(pucIE)) == rxAssocReqIETable[i].ucElemID) {
1657 rxAssocReqIETable[i].pfnVarifyIE(prAdapter, prSwRfb, (P_IE_HDR_T)pucIE, &u2StatusCode);
1659 if (u2StatusCode != STATUS_CODE_SUCCESSFUL) {
1660 *pu2StatusCode = u2StatusCode;
1661 return WLAN_STATUS_SUCCESS;
1668 } /* end of IE_FOR_EACH */
1670 // parsing for WMM related information (2010/12/21)
1679 if (UNEQUAL_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen,
1680 prIeSsid->aucSSID, prIeSsid->ucLength)) {
1682 u2StatusCode = STATUS_CODE_UNSPECIFIED_FAILURE;
1687 u2StatusCode = STATUS_CODE_UNSPECIFIED_FAILURE;
1691 prStaRec->u2OperationalRateSet = 0;
1692 prStaRec->u2BSSBasicRateSet = 0;
1694 if (prIeSupportedRate || prIeExtSupportedRate) {
1695 rateGetRateSetFromIEs(prIeSupportedRate,
1696 prIeExtSupportedRate,
1697 &prStaRec->u2OperationalRateSet,
1698 &u2BSSBasicRateSet, /* Ignore any Basic Bit */
1699 &fgIsUnknownBssBasicRate);
1701 if ((prBssInfo->u2BSSBasicRateSet & prStaRec->u2OperationalRateSet) !=
1702 prBssInfo->u2BSSBasicRateSet) {
1704 u2StatusCode = STATUS_CODE_ASSOC_DENIED_RATE_NOT_SUPPORTED;
1708 /* Accpet the Sta, update BSSBasicRateSet from Bss */
1710 prStaRec->u2BSSBasicRateSet = prBssInfo->u2BSSBasicRateSet;
1712 prStaRec->u2DesiredNonHTRateSet = (prStaRec->u2OperationalRateSet & RATE_SET_ALL_ABG);
1714 if (BAND_2G4 == HIF_RX_HDR_GET_RF_BAND(prSwRfb->prHifRxHdr)) {
1715 #if 0 /* Marked by CMC 20111024 */
1716 /* check if support 11n */
1717 if (!(u2BSSBasicRateSet & RATE_SET_BIT_HT_PHY)) {
1719 if (prStaRec->u2OperationalRateSet & RATE_SET_OFDM) {
1720 prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_ERP;
1724 if (!(u2BSSBasicRateSet & RATE_SET_OFDM)) {
1725 if (prStaRec->u2OperationalRateSet & RATE_SET_HR_DSSS) {
1726 prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_HR_DSSS;
1733 if (prStaRec->u2OperationalRateSet & RATE_SET_OFDM) {
1734 prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_ERP;
1736 if (prStaRec->u2OperationalRateSet & RATE_SET_HR_DSSS) {
1737 prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_HR_DSSS;
1741 else { /* (BAND_5G == prBssDesc->eBande) */
1742 #if 0 /* Marked by CMC 20111024 */
1743 if (!(u2BSSBasicRateSet & RATE_SET_BIT_HT_PHY)) {
1745 prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_OFDM;
1747 ASSERT((prStaRec->u2OperationalRateSet & RATE_SET_HR_DSSS) == 0);
1749 if (prStaRec->u2OperationalRateSet & RATE_SET_OFDM) {
1750 prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_OFDM;
1758 u2StatusCode = STATUS_CODE_ASSOC_DENIED_RATE_NOT_SUPPORTED;
1762 #if CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_HOTSPOT_PRIVACY_CHECK
1763 if (prAdapter->fgIsP2PRegistered && IS_STA_IN_P2P(prStaRec)) {
1765 if (!kalP2PGetCipher(prAdapter->prGlueInfo)) {
1766 u2StatusCode = STATUS_CODE_CIPHER_SUITE_REJECTED;
1771 prStaRec->rSecInfo.fgAllowOnly1x = FALSE;
1772 if (kalP2PGetCipher(prAdapter->prGlueInfo)) {
1774 prStaRec->rSecInfo.fgAllowOnly1x = TRUE;
1783 #if CFG_ENABLE_WIFI_DIRECT
1784 if (prAdapter->fgIsP2PRegistered && IS_STA_IN_P2P(prStaRec)) {
1787 PUINT_8 cp = (PUINT_8)&prAssocReqFrame->u2CapInfo;
1788 P_UINT_8 prNewAssocReqIe = NULL;
1791 prNewAssocReqIe= kalMemAlloc(u2IELength, VIR_MEM_TYPE);
1792 if (NULL == prNewAssocReqIe) {
1793 DBGLOG(AIS, WARN, ("allocate memory for (Re)assocReqIe fail,IELength=%d!\n",u2IELength));
1794 u2StatusCode = STATUS_CODE_INVALID_INFO_ELEMENT;
1795 return WLAN_STATUS_FAILURE;
1796 /*note: if return WLAN_STATUS_FAILURE, we wouldn't reply the GC!so he need wait util timeout
1797 should we change to WLAN_STATUS_SUCCESS? but memory allocate fail may also cause reply fail*/
1800 if (prStaRec->fgIsReAssoc)
1804 if (prStaRec->pucAssocReqIe) {
1805 kalMemFree(prStaRec->pucAssocReqIe, VIR_MEM_TYPE, prStaRec->u2AssocReqIeLen);
1806 prStaRec->pucAssocReqIe = NULL;
1808 prStaRec->u2AssocReqIeLen = u2IELength;
1810 prStaRec->pucAssocReqIe = prNewAssocReqIe;
1811 kalMemCopy(prStaRec->pucAssocReqIe, cp, u2IELength);
1815 kalP2PUpdateAssocInfo(prAdapter->prGlueInfo, (PUINT_8)&prAssocReqFrame->u2CapInfo, u2IELength + (prStaRec->fgIsReAssoc ? 10 : 4), prStaRec->fgIsReAssoc);
1819 *pu2StatusCode = u2StatusCode;
1821 return WLAN_STATUS_SUCCESS;
1823 } /* end of assocProcessRxAssocReqFrame() */
1826 /*----------------------------------------------------------------------------*/
1828 * @brief This function is used to compose Common Information Elements for Association
1831 * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
1832 * @param[in] prBssInfo Pointer to the BSS_INFO_T.
1836 /*----------------------------------------------------------------------------*/
1838 assocBuildReAssocRespFrameCommonIEs (
1839 IN P_ADAPTER_T prAdapter,
1840 IN P_MSDU_INFO_T prMsduInfo,
1841 IN P_BSS_INFO_T prBssInfo
1845 P_STA_RECORD_T prStaRec;
1846 UINT_8 ucSupRatesLen;
1847 UINT_8 ucExtSupRatesLen;
1851 ASSERT(prMsduInfo->eSrc == TX_PACKET_MGMT);
1853 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
1857 pucBuffer = (PUINT_8)((UINT_32)prMsduInfo->prPacket +
1858 (UINT_32)prMsduInfo->u2FrameLength);
1861 if (prBssInfo->ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES) {
1863 ucSupRatesLen = ELEM_MAX_LEN_SUP_RATES;
1864 ucExtSupRatesLen = prBssInfo->ucAllSupportedRatesLen - ELEM_MAX_LEN_SUP_RATES;
1867 ucSupRatesLen = prBssInfo->ucAllSupportedRatesLen;
1868 ucExtSupRatesLen = 0;
1871 /* Fill the Supported Rates element. */
1872 if (ucSupRatesLen) {
1873 SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_SUP_RATES;
1874 SUP_RATES_IE(pucBuffer)->ucLength = ucSupRatesLen;
1875 kalMemCopy(SUP_RATES_IE(pucBuffer)->aucSupportedRates,
1876 prBssInfo->aucAllSupportedRates,
1879 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1880 pucBuffer += IE_SIZE(pucBuffer);
1884 /* Fill the Extended Supported Rates element. */
1885 if (ucExtSupRatesLen) {
1887 EXT_SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_EXTENDED_SUP_RATES;
1888 EXT_SUP_RATES_IE(pucBuffer)->ucLength = ucExtSupRatesLen;
1890 kalMemCopy(EXT_SUP_RATES_IE(pucBuffer)->aucExtSupportedRates,
1891 &prBssInfo->aucAllSupportedRates[ucSupRatesLen],
1894 prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
1898 } /* end of assocBuildReAssocRespFrameCommonIEs() */
1901 /*----------------------------------------------------------------------------*/
1903 * @brief This function will compose the (Re)Association Response frame
1905 * @param[in] prStaRec Pointer to the STA_RECORD_T
1906 * @param[in] pucBuffer Pointer to the frame buffer.
1907 * @param[in] aucBssid Given BSSID.
1908 * @param[in] u2CapInfo Capability Field of current BSS.
1909 * @param[in out] pu2PayloadLen Return the length of the composed fixed fields
1913 /*----------------------------------------------------------------------------*/
1915 assocComposeReAssocRespFrameHeaderAndFF (
1916 IN P_STA_RECORD_T prStaRec,
1917 IN PUINT_8 pucBuffer,
1918 IN UINT_8 aucBSSID[],
1919 IN UINT_16 u2CapInfo,
1920 IN OUT PUINT_16 pu2PayloadLen
1923 P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame;
1924 BOOLEAN fgIsReAssoc;
1926 UINT_16 u2FrameCtrl;
1932 ASSERT(pu2PayloadLen);
1934 prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T)pucBuffer;
1935 fgIsReAssoc = prStaRec->fgIsReAssoc;
1937 //4 <1> Compose the frame header of the (Re)Association Request frame.
1938 /* Fill the Frame Control field. */
1940 u2FrameCtrl = MAC_FRAME_REASSOC_RSP;
1943 u2FrameCtrl = MAC_FRAME_ASSOC_RSP;
1945 //WLAN_SET_FIELD_16(&prAssocFrame->u2FrameCtrl, u2FrameCtrl);
1946 prAssocRspFrame->u2FrameCtrl = u2FrameCtrl; // NOTE(Kevin): Optimized for ARM
1948 /* Fill the DA field with Target MAC Address. */
1949 COPY_MAC_ADDR(prAssocRspFrame->aucDestAddr, prStaRec->aucMacAddr);
1951 /* Fill the SA field with current BSSID. */
1952 COPY_MAC_ADDR(prAssocRspFrame->aucSrcAddr, aucBSSID);
1954 /* Fill the BSSID field with current BSSID. */
1955 COPY_MAC_ADDR(prAssocRspFrame->aucBSSID, aucBSSID);
1957 /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
1958 prAssocRspFrame->u2SeqCtrl = 0;
1961 //4 <2> Compose the frame body's common fixed field part of the (Re)Association Request frame.
1962 /* Fill the Capability Information field. */
1963 //WLAN_SET_FIELD_16(&prAssocFrame->u2CapInfo, u2CapInfo);
1964 prAssocRspFrame->u2CapInfo = u2CapInfo; // NOTE(Kevin): Optimized for ARM
1966 //WLAN_SET_FIELD_16(&prAssocFrame->u2StatusCode, prStaRec->u2StatusCode);
1967 prAssocRspFrame->u2StatusCode = prStaRec->u2StatusCode; // NOTE(Kevin): Optimized for ARM
1969 //WLAN_SET_FIELD_16(&prAssocFrame->u2AssocId, ((prStaRec->u2AssocId & AID_MASK) | AID_MSB));
1970 prAssocRspFrame->u2AssocId =
1971 ((prStaRec->u2AssocId & AID_MASK) | AID_MSB); // NOTE(Kevin): Optimized for ARM
1973 *pu2PayloadLen = (CAP_INFO_FIELD_LEN +
1974 STATUS_CODE_FIELD_LEN +
1978 } /* end of assocComposeReAssocRespFrameHeaderAndFF() */
1981 /*----------------------------------------------------------------------------*/
1983 * @brief This function will send the (Re)Association Resp frame
1985 * @param[in] prStaRec Pointer to the STA_RECORD_T
1987 * @retval WLAN_STATUS_RESOURCES No available resource for frame composing.
1988 * @retval WLAN_STATUS_SUCCESS Successfully send frame to TX Module
1990 /*----------------------------------------------------------------------------*/
1992 assocSendReAssocRespFrame (
1993 IN P_ADAPTER_T prAdapter,
1994 IN P_STA_RECORD_T prStaRec
1997 P_BSS_INFO_T prBssInfo;
1998 P_MSDU_INFO_T prMsduInfo;
2000 UINT_16 u2PayloadLen;
2001 UINT_16 u2EstimatedFrameLen;
2002 UINT_16 u2EstimatedExtraIELen;
2003 BOOLEAN fgIsReAssoc;
2010 //4 <1> Allocate a PKT_INFO_T for Authentication Frame
2011 fgIsReAssoc = prStaRec->fgIsReAssoc;
2013 /* Init with MGMT Header Length + Length of Fixed Fields + Common IE Length */
2014 u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + \
2015 WLAN_MAC_MGMT_HEADER_LEN + \
2016 CAP_INFO_FIELD_LEN + \
2017 STATUS_CODE_FIELD_LEN + \
2019 (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) + \
2020 (ELEM_HDR_LEN + (RATE_NUM - ELEM_MAX_LEN_SUP_RATES));
2022 /* + Extra IE Length */
2023 u2EstimatedExtraIELen = 0;
2025 for (i = 0; i < sizeof(txAssocRespIETable)/sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
2026 if (txAssocRespIETable[i].u2EstimatedFixedIELen != 0) {
2027 u2EstimatedExtraIELen += txAssocRespIETable[i].u2EstimatedFixedIELen;
2029 else if (txAssocRespIETable[i].pfnCalculateVariableIELen != NULL) {
2030 u2EstimatedExtraIELen += (UINT_16)txAssocRespIETable[i].pfnCalculateVariableIELen(prAdapter,
2031 prStaRec->ucNetTypeIndex,
2037 u2EstimatedFrameLen += u2EstimatedExtraIELen;
2039 /* Allocate a MSDU_INFO_T */
2040 if ( (prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen)) == NULL) {
2041 DBGLOG(AAA, WARN, ("No PKT_INFO_T for sending (Re)Assoc Response.\n"));
2042 return WLAN_STATUS_RESOURCES;
2045 //4 <2> Compose (Re)Association Request frame header and fixed fields in MSDU_INfO_T.
2046 ASSERT(prStaRec->ucNetTypeIndex != NETWORK_TYPE_AIS_INDEX);
2047 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
2049 /* Compose Header and Fixed Field */
2050 assocComposeReAssocRespFrameHeaderAndFF(prStaRec,
2051 (PUINT_8)((UINT_32)(prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
2052 prBssInfo->aucBSSID,
2053 prBssInfo->u2CapInfo,
2056 //4 <3> Update information of MSDU_INFO_T
2057 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
2059 prMsduInfo->eSrc = TX_PACKET_MGMT;
2060 prMsduInfo->ucPacketType = HIF_TX_PACKET_TYPE_MGMT;
2061 prMsduInfo->ucStaRecIndex = prStaRec->ucIndex;
2062 prMsduInfo->ucNetworkType = prStaRec->ucNetTypeIndex;
2063 prMsduInfo->ucMacHeaderLength = WLAN_MAC_MGMT_HEADER_LEN;
2064 prMsduInfo->fgIs802_1x = FALSE;
2065 prMsduInfo->fgIs802_11 = TRUE;
2066 prMsduInfo->u2FrameLength = WLAN_MAC_MGMT_HEADER_LEN + u2PayloadLen;
2067 prMsduInfo->ucTxSeqNum = nicIncreaseTxSeqNum(prAdapter);
2068 prMsduInfo->pfTxDoneHandler = aaaFsmRunEventTxDone;
2069 prMsduInfo->fgIsBasicRate = TRUE;
2071 //4 <4> Compose the frame body's IEs of the (Re)Association Request frame.
2072 assocBuildReAssocRespFrameCommonIEs(prAdapter, prMsduInfo, prBssInfo);
2075 //4 <5> Compose IEs in MSDU_INFO_T
2078 for (i = 0; i < sizeof(txAssocRespIETable)/sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
2079 if (txAssocRespIETable[i].pfnAppendIE) {
2080 txAssocRespIETable[i].pfnAppendIE(prAdapter, prMsduInfo);
2084 /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
2086 //4 <6> Enqueue the frame to send this (Re)Association request frame.
2087 nicTxEnqueueMsdu(prAdapter, prMsduInfo);
2089 return WLAN_STATUS_SUCCESS;
2091 } /* end of assocSendReAssocRespFrame() */
2092 #endif /* CFG_SUPPORT_AAA */