OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / hardware / ti / wlan / wl1271 / stad / src / Sta_Management / mlmeSm.c
1 /*
2  * mlmeSm.c
3  *
4  * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.      
5  * All rights reserved.                                                  
6  *                                                                       
7  * Redistribution and use in source and binary forms, with or without    
8  * modification, are permitted provided that the following conditions    
9  * are met:                                                              
10  *                                                                       
11  *  * Redistributions of source code must retain the above copyright     
12  *    notice, this list of conditions and the following disclaimer.      
13  *  * Redistributions in binary form must reproduce the above copyright  
14  *    notice, this list of conditions and the following disclaimer in    
15  *    the documentation and/or other materials provided with the         
16  *    distribution.                                                      
17  *  * Neither the name Texas Instruments nor the names of its            
18  *    contributors may be used to endorse or promote products derived    
19  *    from this software without specific prior written permission.      
20  *                                                                       
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 /** \file mlmeSM.c
35  *  \brief 802.11 MLME SM source
36  *
37  *  \see mlmeSM.h
38  */
39
40
41 /***************************************************************************/
42 /*                                                                         */
43 /*      MODULE: mlmeSM.c                                                   */
44 /*    PURPOSE:  802.11 MLME SM source                                      */
45 /*                                                                         */
46 /***************************************************************************/
47
48 #define __FILE_ID__  FILE_ID_69
49 #include "osApi.h"
50 #include "paramOut.h"
51 #include "fsm.h"
52 #include "report.h"
53 #include "smeApi.h"
54 #include "AssocSM.h"
55 #include "authSm.h"
56 #include "mlmeBuilder.h"
57 #include "mlmeSm.h"
58 #include "openAuthSm.h"
59 #include "sharedKeyAuthSm.h"
60 #include "connApi.h"
61 #include "DrvMainModules.h"
62
63
64 #ifdef TI_DBG
65 #include "siteMgrApi.h"
66 #endif
67 /* Constants */
68
69 /* Enumerations */
70
71 /* Typedefs */
72
73 /* Structures */
74
75 /* External data definitions */
76
77 /* External functions definitions */
78
79 /* Global variables */
80
81 /* Local function prototypes */
82 static void mlme_stopAssocAndAuth(mlme_t *pMlme);
83
84 /* functions */
85
86 /**
87 *
88 * mlme_Create - allocate memory for MLME SM
89 *
90 * \b Description: 
91 *
92 * Allocate memory for MLME SM. \n
93 *       Allocates memory for MLME context. \n
94 *       Allocates memory for MLME timer. \n
95 *       Allocates memory for MLME SM matrix. \n
96 *
97 * \b ARGS:
98 *
99 *  I   - pOs - OS context  \n
100 *
101 * \b RETURNS:
102 *
103 *  TI_OK if successful, TI_NOK otherwise.
104 *
105 * \sa rsn_mainSecSmKeysOnlyStop()
106 */
107 TI_HANDLE mlme_create(TI_HANDLE hOs)
108 {
109     mlme_t  *pHandle;
110     TI_STATUS       status;
111
112     /* allocate MLME context memory */
113     pHandle = (mlme_t*)os_memoryAlloc(hOs, sizeof(mlme_t));
114     if (pHandle == NULL)
115     {
116         return NULL;
117     }
118
119     /* zero all MLME context */
120     os_memoryZero(hOs, pHandle, sizeof(mlme_t));
121
122     pHandle->hOs = hOs;
123
124     /* allocate memory for MLME state machine */
125     status = fsm_Create(hOs, &pHandle->pMlmeSm, MLME_SM_NUM_STATES, MLME_SM_NUM_EVENTS);
126     if (status != TI_OK)
127     {
128         os_memoryFree(hOs, pHandle, sizeof(mlme_t));
129         return NULL;
130     }
131
132     return pHandle;
133 }
134
135
136 /**
137 *
138 * mlme_Unload - unload MLME SM from memory
139 *
140 * \b Description: 
141 *
142 * Unload MLME SM from memory
143 *
144 * \b ARGS:
145 *
146 *  I   - hMlme - MLME SM context  \n
147 *
148 * \b RETURNS:
149 *
150 *  TI_OK if successful, TI_NOK otherwise.
151 *
152 * \sa rsn_mainSecSmKeysOnlyStop()
153 */
154 TI_STATUS mlme_unload(TI_HANDLE hMlme)
155 {
156     TI_STATUS       status;
157     mlme_t      *pHandle;
158
159     pHandle = (mlme_t*)hMlme;
160
161     status = fsm_Unload(pHandle->hOs, pHandle->pMlmeSm);
162     if (status != TI_OK)
163     {
164         /* report failure but don't stop... */
165     }
166     
167     os_memoryFree(pHandle->hOs, hMlme, sizeof(mlme_t));
168
169     return TI_OK;
170 }
171
172 /**
173 *
174 * mlme_smConfig - configure a new MLME SM
175 *
176 * \b Description: 
177 *
178 * Configure a new MLME SM and other modules handles.
179 *
180 * \b RETURNS:
181 *
182 *  void
183 *
184 * \sa mlme_Create, mlme_Unload
185 */
186 void mlme_init (TStadHandlesList *pStadHandles)
187 {
188     mlme_t *pHandle = (mlme_t *)(pStadHandles->hMlmeSm);
189     
190     /** Main 802.1X State Machine matrix */
191     fsm_actionCell_t    mlme_smMatrix[MLME_SM_NUM_STATES][MLME_SM_NUM_EVENTS] =
192     {
193         /* next state and actions for IDLE state */
194         {{MLME_SM_STATE_AUTH_WAIT, (fsm_Action_t)mlme_smStartIdle},             /* MLME_SM_EVENT_START */
195          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smNOP},                     /* MLME_SM_EVENT_STOP  */
196          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smActionUnexpected},       /* MLME_SM_EVENT_AUTH_SUCCESS */
197          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smActionUnexpected},       /* MLME_SM_EVENT_AUTH_FAIL */
198          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smActionUnexpected},       /* MLME_SM_EVENT_ASSOC_SUCCESS */
199          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smActionUnexpected}        /* MLME_SM_EVENT_ASSOC_FAIL */
200         },
201         /* next state and actions for AUTH_WAIT state */
202         {{MLME_SM_STATE_AUTH_WAIT, (fsm_Action_t)mlme_smActionUnexpected},      /* MLME_SM_EVENT_START */
203          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smNOP},                       /* MLME_SM_EVENT_STOP  */
204          {MLME_SM_STATE_ASSOC_WAIT, (fsm_Action_t)mlme_smAuthSuccessAuthWait},  /* MLME_SM_EVENT_AUTH_SUCCESS */
205          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smAuthFailAuthWait},           /* MLME_SM_EVENT_AUTH_FAIL */
206          {MLME_SM_STATE_AUTH_WAIT, (fsm_Action_t)mlme_smActionUnexpected},      /* MLME_SM_EVENT_ASSOC_SUCCESS */
207          {MLME_SM_STATE_AUTH_WAIT, (fsm_Action_t)mlme_smActionUnexpected}       /* MLME_SM_EVENT_ASSOC_FAIL */
208         },
209         /* next state and actions for ASSOC_WAIT state */
210         {{MLME_SM_STATE_ASSOC_WAIT, (fsm_Action_t)mlme_smActionUnexpected}, /* MLME_SM_EVENT_START */
211          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smStopAssocWait},          /* MLME_SM_EVENT_STOP  */
212          {MLME_SM_STATE_ASSOC_WAIT, (fsm_Action_t)mlme_smActionUnexpected}, /* MLME_SM_EVENT_AUTH_SUCCESS */
213          {MLME_SM_STATE_ASSOC_WAIT, (fsm_Action_t)mlme_smActionUnexpected}, /* MLME_SM_EVENT_AUTH_FAIL */
214          {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smAssocSuccessAssocWait}, /* MLME_SM_EVENT_ASSOC_SUCCESS */
215          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smAssocFailAssocWait}      /* MLME_SM_EVENT_ASSOC_FAIL */
216         },
217         /* next state and actions for ASSOC state */
218         {{MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected},  /* MLME_SM_EVENT_START */
219          {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smStopAssoc},          /* MLME_SM_EVENT_STOP  */
220          {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected},  /* MLME_SM_EVENT_AUTH_SUCCESS */
221          {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected},  /* MLME_SM_EVENT_AUTH_FAIL */
222          {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected},  /* MLME_SM_EVENT_ASSOC_SUCCESS */
223          {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected}   /* MLME_SM_EVENT_ASSOC_FAIL */
224         }
225     };
226     
227     fsm_Config(pHandle->pMlmeSm, &mlme_smMatrix[0][0], MLME_SM_NUM_STATES, MLME_SM_NUM_EVENTS, mlme_smEvent, pStadHandles->hOs);
228     
229     pHandle->currentState = MLME_SM_STATE_IDLE;
230     pHandle->legacyAuthType = AUTH_LEGACY_NONE;
231     pHandle->reAssoc = TI_FALSE;
232     pHandle->disConnType = DISCONNECT_IMMEDIATE;
233     pHandle->disConnReason = STATUS_UNSPECIFIED;
234     
235     pHandle->hAssoc            = pStadHandles->hAssoc;
236     pHandle->hAuth             = pStadHandles->hAuth;
237     pHandle->hSiteMgr          = pStadHandles->hSiteMgr;
238     pHandle->hCtrlData         = pStadHandles->hCtrlData;
239     pHandle->hTxMgmtQ          = pStadHandles->hTxMgmtQ;
240     pHandle->hMeasurementMgr   = pStadHandles->hMeasurementMgr;
241     pHandle->hSwitchChannel    = pStadHandles->hSwitchChannel;
242     pHandle->hRegulatoryDomain = pStadHandles->hRegulatoryDomain;
243     pHandle->hReport           = pStadHandles->hReport;
244     pHandle->hOs               = pStadHandles->hOs;
245     pHandle->hConn             = pStadHandles->hConn;
246     pHandle->hCurrBss          = pStadHandles->hCurrBss;
247     pHandle->hApConn           = pStadHandles->hAPConnection;
248     pHandle->hScanCncn         = pStadHandles->hScanCncn;
249     pHandle->hQosMngr          = pStadHandles->hQosMngr;
250     pHandle->hTWD              = pStadHandles->hTWD;
251     pHandle->hTxCtrl           = pStadHandles->hTxCtrl;
252
253     /*
254     debug info
255     */
256     pHandle->debug_lastProbeRspTSFTime = 0;
257     pHandle->debug_lastDtimBcnTSFTime = 0;
258     pHandle->debug_lastBeaconTSFTime = 0;
259     pHandle->debug_isFunctionFirstTime = TI_TRUE;
260     pHandle->BeaconsCounterPS = 0;
261 }
262
263 void mlme_SetDefaults (TI_HANDLE hMlmeSm, TMlmeInitParams *pMlmeInitParams)
264 {
265     mlme_t *pMlme = (mlme_t *)(hMlmeSm);
266
267     /* set default values */
268     pMlme->bParseBeaconWSC = pMlmeInitParams->parseWSCInBeacons;
269 }
270
271 TI_STATUS mlme_setParam(TI_HANDLE           hMlmeSm,
272                         paramInfo_t         *pParam)
273 {
274     mlme_t *pMlmeSm = (mlme_t *)hMlmeSm;
275
276     switch(pParam->paramType)
277     {
278     case MLME_LEGACY_TYPE_PARAM:
279
280         switch (pParam->content.mlmeLegacyAuthType)
281         {
282         case AUTH_LEGACY_RESERVED1:
283         case AUTH_LEGACY_OPEN_SYSTEM:
284             /* First configure the MLME with the new legacy authentication type */
285             pMlmeSm->legacyAuthType = pParam->content.mlmeLegacyAuthType;
286             /* Now configure the authentication module. */
287             pParam->paramType = AUTH_LEGACY_TYPE_PARAM;
288             return auth_setParam(pMlmeSm->hAuth, pParam);
289
290         case AUTH_LEGACY_SHARED_KEY:
291             /* First configure the MLME with the new legacy authentication type */
292             pMlmeSm->legacyAuthType = AUTH_LEGACY_SHARED_KEY;
293             /* Now configure the authentication module. */
294             pParam->paramType = AUTH_LEGACY_TYPE_PARAM;
295             return auth_setParam(pMlmeSm->hAuth, pParam);
296
297         case AUTH_LEGACY_AUTO_SWITCH:
298             /* First configure the MLME with the new legacy authentication type */
299             pMlmeSm->legacyAuthType = AUTH_LEGACY_AUTO_SWITCH;
300             /* Now configure the authentication module, 
301                 Auto switch mode means start always with shared key, if fail move to open system. */
302             pParam->paramType = AUTH_LEGACY_TYPE_PARAM;
303             pParam->content.authLegacyAuthType = AUTH_LEGACY_SHARED_KEY;
304             return auth_setParam(pMlmeSm->hAuth, pParam);
305
306         default:
307             TRACE1(pMlmeSm->hReport, REPORT_SEVERITY_ERROR, "Set param, Params is not supported, 0x%x\n\n", pParam->content.mlmeLegacyAuthType);
308             return PARAM_VALUE_NOT_VALID;
309         }
310 /*      break;  - unreachable */
311
312     case MLME_RE_ASSOC_PARAM:
313         pMlmeSm->reAssoc = pParam->content.mlmeReAssoc;
314         break;
315
316     default:
317         TRACE1(pMlmeSm->hReport, REPORT_SEVERITY_ERROR, "Set param, Params is not supported, 0x%x\n\n", pParam->paramType);
318         return PARAM_NOT_SUPPORTED;
319     }
320
321     return TI_OK;
322 }
323
324 TI_STATUS mlme_getParam(TI_HANDLE           hMlmeSm, 
325                         paramInfo_t         *pParam)
326 {
327     mlme_t *pMlmeSm = (mlme_t *)hMlmeSm;
328
329     switch(pParam->paramType)
330     {
331     case MLME_LEGACY_TYPE_PARAM:
332         pParam->content.mlmeLegacyAuthType = pMlmeSm->legacyAuthType;           
333         break;
334
335     case MLME_CAPABILITY_PARAM:
336         pParam->content.mlmeLegacyAuthType = pMlmeSm->legacyAuthType;
337         assoc_smCapBuild(pMlmeSm->hAssoc, &(pParam->content.siteMgrSiteCapability));
338         break;
339
340     case MLME_BEACON_RECV:
341         pParam->content.siteMgrTiWlanCounters.BeaconsRecv = pMlmeSm->BeaconsCounterPS;
342         break;
343
344     default:
345         TRACE1(pMlmeSm->hReport, REPORT_SEVERITY_ERROR, "Get param, Params is not supported, %d\n\n", pParam->content.mlmeLegacyAuthType);
346         return PARAM_NOT_SUPPORTED;
347     }
348
349     return TI_OK;
350 }
351
352 /**
353 *
354 * mlme_Start - Start event for the MLME SM
355 *
356 * \b Description: 
357 *
358 * Start event for the MLME SM
359 *
360 * \b ARGS:
361 *
362 *  I   - hMlme - MLME SM context  \n
363 *
364 * \b RETURNS:
365 *
366 *  TI_OK if successful, TI_NOK otherwise.
367 *
368 * \sa mlme_Stop, mlme_Recv
369 */
370 TI_STATUS mlme_start(TI_HANDLE hMlme)
371 {
372     TI_STATUS   status;
373     mlme_t              *pHandle = (mlme_t*)hMlme;
374
375     if (pHandle == NULL)
376     {
377         return TI_NOK;
378     }
379
380     if (pHandle->legacyAuthType == AUTH_LEGACY_NONE)
381     {
382         TRACE0(pHandle->hReport, REPORT_SEVERITY_ERROR, "mlme_start: pHandle->legacyAuthType == AUTH_LEGACY_NONE\n");
383         return TI_NOK;
384     }
385
386     status = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_START, pHandle);
387
388     return status;
389 }
390
391 /**
392 *
393 * mlme_Stop - Stop event for the MLME SM
394 *
395 * \b Description: 
396 *
397 * Stop event for the MLME SM
398 *
399 * \b ARGS:
400 *
401 *  I   - hMlme - MLME SM context  \n
402 *
403 * \b RETURNS:
404 *
405 *  TI_OK if successful, TI_NOK otherwise.
406 *
407 * \sa mlme_Start, mlme_Recv
408 */
409 TI_STATUS mlme_stop(TI_HANDLE hMlme, DisconnectType_e disConnType, mgmtStatus_e reason)
410 {
411     TI_STATUS       status;
412     mlme_t      *pHandle;
413
414     pHandle = (mlme_t*)hMlme;
415
416     if (pHandle->legacyAuthType == AUTH_LEGACY_NONE)
417         return TI_NOK;
418
419     pHandle->disConnType = disConnType;
420     pHandle->disConnReason = reason;
421
422     status = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_STOP, pHandle);
423     
424     return status;
425 }
426
427
428 /**
429 *
430 * mlme_reportAuthStatus - Set a specific parameter to the MLME SM
431 *
432 * \b Description: 
433 *
434 * Set a specific parameter to the MLME SM.
435 *
436 * \b ARGS:
437 *
438 *  I   - hMlme - MLME SM context  \n
439 *  I/O - pParam - Parameter \n
440 *
441 * \b RETURNS:
442 *
443 *  TI_OK if successful, TI_NOK otherwise.
444 *
445 * \sa mlme_Start, mlme_Stop
446 */
447 TI_STATUS mlme_reportAuthStatus(TI_HANDLE hMlme, TI_UINT16 status)
448 {
449     mlme_t          *pHandle;
450     paramInfo_t     param;
451     TI_STATUS       fStatus;
452
453     pHandle = (mlme_t*)hMlme;
454
455     if (pHandle == NULL)
456         return TI_NOK;
457  
458     if (pHandle->legacyAuthType == AUTH_LEGACY_NONE)
459         return TI_NOK;
460
461     pHandle->mlmeData.uStatusCode = status;
462
463     /* If status is successful */
464     if (status == 0)
465     {
466         /* Mark a successful status - used for conn.c */
467         pHandle->mlmeData.mgmtStatus = STATUS_SUCCESSFUL;
468         fStatus = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_AUTH_SUCCESS, pHandle);
469     } 
470     else 
471     {
472         /* Now, if the MLME legacy auth type is AUTO_SWITCH, and the Auth legacy auth type is shared key, 
473             we configure the auth SM to open system, otherwise, this is really an authentication failure. */
474         param.paramType = AUTH_LEGACY_TYPE_PARAM;
475         auth_getParam(pHandle->hAuth, &param);
476
477         if ((pHandle->legacyAuthType == AUTH_LEGACY_AUTO_SWITCH) && (param.content.authLegacyAuthType ==  AUTH_LEGACY_SHARED_KEY))
478         {
479             param.content.authLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
480             fStatus = auth_setParam(pHandle->hAuth, &param);
481             fStatus = auth_start(pHandle->hAuth);
482         }
483
484         else
485         {
486             pHandle->mlmeData.mgmtStatus = STATUS_AUTH_REJECT;
487             fStatus = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_AUTH_FAIL, pHandle);
488         }
489
490     }
491
492     return fStatus;
493 }
494
495 /**
496 *
497 * mlme_reportAssocStatus - Set a specific parameter to the MLME SM
498 *
499 * \b Description: 
500 *
501 * Set a specific parameter to the MLME SM.
502 *
503 * \b ARGS:
504 *
505 *  I   - hMlme - MLME SM context  \n
506 *  I/O - pParam - Parameter \n
507 *
508 * \b RETURNS:
509 *
510 *  TI_OK if successful, TI_NOK otherwise.
511 *
512 * \sa mlme_Start, mlme_Stop
513 */
514 TI_STATUS mlme_reportAssocStatus(TI_HANDLE hMlme, TI_UINT16 status)
515 {
516     mlme_t      *pHandle;
517     TI_STATUS   fStatus;
518
519     pHandle = (mlme_t*)hMlme;
520
521     if (pHandle == NULL)
522         return TI_NOK;
523
524     if (pHandle->legacyAuthType == AUTH_LEGACY_NONE)
525         return TI_NOK;
526
527     pHandle->mlmeData.uStatusCode = status;
528
529     /* If status is successful */
530     if (status == 0)
531     {
532         pHandle->mlmeData.mgmtStatus = STATUS_SUCCESSFUL;
533         fStatus = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_ASSOC_SUCCESS, pHandle);
534     } else 
535     {
536         pHandle->mlmeData.mgmtStatus = STATUS_ASSOC_REJECT;
537         fStatus = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_ASSOC_FAIL, pHandle);
538     }
539
540     return fStatus;
541 }
542
543
544 /**
545 *
546 * mlme_SetParam - Set a specific parameter to the MLME SM
547 *
548 * \b Description: 
549 *
550 * Set a specific parameter to the MLME SM.
551 *
552 * \b ARGS:
553 *
554 *  I   - hMlme - MLME SM context  \n
555 *  I/O - pParam - Parameter \n
556 *
557 * \b RETURNS:
558 *
559 *  TI_OK if successful, TI_NOK otherwise.
560 *
561 * \sa mlme_Start, mlme_Stop
562 */
563 TI_STATUS mlme_smEvent(TI_UINT8 *currentState, TI_UINT8 event, TI_HANDLE hMlme)
564 {
565    mlme_t *pMlme = (mlme_t *)hMlme;
566     TI_STATUS       status;
567     TI_UINT8        nextState;
568
569     status = fsm_GetNextState(pMlme->pMlmeSm, *currentState, event, &nextState);
570     if (status != TI_OK)
571     {
572         TRACE0(pMlme->hReport, REPORT_SEVERITY_ERROR, "MLME_SM: ERROR - failed getting next state \n");
573
574         return(TI_NOK);
575     }
576
577         TRACE3( pMlme->hReport, REPORT_SEVERITY_INFORMATION, "mlme_smEvent: <currentState = %d, event = %d> --> nextState = %d\n", *currentState, event, nextState);
578
579     status = fsm_Event(pMlme->pMlmeSm, currentState, event, (void *)pMlme);
580
581     return(status);
582 }
583
584 /* state machine functions */
585
586 TI_STATUS mlme_smStartIdle(mlme_t *pMlme)
587 {
588     TI_STATUS       status;
589
590     status = auth_start(pMlme->hAuth);
591
592     return status;
593 }
594
595 TI_STATUS mlme_smClass3Idle(mlme_t *pMlme)
596 {
597     return TI_OK;
598 }
599
600
601
602 TI_STATUS mlme_smAuthSuccessAuthWait(mlme_t *pMlme)
603 {
604     TI_STATUS       status;
605
606     if (pMlme->reAssoc)
607     {
608         status = reassoc_start(pMlme->hAssoc);
609     }
610     else
611     {
612         status = assoc_start(pMlme->hAssoc);
613     }
614
615     return status;
616 }
617
618 TI_STATUS mlme_smAuthFailAuthWait(mlme_t *pMlme)
619 {
620     TI_STATUS       status;
621
622     status = mlme_smReportStatus(pMlme);
623
624     return status;
625 }
626
627 TI_STATUS mlme_smStopAssocWait(mlme_t *pMlme)
628 {
629     mlme_stopAssocAndAuth(pMlme);
630     return TI_OK;
631 }
632
633 TI_STATUS mlme_smAssocSuccessAssocWait(mlme_t *pMlme)
634 {
635     TI_STATUS       status;
636
637     status = mlme_smReportStatus(pMlme);
638
639     return status;
640 }
641
642 TI_STATUS mlme_smAssocFailAssocWait(mlme_t *pMlme)
643 {
644     TI_STATUS       status;
645  
646     status = mlme_smReportStatus(pMlme);
647
648     return status;
649 }
650
651
652 TI_STATUS mlme_smStopAssoc(mlme_t *pMlme)
653 {
654     mlme_stopAssocAndAuth(pMlme);
655     return TI_OK;
656 }
657
658
659
660 TI_STATUS mlme_smNOP(mlme_t *pMlme)
661 {
662     return TI_OK;
663 }
664
665 TI_STATUS mlme_smActionUnexpected(mlme_t *pMlme)
666 {
667     return TI_OK;
668 }
669
670 /* local functions */
671
672 TI_STATUS mlme_smReportStatus(mlme_t *pMlme)
673 {
674     TI_STATUS       status;
675
676     if (pMlme == NULL)
677     {
678         return TI_NOK;
679     }
680
681     status = conn_reportMlmeStatus(pMlme->hConn, pMlme->mlmeData.mgmtStatus, pMlme->mlmeData.uStatusCode);
682     return status;
683 }
684
685
686 static void mlme_stopAssocAndAuth(mlme_t *pMlme)
687 {
688
689     TI_BOOL         sendDeAuth;
690     TI_BOOL         sendDisAssoc;
691
692     /* Don't send deauth/disassoc, FW will do it on disconnect command */
693     sendDeAuth   = TI_FALSE;
694     sendDisAssoc = TI_FALSE;
695
696         TRACE0(pMlme->hReport, REPORT_SEVERITY_INFORMATION, "mlme_stopAssocAndAuth: Auth/assoc stop without sending deauth/disassoc\n");
697
698     assoc_setDisAssocFlag(pMlme->hAssoc, sendDisAssoc);
699     assoc_stop(pMlme->hAssoc);
700     
701     auth_stop(pMlme->hAuth, sendDeAuth, pMlme->disConnReason );
702 }
703 /*****************************************************************************
704 **
705 ** MLME messages builder/Parser
706 **
707 *****************************************************************************/
708
709
710
711
712
713
714