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