PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/Management/scan/scanCncn/ScanCncnAppApi.c

http://github.com/CyanogenMod/cm-kernel
C | 213 lines | 110 code | 17 blank | 86 comment | 13 complexity | 1e23339794b14af1d711ced08750bfc5 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.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 ScanCncnAppApi.c
  36. * \brief This file include implementation of application scan requests adapter.\n
  37. * \author Ronen Kalish
  38. * \date 30-Jan-2005
  39. */
  40. #include "ScanCncnAppApi.h"
  41. #include "ScanCncn.h"
  42. #include "EvHandler.h"
  43. #include "report.h"
  44. #include "smeApi.h"
  45. #include "siteMgrApi.h"
  46. #include "ScanCncnOidSM.h"
  47. /**
  48. * \author Ronen Kalish\n
  49. * \date 30-Jan-2005\n
  50. * \brief Parses and executes a set param command.\n
  51. *
  52. * Function Scope \e Public.\n
  53. * \param hScanCncn - handle to the scan concentrator object.\n
  54. * \param pParam - the param to set.\n
  55. * \return OK if the scan started successfully, NOK otherwise.\n
  56. */
  57. TI_STATUS scanConcentrator_setParam( TI_HANDLE hScanCncn, paramInfo_t *pParam )
  58. {
  59. scanConcentrator_t* pScanConcentrator = (scanConcentrator_t *)hScanCncn;
  60. scan_Params_t* pScanParam;
  61. UINT32 currentTimeStamp;
  62. switch ( pParam->paramType )
  63. {
  64. case SCAN_CNCN_START_APP_SCAN:
  65. pScanParam = pParam->content.pScanParams;
  66. /*
  67. * Prepare scan complete's aging, by increasing the scanned sites
  68. * scan attemps counter. The counter will be checked upon scan complete,
  69. * and the sites with no update scan results will be dropped.
  70. */
  71. siteMgr_setNotReceivedParameter( pScanConcentrator->hSiteManager, &(pScanParam->desiredSsid), pScanParam->band );
  72. if ( SCAN_CRS_SCAN_RUNNING !=
  73. scanConcentrator_scan( hScanCncn, SCAN_SCC_APP, pScanParam ) )
  74. {
  75. /* Scan was not started successfully, send a scan complete event to the user */
  76. EvHandlerSendEvent( pScanConcentrator->hEventSrv, IPC_EVENT_SCAN_COMPLETE, NULL, 0 );
  77. return NOK;
  78. }
  79. break;
  80. case SCAN_CNCN_STOP_APP_SCAN:
  81. scanConcentrator_stopScan( hScanCncn, SCAN_SCC_APP );
  82. break;
  83. case SCAN_CNCN_BSSID_LIST_SCAN_PARAM:
  84. /* check if OID scans are enabled in the registry */
  85. if ( 0 == pScanConcentrator->initParams.minimumDurationBetweenOidScans )
  86. {
  87. WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
  88. ("Received OID scan request when OID scans are disabled, quitting...\n") );
  89. return OK; /* TODO ronen: return correct Windows value */
  90. }
  91. /* check if the last OID scan didn't start at a shorter duration than the configured minimum */
  92. currentTimeStamp = os_timeStampMs( pScanConcentrator->hOS );
  93. if ( (currentTimeStamp - pScanConcentrator->oidScanLastTimeStamp) <
  94. (pScanConcentrator->initParams.minimumDurationBetweenOidScans * 1000) ) /*converted to ms */
  95. {
  96. WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
  97. ("Last OID scan performed at:%d, now is:%d, min duration is %d, too early for another scan!\n", \
  98. pScanConcentrator->oidScanLastTimeStamp, currentTimeStamp, pScanConcentrator->initParams.minimumDurationBetweenOidScans) );
  99. return OK; /* TODO ronen: return correct Windows value */
  100. }
  101. /* mark that an OID scan process has started */
  102. pScanConcentrator->bOidScanRunning = TRUE;
  103. pScanConcentrator->oidScanLastTimeStamp = currentTimeStamp;
  104. WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
  105. ("Starting OID scan process...\n") );
  106. /* and actually start the scan */
  107. scanConcentratorOidSM_SMEvent( hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_START_SCAN );
  108. break;
  109. default:
  110. WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
  111. ("Set param, Params is not supported:%d\n\n", pParam->paramType) );
  112. return PARAM_NOT_SUPPORTED;
  113. }
  114. return OK;
  115. }
  116. /**
  117. * \author Ronen Kalish\n
  118. * \date 30-Jan-2005\n
  119. * \brief Parses and executes a get param command.\n
  120. *
  121. * Function Scope \e Public.\n
  122. * \param hScanCncn - handle to the scan concentrator object.\n
  123. * \param pParam - the param to get.\n
  124. * \return always PARAM_NOT_SUPPORTED (not supposed to be called).\n
  125. */
  126. TI_STATUS scanConcentrator_getParam( TI_HANDLE hScanCncn, paramInfo_t *pParam )
  127. {
  128. return PARAM_NOT_SUPPORTED;
  129. }
  130. /**
  131. * \author Ronen Kalish\n
  132. * \date 30-Jan-2005\n
  133. * \brief Scan result callback for application scan.\n
  134. *
  135. * Function Scope \e Public.\n
  136. * \param hScanCncn - handle to the scan concentrator object.\n
  137. * \param status - the scan result status (scan complete, result received etc.).\n
  138. * \param frameInfo - a pointer to the structure holding all frame related info (in case a frame was received).\n
  139. * \prama SPSStatus - a bitmap indicating on which channels scan was attempted (valid for SPS scan only!).\n
  140. */
  141. void scanConcentrator_appScanResultCB( TI_HANDLE hScanCncn, scan_cncnResultStatus_e status,
  142. scan_frameInfo_t* frameInfo, UINT16 SPSStatus )
  143. {
  144. scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
  145. switch ( status )
  146. {
  147. case SCAN_CRS_RECEIVED_FRAME:
  148. /* forward scan results to site manager, like in the good old days... */
  149. siteMgr_updateSite( pScanConcentrator->hSiteManager, frameInfo->bssId,
  150. frameInfo->parsedIEs, frameInfo->channel, frameInfo->band, FALSE );
  151. if ( BEACON == frameInfo->parsedIEs->subType )
  152. {
  153. siteMgr_saveBeaconBuffer( pScanConcentrator->hSiteManager, frameInfo->bssId,
  154. frameInfo->buffer, frameInfo->bufferLength );
  155. }
  156. else
  157. {
  158. siteMgr_saveProbeRespBuffer( pScanConcentrator->hSiteManager, frameInfo->bssId,
  159. frameInfo->buffer, frameInfo->bufferLength );
  160. }
  161. break;
  162. case SCAN_CRS_SCAN_COMPLETE_OK:
  163. siteMgr_removeNotReceivedSites( pScanConcentrator->hSiteManager );
  164. /* There's no break on purpose! */
  165. /* if the current running app scan is an OID scan, send a scan complete event to its state machine */
  166. if ( TRUE == pScanConcentrator->bOidScanRunning )
  167. {
  168. scanConcentratorOidSM_SMEvent(hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_COMPLETE );
  169. }
  170. else
  171. {
  172. /* send a scan complete event to the user */
  173. EvHandlerSendEvent( pScanConcentrator->hEventSrv, IPC_EVENT_SCAN_COMPLETE, NULL, 0 );
  174. }
  175. break;
  176. case SCAN_CRS_TSF_ERROR:
  177. case SCAN_CRS_SCAN_STOPPED:
  178. case SCAN_CRS_SCAN_RUNNING:
  179. case SCAN_CRS_SCAN_FAILED:
  180. case SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY:
  181. case SCAN_CRS_SCAN_ABORTED_FW_RESET:
  182. case SCAN_CRS_NUM_OF_RES_STATUS:
  183. default:
  184. /* The scan was finished, send a scan complete event to the user
  185. (regardless of why the scan was completed) */
  186. if ( TRUE == pScanConcentrator->bOidScanRunning )
  187. {
  188. scanConcentratorOidSM_SMEvent(hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_FAILED );
  189. }
  190. else
  191. {
  192. EvHandlerSendEvent( pScanConcentrator->hEventSrv, IPC_EVENT_SCAN_COMPLETE, NULL, 0 );
  193. }
  194. break;
  195. }
  196. }