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, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 100 | FL("Unable to retrieve POI from CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | if (wlan_cfgGetInt(pMac, WNI_CFG_RSN_ENABLED, |
| 104 | &val) != eSIR_SUCCESS) |
| 105 | { |
| 106 | limLog(pMac, LOGP, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 107 | FL("Unable to retrieve RSN_ENABLED from CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 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 | */ |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 118 | PELOG1(limLog(pMac, LOG1, FL("RSN ie len %d but PRIVACY %d RSN %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 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 | { |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 131 | limLog(pMac, LOGE, FL("RSN/WPA/WAPI EID %d not [%d || %d]"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 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)) |
Gopichand Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 146 | { |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 152 | } |
| 153 | else if(pRSNie->rsnIEdata[startPos] == DOT11F_EID_WPA) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 154 | { |
Gopichand Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 155 | // 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 167 | |
Gopichand Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 168 | return false; |
| 169 | } |
| 170 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 171 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 172 | #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 Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 177 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 178 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 179 | FL("WAPI IE len %d not [%d,%d]"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 180 | pRSNie->rsnIEdata[startPos+1], DOT11F_IE_WAPI_MIN_LEN, |
| 181 | DOT11F_IE_WAPI_MAX_LEN); |
| 182 | |
| 183 | return false; |
| 184 | } |
Gopichand Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 185 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 186 | #endif |
| 187 | else |
Gopichand Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 188 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 189 | //we will never be here, simply for completeness |
Gopichand Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 190 | return false; |
| 191 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 192 | 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 | |
| 220 | static tANI_U8 |
| 221 | limIsAddieValidInSmeReqMessage(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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 238 | FL("****Invalid Add IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 252 | /** |
| 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 | |
| 271 | tANI_U8 |
| 272 | limSetRSNieWPAiefromSmeStartBSSReqMessage(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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 283 | FL("Unable to retrieve POI from CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | if (wlan_cfgGetInt(pMac, WNI_CFG_RSN_ENABLED, |
| 287 | &val) != eSIR_SUCCESS) |
| 288 | { |
| 289 | limLog(pMac, LOGP, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 290 | FL("Unable to retrieve RSN_ENABLED from CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 291 | } |
| 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 301 | PELOG1(limLog(pMac, LOG1, FL("RSN ie len %d but PRIVACY %d RSN %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 302 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 310 | limLog(pMac, LOGE, FL("RSN/WPA EID %d not [%d || %d]"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 323 | limLog(pMac, LOGE, FL("RSN IE len %d not [%d,%d]"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 324 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 335 | FL("First byte[%d] in rsnIEdata is not RSN_EID"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 336 | pRSNie->rsnIEdata[1]); |
| 337 | return false; |
| 338 | } |
| 339 | |
| 340 | limLog(pMac, |
| 341 | LOG1, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 342 | FL("WPA IE is present along with WPA2 IE")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 343 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 350 | FL("Only RSN IE is present")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 351 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 359 | FL("Only WPA IE is present")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 360 | |
| 361 | dot11fUnpackIeWPA(pMac,&pRSNie->rsnIEdata[6],(tANI_U8)pRSNie->length-4, |
| 362 | &pSessionEntry->gStartBssWPAIe); |
| 363 | } |
| 364 | |
| 365 | // Check validity of WPA IE |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 366 | if(wpaIndex +4 < SIR_MAC_MAX_IE_LENGTH ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 367 | { |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 368 | val = sirReadU32((tANI_U8 *) &pRSNie->rsnIEdata[wpaIndex + 2]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 369 | |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 370 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 378 | FL("WPA IE len %d not [%d,%d] OR data 0x%x not 0x%x"), |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 379 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 395 | } |
| 396 | else |
| 397 | { |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 398 | return false; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 399 | } |
| 400 | } |
| 401 | |
| 402 | return true; |
| 403 | } /*** end limSetRSNieWPAiefromSmeStartBSSReqMessage() ***/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 404 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 405 | |
| 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 | |
| 427 | static tANI_U8 |
| 428 | limIsBssDescrValidInSmeReqMessage(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 | |
| 440 | end: |
| 441 | return valid; |
| 442 | } /*** end limIsBssDescrValidInSmeReqMessage() ***/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 443 | |
| 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 | |
| 465 | tANI_U8 |
| 466 | limIsSmeStartReqValid(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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 477 | FL("Invalid length %d in eWNI_SME_START_REQ"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 478 | ((tpSirSmeStartReq) pMsg)->length); |
| 479 | |
| 480 | valid = false; |
| 481 | goto end; |
| 482 | } |
| 483 | |
| 484 | end: |
| 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 | |
| 510 | tANI_U8 |
| 511 | limIsSmeStartBssReqValid(tpAniSirGlobal pMac, |
| 512 | tpSirSmeStartBssReq pStartBssReq) |
| 513 | { |
| 514 | tANI_U8 i = 0; |
| 515 | tANI_U8 valid = true; |
| 516 | |
| 517 | PELOG1(limLog(pMac, LOG1, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 518 | FL("Parsed START_BSS_REQ fields are bssType=%d, channelId=%d, SSID len=%d, rsnIE len=%d, nwType=%d, rateset len=%d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 519 | 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 Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 529 | /** |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 530 | * Should not have received start BSS req with bssType |
| 531 | * Infrastructure on STA. |
| 532 | * Log error. |
| 533 | */ |
Jeff Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 534 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 540 | |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 552 | /* Added for SoftAP support */ |
| 553 | case eSIR_INFRA_AP_MODE: |
| 554 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 555 | |
| 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 563 | FL("Invalid bssType %d in eWNI_SME_START_BSS_REQ"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 564 | pStartBssReq->bssType); |
| 565 | |
| 566 | valid = false; |
| 567 | goto end; |
| 568 | } |
| 569 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 570 | /* 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 579 | FL("Invalid SSID length in eWNI_SME_START_BSS_REQ")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 580 | |
| 581 | valid = false; |
| 582 | goto end; |
| 583 | } |
| 584 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 585 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 586 | |
| 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 Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 609 | FL("Invalid operational rates in eWNI_SME_START_BSS_REQ")); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 610 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 611 | 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 Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 627 | FL("Invalid operational rates in eWNI_SME_START_BSS_REQ")); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 628 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 629 | pStartBssReq->operationalRateSet.rate, |
| 630 | pStartBssReq->operationalRateSet.numRates); |
| 631 | |
| 632 | valid = false; |
| 633 | goto end; |
| 634 | } |
| 635 | } |
Jeff Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 636 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 637 | { |
| 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 Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame^] | 644 | FL("Invalid operational rates in eWNI_SME_START_BSS_REQ")); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 645 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 646 | pStartBssReq->operationalRateSet.rate, |
| 647 | pStartBssReq->operationalRateSet.numRates); |
| 648 | |
| 649 | valid = false; |
| 650 | goto end; |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | end: |
| 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 | |
| 680 | tANI_U8 |
| 681 | limIsSmeJoinReqValid(tpAniSirGlobal pMac, tpSirSmeJoinReq pJoinReq) |
| 682 | { |
| 683 | tANI_U8 valid = true; |
| 684 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 685 | |
| 686 | if (!limIsRSNieValidInSmeReqMessage(pMac, &pJoinReq->rsnIE)) |
| 687 | { |
| 688 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 689 | FL("received SME_JOIN_REQ with invalid RSNIE")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 690 | valid = false; |
| 691 | goto end; |
| 692 | } |
| 693 | |
| 694 | if (!limIsAddieValidInSmeReqMessage(pMac, &pJoinReq->addIEScan)) |
| 695 | { |
| 696 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 697 | FL("received SME_JOIN_REQ with invalid additional IE for scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 698 | valid = false; |
| 699 | goto end; |
| 700 | } |
| 701 | |
| 702 | if (!limIsAddieValidInSmeReqMessage(pMac, &pJoinReq->addIEAssoc)) |
| 703 | { |
| 704 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 705 | FL("received SME_JOIN_REQ with invalid additional IE for assoc")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 706 | valid = false; |
| 707 | goto end; |
| 708 | } |
| 709 | |
| 710 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 711 | if (!limIsBssDescrValidInSmeReqMessage(pMac, |
| 712 | &pJoinReq->bssDescription)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 713 | { |
| 714 | /// Received eWNI_SME_JOIN_REQ with invalid BSS Info |
| 715 | // Log the event |
| 716 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 717 | FL("received SME_JOIN_REQ with invalid bssInfo")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 718 | |
| 719 | valid = false; |
| 720 | goto end; |
| 721 | } |
| 722 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 723 | /* |
| 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 733 | FL("received SME_JOIN_REQ with Self Mac and BSSID Same")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 734 | |
| 735 | valid = false; |
| 736 | goto end; |
| 737 | } |
| 738 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 739 | end: |
| 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 | |
| 766 | tANI_U8 |
| 767 | limIsSmeDisassocReqValid(tpAniSirGlobal pMac, |
| 768 | tpSirSmeDisassocReq pDisassocReq, tpPESession psessionEntry) |
| 769 | { |
| 770 | if (limIsGroupAddr(pDisassocReq->peerMacAddr) && |
| 771 | !limIsAddrBC(pDisassocReq->peerMacAddr)) |
| 772 | return false; |
| 773 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 774 | |
| 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 | |
| 801 | tANI_U8 |
| 802 | limIsSmeDisassocCnfValid(tpAniSirGlobal pMac, |
| 803 | tpSirSmeDisassocCnf pDisassocCnf, tpPESession psessionEntry) |
| 804 | { |
| 805 | if (limIsGroupAddr(pDisassocCnf->peerMacAddr)) |
| 806 | return false; |
| 807 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 808 | 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 | |
| 833 | tANI_U8 |
| 834 | limIsSmeDeauthReqValid(tpAniSirGlobal pMac, tpSirSmeDeauthReq pDeauthReq, tpPESession psessionEntry) |
| 835 | { |
| 836 | if (limIsGroupAddr(pDeauthReq->peerMacAddr) && |
| 837 | !limIsAddrBC(pDeauthReq->peerMacAddr)) |
| 838 | return false; |
| 839 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 840 | 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 | |
| 864 | tANI_U8 |
| 865 | limIsSmeScanReqValid(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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 894 | PELOGW(limLog(pMac, LOGW, FL("Max Channel Time < Min Channel Time"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 895 | valid = false; |
| 896 | goto end; |
| 897 | } |
| 898 | |
| 899 | end: |
| 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 | |
| 924 | tANI_U8 |
| 925 | limIsSmeAuthReqValid(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 | |
| 937 | end: |
| 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 | |
| 962 | tANI_U8 |
| 963 | limIsSmeSetContextReqValid(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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 982 | FL("No keys present in SME_SETCONTEXT_REQ for edType=%d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 983 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 997 | FL("Keys present in SME_SETCONTEXT_REQ for edType=%d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 998 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1011 | FL("Invalid edType=%d in SME_SETCONTEXT_REQ"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1012 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1025 | FL("Unable to retrieve POI from CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1026 | } |
| 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1037 | FL("Privacy is not enabled, yet non-None EDtype=%d in SME_SETCONTEXT_REQ"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1038 | 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 Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1062 | FL("Invalid keyLength =%d for edType=%d in SME_SETCONTEXT_REQ"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1063 | pKey->keyLength, pSetContextReq->keyMaterial.edType); |
| 1064 | |
| 1065 | valid = false; |
| 1066 | goto end; |
| 1067 | } |
| 1068 | pKey++; |
| 1069 | } |
| 1070 | |
| 1071 | end: |
| 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 | |
| 1096 | tANI_U8 |
| 1097 | limIsSmeStopBssReqValid(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 | |
| 1128 | tANI_U8* |
| 1129 | limGetBssIdFromSmeJoinReqMsg(tANI_U8 *pBuf) |
| 1130 | { |
| 1131 | if (!pBuf) |
| 1132 | return NULL; |
| 1133 | |
| 1134 | pBuf += sizeof(tANI_U32); // skip message header |
| 1135 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1136 | |
| 1137 | pBuf += limGetU16(pBuf) + sizeof(tANI_U16); // skip RSN IE |
| 1138 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1139 | pBuf += sizeof(tANI_U16); // skip length of BSS description |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1140 | |
| 1141 | return (pBuf); |
| 1142 | } /*** end limGetBssIdFromSmeJoinReqMsg() ***/ |
| 1143 | |
| 1144 | |