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