blob: f8f45e738e602596825fe2cca7a141359114abfd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhinav Kumar4d44f632019-08-02 13:55:54 +05302 * Copyright (c) 2011-2017, 2019 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
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 */
Chet Lanctot4c986162013-05-08 13:59:56 -070027
Jeff Johnson295189b2012-06-20 16:38:30 -070028/** ------------------------------------------------------------------------- *
29 ------------------------------------------------------------------------- *
30
31
32 \file csrUtil.c
33
34 Implementation supporting routines for CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -070035 ========================================================================== */
36
Jeff Johnson295189b2012-06-20 16:38:30 -070037
Jeff Johnson295189b2012-06-20 16:38:30 -070038#include "aniGlobal.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070039
40#include "palApi.h"
41#include "csrSupport.h"
42#include "csrInsideApi.h"
43#include "smsDebug.h"
44#include "smeQosInternal.h"
Jeff Johnsone7245742012-09-05 17:12:55 -070045#include "wlan_qct_wda.h"
46
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080047#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -070048#include "vos_utils.h"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080049#include "csrEse.h"
50#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD*/
Jeff Johnson295189b2012-06-20 16:38:30 -070051tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ] = {
52 { 0x00, 0x50, 0xf2, 0x00 },
53 { 0x00, 0x50, 0xf2, 0x01 },
54 { 0x00, 0x50, 0xf2, 0x02 },
55 { 0x00, 0x50, 0xf2, 0x03 },
56 { 0x00, 0x50, 0xf2, 0x04 },
57 { 0x00, 0x50, 0xf2, 0x05 },
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080058#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070059 { 0x00, 0x40, 0x96, 0x00 }, // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080060#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070061};
62
63tANI_U8 csrRSNOui[][ CSR_RSN_OUI_SIZE ] = {
64 { 0x00, 0x0F, 0xAC, 0x00 }, // group cipher
65 { 0x00, 0x0F, 0xAC, 0x01 }, // WEP-40 or RSN
66 { 0x00, 0x0F, 0xAC, 0x02 }, // TKIP or RSN-PSK
67 { 0x00, 0x0F, 0xAC, 0x03 }, // Reserved
68 { 0x00, 0x0F, 0xAC, 0x04 }, // AES-CCMP
69 { 0x00, 0x0F, 0xAC, 0x05 }, // WEP-104
Chet Lanctot4c986162013-05-08 13:59:56 -070070 { 0x00, 0x40, 0x96, 0x00 }, // CCKM
Abhishek Singhae408032014-09-25 17:22:04 +053071 { 0x00, 0x0F, 0xAC, 0x06 }, // BIP (encryption type) or RSN-PSK-SHA256 (authentication type)
72 /* RSN-8021X-SHA256 (authentication type) */
Abhinav Kumar4d44f632019-08-02 13:55:54 +053073 { 0x00, 0x0F, 0xAC, 0x05 },
74#ifdef WLAN_FEATURE_SAE
75#define ENUM_SAE 9
76 /* SAE */
77 {0x00, 0x0F, 0xAC, 0x08},
78#define ENUM_FT_SAE 10
79 /* FT SAE */
80 {0x00, 0x0F, 0xAC, 0x09},
81#else
82 {0x00, 0x00, 0x00, 0x00},
83 {0x00, 0x00, 0x00, 0x00},
84 #endif
85 /* define new oui here */
Abhinav Kumar487e49e2019-07-22 14:46:18 +053086#define ENUM_OWE 11
87 /* OWE https://tools.ietf.org/html/rfc8110 */
88 {0x00, 0x0F, 0xAC, 0x12},
Jeff Johnson295189b2012-06-20 16:38:30 -070089};
90
91#ifdef FEATURE_WLAN_WAPI
Kaushik, Sushantfe230152014-04-08 14:37:47 +053092tANI_U8 csrWapiOui[CSR_WAPI_OUI_ROW_SIZE][ CSR_WAPI_OUI_SIZE ] = {
Jeff Johnson295189b2012-06-20 16:38:30 -070093 { 0x00, 0x14, 0x72, 0x00 }, // Reserved
94 { 0x00, 0x14, 0x72, 0x01 }, // WAI certificate or SMS4
95 { 0x00, 0x14, 0x72, 0x02 } // WAI PSK
96};
97#endif /* FEATURE_WLAN_WAPI */
98tANI_U8 csrWmeInfoOui[ CSR_WME_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
99tANI_U8 csrWmeParmOui[ CSR_WME_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
100
101static tCsrIELenInfo gCsrIELengthTable[] = {
102/* 000 */ { SIR_MAC_SSID_EID_MIN, SIR_MAC_SSID_EID_MAX },
103/* 001 */ { SIR_MAC_RATESET_EID_MIN, SIR_MAC_RATESET_EID_MAX },
104/* 002 */ { SIR_MAC_FH_PARAM_SET_EID_MIN, SIR_MAC_FH_PARAM_SET_EID_MAX },
105/* 003 */ { SIR_MAC_DS_PARAM_SET_EID_MIN, SIR_MAC_DS_PARAM_SET_EID_MAX },
106/* 004 */ { SIR_MAC_CF_PARAM_SET_EID_MIN, SIR_MAC_CF_PARAM_SET_EID_MAX },
107/* 005 */ { SIR_MAC_TIM_EID_MIN, SIR_MAC_TIM_EID_MAX },
108/* 006 */ { SIR_MAC_IBSS_PARAM_SET_EID_MIN, SIR_MAC_IBSS_PARAM_SET_EID_MAX },
109/* 007 */ { SIR_MAC_COUNTRY_EID_MIN, SIR_MAC_COUNTRY_EID_MAX },
110/* 008 */ { SIR_MAC_FH_PARAMS_EID_MIN, SIR_MAC_FH_PARAMS_EID_MAX },
111/* 009 */ { SIR_MAC_FH_PATTERN_EID_MIN, SIR_MAC_FH_PATTERN_EID_MAX },
112/* 010 */ { SIR_MAC_REQUEST_EID_MIN, SIR_MAC_REQUEST_EID_MAX },
113/* 011 */ { SIR_MAC_QBSS_LOAD_EID_MIN, SIR_MAC_QBSS_LOAD_EID_MAX },
114/* 012 */ { SIR_MAC_EDCA_PARAM_SET_EID_MIN, SIR_MAC_EDCA_PARAM_SET_EID_MAX },
115/* 013 */ { SIR_MAC_TSPEC_EID_MIN, SIR_MAC_TSPEC_EID_MAX },
116/* 014 */ { SIR_MAC_TCLAS_EID_MIN, SIR_MAC_TCLAS_EID_MAX },
117/* 015 */ { SIR_MAC_QOS_SCHEDULE_EID_MIN, SIR_MAC_QOS_SCHEDULE_EID_MAX },
118/* 016 */ { SIR_MAC_CHALLENGE_TEXT_EID_MIN, SIR_MAC_CHALLENGE_TEXT_EID_MAX },
119/* 017 */ { 0, 255 },
120/* 018 */ { 0, 255 },
121/* 019 */ { 0, 255 },
122/* 020 */ { 0, 255 },
123/* 021 */ { 0, 255 },
124/* 022 */ { 0, 255 },
125/* 023 */ { 0, 255 },
126/* 024 */ { 0, 255 },
127/* 025 */ { 0, 255 },
128/* 026 */ { 0, 255 },
129/* 027 */ { 0, 255 },
130/* 028 */ { 0, 255 },
131/* 029 */ { 0, 255 },
132/* 030 */ { 0, 255 },
133/* 031 */ { 0, 255 },
134/* 032 */ { SIR_MAC_PWR_CONSTRAINT_EID_MIN, SIR_MAC_PWR_CONSTRAINT_EID_MAX },
135/* 033 */ { SIR_MAC_PWR_CAPABILITY_EID_MIN, SIR_MAC_PWR_CAPABILITY_EID_MAX },
136/* 034 */ { SIR_MAC_TPC_REQ_EID_MIN, SIR_MAC_TPC_REQ_EID_MAX },
137/* 035 */ { SIR_MAC_TPC_RPT_EID_MIN, SIR_MAC_TPC_RPT_EID_MAX },
138/* 036 */ { SIR_MAC_SPRTD_CHNLS_EID_MIN, SIR_MAC_SPRTD_CHNLS_EID_MAX },
139/* 037 */ { SIR_MAC_CHNL_SWITCH_ANN_EID_MIN, SIR_MAC_CHNL_SWITCH_ANN_EID_MAX },
140/* 038 */ { SIR_MAC_MEAS_REQ_EID_MIN, SIR_MAC_MEAS_REQ_EID_MAX },
141/* 039 */ { SIR_MAC_MEAS_RPT_EID_MIN, SIR_MAC_MEAS_RPT_EID_MAX },
142/* 040 */ { SIR_MAC_QUIET_EID_MIN, SIR_MAC_QUIET_EID_MAX },
143/* 041 */ { SIR_MAC_IBSS_DFS_EID_MIN, SIR_MAC_IBSS_DFS_EID_MAX },
144/* 042 */ { SIR_MAC_ERP_INFO_EID_MIN, SIR_MAC_ERP_INFO_EID_MAX },
145/* 043 */ { SIR_MAC_TS_DELAY_EID_MIN, SIR_MAC_TS_DELAY_EID_MAX },
146/* 044 */ { SIR_MAC_TCLAS_PROC_EID_MIN, SIR_MAC_TCLAS_PROC_EID_MAX },
147/* 045 */ { SIR_MAC_QOS_ACTION_EID_MIN, SIR_MAC_QOS_ACTION_EID_MAX },
148/* 046 */ { SIR_MAC_QOS_CAPABILITY_EID_MIN, SIR_MAC_QOS_CAPABILITY_EID_MAX },
149/* 047 */ { 0, 255 },
150/* 048 */ { SIR_MAC_RSN_EID_MIN, SIR_MAC_RSN_EID_MAX },
151/* 049 */ { 0, 255 },
152/* 050 */ { SIR_MAC_EXTENDED_RATE_EID_MIN, SIR_MAC_EXTENDED_RATE_EID_MAX },
153/* 051 */ { 0, 255 },
154/* 052 */ { 0, 255 },
155/* 053 */ { 0, 255 },
156/* 054 */ { 0, 255 },
157/* 055 */ { 0, 255 },
158/* 056 */ { 0, 255 },
159/* 057 */ { 0, 255 },
160/* 058 */ { 0, 255 },
161/* 059 */ { 0, 255 },
162/* 060 */ { 0, 255 },
163/* 061 */ { 0, 255 },
164/* 062 */ { 0, 255 },
165/* 063 */ { 0, 255 },
166/* 064 */ { 0, 255 },
167/* 065 */ { 0, 255 },
168/* 066 */ { 0, 255 },
169/* 067 */ { 0, 255 },
170#ifdef FEATURE_WLAN_WAPI
171/* 068 */ { DOT11F_EID_WAPI, DOT11F_IE_WAPI_MAX_LEN },
172#else
173/* 068 */ { 0, 255 },
174#endif /* FEATURE_WLAN_WAPI */
175/* 069 */ { 0, 255 },
176/* 070 */ { 0, 255 },
177/* 071 */ { 0, 255 },
178/* 072 */ { 0, 255 },
179/* 073 */ { 0, 255 },
180/* 074 */ { 0, 255 },
181/* 075 */ { 0, 255 },
182/* 076 */ { 0, 255 },
183/* 077 */ { 0, 255 },
184/* 078 */ { 0, 255 },
185/* 079 */ { 0, 255 },
186/* 080 */ { 0, 255 },
187/* 081 */ { 0, 255 },
188/* 082 */ { 0, 255 },
189/* 083 */ { 0, 255 },
190/* 084 */ { 0, 255 },
191/* 085 */ { 0, 255 },
192/* 086 */ { 0, 255 },
193/* 087 */ { 0, 255 },
194/* 088 */ { 0, 255 },
195/* 089 */ { 0, 255 },
196/* 090 */ { 0, 255 },
197/* 091 */ { 0, 255 },
198/* 092 */ { 0, 255 },
199/* 093 */ { 0, 255 },
200/* 094 */ { 0, 255 },
201/* 095 */ { 0, 255 },
202/* 096 */ { 0, 255 },
203/* 097 */ { 0, 255 },
204/* 098 */ { 0, 255 },
205/* 099 */ { 0, 255 },
206/* 100 */ { 0, 255 },
207/* 101 */ { 0, 255 },
208/* 102 */ { 0, 255 },
209/* 103 */ { 0, 255 },
210/* 104 */ { 0, 255 },
211/* 105 */ { 0, 255 },
212/* 106 */ { 0, 255 },
213/* 107 */ { 0, 255 },
214/* 108 */ { 0, 255 },
215/* 109 */ { 0, 255 },
216/* 110 */ { 0, 255 },
217/* 111 */ { 0, 255 },
218/* 112 */ { 0, 255 },
219/* 113 */ { 0, 255 },
220/* 114 */ { 0, 255 },
221/* 115 */ { 0, 255 },
222/* 116 */ { 0, 255 },
223/* 117 */ { 0, 255 },
224/* 118 */ { 0, 255 },
225/* 119 */ { 0, 255 },
226/* 120 */ { 0, 255 },
227/* 121 */ { 0, 255 },
228/* 122 */ { 0, 255 },
229/* 123 */ { 0, 255 },
230/* 124 */ { 0, 255 },
231/* 125 */ { 0, 255 },
232/* 126 */ { 0, 255 },
233/* 127 */ { 0, 255 },
234/* 128 */ { 0, 255 },
235/* 129 */ { 0, 255 },
236/* 130 */ { 0, 255 },
237/* 131 */ { 0, 255 },
238/* 132 */ { 0, 255 },
239/* 133 */ { 0, 255 },
240/* 134 */ { 0, 255 },
241/* 135 */ { 0, 255 },
242/* 136 */ { 0, 255 },
243/* 137 */ { 0, 255 },
244/* 138 */ { 0, 255 },
245/* 139 */ { 0, 255 },
246/* 140 */ { 0, 255 },
247/* 141 */ { 0, 255 },
248/* 142 */ { 0, 255 },
249/* 143 */ { 0, 255 },
250/* 144 */ { 0, 255 },
251/* 145 */ { 0, 255 },
252/* 146 */ { 0, 255 },
253/* 147 */ { 0, 255 },
254/* 148 */ { 0, 255 },
255/* 149 */ { 0, 255 },
256/* 150 */ { 0, 255 },
257/* 151 */ { 0, 255 },
258/* 152 */ { 0, 255 },
259/* 153 */ { 0, 255 },
260/* 154 */ { 0, 255 },
261/* 155 */ { 0, 255 },
262/* 156 */ { 0, 255 },
263/* 157 */ { 0, 255 },
264/* 158 */ { 0, 255 },
265/* 159 */ { 0, 255 },
266/* 160 */ { 0, 255 },
267/* 161 */ { 0, 255 },
268/* 162 */ { 0, 255 },
269/* 163 */ { 0, 255 },
270/* 164 */ { 0, 255 },
271/* 165 */ { 0, 255 },
272/* 166 */ { 0, 255 },
273/* 167 */ { 0, 255 },
274/* 168 */ { 0, 255 },
275/* 169 */ { 0, 255 },
276/* 170 */ { 0, 255 },
277/* 171 */ { 0, 255 },
278/* 172 */ { 0, 255 },
279/* 173 */ { 0, 255 },
280/* 174 */ { 0, 255 },
281/* 175 */ { 0, 255 },
282/* 176 */ { 0, 255 },
283/* 177 */ { 0, 255 },
284/* 178 */ { 0, 255 },
285/* 179 */ { 0, 255 },
286/* 180 */ { 0, 255 },
287/* 181 */ { 0, 255 },
288/* 182 */ { 0, 255 },
289/* 183 */ { 0, 255 },
290/* 184 */ { 0, 255 },
291/* 185 */ { 0, 255 },
292/* 186 */ { 0, 255 },
293/* 187 */ { 0, 255 },
294/* 188 */ { 0, 255 },
295/* 189 */ { 0, 255 },
296/* 190 */ { 0, 255 },
297/* 191 */ { 0, 255 },
298/* 192 */ { 0, 255 },
299/* 193 */ { 0, 255 },
300/* 194 */ { 0, 255 },
301/* 195 */ { 0, 255 },
302/* 196 */ { 0, 255 },
303/* 197 */ { 0, 255 },
304/* 198 */ { 0, 255 },
305/* 199 */ { 0, 255 },
306/* 200 */ { 0, 255 },
307/* 201 */ { 0, 255 },
308/* 202 */ { 0, 255 },
309/* 203 */ { 0, 255 },
310/* 204 */ { 0, 255 },
311/* 205 */ { 0, 255 },
312/* 206 */ { 0, 255 },
313/* 207 */ { 0, 255 },
314/* 208 */ { 0, 255 },
315/* 209 */ { 0, 255 },
316/* 210 */ { 0, 255 },
317/* 211 */ { 0, 255 },
318/* 212 */ { 0, 255 },
319/* 213 */ { 0, 255 },
320/* 214 */ { 0, 255 },
321/* 215 */ { 0, 255 },
322/* 216 */ { 0, 255 },
323/* 217 */ { 0, 255 },
324/* 218 */ { 0, 255 },
325/* 219 */ { 0, 255 },
326/* 220 */ { 0, 255 },
327/* 221 */ { SIR_MAC_WPA_EID_MIN, SIR_MAC_WPA_EID_MAX },
328/* 222 */ { 0, 255 },
329/* 223 */ { 0, 255 },
330/* 224 */ { 0, 255 },
331/* 225 */ { 0, 255 },
332/* 226 */ { 0, 255 },
333/* 227 */ { 0, 255 },
334/* 228 */ { 0, 255 },
335/* 229 */ { 0, 255 },
336/* 230 */ { 0, 255 },
337/* 231 */ { 0, 255 },
338/* 232 */ { 0, 255 },
339/* 233 */ { 0, 255 },
340/* 234 */ { 0, 255 },
341/* 235 */ { 0, 255 },
342/* 236 */ { 0, 255 },
343/* 237 */ { 0, 255 },
344/* 238 */ { 0, 255 },
345/* 239 */ { 0, 255 },
346/* 240 */ { 0, 255 },
347/* 241 */ { 0, 255 },
348/* 242 */ { 0, 255 },
349/* 243 */ { 0, 255 },
350/* 244 */ { 0, 255 },
351/* 245 */ { 0, 255 },
352/* 246 */ { 0, 255 },
353/* 247 */ { 0, 255 },
354/* 248 */ { 0, 255 },
355/* 249 */ { 0, 255 },
356/* 250 */ { 0, 255 },
357/* 251 */ { 0, 255 },
358/* 252 */ { 0, 255 },
359/* 253 */ { 0, 255 },
360/* 254 */ { 0, 255 },
361/* 255 */ { SIR_MAC_ANI_WORKAROUND_EID_MIN, SIR_MAC_ANI_WORKAROUND_EID_MAX }
362};
363
364#if 0
365//Don't not insert entry into the table, put it to the end. If you have to insert, make sure it is also
366//reflected in eCsrCountryIndex
367static tCsrCountryInfo gCsrCountryInfo[eCSR_NUM_COUNTRY_INDEX] =
368{
369 {REG_DOMAIN_FCC, {'U', 'S', ' '}}, //USA/******The "US" MUST be at index 0*******/
370 {REG_DOMAIN_WORLD, {'A', 'D', ' '}}, //ANDORRA
371 {REG_DOMAIN_WORLD, {'A', 'E', ' '}}, //UAE
372 {REG_DOMAIN_WORLD, {'A', 'F', ' '}}, //AFGHANISTAN
373 {REG_DOMAIN_WORLD, {'A', 'G', ' '}}, //ANTIGUA AND BARBUDA
374 {REG_DOMAIN_WORLD, {'A', 'I', ' '}}, //ANGUILLA
375 {REG_DOMAIN_HI_5GHZ, {'A', 'L', ' '}}, //ALBANIA
376 {REG_DOMAIN_WORLD, {'A', 'M', ' '}}, //ARMENIA
377 {REG_DOMAIN_WORLD, {'A', 'N', ' '}}, //NETHERLANDS ANTILLES
378 {REG_DOMAIN_WORLD, {'A', 'O', ' '}}, //ANGOLA
379 {REG_DOMAIN_WORLD, {'A', 'Q', ' '}}, //ANTARCTICA
380 {REG_DOMAIN_HI_5GHZ, {'A', 'R', ' '}}, //ARGENTINA
381 {REG_DOMAIN_FCC, {'A', 'S', ' '}}, //AMERICAN SOMOA
382 {REG_DOMAIN_ETSI, {'A', 'T', ' '}}, //AUSTRIA
383 {REG_DOMAIN_ETSI, {'A', 'U', ' '}}, //AUSTRALIA
384 {REG_DOMAIN_WORLD, {'A', 'W', ' '}}, //ARUBA
385 {REG_DOMAIN_WORLD, {'A', 'X', ' '}}, //ALAND ISLANDS
386 {REG_DOMAIN_WORLD, {'A', 'Z', ' '}}, //AZERBAIJAN
387 {REG_DOMAIN_WORLD, {'B', 'A', ' '}}, //BOSNIA AND HERZEGOVINA
388 {REG_DOMAIN_WORLD, {'B', 'B', ' '}}, //BARBADOS
389 {REG_DOMAIN_WORLD, {'B', 'D', ' '}}, //BANGLADESH
390 {REG_DOMAIN_ETSI, {'B', 'E', ' '}}, //BELGIUM
391 {REG_DOMAIN_WORLD, {'B', 'F', ' '}}, //BURKINA FASO
392 {REG_DOMAIN_HI_5GHZ, {'B', 'G', ' '}}, //BULGARIA
393 {REG_DOMAIN_WORLD, {'B', 'H', ' '}}, //BAHRAIN
394 {REG_DOMAIN_WORLD, {'B', 'I', ' '}}, //BURUNDI
395 {REG_DOMAIN_WORLD, {'B', 'J', ' '}}, //BENIN
396 {REG_DOMAIN_WORLD, {'B', 'L', ' '}}, //SAINT BARTHELEMY
397 {REG_DOMAIN_ETSI, {'B', 'M', ' '}}, //BERMUDA
398 {REG_DOMAIN_WORLD, {'B', 'N', ' '}}, //BRUNEI DARUSSALAM
399 {REG_DOMAIN_WORLD, {'B', 'O', ' '}}, //BOLIVIA
400 {REG_DOMAIN_WORLD, {'B', 'R', ' '}}, //BRAZIL
401 {REG_DOMAIN_WORLD, {'B', 'S', ' '}}, //BAHAMAS
402 {REG_DOMAIN_WORLD, {'B', 'T', ' '}}, //BHUTAN
403 {REG_DOMAIN_WORLD, {'B', 'V', ' '}}, //BOUVET ISLAND
404 {REG_DOMAIN_WORLD, {'B', 'W', ' '}}, //BOTSWANA
405 {REG_DOMAIN_WORLD, {'B', 'Y', ' '}}, //BELARUS
406 {REG_DOMAIN_WORLD, {'B', 'Z', ' '}}, //BELIZE
407 {REG_DOMAIN_FCC, {'C', 'A', ' '}}, //CANADA
408 {REG_DOMAIN_WORLD, {'C', 'C', ' '}}, //COCOS (KEELING) ISLANDS
409 {REG_DOMAIN_WORLD, {'C', 'D', ' '}}, //CONGO, THE DEMOCRATIC REPUBLIC OF THE
410 {REG_DOMAIN_WORLD, {'C', 'F', ' '}}, //CENTRAL AFRICAN REPUBLIC
411 {REG_DOMAIN_WORLD, {'C', 'G', ' '}}, //CONGO
412 {REG_DOMAIN_ETSI, {'C', 'H', ' '}}, //SWITZERLAND
413 {REG_DOMAIN_WORLD, {'C', 'I', ' '}}, //COTE D'IVOIRE
414 {REG_DOMAIN_WORLD, {'C', 'K', ' '}}, //COOK ISLANDS
415 {REG_DOMAIN_WORLD, {'C', 'L', ' '}}, //CHILE
416 {REG_DOMAIN_WORLD, {'C', 'M', ' '}}, //CAMEROON
417 {REG_DOMAIN_HI_5GHZ, {'C', 'N', ' '}}, //CHINA
418 {REG_DOMAIN_WORLD, {'C', 'O', ' '}}, //COLOMBIA
419 {REG_DOMAIN_WORLD, {'C', 'R', ' '}}, //COSTA RICA
420 {REG_DOMAIN_WORLD, {'C', 'U', ' '}}, //CUBA
421 {REG_DOMAIN_WORLD, {'C', 'V', ' '}}, //CAPE VERDE
422 {REG_DOMAIN_WORLD, {'C', 'X', ' '}}, //CHRISTMAS ISLAND
423 {REG_DOMAIN_WORLD, {'C', 'Y', ' '}}, //CYPRUS
424 {REG_DOMAIN_HI_5GHZ, {'C', 'Z', ' '}}, //CZECH REPUBLIC
425 {REG_DOMAIN_ETSI, {'D', 'E', ' '}}, //GERMANY
426 {REG_DOMAIN_WORLD, {'D', 'J', ' '}}, //DJIBOUTI
427 {REG_DOMAIN_ETSI, {'D', 'K', ' '}}, //DENMARK
428 {REG_DOMAIN_WORLD, {'D', 'M', ' '}}, //DOMINICA
429 {REG_DOMAIN_WORLD, {'D', 'O', ' '}}, //DOMINICAN REPUBLIC
430 {REG_DOMAIN_WORLD, {'D', 'Z', ' '}}, //ALGERIA
431 {REG_DOMAIN_WORLD, {'E', 'C', ' '}}, //ECUADOR
432 {REG_DOMAIN_HI_5GHZ, {'E', 'E', ' '}}, //ESTONIA
433 {REG_DOMAIN_WORLD, {'E', 'G', ' '}}, //EGYPT
434 {REG_DOMAIN_WORLD, {'E', 'H', ' '}}, //WESTERN SAHARA
435 {REG_DOMAIN_WORLD, {'E', 'R', ' '}}, //ERITREA
436 {REG_DOMAIN_ETSI, {'E', 'S', ' '}}, //SPAIN
437 {REG_DOMAIN_WORLD, {'E', 'T', ' '}}, //ETHIOPIA
438 {REG_DOMAIN_WORLD, {'F', 'I', ' '}}, //FINLAND
439 {REG_DOMAIN_WORLD, {'F', 'J', ' '}}, //FIJI
440 {REG_DOMAIN_WORLD, {'F', 'K', ' '}}, //FALKLAND ISLANDS (MALVINAS)
441 {REG_DOMAIN_WORLD, {'F', 'M', ' '}}, //MICRONESIA, FEDERATED STATES OF
442 {REG_DOMAIN_WORLD, {'F', 'O', ' '}}, //FAROE ISLANDS
443 {REG_DOMAIN_ETSI, {'F', 'R', ' '}}, //FRANCE
444 {REG_DOMAIN_WORLD, {'G', 'A', ' '}}, //GABON
445 {REG_DOMAIN_ETSI, {'G', 'B', ' '}}, //UNITED KINGDOM
446 {REG_DOMAIN_WORLD, {'G', 'D', ' '}}, //GRENADA
447 {REG_DOMAIN_HI_5GHZ, {'G', 'E', ' '}}, //GEORGIA
448 {REG_DOMAIN_WORLD, {'G', 'F', ' '}}, //FRENCH GUIANA
449 {REG_DOMAIN_ETSI, {'G', 'G', ' '}}, //GUERNSEY
450 {REG_DOMAIN_WORLD, {'G', 'H', ' '}}, //GHANA
451 {REG_DOMAIN_WORLD, {'G', 'I', ' '}}, //GIBRALTAR
452 {REG_DOMAIN_WORLD, {'G', 'L', ' '}}, //GREENLAND
453 {REG_DOMAIN_WORLD, {'G', 'M', ' '}}, //GAMBIA
454 {REG_DOMAIN_WORLD, {'G', 'N', ' '}}, //GUINEA
455 {REG_DOMAIN_WORLD, {'G', 'P', ' '}}, //GUADELOUPE
456 {REG_DOMAIN_WORLD, {'G', 'Q', ' '}}, //EQUATORIAL GUINEA
457 {REG_DOMAIN_ETSI, {'G', 'R', ' '}}, //GREECE
458 {REG_DOMAIN_WORLD, {'G', 'S', ' '}}, //SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS
459 {REG_DOMAIN_WORLD, {'G', 'T', ' '}}, //GUATEMALA
460 {REG_DOMAIN_WORLD, {'G', 'U', ' '}}, //GUAM
461 {REG_DOMAIN_WORLD, {'G', 'W', ' '}}, //GUINEA-BISSAU
462 {REG_DOMAIN_WORLD, {'G', 'Y', ' '}}, //GUYANA
463 {REG_DOMAIN_WORLD, {'H', 'K', ' '}}, //HONGKONG
464 {REG_DOMAIN_WORLD, {'H', 'M', ' '}}, //HEARD ISLAND AND MCDONALD ISLANDS
465 {REG_DOMAIN_WORLD, {'H', 'N', ' '}}, //HONDURAS
466 {REG_DOMAIN_HI_5GHZ, {'H', 'R', ' '}}, //CROATIA
467 {REG_DOMAIN_WORLD, {'H', 'T', ' '}}, //HAITI
468 {REG_DOMAIN_HI_5GHZ, {'H', 'U', ' '}}, //HUNGARY
469 {REG_DOMAIN_APAC, {'I', 'D', ' '}}, //INDONESIA
470 {REG_DOMAIN_ETSI, {'I', 'E', ' '}}, //IRELAND
471 {REG_DOMAIN_WORLD, {'I', 'L', ' '}}, //ISREAL
472 {REG_DOMAIN_ETSI, {'I', 'M', ' '}}, //ISLE OF MAN
473 {REG_DOMAIN_WORLD, {'I', 'N', ' '}}, //INDIA
474 {REG_DOMAIN_ETSI, {'I', 'O', ' '}}, //BRITISH INDIAN OCEAN TERRITORY
475 {REG_DOMAIN_WORLD, {'I', 'Q', ' '}}, //IRAQ
476 {REG_DOMAIN_WORLD, {'I', 'R', ' '}}, //IRAN, ISLAMIC REPUBLIC OF
477 {REG_DOMAIN_WORLD, {'I', 'S', ' '}}, //ICELAND
478 {REG_DOMAIN_ETSI, {'I', 'T', ' '}}, //ITALY
479 {REG_DOMAIN_ETSI, {'J', 'E', ' '}}, //JERSEY
480 {REG_DOMAIN_WORLD, {'J', 'M', ' '}}, //JAMAICA
481 {REG_DOMAIN_WORLD, {'J', 'O', ' '}}, //JORDAN
482 {REG_DOMAIN_JAPAN, {'J', 'P', ' '}}, //JAPAN
483 {REG_DOMAIN_WORLD, {'K', 'E', ' '}}, //KENYA
484 {REG_DOMAIN_WORLD, {'K', 'G', ' '}}, //KYRGYZSTAN
485 {REG_DOMAIN_WORLD, {'K', 'H', ' '}}, //CAMBODIA
486 {REG_DOMAIN_WORLD, {'K', 'I', ' '}}, //KIRIBATI
487 {REG_DOMAIN_WORLD, {'K', 'M', ' '}}, //COMOROS
488 {REG_DOMAIN_WORLD, {'K', 'N', ' '}}, //SAINT KITTS AND NEVIS
489 {REG_DOMAIN_KOREA, {'K', 'P', ' '}}, //KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF
490 {REG_DOMAIN_KOREA, {'K', 'R', ' '}}, //KOREA, REPUBLIC OF
491 {REG_DOMAIN_WORLD, {'K', 'W', ' '}}, //KUWAIT
492 {REG_DOMAIN_WORLD, {'K', 'Y', ' '}}, //CAYMAN ISLANDS
493 {REG_DOMAIN_WORLD, {'K', 'Z', ' '}}, //KAZAKHSTAN
494 {REG_DOMAIN_WORLD, {'L', 'A', ' '}}, //LAO PEOPLE'S DEMOCRATIC REPUBLIC
495 {REG_DOMAIN_WORLD, {'L', 'B', ' '}}, //LEBANON
496 {REG_DOMAIN_WORLD, {'L', 'C', ' '}}, //SAINT LUCIA
497 {REG_DOMAIN_ETSI, {'L', 'I', ' '}}, //LIECHTENSTEIN
498 {REG_DOMAIN_WORLD, {'L', 'K', ' '}}, //SRI LANKA
499 {REG_DOMAIN_WORLD, {'L', 'R', ' '}}, //LIBERIA
500 {REG_DOMAIN_WORLD, {'L', 'S', ' '}}, //LESOTHO
501 {REG_DOMAIN_HI_5GHZ, {'L', 'T', ' '}}, //LITHUANIA
502 {REG_DOMAIN_ETSI, {'L', 'U', ' '}}, //LUXEMBOURG
503 {REG_DOMAIN_HI_5GHZ, {'L', 'V', ' '}}, //LATVIA
504 {REG_DOMAIN_WORLD, {'L', 'Y', ' '}}, //LIBYAN ARAB JAMAHIRIYA
505 {REG_DOMAIN_WORLD, {'M', 'A', ' '}}, //MOROCCO
506 {REG_DOMAIN_ETSI, {'M', 'C', ' '}}, //MONACO
507 {REG_DOMAIN_WORLD, {'M', 'D', ' '}}, //MOLDOVA, REPUBLIC OF
508 {REG_DOMAIN_WORLD, {'M', 'E', ' '}}, //MONTENEGRO
509 {REG_DOMAIN_WORLD, {'M', 'G', ' '}}, //MADAGASCAR
510 {REG_DOMAIN_WORLD, {'M', 'H', ' '}}, //MARSHALL ISLANDS
511 {REG_DOMAIN_WORLD, {'M', 'K', ' '}}, //MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF
512 {REG_DOMAIN_WORLD, {'M', 'L', ' '}}, //MALI
513 {REG_DOMAIN_WORLD, {'M', 'M', ' '}}, //MYANMAR
514 {REG_DOMAIN_HI_5GHZ, {'M', 'N', ' '}}, //MONGOLIA
515 {REG_DOMAIN_WORLD, {'M', 'O', ' '}}, //MACAO
516 {REG_DOMAIN_WORLD, {'M', 'P', ' '}}, //NORTHERN MARIANA ISLANDS
517 {REG_DOMAIN_WORLD, {'M', 'Q', ' '}}, //MARTINIQUE
518 {REG_DOMAIN_WORLD, {'M', 'R', ' '}}, //MAURITANIA
519 {REG_DOMAIN_WORLD, {'M', 'S', ' '}}, //MONTSERRAT
520 {REG_DOMAIN_WORLD, {'M', 'T', ' '}}, //MALTA
521 {REG_DOMAIN_WORLD, {'M', 'U', ' '}}, //MAURITIUS
522 {REG_DOMAIN_WORLD, {'M', 'V', ' '}}, //MALDIVES
523 {REG_DOMAIN_WORLD, {'M', 'W', ' '}}, //MALAWI
524 {REG_DOMAIN_WORLD, {'M', 'X', ' '}}, //MEXICO
525 {REG_DOMAIN_HI_5GHZ, {'M', 'Y', ' '}}, //MALAYSIA
526 {REG_DOMAIN_WORLD, {'M', 'Z', ' '}}, //MOZAMBIQUE
527 {REG_DOMAIN_WORLD, {'N', 'A', ' '}}, //NAMIBIA
528 {REG_DOMAIN_WORLD, {'N', 'C', ' '}}, //NEW CALEDONIA
529 {REG_DOMAIN_WORLD, {'N', 'E', ' '}}, //NIGER
530 {REG_DOMAIN_WORLD, {'N', 'F', ' '}}, //NORFOLD ISLAND
531 {REG_DOMAIN_WORLD, {'N', 'G', ' '}}, //NIGERIA
532 {REG_DOMAIN_WORLD, {'N', 'I', ' '}}, //NICARAGUA
533 {REG_DOMAIN_ETSI, {'N', 'L', ' '}}, //NETHERLANDS
534 {REG_DOMAIN_WORLD, {'N', 'O', ' '}}, //NORWAY
535 {REG_DOMAIN_WORLD, {'N', 'P', ' '}}, //NEPAL
536 {REG_DOMAIN_WORLD, {'N', 'R', ' '}}, //NAURU
537 {REG_DOMAIN_WORLD, {'N', 'U', ' '}}, //NIUE
538 {REG_DOMAIN_ETSI, {'N', 'Z', ' '}}, //NEW ZEALAND
539 {REG_DOMAIN_WORLD, {'O', 'M', ' '}}, //OMAN
540 {REG_DOMAIN_WORLD, {'P', 'A', ' '}}, //PANAMA
541 {REG_DOMAIN_WORLD, {'P', 'E', ' '}}, //PERU
542 {REG_DOMAIN_WORLD, {'P', 'F', ' '}}, //FRENCH POLYNESIA
543 {REG_DOMAIN_WORLD, {'P', 'G', ' '}}, //PAPUA NEW GUINEA
544 {REG_DOMAIN_WORLD, {'P', 'H', ' '}}, //PHILIPPINES
545 {REG_DOMAIN_WORLD, {'P', 'K', ' '}}, //PAKISTAN
546 {REG_DOMAIN_WORLD, {'P', 'L', ' '}}, //POLAND
547 {REG_DOMAIN_WORLD, {'P', 'M', ' '}}, //SAINT PIERRE AND MIQUELON
548 {REG_DOMAIN_WORLD, {'P', 'N', ' '}}, //PITCAIRN
549 {REG_DOMAIN_FCC, {'P', 'R', ' '}}, //PUERTO RICO
550 {REG_DOMAIN_WORLD, {'P', 'S', ' '}}, //PALESTINIAN TERRITORY, OCCUPIED
551 {REG_DOMAIN_ETSI, {'P', 'T', ' '}}, //PORTUGAL
552 {REG_DOMAIN_WORLD, {'P', 'W', ' '}}, //PALAU
553 {REG_DOMAIN_WORLD, {'P', 'Y', ' '}}, //PARAGUAY
554 {REG_DOMAIN_WORLD, {'Q', 'A', ' '}}, //QATAR
555 {REG_DOMAIN_WORLD, {'R', 'E', ' '}}, //REUNION
556 {REG_DOMAIN_HI_5GHZ, {'R', 'O', ' '}}, //ROMANIA
557 {REG_DOMAIN_HI_5GHZ, {'R', 'S', ' '}}, //SERBIA
558 {REG_DOMAIN_WORLD, {'R', 'U', ' '}}, //RUSSIA
559 {REG_DOMAIN_WORLD, {'R', 'W', ' '}}, //RWANDA
560 {REG_DOMAIN_WORLD, {'S', 'A', ' '}}, //SAUDI ARABIA
561 {REG_DOMAIN_WORLD, {'S', 'B', ' '}}, //SOLOMON ISLANDS
562 {REG_DOMAIN_ETSI, {'S', 'C', ' '}}, //SEYCHELLES
563 {REG_DOMAIN_WORLD, {'S', 'D', ' '}}, //SUDAN
564 {REG_DOMAIN_ETSI, {'S', 'E', ' '}}, //SWEDEN
565 {REG_DOMAIN_APAC, {'S', 'G', ' '}}, //SINGAPORE
566 {REG_DOMAIN_WORLD, {'S', 'H', ' '}}, //SAINT HELENA
567 {REG_DOMAIN_HI_5GHZ, {'S', 'I', ' '}}, //SLOVENNIA
568 {REG_DOMAIN_WORLD, {'S', 'J', ' '}}, //SVALBARD AND JAN MAYEN
569 {REG_DOMAIN_HI_5GHZ, {'S', 'K', ' '}}, //SLOVAKIA
570 {REG_DOMAIN_WORLD, {'S', 'L', ' '}}, //SIERRA LEONE
571 {REG_DOMAIN_WORLD, {'S', 'M', ' '}}, //SAN MARINO
572 {REG_DOMAIN_WORLD, {'S', 'N', ' '}}, //SENEGAL
573 {REG_DOMAIN_WORLD, {'S', 'O', ' '}}, //SOMALIA
574 {REG_DOMAIN_WORLD, {'S', 'R', ' '}}, //SURINAME
575 {REG_DOMAIN_WORLD, {'S', 'T', ' '}}, //SAO TOME AND PRINCIPE
576 {REG_DOMAIN_WORLD, {'S', 'V', ' '}}, //EL SALVADOR
577 {REG_DOMAIN_WORLD, {'S', 'Y', ' '}}, //SYRIAN ARAB REPUBLIC
578 {REG_DOMAIN_WORLD, {'S', 'Z', ' '}}, //SWAZILAND
579 {REG_DOMAIN_WORLD, {'T', 'C', ' '}}, //TURKS AND CAICOS ISLANDS
580 {REG_DOMAIN_WORLD, {'T', 'D', ' '}}, //CHAD
581 {REG_DOMAIN_WORLD, {'T', 'F', ' '}}, //FRENCH SOUTHERN TERRITORIES
582 {REG_DOMAIN_WORLD, {'T', 'G', ' '}}, //TOGO
583 {REG_DOMAIN_WORLD, {'T', 'H', ' '}}, //THAILAND
584 {REG_DOMAIN_WORLD, {'T', 'J', ' '}}, //TAJIKISTAN
585 {REG_DOMAIN_WORLD, {'T', 'K', ' '}}, //TOKELAU
586 {REG_DOMAIN_WORLD, {'T', 'L', ' '}}, //TIMOR-LESTE
587 {REG_DOMAIN_WORLD, {'T', 'M', ' '}}, //TURKMENISTAN
588 {REG_DOMAIN_WORLD, {'T', 'N', ' '}}, //TUNISIA
589 {REG_DOMAIN_WORLD, {'T', 'O', ' '}}, //TONGA
590 {REG_DOMAIN_WORLD, {'T', 'R', ' '}}, //TURKEY
591 {REG_DOMAIN_WORLD, {'T', 'T', ' '}}, //TRINIDAD AND TOBAGO
592 {REG_DOMAIN_WORLD, {'T', 'V', ' '}}, //TUVALU
593 {REG_DOMAIN_HI_5GHZ, {'T', 'W', ' '}}, //TAIWAN, PROVINCE OF CHINA
594 {REG_DOMAIN_WORLD, {'T', 'Z', ' '}}, //TANZANIA, UNITED REPUBLIC OF
595 {REG_DOMAIN_HI_5GHZ, {'U', 'A', ' '}}, //UKRAINE
596 {REG_DOMAIN_WORLD, {'U', 'G', ' '}}, //UGANDA
597 {REG_DOMAIN_FCC, {'U', 'M', ' '}}, //UNITED STATES MINOR OUTLYING ISLANDS
598 {REG_DOMAIN_WORLD, {'U', 'Y', ' '}}, //URUGUAY
599 {REG_DOMAIN_HI_5GHZ, {'U', 'Z', ' '}}, //UZBEKISTAN
600 {REG_DOMAIN_ETSI, {'V', 'A', ' '}}, //HOLY SEE (VATICAN CITY STATE)
601 {REG_DOMAIN_WORLD, {'V', 'C', ' '}}, //SAINT VINCENT AND THE GRENADINES
602 {REG_DOMAIN_HI_5GHZ, {'V', 'E', ' '}}, //VENEZUELA
603 {REG_DOMAIN_ETSI, {'V', 'G', ' '}}, //VIRGIN ISLANDS, BRITISH
604 {REG_DOMAIN_FCC, {'V', 'I', ' '}}, //VIRGIN ISLANDS, US
605 {REG_DOMAIN_WORLD, {'V', 'N', ' '}}, //VIET NAM
606 {REG_DOMAIN_WORLD, {'V', 'U', ' '}}, //VANUATU
607 {REG_DOMAIN_WORLD, {'W', 'F', ' '}}, //WALLIS AND FUTUNA
608 {REG_DOMAIN_WORLD, {'W', 'S', ' '}}, //SOMOA
609 {REG_DOMAIN_WORLD, {'Y', 'E', ' '}}, //YEMEN
610 {REG_DOMAIN_WORLD, {'Y', 'T', ' '}}, //MAYOTTE
611 {REG_DOMAIN_WORLD, {'Z', 'A', ' '}}, //SOUTH AFRICA
612 {REG_DOMAIN_WORLD, {'Z', 'M', ' '}}, //ZAMBIA
613 {REG_DOMAIN_WORLD, {'Z', 'W', ' '}}, //ZIMBABWE
614
615 {REG_DOMAIN_KOREA, {'K', '1', ' '}}, //Korea alternate 1
616 {REG_DOMAIN_KOREA, {'K', '2', ' '}}, //Korea alternate 2
617 {REG_DOMAIN_KOREA, {'K', '3', ' '}}, //Korea alternate 3
618 {REG_DOMAIN_KOREA, {'K', '4', ' '}}, //Korea alternate 4
619};
620
621
622//The channels listed here doesn't mean they are valid channels for certain domain. They are here only to present
623//whether they should be passive scanned.
624tCsrDomainChnInfo gCsrDomainChnInfo[NUM_REG_DOMAINS] =
625{
626 //REG_DOMAIN_FCC
627 {
628 REG_DOMAIN_FCC,
629 45, //Num channels
630 //Channels
631 {
632 //5GHz
633 //5180 - 5240
634 {36, eSIR_ACTIVE_SCAN},
635 {40, eSIR_ACTIVE_SCAN},
636 {44, eSIR_ACTIVE_SCAN},
637 {48, eSIR_ACTIVE_SCAN},
638 //5250 to 5350
639 {52, eSIR_PASSIVE_SCAN},
640 {56, eSIR_PASSIVE_SCAN},
641 {60, eSIR_PASSIVE_SCAN},
642 {64, eSIR_PASSIVE_SCAN},
643 //5470 to 5725
644 {100, eSIR_PASSIVE_SCAN},
645 {104, eSIR_PASSIVE_SCAN},
646 {108, eSIR_PASSIVE_SCAN},
647 {112, eSIR_PASSIVE_SCAN},
648 {116, eSIR_PASSIVE_SCAN},
649 {120, eSIR_PASSIVE_SCAN},
650 {124, eSIR_PASSIVE_SCAN},
651 {128, eSIR_PASSIVE_SCAN},
652 {132, eSIR_PASSIVE_SCAN},
653 {136, eSIR_PASSIVE_SCAN},
654 {140, eSIR_PASSIVE_SCAN},
655 //5745 - 5825
656 {149, eSIR_ACTIVE_SCAN},
657 {153, eSIR_ACTIVE_SCAN},
658 {157, eSIR_ACTIVE_SCAN},
659 {161, eSIR_ACTIVE_SCAN},
660 {165, eSIR_ACTIVE_SCAN},
661 //4.9GHz
662 //4920 - 5080
663 {240, eSIR_ACTIVE_SCAN},
664 {244, eSIR_ACTIVE_SCAN},
665 {248, eSIR_ACTIVE_SCAN},
666 {252, eSIR_ACTIVE_SCAN},
667 {208, eSIR_ACTIVE_SCAN},
668 {212, eSIR_ACTIVE_SCAN},
669 {216, eSIR_ACTIVE_SCAN},
670 //2,4GHz
671 {1, eSIR_ACTIVE_SCAN},
672 {2, eSIR_ACTIVE_SCAN},
673 {3, eSIR_ACTIVE_SCAN},
674 {4, eSIR_ACTIVE_SCAN},
675 {5, eSIR_ACTIVE_SCAN},
676 {6, eSIR_ACTIVE_SCAN},
677 {7, eSIR_ACTIVE_SCAN},
678 {8, eSIR_ACTIVE_SCAN},
679 {9, eSIR_ACTIVE_SCAN},
680 {10, eSIR_ACTIVE_SCAN},
681 {11, eSIR_ACTIVE_SCAN},
682 {12, eSIR_ACTIVE_SCAN},
683 {13, eSIR_ACTIVE_SCAN},
684 {14, eSIR_ACTIVE_SCAN},
685 }
686 },
687 //REG_DOMAIN_ETSI
688 {
689 REG_DOMAIN_ETSI,
690 45, //Num channels
691 //Channels
692 {
693 //5GHz
694 //5180 - 5240
695 {36, eSIR_ACTIVE_SCAN},
696 {40, eSIR_ACTIVE_SCAN},
697 {44, eSIR_ACTIVE_SCAN},
698 {48, eSIR_ACTIVE_SCAN},
699 //5250 to 5350
700 {52, eSIR_PASSIVE_SCAN},
701 {56, eSIR_PASSIVE_SCAN},
702 {60, eSIR_PASSIVE_SCAN},
703 {64, eSIR_PASSIVE_SCAN},
704 //5470 to 5725
705 {100, eSIR_PASSIVE_SCAN},
706 {104, eSIR_PASSIVE_SCAN},
707 {108, eSIR_PASSIVE_SCAN},
708 {112, eSIR_PASSIVE_SCAN},
709 {116, eSIR_PASSIVE_SCAN},
710 {120, eSIR_PASSIVE_SCAN},
711 {124, eSIR_PASSIVE_SCAN},
712 {128, eSIR_PASSIVE_SCAN},
713 {132, eSIR_PASSIVE_SCAN},
714 {136, eSIR_PASSIVE_SCAN},
715 {140, eSIR_PASSIVE_SCAN},
716 //5745 - 5825
717 {149, eSIR_ACTIVE_SCAN},
718 {153, eSIR_ACTIVE_SCAN},
719 {157, eSIR_ACTIVE_SCAN},
720 {161, eSIR_ACTIVE_SCAN},
721 {165, eSIR_ACTIVE_SCAN},
722 //4.9GHz
723 //4920 - 5080
724 {240, eSIR_ACTIVE_SCAN},
725 {244, eSIR_ACTIVE_SCAN},
726 {248, eSIR_ACTIVE_SCAN},
727 {252, eSIR_ACTIVE_SCAN},
728 {208, eSIR_ACTIVE_SCAN},
729 {212, eSIR_ACTIVE_SCAN},
730 {216, eSIR_ACTIVE_SCAN},
731 //2,4GHz
732 {1, eSIR_ACTIVE_SCAN},
733 {2, eSIR_ACTIVE_SCAN},
734 {3, eSIR_ACTIVE_SCAN},
735 {4, eSIR_ACTIVE_SCAN},
736 {5, eSIR_ACTIVE_SCAN},
737 {6, eSIR_ACTIVE_SCAN},
738 {7, eSIR_ACTIVE_SCAN},
739 {8, eSIR_ACTIVE_SCAN},
740 {9, eSIR_ACTIVE_SCAN},
741 {10, eSIR_ACTIVE_SCAN},
742 {11, eSIR_ACTIVE_SCAN},
743 {12, eSIR_ACTIVE_SCAN},
744 {13, eSIR_ACTIVE_SCAN},
745 {14, eSIR_ACTIVE_SCAN},
746 }
747 },
748 //REG_DOMAIN_JAPAN
749 {
750 REG_DOMAIN_JAPAN,
751 45, //Num channels
752 //Channels
753 {
754 //5GHz
755 //5180 - 5240
756 {36, eSIR_ACTIVE_SCAN},
757 {40, eSIR_ACTIVE_SCAN},
758 {44, eSIR_ACTIVE_SCAN},
759 {48, eSIR_ACTIVE_SCAN},
760 //5250 to 5350
761 {52, eSIR_PASSIVE_SCAN},
762 {56, eSIR_PASSIVE_SCAN},
763 {60, eSIR_PASSIVE_SCAN},
764 {64, eSIR_PASSIVE_SCAN},
765 //5470 to 5725
766 {100, eSIR_PASSIVE_SCAN},
767 {104, eSIR_PASSIVE_SCAN},
768 {108, eSIR_PASSIVE_SCAN},
769 {112, eSIR_PASSIVE_SCAN},
770 {116, eSIR_PASSIVE_SCAN},
771 {120, eSIR_PASSIVE_SCAN},
772 {124, eSIR_PASSIVE_SCAN},
773 {128, eSIR_PASSIVE_SCAN},
774 {132, eSIR_PASSIVE_SCAN},
775 {136, eSIR_PASSIVE_SCAN},
776 {140, eSIR_PASSIVE_SCAN},
777 //5745 - 5825
778 {149, eSIR_ACTIVE_SCAN},
779 {153, eSIR_ACTIVE_SCAN},
780 {157, eSIR_ACTIVE_SCAN},
781 {161, eSIR_ACTIVE_SCAN},
782 {165, eSIR_ACTIVE_SCAN},
783 //4.9GHz
784 //4920 - 5080
785 {240, eSIR_ACTIVE_SCAN},
786 {244, eSIR_ACTIVE_SCAN},
787 {248, eSIR_ACTIVE_SCAN},
788 {252, eSIR_ACTIVE_SCAN},
789 {208, eSIR_ACTIVE_SCAN},
790 {212, eSIR_ACTIVE_SCAN},
791 {216, eSIR_ACTIVE_SCAN},
792 //2,4GHz
793 {1, eSIR_ACTIVE_SCAN},
794 {2, eSIR_ACTIVE_SCAN},
795 {3, eSIR_ACTIVE_SCAN},
796 {4, eSIR_ACTIVE_SCAN},
797 {5, eSIR_ACTIVE_SCAN},
798 {6, eSIR_ACTIVE_SCAN},
799 {7, eSIR_ACTIVE_SCAN},
800 {8, eSIR_ACTIVE_SCAN},
801 {9, eSIR_ACTIVE_SCAN},
802 {10, eSIR_ACTIVE_SCAN},
803 {11, eSIR_ACTIVE_SCAN},
804 {12, eSIR_ACTIVE_SCAN},
805 {13, eSIR_ACTIVE_SCAN},
806 {14, eSIR_ACTIVE_SCAN},
807 }
808 },
809 //REG_DOMAIN_WORLD
810 {
811 REG_DOMAIN_WORLD,
812 45, //Num channels
813 //Channels
814 {
815 //5GHz
816 //5180 - 5240
817 {36, eSIR_ACTIVE_SCAN},
818 {40, eSIR_ACTIVE_SCAN},
819 {44, eSIR_ACTIVE_SCAN},
820 {48, eSIR_ACTIVE_SCAN},
821 //5250 to 5350
822 {52, eSIR_ACTIVE_SCAN},
823 {56, eSIR_ACTIVE_SCAN},
824 {60, eSIR_ACTIVE_SCAN},
825 {64, eSIR_ACTIVE_SCAN},
826 //5470 to 5725
827 {100, eSIR_ACTIVE_SCAN},
828 {104, eSIR_ACTIVE_SCAN},
829 {108, eSIR_ACTIVE_SCAN},
830 {112, eSIR_ACTIVE_SCAN},
831 {116, eSIR_ACTIVE_SCAN},
832 {120, eSIR_ACTIVE_SCAN},
833 {124, eSIR_ACTIVE_SCAN},
834 {128, eSIR_ACTIVE_SCAN},
835 {132, eSIR_ACTIVE_SCAN},
836 {136, eSIR_ACTIVE_SCAN},
837 {140, eSIR_ACTIVE_SCAN},
838 //5745 - 5825
839 {149, eSIR_ACTIVE_SCAN},
840 {153, eSIR_ACTIVE_SCAN},
841 {157, eSIR_ACTIVE_SCAN},
842 {161, eSIR_ACTIVE_SCAN},
843 {165, eSIR_ACTIVE_SCAN},
844 //4.9GHz
845 //4920 - 5080
846 {240, eSIR_ACTIVE_SCAN},
847 {244, eSIR_ACTIVE_SCAN},
848 {248, eSIR_ACTIVE_SCAN},
849 {252, eSIR_ACTIVE_SCAN},
850 {208, eSIR_ACTIVE_SCAN},
851 {212, eSIR_ACTIVE_SCAN},
852 {216, eSIR_ACTIVE_SCAN},
853 //2,4GHz
854 {1, eSIR_ACTIVE_SCAN},
855 {2, eSIR_ACTIVE_SCAN},
856 {3, eSIR_ACTIVE_SCAN},
857 {4, eSIR_ACTIVE_SCAN},
858 {5, eSIR_ACTIVE_SCAN},
859 {6, eSIR_ACTIVE_SCAN},
860 {7, eSIR_ACTIVE_SCAN},
861 {8, eSIR_ACTIVE_SCAN},
862 {9, eSIR_ACTIVE_SCAN},
863 {10, eSIR_ACTIVE_SCAN},
864 {11, eSIR_ACTIVE_SCAN},
865 {12, eSIR_ACTIVE_SCAN},
866 {13, eSIR_ACTIVE_SCAN},
867 {14, eSIR_ACTIVE_SCAN},
868 }
869 },
870 //REG_DOMAIN_N_AMER_EXC_FCC
871 {
872 REG_DOMAIN_N_AMER_EXC_FCC,
873 45, //Num channels
874 //Channels
875 {
876 //5GHz
877 //5180 - 5240
878 {36, eSIR_ACTIVE_SCAN},
879 {40, eSIR_ACTIVE_SCAN},
880 {44, eSIR_ACTIVE_SCAN},
881 {48, eSIR_ACTIVE_SCAN},
882 //5250 to 5350
883 {52, eSIR_PASSIVE_SCAN},
884 {56, eSIR_PASSIVE_SCAN},
885 {60, eSIR_PASSIVE_SCAN},
886 {64, eSIR_PASSIVE_SCAN},
887 //5470 to 5725
888 {100, eSIR_ACTIVE_SCAN},
889 {104, eSIR_ACTIVE_SCAN},
890 {108, eSIR_ACTIVE_SCAN},
891 {112, eSIR_ACTIVE_SCAN},
892 {116, eSIR_ACTIVE_SCAN},
893 {120, eSIR_ACTIVE_SCAN},
894 {124, eSIR_ACTIVE_SCAN},
895 {128, eSIR_ACTIVE_SCAN},
896 {132, eSIR_ACTIVE_SCAN},
897 {136, eSIR_ACTIVE_SCAN},
898 {140, eSIR_ACTIVE_SCAN},
899 //5745 - 5825
900 {149, eSIR_ACTIVE_SCAN},
901 {153, eSIR_ACTIVE_SCAN},
902 {157, eSIR_ACTIVE_SCAN},
903 {161, eSIR_ACTIVE_SCAN},
904 {165, eSIR_ACTIVE_SCAN},
905 //4.9GHz
906 //4920 - 5080
907 {240, eSIR_ACTIVE_SCAN},
908 {244, eSIR_ACTIVE_SCAN},
909 {248, eSIR_ACTIVE_SCAN},
910 {252, eSIR_ACTIVE_SCAN},
911 {208, eSIR_ACTIVE_SCAN},
912 {212, eSIR_ACTIVE_SCAN},
913 {216, eSIR_ACTIVE_SCAN},
914 //2,4GHz
915 {1, eSIR_ACTIVE_SCAN},
916 {2, eSIR_ACTIVE_SCAN},
917 {3, eSIR_ACTIVE_SCAN},
918 {4, eSIR_ACTIVE_SCAN},
919 {5, eSIR_ACTIVE_SCAN},
920 {6, eSIR_ACTIVE_SCAN},
921 {7, eSIR_ACTIVE_SCAN},
922 {8, eSIR_ACTIVE_SCAN},
923 {9, eSIR_ACTIVE_SCAN},
924 {10, eSIR_ACTIVE_SCAN},
925 {11, eSIR_ACTIVE_SCAN},
926 {12, eSIR_ACTIVE_SCAN},
927 {13, eSIR_ACTIVE_SCAN},
928 {14, eSIR_ACTIVE_SCAN},
929 }
930 },
931 //REG_DOMAIN_APAC
932 {
933 REG_DOMAIN_APAC,
934 45, //Num channels
935 //Channels
936 {
937 //5GHz
938 //5180 - 5240
939 {36, eSIR_ACTIVE_SCAN},
940 {40, eSIR_ACTIVE_SCAN},
941 {44, eSIR_ACTIVE_SCAN},
942 {48, eSIR_ACTIVE_SCAN},
943 //5250 to 5350
944 {52, eSIR_PASSIVE_SCAN},
945 {56, eSIR_PASSIVE_SCAN},
946 {60, eSIR_PASSIVE_SCAN},
947 {64, eSIR_PASSIVE_SCAN},
948 //5470 to 5725
949 {100, eSIR_ACTIVE_SCAN},
950 {104, eSIR_ACTIVE_SCAN},
951 {108, eSIR_ACTIVE_SCAN},
952 {112, eSIR_ACTIVE_SCAN},
953 {116, eSIR_ACTIVE_SCAN},
954 {120, eSIR_ACTIVE_SCAN},
955 {124, eSIR_ACTIVE_SCAN},
956 {128, eSIR_ACTIVE_SCAN},
957 {132, eSIR_ACTIVE_SCAN},
958 {136, eSIR_ACTIVE_SCAN},
959 {140, eSIR_ACTIVE_SCAN},
960 //5745 - 5825
961 {149, eSIR_ACTIVE_SCAN},
962 {153, eSIR_ACTIVE_SCAN},
963 {157, eSIR_ACTIVE_SCAN},
964 {161, eSIR_ACTIVE_SCAN},
965 {165, eSIR_ACTIVE_SCAN},
966 //4.9GHz
967 //4920 - 5080
968 {240, eSIR_ACTIVE_SCAN},
969 {244, eSIR_ACTIVE_SCAN},
970 {248, eSIR_ACTIVE_SCAN},
971 {252, eSIR_ACTIVE_SCAN},
972 {208, eSIR_ACTIVE_SCAN},
973 {212, eSIR_ACTIVE_SCAN},
974 {216, eSIR_ACTIVE_SCAN},
975 //2,4GHz
976 {1, eSIR_ACTIVE_SCAN},
977 {2, eSIR_ACTIVE_SCAN},
978 {3, eSIR_ACTIVE_SCAN},
979 {4, eSIR_ACTIVE_SCAN},
980 {5, eSIR_ACTIVE_SCAN},
981 {6, eSIR_ACTIVE_SCAN},
982 {7, eSIR_ACTIVE_SCAN},
983 {8, eSIR_ACTIVE_SCAN},
984 {9, eSIR_ACTIVE_SCAN},
985 {10, eSIR_ACTIVE_SCAN},
986 {11, eSIR_ACTIVE_SCAN},
987 {12, eSIR_ACTIVE_SCAN},
988 {13, eSIR_ACTIVE_SCAN},
989 {14, eSIR_ACTIVE_SCAN},
990 }
991 },
992 //REG_DOMAIN_KOREA
993 {
994 REG_DOMAIN_KOREA,
995 45, //Num channels
996 //Channels
997 {
998 //5GHz
999 //5180 - 5240
1000 {36, eSIR_ACTIVE_SCAN},
1001 {40, eSIR_ACTIVE_SCAN},
1002 {44, eSIR_ACTIVE_SCAN},
1003 {48, eSIR_ACTIVE_SCAN},
1004 //5250 to 5350
1005 {52, eSIR_PASSIVE_SCAN},
1006 {56, eSIR_PASSIVE_SCAN},
1007 {60, eSIR_PASSIVE_SCAN},
1008 {64, eSIR_PASSIVE_SCAN},
1009 //5470 to 5725
1010 {100, eSIR_PASSIVE_SCAN},
1011 {104, eSIR_PASSIVE_SCAN},
1012 {108, eSIR_PASSIVE_SCAN},
1013 {112, eSIR_PASSIVE_SCAN},
1014 {116, eSIR_PASSIVE_SCAN},
1015 {120, eSIR_PASSIVE_SCAN},
1016 {124, eSIR_PASSIVE_SCAN},
1017 {128, eSIR_PASSIVE_SCAN},
1018 {132, eSIR_PASSIVE_SCAN},
1019 {136, eSIR_PASSIVE_SCAN},
1020 {140, eSIR_PASSIVE_SCAN},
1021 //5745 - 5825
1022 {149, eSIR_ACTIVE_SCAN},
1023 {153, eSIR_ACTIVE_SCAN},
1024 {157, eSIR_ACTIVE_SCAN},
1025 {161, eSIR_ACTIVE_SCAN},
1026 {165, eSIR_ACTIVE_SCAN},
1027 //4.9GHz
1028 //4920 - 5080
1029 {240, eSIR_ACTIVE_SCAN},
1030 {244, eSIR_ACTIVE_SCAN},
1031 {248, eSIR_ACTIVE_SCAN},
1032 {252, eSIR_ACTIVE_SCAN},
1033 {208, eSIR_ACTIVE_SCAN},
1034 {212, eSIR_ACTIVE_SCAN},
1035 {216, eSIR_ACTIVE_SCAN},
1036 //2,4GHz
1037 {1, eSIR_ACTIVE_SCAN},
1038 {2, eSIR_ACTIVE_SCAN},
1039 {3, eSIR_ACTIVE_SCAN},
1040 {4, eSIR_ACTIVE_SCAN},
1041 {5, eSIR_ACTIVE_SCAN},
1042 {6, eSIR_ACTIVE_SCAN},
1043 {7, eSIR_ACTIVE_SCAN},
1044 {8, eSIR_ACTIVE_SCAN},
1045 {9, eSIR_ACTIVE_SCAN},
1046 {10, eSIR_ACTIVE_SCAN},
1047 {11, eSIR_ACTIVE_SCAN},
1048 {12, eSIR_ACTIVE_SCAN},
1049 {13, eSIR_ACTIVE_SCAN},
1050 {14, eSIR_ACTIVE_SCAN},
1051 }
1052 },
1053 //REG_DOMAIN_HI_5GHZ
1054 {
1055 REG_DOMAIN_HI_5GHZ,
1056 45, //Num channels
1057 //Channels
1058 {
1059 //5GHz
1060 //5180 - 5240
1061 {36, eSIR_ACTIVE_SCAN},
1062 {40, eSIR_ACTIVE_SCAN},
1063 {44, eSIR_ACTIVE_SCAN},
1064 {48, eSIR_ACTIVE_SCAN},
1065 //5250 to 5350
1066 {52, eSIR_ACTIVE_SCAN},
1067 {56, eSIR_ACTIVE_SCAN},
1068 {60, eSIR_ACTIVE_SCAN},
1069 {64, eSIR_ACTIVE_SCAN},
1070 //5470 to 5725
1071 {100, eSIR_ACTIVE_SCAN},
1072 {104, eSIR_ACTIVE_SCAN},
1073 {108, eSIR_ACTIVE_SCAN},
1074 {112, eSIR_ACTIVE_SCAN},
1075 {116, eSIR_ACTIVE_SCAN},
1076 {120, eSIR_ACTIVE_SCAN},
1077 {124, eSIR_ACTIVE_SCAN},
1078 {128, eSIR_ACTIVE_SCAN},
1079 {132, eSIR_ACTIVE_SCAN},
1080 {136, eSIR_ACTIVE_SCAN},
1081 {140, eSIR_ACTIVE_SCAN},
1082 //5745 - 5825
1083 {149, eSIR_ACTIVE_SCAN},
1084 {153, eSIR_ACTIVE_SCAN},
1085 {157, eSIR_ACTIVE_SCAN},
1086 {161, eSIR_ACTIVE_SCAN},
1087 {165, eSIR_ACTIVE_SCAN},
1088 //4.9GHz
1089 //4920 - 5080
1090 {240, eSIR_ACTIVE_SCAN},
1091 {244, eSIR_ACTIVE_SCAN},
1092 {248, eSIR_ACTIVE_SCAN},
1093 {252, eSIR_ACTIVE_SCAN},
1094 {208, eSIR_ACTIVE_SCAN},
1095 {212, eSIR_ACTIVE_SCAN},
1096 {216, eSIR_ACTIVE_SCAN},
1097 //2,4GHz
1098 {1, eSIR_ACTIVE_SCAN},
1099 {2, eSIR_ACTIVE_SCAN},
1100 {3, eSIR_ACTIVE_SCAN},
1101 {4, eSIR_ACTIVE_SCAN},
1102 {5, eSIR_ACTIVE_SCAN},
1103 {6, eSIR_ACTIVE_SCAN},
1104 {7, eSIR_ACTIVE_SCAN},
1105 {8, eSIR_ACTIVE_SCAN},
1106 {9, eSIR_ACTIVE_SCAN},
1107 {10, eSIR_ACTIVE_SCAN},
1108 {11, eSIR_ACTIVE_SCAN},
1109 {12, eSIR_ACTIVE_SCAN},
1110 {13, eSIR_ACTIVE_SCAN},
1111 {14, eSIR_ACTIVE_SCAN},
1112 }
1113 },
1114 //REG_DOMAIN_NO_5GHZ
1115 {
1116 REG_DOMAIN_NO_5GHZ,
1117 45, //Num channels
1118 //Channels
1119 {
1120 //5GHz
1121 //5180 - 5240
1122 {36, eSIR_ACTIVE_SCAN},
1123 {40, eSIR_ACTIVE_SCAN},
1124 {44, eSIR_ACTIVE_SCAN},
1125 {48, eSIR_ACTIVE_SCAN},
1126 //5250 to 5350
1127 {52, eSIR_ACTIVE_SCAN},
1128 {56, eSIR_ACTIVE_SCAN},
1129 {60, eSIR_ACTIVE_SCAN},
1130 {64, eSIR_ACTIVE_SCAN},
1131 //5470 to 5725
1132 {100, eSIR_ACTIVE_SCAN},
1133 {104, eSIR_ACTIVE_SCAN},
1134 {108, eSIR_ACTIVE_SCAN},
1135 {112, eSIR_ACTIVE_SCAN},
1136 {116, eSIR_ACTIVE_SCAN},
1137 {120, eSIR_ACTIVE_SCAN},
1138 {124, eSIR_ACTIVE_SCAN},
1139 {128, eSIR_ACTIVE_SCAN},
1140 {132, eSIR_ACTIVE_SCAN},
1141 {136, eSIR_ACTIVE_SCAN},
1142 {140, eSIR_ACTIVE_SCAN},
1143 //5745 - 5825
1144 {149, eSIR_ACTIVE_SCAN},
1145 {153, eSIR_ACTIVE_SCAN},
1146 {157, eSIR_ACTIVE_SCAN},
1147 {161, eSIR_ACTIVE_SCAN},
1148 {165, eSIR_ACTIVE_SCAN},
1149 //4.9GHz
1150 //4920 - 5080
1151 {240, eSIR_ACTIVE_SCAN},
1152 {244, eSIR_ACTIVE_SCAN},
1153 {248, eSIR_ACTIVE_SCAN},
1154 {252, eSIR_ACTIVE_SCAN},
1155 {208, eSIR_ACTIVE_SCAN},
1156 {212, eSIR_ACTIVE_SCAN},
1157 {216, eSIR_ACTIVE_SCAN},
1158 //2,4GHz
1159 {1, eSIR_ACTIVE_SCAN},
1160 {2, eSIR_ACTIVE_SCAN},
1161 {3, eSIR_ACTIVE_SCAN},
1162 {4, eSIR_ACTIVE_SCAN},
1163 {5, eSIR_ACTIVE_SCAN},
1164 {6, eSIR_ACTIVE_SCAN},
1165 {7, eSIR_ACTIVE_SCAN},
1166 {8, eSIR_ACTIVE_SCAN},
1167 {9, eSIR_ACTIVE_SCAN},
1168 {10, eSIR_ACTIVE_SCAN},
1169 {11, eSIR_ACTIVE_SCAN},
1170 {12, eSIR_ACTIVE_SCAN},
1171 {13, eSIR_ACTIVE_SCAN},
1172 {14, eSIR_ACTIVE_SCAN},
1173 }
1174 },
1175};
1176#endif
1177
1178extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
1179
Jeff Johnson295189b2012-06-20 16:38:30 -07001180////////////////////////////////////////////////////////////////////////
1181
1182/**
1183 * \var gPhyRatesSuppt
1184 *
1185 * \brief Rate support lookup table
1186 *
1187 *
1188 * This is a lookup table indexing rates & configuration parameters to
1189 * support. Given a rate (in unites of 0.5Mpbs) & three booleans (MIMO
1190 * Enabled, Channel Bonding Enabled, & Concatenation Enabled), one can
1191 * determine whether the given rate is supported by computing two
1192 * indices. The first maps the rate to table row as indicated below
1193 * (i.e. eHddSuppRate_6Mbps maps to row zero, eHddSuppRate_9Mbps to row
1194 * 1, and so on). Index two can be computed like so:
1195 *
1196 * \code
1197 idx2 = ( fEsf ? 0x4 : 0x0 ) |
1198 ( fCb ? 0x2 : 0x0 ) |
1199 ( fMimo ? 0x1 : 0x0 );
1200 * \endcode
1201 *
1202 *
1203 * Given that:
1204 *
1205 \code
1206 fSupported = gPhyRatesSuppt[idx1][idx2];
1207 \endcode
1208 *
1209 *
1210 * This table is based on the document "PHY Supported Rates.doc". This
1211 * table is permissive in that a rate is reflected as being supported
1212 * even when turning off an enabled feature would be required. For
1213 * instance, "PHY Supported Rates" lists 42Mpbs as unsupported when CB,
1214 * ESF, & MIMO are all on. However, if we turn off either of CB or
1215 * MIMO, it then becomes supported. Therefore, we mark it as supported
1216 * even in index 7 of this table.
1217 *
1218 *
1219 */
1220
1221static const tANI_BOOLEAN gPhyRatesSuppt[24][8] = {
1222
1223 // SSF SSF SSF SSF ESF ESF ESF ESF
1224 // SIMO MIMO SIMO MIMO SIMO MIMO SIMO MIMO
1225 // No CB No CB CB CB No CB No CB CB CB
1226 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 6Mbps
1227 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 9Mbps
1228 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 12Mbps
1229 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 18Mbps
1230 { FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE }, // 20Mbps
1231 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 24Mbps
1232 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 36Mbps
1233 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 40Mbps
1234 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 42Mbps
1235 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 48Mbps
1236 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 54Mbps
1237 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 72Mbps
1238 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 80Mbps
1239 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 84Mbps
1240 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 96Mbps
1241 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 108Mbps
1242 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 120Mbps
1243 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 126Mbps
1244 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 144Mbps
1245 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 160Mbps
1246 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 168Mbps
1247 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 192Mbps
1248 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 216Mbps
1249 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 240Mbps
1250
1251};
1252
1253#define CASE_RETURN_STR(n) case (n): return (#n)
1254
1255const char *
1256get_eRoamCmdStatus_str(eRoamCmdStatus val)
1257{
1258 switch (val)
1259 {
1260 CASE_RETURN_STR(eCSR_ROAM_CANCELLED);
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05301261 CASE_RETURN_STR(eCSR_ROAM_FAILED);
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 CASE_RETURN_STR(eCSR_ROAM_ROAMING_START);
1263 CASE_RETURN_STR(eCSR_ROAM_ROAMING_COMPLETION);
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05301264 CASE_RETURN_STR(eCSR_ROAM_CONNECT_COMPLETION);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_START);
1266 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_COMPLETION);
1267 CASE_RETURN_STR(eCSR_ROAM_DISASSOCIATED);
1268 CASE_RETURN_STR(eCSR_ROAM_SHOULD_ROAM);
1269 CASE_RETURN_STR(eCSR_ROAM_SCAN_FOUND_NEW_BSS);
1270 CASE_RETURN_STR(eCSR_ROAM_LOSTLINK);
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05301271 CASE_RETURN_STR(eCSR_ROAM_LOSTLINK_DETECTED);
1272 CASE_RETURN_STR(eCSR_ROAM_MIC_ERROR_IND);
1273 CASE_RETURN_STR(eCSR_ROAM_IBSS_IND);
1274 CASE_RETURN_STR(eCSR_ROAM_CONNECT_STATUS_UPDATE);
1275 CASE_RETURN_STR(eCSR_ROAM_GEN_INFO);
1276 CASE_RETURN_STR(eCSR_ROAM_SET_KEY_COMPLETE);
1277 CASE_RETURN_STR(eCSR_ROAM_REMOVE_KEY_COMPLETE);
1278 CASE_RETURN_STR(eCSR_ROAM_IBSS_LEAVE);
1279 CASE_RETURN_STR(eCSR_ROAM_WDS_IND);
1280 CASE_RETURN_STR(eCSR_ROAM_INFRA_IND);
1281 CASE_RETURN_STR(eCSR_ROAM_WPS_PBC_PROBE_REQ_IND);
1282#ifdef WLAN_FEATURE_VOWIFI_11R
1283 CASE_RETURN_STR(eCSR_ROAM_FT_RESPONSE);
1284#endif
1285 CASE_RETURN_STR(eCSR_ROAM_FT_START);
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05301286 CASE_RETURN_STR(eCSR_ROAM_REMAIN_CHAN_READY);
1287 CASE_RETURN_STR(eCSR_ROAM_SEND_ACTION_CNF);
1288 CASE_RETURN_STR(eCSR_ROAM_SESSION_OPENED);
1289 CASE_RETURN_STR(eCSR_ROAM_FT_REASSOC_FAILED);
1290#ifdef FEATURE_WLAN_LFR
1291 CASE_RETURN_STR(eCSR_ROAM_PMK_NOTIFY);
1292#endif
1293#ifdef FEATURE_WLAN_LFR_METRICS
1294 CASE_RETURN_STR(eCSR_ROAM_PREAUTH_INIT_NOTIFY);
1295 CASE_RETURN_STR(eCSR_ROAM_PREAUTH_STATUS_SUCCESS);
1296 CASE_RETURN_STR(eCSR_ROAM_PREAUTH_STATUS_FAILURE);
1297 CASE_RETURN_STR(eCSR_ROAM_HANDOVER_SUCCESS);
1298#endif
1299#ifdef FEATURE_WLAN_TDLS
1300 CASE_RETURN_STR(eCSR_ROAM_TDLS_STATUS_UPDATE);
1301 CASE_RETURN_STR(eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND);
1302#endif
1303 CASE_RETURN_STR(eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS);
1304 CASE_RETURN_STR(eCSR_ROAM_SEND_P2P_STOP_BSS);
1305#ifdef WLAN_FEATURE_11W
1306 CASE_RETURN_STR(eCSR_ROAM_UNPROT_MGMT_FRAME_IND);
1307#endif
1308#ifdef WLAN_FEATURE_RMC
1309 CASE_RETURN_STR(eCSR_ROAM_IBSS_PEER_INFO_COMPLETE);
1310#endif
1311#ifdef WLAN_FEATURE_AP_HT40_24G
1312 CASE_RETURN_STR(eCSR_ROAM_2040_COEX_INFO_IND);
1313#endif
1314#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1315 CASE_RETURN_STR(eCSR_ROAM_TSM_IE_IND);
1316 CASE_RETURN_STR(eCSR_ROAM_CCKM_PREAUTH_NOTIFY);
1317 CASE_RETURN_STR(eCSR_ROAM_ESE_ADJ_AP_REPORT_IND);
1318 CASE_RETURN_STR(eCSR_ROAM_ESE_BCN_REPORT_IND);
1319#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
1320 CASE_RETURN_STR(eCSR_ROAM_UPDATE_MAX_RATE_IND);
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301321 CASE_RETURN_STR(eCSR_ROAM_LOST_LINK_PARAMS_IND);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05301322 CASE_RETURN_STR(eCSR_ROAM_ECSA_BCN_TX_IND);
1323 CASE_RETURN_STR(eCSR_ROAM_ECSA_CHAN_CHANGE_RSP);
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05301324 CASE_RETURN_STR(eCSR_ROAM_SAE_COMPUTE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 default:
1326 return "unknown";
1327 }
1328}
1329
1330const char *
1331get_eCsrRoamResult_str(eCsrRoamResult val)
1332{
1333 switch (val)
1334 {
1335 CASE_RETURN_STR(eCSR_ROAM_RESULT_NONE);
1336 CASE_RETURN_STR(eCSR_ROAM_RESULT_FAILURE);
1337 CASE_RETURN_STR(eCSR_ROAM_RESULT_ASSOCIATED);
1338 CASE_RETURN_STR(eCSR_ROAM_RESULT_NOT_ASSOCIATED);
1339 CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_FAILURE);
1340 CASE_RETURN_STR(eCSR_ROAM_RESULT_FORCED);
1341 CASE_RETURN_STR(eCSR_ROAM_RESULT_DISASSOC_IND);
1342 CASE_RETURN_STR(eCSR_ROAM_RESULT_DEAUTH_IND);
1343 CASE_RETURN_STR(eCSR_ROAM_RESULT_CAP_CHANGED);
1344 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_CONNECT);
1345 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_INACTIVE);
1346 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_NEW_PEER);
1347 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_COALESCED);
1348 default:
1349 return "unknown";
1350 }
1351}
1352
1353
1354
1355tANI_BOOLEAN csrGetBssIdBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tCsrBssid *pBssId )
1356{
Kiet Lam64c1b492013-07-12 13:56:44 +05301357 vos_mem_copy(pBssId, &pSirBssDesc->bssId[ 0 ], sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 return( TRUE );
1359}
1360
1361
1362tANI_BOOLEAN csrIsBssIdEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 )
1363{
1364 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1365 tANI_BOOLEAN fEqual = FALSE;
1366 tCsrBssid bssId1;
1367 tCsrBssid bssId2;
1368
1369 do {
1370 if ( !pSirBssDesc1 ) break;
1371 if ( !pSirBssDesc2 ) break;
1372
1373 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc1, &bssId1 ) ) break;
1374 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc2, &bssId2 ) ) break;
1375
1376 //sirCompareMacAddr
1377 fEqual = csrIsMacAddressEqual(pMac, &bssId1, &bssId2);
1378
1379 } while( 0 );
1380
1381 return( fEqual );
1382}
1383
1384tANI_BOOLEAN csrIsConnStateConnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1385{
1386 return( eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1387}
1388
1389tANI_BOOLEAN csrIsConnStateDisconnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1390{
1391 return( eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1392}
1393
1394tANI_BOOLEAN csrIsConnStateConnectedInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1395{
1396 return( eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == pMac->roam.roamSession[sessionId].connectState );
1397}
1398
1399tANI_BOOLEAN csrIsConnStateConnected( tpAniSirGlobal pMac, tANI_U32 sessionId )
1400{
1401 if( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateConnectedInfra( pMac, sessionId ) || csrIsConnStateConnectedWds( pMac, sessionId) )
1402 return TRUE;
1403 else
1404 return FALSE;
1405}
1406
1407tANI_BOOLEAN csrIsConnStateInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1408{
1409 return( csrIsConnStateConnectedInfra( pMac, sessionId ) );
1410}
1411
1412tANI_BOOLEAN csrIsConnStateIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1413{
1414 return( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateDisconnectedIbss( pMac, sessionId ) );
1415}
1416
1417
1418tANI_BOOLEAN csrIsConnStateConnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1419{
1420 return( eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1421}
1422
Jeff Johnson295189b2012-06-20 16:38:30 -07001423tANI_BOOLEAN csrIsConnStateConnectedInfraAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1424{
1425 return( (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == pMac->roam.roamSession[sessionId].connectState) ||
1426 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState ) );
1427}
Jeff Johnson295189b2012-06-20 16:38:30 -07001428
1429tANI_BOOLEAN csrIsConnStateDisconnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1430{
1431 return( eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1432}
1433
1434tANI_BOOLEAN csrIsConnStateWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1435{
1436 return( csrIsConnStateConnectedWds( pMac, sessionId ) ||
1437 csrIsConnStateDisconnectedWds( pMac, sessionId ) );
1438}
1439
Jeff Johnsone7245742012-09-05 17:12:55 -07001440tANI_BOOLEAN csrIsConnStateAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1441{
1442 tCsrRoamSession *pSession;
1443 pSession = CSR_GET_SESSION(pMac, sessionId);
1444 if (!pSession)
1445 return eANI_BOOLEAN_FALSE;
1446 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
1447 {
1448 return eANI_BOOLEAN_TRUE;
1449 }
1450 return eANI_BOOLEAN_FALSE;
1451}
1452
Jeff Johnson295189b2012-06-20 16:38:30 -07001453tANI_BOOLEAN csrIsAnySessionInConnectState( tpAniSirGlobal pMac )
1454{
1455 tANI_U32 i;
1456 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1457
1458 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1459 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001460 if( CSR_IS_SESSION_VALID( pMac, i ) &&
1461 ( csrIsConnStateInfra( pMac, i )
1462 || csrIsConnStateIbss( pMac, i )
1463 || csrIsConnStateAp( pMac, i) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 {
1465 fRc = eANI_BOOLEAN_TRUE;
1466 break;
1467 }
1468 }
1469
1470 return ( fRc );
1471}
1472
1473tANI_S8 csrGetInfraSessionId( tpAniSirGlobal pMac )
1474{
1475 tANI_U8 i;
1476 tANI_S8 sessionid = -1;
1477
1478 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1479 {
1480 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateInfra( pMac, i ) )
1481 {
1482 sessionid = i;
1483 break;
1484 }
1485 }
1486
1487 return ( sessionid );
1488}
1489
1490tANI_U8 csrGetInfraOperationChannel( tpAniSirGlobal pMac, tANI_U8 sessionId)
1491{
1492 tANI_U8 channel;
1493
1494 if( CSR_IS_SESSION_VALID( pMac, sessionId ))
1495 {
1496 channel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
1497 }
1498 else
1499 {
1500 channel = 0;
1501 }
1502 return channel;
1503}
1504
Sushant Kaushik1d732562014-05-21 14:15:37 +05301505tANI_BOOLEAN csrIsSessionClientAndConnected(tpAniSirGlobal pMac, tANI_U8 sessionId)
1506{
1507 tCsrRoamSession *pSession = NULL;
1508 if ( CSR_IS_SESSION_VALID( pMac, sessionId) && csrIsConnStateInfra( pMac, sessionId))
1509 {
1510 pSession = CSR_GET_SESSION( pMac, sessionId);
Kaushik, Sushant79901762014-08-23 17:51:02 +05301511 if (NULL != pSession->pCurRoamProfile)
Sushant Kaushik1d732562014-05-21 14:15:37 +05301512 {
Kaushik, Sushant79901762014-08-23 17:51:02 +05301513 if ((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1514 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE))
1515 {
1516 return TRUE;
1517 }
Sushant Kaushik1d732562014-05-21 14:15:37 +05301518 }
1519 }
1520 return FALSE;
1521}
Jeff Johnson295189b2012-06-20 16:38:30 -07001522//This routine will return operating channel on FIRST BSS that is active/operating to be used for concurrency mode.
1523//If other BSS is not up or not connected it will return 0
1524
1525tANI_U8 csrGetConcurrentOperationChannel( tpAniSirGlobal pMac )
1526{
1527 tCsrRoamSession *pSession = NULL;
1528 tANI_U8 i = 0;
1529
1530 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1531 {
1532 if( CSR_IS_SESSION_VALID( pMac, i ) )
1533 {
1534 pSession = CSR_GET_SESSION( pMac, i );
1535
1536 if (NULL != pSession->pCurRoamProfile)
1537 {
1538 if (
1539 (((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1540 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE)) &&
1541 (pSession->connectState == eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED))
1542 ||
1543 (((pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) ||
1544 (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE)) &&
1545 (pSession->connectState != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
1546 )
1547 return (pSession->connectedProfile.operationChannel);
1548 }
1549
1550 }
1551 }
1552 return 0;
1553}
1554
1555tANI_BOOLEAN csrIsAllSessionDisconnected( tpAniSirGlobal pMac )
1556{
1557 tANI_U32 i;
1558 tANI_BOOLEAN fRc = eANI_BOOLEAN_TRUE;
1559
1560 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1561 {
1562 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1563 {
1564 fRc = eANI_BOOLEAN_FALSE;
1565 break;
1566 }
1567 }
1568
1569 return ( fRc );
1570}
1571
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001572tANI_BOOLEAN csrIsStaSessionConnected( tpAniSirGlobal pMac )
1573{
1574 tANI_U32 i;
1575 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1576 tCsrRoamSession *pSession = NULL;
1577 tANI_U32 countSta = 0;
1578
1579 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1580 {
1581 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1582 {
1583 pSession = CSR_GET_SESSION( pMac, i );
1584
1585 if (NULL != pSession->pCurRoamProfile)
1586 {
1587 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) {
1588 countSta++;
1589 }
1590 }
1591 }
1592 }
1593
1594 /* return TRUE if one of the following conditions is TRUE:
1595 * - more than one STA session connected
1596 */
1597 if ( countSta > 0) {
1598 fRc = eANI_BOOLEAN_TRUE;
1599 }
1600
1601 return( fRc );
1602}
1603
Bala Venkatesh5bfddc22019-02-13 14:42:05 +05301604tANI_BOOLEAN csrIsP2pGoSessionConnected( tpAniSirGlobal pMac )
1605{
1606 tANI_U32 i;
1607 tCsrRoamSession *pSession = NULL;
1608
1609 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1610 {
1611 if(CSR_IS_SESSION_VALID( pMac, i) &&
1612 !csrIsConnStateDisconnected(pMac, i))
1613 {
1614 pSession = CSR_GET_SESSION(pMac, i);
1615
1616 if (NULL != pSession->pCurRoamProfile)
1617 {
1618 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1619 return eANI_BOOLEAN_TRUE;
1620 }
1621 }
1622 }
1623 }
1624
1625 return eANI_BOOLEAN_FALSE;
1626}
1627
1628
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001629tANI_BOOLEAN csrIsP2pSessionConnected( tpAniSirGlobal pMac )
1630{
1631 tANI_U32 i;
1632 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1633 tCsrRoamSession *pSession = NULL;
1634 tANI_U32 countP2pCli = 0;
1635 tANI_U32 countP2pGo = 0;
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001636 tANI_U32 countSAP = 0;
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001637
1638 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1639 {
1640 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1641 {
1642 pSession = CSR_GET_SESSION( pMac, i );
1643
1644 if (NULL != pSession->pCurRoamProfile)
1645 {
1646 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE) {
1647 countP2pCli++;
1648 }
1649
1650 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1651 countP2pGo++;
1652 }
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001653
1654 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE) {
1655 countSAP++;
1656 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001657 }
1658 }
1659 }
1660
1661 /* return TRUE if one of the following conditions is TRUE:
1662 * - at least one P2P CLI session is connected
1663 * - at least one P2P GO session is connected
1664 */
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001665 if ( (countP2pCli > 0) || (countP2pGo > 0 ) || (countSAP > 0 ) ) {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001666 fRc = eANI_BOOLEAN_TRUE;
1667 }
1668
1669 return( fRc );
1670}
1671
Madan Mohan Koyyalamudid3d22592012-09-24 14:01:29 -07001672tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac )
1673{
1674 tANI_U32 i, count;
1675 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1676
1677 count = 0;
1678 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1679 {
1680 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1681 {
1682 count++;
1683 }
1684 }
1685
1686 if (count > 0)
1687 {
1688 fRc = eANI_BOOLEAN_TRUE;
1689 }
1690 return( fRc );
1691}
Jeff Johnson295189b2012-06-20 16:38:30 -07001692
1693tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac )
1694{
1695 tANI_U32 i;
1696 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1697
1698 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1699 {
1700 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1701 {
1702 fRc = eANI_BOOLEAN_TRUE;
1703 break;
1704 }
1705 }
1706
1707 return ( fRc );
1708}
1709
1710tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac )
1711{
1712 tANI_U32 i, noOfConnectedInfra = 0;
1713
1714 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1715
1716 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1717 {
1718 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1719 {
1720 ++noOfConnectedInfra;
1721 }
1722 }
1723
1724 // More than one Infra Sta Connected
1725 if(noOfConnectedInfra > 1)
1726 {
1727 fRc = eANI_BOOLEAN_TRUE;
1728 }
1729
1730 return ( fRc );
1731}
1732
1733tANI_BOOLEAN csrIsIBSSStarted( tpAniSirGlobal pMac )
1734{
1735 tANI_U32 i;
1736 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1737
1738 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1739 {
1740 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateIbss( pMac, i ) )
1741 {
1742 fRc = eANI_BOOLEAN_TRUE;
1743 break;
1744 }
1745 }
1746
1747 return ( fRc );
1748}
1749
1750
1751tANI_BOOLEAN csrIsBTAMPStarted( tpAniSirGlobal pMac )
1752{
1753 tANI_U32 i;
1754 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1755
1756 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1757 {
1758 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedWds( pMac, i ) )
1759 {
1760 fRc = eANI_BOOLEAN_TRUE;
1761 break;
1762 }
1763 }
1764
1765 return ( fRc );
1766}
1767
Jeff Johnsone7245742012-09-05 17:12:55 -07001768tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac )
1769{
1770 tANI_U32 sessionId, noOfCocurrentSession = 0;
1771 eCsrConnectState connectState;
1772
1773 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1774
1775 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1776 {
1777 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1778 {
1779 connectState = pMac->roam.roamSession[sessionId].connectState;
1780 if( (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == connectState) ||
1781 (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == connectState) ||
1782 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == connectState) )
1783 {
1784 ++noOfCocurrentSession;
1785 }
1786 }
1787 }
1788
1789 // More than one session is Up and Running
1790 if(noOfCocurrentSession > 1)
1791 {
1792 fRc = eANI_BOOLEAN_TRUE;
1793 }
1794
1795 return ( fRc );
1796}
1797
Jeff Johnsone7245742012-09-05 17:12:55 -07001798tANI_BOOLEAN csrIsInfraApStarted( tpAniSirGlobal pMac )
1799{
1800 tANI_U32 sessionId;
1801 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1802
1803 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1804 {
1805 if( CSR_IS_SESSION_VALID( pMac, sessionId ) && (csrIsConnStateConnectedInfraAp(pMac, sessionId)) )
1806 {
1807 fRc = eANI_BOOLEAN_TRUE;
1808 break;
1809 }
1810 }
1811
1812 return ( fRc );
1813
1814}
Jeff Johnsone7245742012-09-05 17:12:55 -07001815
Jeff Johnson295189b2012-06-20 16:38:30 -07001816tANI_BOOLEAN csrIsBTAMP( tpAniSirGlobal pMac, tANI_U32 sessionId )
1817{
1818 return ( csrIsConnStateConnectedWds( pMac, sessionId ) );
1819}
1820
1821
1822tANI_BOOLEAN csrIsConnStateDisconnected(tpAniSirGlobal pMac, tANI_U32 sessionId)
1823{
1824 return (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED == pMac->roam.roamSession[sessionId].connectState);
1825}
1826
Jeff Johnsone7245742012-09-05 17:12:55 -07001827tANI_BOOLEAN csrIsValidMcConcurrentSession(tpAniSirGlobal pMac, tANI_U32 sessionId,
1828 tSirBssDescription *pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001829{
1830 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07001831 eAniBoolean status = eANI_BOOLEAN_FALSE;
1832
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 //Check for MCC support
1834 if (!pMac->roam.configParam.fenableMCCMode)
1835 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001836 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 }
1838
Jeff Johnsone7245742012-09-05 17:12:55 -07001839 //Validate BeaconInterval
1840 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1841 {
1842 pSession = CSR_GET_SESSION( pMac, sessionId );
1843 if (NULL != pSession->pCurRoamProfile)
1844 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001845 if (csrIsconcurrentsessionValid (pMac, sessionId,
1846 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001847 == eHAL_STATUS_SUCCESS )
1848 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001849 if (csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId,
1850 &pBssDesc->beaconInterval, sessionId,
1851 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001852 != eHAL_STATUS_SUCCESS)
1853 {
1854 status = eANI_BOOLEAN_FALSE;
1855 }
1856 else
1857 {
1858 status = eANI_BOOLEAN_TRUE;
1859 }
1860 }
1861 else
1862 {
1863 status = eANI_BOOLEAN_FALSE;
1864 }
1865 }
1866 }
1867 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001868}
1869
1870static tSirMacCapabilityInfo csrGetBssCapabilities( tSirBssDescription *pSirBssDesc )
1871{
1872 tSirMacCapabilityInfo dot11Caps;
1873
1874 //tSirMacCapabilityInfo is 16-bit
1875 pal_get_U16( (tANI_U8 *)&pSirBssDesc->capabilityInfo, (tANI_U16 *)&dot11Caps );
1876
1877 return( dot11Caps );
1878}
1879
1880tANI_BOOLEAN csrIsInfraBssDesc( tSirBssDescription *pSirBssDesc )
1881{
1882 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1883
1884 return( (tANI_BOOLEAN)dot11Caps.ess );
1885}
1886
1887
1888tANI_BOOLEAN csrIsIbssBssDesc( tSirBssDescription *pSirBssDesc )
1889{
1890 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1891
1892 return( (tANI_BOOLEAN)dot11Caps.ibss );
1893}
1894
1895tANI_BOOLEAN csrIsQoSBssDesc( tSirBssDescription *pSirBssDesc )
1896{
1897 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1898
1899 return( (tANI_BOOLEAN)dot11Caps.qos );
1900}
1901
1902tANI_BOOLEAN csrIsPrivacy( tSirBssDescription *pSirBssDesc )
1903{
1904 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1905
1906 return( (tANI_BOOLEAN)dot11Caps.privacy );
1907}
1908
1909
1910tANI_BOOLEAN csrIs11dSupported(tpAniSirGlobal pMac)
1911{
1912 return(pMac->roam.configParam.Is11dSupportEnabled);
1913}
1914
1915
1916tANI_BOOLEAN csrIs11hSupported(tpAniSirGlobal pMac)
1917{
1918 return(pMac->roam.configParam.Is11hSupportEnabled);
1919}
1920
1921
1922tANI_BOOLEAN csrIs11eSupported(tpAniSirGlobal pMac)
1923{
1924 return(pMac->roam.configParam.Is11eSupportEnabled);
1925}
1926
1927tANI_BOOLEAN csrIsMCCSupported ( tpAniSirGlobal pMac )
1928{
1929 return(pMac->roam.configParam.fenableMCCMode);
1930
1931}
1932
1933tANI_BOOLEAN csrIsWmmSupported(tpAniSirGlobal pMac)
1934{
1935 if(eCsrRoamWmmNoQos == pMac->roam.configParam.WMMSupportMode)
1936 {
1937 return eANI_BOOLEAN_FALSE;
1938 }
1939 else
1940 {
1941 return eANI_BOOLEAN_TRUE;
1942 }
1943}
1944
1945
1946
1947
1948//pIes is the IEs for pSirBssDesc2
1949tANI_BOOLEAN csrIsSsidEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1,
1950 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2 )
1951{
1952 tANI_BOOLEAN fEqual = FALSE;
1953 tSirMacSSid Ssid1, Ssid2;
1954 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1955 tDot11fBeaconIEs *pIes1 = NULL;
1956 tDot11fBeaconIEs *pIesLocal = pIes2;
1957
1958 do {
1959 if( ( NULL == pSirBssDesc1 ) || ( NULL == pSirBssDesc2 ) ) break;
1960 if( !pIesLocal && !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesLocal)) )
1961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001962 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 break;
1964 }
1965 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
1966 {
1967 break;
1968 }
1969 if( ( !pIes1->SSID.present ) || ( !pIesLocal->SSID.present ) ) break;
1970 if ( pIes1->SSID.num_ssid != pIesLocal->SSID.num_ssid ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301971 vos_mem_copy(Ssid1.ssId, pIes1->SSID.ssid, pIes1->SSID.num_ssid);
1972 vos_mem_copy(Ssid2.ssId, pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001973
Kiet Lam64c1b492013-07-12 13:56:44 +05301974 fEqual = vos_mem_compare(Ssid1.ssId, Ssid2.ssId, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001975
1976 } while( 0 );
1977 if(pIes1)
1978 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301979 vos_mem_free(pIes1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 }
1981 if( pIesLocal && !pIes2 )
1982 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301983 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 }
1985
1986 return( fEqual );
1987}
1988
1989tANI_BOOLEAN csrIsAniWmeSupported(tDot11fIEAirgo *pIeAirgo)
1990{
1991 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
1992
1993 if(pIeAirgo && pIeAirgo->present && pIeAirgo->PropCapability.present)
1994 {
1995 fRet = (tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability ));
1996 }
1997
1998 return fRet;
1999}
2000
2001
2002
2003
2004//pIes can be passed in as NULL if the caller doesn't have one prepared
2005tANI_BOOLEAN csrIsBssDescriptionWme( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
2006{
2007 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2008 // Assume that WME is found...
2009 tANI_BOOLEAN fWme = TRUE;
2010 tDot11fBeaconIEs *pIesTemp = pIes;
2011
2012 do
2013 {
2014 if(pIesTemp == NULL)
2015 {
2016 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp)) )
2017 {
2018 fWme = FALSE;
2019 break;
2020 }
2021 }
2022 // if the AirgoProprietary indicator is found, then WME is supported...
2023 if ( csrIsAniWmeSupported(&pIesTemp->Airgo) ) break;
2024 // if the Wme Info IE is found, then WME is supported...
2025 if ( CSR_IS_QOS_BSS(pIesTemp) ) break;
2026 // if none of these are found, then WME is NOT supported...
2027 fWme = FALSE;
2028 } while( 0 );
2029 if( !csrIsWmmSupported( pMac ) && fWme)
2030 {
2031 if( !pIesTemp->HTCaps.present )
2032 {
2033 fWme = FALSE;
2034 }
2035 }
2036 if( ( pIes == NULL ) && ( NULL != pIesTemp ) )
2037 {
2038 //we allocate memory here so free it before returning
Kiet Lam64c1b492013-07-12 13:56:44 +05302039 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07002040 }
2041
2042 return( fWme );
2043}
2044
2045tANI_BOOLEAN csrIsHcfEnabled( tDot11fIEAirgo *pIeAirgo )
2046{
2047 tANI_BOOLEAN fHcfSupported = FALSE;
2048
2049 fHcfSupported = ((tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability )) ||
2050 (pIeAirgo->present && pIeAirgo->HCF.present && pIeAirgo->HCF.enabled));
2051
2052 return( fHcfSupported );
2053}
2054
2055
2056eCsrMediaAccessType csrGetQoSFromBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc,
2057 tDot11fBeaconIEs *pIes )
2058{
2059 eCsrMediaAccessType qosType = eCSR_MEDIUM_ACCESS_DCF;
2060
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07002062
2063 do
2064 {
2065 // if we find WMM in the Bss Description, then we let this
2066 // override and use WMM.
2067 if ( csrIsBssDescriptionWme( hHal, pSirBssDesc, pIes ) )
2068 {
2069 qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2070 }
2071 else
2072 {
2073 // if the QoS bit is on, then the AP is advertising 11E QoS...
2074 if ( csrIsQoSBssDesc( pSirBssDesc ) )
2075 {
2076 // which could be HCF or eDCF.
2077 if ( csrIsHcfEnabled( &pIes->Airgo ) )
2078 {
2079 qosType = eCSR_MEDIUM_ACCESS_11e_HCF;
2080 }
2081 else
2082 {
2083 qosType = eCSR_MEDIUM_ACCESS_11e_eDCF;
2084 }
2085 }
2086 else
2087 {
2088 qosType = eCSR_MEDIUM_ACCESS_DCF;
2089 }
2090 // scale back based on the types turned on for the adapter...
2091 if ( eCSR_MEDIUM_ACCESS_11e_eDCF == qosType && !csrIs11eSupported( hHal ) )
2092 {
2093 qosType = eCSR_MEDIUM_ACCESS_DCF;
2094 }
2095 }
2096
2097 } while(0);
2098
2099 return( qosType );
2100}
2101
2102
2103
2104
2105//Caller allocates memory for pIEStruct
2106eHalStatus csrParseBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIEStruct)
2107{
2108 eHalStatus status = eHAL_STATUS_FAILURE;
2109 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Abhishek Singhbad2b322016-10-21 11:22:33 +05302110 int ieLen = (int)GET_IE_LEN_IN_BSS(pBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002111
2112 if(ieLen > 0 && pIEStruct)
2113 {
2114 if(!DOT11F_FAILED(dot11fUnpackBeaconIEs( pMac, (tANI_U8 *)pBssDesc->ieFields, ieLen, pIEStruct )))
2115 {
2116 status = eHAL_STATUS_SUCCESS;
2117 }
2118 }
2119
2120 return (status);
2121}
2122
2123
2124//This function will allocate memory for the parsed IEs to the caller. Caller must free the memory
2125//after it is done with the data only if this function succeeds
2126eHalStatus csrGetParsedBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs **ppIEStruct)
2127{
2128 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2129 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2130
2131 if(pBssDesc && ppIEStruct)
2132 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302133 *ppIEStruct = vos_mem_malloc(sizeof(tDot11fBeaconIEs));
2134 if ( (*ppIEStruct) != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302136 vos_mem_set((void *)*ppIEStruct, sizeof(tDot11fBeaconIEs), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 status = csrParseBssDescriptionIEs(hHal, pBssDesc, *ppIEStruct);
2138 if(!HAL_STATUS_SUCCESS(status))
2139 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302140 vos_mem_free(*ppIEStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 *ppIEStruct = NULL;
2142 }
2143 }
2144 else
2145 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002146 smsLog( pMac, LOGE, FL(" failed to allocate memory") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 VOS_ASSERT( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +05302148 return eHAL_STATUS_FAILURE;
2149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 }
2151
2152 return (status);
2153}
2154
Siddharth Bhal64246172015-02-27 01:04:37 +05302155eHalStatus csrProcessGetFrameLogCommand( tpAniSirGlobal pMac,
2156 tSmeCmd *pCommand )
2157{
2158 tAniGetFrameLogReq *pMsg;
2159 tANI_U16 msgLen;
2160 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002161
Siddharth Bhal64246172015-02-27 01:04:37 +05302162 msgLen = sizeof(tAniGetFrameLogReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002163
Siddharth Bhal64246172015-02-27 01:04:37 +05302164 if ( NULL == pCommand )
2165 {
2166 smsLog( pMac, LOGE, FL("cannot process. cmd is null") );
2167 return eHAL_STATUS_FAILURE;
2168 }
2169
2170 pMsg = vos_mem_malloc(msgLen);
2171 if ( NULL == pMsg )
2172 {
2173 smsLog( pMac, LOGE, FL("fail to allocate memory") );
2174 return eHAL_STATUS_FAILURE;
2175 }
2176
2177 pMsg->msgType= pal_cpu_to_be16((tANI_U16)WDA_GET_FRAME_LOG_REQ);
2178 pMsg->msgLen= pal_cpu_to_be16(msgLen);
2179
Siddharth Bhal64246172015-02-27 01:04:37 +05302180 pMsg->getFrameLogCmdFlag = pCommand->u.getFramelogCmd.getFrameLogCmdFlag;
2181
2182 status = palSendMBMessage(pMac->hHdd, pMsg);
2183
2184 return( status );
2185}
Jeff Johnson295189b2012-06-20 16:38:30 -07002186
2187tANI_BOOLEAN csrIsNULLSSID( tANI_U8 *pBssSsid, tANI_U8 len )
2188{
2189 tANI_BOOLEAN fNullSsid = FALSE;
2190
2191 tANI_U32 SsidLength;
2192 tANI_U8 *pSsidStr;
2193
2194 do
2195 {
2196 if ( 0 == len )
2197 {
2198 fNullSsid = TRUE;
2199 break;
2200 }
2201
2202 //Consider 0 or space for hidden SSID
2203 if ( 0 == pBssSsid[0] )
2204 {
2205 fNullSsid = TRUE;
2206 break;
2207 }
2208
2209 SsidLength = len;
2210 pSsidStr = pBssSsid;
2211
2212 while ( SsidLength )
2213 {
2214 if( *pSsidStr )
2215 break;
2216
2217 pSsidStr++;
2218 SsidLength--;
2219 }
2220
2221 if( 0 == SsidLength )
2222 {
2223 fNullSsid = TRUE;
2224 break;
2225 }
2226 }
2227 while( 0 );
2228
2229 return fNullSsid;
2230}
2231
2232
2233tANI_U32 csrGetFragThresh( tHalHandle hHal )
2234{
2235 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2236
2237 return pMac->roam.configParam.FragmentationThreshold;
2238}
2239
2240tANI_U32 csrGetRTSThresh( tHalHandle hHal )
2241{
2242 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2243
2244 return pMac->roam.configParam.RTSThreshold;
2245}
2246
2247eCsrPhyMode csrTranslateToPhyModeFromBssDesc( tSirBssDescription *pSirBssDesc )
2248{
2249 eCsrPhyMode phyMode;
2250
2251 switch ( pSirBssDesc->nwType )
2252 {
2253 case eSIR_11A_NW_TYPE:
2254 phyMode = eCSR_DOT11_MODE_11a;
2255 break;
2256
2257 case eSIR_11B_NW_TYPE:
2258 phyMode = eCSR_DOT11_MODE_11b;
2259 break;
2260
2261 case eSIR_11G_NW_TYPE:
2262 phyMode = eCSR_DOT11_MODE_11g;
2263 break;
2264
2265 case eSIR_11N_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 phyMode = eCSR_DOT11_MODE_11n;
2267 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002268#ifdef WLAN_FEATURE_11AC
2269 case eSIR_11AC_NW_TYPE:
2270 default:
2271 phyMode = eCSR_DOT11_MODE_11ac;
2272#else
2273 default:
2274 phyMode = eCSR_DOT11_MODE_11n;
2275#endif
2276 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 return( phyMode );
2279}
2280
2281
2282tANI_U32 csrTranslateToWNICfgDot11Mode(tpAniSirGlobal pMac, eCsrCfgDot11Mode csrDot11Mode)
2283{
2284 tANI_U32 ret;
2285
2286 switch(csrDot11Mode)
2287 {
2288 case eCSR_CFG_DOT11_MODE_AUTO:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002289 smsLog(pMac, LOGW, FL(" Warning: sees eCSR_CFG_DOT11_MODE_AUTO "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 //We cannot decide until now.
2291 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2292 {
2293 ret = WNI_CFG_DOT11_MODE_TAURUS;
2294 }
2295 else
2296 {
Mukul Sharma45063942015-04-01 20:07:59 +05302297#ifdef WLAN_FEATURE_11AC
2298 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2299 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2300 ret = WNI_CFG_DOT11_MODE_11AC;
2301 else
2302 ret = WNI_CFG_DOT11_MODE_11N;
2303#else
2304 ret = WNI_CFG_DOT11_MODE_11N;
2305#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 }
2307 break;
2308 case eCSR_CFG_DOT11_MODE_TAURUS:
2309 ret = WNI_CFG_DOT11_MODE_TAURUS;
2310 break;
2311 case eCSR_CFG_DOT11_MODE_11A:
2312 ret = WNI_CFG_DOT11_MODE_11A;
2313 break;
2314 case eCSR_CFG_DOT11_MODE_11B:
2315 ret = WNI_CFG_DOT11_MODE_11B;
2316 break;
2317 case eCSR_CFG_DOT11_MODE_11G:
2318 ret = WNI_CFG_DOT11_MODE_11G;
2319 break;
2320 case eCSR_CFG_DOT11_MODE_11N:
2321 ret = WNI_CFG_DOT11_MODE_11N;
2322 break;
2323 case eCSR_CFG_DOT11_MODE_POLARIS:
2324 ret = WNI_CFG_DOT11_MODE_POLARIS;
2325 break;
2326 case eCSR_CFG_DOT11_MODE_TITAN:
2327 ret = WNI_CFG_DOT11_MODE_TITAN;
2328 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 case eCSR_CFG_DOT11_MODE_11G_ONLY:
Mukul Sharma45063942015-04-01 20:07:59 +05302330 ret = WNI_CFG_DOT11_MODE_11G_ONLY;
2331 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 case eCSR_CFG_DOT11_MODE_11N_ONLY:
Mukul Sharma45063942015-04-01 20:07:59 +05302333 ret = WNI_CFG_DOT11_MODE_11N_ONLY;
2334 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002335
2336#ifdef WLAN_FEATURE_11AC
Mukul Sharma45063942015-04-01 20:07:59 +05302337 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
2338 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2339 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2340 ret = WNI_CFG_DOT11_MODE_11AC_ONLY;
2341 else
2342 ret = WNI_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002343 break;
Mukul Sharma45063942015-04-01 20:07:59 +05302344 case eCSR_CFG_DOT11_MODE_11AC:
2345 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2346 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2347 ret = WNI_CFG_DOT11_MODE_11AC;
2348 else
2349 ret = WNI_CFG_DOT11_MODE_11N;
2350 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002351#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002353 smsLog(pMac, LOGW, FL("doesn't expect %d as csrDo11Mode"), csrDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 if(eCSR_BAND_24 == pMac->roam.configParam.eBand)
2355 {
2356 ret = WNI_CFG_DOT11_MODE_11G;
2357 }
2358 else
2359 {
2360 ret = WNI_CFG_DOT11_MODE_11A;
2361 }
2362 break;
2363 }
2364
2365 return (ret);
2366}
2367
2368
2369//This function should only return the super set of supported modes. 11n implies 11b/g/a/n.
2370eHalStatus csrGetPhyModeFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription,
2371 eCsrPhyMode *pPhyMode, tDot11fBeaconIEs *pIes)
2372{
2373 eHalStatus status = eHAL_STATUS_SUCCESS;
2374 eCsrPhyMode phyMode = csrTranslateToPhyModeFromBssDesc(pBSSDescription);
2375
2376 if( pIes )
2377 {
2378 if(pIes->Airgo.present)
2379 {
2380 if(pIes->Airgo.PropCapability.present)
2381 {
2382 if( PROP_CAPABILITY_GET( TAURUS, pIes->Airgo.PropCapability.capability ))
2383 {
2384 phyMode = eCSR_DOT11_MODE_TAURUS;
2385 }
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302386 }
2387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 if(pIes->HTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2389 {
2390 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002391#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05302392 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302393 {
2394 phyMode = eCSR_DOT11_MODE_11ac;
2395 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002396#endif
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 *pPhyMode = phyMode;
2399 }
2400
2401 return (status);
2402
2403}
2404
2405
2406//This function returns the correct eCSR_CFG_DOT11_MODE is the two phyModes matches
2407//bssPhyMode is the mode derived from the BSS description
2408//f5GhzBand is derived from the channel id of BSS description
2409tANI_BOOLEAN csrGetPhyModeInUse( eCsrPhyMode phyModeIn, eCsrPhyMode bssPhyMode, tANI_BOOLEAN f5GhzBand,
2410 eCsrCfgDot11Mode *pCfgDot11ModeToUse )
2411{
2412 tANI_BOOLEAN fMatch = FALSE;
2413 eCsrCfgDot11Mode cfgDot11Mode;
2414
2415 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; // to suppress compiler warning
2416
2417 switch( phyModeIn )
2418 {
2419 case eCSR_DOT11_MODE_abg: //11a or 11b or 11g
2420 if( f5GhzBand )
2421 {
2422 fMatch = TRUE;
2423 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2424 }
2425 else if( eCSR_DOT11_MODE_11b == bssPhyMode )
2426 {
2427 fMatch = TRUE;
2428 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2429 }
2430 else
2431 {
2432 fMatch = TRUE;
2433 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2434 }
2435 break;
2436
2437 case eCSR_DOT11_MODE_11a: //11a
2438 if( f5GhzBand )
2439 {
2440 fMatch = TRUE;
2441 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2442 }
2443 break;
2444
2445 case eCSR_DOT11_MODE_11a_ONLY: //11a
2446 if( eCSR_DOT11_MODE_11a == bssPhyMode )
2447 {
2448 fMatch = TRUE;
2449 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2450 }
2451 break;
2452
2453 case eCSR_DOT11_MODE_11g:
2454 if(!f5GhzBand)
2455 {
2456 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2457 {
2458 fMatch = TRUE;
2459 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2460 }
2461 else
2462 {
2463 fMatch = TRUE;
2464 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2465 }
2466 }
2467 break;
2468
2469 case eCSR_DOT11_MODE_11g_ONLY:
2470 if( eCSR_DOT11_MODE_11g == bssPhyMode )
2471 {
2472 fMatch = TRUE;
2473 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2474 }
2475 break;
2476
2477 case eCSR_DOT11_MODE_11b:
2478 if( !f5GhzBand )
2479 {
2480 fMatch = TRUE;
2481 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2482 }
2483 break;
2484
2485 case eCSR_DOT11_MODE_11b_ONLY:
2486 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2487 {
2488 fMatch = TRUE;
2489 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2490 }
2491 break;
2492
2493 case eCSR_DOT11_MODE_11n:
2494 fMatch = TRUE;
2495 switch(bssPhyMode)
2496 {
2497 case eCSR_DOT11_MODE_11g:
2498 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2499 break;
2500 case eCSR_DOT11_MODE_11b:
2501 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2502 break;
2503 case eCSR_DOT11_MODE_11a:
2504 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2505 break;
2506 case eCSR_DOT11_MODE_11n:
Jeff Johnsone7245742012-09-05 17:12:55 -07002507#ifdef WLAN_FEATURE_11AC
2508 case eCSR_DOT11_MODE_11ac:
2509#endif
2510 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2511 break;
2512
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 case eCSR_DOT11_MODE_TAURUS:
2514 default:
Jeff Johnsone7245742012-09-05 17:12:55 -07002515#ifdef WLAN_FEATURE_11AC
2516 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2517#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002519#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 break;
2521 }
2522 break;
2523
2524 case eCSR_DOT11_MODE_11n_ONLY:
2525 if((eCSR_DOT11_MODE_11n == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2526 {
2527 fMatch = TRUE;
2528 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002529
2530 }
2531
2532 break;
2533#ifdef WLAN_FEATURE_11AC
2534 case eCSR_DOT11_MODE_11ac:
2535 fMatch = TRUE;
2536 switch(bssPhyMode)
2537 {
2538 case eCSR_DOT11_MODE_11g:
2539 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2540 break;
2541 case eCSR_DOT11_MODE_11b:
2542 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2543 break;
2544 case eCSR_DOT11_MODE_11a:
2545 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2546 break;
2547 case eCSR_DOT11_MODE_11n:
2548 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2549 break;
2550 case eCSR_DOT11_MODE_11ac:
2551 case eCSR_DOT11_MODE_TAURUS:
2552 default:
2553 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2554 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 }
2556 break;
2557
Jeff Johnsone7245742012-09-05 17:12:55 -07002558 case eCSR_DOT11_MODE_11ac_ONLY:
2559 if((eCSR_DOT11_MODE_11ac == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2560 {
2561 fMatch = TRUE;
2562 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2563 }
2564 break;
2565#endif
2566
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 case eCSR_DOT11_MODE_TAURUS:
2568 default:
2569 fMatch = TRUE;
2570 switch(bssPhyMode)
2571 {
2572 case eCSR_DOT11_MODE_11g:
2573 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2574 break;
2575 case eCSR_DOT11_MODE_11b:
2576 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2577 break;
2578 case eCSR_DOT11_MODE_11a:
2579 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2580 break;
2581 case eCSR_DOT11_MODE_11n:
2582 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2583 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002584#ifdef WLAN_FEATURE_11AC
2585 case eCSR_DOT11_MODE_11ac:
2586 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2587 break;
2588#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 case eCSR_DOT11_MODE_TAURUS:
2590 default:
2591 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
2592 break;
2593 }
2594 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 }
2596
2597 if ( fMatch && pCfgDot11ModeToUse )
2598 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002599#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudief5dd972012-10-11 15:06:09 -07002600 if(cfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC && (!IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)))
Jeff Johnsone7245742012-09-05 17:12:55 -07002601 {
2602 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2603 }
2604 else
2605#endif
2606 {
2607 *pCfgDot11ModeToUse = cfgDot11Mode;
2608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 return( fMatch );
2611}
2612
2613
2614//This function decides whether the one of the bit of phyMode is matching the mode in the BSS and allowed by the user
2615//setting, pMac->roam.configParam.uCfgDot11Mode. It returns the mode that fits the criteria.
2616tANI_BOOLEAN csrIsPhyModeMatch( tpAniSirGlobal pMac, tANI_U32 phyMode,
2617 tSirBssDescription *pSirBssDesc, tCsrRoamProfile *pProfile,
2618 eCsrCfgDot11Mode *pReturnCfgDot11Mode,
2619 tDot11fBeaconIEs *pIes)
2620{
2621 tANI_BOOLEAN fMatch = FALSE;
2622 eCsrPhyMode phyModeInBssDesc, phyMode2;
2623 eCsrCfgDot11Mode cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_TAURUS;
2624 tANI_U32 bitMask, loopCount;
2625
2626 if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pSirBssDesc, &phyModeInBssDesc, pIes )))
2627 {
2628 //In case some change change eCSR_DOT11_MODE_TAURUS to non-0
2629 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2630 {
2631 //Taurus means anything
2632 if ( eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode )
2633 {
2634 phyMode = eCSR_DOT11_MODE_abg;
2635 }
2636 else if(eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode)
2637 {
2638 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2639 {
2640 phyMode = eCSR_DOT11_MODE_TAURUS;
2641 }
2642 else
2643 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002644
2645#ifdef WLAN_FEATURE_11AC
2646 phyMode = eCSR_DOT11_MODE_11ac;
2647#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002649#endif
2650
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 }
2652 }
2653 else
2654 {
2655 //user's pick
2656 phyMode = pMac->roam.configParam.phyMode;
2657 }
2658 }
2659 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode) )
2660 {
2661 if(0 != phyMode)
2662 {
2663 if(eCSR_DOT11_MODE_AUTO & phyMode)
2664 {
2665 phyMode2 = eCSR_DOT11_MODE_AUTO & phyMode;
2666 }
2667 else
2668 {
2669 phyMode2 = eCSR_DOT11_MODE_TAURUS & phyMode;
2670 }
2671 }
2672 else
2673 {
2674 phyMode2 = phyMode;
2675 }
2676 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2677 &cfgDot11ModeToUse );
2678 }
2679 else
2680 {
2681 bitMask = 1;
2682 loopCount = 0;
2683 while(loopCount < eCSR_NUM_PHY_MODE)
2684 {
2685 if(0 != ( phyMode2 = (phyMode & (bitMask << loopCount++)) ))
2686 {
2687 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2688 &cfgDot11ModeToUse );
2689 if(fMatch) break;
2690 }
2691 }
2692 }
2693 if ( fMatch && pReturnCfgDot11Mode )
2694 {
2695 if( pProfile )
2696 {
2697 /* IEEE 11n spec (8.4.3): HT STA shall eliminate TKIP as a
2698 * choice for the pairwise cipher suite if CCMP is advertised
2699 * by the AP or if the AP included an HT capabilities element
2700 * in its Beacons and Probe Response.
2701 */
2702 if( (!CSR_IS_11n_ALLOWED( pProfile->negotiatedUCEncryptionType )) &&
2703 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11ModeToUse) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002704#ifdef WLAN_FEATURE_11AC
2705 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11ModeToUse) ||
2706#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11ModeToUse)) )
2708 {
2709 //We cannot do 11n here
2710 if( !CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId) )
2711 {
2712 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2713 }
2714 else
2715 {
2716 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2717 }
2718 }
2719 }
2720 *pReturnCfgDot11Mode = cfgDot11ModeToUse;
2721 }
2722 }
2723
2724 return( fMatch );
2725}
2726
2727
2728eCsrCfgDot11Mode csrFindBestPhyMode( tpAniSirGlobal pMac, tANI_U32 phyMode )
2729{
2730 eCsrCfgDot11Mode cfgDot11ModeToUse;
2731 eCsrBand eBand = pMac->roam.configParam.eBand;
2732
Jeff Johnsone7245742012-09-05 17:12:55 -07002733
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302734 if ((0 == phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002735#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302736 (eCSR_DOT11_MODE_11ac & phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002737#endif
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302738 (eCSR_DOT11_MODE_AUTO & phyMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 {
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302740#ifdef WLAN_FEATURE_11AC
2741 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2742 {
2743 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC;
2744 }
2745 else
2746#endif
2747 {
2748 /* Default to 11N mode if user has configured 11ac mode
2749 * and FW doesn't supports 11ac mode .
2750 */
2751 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 }
2754 else
2755 {
2756 if( ( eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY ) & phyMode )
2757 {
2758 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2759 }
2760 else if ( eCSR_DOT11_MODE_abg & phyMode )
2761 {
2762 if( eCSR_BAND_24 != eBand )
2763 {
2764 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2765 }
2766 else
2767 {
2768 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2769 }
2770 }
2771 else if( ( eCSR_DOT11_MODE_11a | eCSR_DOT11_MODE_11a_ONLY ) & phyMode )
2772 {
2773 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2774 }
2775 else if( ( eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY ) & phyMode )
2776 {
2777 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2778 }
2779 else
2780 {
2781 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B;
2782 }
2783 }
2784
2785 return ( cfgDot11ModeToUse );
2786}
2787
2788
2789
2790
2791tANI_U32 csrGet11hPowerConstraint( tHalHandle hHal, tDot11fIEPowerConstraints *pPowerConstraint )
2792{
2793 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2794 tANI_U32 localPowerConstraint = 0;
2795
2796 // check if .11h support is enabled, if not, the power constraint is 0.
2797 if(pMac->roam.configParam.Is11hSupportEnabled && pPowerConstraint->present)
2798 {
2799 localPowerConstraint = pPowerConstraint->localPowerConstraints;
2800 }
2801
2802 return( localPowerConstraint );
2803}
2804
2805
2806tANI_BOOLEAN csrIsProfileWpa( tCsrRoamProfile *pProfile )
2807{
2808 tANI_BOOLEAN fWpaProfile = FALSE;
2809
2810 switch ( pProfile->negotiatedAuthType )
2811 {
2812 case eCSR_AUTH_TYPE_WPA:
2813 case eCSR_AUTH_TYPE_WPA_PSK:
2814 case eCSR_AUTH_TYPE_WPA_NONE:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002815#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 case eCSR_AUTH_TYPE_CCKM_WPA:
2817#endif
2818 fWpaProfile = TRUE;
2819 break;
2820
2821 default:
2822 fWpaProfile = FALSE;
2823 break;
2824 }
2825
2826 if ( fWpaProfile )
2827 {
2828 switch ( pProfile->negotiatedUCEncryptionType )
2829 {
2830 case eCSR_ENCRYPT_TYPE_WEP40:
2831 case eCSR_ENCRYPT_TYPE_WEP104:
2832 case eCSR_ENCRYPT_TYPE_TKIP:
2833 case eCSR_ENCRYPT_TYPE_AES:
2834 fWpaProfile = TRUE;
2835 break;
2836
2837 default:
2838 fWpaProfile = FALSE;
2839 break;
2840 }
2841 }
2842 return( fWpaProfile );
2843}
2844
2845tANI_BOOLEAN csrIsProfileRSN( tCsrRoamProfile *pProfile )
2846{
2847 tANI_BOOLEAN fRSNProfile = FALSE;
2848
2849 switch ( pProfile->negotiatedAuthType )
2850 {
2851 case eCSR_AUTH_TYPE_RSN:
2852 case eCSR_AUTH_TYPE_RSN_PSK:
2853#ifdef WLAN_FEATURE_VOWIFI_11R
2854 case eCSR_AUTH_TYPE_FT_RSN:
2855 case eCSR_AUTH_TYPE_FT_RSN_PSK:
2856#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002857#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 case eCSR_AUTH_TYPE_CCKM_RSN:
2859#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002860#ifdef WLAN_FEATURE_11W
2861 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05302862 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07002863#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +05302864 fRSNProfile = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05302866 case eCSR_AUTH_TYPE_SAE:
2867 fRSNProfile = true;
2868 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002869
Abhinav Kumar487e49e2019-07-22 14:46:18 +05302870 case eCSR_AUTH_TYPE_OWE:
2871 fRSNProfile = true;
2872 break;
2873
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 default:
2875 fRSNProfile = FALSE;
2876 break;
2877 }
2878
2879 if ( fRSNProfile )
2880 {
2881 switch ( pProfile->negotiatedUCEncryptionType )
2882 {
2883 // !!REVIEW - For WPA2, use of RSN IE mandates
2884 // use of AES as encryption. Here, we qualify
2885 // even if encryption type is WEP or TKIP
2886 case eCSR_ENCRYPT_TYPE_WEP40:
2887 case eCSR_ENCRYPT_TYPE_WEP104:
2888 case eCSR_ENCRYPT_TYPE_TKIP:
2889 case eCSR_ENCRYPT_TYPE_AES:
2890 fRSNProfile = TRUE;
2891 break;
2892
2893 default:
2894 fRSNProfile = FALSE;
2895 break;
2896 }
2897 }
2898 return( fRSNProfile );
2899}
2900
Jeff Johnsone7245742012-09-05 17:12:55 -07002901eHalStatus
2902csrIsconcurrentsessionValid(tpAniSirGlobal pMac,tANI_U32 cursessionId,
2903 tVOS_CON_MODE currBssPersona)
2904{
2905 tANI_U32 sessionId = 0;
2906
2907 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2908 {
2909 if (cursessionId != sessionId )
2910 {
2911 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2912 {
2913 continue;
2914 }
2915
2916 switch (currBssPersona)
2917 {
2918 case VOS_STA_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -07002919 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05302920 smsLog(pMac, LOG4, FL(" Second session for persona %d"), currBssPersona);
Agarwal Ashishe16e1212014-05-15 14:51:36 +05302921 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07002922 }
2923 break;
2924
2925 case VOS_STA_SAP_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302926 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2927 == VOS_STA_SAP_MODE)&&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002928 (pMac->roam.roamSession[sessionId].connectState
2929 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002930 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002931 smsLog(pMac, LOGE, FL(" ****SoftAP mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002932 return eHAL_STATUS_FAILURE;
2933 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002934 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2935 == VOS_P2P_GO_MODE &&
2936 pMac->roam.roamSession[sessionId].connectState
2937 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2938 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2939 == VOS_IBSS_MODE &&
2940 pMac->roam.roamSession[sessionId].connectState
2941 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002942 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002943 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002944 return eHAL_STATUS_FAILURE;
2945 }
2946 break;
2947
2948 case VOS_P2P_CLIENT_MODE:
2949 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002950 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002951 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2952 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002953 smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002954 return eHAL_STATUS_FAILURE;
2955 }
2956 break;
2957
2958 case VOS_P2P_GO_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302959 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2960 == VOS_P2P_GO_MODE) &&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002961 (pMac->roam.roamSession[sessionId].connectState
2962 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002964 smsLog(pMac, LOGE, FL(" ****P2P GO mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002965 return eHAL_STATUS_FAILURE;
2966 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002967 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2968 == VOS_STA_SAP_MODE &&
2969 pMac->roam.roamSession[sessionId].connectState
2970 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2971 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2972 == VOS_IBSS_MODE &&
2973 pMac->roam.roamSession[sessionId].connectState
2974 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002976 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002977 return eHAL_STATUS_FAILURE;
2978 }
2979 break;
Ravi Joshia96ceb42013-05-20 18:52:39 -07002980 case VOS_IBSS_MODE:
2981 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2982 == VOS_IBSS_MODE) &&
2983 (pMac->roam.roamSession[sessionId].connectState
2984 != eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED))
2985 {
2986 smsLog(pMac, LOGE, FL(" ****IBSS mode already exists ****"));
2987 return eHAL_STATUS_FAILURE;
2988 }
2989 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2990 == VOS_P2P_GO_MODE ||
2991 pMac->roam.roamSession[sessionId].bssParams.bssPersona
2992 == VOS_STA_SAP_MODE) &&
2993 pMac->roam.roamSession[sessionId].connectState
2994 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)
2995 {
2996 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
2997 return eHAL_STATUS_FAILURE;
2998 }
2999 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003000 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003001 smsLog(pMac, LOGE, FL("***Persona not handled = %d*****"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003002 break;
3003 }
3004 }
3005 }
3006 return eHAL_STATUS_SUCCESS;
3007
3008}
3009
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003010eHalStatus csrUpdateMCCp2pBeaconInterval(tpAniSirGlobal pMac)
Jeff Johnsone7245742012-09-05 17:12:55 -07003011{
3012 tANI_U32 sessionId = 0;
3013
3014 //If MCC is not supported just break and return SUCCESS
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003015 if ( !pMac->roam.configParam.fenableMCCMode){
3016 return eHAL_STATUS_FAILURE;
3017 }
3018
3019 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
3020 {
3021 /* If GO in MCC support different beacon interval,
3022 * change the BI of the P2P-GO */
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003023 if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3024 == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003025 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003026 /* Handle different BI scneario based on the configuration set.
3027 * If Config is set to 0x02 then Disconnect all the P2P clients
3028 * associated. If config is set to 0x04 then update the BI
3029 * without disconnecting all the clients
3030 */
3031 if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
3032 (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
3033 {
3034 return csrSendChngMCCBeaconInterval( pMac, sessionId);
3035 }
3036 //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
3037 else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
3038 {
3039 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
3040 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003041 }
3042 }
3043 return eHAL_STATUS_FAILURE;
3044}
3045
3046tANI_U16 csrCalculateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U16 sta_bi, tANI_U16 go_gbi)
3047{
3048 tANI_U8 num_beacons = 0;
3049 tANI_U8 is_multiple = 0;
3050 tANI_U16 go_cbi = 0;
3051 tANI_U16 go_fbi = 0;
3052 tANI_U16 sta_cbi = 0;
3053
3054 //If GO's given beacon Interval is less than 100
3055 if(go_gbi < 100)
3056 go_cbi = 100;
3057 //if GO's given beacon Interval is greater than or equal to 100
3058 else
3059 go_cbi = 100 + (go_gbi % 100);
3060
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05303061 if ( sta_bi == 0 )
3062 {
3063 /* There is possibility to receive zero as value.
3064 Which will cause divide by zero. Hence initialise with 100
3065 */
3066 sta_bi = 100;
3067 smsLog(pMac, LOGW,
3068 FL("sta_bi 2nd parameter is zero, initialise to %d"), sta_bi);
3069 }
3070
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003071 // check, if either one is multiple of another
3072 if (sta_bi > go_cbi)
3073 {
3074 is_multiple = !(sta_bi % go_cbi);
3075 }
3076 else
3077 {
3078 is_multiple = !(go_cbi % sta_bi);
3079 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08003080 // if it is multiple, then accept GO's beacon interval range [100,199] as it is
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003081 if (is_multiple)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003082 {
3083 return go_cbi;
3084 }
3085 //else , if it is not multiple, then then check for number of beacons to be
3086 //inserted based on sta BI
3087 num_beacons = sta_bi / 100;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003088 if (num_beacons)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003089 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08003090 // GO's final beacon interval will be aligned to sta beacon interval, but
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003091 //in the range of [100, 199].
3092 sta_cbi = sta_bi / num_beacons;
3093 go_fbi = sta_cbi;
3094 }
3095 else
3096 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08003097 // if STA beacon interval is less than 100, use GO's change bacon interval
3098 //instead of updating to STA's beacon interval.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003099 go_fbi = go_cbi;
3100 }
3101 return go_fbi;
3102}
3103
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003104eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003105 tANI_U16 *beaconInterval, tANI_U32 cursessionId,
3106 tVOS_CON_MODE currBssPersona)
3107{
3108 tANI_U32 sessionId = 0;
3109 tANI_U16 new_beaconInterval = 0;
3110
3111 //If MCC is not supported just break
3112 if (!pMac->roam.configParam.fenableMCCMode){
Jeff Johnsone7245742012-09-05 17:12:55 -07003113 return eHAL_STATUS_FAILURE;
3114 }
3115
3116 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
3117 {
3118 if (cursessionId != sessionId )
3119 {
3120 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
3121 {
3122 continue;
3123 }
3124
3125 switch (currBssPersona)
3126 {
3127 case VOS_STA_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003128 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3129 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003130 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
3131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003132 smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003133 }
3134 //IF SAP has started and STA wants to connect on different channel MCC should
3135 //MCC should not be enabled so making it false to enforce on same channel
3136 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3137 == VOS_STA_SAP_MODE)
3138 {
3139 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3140 != channelId )
3141 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05303142 smsLog(pMac, LOGE, FL("*** MCC with SAP+STA sessions ****"));
3143 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07003144 }
3145 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003146 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003147 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3148 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003149 /* if GO in MCC support different beacon interval,
3150 * change the BI of the P2P-GO */
3151 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
Jeff Johnsone7245742012-09-05 17:12:55 -07003152 != channelId ) &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003153 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003154 != *beaconInterval))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003155 {
3156 /* if GO in MCC support different beacon interval, return success */
3157 if ( pMac->roam.configParam.fAllowMCCGODiffBI == 0x01)
3158 {
3159 return eHAL_STATUS_SUCCESS;
3160 }
3161 // Send only Broadcast disassoc and update beaconInterval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003162 //If configuration is set to 0x04 then dont
3163 // disconnect all the station
3164 else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
3165 (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003166 {
3167 //Check to pass the right beacon Interval
3168 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval,
3169 pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003170 smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003171 //Update the becon Interval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003172 if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003173 {
3174 //Update the beaconInterval now
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003175 smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
3176 pMac->roam.configParam.fAllowMCCGODiffBI);
3177
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003178 pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
3179 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003180 return csrUpdateMCCp2pBeaconInterval(pMac);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003181 }
3182 return eHAL_STATUS_SUCCESS;
3183 }
3184 //Disconnect the P2P session
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003185 else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003186 {
3187 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
3188 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
3189 }
3190 else
3191 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003192 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to preferred AP..."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003193 return eHAL_STATUS_FAILURE;
3194 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003195 }
3196 }
3197 break;
3198
3199 case VOS_P2P_CLIENT_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003200 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3201 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003202 == VOS_STA_MODE)) //check for P2P client mode
3203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003204 smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003205 }
3206 //IF SAP has started and STA wants to connect on different channel MCC should
3207 //MCC should not be enabled so making it false to enforce on same channel
3208 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3209 == VOS_STA_SAP_MODE)
3210 {
3211 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3212 != channelId )
3213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003214 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP + CLIENT****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003215 return eHAL_STATUS_FAILURE;
3216 }
3217 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003218 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003219 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3220 {
3221 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
3222 != channelId ) &&
3223 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
3224 != *beaconInterval))
3225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003226 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to P2P_GO network ..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003227 return eHAL_STATUS_FAILURE;
3228 }
3229 }
3230 break;
3231
3232 case VOS_P2P_GO_MODE :
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003233 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003234 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3235 ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003236 == VOS_P2P_CLIENT_MODE) ||
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003237 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003238 == VOS_STA_MODE))) //check for P2P_client scenario
3239 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003240 if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003241 == 0 )&&
3242 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
3243 == 0))
3244 {
3245 continue;
3246 }
3247
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05303248 //Assert if connected profile beacon internal is ZERO
3249 if(!pMac->roam.roamSession[sessionId].\
3250 connectedProfile.beaconInterval)
3251 {
3252 smsLog( pMac, LOGE, FL(" Connected profile "
3253 "beacon interval is zero") );
3254 }
3255
Jeff Johnsone7245742012-09-05 17:12:55 -07003256
3257 if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003258 (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003259 != channelId ) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003260 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003261 != *beaconInterval))
3262 {
3263 /*
3264 * Updated beaconInterval should be used only when we are starting a new BSS
3265 * not incase of client or STA case
3266 */
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003267 //Calculate beacon Interval for P2P-GO incase of MCC
3268 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac,
Chet Lanctot4c986162013-05-08 13:59:56 -07003269 pMac->roam.roamSession[sessionId].bssParams.beaconInterval,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003270 *beaconInterval );
3271 if(*beaconInterval != new_beaconInterval)
3272 *beaconInterval = new_beaconInterval;
Jeff Johnsone7245742012-09-05 17:12:55 -07003273 return eHAL_STATUS_SUCCESS;
3274 }
3275 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003276 }
3277 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003278
3279 default :
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303280 smsLog(pMac, LOGE, FL(" Persona not supported : %d"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003281 return eHAL_STATUS_FAILURE;
3282 }
3283 }
3284 }
3285
3286 return eHAL_STATUS_SUCCESS;
3287}
Jeff Johnson295189b2012-06-20 16:38:30 -07003288
3289#ifdef WLAN_FEATURE_VOWIFI_11R
3290/* Function to return TRUE if the authtype is 11r */
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003291tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -07003292{
3293 switch ( AuthType )
3294 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003295 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3296 if(mdiePresent)
3297 return TRUE;
3298 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3300 case eCSR_AUTH_TYPE_FT_RSN:
3301 return TRUE;
3302 break;
3303 default:
3304 break;
3305 }
3306 return FALSE;
3307}
3308
3309/* Function to return TRUE if the profile is 11r */
3310tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
3311{
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003312 return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
Jeff Johnson295189b2012-06-20 16:38:30 -07003313}
3314
3315#endif
3316
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003317#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003318
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003319/* Function to return TRUE if the authtype is ESE */
3320tANI_BOOLEAN csrIsAuthTypeESE( eCsrAuthType AuthType )
Jeff Johnson295189b2012-06-20 16:38:30 -07003321{
3322 switch ( AuthType )
3323 {
3324 case eCSR_AUTH_TYPE_CCKM_WPA:
3325 case eCSR_AUTH_TYPE_CCKM_RSN:
3326 return TRUE;
3327 break;
3328 default:
3329 break;
3330 }
3331 return FALSE;
3332}
3333
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003334/* Function to return TRUE if the profile is ESE */
3335tANI_BOOLEAN csrIsProfileESE( tCsrRoamProfile *pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003336{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003337 return (csrIsAuthTypeESE( pProfile->negotiatedAuthType ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003338}
3339
3340#endif
3341
3342#ifdef FEATURE_WLAN_WAPI
3343tANI_BOOLEAN csrIsProfileWapi( tCsrRoamProfile *pProfile )
3344{
3345 tANI_BOOLEAN fWapiProfile = FALSE;
3346
3347 switch ( pProfile->negotiatedAuthType )
3348 {
3349 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
3350 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
3351 fWapiProfile = TRUE;
3352 break;
3353
3354 default:
3355 fWapiProfile = FALSE;
3356 break;
3357 }
3358
3359 if ( fWapiProfile )
3360 {
3361 switch ( pProfile->negotiatedUCEncryptionType )
3362 {
3363 case eCSR_ENCRYPT_TYPE_WPI:
3364 fWapiProfile = TRUE;
3365 break;
3366
3367 default:
3368 fWapiProfile = FALSE;
3369 break;
3370 }
3371 }
3372 return( fWapiProfile );
3373}
3374
3375static tANI_BOOLEAN csrIsWapiOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3376{
Kiet Lam64c1b492013-07-12 13:56:44 +05303377 return (vos_mem_compare(Oui1, Oui2, CSR_WAPI_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003378}
3379
3380static tANI_BOOLEAN csrIsWapiOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3381 tANI_U8 cAllCyphers,
3382 tANI_U8 Cypher[],
3383 tANI_U8 Oui[] )
3384{
3385 tANI_BOOLEAN fYes = FALSE;
3386 tANI_U8 idx;
3387
3388 for ( idx = 0; idx < cAllCyphers; idx++ )
3389 {
3390 if ( csrIsWapiOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3391 {
3392 fYes = TRUE;
3393 break;
3394 }
3395 }
3396
3397 if ( fYes && Oui )
3398 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303399 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 }
3401
3402 return( fYes );
3403}
3404#endif /* FEATURE_WLAN_WAPI */
3405
3406static tANI_BOOLEAN csrIsWpaOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3407{
Kiet Lam64c1b492013-07-12 13:56:44 +05303408 return(vos_mem_compare(Oui1, Oui2, CSR_WPA_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003409}
3410
3411static tANI_BOOLEAN csrIsOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3412 tANI_U8 cAllCyphers,
3413 tANI_U8 Cypher[],
3414 tANI_U8 Oui[] )
3415{
3416 tANI_BOOLEAN fYes = FALSE;
3417 tANI_U8 idx;
3418
3419 for ( idx = 0; idx < cAllCyphers; idx++ )
3420 {
3421 if ( csrIsWpaOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3422 {
3423 fYes = TRUE;
3424 break;
3425 }
3426 }
3427
3428 if ( fYes && Oui )
3429 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303430 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 }
3432
3433 return( fYes );
3434}
3435
3436static tANI_BOOLEAN csrMatchRSNOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3437 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3438 tANI_U8 Oui[] )
3439{
3440 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui[ouiIndex], Oui ) );
3441
3442}
3443
3444#ifdef FEATURE_WLAN_WAPI
3445static tANI_BOOLEAN csrMatchWapiOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3446 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3447 tANI_U8 Oui[] )
3448{
Kaushik, Sushantfe230152014-04-08 14:37:47 +05303449 if (ouiIndex < CSR_WAPI_OUI_ROW_SIZE)// since csrWapiOui row size is 3 .
3450 return( csrIsWapiOuiMatch( pMac, AllCyphers, cAllCyphers,
3451 csrWapiOui[ouiIndex], Oui ) );
3452 else
3453 return FALSE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07003454
3455}
3456#endif /* FEATURE_WLAN_WAPI */
3457
3458static tANI_BOOLEAN csrMatchWPAOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3459 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3460 tANI_U8 Oui[] )
3461{
3462 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui[ouiIndex], Oui ) );
3463
3464}
3465
3466#if 0
3467static tANI_BOOLEAN csrIsRSNUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3468 tANI_U8 cAllCyphers,
3469 tANI_U8 Oui[] )
3470{
3471 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui00, Oui ) );
3472}
3473
3474static tANI_BOOLEAN csrIsRSNMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3475 tANI_U8 cAllCyphers,
3476 tANI_U8 Oui[] )
3477{
3478 tANI_BOOLEAN fYes = FALSE;
3479
3480 // Check Wep 104 first, if fails, then check Wep40.
3481 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui05, Oui );
3482
3483 if ( !fYes )
3484 {
3485 // if not Wep-104, check Wep-40
3486 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui01, Oui );
3487 }
3488
3489 return( fYes );
3490}
3491
3492
3493static tANI_BOOLEAN csrIsRSNUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3494 tANI_U8 cAllCyphers,
3495 tANI_U8 Oui[] )
3496{
3497 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3498}
3499
3500
3501static tANI_BOOLEAN csrIsRSNMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3502 tANI_U8 cAllCyphers,
3503 tANI_U8 Oui[] )
3504{
3505 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3506}
3507
3508static tANI_BOOLEAN csrIsRSNUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3509 tANI_U8 cAllCyphers,
3510 tANI_U8 Oui[] )
3511{
3512 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3513}
3514
3515static tANI_BOOLEAN csrIsRSNMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3516 tANI_U8 cAllCyphers,
3517 tANI_U8 Oui[] )
3518{
3519 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3520}
3521#endif
3522#ifdef FEATURE_WLAN_WAPI
3523static tANI_BOOLEAN csrIsAuthWapiCert( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3524 tANI_U8 cAllSuites,
3525 tANI_U8 Oui[] )
3526{
3527 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[1], Oui ) );
3528}
3529static tANI_BOOLEAN csrIsAuthWapiPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3530 tANI_U8 cAllSuites,
3531 tANI_U8 Oui[] )
3532{
3533 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[2], Oui ) );
3534}
3535#endif /* FEATURE_WLAN_WAPI */
3536
3537#ifdef WLAN_FEATURE_VOWIFI_11R
3538
3539/*
3540 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3541 * here. This matches for FT Auth with the 802.1X exchange.
3542 *
3543 */
3544static tANI_BOOLEAN csrIsFTAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3545 tANI_U8 cAllSuites,
3546 tANI_U8 Oui[] )
3547{
3548 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[03], Oui ) );
3549}
3550
3551/*
3552 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3553 * here. This matches for FT Auth with the PSK.
3554 *
3555 */
3556static tANI_BOOLEAN csrIsFTAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3557 tANI_U8 cAllSuites,
3558 tANI_U8 Oui[] )
3559{
3560 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[04], Oui ) );
3561}
3562
3563#endif
3564
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003565#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003566
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003567/*
3568 * Function for ESE CCKM AKM Authentication. We match the CCKM AKM Authentication Key Management suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 * here. This matches for CCKM AKM Auth with the 802.1X exchange.
3570 *
3571 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003572static tANI_BOOLEAN csrIsEseCckmAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 tANI_U8 cAllSuites,
3574 tANI_U8 Oui[] )
3575{
3576 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[06], Oui ) );
3577}
3578
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003579static tANI_BOOLEAN csrIsEseCckmAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 tANI_U8 cAllSuites,
3581 tANI_U8 Oui[] )
3582{
3583 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[06], Oui ) );
3584}
3585
3586#endif
3587
3588static tANI_BOOLEAN csrIsAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3589 tANI_U8 cAllSuites,
3590 tANI_U8 Oui[] )
3591{
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[01], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003593}
3594static tANI_BOOLEAN csrIsAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3595 tANI_U8 cAllSuites,
3596 tANI_U8 Oui[] )
3597{
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[02], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003599}
3600
Chet Lanctot186b5732013-03-18 10:26:30 -07003601#ifdef WLAN_FEATURE_11W
3602static tANI_BOOLEAN csrIsAuthRSNPskSha256( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3603 tANI_U8 cAllSuites,
3604 tANI_U8 Oui[] )
3605{
Chet Lanctot4c986162013-05-08 13:59:56 -07003606 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[07], Oui );
Chet Lanctot186b5732013-03-18 10:26:30 -07003607}
Abhishek Singhae408032014-09-25 17:22:04 +05303608static tANI_BOOLEAN csrIsAuthRSN8021xSha256(tpAniSirGlobal pMac,
3609 tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3610 tANI_U8 cAllSuites,
3611 tANI_U8 Oui[] )
3612{
3613 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[8], Oui );
3614}
Chet Lanctot186b5732013-03-18 10:26:30 -07003615#endif
3616
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303617#ifdef WLAN_FEATURE_SAE
3618/**
3619 * csr_is_auth_wpa_sae() - check whether oui is SAE
3620 * @mac: Global MAC context
3621 * @all_suites: pointer to all supported akm suites
3622 * @suite_count: all supported akm suites count
3623 * @oui: Oui needs to be matched
3624 *
3625 * Return: True if OUI is SAE, false otherwise
3626 */
3627static bool csr_is_auth_wpa_sae(tpAniSirGlobal mac,
3628 uint8_t all_suites[][CSR_RSN_OUI_SIZE],
3629 uint8_t suite_count, uint8_t oui[])
3630{
3631 return csrIsOuiMatch(mac, all_suites, suite_count, csrRSNOui[ENUM_SAE],
3632 oui);
3633}
3634#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +05303635
3636/**
3637 * csr_is_auth_wpa_sae() - check whether oui is OWE
3638 * @mac: Global MAC context
3639 * @all_suites: pointer to all supported akm suites
3640 * @suite_count: all supported akm suites count
3641 * @oui: Oui needs to be matched
3642 *
3643 * Return: True if OUI is SAE, false otherwise
3644 */
3645static bool csr_is_auth_wpa_owe(tpAniSirGlobal mac,
3646 uint8_t all_suites[][CSR_RSN_OUI_SIZE],
3647 uint8_t suite_count, uint8_t oui[])
3648{
3649 return csrIsOuiMatch
3650 (mac, all_suites, suite_count, csrRSNOui[ENUM_OWE], oui);
3651}
3652
Jeff Johnson295189b2012-06-20 16:38:30 -07003653static tANI_BOOLEAN csrIsAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3654 tANI_U8 cAllSuites,
3655 tANI_U8 Oui[] )
3656{
3657 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[01], Oui ) );
3658}
3659
3660#ifdef NOT_CURRENTLY_USED
3661static tANI_BOOLEAN csrIsAuth802_1x( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3662 tANI_U8 cAllSuites,
3663 tANI_U8 Oui[] )
3664{
3665 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[00], Oui ) );
3666}
3667#endif // NOT_CURRENTLY_USED
3668
3669static tANI_BOOLEAN csrIsAuthWpaPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3670 tANI_U8 cAllSuites,
3671 tANI_U8 Oui[] )
3672{
3673 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[02], Oui ) );
3674}
3675#if 0
3676static tANI_BOOLEAN csrIsUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3677 tANI_U8 cAllCyphers,
3678 tANI_U8 Oui[] )
3679{
3680 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui00, Oui ) );
3681}
3682
3683static tANI_BOOLEAN csrIsUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3684 tANI_U8 cAllCyphers,
3685 tANI_U8 Oui[] )
3686{
3687 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3688}
3689
3690static tANI_BOOLEAN csrIsUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3691 tANI_U8 cAllCyphers,
3692 tANI_U8 Oui[] )
3693{
3694 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3695}
3696
3697
3698static tANI_BOOLEAN csrIsMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3699 tANI_U8 cAllCyphers,
3700 tANI_U8 Oui[] )
3701{
3702 tANI_BOOLEAN fYes = FALSE;
3703
3704 // Check Wep 104 first, if fails, then check Wep40.
3705 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui05, Oui );
3706
3707 if ( !fYes )
3708 {
3709 // if not Wep-104, check Wep-40
3710 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui01, Oui );
3711 }
3712
3713 return( fYes );
3714}
3715
3716
3717static tANI_BOOLEAN csrIsMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3718 tANI_U8 cAllCyphers,
3719 tANI_U8 Oui[] )
3720{
3721 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3722}
3723
3724
3725static tANI_BOOLEAN csrIsMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3726 tANI_U8 cAllCyphers,
3727 tANI_U8 Oui[] )
3728{
3729 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3730}
3731
3732#endif
3733
3734tANI_U8 csrGetOUIIndexFromCipher( eCsrEncryptionType enType )
3735{
3736 tANI_U8 OUIIndex;
3737
3738 switch ( enType )
3739 {
3740 case eCSR_ENCRYPT_TYPE_WEP40:
3741 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3742 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX;
3743 break;
3744 case eCSR_ENCRYPT_TYPE_WEP104:
3745 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3746 OUIIndex = CSR_OUI_WEP104_INDEX;
3747 break;
3748 case eCSR_ENCRYPT_TYPE_TKIP:
3749 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX;
3750 break;
3751 case eCSR_ENCRYPT_TYPE_AES:
3752 OUIIndex = CSR_OUI_AES_INDEX;
3753 break;
3754 case eCSR_ENCRYPT_TYPE_NONE:
3755 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX;
3756 break;
3757#ifdef FEATURE_WLAN_WAPI
3758 case eCSR_ENCRYPT_TYPE_WPI:
3759 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX;
3760 break;
3761#endif /* FEATURE_WLAN_WAPI */
3762 default: //HOWTO handle this?
3763 OUIIndex = CSR_OUI_RESERVED_INDEX;
3764 break;
3765 }//switch
3766
3767 return OUIIndex;
3768}
3769
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303770#ifdef WLAN_FEATURE_SAE
3771/**
3772 * csr_check_sae_auth() - update negotiated auth if matches to SAE auth type
3773 * @mac_ctx: pointer to mac context
3774 * @authsuites: auth suites
3775 * @c_auth_suites: auth suites count
3776 * @authentication: authentication
3777 * @auth_type: authentication type list
3778 * @index: current counter
3779 * @neg_authtype: pointer to negotiated auth
3780 *
3781 * Return: None
3782 */
3783static void csr_check_sae_auth(tpAniSirGlobal mac_ctx,
3784 uint8_t authsuites[][CSR_RSN_OUI_SIZE],
3785 uint8_t c_auth_suites,
3786 uint8_t authentication[],
3787 tCsrAuthList *auth_type,
3788 uint8_t index, eCsrAuthType *neg_authtype)
3789{
3790 if ((*neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) &&
3791 csr_is_auth_wpa_sae(mac_ctx, authsuites, c_auth_suites,
3792 authentication)) {
3793 if (eCSR_AUTH_TYPE_SAE == auth_type->authType[index])
3794 *neg_authtype = eCSR_AUTH_TYPE_SAE;
Abhinav Kumar2184e162019-09-16 15:02:24 +05303795 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == auth_type->authType[index])
3796 *neg_authtype = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303797 }
3798 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3799 FL("negotiated auth type is %d"), *neg_authtype);
3800}
3801#else
3802static void csr_check_sae_auth(tpAniSirGlobal mac_ctx,
3803 uint8_t authsuites[][CSR_RSN_OUI_SIZE],
3804 uint8_t c_auth_suites,
3805 uint8_t authentication[],
3806 tCsrAuthList *auth_type,
3807 uint8_t index, eCsrAuthType *neg_authtype)
3808{
3809}
3810#endif
3811
Jeff Johnson295189b2012-06-20 16:38:30 -07003812tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3813 tDot11fIERSN *pRSNIe,
3814 tANI_U8 *UnicastCypher,
3815 tANI_U8 *MulticastCypher,
3816 tANI_U8 *AuthSuite,
3817 tCsrRSNCapabilities *Capabilities,
3818 eCsrAuthType *pNegotiatedAuthtype,
3819 eCsrEncryptionType *pNegotiatedMCCipher )
3820{
3821 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3822 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3823 tANI_U8 cUnicastCyphers = 0;
3824 tANI_U8 cMulticastCyphers = 0;
3825 tANI_U8 cAuthSuites = 0, i;
3826 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3827 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3828 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3829 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3830 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3831 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3832
3833 do{
3834 if ( pRSNIe->present )
3835 {
3836 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303837 vos_mem_copy(MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05303839 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_cnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3841 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303842 vos_mem_copy((void *)&AuthSuites[i],
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05303843 (void *)&pRSNIe->akm_suite[i],
Kiet Lam64c1b492013-07-12 13:56:44 +05303844 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 }
3846
3847 //Check - Is requested Unicast Cipher supported by the BSS.
3848 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3849 csrGetOUIIndexFromCipher( enType ), Unicast );
3850
3851 if( !fAcceptableCyphers ) break;
3852
3853
3854 //Unicast is supported. Pick the first matching Group cipher, if any.
3855 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3856 {
3857 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3858 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3859 if(fAcceptableCyphers)
3860 {
3861 break;
3862 }
3863 }
3864 if( !fAcceptableCyphers ) break;
3865
3866 if( pNegotiatedMCCipher )
3867 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3868
3869 /* Initializing with FALSE as it has TRUE value already */
3870 fAcceptableCyphers = FALSE;
3871 for (i = 0 ; i < pAuthType->numEntries; i++)
3872 {
3873 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303874
3875 /* Set SAE as first preference */
3876 csr_check_sae_auth(pMac, AuthSuites, cAuthSuites,
3877 Authentication, pAuthType, i, &negAuthType);
3878
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 #ifdef WLAN_FEATURE_VOWIFI_11R
3880 /* Changed the AKM suites according to order of preference */
3881 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3882 {
3883 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3884 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3885 }
3886 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3887 {
3888 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3889 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3890 }
3891#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003892#ifdef FEATURE_WLAN_ESE
3893 /* ESE only supports 802.1X. No PSK. */
3894 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 {
3896 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3897 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3898 }
3899#endif
3900 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3901 {
3902 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3903 negAuthType = eCSR_AUTH_TYPE_RSN;
3904 }
3905 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3906 {
3907 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3908 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3909 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003910#ifdef WLAN_FEATURE_11W
3911 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3912 {
3913 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3914 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3915 }
Abhishek Singhae408032014-09-25 17:22:04 +05303916 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) &&
3917 csrIsAuthRSN8021xSha256(pMac, AuthSuites,
3918 cAuthSuites, Authentication)) {
3919 if (eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
3920 pAuthType->authType[i])
3921 negAuthType = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3922 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003923#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +05303924 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) &&
3925 csr_is_auth_wpa_owe(pMac, AuthSuites,
3926 cAuthSuites, Authentication)) {
3927 if (eCSR_AUTH_TYPE_OWE == pAuthType->authType[i])
3928 negAuthType = eCSR_AUTH_TYPE_OWE;
3929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003930
3931 // The 1st auth type in the APs RSN IE, to match stations connecting
3932 // profiles auth type will cause us to exit this loop
3933 // This is added as some APs advertise multiple akms in the RSN IE.
3934 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3935 {
3936 fAcceptableCyphers = TRUE;
3937 break;
3938 }
3939 } // for
3940 }
3941
3942 }while (0);
3943
3944 if ( fAcceptableCyphers )
3945 {
3946 if ( MulticastCypher )
3947 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303948 vos_mem_copy(MulticastCypher, Multicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 }
3950
3951 if ( UnicastCypher )
3952 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303953 vos_mem_copy(UnicastCypher, Unicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 }
3955
3956 if ( AuthSuite )
3957 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303958 vos_mem_copy(AuthSuite, Authentication, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 }
3960
3961 if ( pNegotiatedAuthtype )
3962 {
3963 *pNegotiatedAuthtype = negAuthType;
3964 }
3965 if ( Capabilities )
3966 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003967 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3968 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3969 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003970 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
Abhishek Singhf53e89d2015-06-18 12:30:00 +05303971#ifdef WLAN_FEATURE_11W
Chet Lanctot186b5732013-03-18 10:26:30 -07003972 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3973 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
Abhishek Singhf53e89d2015-06-18 12:30:00 +05303974#else
3975 Capabilities->MFPRequired = 0 ; // Bit 6 MFPR
3976 Capabilities->MFPCapable = 0 ; // Bit 7 MFPC
3977#endif
3978
Chet Lanctot186b5732013-03-18 10:26:30 -07003979 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 }
3981 }
3982 return( fAcceptableCyphers );
3983}
3984
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303985#ifdef WLAN_FEATURE_11W
3986/* ---------------------------------------------------------------------------
3987 \fn csrIsPMFCapabilitiesInRSNMatch
Jeff Johnson295189b2012-06-20 16:38:30 -07003988
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303989 \brief this function is to match our current capabilities with the AP
3990 to which we are expecting make the connection.
3991
3992 \param hHal - HAL Pointer
3993 pFilterMFPEnabled - given by supplicant to us to specify what kind
3994 of connection supplicant is expecting to make
3995 if it is enabled then make PMF connection.
3996 if it is disabled then make normal connection.
3997 pFilterMFPRequired - given by supplicant based on our configuration
3998 if it is 1 then we will require mandatory
3999 PMF connection and if it is 0 then we PMF
4000 connection is optional.
4001 pFilterMFPCapable - given by supplicant based on our configuration
4002 if it 1 then we are PMF capable and if it 0
4003 then we are not PMF capable.
4004 pRSNIe - RSNIe from Beacon/probe response of
4005 neighbor AP against which we will compare
4006 our capabilities.
4007
4008 \return tANI_BOOLEAN - if our PMF capabilities matches with AP then we
4009 will return true to indicate that we are good
4010 to make connection with it. Else we will return
4011 false.
4012 -------------------------------------------------------------------------------*/
4013static tANI_BOOLEAN
4014csrIsPMFCapabilitiesInRSNMatch( tHalHandle hHal,
4015 tANI_BOOLEAN *pFilterMFPEnabled,
4016 tANI_U8 *pFilterMFPRequired,
4017 tANI_U8 *pFilterMFPCapable,
4018 tDot11fIERSN *pRSNIe)
4019{
4020 tANI_U8 apProfileMFPCapable = 0;
4021 tANI_U8 apProfileMFPRequired = 0;
4022 if (pRSNIe && pFilterMFPEnabled && pFilterMFPCapable && pFilterMFPRequired)
4023 {
4024 /* Extracting MFPCapable bit from RSN Ie */
4025 apProfileMFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1;
4026 apProfileMFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1;
4027 if (*pFilterMFPEnabled && *pFilterMFPCapable && *pFilterMFPRequired
4028 && (apProfileMFPCapable == 0))
4029 {
4030 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4031 "AP is not capable to make PMF connection");
4032 return VOS_FALSE;
4033 }
4034 else if (*pFilterMFPEnabled && *pFilterMFPCapable &&
4035 !(*pFilterMFPRequired) && (apProfileMFPCapable == 0))
4036 {
4037 /*
4038 * This is tricky, because supplicant asked us to make mandatory
4039 * PMF connection eventhough PMF connection is optional here.
4040 * so if AP is not capable of PMF then drop it. Don't try to
4041 * connect with it.
4042 */
4043 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4044 "we need PMF connection & AP isn't capable to make PMF connection");
4045 return VOS_FALSE;
4046 }
4047 else if (!(*pFilterMFPCapable) &&
4048 apProfileMFPCapable && apProfileMFPRequired)
4049 {
4050 /*
4051 * In this case, AP with whom we trying to connect requires
4052 * mandatory PMF connections and we are not capable so this AP
4053 * is not good choice to connect
4054 */
4055 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4056 "AP needs PMF connection and we are not capable of pmf connection");
4057 return VOS_FALSE;
4058 }
4059 else if (!(*pFilterMFPEnabled) && *pFilterMFPCapable &&
4060 (apProfileMFPCapable == 1))
4061 {
4062 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4063 "we don't need PMF connection eventhough both parties are capable");
4064 return VOS_FALSE;
4065 }
4066 }
4067 return VOS_TRUE;
4068}
4069#endif
4070
4071tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType,
4072 eCsrEncryptionType enType,
4073 tCsrEncryptionList *pEnMcType,
4074 tANI_BOOLEAN *pMFPEnabled, tANI_U8 *pMFPRequired,
4075 tANI_U8 *pMFPCapable,
4076 tDot11fBeaconIEs *pIes,
4077 eCsrAuthType *pNegotiatedAuthType,
4078 eCsrEncryptionType *pNegotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07004079{
4080 tANI_BOOLEAN fRSNMatch = FALSE;
4081
4082 // See if the cyphers in the Bss description match with the settings in the profile.
4083 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
4084 pNegotiatedAuthType, pNegotiatedMCCipher );
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05304085#ifdef WLAN_FEATURE_11W
4086 /* If all the filter matches then finally checks for PMF capabilities */
4087 if (fRSNMatch)
4088 {
4089 fRSNMatch = csrIsPMFCapabilitiesInRSNMatch( hHal, pMFPEnabled,
4090 pMFPRequired, pMFPCapable,
4091 &pIes->RSN);
4092 }
4093#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004094
4095 return( fRSNMatch );
4096}
4097
Abhinav Kumar8c122592019-08-07 15:43:20 +05304098/**
4099 * csr_lookup_pmkid_using_ssid() - lookup pmkid using ssid and cache_id
4100 * @mac: pointer to mac
4101 * @session: sme session pointer
4102 * @pmk_cache: pointer to pmk cache
4103 * @index: index value needs to be seached
4104 *
4105 * Return: true if pmkid is found else false
4106 */
4107static bool csr_lookup_pmkid_using_ssid(tpAniSirGlobal mac,
4108 tCsrRoamSession *session,
4109 tPmkidCacheInfo *pmk_cache,
4110 uint32_t *index)
4111{
4112 uint32_t i;
4113 tPmkidCacheInfo *session_pmk;
Jeff Johnson295189b2012-06-20 16:38:30 -07004114
Abhinav Kumar8c122592019-08-07 15:43:20 +05304115 for (i = 0; i < session->NumPmkidCache; i++) {
4116 session_pmk = &session->PmkidCacheInfo[i];
4117
4118 if ((!vos_mem_compare(pmk_cache->ssid, session_pmk->ssid,
4119 pmk_cache->ssid_len)) &&
4120 (!vos_mem_compare(session_pmk->cache_id,
4121 pmk_cache->cache_id, CACHE_ID_LEN))) {
4122 /* match found */
4123 *index = i;
4124 return true;
4125 }
4126 }
4127
4128 return false;
4129}
4130
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05304131bool csr_lookup_pmkid_using_bssid(tpAniSirGlobal mac,
Abhinav Kumar8c122592019-08-07 15:43:20 +05304132 tCsrRoamSession *session,
4133 tPmkidCacheInfo *pmk_cache,
4134 uint32_t *index)
4135{
4136 uint32_t i;
4137 tPmkidCacheInfo *session_pmk;
4138
4139 for (i = 0; i < session->NumPmkidCache; i++) {
4140 session_pmk = &session->PmkidCacheInfo[i];
4141 if (vos_is_macaddr_equal((v_MACADDR_t *)pmk_cache->BSSID,
4142 (v_MACADDR_t *)session_pmk->BSSID)) {
4143 /* match found */
4144 *index = i;
4145 return true;
4146 }
4147 }
4148
4149 return false;
4150}
4151
4152tANI_BOOLEAN csrLookupPMKID(tpAniSirGlobal pMac, tANI_U32 sessionId,
4153 tPmkidCacheInfo *pmk_cache)
4154
Jeff Johnson295189b2012-06-20 16:38:30 -07004155{
4156 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4157 tANI_U32 Index;
4158 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4159
Jeff Johnson32d95a32012-09-10 13:15:23 -07004160 if(!pSession)
4161 {
4162 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4163 return FALSE;
4164 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07004165 /* to force the AP initiate fresh 802.1x authentication after re-association should not
4166 * fill the PMKID from cache this is needed
4167 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
4168
4169 if(pSession->fIgnorePMKIDCache)
4170 {
4171 pSession->fIgnorePMKIDCache = FALSE;
4172 return fRC;
4173 }
4174
Abhinav Kumar8c122592019-08-07 15:43:20 +05304175 if (pmk_cache->ssid_len) {
4176 /* Try to find based on cache_id and ssid first */
4177 fMatchFound = csr_lookup_pmkid_using_ssid(pMac, pSession, pmk_cache,
4178 &Index);
4179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004180
Abhinav Kumar8c122592019-08-07 15:43:20 +05304181 /* If not able to find using cache id or ssid_len is not present */
4182 if (!fMatchFound)
4183 fMatchFound = csr_lookup_pmkid_using_bssid(pMac, pSession, pmk_cache,
4184 &Index);
Jeff Johnson295189b2012-06-20 16:38:30 -07004185
Abhinav Kumar8c122592019-08-07 15:43:20 +05304186 if (!fMatchFound) {
4187 smsLog(pMac, LOG2, "No PMKID Match Found");
4188 return false;
Jeff Johnson295189b2012-06-20 16:38:30 -07004189
Abhinav Kumar8c122592019-08-07 15:43:20 +05304190 }
4191
4192 vos_mem_copy(pmk_cache->PMKID, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE);
4193 vos_mem_copy(pmk_cache->pmk, pSession->PmkidCacheInfo[Index].pmk,
4194 pSession->PmkidCacheInfo[Index].pmk_len);
4195 pmk_cache->pmk_len = pSession->PmkidCacheInfo[Index].pmk_len;
4196
4197 fRC = TRUE;
4198
Sushant Kaushik0b343422015-05-25 17:15:55 +05304199 smsLog(pMac, LOG1, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 fRC, pSession->NumPmkidCache);
4201
4202 return fRC;
4203}
4204
4205
4206tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4207 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
4208{
4209 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4210 tANI_BOOLEAN fRSNMatch;
4211 tANI_U8 cbRSNIe = 0;
4212 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
4213 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
4214 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
4215 tCsrRSNAuthIe *pAuthSuite;
4216 tCsrRSNCapabilities RSNCapabilities;
4217 tCsrRSNPMKIe *pPMK;
Abhinav Kumar8c122592019-08-07 15:43:20 +05304218 tPmkidCacheInfo pmkid_cache;
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304219 uint32_t ret;
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004220#ifdef WLAN_FEATURE_11W
4221 tANI_U8 *pGroupMgmtCipherSuite;
4222#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 tDot11fBeaconIEs *pIesLocal = pIes;
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304224 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
Abhinav Kumar12560c32018-08-27 18:14:00 +05304225 tDot11fIERSN rsn_ie = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07004226
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004227 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004228
sheenam mongab433f102019-12-13 18:55:50 +05304229 vos_mem_zero(&pmkid_cache, sizeof(pmkid_cache));
4230
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 do
4232 {
4233 if ( !csrIsProfileRSN( pProfile ) ) break;
4234
4235 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4236 {
4237 break;
4238 }
4239
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304240 /* Use intersection of the RSN cap sent by user space and
4241 * the AP, so that only common capability are enabled.
4242 */
4243 if (pProfile->pRSNReqIE && pProfile->nRSNReqIELength) {
4244 ret = dot11fUnpackIeRSN(pMac, pProfile->pRSNReqIE + 2,
4245 pProfile->nRSNReqIELength -2, &rsn_ie);
4246 if (DOT11F_SUCCEEDED(ret)) {
4247 pIesLocal->RSN.RSN_Cap[0] = pIesLocal->RSN.RSN_Cap[0] &
4248 rsn_ie.RSN_Cap[0];
4249 pIesLocal->RSN.RSN_Cap[1] = pIesLocal->RSN.RSN_Cap[1] &
4250 rsn_ie.RSN_Cap[1];
4251 }
4252 }
4253
4254 /* See if the cyphers in the Bss description match with the settings in the profile */
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4256 &pProfile->mcEncryptionType, &pIesLocal->RSN,
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304257 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, &negAuthType, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 if ( !fRSNMatch ) break;
4259
4260 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
4261
4262 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
4263
Kiet Lam64c1b492013-07-12 13:56:44 +05304264 vos_mem_copy(pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004265
4266 pRSNIe->cUnicastCyphers = 1;
4267
Kiet Lam64c1b492013-07-12 13:56:44 +05304268 vos_mem_copy(&pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004269
4270 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
4271
4272 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304273 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004274
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304275 /* PreAuthSupported is an AP only capability */
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 RSNCapabilities.PreAuthSupported = 0;
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304277
4278 /* Use the Management Frame Protection values given by the supplicant,
4279 * if AP and STA both are MFP capable.
4280 */
Chet Lanctot186b5732013-03-18 10:26:30 -07004281#ifdef WLAN_FEATURE_11W
4282 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
4283 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
4284#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
4286
4287 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
Abhinav Kumar8c122592019-08-07 15:43:20 +05304288 vos_mem_copy((v_MACADDR_t *)pmkid_cache.BSSID,
4289 (v_MACADDR_t *)pSirBssDesc->bssId, VOS_MAC_ADDR_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004290
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304291 if (
4292#ifdef FEATURE_WLAN_ESE
4293 (eCSR_AUTH_TYPE_CCKM_RSN != negAuthType) &&
4294#endif
Abhinav Kumar8c122592019-08-07 15:43:20 +05304295 csrLookupPMKID( pMac, sessionId, &pmkid_cache))
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 {
4297 pPMK->cPMKIDs = 1;
4298
Abhinav Kumar8c122592019-08-07 15:43:20 +05304299 vos_mem_copy(pPMK->PMKIDList[0].PMKID, pmkid_cache.PMKID,
4300 CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 }
4302 else
4303 {
4304 pPMK->cPMKIDs = 0;
4305 }
4306
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004307#ifdef WLAN_FEATURE_11W
4308 if ( pProfile->MFPEnabled )
4309 {
4310 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
4311 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
Kiet Lam64c1b492013-07-12 13:56:44 +05304312 vos_mem_copy(pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE);
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004313 }
4314#endif
4315
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4317 // Add in the size of the Auth suite (count plus a single OUI)
4318 // Add in the RSN caps field.
4319 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004320 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
4322 sizeof( *pAuthSuite ) +
4323 sizeof( tCsrRSNCapabilities ));
4324 if(pPMK->cPMKIDs)
4325 {
4326 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
4327 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
4328 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004329#ifdef WLAN_FEATURE_11W
4330 if ( pProfile->MFPEnabled )
4331 {
4332 if ( 0 == pPMK->cPMKIDs )
4333 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
4334 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
4335 }
4336#endif
4337
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 // return the size of the IE header (total) constructed...
4339 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
4340
4341 } while( 0 );
4342
4343 if( !pIes && pIesLocal )
4344 {
4345 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304346 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 }
4348
4349 return( cbRSNIe );
4350}
4351
4352
4353#ifdef FEATURE_WLAN_WAPI
4354tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4355 tDot11fIEWAPI *pWapiIe,
4356 tANI_U8 *UnicastCypher,
4357 tANI_U8 *MulticastCypher,
4358 tANI_U8 *AuthSuite,
4359 eCsrAuthType *pNegotiatedAuthtype,
4360 eCsrEncryptionType *pNegotiatedMCCipher )
4361{
4362 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4363 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4364 tANI_U8 cUnicastCyphers = 0;
4365 tANI_U8 cMulticastCyphers = 0;
4366 tANI_U8 cAuthSuites = 0, i;
4367 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
4368 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
4369 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
4370 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
4371 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
4372 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4373
4374 do{
4375 if ( pWapiIe->present )
4376 {
4377 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05304378 vos_mem_copy(MulticastCyphers, pWapiIe->multicast_cipher_suite,
4379 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
4381 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
4382 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
4383 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304384 vos_mem_copy((void *)&AuthSuites[i], (void *)&pWapiIe->akm_suites[i],
4385 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 }
4387
4388 //Check - Is requested Unicast Cipher supported by the BSS.
4389 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
4390 csrGetOUIIndexFromCipher( enType ), Unicast );
4391
4392 if( !fAcceptableCyphers ) break;
4393
4394
4395 //Unicast is supported. Pick the first matching Group cipher, if any.
4396 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4397 {
4398 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4399 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
4400 if(fAcceptableCyphers)
4401 {
4402 break;
4403 }
4404 }
4405 if( !fAcceptableCyphers ) break;
4406
4407 if( pNegotiatedMCCipher )
4408 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4409
4410 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4411 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
4412 {
4413 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4414 }
4415 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
4416 {
4417 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4418 }
4419 else
4420 {
4421 fAcceptableCyphers = FALSE;
4422 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4423 }
4424 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
4425 {
4426 //Caller doesn't care about auth type, or BSS doesn't match
4427 break;
4428 }
4429 fAcceptableCyphers = FALSE;
4430 for( i = 0 ; i < pAuthType->numEntries; i++ )
4431 {
4432 if( pAuthType->authType[i] == negAuthType )
4433 {
4434 fAcceptableCyphers = TRUE;
4435 break;
4436 }
4437 }
4438 }
4439 }while (0);
4440
4441 if ( fAcceptableCyphers )
4442 {
4443 if ( MulticastCypher )
4444 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304445 vos_mem_copy(MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 }
4447
4448 if ( UnicastCypher )
4449 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304450 vos_mem_copy(UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 }
4452
4453 if ( AuthSuite )
4454 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304455 vos_mem_copy(AuthSuite, Authentication, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 }
4457
4458 if ( pNegotiatedAuthtype )
4459 {
4460 *pNegotiatedAuthtype = negAuthType;
4461 }
4462 }
4463 return( fAcceptableCyphers );
4464}
4465
4466tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4467 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
4468{
4469 tANI_BOOLEAN fWapiMatch = FALSE;
4470
4471 // See if the cyphers in the Bss description match with the settings in the profile.
4472 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4473 pNegotiatedAuthType, pNegotiatedMCCipher );
4474
4475 return( fWapiMatch );
4476}
4477
4478tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4479{
4480 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4481 tANI_U32 Index;
4482 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4483
Jeff Johnson32d95a32012-09-10 13:15:23 -07004484 if(!pSession)
4485 {
4486 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4487 return FALSE;
4488 }
4489
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 do
4491 {
4492 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4493 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004494 smsLog(pMac, LOGW, "match BKID "MAC_ADDRESS_STR" to ",
4495 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05304496 if (vos_mem_compare(pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 {
4498 // match found
4499 fMatchFound = TRUE;
4500 break;
4501 }
4502 }
4503
4504 if( !fMatchFound ) break;
4505
Kiet Lam64c1b492013-07-12 13:56:44 +05304506 vos_mem_copy(pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004507
4508 fRC = TRUE;
4509 }
4510 while( 0 );
4511 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4512
4513 return fRC;
4514}
4515
4516tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4517 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4518{
4519 tANI_BOOLEAN fWapiMatch = FALSE;
4520 tANI_U8 cbWapiIe = 0;
4521 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4522 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4523 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4524 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4525 tANI_U8 *pWapi = NULL;
4526 tANI_BOOLEAN fBKIDFound = FALSE;
4527 tDot11fBeaconIEs *pIesLocal = pIes;
4528
4529 do
4530 {
4531 if ( !csrIsProfileWapi( pProfile ) ) break;
4532
4533 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4534 {
4535 break;
4536 }
4537
4538 // See if the cyphers in the Bss description match with the settings in the profile.
4539 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4540 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4541 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4542 if ( !fWapiMatch ) break;
4543
Kiet Lam64c1b492013-07-12 13:56:44 +05304544 vos_mem_set(pWapiIe, sizeof(tCsrWapiIe), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004545
4546 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4547
4548 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4549
4550 pWapiIe->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304551 vos_mem_copy(&pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004552
4553 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4554
4555 *pWapi = (tANI_U16)1; //cUnicastCyphers
4556 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304557 vos_mem_copy(pWapi, UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 pWapi += sizeof( UnicastCypher );
4559
Kiet Lam64c1b492013-07-12 13:56:44 +05304560 vos_mem_copy(pWapi, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 pWapi += sizeof( MulticastCypher );
4562
4563
4564 // WAPI capabilities follows the Auth Suite (two octects)
4565 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4566 // & since we already did a memset pWapiIe to 0, skip these fields
4567 pWapi +=2;
4568
4569 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4570
4571
4572 if( fBKIDFound )
4573 {
4574 /* Do we need to change the endianness here */
4575 *pWapi = (tANI_U16)1; //cBKIDs
4576 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304577 vos_mem_copy(pWapi, BKId, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 }
4579 else
4580 {
4581 *pWapi = 0;
4582 pWapi+=1;
4583 *pWapi = 0;
4584 pWapi+=1;
4585 }
4586
4587 // Add in the IE fields except the IE header
4588 // Add BKID count and BKID (if any)
4589 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4590
4591 /*2 bytes for BKID Count field*/
4592 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4593
4594 if(fBKIDFound)
4595 {
4596 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4597 }
4598 // return the size of the IE header (total) constructed...
4599 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4600
4601 } while( 0 );
4602
4603 if( !pIes && pIesLocal )
4604 {
4605 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304606 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 }
4608
4609 return( cbWapiIe );
4610}
4611#endif /* FEATURE_WLAN_WAPI */
4612
4613tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4614 tDot11fIEWPA *pWpaIe,
4615 tANI_U8 *UnicastCypher,
4616 tANI_U8 *MulticastCypher,
4617 tANI_U8 *AuthSuite,
4618 eCsrAuthType *pNegotiatedAuthtype,
4619 eCsrEncryptionType *pNegotiatedMCCipher )
4620{
4621 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4622 tANI_U8 cUnicastCyphers = 0;
4623 tANI_U8 cMulticastCyphers = 0;
4624 tANI_U8 cAuthSuites = 0;
4625 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4626 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4627 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4628 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4629 tANI_U8 i;
4630 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4631
4632 do
4633 {
4634 if ( pWpaIe->present )
4635 {
4636 cMulticastCyphers = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304637 vos_mem_copy(MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4639 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4640
4641 //Check - Is requested Unicast Cipher supported by the BSS.
4642 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4643 csrGetOUIIndexFromCipher( enType ), Unicast );
4644
4645 if( !fAcceptableCyphers ) break;
4646
4647
4648 //Unicast is supported. Pick the first matching Group cipher, if any.
4649 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4650 {
4651 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4652 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4653 if(fAcceptableCyphers)
4654 {
4655 break;
4656 }
4657 }
4658 if( !fAcceptableCyphers ) break;
4659
4660 if( pNegotiatedMCCipher )
4661 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4662
4663 /* Initializing with FALSE as it has TRUE value already */
4664 fAcceptableCyphers = FALSE;
4665 for (i = 0 ; i < pAuthType->numEntries; i++)
4666 {
4667 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4668 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4669 {
4670 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4671 negAuthType = eCSR_AUTH_TYPE_WPA;
4672 }
4673 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4674 {
4675 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4676 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4677 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004678#ifdef FEATURE_WLAN_ESE
4679 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 {
4681 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4682 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4683 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004684#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004685
4686 // The 1st auth type in the APs WPA IE, to match stations connecting
4687 // profiles auth type will cause us to exit this loop
4688 // This is added as some APs advertise multiple akms in the WPA IE.
4689 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4690 {
4691 fAcceptableCyphers = TRUE;
4692 break;
4693 }
4694 } // for
4695 }
4696 }while(0);
4697
4698 if ( fAcceptableCyphers )
4699 {
4700 if ( MulticastCypher )
4701 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304702 vos_mem_copy((tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 }
4704
4705 if ( UnicastCypher )
4706 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304707 vos_mem_copy((tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 }
4709
4710 if ( AuthSuite )
4711 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304712 vos_mem_copy((tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 }
4714
4715 if( pNegotiatedAuthtype )
4716 {
4717 *pNegotiatedAuthtype = negAuthType;
4718 }
4719 }
4720
4721 return( fAcceptableCyphers );
4722}
4723
4724
4725
4726tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4727 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4728{
4729 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4730
4731 // See if the cyphers in the Bss description match with the settings in the profile.
4732 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4733
4734 return( fWpaMatch );
4735}
4736
4737
4738tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4739 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4740{
4741 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4742 tANI_BOOLEAN fWpaMatch;
4743 tANI_U8 cbWpaIe = 0;
4744 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4745 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4746 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4747 tCsrWpaAuthIe *pAuthSuite;
4748 tDot11fBeaconIEs *pIesLocal = pIes;
4749
4750 do
4751 {
4752 if ( !csrIsProfileWpa( pProfile ) ) break;
4753
4754 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4755 {
4756 break;
4757 }
4758 // See if the cyphers in the Bss description match with the settings in the profile.
4759 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4760 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4761 if ( !fWpaMatch ) break;
4762
4763 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4764
Kiet Lam64c1b492013-07-12 13:56:44 +05304765 vos_mem_copy(pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004766
4767 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4768
Kiet Lam64c1b492013-07-12 13:56:44 +05304769 vos_mem_copy(pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004770
4771 pWpaIe->cUnicastCyphers = 1;
4772
Kiet Lam64c1b492013-07-12 13:56:44 +05304773 vos_mem_copy(&pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004774
4775 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4776
4777 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304778 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004779
4780 // The WPA capabilities follows the Auth Suite (two octects)--
4781 // this field is optional, and we always "send" zero, so just
4782 // remove it. This is consistent with our assumptions in the
4783 // frames compiler; c.f. bug 15234:
4784 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4785
4786 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4787 // Add in the size of the Auth suite (count plus a single OUI)
4788 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4789 sizeof( *pAuthSuite );
4790
4791 // return the size of the IE header (total) constructed...
4792 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4793
4794 } while( 0 );
4795
4796 if( !pIes && pIesLocal )
4797 {
4798 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304799 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 }
4801
4802 return( cbWpaIe );
4803}
4804
4805
4806tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4807 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4808{
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 tDot11IEHeader *pIEHeader;
4810 tSirMacPropIE *pSirMacPropIE;
4811 tANI_U32 cbParsed;
4812 tANI_U32 cbIE;
4813 int cExpectedIEs = 0;
4814 int cFoundIEs = 0;
4815 int cbPropIETotal;
4816
4817 pIEHeader = (tDot11IEHeader *)pIes;
4818 if(pWpaIe) cExpectedIEs++;
4819 if(pRSNIe) cExpectedIEs++;
4820
4821 // bss description length includes all fields other than the length itself
4822 cbParsed = 0;
4823
4824 // Loop as long as there is data left in the IE of the Bss Description
4825 // and the number of Expected IEs is NOT found yet.
4826 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4827 {
4828 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4829
4830 if ( ( cbIE + cbParsed ) > len ) break;
4831
4832 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4833 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4834 {
4835 switch( pIEHeader->ElementID )
4836 {
4837 // Parse the 221 (0xdd) Proprietary IEs here...
4838 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4839 // Airgo proprietary IE information.
4840 case SIR_MAC_WPA_EID:
4841 {
4842 tANI_U32 aniOUI;
4843 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4844
4845 pOui++;
4846 aniOUI = ANI_OUI;
4847 aniOUI = i_ntohl( aniOUI );
4848
4849 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4850 cbPropIETotal = pSirMacPropIE->length;
4851
4852 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4853 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4854 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4855 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4856 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4857 {
4858 }
4859 else
4860 {
4861 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4862
4863 if(!pWpaIe || !pcbWpaIe) break;
4864 // Check if this is a valid WPA IE. Then check that the
4865 // WPA OUI is in place and the version is one that we support.
4866 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
Kiet Lam64c1b492013-07-12 13:56:44 +05304867 ( vos_mem_compare( pIe->Oui, (void *)csrWpaOui[1],
4868 sizeof( pIe->Oui ) ) ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4870 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304871 vos_mem_copy(pWpaIe, pIe,
4872 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4874 cFoundIEs++;
4875
4876 break;
4877 }
4878 }
4879
4880 break;
4881 }
4882
4883 case SIR_MAC_RSN_EID:
4884 {
4885 tCsrRSNIe *pIe;
4886
4887 if(!pcbRSNIe || !pRSNIe) break;
4888 pIe = (tCsrRSNIe *)pIEHeader;
4889
4890 // Check the length of the RSN Ie to assure it is valid. Then check that the
4891 // version is one that we support.
4892
4893 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4894 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4895
4896 cFoundIEs++;
4897
4898 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4899 // the buffer passed in.
4900 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05304901 vos_mem_copy(pRSNIe, pIe,
4902 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4904
4905 break;
4906 }
4907
4908 // Add support for other IE here...
4909 default:
4910 break;
4911 }
4912 }
4913
4914 cbParsed += cbIE;
4915
4916 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4917
4918 }
4919
4920 // return a BOOL that tells if all of the IEs asked for were found...
4921 return( cFoundIEs == cExpectedIEs );
4922}
4923
4924
4925//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4926//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4927tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4928 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4929{
4930 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4931 tANI_U8 cbWpaIe = 0;
4932
4933 do
4934 {
4935 if ( !csrIsProfileWpa( pProfile ) ) break;
4936 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4937 {
4938 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4939 {
4940 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304941 vos_mem_copy(pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 }
4943 else
4944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004945 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 }
4947 }
4948 else
4949 {
4950 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4951 }
4952 }while(0);
4953
4954 return (cbWpaIe);
4955}
4956
4957
4958//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4959//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4960tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4961 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4962{
4963 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4964 tANI_U8 cbRsnIe = 0;
4965
4966 do
4967 {
4968 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004969#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304970 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004971 {
4972 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4973 // scratch. So it contains the current PMK-IDs
4974 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4975 }
4976 else
4977#endif
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304978 if(pProfile->force_rsne_override &&
4979 pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 {
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304981 smsLog(pMac, LOGW, "force_rsne_override, copy RSN IE provided by user");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004982 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4984 {
4985 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304986 vos_mem_copy(pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 }
4988 else
4989 {
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304990 smsLog(pMac, LOGW, "csrRetrieveRsnIe detect invalid RSN IE length (%d)",
4991 pProfile->nRSNReqIELength);
4992 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 }
4994 }
4995 else
4996 {
4997 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4998 }
4999 }while(0);
5000
5001 return (cbRsnIe);
5002}
5003
5004
5005#ifdef FEATURE_WLAN_WAPI
5006//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
5007//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
5008tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
5009 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
5010 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
5011{
5012 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5013 tANI_U8 cbWapiIe = 0;
5014
5015 do
5016 {
5017 if ( !csrIsProfileWapi( pProfile ) ) break;
5018 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
5019 {
5020 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
5021 {
5022 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305023 vos_mem_copy(pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 }
5025 else
5026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005027 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 }
5029 }
5030 else
5031 {
5032 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
5033 }
5034 }while(0);
5035
5036 return (cbWapiIe);
5037}
5038#endif /* FEATURE_WLAN_WAPI */
5039
5040tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
5041{
5042 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5043 tListElem *pEntry;
5044 tANI_U16 i;
5045 tANI_U16 startingChannel;
5046 tANI_BOOLEAN found = FALSE;
5047 tCsrChannelSet *pChannelGroup;
5048
5049 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
5050
5051 while ( pEntry )
5052 {
5053 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
5054 startingChannel = pChannelGroup->firstChannel;
5055 for ( i = 0; i < pChannelGroup->numChannels; i++ )
5056 {
5057 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
5058 {
5059 found = TRUE;
5060 break;
5061 }
5062 }
5063
5064 if ( found )
5065 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305066 vos_mem_copy(returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 break;
5068 }
5069 else
5070 {
5071 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
5072 }
5073 }
5074
5075 return( found );
5076}
5077
5078tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
5079{
5080 tANI_BOOLEAN fSupported = FALSE;
5081 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
5082
5083 switch ( nonBasicRate )
5084 {
5085 case eCsrSuppRate_1Mbps:
5086 case eCsrSuppRate_2Mbps:
5087 case eCsrSuppRate_5_5Mbps:
5088 case eCsrSuppRate_11Mbps:
5089 fSupported = TRUE;
5090 break;
5091
5092 default:
5093 break;
5094 }
5095
5096 return( fSupported );
5097}
5098
5099tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
5100{
5101 tANI_BOOLEAN fSupported = FALSE;
5102 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
5103
5104 switch ( nonBasicRate )
5105 {
5106 case eCsrSuppRate_6Mbps:
5107 case eCsrSuppRate_9Mbps:
5108 case eCsrSuppRate_12Mbps:
5109 case eCsrSuppRate_18Mbps:
5110 case eCsrSuppRate_24Mbps:
5111 case eCsrSuppRate_36Mbps:
5112 case eCsrSuppRate_48Mbps:
5113 case eCsrSuppRate_54Mbps:
5114 fSupported = TRUE;
5115 break;
5116
5117 default:
5118 break;
5119 }
5120
5121 return( fSupported );
5122}
5123
5124
5125
5126tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
5127{
5128 tAniEdType edType;
5129
5130 switch ( EncryptType )
5131 {
5132 default:
5133 case eCSR_ENCRYPT_TYPE_NONE:
5134 edType = eSIR_ED_NONE;
5135 break;
5136
5137 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5138 case eCSR_ENCRYPT_TYPE_WEP40:
5139 edType = eSIR_ED_WEP40;
5140 break;
5141
5142 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5143 case eCSR_ENCRYPT_TYPE_WEP104:
5144 edType = eSIR_ED_WEP104;
5145 break;
5146
5147 case eCSR_ENCRYPT_TYPE_TKIP:
5148 edType = eSIR_ED_TKIP;
5149 break;
5150
5151 case eCSR_ENCRYPT_TYPE_AES:
5152 edType = eSIR_ED_CCMP;
5153 break;
5154#ifdef FEATURE_WLAN_WAPI
5155 case eCSR_ENCRYPT_TYPE_WPI:
5156 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05305157 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005158#endif
5159#ifdef WLAN_FEATURE_11W
5160 //11w BIP
5161 case eCSR_ENCRYPT_TYPE_AES_CMAC:
5162 edType = eSIR_ED_AES_128_CMAC;
5163 break;
5164#endif
5165 }
5166
5167 return( edType );
5168}
5169
5170
5171//pIes can be NULL
5172tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
5173 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
5174 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
5175 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
5176{
5177 tANI_U32 idx;
5178 tANI_BOOLEAN fMatch = FALSE;
5179 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5180 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
5181
5182 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
5183
5184 do
5185 {
5186 //If privacy bit is not set, consider no match
5187 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
5188
5189 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
5190 {
5191 switch( pMCEncryptionList->encryptionType[idx] )
5192 {
5193 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5194 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5195 case eCSR_ENCRYPT_TYPE_WEP40:
5196 case eCSR_ENCRYPT_TYPE_WEP104:
5197 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
5198 */
5199 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
5200 {
5201 fMatch = TRUE;
5202 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
5203 }
5204 break;
5205 default:
5206 fMatch = FALSE;
5207 break;
5208 }
5209 if(fMatch) break;
5210 }
5211
5212 if(!fMatch) break;
5213
5214 for( idx = 0; idx < pAuthList->numEntries; idx++ )
5215 {
5216 switch( pAuthList->authType[idx] )
5217 {
5218 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5219 case eCSR_AUTH_TYPE_SHARED_KEY:
5220 case eCSR_AUTH_TYPE_AUTOSWITCH:
5221 fMatch = TRUE;
5222 negotiatedAuth = pAuthList->authType[idx];
5223 break;
5224 default:
5225 fMatch = FALSE;
5226 }
5227 if (fMatch) break;
5228 }
5229
5230 if(!fMatch) break;
5231 //In case of WPA / WPA2, check whether it supports WEP as well
5232 if(pIes)
5233 {
5234 //Prepare the encryption type for WPA/WPA2 functions
5235 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
5236 {
5237 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
5238 }
5239 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
5240 {
5241 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5242 }
5243 //else we can use the encryption type directly
Kiet Lam64c1b492013-07-12 13:56:44 +05305244 if ( pIes->WPA.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305246 fMatch = vos_mem_compare(pIes->WPA.multicast_cipher,
5247 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
5248 CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 if( fMatch ) break;
5250 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305251 if ( pIes->RSN.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07005252 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305253 fMatch = vos_mem_compare(pIes->RSN.gp_cipher_suite,
5254 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
5255 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 }
5257 }
5258
5259 }while(0);
5260
5261 if( fMatch )
5262 {
5263 if( pNegotiatedAuthType )
5264 *pNegotiatedAuthType = negotiatedAuth;
5265
5266 if( pNegotiatedMCEncryption )
5267 *pNegotiatedMCEncryption = negotiatedMCCipher;
5268 }
5269
5270
5271 return fMatch;
5272}
5273
5274
5275//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305276tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType,
5277 tCsrEncryptionList *pUCEncryptionType,
5278 tCsrEncryptionList *pMCEncryptionType,
5279 tANI_BOOLEAN *pMFPEnabled,
5280 tANI_U8 *pMFPRequired, tANI_U8 *pMFPCapable,
5281 tSirBssDescription *pSirBssDesc,
5282 tDot11fBeaconIEs *pIes,
5283 eCsrAuthType *negotiatedAuthtype,
5284 eCsrEncryptionType *negotiatedUCCipher,
5285 eCsrEncryptionType *negotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07005286{
5287 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5288 tANI_BOOLEAN fMatch = FALSE;
5289 tANI_U8 i,idx;
5290 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
5291 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
5292
5293 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
5294 {
5295 ucCipher = pUCEncryptionType->encryptionType[i];
5296 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
5297 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
5298 // encryption type.
5299 switch ( ucCipher )
5300 {
5301 case eCSR_ENCRYPT_TYPE_NONE:
5302 {
5303 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
5304 // required so we have to reject this Bss.
5305 if ( csrIsPrivacy( pSirBssDesc ) )
5306 {
5307 fMatch = FALSE;
5308 }
5309 else
5310 {
5311 fMatch = TRUE;
5312 }
5313
5314 if ( fMatch )
5315 {
5316 fMatch = FALSE;
5317 //Check Multicast cipher requested and Auth type requested.
5318 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
5319 {
5320 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
5321 {
5322 fMatch = TRUE; //Multicast can only be none.
5323 mcCipher = pMCEncryptionType->encryptionType[idx];
5324 break;
5325 }
5326 }
5327 if (!fMatch) break;
5328
5329 fMatch = FALSE;
5330 //Check Auth list. It should contain AuthOpen.
5331 for( idx = 0 ; idx < authType->numEntries ; idx++ )
5332 {
5333 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
5334 {
5335 fMatch = TRUE;
5336 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5337 break;
5338 }
5339 }
5340 if (!fMatch) break;
5341
5342 }
5343 break;
5344 }
5345
5346 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5347 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5348 // !! might want to check for WEP keys set in the Profile.... ?
5349 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
5350 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
5351 // encryption is not allowed without the Privacy bit turned on.
5352 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5353
5354 break;
5355
5356 // these are all of the WPA encryption types...
5357 case eCSR_ENCRYPT_TYPE_WEP40:
5358 case eCSR_ENCRYPT_TYPE_WEP104:
5359 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5360 break;
5361
5362 case eCSR_ENCRYPT_TYPE_TKIP:
5363 case eCSR_ENCRYPT_TYPE_AES:
5364 {
5365 if(pIes)
5366 {
5367 // First check if there is a RSN match
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305368 fMatch = csrIsRSNMatch( pMac, authType, ucCipher,
5369 pMCEncryptionType, pMFPEnabled,
5370 pMFPRequired, pMFPCapable,
5371 pIes, &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 if( !fMatch )
5373 {
5374 // If not RSN, then check if there is a WPA match
5375 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
5376 &negAuthType, &mcCipher );
5377 }
5378 }
5379 else
5380 {
5381 fMatch = FALSE;
5382 }
5383 break;
5384 }
5385#ifdef FEATURE_WLAN_WAPI
5386 case eCSR_ENCRYPT_TYPE_WPI://WAPI
5387 {
5388 if(pIes)
5389 {
5390 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5391 }
5392 else
5393 {
5394 fMatch = FALSE;
5395 }
5396 break;
5397 }
5398#endif /* FEATURE_WLAN_WAPI */
5399 case eCSR_ENCRYPT_TYPE_ANY:
5400 default:
5401 {
5402 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
5403
5404 fMatch = eANI_BOOLEAN_TRUE;
5405 //It is allowed to match anything. Try the more secured ones first.
5406 if(pIes)
5407 {
5408 //Check AES first
5409 ucCipher = eCSR_ENCRYPT_TYPE_AES;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305410 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5411 pMCEncryptionType, pMFPEnabled,
5412 pMFPRequired, pMFPCapable, pIes,
5413 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 if(!fMatchAny)
5415 {
5416 //Check TKIP
5417 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305418 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5419 pMCEncryptionType,
5420 pMFPEnabled, pMFPRequired,
5421 pMFPCapable, pIes,
5422 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 }
5424#ifdef FEATURE_WLAN_WAPI
5425 if(!fMatchAny)
5426 {
5427 //Check WAPI
5428 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
5429 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5430 }
5431#endif /* FEATURE_WLAN_WAPI */
5432 }
5433 if(!fMatchAny)
5434 {
5435 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
5436 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5437 {
5438 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
5439 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5440 {
5441 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5442 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5443 {
5444 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5445 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5446 {
5447 //It must be open and no encryption
5448 if ( csrIsPrivacy( pSirBssDesc ) )
5449 {
5450 //This is not right
5451 fMatch = eANI_BOOLEAN_FALSE;
5452 }
5453 else
5454 {
5455 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5456 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
5457 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
5458 }
5459 }
5460 }
5461 }
5462 }
5463 }
5464 break;
5465 }
5466 }
5467
5468 }
5469
5470 if( fMatch )
5471 {
5472 if( negotiatedUCCipher )
5473 *negotiatedUCCipher = ucCipher;
5474
5475 if( negotiatedMCCipher )
5476 *negotiatedMCCipher = mcCipher;
5477
5478 if( negotiatedAuthtype )
5479 *negotiatedAuthtype = negAuthType;
5480 }
5481
5482 return( fMatch );
5483}
5484
5485
5486tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
5487 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
5488{
5489 tANI_BOOLEAN fMatch = FALSE;
5490
5491 do {
Padma, Santhosh Kumara43e06c2015-05-21 14:58:13 +05305492 // Check for the specification of the Broadcast SSID at the beginning
5493 // of the list. If specified, then all SSIDs are matches
5494 // (broadcast SSID means accept all SSIDs).
5495 if ( ssid1Len == 0 )
5496 {
5497 fMatch = TRUE;
5498 break;
5499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005500
5501 // There are a few special cases. If the Bss description has a Broadcast SSID,
5502 // then our Profile must have a single SSID without Wildcards so we can program
5503 // the SSID.
5504 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5505 // but the SSID value is all NULL characters. That condition is trated same
5506 // as NULL SSID
5507 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5508 {
5509 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5510 {
5511 fMatch = TRUE;
5512 }
5513 break;
5514 }
5515
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 if(ssid1Len != bssSsidLen) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05305517 if (vos_mem_compare(bssSsid, ssid1, bssSsidLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 {
5519 fMatch = TRUE;
5520 break;
5521 }
5522
5523 } while( 0 );
5524
5525 return( fMatch );
5526}
5527
5528
5529//Null ssid means match
5530tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5531{
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 tANI_BOOLEAN fMatch = FALSE;
5533 tANI_U32 i;
5534
5535 if ( pSsidList && pSsid )
5536 {
5537 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5538 {
5539 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
Kiet Lam64c1b492013-07-12 13:56:44 +05305540 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5541 vos_mem_compare(pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 {
5543 fMatch = TRUE;
5544 break;
5545 }
5546 }
5547 }
5548
5549 return (fMatch);
5550}
5551
5552//like to use sirCompareMacAddr
5553tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5554{
5555 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5556
Kiet Lam64c1b492013-07-12 13:56:44 +05305557 return (vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005558}
5559
5560//like to use sirCompareMacAddr
5561tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5562{
5563 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5564
Kiet Lam64c1b492013-07-12 13:56:44 +05305565 return(vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005566}
5567
5568
5569//like to use sirCompareMacAddr
5570tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5571{
Kiet Lam64c1b492013-07-12 13:56:44 +05305572 return(vos_mem_compare(pMacAddr1, pMacAddr2, sizeof(tCsrBssid)));
Jeff Johnson295189b2012-06-20 16:38:30 -07005573}
5574
5575
5576tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5577{
5578 tANI_BOOLEAN fMatch = FALSE;
5579 tCsrBssid ProfileBssid;
5580 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5581
5582 // for efficiency of the MAC_ADDRESS functions, move the
5583 // Bssid's into MAC_ADDRESS structs.
Kiet Lam64c1b492013-07-12 13:56:44 +05305584 vos_mem_copy(&ProfileBssid, pProfBssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005585
5586 do {
5587
5588 // Give the profile the benefit of the doubt... accept either all 0 or
5589 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5590 // match any Bssids).
5591 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5592 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5593 {
5594 fMatch = TRUE;
5595 break;
5596 }
5597
5598 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5599 {
5600 fMatch = TRUE;
5601 break;
5602 }
5603
5604 } while( 0 );
5605
5606 return( fMatch );
5607}
5608
5609
5610tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5611{
5612 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5613 return eANI_BOOLEAN_FALSE;
5614 else
5615 return eANI_BOOLEAN_TRUE;
5616}
5617
5618
5619tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5620{
5621 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5622}
5623
5624tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5625{
5626 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5627}
5628
5629tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5630{
5631 tANI_BOOLEAN fMatch = TRUE;
5632
5633 do
5634 {
5635 switch( bssType )
5636 {
5637 case eCSR_BSS_TYPE_ANY:
5638 break;
5639
5640 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5641 case eCSR_BSS_TYPE_WDS_STA:
5642 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5643 fMatch = FALSE;
5644
5645 break;
5646
5647 case eCSR_BSS_TYPE_IBSS:
5648 case eCSR_BSS_TYPE_START_IBSS:
5649 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5650 fMatch = FALSE;
5651
5652 break;
5653
5654 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5655 default:
5656 fMatch = FALSE;
5657 break;
5658 }
5659 }
5660 while( 0 );
5661
5662
5663 return( fMatch );
5664}
5665
5666static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5667{
5668 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5669}
5670
5671
5672
5673static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5674{
5675 tANI_BOOLEAN fMatch = TRUE;
5676
5677 do
5678 {
5679 // if the channel is ANY, then always match...
5680 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5681 if ( Channel == pSirBssDesc->channelId ) break;
5682
5683 // didn't match anything.. so return NO match
5684 fMatch = FALSE;
5685
5686 } while( 0 );
5687
5688 return( fMatch );
5689}
5690
5691
5692tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5693{
5694 tANI_BOOLEAN fMatch = TRUE;
5695
5696 do
5697 {
5698 // if the profile says Any channel AND the global settings says ANY channel, then we
5699 // always match...
5700 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5701
5702 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5703 {
5704 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5705 }
5706
5707 } while( 0 );
5708
5709 return( fMatch );
5710}
5711
5712
5713/**
5714 * \brief Enquire as to whether a given rate is supported by the
5715 * adapter as currently configured
5716 *
5717 *
5718 * \param nRate A rate in units of 500kbps
5719 *
5720 * \return TRUE if the adapter is currently capable of supporting this
5721 * rate, FALSE else
5722 *
5723 *
5724 * The rate encoding is just as in 802.11 Information Elements, except
5725 * that the high bit is \em not interpreted as indicating a Basic Rate,
5726 * and proprietary rates are allowed, too.
5727 *
5728 * Note that if the adapter's dot11Mode is g, we don't restrict the
5729 * rates. According to hwReadEepromParameters, this will happen when:
5730 *
5731 * ... the card is configured for ALL bands through the property
5732 * page. If this occurs, and the card is not an ABG card ,then this
5733 * code is setting the dot11Mode to assume the mode that the
5734 * hardware can support. For example, if the card is an 11BG card
5735 * and we are configured to support ALL bands, then we change the
5736 * dot11Mode to 11g because ALL in this case is only what the
5737 * hardware can support.
5738 *
5739 *
5740 */
5741
5742static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5743{
5744 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5745 tANI_U16 idx, newRate;
5746
5747 //In case basic rate flag is set
5748 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5749 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5750 {
5751 switch ( newRate )
5752 {
5753 case eCsrSuppRate_6Mbps:
5754 case eCsrSuppRate_9Mbps:
5755 case eCsrSuppRate_12Mbps:
5756 case eCsrSuppRate_18Mbps:
5757 case eCsrSuppRate_24Mbps:
5758 case eCsrSuppRate_36Mbps:
5759 case eCsrSuppRate_48Mbps:
5760 case eCsrSuppRate_54Mbps:
5761 fSupported = TRUE;
5762 break;
5763 default:
5764 fSupported = FALSE;
5765 break;
5766 }
5767
5768 }
5769 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5770 {
5771 switch ( newRate )
5772 {
5773 case eCsrSuppRate_1Mbps:
5774 case eCsrSuppRate_2Mbps:
5775 case eCsrSuppRate_5_5Mbps:
5776 case eCsrSuppRate_11Mbps:
5777 fSupported = TRUE;
5778 break;
5779 default:
5780 fSupported = FALSE;
5781 break;
5782 }
5783 }
5784 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5785 {
5786
5787 switch ( newRate )
5788 {
5789 case eCsrSuppRate_1Mbps:
5790 case eCsrSuppRate_2Mbps:
5791 case eCsrSuppRate_5_5Mbps:
5792 case eCsrSuppRate_6Mbps:
5793 case eCsrSuppRate_9Mbps:
5794 case eCsrSuppRate_11Mbps:
5795 case eCsrSuppRate_12Mbps:
5796 case eCsrSuppRate_18Mbps:
5797 case eCsrSuppRate_24Mbps:
5798 case eCsrSuppRate_36Mbps:
5799 case eCsrSuppRate_48Mbps:
5800 case eCsrSuppRate_54Mbps:
5801 fSupported = TRUE;
5802 break;
5803 default:
5804 fSupported = FALSE;
5805 break;
5806 }
5807
5808 }
5809 else {
5810
5811 if ( eCsrSuppRate_1Mbps == newRate ||
5812 eCsrSuppRate_2Mbps == newRate ||
5813 eCsrSuppRate_5_5Mbps == newRate ||
5814 eCsrSuppRate_11Mbps == newRate )
5815 {
5816 fSupported = TRUE;
5817 }
5818 else {
5819 idx = 0x1;
5820
5821 switch ( newRate )
5822 {
5823 case eCsrSuppRate_6Mbps:
5824 fSupported = gPhyRatesSuppt[0][idx];
5825 break;
5826 case eCsrSuppRate_9Mbps:
5827 fSupported = gPhyRatesSuppt[1][idx];
5828 break;
5829 case eCsrSuppRate_12Mbps:
5830 fSupported = gPhyRatesSuppt[2][idx];
5831 break;
5832 case eCsrSuppRate_18Mbps:
5833 fSupported = gPhyRatesSuppt[3][idx];
5834 break;
5835 case eCsrSuppRate_20Mbps:
5836 fSupported = gPhyRatesSuppt[4][idx];
5837 break;
5838 case eCsrSuppRate_24Mbps:
5839 fSupported = gPhyRatesSuppt[5][idx];
5840 break;
5841 case eCsrSuppRate_36Mbps:
5842 fSupported = gPhyRatesSuppt[6][idx];
5843 break;
5844 case eCsrSuppRate_40Mbps:
5845 fSupported = gPhyRatesSuppt[7][idx];
5846 break;
5847 case eCsrSuppRate_42Mbps:
5848 fSupported = gPhyRatesSuppt[8][idx];
5849 break;
5850 case eCsrSuppRate_48Mbps:
5851 fSupported = gPhyRatesSuppt[9][idx];
5852 break;
5853 case eCsrSuppRate_54Mbps:
5854 fSupported = gPhyRatesSuppt[10][idx];
5855 break;
5856 case eCsrSuppRate_72Mbps:
5857 fSupported = gPhyRatesSuppt[11][idx];
5858 break;
5859 case eCsrSuppRate_80Mbps:
5860 fSupported = gPhyRatesSuppt[12][idx];
5861 break;
5862 case eCsrSuppRate_84Mbps:
5863 fSupported = gPhyRatesSuppt[13][idx];
5864 break;
5865 case eCsrSuppRate_96Mbps:
5866 fSupported = gPhyRatesSuppt[14][idx];
5867 break;
5868 case eCsrSuppRate_108Mbps:
5869 fSupported = gPhyRatesSuppt[15][idx];
5870 break;
5871 case eCsrSuppRate_120Mbps:
5872 fSupported = gPhyRatesSuppt[16][idx];
5873 break;
5874 case eCsrSuppRate_126Mbps:
5875 fSupported = gPhyRatesSuppt[17][idx];
5876 break;
5877 case eCsrSuppRate_144Mbps:
5878 fSupported = gPhyRatesSuppt[18][idx];
5879 break;
5880 case eCsrSuppRate_160Mbps:
5881 fSupported = gPhyRatesSuppt[19][idx];
5882 break;
5883 case eCsrSuppRate_168Mbps:
5884 fSupported = gPhyRatesSuppt[20][idx];
5885 break;
5886 case eCsrSuppRate_192Mbps:
5887 fSupported = gPhyRatesSuppt[21][idx];
5888 break;
5889 case eCsrSuppRate_216Mbps:
5890 fSupported = gPhyRatesSuppt[22][idx];
5891 break;
5892 case eCsrSuppRate_240Mbps:
5893 fSupported = gPhyRatesSuppt[23][idx];
5894 break;
5895 default:
5896 fSupported = FALSE;
5897 break;
5898 }
5899 }
5900 }
5901
5902 return fSupported;
5903}
5904
5905
5906
5907static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5908 tDot11fIESuppRates *pBssSuppRates,
5909 tDot11fIEExtSuppRates *pBssExtSuppRates )
5910{
5911 tANI_BOOLEAN fMatch = TRUE;
5912 tANI_U32 i;
5913
5914
5915 // Validate that all of the Basic rates advertised in the Bss description are supported.
5916 if ( pBssSuppRates )
5917 {
5918 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5919 {
5920 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5921 {
5922 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5923 {
5924 fMatch = FALSE;
5925 break;
5926 }
5927 }
5928 }
5929 }
5930
5931 if ( fMatch && pBssExtSuppRates )
5932 {
5933 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5934 {
5935 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5936 {
5937 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5938 {
5939 fMatch = FALSE;
5940 break;
5941 }
5942 }
5943 }
5944 }
5945
5946 return( fMatch );
5947
5948}
5949
Pragaspathi Thilagaraje548fab2018-06-22 11:55:55 +05305950/**
5951 * csr_match_security() - wrapper to check if the security is matching
5952 * @mac_ctx: mac context
5953 * @filter: scan filter
5954 * @bss_desc: BSS Descriptor
5955 * @ies_ptr: Pointer to the IE fields
5956 * @neg_auth_type: Negotiated Auth type with the AP
5957 * @neg_uc_cipher: Negotiated unicast cipher suite
5958 * @neg_mc_cipher: Negotiated multicast cipher
5959 *
5960 * Return: true if matched else false.
5961 */
5962#ifdef WLAN_FEATURE_11W
5963static inline bool csr_match_security(tpAniSirGlobal pMac,
5964 tCsrScanResultFilter *filter, tSirBssDescription *bss_desc,
5965 tDot11fBeaconIEs *ies_ptr, eCsrAuthType *neg_auth,
5966 eCsrEncryptionType *neg_uc,
5967 eCsrEncryptionType *neg_mc)
5968{
5969
5970 if (!filter)
5971 return false;
5972
5973 if (filter->bWPSAssociation || filter->bOSENAssociation)
5974 return true;
5975
5976 if (filter->ignore_pmf_cap)
5977 return csrIsSecurityMatch(pMac, &filter->authType,
5978 &filter->EncryptionType,
5979 &filter->mcEncryptionType,
5980 NULL, NULL, NULL,
5981 bss_desc, ies_ptr, neg_auth,
5982 neg_uc, neg_mc);
5983 else
5984 return csrIsSecurityMatch(pMac, &filter->authType,
5985 &filter->EncryptionType,
5986 &filter->mcEncryptionType,
5987 &filter->MFPEnabled,
5988 &filter->MFPRequired,
5989 &filter->MFPCapable,
5990 bss_desc, ies_ptr, neg_auth,
5991 neg_uc, neg_mc);
5992
5993}
5994#else
5995static inline bool csr_match_security(tpAniSirGlobal mac_ctx,
5996 tCsrScanResultFilter *filter, tSirBssDescription *bss_desc,
5997 tDot11fBeaconIEs *ies_ptr, eCsrAuthType *neg_auth,
5998 eCsrEncryptionType *neg_uc,
5999 eCsrEncryptionType *neg_mc)
6000
6001{
6002 if (!filter)
6003 return false;
6004
6005 if (filter->bWPSAssociation || filter->bOSENAssociation)
6006 return true;
6007
6008 return csrIsSecurityMatch(mac_ctx, &filter->authType,
6009 &filter->EncryptionType,
6010 &filter->mcEncryptionType,
6011 NULL, NULL, NULL,
6012 bss_desc, ies_ptr, neg_auth,
6013 neg_uc, neg_mc);
6014}
6015#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006016
6017//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
6018tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
6019 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
6020 tDot11fBeaconIEs **ppIes)
6021{
6022 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6023 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
6024 tANI_U32 i;
6025 tDot11fBeaconIEs *pIes = NULL;
6026 tANI_U8 *pb;
6027
6028 do {
6029 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
6030 {
6031 //If no IEs passed in, get our own.
6032 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
6033 {
6034 break;
6035 }
6036 }
6037 else
6038 {
6039 //Save the one pass in for local use
6040 pIes = *ppIes;
6041 }
6042
6043 //Check if caller wants P2P
6044 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
6045 if(!fCheck) break;
6046
6047 if(pIes->SSID.present)
6048 {
6049 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
6050 {
6051 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
6052 pIes->SSID.ssid,
6053 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
6054 if ( fCheck ) break;
6055 }
6056 if(!fCheck) break;
6057 }
6058 fCheck = eANI_BOOLEAN_TRUE;
6059 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
6060 {
6061 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
6062 if ( fCheck ) break;
6063
6064 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
6065 {
6066 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
6067 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
6068
6069 if ( fCheck ) break;
6070 }
6071 }
6072 if(!fCheck) break;
6073
6074 fCheck = eANI_BOOLEAN_TRUE;
6075 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
6076 {
6077 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
6078 if ( fCheck ) break;
6079 }
6080 if(!fCheck)
6081 break;
6082#if defined WLAN_FEATURE_VOWIFI
6083 /* If this is for measurement filtering */
6084 if( pFilter->fMeasurement )
6085 {
6086 fRC = eANI_BOOLEAN_TRUE;
6087 break;
6088 }
6089#endif
6090 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
Pragaspathi Thilagaraje548fab2018-06-22 11:55:55 +05306091 if ( !csr_match_security(pMac, pFilter, pBssDesc, pIes, pNegAuth, pNegUc, pNegMc)) break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
6093 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
6094 //Tush-QoS: validate first if asked for APSD or WMM association
6095 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
6096 !CSR_IS_QOS_BSS(pIes) )
6097 break;
6098 //Check country. check even when pb is NULL because we may want to make sure
6099 //AP has a country code in it if fEnforceCountryCodeMatch is set.
6100 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
6101
6102 fCheck = csrMatchCountryCode( pMac, pb, pIes );
6103 if(!fCheck)
6104 break;
6105
6106#ifdef WLAN_FEATURE_VOWIFI_11R
Hema Aparna Medicharlaf9dec8d2015-04-29 12:37:06 +05306107 if (pFilter->MDID.mdiePresent && csrRoamIs11rAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 {
6109 if (pBssDesc->mdiePresent)
6110 {
6111 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
6112 break;
6113 }
6114 else
6115 break;
6116 }
6117#endif
6118 fRC = eANI_BOOLEAN_TRUE;
6119
6120 } while( 0 );
6121 if( ppIes )
6122 {
6123 *ppIes = pIes;
6124 }
6125 else if( pIes )
6126 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306127 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 }
6129
6130 return( fRC );
6131}
6132
6133tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
6134 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
6135{
6136 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
6137 tCsrAuthList authList;
6138
6139 ucEncryptionList.numEntries = 1;
6140 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
6141
6142 mcEncryptionList.numEntries = 1;
6143 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
6144
6145 authList.numEntries = 1;
6146 authList.authType[0] = pProfile->AuthType;
6147
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05306148 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList,
6149 &mcEncryptionList, NULL, NULL, NULL,
6150 pBssDesc, pIes, NULL, NULL, NULL ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006151
6152}
6153
6154
6155tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
6156 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
6157{
6158 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6159 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
6160 tDot11fBeaconIEs *pIesLocal = pIes;
6161
6162 do {
6163 if( !pIes )
6164 {
6165 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
6166 {
6167 break;
6168 }
6169 }
6170 fCheck = eANI_BOOLEAN_TRUE;
6171 if(pIesLocal->SSID.present)
6172 {
6173 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
6174 if(pProfile->SSID.length)
6175 {
6176 fCheckSsid = eANI_BOOLEAN_TRUE;
6177 }
6178 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
6179 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
6180 if(!fCheck) break;
6181 }
6182 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
6183 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
6184 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
6185 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
6186 if(!fCheck)
6187 break;
6188
6189 fRC = eANI_BOOLEAN_TRUE;
6190
6191 } while( 0 );
6192
6193 if( !pIes && pIesLocal )
6194 {
6195 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05306196 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 }
6198
6199 return( fRC );
6200}
6201
6202
6203
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05306204void csrAddRateBitmap(tANI_U8 rate, tANI_U16 *pRateBitmap)
6205{
6206 tANI_U16 rateBitmap;
6207 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6208 rateBitmap = *pRateBitmap;
6209 switch(n)
6210 {
6211 case SIR_MAC_RATE_1:
6212 rateBitmap |= SIR_MAC_RATE_1_BITMAP;
6213 break;
6214 case SIR_MAC_RATE_2:
6215 rateBitmap |= SIR_MAC_RATE_2_BITMAP;
6216 break;
6217 case SIR_MAC_RATE_5_5:
6218 rateBitmap |= SIR_MAC_RATE_5_5_BITMAP;
6219 break;
6220 case SIR_MAC_RATE_11:
6221 rateBitmap |= SIR_MAC_RATE_11_BITMAP;
6222 break;
6223 case SIR_MAC_RATE_6:
6224 rateBitmap |= SIR_MAC_RATE_6_BITMAP;
6225 break;
6226 case SIR_MAC_RATE_9:
6227 rateBitmap |= SIR_MAC_RATE_9_BITMAP;
6228 break;
6229 case SIR_MAC_RATE_12:
6230 rateBitmap |= SIR_MAC_RATE_12_BITMAP;
6231 break;
6232 case SIR_MAC_RATE_18:
6233 rateBitmap |= SIR_MAC_RATE_18_BITMAP;
6234 break;
6235 case SIR_MAC_RATE_24:
6236 rateBitmap |= SIR_MAC_RATE_24_BITMAP;
6237 break;
6238 case SIR_MAC_RATE_36:
6239 rateBitmap |= SIR_MAC_RATE_36_BITMAP;
6240 break;
6241 case SIR_MAC_RATE_48:
6242 rateBitmap |= SIR_MAC_RATE_48_BITMAP;
6243 break;
6244 case SIR_MAC_RATE_54:
6245 rateBitmap |= SIR_MAC_RATE_54_BITMAP;
6246 break;
6247 }
6248 *pRateBitmap = rateBitmap;
6249}
6250
6251
6252
6253tANI_BOOLEAN csrIsRateAlreadyPresent(tANI_U8 rate, tANI_U16 rateBitmap)
6254{
6255 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6256
6257 switch(n)
6258 {
6259 case SIR_MAC_RATE_1:
6260 rateBitmap &= SIR_MAC_RATE_1_BITMAP;
6261 break;
6262 case SIR_MAC_RATE_2:
6263 rateBitmap &= SIR_MAC_RATE_2_BITMAP;
6264 break;
6265 case SIR_MAC_RATE_5_5:
6266 rateBitmap &= SIR_MAC_RATE_5_5_BITMAP;
6267 break;
6268 case SIR_MAC_RATE_11:
6269 rateBitmap &= SIR_MAC_RATE_11_BITMAP;
6270 break;
6271 case SIR_MAC_RATE_6:
6272 rateBitmap &= SIR_MAC_RATE_6_BITMAP;
6273 break;
6274 case SIR_MAC_RATE_9:
6275 rateBitmap &= SIR_MAC_RATE_9_BITMAP;
6276 break;
6277 case SIR_MAC_RATE_12:
6278 rateBitmap &= SIR_MAC_RATE_12_BITMAP;
6279 break;
6280 case SIR_MAC_RATE_18:
6281 rateBitmap &= SIR_MAC_RATE_18_BITMAP;
6282 break;
6283 case SIR_MAC_RATE_24:
6284 rateBitmap &= SIR_MAC_RATE_24_BITMAP;
6285 break;
6286 case SIR_MAC_RATE_36:
6287 rateBitmap &= SIR_MAC_RATE_36_BITMAP;
6288 break;
6289 case SIR_MAC_RATE_48:
6290 rateBitmap &= SIR_MAC_RATE_48_BITMAP;
6291 break;
6292 case SIR_MAC_RATE_54:
6293 rateBitmap &= SIR_MAC_RATE_54_BITMAP;
6294 break;
6295 }
6296 return !!rateBitmap;
6297}
6298
6299
6300
Jeff Johnson295189b2012-06-20 16:38:30 -07006301tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
6302{
6303 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6304 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6305
6306 return csrIsAggregateRateSupported( pMac, n );
6307}
6308
6309
6310tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
6311{
6312 tANI_U16 ConvertedRate = Rate;
6313
6314 switch( Rate )
6315 {
6316 case SIR_MAC_RATE_1:
6317 ConvertedRate = 2;
6318 break;
6319 case SIR_MAC_RATE_2:
6320 ConvertedRate = 4;
6321 break;
6322 case SIR_MAC_RATE_5_5:
6323 ConvertedRate = 11;
6324 break;
6325 case SIR_MAC_RATE_11:
6326 ConvertedRate = 22;
6327 break;
6328
6329 case SIR_MAC_RATE_6:
6330 ConvertedRate = 12;
6331 break;
6332 case SIR_MAC_RATE_9:
6333 ConvertedRate = 18;
6334 break;
6335 case SIR_MAC_RATE_12:
6336 ConvertedRate = 24;
6337 break;
6338 case SIR_MAC_RATE_18:
6339 ConvertedRate = 36;
6340 break;
6341 case SIR_MAC_RATE_24:
6342 ConvertedRate = 48;
6343 break;
6344 case SIR_MAC_RATE_36:
6345 ConvertedRate = 72;
6346 break;
6347 case SIR_MAC_RATE_42:
6348 ConvertedRate = 84;
6349 break;
6350 case SIR_MAC_RATE_48:
6351 ConvertedRate = 96;
6352 break;
6353 case SIR_MAC_RATE_54:
6354 ConvertedRate = 108;
6355 break;
6356
6357 case SIR_MAC_RATE_72:
6358 ConvertedRate = 144;
6359 break;
6360 case SIR_MAC_RATE_84:
6361 ConvertedRate = 168;
6362 break;
6363 case SIR_MAC_RATE_96:
6364 ConvertedRate = 192;
6365 break;
6366 case SIR_MAC_RATE_108:
6367 ConvertedRate = 216;
6368 break;
6369 case SIR_MAC_RATE_126:
6370 ConvertedRate = 252;
6371 break;
6372 case SIR_MAC_RATE_144:
6373 ConvertedRate = 288;
6374 break;
6375 case SIR_MAC_RATE_168:
6376 ConvertedRate = 336;
6377 break;
6378 case SIR_MAC_RATE_192:
6379 ConvertedRate = 384;
6380 break;
6381 case SIR_MAC_RATE_216:
6382 ConvertedRate = 432;
6383 break;
6384 case SIR_MAC_RATE_240:
6385 ConvertedRate = 480;
6386 break;
6387
6388 case 0xff:
6389 ConvertedRate = 0;
6390 break;
6391 }
6392
6393 return ConvertedRate;
6394}
6395
6396
6397tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
6398{
6399 tANI_U8 i;
6400 tANI_U16 nBest;
6401
6402 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
6403
6404 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
6405 {
6406 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
6407 }
6408
6409 for ( i = 1U; i < pSuppRates->numRates; ++i )
6410 {
6411 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6412 }
6413
6414 if ( NULL != pExtRates )
6415 {
6416 for ( i = 0U; i < pExtRates->numRates; ++i )
6417 {
6418 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6419 }
6420 }
6421
6422 if ( NULL != pPropRates )
6423 {
6424 for ( i = 0U; i < pPropRates->numPropRates; ++i )
6425 {
6426 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
6427 }
6428 }
6429
6430 return nBest;
6431}
6432
6433
6434void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
6435{
6436 if(pProfile)
6437 {
6438 if(pProfile->BSSIDs.bssid)
6439 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306440 vos_mem_free(pProfile->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 pProfile->BSSIDs.bssid = NULL;
6442 }
6443 if(pProfile->SSIDs.SSIDList)
6444 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306445 vos_mem_free(pProfile->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 pProfile->SSIDs.SSIDList = NULL;
6447 }
6448 if(pProfile->pWPAReqIE)
6449 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306450 vos_mem_free(pProfile->pWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 pProfile->pWPAReqIE = NULL;
6452 }
6453 if(pProfile->pRSNReqIE)
6454 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306455 vos_mem_free(pProfile->pRSNReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 pProfile->pRSNReqIE = NULL;
6457 }
6458#ifdef FEATURE_WLAN_WAPI
6459 if(pProfile->pWAPIReqIE)
6460 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306461 vos_mem_free(pProfile->pWAPIReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 pProfile->pWAPIReqIE = NULL;
6463 }
6464#endif /* FEATURE_WLAN_WAPI */
6465
Agarwal Ashish4f616132013-12-30 23:32:50 +05306466 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306468 memset(pProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306469 pProfile->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 }
6471
6472 if(pProfile->pAddIEAssoc)
6473 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306474 vos_mem_free(pProfile->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 pProfile->pAddIEAssoc = NULL;
6476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 if(pProfile->ChannelInfo.ChannelList)
6478 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306479 vos_mem_free(pProfile->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 pProfile->ChannelInfo.ChannelList = NULL;
6481 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306482 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 }
6484}
6485
6486void csrFreeScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
6487{
6488 if(pScanFilter->BSSIDs.bssid)
6489 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306490 vos_mem_free(pScanFilter->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 pScanFilter->BSSIDs.bssid = NULL;
6492 }
6493 if(pScanFilter->ChannelInfo.ChannelList)
6494 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306495 vos_mem_free(pScanFilter->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 pScanFilter->ChannelInfo.ChannelList = NULL;
6497 }
6498 if(pScanFilter->SSIDs.SSIDList)
6499 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306500 vos_mem_free(pScanFilter->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006501 pScanFilter->SSIDs.SSIDList = NULL;
6502 }
6503}
6504
6505
6506void csrFreeRoamProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6507{
6508 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6509
6510 if(pSession->pCurRoamProfile)
6511 {
6512 csrReleaseProfile(pMac, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306513 vos_mem_free(pSession->pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 pSession->pCurRoamProfile = NULL;
6515 }
6516}
6517
6518
6519void csrFreeConnectBssDesc(tpAniSirGlobal pMac, tANI_U32 sessionId)
6520{
6521 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6522
6523 if(pSession->pConnectBssDesc)
6524 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306525 vos_mem_free(pSession->pConnectBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 pSession->pConnectBssDesc = NULL;
6527 }
6528}
6529
6530
6531
6532tSirResultCodes csrGetDisassocRspStatusCode( tSirSmeDisassocRsp *pSmeDisassocRsp )
6533{
6534 tANI_U8 *pBuffer = (tANI_U8 *)pSmeDisassocRsp;
6535 tANI_U32 ret;
6536
6537 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
6538 //tSirResultCodes is an enum, assuming is 32bit
6539 //If we cannot make this assumption, use copymemory
6540 pal_get_U32( pBuffer, &ret );
6541
6542 return( ( tSirResultCodes )ret );
6543}
6544
6545
6546tSirResultCodes csrGetDeAuthRspStatusCode( tSirSmeDeauthRsp *pSmeRsp )
6547{
6548 tANI_U8 *pBuffer = (tANI_U8 *)pSmeRsp;
6549 tANI_U32 ret;
6550
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006551 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tANI_U8) + sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -07006552 //tSirResultCodes is an enum, assuming is 32bit
6553 //If we cannot make this assumption, use copymemory
6554 pal_get_U32( pBuffer, &ret );
6555
6556 return( ( tSirResultCodes )ret );
6557}
6558
6559#if 0
6560tSirScanType csrGetScanType(tANI_U8 chnId, eRegDomainId domainId, tANI_U8 *countryCode)
6561{
6562 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6563 tANI_U8 cc = 0;
6564
6565 while (cc++ < gCsrDomainChnInfo[domainId].numChannels)
6566 {
6567 if(chnId == gCsrDomainChnInfo[domainId].chnInfo[cc].chnId)
6568 {
6569 scanType = gCsrDomainChnInfo[domainId].chnInfo[cc].scanType;
6570 break;
6571 }
6572 }
6573
6574 return (scanType);
6575}
6576#endif
6577
6578tSirScanType csrGetScanType(tpAniSirGlobal pMac, tANI_U8 chnId)
6579{
6580 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6581 eNVChannelEnabledType channelEnabledType;
6582
6583 channelEnabledType = vos_nv_getChannelEnabledState(chnId);
6584 if( NV_CHANNEL_ENABLE == channelEnabledType)
6585 {
6586 scanType = eSIR_ACTIVE_SCAN;
6587 }
6588 return (scanType);
6589}
6590
6591
6592tANI_U8 csrToUpper( tANI_U8 ch )
6593{
6594 tANI_U8 chOut;
6595
6596 if ( ch >= 'a' && ch <= 'z' )
6597 {
6598 chOut = ch - 'a' + 'A';
6599 }
6600 else
6601 {
6602 chOut = ch;
6603 }
6604 return( chOut );
6605}
6606
6607
6608tSirBssType csrTranslateBsstypeToMacType(eCsrRoamBssType csrtype)
6609{
6610 tSirBssType ret;
6611
6612 switch(csrtype)
6613 {
6614 case eCSR_BSS_TYPE_INFRASTRUCTURE:
6615 ret = eSIR_INFRASTRUCTURE_MODE;
6616 break;
6617 case eCSR_BSS_TYPE_IBSS:
6618 case eCSR_BSS_TYPE_START_IBSS:
6619 ret = eSIR_IBSS_MODE;
6620 break;
6621 case eCSR_BSS_TYPE_WDS_AP:
6622 ret = eSIR_BTAMP_AP_MODE;
6623 break;
6624 case eCSR_BSS_TYPE_WDS_STA:
6625 ret = eSIR_BTAMP_STA_MODE;
6626 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 case eCSR_BSS_TYPE_INFRA_AP:
6628 ret = eSIR_INFRA_AP_MODE;
6629 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 case eCSR_BSS_TYPE_ANY:
6631 default:
6632 ret = eSIR_AUTO_MODE;
6633 break;
6634 }
6635
6636 return (ret);
6637}
6638
6639
6640//This function use the parameters to decide the CFG value.
6641//CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG
6642//So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value
Jeff Johnson295189b2012-06-20 16:38:30 -07006643eCsrCfgDot11Mode csrGetCfgDot11ModeFromCsrPhyMode(tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tANI_BOOLEAN fProprietary)
Jeff Johnson295189b2012-06-20 16:38:30 -07006644{
6645 tANI_U32 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6646
6647 switch(phyMode)
6648 {
6649 case eCSR_DOT11_MODE_11a:
6650 case eCSR_DOT11_MODE_11a_ONLY:
6651 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
6652 break;
6653 case eCSR_DOT11_MODE_11b:
6654 case eCSR_DOT11_MODE_11b_ONLY:
6655 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
6656 break;
6657 case eCSR_DOT11_MODE_11g:
6658 case eCSR_DOT11_MODE_11g_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 if(pProfile && (CSR_IS_INFRA_AP(pProfile)) && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
6660 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
6661 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
6663 break;
6664 case eCSR_DOT11_MODE_11n:
6665 if(fProprietary)
6666 {
6667 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6668 }
6669 else
6670 {
6671 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6672 }
6673 break;
6674 case eCSR_DOT11_MODE_11n_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 if(pProfile && CSR_IS_INFRA_AP(pProfile))
6676 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
6677 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6679 break;
6680 case eCSR_DOT11_MODE_TAURUS:
6681 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6682 break;
6683 case eCSR_DOT11_MODE_abg:
6684 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6685 break;
6686 case eCSR_DOT11_MODE_AUTO:
6687 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
6688 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07006689
6690#ifdef WLAN_FEATURE_11AC
6691 case eCSR_DOT11_MODE_11ac:
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006692 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6693 {
6694 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
6695 }
6696 else
6697 {
Ravi Joshia96ceb42013-05-20 18:52:39 -07006698 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006699 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006700 break;
6701 case eCSR_DOT11_MODE_11ac_ONLY:
Ravi Joshia96ceb42013-05-20 18:52:39 -07006702 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6703 {
6704 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
6705 }
6706 else
6707 {
6708 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6709 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006710 break;
6711#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006712 default:
6713 //No need to assign anything here
6714 break;
6715 }
6716
6717 return (cfgDot11Mode);
6718}
6719
6720
6721eHalStatus csrSetRegulatoryDomain(tpAniSirGlobal pMac, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6722{
6723 eHalStatus status = eHAL_STATUS_SUCCESS;
6724 tANI_BOOLEAN fRestart;
6725
6726 if(pMac->scan.domainIdCurrent == domainId)
6727 {
6728 //no change
6729 fRestart = eANI_BOOLEAN_FALSE;
6730 }
6731 else if( !pMac->roam.configParam.fEnforceDefaultDomain )
6732 {
6733 pMac->scan.domainIdCurrent = domainId;
6734 fRestart = eANI_BOOLEAN_TRUE;
6735 }
6736 else
6737 {
6738 //We cannot change the domain
6739 status = eHAL_STATUS_CSR_WRONG_STATE;
6740 fRestart = eANI_BOOLEAN_FALSE;
6741 }
6742 if(pfRestartNeeded)
6743 {
6744 *pfRestartNeeded = fRestart;
6745 }
6746
6747 return (status);
6748}
6749
6750
6751v_REGDOMAIN_t csrGetCurrentRegulatoryDomain(tpAniSirGlobal pMac)
6752{
6753 return (pMac->scan.domainIdCurrent);
6754}
6755
Jeff Johnson295189b2012-06-20 16:38:30 -07006756
Kiet Lam6c583332013-10-14 05:37:09 +05306757eHalStatus csrGetRegulatoryDomainForCountry
6758(
6759tpAniSirGlobal pMac,
6760tANI_U8 *pCountry,
6761v_REGDOMAIN_t *pDomainId,
6762v_CountryInfoSource_t source
6763)
Jeff Johnson295189b2012-06-20 16:38:30 -07006764{
6765 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6766 VOS_STATUS vosStatus;
6767 v_COUNTRYCODE_t countryCode;
6768 v_REGDOMAIN_t domainId;
6769
6770 if(pCountry)
6771 {
6772 countryCode[0] = pCountry[0];
6773 countryCode[1] = pCountry[1];
Kiet Lam6c583332013-10-14 05:37:09 +05306774 vosStatus = vos_nv_getRegDomainFromCountryCode(&domainId,
6775 countryCode,
6776 source);
6777
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
6779 {
6780 if( pDomainId )
6781 {
6782 *pDomainId = domainId;
6783 }
6784 status = eHAL_STATUS_SUCCESS;
6785 }
6786 else
6787 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306788 smsLog(pMac, LOGW, FL(" Couldn't find domain for country code %c%c"), pCountry[0], pCountry[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 status = eHAL_STATUS_INVALID_PARAMETER;
6790 }
6791 }
6792
6793 return (status);
6794}
6795
6796//To check whether a country code matches the one in the IE
6797//Only check the first two characters, ignoring in/outdoor
6798//pCountry -- caller allocated buffer contain the country code that is checking against
6799//the one in pIes. It can be NULL.
6800//caller must provide pIes, it cannot be NULL
6801//This function always return TRUE if 11d support is not turned on.
6802tANI_BOOLEAN csrMatchCountryCode( tpAniSirGlobal pMac, tANI_U8 *pCountry, tDot11fBeaconIEs *pIes )
6803{
6804 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson43971f52012-07-17 12:26:56 -07006805 v_REGDOMAIN_t domainId = REGDOMAIN_COUNT; //This is init to invalid value
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 eHalStatus status;
6807
6808 do
6809 {
6810 if( !csrIs11dSupported( pMac) )
6811 {
6812 break;
6813 }
6814 if( !pIes )
6815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006816 smsLog(pMac, LOGE, FL(" No IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 break;
6818 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006819 if( pMac->roam.configParam.fEnforceDefaultDomain ||
6820 pMac->roam.configParam.fEnforceCountryCodeMatch )
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006822 //Make sure this country is recognizable
6823 if( pIes->Country.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 {
Kiet Lam6c583332013-10-14 05:37:09 +05306825 status = csrGetRegulatoryDomainForCountry(pMac,
6826 pIes->Country.country,
6827 &domainId, COUNTRY_QUERY);
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006828 if( !HAL_STATUS_SUCCESS( status ) )
6829 {
Kiet Lam6c583332013-10-14 05:37:09 +05306830 status = csrGetRegulatoryDomainForCountry(pMac,
6831 pMac->scan.countryCode11d,
6832 (v_REGDOMAIN_t *) &domainId,
6833 COUNTRY_QUERY);
Gowri Deepthiff9adf92012-12-13 15:09:56 -08006834 if( !HAL_STATUS_SUCCESS( status ) )
6835 {
6836 fRet = eANI_BOOLEAN_FALSE;
6837 break;
6838 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006841 //check whether it is needed to enforce to the default regulatory domain first
6842 if( pMac->roam.configParam.fEnforceDefaultDomain )
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006844 if( domainId != pMac->scan.domainIdCurrent )
6845 {
6846 fRet = eANI_BOOLEAN_FALSE;
6847 break;
6848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006850 if( pMac->roam.configParam.fEnforceCountryCodeMatch )
6851 {
Jeff Johnson43971f52012-07-17 12:26:56 -07006852 if( domainId >= REGDOMAIN_COUNT )
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006853 {
6854 fRet = eANI_BOOLEAN_FALSE;
6855 break;
6856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 }
6858 }
6859 if( pCountry )
6860 {
6861 tANI_U32 i;
6862
6863 if( !pIes->Country.present )
6864 {
6865 fRet = eANI_BOOLEAN_FALSE;
6866 break;
6867 }
6868 // Convert the CountryCode characters to upper
6869 for ( i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++ )
6870 {
6871 pCountry[i] = csrToUpper( pCountry[i] );
6872 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306873 if (!vos_mem_compare(pIes->Country.country, pCountry,
6874 WNI_CFG_COUNTRY_CODE_LEN - 1))
Jeff Johnson295189b2012-06-20 16:38:30 -07006875 {
6876 fRet = eANI_BOOLEAN_FALSE;
6877 break;
6878 }
6879 }
6880 } while(0);
6881
6882 return (fRet);
6883}
6884
6885#if 0
6886eHalStatus csrSetCountryDomainMapping(tpAniSirGlobal pMac, tCsrCountryDomainMapping *pCountryDomainMapping)
6887{
6888 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6889 tANI_U32 i, j;
6890 tANI_BOOLEAN fDomainChanged = eANI_BOOLEAN_FALSE;
6891 tANI_U8 countryCode[WNI_CFG_COUNTRY_CODE_LEN];
6892
6893 i = WNI_CFG_COUNTRY_CODE_LEN;
6894 //Get the currently used country code
6895 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, countryCode, &i);
6896 if(HAL_STATUS_SUCCESS(status))
6897 {
6898 if(pCountryDomainMapping && pCountryDomainMapping->numEntry)
6899 {
6900 for(i = 0; i < pCountryDomainMapping->numEntry; i++)
6901 {
6902 for(j = 0; j < eCSR_NUM_COUNTRY_INDEX; j++)
6903 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306904 if (vos_mem_compare(gCsrCountryInfo[j].countryCode,
6905 pCountryDomainMapping->pCountryInfo[i].countryCode,
6906 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 {
6908 if(gCsrCountryInfo[j].domainId != pCountryDomainMapping->pCountryInfo[i].domainId)
6909 {
6910 gCsrCountryInfo[j].domainId = pCountryDomainMapping->pCountryInfo[i].domainId;
6911 //Check whether it matches the currently used country code
6912 //If matching, need to update base on the new domain setting.
Kiet Lam64c1b492013-07-12 13:56:44 +05306913 if (vos_mem_compare(countryCode,
6914 pCountryDomainMapping->pCountryInfo[i].countryCode,
6915 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 {
6917 fDomainChanged = eANI_BOOLEAN_TRUE;
6918 }
6919 }
6920 break;
6921 }
6922 }
6923 }
6924 status = eHAL_STATUS_SUCCESS;
6925 if(fDomainChanged)
6926 {
6927 tCsrChannel *pChannelList;
6928
6929 if(pMac->scan.f11dInfoApplied)
6930 {
6931 //11d info already applied. Let's reapply with the new domain setting
6932 if(pMac->scan.channels11d.numChannels)
6933 {
6934 pChannelList = &pMac->scan.channels11d;
6935 }
6936 else
6937 {
6938 pChannelList = &pMac->scan.base20MHzChannels;
6939 }
6940 }
6941 else
6942 {
6943 //no 11d so we use the base channelist from EEPROM
6944 pChannelList = &pMac->scan.base20MHzChannels;
6945 }
6946 //set the new domain's scan requirement to CFG
6947 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
6948 }
6949 }
6950 }
6951
6952 return (status);
6953}
6954
6955eHalStatus csrSetDomainScanSetting(tpAniSirGlobal pMac, tCsrDomainFreqInfo *pDomainFreqInfo)
6956{
6957 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6958 tANI_U32 i, j;
6959 tANI_U16 freq;
6960
6961 if(pDomainFreqInfo && pDomainFreqInfo->numEntry && (pDomainFreqInfo->domainId < NUM_REG_DOMAINS))
6962 {
6963 tCsrDomainChnInfo *pDomainChnInfo = &gCsrDomainChnInfo[pDomainFreqInfo->domainId];
6964
6965 for(j = 0; j < pDomainChnInfo->numChannels; j++)
6966 {
6967 if(HAL_STATUS_SUCCESS(halPhyChIdToFreqConversion(pDomainChnInfo->chnInfo[j].chnId, &freq)))
6968 {
6969 for(i = 0; i < pDomainFreqInfo->numEntry; i++)
6970 {
6971 if((pDomainFreqInfo->pCsrScanFreqInfo[i].nStartFreq <= freq) &&
6972 (freq <= pDomainFreqInfo->pCsrScanFreqInfo[i].nEndFreq))
6973 {
6974 pDomainChnInfo->chnInfo[j].scanType = pDomainFreqInfo->pCsrScanFreqInfo[i].scanType;
6975 break;
6976 }
6977 }
6978 }
6979 else
6980 {
6981 smsLog(pMac, LOGW, " Failed to get frequency of channel %d", pDomainChnInfo->chnInfo[j].chnId);
6982 }
6983 }
6984 status = eHAL_STATUS_SUCCESS;
6985 }
6986
6987 return (status);
6988}
6989#endif
6990
6991eHalStatus csrGetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6992 tCsrRoamModifyProfileFields *pModifyProfileFields)
6993{
6994
6995 if(!pModifyProfileFields)
6996 {
6997 return eHAL_STATUS_FAILURE;
6998 }
6999
Kiet Lam64c1b492013-07-12 13:56:44 +05307000 vos_mem_copy(pModifyProfileFields,
7001 &pMac->roam.roamSession[sessionId].connectedProfile.modifyProfileFields,
7002 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07007003
7004 return eHAL_STATUS_SUCCESS;
7005}
7006
7007eHalStatus csrSetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
7008 tCsrRoamModifyProfileFields *pModifyProfileFields)
7009{
7010 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7011
Kiet Lam64c1b492013-07-12 13:56:44 +05307012 vos_mem_copy(&pSession->connectedProfile.modifyProfileFields,
7013 pModifyProfileFields,
7014 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07007015
7016 return eHAL_STATUS_SUCCESS;
7017}
7018
7019
7020#if 0
7021/* ---------------------------------------------------------------------------
7022 \fn csrGetSupportedCountryCode
7023 \brief this function is to get a list of the country code current being supported
7024 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
7025 this has the country code list. 3 bytes for each country code. This may be NULL if
7026 caller wants to know the needed bytes.
7027 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
7028 this contains the length of the data in pBuf
7029 \return eHalStatus
7030 -------------------------------------------------------------------------------*/
7031eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
7032{
7033 tANI_U32 numOfCountry = sizeof( gCsrCountryInfo ) / sizeof( gCsrCountryInfo[0] );
7034 tANI_U32 numBytes = 0;
7035 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7036
7037 if( pbLen )
7038 {
7039 numBytes = *pbLen;
7040 //Consider it ok, at least we can return the number of bytes needed;
7041 *pbLen = numOfCountry * WNI_CFG_COUNTRY_CODE_LEN;
7042 status = eHAL_STATUS_SUCCESS;
7043 if( pBuf && ( numBytes >= *pbLen ) )
7044 {
7045 //The ugly part starts.
7046 //We may need to alter the data structure and find a way to make this faster.
7047 tANI_U32 i;
7048
Kiet Lam64c1b492013-07-12 13:56:44 +05307049 for ( i = 0; i < numOfCountry; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307051 vos_mem_copy(pBuf + ( i * WNI_CFG_COUNTRY_CODE_LEN ),
7052 gCsrCountryInfo[i].countryCode,
7053 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 }
7055 }
7056 }
7057
7058 return ( status );
7059}
7060#endif
7061
7062/* ---------------------------------------------------------------------------
7063 \fn csrGetSupportedCountryCode
7064 \brief this function is to get a list of the country code current being supported
7065 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
7066 this has the country code list. 3 bytes for each country code. This may be NULL if
7067 caller wants to know the needed bytes.
7068 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
7069 this contains the length of the data in pBuf
7070 \return eHalStatus
7071 -------------------------------------------------------------------------------*/
7072eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
7073{
7074 eHalStatus status = eHAL_STATUS_SUCCESS;
7075 VOS_STATUS vosStatus;
7076 v_SIZE_t size = (v_SIZE_t)*pbLen;
7077
7078 vosStatus = vos_nv_getSupportedCountryCode( pBuf, &size, 1 );
7079 //eiter way, return the value back
7080 *pbLen = (tANI_U32)size;
7081
7082 //If pBuf is NULL, caller just want to get the size, consider it success
7083 if(pBuf)
7084 {
7085 if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
7086 {
7087 tANI_U32 i, n = *pbLen / 3;
7088
7089 for( i = 0; i < n; i++ )
7090 {
7091 pBuf[i*3 + 2] = ' ';
7092 }
7093 }
7094 else
7095 {
7096 status = eHAL_STATUS_FAILURE;
7097 }
7098 }
7099
7100 return (status);
7101}
7102
7103
7104
7105//Upper layer to get the list of the base channels to scan for passively 11d info from csr
7106eHalStatus csrScanGetBaseChannels( tpAniSirGlobal pMac, tCsrChannelInfo * pChannelInfo )
7107{
7108 eHalStatus status = eHAL_STATUS_FAILURE;
7109
7110 do
7111 {
7112
7113 if(!pMac->scan.baseChannels.numChannels || !pChannelInfo)
7114 {
7115 break;
7116 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307117 pChannelInfo->ChannelList = vos_mem_malloc(pMac->scan.baseChannels.numChannels);
7118 if ( NULL == pChannelInfo->ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007120 smsLog( pMac, LOGE, FL("csrScanGetBaseChannels: fail to allocate memory") );
Kiet Lam64c1b492013-07-12 13:56:44 +05307121 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307123 vos_mem_copy(pChannelInfo->ChannelList,
7124 pMac->scan.baseChannels.channelList,
7125 pMac->scan.baseChannels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 pChannelInfo->numOfChannels = pMac->scan.baseChannels.numChannels;
7127
7128 }while(0);
7129
7130 return ( status );
7131}
7132
7133
7134tANI_BOOLEAN csrIsSetKeyAllowed(tpAniSirGlobal pMac, tANI_U32 sessionId)
7135{
7136 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007137 tCsrRoamSession *pSession;
7138
7139 pSession =CSR_GET_SESSION(pMac, sessionId);
7140
7141 /*This condition is not working for infra state. When infra is in not-connected state
7142 * the pSession->pCurRoamProfile is NULL. And this function returns TRUE, that is incorrect.
7143 * Since SAP requires to set key without any BSS started, it needs this condition to be met.
7144 * In other words, this function is useless.
7145 * The current work-around is to process setcontext_rsp and removekey_rsp no matter what the
7146 * state is.
7147 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007148 smsLog( pMac, LOG2, FL(" is not what it intends to. Must be revisit or removed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 if( (NULL == pSession) ||
7150 ( csrIsConnStateDisconnected( pMac, sessionId ) &&
7151 (pSession->pCurRoamProfile != NULL) &&
7152 (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) )
7153 )
7154 {
7155 fRet = eANI_BOOLEAN_FALSE;
7156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007157
7158 return ( fRet );
7159}
7160
7161//no need to acquire lock for this basic function
7162tANI_U16 sme_ChnToFreq(tANI_U8 chanNum)
7163{
7164 int i;
7165
7166 for (i = 0; i < NUM_RF_CHANNELS; i++)
7167 {
7168 if (rfChannels[i].channelNum == chanNum)
7169 {
7170 return rfChannels[i].targetFreq;
7171 }
7172 }
7173
7174 return (0);
7175}
7176
7177/* Disconnect all active sessions by sending disassoc. This is mainly used to disconnect the remaining session when we
7178 * transition from concurrent sessions to a single session. The use case is Infra STA and wifi direct multiple sessions are up and
7179 * P2P session is removed. The Infra STA session remains and should resume BMPS if BMPS is enabled by default. However, there
7180 * are some issues seen with BMPS resume during this transition and this is a workaround which will allow the Infra STA session to
7181 * disconnect and auto connect back and enter BMPS this giving the same effect as resuming BMPS
7182 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007183
7184//Remove this code once SLM_Sessionization is supported
7185//BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnson295189b2012-06-20 16:38:30 -07007186void csrDisconnectAllActiveSessions(tpAniSirGlobal pMac)
7187{
7188 tANI_U8 i;
7189
7190 /* Disconnect all the active sessions */
7191 for (i=0; i<CSR_ROAM_SESSION_MAX; i++)
7192 {
7193 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
7194 {
7195 csrRoamDisconnectInternal(pMac, i, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7196 }
7197 }
7198}
Mohit Khanna349bc392012-09-11 17:24:52 -07007199
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07007200#ifdef FEATURE_WLAN_LFR
7201tANI_BOOLEAN csrIsChannelPresentInList(
7202 tANI_U8 *pChannelList,
7203 int numChannels,
7204 tANI_U8 channel
7205 )
7206{
7207 int i = 0;
7208
7209 // Check for NULL pointer
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08007210 if (!pChannelList || (numChannels == 0))
7211 {
7212 return FALSE;
7213 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07007214
7215 // Look for the channel in the list
7216 for (i = 0; i < numChannels; i++)
7217 {
7218 if (pChannelList[i] == channel)
7219 return TRUE;
7220 }
7221
7222 return FALSE;
7223}
7224
7225VOS_STATUS csrAddToChannelListFront(
7226 tANI_U8 *pChannelList,
7227 int numChannels,
7228 tANI_U8 channel
7229 )
7230{
7231 int i = 0;
7232
7233 // Check for NULL pointer
7234 if (!pChannelList) return eHAL_STATUS_E_NULL_VALUE;
7235
7236 // Make room for the addition. (Start moving from the back.)
7237 for (i = numChannels; i > 0; i--)
7238 {
7239 pChannelList[i] = pChannelList[i-1];
7240 }
7241
7242 // Now add the NEW channel...at the front
7243 pChannelList[0] = channel;
7244
7245 return eHAL_STATUS_SUCCESS;
7246}
7247#endif
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307248const char * sme_requestTypetoString(const v_U8_t requestType)
7249{
7250 switch (requestType)
7251 {
7252 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_11D_SCAN );
7253 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_FULL_SCAN );
7254 CASE_RETURN_STRING( eCSR_SCAN_IDLE_MODE_SCAN );
7255 CASE_RETURN_STRING( eCSR_SCAN_HO_BG_SCAN );
7256 CASE_RETURN_STRING( eCSR_SCAN_HO_PROBE_SCAN );
7257 CASE_RETURN_STRING( eCSR_SCAN_HO_NT_BG_SCAN );
7258 CASE_RETURN_STRING( eCSR_SCAN_P2P_DISCOVERY );
7259 CASE_RETURN_STRING( eCSR_SCAN_SOFTAP_CHANNEL_RANGE );
7260 CASE_RETURN_STRING( eCSR_SCAN_P2P_FIND_PEER );
7261 default:
7262 return "Unknown Scan Request Type";
7263 }
7264}