Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2015, 2018 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; |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 264 | tANI_U32 status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 265 | |
| 266 | if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, |
| 267 | &privacy) != eSIR_SUCCESS) |
| 268 | { |
| 269 | limLog(pMac, LOGP, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 270 | FL("Unable to retrieve POI from CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | if (wlan_cfgGetInt(pMac, WNI_CFG_RSN_ENABLED, |
| 274 | &val) != eSIR_SUCCESS) |
| 275 | { |
| 276 | limLog(pMac, LOGP, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 277 | FL("Unable to retrieve RSN_ENABLED from CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | if (pRSNie->length && (!privacy || !val)) |
| 281 | { |
| 282 | // Privacy & RSN not enabled in CFG. |
| 283 | /** |
| 284 | * In order to allow mixed mode for Guest access |
| 285 | * allow BSS creation/join with no Privacy capability |
| 286 | * yet advertising WPA IE |
| 287 | */ |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 288 | 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] | 289 | pRSNie->length, privacy, val);) |
| 290 | } |
| 291 | |
| 292 | if (pRSNie->length) |
| 293 | { |
| 294 | if ((pRSNie->rsnIEdata[0] != SIR_MAC_RSN_EID) && |
| 295 | (pRSNie->rsnIEdata[0] != SIR_MAC_WPA_EID)) |
| 296 | { |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 297 | limLog(pMac, LOGE, FL("RSN/WPA EID %d not [%d || %d]"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 298 | pRSNie->rsnIEdata[0], SIR_MAC_RSN_EID, |
| 299 | SIR_MAC_WPA_EID); |
| 300 | return false; |
| 301 | } |
| 302 | |
| 303 | // Check validity of RSN IE |
| 304 | if ((pRSNie->rsnIEdata[0] == SIR_MAC_RSN_EID) && |
| 305 | #if 0 // Comparison always false |
| 306 | (pRSNie->rsnIEdata[1] > SIR_MAC_RSN_IE_MAX_LENGTH) || |
| 307 | #endif |
| 308 | (pRSNie->rsnIEdata[1] < SIR_MAC_RSN_IE_MIN_LENGTH)) |
| 309 | { |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 310 | limLog(pMac, LOGE, FL("RSN IE len %d not [%d,%d]"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | pRSNie->rsnIEdata[1], SIR_MAC_RSN_IE_MIN_LENGTH, |
| 312 | SIR_MAC_RSN_IE_MAX_LENGTH); |
| 313 | return false; |
| 314 | } |
| 315 | |
| 316 | if (pRSNie->length > pRSNie->rsnIEdata[1] + 2) |
| 317 | { |
| 318 | if (pRSNie->rsnIEdata[0] != SIR_MAC_RSN_EID) |
| 319 | { |
| 320 | limLog(pMac, |
| 321 | LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 322 | FL("First byte[%d] in rsnIEdata is not RSN_EID"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 323 | pRSNie->rsnIEdata[1]); |
| 324 | return false; |
| 325 | } |
| 326 | |
| 327 | limLog(pMac, |
| 328 | LOG1, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 329 | FL("WPA IE is present along with WPA2 IE")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 330 | wpaIndex = 2 + pRSNie->rsnIEdata[1]; |
| 331 | } |
| 332 | else if ((pRSNie->length == pRSNie->rsnIEdata[1] + 2) && |
| 333 | (pRSNie->rsnIEdata[0] == SIR_MAC_RSN_EID)) |
| 334 | { |
| 335 | limLog(pMac, |
| 336 | LOG1, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 337 | FL("Only RSN IE is present")); |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 338 | status = dot11fUnpackIeRSN(pMac,&pRSNie->rsnIEdata[2], |
Abhinav Kumar | e58f3bc | 2018-04-03 12:59:05 +0530 | [diff] [blame] | 339 | pRSNie->rsnIEdata[1], |
| 340 | &pSessionEntry->gStartBssRSNIe); |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 341 | if (DOT11F_FAILED(status)) |
| 342 | { |
| 343 | limLog(pMac, |
| 344 | LOGE,FL("unpack failed for RSN IE (0x%08x)"), |
| 345 | status); |
| 346 | return false; |
| 347 | } |
| 348 | return true; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 349 | } |
| 350 | else if ((pRSNie->length == pRSNie->rsnIEdata[1] + 2) && |
| 351 | (pRSNie->rsnIEdata[0] == SIR_MAC_WPA_EID)) |
| 352 | { |
| 353 | limLog(pMac, |
| 354 | LOG1, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 355 | FL("Only WPA IE is present")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 356 | |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 357 | status = dot11fUnpackIeWPA(pMac,&pRSNie->rsnIEdata[6], |
Abhinav Kumar | e58f3bc | 2018-04-03 12:59:05 +0530 | [diff] [blame] | 358 | pRSNie->rsnIEdata[1] - 4, |
| 359 | &pSessionEntry->gStartBssWPAIe); |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 360 | if (DOT11F_FAILED(status)) |
| 361 | { |
| 362 | limLog(pMac, |
| 363 | LOGE,FL("unpack failed for WPA IE (0x%08x)"), |
| 364 | status); |
| 365 | return false; |
| 366 | } |
| 367 | return true; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | // Check validity of WPA IE |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 371 | if(wpaIndex +4 < SIR_MAC_MAX_IE_LENGTH ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 372 | { |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 373 | val = sirReadU32((tANI_U8 *) &pRSNie->rsnIEdata[wpaIndex + 2]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 374 | |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 375 | if ((pRSNie->rsnIEdata[wpaIndex] == SIR_MAC_WPA_EID) && |
| 376 | #if 0 // Comparison always false |
| 377 | (pRSNie->rsnIEdata[wpaIndex + 1] > SIR_MAC_WPA_IE_MAX_LENGTH) || |
| 378 | #endif |
| 379 | ((pRSNie->rsnIEdata[wpaIndex + 1] < SIR_MAC_WPA_IE_MIN_LENGTH) || |
| 380 | (SIR_MAC_WPA_OUI != val))) |
| 381 | { |
| 382 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 383 | 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] | 384 | pRSNie->rsnIEdata[1], SIR_MAC_RSN_IE_MIN_LENGTH, |
| 385 | SIR_MAC_RSN_IE_MAX_LENGTH, val, SIR_MAC_WPA_OUI); |
| 386 | |
| 387 | return false; |
| 388 | } |
| 389 | else |
| 390 | { |
| 391 | /* Both RSN and WPA IEs are present */ |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 392 | status = dot11fUnpackIeRSN(pMac,&pRSNie->rsnIEdata[2], |
| 393 | pRSNie->rsnIEdata[1], &pSessionEntry->gStartBssRSNIe); |
| 394 | if (DOT11F_FAILED(status)) |
| 395 | { |
| 396 | limLog(pMac,LOGE,FL("unpack failed for RSN IE status:(0x%08x)"), |
| 397 | status); |
| 398 | return false; |
| 399 | } |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 400 | |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 401 | status = dot11fUnpackIeWPA(pMac,&pRSNie->rsnIEdata[wpaIndex + 6], |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 402 | pRSNie->rsnIEdata[wpaIndex + 1]-4, |
| 403 | &pSessionEntry->gStartBssWPAIe); |
Pragaspathi Thilagaraj | b2041e8 | 2018-03-28 17:14:02 +0530 | [diff] [blame] | 404 | if (DOT11F_FAILED(status)) |
| 405 | { |
| 406 | limLog(pMac, LOGE,FL("unpack failed for WPA IE status:(0x%08x)"), |
| 407 | status); |
| 408 | return false; |
| 409 | } |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 410 | |
| 411 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 412 | } |
| 413 | else |
| 414 | { |
Gopichand Nakkala | fa9e298 | 2013-03-29 00:48:18 +0530 | [diff] [blame] | 415 | return false; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 416 | } |
| 417 | } |
| 418 | |
| 419 | return true; |
| 420 | } /*** end limSetRSNieWPAiefromSmeStartBSSReqMessage() ***/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 421 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 422 | |
| 423 | |
| 424 | |
| 425 | /** |
| 426 | * limIsBssDescrValidInSmeReqMessage() |
| 427 | * |
| 428 | *FUNCTION: |
| 429 | * This function is called to verify if the BSS Descr |
| 430 | * received in various SME_REQ messages is valid or not |
| 431 | * |
| 432 | *LOGIC: |
| 433 | * BSS Descritipion validity checks are performed in this function |
| 434 | * |
| 435 | *ASSUMPTIONS: |
| 436 | * |
| 437 | *NOTE: |
| 438 | * |
| 439 | * @param pMac Pointer to Global MAC structure |
| 440 | * @param pBssDescr Pointer to received Bss Descritipion |
| 441 | * @return true when BSS description is valid, false otherwise |
| 442 | */ |
| 443 | |
| 444 | static tANI_U8 |
| 445 | limIsBssDescrValidInSmeReqMessage(tpAniSirGlobal pMac, |
| 446 | tpSirBssDescription pBssDescr) |
| 447 | { |
| 448 | tANI_U8 valid = true; |
| 449 | |
| 450 | if (limIsAddrBC(pBssDescr->bssId) || |
| 451 | !pBssDescr->channelId) |
| 452 | { |
| 453 | valid = false; |
| 454 | goto end; |
| 455 | } |
| 456 | |
| 457 | end: |
| 458 | return valid; |
| 459 | } /*** end limIsBssDescrValidInSmeReqMessage() ***/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 460 | |
| 461 | |
| 462 | |
| 463 | /** |
| 464 | * limIsSmeStartReqValid() |
| 465 | * |
| 466 | *FUNCTION: |
| 467 | * This function is called by limProcessSmeReqMessages() upon |
| 468 | * receiving SME_START_REQ message from application. |
| 469 | * |
| 470 | *LOGIC: |
| 471 | * Message validity checks are performed in this function |
| 472 | * |
| 473 | *ASSUMPTIONS: |
| 474 | * |
| 475 | *NOTE: |
| 476 | * |
| 477 | * @param pMsg - Pointer to received SME_START_BSS_REQ message |
| 478 | * @return true when received SME_START_REQ is formatted correctly |
| 479 | * false otherwise |
| 480 | */ |
| 481 | |
| 482 | tANI_U8 |
| 483 | limIsSmeStartReqValid(tpAniSirGlobal pMac, tANI_U32 *pMsg) |
| 484 | { |
| 485 | tANI_U8 valid = true; |
| 486 | |
| 487 | if (((tpSirSmeStartReq) pMsg)->length != sizeof(tSirSmeStartReq)) |
| 488 | { |
| 489 | /** |
| 490 | * Invalid length in START_REQ message |
| 491 | * Log error. |
| 492 | */ |
| 493 | limLog(pMac, LOGW, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 494 | FL("Invalid length %d in eWNI_SME_START_REQ"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 495 | ((tpSirSmeStartReq) pMsg)->length); |
| 496 | |
| 497 | valid = false; |
| 498 | goto end; |
| 499 | } |
| 500 | |
| 501 | end: |
| 502 | return valid; |
| 503 | } /*** end limIsSmeStartReqValid() ***/ |
| 504 | |
| 505 | |
| 506 | |
| 507 | /** |
| 508 | * limIsSmeStartBssReqValid() |
| 509 | * |
| 510 | *FUNCTION: |
| 511 | * This function is called by limProcessSmeReqMessages() upon |
| 512 | * receiving SME_START_BSS_REQ message from application. |
| 513 | * |
| 514 | *LOGIC: |
| 515 | * Message validity checks are performed in this function |
| 516 | * |
| 517 | *ASSUMPTIONS: |
| 518 | * |
| 519 | *NOTE: |
| 520 | * |
| 521 | * @param pMac Pointer to Global MAC structure |
| 522 | * @param pStartBssReq Pointer to received SME_START_BSS_REQ message |
| 523 | * @return true when received SME_START_BSS_REQ is formatted correctly |
| 524 | * false otherwise |
| 525 | */ |
| 526 | |
| 527 | tANI_U8 |
| 528 | limIsSmeStartBssReqValid(tpAniSirGlobal pMac, |
| 529 | tpSirSmeStartBssReq pStartBssReq) |
| 530 | { |
| 531 | tANI_U8 i = 0; |
| 532 | tANI_U8 valid = true; |
| 533 | |
| 534 | PELOG1(limLog(pMac, LOG1, |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 535 | FL("Parsed START_BSS_REQ fields are bssType=%s (%d), channelId=%d," |
| 536 | " SSID len=%d, rsnIE len=%d, nwType=%d, rateset len=%d"), |
| 537 | lim_BssTypetoString(pStartBssReq->bssType), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 538 | pStartBssReq->bssType, |
| 539 | pStartBssReq->channelId, |
| 540 | pStartBssReq->ssId.length, |
| 541 | pStartBssReq->rsnIE.length, |
| 542 | pStartBssReq->nwType, |
| 543 | pStartBssReq->operationalRateSet.numRates);) |
| 544 | |
| 545 | switch (pStartBssReq->bssType) |
| 546 | { |
| 547 | case eSIR_INFRASTRUCTURE_MODE: |
Jeff Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 548 | /** |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 549 | * Should not have received start BSS req with bssType |
| 550 | * Infrastructure on STA. |
| 551 | * Log error. |
| 552 | */ |
Jeff Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 553 | limLog(pMac, LOGE, |
| 554 | FL("Invalid bssType %d in eWNI_SME_START_BSS_REQ"), |
| 555 | pStartBssReq->bssType); |
| 556 | valid = false; |
| 557 | goto end; |
| 558 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 559 | |
| 560 | case eSIR_IBSS_MODE: |
| 561 | break; |
| 562 | |
| 563 | /* Added for BT AMP support */ |
| 564 | case eSIR_BTAMP_STA_MODE: |
| 565 | break; |
| 566 | |
| 567 | /* Added for BT AMP support */ |
| 568 | case eSIR_BTAMP_AP_MODE: |
| 569 | break; |
| 570 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 571 | /* Added for SoftAP support */ |
| 572 | case eSIR_INFRA_AP_MODE: |
| 573 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 574 | |
| 575 | default: |
| 576 | /** |
| 577 | * Should not have received start BSS req with bssType |
| 578 | * other than Infrastructure/IBSS. |
| 579 | * Log error |
| 580 | */ |
| 581 | limLog(pMac, LOGW, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 582 | FL("Invalid bssType %d in eWNI_SME_START_BSS_REQ"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 583 | pStartBssReq->bssType); |
| 584 | |
| 585 | valid = false; |
| 586 | goto end; |
| 587 | } |
| 588 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 589 | /* This below code is client specific code. TODO */ |
| 590 | if (pStartBssReq->bssType == eSIR_IBSS_MODE) |
| 591 | { |
| 592 | if (!pStartBssReq->ssId.length || |
| 593 | (pStartBssReq->ssId.length > SIR_MAC_MAX_SSID_LENGTH)) |
| 594 | { |
| 595 | // Invalid length for SSID. |
| 596 | // Reject START_BSS_REQ |
| 597 | limLog(pMac, LOGW, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 598 | FL("Invalid SSID length in eWNI_SME_START_BSS_REQ")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 599 | |
| 600 | valid = false; |
| 601 | goto end; |
| 602 | } |
| 603 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 604 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 605 | |
| 606 | if (!limIsRSNieValidInSmeReqMessage(pMac, &pStartBssReq->rsnIE)) |
| 607 | { |
| 608 | valid = false; |
| 609 | goto end; |
| 610 | } |
| 611 | |
| 612 | if (pStartBssReq->nwType != eSIR_11A_NW_TYPE && |
| 613 | pStartBssReq->nwType != eSIR_11B_NW_TYPE && |
| 614 | pStartBssReq->nwType != eSIR_11G_NW_TYPE) |
| 615 | { |
| 616 | valid = false; |
| 617 | goto end; |
| 618 | } |
| 619 | |
| 620 | if (pStartBssReq->nwType == eSIR_11A_NW_TYPE) |
| 621 | { |
| 622 | for (i = 0; i < pStartBssReq->operationalRateSet.numRates; i++) |
| 623 | if (!sirIsArate(pStartBssReq->operationalRateSet.rate[i] & 0x7F)) |
| 624 | { |
| 625 | // Invalid Operational rates |
| 626 | // Reject START_BSS_REQ |
| 627 | limLog(pMac, LOGW, |
Gopichand Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame] | 628 | FL("Invalid operational rates in eWNI_SME_START_BSS_REQ")); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 629 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 630 | pStartBssReq->operationalRateSet.rate, |
| 631 | pStartBssReq->operationalRateSet.numRates); |
| 632 | |
| 633 | valid = false; |
| 634 | goto end; |
| 635 | } |
| 636 | } |
| 637 | // check if all the rates in the operatioal rate set are legal 11G rates |
| 638 | else if (pStartBssReq->nwType == eSIR_11G_NW_TYPE) |
| 639 | { |
| 640 | for (i = 0; i < pStartBssReq->operationalRateSet.numRates; i++) |
| 641 | if (!sirIsGrate(pStartBssReq->operationalRateSet.rate[i] & 0x7F)) |
| 642 | { |
| 643 | // Invalid Operational rates |
| 644 | // Reject START_BSS_REQ |
| 645 | limLog(pMac, LOGW, |
Gopichand Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame] | 646 | FL("Invalid operational rates in eWNI_SME_START_BSS_REQ")); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 647 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 648 | pStartBssReq->operationalRateSet.rate, |
| 649 | pStartBssReq->operationalRateSet.numRates); |
| 650 | |
| 651 | valid = false; |
| 652 | goto end; |
| 653 | } |
| 654 | } |
Jeff Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 655 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 656 | { |
| 657 | for (i = 0; i < pStartBssReq->operationalRateSet.numRates; i++) |
| 658 | if (!sirIsBrate(pStartBssReq->operationalRateSet.rate[i] & 0x7F)) |
| 659 | { |
| 660 | // Invalid Operational rates |
| 661 | // Reject START_BSS_REQ |
| 662 | limLog(pMac, LOGW, |
Gopichand Nakkala | cc8cf8e | 2013-04-25 06:03:10 -0700 | [diff] [blame] | 663 | FL("Invalid operational rates in eWNI_SME_START_BSS_REQ")); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 664 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 665 | pStartBssReq->operationalRateSet.rate, |
| 666 | pStartBssReq->operationalRateSet.numRates); |
| 667 | |
| 668 | valid = false; |
| 669 | goto end; |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | end: |
| 674 | return valid; |
| 675 | } /*** end limIsSmeStartBssReqValid() ***/ |
| 676 | |
| 677 | |
| 678 | |
| 679 | /** |
| 680 | * limIsSmeJoinReqValid() |
| 681 | * |
| 682 | *FUNCTION: |
| 683 | * This function is called by limProcessSmeReqMessages() upon |
| 684 | * receiving SME_JOIN_REQ message from application. |
| 685 | * |
| 686 | *LOGIC: |
| 687 | * Message validity checks are performed in this function |
| 688 | * |
| 689 | *ASSUMPTIONS: |
| 690 | * |
| 691 | *NOTE: |
| 692 | * |
| 693 | * @param pMac Pointer to Global MAC structure |
| 694 | * @param pJoinReq Pointer to received SME_JOIN_REQ message |
| 695 | * @return true when received SME_JOIN_REQ is formatted correctly |
| 696 | * false otherwise |
| 697 | */ |
| 698 | |
| 699 | tANI_U8 |
| 700 | limIsSmeJoinReqValid(tpAniSirGlobal pMac, tpSirSmeJoinReq pJoinReq) |
| 701 | { |
| 702 | tANI_U8 valid = true; |
| 703 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 704 | |
Pragaspathi Thilagaraj | 03e2ab1 | 2018-06-22 12:19:48 +0530 | [diff] [blame] | 705 | //If force_rsne_override is enabled that mean User has provided the |
| 706 | //test RSNIE which need to be send as it is in assoc req and thus RSNIE |
| 707 | //validity is not required. |
| 708 | if (!pJoinReq->force_rsne_override && |
| 709 | !limIsRSNieValidInSmeReqMessage(pMac, &pJoinReq->rsnIE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 710 | { |
| 711 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 712 | FL("received SME_JOIN_REQ with invalid RSNIE")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 713 | valid = false; |
| 714 | goto end; |
| 715 | } |
| 716 | |
| 717 | if (!limIsAddieValidInSmeReqMessage(pMac, &pJoinReq->addIEScan)) |
| 718 | { |
| 719 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 720 | FL("received SME_JOIN_REQ with invalid additional IE for scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 721 | valid = false; |
| 722 | goto end; |
| 723 | } |
| 724 | |
| 725 | if (!limIsAddieValidInSmeReqMessage(pMac, &pJoinReq->addIEAssoc)) |
| 726 | { |
| 727 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 728 | FL("received SME_JOIN_REQ with invalid additional IE for assoc")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 729 | valid = false; |
| 730 | goto end; |
| 731 | } |
| 732 | |
| 733 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 734 | if (!limIsBssDescrValidInSmeReqMessage(pMac, |
| 735 | &pJoinReq->bssDescription)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 736 | { |
| 737 | /// Received eWNI_SME_JOIN_REQ with invalid BSS Info |
| 738 | // Log the event |
| 739 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 740 | FL("received SME_JOIN_REQ with invalid bssInfo")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 741 | |
| 742 | valid = false; |
| 743 | goto end; |
| 744 | } |
| 745 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 746 | /* |
| 747 | Reject Join Req if the Self Mac Address and |
| 748 | the Ap's Mac Address is same |
| 749 | */ |
Bansidhar Gopalachari | 72515da | 2013-07-11 11:14:27 +0530 | [diff] [blame] | 750 | if ( vos_mem_compare( (tANI_U8* ) pJoinReq->selfMacAddr, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 751 | (tANI_U8 *) pJoinReq->bssDescription.bssId, |
| 752 | (tANI_U8) (sizeof(tSirMacAddr)))) |
| 753 | { |
| 754 | // Log the event |
| 755 | limLog(pMac, LOGE, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 756 | FL("received SME_JOIN_REQ with Self Mac and BSSID Same")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 757 | |
| 758 | valid = false; |
| 759 | goto end; |
| 760 | } |
| 761 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 762 | end: |
| 763 | return valid; |
| 764 | } /*** end limIsSmeJoinReqValid() ***/ |
| 765 | |
| 766 | |
| 767 | |
| 768 | /** |
| 769 | * limIsSmeDisassocReqValid() |
| 770 | * |
| 771 | *FUNCTION: |
| 772 | * This function is called by limProcessSmeReqMessages() upon |
| 773 | * receiving SME_DISASSOC_REQ 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 pDisassocReq Pointer to received SME_DISASSOC_REQ message |
| 784 | * @return true When received SME_DISASSOC_REQ is formatted |
| 785 | * correctly |
| 786 | * false otherwise |
| 787 | */ |
| 788 | |
| 789 | tANI_U8 |
| 790 | limIsSmeDisassocReqValid(tpAniSirGlobal pMac, |
| 791 | tpSirSmeDisassocReq pDisassocReq, tpPESession psessionEntry) |
| 792 | { |
| 793 | if (limIsGroupAddr(pDisassocReq->peerMacAddr) && |
| 794 | !limIsAddrBC(pDisassocReq->peerMacAddr)) |
| 795 | return false; |
| 796 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 797 | |
| 798 | return true; |
| 799 | } /*** end limIsSmeDisassocReqValid() ***/ |
| 800 | |
| 801 | |
| 802 | |
| 803 | /** |
| 804 | * limIsSmeDisassocCnfValid() |
| 805 | * |
| 806 | *FUNCTION: |
| 807 | * This function is called by limProcessSmeReqMessages() upon |
| 808 | * receiving SME_DISASSOC_CNF message from application. |
| 809 | * |
| 810 | *LOGIC: |
| 811 | * Message validity checks are performed in this function |
| 812 | * |
| 813 | *ASSUMPTIONS: |
| 814 | * |
| 815 | *NOTE: |
| 816 | * |
| 817 | * @param pMac Pointer to Global MAC structure |
| 818 | * @param pDisassocCnf Pointer to received SME_DISASSOC_REQ message |
| 819 | * @return true When received SME_DISASSOC_CNF is formatted |
| 820 | * correctly |
| 821 | * false otherwise |
| 822 | */ |
| 823 | |
| 824 | tANI_U8 |
| 825 | limIsSmeDisassocCnfValid(tpAniSirGlobal pMac, |
| 826 | tpSirSmeDisassocCnf pDisassocCnf, tpPESession psessionEntry) |
| 827 | { |
| 828 | if (limIsGroupAddr(pDisassocCnf->peerMacAddr)) |
| 829 | return false; |
| 830 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 831 | return true; |
| 832 | } /*** end limIsSmeDisassocCnfValid() ***/ |
| 833 | |
| 834 | |
| 835 | |
| 836 | /** |
| 837 | * limIsSmeDeauthReqValid() |
| 838 | * |
| 839 | *FUNCTION: |
| 840 | * This function is called by limProcessSmeReqMessages() upon |
| 841 | * receiving SME_DEAUTH_REQ message from application. |
| 842 | * |
| 843 | *LOGIC: |
| 844 | * Message validity checks are performed in this function |
| 845 | * |
| 846 | *ASSUMPTIONS: |
| 847 | * |
| 848 | *NOTE: |
| 849 | * |
| 850 | * @param pMac Pointer to Global MAC structure |
| 851 | * @param pDeauthReq Pointer to received SME_DEAUTH_REQ message |
| 852 | * @return true When received SME_DEAUTH_REQ is formatted correctly |
| 853 | * false otherwise |
| 854 | */ |
| 855 | |
| 856 | tANI_U8 |
| 857 | limIsSmeDeauthReqValid(tpAniSirGlobal pMac, tpSirSmeDeauthReq pDeauthReq, tpPESession psessionEntry) |
| 858 | { |
| 859 | if (limIsGroupAddr(pDeauthReq->peerMacAddr) && |
| 860 | !limIsAddrBC(pDeauthReq->peerMacAddr)) |
| 861 | return false; |
| 862 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 863 | return true; |
| 864 | } /*** end limIsSmeDeauthReqValid() ***/ |
| 865 | |
| 866 | |
| 867 | |
| 868 | /** |
| 869 | * limIsSmeScanReqValid() |
| 870 | * |
| 871 | *FUNCTION: |
| 872 | * This function is called by limProcessSmeReqMessages() upon |
| 873 | * receiving SME_SCAN_REQ message from application. |
| 874 | * |
| 875 | *LOGIC: |
| 876 | * Message validity checks are performed in this function |
| 877 | * |
| 878 | *ASSUMPTIONS: |
| 879 | * |
| 880 | *NOTE: |
| 881 | * |
| 882 | * @param pScanReq Pointer to received SME_SCAN_REQ message |
| 883 | * @return true when received SME_SCAN_REQ is formatted correctly |
| 884 | * false otherwise |
| 885 | */ |
| 886 | |
| 887 | tANI_U8 |
| 888 | limIsSmeScanReqValid(tpAniSirGlobal pMac, tpSirSmeScanReq pScanReq) |
| 889 | { |
| 890 | tANI_U8 valid = true; |
| 891 | tANI_U8 i = 0; |
| 892 | |
Abhishek Singh | d920594 | 2015-04-29 14:45:36 +0530 | [diff] [blame] | 893 | if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) |
| 894 | { |
| 895 | valid = false; |
| 896 | limLog(pMac, LOGE, FL("Number of SSIDs > SIR_SCAN_MAX_NUM_SSID")); |
| 897 | goto end; |
| 898 | } |
| 899 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 900 | for (i = 0; i < pScanReq->numSsid; i++) |
| 901 | { |
| 902 | if (pScanReq->ssId[i].length > SIR_MAC_MAX_SSID_LENGTH) |
| 903 | { |
Rashmi Ramanna | 6c13a34 | 2014-01-07 11:44:07 +0530 | [diff] [blame] | 904 | limLog(pMac, LOGE, |
| 905 | FL("Requested SSID length > SIR_MAC_MAX_SSID_LENGTH")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 906 | valid = false; |
| 907 | goto end; |
| 908 | } |
| 909 | } |
Abhishek Singh | d920594 | 2015-04-29 14:45:36 +0530 | [diff] [blame] | 910 | if ((pScanReq->bssType < 0) || (pScanReq->bssType > eSIR_AUTO_MODE)) |
Rashmi Ramanna | 6c13a34 | 2014-01-07 11:44:07 +0530 | [diff] [blame] | 911 | { |
| 912 | limLog(pMac, LOGE, FL("Invalid BSS Type")); |
| 913 | valid = false; |
| 914 | } |
| 915 | if (limIsGroupAddr(pScanReq->bssId) && !limIsAddrBC(pScanReq->bssId)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 916 | { |
| 917 | valid = false; |
Rashmi Ramanna | 6c13a34 | 2014-01-07 11:44:07 +0530 | [diff] [blame] | 918 | limLog(pMac, LOGE, FL("BSSID is group addr and is not Broadcast Addr")); |
| 919 | } |
| 920 | if (!(pScanReq->scanType == eSIR_PASSIVE_SCAN || pScanReq->scanType == eSIR_ACTIVE_SCAN)) |
| 921 | { |
| 922 | valid = false; |
| 923 | limLog(pMac, LOGE, FL("Invalid Scan Type")); |
| 924 | } |
| 925 | if (pScanReq->channelList.numChannels > SIR_MAX_NUM_CHANNELS) |
| 926 | { |
| 927 | valid = false; |
| 928 | limLog(pMac, LOGE, FL("Number of Channels > SIR_MAX_NUM_CHANNELS")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | /* |
| 932 | ** check min/max channelTime range |
| 933 | **/ |
| 934 | |
Rashmi Ramanna | 6c13a34 | 2014-01-07 11:44:07 +0530 | [diff] [blame] | 935 | if (valid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 936 | { |
Rashmi Ramanna | 6c13a34 | 2014-01-07 11:44:07 +0530 | [diff] [blame] | 937 | if ((pScanReq->scanType == eSIR_ACTIVE_SCAN) && |
| 938 | (pScanReq->maxChannelTime < pScanReq->minChannelTime)) |
| 939 | { |
| 940 | limLog(pMac, LOGE, FL("Max Channel Time < Min Channel Time")); |
| 941 | valid = false; |
| 942 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | end: |
| 946 | return valid; |
| 947 | } /*** end limIsSmeScanReqValid() ***/ |
| 948 | |
| 949 | |
| 950 | |
| 951 | /** |
| 952 | * limIsSmeAuthReqValid() |
| 953 | * |
| 954 | *FUNCTION: |
| 955 | * This function is called by limProcessSmeReqMessages() upon |
| 956 | * receiving SME_AUTH_REQ message from application. |
| 957 | * |
| 958 | *LOGIC: |
| 959 | * Message validity checks are performed in this function |
| 960 | * |
| 961 | *ASSUMPTIONS: |
| 962 | * |
| 963 | *NOTE: |
| 964 | * |
| 965 | * @param pAuthReq Pointer to received SME_AUTH_REQ message |
| 966 | * @return true when received SME_AUTH_REQ is formatted correctly |
| 967 | * false otherwise |
| 968 | */ |
| 969 | |
| 970 | tANI_U8 |
| 971 | limIsSmeAuthReqValid(tpSirSmeAuthReq pAuthReq) |
| 972 | { |
| 973 | tANI_U8 valid = true; |
| 974 | |
| 975 | if (limIsGroupAddr(pAuthReq->peerMacAddr) || |
| 976 | (pAuthReq->authType > eSIR_AUTO_SWITCH) || |
| 977 | !pAuthReq->channelNumber) |
| 978 | { |
| 979 | valid = false; |
| 980 | goto end; |
| 981 | } |
| 982 | |
| 983 | end: |
| 984 | return valid; |
| 985 | } /*** end limIsSmeAuthReqValid() ***/ |
| 986 | |
| 987 | |
| 988 | |
| 989 | /** |
| 990 | * limIsSmeSetContextReqValid() |
| 991 | * |
| 992 | *FUNCTION: |
| 993 | * This function is called by limProcessSmeReqMessages() upon |
| 994 | * receiving SME_SET_CONTEXT_REQ message from application. |
| 995 | * |
| 996 | *LOGIC: |
| 997 | * Message validity checks are performed in this function |
| 998 | * |
| 999 | *ASSUMPTIONS: |
| 1000 | * |
| 1001 | *NOTE: |
| 1002 | * |
| 1003 | * @param pMsg - Pointer to received SME_SET_CONTEXT_REQ message |
| 1004 | * @return true when received SME_SET_CONTEXT_REQ is formatted correctly |
| 1005 | * false otherwise |
| 1006 | */ |
| 1007 | |
| 1008 | tANI_U8 |
| 1009 | limIsSmeSetContextReqValid(tpAniSirGlobal pMac, tpSirSmeSetContextReq pSetContextReq) |
| 1010 | { |
| 1011 | tANI_U8 i = 0; |
| 1012 | tANI_U8 valid = true; |
| 1013 | tpSirKeys pKey = pSetContextReq->keyMaterial.key; |
| 1014 | |
| 1015 | if ((pSetContextReq->keyMaterial.edType != eSIR_ED_WEP40) && |
| 1016 | (pSetContextReq->keyMaterial.edType != eSIR_ED_WEP104) && |
| 1017 | (pSetContextReq->keyMaterial.edType != eSIR_ED_NONE) && |
| 1018 | #ifdef FEATURE_WLAN_WAPI |
| 1019 | (pSetContextReq->keyMaterial.edType != eSIR_ED_WPI) && |
| 1020 | #endif |
| 1021 | !pSetContextReq->keyMaterial.numKeys) |
| 1022 | { |
| 1023 | /** |
| 1024 | * No keys present in case of TKIP or CCMP |
| 1025 | * Log error. |
| 1026 | */ |
| 1027 | limLog(pMac, LOGW, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1028 | FL("No keys present in SME_SETCONTEXT_REQ for edType=%d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1029 | pSetContextReq->keyMaterial.edType); |
| 1030 | |
| 1031 | valid = false; |
| 1032 | goto end; |
| 1033 | } |
| 1034 | |
| 1035 | if (pSetContextReq->keyMaterial.numKeys && |
| 1036 | (pSetContextReq->keyMaterial.edType == eSIR_ED_NONE)) |
| 1037 | { |
| 1038 | /** |
| 1039 | * Keys present in case of no ED policy |
| 1040 | * Log error. |
| 1041 | */ |
| 1042 | limLog(pMac, LOGW, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1043 | FL("Keys present in SME_SETCONTEXT_REQ for edType=%d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1044 | pSetContextReq->keyMaterial.edType); |
| 1045 | |
| 1046 | valid = false; |
| 1047 | goto end; |
| 1048 | } |
| 1049 | |
| 1050 | if (pSetContextReq->keyMaterial.edType >= eSIR_ED_NOT_IMPLEMENTED) |
| 1051 | { |
| 1052 | /** |
| 1053 | * Invalid edType in the message |
| 1054 | * Log error. |
| 1055 | */ |
| 1056 | limLog(pMac, LOGW, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1057 | FL("Invalid edType=%d in SME_SETCONTEXT_REQ"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1058 | pSetContextReq->keyMaterial.edType); |
| 1059 | |
| 1060 | valid = false; |
| 1061 | goto end; |
| 1062 | } |
| 1063 | else if (pSetContextReq->keyMaterial.edType > eSIR_ED_NONE) |
| 1064 | { |
| 1065 | tANI_U32 poi; |
| 1066 | |
| 1067 | if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, |
| 1068 | &poi) != eSIR_SUCCESS) |
| 1069 | { |
| 1070 | limLog(pMac, LOGP, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1071 | FL("Unable to retrieve POI from CFG")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | if (!poi) |
| 1075 | { |
| 1076 | /** |
| 1077 | * Privacy is not enabled |
| 1078 | * In order to allow mixed mode for Guest access |
| 1079 | * allow BSS creation/join with no Privacy capability |
| 1080 | * yet advertising WPA IE |
| 1081 | */ |
| 1082 | PELOG1(limLog(pMac, LOG1, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1083 | 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] | 1084 | pSetContextReq->keyMaterial.edType);) |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | for (i = 0; i < pSetContextReq->keyMaterial.numKeys; i++) |
| 1089 | { |
| 1090 | if (((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) && |
| 1091 | (pKey->keyLength != 5)) || |
| 1092 | ((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104) && |
| 1093 | (pKey->keyLength != 13)) || |
| 1094 | ((pSetContextReq->keyMaterial.edType == eSIR_ED_TKIP) && |
| 1095 | (pKey->keyLength != 32)) || |
| 1096 | #ifdef FEATURE_WLAN_WAPI |
| 1097 | ((pSetContextReq->keyMaterial.edType == eSIR_ED_WPI) && |
| 1098 | (pKey->keyLength != 32)) || |
| 1099 | #endif |
| 1100 | ((pSetContextReq->keyMaterial.edType == eSIR_ED_CCMP) && |
| 1101 | (pKey->keyLength != 16))) |
| 1102 | { |
| 1103 | /** |
| 1104 | * Invalid key length for a given ED type |
| 1105 | * Log error. |
| 1106 | */ |
| 1107 | limLog(pMac, LOGW, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 1108 | FL("Invalid keyLength =%d for edType=%d in SME_SETCONTEXT_REQ"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1109 | pKey->keyLength, pSetContextReq->keyMaterial.edType); |
| 1110 | |
| 1111 | valid = false; |
| 1112 | goto end; |
| 1113 | } |
| 1114 | pKey++; |
| 1115 | } |
| 1116 | |
| 1117 | end: |
| 1118 | return valid; |
| 1119 | } /*** end limIsSmeSetContextReqValid() ***/ |
| 1120 | |
| 1121 | |
| 1122 | |
| 1123 | /** |
| 1124 | * limIsSmeStopBssReqValid() |
| 1125 | * |
| 1126 | *FUNCTION: |
| 1127 | * This function is called by limProcessSmeReqMessages() upon |
| 1128 | * receiving SME_STOP_BSS_REQ message from application. |
| 1129 | * |
| 1130 | *LOGIC: |
| 1131 | * Message validity checks are performed in this function |
| 1132 | * |
| 1133 | *ASSUMPTIONS: |
| 1134 | * |
| 1135 | *NOTE: |
| 1136 | * |
| 1137 | * @param pMsg - Pointer to received SME_STOP_BSS_REQ message |
| 1138 | * @return true when received SME_STOP_BSS_REQ is formatted correctly |
| 1139 | * false otherwise |
| 1140 | */ |
| 1141 | |
| 1142 | tANI_U8 |
| 1143 | limIsSmeStopBssReqValid(tANI_U32 *pMsg) |
| 1144 | { |
| 1145 | tANI_U8 valid = true; |
| 1146 | |
| 1147 | return valid; |
| 1148 | } /*** end limIsSmeStopBssReqValid() ***/ |
| 1149 | |
| 1150 | |
| 1151 | /** |
| 1152 | * limGetBssIdFromSmeJoinReqMsg() |
| 1153 | * |
| 1154 | *FUNCTION: |
| 1155 | * This function is called in various places to get BSSID |
| 1156 | * from BSS description/Neighbor BSS Info in the SME_JOIN_REQ/ |
| 1157 | * SME_REASSOC_REQ message. |
| 1158 | * |
| 1159 | *PARAMS: |
| 1160 | * |
| 1161 | *LOGIC: |
| 1162 | * |
| 1163 | *ASSUMPTIONS: |
| 1164 | * NA |
| 1165 | * |
| 1166 | *NOTE: |
| 1167 | * NA |
| 1168 | * |
| 1169 | * @param pBuf - Pointer to received SME_JOIN/SME_REASSOC_REQ |
| 1170 | * message |
| 1171 | * @return pBssId - Pointer to BSSID |
| 1172 | */ |
| 1173 | |
| 1174 | tANI_U8* |
| 1175 | limGetBssIdFromSmeJoinReqMsg(tANI_U8 *pBuf) |
| 1176 | { |
| 1177 | if (!pBuf) |
| 1178 | return NULL; |
| 1179 | |
| 1180 | pBuf += sizeof(tANI_U32); // skip message header |
| 1181 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1182 | |
| 1183 | pBuf += limGetU16(pBuf) + sizeof(tANI_U16); // skip RSN IE |
| 1184 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1185 | pBuf += sizeof(tANI_U16); // skip length of BSS description |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1186 | |
| 1187 | return (pBuf); |
| 1188 | } /*** end limGetBssIdFromSmeJoinReqMsg() ***/ |
| 1189 | |
| 1190 | |