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