Home | History | Annotate | Download | only in rsn
      1 /** \file admCtrlWep.c
      2  *  \brief Admission control API implimentation
      3  *
      4  *  \see admCtrl.h
      5  */
      6 /****************************************************************************
      7 **+-----------------------------------------------------------------------+**
      8 **|                                                                       |**
      9 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
     10 **| All rights reserved.                                                  |**
     11 **|                                                                       |**
     12 **| Redistribution and use in source and binary forms, with or without    |**
     13 **| modification, are permitted provided that the following conditions    |**
     14 **| are met:                                                              |**
     15 **|                                                                       |**
     16 **|  * Redistributions of source code must retain the above copyright     |**
     17 **|    notice, this list of conditions and the following disclaimer.      |**
     18 **|  * Redistributions in binary form must reproduce the above copyright  |**
     19 **|    notice, this list of conditions and the following disclaimer in    |**
     20 **|    the documentation and/or other materials provided with the         |**
     21 **|    distribution.                                                      |**
     22 **|  * Neither the name Texas Instruments nor the names of its            |**
     23 **|    contributors may be used to endorse or promote products derived    |**
     24 **|    from this software without specific prior written permission.      |**
     25 **|                                                                       |**
     26 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
     27 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
     28 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
     29 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
     30 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
     31 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
     32 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
     33 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
     34 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
     35 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
     36 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
     37 **|                                                                       |**
     38 **+-----------------------------------------------------------------------+**
     39 ****************************************************************************/
     40 
     41 /****************************************************************************
     42  *                                                                          *
     43  *   MODULE:  Admission Control	    		                                *
     44  *   PURPOSE: Admission Control Module API                              	*
     45  *                                                                          *
     46  ****************************************************************************/
     47 
     48 #include "osApi.h"
     49 
     50 #include "paramOut.h"
     51 #include "paramIn.h"
     52 
     53 #include "utils.h"
     54 #include "fsm.h"
     55 #include "report.h"
     56 #include "mlmeApi.h"
     57 #include "DataCtrl_Api.h"
     58 
     59 #include "rsnApi.h"
     60 #include "admCtrl.h"
     61 
     62 #include "rsn.h"
     63 #include "admCtrl.h"
     64 #ifdef EXC_MODULE_INCLUDED
     65 #include "admCtrlWpa.h"
     66 #include "admCtrlExc.h"
     67 #endif
     68 
     69 
     70 /* Constants */
     71 
     72 /* Enumerations */
     73 
     74 /* Typedefs */
     75 
     76 /* Structures */
     77 
     78 /* External data definitions */
     79 
     80 /* Local functions definitions */
     81 
     82 /* Global variables */
     83 
     84 /* Function prototypes */
     85 TI_STATUS admCtrlWep_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength);
     86 
     87 TI_STATUS admCtrlWep_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen);
     88 
     89 TI_STATUS admCtrlWep_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation);
     90 
     91 
     92 /**
     93 *
     94 * admCtrlWep_config  - Configure EXC admission control.
     95 *
     96 * \b Description:
     97 *
     98 * Configure EXC admission control.
     99 *
    100 * \b ARGS:
    101 *
    102 *  I   - pAdmCtrl - context \n
    103 *
    104 * \b RETURNS:
    105 *
    106 *  OK on success, NOK on failure.
    107 *
    108 * \sa
    109 */
    110 TI_STATUS admCtrlWep_config(admCtrl_t *pAdmCtrl)
    111 {
    112 	TI_STATUS			status;
    113 	rsn_paeConfig_t 	paeConfig;
    114 
    115 
    116 	/* set admission control parameters */
    117 	pAdmCtrl->externalAuthMode = (externalAuthMode_e)pAdmCtrl->authSuite;
    118 	if ((pAdmCtrl->unicastSuite != RSN_CIPHER_WEP) &&
    119 		(pAdmCtrl->unicastSuite != RSN_CIPHER_CKIP))
    120 	{
    121 		pAdmCtrl->unicastSuite = RSN_CIPHER_WEP;
    122 	}
    123 
    124 	if ((pAdmCtrl->broadcastSuite != RSN_CIPHER_WEP) &&
    125 		(pAdmCtrl->broadcastSuite != RSN_CIPHER_CKIP))
    126 	{
    127 		pAdmCtrl->broadcastSuite = RSN_CIPHER_WEP;
    128 	}
    129 
    130 	/* set callback functions (API) */
    131 	pAdmCtrl->getInfoElement = admCtrlWep_getInfoElement;
    132 	pAdmCtrl->setSite = admCtrlWep_setSite;
    133 	pAdmCtrl->evalSite = admCtrlWep_evalSite;
    134 	pAdmCtrl->getPreAuthStatus = admCtrl_nullGetPreAuthStatus;
    135 	pAdmCtrl->startPreAuth	= admCtrl_nullStartPreAuth;
    136     pAdmCtrl->get802_1x_AkmExists = admCtrl_nullGet802_1x_AkmExists;
    137 
    138 
    139 
    140 	pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
    141 
    142 	/* set PAE parametrs */
    143 	paeConfig.authProtocol = pAdmCtrl->externalAuthMode;
    144 	paeConfig.unicastSuite = pAdmCtrl->unicastSuite;
    145 	paeConfig.broadcastSuite = pAdmCtrl->broadcastSuite;
    146 	paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
    147 	/* set default PAE configuration */
    148 	status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, &paeConfig);
    149 
    150 	return status;
    151 }
    152 
    153 
    154 /**
    155 *
    156 * admCtrlWep_getInfoElement - Build the current information element.
    157 *
    158 * \b Description:
    159 *
    160 * Build the current information element.
    161 *
    162 * \b ARGS:
    163 *
    164 *  I   - pAdmCtrl - context \n
    165 *  I   - pIe - IE buffer \n
    166 *  I   - pLength - length of IE \n
    167 *
    168 * \b RETURNS:
    169 *
    170 *  OK on success, NOK on failure.
    171 *
    172 * \sa
    173 */
    174 TI_STATUS admCtrlWep_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength)
    175 {
    176 
    177 	if ((pAdmCtrl==NULL) || (pLength==NULL))
    178 	{
    179 		return NOK;
    180 	}
    181 	*pLength = 0;
    182 	return OK;
    183 
    184 }
    185 /**
    186 *
    187 * admCtrlWep_setSite  - Set current primary site parameters for registration.
    188 *
    189 * \b Description:
    190 *
    191 * Set current primary site parameters for registration.
    192 *
    193 * \b ARGS:
    194 *
    195 *  I   - pAdmCtrl - context \n
    196 *  I   - pRsnData - site's RSN data \n
    197 *  O   - pAssocIe - result IE of evaluation \n
    198 *  O   - pAssocIeLen - length of result IE of evaluation \n
    199 *
    200 * \b RETURNS:
    201 *
    202 *  OK on site is aproved, NOK on site is rejected.
    203 *
    204 * \sa
    205 */
    206 TI_STATUS admCtrlWep_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen)
    207 {
    208 	TI_STATUS			status;
    209 	paramInfo_t			param;
    210     whalParamInfo_t     whalParam;
    211 	authSuite_e			authSuite;
    212 
    213 #ifdef EXC_MODULE_INCLUDED
    214 	if (parseIeBuffer(pAdmCtrl->hOs, pRsnData->pIe, pRsnData->ieLen, EXC_EXT_1_IE_ID, NULL, NULL, 0))
    215 	{
    216 		pAdmCtrl->excSupport = TRUE;
    217 		return (admCtrlExc_setSite(pAdmCtrl, pRsnData, pAssocIe, pAssocIeLen));
    218 	}
    219 #endif
    220 
    221 
    222 	pAdmCtrl->excSupport = FALSE;
    223 	pAdmCtrl->unicastSuite = RSN_CIPHER_WEP;
    224 	pAdmCtrl->broadcastSuite = RSN_CIPHER_WEP;
    225 
    226 	admCtrlWep_config(pAdmCtrl);
    227 
    228 	authSuite = pAdmCtrl->authSuite;
    229 
    230   /* Config the default keys */
    231 	if ((authSuite == RSN_AUTH_SHARED_KEY) || (authSuite == RSN_AUTH_AUTO_SWITCH))
    232 	{	/* Configure Security status in HAL */
    233 		whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
    234 		whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)RSN_CIPHER_WEP;
    235 		status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
    236 		/* Configure the keys in HAL */
    237 		rsn_setDefaultKeys(pAdmCtrl->pRsn);
    238 	}
    239 
    240 
    241 	/* Now we configure the MLME module with the 802.11 legacy authentication suite,
    242 		THe MLME will configure later the authentication module */
    243 	param.paramType = MLME_LEGACY_TYPE_PARAM;
    244 #ifdef EXC_MODULE_INCLUDED
    245 	if (pAdmCtrl->networkEapMode!=OS_EXC_NETWORK_EAP_OFF)
    246     {
    247         param.content.mlmeLegacyAuthType = AUTH_LEGACY_RESERVED1;
    248     }
    249     else
    250 #endif
    251     {
    252         switch (authSuite)
    253         {
    254         case RSN_AUTH_OPEN:
    255             param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
    256             break;
    257 
    258         case RSN_AUTH_SHARED_KEY:
    259             param.content.mlmeLegacyAuthType = AUTH_LEGACY_SHARED_KEY;
    260             break;
    261 
    262         case RSN_AUTH_AUTO_SWITCH:
    263             param.content.mlmeLegacyAuthType = AUTH_LEGACY_AUTO_SWITCH;
    264             WLAN_REPORT_INFORMATION(pAdmCtrl->hReport , RSN_MODULE_LOG,
    265                           ("WEP admCtrl mlme_setParam, RSN_AUTH_AUTO_SWITCH\n"));
    266             break;
    267 
    268         default:
    269             return NOK;
    270         }
    271     }
    272 
    273 	status = mlme_setParam(pAdmCtrl->hMlme, &param);
    274 	if (status != OK)
    275 	{
    276 		return status;
    277 	}
    278 
    279 	param.paramType = RX_DATA_EAPOL_DESTINATION_PARAM;
    280 	param.content.rxDataEapolDestination = OS_ABS_LAYER;
    281 	status = rxData_setParam(pAdmCtrl->hRx, &param);
    282 	if (status != OK)
    283 	{
    284 		return status;
    285 	}
    286 
    287 	/* Configure Security status in HAL */
    288     whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
    289     whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)RSN_CIPHER_WEP;
    290     status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
    291 
    292 	return status;
    293 
    294 }
    295 
    296 /**
    297 *
    298 * admCtrlWep_evalSite  - Evaluate site for registration.
    299 *
    300 * \b Description:
    301 *
    302 * evaluate site RSN capabilities against the station's cap.
    303 * If the BSS type is infrastructure, the station matches the site only if it's WEP status is same as the site
    304 * In IBSS, it does not matter
    305 *
    306 * \b ARGS:
    307 *
    308 *  I   - pAdmCtrl - Context \n
    309 *  I   - pRsnData - site's RSN data \n
    310 *  O   - pEvaluation - Result of evaluation \n
    311 *
    312 * \b RETURNS:
    313 *
    314 *  OK
    315 *
    316 * \sa
    317 */
    318 TI_STATUS admCtrlWep_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation)
    319 {
    320 
    321 	*pEvaluation = 0;
    322 
    323 	if (pRsnData==NULL)
    324 	{
    325 		return NOK;
    326 	}
    327     pAdmCtrl->setSiteFirst = FALSE;
    328 
    329 #ifdef EXC_MODULE_INCLUDED
    330 	if (admCtrlExc_evalSite(pAdmCtrl, pRsnData, bssType, pEvaluation, &pAdmCtrl->excSupport) != OK)
    331     {
    332         return NOK;
    333     }
    334 #else
    335 	pAdmCtrl->excSupport = FALSE;
    336 #endif /*EXC_MODULE_INCLUDED*/
    337 	if (!pAdmCtrl->excSupport)
    338 	{	/* WEP only */
    339 		*pEvaluation = 1;
    340 	}
    341 
    342 	/* Check privacy bit if not in mixed mode */
    343 	if (!pAdmCtrl->mixedMode)
    344 	{	/* There's no mixed mode, so make sure that the privacy Bit matches the privacy mode*/
    345 		if (!pRsnData->privacy)
    346 			{
    347 				*pEvaluation = 0;
    348                 return NOK;
    349 			}
    350 	}
    351 
    352 	return OK;
    353 }
    354 
    355 
    356 
    357 
    358