2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/sec_fsm.c#1 $
6 \brief This is the file implement security check state machine.
8 In security module, do the port control check after success join to an AP,
9 and the path to NORMAL TR, the state machine handle these state transition.
18 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
19 * Adjust code for DBG and CONFIG_XLOG.
22 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
23 * modify the xlog related code.
26 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
27 * change the debug module level.
30 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
31 * adding the code for XLOG.
34 * [WCXRP00000248] [MT6620 Wi-Fi][FW]Fixed the Klockwork error
35 * fixed the kclocwork error.
37 * 01 26 2011 yuche.tsai
38 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
41 * 01 25 2011 yuche.tsai
42 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
43 * Fix Compile Error when DBG is disabled.
45 * 01 25 2011 yuche.tsai
46 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
47 * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
50 * [WCXRP00000072] [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue
51 * [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue.
55 * [WCXRP00005002][MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning.
57 * 09 03 2010 kevin.huang
59 * Refine #include sequence and solve recursive/nested #include issue
63 * adding the eapol callback setting.
67 * adding the tx pkt call back handle for countermeasure.
71 * fixed the compilng error at debug mode.
75 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
78 * [WPD00003840][MT6620 5931] Security migration
79 * modify some code for concurrent network.
82 * [WPD00003840][MT6620 5931] Security migration
83 * consdier the concurrent network setting.
86 * [BORA00000626][MT6620] Refine the remove key flow for WHQL testing
87 * fixed the ad-hoc wpa-none send non-encrypted frame issue.
89 * 05 24 2010 kevin.huang
90 * [BORA00000794][WIFISYS][New Feature]Power Management Support
91 * Refine authSendAuthFrame() for NULL STA_RECORD_T case and minimum deauth interval.
94 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
95 * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
98 * [BORA00000680][MT6620] Support the statistic for Microsoft os query
99 * fixed the Klocwork error and refine the class error message.
102 * [BORA00000637][MT6620 Wi-Fi] [Bug] WPA2 pre-authentication timer not correctly initialize
103 * move the AIS specific variable for security to AIS specific structure.
106 * [BORA00000637][MT6620 Wi-Fi] [Bug] WPA2 pre-authentication timer not correctly initialize
107 * Fixed the pre-authentication timer not correctly init issue, and modify the security related callback function prototype.
110 * [BORA00000605][WIFISYS] Phase3 Integration
111 * Refine the variable and parameter for security.
114 * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
115 * add and fixed some security function.
118 * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
119 * fixed the compiling warning
121 * 12 18 2009 cm.chang
122 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
125 * Dec 7 2009 mtk01088
126 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
129 * Dec 4 2009 mtk01088
130 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
133 * Dec 1 2009 mtk01088
134 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
137 * Nov 23 2009 mtk01088
138 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
139 * adjust the function name
141 * Nov 19 2009 mtk01088
142 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
143 * adjust the state machine, to meet the firmware security design v1.1
145 * Nov 18 2009 mtk01088
146 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
151 /*******************************************************************************
152 * C O M P I L E R F L A G S
153 ********************************************************************************
156 /*******************************************************************************
157 * E X T E R N A L R E F E R E N C E S
158 ********************************************************************************
162 #if CFG_RSN_MIGRATION
164 /*******************************************************************************
166 ********************************************************************************
169 /*******************************************************************************
171 ********************************************************************************
174 /*******************************************************************************
175 * P U B L I C D A T A
176 ********************************************************************************
179 /*******************************************************************************
180 * P R I V A T E D A T A
181 ********************************************************************************
184 /*lint -save -e64 Type mismatch */
185 static PUINT_8 apucDebugSecState
[SEC_STATE_NUM
] = {
186 (PUINT_8
) DISP_STRING("SEC_STATE_INIT"),
187 (PUINT_8
) DISP_STRING("SEC_STATE_INITIATOR_PORT_BLOCKED"),
188 (PUINT_8
) DISP_STRING("SEC_STATE_RESPONDER_PORT_BLOCKED"),
189 (PUINT_8
) DISP_STRING("SEC_STATE_CHECK_OK"),
190 (PUINT_8
) DISP_STRING("SEC_STATE_SEND_EAPOL"),
191 (PUINT_8
) DISP_STRING("SEC_STATE_SEND_DEAUTH"),
192 (PUINT_8
) DISP_STRING("SEC_STATE_COUNTERMEASURE"),
198 /*******************************************************************************
200 ********************************************************************************
203 /*******************************************************************************
204 * F U N C T I O N D E C L A R A T I O N S
205 ********************************************************************************
208 /*******************************************************************************
210 ********************************************************************************
213 /*----------------------------------------------------------------------------*/
215 * \brief This function will do initialization of Security FSM and all variables in
218 * \param[in] prSta Pointer to the STA record
222 /*----------------------------------------------------------------------------*/
223 VOID
secFsmInit(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
225 P_SEC_INFO_T prSecInfo
;
226 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecBssInfo
;
230 prSecInfo
= &prSta
->rSecInfo
;
233 /* At MT5921, is ok, but at MT6620, firmware base ASIC, the firmware */
234 /* will lost these data, thus, driver have to keep the wep material and */
235 /* setting to firmware while awake from D3. */
238 prSecInfo
->eCurrentState
= SEC_STATE_INIT
;
240 prSecInfo
->fg2nd1xSend
= FALSE
;
241 prSecInfo
->fgKeyStored
= FALSE
;
243 if (IS_STA_IN_AIS(prSta
)) {
244 prAisSpecBssInfo
= &prAdapter
->rWifiVar
.rAisSpecificBssInfo
;
246 prAisSpecBssInfo
->u4RsnaLastMICFailTime
= 0;
247 prAisSpecBssInfo
->fgCheckEAPoLTxDone
= FALSE
;
249 cnmTimerInitTimer(prAdapter
,
250 &prAdapter
->rWifiVar
.rAisSpecificBssInfo
.
251 rRsnaEAPoLReportTimeoutTimer
,
252 (PFN_MGMT_TIMEOUT_FUNC
) secFsmEventEapolTxTimeout
,
255 cnmTimerInitTimer(prAdapter
,
256 &prAdapter
->rWifiVar
.rAisSpecificBssInfo
.rRsnaBlockTrafficTimer
,
257 (PFN_MGMT_TIMEOUT_FUNC
) secFsmEventEndOfCounterMeasure
,
265 /*----------------------------------------------------------------------------*/
267 * \brief This function will do uninitialization of Security FSM and all variables in
270 * \param[in] prSta Pointer to the STA record
274 /*----------------------------------------------------------------------------*/
275 VOID
/* whsu:Todo: */
276 secFsmUnInit(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
278 P_SEC_INFO_T prSecInfo
;
282 prSecInfo
= &prSta
->rSecInfo
;
284 prSecInfo
->fg2nd1xSend
= FALSE
;
285 prSecInfo
->fgKeyStored
= FALSE
;
287 /* nicPrivacyRemoveWlanTable(prSta->ucWTEntry); */
289 if (IS_STA_IN_AIS(prSta
)) {
290 cnmTimerStopTimer(prAdapter
,
291 &prAdapter
->rWifiVar
.rAisSpecificBssInfo
.
292 rRsnaEAPoLReportTimeoutTimer
);
293 cnmTimerStopTimer(prAdapter
,
294 &prAdapter
->rWifiVar
.rAisSpecificBssInfo
.rRsnaBlockTrafficTimer
);
300 /*----------------------------------------------------------------------------*/
302 * \brief This function will do action part while in STATE transition of
303 * STANDBY to CHECK_OK.
305 * \param[in] prSta Pointer to the Sta record
309 /*----------------------------------------------------------------------------*/
310 __KAL_INLINE__ VOID
secFsmTrans_INIT_to_CHECK_OK(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
312 secSetPortBlocked(prAdapter
, prSta
, FALSE
);
318 /*----------------------------------------------------------------------------*/
320 * \brief This function will do action part while in STATE transition of
321 * INIT to INITIATOR_PORT_BLOCKED.
323 * \param[in] prSta Pointer to the Sta record
327 /*----------------------------------------------------------------------------*/
329 secFsmTrans_INIT_to_INITIATOR_PORT_BLOCKED(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
336 /*----------------------------------------------------------------------------*/
338 * \brief This function will do action part while in STATE transition of
339 * INIT to RESPONDER_PORT_BLOCKED.
341 * \param[in] prSta Pointer to the Sta record
345 /*----------------------------------------------------------------------------*/
347 secFsmTrans_INIT_to_RESPONDER_PORT_BLOCKED(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
353 /*----------------------------------------------------------------------------*/
355 * \brief This function will do action part while in STATE transition of
356 * INITIATOR_PORT_BLOCKED to CHECK_OK.
358 * \param[in] prSta Pointer to the Sta record
362 /*----------------------------------------------------------------------------*/
364 secFsmTrans_INITIATOR_PORT_BLOCKED_to_CHECK_OK(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
366 secSetPortBlocked(prAdapter
, prSta
, FALSE
);
371 /*----------------------------------------------------------------------------*/
373 * \brief This function will do action part while in STATE transition of
374 * RESPONDER_PORT_BLOCKED to CHECK_OK.
376 * \param[in] prSta Pointer to the Sta record
380 /*----------------------------------------------------------------------------*/
382 secFsmTrans_RESPONDER_PORT_BLOCKED_to_CHECK_OK(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
384 secSetPortBlocked(prAdapter
, prSta
, FALSE
);
389 /*----------------------------------------------------------------------------*/
391 * \brief This function will do action part while in STATE transition of
392 * CHECK_OK to SEND_EAPOL
394 * \param[in] prSta Pointer to the Sta record
398 /*----------------------------------------------------------------------------*/
400 secFsmTrans_CHECK_OK_to_SEND_EAPOL(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
403 P_AIS_SPECIFIC_BSS_INFO_T prAisBssInfo
;
409 prAisBssInfo
= &prAdapter
->rWifiVar
.rAisSpecificBssInfo
;
411 ASSERT(prAisBssInfo
);
413 if (!IS_STA_IN_AIS(prSta
)) {
414 DBGLOG(RSN
, INFO
, ("Counter Measure should occur at AIS network!!\n"));
419 prAisBssInfo
->fgCheckEAPoLTxDone
= TRUE
;
421 /* cnmTimerStartTimer(prAdapter, */
422 /* &prAisBssInfo->rRsnaEAPoLReportTimeoutTimer, */
423 /* SEC_TO_MSEC(EAPOL_REPORT_SEND_TIMEOUT_INTERVAL_SEC)); */
429 /*----------------------------------------------------------------------------*/
431 * \brief This function will do action part while in STATE transition of
432 * SEND_EAPOL to SEND_DEAUTH.
434 * \param[in] prSta Pointer to the Sta record
438 /*----------------------------------------------------------------------------*/
440 secFsmTrans_SEND_EAPOL_to_SEND_DEAUTH(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
443 if (!IS_STA_IN_AIS(prSta
)) {
444 DBGLOG(RSN
, INFO
, ("Counter Measure should occur at AIS network!!\n"));
449 /* Compose deauth frame to AP, a call back function for tx done */
450 if (authSendDeauthFrame(prAdapter
,
453 REASON_CODE_MIC_FAILURE
,
454 (PFN_TX_DONE_HANDLER
) secFsmEventDeauthTxDone
) !=
455 WLAN_STATUS_SUCCESS
) {
461 /*----------------------------------------------------------------------------*/
463 * \brief This function will do action part while in STATE transition of
464 * SEND_DEAUTH to COUNTERMEASURE.
466 * \param[in] prSta Pointer to the Sta record
470 /*----------------------------------------------------------------------------*/
472 secFsmTrans_SEND_DEAUTH_to_COUNTERMEASURE(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
477 if (!IS_STA_IN_AIS(prSta
)) {
478 DBGLOG(RSN
, INFO
, ("Counter Measure should occur at AIS network!!\n"));
482 /* Start the 60 sec timer */
483 cnmTimerStartTimer(prAdapter
,
484 &prAdapter
->rWifiVar
.rAisSpecificBssInfo
.rRsnaBlockTrafficTimer
,
485 SEC_TO_MSEC(COUNTER_MEASURE_TIMEOUT_INTERVAL_SEC
));
490 /*----------------------------------------------------------------------------*/
492 * \brief This function will do action part while in STATE transition of
493 * SEND_DEAUTH to COUNTERMEASURE.
495 * \param[in] prSta Pointer to the Sta record
499 /*----------------------------------------------------------------------------*/
501 secFsmTrans_COUNTERMEASURE_to_INIT(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
504 /* Clear the counter measure flag */
508 /*----------------------------------------------------------------------------*/
510 * \brief The Core FSM engine of security module.
512 * \param[in] prSta Pointer to the Sta record
513 * \param[in] eNextState Enum value of next sec STATE
517 /*----------------------------------------------------------------------------*/
518 VOID
secFsmSteps(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
, IN ENUM_SEC_STATE_T eNextState
)
520 P_SEC_INFO_T prSecInfo
;
521 BOOLEAN fgIsTransition
= (BOOLEAN
) FALSE
;
525 prSecInfo
= &prSta
->rSecInfo
;
528 DEBUGFUNC("secFsmSteps");
530 /* Do entering Next State */
531 prSecInfo
->ePreviousState
= prSecInfo
->eCurrentState
;
533 /* Do entering Next State */
535 DBGLOG(RSN
, STATE
, ("\n" MACSTR
" TRANSITION: [%s] -> [%s]\n\n",
536 MAC2STR(prSta
->aucMacAddr
),
537 apucDebugSecState
[prSecInfo
->eCurrentState
],
538 apucDebugSecState
[eNextState
]));
540 DBGLOG(RSN
, STATE
, ("\n" MACSTR
" [%d] TRANSITION: [%d] -> [%d]\n\n",
541 MAC2STR(prSta
->aucMacAddr
),
542 DBG_RSN_IDX
, prSecInfo
->eCurrentState
, eNextState
));
544 prSecInfo
->eCurrentState
= eNextState
;
546 fgIsTransition
= (BOOLEAN
) FALSE
;
548 /* Do tasks of the State that we just entered */
549 switch (prSecInfo
->eCurrentState
) {
552 case SEC_STATE_INITIATOR_PORT_BLOCKED
:
554 case SEC_STATE_RESPONDER_PORT_BLOCKED
:
556 case SEC_STATE_CHECK_OK
:
558 case SEC_STATE_SEND_EAPOL
:
560 case SEC_STATE_SEND_DEAUTH
:
562 case SEC_STATE_COUNTERMEASURE
:
565 ASSERT(0); /* Make sure we have handle all STATEs */
570 while (fgIsTransition
);
577 /*----------------------------------------------------------------------------*/
579 * \brief This function will do initialization of Security FSM and all variables in
582 * \param[in] prSta Pointer to the Sta record
586 /*----------------------------------------------------------------------------*/
587 VOID
secFsmEventStart(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
589 P_SEC_INFO_T prSecInfo
;
590 BOOLEAN fgIsTransition
= (BOOLEAN
) FALSE
;
591 ENUM_SEC_STATE_T eNextState
;
593 DBGLOG(RSN
, TRACE
, ("secFsmRunEventStart\n"));
600 if (!IS_STA_IN_AIS(prSta
))
603 DBGLOG(RSN
, TRACE
, ("secFsmRunEventStart for sta " MACSTR
" network %d\n",
604 MAC2STR(prSta
->aucMacAddr
), prSta
->ucNetTypeIndex
));
606 prSecInfo
= (P_SEC_INFO_T
) &prSta
->rSecInfo
;
608 eNextState
= prSecInfo
->eCurrentState
;
610 secSetPortBlocked(prAdapter
, prSta
, TRUE
);
612 /* prSta->fgTransmitKeyExist = FALSE; */
613 /* whsu:: nicPrivacySetStaDefaultWTIdx(prSta); */
615 #if 1 /* Since the 1x and key can set to firmware in order, always enter the check ok state */
616 SEC_STATE_TRANSITION(prAdapter
, prSta
, INIT
, CHECK_OK
);
618 if (IS_STA_IN_AIS(prSta
->eStaType
)) {
619 if (secRsnKeyHandshakeEnabled(prAdapter
) == TRUE
621 || (prAdapter
->rWifiVar
.rConnSettings
.fgWapiMode
)
624 prSta
->fgTransmitKeyExist
= FALSE
;
625 /* nicPrivacyInitialize(prSta->ucNetTypeIndex); */
626 SEC_STATE_TRANSITION(prAdapter
, prSta
, INIT
, INITIATOR_PORT_BLOCKED
);
628 SEC_STATE_TRANSITION(prAdapter
, prSta
, INIT
, CHECK_OK
);
631 #if CFG_ENABLE_WIFI_DIRECT || CFG_ENABLE_BT_OVER_WIFI
632 #if CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_BT_OVER_WIFI
633 else if ((prSta
->eStaType
== STA_TYPE_BOW_CLIENT
) || (prSta
->eStaType
== STA_TYPE_P2P_GC
))
634 #elif CFG_ENABLE_WIFI_DIRECT
635 else if (prSta
->eStaType
== STA_TYPE_P2P_GC
)
636 #elif CFG_ENABLE_BT_OVER_WIFI
637 else if (prSta
->eStaType
== STA_TYPE_BOW_CLIENT
)
640 SEC_STATE_TRANSITION(prAdapter
, prSta
, INIT
, RESPONDER_PORT_BLOCKED
);
644 SEC_STATE_TRANSITION(prAdapter
, prSta
, INIT
, INITIATOR_PORT_BLOCKED
);
647 if (prSecInfo
->eCurrentState
!= eNextState
) {
648 secFsmSteps(prAdapter
, prSta
, eNextState
);
652 } /* secFsmRunEventStart */
655 /*----------------------------------------------------------------------------*/
657 * \brief This function called by reset procedure to force the sec fsm enter
660 * \param[in] ucNetTypeIdx The Specific Network type index
661 * \param[in] prSta Pointer to the Sta record
665 /*----------------------------------------------------------------------------*/
666 VOID
secFsmEventAbort(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
668 P_SEC_INFO_T prSecInfo
;
670 DBGLOG(RSN
, TRACE
, ("secFsmEventAbort for sta " MACSTR
" network %d\n",
671 MAC2STR(prSta
->aucMacAddr
), prSta
->ucNetTypeIndex
));
678 if (!IS_STA_IN_AIS(prSta
))
681 prSecInfo
= (P_SEC_INFO_T
) &prSta
->rSecInfo
;
683 prSta
->fgTransmitKeyExist
= FALSE
;
685 secSetPortBlocked(prAdapter
, prSta
, TRUE
);
687 if (prSecInfo
== NULL
)
690 if (IS_STA_IN_AIS(prSta
)) {
692 prAdapter
->rWifiVar
.rAisSpecificBssInfo
.fgTransmitKeyExist
= FALSE
;
694 if (prSecInfo
->eCurrentState
== SEC_STATE_SEND_EAPOL
) {
695 if (prAdapter
->rWifiVar
.rAisSpecificBssInfo
.fgCheckEAPoLTxDone
== FALSE
) {
696 DBGLOG(RSN
, TRACE
, ("EAPOL STATE not match the flag\n"));
697 /* cnmTimerStopTimer(prAdapter, &prAdapter->rWifiVar.rAisSpecificBssInfo.rRsnaEAPoLReportTimeoutTimer); */
701 prSecInfo
->eCurrentState
= SEC_STATE_INIT
;
705 /*----------------------------------------------------------------------------*/
707 * \brief This function will indicate an Event of "2nd EAPoL Tx is sending" to Sec FSM.
709 * \param[in] prSta Pointer to the Sta record
713 /*----------------------------------------------------------------------------*/
714 VOID
secFsmEvent2ndEapolTx(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
716 P_SEC_INFO_T prSecInfo
;
717 ENUM_SEC_STATE_T eNextState
;
718 /* BOOLEAN fgIsTransition = (BOOLEAN)FALSE; */
720 DEBUGFUNC("secFsmRunEvent2ndEapolTx");
724 prSecInfo
= &prSta
->rSecInfo
;
725 eNextState
= prSecInfo
->eCurrentState
;
728 DBGLOG(RSN
, TRACE
, (MACSTR
" Sec state %s\n", MAC2STR(prSta
->aucMacAddr
),
729 apucDebugSecState
[prSecInfo
->eCurrentState
]));
732 (MACSTR
" Sec state [%d]\n", MAC2STR(prSta
->aucMacAddr
), prSecInfo
->eCurrentState
));
735 switch (prSecInfo
->eCurrentState
) {
736 case SEC_STATE_INITIATOR_PORT_BLOCKED
:
737 case SEC_STATE_CHECK_OK
:
738 prSecInfo
->fg2nd1xSend
= TRUE
;
743 ("Rcv 2nd EAPoL at %s\n", apucDebugSecState
[prSecInfo
->eCurrentState
]));
745 DBGLOG(RSN
, WARN
, ("Rcv 2nd EAPoL at [%d]\n", prSecInfo
->eCurrentState
));
750 if (prSecInfo
->eCurrentState
!= eNextState
) {
751 secFsmSteps(prAdapter
, prSta
, eNextState
);
756 } /* secFsmRunEvent2ndEapolTx */
759 /*----------------------------------------------------------------------------*/
761 * \brief This function will indicate an Event of "4th EAPoL Tx is Tx done" to Sec FSM.
763 * \param[in] prSta Pointer to the Sta record
767 /*----------------------------------------------------------------------------*/
768 VOID
secFsmEvent4ndEapolTxDone(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
770 P_SEC_INFO_T prSecInfo
;
771 ENUM_SEC_STATE_T eNextState
;
772 BOOLEAN fgIsTransition
= (BOOLEAN
) FALSE
;
773 P_CMD_802_11_KEY prStoredKey
;
775 DEBUGFUNC("secFsmRunEvent4ndEapolTx");
779 prSecInfo
= &prSta
->rSecInfo
;
780 eNextState
= prSecInfo
->eCurrentState
;
783 DBGLOG(RSN
, TRACE
, (MACSTR
" Sec state %s\n", MAC2STR(prSta
->aucMacAddr
),
784 apucDebugSecState
[prSecInfo
->eCurrentState
]));
787 (MACSTR
" Sec state [%d]\n", MAC2STR(prSta
->aucMacAddr
), prSecInfo
->eCurrentState
));
790 switch (prSecInfo
->eCurrentState
) {
791 case SEC_STATE_INITIATOR_PORT_BLOCKED
:
792 case SEC_STATE_CHECK_OK
:
793 prSecInfo
->fg2nd1xSend
= FALSE
;
794 if (prSecInfo
->fgKeyStored
) {
795 prStoredKey
= (P_CMD_802_11_KEY
) prSecInfo
->aucStoredKey
;
797 /* prSta = rxmLookupStaRecIndexFromTA(prStoredKey->aucPeerAddr); */
798 /* if (nicPrivacySetKeyEntry(prStoredKey, prSta->ucWTEntry) == FALSE) */
799 /* DBGLOG(RSN, WARN, ("nicPrivacySetKeyEntry() fail,..\n")); */
802 prSecInfo
->fgKeyStored
= FALSE
;
803 prSta
->fgTransmitKeyExist
= TRUE
;
805 if (prSecInfo
->eCurrentState
== SEC_STATE_INITIATOR_PORT_BLOCKED
) {
806 SEC_STATE_TRANSITION(prAdapter
, prSta
, INITIATOR_PORT_BLOCKED
, CHECK_OK
);
813 ("Rcv thh EAPoL Tx done at %s\n",
814 apucDebugSecState
[prSecInfo
->eCurrentState
]));
816 DBGLOG(RSN
, WARN
, ("Rcv thh EAPoL Tx done at [%d]\n", prSecInfo
->eCurrentState
));
821 if (prSecInfo
->eCurrentState
!= eNextState
) {
822 secFsmSteps(prAdapter
, prSta
, eNextState
);
827 } /* secFsmRunEvent4ndEapolTx */
830 /*----------------------------------------------------------------------------*/
832 * \brief This function will indicate an Event of "Pairwise key installed" to SEC FSM.
834 * \param[in] prSta Pointer to the Sta record
836 * \retval TRUE The key can be installed to HW
837 * \retval FALSE The kay conflict with the current key, abort it
839 /*----------------------------------------------------------------------------*/
840 BOOLEAN
secFsmEventPTKInstalled(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
842 P_SEC_INFO_T prSecInfo
;
843 ENUM_SEC_STATE_T eNextState
;
844 BOOLEAN fgStatus
= TRUE
;
845 BOOLEAN fgIsTransition
= (BOOLEAN
) FALSE
;
849 prSecInfo
= &prSta
->rSecInfo
;
850 if (prSecInfo
== NULL
)
851 return TRUE
; /* Not PTK */
854 DBGLOG(RSN
, TRACE
, (MACSTR
" Sec state %s\n", MAC2STR(prSta
->aucMacAddr
),
855 apucDebugSecState
[prSecInfo
->eCurrentState
]));
858 (MACSTR
" Sec state [%d]\n", MAC2STR(prSta
->aucMacAddr
), prSecInfo
->eCurrentState
));
861 eNextState
= prSecInfo
->eCurrentState
;
863 switch (prSecInfo
->eCurrentState
) {
865 /* Legacy wep, wpa-none */
868 case SEC_STATE_INITIATOR_PORT_BLOCKED
:
869 if (prSecInfo
->fg2nd1xSend
) {
871 SEC_STATE_TRANSITION(prAdapter
, prSta
, INITIATOR_PORT_BLOCKED
, CHECK_OK
);
875 case SEC_STATE_RESPONDER_PORT_BLOCKED
:
876 SEC_STATE_TRANSITION(prAdapter
, prSta
, RESPONDER_PORT_BLOCKED
, CHECK_OK
);
880 case SEC_STATE_CHECK_OK
:
888 if (prSecInfo
->eCurrentState
!= eNextState
) {
889 secFsmSteps(prAdapter
, prSta
, eNextState
);
894 } /* end of secFsmRunEventPTKInstalled() */
897 /*----------------------------------------------------------------------------*/
899 * \brief This function will indicate an Event of "Counter Measure" to SEC FSM.
901 * \param[in] prSta Pointer to the Sta record
905 /*----------------------------------------------------------------------------*/
906 VOID
secFsmEventStartCounterMeasure(IN P_ADAPTER_T prAdapter
, IN P_STA_RECORD_T prSta
)
908 P_SEC_INFO_T prSecInfo
;
909 ENUM_SEC_STATE_T eNextState
;
910 BOOLEAN fgIsTransition
= (BOOLEAN
) FALSE
;
912 DEBUGFUNC("secFsmRunEventStartCounterMeasure");
916 if (!IS_STA_IN_AIS(prSta
)) {
917 DBGLOG(RSN
, INFO
, ("Counter Measure should occur at AIS network!!\n"));
922 prSecInfo
= &prSta
->rSecInfo
;
924 eNextState
= prSecInfo
->eCurrentState
;
927 DBGLOG(RSN
, TRACE
, (MACSTR
" Sec state %s\n", MAC2STR(prSta
->aucMacAddr
),
928 apucDebugSecState
[prSecInfo
->eCurrentState
]));
931 (MACSTR
" Sec state [%d]\n", MAC2STR(prSta
->aucMacAddr
), prSecInfo
->eCurrentState
));
934 prAdapter
->rWifiVar
.rAisSpecificBssInfo
.u4RsnaLastMICFailTime
= 0;
936 switch (prSecInfo
->eCurrentState
) {
937 case SEC_STATE_CHECK_OK
:
939 prAdapter
->rWifiVar
.rAisSpecificBssInfo
.fgCounterMeasure
= TRUE
;
941 /* <Todo> dls port control */
942 SEC_STATE_TRANSITION(prAdapter
, prSta
, CHECK_OK
, SEND_EAPOL
);
950 /* Call arbFsmSteps() when we are going to change ARB STATE */
951 if (prSecInfo
->eCurrentState
!= eNextState
) {
952 secFsmSteps(prAdapter
, prSta
, eNextState
);
957 } /* secFsmRunEventStartCounterMeasure */
960 /*----------------------------------------------------------------------------*/
962 * \brief This function will indicate an Event of "802.1x EAPoL Tx Done" to Sec FSM.
964 * \param[in] prSta Pointer to the Sta record
968 /*----------------------------------------------------------------------------*/
970 secFsmEventEapolTxDone(IN P_ADAPTER_T prAdapter
,
971 IN P_STA_RECORD_T prStaRec
, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus
)
973 P_SEC_INFO_T prSecInfo
;
974 ENUM_SEC_STATE_T eNextState
;
975 BOOLEAN fgIsTransition
= (BOOLEAN
) FALSE
;
976 P_AIS_SPECIFIC_BSS_INFO_T prAisBssInfo
;
978 DEBUGFUNC("secFsmRunEventEapolTxDone");
982 if (rTxDoneStatus
!= TX_RESULT_SUCCESS
) {
983 DBGLOG(RSN
, INFO
, ("Error EAPoL fram fail to send!!\n"));
988 if (!IS_STA_IN_AIS(prStaRec
)) {
989 DBGLOG(RSN
, INFO
, ("Counter Measure should occur at AIS network!!\n"));
994 prAisBssInfo
= &prAdapter
->rWifiVar
.rAisSpecificBssInfo
;
996 ASSERT(prAisBssInfo
);
998 prSecInfo
= &prStaRec
->rSecInfo
;
999 eNextState
= prSecInfo
->eCurrentState
;
1002 DBGLOG(RSN
, TRACE
, (MACSTR
" Sec state %s\n", MAC2STR(prStaRec
->aucMacAddr
),
1003 apucDebugSecState
[prSecInfo
->eCurrentState
]));
1006 (MACSTR
" Sec state [%d]\n", MAC2STR(prStaRec
->aucMacAddr
),
1007 prSecInfo
->eCurrentState
));
1010 switch (prSecInfo
->eCurrentState
) {
1011 case SEC_STATE_SEND_EAPOL
:
1012 if (prAisBssInfo
->fgCheckEAPoLTxDone
== FALSE
) {
1016 prAisBssInfo
->fgCheckEAPoLTxDone
= FALSE
;
1017 /* cnmTimerStopTimer(prAdapter, &prAisBssInfo->rRsnaEAPoLReportTimeoutTimer); */
1019 SEC_STATE_TRANSITION(prAdapter
, prStaRec
, SEND_EAPOL
, SEND_DEAUTH
);
1025 if (prSecInfo
->eCurrentState
!= eNextState
) {
1026 secFsmSteps(prAdapter
, prStaRec
, eNextState
);
1031 } /* secFsmRunEventEapolTxDone */
1034 /*----------------------------------------------------------------------------*/
1036 * \brief This function will indicate an Event of "Deauth frame Tx Done" to Sec FSM.
1038 * \param[in] pMsduInfo Pointer to the Msdu Info
1039 * \param[in] rStatus The Tx done status
1043 * \note after receive deauth frame, callback function call this
1045 /*----------------------------------------------------------------------------*/
1047 secFsmEventDeauthTxDone(IN P_ADAPTER_T prAdapter
,
1048 IN P_MSDU_INFO_T prMsduInfo
, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus
)
1050 P_STA_RECORD_T prStaRec
;
1051 P_SEC_INFO_T prSecInfo
;
1052 ENUM_SEC_STATE_T eNextState
;
1053 BOOLEAN fgIsTransition
= (BOOLEAN
) FALSE
;
1055 DEBUGFUNC("secFsmRunEventDeauthTxDone");
1059 prStaRec
= cnmGetStaRecByIndex(prAdapter
, prMsduInfo
->ucStaRecIndex
);
1066 if (!IS_STA_IN_AIS(prStaRec
)) {
1067 DBGLOG(RSN
, INFO
, ("Counter Measure should occur at AIS network!!\n"));
1072 prSecInfo
= (P_SEC_INFO_T
) &prStaRec
->rSecInfo
;
1075 DBGLOG(RSN
, TRACE
, (MACSTR
" Sec state %s\n", MAC2STR(prStaRec
->aucMacAddr
),
1076 apucDebugSecState
[prSecInfo
->eCurrentState
]));
1079 (MACSTR
" Sec state [%d]\n", MAC2STR(prStaRec
->aucMacAddr
),
1080 prSecInfo
->eCurrentState
));
1083 switch (prSecInfo
->eCurrentState
) {
1084 case SEC_STATE_SEND_DEAUTH
:
1086 DBGLOG(RSN
, TRACE
, ("Set timer %d\n", COUNTER_MEASURE_TIMEOUT_INTERVAL_SEC
));
1088 SEC_STATE_TRANSITION(prAdapter
, prStaRec
, SEND_DEAUTH
, COUNTERMEASURE
);
1098 } /* secFsmRunEventDeauthTxDone */
1101 /*----------------------------------------------------------------------------*/
1103 * \brief This function will check the eapol error frame fail to send issue.
1105 * \param[in] prSta Pointer to the Sta record
1109 /*----------------------------------------------------------------------------*/
1110 VOID
secFsmEventEapolTxTimeout(IN P_ADAPTER_T prAdapter
, IN UINT_32 u4Parm
)
1112 P_STA_RECORD_T prStaRec
;
1114 DEBUGFUNC("secFsmRunEventEapolTxTimeout");
1116 prStaRec
= (P_STA_RECORD_T
) u4Parm
;
1120 /* Todo:: How to handle the Eapol Error fail to send case? */
1125 } /* secFsmEventEapolTxTimeout */
1128 /*----------------------------------------------------------------------------*/
1130 * \brief This function will stop the counterMeasure duration.
1132 * \param[in] prSta Pointer to the Sta record
1136 /*----------------------------------------------------------------------------*/
1137 VOID
secFsmEventEndOfCounterMeasure(IN P_ADAPTER_T prAdapter
, UINT_32 u4Parm
)
1139 P_STA_RECORD_T prSta
;
1140 P_SEC_INFO_T prSecInfo
;
1141 ENUM_SEC_STATE_T eNextState
;
1142 BOOLEAN fgIsTransition
= (BOOLEAN
) FALSE
;
1144 DEBUGFUNC("secFsmRunEventEndOfCounterMeasure");
1146 prSta
= (P_STA_RECORD_T
) u4Parm
;
1150 if (!IS_STA_IN_AIS(prSta
)) {
1151 DBGLOG(RSN
, INFO
, ("Counter Measure should occur at AIS network!!\n"));
1156 prSecInfo
= &prSta
->rSecInfo
;
1157 eNextState
= prSecInfo
->eCurrentState
;
1160 DBGLOG(RSN
, TRACE
, (MACSTR
" Sec state %s\n", MAC2STR(prSta
->aucMacAddr
),
1161 apucDebugSecState
[prSecInfo
->eCurrentState
]));
1164 (MACSTR
" Sec state [%d]\n", MAC2STR(prSta
->aucMacAddr
), prSecInfo
->eCurrentState
));
1167 switch (prSecInfo
->eCurrentState
) {
1168 case SEC_STATE_SEND_DEAUTH
:
1170 prAdapter
->rWifiVar
.rAisSpecificBssInfo
.fgCounterMeasure
= FALSE
;
1172 SEC_STATE_TRANSITION(prAdapter
, prSta
, COUNTERMEASURE
, INIT
);
1180 /* Call arbFsmSteps() when we are going to change ARB STATE */
1181 if (prSecInfo
->eCurrentState
!= eNextState
) {
1182 secFsmSteps(prAdapter
, prSta
, eNextState
);
1186 } /* end of secFsmRunEventEndOfCounterMeasure */