PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/hal/security/whalWep.c

http://github.com/CyanogenMod/cm-kernel
C | 187 lines | 62 code | 23 blank | 102 comment | 10 complexity | 4397835f5c9ba37028d1e801debc4ff8 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. #include "whalCommon.h"
  36. #include "whalCtrl_api.h"
  37. #include "whalCtrl.h"
  38. #include "whalSecurity.h"
  39. /*
  40. * ----------------------------------------------------------------------------
  41. * Function : whalWep_Create
  42. *
  43. * Input :
  44. * Output :
  45. * Process :
  46. * Note(s) :
  47. * -----------------------------------------------------------------------------
  48. */
  49. TI_HANDLE whalWep_Create (TI_HANDLE hOs, TI_HANDLE hWhalCtrl)
  50. {
  51. WHAL_WEP* pWhalWep;
  52. pWhalWep = (WHAL_WEP *)os_memoryAlloc (hOs, sizeof(WHAL_WEP));
  53. if (pWhalWep == NULL)
  54. return NULL;
  55. os_memoryZero (hOs, (void *)pWhalWep, sizeof(WHAL_WEP));
  56. pWhalWep->pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  57. pWhalWep->hOs = hOs;
  58. return((TI_HANDLE)pWhalWep);
  59. }
  60. /*
  61. * ----------------------------------------------------------------------------
  62. * Function : whalWep_Config
  63. *
  64. * Input :
  65. * Output :
  66. * Process :
  67. * Note(s) :
  68. * -----------------------------------------------------------------------------
  69. */
  70. int whalWep_Config (TI_HANDLE hWhalWep, whalWep_config_t* pWhalWepCfg)
  71. {
  72. WHAL_WEP* pWhalWep = (WHAL_WEP *)hWhalWep;
  73. pWhalWep->hMemMgr = pWhalWepCfg->hMemMgr;
  74. pWhalWep->hReport = pWhalWepCfg->hReport;
  75. /* YV - need to move here, the settings of ACXWEPOptions IE configuration!!*/
  76. /* which set the number of keys for which to reseve space in the WEP cache*/
  77. return (OK);
  78. }
  79. /*
  80. * ----------------------------------------------------------------------------
  81. * Function : whalWep_KeyAdd
  82. *
  83. * Input :
  84. * Output :
  85. * Process :
  86. * Note(s) :
  87. * -----------------------------------------------------------------------------
  88. */
  89. int whalWep_KeyAdd (TI_HANDLE hWhalWep, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle)
  90. {
  91. WHAL_WEP* pWhalWep = (WHAL_WEP *)hWhalWep;
  92. /* Non WEP keys are trashed*/
  93. if (pKey->keyType != WEP_KEY)
  94. return (NOK);
  95. /* Check for mapping key or default key */
  96. if ( MAC_NULL(&pKey->macAddress) )
  97. {
  98. /* Configure the encKeys to the HW - default keys cache*/
  99. return (whal_hwCtrl_WepDefaultKeyAdd (pWhalWep->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
  100. }
  101. else /* Use key mapping */
  102. {
  103. return (whal_hwCtrl_WepMappingKeyAdd (pWhalWep->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
  104. }
  105. }
  106. /*
  107. * ----------------------------------------------------------------------------
  108. * Function : whalWep_KeyRemove
  109. *
  110. * Input :
  111. * Output :
  112. * Process :
  113. * Note(s) :
  114. * -----------------------------------------------------------------------------
  115. */
  116. int whalWep_KeyRemove (TI_HANDLE hWhalWep, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle)
  117. {
  118. WHAL_WEP* pWhalWep = (WHAL_WEP *)hWhalWep;
  119. /* Non WEP keys are trashed*/
  120. if (pKey->keyType != WEP_KEY)
  121. return (NOK);
  122. /* Check for mapping key or default key */
  123. if ( MAC_NULL(&pKey->macAddress) )
  124. {
  125. return (whal_hwCtrl_WepDefaultKeyRemove (pWhalWep->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
  126. }
  127. else
  128. {
  129. return (whal_hwCtrl_WepMappingKeyRemove (pWhalWep->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
  130. }
  131. }
  132. /*
  133. * ----------------------------------------------------------------------------
  134. * Function : whalWep_DefaultKeyIdSet
  135. *
  136. * Input :
  137. * Output :
  138. * Process :
  139. * Note(s) :
  140. * -----------------------------------------------------------------------------
  141. */
  142. int whalWep_DefaultKeyIdSet (TI_HANDLE hWhalWep, UINT8 aKeyId, void *CB_Func, TI_HANDLE CB_handle)
  143. {
  144. WHAL_WEP *pWhalWep = (WHAL_WEP *)hWhalWep;
  145. /* Configure the default key id to the HW*/
  146. return (whal_hwCtrl_DefaultKeyIdSet (pWhalWep->pWhalCtrl->pHwCtrl, aKeyId, CB_Func, CB_handle));
  147. }
  148. /*
  149. * ----------------------------------------------------------------------------
  150. * Function : whalWep_Destroy
  151. *
  152. * Input :
  153. * Output :
  154. * Process :
  155. * Note(s) :
  156. * -----------------------------------------------------------------------------
  157. */
  158. int whalWep_Destroy (TI_HANDLE hWhalWep)
  159. {
  160. WHAL_WEP *pWhalWep = (WHAL_WEP *)hWhalWep;
  161. if (pWhalWep)
  162. os_memoryFree (pWhalWep->hOs, pWhalWep, sizeof(WHAL_WEP));
  163. return (OK);
  164. }