Home | History | Annotate | Download | only in conn
      1 /** \file conn.c
      2  *  \brief connection module interface
      3  *
      4  *  \see conn.h
      5  */
      6 /****************************************************************************
      7 **+-----------------------------------------------------------------------+**
      8 **|                                                                       |**
      9 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
     10 **| All rights reserved.                                                  |**
     11 **|                                                                       |**
     12 **| Redistribution and use in source and binary forms, with or without    |**
     13 **| modification, are permitted provided that the following conditions    |**
     14 **| are met:                                                              |**
     15 **|                                                                       |**
     16 **|  * Redistributions of source code must retain the above copyright     |**
     17 **|    notice, this list of conditions and the following disclaimer.      |**
     18 **|  * Redistributions in binary form must reproduce the above copyright  |**
     19 **|    notice, this list of conditions and the following disclaimer in    |**
     20 **|    the documentation and/or other materials provided with the         |**
     21 **|    distribution.                                                      |**
     22 **|  * Neither the name Texas Instruments nor the names of its            |**
     23 **|    contributors may be used to endorse or promote products derived    |**
     24 **|    from this software without specific prior written permission.      |**
     25 **|                                                                       |**
     26 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
     27 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
     28 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
     29 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
     30 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
     31 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
     32 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
     33 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
     34 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
     35 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
     36 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
     37 **|                                                                       |**
     38 **+-----------------------------------------------------------------------+**
     39 ****************************************************************************/
     40 
     41 /****************************************************************************************************/
     42 /*																									*/
     43 /*		MODULE:		conn.c																			*/
     44 /*		PURPOSE:	Connection module interface. The connection	itself is implemented in the files	*/
     45 /*					connInfra, connIbss & connSelf. This file distributes the events received to 	*/
     46 /*					one of the modules based on the current connection type.						*/
     47 /*																									*/
     48 /****************************************************************************************************/
     49 
     50 
     51 #include "report.h"
     52 #include "osTIType.h"
     53 #include "osApi.h"
     54 #include "conn.h"
     55 #include "connApi.h"
     56 #include "connIbss.h"
     57 #include "connInfra.h"
     58 #include "802_11Defs.h"
     59 #include "utils.h"
     60 #include "smeApi.h"
     61 #include "paramOut.h"
     62 #include "paramIn.h"
     63 #include "siteMgrApi.h"
     64 #include "smeSmApi.h"
     65 #include "scrApi.h"
     66 #include "healthMonitor.h"
     67 #include "qosMngr_API.h"
     68 
     69 #define CONN_INIT_BIT					1
     70 #define TIMER_INIT_BIT					2
     71 #define	IBSS_SM_INIT_BIT				3
     72 #define	INFRA_SM_INIT_BIT				4
     73 #define INFRA_DISASSOC_TIMER_INIT_BIT	6
     74 
     75 /* Local functions prototypes */
     76 
     77 static void conn_timeout(TI_HANDLE hConn);
     78 
     79 static void release_module(conn_t *pConn, UINT32 initVec);
     80 
     81 /* Interface functions Implementation */
     82 
     83 /************************************************************************
     84  *                        conn_create								*
     85  ************************************************************************
     86 DESCRIPTION: Connection module creation function, called by the config mgr in creation phase
     87 				performs the following:
     88 				-	Allocate the connection handle
     89 				-	Create the connection timer
     90 				-	Create the connection state machine
     91 
     92 INPUT:      hOs -			Handle to OS
     93 
     94 
     95 OUTPUT:
     96 
     97 RETURN:     Handle to the connection module on success, NULL otherwise
     98 
     99 ************************************************************************/
    100 TI_HANDLE conn_create(TI_HANDLE hOs)
    101 {
    102 	conn_t			*pConn;
    103 	UINT32			initVec;
    104 	fsm_stateMachine_t *pFsm;
    105 	TI_STATUS status;
    106 
    107 	initVec = 0;
    108 
    109 	pConn = os_memoryAlloc(hOs, sizeof(conn_t));
    110 	if (pConn == NULL)
    111 		return NULL;
    112 
    113 	initVec |= (1<<CONN_INIT_BIT);
    114 
    115     /* Rename to connSelfIbssTimer */
    116 	pConn->pTimer = os_timerCreate(hOs, conn_timeout, pConn);
    117 	if (pConn->pTimer == NULL)
    118 	{
    119 		release_module(pConn, initVec);
    120 		return NULL;
    121 	}
    122 
    123 	initVec |= (1<<TIMER_INIT_BIT);
    124 
    125 
    126 	/* Creating connection Ibss SM */
    127     status = fsm_Create(hOs, &pFsm, CONN_IBSS_NUM_STATES, CONN_IBSS_NUM_EVENTS);
    128 	if (status != OK)
    129 	{
    130 		release_module(pConn, initVec);
    131 		return NULL;
    132 	}
    133 	pConn->ibss_pFsm = pFsm;
    134 
    135     initVec |= (1<<IBSS_SM_INIT_BIT);
    136 
    137     /* Creating connection Infra SM */
    138    	status = fsm_Create(hOs, &pFsm, CONN_INFRA_NUM_STATES, CONN_INFRA_NUM_EVENTS);
    139 	if (status != OK)
    140 	{
    141 		release_module(pConn, initVec);
    142 		return NULL;
    143 	}
    144 	pConn->infra_pFsm = pFsm;
    145 
    146     initVec |= (1<<INFRA_SM_INIT_BIT);
    147 
    148 
    149     /* ------- */
    150 
    151 	pConn->hOs = hOs;
    152 
    153 	return(pConn);
    154 }
    155 
    156 
    157 /************************************************************************
    158  *                        conn_config									*
    159  ************************************************************************
    160 DESCRIPTION: Connection module configuration function, called by the config mgr in configuration phase
    161 				performs the following:
    162 				-	Reset & initiailzes local variables
    163 				-	Init the handles to be used by the module
    164 
    165 INPUT:      hConn	-	Connection handle
    166 			List of handles to be used by the module
    167 			pConnInitParams	-	Init table of the module.
    168 
    169 
    170 OUTPUT:
    171 
    172 RETURN:     OK on success, NOK otherwise
    173 
    174 ************************************************************************/
    175 TI_STATUS conn_config(TI_HANDLE 	hConn,
    176 				   TI_HANDLE 	hSiteMgr,
    177 				   TI_HANDLE	hSmeSm,
    178 				   TI_HANDLE	hMlmeSm,
    179 				   TI_HANDLE	hRsn,
    180 				   TI_HANDLE	hRxData,
    181 				   TI_HANDLE	hTxData,
    182 				   TI_HANDLE 	hReport,
    183 				   TI_HANDLE 	hOs,
    184 				   TI_HANDLE	hPwrMngr,
    185 				   TI_HANDLE    hCtrlData,
    186 				   TI_HANDLE	hMeasurementMgr,
    187 				   TI_HANDLE	hTrafficMonitor,
    188 				   TI_HANDLE	hScr,
    189 				   TI_HANDLE	hExcMngr,
    190 				   TI_HANDLE	hQosMngr,
    191 				   TI_HANDLE	hHalCtrl,
    192 				   TI_HANDLE	hScanCnc,
    193 				   TI_HANDLE	hCurrBss,
    194 				   TI_HANDLE	hSwitchChannel,
    195 				   TI_HANDLE	hEvHandler,
    196 				   TI_HANDLE	hHealthMonitor,
    197 				   TI_HANDLE	hMacServices,
    198                    TI_HANDLE    hRegulatoryDomain,
    199   				   TI_HANDLE    hSoftGemini,
    200 				   connInitParams_t		*pConnInitParams)
    201 {
    202 	conn_t *pConn = (conn_t *)hConn;
    203 
    204 	pConn->state = 0;
    205 	os_memoryZero(hOs, &(pConn->smContext), sizeof(connSmContext_t));
    206 	pConn->timeout			= pConnInitParams->connSelfTimeout;
    207 	pConn->hSiteMgr			= hSiteMgr;
    208 	pConn->hSmeSm			= hSmeSm;
    209 	pConn->hMlmeSm			= hMlmeSm;
    210 	pConn->hRsn				= hRsn;
    211 	pConn->hRxData			= hRxData;
    212 	pConn->hTxData			= hTxData;
    213 	pConn->hReport			= hReport;
    214 	pConn->hOs				= hOs;
    215 	pConn->hPwrMngr			= hPwrMngr;
    216 	pConn->hCtrlData		= hCtrlData;
    217 	pConn->hMeasurementMgr	= hMeasurementMgr;
    218 	pConn->hTrafficMonitor  = hTrafficMonitor;
    219 	pConn->hScr				= hScr;
    220 	pConn->hExcMngr			= hExcMngr;
    221 	pConn->hQosMngr			= hQosMngr;
    222 	pConn->hHalCtrl			= hHalCtrl;
    223 	pConn->hScanCnc			= hScanCnc;
    224 	pConn->hCurrBss			= hCurrBss;
    225 	pConn->hSwitchChannel	= hSwitchChannel;
    226 	pConn->hEvHandler		= hEvHandler;
    227 	pConn->hHealthMonitor	= hHealthMonitor;
    228 	pConn->hMacServices 	= hMacServices;
    229 	pConn->hSoftGemini		= hSoftGemini;
    230     pConn->hRegulatoryDomain = hRegulatoryDomain;
    231 
    232 	pConn->connType			 = CONN_TYPE_FIRST_CONN;
    233     pConn->ibssDisconnectCount = 0;
    234 
    235 	whalCtrl_EventMbox_RegisterForEvent(pConn->hHalCtrl,  HAL_EVENT_JOIN_CMPLT,
    236 									(void *)connInfra_JoinCmpltNotification, pConn);
    237 
    238 	whalCtrl_EventMbox_Enable(pConn->hHalCtrl, HAL_EVENT_JOIN_CMPLT);
    239 
    240 	WLAN_REPORT_INIT(hReport, CONN_MODULE_LOG,  (".....Connection configured successfully\n"));
    241 
    242 	return OK;
    243 }
    244 
    245 /************************************************************************
    246  *                        conn_unLoad									*
    247  ************************************************************************
    248 DESCRIPTION: Connection module unload function, called by the config mgr in the unlod phase
    249 				performs the following:
    250 				-	Free all memory aloocated by the module
    251 
    252 INPUT:      hConn	-	Connection handle.
    253 
    254 
    255 OUTPUT:
    256 
    257 RETURN:     OK on success, NOK otherwise
    258 
    259 ************************************************************************/
    260 TI_STATUS conn_unLoad(TI_HANDLE hConn)
    261 {
    262 	UINT32			initVec;
    263 	conn_t			*pConn = (conn_t *)hConn;
    264 
    265 	if (!pConn)
    266 		return OK;
    267 
    268 	initVec = 0xFFFF;
    269 	release_module(pConn, initVec);
    270 
    271 	return OK;
    272 }
    273 
    274 /***********************************************************************
    275  *                        conn_setParam
    276  ***********************************************************************
    277 DESCRIPTION: Connection set param function, called by the following:
    278 				-	config mgr in order to set a parameter from the OS abstraction layer.
    279 				-	Form inside the driver
    280 				In this fuction, the site manager configures the connection type in the select phase.
    281 				The connection type is used to distribute the connection events to the corresponding connection SM
    282 
    283 INPUT:      hConn	-	Connection handle.
    284 			pParam	-	Pointer to the parameter
    285 
    286 OUTPUT:
    287 
    288 RETURN:     OK on success, NOK otherwise
    289 
    290 ************************************************************************/
    291 TI_STATUS conn_setParam(TI_HANDLE		hConn,
    292 					 paramInfo_t	*pParam)
    293 {
    294 	conn_t *pConn = (conn_t *)hConn;
    295 
    296 	switch(pParam->paramType)
    297 	{
    298 	case CONN_TYPE_PARAM:
    299 		pConn->currentConnType = pParam->content.connType;
    300 		switch (pParam->content.connType)
    301 		{
    302 		case CONNECTION_IBSS:
    303 		case CONNECTION_SELF:
    304 			return conn_ibssConfig(pConn);
    305 
    306 		case CONNECTION_INFRA:
    307 			return conn_infraConfig(pConn);
    308 
    309 		default:
    310 			WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Set connection type, type is not valid, %d\n\n", pParam->content.connType));
    311 			return PARAM_VALUE_NOT_VALID;
    312 		}
    313 
    314 	case CONN_SELF_TIMEOUT_PARAM:
    315 		if ((pParam->content.connSelfTimeout < CONN_SELF_TIMEOUT_MIN) || (pParam->content.connSelfTimeout > CONN_SELF_TIMEOUT_MAX))
    316 			return PARAM_VALUE_NOT_VALID;
    317 		pConn->timeout = pParam->content.connSelfTimeout;
    318 		break;
    319 
    320 	default:
    321 		WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Set param, Params is not supported, %d\n\n", pParam->paramType));
    322 		return PARAM_NOT_SUPPORTED;
    323 	}
    324 
    325 	return OK;
    326 }
    327 
    328 /***********************************************************************
    329  *                        conn_getParam
    330  ***********************************************************************
    331 DESCRIPTION: Connection get param function, called by the following:
    332 			-	config mgr in order to get a parameter from the OS abstraction layer.
    333 			-	Fomr inside the dirver
    334 
    335 INPUT:      hConn	-	Connection handle.
    336 			pParam	-	Pointer to the parameter
    337 
    338 OUTPUT:
    339 
    340 RETURN:     OK on success, NOK otherwise
    341 
    342 ************************************************************************/
    343 TI_STATUS conn_getParam(TI_HANDLE		hConn,
    344 					 paramInfo_t	*pParam)
    345 {
    346 	conn_t *pConn = (conn_t *)hConn;
    347 
    348 	switch(pParam->paramType)
    349 	{
    350 	case CONN_TYPE_PARAM:
    351 		pParam->content.connType = pConn->currentConnType;
    352 		break;
    353 
    354 	case CONN_SELF_TIMEOUT_PARAM:
    355 		pParam->content.connSelfTimeout = pConn->timeout;
    356 		break;
    357 
    358 	default:
    359 		WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Get param, Params is not supported, %d\n\n", pParam->paramType));
    360 		return PARAM_NOT_SUPPORTED;
    361 	}
    362 
    363 	return OK;
    364 }
    365 
    366 /***********************************************************************
    367  *                        conn_start
    368  ***********************************************************************
    369 DESCRIPTION: Called by the SME SM in order to start the connection SM
    370 			 This function start the current connection SM
    371 
    372 INPUT:      hConn	-	Connection handle.
    373 
    374 OUTPUT:
    375 
    376 RETURN:     OK on success, NOK otherwise
    377 
    378 ************************************************************************/
    379 TI_STATUS conn_start(TI_HANDLE hConn, connType_e connType,
    380 					 	conn_status_callback_t  pConnStatusCB,
    381 						TI_HANDLE connStatCbObj,
    382 						BOOL disConEraseKeys,
    383 						BOOL reNegotiateTspec)
    384 {
    385 	conn_t *pConn = (conn_t *)hConn;
    386 	paramInfoPartial_t param;
    387 
    388 	pConn->pConnStatusCB = pConnStatusCB;
    389 	pConn->connStatCbObj = connStatCbObj;
    390 
    391 	pConn->connType = connType;
    392 	pConn->disConEraseKeys = disConEraseKeys;
    393 
    394 	/* Initialize the DISASSOCIATE event parameters to default */
    395 	pConn->smContext.disAssocEventReason = STATUS_UNSPECIFIED;
    396 	pConn->smContext.disAssocEventStatusCode  = 0;
    397 
    398 	/* If requested, re-negotiate voice TSPEC */
    399 	param.paramType = QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC;
    400 	param.content.TspecConfigure.voiceTspecConfigure = reNegotiateTspec;
    401 	param.content.TspecConfigure.videoTspecConfigure = reNegotiateTspec;
    402 	qosMngr_setParamsPartial(pConn->hQosMngr, &param);
    403 
    404 	switch(pConn->currentConnType)
    405 	{
    406 	case CONNECTION_IBSS:
    407 		return conn_ibssSMEvent(&pConn->state, CONN_IBSS_CONNECT, (TI_HANDLE) pConn);
    408 
    409 	case CONNECTION_SELF:
    410 		return conn_ibssSMEvent(&pConn->state, CONN_IBSS_CREATE, (TI_HANDLE) pConn);
    411 
    412 	case CONNECTION_INFRA:
    413 		return conn_infraSMEvent(&pConn->state, CONN_INFRA_CONNECT, (TI_HANDLE) pConn);
    414 
    415     default:
    416 		WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Start connection, invalid type %d\n\n", pConn->currentConnType));
    417 		return NOK;
    418 
    419 	}
    420 }
    421 
    422 /***********************************************************************
    423  *                        conn_stop
    424  ***********************************************************************
    425 DESCRIPTION: Called by the SME SM in order to stop the connection SM
    426 			 This function stop the current connection SM.
    427 
    428 INPUT:      hConn	-	Connection handle.
    429 
    430 OUTPUT:
    431 
    432 RETURN:     OK on success, NOK otherwise
    433 
    434 ************************************************************************/
    435 TI_STATUS conn_stop(TI_HANDLE 				hConn,
    436 					disConnType_e 			disConnType,
    437 					mgmtStatus_e 			reason,
    438 					BOOL					disConEraseKeys,
    439 					conn_status_callback_t  pConnStatusCB,
    440 					TI_HANDLE 				connStatCbObj  )
    441 {
    442 	conn_t *pConn = (conn_t *)hConn;
    443 
    444 	pConn->pConnStatusCB = pConnStatusCB;
    445 	pConn->connStatCbObj = connStatCbObj;
    446 
    447 	pConn->disConnType 		 = disConnType;
    448 	pConn->disConnReasonToAP = reason;
    449 	pConn->disConEraseKeys	 = disConEraseKeys;
    450 
    451 	/*
    452 	 * Mark the disconnection reason as unspecified to indicate that conn module has no information regarding the DISASSOCIATE event to be raised
    453 	 * by the SME
    454 	 */
    455 	pConn->smContext.disAssocEventReason = STATUS_UNSPECIFIED;
    456 	pConn->smContext.disAssocEventStatusCode  = 0;
    457 
    458     WLAN_REPORT_INFORMATION(pConn->hReport, CONN_MODULE_LOG, ("conn_stop, disConnType %d, reason=%d, disConEraseKeys=%d\n\n",
    459                   disConnType, reason, disConEraseKeys));
    460 
    461 	switch(pConn->currentConnType)
    462 	{
    463 	case CONNECTION_IBSS:
    464     case CONNECTION_SELF:
    465         pConn->ibssDisconnectCount++;
    466 		return conn_ibssSMEvent(&pConn->state, CONN_IBSS_DISCONNECT, (TI_HANDLE) pConn);
    467 
    468 	case CONNECTION_INFRA:
    469 		return conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONNECT, (TI_HANDLE) pConn);
    470 
    471 
    472 	default:
    473 		WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Stop connection, invalid type %d\n\n", pConn->currentConnType));
    474 		return NOK;
    475 	}
    476 }
    477 
    478 
    479 /***********************************************************************
    480  *                        conn_reportMlmeStatus
    481  ***********************************************************************
    482 DESCRIPTION:	Called by the MLME SM when MLME status changed.
    483 				Valid only in the case that the current connection type is infrastructure
    484 				The function calls the connection infra SM with MLME success or MLME failure
    485 				according to the status
    486 
    487 INPUT:      hConn	-	Connection handle.
    488 			status	-	MLME status
    489 
    490 OUTPUT:
    491 
    492 RETURN:     OK on success, NOK otherwise
    493 
    494 ************************************************************************/
    495 TI_STATUS conn_reportMlmeStatus(TI_HANDLE			hConn,
    496 								mgmtStatus_e		status, UINT16 uStatusCode)
    497 {
    498 	conn_t *pConn = (conn_t *)hConn;
    499 
    500 	/* Save the reason for the use of the SME when triggering DISASSOCIATE event */
    501 	pConn->smContext.disAssocEventReason = status;
    502 	pConn->smContext.disAssocEventStatusCode = uStatusCode;
    503 
    504 	if (status == STATUS_SUCCESSFUL)
    505 	{
    506 		conn_infraSMEvent(&pConn->state, CONN_INFRA_MLME_SUCC, pConn);
    507 	}
    508 	else
    509 	{
    510 		WLAN_OS_REPORT(("-------------------------------------\n"));
    511 		WLAN_OS_REPORT(("               CONN LOST             \n"));
    512 		WLAN_OS_REPORT(("-------------------------------------\n"));
    513 
    514 		if( pConn->connType == CONN_TYPE_ROAM )
    515 			pConn->disConnType = DISCONN_TYPE_IMMEDIATE;
    516 		else /* connType == CONN_TYPE_ESS */
    517 			pConn->disConnType = DISCONN_TYPE_DEAUTH;
    518 
    519         WLAN_REPORT_INFORMATION(pConn->hReport, CONN_MODULE_LOG,
    520 			("conn_reportMlmeStatus, disAssocEventReason %d, disAssocEventStatusCode = %d, connType=%d, disConnType=%d \n",
    521             pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode, pConn->connType, pConn->disConnType));
    522 
    523 		conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONNECT, pConn);
    524 	}
    525 
    526 	return OK;
    527 }
    528 
    529 /***********************************************************************
    530  *                        conn_reportRsnStatus
    531  ***********************************************************************
    532 DESCRIPTION:	Called by the RSN SM when RSN status changed.
    533 				This function calls the current connection SM with RSN success or RSN failure based on the status
    534 
    535 INPUT:      hConn	-	Connection handle.
    536 			status	-	RSN status
    537 
    538 OUTPUT:
    539 
    540 RETURN:     OK on success, NOK otherwise
    541 
    542 ************************************************************************/
    543 TI_STATUS conn_reportRsnStatus(TI_HANDLE			hConn,
    544 							mgmtStatus_e		status)
    545 {
    546 	conn_t *pConn = (conn_t *)hConn;
    547 
    548 	/* Save the reason for the use of the SME when triggering DISASSOCIATE event. For now we just have STATUS_SECURITY_FAILURE */
    549 	pConn->smContext.disAssocEventReason = status;
    550 	pConn->smContext.disAssocEventStatusCode = 0; /* For now we don't use this parameter in RSN */
    551 
    552 	switch(pConn->currentConnType)
    553 	{
    554 	case CONNECTION_IBSS:
    555 	case CONNECTION_SELF:
    556 		if (status == STATUS_SUCCESSFUL)
    557 			return conn_ibssSMEvent(&pConn->state, CONN_IBSS_RSN_SUCC, (TI_HANDLE) pConn);
    558 		else
    559 			return conn_ibssSMEvent(&pConn->state, CONN_IBSS_DISCONNECT, (TI_HANDLE) pConn);
    560 
    561 
    562 
    563 	case CONNECTION_INFRA:
    564 		if (status == STATUS_SUCCESSFUL)
    565 			return conn_infraSMEvent(&pConn->state, CONN_INFRA_RSN_SUCC, (TI_HANDLE) pConn);
    566 
    567 		else{ /* status == STATUS_SECURITY_FAILURE */
    568 			/*
    569 			 * In infrastructure - if the connection is standard 802.11 connection (ESS) then
    570 			 * need to disassociate. In roaming mode, the connection is stopped without sending
    571 			 * the reassociation frame.
    572 			 */
    573 			if( pConn->connType == CONN_TYPE_ROAM )
    574 				pConn->disConnType = DISCONN_TYPE_IMMEDIATE;
    575 			else /* connType == CONN_TYPE_ESS */
    576 				pConn->disConnType = DISCONN_TYPE_DISASSOC;
    577 
    578             WLAN_REPORT_INFORMATION(pConn->hReport, CONN_MODULE_LOG, ("conn_reportRsnStatus, disAssocEventReason %d, connType=%d, disConnType=%d \n\n",
    579                           pConn->smContext.disAssocEventReason, pConn->connType, pConn->disConnType));
    580 
    581 			return conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONNECT, (TI_HANDLE) pConn);
    582 		}
    583 	case CONNECTION_NONE:
    584 		break;
    585 	}
    586 
    587 	return OK;
    588 }
    589 
    590 /***********************************************************************
    591  *                        conn_timeout
    592  ***********************************************************************
    593 DESCRIPTION:	Called by the OS abstraction layer when the self timer expired
    594 				Valid only if the current connection type is self
    595 				This function calls the self connection SM with timeout event
    596 
    597 INPUT:      hConn	-	Connection handle.
    598 
    599 OUTPUT:
    600 
    601 RETURN:     OK on success, NOK otherwise
    602 
    603 ************************************************************************/
    604 static void conn_timeout(void *pContext)
    605 {
    606 	conn_t *pConn = (conn_t *)pContext;
    607 
    608 	switch(pConn->currentConnType)
    609 	{
    610 	case CONNECTION_IBSS:
    611 	case CONNECTION_SELF:
    612 		conn_ibssSMEvent(&pConn->state, CONN_IBSS_DISCONNECT, pConn);
    613 		break;
    614 
    615 	case CONNECTION_INFRA:
    616 		conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONN_COMPLETE, (TI_HANDLE) pConn);
    617 		healthMonitor_sendFailureEvent(pConn->hHealthMonitor, DISCONNECT_TIMEOUT);
    618 		break;
    619 
    620 	case CONNECTION_NONE:
    621 		break;
    622 	}
    623 
    624 	return;
    625 }
    626 
    627 
    628 /***********************************************************************
    629  *                        conn_join
    630  ***********************************************************************
    631 DESCRIPTION:	Called by the site manager when detecting that another station joined our own created IBSS
    632 				Valid only if the current connection type is self
    633 				This function calls the self connection SM with join event
    634 
    635 INPUT:      hConn	-	Connection handle.
    636 
    637 OUTPUT:
    638 
    639 RETURN:     OK on success, NOK otherwise
    640 
    641 ************************************************************************/
    642 TI_STATUS conn_ibssStaJoined(TI_HANDLE hConn)
    643 {
    644 	conn_t *pConn = (conn_t *)hConn;
    645 	conn_ibssSMEvent(&pConn->state, CONN_IBSS_STA_JOINED, pConn);
    646 	return OK;
    647 }
    648 
    649 /***********************************************************************
    650  *                        release_module
    651  ***********************************************************************
    652 DESCRIPTION:	Called by the un load function
    653 				Go over the vector, for each bit that is set, release the corresponding module.
    654 
    655 INPUT:      hConn	-	Connection handle.
    656 			initVec	-	Vector that contains a bit set for each module thah had been initiualized
    657 
    658 OUTPUT:
    659 
    660 RETURN:     OK on success, NOK otherwise
    661 
    662 ************************************************************************/
    663 static void release_module(conn_t *pConn, UINT32 initVec)
    664 {
    665 	if (initVec & (1 << IBSS_SM_INIT_BIT))
    666 		fsm_Unload(pConn->hOs, pConn->ibss_pFsm);
    667 
    668     if (initVec & (1 << INFRA_SM_INIT_BIT))
    669 		fsm_Unload(pConn->hOs, pConn->infra_pFsm);
    670 
    671 	if (initVec & (1 << TIMER_INIT_BIT))
    672 		utils_nullTimerDestroy(pConn->hOs, pConn->pTimer);
    673 
    674     if (initVec & (1 << CONN_INIT_BIT))
    675 		utils_nullMemoryFree(pConn->hOs, pConn, sizeof(conn_t));
    676 
    677 	initVec = 0;
    678 }
    679 
    680 
    681 /***********************************************************************
    682  *                        conn_waitToDisassoc
    683  ***********************************************************************
    684 DESCRIPTION:
    685 
    686   INPUT:      hConn	-	Connection handle.
    687 
    688 OUTPUT:
    689 
    690 RETURN:     OK on success, NOK otherwise
    691 
    692 ************************************************************************/
    693 void conn_disConnFrameSentCBFunc(TI_HANDLE hConn)
    694 {
    695 	conn_t *pConn = (conn_t *)hConn;
    696 
    697 	conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONN_COMPLETE, (TI_HANDLE) pConn);
    698 }
    699 
    700 /**
    701 *
    702 * conn_ibssPrintStatistics
    703 *
    704 * \b Description:
    705 *
    706 * Called by Site Manager when request to print statistics is requested from CLI
    707 *
    708 * \b ARGS: Connection handle
    709 *
    710 * \b RETURNS:
    711 *
    712 *  None.
    713 *
    714 * \sa
    715 */
    716 void conn_ibssPrintStatistics(TI_HANDLE hConn)
    717 {
    718 #ifdef REPORT_LOG
    719     conn_t *pConn = (conn_t *)hConn;
    720 
    721     WLAN_OS_REPORT(("- IBSS Disconnect = %d\n", pConn->ibssDisconnectCount));
    722     WLAN_OS_REPORT(("\n"));
    723 #endif
    724 }
    725 
    726