blob: 73cc42e2e1aa5689d1c3e847fdcf581104ff1854 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*
43 *
44 * Airgo Networks, Inc proprietary. All rights reserved.
45 * This file limSmeReqUtils.cc contains the utility functions
46 * for processing SME request messages.
47 * Author: Chandra Modumudi
48 * Date: 02/11/02
49 * History:-
50 * Date Modified by Modification Information
51 * --------------------------------------------------------------------
52 * 05/26/10 js WPA handling in (Re)Assoc frames
Jeff Johnson3c3e1782013-02-27 10:48:42 -080053 *
Jeff Johnson295189b2012-06-20 16:38:30 -070054 */
55
56#include "wniApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "cfgApi.h"
59#include "sirApi.h"
60#include "schApi.h"
61#include "utilsApi.h"
62#include "limTypes.h"
63#include "limUtils.h"
64#include "limAssocUtils.h"
65#include "limSecurityUtils.h"
66#include "limSerDesUtils.h"
67
68
69
70/**
71 * limIsRSNieValidInSmeReqMessage()
72 *
73 *FUNCTION:
74 * This function is called to verify if the RSN IE
75 * received in various SME_REQ messages is valid or not
76 *
77 *LOGIC:
78 * RSN IE validity checks are performed in this function
79 *
80 *ASSUMPTIONS:
81 *
82 *NOTE:
83 *
84 * @param pMac Pointer to Global MAC structure
85 * @param pRSNie Pointer to received RSN IE
86 * @return true when RSN IE is valid, false otherwise
87 */
88
89static tANI_U8
90limIsRSNieValidInSmeReqMessage(tpAniSirGlobal pMac, tpSirRSNie pRSNie)
91{
92 tANI_U8 startPos = 0;
93 tANI_U32 privacy, val;
94 int len;
95
96 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
97 &privacy) != eSIR_SUCCESS)
98 {
99 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700100 FL("Unable to retrieve POI from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700101 }
102
103 if (wlan_cfgGetInt(pMac, WNI_CFG_RSN_ENABLED,
104 &val) != eSIR_SUCCESS)
105 {
106 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700107 FL("Unable to retrieve RSN_ENABLED from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700108 }
109
110 if (pRSNie->length && (!privacy || !val))
111 {
112 // Privacy & RSN not enabled in CFG.
113 /**
114 * In order to allow mixed mode for Guest access
115 * allow BSS creation/join with no Privacy capability
116 * yet advertising WPA IE
117 */
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700118 PELOG1(limLog(pMac, LOG1, FL("RSN ie len %d but PRIVACY %d RSN %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700119 pRSNie->length, privacy, val);)
120 }
121
122 if (pRSNie->length)
123 {
124 if ((pRSNie->rsnIEdata[0] != DOT11F_EID_RSN) &&
125 (pRSNie->rsnIEdata[0] != DOT11F_EID_WPA)
126#ifdef FEATURE_WLAN_WAPI
127 && (pRSNie->rsnIEdata[0] != DOT11F_EID_WAPI)
128#endif
129 )
130 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700131 limLog(pMac, LOGE, FL("RSN/WPA/WAPI EID %d not [%d || %d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 pRSNie->rsnIEdata[0], DOT11F_EID_RSN,
133 DOT11F_EID_WPA);
134 return false;
135 }
136
137 len = pRSNie->length;
138 startPos = 0;
139 while(len > 0)
140 {
141 // Check validity of RSN IE
142 if (pRSNie->rsnIEdata[startPos] == DOT11F_EID_RSN)
143 {
144 if((pRSNie->rsnIEdata[startPos+1] > DOT11F_IE_RSN_MAX_LEN) ||
145 (pRSNie->rsnIEdata[startPos+1] < DOT11F_IE_RSN_MIN_LEN))
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700146 {
147 limLog(pMac, LOGE, FL("RSN IE len %d not [%d,%d]"),
148 pRSNie->rsnIEdata[startPos+1], DOT11F_IE_RSN_MIN_LEN,
149 DOT11F_IE_RSN_MAX_LEN);
150 return false;
151 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 }
153 else if(pRSNie->rsnIEdata[startPos] == DOT11F_EID_WPA)
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 {
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700155 // Check validity of WPA IE
156 if (SIR_MAC_MAX_IE_LENGTH > startPos)
157 {
158 val = sirReadU32((tANI_U8 *) &pRSNie->rsnIEdata[startPos + 2]);
159 if((pRSNie->rsnIEdata[startPos + 1] < DOT11F_IE_WPA_MIN_LEN) ||
160 (pRSNie->rsnIEdata[startPos + 1] > DOT11F_IE_WPA_MAX_LEN) ||
161 (SIR_MAC_WPA_OUI != val))
162 {
163 limLog(pMac, LOGE,
164 FL("WPA IE len %d not [%d,%d] OR data 0x%x not 0x%x"),
165 pRSNie->rsnIEdata[startPos+1], DOT11F_IE_WPA_MIN_LEN,
166 DOT11F_IE_WPA_MAX_LEN, val, SIR_MAC_WPA_OUI);
Jeff Johnson295189b2012-06-20 16:38:30 -0700167
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700168 return false;
169 }
170 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700172#ifdef FEATURE_WLAN_WAPI
173 else if(pRSNie->rsnIEdata[startPos] == DOT11F_EID_WAPI)
174 {
175 if((pRSNie->rsnIEdata[startPos+1] > DOT11F_IE_WAPI_MAX_LEN) ||
176 (pRSNie->rsnIEdata[startPos+1] < DOT11F_IE_WAPI_MIN_LEN))
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700177 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700179 FL("WAPI IE len %d not [%d,%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 pRSNie->rsnIEdata[startPos+1], DOT11F_IE_WAPI_MIN_LEN,
181 DOT11F_IE_WAPI_MAX_LEN);
182
183 return false;
184 }
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700185 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700186#endif
187 else
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700188 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 //we will never be here, simply for completeness
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700190 return false;
191 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 startPos += 2 + pRSNie->rsnIEdata[startPos+1]; //EID + length field + length
193 len -= startPos;
194 }//while
195
196 }
197
198 return true;
199} /*** end limIsRSNieValidInSmeReqMessage() ***/
200
201/**
202 * limIsAddieValidInSmeReqMessage()
203 *
204 *FUNCTION:
205 * This function is called to verify if the Add IE
206 * received in various SME_REQ messages is valid or not
207 *
208 *LOGIC:
209 * Add IE validity checks are performed on only length
210 *
211 *ASSUMPTIONS:
212 *
213 *NOTE:
214 *
215 * @param pMac Pointer to Global MAC structure
216 * @param pWSCie Pointer to received WSC IE
217 * @return true when WSC IE is valid, false otherwise
218 */
219
220static tANI_U8
221limIsAddieValidInSmeReqMessage(tpAniSirGlobal pMac, tpSirAddie pAddie)
222{
223 int left = pAddie->length;
224 tANI_U8 *ptr = pAddie->addIEdata;
225 tANI_U8 elem_id, elem_len;
226
227 if (left == 0)
228 return true;
229
230 while(left >= 2)
231 {
232 elem_id = ptr[0];
233 elem_len = ptr[1];
234 left -= 2;
235 if(elem_len > left)
236 {
237 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700238 FL("****Invalid Add IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 elem_id,elem_len,left);
240 return false;
241 }
242
243 left -= elem_len;
244 ptr += (elem_len + 2);
245 }
246 // there shouldn't be any left byte
247
248
249 return true;
250} /*** end limIsAddieValidInSmeReqMessage() ***/
251
Jeff Johnson295189b2012-06-20 16:38:30 -0700252/**
253 * limSetRSNieWPAiefromSmeStartBSSReqMessage()
254 *
255 *FUNCTION:
256 * This function is called to verify if the RSN IE
257 * received in various SME_REQ messages is valid or not
258 *
259 *LOGIC:
260 * RSN IE validity checks are performed in this function
261 *
262 *ASSUMPTIONS:
263 *
264 *NOTE:
265 *
266 * @param pMac Pointer to Global MAC structure
267 * @param pRSNie Pointer to received RSN IE
268 * @return true when RSN IE is valid, false otherwise
269 */
270
271tANI_U8
272limSetRSNieWPAiefromSmeStartBSSReqMessage(tpAniSirGlobal pMac,
273 tpSirRSNie pRSNie,
274 tpPESession pSessionEntry)
275{
276 tANI_U8 wpaIndex = 0;
277 tANI_U32 privacy, val;
278
279 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
280 &privacy) != eSIR_SUCCESS)
281 {
282 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700283 FL("Unable to retrieve POI from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 }
285
286 if (wlan_cfgGetInt(pMac, WNI_CFG_RSN_ENABLED,
287 &val) != eSIR_SUCCESS)
288 {
289 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700290 FL("Unable to retrieve RSN_ENABLED from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 }
292
293 if (pRSNie->length && (!privacy || !val))
294 {
295 // Privacy & RSN not enabled in CFG.
296 /**
297 * In order to allow mixed mode for Guest access
298 * allow BSS creation/join with no Privacy capability
299 * yet advertising WPA IE
300 */
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700301 PELOG1(limLog(pMac, LOG1, FL("RSN ie len %d but PRIVACY %d RSN %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 pRSNie->length, privacy, val);)
303 }
304
305 if (pRSNie->length)
306 {
307 if ((pRSNie->rsnIEdata[0] != SIR_MAC_RSN_EID) &&
308 (pRSNie->rsnIEdata[0] != SIR_MAC_WPA_EID))
309 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700310 limLog(pMac, LOGE, FL("RSN/WPA EID %d not [%d || %d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 pRSNie->rsnIEdata[0], SIR_MAC_RSN_EID,
312 SIR_MAC_WPA_EID);
313 return false;
314 }
315
316 // Check validity of RSN IE
317 if ((pRSNie->rsnIEdata[0] == SIR_MAC_RSN_EID) &&
318#if 0 // Comparison always false
319 (pRSNie->rsnIEdata[1] > SIR_MAC_RSN_IE_MAX_LENGTH) ||
320#endif
321 (pRSNie->rsnIEdata[1] < SIR_MAC_RSN_IE_MIN_LENGTH))
322 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700323 limLog(pMac, LOGE, FL("RSN IE len %d not [%d,%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 pRSNie->rsnIEdata[1], SIR_MAC_RSN_IE_MIN_LENGTH,
325 SIR_MAC_RSN_IE_MAX_LENGTH);
326 return false;
327 }
328
329 if (pRSNie->length > pRSNie->rsnIEdata[1] + 2)
330 {
331 if (pRSNie->rsnIEdata[0] != SIR_MAC_RSN_EID)
332 {
333 limLog(pMac,
334 LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700335 FL("First byte[%d] in rsnIEdata is not RSN_EID"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700336 pRSNie->rsnIEdata[1]);
337 return false;
338 }
339
340 limLog(pMac,
341 LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700342 FL("WPA IE is present along with WPA2 IE"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 wpaIndex = 2 + pRSNie->rsnIEdata[1];
344 }
345 else if ((pRSNie->length == pRSNie->rsnIEdata[1] + 2) &&
346 (pRSNie->rsnIEdata[0] == SIR_MAC_RSN_EID))
347 {
348 limLog(pMac,
349 LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700350 FL("Only RSN IE is present"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 dot11fUnpackIeRSN(pMac,&pRSNie->rsnIEdata[2],
352 (tANI_U8)pRSNie->length,&pSessionEntry->gStartBssRSNIe);
353 }
354 else if ((pRSNie->length == pRSNie->rsnIEdata[1] + 2) &&
355 (pRSNie->rsnIEdata[0] == SIR_MAC_WPA_EID))
356 {
357 limLog(pMac,
358 LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700359 FL("Only WPA IE is present"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700360
361 dot11fUnpackIeWPA(pMac,&pRSNie->rsnIEdata[6],(tANI_U8)pRSNie->length-4,
362 &pSessionEntry->gStartBssWPAIe);
363 }
364
365 // Check validity of WPA IE
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +0530366 if(wpaIndex +4 < SIR_MAC_MAX_IE_LENGTH )
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 {
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +0530368 val = sirReadU32((tANI_U8 *) &pRSNie->rsnIEdata[wpaIndex + 2]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700369
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +0530370 if ((pRSNie->rsnIEdata[wpaIndex] == SIR_MAC_WPA_EID) &&
371#if 0 // Comparison always false
372 (pRSNie->rsnIEdata[wpaIndex + 1] > SIR_MAC_WPA_IE_MAX_LENGTH) ||
373#endif
374 ((pRSNie->rsnIEdata[wpaIndex + 1] < SIR_MAC_WPA_IE_MIN_LENGTH) ||
375 (SIR_MAC_WPA_OUI != val)))
376 {
377 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700378 FL("WPA IE len %d not [%d,%d] OR data 0x%x not 0x%x"),
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +0530379 pRSNie->rsnIEdata[1], SIR_MAC_RSN_IE_MIN_LENGTH,
380 SIR_MAC_RSN_IE_MAX_LENGTH, val, SIR_MAC_WPA_OUI);
381
382 return false;
383 }
384 else
385 {
386 /* Both RSN and WPA IEs are present */
387 dot11fUnpackIeRSN(pMac,&pRSNie->rsnIEdata[2],
388 (tANI_U8)pRSNie->length,&pSessionEntry->gStartBssRSNIe);
389
390 dot11fUnpackIeWPA(pMac,&pRSNie->rsnIEdata[wpaIndex + 6],
391 pRSNie->rsnIEdata[wpaIndex + 1]-4,
392 &pSessionEntry->gStartBssWPAIe);
393
394 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 }
396 else
397 {
Gopichand Nakkalafa9e2982013-03-29 00:48:18 +0530398 return false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 }
400 }
401
402 return true;
403} /*** end limSetRSNieWPAiefromSmeStartBSSReqMessage() ***/
Jeff Johnson295189b2012-06-20 16:38:30 -0700404
Jeff Johnson295189b2012-06-20 16:38:30 -0700405
406
407
408/**
409 * limIsBssDescrValidInSmeReqMessage()
410 *
411 *FUNCTION:
412 * This function is called to verify if the BSS Descr
413 * received in various SME_REQ messages is valid or not
414 *
415 *LOGIC:
416 * BSS Descritipion validity checks are performed in this function
417 *
418 *ASSUMPTIONS:
419 *
420 *NOTE:
421 *
422 * @param pMac Pointer to Global MAC structure
423 * @param pBssDescr Pointer to received Bss Descritipion
424 * @return true when BSS description is valid, false otherwise
425 */
426
427static tANI_U8
428limIsBssDescrValidInSmeReqMessage(tpAniSirGlobal pMac,
429 tpSirBssDescription pBssDescr)
430{
431 tANI_U8 valid = true;
432
433 if (limIsAddrBC(pBssDescr->bssId) ||
434 !pBssDescr->channelId)
435 {
436 valid = false;
437 goto end;
438 }
439
440end:
441 return valid;
442} /*** end limIsBssDescrValidInSmeReqMessage() ***/
Jeff Johnson295189b2012-06-20 16:38:30 -0700443
444
445
446/**
447 * limIsSmeStartReqValid()
448 *
449 *FUNCTION:
450 * This function is called by limProcessSmeReqMessages() upon
451 * receiving SME_START_REQ message from application.
452 *
453 *LOGIC:
454 * Message validity checks are performed in this function
455 *
456 *ASSUMPTIONS:
457 *
458 *NOTE:
459 *
460 * @param pMsg - Pointer to received SME_START_BSS_REQ message
461 * @return true when received SME_START_REQ is formatted correctly
462 * false otherwise
463 */
464
465tANI_U8
466limIsSmeStartReqValid(tpAniSirGlobal pMac, tANI_U32 *pMsg)
467{
468 tANI_U8 valid = true;
469
470 if (((tpSirSmeStartReq) pMsg)->length != sizeof(tSirSmeStartReq))
471 {
472 /**
473 * Invalid length in START_REQ message
474 * Log error.
475 */
476 limLog(pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700477 FL("Invalid length %d in eWNI_SME_START_REQ"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 ((tpSirSmeStartReq) pMsg)->length);
479
480 valid = false;
481 goto end;
482 }
483
484end:
485 return valid;
486} /*** end limIsSmeStartReqValid() ***/
487
488
489
490/**
491 * limIsSmeStartBssReqValid()
492 *
493 *FUNCTION:
494 * This function is called by limProcessSmeReqMessages() upon
495 * receiving SME_START_BSS_REQ message from application.
496 *
497 *LOGIC:
498 * Message validity checks are performed in this function
499 *
500 *ASSUMPTIONS:
501 *
502 *NOTE:
503 *
504 * @param pMac Pointer to Global MAC structure
505 * @param pStartBssReq Pointer to received SME_START_BSS_REQ message
506 * @return true when received SME_START_BSS_REQ is formatted correctly
507 * false otherwise
508 */
509
510tANI_U8
511limIsSmeStartBssReqValid(tpAniSirGlobal pMac,
512 tpSirSmeStartBssReq pStartBssReq)
513{
514 tANI_U8 i = 0;
515 tANI_U8 valid = true;
516
517 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700518 FL("Parsed START_BSS_REQ fields are bssType=%d, channelId=%d, SSID len=%d, rsnIE len=%d, nwType=%d, rateset len=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 pStartBssReq->bssType,
520 pStartBssReq->channelId,
521 pStartBssReq->ssId.length,
522 pStartBssReq->rsnIE.length,
523 pStartBssReq->nwType,
524 pStartBssReq->operationalRateSet.numRates);)
525
526 switch (pStartBssReq->bssType)
527 {
528 case eSIR_INFRASTRUCTURE_MODE:
Jeff Johnson62c27982013-02-27 17:53:55 -0800529 /**
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 * Should not have received start BSS req with bssType
531 * Infrastructure on STA.
532 * Log error.
533 */
Jeff Johnson62c27982013-02-27 17:53:55 -0800534 limLog(pMac, LOGE,
535 FL("Invalid bssType %d in eWNI_SME_START_BSS_REQ"),
536 pStartBssReq->bssType);
537 valid = false;
538 goto end;
539 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700540
541 case eSIR_IBSS_MODE:
542 break;
543
544 /* Added for BT AMP support */
545 case eSIR_BTAMP_STA_MODE:
546 break;
547
548 /* Added for BT AMP support */
549 case eSIR_BTAMP_AP_MODE:
550 break;
551
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 /* Added for SoftAP support */
553 case eSIR_INFRA_AP_MODE:
554 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
556 default:
557 /**
558 * Should not have received start BSS req with bssType
559 * other than Infrastructure/IBSS.
560 * Log error
561 */
562 limLog(pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700563 FL("Invalid bssType %d in eWNI_SME_START_BSS_REQ"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 pStartBssReq->bssType);
565
566 valid = false;
567 goto end;
568 }
569
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 /* This below code is client specific code. TODO */
571 if (pStartBssReq->bssType == eSIR_IBSS_MODE)
572 {
573 if (!pStartBssReq->ssId.length ||
574 (pStartBssReq->ssId.length > SIR_MAC_MAX_SSID_LENGTH))
575 {
576 // Invalid length for SSID.
577 // Reject START_BSS_REQ
578 limLog(pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700579 FL("Invalid SSID length in eWNI_SME_START_BSS_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700580
581 valid = false;
582 goto end;
583 }
584 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700585
Jeff Johnson295189b2012-06-20 16:38:30 -0700586
587 if (!limIsRSNieValidInSmeReqMessage(pMac, &pStartBssReq->rsnIE))
588 {
589 valid = false;
590 goto end;
591 }
592
593 if (pStartBssReq->nwType != eSIR_11A_NW_TYPE &&
594 pStartBssReq->nwType != eSIR_11B_NW_TYPE &&
595 pStartBssReq->nwType != eSIR_11G_NW_TYPE)
596 {
597 valid = false;
598 goto end;
599 }
600
601 if (pStartBssReq->nwType == eSIR_11A_NW_TYPE)
602 {
603 for (i = 0; i < pStartBssReq->operationalRateSet.numRates; i++)
604 if (!sirIsArate(pStartBssReq->operationalRateSet.rate[i] & 0x7F))
605 {
606 // Invalid Operational rates
607 // Reject START_BSS_REQ
608 limLog(pMac, LOGW,
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700609 FL("Invalid operational rates in eWNI_SME_START_BSS_REQ"));
Mohit Khanna23863762012-09-11 17:40:09 -0700610 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 pStartBssReq->operationalRateSet.rate,
612 pStartBssReq->operationalRateSet.numRates);
613
614 valid = false;
615 goto end;
616 }
617 }
618 // check if all the rates in the operatioal rate set are legal 11G rates
619 else if (pStartBssReq->nwType == eSIR_11G_NW_TYPE)
620 {
621 for (i = 0; i < pStartBssReq->operationalRateSet.numRates; i++)
622 if (!sirIsGrate(pStartBssReq->operationalRateSet.rate[i] & 0x7F))
623 {
624 // Invalid Operational rates
625 // Reject START_BSS_REQ
626 limLog(pMac, LOGW,
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700627 FL("Invalid operational rates in eWNI_SME_START_BSS_REQ"));
Mohit Khanna23863762012-09-11 17:40:09 -0700628 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 pStartBssReq->operationalRateSet.rate,
630 pStartBssReq->operationalRateSet.numRates);
631
632 valid = false;
633 goto end;
634 }
635 }
Jeff Johnson62c27982013-02-27 17:53:55 -0800636 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 {
638 for (i = 0; i < pStartBssReq->operationalRateSet.numRates; i++)
639 if (!sirIsBrate(pStartBssReq->operationalRateSet.rate[i] & 0x7F))
640 {
641 // Invalid Operational rates
642 // Reject START_BSS_REQ
643 limLog(pMac, LOGW,
Gopichand Nakkalacc8cf8e2013-04-25 06:03:10 -0700644 FL("Invalid operational rates in eWNI_SME_START_BSS_REQ"));
Mohit Khanna23863762012-09-11 17:40:09 -0700645 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 pStartBssReq->operationalRateSet.rate,
647 pStartBssReq->operationalRateSet.numRates);
648
649 valid = false;
650 goto end;
651 }
652 }
653
654end:
655 return valid;
656} /*** end limIsSmeStartBssReqValid() ***/
657
658
659
660/**
661 * limIsSmeJoinReqValid()
662 *
663 *FUNCTION:
664 * This function is called by limProcessSmeReqMessages() upon
665 * receiving SME_JOIN_REQ message from application.
666 *
667 *LOGIC:
668 * Message validity checks are performed in this function
669 *
670 *ASSUMPTIONS:
671 *
672 *NOTE:
673 *
674 * @param pMac Pointer to Global MAC structure
675 * @param pJoinReq Pointer to received SME_JOIN_REQ message
676 * @return true when received SME_JOIN_REQ is formatted correctly
677 * false otherwise
678 */
679
680tANI_U8
681limIsSmeJoinReqValid(tpAniSirGlobal pMac, tpSirSmeJoinReq pJoinReq)
682{
683 tANI_U8 valid = true;
684
Jeff Johnson295189b2012-06-20 16:38:30 -0700685
686 if (!limIsRSNieValidInSmeReqMessage(pMac, &pJoinReq->rsnIE))
687 {
688 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700689 FL("received SME_JOIN_REQ with invalid RSNIE"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 valid = false;
691 goto end;
692 }
693
694 if (!limIsAddieValidInSmeReqMessage(pMac, &pJoinReq->addIEScan))
695 {
696 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700697 FL("received SME_JOIN_REQ with invalid additional IE for scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 valid = false;
699 goto end;
700 }
701
702 if (!limIsAddieValidInSmeReqMessage(pMac, &pJoinReq->addIEAssoc))
703 {
704 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700705 FL("received SME_JOIN_REQ with invalid additional IE for assoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 valid = false;
707 goto end;
708 }
709
710
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 if (!limIsBssDescrValidInSmeReqMessage(pMac,
712 &pJoinReq->bssDescription))
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 {
714 /// Received eWNI_SME_JOIN_REQ with invalid BSS Info
715 // Log the event
716 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700717 FL("received SME_JOIN_REQ with invalid bssInfo"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700718
719 valid = false;
720 goto end;
721 }
722
Jeff Johnsone7245742012-09-05 17:12:55 -0700723 /*
724 Reject Join Req if the Self Mac Address and
725 the Ap's Mac Address is same
726 */
727 if( palEqualMemory( pMac->hHdd, (tANI_U8* ) pJoinReq->selfMacAddr,
728 (tANI_U8 *) pJoinReq->bssDescription.bssId,
729 (tANI_U8) (sizeof(tSirMacAddr))))
730 {
731 // Log the event
732 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700733 FL("received SME_JOIN_REQ with Self Mac and BSSID Same"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700734
735 valid = false;
736 goto end;
737 }
738
Jeff Johnson295189b2012-06-20 16:38:30 -0700739end:
740 return valid;
741} /*** end limIsSmeJoinReqValid() ***/
742
743
744
745/**
746 * limIsSmeDisassocReqValid()
747 *
748 *FUNCTION:
749 * This function is called by limProcessSmeReqMessages() upon
750 * receiving SME_DISASSOC_REQ message from application.
751 *
752 *LOGIC:
753 * Message validity checks are performed in this function
754 *
755 *ASSUMPTIONS:
756 *
757 *NOTE:
758 *
759 * @param pMac Pointer to Global MAC structure
760 * @param pDisassocReq Pointer to received SME_DISASSOC_REQ message
761 * @return true When received SME_DISASSOC_REQ is formatted
762 * correctly
763 * false otherwise
764 */
765
766tANI_U8
767limIsSmeDisassocReqValid(tpAniSirGlobal pMac,
768 tpSirSmeDisassocReq pDisassocReq, tpPESession psessionEntry)
769{
770 if (limIsGroupAddr(pDisassocReq->peerMacAddr) &&
771 !limIsAddrBC(pDisassocReq->peerMacAddr))
772 return false;
773
Jeff Johnson295189b2012-06-20 16:38:30 -0700774
775 return true;
776} /*** end limIsSmeDisassocReqValid() ***/
777
778
779
780/**
781 * limIsSmeDisassocCnfValid()
782 *
783 *FUNCTION:
784 * This function is called by limProcessSmeReqMessages() upon
785 * receiving SME_DISASSOC_CNF message from application.
786 *
787 *LOGIC:
788 * Message validity checks are performed in this function
789 *
790 *ASSUMPTIONS:
791 *
792 *NOTE:
793 *
794 * @param pMac Pointer to Global MAC structure
795 * @param pDisassocCnf Pointer to received SME_DISASSOC_REQ message
796 * @return true When received SME_DISASSOC_CNF is formatted
797 * correctly
798 * false otherwise
799 */
800
801tANI_U8
802limIsSmeDisassocCnfValid(tpAniSirGlobal pMac,
803 tpSirSmeDisassocCnf pDisassocCnf, tpPESession psessionEntry)
804{
805 if (limIsGroupAddr(pDisassocCnf->peerMacAddr))
806 return false;
807
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 return true;
809} /*** end limIsSmeDisassocCnfValid() ***/
810
811
812
813/**
814 * limIsSmeDeauthReqValid()
815 *
816 *FUNCTION:
817 * This function is called by limProcessSmeReqMessages() upon
818 * receiving SME_DEAUTH_REQ message from application.
819 *
820 *LOGIC:
821 * Message validity checks are performed in this function
822 *
823 *ASSUMPTIONS:
824 *
825 *NOTE:
826 *
827 * @param pMac Pointer to Global MAC structure
828 * @param pDeauthReq Pointer to received SME_DEAUTH_REQ message
829 * @return true When received SME_DEAUTH_REQ is formatted correctly
830 * false otherwise
831 */
832
833tANI_U8
834limIsSmeDeauthReqValid(tpAniSirGlobal pMac, tpSirSmeDeauthReq pDeauthReq, tpPESession psessionEntry)
835{
836 if (limIsGroupAddr(pDeauthReq->peerMacAddr) &&
837 !limIsAddrBC(pDeauthReq->peerMacAddr))
838 return false;
839
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 return true;
841} /*** end limIsSmeDeauthReqValid() ***/
842
843
844
845/**
846 * limIsSmeScanReqValid()
847 *
848 *FUNCTION:
849 * This function is called by limProcessSmeReqMessages() upon
850 * receiving SME_SCAN_REQ message from application.
851 *
852 *LOGIC:
853 * Message validity checks are performed in this function
854 *
855 *ASSUMPTIONS:
856 *
857 *NOTE:
858 *
859 * @param pScanReq Pointer to received SME_SCAN_REQ message
860 * @return true when received SME_SCAN_REQ is formatted correctly
861 * false otherwise
862 */
863
864tANI_U8
865limIsSmeScanReqValid(tpAniSirGlobal pMac, tpSirSmeScanReq pScanReq)
866{
867 tANI_U8 valid = true;
868 tANI_U8 i = 0;
869
870 for (i = 0; i < pScanReq->numSsid; i++)
871 {
872 if (pScanReq->ssId[i].length > SIR_MAC_MAX_SSID_LENGTH)
873 {
874 valid = false;
875 goto end;
876 }
877 }
878 if ((pScanReq->bssType > eSIR_AUTO_MODE) ||
879 (limIsGroupAddr(pScanReq->bssId) && !limIsAddrBC(pScanReq->bssId)) ||
880 (!(pScanReq->scanType == eSIR_PASSIVE_SCAN || pScanReq->scanType == eSIR_ACTIVE_SCAN)) ||
881 (pScanReq->channelList.numChannels > SIR_MAX_NUM_CHANNELS))
882 {
883 valid = false;
884 goto end;
885 }
886
887 /*
888 ** check min/max channelTime range
889 **/
890
891 if ((pScanReq->scanType == eSIR_ACTIVE_SCAN) &&
892 (pScanReq->maxChannelTime < pScanReq->minChannelTime))
893 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700894 PELOGW(limLog(pMac, LOGW, FL("Max Channel Time < Min Channel Time"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 valid = false;
896 goto end;
897 }
898
899end:
900 return valid;
901} /*** end limIsSmeScanReqValid() ***/
902
903
904
905/**
906 * limIsSmeAuthReqValid()
907 *
908 *FUNCTION:
909 * This function is called by limProcessSmeReqMessages() upon
910 * receiving SME_AUTH_REQ message from application.
911 *
912 *LOGIC:
913 * Message validity checks are performed in this function
914 *
915 *ASSUMPTIONS:
916 *
917 *NOTE:
918 *
919 * @param pAuthReq Pointer to received SME_AUTH_REQ message
920 * @return true when received SME_AUTH_REQ is formatted correctly
921 * false otherwise
922 */
923
924tANI_U8
925limIsSmeAuthReqValid(tpSirSmeAuthReq pAuthReq)
926{
927 tANI_U8 valid = true;
928
929 if (limIsGroupAddr(pAuthReq->peerMacAddr) ||
930 (pAuthReq->authType > eSIR_AUTO_SWITCH) ||
931 !pAuthReq->channelNumber)
932 {
933 valid = false;
934 goto end;
935 }
936
937end:
938 return valid;
939} /*** end limIsSmeAuthReqValid() ***/
940
941
942
943/**
944 * limIsSmeSetContextReqValid()
945 *
946 *FUNCTION:
947 * This function is called by limProcessSmeReqMessages() upon
948 * receiving SME_SET_CONTEXT_REQ message from application.
949 *
950 *LOGIC:
951 * Message validity checks are performed in this function
952 *
953 *ASSUMPTIONS:
954 *
955 *NOTE:
956 *
957 * @param pMsg - Pointer to received SME_SET_CONTEXT_REQ message
958 * @return true when received SME_SET_CONTEXT_REQ is formatted correctly
959 * false otherwise
960 */
961
962tANI_U8
963limIsSmeSetContextReqValid(tpAniSirGlobal pMac, tpSirSmeSetContextReq pSetContextReq)
964{
965 tANI_U8 i = 0;
966 tANI_U8 valid = true;
967 tpSirKeys pKey = pSetContextReq->keyMaterial.key;
968
969 if ((pSetContextReq->keyMaterial.edType != eSIR_ED_WEP40) &&
970 (pSetContextReq->keyMaterial.edType != eSIR_ED_WEP104) &&
971 (pSetContextReq->keyMaterial.edType != eSIR_ED_NONE) &&
972#ifdef FEATURE_WLAN_WAPI
973 (pSetContextReq->keyMaterial.edType != eSIR_ED_WPI) &&
974#endif
975 !pSetContextReq->keyMaterial.numKeys)
976 {
977 /**
978 * No keys present in case of TKIP or CCMP
979 * Log error.
980 */
981 limLog(pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700982 FL("No keys present in SME_SETCONTEXT_REQ for edType=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 pSetContextReq->keyMaterial.edType);
984
985 valid = false;
986 goto end;
987 }
988
989 if (pSetContextReq->keyMaterial.numKeys &&
990 (pSetContextReq->keyMaterial.edType == eSIR_ED_NONE))
991 {
992 /**
993 * Keys present in case of no ED policy
994 * Log error.
995 */
996 limLog(pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700997 FL("Keys present in SME_SETCONTEXT_REQ for edType=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 pSetContextReq->keyMaterial.edType);
999
1000 valid = false;
1001 goto end;
1002 }
1003
1004 if (pSetContextReq->keyMaterial.edType >= eSIR_ED_NOT_IMPLEMENTED)
1005 {
1006 /**
1007 * Invalid edType in the message
1008 * Log error.
1009 */
1010 limLog(pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001011 FL("Invalid edType=%d in SME_SETCONTEXT_REQ"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 pSetContextReq->keyMaterial.edType);
1013
1014 valid = false;
1015 goto end;
1016 }
1017 else if (pSetContextReq->keyMaterial.edType > eSIR_ED_NONE)
1018 {
1019 tANI_U32 poi;
1020
1021 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED,
1022 &poi) != eSIR_SUCCESS)
1023 {
1024 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001025 FL("Unable to retrieve POI from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 }
1027
1028 if (!poi)
1029 {
1030 /**
1031 * Privacy is not enabled
1032 * In order to allow mixed mode for Guest access
1033 * allow BSS creation/join with no Privacy capability
1034 * yet advertising WPA IE
1035 */
1036 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001037 FL("Privacy is not enabled, yet non-None EDtype=%d in SME_SETCONTEXT_REQ"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 pSetContextReq->keyMaterial.edType);)
1039 }
1040 }
1041
1042 for (i = 0; i < pSetContextReq->keyMaterial.numKeys; i++)
1043 {
1044 if (((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) &&
1045 (pKey->keyLength != 5)) ||
1046 ((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104) &&
1047 (pKey->keyLength != 13)) ||
1048 ((pSetContextReq->keyMaterial.edType == eSIR_ED_TKIP) &&
1049 (pKey->keyLength != 32)) ||
1050#ifdef FEATURE_WLAN_WAPI
1051 ((pSetContextReq->keyMaterial.edType == eSIR_ED_WPI) &&
1052 (pKey->keyLength != 32)) ||
1053#endif
1054 ((pSetContextReq->keyMaterial.edType == eSIR_ED_CCMP) &&
1055 (pKey->keyLength != 16)))
1056 {
1057 /**
1058 * Invalid key length for a given ED type
1059 * Log error.
1060 */
1061 limLog(pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001062 FL("Invalid keyLength =%d for edType=%d in SME_SETCONTEXT_REQ"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 pKey->keyLength, pSetContextReq->keyMaterial.edType);
1064
1065 valid = false;
1066 goto end;
1067 }
1068 pKey++;
1069 }
1070
1071end:
1072 return valid;
1073} /*** end limIsSmeSetContextReqValid() ***/
1074
1075
1076
1077/**
1078 * limIsSmeStopBssReqValid()
1079 *
1080 *FUNCTION:
1081 * This function is called by limProcessSmeReqMessages() upon
1082 * receiving SME_STOP_BSS_REQ message from application.
1083 *
1084 *LOGIC:
1085 * Message validity checks are performed in this function
1086 *
1087 *ASSUMPTIONS:
1088 *
1089 *NOTE:
1090 *
1091 * @param pMsg - Pointer to received SME_STOP_BSS_REQ message
1092 * @return true when received SME_STOP_BSS_REQ is formatted correctly
1093 * false otherwise
1094 */
1095
1096tANI_U8
1097limIsSmeStopBssReqValid(tANI_U32 *pMsg)
1098{
1099 tANI_U8 valid = true;
1100
1101 return valid;
1102} /*** end limIsSmeStopBssReqValid() ***/
1103
1104
1105/**
1106 * limGetBssIdFromSmeJoinReqMsg()
1107 *
1108 *FUNCTION:
1109 * This function is called in various places to get BSSID
1110 * from BSS description/Neighbor BSS Info in the SME_JOIN_REQ/
1111 * SME_REASSOC_REQ message.
1112 *
1113 *PARAMS:
1114 *
1115 *LOGIC:
1116 *
1117 *ASSUMPTIONS:
1118 * NA
1119 *
1120 *NOTE:
1121 * NA
1122 *
1123 * @param pBuf - Pointer to received SME_JOIN/SME_REASSOC_REQ
1124 * message
1125 * @return pBssId - Pointer to BSSID
1126 */
1127
1128tANI_U8*
1129limGetBssIdFromSmeJoinReqMsg(tANI_U8 *pBuf)
1130{
1131 if (!pBuf)
1132 return NULL;
1133
1134 pBuf += sizeof(tANI_U32); // skip message header
1135
Jeff Johnson295189b2012-06-20 16:38:30 -07001136
1137 pBuf += limGetU16(pBuf) + sizeof(tANI_U16); // skip RSN IE
1138
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 pBuf += sizeof(tANI_U16); // skip length of BSS description
Jeff Johnson295189b2012-06-20 16:38:30 -07001140
1141 return (pBuf);
1142} /*** end limGetBssIdFromSmeJoinReqMsg() ***/
1143
1144