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