PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

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

http://github.com/CyanogenMod/cm-kernel
C | 1786 lines | 932 code | 200 blank | 654 comment | 92 complexity | a29c4f7cede1ef95734795242c7e3f22 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  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

Large files files are truncated, but you can click here to view the full file