Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 2 | * 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 Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 22 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 23 | * |
| 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 Johnson | 3c3e178 | 2013-02-27 10:48:42 -0800 | [diff] [blame] | 53 | * |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 54 | */ |
| 55 | |
| 56 | #include "wniApi.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 57 | #include "wniCfgSta.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 58 | #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 | |
| 89 | static tANI_U8 |
| 90 | limIsRSNieValidInSmeReqMessage(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, |
| 100 | FL("Unable to retrieve POI from CFG\n")); |
| 101 | } |
| 102 | |
| 103 | if (wlan_cfgGetInt(pMac, WNI_CFG_RSN_ENABLED, |
| 104 | &val) != eSIR_SUCCESS) |
| 105 | { |
| 106 | limLog(pMac, LOGP, |
| 107 | FL("Unable to retrieve RSN_ENABLED from CFG\n")); |
| 108 | } |
| 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 | */ |
| 118 | PELOG1(limLog(pMac, LOG1, FL("RSN ie len %d but PRIVACY %d RSN %d\n"), |
| 119 | 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 | { |
| 131 | limLog(pMac, LOGE, FL("RSN/WPA/WAPI EID %d not [%d || %d]\n"), |
| 132 | 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)) |
| 146 | { |
| 147 | limLog(pMac, LOGE, FL("RSN IE len %d not [%d,%d]\n"), |
| 148 | pRSNie->rsnIEdata[startPos+1], DOT11F_IE_RSN_MIN_LEN, |
| 149 | DOT11F_IE_RSN_MAX_LEN); |
| 150 | return false; |
| 151 | } |
| 152 | } |
| 153 | else if(pRSNie->rsnIEdata[startPos] == DOT11F_EID_WPA) |
| 154 | { |
| 155 | // Check validity of WPA IE |
| 156 | val = sirReadU32((tANI_U8 *) &pRSNie->rsnIEdata[startPos + 2]); |
| 157 | if((pRSNie->rsnIEdata[startPos + 1] < DOT11F_IE_WPA_MIN_LEN) || |
| 158 | (pRSNie->rsnIEdata[startPos + 1] > DOT11F_IE_WPA_MAX_LEN) || |
| 159 | (SIR_MAC_WPA_OUI != val)) |
| 160 | { |
| 161 | limLog(pMac, LOGE, |
| 162 | FL("WPA IE len %d not [%d,%d] OR data 0x%x not 0x%x\n"), |
| 163 | pRSNie->rsnIEdata[startPos+1], DOT11F_IE_WPA_MIN_LEN, |
| 164 | DOT11F_IE_WPA_MAX_LEN, val, SIR_MAC_WPA_OUI); |
| 165 | |
| 166 | return false; |
| 167 | } |
| 168 | } |
| 169 | #ifdef FEATURE_WLAN_WAPI |
| 170 | else if(pRSNie->rsnIEdata[startPos] == DOT11F_EID_WAPI) |
| 171 | { |
| 172 | if((pRSNie->rsnIEdata[startPos+1] > DOT11F_IE_WAPI_MAX_LEN) || |
| 173 | (pRSNie->rsnIEdata[startPos+1] < DOT11F_IE_WAPI_MIN_LEN)) |
| 174 | { |
| 175 | limLog(pMac, LOGE, |
| 176 | FL("WAPI IE len %d not [%d,%d]\n"), |
| 177 | pRSNie->rsnIEdata[startPos+1], DOT11F_IE_WAPI_MIN_LEN, |
| 178 | DOT11F_IE_WAPI_MAX_LEN); |
| 179 | |
| 180 | return false; |
| 181 | } |
| 182 | } |
| 183 | #endif |
| 184 | else |
| 185 | { |
| 186 | //we will never be here, simply for completeness |
| 187 | return false; |
| 188 | } |
| 189 | startPos += 2 + pRSNie->rsnIEdata[startPos+1]; //EID + length field + length |
| 190 | len -= startPos; |
| 191 | }//while |
| 192 | |
| 193 | } |
| 194 | |
| 195 | return true; |
| 196 | } /*** end limIsRSNieValidInSmeReqMessage() ***/ |
| 197 | |
| 198 | /** |
| 199 | * limIsAddieValidInSmeReqMessage() |
| 200 | * |
| 201 | *FUNCTION: |
| 202 | * This function is called to verify if the Add IE |
| 203 | * received in various SME_REQ messages is valid or not |
| 204 | * |
| 205 | *LOGIC: |
| 206 | * Add IE validity checks are performed on only length |
| 207 | * |
| 208 | *ASSUMPTIONS: |
| 209 | * |
| 210 | *NOTE: |
| 211 | * |
| 212 | * @param pMac Pointer to Global MAC structure |
| 213 | * @param pWSCie Pointer to received WSC IE |
| 214 | * @return true when WSC IE is valid, false otherwise |
| 215 | */ |
| 216 | |
| 217 | static tANI_U8 |
| 218 | limIsAddieValidInSmeReqMessage(tpAniSirGlobal pMac, tpSirAddie pAddie) |
| 219 | { |
| 220 | int left = pAddie->length; |
| 221 | tANI_U8 *ptr = pAddie->addIEdata; |
| 222 | tANI_U8 elem_id, elem_len; |
| 223 | |
| 224 | if (left == 0) |
| 225 | return true; |
| 226 | |
| 227 | while(left >= 2) |
| 228 | { |
| 229 | elem_id = ptr[0]; |
| 230 | elem_len = ptr[1]; |
| 231 | left -= 2; |
| 232 | if(elem_len > left) |
| 233 | { |
| 234 | limLog( pMac, LOGE, |
| 235 | FL("****Invalid Add IEs eid = %d elem_len=%d left=%d*****\n"), |
| 236 | elem_id,elem_len,left); |
| 237 | return false; |
| 238 | } |
| 239 | |
| 240 | left -= elem_len; |
| 241 | ptr += (elem_len + 2); |
| 242 | } |
| 243 | // there shouldn't be any left byte |
| 244 | |
| 245 | |
| 246 | return true; |
| 247 | } /*** end limIsAddieValidInSmeReqMessage() ***/ |
| 248 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 249 | /** |
| 250 | * limSetRSNieWPAiefromSmeStartBSSReqMessage() |
| 251 | * |
| 252 | *FUNCTION: |
| 253 | * This function is called to verify if the RSN IE |
| 254 | * received in various SME_REQ messages is valid or not |
| 255 | * |
| 256 | *LOGIC: |
| 257 | * RSN IE validity checks are performed in this function |
| 258 | * |
| 259 | *ASSUMPTIONS: |
| 260 | * |
| 261 | *NOTE: |
| 262 | * |
| 263 | * @param pMac Pointer to Global MAC structure |
| 264 | * @param pRSNie Pointer to received RSN IE |
| 265 | * @return true when RSN IE is valid, false otherwise |
| 266 | */ |
| 267 | |
| 268 | tANI_U8 |
| 269 | limSetRSNieWPAiefromSmeStartBSSReqMessage(tpAniSirGlobal pMac, |
| 270 | tpSirRSNie pRSNie, |
| 271 | tpPESession pSessionEntry) |
| 272 | { |
| 273 | tANI_U8 wpaIndex = 0; |
| 274 | tANI_U32 privacy, val; |
| 275 | |
| 276 | if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, |
| 277 | &privacy) != eSIR_SUCCESS) |
| 278 | { |
| 279 | limLog(pMac, LOGP, |
| 280 | FL("Unable to retrieve POI from CFG\n")); |
| 281 | } |
| 282 | |
| 283 | if (wlan_cfgGetInt(pMac, WNI_CFG_RSN_ENABLED, |
| 284 | &val) != eSIR_SUCCESS) |
| 285 | { |
| 286 | limLog(pMac, LOGP, |
| 287 | FL("Unable to retrieve RSN_ENABLED from CFG\n")); |
| 288 | } |
| 289 | |
| 290 | if (pRSNie->length && (!privacy || !val)) |
| 291 | { |
| 292 | // Privacy & RSN not enabled in CFG. |
| 293 | /** |
| 294 | * In order to allow mixed mode for Guest access |
| 295 | * allow BSS creation/join with no Privacy capability |
| 296 | * yet advertising WPA IE |
| 297 | */ |
| 298 | PELOG1(limLog(pMac, LOG1, FL("RSN ie len %d but PRIVACY %d RSN %d\n"), |
| 299 | pRSNie->length, privacy, val);) |
| 300 | } |
| 301 | |
| 302 | if (pRSNie->length) |
| 303 | { |
| 304 | if ((pRSNie->rsnIEdata[0] != SIR_MAC_RSN_EID) && |
| 305 | (pRSNie->rsnIEdata[0] != SIR_MAC_WPA_EID)) |
| 306 | { |
| 307 | limLog(pMac, LOGE, FL("RSN/WPA EID %d not [%d || %d]\n"), |
| 308 | pRSNie->rsnIEdata[0], SIR_MAC_RSN_EID, |
| 309 | SIR_MAC_WPA_EID); |
| 310 | return false; |
| 311 | } |
| 312 | |
| 313 | // Check validity of RSN IE |
| 314 | if ((pRSNie->rsnIEdata[0] == SIR_MAC_RSN_EID) && |
| 315 | #if 0 // Comparison always false |
| 316 | (pRSNie->rsnIEdata[1] > SIR_MAC_RSN_IE_MAX_LENGTH) || |
| 317 | #endif |
| 318 | (pRSNie->rsnIEdata[1] < SIR_MAC_RSN_IE_MIN_LENGTH)) |
| 319 | { |
| 320 | limLog(pMac, LOGE, FL("RSN IE len %d not [%d,%d]\n"), |
| 321 | pRSNie->rsnIEdata[1], SIR_MAC_RSN_IE_MIN_LENGTH, |
| 322 | SIR_MAC_RSN_IE_MAX_LENGTH); |
| 323 | return false; |
| 324 | } |
| 325 | |
| 326 | if (pRSNie->length > pRSNie->rsnIEdata[1] + 2) |
| 327 | { |
| 328 | if (pRSNie->rsnIEdata[0] != SIR_MAC_RSN_EID) |
| 329 | { |
| 330 | limLog(pMac, |
| 331 | LOGE, |
| 332 | FL("First byte[%d] in rsnIEdata is not RSN_EID\n"), |
| 333 | pRSNie->rsnIEdata[1]); |
| 334 | return false; |
| 335 | } |
| 336 | |
| 337 | limLog(pMac, |
| 338 | LOG1, |
| 339 | FL("WPA IE is present along with WPA2 IE\n")); |
| 340 | wpaIndex = 2 + pRSNie->rsnIEdata[1]; |
| 341 | } |
| 342 | else if ((pRSNie->length == pRSNie->rsnIEdata[1] + 2) && |
| 343 | (pRSNie->rsnIEdata[0] == SIR_MAC_RSN_EID)) |
| 344 | { |
| 345 | limLog(pMac, |
| 346 | LOG1, |
| 347 | FL("Only RSN IE is present\n")); |
| 348 | dot11fUnpackIeRSN(pMac,&pRSNie->rsnIEdata[2], |
| 349 | (tANI_U8)pRSNie->length,&pSessionEntry->gStartBssRSNIe); |
| 350 | } |
| 351 | else if ((pRSNie->length == pRSNie->rsnIEdata[1] + 2) && |
| 352 | (pRSNie->rsnIEdata[0] == SIR_MAC_WPA_EID)) |
| 353 | { |
| 354 | limLog(pMac, |
| 355 | LOG1, |
| 356 | FL("Only WPA IE is present\n")); |
| 357 | |
| 358 | dot11fUnpackIeWPA(pMac,&pRSNie->rsnIEdata[6],(tANI_U8)pRSNie->length-4, |
| 359 | &pSessionEntry->gStartBssWPAIe); |
| 360 | } |
| 361 | |
| 362 | // Check validity of WPA IE |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 363 | if(wpaIndex +4 < SIR_MAC_MAX_IE_LENGTH ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 364 | { |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 365 | val = sirReadU32((tANI_U8 *) &pRSNie->rsnIEdata[wpaIndex + 2]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 366 | |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 367 | if ((pRSNie->rsnIEdata[wpaIndex] == SIR_MAC_WPA_EID) && |
| 368 | #if 0 // Comparison always false |
| 369 | (pRSNie->rsnIEdata[wpaIndex + 1] > SIR_MAC_WPA_IE_MAX_LENGTH) || |
| 370 | #endif |
| 371 | ((pRSNie->rsnIEdata[wpaIndex + 1] < SIR_MAC_WPA_IE_MIN_LENGTH) || |
| 372 | (SIR_MAC_WPA_OUI != val))) |
| 373 | { |
| 374 | limLog(pMac, LOGE, |
| 375 | FL("WPA IE len %d not [%d,%d] OR data 0x%x not 0x%x\n"), |
| 376 | pRSNie->rsnIEdata[1], SIR_MAC_RSN_IE_MIN_LENGTH, |
| 377 | SIR_MAC_RSN_IE_MAX_LENGTH, val, SIR_MAC_WPA_OUI); |
| 378 | |
| 379 | return false; |
| 380 | } |
| 381 | else |
| 382 | { |
| 383 | /* Both RSN and WPA IEs are present */ |
| 384 | dot11fUnpackIeRSN(pMac,&pRSNie->rsnIEdata[2], |
| 385 | (tANI_U8)pRSNie->length,&pSessionEntry->gStartBssRSNIe); |
| 386 | |
| 387 | dot11fUnpackIeWPA(pMac,&pRSNie->rsnIEdata[wpaIndex + 6], |
| 388 | pRSNie->rsnIEdata[wpaIndex + 1]-4, |
| 389 | &pSessionEntry->gStartBssWPAIe); |
| 390 | |
| 391 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 392 | } |
| 393 | else |
| 394 | { |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 395 | return false; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 396 | } |
| 397 | } |
| 398 | |
| 399 | return true; |
| 400 | } /*** end limSetRSNieWPAiefromSmeStartBSSReqMessage() ***/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 401 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 402 | |
| 403 | |
| 404 | |
| 405 | /** |
| 406 | * limIsBssDescrValidInSmeReqMessage() |
| 407 | * |
| 408 | *FUNCTION: |
| 409 | * This function is called to verify if the BSS Descr |
| 410 | * received in various SME_REQ messages is valid or not |
| 411 | * |
| 412 | *LOGIC: |
| 413 | * BSS Descritipion validity checks are performed in this function |
| 414 | * |
| 415 | *ASSUMPTIONS: |
| 416 | * |
| 417 | *NOTE: |
| 418 | * |
| 419 | * @param pMac Pointer to Global MAC structure |
| 420 | * @param pBssDescr Pointer to received Bss Descritipion |
| 421 | * @return true when BSS description is valid, false otherwise |
| 422 | */ |
| 423 | |
| 424 | static tANI_U8 |
| 425 | limIsBssDescrValidInSmeReqMessage(tpAniSirGlobal pMac, |
| 426 | tpSirBssDescription pBssDescr) |
| 427 | { |
| 428 | tANI_U8 valid = true; |
| 429 | |
| 430 | if (limIsAddrBC(pBssDescr->bssId) || |
| 431 | !pBssDescr->channelId) |
| 432 | { |
| 433 | valid = false; |
| 434 | goto end; |
| 435 | } |
| 436 | |
| 437 | end: |
| 438 | return valid; |
| 439 | } /*** end limIsBssDescrValidInSmeReqMessage() ***/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 440 | |
| 441 | |
| 442 | |
| 443 | /** |
| 444 | * limIsSmeStartReqValid() |
| 445 | * |
| 446 | *FUNCTION: |
| 447 | * This function is called by limProcessSmeReqMessages() upon |
| 448 | * receiving SME_START_REQ message from application. |
| 449 | * |
| 450 | *LOGIC: |
| 451 | * Message validity checks are performed in this function |
| 452 | * |
| 453 | *ASSUMPTIONS: |
| 454 | * |
| 455 | *NOTE: |
| 456 | * |
| 457 | * @param pMsg - Pointer to received SME_START_BSS_REQ message |
| 458 | * @return true when received SME_START_REQ is formatted correctly |
| 459 | * false otherwise |
| 460 | */ |
| 461 | |
| 462 | tANI_U8 |
| 463 | limIsSmeStartReqValid(tpAniSirGlobal pMac, tANI_U32 *pMsg) |
| 464 | { |
| 465 | tANI_U8 valid = true; |
| 466 | |
| 467 | if (((tpSirSmeStartReq) pMsg)->length != sizeof(tSirSmeStartReq)) |
| 468 | { |
| 469 | /** |
| 470 | * Invalid length in START_REQ message |
| 471 | * Log error. |
| 472 | */ |
| 473 | limLog(pMac, LOGW, |
| 474 | FL("Invalid length %d in eWNI_SME_START_REQ\n"), |
| 475 | ((tpSirSmeStartReq) pMsg)->length); |
| 476 | |
| 477 | valid = false; |
| 478 | goto end; |
| 479 | } |
| 480 | |
| 481 | end: |
| 482 | return valid; |
| 483 | } /*** end limIsSmeStartReqValid() ***/ |
| 484 | |
| 485 | |
| 486 | |
| 487 | /** |
| 488 | * limIsSmeStartBssReqValid() |
| 489 | * |
| 490 | *FUNCTION: |
| 491 | * This function is called by limProcessSmeReqMessages() upon |
| 492 | * receiving SME_START_BSS_REQ message from application. |
| 493 | * |
| 494 | *LOGIC: |
| 495 | * Message validity checks are performed in this function |
| 496 | * |
| 497 | *ASSUMPTIONS: |
| 498 | * |
| 499 | *NOTE: |
| 500 | * |
| 501 | * @param pMac Pointer to Global MAC structure |
| 502 | * @param pStartBssReq Pointer to received SME_START_BSS_REQ message |
| 503 | * @return true when received SME_START_BSS_REQ is formatted correctly |
| 504 | * false otherwise |
| 505 | */ |
| 506 | |
| 507 | tANI_U8 |
| 508 | limIsSmeStartBssReqValid(tpAniSirGlobal pMac, |
| 509 | tpSirSmeStartBssReq pStartBssReq) |
| 510 | { |
| 511 | tANI_U8 i = 0; |
| 512 | tANI_U8 valid = true; |
| 513 | |
| 514 | PELOG1(limLog(pMac, LOG1, |
| 515 | FL("Parsed START_BSS_REQ fields are bssType=%d, channelId=%d, SSID len=%d, rsnIE len=%d, nwType=%d, rateset len=%d\n"), |
| 516 | pStartBssReq->bssType, |
| 517 | pStartBssReq->channelId, |
| 518 | pStartBssReq->ssId.length, |
| 519 | pStartBssReq->rsnIE.length, |
| 520 | pStartBssReq->nwType, |
| 521 | pStartBssReq->operationalRateSet.numRates);) |
| 522 | |
| 523 | switch (pStartBssReq->bssType) |
| 524 | { |
| 525 | case eSIR_INFRASTRUCTURE_MODE: |
Jeff Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 526 | /** |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 527 | * Should not have received start BSS req with bssType |
| 528 | * Infrastructure on STA. |
| 529 | * Log error. |
| 530 | */ |
Jeff Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 531 | limLog(pMac, LOGE, |
| 532 | FL("Invalid bssType %d in eWNI_SME_START_BSS_REQ"), |
| 533 | pStartBssReq->bssType); |
| 534 | valid = false; |
| 535 | goto end; |
| 536 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 537 | |
| 538 | case eSIR_IBSS_MODE: |
| 539 | break; |
| 540 | |
| 541 | /* Added for BT AMP support */ |
| 542 | case eSIR_BTAMP_STA_MODE: |
| 543 | break; |
| 544 | |
| 545 | /* Added for BT AMP support */ |
| 546 | case eSIR_BTAMP_AP_MODE: |
| 547 | break; |
| 548 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 549 | /* Added for SoftAP support */ |
| 550 | case eSIR_INFRA_AP_MODE: |
| 551 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 552 | |
| 553 | default: |
| 554 | /** |
| 555 | * Should not have received start BSS req with bssType |
| 556 | * other than Infrastructure/IBSS. |
| 557 | * Log error |
| 558 | */ |
| 559 | limLog(pMac, LOGW, |
| 560 | FL("Invalid bssType %d in eWNI_SME_START_BSS_REQ\n"), |
| 561 | pStartBssReq->bssType); |
| 562 | |
| 563 | valid = false; |
| 564 | goto end; |
| 565 | } |
| 566 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 567 | /* This below code is client specific code. TODO */ |
| 568 | if (pStartBssReq->bssType == eSIR_IBSS_MODE) |
| 569 | { |
| 570 | if (!pStartBssReq->ssId.length || |
| 571 | (pStartBssReq->ssId.length > SIR_MAC_MAX_SSID_LENGTH)) |
| 572 | { |
| 573 | // Invalid length for SSID. |
| 574 | // Reject START_BSS_REQ |
| 575 | limLog(pMac, LOGW, |
| 576 | FL("Invalid SSID length in eWNI_SME_START_BSS_REQ\n")); |
| 577 | |
| 578 | valid = false; |
| 579 | goto end; |
| 580 | } |
| 581 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 582 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 583 | |
| 584 | if (!limIsRSNieValidInSmeReqMessage(pMac, &pStartBssReq->rsnIE)) |
| 585 | { |
| 586 | valid = false; |
| 587 | goto end; |
| 588 | } |
| 589 | |
| 590 | if (pStartBssReq->nwType != eSIR_11A_NW_TYPE && |
| 591 | pStartBssReq->nwType != eSIR_11B_NW_TYPE && |
| 592 | pStartBssReq->nwType != eSIR_11G_NW_TYPE) |
| 593 | { |
| 594 | valid = false; |
| 595 | goto end; |
| 596 | } |
| 597 | |
| 598 | if (pStartBssReq->nwType == eSIR_11A_NW_TYPE) |
| 599 | { |
| 600 | for (i = 0; i < pStartBssReq->operationalRateSet.numRates; i++) |
| 601 | if (!sirIsArate(pStartBssReq->operationalRateSet.rate[i] & 0x7F)) |
| 602 | { |
| 603 | // Invalid Operational rates |
| 604 | // Reject START_BSS_REQ |
| 605 | limLog(pMac, LOGW, |
| 606 | FL("Invalid operational rates in eWNI_SME_START_BSS_REQ\n")); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 607 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 608 | pStartBssReq->operationalRateSet.rate, |
| 609 | pStartBssReq->operationalRateSet.numRates); |
| 610 | |
| 611 | valid = false; |
| 612 | goto end; |
| 613 | } |
| 614 | } |
| 615 | // check if all the rates in the operatioal rate set are legal 11G rates |
| 616 | else if (pStartBssReq->nwType == eSIR_11G_NW_TYPE) |
| 617 | { |
| 618 | for (i = 0; i < pStartBssReq->operationalRateSet.numRates; i++) |
| 619 | if (!sirIsGrate(pStartBssReq->operationalRateSet.rate[i] & 0x7F)) |
| 620 | { |
| 621 | // Invalid Operational rates |
| 622 | // Reject START_BSS_REQ |
| 623 | limLog(pMac, LOGW, |
| 624 | FL("Invalid operational rates in eWNI_SME_START_BSS_REQ\n")); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 625 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 626 | pStartBssReq->operationalRateSet.rate, |
| 627 | pStartBssReq->operationalRateSet.numRates); |
| 628 | |
| 629 | valid = false; |
| 630 | goto end; |
| 631 | } |
| 632 | } |
Jeff Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 633 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 634 | { |
| 635 | for (i = 0; i < pStartBssReq->operationalRateSet.numRates; i++) |
| 636 | if (!sirIsBrate(pStartBssReq->operationalRateSet.rate[i] & 0x7F)) |
| 637 | { |
| 638 | // Invalid Operational rates |
| 639 | // Reject START_BSS_REQ |
| 640 | limLog(pMac, LOGW, |
| 641 | FL("Invalid operational rates in eWNI_SME_START_BSS_REQ\n")); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 642 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 643 | pStartBssReq->operationalRateSet.rate, |
| 644 | pStartBssReq->operationalRateSet.numRates); |
| 645 | |
| 646 | valid = false; |
| 647 | goto end; |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | end: |
| 652 | return valid; |
| 653 | } /*** end limIsSmeStartBssReqValid() ***/ |
| 654 | |
| 655 | |
| 656 | |
| 657 | /** |
| 658 | * limIsSmeJoinReqValid() |
| 659 | * |
| 660 | *FUNCTION: |
| 661 | * This function is called by limProcessSmeReqMessages() upon |
| 662 | * receiving SME_JOIN_REQ message from application. |
| 663 | * |
| 664 | *LOGIC: |
| 665 | * Message validity checks are performed in this function |
| 666 | * |
| 667 | *ASSUMPTIONS: |
| 668 | * |
| 669 | *NOTE: |
| 670 | * |
| 671 | * @param pMac Pointer to Global MAC structure |
| 672 | * @param pJoinReq Pointer to received SME_JOIN_REQ message |
| 673 | * @return true when received SME_JOIN_REQ is formatted correctly |
| 674 | * false otherwise |
| 675 | */ |
| 676 | |
| 677 | tANI_U8 |
| 678 | limIsSmeJoinReqValid(tpAniSirGlobal pMac, tpSirSmeJoinReq pJoinReq) |
| 679 | { |
| 680 | tANI_U8 valid = true; |
| 681 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 682 | |
| 683 | if (!limIsRSNieValidInSmeReqMessage(pMac, &pJoinReq->rsnIE)) |
| 684 | { |
| 685 | limLog(pMac, LOGE, |
| 686 | FL("received SME_JOIN_REQ with invalid RSNIE\n")); |
| 687 | valid = false; |
| 688 | goto end; |
| 689 | } |
| 690 | |
| 691 | if (!limIsAddieValidInSmeReqMessage(pMac, &pJoinReq->addIEScan)) |
| 692 | { |
| 693 | limLog(pMac, LOGE, |
| 694 | FL("received SME_JOIN_REQ with invalid additional IE for scan\n")); |
| 695 | valid = false; |
| 696 | goto end; |
| 697 | } |
| 698 | |
| 699 | if (!limIsAddieValidInSmeReqMessage(pMac, &pJoinReq->addIEAssoc)) |
| 700 | { |
| 701 | limLog(pMac, LOGE, |
| 702 | FL("received SME_JOIN_REQ with invalid additional IE for assoc\n")); |
| 703 | valid = false; |
| 704 | goto end; |
| 705 | } |
| 706 | |
| 707 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 708 | if (!limIsBssDescrValidInSmeReqMessage(pMac, |
| 709 | &pJoinReq->bssDescription)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 710 | { |
| 711 | /// Received eWNI_SME_JOIN_REQ with invalid BSS Info |
| 712 | // Log the event |
| 713 | limLog(pMac, LOGE, |
| 714 | FL("received SME_JOIN_REQ with invalid bssInfo\n")); |
| 715 | |
| 716 | valid = false; |
| 717 | goto end; |
| 718 | } |
| 719 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 720 | /* |
| 721 | Reject Join Req if the Self Mac Address and |
| 722 | the Ap's Mac Address is same |
| 723 | */ |
| 724 | if( palEqualMemory( pMac->hHdd, (tANI_U8* ) pJoinReq->selfMacAddr, |
| 725 | (tANI_U8 *) pJoinReq->bssDescription.bssId, |
| 726 | (tANI_U8) (sizeof(tSirMacAddr)))) |
| 727 | { |
| 728 | // Log the event |
| 729 | limLog(pMac, LOGE, |
| 730 | FL("received SME_JOIN_REQ with Self Mac and BSSID Same\n")); |
| 731 | |
| 732 | valid = false; |
| 733 | goto end; |
| 734 | } |
| 735 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 736 | end: |
| 737 | return valid; |
| 738 | } /*** end limIsSmeJoinReqValid() ***/ |
| 739 | |
| 740 | |
| 741 | |
| 742 | /** |
| 743 | * limIsSmeDisassocReqValid() |
| 744 | * |
| 745 | *FUNCTION: |
| 746 | * This function is called by limProcessSmeReqMessages() upon |
| 747 | * receiving SME_DISASSOC_REQ message from application. |
| 748 | * |
| 749 | *LOGIC: |
| 750 | * Message validity checks are performed in this function |
| 751 | * |
| 752 | *ASSUMPTIONS: |
| 753 | * |
| 754 | *NOTE: |
| 755 | * |
| 756 | * @param pMac Pointer to Global MAC structure |
| 757 | * @param pDisassocReq Pointer to received SME_DISASSOC_REQ message |
| 758 | * @return true When received SME_DISASSOC_REQ is formatted |
| 759 | * correctly |
| 760 | * false otherwise |
| 761 | */ |
| 762 | |
| 763 | tANI_U8 |
| 764 | limIsSmeDisassocReqValid(tpAniSirGlobal pMac, |
| 765 | tpSirSmeDisassocReq pDisassocReq, tpPESession psessionEntry) |
| 766 | { |
| 767 | if (limIsGroupAddr(pDisassocReq->peerMacAddr) && |
| 768 | !limIsAddrBC(pDisassocReq->peerMacAddr)) |
| 769 | return false; |
| 770 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 771 | |
| 772 | return true; |
| 773 | } /*** end limIsSmeDisassocReqValid() ***/ |
| 774 | |
| 775 | |
| 776 | |
| 777 | /** |
| 778 | * limIsSmeDisassocCnfValid() |
| 779 | * |
| 780 | *FUNCTION: |
| 781 | * This function is called by limProcessSmeReqMessages() upon |
| 782 | * receiving SME_DISASSOC_CNF message from application. |
| 783 | * |
| 784 | *LOGIC: |
| 785 | * Message validity checks are performed in this function |
| 786 | * |
| 787 | *ASSUMPTIONS: |
| 788 | * |
| 789 | *NOTE: |
| 790 | * |
| 791 | * @param pMac Pointer to Global MAC structure |
| 792 | * @param pDisassocCnf Pointer to received SME_DISASSOC_REQ message |
| 793 | * @return true When received SME_DISASSOC_CNF is formatted |
| 794 | * correctly |
| 795 | * false otherwise |
| 796 | */ |
| 797 | |
| 798 | tANI_U8 |
| 799 | limIsSmeDisassocCnfValid(tpAniSirGlobal pMac, |
| 800 | tpSirSmeDisassocCnf pDisassocCnf, tpPESession psessionEntry) |
| 801 | { |
| 802 | if (limIsGroupAddr(pDisassocCnf->peerMacAddr)) |
| 803 | return false; |
| 804 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 805 | return true; |
| 806 | } /*** end limIsSmeDisassocCnfValid() ***/ |
| 807 | |
| 808 | |
| 809 | |
| 810 | /** |
| 811 | * limIsSmeDeauthReqValid() |
| 812 | * |
| 813 | *FUNCTION: |
| 814 | * This function is called by limProcessSmeReqMessages() upon |
| 815 | * receiving SME_DEAUTH_REQ message from application. |
| 816 | * |
| 817 | *LOGIC: |
| 818 | * Message validity checks are performed in this function |
| 819 | * |
| 820 | *ASSUMPTIONS: |
| 821 | * |
| 822 | *NOTE: |
| 823 | * |
| 824 | * @param pMac Pointer to Global MAC structure |
| 825 | * @param pDeauthReq Pointer to received SME_DEAUTH_REQ message |
| 826 | * @return true When received SME_DEAUTH_REQ is formatted correctly |
| 827 | * false otherwise |
| 828 | */ |
| 829 | |
| 830 | tANI_U8 |
| 831 | limIsSmeDeauthReqValid(tpAniSirGlobal pMac, tpSirSmeDeauthReq pDeauthReq, tpPESession psessionEntry) |
| 832 | { |
| 833 | if (limIsGroupAddr(pDeauthReq->peerMacAddr) && |
| 834 | !limIsAddrBC(pDeauthReq->peerMacAddr)) |
| 835 | return false; |
| 836 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 837 | return true; |
| 838 | } /*** end limIsSmeDeauthReqValid() ***/ |
| 839 | |
| 840 | |
| 841 | |
| 842 | /** |
| 843 | * limIsSmeScanReqValid() |
| 844 | * |
| 845 | *FUNCTION: |
| 846 | * This function is called by limProcessSmeReqMessages() upon |
| 847 | * receiving SME_SCAN_REQ message from application. |
| 848 | * |
| 849 | *LOGIC: |
| 850 | * Message validity checks are performed in this function |
| 851 | * |
| 852 | *ASSUMPTIONS: |
| 853 | * |
| 854 | *NOTE: |
| 855 | * |
| 856 | * @param pScanReq Pointer to received SME_SCAN_REQ message |
| 857 | * @return true when received SME_SCAN_REQ is formatted correctly |
| 858 | * false otherwise |
| 859 | */ |
| 860 | |
| 861 | tANI_U8 |
| 862 | limIsSmeScanReqValid(tpAniSirGlobal pMac, tpSirSmeScanReq pScanReq) |
| 863 | { |
| 864 | tANI_U8 valid = true; |
| 865 | tANI_U8 i = 0; |
| 866 | |
| 867 | for (i = 0; i < pScanReq->numSsid; i++) |
| 868 | { |
| 869 | if (pScanReq->ssId[i].length > SIR_MAC_MAX_SSID_LENGTH) |
| 870 | { |
| 871 | valid = false; |
| 872 | goto end; |
| 873 | } |
| 874 | } |
| 875 | if ((pScanReq->bssType > eSIR_AUTO_MODE) || |
| 876 | (limIsGroupAddr(pScanReq->bssId) && !limIsAddrBC(pScanReq->bssId)) || |
| 877 | (!(pScanReq->scanType == eSIR_PASSIVE_SCAN || pScanReq->scanType == eSIR_ACTIVE_SCAN)) || |
| 878 | (pScanReq->channelList.numChannels > SIR_MAX_NUM_CHANNELS)) |
| 879 | { |
| 880 | valid = false; |
| 881 | goto end; |
| 882 | } |
| 883 | |
| 884 | /* |
| 885 | ** check min/max channelTime range |
| 886 | **/ |
| 887 | |
| 888 | if ((pScanReq->scanType == eSIR_ACTIVE_SCAN) && |
| 889 | (pScanReq->maxChannelTime < pScanReq->minChannelTime)) |
| 890 | { |
| 891 | PELOGW(limLog(pMac, LOGW, FL("Max Channel Time < Min Channel Time\n"));) |
| 892 | valid = false; |
| 893 | goto end; |
| 894 | } |
| 895 | |
| 896 | end: |
| 897 | return valid; |
| 898 | } /*** end limIsSmeScanReqValid() ***/ |
| 899 | |
| 900 | |
| 901 | |
| 902 | /** |
| 903 | * limIsSmeAuthReqValid() |
| 904 | * |
| 905 | *FUNCTION: |
| 906 | * This function is called by limProcessSmeReqMessages() upon |
| 907 | * receiving SME_AUTH_REQ message from application. |
| 908 | * |
| 909 | *LOGIC: |
| 910 | * Message validity checks are performed in this function |
| 911 | * |
| 912 | *ASSUMPTIONS: |
| 913 | * |
| 914 | *NOTE: |
| 915 | * |
| 916 | * @param pAuthReq Pointer to received SME_AUTH_REQ message |
| 917 | * @return true when received SME_AUTH_REQ is formatted correctly |
| 918 | * false otherwise |
| 919 | */ |
| 920 | |
| 921 | tANI_U8 |
| 922 | limIsSmeAuthReqValid(tpSirSmeAuthReq pAuthReq) |
| 923 | { |
| 924 | tANI_U8 valid = true; |
| 925 | |
| 926 | if (limIsGroupAddr(pAuthReq->peerMacAddr) || |
| 927 | (pAuthReq->authType > eSIR_AUTO_SWITCH) || |
| 928 | !pAuthReq->channelNumber) |
| 929 | { |
| 930 | valid = false; |
| 931 | goto end; |
| 932 | } |
| 933 | |
| 934 | end: |
| 935 | return valid; |
| 936 | } /*** end limIsSmeAuthReqValid() ***/ |
| 937 | |
| 938 | |
| 939 | |
| 940 | /** |
| 941 | * limIsSmeSetContextReqValid() |
| 942 | * |
| 943 | *FUNCTION: |
| 944 | * This function is called by limProcessSmeReqMessages() upon |
| 945 | * receiving SME_SET_CONTEXT_REQ message from application. |
| 946 | * |
| 947 | *LOGIC: |
| 948 | * Message validity checks are performed in this function |
| 949 | * |
| 950 | *ASSUMPTIONS: |
| 951 | * |
| 952 | *NOTE: |
| 953 | * |
| 954 | * @param pMsg - Pointer to received SME_SET_CONTEXT_REQ message |
| 955 | * @return true when received SME_SET_CONTEXT_REQ is formatted correctly |
| 956 | * false otherwise |
| 957 | */ |
| 958 | |
| 959 | tANI_U8 |
| 960 | limIsSmeSetContextReqValid(tpAniSirGlobal pMac, tpSirSmeSetContextReq pSetContextReq) |
| 961 | { |
| 962 | tANI_U8 i = 0; |
| 963 | tANI_U8 valid = true; |
| 964 | tpSirKeys pKey = pSetContextReq->keyMaterial.key; |
| 965 | |
| 966 | if ((pSetContextReq->keyMaterial.edType != eSIR_ED_WEP40) && |
| 967 | (pSetContextReq->keyMaterial.edType != eSIR_ED_WEP104) && |
| 968 | (pSetContextReq->keyMaterial.edType != eSIR_ED_NONE) && |
| 969 | #ifdef FEATURE_WLAN_WAPI |
| 970 | (pSetContextReq->keyMaterial.edType != eSIR_ED_WPI) && |
| 971 | #endif |
| 972 | !pSetContextReq->keyMaterial.numKeys) |
| 973 | { |
| 974 | /** |
| 975 | * No keys present in case of TKIP or CCMP |
| 976 | * Log error. |
| 977 | */ |
| 978 | limLog(pMac, LOGW, |
| 979 | FL("No keys present in SME_SETCONTEXT_REQ for edType=%d\n"), |
| 980 | pSetContextReq->keyMaterial.edType); |
| 981 | |
| 982 | valid = false; |
| 983 | goto end; |
| 984 | } |
| 985 | |
| 986 | if (pSetContextReq->keyMaterial.numKeys && |
| 987 | (pSetContextReq->keyMaterial.edType == eSIR_ED_NONE)) |
| 988 | { |
| 989 | /** |
| 990 | * Keys present in case of no ED policy |
| 991 | * Log error. |
| 992 | */ |
| 993 | limLog(pMac, LOGW, |
| 994 | FL("Keys present in SME_SETCONTEXT_REQ for edType=%d\n"), |
| 995 | pSetContextReq->keyMaterial.edType); |
| 996 | |
| 997 | valid = false; |
| 998 | goto end; |
| 999 | } |
| 1000 | |
| 1001 | if (pSetContextReq->keyMaterial.edType >= eSIR_ED_NOT_IMPLEMENTED) |
| 1002 | { |
| 1003 | /** |
| 1004 | * Invalid edType in the message |
| 1005 | * Log error. |
| 1006 | */ |
| 1007 | limLog(pMac, LOGW, |
| 1008 | FL("Invalid edType=%d in SME_SETCONTEXT_REQ\n"), |
| 1009 | pSetContextReq->keyMaterial.edType); |
| 1010 | |
| 1011 | valid = false; |
| 1012 | goto end; |
| 1013 | } |
| 1014 | else if (pSetContextReq->keyMaterial.edType > eSIR_ED_NONE) |
| 1015 | { |
| 1016 | tANI_U32 poi; |
| 1017 | |
| 1018 | if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, |
| 1019 | &poi) != eSIR_SUCCESS) |
| 1020 | { |
| 1021 | limLog(pMac, LOGP, |
| 1022 | FL("Unable to retrieve POI from CFG\n")); |
| 1023 | } |
| 1024 | |
| 1025 | if (!poi) |
| 1026 | { |
| 1027 | /** |
| 1028 | * Privacy is not enabled |
| 1029 | * In order to allow mixed mode for Guest access |
| 1030 | * allow BSS creation/join with no Privacy capability |
| 1031 | * yet advertising WPA IE |
| 1032 | */ |
| 1033 | PELOG1(limLog(pMac, LOG1, |
| 1034 | FL("Privacy is not enabled, yet non-None EDtype=%d in SME_SETCONTEXT_REQ\n"), |
| 1035 | pSetContextReq->keyMaterial.edType);) |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | for (i = 0; i < pSetContextReq->keyMaterial.numKeys; i++) |
| 1040 | { |
| 1041 | if (((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) && |
| 1042 | (pKey->keyLength != 5)) || |
| 1043 | ((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104) && |
| 1044 | (pKey->keyLength != 13)) || |
| 1045 | ((pSetContextReq->keyMaterial.edType == eSIR_ED_TKIP) && |
| 1046 | (pKey->keyLength != 32)) || |
| 1047 | #ifdef FEATURE_WLAN_WAPI |
| 1048 | ((pSetContextReq->keyMaterial.edType == eSIR_ED_WPI) && |
| 1049 | (pKey->keyLength != 32)) || |
| 1050 | #endif |
| 1051 | ((pSetContextReq->keyMaterial.edType == eSIR_ED_CCMP) && |
| 1052 | (pKey->keyLength != 16))) |
| 1053 | { |
| 1054 | /** |
| 1055 | * Invalid key length for a given ED type |
| 1056 | * Log error. |
| 1057 | */ |
| 1058 | limLog(pMac, LOGW, |
| 1059 | FL("Invalid keyLength =%d for edType=%d in SME_SETCONTEXT_REQ\n"), |
| 1060 | pKey->keyLength, pSetContextReq->keyMaterial.edType); |
| 1061 | |
| 1062 | valid = false; |
| 1063 | goto end; |
| 1064 | } |
| 1065 | pKey++; |
| 1066 | } |
| 1067 | |
| 1068 | end: |
| 1069 | return valid; |
| 1070 | } /*** end limIsSmeSetContextReqValid() ***/ |
| 1071 | |
| 1072 | |
| 1073 | |
| 1074 | /** |
| 1075 | * limIsSmeStopBssReqValid() |
| 1076 | * |
| 1077 | *FUNCTION: |
| 1078 | * This function is called by limProcessSmeReqMessages() upon |
| 1079 | * receiving SME_STOP_BSS_REQ message from application. |
| 1080 | * |
| 1081 | *LOGIC: |
| 1082 | * Message validity checks are performed in this function |
| 1083 | * |
| 1084 | *ASSUMPTIONS: |
| 1085 | * |
| 1086 | *NOTE: |
| 1087 | * |
| 1088 | * @param pMsg - Pointer to received SME_STOP_BSS_REQ message |
| 1089 | * @return true when received SME_STOP_BSS_REQ is formatted correctly |
| 1090 | * false otherwise |
| 1091 | */ |
| 1092 | |
| 1093 | tANI_U8 |
| 1094 | limIsSmeStopBssReqValid(tANI_U32 *pMsg) |
| 1095 | { |
| 1096 | tANI_U8 valid = true; |
| 1097 | |
| 1098 | return valid; |
| 1099 | } /*** end limIsSmeStopBssReqValid() ***/ |
| 1100 | |
| 1101 | |
| 1102 | /** |
| 1103 | * limGetBssIdFromSmeJoinReqMsg() |
| 1104 | * |
| 1105 | *FUNCTION: |
| 1106 | * This function is called in various places to get BSSID |
| 1107 | * from BSS description/Neighbor BSS Info in the SME_JOIN_REQ/ |
| 1108 | * SME_REASSOC_REQ message. |
| 1109 | * |
| 1110 | *PARAMS: |
| 1111 | * |
| 1112 | *LOGIC: |
| 1113 | * |
| 1114 | *ASSUMPTIONS: |
| 1115 | * NA |
| 1116 | * |
| 1117 | *NOTE: |
| 1118 | * NA |
| 1119 | * |
| 1120 | * @param pBuf - Pointer to received SME_JOIN/SME_REASSOC_REQ |
| 1121 | * message |
| 1122 | * @return pBssId - Pointer to BSSID |
| 1123 | */ |
| 1124 | |
| 1125 | tANI_U8* |
| 1126 | limGetBssIdFromSmeJoinReqMsg(tANI_U8 *pBuf) |
| 1127 | { |
| 1128 | if (!pBuf) |
| 1129 | return NULL; |
| 1130 | |
| 1131 | pBuf += sizeof(tANI_U32); // skip message header |
| 1132 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1133 | |
| 1134 | pBuf += limGetU16(pBuf) + sizeof(tANI_U16); // skip RSN IE |
| 1135 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1136 | pBuf += sizeof(tANI_U16); // skip length of BSS description |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1137 | |
| 1138 | return (pBuf); |
| 1139 | } /*** end limGetBssIdFromSmeJoinReqMsg() ***/ |
| 1140 | |
| 1141 | |