Home | History | Annotate | Download | only in Connection_Managment
      1 /*
      2  * conn.c
      3  *
      4  * Copyright(c) 1998 - 2010 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 conn.c
     35  *  \brief connection module interface
     36  *
     37  *  \see conn.h
     38  */
     39 
     40 /****************************************************************************************************/
     41 /*																									*/
     42 /*		MODULE:		conn.c																			*/
     43 /*		PURPOSE:	Connection module interface. The connection	itself is implemented in the files	*/
     44 /*					connInfra, connIbss & connSelf. This file distributes the events received to 	*/
     45 /*					one of the modules based on the current connection type.						*/
     46 /*																									*/
     47 /****************************************************************************************************/
     48 
     49 
     50 #define __FILE_ID__  FILE_ID_25
     51 #include "tidef.h"
     52 #include "report.h"
     53 #include "osApi.h"
     54 #include "timer.h"
     55 #include "conn.h"
     56 #include "connApi.h"
     57 #include "connIbss.h"
     58 #include "connInfra.h"
     59 #include "802_11Defs.h"
     60 #include "smeApi.h"
     61 #include "paramOut.h"
     62 #include "siteMgrApi.h"
     63 #include "sme.h"
     64 #include "scrApi.h"
     65 #include "healthMonitor.h"
     66 #include "qosMngr_API.h"
     67 #include "TWDriver.h"
     68 #include "DrvMainModules.h"
     69 
     70 
     71 /* Local functions prototypes */
     72 static void release_module(conn_t *pConn);
     73 
     74 static void conn_DisconnectComplete (conn_t *pConn, TI_UINT8  *data, TI_UINT8   dataLength);
     75 
     76 /************************************************************************
     77  *                        conn_create								*
     78  ************************************************************************
     79 DESCRIPTION: Connection module creation function, called by the config mgr in creation phase
     80 				performs the following:
     81 				-	Allocate the connection handle
     82 				-	Create the connection timer
     83 				-	Create the connection state machine
     84 
     85 INPUT:      hOs -			Handle to OS
     86 
     87 
     88 OUTPUT:
     89 
     90 RETURN:     Handle to the connection module on success, NULL otherwise
     91 
     92 ************************************************************************/
     93 TI_HANDLE conn_create(TI_HANDLE hOs)
     94 {
     95 	conn_t *pConn;
     96 	fsm_stateMachine_t *pFsm;
     97 	TI_STATUS status;
     98 
     99 	pConn = os_memoryAlloc(hOs, sizeof(conn_t));
    100 	if (pConn == NULL)
    101 	{
    102 		return NULL;
    103 	}
    104 	os_memoryZero (pConn->hOs, pConn, sizeof(conn_t));
    105 
    106 	/* Creating connection Ibss SM */
    107 	status = fsm_Create(hOs, &pFsm, CONN_IBSS_NUM_STATES, CONN_IBSS_NUM_EVENTS);
    108 	if (status != TI_OK)
    109 	{
    110 		release_module(pConn);
    111 		return NULL;
    112 	}
    113 	pConn->ibss_pFsm = pFsm;
    114 
    115 	/* Creating connection Infra SM */
    116    	status = fsm_Create(hOs, &pFsm, CONN_INFRA_NUM_STATES, CONN_INFRA_NUM_EVENTS);
    117 	if (status != TI_OK)
    118 	{
    119 		release_module(pConn);
    120 		return NULL;
    121 	}
    122 	pConn->infra_pFsm = pFsm;
    123 
    124 	pConn->hOs = hOs;
    125 
    126 	return(pConn);
    127 }
    128 
    129 
    130 /************************************************************************
    131  *                        conn_config									*
    132  ************************************************************************
    133 DESCRIPTION: Connection module configuration function, called by the DrvMain in init phase.
    134 				performs the following:
    135 				-	Reset & initiailzes local variables
    136 				-	Init the handles to be used by the module
    137 
    138 INPUT:      List of handles to be used by the module
    139 
    140 OUTPUT:
    141 
    142 RETURN:     void
    143 
    144 ************************************************************************/
    145 void conn_init (TStadHandlesList *pStadHandles)
    146 {
    147 	conn_t *pConn = (conn_t *)(pStadHandles->hConn);
    148 
    149 	pConn->state = 0;
    150 	os_memoryZero (pConn->hOs, &(pConn->smContext), sizeof(connSmContext_t));
    151 
    152 	pConn->hSiteMgr			= pStadHandles->hSiteMgr;
    153 	pConn->hSmeSm			= pStadHandles->hSme;
    154 	pConn->hMlmeSm			= pStadHandles->hMlmeSm;
    155 	pConn->hRsn				= pStadHandles->hRsn;
    156 	pConn->hRxData			= pStadHandles->hRxData;
    157 	pConn->hReport			= pStadHandles->hReport;
    158 	pConn->hOs				= pStadHandles->hOs;
    159 	pConn->hPwrMngr			= pStadHandles->hPowerMgr;
    160 	pConn->hCtrlData		= pStadHandles->hCtrlData;
    161 	pConn->hMeasurementMgr	= pStadHandles->hMeasurementMgr;
    162 	pConn->hTrafficMonitor  = pStadHandles->hTrafficMon;
    163 	pConn->hScr				= pStadHandles->hSCR;
    164 	pConn->hXCCMngr			= pStadHandles->hXCCMngr;
    165 	pConn->hQosMngr			= pStadHandles->hQosMngr;
    166 	pConn->hTWD		        = pStadHandles->hTWD;
    167     pConn->hScanCncn        = pStadHandles->hScanCncn;
    168 	pConn->hCurrBss			= pStadHandles->hCurrBss;
    169 	pConn->hSwitchChannel	= pStadHandles->hSwitchChannel;
    170 	pConn->hEvHandler		= pStadHandles->hEvHandler;
    171 	pConn->hHealthMonitor	= pStadHandles->hHealthMonitor;
    172 	pConn->hTxMgmtQ		    = pStadHandles->hTxMgmtQ;
    173     pConn->hRegulatoryDomain= pStadHandles->hRegulatoryDomain;
    174     pConn->hTxCtrl          = pStadHandles->hTxCtrl;
    175     pConn->hTimer           = pStadHandles->hTimer;
    176 	pConn->hSoftGemini		= pStadHandles->hSoftGemini;
    177 
    178     TRACE0(pConn->hReport, REPORT_SEVERITY_INIT, ".....Connection configured successfully\n");
    179 }
    180 
    181 
    182 TI_STATUS conn_SetDefaults (TI_HANDLE 	hConn, connInitParams_t		*pConnInitParams)
    183 {
    184     conn_t *pConn = (conn_t *)hConn;
    185 
    186     pConn->timeout			   = pConnInitParams->connSelfTimeout;
    187 	pConn->connType			   = CONN_TYPE_FIRST_CONN;
    188     pConn->ibssDisconnectCount = 0;
    189 
    190 	/* allocate OS timer memory */
    191     pConn->hConnTimer = tmr_CreateTimer (pConn->hTimer);
    192 	if (pConn->hConnTimer == NULL)
    193 	{
    194         TRACE0(pConn->hReport, REPORT_SEVERITY_ERROR, "conn_SetDefaults(): Failed to create hConnTimer!\n");
    195 		release_module (pConn);
    196 		return TI_NOK;
    197 	}
    198 
    199 	TWD_RegisterEvent (pConn->hTWD,
    200                        TWD_OWN_EVENT_JOIN_CMPLT,
    201 					   (void *)connInfra_JoinCmpltNotification,
    202                        pConn);
    203 
    204 	TWD_EnableEvent (pConn->hTWD, TWD_OWN_EVENT_JOIN_CMPLT);
    205 
    206 	 /* Register for 'TWD_OWN_EVENT_DISCONNECT_COMPLETE' event */
    207     TWD_RegisterEvent (pConn->hTWD, TWD_OWN_EVENT_DISCONNECT_COMPLETE, (void *)conn_DisconnectComplete, pConn);
    208 	TWD_EnableEvent (pConn->hTWD, TWD_OWN_EVENT_DISCONNECT_COMPLETE);
    209 
    210 	return TI_OK;
    211 }
    212 
    213 /************************************************************************
    214  *                        conn_unLoad									*
    215  ************************************************************************
    216 DESCRIPTION: Connection module unload function, called by the config mgr in the unlod phase
    217 				performs the following:
    218 				-	Free all memory aloocated by the module
    219 
    220 INPUT:      hConn	-	Connection handle.
    221 
    222 
    223 OUTPUT:
    224 
    225 RETURN:     TI_OK on success, TI_NOK otherwise
    226 
    227 ************************************************************************/
    228 TI_STATUS conn_unLoad(TI_HANDLE hConn)
    229 {
    230 	conn_t			*pConn = (conn_t *)hConn;
    231 
    232 	if (!pConn)
    233     {
    234 		return TI_OK;
    235     }
    236 
    237 	release_module(pConn);
    238 
    239 	return TI_OK;
    240 }
    241 
    242 /***********************************************************************
    243  *                        conn_setParam
    244  ***********************************************************************
    245 DESCRIPTION: Connection set param function, called by the following:
    246 				-	config mgr in order to set a parameter from the OS abstraction layer.
    247 				-	Form inside the driver
    248 				In this fuction, the site manager configures the connection type in the select phase.
    249 				The connection type is used to distribute the connection events to the corresponding connection SM
    250 
    251 INPUT:      hConn	-	Connection handle.
    252 			pParam	-	Pointer to the parameter
    253 
    254 OUTPUT:
    255 
    256 RETURN:     TI_OK on success, TI_NOK otherwise
    257 
    258 ************************************************************************/
    259 TI_STATUS conn_setParam(TI_HANDLE		hConn,
    260 					 paramInfo_t	*pParam)
    261 {
    262 	conn_t *pConn = (conn_t *)hConn;
    263 
    264 	switch(pParam->paramType)
    265 	{
    266 	case CONN_TYPE_PARAM:
    267 		pConn->currentConnType = pParam->content.connType;
    268 		switch (pParam->content.connType)
    269 		{
    270 		case CONNECTION_IBSS:
    271 		case CONNECTION_SELF:
    272 			return conn_ibssConfig(pConn);
    273 
    274 		case CONNECTION_INFRA:
    275 			return conn_infraConfig(pConn);
    276 
    277 		default:
    278 TRACE1(pConn->hReport, REPORT_SEVERITY_ERROR, "Set connection type, type is not valid, %d\n\n", pParam->content.connType);
    279 			return PARAM_VALUE_NOT_VALID;
    280 		}
    281 
    282 	case CONN_SELF_TIMEOUT_PARAM:
    283 		if ((pParam->content.connSelfTimeout < CONN_SELF_TIMEOUT_MIN) || (pParam->content.connSelfTimeout > CONN_SELF_TIMEOUT_MAX))
    284 			return PARAM_VALUE_NOT_VALID;
    285 		pConn->timeout = pParam->content.connSelfTimeout;
    286 		break;
    287 
    288 	default:
    289 TRACE1(pConn->hReport, REPORT_SEVERITY_ERROR, "Set param, Params is not supported, %d\n\n", pParam->paramType);
    290 		return PARAM_NOT_SUPPORTED;
    291 	}
    292 
    293 	return TI_OK;
    294 }
    295 
    296 /***********************************************************************
    297  *                        conn_getParam
    298  ***********************************************************************
    299 DESCRIPTION: Connection get param function, called by the following:
    300 			-	config mgr in order to get a parameter from the OS abstraction layer.
    301 			-	Fomr inside the dirver
    302 
    303 INPUT:      hConn	-	Connection handle.
    304 			pParam	-	Pointer to the parameter
    305 
    306 OUTPUT:
    307 
    308 RETURN:     TI_OK on success, TI_NOK otherwise
    309 
    310 ************************************************************************/
    311 TI_STATUS conn_getParam(TI_HANDLE		hConn,
    312 					 paramInfo_t	*pParam)
    313 {
    314 	conn_t *pConn = (conn_t *)hConn;
    315 
    316 	switch(pParam->paramType)
    317 	{
    318 	case CONN_TYPE_PARAM:
    319 		pParam->content.connType = pConn->currentConnType;
    320 		break;
    321 
    322 	case CONN_SELF_TIMEOUT_PARAM:
    323 		pParam->content.connSelfTimeout = pConn->timeout;
    324 		break;
    325 
    326 	default:
    327 TRACE1(pConn->hReport, REPORT_SEVERITY_ERROR, "Get param, Params is not supported, %d\n\n", pParam->paramType);
    328 		return PARAM_NOT_SUPPORTED;
    329 	}
    330 
    331 	return TI_OK;
    332 }
    333 
    334 /***********************************************************************
    335  *                        conn_start
    336  ***********************************************************************
    337 DESCRIPTION: Called by the SME SM in order to start the connection SM
    338 			 This function start the current connection SM
    339 
    340 INPUT:      hConn	-	Connection handle.
    341 
    342 OUTPUT:
    343 
    344 RETURN:     TI_OK on success, TI_NOK otherwise
    345 
    346 ************************************************************************/
    347 TI_STATUS conn_start(TI_HANDLE hConn,
    348                      EConnType connType,
    349 		     conn_status_callback_t  pConnStatusCB,
    350 		     TI_HANDLE connStatCbObj,
    351    		     TI_BOOL disConEraseKeys,
    352 		     TI_BOOL reNegotiateTspec)
    353 {
    354 	conn_t *pConn = (conn_t *)hConn;
    355 	paramInfo_t param;
    356 
    357 	pConn->pConnStatusCB = pConnStatusCB;
    358 	pConn->connStatCbObj = connStatCbObj;
    359 
    360 	pConn->connType = connType;
    361 	pConn->disConEraseKeys = disConEraseKeys;
    362 
    363 	/* Initialize the DISASSOCIATE event parameters to default */
    364 	pConn->smContext.disAssocEventReason = STATUS_UNSPECIFIED;
    365 	pConn->smContext.disAssocEventStatusCode  = 0;
    366 
    367 
    368 	/* If requested, re-negotiate voice TSPEC */
    369 	param.paramType = QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC;
    370 	param.content.TspecConfigure.voiceTspecConfigure = reNegotiateTspec;
    371     param.content.TspecConfigure.videoTspecConfigure = reNegotiateTspec;
    372 
    373 	qosMngr_setParams(pConn->hQosMngr, &param);
    374 
    375 	switch(pConn->currentConnType)
    376 	{
    377 	case CONNECTION_IBSS:
    378 		return conn_ibssSMEvent(&pConn->state, CONN_IBSS_CONNECT, (TI_HANDLE) pConn);
    379 
    380 	case CONNECTION_SELF:
    381 		return conn_ibssSMEvent(&pConn->state, CONN_IBSS_CREATE, (TI_HANDLE) pConn);
    382 
    383 	case CONNECTION_INFRA:
    384 		return conn_infraSMEvent(&pConn->state, CONN_INFRA_CONNECT, (TI_HANDLE) pConn);
    385 
    386     default:
    387 TRACE1(pConn->hReport, REPORT_SEVERITY_ERROR, "Start connection, invalid type %d\n\n", pConn->currentConnType);
    388 		return TI_NOK;
    389 
    390 	}
    391 }
    392 
    393 /***********************************************************************
    394  *                        conn_stop
    395  ***********************************************************************
    396 DESCRIPTION: Called by the SME SM in order to stop the connection SM
    397 			 This function stop the current connection SM.
    398 
    399 INPUT:      hConn	-	Connection handle.
    400 
    401 OUTPUT:
    402 
    403 RETURN:     TI_OK on success, TI_NOK otherwise
    404 
    405 ************************************************************************/
    406 TI_STATUS conn_stop(TI_HANDLE 				hConn,
    407 					DisconnectType_e		disConnType,
    408 					mgmtStatus_e 			reason,
    409 					TI_BOOL					disConEraseKeys,
    410 					conn_status_callback_t  pConnStatusCB,
    411 					TI_HANDLE 				connStatCbObj  )
    412 {
    413 	conn_t *pConn = (conn_t *)hConn;
    414 
    415 	pConn->pConnStatusCB = pConnStatusCB;
    416 	pConn->connStatCbObj = connStatCbObj;
    417 
    418 	pConn->disConnType 	 = disConnType;
    419 	pConn->disConnReasonToAP = reason;
    420 	pConn->disConEraseKeys = disConEraseKeys;
    421 
    422 	/*
    423 	 * Mark the disconnection reason as unspecified to indicate that conn module has no information regarding the DISASSOCIATE event to be raised
    424 	 * by the SME
    425 	 */
    426 	pConn->smContext.disAssocEventReason = STATUS_UNSPECIFIED;
    427 	pConn->smContext.disAssocEventStatusCode  = 0;
    428 
    429 
    430     TRACE3(pConn->hReport, REPORT_SEVERITY_INFORMATION, "conn_stop, disConnType %d, reason=%d, disConEraseKeys=%d\n\n", disConnType, reason, disConEraseKeys);
    431 
    432 	switch(pConn->currentConnType)
    433 	{
    434 	case CONNECTION_IBSS:
    435 	case CONNECTION_SELF:
    436         pConn->ibssDisconnectCount++;
    437 		return conn_ibssSMEvent(&pConn->state, CONN_IBSS_DISCONNECT, (TI_HANDLE) pConn);
    438 
    439 	case CONNECTION_INFRA:
    440 		return conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONNECT, (TI_HANDLE) pConn);
    441 
    442 
    443 	default:
    444 TRACE1(pConn->hReport, REPORT_SEVERITY_ERROR, "Stop connection, invalid type %d\n\n", pConn->currentConnType);
    445 		return TI_NOK;
    446 	}
    447 }
    448 
    449 
    450 /***********************************************************************
    451  *                        conn_reportMlmeStatus
    452  ***********************************************************************
    453 DESCRIPTION:	Called by the MLME SM when MLME status changed.
    454 				Valid only in the case that the current connection type is infrastructure
    455 				The function calls the connection infra SM with MLME success or MLME failure
    456 				according to the status
    457 
    458 INPUT:      hConn	-	Connection handle.
    459 			status	-	MLME status
    460 
    461 OUTPUT:
    462 
    463 RETURN:     TI_OK on success, TI_NOK otherwise
    464 
    465 ************************************************************************/
    466 TI_STATUS conn_reportMlmeStatus(TI_HANDLE			hConn,
    467 							mgmtStatus_e		status,
    468 							TI_UINT16				uStatusCode)
    469 {
    470 	conn_t *pConn = (conn_t *)hConn;
    471 
    472 
    473 	/* Save the reason for the use of the SME when triggering DISASSOCIATE event */
    474 	pConn->smContext.disAssocEventReason = status;
    475 	pConn->smContext.disAssocEventStatusCode = uStatusCode;
    476 
    477 	if (status == STATUS_SUCCESSFUL)
    478 	{
    479 		conn_infraSMEvent(&pConn->state, CONN_INFRA_MLME_SUCC, pConn);
    480 	}
    481 	else
    482 	{
    483         TRACE0(pConn->hReport, REPORT_SEVERITY_CONSOLE,"-------------------------------------\n");
    484         TRACE0(pConn->hReport, REPORT_SEVERITY_CONSOLE,"               CONN LOST             \n");
    485         TRACE0(pConn->hReport, REPORT_SEVERITY_CONSOLE,"-------------------------------------\n");
    486 
    487 #ifdef REPORT_LOG
    488 		WLAN_OS_REPORT(("-------------------------------------\n"));
    489 		WLAN_OS_REPORT(("               CONN LOST             \n"));
    490 		WLAN_OS_REPORT(("-------------------------------------\n"));
    491 #else
    492 		os_printf("%s: *** CONN LOST ***\n", __func__);
    493 #endif
    494 		if( pConn->connType == CONN_TYPE_ROAM )
    495 			pConn->disConnType = DISCONNECT_IMMEDIATE;
    496 		else /* connType == CONN_TYPE_ESS */
    497 			pConn->disConnType = DISCONNECT_DE_AUTH;
    498 
    499         TRACE4(pConn->hReport, REPORT_SEVERITY_INFORMATION, "conn_reportMlmeStatus, disAssocEventReason %d, disAssocEventStatusCode = %d, connType=%d, disConnType=%d \n", pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode, pConn->connType, pConn->disConnType);
    500 
    501 		conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONNECT, pConn);
    502 	}
    503 
    504 	return TI_OK;
    505 }
    506 
    507 /***********************************************************************
    508  *                        conn_reportRsnStatus
    509  ***********************************************************************
    510 DESCRIPTION:	Called by the RSN SM when RSN status changed.
    511 				This function calls the current connection SM with RSN success or RSN failure based on the status
    512 
    513 INPUT:      hConn	-	Connection handle.
    514 			status	-	RSN status
    515 
    516 OUTPUT:
    517 
    518 RETURN:     TI_OK on success, TI_NOK otherwise
    519 
    520 ************************************************************************/
    521 TI_STATUS conn_reportRsnStatus(TI_HANDLE			hConn,
    522 							mgmtStatus_e		status)
    523 {
    524 	conn_t *pConn = (conn_t *)hConn;
    525 
    526 	/* Save the reason for the use of the SME when triggering DISASSOCIATE event. For now we just have STATUS_SECURITY_FAILURE */
    527 	pConn->smContext.disAssocEventReason = status;
    528 	pConn->smContext.disAssocEventStatusCode = 1; /* we use this status at SME, if != 0 means that assoc frame sent */
    529 
    530 	switch(pConn->currentConnType)
    531 	{
    532 	case CONNECTION_IBSS:
    533 	case CONNECTION_SELF:
    534 		if (status == STATUS_SUCCESSFUL)
    535 			return conn_ibssSMEvent(&pConn->state, CONN_IBSS_RSN_SUCC, (TI_HANDLE) pConn);
    536 		else
    537 			return conn_ibssSMEvent(&pConn->state, CONN_IBSS_DISCONNECT, (TI_HANDLE) pConn);
    538 
    539 
    540 
    541 	case CONNECTION_INFRA:
    542 		if (status == STATUS_SUCCESSFUL)
    543 			return conn_infraSMEvent(&pConn->state, CONN_INFRA_RSN_SUCC, (TI_HANDLE) pConn);
    544 
    545 		else{ /* status == STATUS_SECURITY_FAILURE */
    546 			/*
    547 			 * In infrastructure - if the connection is standard 802.11 connection (ESS) then
    548 			 * need to disassociate. In roaming mode, the connection is stopped without sending
    549 			 * the reassociation frame.
    550 			 */
    551 			if( pConn->connType == CONN_TYPE_ROAM )
    552 				pConn->disConnType = DISCONNECT_IMMEDIATE;
    553 			else /* connType == CONN_TYPE_ESS */
    554 				pConn->disConnType = DISCONNECT_DE_AUTH;
    555 
    556             TRACE3(pConn->hReport, REPORT_SEVERITY_INFORMATION, "conn_reportRsnStatus, disAssocEventReason %d, connType=%d, disConnType=%d \n\n", pConn->smContext.disAssocEventReason, pConn->connType, pConn->disConnType);
    557 
    558 			return conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONNECT, (TI_HANDLE) pConn);
    559 		}
    560 	case CONNECTION_NONE:
    561 		break;
    562 	}
    563 
    564 	return TI_OK;
    565 }
    566 
    567 /***********************************************************************
    568  *                        conn_timeout
    569  ***********************************************************************
    570 DESCRIPTION:	Called by the OS abstraction layer when the self timer expired
    571 				Valid only if the current connection type is self
    572 				This function calls the self connection SM with timeout event
    573 
    574 INPUT:      hConn	-	Connection handle.
    575             bTwdInitOccured -   Indicates if TWDriver recovery occured since timer started
    576 
    577 OUTPUT:
    578 
    579 RETURN:     TI_OK on success, TI_NOK otherwise
    580 
    581 ************************************************************************/
    582 void conn_timeout (TI_HANDLE hConn, TI_BOOL bTwdInitOccured)
    583 {
    584 	conn_t *pConn = (conn_t *)hConn;
    585 
    586 	switch(pConn->currentConnType)
    587 	{
    588 	case CONNECTION_IBSS:
    589 	case CONNECTION_SELF:
    590 		conn_ibssSMEvent(&pConn->state, CONN_IBSS_DISCONNECT, pConn);
    591 		break;
    592 
    593 	case CONNECTION_INFRA:
    594 		conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONN_COMPLETE, (TI_HANDLE) pConn);
    595         /* Initiate recovery only if not already occured. */
    596         if (!bTwdInitOccured)
    597         {
    598 		healthMonitor_sendFailureEvent(pConn->hHealthMonitor, DISCONNECT_TIMEOUT);
    599         }
    600 		break;
    601 
    602 	case CONNECTION_NONE:
    603 		break;
    604 	}
    605 
    606 	return;
    607 }
    608 
    609 
    610 /***********************************************************************
    611  *                        conn_join
    612  ***********************************************************************
    613 DESCRIPTION:	Called by the site manager when detecting that another station joined our own created IBSS
    614 				Valid only if the current connection type is self
    615 				This function calls the self connection SM with join event
    616 
    617 INPUT:      hConn	-	Connection handle.
    618 
    619 OUTPUT:
    620 
    621 RETURN:     TI_OK on success, TI_NOK otherwise
    622 
    623 ************************************************************************/
    624 TI_STATUS conn_ibssStaJoined(TI_HANDLE hConn)
    625 {
    626 	conn_t *pConn = (conn_t *)hConn;
    627 
    628 	conn_ibssSMEvent(&pConn->state, CONN_IBSS_STA_JOINED, pConn);
    629 	return TI_OK;
    630 }
    631 
    632 
    633 TI_STATUS conn_ibssMerge(TI_HANDLE hConn)
    634 {
    635 	conn_t *pConn = (conn_t *)hConn;
    636 
    637 	conn_ibssSMEvent(&pConn->state, CONN_IBSS_MERGE, pConn);
    638 	return TI_OK;
    639 }
    640 
    641 
    642 
    643 /***********************************************************************
    644  *                        release_module
    645  ***********************************************************************
    646 DESCRIPTION:	Release all module resources - FSMs, timer and object.
    647 
    648 INPUT:      hConn	-	Connection handle.
    649 
    650 OUTPUT:
    651 
    652 RETURN:     void
    653 
    654 ************************************************************************/
    655 static void release_module(conn_t *pConn)
    656 {
    657 	if (pConn->ibss_pFsm)
    658     {
    659 		fsm_Unload (pConn->hOs, pConn->ibss_pFsm);
    660     }
    661 
    662     if (pConn->infra_pFsm)
    663     {
    664 		fsm_Unload (pConn->hOs, pConn->infra_pFsm);
    665     }
    666 
    667 	if (pConn->hConnTimer)
    668     {
    669 		tmr_DestroyTimer (pConn->hConnTimer);
    670     }
    671 
    672 	os_memoryFree(pConn->hOs, pConn, sizeof(conn_t));
    673 }
    674 
    675 static void conn_DisconnectComplete (conn_t *pConn, TI_UINT8  *data, TI_UINT8   dataLength)
    676 {
    677 	switch(pConn->currentConnType)
    678 	{
    679 	case CONNECTION_IBSS:
    680 		connIbss_DisconnectComplete(pConn, data, dataLength);
    681 		break;
    682 
    683 	case CONNECTION_SELF:
    684 		connIbss_DisconnectComplete(pConn, data, dataLength);
    685 		break;
    686 
    687 	case CONNECTION_INFRA:
    688 		connInfra_DisconnectComplete(pConn, data, dataLength);
    689 		break;
    690 
    691     default:
    692 		TRACE1(pConn->hReport, REPORT_SEVERITY_ERROR, "conn_DisconnectComplete, invalid type %d\n\n", pConn->currentConnType);
    693 
    694 	}
    695 }
    696 
    697 
    698 #ifdef REPORT_LOG
    699 /**
    700 *
    701 * conn_ibssPrintStatistics
    702 *
    703 * \b Description:
    704 *
    705 * Called by Site Manager when request to print statistics is requested from CLI
    706 *
    707 * \b ARGS: Connection handle
    708 *
    709 * \b RETURNS:
    710 *
    711 *  None.
    712 *
    713 * \sa
    714 */
    715 void conn_ibssPrintStatistics(TI_HANDLE hConn)
    716 {
    717     conn_t *pConn = (conn_t *)hConn;
    718 
    719     WLAN_OS_REPORT(("- IBSS Disconnect = %d\n", pConn->ibssDisconnectCount));
    720     WLAN_OS_REPORT(("\n"));
    721 }
    722 #endif /*#ifdef REPORT_LOG*/
    723 
    724 
    725