PageRenderTime 55ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/Management/apConn/apConn.c

https://bitbucket.org/cyanogenmod/cm-kernel
C | 2787 lines | 1366 code | 329 blank | 1092 comment | 141 complexity | a29c4f7cede1ef95734795242c7e3f22 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 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. ****************************************************************************/
  35. /** \file apConn.c
  36. * \brief AP Connection
  37. *
  38. * \see apConn.h
  39. */
  40. /****************************************************************************
  41. * *
  42. * MODULE: AP Connection *
  43. * PURPOSE: *
  44. * Roaming ability of eSTA is implemented by Roaming Manager Component and
  45. * described in "Roaming Manager module LLD" document, and by
  46. * AP Connection module. AP Connection module implemented as two sub-modules:
  47. * The major one is AP Connection, that is responsible for:
  48. * - providing Roaming Manager with access to other parts of WLAN Driver,
  49. * - implementing low levels of roaming mechanism.
  50. * Current BSS sub-module takes care of:
  51. * - maintaining database of current AP info,
  52. * - providing access to database of current AP info.
  53. * *
  54. ****************************************************************************/
  55. #include "osApi.h"
  56. #include "paramIn.h"
  57. #include "report.h"
  58. #include "utils.h"
  59. #include "smeSmApi.h"
  60. #include "siteMgrApi.h"
  61. #include "smeApi.h"
  62. #include "PowerMgr_API.h"
  63. #include "TrafficMonitorAPI.h"
  64. #include "RateAdaptation.h"
  65. #include "qosMngr_API.h"
  66. #ifdef EXC_MODULE_INCLUDED
  67. #include "excMngr.h"
  68. #endif
  69. #include "measurementMgrApi.h"
  70. #include "connApi.h"
  71. #include "EvHandler.h"
  72. #include "apConn.h"
  73. #include "currBss.h"
  74. #include "Ctrl.h"
  75. #include "fsm.h"
  76. #include "scrApi.h"
  77. #include "regulatoryDomainApi.h"
  78. /* Constants and macros */
  79. #ifdef TI_DBG
  80. #define AP_CONN_VALIDATE_HANDLE(hAPConnection) \
  81. if (hAPConnection == NULL) \
  82. { \
  83. WLAN_OS_REPORT(("FATAL ERROR: AP Connection context is not initiated\n")); \
  84. return NOK; \
  85. }
  86. #else
  87. #define AP_CONN_VALIDATE_HANDLE(hAPConnection)
  88. #endif
  89. #define MAX_ROAMING_TRIGGERS ROAMING_TRIGGER_LAST
  90. #define UPDATE_SEND_DEAUTH_PACKET_FLAG(roamingEventType) \
  91. if ((roamingEventType >= ROAMING_TRIGGER_MAX_TX_RETRIES) && \
  92. (roamingEventType != ROAMING_TRIGGER_SECURITY_ATTACK)) \
  93. { \
  94. pAPConnection->sendDeauthPacket = FALSE; \
  95. }
  96. /* Init bits */
  97. /* Enumerations */
  98. /**
  99. * AP Connection state machine states
  100. */
  101. typedef enum
  102. {
  103. AP_CONNECT_STATE_IDLE = 0, /**< Initial state */
  104. AP_CONNECT_STATE_WAIT_ROAM, /**< Connected to AP, waiting for start roaming command */
  105. AP_CONNECT_STATE_SWITCHING_CHANNEL, /**< Connected to AP, switch channel in progress */
  106. AP_CONNECT_STATE_WAIT_CONNECT_CMD, /**< SCR allocated, PS mode entered; wait for cmd from Roam Mngr */
  107. AP_CONNECT_STATE_PREPARE_HAND_OFF, /**< Request CCKM for new AP, wait for response */
  108. AP_CONNECT_STATE_CONNECTING, /**< Performing Connection to new AP; wait for response from Conn SM */
  109. AP_CONNECT_STATE_DISCONNECTING, /**< Wait for completion of current link disconnection */
  110. AP_CONNECT_STATE_REESTABLISH_VOICE, /**< Wait for completion of voice TSPEC re-negotiation */
  111. AP_CONNECT_STATE_LAST
  112. } apConn_smStates;
  113. /**
  114. * AP Connection state machine events
  115. */
  116. typedef enum
  117. {
  118. AP_CONNECT_EVENT_PREPARE_FOR_ROAMING= 0,/**< Sent by Roam MNGR when roaming event occurs */
  119. AP_CONNECT_EVENT_FINISHED_OK, /**< Indicates successful completion of request sent to Conn SM */
  120. AP_CONNECT_EVENT_FINISHED_NOT_OK, /**< Indicates unsuccessful completion of request sent to Conn SM */
  121. AP_CONNECT_EVENT_RETAIN_CURRENT_AP, /**< Sent by Roam MNGR when it wishes to give-up roaming */
  122. AP_CONNECT_EVENT_START, /**< Sent by SME when first time link to AP is established */
  123. AP_CONNECT_EVENT_START_ROAM, /**< Sent by Roam MNGR when it wishes to roam to new AP */
  124. AP_CONNECT_EVENT_START_SWITCH_CHANNEL, /**< Sent by Switch channel module when starting switch channel process (tx enabled) */
  125. AP_CONNECT_EVENT_FINISHED_SWITCH_CH, /**< Sent by Switch channel module when finishing switch channel process (tx enabled) */
  126. AP_CONNECT_EVENT_FINISHED_HAND_OVER, /**< Sent by EXC module when finishing hand-over */
  127. AP_CONNECT_EVENT_STOP, /**< Disconnect current link, send stop indication to other modules */
  128. AP_CONNECT_EVENT_LAST
  129. } apConn_smEvents;
  130. #define AP_CONNECT_NUM_STATES AP_CONNECT_STATE_LAST
  131. #define AP_CONNECT_NUM_EVENTS AP_CONNECT_EVENT_LAST
  132. #ifdef REPORT_LOG
  133. /* Global variables */
  134. static char *apConn_stateDesc[AP_CONNECT_NUM_STATES] = {
  135. "APC_STATE_IDLE",
  136. "APC_STATE_WAIT_ROAM",
  137. "APC_STATE_SWITCHING_CHANNEL",
  138. "APC_STATE_WAIT_CONNECT_CMD",
  139. "APC_STATE_PREPARE_HAND_OFF",
  140. "APC_STATE_CONNECTING",
  141. "APC_STATE_DISCONNECTING",
  142. "APC_STATE_REESTABLISH_VOICE"
  143. };
  144. static char *apConn_eventDesc[AP_CONNECT_NUM_EVENTS] = {
  145. "APC_EVENT_PREPARE_FOR_ROAMING",
  146. "APC_EVENT_FINISHED_OK",
  147. "APC_EVENT_FINISHED_NOT_OK",
  148. "APC_EVENT_RETAIN_CURRENT_AP",
  149. "APC_EVENT_START",
  150. "APC_EVENT_START_ROAM",
  151. "APC_EVENT_START_SWITCH_CHANNEL",
  152. "APC_EVENT_FINISHED_SWITCH_CHANNEL",
  153. "APC_EVENT_FINISHED_HAND_OVER",
  154. "APC_EVENT_STOP"
  155. };
  156. #endif
  157. /* Typedefs */
  158. /* Structures */
  159. /**
  160. * AP Connection control block
  161. * Following structure defines parameters that can be configured externally,
  162. * internal variables, AP Connection state machine and handlers of other modules
  163. * used by AP Connection module
  164. */
  165. typedef struct _apConn_t
  166. {
  167. /* AP Connection state machine */
  168. fsm_stateMachine_t *apConnSM; /**< AP Connection module state machine */
  169. apConn_smStates currentState; /**< AP Connection state machine current state */
  170. /* Internal parameters */
  171. BOOL firstAttempt2Roam; /**< TRUE if still connected to original AP, FALSE otherwise */
  172. BOOL roamingEnabled; /**< If FALSE, act like if no roaming callback registered. */
  173. apConn_roamingTrigger_e roamReason; /**< The most severe and recent reason for roaming */
  174. APDisconnect_t APDisconnect; /**< The AP disconnect trigger extra information */
  175. bssEntry_t *newAP; /**< Stores parameters of roaming candidate */
  176. apConn_connRequest_e requestType; /**< Stores type of roaming request */
  177. INT8 rssiThreshold; /**< Stores recently configured RSSI threshold */
  178. UINT8 snrThreshold; /**< Stores recently configured SNR threshold */
  179. UINT8 txFailureThreshold; /**< Stores recently configured consec. no ack threshold */
  180. UINT8 lowRateThreshold; /**< Stores recently configured consec. no ack threshold */
  181. UINT32 vsIElength; /**< Length of vendor specific info-element for assoc req (if defined) */
  182. char *vsIEbuf; /**< Pointer to vendor specific info-element for assoc req (if defined) */
  183. BOOL isRssiTriggerMaskedOut;
  184. BOOL isSnrTriggerMaskedOut;
  185. BOOL isConsTxFailureMaskedOut;
  186. BOOL islowRateTriggerMaskedOut;
  187. BOOL removeKeys; /**< Indicates whether keys should be removed after disconnect or not */
  188. BOOL ignoreDeauthReason0;/**< Indicates whether to ignore DeAuth with reason 0, required for Rogue AP test EXC-V2 */
  189. BOOL sendDeauthPacket; /**< Indicates whether to send DEAUTH packet when discommecting or not */
  190. BOOL voiceTspecConfigured;/**< Shall be set to TRUE before roaming in case the TSPEC is configured */
  191. BOOL videoTspecConfigured;/**< Shall be set to TRUE before roaming in case the TSPEC is configured */
  192. BOOL reNegotiateTSPEC; /**< Shall be set to TRUE before hand-over if requested by Roaming Manager */
  193. BOOL resetReportedRoamingStatistics; /**< Shall be set to TRUE if starting to measure traffic */
  194. UINT16 lastRoamingDelay;
  195. UINT32 roamingStartedTimestamp;
  196. UINT8 roamingSuccesfulHandoverNum;
  197. BOOL bNonRoamingDisAssocReason; /**< Indicate whether last disconnection was called from outside (SME) */
  198. /** Callback functions, registered by Roaming manager */
  199. apConn_roamMngrCallb_t roamEventCallb; /**< roam event triggers */
  200. apConn_roamMngrCallb_t reportStatusCallb; /**< connection status events */
  201. apConn_roamMngrCallb_t returnNeighborApsCallb; /**< neighbor APs list update */
  202. /* Handlers of other modules used by AP Connection */
  203. TI_HANDLE hOs;
  204. TI_HANDLE hReport;
  205. TI_HANDLE hCurrBSS;
  206. TI_HANDLE hRoamMng;
  207. TI_HANDLE hSme;
  208. TI_HANDLE hSiteMgr;
  209. TI_HANDLE hExcMngr;
  210. TI_HANDLE hConnSm;
  211. TI_HANDLE hPrivacy;
  212. TI_HANDLE hQos;
  213. TI_HANDLE hRateAdapt;
  214. TI_HANDLE hEvHandler;
  215. TI_HANDLE hScr;
  216. TI_HANDLE hAssoc;
  217. TI_HANDLE hRegulatoryDomain;
  218. /* Counters for statistics */
  219. UINT32 roamingTriggerEvents[MAX_ROAMING_TRIGGERS];
  220. UINT32 roamingSuccesfulHandoverTotalNum;
  221. UINT32 roamingFailedHandoverNum;
  222. UINT32 retainCurrAPNum;
  223. UINT32 disconnectFromRoamMngrNum;
  224. UINT32 stopFromSmeNum;
  225. } apConn_t;
  226. /* Internal functions prototypes */
  227. /* SM functions */
  228. static TI_STATUS apConn_smEvent(apConn_smStates *currState, UINT8 event, void* data);
  229. static TI_STATUS apConn_smNop(void *pData);
  230. static TI_STATUS apConn_smUnexpected(void *pData);
  231. static TI_STATUS apConn_startWaitingForTriggers(void *pData);
  232. static TI_STATUS apConn_connectedToNewAP(void *pData);
  233. static TI_STATUS apConn_configureDriverBeforeRoaming(void *pData);
  234. static TI_STATUS apConn_stopConnection(void *pData);
  235. static TI_STATUS apConn_invokeConnectionToNewAp(void *pData);
  236. static TI_STATUS apConn_reportDisconnected(void *pData);
  237. static TI_STATUS apConn_retainAP(void *pData);
  238. static TI_STATUS apConn_requestCCKM(void *pData);
  239. static TI_STATUS apConn_reportConnFail(void *pData);
  240. static TI_STATUS apConn_swChFinished(void *pData);
  241. static TI_STATUS apConn_handleTspecReneg (void *pData);
  242. /* other functions */
  243. #ifdef EXC_MODULE_INCLUDED
  244. static void apConn_calcNewTsf(apConn_t *hAPConnection, UINT8 *tsfTimeStamp, UINT32 newSiteOsTimeStamp, UINT32 beaconInterval);
  245. #endif
  246. static TI_STATUS apConn_qosMngrReportResultCallb (TI_HANDLE hApConn, trafficAdmRequestStatus_e result);
  247. static void apConn_reportConnStatusToSME (apConn_t *pAPConnection);
  248. /* Public functions implementation */
  249. /**
  250. *
  251. * apConn_create
  252. *
  253. * \b Description:
  254. *
  255. * Create the AP Connection context:
  256. * allocate memory for internal variables;
  257. * create state machine.
  258. *
  259. * \b ARGS:
  260. *
  261. * I - hOs - OS handler
  262. *
  263. * \b RETURNS:
  264. *
  265. * Pointer to the AP Connection on success, NULL on failure
  266. * (unable to allocate memory or other error).
  267. *
  268. * \sa
  269. */
  270. TI_HANDLE apConn_create(TI_HANDLE hOs)
  271. {
  272. TI_STATUS status;
  273. apConn_t *pAPConnection;
  274. if ((pAPConnection = os_memoryAlloc(hOs, sizeof(apConn_t))) != NULL)
  275. {
  276. pAPConnection->hOs = hOs;
  277. status = fsm_Create(hOs, &(pAPConnection->apConnSM), AP_CONNECT_NUM_STATES, AP_CONNECT_NUM_EVENTS);
  278. if (status == OK)
  279. {
  280. /* Succeeded to create AP Connection module context - return pointer to it */
  281. return pAPConnection;
  282. }
  283. else /* Failed to create state machine */
  284. {
  285. WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error creating apConnSM - aborting\n"));
  286. /* Free pre-allocated control block */
  287. utils_nullMemoryFree(hOs, pAPConnection, sizeof(apConn_t));
  288. return NULL;
  289. }
  290. }
  291. else /* Failed to allocate control block */
  292. {
  293. WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error allocating cb - aborting\n"));
  294. return NULL;
  295. }
  296. }
  297. /**
  298. *
  299. * apConn_unload
  300. *
  301. * \b Description:
  302. *
  303. * Finish AP Connection module work:
  304. * release the allocation for state machine and internal variables.
  305. *
  306. * \b ARGS:
  307. *
  308. *
  309. * \b RETURNS:
  310. *
  311. * OK if successful, NOK otherwise.
  312. *
  313. * \sa
  314. */
  315. TI_STATUS apConn_unload(TI_HANDLE hAPConnection)
  316. {
  317. apConn_t *pAPConnection;
  318. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  319. pAPConnection = (apConn_t *)hAPConnection;
  320. /* Unload state machine */
  321. fsm_Unload(pAPConnection->hOs, pAPConnection->apConnSM);
  322. /* Free pre-allocated control block */
  323. utils_nullMemoryFree(pAPConnection->hOs, pAPConnection, sizeof(apConn_t));
  324. return OK;
  325. }
  326. /**
  327. *
  328. * apConn_config
  329. *
  330. * \b Description:
  331. *
  332. * Prepare AP Connection module to work: initiate internal variables, start state machine
  333. *
  334. * \b ARGS:
  335. *
  336. * I - hCurrAP - Current BSS handle \n
  337. * I - hRoamMng - Roaming Manager handle \n
  338. * I - hSme - SME context \n
  339. * I - hPowerMgr - Power Manager context \n
  340. *
  341. * \b RETURNS:
  342. *
  343. * OK on success, NOK on failure.
  344. *
  345. * \sa
  346. */
  347. TI_STATUS apConn_config(TI_HANDLE hAPConnection,
  348. TI_HANDLE hReport,
  349. TI_HANDLE hCurrAP,
  350. TI_HANDLE hRoamMng,
  351. TI_HANDLE hSme,
  352. TI_HANDLE hSiteMgr,
  353. TI_HANDLE hExcMngr,
  354. TI_HANDLE hConnSm,
  355. TI_HANDLE hPrivacy,
  356. TI_HANDLE hQos,
  357. TI_HANDLE hCtrl,
  358. TI_HANDLE hEvHandler,
  359. TI_HANDLE hScr,
  360. TI_HANDLE hAssoc,
  361. TI_HANDLE hRegulatoryDomain,
  362. apConnParams_t *pApConnParams)
  363. {
  364. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  365. TI_STATUS status;
  366. UINT32 index;
  367. /** State Machine matrix */
  368. fsm_actionCell_t apConn_matrix[AP_CONNECT_NUM_STATES][AP_CONNECT_NUM_EVENTS] =
  369. {
  370. /* next state and actions for IDLE state */
  371. { {AP_CONNECT_STATE_IDLE, apConn_smUnexpected}, /* PREPARE_FOR_ROAMING */
  372. {AP_CONNECT_STATE_IDLE, apConn_smUnexpected}, /* FINISHED_OK */
  373. {AP_CONNECT_STATE_IDLE, apConn_smUnexpected}, /* FINISHED_NOT_OK */
  374. {AP_CONNECT_STATE_IDLE, apConn_smUnexpected}, /* RETAIN_CURRENT_AP */
  375. {AP_CONNECT_STATE_WAIT_ROAM,apConn_startWaitingForTriggers},/* START */
  376. {AP_CONNECT_STATE_IDLE, apConn_smUnexpected}, /* START_ROAM */
  377. {AP_CONNECT_STATE_IDLE, apConn_smUnexpected}, /* START_SWITCH_CHANNEL */
  378. {AP_CONNECT_STATE_IDLE, apConn_smNop}, /* FINISHED_SWITCH_CH */
  379. {AP_CONNECT_STATE_IDLE, apConn_smNop}, /* FINISHED_HAND_OVER */
  380. {AP_CONNECT_STATE_IDLE, apConn_smUnexpected} /* STOP */
  381. },
  382. /* next state and actions for WAIT_ROAM state */
  383. { {AP_CONNECT_STATE_WAIT_CONNECT_CMD,apConn_configureDriverBeforeRoaming},/* PREPARE_FOR_ROAMING */
  384. {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected}, /* FINISHED_OK */
  385. {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected}, /* FINISHED_NOT_OK */
  386. {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected}, /* RETAIN_CURRENT_AP */
  387. {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected}, /* START */
  388. {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected}, /* START_ROAM */
  389. {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smNop}, /* START_SWITCH_CHANNEL */
  390. {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected}, /* FINISHED_SWITCH_CH */
  391. {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected}, /* FINISHED_HAND_OVER */
  392. {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection} /* STOP */
  393. },
  394. /* next state and actions for SWITCHING_CHANNEL state */
  395. { {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected}, /* PREPARE_FOR_ROAMING */
  396. {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected}, /* FINISHED_OK */
  397. {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected}, /* FINISHED_NOT_OK */
  398. {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected}, /* RETAIN_CURRENT_AP */
  399. {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected}, /* START */
  400. {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected}, /* START_ROAM */
  401. {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_swChFinished}, /* START_SWITCH_CHANNEL */
  402. {AP_CONNECT_STATE_WAIT_ROAM, apConn_smNop}, /* FINISHED_SWITCH_CH */
  403. {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected}, /* FINISHED_HAND_OVER */
  404. {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection} /* STOP */
  405. },
  406. /* next state and actions for WAIT_CONNECT_CMD state */
  407. { {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected}, /* PREPARE_FOR_ROAMING */
  408. {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected}, /* FINISHED_OK */
  409. {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected}, /* FINISHED_NOT_OK */
  410. {AP_CONNECT_STATE_WAIT_ROAM, apConn_retainAP}, /* RETAIN_CURRENT_AP */
  411. {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected}, /* START */
  412. {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_requestCCKM}, /* START_ROAM */
  413. {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected}, /* START_SWITCH_CHANNEL */
  414. {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected}, /* FINISHED_SWITCH_CH */
  415. {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected}, /* FINISHED_HAND_OVER */
  416. {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection} /* STOP */
  417. },
  418. /* next state and actions for PREPARE_HAND_OFF state */
  419. { {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected}, /* PREPARE_FOR_ROAMING */
  420. {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected}, /* FINISHED_OK */
  421. {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected}, /* FINISHED_NOT_OK */
  422. {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected}, /* RETAIN_CURRENT_AP */
  423. {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected}, /* START */
  424. {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected}, /* START_ROAM */
  425. {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected}, /* START_SWITCH_CHANNEL */
  426. {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected}, /* FINISHED_SWITCH_CH */
  427. {AP_CONNECT_STATE_CONNECTING, apConn_invokeConnectionToNewAp},/* FINISHED_HAND_OVER */
  428. {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection} /* STOP */
  429. },
  430. /* next state and actions for CONNECTING state */
  431. { {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected}, /* PREPARE_FOR_ROAMING */
  432. {AP_CONNECT_STATE_REESTABLISH_VOICE,apConn_handleTspecReneg},/* FINISHED_OK */
  433. {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_reportConnFail}, /* FINISHED_NOT_OK */
  434. {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected}, /* RETAIN_CURRENT_AP */
  435. {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected}, /* START */
  436. {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected}, /* START_ROAM */
  437. {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected}, /* START_SWITCH_CHANNEL */
  438. {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected}, /* FINISHED_SWITCH_CH */
  439. {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected}, /* FINISHED_HAND_OVER */
  440. {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection} /* STOP */
  441. },
  442. /* next state and actions for DISCONNECTING state */
  443. { {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop}, /* PREPARE_FOR_ROAMING */
  444. {AP_CONNECT_STATE_IDLE, apConn_reportDisconnected}, /* FINISHED_OK */
  445. {AP_CONNECT_STATE_IDLE, apConn_reportDisconnected}, /* FINISHED_NOT_OK */
  446. {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop}, /* RETAIN_CURRENT_AP */
  447. {AP_CONNECT_STATE_DISCONNECTING, apConn_smUnexpected}, /* START */
  448. {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop}, /* START_ROAM */
  449. {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop}, /* START_SWITCH_CHANNEL */
  450. {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop}, /* FINISHED_SWITCH_CH */
  451. {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop}, /* FINISHED_HAND_OVER */
  452. {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop}, /* STOP */
  453. },
  454. /* next state and actions for REESTABLISH_VOICE state */
  455. { {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected}, /* PREPARE_FOR_ROAMING */
  456. {AP_CONNECT_STATE_WAIT_ROAM,apConn_connectedToNewAP}, /* FINISHED_OK */
  457. {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_reportConnFail}, /* FINISHED_NOT_OK */
  458. {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected}, /* RETAIN_CURRENT_AP */
  459. {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected}, /* START */
  460. {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected}, /* START_ROAM */
  461. {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected}, /* START_SWITCH_CHANNEL */
  462. {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected}, /* FINISHED_SWITCH_CH */
  463. {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected}, /* FINISHED_HAND_OVER */
  464. {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection} /* STOP */
  465. }
  466. };
  467. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  468. status = fsm_Config(pAPConnection->apConnSM,
  469. (fsm_Matrix_t)&apConn_matrix[0][0],
  470. AP_CONNECT_NUM_STATES,
  471. AP_CONNECT_NUM_EVENTS,
  472. (fsm_eventActivation_t)apConn_smEvent,
  473. pAPConnection->hOs);
  474. if (status == OK)
  475. {
  476. pAPConnection->currentState = AP_CONNECT_STATE_IDLE;
  477. pAPConnection->firstAttempt2Roam = TRUE;
  478. pAPConnection->hReport = hReport;
  479. pAPConnection->hCurrBSS = hCurrAP;
  480. pAPConnection->hRoamMng = hRoamMng;
  481. pAPConnection->hSme = hSme;
  482. pAPConnection->hSiteMgr = hSiteMgr;
  483. pAPConnection->hExcMngr = hExcMngr;
  484. pAPConnection->hConnSm = hConnSm;
  485. pAPConnection->hPrivacy = hPrivacy;
  486. pAPConnection->hQos = hQos;
  487. pAPConnection->hRateAdapt = ((ctrlData_t *)hCtrl)->pRateAdaptation;
  488. pAPConnection->hEvHandler = hEvHandler;
  489. pAPConnection->hScr = hScr;
  490. pAPConnection->hAssoc = hAssoc;
  491. pAPConnection->hRegulatoryDomain = hRegulatoryDomain;
  492. pAPConnection->roamingEnabled = TRUE;
  493. pAPConnection->reportStatusCallb = NULL;
  494. pAPConnection->roamEventCallb = NULL;
  495. pAPConnection->returnNeighborApsCallb = NULL;
  496. pAPConnection->ignoreDeauthReason0 = pApConnParams->ignoreDeauthReason0;
  497. for (index=ROAMING_TRIGGER_NONE; index<ROAMING_TRIGGER_LAST; index++)
  498. {
  499. pAPConnection->roamingTriggerEvents[index] = 0;
  500. }
  501. pAPConnection->roamingSuccesfulHandoverNum = 0;
  502. pAPConnection->roamingSuccesfulHandoverTotalNum = 0;
  503. pAPConnection->roamingFailedHandoverNum = 0;
  504. pAPConnection->retainCurrAPNum = 0;
  505. pAPConnection->disconnectFromRoamMngrNum = 0;
  506. pAPConnection->stopFromSmeNum = 0;
  507. pAPConnection->txFailureThreshold = NO_ACK_DEFAULT_THRESHOLD;
  508. pAPConnection->lowRateThreshold = LOW_RATE_DEFAULT_THRESHOLD;
  509. pAPConnection->rssiThreshold = RSSI_DEFAULT_THRESHOLD;
  510. pAPConnection->snrThreshold = SNR_DEFAULT_THRESHOLD;
  511. pAPConnection->vsIElength = 0;
  512. pAPConnection->isRssiTriggerMaskedOut = FALSE;
  513. pAPConnection->isSnrTriggerMaskedOut = TRUE;
  514. pAPConnection->islowRateTriggerMaskedOut = FALSE;
  515. pAPConnection->isConsTxFailureMaskedOut = FALSE;
  516. pAPConnection->removeKeys = TRUE;
  517. pAPConnection->sendDeauthPacket = TRUE; /* Default behavior is radio On - send DISASSOC frame */
  518. pAPConnection->voiceTspecConfigured = FALSE;
  519. pAPConnection->videoTspecConfigured = FALSE;
  520. pAPConnection->resetReportedRoamingStatistics = FALSE;
  521. pAPConnection->reNegotiateTSPEC = FALSE;
  522. pAPConnection->bNonRoamingDisAssocReason = FALSE;
  523. pAPConnection->roamingStartedTimestamp = 0;
  524. pAPConnection->lastRoamingDelay = 0;
  525. pAPConnection->roamingSuccesfulHandoverNum = 0;
  526. return OK;
  527. }
  528. else/* Unable to configure State Machine */
  529. {
  530. WLAN_REPORT_ERROR(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("FATAL ERROR: apConn_config(): Failed to configure sm\n"));
  531. return status;
  532. }
  533. }
  534. /**
  535. *
  536. * apConn_isPsRequiredBeforeScan
  537. *
  538. * \b Description:
  539. *
  540. * verify if the PS required before scan according if roaming triger is part of ROAMING_TRIGGER_LOW_QUALITY_GROUP
  541. *
  542. * \b ARGS:
  543. *
  544. * I - hAPConnection - pointer to module\n
  545. *
  546. * \b RETURNS:
  547. *
  548. * TRUE or FALSE.
  549. *
  550. * \sa
  551. */
  552. BOOLEAN apConn_isPsRequiredBeforeScan(TI_HANDLE hAPConnection)
  553. {
  554. apConn_t * pAPConnection = (apConn_t *) hAPConnection;
  555. /* check if part of ROAMING_TRIGGER_LOW_QUALITY_GROUP */
  556. if (pAPConnection->roamReason <= ROAMING_TRIGGER_MAX_TX_RETRIES)
  557. return TRUE;
  558. else
  559. return FALSE;
  560. }
  561. /**
  562. *
  563. * apConn_ConnCompleteInd
  564. *
  565. * \b Description:
  566. *
  567. * Inform AP Connection about successful / unsuccessful completion
  568. * of link establishing
  569. *
  570. * \b ARGS:
  571. *
  572. * I - result - OK if successfully connected, NOK otherwise \n
  573. *
  574. * \b RETURNS:
  575. *
  576. * OK if successful, NOK otherwise.
  577. *
  578. * \sa
  579. */
  580. TI_STATUS apConn_ConnCompleteInd(TI_HANDLE hAPConnection, mgmtStatus_e status, UINT32 uStatusCode)
  581. {
  582. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  583. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  584. if (status == STATUS_SUCCESSFUL)
  585. {
  586. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
  587. }
  588. else
  589. {
  590. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection);
  591. }
  592. return OK;
  593. }
  594. /**
  595. *
  596. * apConn_getRoamThresholds
  597. *
  598. * \b Description:
  599. *
  600. * Used to query for the current roaming thresholds configuration
  601. *
  602. * \b ARGS:
  603. *
  604. * I - hAPConnection - pointer to module\n
  605. * O - pParam - pointer to buffer to store the thresholds\n
  606. *
  607. * \b RETURNS:
  608. *
  609. * OK if successful, NOK otherwise.
  610. *
  611. * \sa
  612. */
  613. TI_STATUS apConn_getRoamThresholds(TI_HANDLE hAPConnection, roamingMngrThresholdsConfig_t *pParam)
  614. {
  615. apConn_t * pAPConnection = (apConn_t *) hAPConnection;
  616. pParam->lowRssiThreshold = pAPConnection->rssiThreshold;
  617. pParam->lowSnrThreshold = pAPConnection->snrThreshold;
  618. pParam->txRateThreshold = pAPConnection->lowRateThreshold;
  619. pParam->dataRetryThreshold = pAPConnection->txFailureThreshold;
  620. currBSS_getRoamingParams(pAPConnection->hCurrBSS,
  621. &pParam->numExpectedTbttForBSSLoss,
  622. &pParam->lowQualityForBackgroungScanCondition,
  623. &pParam->normalQualityForBackgroungScanCondition,
  624. &pParam->rssiFilterWeight,
  625. &pParam->snrFilterWeight);
  626. return OK;
  627. }
  628. /**
  629. *
  630. * apConn_setRoamThresholds
  631. *
  632. * \b Description:
  633. *
  634. * Used to configure roaming thresholds
  635. *
  636. * \b ARGS:
  637. *
  638. * I - pParam - pointer to type and details of configuration request\n
  639. *
  640. * \b RETURNS:
  641. *
  642. * OK if successful, NOK otherwise.
  643. *
  644. * \sa
  645. */
  646. TI_STATUS apConn_setRoamThresholds(TI_HANDLE hAPConnection, roamingMngrThresholdsConfig_t *pParam)
  647. {
  648. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  649. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  650. /* If low quality trigger threshold is set to 0 - this is the request to ignore this trigger */
  651. /* Otherwise store it */
  652. if (pParam->lowRssiThreshold == (INT8)AP_CONNECT_TRIGGER_IGNORED)
  653. {
  654. pAPConnection->isRssiTriggerMaskedOut = TRUE;
  655. pParam->lowRssiThreshold = pAPConnection->rssiThreshold;
  656. }
  657. else
  658. {
  659. pAPConnection->isRssiTriggerMaskedOut = FALSE;
  660. pAPConnection->rssiThreshold = pParam->lowRssiThreshold;
  661. }
  662. if (pParam->txRateThreshold == AP_CONNECT_TRIGGER_IGNORED)
  663. {
  664. pAPConnection->islowRateTriggerMaskedOut = TRUE;
  665. pParam->txRateThreshold = pAPConnection->lowRateThreshold;
  666. }
  667. else
  668. {
  669. pAPConnection->islowRateTriggerMaskedOut = FALSE;
  670. pAPConnection->lowRateThreshold = pParam->txRateThreshold;
  671. }
  672. if (pParam->dataRetryThreshold == AP_CONNECT_TRIGGER_IGNORED)
  673. {
  674. pAPConnection->isConsTxFailureMaskedOut = TRUE;
  675. pParam->dataRetryThreshold = pAPConnection->txFailureThreshold;
  676. }
  677. else
  678. {
  679. pAPConnection->isConsTxFailureMaskedOut = FALSE;
  680. pAPConnection->txFailureThreshold = pParam->dataRetryThreshold;
  681. }
  682. if (pParam->rssiFilterWeight == (UINT8)AP_CONNECT_TRIGGER_IGNORED)
  683. {
  684. pParam->rssiFilterWeight = RSSI_DEFAULT_WEIGHT;
  685. }
  686. if (pParam->snrFilterWeight == (UINT8)AP_CONNECT_TRIGGER_IGNORED)
  687. {
  688. pParam->snrFilterWeight = SNR_DEFAULT_WEIGHT;
  689. }
  690. pAPConnection->isSnrTriggerMaskedOut = FALSE;
  691. pAPConnection->snrThreshold = pParam->lowSnrThreshold;
  692. currBSS_updateRoamingTriggers(pAPConnection->hCurrBSS, pParam);
  693. rateAdaptation_configLowRateThrsh(pAPConnection->hRateAdapt,pParam->txRateThreshold);
  694. return OK;
  695. }
  696. /**
  697. *
  698. * apConn_registerRoamMngrCallb
  699. *
  700. * \b Description:
  701. *
  702. * Used to store method of Roaming Manager in the internal database of AP Connection Module.
  703. * If this function was never called, any roaming event would cause disconnect.
  704. *
  705. * \b ARGS:
  706. *
  707. * I - callbackType - type of callback \n
  708. * I - callbackFunction - pointer to callback \n
  709. *
  710. * \b RETURNS:
  711. *
  712. * OK if successful, NOK otherwise.
  713. *
  714. * \sa
  715. */
  716. TI_STATUS apConn_registerRoamMngrCallb(TI_HANDLE hAPConnection,
  717. apConn_roamMngrCallb_t roamEventCallb,
  718. apConn_roamMngrCallb_t reportStatusCallb,
  719. apConn_roamMngrCallb_t returnNeighborApsCallb)
  720. {
  721. apConn_t *pAPConnection;
  722. apConn_connStatus_t reportStatus;
  723. paramInfo_t param;
  724. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  725. pAPConnection = (apConn_t *)hAPConnection;
  726. pAPConnection->roamEventCallb = roamEventCallb;
  727. pAPConnection->reportStatusCallb = reportStatusCallb;
  728. if ((pAPConnection->roamingEnabled) && (pAPConnection->currentState != AP_CONNECT_STATE_IDLE))
  729. {
  730. param.paramType = ASSOC_ASSOCIATION_RESP_PARAM;
  731. assoc_getParam(pAPConnection->hAssoc, &param);
  732. reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
  733. reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
  734. reportStatus.status = CONN_STATUS_CONNECTED;
  735. reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
  736. }
  737. ((apConn_t *)hAPConnection)->returnNeighborApsCallb = returnNeighborApsCallb;
  738. return OK;
  739. }
  740. /**
  741. *
  742. * apConn_unregisterRoamMngrCallb
  743. *
  744. * \b Description:
  745. *
  746. * Used to Erase methods of Roaming Manager from the internal database of AP Connection
  747. * module. From the moment this function was called, any roaming event would cause disconnect.
  748. *
  749. * \b ARGS:
  750. *
  751. * \b RETURNS:
  752. *
  753. * OK if successful, NOK otherwise.
  754. *
  755. * \sa
  756. */
  757. TI_STATUS apConn_unregisterRoamMngrCallb(TI_HANDLE hAPConnection)
  758. {
  759. apConn_t *pAPConnection;
  760. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  761. pAPConnection = (apConn_t *)hAPConnection;
  762. pAPConnection->roamEventCallb = NULL;
  763. pAPConnection->reportStatusCallb = NULL;
  764. pAPConnection->returnNeighborApsCallb = NULL;
  765. if ((pAPConnection->currentState != AP_CONNECT_STATE_IDLE) && (pAPConnection->currentState != AP_CONNECT_STATE_WAIT_ROAM))
  766. {
  767. /* Roaming Manager is unregistering it's callbacks in the middle of roaming - disconnect */
  768. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
  769. }
  770. return OK;
  771. }
  772. /**
  773. *
  774. * apConn_disconnect
  775. *
  776. * \b Description:
  777. *
  778. * Roaming Manager calls this function when it fails to find candidate for roaming from
  779. * one hand, and the connection with current AP is not possible from another.
  780. *
  781. * \b ARGS:
  782. *
  783. * \b RETURNS:
  784. *
  785. * OK if successful, NOK otherwise.
  786. *
  787. * \sa
  788. */
  789. TI_STATUS apConn_disconnect(TI_HANDLE hAPConnection)
  790. {
  791. apConn_t *pAPConnection;
  792. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  793. pAPConnection = (apConn_t *)hAPConnection;
  794. UPDATE_SEND_DEAUTH_PACKET_FLAG(pAPConnection->roamReason);
  795. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
  796. pAPConnection->disconnectFromRoamMngrNum++;
  797. return OK;
  798. }
  799. /**
  800. *
  801. * apConn_getStaCapabilities
  802. *
  803. * \b Description:
  804. *
  805. * Roaming Manager calls this function during selection of new candidate for roaming.
  806. * Returned are local Station capabilities (IEs) of quality and privacy, needed to
  807. * evaluate AP sites as suitable for roaming.
  808. *
  809. * \b ARGS:
  810. *
  811. * O - ie_list - station capabilities \n
  812. *
  813. * \b RETURNS:
  814. *
  815. * OK if successful, NOK otherwise.
  816. *
  817. * \sa
  818. */
  819. TI_STATUS apConn_getStaCapabilities(TI_HANDLE hAPConnection,
  820. apConn_staCapabilities_t *ie_list)
  821. {
  822. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  823. apConn_staCapabilities_t *pList;
  824. paramInfo_t param;
  825. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  826. pList = ie_list;
  827. /* Get authentication suite type */
  828. param.paramType = RSN_EXT_AUTHENTICATION_MODE;
  829. rsn_getParam(pAPConnection->hPrivacy, &param);
  830. switch (param.content.rsnExtAuthneticationMode)
  831. {
  832. case RSN_EXT_AUTH_MODE_OPEN:
  833. pList->authMode = os802_11AuthModeOpen;
  834. break;
  835. case RSN_EXT_AUTH_MODE_SHARED_KEY:
  836. pList->authMode = os802_11AuthModeShared;
  837. break;
  838. case RSN_EXT_AUTH_MODE_AUTO_SWITCH:
  839. pList->authMode = os802_11AuthModeAutoSwitch;
  840. break;
  841. case RSN_EXT_AUTH_MODE_WPA:
  842. pList->authMode = os802_11AuthModeWPA;
  843. break;
  844. case RSN_EXT_AUTH_MODE_WPAPSK:
  845. pList->authMode = os802_11AuthModeWPAPSK;
  846. break;
  847. case RSN_EXT_AUTH_MODE_WPANONE:
  848. pList->authMode = os802_11AuthModeWPANone;
  849. break;
  850. case RSN_EXT_AUTH_MODE_WPA2:
  851. pList->authMode = os802_11AuthModeWPA2;
  852. break;
  853. case RSN_EXT_AUTH_MODE_WPA2PSK:
  854. pList->authMode = os802_11AuthModeWPA2PSK;
  855. break;
  856. default:
  857. pList->authMode = os802_11AuthModeOpen;
  858. break;
  859. }
  860. /* Get encryption type */
  861. param.paramType = RSN_ENCRYPTION_STATUS_PARAM;
  862. rsn_getParam(pAPConnection->hPrivacy, &param);
  863. switch (param.content.rsnEncryptionStatus)
  864. {
  865. case RSN_CIPHER_NONE:
  866. pList->encryptionType = OS_ENCRYPTION_TYPE_NONE;
  867. break;
  868. case RSN_CIPHER_WEP:
  869. case RSN_CIPHER_WEP104:
  870. pList->encryptionType = OS_ENCRYPTION_TYPE_WEP;
  871. break;
  872. case RSN_CIPHER_TKIP:
  873. case RSN_CIPHER_CKIP:
  874. pList->encryptionType = OS_ENCRYPTION_TYPE_TKIP;
  875. break;
  876. case RSN_CIPHER_AES_WRAP:
  877. case RSN_CIPHER_AES_CCMP:
  878. pList->encryptionType = OS_ENCRYPTION_TYPE_AES;
  879. break;
  880. default:
  881. pList->encryptionType = OS_ENCRYPTION_TYPE_NONE;
  882. break;
  883. }
  884. /* Get supported rates */
  885. param.paramType = SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM;
  886. siteMgr_getParam(pAPConnection->hSiteMgr, &param);
  887. os_memoryCopy(pAPConnection->hOs, (void *)param.content.siteMgrDesiredSupportedRateSet.ratesString, pList->rateMask, sizeof(OS_802_11_RATES_EX));
  888. /* Get mode: 2.4G, 5G or Dual */
  889. param.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
  890. siteMgr_getParam(pAPConnection->hSiteMgr, &param);
  891. pList->networkType = (OS_802_11_NETWORK_TYPE)param.content.siteMgrDot11Mode;
  892. switch(param.content.siteMgrDot11Mode)
  893. {
  894. case DOT11_B_MODE:
  895. pList->networkType = os802_11DS;
  896. break;
  897. case DOT11_A_MODE:
  898. pList->networkType = os802_11OFDM5;
  899. break;
  900. case DOT11_G_MODE:
  901. pList->networkType = os802_11OFDM24;
  902. break;
  903. case DOT11_DUAL_MODE:
  904. pList->networkType = os802_11Automode;
  905. break;
  906. default:
  907. pList->networkType = os802_11DS;
  908. break;
  909. }
  910. /* Get EXC status */
  911. #ifdef EXC_MODULE_INCLUDED
  912. param.paramType = EXC_ENABLED;
  913. excMngr_getParam(pAPConnection->hExcMngr, &param);
  914. pList->excEnabled = (param.content.excEnabled==EXC_MODE_ENABLED)? TRUE : FALSE;
  915. #else
  916. pList->excEnabled = FALSE;
  917. #endif
  918. /* Get QoS type */
  919. param.paramType = QOS_MNGR_ACTIVE_PROTOCOL;
  920. qosMngr_getParams(pAPConnection->hQos, &param);
  921. pList->qosEnabled = (param.content.qosSiteProtocol==NONE_QOS)? FALSE : TRUE;
  922. pList->regDomain = REG_DOMAIN_FIXED;
  923. /* Get regulatory domain type */
  924. param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
  925. regulatoryDomain_getParam(pAPConnection->hRegulatoryDomain, &param);
  926. if (param.content.spectrumManagementEnabled)
  927. { /* 802.11h is enabled (802.11h includes 802.11d) */
  928. pList->regDomain = REG_DOMAIN_80211H;
  929. }
  930. else
  931. {
  932. param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
  933. regulatoryDomain_getParam(pAPConnection->hRegulatoryDomain, &param);
  934. if (param.content.regulatoryDomainEnabled)
  935. { /* 802.11d is enabled */
  936. pList->regDomain = REG_DOMAIN_80211D;
  937. }
  938. }
  939. return OK;
  940. }
  941. /**
  942. *
  943. * apConn_connectToAP
  944. *
  945. * \b Description:
  946. *
  947. * Roaming Manager calls this function when it has completed the process of selection
  948. * of new AP candidate for roaming. In addition, Roaming manager informs AP Connection
  949. * module whether this is new AP or the current one, and whether to perform full
  950. * roaming procedure or just to retain to current AP.
  951. *
  952. * \b ARGS:
  953. *
  954. * I - requestType - Connect to new AP, current AP (retain to current AP or re-connect) \n
  955. * I - newAP - Pointer to parameters list of AP candidate for roaming \n
  956. *
  957. * \b RETURNS:
  958. *
  959. * OK if successful, NOK otherwise.
  960. *
  961. * \sa
  962. */
  963. TI_STATUS apConn_connectToAP(TI_HANDLE hAPConnection,
  964. bssEntry_t *newAP,
  965. apConn_connRequest_t *request,
  966. BOOL reNegotiateTspec)
  967. {
  968. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  969. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  970. pAPConnection->requestType = request->requestType;
  971. switch (request->requestType)
  972. {
  973. case AP_CONNECT_RETAIN_CURR_AP:
  974. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_RETAIN_CURRENT_AP, pAPConnection);
  975. break;
  976. case AP_CONNECT_FULL_TO_AP:
  977. pAPConnection->removeKeys = TRUE;
  978. pAPConnection->newAP = newAP;
  979. pAPConnection->roamingFailedHandoverNum++;
  980. pAPConnection->reNegotiateTSPEC = reNegotiateTspec;
  981. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START_ROAM, pAPConnection);
  982. break;
  983. case AP_CONNECT_FAST_TO_AP:
  984. case AP_CONNECT_RECONNECT_CURR_AP:
  985. pAPConnection->removeKeys = FALSE;
  986. pAPConnection->newAP = newAP;
  987. pAPConnection->roamingFailedHandoverNum++;
  988. pAPConnection->reNegotiateTSPEC = reNegotiateTspec;
  989. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START_ROAM, pAPConnection);
  990. break;
  991. default:
  992. break;
  993. }
  994. /* If there is vendor specific IE to attach to Assoc req, store it now */
  995. if (request->dataBufLength > 0)
  996. {
  997. pAPConnection->vsIEbuf = request->dataBuf;
  998. pAPConnection->vsIElength = request->dataBufLength;
  999. }
  1000. return OK;
  1001. }
  1002. /**
  1003. *
  1004. * apConn_getBSSParams
  1005. *
  1006. * \b Description:
  1007. *
  1008. * Roaming Manager calls this function in order to evaluate the quality of new
  1009. * AP candidates for roaming against the quality of current AP.
  1010. * The function returns parameters of current AP.
  1011. *
  1012. * \b ARGS:
  1013. *
  1014. * O - currentAP - Pointer to parameters list of current AP \n
  1015. *
  1016. * \b RETURNS:
  1017. *
  1018. * Pointer to current BSS parameters database if successful, NULL otherwise.
  1019. *
  1020. * \sa
  1021. */
  1022. bssEntry_t *apConn_getBSSParams(TI_HANDLE hAPConnection)
  1023. {
  1024. #ifdef TI_DBG
  1025. if (hAPConnection == NULL) /* Failed to allocate control block */
  1026. {
  1027. WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error allocating cb - aborting\n"));
  1028. return NULL;
  1029. }
  1030. #endif
  1031. return currBSS_getBssInfo(((apConn_t *)hAPConnection)->hCurrBSS);
  1032. }
  1033. /**
  1034. *
  1035. * apConn_isSiteBanned
  1036. *
  1037. * \b Description:
  1038. *
  1039. * Roaming Manager calls this function during selection of new candidate for roaming.
  1040. * Only APs which are not marked as banned are allowed to be selected.
  1041. *
  1042. * \b ARGS:
  1043. *
  1044. * O - givenAp - Pointer to BSSID to check if banned \n
  1045. *
  1046. * \b RETURNS:
  1047. *
  1048. * TRUE if banned, FALSE otherwise.
  1049. *
  1050. * \sa
  1051. */
  1052. BOOL apConn_isSiteBanned(TI_HANDLE hAPConnection, macAddress_t * givenAp)
  1053. {
  1054. apConn_t * pAPConnection = (apConn_t *) hAPConnection;
  1055. return rsn_isSiteBanned(pAPConnection->hPrivacy, *givenAp);
  1056. }
  1057. /**
  1058. *
  1059. * apConn_getPreAuthAPStatus
  1060. *
  1061. * \b Description:
  1062. *
  1063. * Roaming Manager calls this function during selection of new candidate for roaming.
  1064. * Among all APs with good quality, those who were pre-authenticated are preferred.
  1065. *
  1066. * \b ARGS:
  1067. *
  1068. * O - givenAp - Pointer to BSSID to check the pre-authenticated status for \n
  1069. *
  1070. * \b RETURNS:
  1071. *
  1072. * OK if successful, NOK otherwise.
  1073. *
  1074. * \sa
  1075. */
  1076. BOOL apConn_getPreAuthAPStatus(TI_HANDLE hAPConnection,
  1077. macAddress_t *givenAp)
  1078. {
  1079. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1080. paramInfoPartial_t param;
  1081. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  1082. param.paramType = RSN_PRE_AUTH_STATUS;
  1083. os_memoryCopy(pAPConnection->hOs, (void *)param.content.rsnApMac.addr, (void *)givenAp->addr, MAC_ADDR_LEN);
  1084. rsn_getParamPartial(pAPConnection->hPrivacy, &param);
  1085. return param.content.rsnPreAuthStatus;
  1086. }
  1087. /**
  1088. *
  1089. * apConn_preAuthenticate
  1090. *
  1091. * \b Description:
  1092. *
  1093. * Roaming Manager calls this function periodically in order to update the list
  1094. * of pre-authenticated APs. The list is managed by WLAN driver and required
  1095. * by Roaming Manager during selection of roaming candidate process.
  1096. *
  1097. * \b ARGS:
  1098. *
  1099. * I - listAPs - List of APs to pre-authenticate \n
  1100. * I - sizeOfList - Size of list of APs to pre-authenticate \n
  1101. *
  1102. * \b RETURNS:
  1103. *
  1104. * OK if successful, NOK otherwise.
  1105. *
  1106. * \sa
  1107. */
  1108. TI_STATUS apConn_preAuthenticate(TI_HANDLE hAPConnection, bssList_t *listAPs, UINT8 listAPs_numOfEntries)
  1109. {
  1110. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1111. bssidList4PreAuth_t apList;
  1112. UINT32 listIndex, apListIndex;
  1113. bssEntry_t *pCurrentAP;
  1114. UINT8 *pRsnIEs;
  1115. #ifdef TI_DBG
  1116. if ((hAPConnection == NULL) || (listAPs == NULL))
  1117. {
  1118. WLAN_OS_REPORT(("FATAL ERROR: AP Connection context is not initiated\n"));
  1119. return NOK;
  1120. }
  1121. WLAN_REPORT_INFORMATION(pAPConnection->hReport, SITE_MGR_MODULE_LOG, ("apConn_reserveResources \n"));
  1122. #endif
  1123. if (listAPs_numOfEntries != 0) {
  1124. for (listIndex=0, apListIndex=0; listIndex<listAPs->numOfEntries; listIndex++)
  1125. {
  1126. os_memoryCopy(pAPConnection->hOs, &(apList.bssidList[apListIndex].bssId),
  1127. (void *)listAPs->BSSList[listIndex].BSSID.addr, MAC_ADDR_LEN);
  1128. /* search in the buffer pointer to the beginning of the
  1129. RSN IE according to the IE ID */
  1130. if (!parseIeBuffer(pAPConnection->hOs, listAPs->BSSList[listIndex].pBuffer, listAPs->BSSList[listIndex].bufferLength, RSN_IE_ID, &pRsnIEs, NULL, 0))
  1131. {
  1132. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1133. ("apConn_preAuthenticate, no RSN IE was found \n"));
  1134. WLAN_REPORT_HEX_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1135. listAPs->BSSList[listIndex].pBuffer, listAPs->BSSList[listIndex].bufferLength);
  1136. continue;
  1137. }
  1138. apList.bssidList[apListIndex].pRsnIEs = (dot11_RSN_t*)pRsnIEs;
  1139. apList.bssidList[apListIndex].rsnIeLen = apList.bssidList[apListIndex].pRsnIEs->hdr.eleLen+2;
  1140. apListIndex++;
  1141. }
  1142. }
  1143. else
  1144. {
  1145. listIndex=0;
  1146. apListIndex=0;
  1147. }
  1148. /* Start pre-auth after any Conn succ (including first),
  1149. and not only when a New BSSID was added, in order to save/refresh
  1150. PMKID of the current AP.*/
  1151. {
  1152. /* Add the current BSSID to the list */
  1153. pCurrentAP = apConn_getBSSParams(pAPConnection);
  1154. os_memoryCopy(pAPConnection->hOs, &(apList.bssidList[apListIndex].bssId),
  1155. (void *)pCurrentAP->BSSID.addr, MAC_ADDR_LEN);
  1156. /* search in the buffer pointer to the beginning of the
  1157. RSN IE according to the IE ID */
  1158. if (!parseIeBuffer(pAPConnection->hOs, pCurrentAP->pBuffer, pCurrentAP->bufferLength, RSN_IE_ID, &pRsnIEs, NULL, 0))
  1159. {
  1160. WLAN_REPORT_ERROR(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1161. ("apConn_preAuthenticate, no RSN IE was found in the current BSS, BSSID=0x%x-0x%x-0x%x-0x%x-0x%x-0x%x \n",
  1162. pCurrentAP->BSSID.addr[0], pCurrentAP->BSSID.addr[1], pCurrentAP->BSSID.addr[2],
  1163. pCurrentAP->BSSID.addr[3], pCurrentAP->BSSID.addr[4], pCurrentAP->BSSID.addr[5]));
  1164. HexDumpData(pCurrentAP->pBuffer, pCurrentAP->bufferLength);
  1165. apList.bssidList[apListIndex].pRsnIEs = NULL;
  1166. apList.bssidList[apListIndex].rsnIeLen = 0;
  1167. }
  1168. else
  1169. {
  1170. apList.bssidList[apListIndex].pRsnIEs = (dot11_RSN_t*)pRsnIEs;
  1171. apList.bssidList[apListIndex].rsnIeLen = apList.bssidList[apListIndex].pRsnIEs->hdr.eleLen+2;
  1172. }
  1173. apList.NumOfItems = apListIndex+1;
  1174. rsn_startPreAuth(pAPConnection->hPrivacy, &apList);
  1175. }
  1176. return OK;
  1177. }
  1178. /**
  1179. *
  1180. * apConn_prepareToRoaming
  1181. *
  1182. * \b Description:
  1183. *
  1184. * Roaming Manager calls this function when roaming event is received and Roaming Manager
  1185. * wishes to start the roaming process, thus want to prevent scan and measurement in the
  1186. * system. The function will return OK if the allocation is performed, PEND if the
  1187. * allocation is started, NOK in case the allocation is not possible.
  1188. * In case of successful allocation, Roaming Manager will be informed via callback about
  1189. * the end of the allocation.
  1190. *
  1191. * \b ARGS:
  1192. *
  1193. * I - reason - the reason for roaming \n
  1194. *
  1195. * \b RETURNS:
  1196. *
  1197. * OK if successful, NOK otherwise.
  1198. *
  1199. * \sa
  1200. */
  1201. TI_STATUS apConn_prepareToRoaming(TI_HANDLE hAPConnection, apConn_roamingTrigger_e reason)
  1202. {
  1203. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1204. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  1205. pAPConnection->roamReason = reason;
  1206. return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_PREPARE_FOR_ROAMING, pAPConnection);
  1207. }
  1208. /**
  1209. *
  1210. * apConn_indicateSwitchChannelInProgress
  1211. *
  1212. * \b Description:
  1213. *
  1214. * This function is called when switch channel process is started; it will trigger
  1215. * AP Connection state machine from 'Wait for roaming start' to 'Switch channel in progress'
  1216. * state.
  1217. *
  1218. * \b ARGS:
  1219. *
  1220. * I - reason - the reason for roaming \n
  1221. *
  1222. * \b RETURNS:
  1223. *
  1224. * OK if successful, NOK otherwise.
  1225. *
  1226. * \sa
  1227. */
  1228. TI_STATUS apConn_indicateSwitchChannelInProgress(TI_HANDLE hAPConnection)
  1229. {
  1230. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1231. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  1232. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START_SWITCH_CHANNEL, pAPConnection);
  1233. return OK;
  1234. }
  1235. /**
  1236. *
  1237. * apConn_indicateSwitchChannelFinished
  1238. *
  1239. * \b Description:
  1240. *
  1241. * This function is called when switch channel process is finished
  1242. *
  1243. * \b ARGS:
  1244. *
  1245. * I - reason - the reason for roaming \n
  1246. *
  1247. * \b RETURNS:
  1248. *
  1249. * OK if successful, NOK otherwise.
  1250. *
  1251. * \sa
  1252. */
  1253. TI_STATUS apConn_indicateSwitchChannelFinished(TI_HANDLE hAPConnection)
  1254. {
  1255. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1256. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  1257. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_SWITCH_CH, pAPConnection);
  1258. return OK;
  1259. }
  1260. /**
  1261. *
  1262. * apConn_start
  1263. *
  1264. * \b Description:
  1265. *
  1266. * Called by SME module when new connection has been successfully established (first time connection)
  1267. *
  1268. * \b ARGS:
  1269. *
  1270. * I - isValidBSS - if FALSE, no roaming shall be performed, disconnect upon any roaming event;
  1271. * other parameters of current AP can be received from Current BSS module
  1272. *
  1273. * \b RETURNS:
  1274. *
  1275. * OK if successful, NOK otherwise.
  1276. *
  1277. * \sa
  1278. */
  1279. TI_STATUS apConn_start(TI_HANDLE hAPConnection, BOOLEAN roamingEnabled)
  1280. {
  1281. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1282. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  1283. pAPConnection->roamingEnabled = roamingEnabled;
  1284. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START, pAPConnection);
  1285. return OK;
  1286. }
  1287. /**
  1288. *
  1289. * apConn_stop
  1290. *
  1291. * \b Description:
  1292. *
  1293. * Called by SME module when current connection must be taken down
  1294. * (due to driver download, connection failure or any other reason)
  1295. *
  1296. * \b ARGS:
  1297. *
  1298. * \b RETURNS:
  1299. *
  1300. * OK if successful, NOK otherwise.
  1301. *
  1302. * \sa
  1303. */
  1304. TI_STATUS apConn_stop(TI_HANDLE hAPConnection, BOOLEAN removeKeys, BOOLEAN immediateShutdown)
  1305. {
  1306. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1307. pAPConnection->stopFromSmeNum++;
  1308. pAPConnection->removeKeys = removeKeys;
  1309. pAPConnection->sendDeauthPacket = !(immediateShutdown); /* If immediateShutdown is TRUE, no need to send DISASSOC frame - used during unload process */
  1310. pAPConnection->reNegotiateTSPEC = FALSE;
  1311. pAPConnection->voiceTspecConfigured = FALSE;
  1312. pAPConnection->videoTspecConfigured = FALSE;
  1313. /* Mark that the connection is stopped due to reason outside the scope of this module */
  1314. pAPConnection->bNonRoamingDisAssocReason = TRUE;
  1315. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
  1316. return OK;
  1317. }
  1318. /**
  1319. *
  1320. * apConn_reportRoamingEventDisconnect
  1321. *
  1322. * \b Description:
  1323. *
  1324. * Called by Roaming Manager to inform of Disconnect
  1325. * uStatusCode - status code of deauth/disassoc packet
  1326. * bDeAuthenticate - Whether this packet is DeAuth ( if
  1327. * DisAssoc than FALSE)
  1328. *
  1329. * \b ARGS:
  1330. *
  1331. *
  1332. * \b RETURNS:
  1333. *
  1334. * OK if successful, NOK otherwise.
  1335. *
  1336. * \sa
  1337. */
  1338. TI_STATUS apConn_reportRoamingEventDisconnect(TI_HANDLE hAPConnection,UINT16 uStatusCode,BOOLEAN bDeAuthenticate )
  1339. {
  1340. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1341. roamingEventData_u RoamingEventData;
  1342. RoamingEventData.APDisconnect.uStatusCode = uStatusCode ; /* status code of deauth/disassoc packet */
  1343. RoamingEventData.APDisconnect.bDeAuthenticate = bDeAuthenticate; /* TRUE state that it is DeAuth packet */
  1344. apConn_reportRoamingEvent(pAPConnection, ROAMING_TRIGGER_AP_DISCONNECT, &RoamingEventData);
  1345. return( TI_OK );
  1346. }
  1347. /**
  1348. *
  1349. * apConn_reportRoamingEvent
  1350. *
  1351. * \b Description:
  1352. *
  1353. * Called when one of roaming events occur
  1354. *
  1355. * \b ARGS:
  1356. *
  1357. * I - roamingEventType
  1358. * I - pRoamingEventData - in case of 'Tx rate' event, or AP disconnect
  1359. *
  1360. * \b RETURNS:
  1361. *
  1362. * OK if successful, NOK otherwise.
  1363. *
  1364. * \sa
  1365. */
  1366. TI_STATUS apConn_reportRoamingEvent(TI_HANDLE hAPConnection,
  1367. apConn_roamingTrigger_e roamingEventType,
  1368. roamingEventData_u *pRoamingEventData)
  1369. {
  1370. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1371. paramInfo_t param; /* parameter for retrieving BSSID */
  1372. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  1373. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1374. ("apConn_reportRoamingEvent, type=%d, cur_state=%d, roamingEnabled=%d, roamEventCallb=%p \n",
  1375. roamingEventType, pAPConnection->currentState,
  1376. pAPConnection->roamingEnabled, pAPConnection->roamEventCallb));
  1377. /* 1. Check if this is Rogue AP test case */
  1378. if (roamingEventType == ROAMING_TRIGGER_AP_DISCONNECT)
  1379. {
  1380. if (pRoamingEventData != NULL)
  1381. { /* Save the disconnect reason for future use */
  1382. pAPConnection->APDisconnect.uStatusCode = pRoamingEventData->APDisconnect.uStatusCode;
  1383. pAPConnection->APDisconnect.bDeAuthenticate = pRoamingEventData->APDisconnect.bDeAuthenticate;
  1384. }
  1385. if ((pAPConnection->ignoreDeauthReason0) && (pRoamingEventData!=NULL) &&
  1386. (pAPConnection->APDisconnect.uStatusCode == 0))
  1387. { /* This is required for Rogue AP test,
  1388. When Rogue AP due to invalid User name, deauth with reason 0 arrives before the Rogue AP,
  1389. and this EXC test fails.*/
  1390. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1391. ("apConn_reportRoamingEvent, Ignore DeAuth with reason 0 \n"));
  1392. return OK;
  1393. }
  1394. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1395. ("apConn_reportRoamingEvent, DeAuth with reason %d \n", pAPConnection->APDisconnect.uStatusCode));
  1396. if (pAPConnection->APDisconnect.uStatusCode == STATUS_CODE_802_1X_AUTHENTICATION_FAILED)
  1397. {
  1398. #ifdef EXC_MODULE_INCLUDED
  1399. TI_STATUS status;
  1400. /* Raise the EAP-Failure as event */
  1401. status = excMngr_rogueApDetected (pAPConnection->hExcMngr, RSN_AUTH_STATUS_CHALLENGE_FROM_AP_FAILED);
  1402. #endif
  1403. /* Remove AP from candidate list for a specified amount of time */
  1404. param.paramType = SITE_MGR_CURRENT_BSSID_PARAM;
  1405. siteMgr_getParam(pAPConnection->hSiteMgr, &param);
  1406. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1407. ("current station is banned from the roaming candidates list for %d Ms\n",
  1408. RSN_AUTH_FAILURE_TIMEOUT));
  1409. rsn_banSite(pAPConnection->hPrivacy, param.content.siteMgrDesiredBSSID, RSN_SITE_BAN_LEVEL_FULL, RSN_AUTH_FAILURE_TIMEOUT);
  1410. }
  1411. }
  1412. /* 2. Check if received trigger is masked out */
  1413. if (((pAPConnection->isConsTxFailureMaskedOut) && (roamingEventType == ROAMING_TRIGGER_MAX_TX_RETRIES)) ||
  1414. ((pAPConnection->isRssiTriggerMaskedOut) && (roamingEventType == ROAMING_TRIGGER_LOW_QUALITY)) ||
  1415. ((pAPConnection->isSnrTriggerMaskedOut) && (roamingEventType == ROAMING_TRIGGER_LOW_SNR)) ||
  1416. ((pAPConnection->islowRateTriggerMaskedOut)&& (roamingEventType == ROAMING_TRIGGER_LOW_TX_RATE)))
  1417. {
  1418. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("apConn_reportRoamingEvent, trigger ignored \n"));
  1419. return OK;
  1420. }
  1421. /* 3. Valid trigger received: */
  1422. /* 3a. Update statistics */
  1423. pAPConnection->roamingTriggerEvents[roamingEventType]++;
  1424. /* 3b. Store the most severe trigger */
  1425. if (pAPConnection->roamReason < roamingEventType)
  1426. {
  1427. pAPConnection->roamReason = roamingEventType;
  1428. }
  1429. /* 3c. Check if Roaming Manager is available */
  1430. if (((!pAPConnection->roamingEnabled) || (pAPConnection->roamEventCallb == NULL) ||
  1431. (pAPConnection->currentState == AP_CONNECT_STATE_IDLE))
  1432. && (roamingEventType > ROAMING_TRIGGER_LOW_QUALITY)
  1433. && (roamingEventType != ROAMING_TRIGGER_MAX_TX_RETRIES))
  1434. /*
  1435. * The last condition was added so that MAX_TX_RETRIES would not cause a disconnect.
  1436. * This is done because the current default value for max TX retries is good enough for
  1437. * roaming (i.e. it indicates a low quality AP), but would cause unnecessary disconnects
  1438. * if used when roaming is disabled
  1439. */
  1440. {
  1441. /* 'Any SSID' configured, meaning Roaming Manager is not allowed to perform roaming,
  1442. or Roaming Manager is not registered for roaming events;
  1443. unless this is trigger to change parameters of background scan, disconnect the link */
  1444. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("Disconnecting link due to roaming event: ev = %d\n", roamingEventType));
  1445. /* Handle IBSS case TBD to remove
  1446. Handle also the case where A first connection is in progress, and
  1447. de-auth arrived. */
  1448. if (pAPConnection->currentState == AP_CONNECT_STATE_IDLE)
  1449. {
  1450. apConn_reportConnStatusToSME(pAPConnection);
  1451. }
  1452. else
  1453. {
  1454. /* Infra-structure BSS case - disconnect the link */
  1455. if (roamingEventType >= ROAMING_TRIGGER_AP_DISCONNECT)
  1456. {
  1457. pAPConnection->removeKeys = TRUE;
  1458. }
  1459. else
  1460. {
  1461. pAPConnection->removeKeys = FALSE;
  1462. }
  1463. UPDATE_SEND_DEAUTH_PACKET_FLAG(roamingEventType);
  1464. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
  1465. }
  1466. return OK;
  1467. }
  1468. /* 4. Check if we are in the middle of switching channel */
  1469. if (pAPConnection->currentState == AP_CONNECT_STATE_SWITCHING_CHANNEL)
  1470. {
  1471. /* Trigger received in the middle of switch channel, continue without reporting Roaming Manager */
  1472. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("Roaming event during switch channel: ev = %d\n", roamingEventType));
  1473. return OK;
  1474. }
  1475. /* 5. Report Roaming Manager */
  1476. if ((pAPConnection->roamingEnabled == TRUE) && (pAPConnection->roamEventCallb != NULL))
  1477. {
  1478. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("Roaming event raised: ev = %d\n", roamingEventType));
  1479. if (roamingEventType == ROAMING_TRIGGER_LOW_QUALITY)
  1480. {
  1481. EvHandlerSendEvent(pAPConnection->hEvHandler, IPC_EVENT_LOW_RSSI, NULL,0);
  1482. }
  1483. /* Report to Roaming Manager */
  1484. pAPConnection->roamEventCallb(pAPConnection->hRoamMng, &roamingEventType);
  1485. }
  1486. return OK;
  1487. }
  1488. /**
  1489. *
  1490. * apConn_RoamHandoffFinished
  1491. *
  1492. * \b Description:
  1493. *
  1494. * Called when EXC module receives response from the supplicant or recognizes
  1495. * timeout while waiting for the response
  1496. *
  1497. * \b ARGS:
  1498. *
  1499. * \b RETURNS:
  1500. *
  1501. * \sa
  1502. */
  1503. void apConn_RoamHandoffFinished(TI_HANDLE hAPConnection)
  1504. {
  1505. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1506. #ifdef TI_DBG
  1507. if (hAPConnection == NULL) /* Failed to allocate control block */
  1508. {
  1509. WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error allocating cb - aborting\n"));
  1510. return;
  1511. }
  1512. #endif
  1513. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_HAND_OVER, pAPConnection);
  1514. }
  1515. /**
  1516. *
  1517. * apConn_DisconnCompleteInd
  1518. *
  1519. * \b Description:
  1520. *
  1521. * DISASSOCIATE Packet was sent - proceed with stopping the module
  1522. *
  1523. * \b ARGS:
  1524. *
  1525. * I - pData - pointer to AP Connection context\n
  1526. *
  1527. * \b RETURNS:
  1528. *
  1529. * OK on success, NOK otherwise.
  1530. *
  1531. * \sa
  1532. */
  1533. TI_STATUS apConn_DisconnCompleteInd(TI_HANDLE hAPConnection, mgmtStatus_e status, UINT32 uStatusCode)
  1534. {
  1535. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1536. AP_CONN_VALIDATE_HANDLE(hAPConnection);
  1537. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
  1538. return OK;
  1539. }
  1540. /**
  1541. *
  1542. * apConn_updateNeighborAPsList
  1543. *
  1544. * \b Description:
  1545. *
  1546. * Called by EXC Manager when Priority APs are found
  1547. *
  1548. * \b ARGS:
  1549. *
  1550. * \b RETURNS:
  1551. *
  1552. * OK if successful, NOK otherwise.
  1553. *
  1554. * \sa
  1555. */
  1556. void apConn_updateNeighborAPsList(TI_HANDLE hAPConnection, neighborAPList_t *pListOfpriorityAps)
  1557. {
  1558. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1559. if (pAPConnection->returnNeighborApsCallb != NULL )
  1560. {
  1561. pAPConnection->returnNeighborApsCallb(pAPConnection->hRoamMng, pListOfpriorityAps);
  1562. }
  1563. }
  1564. /**
  1565. *
  1566. * apConn_getRoamingStatistics
  1567. *
  1568. * \b Description:
  1569. *
  1570. * Called from Measurement EXC sub-module when preparing TSM report to the AP.
  1571. *
  1572. * \b ARGS: AP Connection handle
  1573. *
  1574. * \b RETURNS:
  1575. *
  1576. * total number of successful roams
  1577. * delay of the latest successful roam
  1578. *
  1579. * \sa
  1580. */
  1581. void apConn_getRoamingStatistics(TI_HANDLE hAPConnection, UINT8 *roamingCount, UINT16 *roamingDelay)
  1582. {
  1583. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1584. /* Get (and clear) total number of successful roams */
  1585. *roamingCount = pAPConnection->roamingSuccesfulHandoverNum;
  1586. pAPConnection->roamingSuccesfulHandoverNum = 0;
  1587. /* Get delay of the latest roam */
  1588. *roamingDelay = pAPConnection->lastRoamingDelay;
  1589. pAPConnection->lastRoamingDelay = 0;
  1590. }
  1591. /**
  1592. *
  1593. * apConn_resetRoamingStatistics
  1594. *
  1595. * \b Description:
  1596. *
  1597. * Called from Measurement EXC sub-module in order to re-start roaming statistics.
  1598. *
  1599. * \b ARGS: AP Connection handle
  1600. *
  1601. * \b RETURNS:
  1602. *
  1603. * total number of successful roams
  1604. * delay of the latest successful roam
  1605. *
  1606. * \sa
  1607. */
  1608. void apConn_resetRoamingStatistics(TI_HANDLE hAPConnection)
  1609. {
  1610. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1611. pAPConnection->resetReportedRoamingStatistics = TRUE;
  1612. pAPConnection->roamingSuccesfulHandoverNum = 0;
  1613. pAPConnection->lastRoamingDelay = 0;
  1614. }
  1615. /**
  1616. *
  1617. * apConn_stopRoamingStatistics
  1618. *
  1619. * \b Description:
  1620. *
  1621. * Called from Measurement CCX sub-module in order to stop roaming statistics.
  1622. *
  1623. * \b ARGS: AP Connection handle
  1624. *
  1625. * \b RETURNS:
  1626. *
  1627. * \sa
  1628. */
  1629. void apConn_stopRoamingStatistics(TI_HANDLE hAPConnection)
  1630. {
  1631. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1632. pAPConnection->resetReportedRoamingStatistics = FALSE;
  1633. }
  1634. /**
  1635. *
  1636. * apConn_printStatistics
  1637. *
  1638. * \b Description:
  1639. *
  1640. * Called by Site Manager when request to print statistics is requested from CLI
  1641. *
  1642. * \b ARGS: AP Connection handle
  1643. *
  1644. * \b RETURNS:
  1645. *
  1646. * OK if successful, NOK otherwise.
  1647. *
  1648. * \sa
  1649. */
  1650. void apConn_printStatistics(TI_HANDLE hAPConnection)
  1651. {
  1652. WLAN_OS_REPORT(("-------------- Roaming Statistics ---------------\n\n"));
  1653. WLAN_OS_REPORT(("- Low TX rate = %d\n", ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_LOW_TX_RATE]));
  1654. WLAN_OS_REPORT(("- Low SNR = %d\n", ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_LOW_SNR]));
  1655. WLAN_OS_REPORT(("- Low Quality = %d\n", ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_LOW_QUALITY]));
  1656. WLAN_OS_REPORT(("- MAX TX retries = %d\n", ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_MAX_TX_RETRIES]));
  1657. WLAN_OS_REPORT(("- BSS Loss TX = %d\n", ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_BSS_LOSS]));
  1658. WLAN_OS_REPORT(("- Switch Channel = %d\n", ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_SWITCH_CHANNEL]));
  1659. WLAN_OS_REPORT(("- AP Disconnect = %d\n", ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_AP_DISCONNECT]));
  1660. WLAN_OS_REPORT(("- SEC attack = %d\n", ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_SECURITY_ATTACK]));
  1661. WLAN_OS_REPORT(("\n"));
  1662. WLAN_OS_REPORT(("- Succesfull Total roaming = %d\n", ((apConn_t *)hAPConnection)->roamingSuccesfulHandoverTotalNum));
  1663. WLAN_OS_REPORT(("- Unsuccesfull roaming = %d\n", ((apConn_t *)hAPConnection)->roamingFailedHandoverNum));
  1664. WLAN_OS_REPORT(("- Giving up roaming = %d\n", ((apConn_t *)hAPConnection)->retainCurrAPNum));
  1665. WLAN_OS_REPORT(("- Disconnect cmd from roaming manager = %d\n", ((apConn_t *)hAPConnection)->disconnectFromRoamMngrNum));
  1666. WLAN_OS_REPORT(("- Disconnect cmd from SME = %d\n", ((apConn_t *)hAPConnection)->stopFromSmeNum));
  1667. WLAN_OS_REPORT(("\n"));
  1668. }
  1669. /**
  1670. *
  1671. * apConn_getVendorSpecificIE
  1672. *
  1673. * \b Description:
  1674. *
  1675. * Called by Association SM when request to associate is built and sent to AP;
  1676. * returns request updated with vendor specific info-element
  1677. *
  1678. * \b ARGS:
  1679. *
  1680. * I - hAPConnection - AP Connection handle\n
  1681. * O - pRequest - pointer to request buffer\n
  1682. * O - len - size of returned IE\n
  1683. *
  1684. * \b RETURNS:
  1685. *
  1686. * OK if successful, NOK otherwise.
  1687. *
  1688. * \sa
  1689. */
  1690. TI_STATUS apConn_getVendorSpecificIE(TI_HANDLE hAPConnection, UINT8 *pRequest, UINT32 *len)
  1691. {
  1692. apConn_t *pAPConnection = (apConn_t *)hAPConnection;
  1693. if (pAPConnection->vsIElength > 0)
  1694. {
  1695. *len = pAPConnection->vsIElength;
  1696. os_memoryCopy(pAPConnection->hOs, pRequest, pAPConnection->vsIEbuf, pAPConnection->vsIElength);
  1697. }
  1698. else
  1699. {
  1700. *len = 0;
  1701. }
  1702. return OK;
  1703. }
  1704. /* Internal functions implementation */
  1705. /**
  1706. *
  1707. * apConn_smEvent
  1708. *
  1709. * \b Description:
  1710. *
  1711. * AP Connection state machine transition function
  1712. *
  1713. * \b ARGS:
  1714. *
  1715. * I/O - currentState - current state in the state machine\n
  1716. * I - event - specific event for the state machine\n
  1717. * I - pData - pointer to AP Connection context\n
  1718. *
  1719. * \b RETURNS:
  1720. *
  1721. * OK on success, NOK otherwise.
  1722. *
  1723. * \sa
  1724. */
  1725. static TI_STATUS apConn_smEvent(apConn_smStates *currState, UINT8 event, void* data)
  1726. {
  1727. TI_STATUS status;
  1728. UINT8 nextState;
  1729. apConn_t *pAPConnection;
  1730. pAPConnection = (apConn_t *)data;
  1731. status = fsm_GetNextState(pAPConnection->apConnSM, (UINT8)*currState, event, &nextState);
  1732. if (status == OK)
  1733. {
  1734. WLAN_REPORT_SM(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1735. ("<%s, %s> --> %s\n\n",
  1736. apConn_stateDesc[*currState],
  1737. apConn_eventDesc[event],
  1738. apConn_stateDesc[nextState]));
  1739. status = fsm_Event(pAPConnection->apConnSM, (UINT8 *)currState, event, pAPConnection);
  1740. return status;
  1741. }
  1742. else
  1743. {
  1744. WLAN_REPORT_ERROR(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("apConn_smEvent, fsm_GetNextState error\n"));
  1745. return status;
  1746. }
  1747. }
  1748. /**
  1749. *
  1750. * apConn_smNop - Do nothing
  1751. *
  1752. * \b Description:
  1753. *
  1754. * Do nothing in the SM.
  1755. *
  1756. * \b ARGS:
  1757. *
  1758. * I - pData - pointer to AP Connection context \n
  1759. *
  1760. * \b RETURNS:
  1761. *
  1762. * OK if successful, NOK otherwise.
  1763. *
  1764. *
  1765. */
  1766. static TI_STATUS apConn_smNop(void *pData)
  1767. {
  1768. WLAN_REPORT_INFORMATION((((apConn_t *)pData)->hReport), ROAMING_MANAGER_MODULE_LOG, ("apConn_smNop\n"));
  1769. return OK;
  1770. }
  1771. /**
  1772. *
  1773. * apConn_smUnexpected - Unexpected event
  1774. *
  1775. * \b Description:
  1776. *
  1777. * Unexpected event in the SM.
  1778. *
  1779. * \b ARGS:
  1780. *
  1781. * I - pData - pointer to AP Connection context \n
  1782. *
  1783. * \b RETURNS:
  1784. *
  1785. * OK if successful, NOK otherwise.
  1786. *
  1787. *
  1788. */
  1789. static TI_STATUS apConn_smUnexpected(void *pData)
  1790. {
  1791. WLAN_REPORT_INFORMATION(((apConn_t *)pData)->hReport, ROAMING_MANAGER_MODULE_LOG, ("apConn_smUnexpected\n"));
  1792. return NOK;
  1793. }
  1794. /**
  1795. *
  1796. * apConn_startWaitingForTriggers
  1797. *
  1798. * \b Description:
  1799. *
  1800. * SME informs AP Connection module about successfull link establishment; start wiating for roaming triggers
  1801. *
  1802. * \b ARGS:
  1803. *
  1804. * I - pData - pointer to AP Connection context \n
  1805. *
  1806. * \b RETURNS:
  1807. *
  1808. * OK on success, NOK otherwise.
  1809. *
  1810. * \sa
  1811. */
  1812. static TI_STATUS apConn_startWaitingForTriggers(void *pData)
  1813. {
  1814. apConn_t *pAPConnection;
  1815. apConn_connStatus_t reportStatus;
  1816. paramInfoPartial_t param;
  1817. pAPConnection = (apConn_t *)pData;
  1818. if ((pAPConnection->roamingEnabled) && (pAPConnection->reportStatusCallb != NULL))
  1819. {
  1820. param.paramType = ASSOC_ASSOCIATION_RESP_PARAM;
  1821. assoc_getParamPartial(pAPConnection->hAssoc, &param);
  1822. reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
  1823. reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
  1824. reportStatus.status = CONN_STATUS_CONNECTED;
  1825. pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
  1826. }
  1827. pAPConnection->firstAttempt2Roam = TRUE;
  1828. pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
  1829. pAPConnection->removeKeys = TRUE;
  1830. pAPConnection->sendDeauthPacket = TRUE;
  1831. pAPConnection->reNegotiateTSPEC = FALSE;
  1832. pAPConnection->voiceTspecConfigured = FALSE;
  1833. pAPConnection->videoTspecConfigured = FALSE;
  1834. return OK;
  1835. }
  1836. /**
  1837. *
  1838. * apConn_connectedToNewAP
  1839. *
  1840. * \b Description:
  1841. *
  1842. * After roaming was requested, Connection SM informs AP Connection module about
  1843. * successful link re-establishment; start waiting for roaming triggers
  1844. *
  1845. * \b ARGS:
  1846. *
  1847. * I - pData - pointer to AP Connection context \n
  1848. *
  1849. * \b RETURNS:
  1850. *
  1851. * OK on success, NOK otherwise.
  1852. *
  1853. * \sa
  1854. */
  1855. static TI_STATUS apConn_connectedToNewAP(void *pData)
  1856. {
  1857. apConn_t *pAPConnection;
  1858. apConn_connStatus_t reportStatus;
  1859. paramInfoPartial_t param;
  1860. pAPConnection = (apConn_t *)pData;
  1861. /* Configure SCR group back to connection */
  1862. scr_setGroup (pAPConnection->hScr, SCR_GID_CONNECTED);
  1863. /* Erase vendor specific info-element if was defined for last AP Assoc request */
  1864. pAPConnection->vsIElength = 0;
  1865. /* TBD Notify Curr BSS module about update of current AP database */
  1866. if (pAPConnection->roamingFailedHandoverNum>0)
  1867. {
  1868. pAPConnection->roamingFailedHandoverNum--;
  1869. }
  1870. /* Report Roaming Manager */
  1871. if (pAPConnection->reportStatusCallb != NULL)
  1872. {
  1873. param.paramType = ASSOC_ASSOCIATION_RESP_PARAM;
  1874. assoc_getParamPartial(pAPConnection->hAssoc, &param);
  1875. reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
  1876. reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
  1877. reportStatus.status = CONN_STATUS_HANDOVER_SUCCESS;
  1878. pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
  1879. }
  1880. pAPConnection->firstAttempt2Roam = TRUE;
  1881. pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
  1882. pAPConnection->roamingSuccesfulHandoverTotalNum++;
  1883. pAPConnection->removeKeys = TRUE;
  1884. pAPConnection->sendDeauthPacket = TRUE;
  1885. pAPConnection->reNegotiateTSPEC = FALSE;
  1886. pAPConnection->voiceTspecConfigured = FALSE;
  1887. pAPConnection->videoTspecConfigured = FALSE;
  1888. if (!pAPConnection->resetReportedRoamingStatistics)
  1889. {
  1890. pAPConnection->roamingSuccesfulHandoverNum++;
  1891. pAPConnection->lastRoamingDelay =
  1892. (UINT16)os_timeStampMs(pAPConnection->hOs) - pAPConnection->roamingStartedTimestamp;
  1893. }
  1894. else
  1895. {
  1896. pAPConnection->resetReportedRoamingStatistics = FALSE;
  1897. }
  1898. /* Raise event of Roaming Completion */
  1899. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1900. ("EvHandlerSendEvent -ROAMING_COMPLETE\n" ));
  1901. EvHandlerSendEvent(pAPConnection->hEvHandler, IPC_EVENT_ROAMING_COMPLETE, NULL, 0);
  1902. return OK;
  1903. }
  1904. /**
  1905. *
  1906. * apConn_stopConnection
  1907. *
  1908. * \b Description:
  1909. *
  1910. * Stop required before roaming was started
  1911. *
  1912. * \b ARGS:
  1913. *
  1914. * I - pData - pointer to AP Connection context\n
  1915. *
  1916. * \b RETURNS:
  1917. *
  1918. * OK on success, NOK otherwise.
  1919. *
  1920. * \sa
  1921. */
  1922. static TI_STATUS apConn_stopConnection(void *pData)
  1923. {
  1924. apConn_t *pAPConnection;
  1925. disConnType_e disConnType;
  1926. pAPConnection = (apConn_t *)pData;
  1927. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  1928. ("apConn_stopConnection, calls conn_stop, removeKeys=%d, sendDeauthPacket=%d \n", pAPConnection->removeKeys, pAPConnection->sendDeauthPacket));
  1929. /* Erase vendor specific info-element if was defined for last AP Assoc request */
  1930. pAPConnection->vsIElength = 0;
  1931. /* In case AP connection was stopped by SME, and radioOn is false, meaning immidiate shutdown is required without disassoc frame */
  1932. /* Otherwise, ask for normal disconnection with disassoc frame */
  1933. disConnType = (pAPConnection->sendDeauthPacket == TRUE) ? DISCONN_TYPE_DEAUTH : DISCONN_TYPE_IMMEDIATE;
  1934. /* Stop Connection state machine - always immediate TBD */
  1935. conn_stop(pAPConnection->hConnSm,
  1936. disConnType,
  1937. STATUS_UNSPECIFIED,
  1938. FALSE, /* pAPConnection->removeKeys - for Roaming, do not remove the keys */
  1939. apConn_DisconnCompleteInd,
  1940. pAPConnection);
  1941. return OK;
  1942. }
  1943. /**
  1944. *
  1945. * apConn_reportDisconnected
  1946. *
  1947. * \b Description:
  1948. *
  1949. * Moving from 'Disconnecting' state to 'Idle':
  1950. * RoamMgr.status("not-connected")
  1951. *
  1952. * \b ARGS:
  1953. *
  1954. * I - pData - pointer to AP Connection context\n
  1955. *
  1956. * \b RETURNS:
  1957. *
  1958. * OK on success, NOK otherwise.
  1959. *
  1960. * \sa
  1961. */
  1962. static TI_STATUS apConn_reportDisconnected(void *pData)
  1963. {
  1964. apConn_t *pAPConnection;
  1965. apConn_connStatus_t reportStatus;
  1966. pAPConnection = (apConn_t *)pData;
  1967. if (pAPConnection->reportStatusCallb != NULL)
  1968. {
  1969. reportStatus.status = CONN_STATUS_NOT_CONNECTED;
  1970. pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
  1971. }
  1972. pAPConnection->firstAttempt2Roam = TRUE;
  1973. /* Notify SME */
  1974. apConn_reportConnStatusToSME(pAPConnection);
  1975. return OK;
  1976. }
  1977. /**
  1978. *
  1979. * apConn_retainAP
  1980. *
  1981. * \b Description:
  1982. *
  1983. * Roaming Manager gives up on roaming.
  1984. * Moving from 'Wait for connection command' back to 'Wait for roam started.
  1985. *
  1986. * \b ARGS:
  1987. *
  1988. * I - pData - pointer to AP Connection context\n
  1989. *
  1990. * \b RETURNS:
  1991. *
  1992. * OK on success, NOK otherwise.
  1993. *
  1994. * \sa
  1995. */
  1996. static TI_STATUS apConn_retainAP(void *data)
  1997. {
  1998. apConn_t *pAPConnection;
  1999. apConn_connStatus_t reportStatus;
  2000. paramInfo_t param;
  2001. pAPConnection = (apConn_t *)data;
  2002. /* Configure SCR group back to connection */
  2003. scr_setGroup (pAPConnection->hScr, SCR_GID_CONNECTED);
  2004. /* Report Roaming Manager */
  2005. if (pAPConnection->reportStatusCallb != NULL)
  2006. {
  2007. param.paramType = ASSOC_ASSOCIATION_RESP_PARAM;
  2008. assoc_getParam(pAPConnection->hAssoc, &param);
  2009. reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
  2010. reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
  2011. reportStatus.status = CONN_STATUS_HANDOVER_SUCCESS;
  2012. pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
  2013. }
  2014. pAPConnection->retainCurrAPNum++;
  2015. pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
  2016. pAPConnection->removeKeys = TRUE;
  2017. pAPConnection->sendDeauthPacket = TRUE;
  2018. pAPConnection->reNegotiateTSPEC = FALSE;
  2019. pAPConnection->voiceTspecConfigured = FALSE;
  2020. pAPConnection->videoTspecConfigured = FALSE;
  2021. return OK;
  2022. }
  2023. /**
  2024. *
  2025. * apConn_requestCCKM
  2026. *
  2027. * \b Description:
  2028. *
  2029. * Roaming Manager requests to roaming.
  2030. * Get CCKM (prepare hand-off).
  2031. *
  2032. * \b ARGS:
  2033. *
  2034. * I - pData - pointer to AP Connection context\n
  2035. *
  2036. * \b RETURNS:
  2037. *
  2038. * OK on success, NOK otherwise.
  2039. *
  2040. * \sa
  2041. */
  2042. static TI_STATUS apConn_requestCCKM(void *data)
  2043. {
  2044. apConn_t *pAPConnection;
  2045. TI_STATUS status;
  2046. pAPConnection = (apConn_t *)data;
  2047. #ifdef EXC_MODULE_INCLUDED
  2048. /* Send request to EXC module */
  2049. apConn_calcNewTsf(pAPConnection, (UINT8 *)&(pAPConnection->newAP->lastRxTSF), pAPConnection->newAP->lastRxHostTimestamp, pAPConnection->newAP->beaconInterval);
  2050. status = excMngr_startCckm(pAPConnection->hExcMngr, &(pAPConnection->newAP->BSSID), (UINT8 *)&(pAPConnection->newAP->lastRxTSF));
  2051. #else
  2052. status = OK;
  2053. apConn_RoamHandoffFinished(pAPConnection);
  2054. #endif
  2055. return status;
  2056. }
  2057. #ifdef EXC_MODULE_INCLUDED
  2058. /**
  2059. *
  2060. * calcNewTsfTimestamp - Calculates the TSF
  2061. *
  2062. * \b Description:
  2063. *
  2064. * Calculates the TSF according to the delta of the TSF from the last Beacon/Probe Resp and the current time.
  2065. *
  2066. * \b ARGS:
  2067. *
  2068. * I - hRoamingMngr - pointer to the roamingMngr SM context \n
  2069. * I/O - tsfTimeStamp - the TSF field in the site entry of the roaming candidate AP
  2070. * I - newSiteOsTimeStamp - the TS field in the site entry of the roaming candidate AP
  2071. *
  2072. * \b RETURNS:
  2073. *
  2074. * Nothing.
  2075. *
  2076. *
  2077. */
  2078. static void apConn_calcNewTsf(apConn_t *hAPConnection, UINT8 *tsfTimeStamp, UINT32 newSiteOsTimeStamp, UINT32 beaconInterval)
  2079. {
  2080. apConn_t *pAPConnection = hAPConnection;
  2081. UINT32 osTimeStamp = os_timeStampMs(pAPConnection->hOs);
  2082. UINT32 deltaTimeStamp;
  2083. UINT32 tsfLsdw,tsfMsdw, newOsTimeStamp;
  2084. UINT32 remainder;
  2085. UINT8 newTsfTimestamp[TIME_STAMP_LEN];
  2086. /* get the delta TS between the TS of the last Beacon/ProbeResp-from the site table
  2087. and the current TS */
  2088. deltaTimeStamp = osTimeStamp - newSiteOsTimeStamp;
  2089. tsfLsdw = *((UINT32*)&tsfTimeStamp[0]);
  2090. tsfMsdw = *((UINT32*)&tsfTimeStamp[4]);
  2091. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  2092. (" TSF time LSDW reversed=%x, TSF time MSDW reversed=%x\n",
  2093. tsfLsdw, tsfMsdw));
  2094. deltaTimeStamp = deltaTimeStamp*1000;/* from mSec to uSec*/
  2095. /* Before adding, save remainder */
  2096. remainder = tsfTimeStamp[3] + ((deltaTimeStamp & 0xff000000) >> 24);
  2097. /* The LS DW of the TS is the TSF taken from the last Beacon/Probe Resp
  2098. + the delta TS from the time the Beacon/Probe Resp arrive till now. */
  2099. newOsTimeStamp = deltaTimeStamp+tsfLsdw;
  2100. /* substracting one beacon interval */
  2101. newOsTimeStamp -= (beaconInterval * 1024); /* im usec */
  2102. /* save just for debug printout */
  2103. deltaTimeStamp +=osTimeStamp; /* uMsec */
  2104. /* update the LSB of the TSF */
  2105. newTsfTimestamp[0] = newOsTimeStamp & 0x000000ff;
  2106. newTsfTimestamp[1] = (newOsTimeStamp & 0x0000ff00) >> 8;
  2107. newTsfTimestamp[2] = (newOsTimeStamp & 0x00ff0000) >> 16;
  2108. newTsfTimestamp[3] = (newOsTimeStamp & 0xff000000) >> 24;
  2109. /* increase the MSB in case of overflow */
  2110. if (remainder > 0xff)
  2111. {
  2112. tsfMsdw++;
  2113. }
  2114. /* update the MSB of the TSF */
  2115. newTsfTimestamp[4] = tsfMsdw & 0x000000ff;
  2116. newTsfTimestamp[5] = (tsfMsdw & 0x0000ff00) >> 8;
  2117. newTsfTimestamp[6] = (tsfMsdw & 0x00ff0000) >> 16;
  2118. newTsfTimestamp[7] = (tsfMsdw & 0xff000000) >> 24;
  2119. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  2120. (" NEW TSF time: reversedTsfTimeStamp= 0x%x, New deltaTimeStamp= 0x%x, \n remainder=0x%x, new tsfTimeStamp=%x-%x-%x-%x-%x-%x-%x-%x\n",
  2121. newOsTimeStamp, deltaTimeStamp, remainder,
  2122. newTsfTimestamp[0], newTsfTimestamp[1], newTsfTimestamp[2], newTsfTimestamp[3],
  2123. newTsfTimestamp[4], newTsfTimestamp[5], newTsfTimestamp[6], newTsfTimestamp[7]));
  2124. os_memoryCopy(pAPConnection->hOs, tsfTimeStamp, newTsfTimestamp, TIME_STAMP_LEN);
  2125. }
  2126. #endif
  2127. /**
  2128. *
  2129. * apConn_invokeConnectionToNewAp
  2130. *
  2131. * \b Description:
  2132. *
  2133. * Got CCKM (hand-off), start re-connection to another AP
  2134. *
  2135. * \b ARGS:
  2136. *
  2137. * I - pData - pointer to AP Connection context\n
  2138. *
  2139. * \b RETURNS:
  2140. *
  2141. * OK on success, NOK otherwise.
  2142. *
  2143. * \sa
  2144. */
  2145. static TI_STATUS apConn_invokeConnectionToNewAp(void *data)
  2146. {
  2147. apConn_t *pAPConnection;
  2148. connType_e connType;
  2149. paramInfoPartial_t param;
  2150. UINT8 staPrivacySupported, apPrivacySupported;
  2151. BOOL renegotiateTspec = FALSE;
  2152. pAPConnection = (apConn_t *)data;
  2153. pAPConnection->roamingStartedTimestamp = os_timeStampMs(pAPConnection->hOs);
  2154. /* Check privacy compatibility */
  2155. param.paramType = RSN_ENCRYPTION_STATUS_PARAM;
  2156. rsn_getParamPartial(pAPConnection->hPrivacy, &param);
  2157. staPrivacySupported = (param.content.rsnEncryptionStatus == RSN_CIPHER_NONE) ? FALSE : TRUE;
  2158. apPrivacySupported = ((pAPConnection->newAP->capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TRUE : FALSE;
  2159. if (staPrivacySupported != apPrivacySupported)
  2160. {
  2161. param.paramType = RSN_MIXED_MODE;
  2162. rsn_getParamPartial(pAPConnection->hPrivacy, &param);
  2163. if (apPrivacySupported ||
  2164. (!param.content.rsnMixedMode && staPrivacySupported))
  2165. {
  2166. WLAN_REPORT_WARNING(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  2167. ("%s: failed privacy comparison %d vs. %d\n", __FUNCTION__, staPrivacySupported, apPrivacySupported));
  2168. return (apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection));
  2169. }
  2170. }
  2171. /* Update data info of desired AP; in case of first attempt to roam,
  2172. store previous primary site info */
  2173. if (siteMgr_overwritePrimarySite(pAPConnection->hSiteMgr, pAPConnection->newAP, pAPConnection->firstAttempt2Roam) != OK)
  2174. {
  2175. WLAN_REPORT_WARNING(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  2176. ("%s: failed to ovewrite Primary Site\n", __FUNCTION__));
  2177. return (apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection));
  2178. }
  2179. /* Update re-associate parameter of MLME */
  2180. if (pAPConnection->requestType == AP_CONNECT_FAST_TO_AP)
  2181. {
  2182. connType = CONN_TYPE_ROAM;
  2183. }
  2184. else
  2185. {
  2186. connType = CONN_TYPE_FIRST_CONN;
  2187. }
  2188. #ifdef EXC_MODULE_INCLUDED
  2189. /* Check the need in TSPEC re-negotiation */
  2190. if ( (pAPConnection->voiceTspecConfigured || pAPConnection->videoTspecConfigured)
  2191. && pAPConnection->reNegotiateTSPEC )
  2192. {
  2193. /* If the candidate AP is at least EXCver4 AP, try to re-negotiate TSPECs */
  2194. if (excMngr_parseExcVer(pAPConnection->hExcMngr,
  2195. pAPConnection->newAP->pBuffer,
  2196. pAPConnection->newAP->bufferLength) >= 4)
  2197. {
  2198. renegotiateTspec = TRUE;
  2199. }
  2200. }
  2201. #endif
  2202. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  2203. ("%s: calls conn_start, removeKeys=%d, renegotiateTSPEC=%d\n", __FUNCTION__,
  2204. pAPConnection->removeKeys, renegotiateTspec));
  2205. /* Start Connection state machine */
  2206. return conn_start(pAPConnection->hConnSm,
  2207. connType,
  2208. apConn_ConnCompleteInd,
  2209. pAPConnection,
  2210. pAPConnection->removeKeys,
  2211. renegotiateTspec);
  2212. }
  2213. /**
  2214. *
  2215. * apConn_reportConnFail
  2216. *
  2217. * \b Description:
  2218. *
  2219. * Got 'Failed' indication from Connection state machine - inform Roaming Manager Module
  2220. *
  2221. * \b ARGS:
  2222. *
  2223. * I - pData - pointer to AP Connection context\n
  2224. *
  2225. * \b RETURNS:
  2226. *
  2227. * OK on success, NOK otherwise.
  2228. *
  2229. * \sa
  2230. */
  2231. static TI_STATUS apConn_reportConnFail(void *data)
  2232. {
  2233. apConn_t *pAPConnection;
  2234. apConn_connStatus_t reportStatus;
  2235. paramInfoPartial_t param;
  2236. pAPConnection = (apConn_t *)data;
  2237. pAPConnection->firstAttempt2Roam = FALSE;
  2238. pAPConnection->resetReportedRoamingStatistics = FALSE;
  2239. /* Erase vendor specific info-element if was defined for last AP Assoc request */
  2240. pAPConnection->vsIElength = 0;
  2241. /* Report to Roaming Manager */
  2242. if (pAPConnection->reportStatusCallb != NULL)
  2243. {
  2244. param.paramType = ASSOC_ASSOCIATION_RESP_PARAM;
  2245. assoc_getParamPartial(pAPConnection->hAssoc, &param);
  2246. reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
  2247. reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
  2248. reportStatus.status = CONN_STATUS_HANDOVER_FAILURE;
  2249. pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);
  2250. }
  2251. return OK;
  2252. }
  2253. /**
  2254. *
  2255. * apConn_configureSCR
  2256. *
  2257. * \b Description:
  2258. *
  2259. * Got 'Failed' indication from Connection state machine - inform Roaming Manager Module
  2260. *
  2261. * \b ARGS:
  2262. *
  2263. * I - pData - pointer to AP Connection context\n
  2264. *
  2265. * \b RETURNS:
  2266. *
  2267. * OK on success, NOK otherwise.
  2268. *
  2269. * \sa
  2270. */
  2271. static TI_STATUS apConn_configureDriverBeforeRoaming(void *pData)
  2272. {
  2273. apConn_t *pAPConnection = (apConn_t*)pData;
  2274. paramInfoPartial_t param;
  2275. /* Configure SCR group of allowed clients according to 'Roaming' rule */
  2276. scr_setGroup (pAPConnection->hScr, SCR_GID_ROAMING);
  2277. param.paramType = QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC;
  2278. qosMngr_getParamsPatial(pAPConnection->hQos, &param);
  2279. pAPConnection->voiceTspecConfigured = param.content.TspecConfigure.voiceTspecConfigure;
  2280. pAPConnection->videoTspecConfigured = param.content.TspecConfigure.videoTspecConfigure;
  2281. pAPConnection->resetReportedRoamingStatistics = FALSE;
  2282. return OK;
  2283. }
  2284. /**
  2285. *
  2286. * apConn_swChFinished
  2287. *
  2288. * \b Description:
  2289. *
  2290. * Switch channel completed; if there were roaming Manager triggers meanwhile,
  2291. * inform Roaming Manager Module
  2292. *
  2293. * \b ARGS:
  2294. *
  2295. * I - pData - pointer to AP Connection context\n
  2296. *
  2297. * \b RETURNS:
  2298. *
  2299. * OK on success, NOK otherwise.
  2300. *
  2301. * \sa
  2302. */
  2303. static TI_STATUS apConn_swChFinished(void *pData)
  2304. {
  2305. apConn_t *pAPConnection = (apConn_t *)pData;
  2306. /* Inform Current BSS module */
  2307. currBSS_restartRssiCounting(pAPConnection->hCurrBSS);
  2308. /* If there are unreported roaming triggers of 'No AP' type,
  2309. report them now to roaming manager */
  2310. if (pAPConnection->roamReason >= ROAMING_TRIGGER_MAX_TX_RETRIES)
  2311. {
  2312. if ((pAPConnection->roamingEnabled == TRUE) &&
  2313. (pAPConnection->roamEventCallb != NULL))
  2314. {
  2315. /* Report to Roaming Manager */
  2316. pAPConnection->roamEventCallb(pAPConnection->hRoamMng, &pAPConnection->roamReason);
  2317. }
  2318. }
  2319. else
  2320. {
  2321. pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
  2322. }
  2323. return OK;
  2324. }
  2325. /**
  2326. *
  2327. * apConn_handleTspecReneg
  2328. *
  2329. * \b Description:
  2330. *
  2331. * This function will be called when moving from CONNECTING state to
  2332. * START_TSPEC_RENEGOTIATION state. It checks if TSPEC re-negotiation was requested
  2333. * by roaming manager, if the TSPEC for voice was defined by user application,
  2334. * if the re-negotiation was performed during hand-over.
  2335. * If so, it will trigger moving to WAIT_ROAM state, otherwise it will start
  2336. * TSPEC negotiation, staying in the REESTABLISHING_VOICE state and waiting
  2337. * for results.
  2338. *
  2339. * \b ARGS:
  2340. *
  2341. * I - pData - pointer to AP Connection context\n
  2342. *
  2343. * \b RETURNS:
  2344. *
  2345. * OK on success, NOK otherwise.
  2346. *
  2347. * \sa
  2348. */
  2349. static TI_STATUS apConn_handleTspecReneg (void *pData)
  2350. {
  2351. apConn_t *pAPConnection = (apConn_t *)pData;
  2352. paramInfo_t param;
  2353. if (pAPConnection->voiceTspecConfigured && pAPConnection->reNegotiateTSPEC)
  2354. {
  2355. param.paramType = QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC;
  2356. qosMngr_getParams(pAPConnection->hQos, &param);
  2357. if (param.content.TspecConfigure.voiceTspecConfigure == TRUE)
  2358. {
  2359. /* TSPEC is already configured, move to CONNECTED */
  2360. return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
  2361. }
  2362. else
  2363. {
  2364. param.paramType = QOS_MNGR_RESEND_TSPEC_REQUEST;
  2365. param.content.qosRenegotiateTspecRequest.callback = (void *)apConn_qosMngrReportResultCallb;
  2366. param.content.qosRenegotiateTspecRequest.handler = pData;
  2367. if (qosMngr_setParams(pAPConnection->hQos, &param) != OK)
  2368. {
  2369. /* Re-negotiation of TSPEC cannot be performed */
  2370. return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection);
  2371. }
  2372. return OK;
  2373. }
  2374. }
  2375. else
  2376. {
  2377. /* No need to re-negotiate TSPEC, move to CONNECTED */
  2378. return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
  2379. }
  2380. }
  2381. /**
  2382. *
  2383. * apConn_qosMngrReportResultCallb
  2384. *
  2385. * \b Description:
  2386. *
  2387. * This function will be transferred to QoS manager upon request to start negotiation
  2388. * of the TSPEC for voice and signaling, and will be called when the voice TSPEC
  2389. * renegotiation is completed. The function will generate FINISHED_OK or
  2390. * FINISHED_NOK events to the state machine of AP Connection, triggering change of
  2391. * the current state.
  2392. *
  2393. * \b ARGS:
  2394. *
  2395. * I - hApConn - pointer to AP Connection context\n
  2396. * I - result - returned by Traffic admission control\n
  2397. *
  2398. * \b RETURNS:
  2399. *
  2400. * OK on success, NOK otherwise.
  2401. *
  2402. * \sa
  2403. */
  2404. static TI_STATUS apConn_qosMngrReportResultCallb (TI_HANDLE hApConn, trafficAdmRequestStatus_e result)
  2405. {
  2406. apConn_t *pAPConnection = (apConn_t *)hApConn;
  2407. AP_CONN_VALIDATE_HANDLE(hApConn);
  2408. if (result == STATUS_TRAFFIC_ADM_REQUEST_ACCEPT)
  2409. {
  2410. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
  2411. }
  2412. else
  2413. {
  2414. apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection);
  2415. }
  2416. return OK;
  2417. }
  2418. /**
  2419. *
  2420. * apConn_reportConnStatusToSME
  2421. *
  2422. * \b Description:
  2423. *
  2424. * Sends report to SME regarding the connection status
  2425. *
  2426. * \b ARGS:
  2427. *
  2428. * I - pAPConnection - pointer to AP Connection context\n
  2429. *
  2430. * \b RETURNS:
  2431. *
  2432. * OK on success, NOK otherwise.
  2433. *
  2434. * \sa
  2435. */
  2436. static void apConn_reportConnStatusToSME (apConn_t *pAPConnection)
  2437. {
  2438. WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
  2439. ("%s roamingTrigger = %d, APDisconnectStatusCode = %d, bNonRoamingDisAssocReason = %d\n",
  2440. __FUNCTION__, pAPConnection->roamReason, pAPConnection->APDisconnect.uStatusCode,
  2441. pAPConnection->bNonRoamingDisAssocReason));
  2442. /* Check if an outside reason caused the disconnection. */
  2443. if (pAPConnection->bNonRoamingDisAssocReason)
  2444. {
  2445. pAPConnection->bNonRoamingDisAssocReason = FALSE;
  2446. smeSm_reportConnStatus(pAPConnection->hSme, STATUS_UNSPECIFIED, 0);
  2447. }
  2448. /* DisAssociation happened due to roaming trigger */
  2449. else if (pAPConnection->roamReason == ROAMING_TRIGGER_AP_DISCONNECT)
  2450. { /* AP disconnect is a special case of the status delivered to SME */
  2451. mgmtStatus_e mgmtStatus = ( pAPConnection->APDisconnect.bDeAuthenticate ? STATUS_AP_DEAUTHENTICATE : STATUS_AP_DISASSOCIATE );
  2452. smeSm_reportConnStatus(pAPConnection->hSme, mgmtStatus, pAPConnection->APDisconnect.uStatusCode);
  2453. }
  2454. else /* Finally, just send the last roaming trigger */
  2455. {
  2456. smeSm_reportConnStatus(pAPConnection->hSme, STATUS_ROAMING_TRIGGER, (UINT32)pAPConnection->roamReason);
  2457. }
  2458. }