1/*
2 * admCtrlWep.c
3 *
4 * Copyright(c) 1998 - 2009 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/** \file admCtrlWep.c
35 *  \brief Admission control API implimentation
36 *
37 *  \see admCtrl.h
38 */
39
40/****************************************************************************
41 *                                                                          *
42 *   MODULE:  Admission Control	    		                                *
43 *   PURPOSE: Admission Control Module API                              	*
44 *                                                                          *
45 ****************************************************************************/
46
47#define __FILE_ID__  FILE_ID_18
48#include "osApi.h"
49#include "paramOut.h"
50#include "fsm.h"
51#include "report.h"
52#include "mlmeApi.h"
53#include "DataCtrl_Api.h"
54#include "rsnApi.h"
55#include "admCtrl.h"
56#include "rsn.h"
57#include "admCtrl.h"
58#ifdef XCC_MODULE_INCLUDED
59#include "admCtrlWpa.h"
60#include "admCtrlXCC.h"
61#endif
62#include "TWDriver.h"
63
64
65/* Constants */
66
67/* Enumerations */
68
69/* Typedefs */
70
71/* Structures */
72
73/* External data definitions */
74
75/* Local functions definitions */
76
77/* Global variables */
78
79/* Function prototypes */
80TI_STATUS admCtrlWep_getInfoElement(admCtrl_t *pAdmCtrl, TI_UINT8 *pIe, TI_UINT32 *pLength);
81
82TI_STATUS admCtrlWep_setSite(admCtrl_t *pAdmCtrl, TRsnData *pRsnData, TI_UINT8 *pAssocIe, TI_UINT8 *pAssocIeLen);
83
84TI_STATUS admCtrlWep_evalSite(admCtrl_t *pAdmCtrl, TRsnData *pRsnData, TRsnSiteParams *pRsnSiteParams, TI_UINT32 *pEvaluation);
85
86
87/**
88*
89* admCtrlWep_config  - Configure XCC admission control.
90*
91* \b Description:
92*
93* Configure XCC admission control.
94*
95* \b ARGS:
96*
97*  I   - pAdmCtrl - context \n
98*
99* \b RETURNS:
100*
101*  TI_OK on success, TI_NOK on failure.
102*
103* \sa
104*/
105TI_STATUS admCtrlWep_config(admCtrl_t *pAdmCtrl)
106{
107	TI_STATUS			status;
108	TRsnPaeConfig   	paeConfig;
109
110
111	/* set admission control parameters */
112	pAdmCtrl->externalAuthMode = (EExternalAuthMode)pAdmCtrl->authSuite;
113	if ((pAdmCtrl->unicastSuite != TWD_CIPHER_WEP) &&
114		(pAdmCtrl->unicastSuite != TWD_CIPHER_CKIP))
115	{
116		pAdmCtrl->unicastSuite = TWD_CIPHER_WEP;
117	}
118
119	if ((pAdmCtrl->broadcastSuite != TWD_CIPHER_WEP) &&
120		(pAdmCtrl->broadcastSuite != TWD_CIPHER_CKIP))
121	{
122		pAdmCtrl->broadcastSuite = TWD_CIPHER_WEP;
123	}
124
125	/* set callback functions (API) */
126	pAdmCtrl->getInfoElement = admCtrlWep_getInfoElement;
127	pAdmCtrl->setSite = admCtrlWep_setSite;
128	pAdmCtrl->evalSite = admCtrlWep_evalSite;
129	pAdmCtrl->getPreAuthStatus = admCtrl_nullGetPreAuthStatus;
130	pAdmCtrl->startPreAuth	= admCtrl_nullStartPreAuth;
131    pAdmCtrl->get802_1x_AkmExists = admCtrl_nullGet802_1x_AkmExists;
132
133
134
135	pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
136
137	/* set PAE parametrs */
138	paeConfig.authProtocol = pAdmCtrl->externalAuthMode;
139	paeConfig.unicastSuite = pAdmCtrl->unicastSuite;
140	paeConfig.broadcastSuite = pAdmCtrl->broadcastSuite;
141	paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
142	/* set default PAE configuration */
143	status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, &paeConfig);
144
145	return status;
146}
147
148
149/**
150*
151* admCtrlWep_getInfoElement - Build the current information element.
152*
153* \b Description:
154*
155* Build the current information element.
156*
157* \b ARGS:
158*
159*  I   - pAdmCtrl - context \n
160*  I   - pIe - IE buffer \n
161*  I   - pLength - length of IE \n
162*
163* \b RETURNS:
164*
165*  TI_OK on success, TI_NOK on failure.
166*
167* \sa
168*/
169TI_STATUS admCtrlWep_getInfoElement(admCtrl_t *pAdmCtrl, TI_UINT8 *pIe, TI_UINT32 *pLength)
170{
171
172	if ((pAdmCtrl==NULL) || (pLength==NULL))
173	{
174		return TI_NOK;
175	}
176	*pLength = 0;
177	return TI_OK;
178
179}
180/**
181*
182* admCtrlWep_setSite  - Set current primary site parameters for registration.
183*
184* \b Description:
185*
186* Set current primary site parameters for registration.
187*
188* \b ARGS:
189*
190*  I   - pAdmCtrl - context \n
191*  I   - pRsnData - site's RSN data \n
192*  O   - pAssocIe - result IE of evaluation \n
193*  O   - pAssocIeLen - length of result IE of evaluation \n
194*
195* \b RETURNS:
196*
197*  TI_OK on site is aproved, TI_NOK on site is rejected.
198*
199* \sa
200*/
201TI_STATUS admCtrlWep_setSite(admCtrl_t *pAdmCtrl, TRsnData *pRsnData, TI_UINT8 *pAssocIe, TI_UINT8 *pAssocIeLen)
202{
203	TI_STATUS			status;
204	paramInfo_t			param;
205    TTwdParamInfo       tTwdParam;
206	EAuthSuite			authSuite;
207
208#ifdef XCC_MODULE_INCLUDED
209	if (mlmeParser_ParseIeBuffer (pAdmCtrl->hMlme, pRsnData->pIe, pRsnData->ieLen, XCC_EXT_1_IE_ID, NULL, NULL, 0))
210	{
211		pAdmCtrl->XCCSupport = TI_TRUE;
212		return (admCtrlXCC_setSite(pAdmCtrl, pRsnData, pAssocIe, pAssocIeLen));
213	}
214#endif
215
216
217	pAdmCtrl->XCCSupport = TI_FALSE;
218	pAdmCtrl->unicastSuite = TWD_CIPHER_WEP;
219	pAdmCtrl->broadcastSuite = TWD_CIPHER_WEP;
220
221	admCtrlWep_config(pAdmCtrl);
222
223	authSuite = pAdmCtrl->authSuite;
224
225  /* Config the default keys */
226	if ((authSuite == RSN_AUTH_SHARED_KEY) || (authSuite == RSN_AUTH_AUTO_SWITCH))
227	{	/* Configure Security status in HAL */
228		tTwdParam.paramType = TWD_RSN_SECURITY_MODE_PARAM_ID;
229		tTwdParam.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_WEP;
230		status = TWD_SetParam(pAdmCtrl->pRsn->hTWD, &tTwdParam);
231		/* Configure the keys in HAL */
232		rsn_setDefaultKeys(pAdmCtrl->pRsn);
233	}
234
235
236	/* Now we configure the MLME module with the 802.11 legacy authentication suite,
237		THe MLME will configure later the authentication module */
238	param.paramType = MLME_LEGACY_TYPE_PARAM;
239#ifdef XCC_MODULE_INCLUDED
240	if (pAdmCtrl->networkEapMode!=OS_XCC_NETWORK_EAP_OFF)
241    {
242        param.content.mlmeLegacyAuthType = AUTH_LEGACY_RESERVED1;
243    }
244    else
245#endif
246    {
247        switch (authSuite)
248        {
249        case RSN_AUTH_OPEN:
250            param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
251            break;
252
253        case RSN_AUTH_SHARED_KEY:
254            param.content.mlmeLegacyAuthType = AUTH_LEGACY_SHARED_KEY;
255            break;
256
257        case RSN_AUTH_AUTO_SWITCH:
258            param.content.mlmeLegacyAuthType = AUTH_LEGACY_AUTO_SWITCH;
259            TRACE0(pAdmCtrl->hReport , REPORT_SEVERITY_INFORMATION, "WEP admCtrl mlme_setParam, RSN_AUTH_AUTO_SWITCH\n");
260            break;
261
262        default:
263            return TI_NOK;
264        }
265    }
266
267	status = mlme_setParam(pAdmCtrl->hMlme, &param);
268	if (status != TI_OK)
269	{
270		return status;
271	}
272
273	param.paramType = RX_DATA_EAPOL_DESTINATION_PARAM;
274	param.content.rxDataEapolDestination = OS_ABS_LAYER;
275	status = rxData_setParam(pAdmCtrl->hRx, &param);
276	if (status != TI_OK)
277	{
278		return status;
279	}
280
281	/* Configure Security status in HAL */
282    tTwdParam.paramType = TWD_RSN_SECURITY_MODE_PARAM_ID;
283    tTwdParam.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_WEP;
284    status = TWD_SetParam(pAdmCtrl->pRsn->hTWD, &tTwdParam);
285
286	return status;
287
288}
289
290/**
291*
292* admCtrlWep_evalSite  - Evaluate site for registration.
293*
294* \b Description:
295*
296* evaluate site RSN capabilities against the station's cap.
297* If the BSS type is infrastructure, the station matches the site only if it's WEP status is same as the site
298* In IBSS, it does not matter
299*
300* \b ARGS:
301*
302*  I   - pAdmCtrl - Context \n
303*  I   - pRsnData - site's RSN data \n
304*  O   - pEvaluation - Result of evaluation \n
305*
306* \b RETURNS:
307*
308*  TI_OK
309*
310* \sa
311*/
312TI_STATUS admCtrlWep_evalSite(admCtrl_t *pAdmCtrl, TRsnData *pRsnData, TRsnSiteParams *pRsnSiteParams, TI_UINT32 *pEvaluation)
313{
314	*pEvaluation = 0;
315
316	if (pRsnData==NULL)
317	{
318		return TI_NOK;
319	}
320    pAdmCtrl->setSiteFirst = TI_FALSE;
321
322#ifdef XCC_MODULE_INCLUDED
323	if (admCtrlXCC_evalSite(pAdmCtrl, pRsnData, pRsnSiteParams, pEvaluation, &pAdmCtrl->XCCSupport) != TI_OK)
324    {
325        return TI_NOK;
326    }
327#else
328	pAdmCtrl->XCCSupport = TI_FALSE;
329#endif /*XCC_MODULE_INCLUDED*/
330	if (!pAdmCtrl->XCCSupport)
331	{	/* WEP only */
332		*pEvaluation = 1;
333	}
334
335	/* Check privacy bit if not in mixed mode */
336	if (!pAdmCtrl->mixedMode)
337	{	/* There's no mixed mode, so make sure that the privacy Bit matches the privacy mode*/
338		if (!pRsnData->privacy)
339			{
340				*pEvaluation = 0;
341                return TI_NOK;
342			}
343	}
344
345	return TI_OK;
346}
347
348
349
350
351