blob: dbcab6042117247671025f744185df80d3160cf8 [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;
3795 }
3796 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3797 FL("negotiated auth type is %d"), *neg_authtype);
3798}
3799#else
3800static void csr_check_sae_auth(tpAniSirGlobal mac_ctx,
3801 uint8_t authsuites[][CSR_RSN_OUI_SIZE],
3802 uint8_t c_auth_suites,
3803 uint8_t authentication[],
3804 tCsrAuthList *auth_type,
3805 uint8_t index, eCsrAuthType *neg_authtype)
3806{
3807}
3808#endif
3809
Jeff Johnson295189b2012-06-20 16:38:30 -07003810tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3811 tDot11fIERSN *pRSNIe,
3812 tANI_U8 *UnicastCypher,
3813 tANI_U8 *MulticastCypher,
3814 tANI_U8 *AuthSuite,
3815 tCsrRSNCapabilities *Capabilities,
3816 eCsrAuthType *pNegotiatedAuthtype,
3817 eCsrEncryptionType *pNegotiatedMCCipher )
3818{
3819 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3820 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3821 tANI_U8 cUnicastCyphers = 0;
3822 tANI_U8 cMulticastCyphers = 0;
3823 tANI_U8 cAuthSuites = 0, i;
3824 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3825 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3826 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3827 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3828 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3829 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3830
3831 do{
3832 if ( pRSNIe->present )
3833 {
3834 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303835 vos_mem_copy(MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05303837 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_cnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3839 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303840 vos_mem_copy((void *)&AuthSuites[i],
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05303841 (void *)&pRSNIe->akm_suite[i],
Kiet Lam64c1b492013-07-12 13:56:44 +05303842 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 }
3844
3845 //Check - Is requested Unicast Cipher supported by the BSS.
3846 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3847 csrGetOUIIndexFromCipher( enType ), Unicast );
3848
3849 if( !fAcceptableCyphers ) break;
3850
3851
3852 //Unicast is supported. Pick the first matching Group cipher, if any.
3853 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3854 {
3855 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3856 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3857 if(fAcceptableCyphers)
3858 {
3859 break;
3860 }
3861 }
3862 if( !fAcceptableCyphers ) break;
3863
3864 if( pNegotiatedMCCipher )
3865 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3866
3867 /* Initializing with FALSE as it has TRUE value already */
3868 fAcceptableCyphers = FALSE;
3869 for (i = 0 ; i < pAuthType->numEntries; i++)
3870 {
3871 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303872
3873 /* Set SAE as first preference */
3874 csr_check_sae_auth(pMac, AuthSuites, cAuthSuites,
3875 Authentication, pAuthType, i, &negAuthType);
3876
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 #ifdef WLAN_FEATURE_VOWIFI_11R
3878 /* Changed the AKM suites according to order of preference */
3879 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3880 {
3881 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3882 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3883 }
3884 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3885 {
3886 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3887 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3888 }
3889#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003890#ifdef FEATURE_WLAN_ESE
3891 /* ESE only supports 802.1X. No PSK. */
3892 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 {
3894 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3895 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3896 }
3897#endif
3898 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3899 {
3900 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3901 negAuthType = eCSR_AUTH_TYPE_RSN;
3902 }
3903 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3904 {
3905 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3906 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3907 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003908#ifdef WLAN_FEATURE_11W
3909 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3910 {
3911 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3912 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3913 }
Abhishek Singhae408032014-09-25 17:22:04 +05303914 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) &&
3915 csrIsAuthRSN8021xSha256(pMac, AuthSuites,
3916 cAuthSuites, Authentication)) {
3917 if (eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
3918 pAuthType->authType[i])
3919 negAuthType = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3920 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003921#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +05303922 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) &&
3923 csr_is_auth_wpa_owe(pMac, AuthSuites,
3924 cAuthSuites, Authentication)) {
3925 if (eCSR_AUTH_TYPE_OWE == pAuthType->authType[i])
3926 negAuthType = eCSR_AUTH_TYPE_OWE;
3927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003928
3929 // The 1st auth type in the APs RSN IE, to match stations connecting
3930 // profiles auth type will cause us to exit this loop
3931 // This is added as some APs advertise multiple akms in the RSN IE.
3932 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3933 {
3934 fAcceptableCyphers = TRUE;
3935 break;
3936 }
3937 } // for
3938 }
3939
3940 }while (0);
3941
3942 if ( fAcceptableCyphers )
3943 {
3944 if ( MulticastCypher )
3945 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303946 vos_mem_copy(MulticastCypher, Multicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 }
3948
3949 if ( UnicastCypher )
3950 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303951 vos_mem_copy(UnicastCypher, Unicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 }
3953
3954 if ( AuthSuite )
3955 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303956 vos_mem_copy(AuthSuite, Authentication, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 }
3958
3959 if ( pNegotiatedAuthtype )
3960 {
3961 *pNegotiatedAuthtype = negAuthType;
3962 }
3963 if ( Capabilities )
3964 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003965 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3966 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3967 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003968 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
Abhishek Singhf53e89d2015-06-18 12:30:00 +05303969#ifdef WLAN_FEATURE_11W
Chet Lanctot186b5732013-03-18 10:26:30 -07003970 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3971 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
Abhishek Singhf53e89d2015-06-18 12:30:00 +05303972#else
3973 Capabilities->MFPRequired = 0 ; // Bit 6 MFPR
3974 Capabilities->MFPCapable = 0 ; // Bit 7 MFPC
3975#endif
3976
Chet Lanctot186b5732013-03-18 10:26:30 -07003977 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 }
3979 }
3980 return( fAcceptableCyphers );
3981}
3982
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303983#ifdef WLAN_FEATURE_11W
3984/* ---------------------------------------------------------------------------
3985 \fn csrIsPMFCapabilitiesInRSNMatch
Jeff Johnson295189b2012-06-20 16:38:30 -07003986
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303987 \brief this function is to match our current capabilities with the AP
3988 to which we are expecting make the connection.
3989
3990 \param hHal - HAL Pointer
3991 pFilterMFPEnabled - given by supplicant to us to specify what kind
3992 of connection supplicant is expecting to make
3993 if it is enabled then make PMF connection.
3994 if it is disabled then make normal connection.
3995 pFilterMFPRequired - given by supplicant based on our configuration
3996 if it is 1 then we will require mandatory
3997 PMF connection and if it is 0 then we PMF
3998 connection is optional.
3999 pFilterMFPCapable - given by supplicant based on our configuration
4000 if it 1 then we are PMF capable and if it 0
4001 then we are not PMF capable.
4002 pRSNIe - RSNIe from Beacon/probe response of
4003 neighbor AP against which we will compare
4004 our capabilities.
4005
4006 \return tANI_BOOLEAN - if our PMF capabilities matches with AP then we
4007 will return true to indicate that we are good
4008 to make connection with it. Else we will return
4009 false.
4010 -------------------------------------------------------------------------------*/
4011static tANI_BOOLEAN
4012csrIsPMFCapabilitiesInRSNMatch( tHalHandle hHal,
4013 tANI_BOOLEAN *pFilterMFPEnabled,
4014 tANI_U8 *pFilterMFPRequired,
4015 tANI_U8 *pFilterMFPCapable,
4016 tDot11fIERSN *pRSNIe)
4017{
4018 tANI_U8 apProfileMFPCapable = 0;
4019 tANI_U8 apProfileMFPRequired = 0;
4020 if (pRSNIe && pFilterMFPEnabled && pFilterMFPCapable && pFilterMFPRequired)
4021 {
4022 /* Extracting MFPCapable bit from RSN Ie */
4023 apProfileMFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1;
4024 apProfileMFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1;
4025 if (*pFilterMFPEnabled && *pFilterMFPCapable && *pFilterMFPRequired
4026 && (apProfileMFPCapable == 0))
4027 {
4028 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4029 "AP is not capable to make PMF connection");
4030 return VOS_FALSE;
4031 }
4032 else if (*pFilterMFPEnabled && *pFilterMFPCapable &&
4033 !(*pFilterMFPRequired) && (apProfileMFPCapable == 0))
4034 {
4035 /*
4036 * This is tricky, because supplicant asked us to make mandatory
4037 * PMF connection eventhough PMF connection is optional here.
4038 * so if AP is not capable of PMF then drop it. Don't try to
4039 * connect with it.
4040 */
4041 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4042 "we need PMF connection & AP isn't capable to make PMF connection");
4043 return VOS_FALSE;
4044 }
4045 else if (!(*pFilterMFPCapable) &&
4046 apProfileMFPCapable && apProfileMFPRequired)
4047 {
4048 /*
4049 * In this case, AP with whom we trying to connect requires
4050 * mandatory PMF connections and we are not capable so this AP
4051 * is not good choice to connect
4052 */
4053 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4054 "AP needs PMF connection and we are not capable of pmf connection");
4055 return VOS_FALSE;
4056 }
4057 else if (!(*pFilterMFPEnabled) && *pFilterMFPCapable &&
4058 (apProfileMFPCapable == 1))
4059 {
4060 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4061 "we don't need PMF connection eventhough both parties are capable");
4062 return VOS_FALSE;
4063 }
4064 }
4065 return VOS_TRUE;
4066}
4067#endif
4068
4069tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType,
4070 eCsrEncryptionType enType,
4071 tCsrEncryptionList *pEnMcType,
4072 tANI_BOOLEAN *pMFPEnabled, tANI_U8 *pMFPRequired,
4073 tANI_U8 *pMFPCapable,
4074 tDot11fBeaconIEs *pIes,
4075 eCsrAuthType *pNegotiatedAuthType,
4076 eCsrEncryptionType *pNegotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07004077{
4078 tANI_BOOLEAN fRSNMatch = FALSE;
4079
4080 // See if the cyphers in the Bss description match with the settings in the profile.
4081 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
4082 pNegotiatedAuthType, pNegotiatedMCCipher );
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05304083#ifdef WLAN_FEATURE_11W
4084 /* If all the filter matches then finally checks for PMF capabilities */
4085 if (fRSNMatch)
4086 {
4087 fRSNMatch = csrIsPMFCapabilitiesInRSNMatch( hHal, pMFPEnabled,
4088 pMFPRequired, pMFPCapable,
4089 &pIes->RSN);
4090 }
4091#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004092
4093 return( fRSNMatch );
4094}
4095
4096
4097tANI_BOOLEAN csrLookupPMKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pPMKId )
4098{
4099 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4100 tANI_U32 Index;
4101 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4102
Jeff Johnson32d95a32012-09-10 13:15:23 -07004103 if(!pSession)
4104 {
4105 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4106 return FALSE;
4107 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07004108 /* to force the AP initiate fresh 802.1x authentication after re-association should not
4109 * fill the PMKID from cache this is needed
4110 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
4111
4112 if(pSession->fIgnorePMKIDCache)
4113 {
4114 pSession->fIgnorePMKIDCache = FALSE;
4115 return fRC;
4116 }
4117
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 do
4119 {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304120 for( Index=0; Index < CSR_MAX_PMKID_ALLOWED; Index++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304122 if( vos_mem_compare(pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 {
4124 // match found
4125 fMatchFound = TRUE;
4126 break;
4127 }
4128 }
4129
4130 if( !fMatchFound ) break;
4131
Kiet Lam64c1b492013-07-12 13:56:44 +05304132 vos_mem_copy(pPMKId, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004133
4134 fRC = TRUE;
4135 }
4136 while( 0 );
Sushant Kaushik0b343422015-05-25 17:15:55 +05304137 smsLog(pMac, LOG1, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 fRC, pSession->NumPmkidCache);
4139
4140 return fRC;
4141}
4142
4143
4144tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4145 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
4146{
4147 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4148 tANI_BOOLEAN fRSNMatch;
4149 tANI_U8 cbRSNIe = 0;
4150 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
4151 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
4152 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
4153 tCsrRSNAuthIe *pAuthSuite;
4154 tCsrRSNCapabilities RSNCapabilities;
4155 tCsrRSNPMKIe *pPMK;
4156 tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304157 uint32_t ret;
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004158#ifdef WLAN_FEATURE_11W
4159 tANI_U8 *pGroupMgmtCipherSuite;
4160#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 tDot11fBeaconIEs *pIesLocal = pIes;
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304162 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
Abhinav Kumar12560c32018-08-27 18:14:00 +05304163 tDot11fIERSN rsn_ie = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07004164
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004165 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004166
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 do
4168 {
4169 if ( !csrIsProfileRSN( pProfile ) ) break;
4170
4171 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4172 {
4173 break;
4174 }
4175
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304176 /* Use intersection of the RSN cap sent by user space and
4177 * the AP, so that only common capability are enabled.
4178 */
4179 if (pProfile->pRSNReqIE && pProfile->nRSNReqIELength) {
4180 ret = dot11fUnpackIeRSN(pMac, pProfile->pRSNReqIE + 2,
4181 pProfile->nRSNReqIELength -2, &rsn_ie);
4182 if (DOT11F_SUCCEEDED(ret)) {
4183 pIesLocal->RSN.RSN_Cap[0] = pIesLocal->RSN.RSN_Cap[0] &
4184 rsn_ie.RSN_Cap[0];
4185 pIesLocal->RSN.RSN_Cap[1] = pIesLocal->RSN.RSN_Cap[1] &
4186 rsn_ie.RSN_Cap[1];
4187 }
4188 }
4189
4190 /* See if the cyphers in the Bss description match with the settings in the profile */
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4192 &pProfile->mcEncryptionType, &pIesLocal->RSN,
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304193 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, &negAuthType, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 if ( !fRSNMatch ) break;
4195
4196 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
4197
4198 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
4199
Kiet Lam64c1b492013-07-12 13:56:44 +05304200 vos_mem_copy(pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004201
4202 pRSNIe->cUnicastCyphers = 1;
4203
Kiet Lam64c1b492013-07-12 13:56:44 +05304204 vos_mem_copy(&pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004205
4206 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
4207
4208 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304209 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004210
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304211 /* PreAuthSupported is an AP only capability */
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 RSNCapabilities.PreAuthSupported = 0;
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304213
4214 /* Use the Management Frame Protection values given by the supplicant,
4215 * if AP and STA both are MFP capable.
4216 */
Chet Lanctot186b5732013-03-18 10:26:30 -07004217#ifdef WLAN_FEATURE_11W
4218 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
4219 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
4220#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
4222
4223 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
4224
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304225 if (
4226#ifdef FEATURE_WLAN_ESE
4227 (eCSR_AUTH_TYPE_CCKM_RSN != negAuthType) &&
4228#endif
4229 csrLookupPMKID( pMac, sessionId, pSirBssDesc->bssId, &(PMKId[0]) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 {
4231 pPMK->cPMKIDs = 1;
4232
Kiet Lam64c1b492013-07-12 13:56:44 +05304233 vos_mem_copy(pPMK->PMKIDList[0].PMKID, PMKId, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 }
4235 else
4236 {
4237 pPMK->cPMKIDs = 0;
4238 }
4239
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004240#ifdef WLAN_FEATURE_11W
4241 if ( pProfile->MFPEnabled )
4242 {
4243 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
4244 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
Kiet Lam64c1b492013-07-12 13:56:44 +05304245 vos_mem_copy(pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE);
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004246 }
4247#endif
4248
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4250 // Add in the size of the Auth suite (count plus a single OUI)
4251 // Add in the RSN caps field.
4252 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004253 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
4255 sizeof( *pAuthSuite ) +
4256 sizeof( tCsrRSNCapabilities ));
4257 if(pPMK->cPMKIDs)
4258 {
4259 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
4260 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
4261 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004262#ifdef WLAN_FEATURE_11W
4263 if ( pProfile->MFPEnabled )
4264 {
4265 if ( 0 == pPMK->cPMKIDs )
4266 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
4267 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
4268 }
4269#endif
4270
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 // return the size of the IE header (total) constructed...
4272 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
4273
4274 } while( 0 );
4275
4276 if( !pIes && pIesLocal )
4277 {
4278 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304279 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 }
4281
4282 return( cbRSNIe );
4283}
4284
4285
4286#ifdef FEATURE_WLAN_WAPI
4287tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4288 tDot11fIEWAPI *pWapiIe,
4289 tANI_U8 *UnicastCypher,
4290 tANI_U8 *MulticastCypher,
4291 tANI_U8 *AuthSuite,
4292 eCsrAuthType *pNegotiatedAuthtype,
4293 eCsrEncryptionType *pNegotiatedMCCipher )
4294{
4295 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4296 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4297 tANI_U8 cUnicastCyphers = 0;
4298 tANI_U8 cMulticastCyphers = 0;
4299 tANI_U8 cAuthSuites = 0, i;
4300 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
4301 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
4302 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
4303 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
4304 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
4305 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4306
4307 do{
4308 if ( pWapiIe->present )
4309 {
4310 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05304311 vos_mem_copy(MulticastCyphers, pWapiIe->multicast_cipher_suite,
4312 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
4314 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
4315 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
4316 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304317 vos_mem_copy((void *)&AuthSuites[i], (void *)&pWapiIe->akm_suites[i],
4318 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 }
4320
4321 //Check - Is requested Unicast Cipher supported by the BSS.
4322 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
4323 csrGetOUIIndexFromCipher( enType ), Unicast );
4324
4325 if( !fAcceptableCyphers ) break;
4326
4327
4328 //Unicast is supported. Pick the first matching Group cipher, if any.
4329 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4330 {
4331 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4332 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
4333 if(fAcceptableCyphers)
4334 {
4335 break;
4336 }
4337 }
4338 if( !fAcceptableCyphers ) break;
4339
4340 if( pNegotiatedMCCipher )
4341 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4342
4343 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4344 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
4345 {
4346 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4347 }
4348 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
4349 {
4350 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4351 }
4352 else
4353 {
4354 fAcceptableCyphers = FALSE;
4355 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4356 }
4357 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
4358 {
4359 //Caller doesn't care about auth type, or BSS doesn't match
4360 break;
4361 }
4362 fAcceptableCyphers = FALSE;
4363 for( i = 0 ; i < pAuthType->numEntries; i++ )
4364 {
4365 if( pAuthType->authType[i] == negAuthType )
4366 {
4367 fAcceptableCyphers = TRUE;
4368 break;
4369 }
4370 }
4371 }
4372 }while (0);
4373
4374 if ( fAcceptableCyphers )
4375 {
4376 if ( MulticastCypher )
4377 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304378 vos_mem_copy(MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 }
4380
4381 if ( UnicastCypher )
4382 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304383 vos_mem_copy(UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 }
4385
4386 if ( AuthSuite )
4387 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304388 vos_mem_copy(AuthSuite, Authentication, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 }
4390
4391 if ( pNegotiatedAuthtype )
4392 {
4393 *pNegotiatedAuthtype = negAuthType;
4394 }
4395 }
4396 return( fAcceptableCyphers );
4397}
4398
4399tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4400 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
4401{
4402 tANI_BOOLEAN fWapiMatch = FALSE;
4403
4404 // See if the cyphers in the Bss description match with the settings in the profile.
4405 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4406 pNegotiatedAuthType, pNegotiatedMCCipher );
4407
4408 return( fWapiMatch );
4409}
4410
4411tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4412{
4413 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4414 tANI_U32 Index;
4415 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4416
Jeff Johnson32d95a32012-09-10 13:15:23 -07004417 if(!pSession)
4418 {
4419 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4420 return FALSE;
4421 }
4422
Jeff Johnson295189b2012-06-20 16:38:30 -07004423 do
4424 {
4425 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4426 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004427 smsLog(pMac, LOGW, "match BKID "MAC_ADDRESS_STR" to ",
4428 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05304429 if (vos_mem_compare(pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 {
4431 // match found
4432 fMatchFound = TRUE;
4433 break;
4434 }
4435 }
4436
4437 if( !fMatchFound ) break;
4438
Kiet Lam64c1b492013-07-12 13:56:44 +05304439 vos_mem_copy(pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004440
4441 fRC = TRUE;
4442 }
4443 while( 0 );
4444 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4445
4446 return fRC;
4447}
4448
4449tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4450 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4451{
4452 tANI_BOOLEAN fWapiMatch = FALSE;
4453 tANI_U8 cbWapiIe = 0;
4454 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4455 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4456 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4457 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4458 tANI_U8 *pWapi = NULL;
4459 tANI_BOOLEAN fBKIDFound = FALSE;
4460 tDot11fBeaconIEs *pIesLocal = pIes;
4461
4462 do
4463 {
4464 if ( !csrIsProfileWapi( pProfile ) ) break;
4465
4466 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4467 {
4468 break;
4469 }
4470
4471 // See if the cyphers in the Bss description match with the settings in the profile.
4472 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4473 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4474 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4475 if ( !fWapiMatch ) break;
4476
Kiet Lam64c1b492013-07-12 13:56:44 +05304477 vos_mem_set(pWapiIe, sizeof(tCsrWapiIe), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004478
4479 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4480
4481 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4482
4483 pWapiIe->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304484 vos_mem_copy(&pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004485
4486 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4487
4488 *pWapi = (tANI_U16)1; //cUnicastCyphers
4489 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304490 vos_mem_copy(pWapi, UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 pWapi += sizeof( UnicastCypher );
4492
Kiet Lam64c1b492013-07-12 13:56:44 +05304493 vos_mem_copy(pWapi, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 pWapi += sizeof( MulticastCypher );
4495
4496
4497 // WAPI capabilities follows the Auth Suite (two octects)
4498 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4499 // & since we already did a memset pWapiIe to 0, skip these fields
4500 pWapi +=2;
4501
4502 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4503
4504
4505 if( fBKIDFound )
4506 {
4507 /* Do we need to change the endianness here */
4508 *pWapi = (tANI_U16)1; //cBKIDs
4509 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304510 vos_mem_copy(pWapi, BKId, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 }
4512 else
4513 {
4514 *pWapi = 0;
4515 pWapi+=1;
4516 *pWapi = 0;
4517 pWapi+=1;
4518 }
4519
4520 // Add in the IE fields except the IE header
4521 // Add BKID count and BKID (if any)
4522 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4523
4524 /*2 bytes for BKID Count field*/
4525 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4526
4527 if(fBKIDFound)
4528 {
4529 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4530 }
4531 // return the size of the IE header (total) constructed...
4532 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4533
4534 } while( 0 );
4535
4536 if( !pIes && pIesLocal )
4537 {
4538 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304539 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 }
4541
4542 return( cbWapiIe );
4543}
4544#endif /* FEATURE_WLAN_WAPI */
4545
4546tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4547 tDot11fIEWPA *pWpaIe,
4548 tANI_U8 *UnicastCypher,
4549 tANI_U8 *MulticastCypher,
4550 tANI_U8 *AuthSuite,
4551 eCsrAuthType *pNegotiatedAuthtype,
4552 eCsrEncryptionType *pNegotiatedMCCipher )
4553{
4554 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4555 tANI_U8 cUnicastCyphers = 0;
4556 tANI_U8 cMulticastCyphers = 0;
4557 tANI_U8 cAuthSuites = 0;
4558 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4559 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4560 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4561 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4562 tANI_U8 i;
4563 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4564
4565 do
4566 {
4567 if ( pWpaIe->present )
4568 {
4569 cMulticastCyphers = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304570 vos_mem_copy(MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4572 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4573
4574 //Check - Is requested Unicast Cipher supported by the BSS.
4575 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4576 csrGetOUIIndexFromCipher( enType ), Unicast );
4577
4578 if( !fAcceptableCyphers ) break;
4579
4580
4581 //Unicast is supported. Pick the first matching Group cipher, if any.
4582 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4583 {
4584 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4585 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4586 if(fAcceptableCyphers)
4587 {
4588 break;
4589 }
4590 }
4591 if( !fAcceptableCyphers ) break;
4592
4593 if( pNegotiatedMCCipher )
4594 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4595
4596 /* Initializing with FALSE as it has TRUE value already */
4597 fAcceptableCyphers = FALSE;
4598 for (i = 0 ; i < pAuthType->numEntries; i++)
4599 {
4600 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4601 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4602 {
4603 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4604 negAuthType = eCSR_AUTH_TYPE_WPA;
4605 }
4606 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4607 {
4608 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4609 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4610 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004611#ifdef FEATURE_WLAN_ESE
4612 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 {
4614 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4615 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4616 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004617#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004618
4619 // The 1st auth type in the APs WPA IE, to match stations connecting
4620 // profiles auth type will cause us to exit this loop
4621 // This is added as some APs advertise multiple akms in the WPA IE.
4622 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4623 {
4624 fAcceptableCyphers = TRUE;
4625 break;
4626 }
4627 } // for
4628 }
4629 }while(0);
4630
4631 if ( fAcceptableCyphers )
4632 {
4633 if ( MulticastCypher )
4634 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304635 vos_mem_copy((tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 }
4637
4638 if ( UnicastCypher )
4639 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304640 vos_mem_copy((tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 }
4642
4643 if ( AuthSuite )
4644 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304645 vos_mem_copy((tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 }
4647
4648 if( pNegotiatedAuthtype )
4649 {
4650 *pNegotiatedAuthtype = negAuthType;
4651 }
4652 }
4653
4654 return( fAcceptableCyphers );
4655}
4656
4657
4658
4659tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4660 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4661{
4662 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4663
4664 // See if the cyphers in the Bss description match with the settings in the profile.
4665 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4666
4667 return( fWpaMatch );
4668}
4669
4670
4671tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4672 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4673{
4674 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4675 tANI_BOOLEAN fWpaMatch;
4676 tANI_U8 cbWpaIe = 0;
4677 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4678 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4679 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4680 tCsrWpaAuthIe *pAuthSuite;
4681 tDot11fBeaconIEs *pIesLocal = pIes;
4682
4683 do
4684 {
4685 if ( !csrIsProfileWpa( pProfile ) ) break;
4686
4687 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4688 {
4689 break;
4690 }
4691 // See if the cyphers in the Bss description match with the settings in the profile.
4692 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4693 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4694 if ( !fWpaMatch ) break;
4695
4696 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4697
Kiet Lam64c1b492013-07-12 13:56:44 +05304698 vos_mem_copy(pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004699
4700 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4701
Kiet Lam64c1b492013-07-12 13:56:44 +05304702 vos_mem_copy(pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004703
4704 pWpaIe->cUnicastCyphers = 1;
4705
Kiet Lam64c1b492013-07-12 13:56:44 +05304706 vos_mem_copy(&pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004707
4708 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4709
4710 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304711 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004712
4713 // The WPA capabilities follows the Auth Suite (two octects)--
4714 // this field is optional, and we always "send" zero, so just
4715 // remove it. This is consistent with our assumptions in the
4716 // frames compiler; c.f. bug 15234:
4717 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4718
4719 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4720 // Add in the size of the Auth suite (count plus a single OUI)
4721 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4722 sizeof( *pAuthSuite );
4723
4724 // return the size of the IE header (total) constructed...
4725 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4726
4727 } while( 0 );
4728
4729 if( !pIes && pIesLocal )
4730 {
4731 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304732 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 }
4734
4735 return( cbWpaIe );
4736}
4737
4738
4739tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4740 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4741{
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 tDot11IEHeader *pIEHeader;
4743 tSirMacPropIE *pSirMacPropIE;
4744 tANI_U32 cbParsed;
4745 tANI_U32 cbIE;
4746 int cExpectedIEs = 0;
4747 int cFoundIEs = 0;
4748 int cbPropIETotal;
4749
4750 pIEHeader = (tDot11IEHeader *)pIes;
4751 if(pWpaIe) cExpectedIEs++;
4752 if(pRSNIe) cExpectedIEs++;
4753
4754 // bss description length includes all fields other than the length itself
4755 cbParsed = 0;
4756
4757 // Loop as long as there is data left in the IE of the Bss Description
4758 // and the number of Expected IEs is NOT found yet.
4759 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4760 {
4761 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4762
4763 if ( ( cbIE + cbParsed ) > len ) break;
4764
4765 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4766 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4767 {
4768 switch( pIEHeader->ElementID )
4769 {
4770 // Parse the 221 (0xdd) Proprietary IEs here...
4771 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4772 // Airgo proprietary IE information.
4773 case SIR_MAC_WPA_EID:
4774 {
4775 tANI_U32 aniOUI;
4776 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4777
4778 pOui++;
4779 aniOUI = ANI_OUI;
4780 aniOUI = i_ntohl( aniOUI );
4781
4782 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4783 cbPropIETotal = pSirMacPropIE->length;
4784
4785 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4786 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4787 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4788 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4789 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4790 {
4791 }
4792 else
4793 {
4794 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4795
4796 if(!pWpaIe || !pcbWpaIe) break;
4797 // Check if this is a valid WPA IE. Then check that the
4798 // WPA OUI is in place and the version is one that we support.
4799 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
Kiet Lam64c1b492013-07-12 13:56:44 +05304800 ( vos_mem_compare( pIe->Oui, (void *)csrWpaOui[1],
4801 sizeof( pIe->Oui ) ) ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4803 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304804 vos_mem_copy(pWpaIe, pIe,
4805 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4807 cFoundIEs++;
4808
4809 break;
4810 }
4811 }
4812
4813 break;
4814 }
4815
4816 case SIR_MAC_RSN_EID:
4817 {
4818 tCsrRSNIe *pIe;
4819
4820 if(!pcbRSNIe || !pRSNIe) break;
4821 pIe = (tCsrRSNIe *)pIEHeader;
4822
4823 // Check the length of the RSN Ie to assure it is valid. Then check that the
4824 // version is one that we support.
4825
4826 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4827 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4828
4829 cFoundIEs++;
4830
4831 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4832 // the buffer passed in.
4833 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05304834 vos_mem_copy(pRSNIe, pIe,
4835 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4837
4838 break;
4839 }
4840
4841 // Add support for other IE here...
4842 default:
4843 break;
4844 }
4845 }
4846
4847 cbParsed += cbIE;
4848
4849 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4850
4851 }
4852
4853 // return a BOOL that tells if all of the IEs asked for were found...
4854 return( cFoundIEs == cExpectedIEs );
4855}
4856
4857
4858//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4859//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4860tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4861 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4862{
4863 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4864 tANI_U8 cbWpaIe = 0;
4865
4866 do
4867 {
4868 if ( !csrIsProfileWpa( pProfile ) ) break;
4869 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4870 {
4871 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4872 {
4873 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304874 vos_mem_copy(pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 }
4876 else
4877 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004878 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 }
4880 }
4881 else
4882 {
4883 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4884 }
4885 }while(0);
4886
4887 return (cbWpaIe);
4888}
4889
4890
4891//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4892//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4893tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4894 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4895{
4896 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4897 tANI_U8 cbRsnIe = 0;
4898
4899 do
4900 {
4901 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004902#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304903 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004904 {
4905 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4906 // scratch. So it contains the current PMK-IDs
4907 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4908 }
4909 else
4910#endif
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304911 if(pProfile->force_rsne_override &&
4912 pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 {
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304914 smsLog(pMac, LOGW, "force_rsne_override, copy RSN IE provided by user");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004915 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4917 {
4918 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304919 vos_mem_copy(pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 }
4921 else
4922 {
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304923 smsLog(pMac, LOGW, "csrRetrieveRsnIe detect invalid RSN IE length (%d)",
4924 pProfile->nRSNReqIELength);
4925 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 }
4927 }
4928 else
4929 {
4930 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4931 }
4932 }while(0);
4933
4934 return (cbRsnIe);
4935}
4936
4937
4938#ifdef FEATURE_WLAN_WAPI
4939//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
4940//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
4941tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
4942 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4943 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4944{
4945 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4946 tANI_U8 cbWapiIe = 0;
4947
4948 do
4949 {
4950 if ( !csrIsProfileWapi( pProfile ) ) break;
4951 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
4952 {
4953 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
4954 {
4955 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304956 vos_mem_copy(pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 }
4958 else
4959 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004960 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 }
4962 }
4963 else
4964 {
4965 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
4966 }
4967 }while(0);
4968
4969 return (cbWapiIe);
4970}
4971#endif /* FEATURE_WLAN_WAPI */
4972
4973tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
4974{
4975 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4976 tListElem *pEntry;
4977 tANI_U16 i;
4978 tANI_U16 startingChannel;
4979 tANI_BOOLEAN found = FALSE;
4980 tCsrChannelSet *pChannelGroup;
4981
4982 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
4983
4984 while ( pEntry )
4985 {
4986 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
4987 startingChannel = pChannelGroup->firstChannel;
4988 for ( i = 0; i < pChannelGroup->numChannels; i++ )
4989 {
4990 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
4991 {
4992 found = TRUE;
4993 break;
4994 }
4995 }
4996
4997 if ( found )
4998 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304999 vos_mem_copy(returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 break;
5001 }
5002 else
5003 {
5004 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
5005 }
5006 }
5007
5008 return( found );
5009}
5010
5011tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
5012{
5013 tANI_BOOLEAN fSupported = FALSE;
5014 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
5015
5016 switch ( nonBasicRate )
5017 {
5018 case eCsrSuppRate_1Mbps:
5019 case eCsrSuppRate_2Mbps:
5020 case eCsrSuppRate_5_5Mbps:
5021 case eCsrSuppRate_11Mbps:
5022 fSupported = TRUE;
5023 break;
5024
5025 default:
5026 break;
5027 }
5028
5029 return( fSupported );
5030}
5031
5032tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
5033{
5034 tANI_BOOLEAN fSupported = FALSE;
5035 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
5036
5037 switch ( nonBasicRate )
5038 {
5039 case eCsrSuppRate_6Mbps:
5040 case eCsrSuppRate_9Mbps:
5041 case eCsrSuppRate_12Mbps:
5042 case eCsrSuppRate_18Mbps:
5043 case eCsrSuppRate_24Mbps:
5044 case eCsrSuppRate_36Mbps:
5045 case eCsrSuppRate_48Mbps:
5046 case eCsrSuppRate_54Mbps:
5047 fSupported = TRUE;
5048 break;
5049
5050 default:
5051 break;
5052 }
5053
5054 return( fSupported );
5055}
5056
5057
5058
5059tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
5060{
5061 tAniEdType edType;
5062
5063 switch ( EncryptType )
5064 {
5065 default:
5066 case eCSR_ENCRYPT_TYPE_NONE:
5067 edType = eSIR_ED_NONE;
5068 break;
5069
5070 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5071 case eCSR_ENCRYPT_TYPE_WEP40:
5072 edType = eSIR_ED_WEP40;
5073 break;
5074
5075 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5076 case eCSR_ENCRYPT_TYPE_WEP104:
5077 edType = eSIR_ED_WEP104;
5078 break;
5079
5080 case eCSR_ENCRYPT_TYPE_TKIP:
5081 edType = eSIR_ED_TKIP;
5082 break;
5083
5084 case eCSR_ENCRYPT_TYPE_AES:
5085 edType = eSIR_ED_CCMP;
5086 break;
5087#ifdef FEATURE_WLAN_WAPI
5088 case eCSR_ENCRYPT_TYPE_WPI:
5089 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05305090 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005091#endif
5092#ifdef WLAN_FEATURE_11W
5093 //11w BIP
5094 case eCSR_ENCRYPT_TYPE_AES_CMAC:
5095 edType = eSIR_ED_AES_128_CMAC;
5096 break;
5097#endif
5098 }
5099
5100 return( edType );
5101}
5102
5103
5104//pIes can be NULL
5105tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
5106 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
5107 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
5108 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
5109{
5110 tANI_U32 idx;
5111 tANI_BOOLEAN fMatch = FALSE;
5112 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5113 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
5114
5115 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
5116
5117 do
5118 {
5119 //If privacy bit is not set, consider no match
5120 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
5121
5122 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
5123 {
5124 switch( pMCEncryptionList->encryptionType[idx] )
5125 {
5126 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5127 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5128 case eCSR_ENCRYPT_TYPE_WEP40:
5129 case eCSR_ENCRYPT_TYPE_WEP104:
5130 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
5131 */
5132 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
5133 {
5134 fMatch = TRUE;
5135 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
5136 }
5137 break;
5138 default:
5139 fMatch = FALSE;
5140 break;
5141 }
5142 if(fMatch) break;
5143 }
5144
5145 if(!fMatch) break;
5146
5147 for( idx = 0; idx < pAuthList->numEntries; idx++ )
5148 {
5149 switch( pAuthList->authType[idx] )
5150 {
5151 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5152 case eCSR_AUTH_TYPE_SHARED_KEY:
5153 case eCSR_AUTH_TYPE_AUTOSWITCH:
5154 fMatch = TRUE;
5155 negotiatedAuth = pAuthList->authType[idx];
5156 break;
5157 default:
5158 fMatch = FALSE;
5159 }
5160 if (fMatch) break;
5161 }
5162
5163 if(!fMatch) break;
5164 //In case of WPA / WPA2, check whether it supports WEP as well
5165 if(pIes)
5166 {
5167 //Prepare the encryption type for WPA/WPA2 functions
5168 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
5169 {
5170 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
5171 }
5172 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
5173 {
5174 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5175 }
5176 //else we can use the encryption type directly
Kiet Lam64c1b492013-07-12 13:56:44 +05305177 if ( pIes->WPA.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07005178 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305179 fMatch = vos_mem_compare(pIes->WPA.multicast_cipher,
5180 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
5181 CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005182 if( fMatch ) break;
5183 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305184 if ( pIes->RSN.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305186 fMatch = vos_mem_compare(pIes->RSN.gp_cipher_suite,
5187 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
5188 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 }
5190 }
5191
5192 }while(0);
5193
5194 if( fMatch )
5195 {
5196 if( pNegotiatedAuthType )
5197 *pNegotiatedAuthType = negotiatedAuth;
5198
5199 if( pNegotiatedMCEncryption )
5200 *pNegotiatedMCEncryption = negotiatedMCCipher;
5201 }
5202
5203
5204 return fMatch;
5205}
5206
5207
5208//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305209tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType,
5210 tCsrEncryptionList *pUCEncryptionType,
5211 tCsrEncryptionList *pMCEncryptionType,
5212 tANI_BOOLEAN *pMFPEnabled,
5213 tANI_U8 *pMFPRequired, tANI_U8 *pMFPCapable,
5214 tSirBssDescription *pSirBssDesc,
5215 tDot11fBeaconIEs *pIes,
5216 eCsrAuthType *negotiatedAuthtype,
5217 eCsrEncryptionType *negotiatedUCCipher,
5218 eCsrEncryptionType *negotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07005219{
5220 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5221 tANI_BOOLEAN fMatch = FALSE;
5222 tANI_U8 i,idx;
5223 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
5224 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
5225
5226 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
5227 {
5228 ucCipher = pUCEncryptionType->encryptionType[i];
5229 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
5230 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
5231 // encryption type.
5232 switch ( ucCipher )
5233 {
5234 case eCSR_ENCRYPT_TYPE_NONE:
5235 {
5236 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
5237 // required so we have to reject this Bss.
5238 if ( csrIsPrivacy( pSirBssDesc ) )
5239 {
5240 fMatch = FALSE;
5241 }
5242 else
5243 {
5244 fMatch = TRUE;
5245 }
5246
5247 if ( fMatch )
5248 {
5249 fMatch = FALSE;
5250 //Check Multicast cipher requested and Auth type requested.
5251 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
5252 {
5253 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
5254 {
5255 fMatch = TRUE; //Multicast can only be none.
5256 mcCipher = pMCEncryptionType->encryptionType[idx];
5257 break;
5258 }
5259 }
5260 if (!fMatch) break;
5261
5262 fMatch = FALSE;
5263 //Check Auth list. It should contain AuthOpen.
5264 for( idx = 0 ; idx < authType->numEntries ; idx++ )
5265 {
5266 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
5267 {
5268 fMatch = TRUE;
5269 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5270 break;
5271 }
5272 }
5273 if (!fMatch) break;
5274
5275 }
5276 break;
5277 }
5278
5279 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5280 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5281 // !! might want to check for WEP keys set in the Profile.... ?
5282 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
5283 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
5284 // encryption is not allowed without the Privacy bit turned on.
5285 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5286
5287 break;
5288
5289 // these are all of the WPA encryption types...
5290 case eCSR_ENCRYPT_TYPE_WEP40:
5291 case eCSR_ENCRYPT_TYPE_WEP104:
5292 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5293 break;
5294
5295 case eCSR_ENCRYPT_TYPE_TKIP:
5296 case eCSR_ENCRYPT_TYPE_AES:
5297 {
5298 if(pIes)
5299 {
5300 // First check if there is a RSN match
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305301 fMatch = csrIsRSNMatch( pMac, authType, ucCipher,
5302 pMCEncryptionType, pMFPEnabled,
5303 pMFPRequired, pMFPCapable,
5304 pIes, &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 if( !fMatch )
5306 {
5307 // If not RSN, then check if there is a WPA match
5308 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
5309 &negAuthType, &mcCipher );
5310 }
5311 }
5312 else
5313 {
5314 fMatch = FALSE;
5315 }
5316 break;
5317 }
5318#ifdef FEATURE_WLAN_WAPI
5319 case eCSR_ENCRYPT_TYPE_WPI://WAPI
5320 {
5321 if(pIes)
5322 {
5323 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5324 }
5325 else
5326 {
5327 fMatch = FALSE;
5328 }
5329 break;
5330 }
5331#endif /* FEATURE_WLAN_WAPI */
5332 case eCSR_ENCRYPT_TYPE_ANY:
5333 default:
5334 {
5335 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
5336
5337 fMatch = eANI_BOOLEAN_TRUE;
5338 //It is allowed to match anything. Try the more secured ones first.
5339 if(pIes)
5340 {
5341 //Check AES first
5342 ucCipher = eCSR_ENCRYPT_TYPE_AES;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305343 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5344 pMCEncryptionType, pMFPEnabled,
5345 pMFPRequired, pMFPCapable, pIes,
5346 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 if(!fMatchAny)
5348 {
5349 //Check TKIP
5350 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305351 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5352 pMCEncryptionType,
5353 pMFPEnabled, pMFPRequired,
5354 pMFPCapable, pIes,
5355 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 }
5357#ifdef FEATURE_WLAN_WAPI
5358 if(!fMatchAny)
5359 {
5360 //Check WAPI
5361 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
5362 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5363 }
5364#endif /* FEATURE_WLAN_WAPI */
5365 }
5366 if(!fMatchAny)
5367 {
5368 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
5369 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5370 {
5371 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
5372 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5373 {
5374 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5375 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5376 {
5377 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5378 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5379 {
5380 //It must be open and no encryption
5381 if ( csrIsPrivacy( pSirBssDesc ) )
5382 {
5383 //This is not right
5384 fMatch = eANI_BOOLEAN_FALSE;
5385 }
5386 else
5387 {
5388 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5389 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
5390 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
5391 }
5392 }
5393 }
5394 }
5395 }
5396 }
5397 break;
5398 }
5399 }
5400
5401 }
5402
5403 if( fMatch )
5404 {
5405 if( negotiatedUCCipher )
5406 *negotiatedUCCipher = ucCipher;
5407
5408 if( negotiatedMCCipher )
5409 *negotiatedMCCipher = mcCipher;
5410
5411 if( negotiatedAuthtype )
5412 *negotiatedAuthtype = negAuthType;
5413 }
5414
5415 return( fMatch );
5416}
5417
5418
5419tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
5420 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
5421{
5422 tANI_BOOLEAN fMatch = FALSE;
5423
5424 do {
Padma, Santhosh Kumara43e06c2015-05-21 14:58:13 +05305425 // Check for the specification of the Broadcast SSID at the beginning
5426 // of the list. If specified, then all SSIDs are matches
5427 // (broadcast SSID means accept all SSIDs).
5428 if ( ssid1Len == 0 )
5429 {
5430 fMatch = TRUE;
5431 break;
5432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005433
5434 // There are a few special cases. If the Bss description has a Broadcast SSID,
5435 // then our Profile must have a single SSID without Wildcards so we can program
5436 // the SSID.
5437 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5438 // but the SSID value is all NULL characters. That condition is trated same
5439 // as NULL SSID
5440 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5441 {
5442 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5443 {
5444 fMatch = TRUE;
5445 }
5446 break;
5447 }
5448
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 if(ssid1Len != bssSsidLen) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05305450 if (vos_mem_compare(bssSsid, ssid1, bssSsidLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 {
5452 fMatch = TRUE;
5453 break;
5454 }
5455
5456 } while( 0 );
5457
5458 return( fMatch );
5459}
5460
5461
5462//Null ssid means match
5463tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5464{
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 tANI_BOOLEAN fMatch = FALSE;
5466 tANI_U32 i;
5467
5468 if ( pSsidList && pSsid )
5469 {
5470 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5471 {
5472 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
Kiet Lam64c1b492013-07-12 13:56:44 +05305473 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5474 vos_mem_compare(pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 {
5476 fMatch = TRUE;
5477 break;
5478 }
5479 }
5480 }
5481
5482 return (fMatch);
5483}
5484
5485//like to use sirCompareMacAddr
5486tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5487{
5488 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5489
Kiet Lam64c1b492013-07-12 13:56:44 +05305490 return (vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005491}
5492
5493//like to use sirCompareMacAddr
5494tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5495{
5496 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5497
Kiet Lam64c1b492013-07-12 13:56:44 +05305498 return(vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005499}
5500
5501
5502//like to use sirCompareMacAddr
5503tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5504{
Kiet Lam64c1b492013-07-12 13:56:44 +05305505 return(vos_mem_compare(pMacAddr1, pMacAddr2, sizeof(tCsrBssid)));
Jeff Johnson295189b2012-06-20 16:38:30 -07005506}
5507
5508
5509tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5510{
5511 tANI_BOOLEAN fMatch = FALSE;
5512 tCsrBssid ProfileBssid;
5513 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5514
5515 // for efficiency of the MAC_ADDRESS functions, move the
5516 // Bssid's into MAC_ADDRESS structs.
Kiet Lam64c1b492013-07-12 13:56:44 +05305517 vos_mem_copy(&ProfileBssid, pProfBssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005518
5519 do {
5520
5521 // Give the profile the benefit of the doubt... accept either all 0 or
5522 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5523 // match any Bssids).
5524 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5525 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5526 {
5527 fMatch = TRUE;
5528 break;
5529 }
5530
5531 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5532 {
5533 fMatch = TRUE;
5534 break;
5535 }
5536
5537 } while( 0 );
5538
5539 return( fMatch );
5540}
5541
5542
5543tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5544{
5545 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5546 return eANI_BOOLEAN_FALSE;
5547 else
5548 return eANI_BOOLEAN_TRUE;
5549}
5550
5551
5552tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5553{
5554 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5555}
5556
5557tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5558{
5559 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5560}
5561
5562tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5563{
5564 tANI_BOOLEAN fMatch = TRUE;
5565
5566 do
5567 {
5568 switch( bssType )
5569 {
5570 case eCSR_BSS_TYPE_ANY:
5571 break;
5572
5573 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5574 case eCSR_BSS_TYPE_WDS_STA:
5575 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5576 fMatch = FALSE;
5577
5578 break;
5579
5580 case eCSR_BSS_TYPE_IBSS:
5581 case eCSR_BSS_TYPE_START_IBSS:
5582 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5583 fMatch = FALSE;
5584
5585 break;
5586
5587 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5588 default:
5589 fMatch = FALSE;
5590 break;
5591 }
5592 }
5593 while( 0 );
5594
5595
5596 return( fMatch );
5597}
5598
5599static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5600{
5601 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5602}
5603
5604
5605
5606static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5607{
5608 tANI_BOOLEAN fMatch = TRUE;
5609
5610 do
5611 {
5612 // if the channel is ANY, then always match...
5613 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5614 if ( Channel == pSirBssDesc->channelId ) break;
5615
5616 // didn't match anything.. so return NO match
5617 fMatch = FALSE;
5618
5619 } while( 0 );
5620
5621 return( fMatch );
5622}
5623
5624
5625tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5626{
5627 tANI_BOOLEAN fMatch = TRUE;
5628
5629 do
5630 {
5631 // if the profile says Any channel AND the global settings says ANY channel, then we
5632 // always match...
5633 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5634
5635 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5636 {
5637 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5638 }
5639
5640 } while( 0 );
5641
5642 return( fMatch );
5643}
5644
5645
5646/**
5647 * \brief Enquire as to whether a given rate is supported by the
5648 * adapter as currently configured
5649 *
5650 *
5651 * \param nRate A rate in units of 500kbps
5652 *
5653 * \return TRUE if the adapter is currently capable of supporting this
5654 * rate, FALSE else
5655 *
5656 *
5657 * The rate encoding is just as in 802.11 Information Elements, except
5658 * that the high bit is \em not interpreted as indicating a Basic Rate,
5659 * and proprietary rates are allowed, too.
5660 *
5661 * Note that if the adapter's dot11Mode is g, we don't restrict the
5662 * rates. According to hwReadEepromParameters, this will happen when:
5663 *
5664 * ... the card is configured for ALL bands through the property
5665 * page. If this occurs, and the card is not an ABG card ,then this
5666 * code is setting the dot11Mode to assume the mode that the
5667 * hardware can support. For example, if the card is an 11BG card
5668 * and we are configured to support ALL bands, then we change the
5669 * dot11Mode to 11g because ALL in this case is only what the
5670 * hardware can support.
5671 *
5672 *
5673 */
5674
5675static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5676{
5677 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5678 tANI_U16 idx, newRate;
5679
5680 //In case basic rate flag is set
5681 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5682 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5683 {
5684 switch ( newRate )
5685 {
5686 case eCsrSuppRate_6Mbps:
5687 case eCsrSuppRate_9Mbps:
5688 case eCsrSuppRate_12Mbps:
5689 case eCsrSuppRate_18Mbps:
5690 case eCsrSuppRate_24Mbps:
5691 case eCsrSuppRate_36Mbps:
5692 case eCsrSuppRate_48Mbps:
5693 case eCsrSuppRate_54Mbps:
5694 fSupported = TRUE;
5695 break;
5696 default:
5697 fSupported = FALSE;
5698 break;
5699 }
5700
5701 }
5702 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5703 {
5704 switch ( newRate )
5705 {
5706 case eCsrSuppRate_1Mbps:
5707 case eCsrSuppRate_2Mbps:
5708 case eCsrSuppRate_5_5Mbps:
5709 case eCsrSuppRate_11Mbps:
5710 fSupported = TRUE;
5711 break;
5712 default:
5713 fSupported = FALSE;
5714 break;
5715 }
5716 }
5717 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5718 {
5719
5720 switch ( newRate )
5721 {
5722 case eCsrSuppRate_1Mbps:
5723 case eCsrSuppRate_2Mbps:
5724 case eCsrSuppRate_5_5Mbps:
5725 case eCsrSuppRate_6Mbps:
5726 case eCsrSuppRate_9Mbps:
5727 case eCsrSuppRate_11Mbps:
5728 case eCsrSuppRate_12Mbps:
5729 case eCsrSuppRate_18Mbps:
5730 case eCsrSuppRate_24Mbps:
5731 case eCsrSuppRate_36Mbps:
5732 case eCsrSuppRate_48Mbps:
5733 case eCsrSuppRate_54Mbps:
5734 fSupported = TRUE;
5735 break;
5736 default:
5737 fSupported = FALSE;
5738 break;
5739 }
5740
5741 }
5742 else {
5743
5744 if ( eCsrSuppRate_1Mbps == newRate ||
5745 eCsrSuppRate_2Mbps == newRate ||
5746 eCsrSuppRate_5_5Mbps == newRate ||
5747 eCsrSuppRate_11Mbps == newRate )
5748 {
5749 fSupported = TRUE;
5750 }
5751 else {
5752 idx = 0x1;
5753
5754 switch ( newRate )
5755 {
5756 case eCsrSuppRate_6Mbps:
5757 fSupported = gPhyRatesSuppt[0][idx];
5758 break;
5759 case eCsrSuppRate_9Mbps:
5760 fSupported = gPhyRatesSuppt[1][idx];
5761 break;
5762 case eCsrSuppRate_12Mbps:
5763 fSupported = gPhyRatesSuppt[2][idx];
5764 break;
5765 case eCsrSuppRate_18Mbps:
5766 fSupported = gPhyRatesSuppt[3][idx];
5767 break;
5768 case eCsrSuppRate_20Mbps:
5769 fSupported = gPhyRatesSuppt[4][idx];
5770 break;
5771 case eCsrSuppRate_24Mbps:
5772 fSupported = gPhyRatesSuppt[5][idx];
5773 break;
5774 case eCsrSuppRate_36Mbps:
5775 fSupported = gPhyRatesSuppt[6][idx];
5776 break;
5777 case eCsrSuppRate_40Mbps:
5778 fSupported = gPhyRatesSuppt[7][idx];
5779 break;
5780 case eCsrSuppRate_42Mbps:
5781 fSupported = gPhyRatesSuppt[8][idx];
5782 break;
5783 case eCsrSuppRate_48Mbps:
5784 fSupported = gPhyRatesSuppt[9][idx];
5785 break;
5786 case eCsrSuppRate_54Mbps:
5787 fSupported = gPhyRatesSuppt[10][idx];
5788 break;
5789 case eCsrSuppRate_72Mbps:
5790 fSupported = gPhyRatesSuppt[11][idx];
5791 break;
5792 case eCsrSuppRate_80Mbps:
5793 fSupported = gPhyRatesSuppt[12][idx];
5794 break;
5795 case eCsrSuppRate_84Mbps:
5796 fSupported = gPhyRatesSuppt[13][idx];
5797 break;
5798 case eCsrSuppRate_96Mbps:
5799 fSupported = gPhyRatesSuppt[14][idx];
5800 break;
5801 case eCsrSuppRate_108Mbps:
5802 fSupported = gPhyRatesSuppt[15][idx];
5803 break;
5804 case eCsrSuppRate_120Mbps:
5805 fSupported = gPhyRatesSuppt[16][idx];
5806 break;
5807 case eCsrSuppRate_126Mbps:
5808 fSupported = gPhyRatesSuppt[17][idx];
5809 break;
5810 case eCsrSuppRate_144Mbps:
5811 fSupported = gPhyRatesSuppt[18][idx];
5812 break;
5813 case eCsrSuppRate_160Mbps:
5814 fSupported = gPhyRatesSuppt[19][idx];
5815 break;
5816 case eCsrSuppRate_168Mbps:
5817 fSupported = gPhyRatesSuppt[20][idx];
5818 break;
5819 case eCsrSuppRate_192Mbps:
5820 fSupported = gPhyRatesSuppt[21][idx];
5821 break;
5822 case eCsrSuppRate_216Mbps:
5823 fSupported = gPhyRatesSuppt[22][idx];
5824 break;
5825 case eCsrSuppRate_240Mbps:
5826 fSupported = gPhyRatesSuppt[23][idx];
5827 break;
5828 default:
5829 fSupported = FALSE;
5830 break;
5831 }
5832 }
5833 }
5834
5835 return fSupported;
5836}
5837
5838
5839
5840static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5841 tDot11fIESuppRates *pBssSuppRates,
5842 tDot11fIEExtSuppRates *pBssExtSuppRates )
5843{
5844 tANI_BOOLEAN fMatch = TRUE;
5845 tANI_U32 i;
5846
5847
5848 // Validate that all of the Basic rates advertised in the Bss description are supported.
5849 if ( pBssSuppRates )
5850 {
5851 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5852 {
5853 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5854 {
5855 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5856 {
5857 fMatch = FALSE;
5858 break;
5859 }
5860 }
5861 }
5862 }
5863
5864 if ( fMatch && pBssExtSuppRates )
5865 {
5866 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5867 {
5868 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5869 {
5870 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5871 {
5872 fMatch = FALSE;
5873 break;
5874 }
5875 }
5876 }
5877 }
5878
5879 return( fMatch );
5880
5881}
5882
Pragaspathi Thilagaraje548fab2018-06-22 11:55:55 +05305883/**
5884 * csr_match_security() - wrapper to check if the security is matching
5885 * @mac_ctx: mac context
5886 * @filter: scan filter
5887 * @bss_desc: BSS Descriptor
5888 * @ies_ptr: Pointer to the IE fields
5889 * @neg_auth_type: Negotiated Auth type with the AP
5890 * @neg_uc_cipher: Negotiated unicast cipher suite
5891 * @neg_mc_cipher: Negotiated multicast cipher
5892 *
5893 * Return: true if matched else false.
5894 */
5895#ifdef WLAN_FEATURE_11W
5896static inline bool csr_match_security(tpAniSirGlobal pMac,
5897 tCsrScanResultFilter *filter, tSirBssDescription *bss_desc,
5898 tDot11fBeaconIEs *ies_ptr, eCsrAuthType *neg_auth,
5899 eCsrEncryptionType *neg_uc,
5900 eCsrEncryptionType *neg_mc)
5901{
5902
5903 if (!filter)
5904 return false;
5905
5906 if (filter->bWPSAssociation || filter->bOSENAssociation)
5907 return true;
5908
5909 if (filter->ignore_pmf_cap)
5910 return csrIsSecurityMatch(pMac, &filter->authType,
5911 &filter->EncryptionType,
5912 &filter->mcEncryptionType,
5913 NULL, NULL, NULL,
5914 bss_desc, ies_ptr, neg_auth,
5915 neg_uc, neg_mc);
5916 else
5917 return csrIsSecurityMatch(pMac, &filter->authType,
5918 &filter->EncryptionType,
5919 &filter->mcEncryptionType,
5920 &filter->MFPEnabled,
5921 &filter->MFPRequired,
5922 &filter->MFPCapable,
5923 bss_desc, ies_ptr, neg_auth,
5924 neg_uc, neg_mc);
5925
5926}
5927#else
5928static inline bool csr_match_security(tpAniSirGlobal mac_ctx,
5929 tCsrScanResultFilter *filter, tSirBssDescription *bss_desc,
5930 tDot11fBeaconIEs *ies_ptr, eCsrAuthType *neg_auth,
5931 eCsrEncryptionType *neg_uc,
5932 eCsrEncryptionType *neg_mc)
5933
5934{
5935 if (!filter)
5936 return false;
5937
5938 if (filter->bWPSAssociation || filter->bOSENAssociation)
5939 return true;
5940
5941 return csrIsSecurityMatch(mac_ctx, &filter->authType,
5942 &filter->EncryptionType,
5943 &filter->mcEncryptionType,
5944 NULL, NULL, NULL,
5945 bss_desc, ies_ptr, neg_auth,
5946 neg_uc, neg_mc);
5947}
5948#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005949
5950//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
5951tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
5952 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
5953 tDot11fBeaconIEs **ppIes)
5954{
5955 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5956 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5957 tANI_U32 i;
5958 tDot11fBeaconIEs *pIes = NULL;
5959 tANI_U8 *pb;
5960
5961 do {
5962 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
5963 {
5964 //If no IEs passed in, get our own.
5965 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
5966 {
5967 break;
5968 }
5969 }
5970 else
5971 {
5972 //Save the one pass in for local use
5973 pIes = *ppIes;
5974 }
5975
5976 //Check if caller wants P2P
5977 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
5978 if(!fCheck) break;
5979
5980 if(pIes->SSID.present)
5981 {
5982 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
5983 {
5984 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
5985 pIes->SSID.ssid,
5986 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
5987 if ( fCheck ) break;
5988 }
5989 if(!fCheck) break;
5990 }
5991 fCheck = eANI_BOOLEAN_TRUE;
5992 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
5993 {
5994 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
5995 if ( fCheck ) break;
5996
5997 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
5998 {
5999 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
6000 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
6001
6002 if ( fCheck ) break;
6003 }
6004 }
6005 if(!fCheck) break;
6006
6007 fCheck = eANI_BOOLEAN_TRUE;
6008 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
6009 {
6010 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
6011 if ( fCheck ) break;
6012 }
6013 if(!fCheck)
6014 break;
6015#if defined WLAN_FEATURE_VOWIFI
6016 /* If this is for measurement filtering */
6017 if( pFilter->fMeasurement )
6018 {
6019 fRC = eANI_BOOLEAN_TRUE;
6020 break;
6021 }
6022#endif
6023 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
Pragaspathi Thilagaraje548fab2018-06-22 11:55:55 +05306024 if ( !csr_match_security(pMac, pFilter, pBssDesc, pIes, pNegAuth, pNegUc, pNegMc)) break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
6026 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
6027 //Tush-QoS: validate first if asked for APSD or WMM association
6028 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
6029 !CSR_IS_QOS_BSS(pIes) )
6030 break;
6031 //Check country. check even when pb is NULL because we may want to make sure
6032 //AP has a country code in it if fEnforceCountryCodeMatch is set.
6033 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
6034
6035 fCheck = csrMatchCountryCode( pMac, pb, pIes );
6036 if(!fCheck)
6037 break;
6038
6039#ifdef WLAN_FEATURE_VOWIFI_11R
Hema Aparna Medicharlaf9dec8d2015-04-29 12:37:06 +05306040 if (pFilter->MDID.mdiePresent && csrRoamIs11rAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 {
6042 if (pBssDesc->mdiePresent)
6043 {
6044 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
6045 break;
6046 }
6047 else
6048 break;
6049 }
6050#endif
6051 fRC = eANI_BOOLEAN_TRUE;
6052
6053 } while( 0 );
6054 if( ppIes )
6055 {
6056 *ppIes = pIes;
6057 }
6058 else if( pIes )
6059 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306060 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 }
6062
6063 return( fRC );
6064}
6065
6066tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
6067 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
6068{
6069 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
6070 tCsrAuthList authList;
6071
6072 ucEncryptionList.numEntries = 1;
6073 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
6074
6075 mcEncryptionList.numEntries = 1;
6076 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
6077
6078 authList.numEntries = 1;
6079 authList.authType[0] = pProfile->AuthType;
6080
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05306081 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList,
6082 &mcEncryptionList, NULL, NULL, NULL,
6083 pBssDesc, pIes, NULL, NULL, NULL ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006084
6085}
6086
6087
6088tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
6089 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
6090{
6091 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6092 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
6093 tDot11fBeaconIEs *pIesLocal = pIes;
6094
6095 do {
6096 if( !pIes )
6097 {
6098 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
6099 {
6100 break;
6101 }
6102 }
6103 fCheck = eANI_BOOLEAN_TRUE;
6104 if(pIesLocal->SSID.present)
6105 {
6106 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
6107 if(pProfile->SSID.length)
6108 {
6109 fCheckSsid = eANI_BOOLEAN_TRUE;
6110 }
6111 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
6112 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
6113 if(!fCheck) break;
6114 }
6115 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
6116 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
6117 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
6118 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
6119 if(!fCheck)
6120 break;
6121
6122 fRC = eANI_BOOLEAN_TRUE;
6123
6124 } while( 0 );
6125
6126 if( !pIes && pIesLocal )
6127 {
6128 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05306129 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 }
6131
6132 return( fRC );
6133}
6134
6135
6136
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05306137void csrAddRateBitmap(tANI_U8 rate, tANI_U16 *pRateBitmap)
6138{
6139 tANI_U16 rateBitmap;
6140 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6141 rateBitmap = *pRateBitmap;
6142 switch(n)
6143 {
6144 case SIR_MAC_RATE_1:
6145 rateBitmap |= SIR_MAC_RATE_1_BITMAP;
6146 break;
6147 case SIR_MAC_RATE_2:
6148 rateBitmap |= SIR_MAC_RATE_2_BITMAP;
6149 break;
6150 case SIR_MAC_RATE_5_5:
6151 rateBitmap |= SIR_MAC_RATE_5_5_BITMAP;
6152 break;
6153 case SIR_MAC_RATE_11:
6154 rateBitmap |= SIR_MAC_RATE_11_BITMAP;
6155 break;
6156 case SIR_MAC_RATE_6:
6157 rateBitmap |= SIR_MAC_RATE_6_BITMAP;
6158 break;
6159 case SIR_MAC_RATE_9:
6160 rateBitmap |= SIR_MAC_RATE_9_BITMAP;
6161 break;
6162 case SIR_MAC_RATE_12:
6163 rateBitmap |= SIR_MAC_RATE_12_BITMAP;
6164 break;
6165 case SIR_MAC_RATE_18:
6166 rateBitmap |= SIR_MAC_RATE_18_BITMAP;
6167 break;
6168 case SIR_MAC_RATE_24:
6169 rateBitmap |= SIR_MAC_RATE_24_BITMAP;
6170 break;
6171 case SIR_MAC_RATE_36:
6172 rateBitmap |= SIR_MAC_RATE_36_BITMAP;
6173 break;
6174 case SIR_MAC_RATE_48:
6175 rateBitmap |= SIR_MAC_RATE_48_BITMAP;
6176 break;
6177 case SIR_MAC_RATE_54:
6178 rateBitmap |= SIR_MAC_RATE_54_BITMAP;
6179 break;
6180 }
6181 *pRateBitmap = rateBitmap;
6182}
6183
6184
6185
6186tANI_BOOLEAN csrIsRateAlreadyPresent(tANI_U8 rate, tANI_U16 rateBitmap)
6187{
6188 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6189
6190 switch(n)
6191 {
6192 case SIR_MAC_RATE_1:
6193 rateBitmap &= SIR_MAC_RATE_1_BITMAP;
6194 break;
6195 case SIR_MAC_RATE_2:
6196 rateBitmap &= SIR_MAC_RATE_2_BITMAP;
6197 break;
6198 case SIR_MAC_RATE_5_5:
6199 rateBitmap &= SIR_MAC_RATE_5_5_BITMAP;
6200 break;
6201 case SIR_MAC_RATE_11:
6202 rateBitmap &= SIR_MAC_RATE_11_BITMAP;
6203 break;
6204 case SIR_MAC_RATE_6:
6205 rateBitmap &= SIR_MAC_RATE_6_BITMAP;
6206 break;
6207 case SIR_MAC_RATE_9:
6208 rateBitmap &= SIR_MAC_RATE_9_BITMAP;
6209 break;
6210 case SIR_MAC_RATE_12:
6211 rateBitmap &= SIR_MAC_RATE_12_BITMAP;
6212 break;
6213 case SIR_MAC_RATE_18:
6214 rateBitmap &= SIR_MAC_RATE_18_BITMAP;
6215 break;
6216 case SIR_MAC_RATE_24:
6217 rateBitmap &= SIR_MAC_RATE_24_BITMAP;
6218 break;
6219 case SIR_MAC_RATE_36:
6220 rateBitmap &= SIR_MAC_RATE_36_BITMAP;
6221 break;
6222 case SIR_MAC_RATE_48:
6223 rateBitmap &= SIR_MAC_RATE_48_BITMAP;
6224 break;
6225 case SIR_MAC_RATE_54:
6226 rateBitmap &= SIR_MAC_RATE_54_BITMAP;
6227 break;
6228 }
6229 return !!rateBitmap;
6230}
6231
6232
6233
Jeff Johnson295189b2012-06-20 16:38:30 -07006234tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
6235{
6236 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6237 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6238
6239 return csrIsAggregateRateSupported( pMac, n );
6240}
6241
6242
6243tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
6244{
6245 tANI_U16 ConvertedRate = Rate;
6246
6247 switch( Rate )
6248 {
6249 case SIR_MAC_RATE_1:
6250 ConvertedRate = 2;
6251 break;
6252 case SIR_MAC_RATE_2:
6253 ConvertedRate = 4;
6254 break;
6255 case SIR_MAC_RATE_5_5:
6256 ConvertedRate = 11;
6257 break;
6258 case SIR_MAC_RATE_11:
6259 ConvertedRate = 22;
6260 break;
6261
6262 case SIR_MAC_RATE_6:
6263 ConvertedRate = 12;
6264 break;
6265 case SIR_MAC_RATE_9:
6266 ConvertedRate = 18;
6267 break;
6268 case SIR_MAC_RATE_12:
6269 ConvertedRate = 24;
6270 break;
6271 case SIR_MAC_RATE_18:
6272 ConvertedRate = 36;
6273 break;
6274 case SIR_MAC_RATE_24:
6275 ConvertedRate = 48;
6276 break;
6277 case SIR_MAC_RATE_36:
6278 ConvertedRate = 72;
6279 break;
6280 case SIR_MAC_RATE_42:
6281 ConvertedRate = 84;
6282 break;
6283 case SIR_MAC_RATE_48:
6284 ConvertedRate = 96;
6285 break;
6286 case SIR_MAC_RATE_54:
6287 ConvertedRate = 108;
6288 break;
6289
6290 case SIR_MAC_RATE_72:
6291 ConvertedRate = 144;
6292 break;
6293 case SIR_MAC_RATE_84:
6294 ConvertedRate = 168;
6295 break;
6296 case SIR_MAC_RATE_96:
6297 ConvertedRate = 192;
6298 break;
6299 case SIR_MAC_RATE_108:
6300 ConvertedRate = 216;
6301 break;
6302 case SIR_MAC_RATE_126:
6303 ConvertedRate = 252;
6304 break;
6305 case SIR_MAC_RATE_144:
6306 ConvertedRate = 288;
6307 break;
6308 case SIR_MAC_RATE_168:
6309 ConvertedRate = 336;
6310 break;
6311 case SIR_MAC_RATE_192:
6312 ConvertedRate = 384;
6313 break;
6314 case SIR_MAC_RATE_216:
6315 ConvertedRate = 432;
6316 break;
6317 case SIR_MAC_RATE_240:
6318 ConvertedRate = 480;
6319 break;
6320
6321 case 0xff:
6322 ConvertedRate = 0;
6323 break;
6324 }
6325
6326 return ConvertedRate;
6327}
6328
6329
6330tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
6331{
6332 tANI_U8 i;
6333 tANI_U16 nBest;
6334
6335 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
6336
6337 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
6338 {
6339 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
6340 }
6341
6342 for ( i = 1U; i < pSuppRates->numRates; ++i )
6343 {
6344 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6345 }
6346
6347 if ( NULL != pExtRates )
6348 {
6349 for ( i = 0U; i < pExtRates->numRates; ++i )
6350 {
6351 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6352 }
6353 }
6354
6355 if ( NULL != pPropRates )
6356 {
6357 for ( i = 0U; i < pPropRates->numPropRates; ++i )
6358 {
6359 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
6360 }
6361 }
6362
6363 return nBest;
6364}
6365
6366
6367void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
6368{
6369 if(pProfile)
6370 {
6371 if(pProfile->BSSIDs.bssid)
6372 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306373 vos_mem_free(pProfile->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 pProfile->BSSIDs.bssid = NULL;
6375 }
6376 if(pProfile->SSIDs.SSIDList)
6377 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306378 vos_mem_free(pProfile->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 pProfile->SSIDs.SSIDList = NULL;
6380 }
6381 if(pProfile->pWPAReqIE)
6382 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306383 vos_mem_free(pProfile->pWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 pProfile->pWPAReqIE = NULL;
6385 }
6386 if(pProfile->pRSNReqIE)
6387 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306388 vos_mem_free(pProfile->pRSNReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 pProfile->pRSNReqIE = NULL;
6390 }
6391#ifdef FEATURE_WLAN_WAPI
6392 if(pProfile->pWAPIReqIE)
6393 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306394 vos_mem_free(pProfile->pWAPIReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 pProfile->pWAPIReqIE = NULL;
6396 }
6397#endif /* FEATURE_WLAN_WAPI */
6398
Agarwal Ashish4f616132013-12-30 23:32:50 +05306399 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306401 memset(pProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306402 pProfile->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 }
6404
6405 if(pProfile->pAddIEAssoc)
6406 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306407 vos_mem_free(pProfile->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 pProfile->pAddIEAssoc = NULL;
6409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 if(pProfile->ChannelInfo.ChannelList)
6411 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306412 vos_mem_free(pProfile->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 pProfile->ChannelInfo.ChannelList = NULL;
6414 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306415 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 }
6417}
6418
6419void csrFreeScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
6420{
6421 if(pScanFilter->BSSIDs.bssid)
6422 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306423 vos_mem_free(pScanFilter->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 pScanFilter->BSSIDs.bssid = NULL;
6425 }
6426 if(pScanFilter->ChannelInfo.ChannelList)
6427 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306428 vos_mem_free(pScanFilter->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 pScanFilter->ChannelInfo.ChannelList = NULL;
6430 }
6431 if(pScanFilter->SSIDs.SSIDList)
6432 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306433 vos_mem_free(pScanFilter->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 pScanFilter->SSIDs.SSIDList = NULL;
6435 }
6436}
6437
6438
6439void csrFreeRoamProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6440{
6441 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6442
6443 if(pSession->pCurRoamProfile)
6444 {
6445 csrReleaseProfile(pMac, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306446 vos_mem_free(pSession->pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006447 pSession->pCurRoamProfile = NULL;
6448 }
6449}
6450
6451
6452void csrFreeConnectBssDesc(tpAniSirGlobal pMac, tANI_U32 sessionId)
6453{
6454 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6455
6456 if(pSession->pConnectBssDesc)
6457 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306458 vos_mem_free(pSession->pConnectBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006459 pSession->pConnectBssDesc = NULL;
6460 }
6461}
6462
6463
6464
6465tSirResultCodes csrGetDisassocRspStatusCode( tSirSmeDisassocRsp *pSmeDisassocRsp )
6466{
6467 tANI_U8 *pBuffer = (tANI_U8 *)pSmeDisassocRsp;
6468 tANI_U32 ret;
6469
6470 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
6471 //tSirResultCodes is an enum, assuming is 32bit
6472 //If we cannot make this assumption, use copymemory
6473 pal_get_U32( pBuffer, &ret );
6474
6475 return( ( tSirResultCodes )ret );
6476}
6477
6478
6479tSirResultCodes csrGetDeAuthRspStatusCode( tSirSmeDeauthRsp *pSmeRsp )
6480{
6481 tANI_U8 *pBuffer = (tANI_U8 *)pSmeRsp;
6482 tANI_U32 ret;
6483
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006484 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tANI_U8) + sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 //tSirResultCodes is an enum, assuming is 32bit
6486 //If we cannot make this assumption, use copymemory
6487 pal_get_U32( pBuffer, &ret );
6488
6489 return( ( tSirResultCodes )ret );
6490}
6491
6492#if 0
6493tSirScanType csrGetScanType(tANI_U8 chnId, eRegDomainId domainId, tANI_U8 *countryCode)
6494{
6495 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6496 tANI_U8 cc = 0;
6497
6498 while (cc++ < gCsrDomainChnInfo[domainId].numChannels)
6499 {
6500 if(chnId == gCsrDomainChnInfo[domainId].chnInfo[cc].chnId)
6501 {
6502 scanType = gCsrDomainChnInfo[domainId].chnInfo[cc].scanType;
6503 break;
6504 }
6505 }
6506
6507 return (scanType);
6508}
6509#endif
6510
6511tSirScanType csrGetScanType(tpAniSirGlobal pMac, tANI_U8 chnId)
6512{
6513 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6514 eNVChannelEnabledType channelEnabledType;
6515
6516 channelEnabledType = vos_nv_getChannelEnabledState(chnId);
6517 if( NV_CHANNEL_ENABLE == channelEnabledType)
6518 {
6519 scanType = eSIR_ACTIVE_SCAN;
6520 }
6521 return (scanType);
6522}
6523
6524
6525tANI_U8 csrToUpper( tANI_U8 ch )
6526{
6527 tANI_U8 chOut;
6528
6529 if ( ch >= 'a' && ch <= 'z' )
6530 {
6531 chOut = ch - 'a' + 'A';
6532 }
6533 else
6534 {
6535 chOut = ch;
6536 }
6537 return( chOut );
6538}
6539
6540
6541tSirBssType csrTranslateBsstypeToMacType(eCsrRoamBssType csrtype)
6542{
6543 tSirBssType ret;
6544
6545 switch(csrtype)
6546 {
6547 case eCSR_BSS_TYPE_INFRASTRUCTURE:
6548 ret = eSIR_INFRASTRUCTURE_MODE;
6549 break;
6550 case eCSR_BSS_TYPE_IBSS:
6551 case eCSR_BSS_TYPE_START_IBSS:
6552 ret = eSIR_IBSS_MODE;
6553 break;
6554 case eCSR_BSS_TYPE_WDS_AP:
6555 ret = eSIR_BTAMP_AP_MODE;
6556 break;
6557 case eCSR_BSS_TYPE_WDS_STA:
6558 ret = eSIR_BTAMP_STA_MODE;
6559 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 case eCSR_BSS_TYPE_INFRA_AP:
6561 ret = eSIR_INFRA_AP_MODE;
6562 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 case eCSR_BSS_TYPE_ANY:
6564 default:
6565 ret = eSIR_AUTO_MODE;
6566 break;
6567 }
6568
6569 return (ret);
6570}
6571
6572
6573//This function use the parameters to decide the CFG value.
6574//CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG
6575//So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value
Jeff Johnson295189b2012-06-20 16:38:30 -07006576eCsrCfgDot11Mode csrGetCfgDot11ModeFromCsrPhyMode(tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tANI_BOOLEAN fProprietary)
Jeff Johnson295189b2012-06-20 16:38:30 -07006577{
6578 tANI_U32 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6579
6580 switch(phyMode)
6581 {
6582 case eCSR_DOT11_MODE_11a:
6583 case eCSR_DOT11_MODE_11a_ONLY:
6584 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
6585 break;
6586 case eCSR_DOT11_MODE_11b:
6587 case eCSR_DOT11_MODE_11b_ONLY:
6588 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
6589 break;
6590 case eCSR_DOT11_MODE_11g:
6591 case eCSR_DOT11_MODE_11g_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 if(pProfile && (CSR_IS_INFRA_AP(pProfile)) && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
6593 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
6594 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
6596 break;
6597 case eCSR_DOT11_MODE_11n:
6598 if(fProprietary)
6599 {
6600 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6601 }
6602 else
6603 {
6604 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6605 }
6606 break;
6607 case eCSR_DOT11_MODE_11n_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 if(pProfile && CSR_IS_INFRA_AP(pProfile))
6609 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
6610 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6612 break;
6613 case eCSR_DOT11_MODE_TAURUS:
6614 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6615 break;
6616 case eCSR_DOT11_MODE_abg:
6617 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6618 break;
6619 case eCSR_DOT11_MODE_AUTO:
6620 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
6621 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07006622
6623#ifdef WLAN_FEATURE_11AC
6624 case eCSR_DOT11_MODE_11ac:
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006625 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6626 {
6627 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
6628 }
6629 else
6630 {
Ravi Joshia96ceb42013-05-20 18:52:39 -07006631 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006632 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006633 break;
6634 case eCSR_DOT11_MODE_11ac_ONLY:
Ravi Joshia96ceb42013-05-20 18:52:39 -07006635 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6636 {
6637 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
6638 }
6639 else
6640 {
6641 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6642 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006643 break;
6644#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 default:
6646 //No need to assign anything here
6647 break;
6648 }
6649
6650 return (cfgDot11Mode);
6651}
6652
6653
6654eHalStatus csrSetRegulatoryDomain(tpAniSirGlobal pMac, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6655{
6656 eHalStatus status = eHAL_STATUS_SUCCESS;
6657 tANI_BOOLEAN fRestart;
6658
6659 if(pMac->scan.domainIdCurrent == domainId)
6660 {
6661 //no change
6662 fRestart = eANI_BOOLEAN_FALSE;
6663 }
6664 else if( !pMac->roam.configParam.fEnforceDefaultDomain )
6665 {
6666 pMac->scan.domainIdCurrent = domainId;
6667 fRestart = eANI_BOOLEAN_TRUE;
6668 }
6669 else
6670 {
6671 //We cannot change the domain
6672 status = eHAL_STATUS_CSR_WRONG_STATE;
6673 fRestart = eANI_BOOLEAN_FALSE;
6674 }
6675 if(pfRestartNeeded)
6676 {
6677 *pfRestartNeeded = fRestart;
6678 }
6679
6680 return (status);
6681}
6682
6683
6684v_REGDOMAIN_t csrGetCurrentRegulatoryDomain(tpAniSirGlobal pMac)
6685{
6686 return (pMac->scan.domainIdCurrent);
6687}
6688
Jeff Johnson295189b2012-06-20 16:38:30 -07006689
Kiet Lam6c583332013-10-14 05:37:09 +05306690eHalStatus csrGetRegulatoryDomainForCountry
6691(
6692tpAniSirGlobal pMac,
6693tANI_U8 *pCountry,
6694v_REGDOMAIN_t *pDomainId,
6695v_CountryInfoSource_t source
6696)
Jeff Johnson295189b2012-06-20 16:38:30 -07006697{
6698 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6699 VOS_STATUS vosStatus;
6700 v_COUNTRYCODE_t countryCode;
6701 v_REGDOMAIN_t domainId;
6702
6703 if(pCountry)
6704 {
6705 countryCode[0] = pCountry[0];
6706 countryCode[1] = pCountry[1];
Kiet Lam6c583332013-10-14 05:37:09 +05306707 vosStatus = vos_nv_getRegDomainFromCountryCode(&domainId,
6708 countryCode,
6709 source);
6710
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
6712 {
6713 if( pDomainId )
6714 {
6715 *pDomainId = domainId;
6716 }
6717 status = eHAL_STATUS_SUCCESS;
6718 }
6719 else
6720 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306721 smsLog(pMac, LOGW, FL(" Couldn't find domain for country code %c%c"), pCountry[0], pCountry[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 status = eHAL_STATUS_INVALID_PARAMETER;
6723 }
6724 }
6725
6726 return (status);
6727}
6728
6729//To check whether a country code matches the one in the IE
6730//Only check the first two characters, ignoring in/outdoor
6731//pCountry -- caller allocated buffer contain the country code that is checking against
6732//the one in pIes. It can be NULL.
6733//caller must provide pIes, it cannot be NULL
6734//This function always return TRUE if 11d support is not turned on.
6735tANI_BOOLEAN csrMatchCountryCode( tpAniSirGlobal pMac, tANI_U8 *pCountry, tDot11fBeaconIEs *pIes )
6736{
6737 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson43971f52012-07-17 12:26:56 -07006738 v_REGDOMAIN_t domainId = REGDOMAIN_COUNT; //This is init to invalid value
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 eHalStatus status;
6740
6741 do
6742 {
6743 if( !csrIs11dSupported( pMac) )
6744 {
6745 break;
6746 }
6747 if( !pIes )
6748 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006749 smsLog(pMac, LOGE, FL(" No IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006750 break;
6751 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006752 if( pMac->roam.configParam.fEnforceDefaultDomain ||
6753 pMac->roam.configParam.fEnforceCountryCodeMatch )
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006755 //Make sure this country is recognizable
6756 if( pIes->Country.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 {
Kiet Lam6c583332013-10-14 05:37:09 +05306758 status = csrGetRegulatoryDomainForCountry(pMac,
6759 pIes->Country.country,
6760 &domainId, COUNTRY_QUERY);
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006761 if( !HAL_STATUS_SUCCESS( status ) )
6762 {
Kiet Lam6c583332013-10-14 05:37:09 +05306763 status = csrGetRegulatoryDomainForCountry(pMac,
6764 pMac->scan.countryCode11d,
6765 (v_REGDOMAIN_t *) &domainId,
6766 COUNTRY_QUERY);
Gowri Deepthiff9adf92012-12-13 15:09:56 -08006767 if( !HAL_STATUS_SUCCESS( status ) )
6768 {
6769 fRet = eANI_BOOLEAN_FALSE;
6770 break;
6771 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006774 //check whether it is needed to enforce to the default regulatory domain first
6775 if( pMac->roam.configParam.fEnforceDefaultDomain )
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006777 if( domainId != pMac->scan.domainIdCurrent )
6778 {
6779 fRet = eANI_BOOLEAN_FALSE;
6780 break;
6781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006782 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006783 if( pMac->roam.configParam.fEnforceCountryCodeMatch )
6784 {
Jeff Johnson43971f52012-07-17 12:26:56 -07006785 if( domainId >= REGDOMAIN_COUNT )
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006786 {
6787 fRet = eANI_BOOLEAN_FALSE;
6788 break;
6789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 }
6791 }
6792 if( pCountry )
6793 {
6794 tANI_U32 i;
6795
6796 if( !pIes->Country.present )
6797 {
6798 fRet = eANI_BOOLEAN_FALSE;
6799 break;
6800 }
6801 // Convert the CountryCode characters to upper
6802 for ( i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++ )
6803 {
6804 pCountry[i] = csrToUpper( pCountry[i] );
6805 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306806 if (!vos_mem_compare(pIes->Country.country, pCountry,
6807 WNI_CFG_COUNTRY_CODE_LEN - 1))
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 {
6809 fRet = eANI_BOOLEAN_FALSE;
6810 break;
6811 }
6812 }
6813 } while(0);
6814
6815 return (fRet);
6816}
6817
6818#if 0
6819eHalStatus csrSetCountryDomainMapping(tpAniSirGlobal pMac, tCsrCountryDomainMapping *pCountryDomainMapping)
6820{
6821 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6822 tANI_U32 i, j;
6823 tANI_BOOLEAN fDomainChanged = eANI_BOOLEAN_FALSE;
6824 tANI_U8 countryCode[WNI_CFG_COUNTRY_CODE_LEN];
6825
6826 i = WNI_CFG_COUNTRY_CODE_LEN;
6827 //Get the currently used country code
6828 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, countryCode, &i);
6829 if(HAL_STATUS_SUCCESS(status))
6830 {
6831 if(pCountryDomainMapping && pCountryDomainMapping->numEntry)
6832 {
6833 for(i = 0; i < pCountryDomainMapping->numEntry; i++)
6834 {
6835 for(j = 0; j < eCSR_NUM_COUNTRY_INDEX; j++)
6836 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306837 if (vos_mem_compare(gCsrCountryInfo[j].countryCode,
6838 pCountryDomainMapping->pCountryInfo[i].countryCode,
6839 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 {
6841 if(gCsrCountryInfo[j].domainId != pCountryDomainMapping->pCountryInfo[i].domainId)
6842 {
6843 gCsrCountryInfo[j].domainId = pCountryDomainMapping->pCountryInfo[i].domainId;
6844 //Check whether it matches the currently used country code
6845 //If matching, need to update base on the new domain setting.
Kiet Lam64c1b492013-07-12 13:56:44 +05306846 if (vos_mem_compare(countryCode,
6847 pCountryDomainMapping->pCountryInfo[i].countryCode,
6848 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 {
6850 fDomainChanged = eANI_BOOLEAN_TRUE;
6851 }
6852 }
6853 break;
6854 }
6855 }
6856 }
6857 status = eHAL_STATUS_SUCCESS;
6858 if(fDomainChanged)
6859 {
6860 tCsrChannel *pChannelList;
6861
6862 if(pMac->scan.f11dInfoApplied)
6863 {
6864 //11d info already applied. Let's reapply with the new domain setting
6865 if(pMac->scan.channels11d.numChannels)
6866 {
6867 pChannelList = &pMac->scan.channels11d;
6868 }
6869 else
6870 {
6871 pChannelList = &pMac->scan.base20MHzChannels;
6872 }
6873 }
6874 else
6875 {
6876 //no 11d so we use the base channelist from EEPROM
6877 pChannelList = &pMac->scan.base20MHzChannels;
6878 }
6879 //set the new domain's scan requirement to CFG
6880 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
6881 }
6882 }
6883 }
6884
6885 return (status);
6886}
6887
6888eHalStatus csrSetDomainScanSetting(tpAniSirGlobal pMac, tCsrDomainFreqInfo *pDomainFreqInfo)
6889{
6890 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6891 tANI_U32 i, j;
6892 tANI_U16 freq;
6893
6894 if(pDomainFreqInfo && pDomainFreqInfo->numEntry && (pDomainFreqInfo->domainId < NUM_REG_DOMAINS))
6895 {
6896 tCsrDomainChnInfo *pDomainChnInfo = &gCsrDomainChnInfo[pDomainFreqInfo->domainId];
6897
6898 for(j = 0; j < pDomainChnInfo->numChannels; j++)
6899 {
6900 if(HAL_STATUS_SUCCESS(halPhyChIdToFreqConversion(pDomainChnInfo->chnInfo[j].chnId, &freq)))
6901 {
6902 for(i = 0; i < pDomainFreqInfo->numEntry; i++)
6903 {
6904 if((pDomainFreqInfo->pCsrScanFreqInfo[i].nStartFreq <= freq) &&
6905 (freq <= pDomainFreqInfo->pCsrScanFreqInfo[i].nEndFreq))
6906 {
6907 pDomainChnInfo->chnInfo[j].scanType = pDomainFreqInfo->pCsrScanFreqInfo[i].scanType;
6908 break;
6909 }
6910 }
6911 }
6912 else
6913 {
6914 smsLog(pMac, LOGW, " Failed to get frequency of channel %d", pDomainChnInfo->chnInfo[j].chnId);
6915 }
6916 }
6917 status = eHAL_STATUS_SUCCESS;
6918 }
6919
6920 return (status);
6921}
6922#endif
6923
6924eHalStatus csrGetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6925 tCsrRoamModifyProfileFields *pModifyProfileFields)
6926{
6927
6928 if(!pModifyProfileFields)
6929 {
6930 return eHAL_STATUS_FAILURE;
6931 }
6932
Kiet Lam64c1b492013-07-12 13:56:44 +05306933 vos_mem_copy(pModifyProfileFields,
6934 &pMac->roam.roamSession[sessionId].connectedProfile.modifyProfileFields,
6935 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006936
6937 return eHAL_STATUS_SUCCESS;
6938}
6939
6940eHalStatus csrSetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6941 tCsrRoamModifyProfileFields *pModifyProfileFields)
6942{
6943 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6944
Kiet Lam64c1b492013-07-12 13:56:44 +05306945 vos_mem_copy(&pSession->connectedProfile.modifyProfileFields,
6946 pModifyProfileFields,
6947 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006948
6949 return eHAL_STATUS_SUCCESS;
6950}
6951
6952
6953#if 0
6954/* ---------------------------------------------------------------------------
6955 \fn csrGetSupportedCountryCode
6956 \brief this function is to get a list of the country code current being supported
6957 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6958 this has the country code list. 3 bytes for each country code. This may be NULL if
6959 caller wants to know the needed bytes.
6960 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6961 this contains the length of the data in pBuf
6962 \return eHalStatus
6963 -------------------------------------------------------------------------------*/
6964eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6965{
6966 tANI_U32 numOfCountry = sizeof( gCsrCountryInfo ) / sizeof( gCsrCountryInfo[0] );
6967 tANI_U32 numBytes = 0;
6968 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6969
6970 if( pbLen )
6971 {
6972 numBytes = *pbLen;
6973 //Consider it ok, at least we can return the number of bytes needed;
6974 *pbLen = numOfCountry * WNI_CFG_COUNTRY_CODE_LEN;
6975 status = eHAL_STATUS_SUCCESS;
6976 if( pBuf && ( numBytes >= *pbLen ) )
6977 {
6978 //The ugly part starts.
6979 //We may need to alter the data structure and find a way to make this faster.
6980 tANI_U32 i;
6981
Kiet Lam64c1b492013-07-12 13:56:44 +05306982 for ( i = 0; i < numOfCountry; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306984 vos_mem_copy(pBuf + ( i * WNI_CFG_COUNTRY_CODE_LEN ),
6985 gCsrCountryInfo[i].countryCode,
6986 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006987 }
6988 }
6989 }
6990
6991 return ( status );
6992}
6993#endif
6994
6995/* ---------------------------------------------------------------------------
6996 \fn csrGetSupportedCountryCode
6997 \brief this function is to get a list of the country code current being supported
6998 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6999 this has the country code list. 3 bytes for each country code. This may be NULL if
7000 caller wants to know the needed bytes.
7001 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
7002 this contains the length of the data in pBuf
7003 \return eHalStatus
7004 -------------------------------------------------------------------------------*/
7005eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
7006{
7007 eHalStatus status = eHAL_STATUS_SUCCESS;
7008 VOS_STATUS vosStatus;
7009 v_SIZE_t size = (v_SIZE_t)*pbLen;
7010
7011 vosStatus = vos_nv_getSupportedCountryCode( pBuf, &size, 1 );
7012 //eiter way, return the value back
7013 *pbLen = (tANI_U32)size;
7014
7015 //If pBuf is NULL, caller just want to get the size, consider it success
7016 if(pBuf)
7017 {
7018 if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
7019 {
7020 tANI_U32 i, n = *pbLen / 3;
7021
7022 for( i = 0; i < n; i++ )
7023 {
7024 pBuf[i*3 + 2] = ' ';
7025 }
7026 }
7027 else
7028 {
7029 status = eHAL_STATUS_FAILURE;
7030 }
7031 }
7032
7033 return (status);
7034}
7035
7036
7037
7038//Upper layer to get the list of the base channels to scan for passively 11d info from csr
7039eHalStatus csrScanGetBaseChannels( tpAniSirGlobal pMac, tCsrChannelInfo * pChannelInfo )
7040{
7041 eHalStatus status = eHAL_STATUS_FAILURE;
7042
7043 do
7044 {
7045
7046 if(!pMac->scan.baseChannels.numChannels || !pChannelInfo)
7047 {
7048 break;
7049 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307050 pChannelInfo->ChannelList = vos_mem_malloc(pMac->scan.baseChannels.numChannels);
7051 if ( NULL == pChannelInfo->ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007053 smsLog( pMac, LOGE, FL("csrScanGetBaseChannels: fail to allocate memory") );
Kiet Lam64c1b492013-07-12 13:56:44 +05307054 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007055 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307056 vos_mem_copy(pChannelInfo->ChannelList,
7057 pMac->scan.baseChannels.channelList,
7058 pMac->scan.baseChannels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 pChannelInfo->numOfChannels = pMac->scan.baseChannels.numChannels;
7060
7061 }while(0);
7062
7063 return ( status );
7064}
7065
7066
7067tANI_BOOLEAN csrIsSetKeyAllowed(tpAniSirGlobal pMac, tANI_U32 sessionId)
7068{
7069 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 tCsrRoamSession *pSession;
7071
7072 pSession =CSR_GET_SESSION(pMac, sessionId);
7073
7074 /*This condition is not working for infra state. When infra is in not-connected state
7075 * the pSession->pCurRoamProfile is NULL. And this function returns TRUE, that is incorrect.
7076 * Since SAP requires to set key without any BSS started, it needs this condition to be met.
7077 * In other words, this function is useless.
7078 * The current work-around is to process setcontext_rsp and removekey_rsp no matter what the
7079 * state is.
7080 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007081 smsLog( pMac, LOG2, FL(" is not what it intends to. Must be revisit or removed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 if( (NULL == pSession) ||
7083 ( csrIsConnStateDisconnected( pMac, sessionId ) &&
7084 (pSession->pCurRoamProfile != NULL) &&
7085 (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) )
7086 )
7087 {
7088 fRet = eANI_BOOLEAN_FALSE;
7089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007090
7091 return ( fRet );
7092}
7093
7094//no need to acquire lock for this basic function
7095tANI_U16 sme_ChnToFreq(tANI_U8 chanNum)
7096{
7097 int i;
7098
7099 for (i = 0; i < NUM_RF_CHANNELS; i++)
7100 {
7101 if (rfChannels[i].channelNum == chanNum)
7102 {
7103 return rfChannels[i].targetFreq;
7104 }
7105 }
7106
7107 return (0);
7108}
7109
7110/* Disconnect all active sessions by sending disassoc. This is mainly used to disconnect the remaining session when we
7111 * transition from concurrent sessions to a single session. The use case is Infra STA and wifi direct multiple sessions are up and
7112 * P2P session is removed. The Infra STA session remains and should resume BMPS if BMPS is enabled by default. However, there
7113 * are some issues seen with BMPS resume during this transition and this is a workaround which will allow the Infra STA session to
7114 * disconnect and auto connect back and enter BMPS this giving the same effect as resuming BMPS
7115 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007116
7117//Remove this code once SLM_Sessionization is supported
7118//BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnson295189b2012-06-20 16:38:30 -07007119void csrDisconnectAllActiveSessions(tpAniSirGlobal pMac)
7120{
7121 tANI_U8 i;
7122
7123 /* Disconnect all the active sessions */
7124 for (i=0; i<CSR_ROAM_SESSION_MAX; i++)
7125 {
7126 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
7127 {
7128 csrRoamDisconnectInternal(pMac, i, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7129 }
7130 }
7131}
Mohit Khanna349bc392012-09-11 17:24:52 -07007132
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07007133#ifdef FEATURE_WLAN_LFR
7134tANI_BOOLEAN csrIsChannelPresentInList(
7135 tANI_U8 *pChannelList,
7136 int numChannels,
7137 tANI_U8 channel
7138 )
7139{
7140 int i = 0;
7141
7142 // Check for NULL pointer
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08007143 if (!pChannelList || (numChannels == 0))
7144 {
7145 return FALSE;
7146 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07007147
7148 // Look for the channel in the list
7149 for (i = 0; i < numChannels; i++)
7150 {
7151 if (pChannelList[i] == channel)
7152 return TRUE;
7153 }
7154
7155 return FALSE;
7156}
7157
7158VOS_STATUS csrAddToChannelListFront(
7159 tANI_U8 *pChannelList,
7160 int numChannels,
7161 tANI_U8 channel
7162 )
7163{
7164 int i = 0;
7165
7166 // Check for NULL pointer
7167 if (!pChannelList) return eHAL_STATUS_E_NULL_VALUE;
7168
7169 // Make room for the addition. (Start moving from the back.)
7170 for (i = numChannels; i > 0; i--)
7171 {
7172 pChannelList[i] = pChannelList[i-1];
7173 }
7174
7175 // Now add the NEW channel...at the front
7176 pChannelList[0] = channel;
7177
7178 return eHAL_STATUS_SUCCESS;
7179}
7180#endif
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307181const char * sme_requestTypetoString(const v_U8_t requestType)
7182{
7183 switch (requestType)
7184 {
7185 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_11D_SCAN );
7186 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_FULL_SCAN );
7187 CASE_RETURN_STRING( eCSR_SCAN_IDLE_MODE_SCAN );
7188 CASE_RETURN_STRING( eCSR_SCAN_HO_BG_SCAN );
7189 CASE_RETURN_STRING( eCSR_SCAN_HO_PROBE_SCAN );
7190 CASE_RETURN_STRING( eCSR_SCAN_HO_NT_BG_SCAN );
7191 CASE_RETURN_STRING( eCSR_SCAN_P2P_DISCOVERY );
7192 CASE_RETURN_STRING( eCSR_SCAN_SOFTAP_CHANNEL_RANGE );
7193 CASE_RETURN_STRING( eCSR_SCAN_P2P_FIND_PEER );
7194 default:
7195 return "Unknown Scan Request Type";
7196 }
7197}