blob: d0647ddbc6a3d7f990cad5d596fe577b7fd97cbe [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 */
Jeff Johnson295189b2012-06-20 16:38:30 -070086};
87
88#ifdef FEATURE_WLAN_WAPI
Kaushik, Sushantfe230152014-04-08 14:37:47 +053089tANI_U8 csrWapiOui[CSR_WAPI_OUI_ROW_SIZE][ CSR_WAPI_OUI_SIZE ] = {
Jeff Johnson295189b2012-06-20 16:38:30 -070090 { 0x00, 0x14, 0x72, 0x00 }, // Reserved
91 { 0x00, 0x14, 0x72, 0x01 }, // WAI certificate or SMS4
92 { 0x00, 0x14, 0x72, 0x02 } // WAI PSK
93};
94#endif /* FEATURE_WLAN_WAPI */
95tANI_U8 csrWmeInfoOui[ CSR_WME_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
96tANI_U8 csrWmeParmOui[ CSR_WME_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
97
98static tCsrIELenInfo gCsrIELengthTable[] = {
99/* 000 */ { SIR_MAC_SSID_EID_MIN, SIR_MAC_SSID_EID_MAX },
100/* 001 */ { SIR_MAC_RATESET_EID_MIN, SIR_MAC_RATESET_EID_MAX },
101/* 002 */ { SIR_MAC_FH_PARAM_SET_EID_MIN, SIR_MAC_FH_PARAM_SET_EID_MAX },
102/* 003 */ { SIR_MAC_DS_PARAM_SET_EID_MIN, SIR_MAC_DS_PARAM_SET_EID_MAX },
103/* 004 */ { SIR_MAC_CF_PARAM_SET_EID_MIN, SIR_MAC_CF_PARAM_SET_EID_MAX },
104/* 005 */ { SIR_MAC_TIM_EID_MIN, SIR_MAC_TIM_EID_MAX },
105/* 006 */ { SIR_MAC_IBSS_PARAM_SET_EID_MIN, SIR_MAC_IBSS_PARAM_SET_EID_MAX },
106/* 007 */ { SIR_MAC_COUNTRY_EID_MIN, SIR_MAC_COUNTRY_EID_MAX },
107/* 008 */ { SIR_MAC_FH_PARAMS_EID_MIN, SIR_MAC_FH_PARAMS_EID_MAX },
108/* 009 */ { SIR_MAC_FH_PATTERN_EID_MIN, SIR_MAC_FH_PATTERN_EID_MAX },
109/* 010 */ { SIR_MAC_REQUEST_EID_MIN, SIR_MAC_REQUEST_EID_MAX },
110/* 011 */ { SIR_MAC_QBSS_LOAD_EID_MIN, SIR_MAC_QBSS_LOAD_EID_MAX },
111/* 012 */ { SIR_MAC_EDCA_PARAM_SET_EID_MIN, SIR_MAC_EDCA_PARAM_SET_EID_MAX },
112/* 013 */ { SIR_MAC_TSPEC_EID_MIN, SIR_MAC_TSPEC_EID_MAX },
113/* 014 */ { SIR_MAC_TCLAS_EID_MIN, SIR_MAC_TCLAS_EID_MAX },
114/* 015 */ { SIR_MAC_QOS_SCHEDULE_EID_MIN, SIR_MAC_QOS_SCHEDULE_EID_MAX },
115/* 016 */ { SIR_MAC_CHALLENGE_TEXT_EID_MIN, SIR_MAC_CHALLENGE_TEXT_EID_MAX },
116/* 017 */ { 0, 255 },
117/* 018 */ { 0, 255 },
118/* 019 */ { 0, 255 },
119/* 020 */ { 0, 255 },
120/* 021 */ { 0, 255 },
121/* 022 */ { 0, 255 },
122/* 023 */ { 0, 255 },
123/* 024 */ { 0, 255 },
124/* 025 */ { 0, 255 },
125/* 026 */ { 0, 255 },
126/* 027 */ { 0, 255 },
127/* 028 */ { 0, 255 },
128/* 029 */ { 0, 255 },
129/* 030 */ { 0, 255 },
130/* 031 */ { 0, 255 },
131/* 032 */ { SIR_MAC_PWR_CONSTRAINT_EID_MIN, SIR_MAC_PWR_CONSTRAINT_EID_MAX },
132/* 033 */ { SIR_MAC_PWR_CAPABILITY_EID_MIN, SIR_MAC_PWR_CAPABILITY_EID_MAX },
133/* 034 */ { SIR_MAC_TPC_REQ_EID_MIN, SIR_MAC_TPC_REQ_EID_MAX },
134/* 035 */ { SIR_MAC_TPC_RPT_EID_MIN, SIR_MAC_TPC_RPT_EID_MAX },
135/* 036 */ { SIR_MAC_SPRTD_CHNLS_EID_MIN, SIR_MAC_SPRTD_CHNLS_EID_MAX },
136/* 037 */ { SIR_MAC_CHNL_SWITCH_ANN_EID_MIN, SIR_MAC_CHNL_SWITCH_ANN_EID_MAX },
137/* 038 */ { SIR_MAC_MEAS_REQ_EID_MIN, SIR_MAC_MEAS_REQ_EID_MAX },
138/* 039 */ { SIR_MAC_MEAS_RPT_EID_MIN, SIR_MAC_MEAS_RPT_EID_MAX },
139/* 040 */ { SIR_MAC_QUIET_EID_MIN, SIR_MAC_QUIET_EID_MAX },
140/* 041 */ { SIR_MAC_IBSS_DFS_EID_MIN, SIR_MAC_IBSS_DFS_EID_MAX },
141/* 042 */ { SIR_MAC_ERP_INFO_EID_MIN, SIR_MAC_ERP_INFO_EID_MAX },
142/* 043 */ { SIR_MAC_TS_DELAY_EID_MIN, SIR_MAC_TS_DELAY_EID_MAX },
143/* 044 */ { SIR_MAC_TCLAS_PROC_EID_MIN, SIR_MAC_TCLAS_PROC_EID_MAX },
144/* 045 */ { SIR_MAC_QOS_ACTION_EID_MIN, SIR_MAC_QOS_ACTION_EID_MAX },
145/* 046 */ { SIR_MAC_QOS_CAPABILITY_EID_MIN, SIR_MAC_QOS_CAPABILITY_EID_MAX },
146/* 047 */ { 0, 255 },
147/* 048 */ { SIR_MAC_RSN_EID_MIN, SIR_MAC_RSN_EID_MAX },
148/* 049 */ { 0, 255 },
149/* 050 */ { SIR_MAC_EXTENDED_RATE_EID_MIN, SIR_MAC_EXTENDED_RATE_EID_MAX },
150/* 051 */ { 0, 255 },
151/* 052 */ { 0, 255 },
152/* 053 */ { 0, 255 },
153/* 054 */ { 0, 255 },
154/* 055 */ { 0, 255 },
155/* 056 */ { 0, 255 },
156/* 057 */ { 0, 255 },
157/* 058 */ { 0, 255 },
158/* 059 */ { 0, 255 },
159/* 060 */ { 0, 255 },
160/* 061 */ { 0, 255 },
161/* 062 */ { 0, 255 },
162/* 063 */ { 0, 255 },
163/* 064 */ { 0, 255 },
164/* 065 */ { 0, 255 },
165/* 066 */ { 0, 255 },
166/* 067 */ { 0, 255 },
167#ifdef FEATURE_WLAN_WAPI
168/* 068 */ { DOT11F_EID_WAPI, DOT11F_IE_WAPI_MAX_LEN },
169#else
170/* 068 */ { 0, 255 },
171#endif /* FEATURE_WLAN_WAPI */
172/* 069 */ { 0, 255 },
173/* 070 */ { 0, 255 },
174/* 071 */ { 0, 255 },
175/* 072 */ { 0, 255 },
176/* 073 */ { 0, 255 },
177/* 074 */ { 0, 255 },
178/* 075 */ { 0, 255 },
179/* 076 */ { 0, 255 },
180/* 077 */ { 0, 255 },
181/* 078 */ { 0, 255 },
182/* 079 */ { 0, 255 },
183/* 080 */ { 0, 255 },
184/* 081 */ { 0, 255 },
185/* 082 */ { 0, 255 },
186/* 083 */ { 0, 255 },
187/* 084 */ { 0, 255 },
188/* 085 */ { 0, 255 },
189/* 086 */ { 0, 255 },
190/* 087 */ { 0, 255 },
191/* 088 */ { 0, 255 },
192/* 089 */ { 0, 255 },
193/* 090 */ { 0, 255 },
194/* 091 */ { 0, 255 },
195/* 092 */ { 0, 255 },
196/* 093 */ { 0, 255 },
197/* 094 */ { 0, 255 },
198/* 095 */ { 0, 255 },
199/* 096 */ { 0, 255 },
200/* 097 */ { 0, 255 },
201/* 098 */ { 0, 255 },
202/* 099 */ { 0, 255 },
203/* 100 */ { 0, 255 },
204/* 101 */ { 0, 255 },
205/* 102 */ { 0, 255 },
206/* 103 */ { 0, 255 },
207/* 104 */ { 0, 255 },
208/* 105 */ { 0, 255 },
209/* 106 */ { 0, 255 },
210/* 107 */ { 0, 255 },
211/* 108 */ { 0, 255 },
212/* 109 */ { 0, 255 },
213/* 110 */ { 0, 255 },
214/* 111 */ { 0, 255 },
215/* 112 */ { 0, 255 },
216/* 113 */ { 0, 255 },
217/* 114 */ { 0, 255 },
218/* 115 */ { 0, 255 },
219/* 116 */ { 0, 255 },
220/* 117 */ { 0, 255 },
221/* 118 */ { 0, 255 },
222/* 119 */ { 0, 255 },
223/* 120 */ { 0, 255 },
224/* 121 */ { 0, 255 },
225/* 122 */ { 0, 255 },
226/* 123 */ { 0, 255 },
227/* 124 */ { 0, 255 },
228/* 125 */ { 0, 255 },
229/* 126 */ { 0, 255 },
230/* 127 */ { 0, 255 },
231/* 128 */ { 0, 255 },
232/* 129 */ { 0, 255 },
233/* 130 */ { 0, 255 },
234/* 131 */ { 0, 255 },
235/* 132 */ { 0, 255 },
236/* 133 */ { 0, 255 },
237/* 134 */ { 0, 255 },
238/* 135 */ { 0, 255 },
239/* 136 */ { 0, 255 },
240/* 137 */ { 0, 255 },
241/* 138 */ { 0, 255 },
242/* 139 */ { 0, 255 },
243/* 140 */ { 0, 255 },
244/* 141 */ { 0, 255 },
245/* 142 */ { 0, 255 },
246/* 143 */ { 0, 255 },
247/* 144 */ { 0, 255 },
248/* 145 */ { 0, 255 },
249/* 146 */ { 0, 255 },
250/* 147 */ { 0, 255 },
251/* 148 */ { 0, 255 },
252/* 149 */ { 0, 255 },
253/* 150 */ { 0, 255 },
254/* 151 */ { 0, 255 },
255/* 152 */ { 0, 255 },
256/* 153 */ { 0, 255 },
257/* 154 */ { 0, 255 },
258/* 155 */ { 0, 255 },
259/* 156 */ { 0, 255 },
260/* 157 */ { 0, 255 },
261/* 158 */ { 0, 255 },
262/* 159 */ { 0, 255 },
263/* 160 */ { 0, 255 },
264/* 161 */ { 0, 255 },
265/* 162 */ { 0, 255 },
266/* 163 */ { 0, 255 },
267/* 164 */ { 0, 255 },
268/* 165 */ { 0, 255 },
269/* 166 */ { 0, 255 },
270/* 167 */ { 0, 255 },
271/* 168 */ { 0, 255 },
272/* 169 */ { 0, 255 },
273/* 170 */ { 0, 255 },
274/* 171 */ { 0, 255 },
275/* 172 */ { 0, 255 },
276/* 173 */ { 0, 255 },
277/* 174 */ { 0, 255 },
278/* 175 */ { 0, 255 },
279/* 176 */ { 0, 255 },
280/* 177 */ { 0, 255 },
281/* 178 */ { 0, 255 },
282/* 179 */ { 0, 255 },
283/* 180 */ { 0, 255 },
284/* 181 */ { 0, 255 },
285/* 182 */ { 0, 255 },
286/* 183 */ { 0, 255 },
287/* 184 */ { 0, 255 },
288/* 185 */ { 0, 255 },
289/* 186 */ { 0, 255 },
290/* 187 */ { 0, 255 },
291/* 188 */ { 0, 255 },
292/* 189 */ { 0, 255 },
293/* 190 */ { 0, 255 },
294/* 191 */ { 0, 255 },
295/* 192 */ { 0, 255 },
296/* 193 */ { 0, 255 },
297/* 194 */ { 0, 255 },
298/* 195 */ { 0, 255 },
299/* 196 */ { 0, 255 },
300/* 197 */ { 0, 255 },
301/* 198 */ { 0, 255 },
302/* 199 */ { 0, 255 },
303/* 200 */ { 0, 255 },
304/* 201 */ { 0, 255 },
305/* 202 */ { 0, 255 },
306/* 203 */ { 0, 255 },
307/* 204 */ { 0, 255 },
308/* 205 */ { 0, 255 },
309/* 206 */ { 0, 255 },
310/* 207 */ { 0, 255 },
311/* 208 */ { 0, 255 },
312/* 209 */ { 0, 255 },
313/* 210 */ { 0, 255 },
314/* 211 */ { 0, 255 },
315/* 212 */ { 0, 255 },
316/* 213 */ { 0, 255 },
317/* 214 */ { 0, 255 },
318/* 215 */ { 0, 255 },
319/* 216 */ { 0, 255 },
320/* 217 */ { 0, 255 },
321/* 218 */ { 0, 255 },
322/* 219 */ { 0, 255 },
323/* 220 */ { 0, 255 },
324/* 221 */ { SIR_MAC_WPA_EID_MIN, SIR_MAC_WPA_EID_MAX },
325/* 222 */ { 0, 255 },
326/* 223 */ { 0, 255 },
327/* 224 */ { 0, 255 },
328/* 225 */ { 0, 255 },
329/* 226 */ { 0, 255 },
330/* 227 */ { 0, 255 },
331/* 228 */ { 0, 255 },
332/* 229 */ { 0, 255 },
333/* 230 */ { 0, 255 },
334/* 231 */ { 0, 255 },
335/* 232 */ { 0, 255 },
336/* 233 */ { 0, 255 },
337/* 234 */ { 0, 255 },
338/* 235 */ { 0, 255 },
339/* 236 */ { 0, 255 },
340/* 237 */ { 0, 255 },
341/* 238 */ { 0, 255 },
342/* 239 */ { 0, 255 },
343/* 240 */ { 0, 255 },
344/* 241 */ { 0, 255 },
345/* 242 */ { 0, 255 },
346/* 243 */ { 0, 255 },
347/* 244 */ { 0, 255 },
348/* 245 */ { 0, 255 },
349/* 246 */ { 0, 255 },
350/* 247 */ { 0, 255 },
351/* 248 */ { 0, 255 },
352/* 249 */ { 0, 255 },
353/* 250 */ { 0, 255 },
354/* 251 */ { 0, 255 },
355/* 252 */ { 0, 255 },
356/* 253 */ { 0, 255 },
357/* 254 */ { 0, 255 },
358/* 255 */ { SIR_MAC_ANI_WORKAROUND_EID_MIN, SIR_MAC_ANI_WORKAROUND_EID_MAX }
359};
360
361#if 0
362//Don't not insert entry into the table, put it to the end. If you have to insert, make sure it is also
363//reflected in eCsrCountryIndex
364static tCsrCountryInfo gCsrCountryInfo[eCSR_NUM_COUNTRY_INDEX] =
365{
366 {REG_DOMAIN_FCC, {'U', 'S', ' '}}, //USA/******The "US" MUST be at index 0*******/
367 {REG_DOMAIN_WORLD, {'A', 'D', ' '}}, //ANDORRA
368 {REG_DOMAIN_WORLD, {'A', 'E', ' '}}, //UAE
369 {REG_DOMAIN_WORLD, {'A', 'F', ' '}}, //AFGHANISTAN
370 {REG_DOMAIN_WORLD, {'A', 'G', ' '}}, //ANTIGUA AND BARBUDA
371 {REG_DOMAIN_WORLD, {'A', 'I', ' '}}, //ANGUILLA
372 {REG_DOMAIN_HI_5GHZ, {'A', 'L', ' '}}, //ALBANIA
373 {REG_DOMAIN_WORLD, {'A', 'M', ' '}}, //ARMENIA
374 {REG_DOMAIN_WORLD, {'A', 'N', ' '}}, //NETHERLANDS ANTILLES
375 {REG_DOMAIN_WORLD, {'A', 'O', ' '}}, //ANGOLA
376 {REG_DOMAIN_WORLD, {'A', 'Q', ' '}}, //ANTARCTICA
377 {REG_DOMAIN_HI_5GHZ, {'A', 'R', ' '}}, //ARGENTINA
378 {REG_DOMAIN_FCC, {'A', 'S', ' '}}, //AMERICAN SOMOA
379 {REG_DOMAIN_ETSI, {'A', 'T', ' '}}, //AUSTRIA
380 {REG_DOMAIN_ETSI, {'A', 'U', ' '}}, //AUSTRALIA
381 {REG_DOMAIN_WORLD, {'A', 'W', ' '}}, //ARUBA
382 {REG_DOMAIN_WORLD, {'A', 'X', ' '}}, //ALAND ISLANDS
383 {REG_DOMAIN_WORLD, {'A', 'Z', ' '}}, //AZERBAIJAN
384 {REG_DOMAIN_WORLD, {'B', 'A', ' '}}, //BOSNIA AND HERZEGOVINA
385 {REG_DOMAIN_WORLD, {'B', 'B', ' '}}, //BARBADOS
386 {REG_DOMAIN_WORLD, {'B', 'D', ' '}}, //BANGLADESH
387 {REG_DOMAIN_ETSI, {'B', 'E', ' '}}, //BELGIUM
388 {REG_DOMAIN_WORLD, {'B', 'F', ' '}}, //BURKINA FASO
389 {REG_DOMAIN_HI_5GHZ, {'B', 'G', ' '}}, //BULGARIA
390 {REG_DOMAIN_WORLD, {'B', 'H', ' '}}, //BAHRAIN
391 {REG_DOMAIN_WORLD, {'B', 'I', ' '}}, //BURUNDI
392 {REG_DOMAIN_WORLD, {'B', 'J', ' '}}, //BENIN
393 {REG_DOMAIN_WORLD, {'B', 'L', ' '}}, //SAINT BARTHELEMY
394 {REG_DOMAIN_ETSI, {'B', 'M', ' '}}, //BERMUDA
395 {REG_DOMAIN_WORLD, {'B', 'N', ' '}}, //BRUNEI DARUSSALAM
396 {REG_DOMAIN_WORLD, {'B', 'O', ' '}}, //BOLIVIA
397 {REG_DOMAIN_WORLD, {'B', 'R', ' '}}, //BRAZIL
398 {REG_DOMAIN_WORLD, {'B', 'S', ' '}}, //BAHAMAS
399 {REG_DOMAIN_WORLD, {'B', 'T', ' '}}, //BHUTAN
400 {REG_DOMAIN_WORLD, {'B', 'V', ' '}}, //BOUVET ISLAND
401 {REG_DOMAIN_WORLD, {'B', 'W', ' '}}, //BOTSWANA
402 {REG_DOMAIN_WORLD, {'B', 'Y', ' '}}, //BELARUS
403 {REG_DOMAIN_WORLD, {'B', 'Z', ' '}}, //BELIZE
404 {REG_DOMAIN_FCC, {'C', 'A', ' '}}, //CANADA
405 {REG_DOMAIN_WORLD, {'C', 'C', ' '}}, //COCOS (KEELING) ISLANDS
406 {REG_DOMAIN_WORLD, {'C', 'D', ' '}}, //CONGO, THE DEMOCRATIC REPUBLIC OF THE
407 {REG_DOMAIN_WORLD, {'C', 'F', ' '}}, //CENTRAL AFRICAN REPUBLIC
408 {REG_DOMAIN_WORLD, {'C', 'G', ' '}}, //CONGO
409 {REG_DOMAIN_ETSI, {'C', 'H', ' '}}, //SWITZERLAND
410 {REG_DOMAIN_WORLD, {'C', 'I', ' '}}, //COTE D'IVOIRE
411 {REG_DOMAIN_WORLD, {'C', 'K', ' '}}, //COOK ISLANDS
412 {REG_DOMAIN_WORLD, {'C', 'L', ' '}}, //CHILE
413 {REG_DOMAIN_WORLD, {'C', 'M', ' '}}, //CAMEROON
414 {REG_DOMAIN_HI_5GHZ, {'C', 'N', ' '}}, //CHINA
415 {REG_DOMAIN_WORLD, {'C', 'O', ' '}}, //COLOMBIA
416 {REG_DOMAIN_WORLD, {'C', 'R', ' '}}, //COSTA RICA
417 {REG_DOMAIN_WORLD, {'C', 'U', ' '}}, //CUBA
418 {REG_DOMAIN_WORLD, {'C', 'V', ' '}}, //CAPE VERDE
419 {REG_DOMAIN_WORLD, {'C', 'X', ' '}}, //CHRISTMAS ISLAND
420 {REG_DOMAIN_WORLD, {'C', 'Y', ' '}}, //CYPRUS
421 {REG_DOMAIN_HI_5GHZ, {'C', 'Z', ' '}}, //CZECH REPUBLIC
422 {REG_DOMAIN_ETSI, {'D', 'E', ' '}}, //GERMANY
423 {REG_DOMAIN_WORLD, {'D', 'J', ' '}}, //DJIBOUTI
424 {REG_DOMAIN_ETSI, {'D', 'K', ' '}}, //DENMARK
425 {REG_DOMAIN_WORLD, {'D', 'M', ' '}}, //DOMINICA
426 {REG_DOMAIN_WORLD, {'D', 'O', ' '}}, //DOMINICAN REPUBLIC
427 {REG_DOMAIN_WORLD, {'D', 'Z', ' '}}, //ALGERIA
428 {REG_DOMAIN_WORLD, {'E', 'C', ' '}}, //ECUADOR
429 {REG_DOMAIN_HI_5GHZ, {'E', 'E', ' '}}, //ESTONIA
430 {REG_DOMAIN_WORLD, {'E', 'G', ' '}}, //EGYPT
431 {REG_DOMAIN_WORLD, {'E', 'H', ' '}}, //WESTERN SAHARA
432 {REG_DOMAIN_WORLD, {'E', 'R', ' '}}, //ERITREA
433 {REG_DOMAIN_ETSI, {'E', 'S', ' '}}, //SPAIN
434 {REG_DOMAIN_WORLD, {'E', 'T', ' '}}, //ETHIOPIA
435 {REG_DOMAIN_WORLD, {'F', 'I', ' '}}, //FINLAND
436 {REG_DOMAIN_WORLD, {'F', 'J', ' '}}, //FIJI
437 {REG_DOMAIN_WORLD, {'F', 'K', ' '}}, //FALKLAND ISLANDS (MALVINAS)
438 {REG_DOMAIN_WORLD, {'F', 'M', ' '}}, //MICRONESIA, FEDERATED STATES OF
439 {REG_DOMAIN_WORLD, {'F', 'O', ' '}}, //FAROE ISLANDS
440 {REG_DOMAIN_ETSI, {'F', 'R', ' '}}, //FRANCE
441 {REG_DOMAIN_WORLD, {'G', 'A', ' '}}, //GABON
442 {REG_DOMAIN_ETSI, {'G', 'B', ' '}}, //UNITED KINGDOM
443 {REG_DOMAIN_WORLD, {'G', 'D', ' '}}, //GRENADA
444 {REG_DOMAIN_HI_5GHZ, {'G', 'E', ' '}}, //GEORGIA
445 {REG_DOMAIN_WORLD, {'G', 'F', ' '}}, //FRENCH GUIANA
446 {REG_DOMAIN_ETSI, {'G', 'G', ' '}}, //GUERNSEY
447 {REG_DOMAIN_WORLD, {'G', 'H', ' '}}, //GHANA
448 {REG_DOMAIN_WORLD, {'G', 'I', ' '}}, //GIBRALTAR
449 {REG_DOMAIN_WORLD, {'G', 'L', ' '}}, //GREENLAND
450 {REG_DOMAIN_WORLD, {'G', 'M', ' '}}, //GAMBIA
451 {REG_DOMAIN_WORLD, {'G', 'N', ' '}}, //GUINEA
452 {REG_DOMAIN_WORLD, {'G', 'P', ' '}}, //GUADELOUPE
453 {REG_DOMAIN_WORLD, {'G', 'Q', ' '}}, //EQUATORIAL GUINEA
454 {REG_DOMAIN_ETSI, {'G', 'R', ' '}}, //GREECE
455 {REG_DOMAIN_WORLD, {'G', 'S', ' '}}, //SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS
456 {REG_DOMAIN_WORLD, {'G', 'T', ' '}}, //GUATEMALA
457 {REG_DOMAIN_WORLD, {'G', 'U', ' '}}, //GUAM
458 {REG_DOMAIN_WORLD, {'G', 'W', ' '}}, //GUINEA-BISSAU
459 {REG_DOMAIN_WORLD, {'G', 'Y', ' '}}, //GUYANA
460 {REG_DOMAIN_WORLD, {'H', 'K', ' '}}, //HONGKONG
461 {REG_DOMAIN_WORLD, {'H', 'M', ' '}}, //HEARD ISLAND AND MCDONALD ISLANDS
462 {REG_DOMAIN_WORLD, {'H', 'N', ' '}}, //HONDURAS
463 {REG_DOMAIN_HI_5GHZ, {'H', 'R', ' '}}, //CROATIA
464 {REG_DOMAIN_WORLD, {'H', 'T', ' '}}, //HAITI
465 {REG_DOMAIN_HI_5GHZ, {'H', 'U', ' '}}, //HUNGARY
466 {REG_DOMAIN_APAC, {'I', 'D', ' '}}, //INDONESIA
467 {REG_DOMAIN_ETSI, {'I', 'E', ' '}}, //IRELAND
468 {REG_DOMAIN_WORLD, {'I', 'L', ' '}}, //ISREAL
469 {REG_DOMAIN_ETSI, {'I', 'M', ' '}}, //ISLE OF MAN
470 {REG_DOMAIN_WORLD, {'I', 'N', ' '}}, //INDIA
471 {REG_DOMAIN_ETSI, {'I', 'O', ' '}}, //BRITISH INDIAN OCEAN TERRITORY
472 {REG_DOMAIN_WORLD, {'I', 'Q', ' '}}, //IRAQ
473 {REG_DOMAIN_WORLD, {'I', 'R', ' '}}, //IRAN, ISLAMIC REPUBLIC OF
474 {REG_DOMAIN_WORLD, {'I', 'S', ' '}}, //ICELAND
475 {REG_DOMAIN_ETSI, {'I', 'T', ' '}}, //ITALY
476 {REG_DOMAIN_ETSI, {'J', 'E', ' '}}, //JERSEY
477 {REG_DOMAIN_WORLD, {'J', 'M', ' '}}, //JAMAICA
478 {REG_DOMAIN_WORLD, {'J', 'O', ' '}}, //JORDAN
479 {REG_DOMAIN_JAPAN, {'J', 'P', ' '}}, //JAPAN
480 {REG_DOMAIN_WORLD, {'K', 'E', ' '}}, //KENYA
481 {REG_DOMAIN_WORLD, {'K', 'G', ' '}}, //KYRGYZSTAN
482 {REG_DOMAIN_WORLD, {'K', 'H', ' '}}, //CAMBODIA
483 {REG_DOMAIN_WORLD, {'K', 'I', ' '}}, //KIRIBATI
484 {REG_DOMAIN_WORLD, {'K', 'M', ' '}}, //COMOROS
485 {REG_DOMAIN_WORLD, {'K', 'N', ' '}}, //SAINT KITTS AND NEVIS
486 {REG_DOMAIN_KOREA, {'K', 'P', ' '}}, //KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF
487 {REG_DOMAIN_KOREA, {'K', 'R', ' '}}, //KOREA, REPUBLIC OF
488 {REG_DOMAIN_WORLD, {'K', 'W', ' '}}, //KUWAIT
489 {REG_DOMAIN_WORLD, {'K', 'Y', ' '}}, //CAYMAN ISLANDS
490 {REG_DOMAIN_WORLD, {'K', 'Z', ' '}}, //KAZAKHSTAN
491 {REG_DOMAIN_WORLD, {'L', 'A', ' '}}, //LAO PEOPLE'S DEMOCRATIC REPUBLIC
492 {REG_DOMAIN_WORLD, {'L', 'B', ' '}}, //LEBANON
493 {REG_DOMAIN_WORLD, {'L', 'C', ' '}}, //SAINT LUCIA
494 {REG_DOMAIN_ETSI, {'L', 'I', ' '}}, //LIECHTENSTEIN
495 {REG_DOMAIN_WORLD, {'L', 'K', ' '}}, //SRI LANKA
496 {REG_DOMAIN_WORLD, {'L', 'R', ' '}}, //LIBERIA
497 {REG_DOMAIN_WORLD, {'L', 'S', ' '}}, //LESOTHO
498 {REG_DOMAIN_HI_5GHZ, {'L', 'T', ' '}}, //LITHUANIA
499 {REG_DOMAIN_ETSI, {'L', 'U', ' '}}, //LUXEMBOURG
500 {REG_DOMAIN_HI_5GHZ, {'L', 'V', ' '}}, //LATVIA
501 {REG_DOMAIN_WORLD, {'L', 'Y', ' '}}, //LIBYAN ARAB JAMAHIRIYA
502 {REG_DOMAIN_WORLD, {'M', 'A', ' '}}, //MOROCCO
503 {REG_DOMAIN_ETSI, {'M', 'C', ' '}}, //MONACO
504 {REG_DOMAIN_WORLD, {'M', 'D', ' '}}, //MOLDOVA, REPUBLIC OF
505 {REG_DOMAIN_WORLD, {'M', 'E', ' '}}, //MONTENEGRO
506 {REG_DOMAIN_WORLD, {'M', 'G', ' '}}, //MADAGASCAR
507 {REG_DOMAIN_WORLD, {'M', 'H', ' '}}, //MARSHALL ISLANDS
508 {REG_DOMAIN_WORLD, {'M', 'K', ' '}}, //MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF
509 {REG_DOMAIN_WORLD, {'M', 'L', ' '}}, //MALI
510 {REG_DOMAIN_WORLD, {'M', 'M', ' '}}, //MYANMAR
511 {REG_DOMAIN_HI_5GHZ, {'M', 'N', ' '}}, //MONGOLIA
512 {REG_DOMAIN_WORLD, {'M', 'O', ' '}}, //MACAO
513 {REG_DOMAIN_WORLD, {'M', 'P', ' '}}, //NORTHERN MARIANA ISLANDS
514 {REG_DOMAIN_WORLD, {'M', 'Q', ' '}}, //MARTINIQUE
515 {REG_DOMAIN_WORLD, {'M', 'R', ' '}}, //MAURITANIA
516 {REG_DOMAIN_WORLD, {'M', 'S', ' '}}, //MONTSERRAT
517 {REG_DOMAIN_WORLD, {'M', 'T', ' '}}, //MALTA
518 {REG_DOMAIN_WORLD, {'M', 'U', ' '}}, //MAURITIUS
519 {REG_DOMAIN_WORLD, {'M', 'V', ' '}}, //MALDIVES
520 {REG_DOMAIN_WORLD, {'M', 'W', ' '}}, //MALAWI
521 {REG_DOMAIN_WORLD, {'M', 'X', ' '}}, //MEXICO
522 {REG_DOMAIN_HI_5GHZ, {'M', 'Y', ' '}}, //MALAYSIA
523 {REG_DOMAIN_WORLD, {'M', 'Z', ' '}}, //MOZAMBIQUE
524 {REG_DOMAIN_WORLD, {'N', 'A', ' '}}, //NAMIBIA
525 {REG_DOMAIN_WORLD, {'N', 'C', ' '}}, //NEW CALEDONIA
526 {REG_DOMAIN_WORLD, {'N', 'E', ' '}}, //NIGER
527 {REG_DOMAIN_WORLD, {'N', 'F', ' '}}, //NORFOLD ISLAND
528 {REG_DOMAIN_WORLD, {'N', 'G', ' '}}, //NIGERIA
529 {REG_DOMAIN_WORLD, {'N', 'I', ' '}}, //NICARAGUA
530 {REG_DOMAIN_ETSI, {'N', 'L', ' '}}, //NETHERLANDS
531 {REG_DOMAIN_WORLD, {'N', 'O', ' '}}, //NORWAY
532 {REG_DOMAIN_WORLD, {'N', 'P', ' '}}, //NEPAL
533 {REG_DOMAIN_WORLD, {'N', 'R', ' '}}, //NAURU
534 {REG_DOMAIN_WORLD, {'N', 'U', ' '}}, //NIUE
535 {REG_DOMAIN_ETSI, {'N', 'Z', ' '}}, //NEW ZEALAND
536 {REG_DOMAIN_WORLD, {'O', 'M', ' '}}, //OMAN
537 {REG_DOMAIN_WORLD, {'P', 'A', ' '}}, //PANAMA
538 {REG_DOMAIN_WORLD, {'P', 'E', ' '}}, //PERU
539 {REG_DOMAIN_WORLD, {'P', 'F', ' '}}, //FRENCH POLYNESIA
540 {REG_DOMAIN_WORLD, {'P', 'G', ' '}}, //PAPUA NEW GUINEA
541 {REG_DOMAIN_WORLD, {'P', 'H', ' '}}, //PHILIPPINES
542 {REG_DOMAIN_WORLD, {'P', 'K', ' '}}, //PAKISTAN
543 {REG_DOMAIN_WORLD, {'P', 'L', ' '}}, //POLAND
544 {REG_DOMAIN_WORLD, {'P', 'M', ' '}}, //SAINT PIERRE AND MIQUELON
545 {REG_DOMAIN_WORLD, {'P', 'N', ' '}}, //PITCAIRN
546 {REG_DOMAIN_FCC, {'P', 'R', ' '}}, //PUERTO RICO
547 {REG_DOMAIN_WORLD, {'P', 'S', ' '}}, //PALESTINIAN TERRITORY, OCCUPIED
548 {REG_DOMAIN_ETSI, {'P', 'T', ' '}}, //PORTUGAL
549 {REG_DOMAIN_WORLD, {'P', 'W', ' '}}, //PALAU
550 {REG_DOMAIN_WORLD, {'P', 'Y', ' '}}, //PARAGUAY
551 {REG_DOMAIN_WORLD, {'Q', 'A', ' '}}, //QATAR
552 {REG_DOMAIN_WORLD, {'R', 'E', ' '}}, //REUNION
553 {REG_DOMAIN_HI_5GHZ, {'R', 'O', ' '}}, //ROMANIA
554 {REG_DOMAIN_HI_5GHZ, {'R', 'S', ' '}}, //SERBIA
555 {REG_DOMAIN_WORLD, {'R', 'U', ' '}}, //RUSSIA
556 {REG_DOMAIN_WORLD, {'R', 'W', ' '}}, //RWANDA
557 {REG_DOMAIN_WORLD, {'S', 'A', ' '}}, //SAUDI ARABIA
558 {REG_DOMAIN_WORLD, {'S', 'B', ' '}}, //SOLOMON ISLANDS
559 {REG_DOMAIN_ETSI, {'S', 'C', ' '}}, //SEYCHELLES
560 {REG_DOMAIN_WORLD, {'S', 'D', ' '}}, //SUDAN
561 {REG_DOMAIN_ETSI, {'S', 'E', ' '}}, //SWEDEN
562 {REG_DOMAIN_APAC, {'S', 'G', ' '}}, //SINGAPORE
563 {REG_DOMAIN_WORLD, {'S', 'H', ' '}}, //SAINT HELENA
564 {REG_DOMAIN_HI_5GHZ, {'S', 'I', ' '}}, //SLOVENNIA
565 {REG_DOMAIN_WORLD, {'S', 'J', ' '}}, //SVALBARD AND JAN MAYEN
566 {REG_DOMAIN_HI_5GHZ, {'S', 'K', ' '}}, //SLOVAKIA
567 {REG_DOMAIN_WORLD, {'S', 'L', ' '}}, //SIERRA LEONE
568 {REG_DOMAIN_WORLD, {'S', 'M', ' '}}, //SAN MARINO
569 {REG_DOMAIN_WORLD, {'S', 'N', ' '}}, //SENEGAL
570 {REG_DOMAIN_WORLD, {'S', 'O', ' '}}, //SOMALIA
571 {REG_DOMAIN_WORLD, {'S', 'R', ' '}}, //SURINAME
572 {REG_DOMAIN_WORLD, {'S', 'T', ' '}}, //SAO TOME AND PRINCIPE
573 {REG_DOMAIN_WORLD, {'S', 'V', ' '}}, //EL SALVADOR
574 {REG_DOMAIN_WORLD, {'S', 'Y', ' '}}, //SYRIAN ARAB REPUBLIC
575 {REG_DOMAIN_WORLD, {'S', 'Z', ' '}}, //SWAZILAND
576 {REG_DOMAIN_WORLD, {'T', 'C', ' '}}, //TURKS AND CAICOS ISLANDS
577 {REG_DOMAIN_WORLD, {'T', 'D', ' '}}, //CHAD
578 {REG_DOMAIN_WORLD, {'T', 'F', ' '}}, //FRENCH SOUTHERN TERRITORIES
579 {REG_DOMAIN_WORLD, {'T', 'G', ' '}}, //TOGO
580 {REG_DOMAIN_WORLD, {'T', 'H', ' '}}, //THAILAND
581 {REG_DOMAIN_WORLD, {'T', 'J', ' '}}, //TAJIKISTAN
582 {REG_DOMAIN_WORLD, {'T', 'K', ' '}}, //TOKELAU
583 {REG_DOMAIN_WORLD, {'T', 'L', ' '}}, //TIMOR-LESTE
584 {REG_DOMAIN_WORLD, {'T', 'M', ' '}}, //TURKMENISTAN
585 {REG_DOMAIN_WORLD, {'T', 'N', ' '}}, //TUNISIA
586 {REG_DOMAIN_WORLD, {'T', 'O', ' '}}, //TONGA
587 {REG_DOMAIN_WORLD, {'T', 'R', ' '}}, //TURKEY
588 {REG_DOMAIN_WORLD, {'T', 'T', ' '}}, //TRINIDAD AND TOBAGO
589 {REG_DOMAIN_WORLD, {'T', 'V', ' '}}, //TUVALU
590 {REG_DOMAIN_HI_5GHZ, {'T', 'W', ' '}}, //TAIWAN, PROVINCE OF CHINA
591 {REG_DOMAIN_WORLD, {'T', 'Z', ' '}}, //TANZANIA, UNITED REPUBLIC OF
592 {REG_DOMAIN_HI_5GHZ, {'U', 'A', ' '}}, //UKRAINE
593 {REG_DOMAIN_WORLD, {'U', 'G', ' '}}, //UGANDA
594 {REG_DOMAIN_FCC, {'U', 'M', ' '}}, //UNITED STATES MINOR OUTLYING ISLANDS
595 {REG_DOMAIN_WORLD, {'U', 'Y', ' '}}, //URUGUAY
596 {REG_DOMAIN_HI_5GHZ, {'U', 'Z', ' '}}, //UZBEKISTAN
597 {REG_DOMAIN_ETSI, {'V', 'A', ' '}}, //HOLY SEE (VATICAN CITY STATE)
598 {REG_DOMAIN_WORLD, {'V', 'C', ' '}}, //SAINT VINCENT AND THE GRENADINES
599 {REG_DOMAIN_HI_5GHZ, {'V', 'E', ' '}}, //VENEZUELA
600 {REG_DOMAIN_ETSI, {'V', 'G', ' '}}, //VIRGIN ISLANDS, BRITISH
601 {REG_DOMAIN_FCC, {'V', 'I', ' '}}, //VIRGIN ISLANDS, US
602 {REG_DOMAIN_WORLD, {'V', 'N', ' '}}, //VIET NAM
603 {REG_DOMAIN_WORLD, {'V', 'U', ' '}}, //VANUATU
604 {REG_DOMAIN_WORLD, {'W', 'F', ' '}}, //WALLIS AND FUTUNA
605 {REG_DOMAIN_WORLD, {'W', 'S', ' '}}, //SOMOA
606 {REG_DOMAIN_WORLD, {'Y', 'E', ' '}}, //YEMEN
607 {REG_DOMAIN_WORLD, {'Y', 'T', ' '}}, //MAYOTTE
608 {REG_DOMAIN_WORLD, {'Z', 'A', ' '}}, //SOUTH AFRICA
609 {REG_DOMAIN_WORLD, {'Z', 'M', ' '}}, //ZAMBIA
610 {REG_DOMAIN_WORLD, {'Z', 'W', ' '}}, //ZIMBABWE
611
612 {REG_DOMAIN_KOREA, {'K', '1', ' '}}, //Korea alternate 1
613 {REG_DOMAIN_KOREA, {'K', '2', ' '}}, //Korea alternate 2
614 {REG_DOMAIN_KOREA, {'K', '3', ' '}}, //Korea alternate 3
615 {REG_DOMAIN_KOREA, {'K', '4', ' '}}, //Korea alternate 4
616};
617
618
619//The channels listed here doesn't mean they are valid channels for certain domain. They are here only to present
620//whether they should be passive scanned.
621tCsrDomainChnInfo gCsrDomainChnInfo[NUM_REG_DOMAINS] =
622{
623 //REG_DOMAIN_FCC
624 {
625 REG_DOMAIN_FCC,
626 45, //Num channels
627 //Channels
628 {
629 //5GHz
630 //5180 - 5240
631 {36, eSIR_ACTIVE_SCAN},
632 {40, eSIR_ACTIVE_SCAN},
633 {44, eSIR_ACTIVE_SCAN},
634 {48, eSIR_ACTIVE_SCAN},
635 //5250 to 5350
636 {52, eSIR_PASSIVE_SCAN},
637 {56, eSIR_PASSIVE_SCAN},
638 {60, eSIR_PASSIVE_SCAN},
639 {64, eSIR_PASSIVE_SCAN},
640 //5470 to 5725
641 {100, eSIR_PASSIVE_SCAN},
642 {104, eSIR_PASSIVE_SCAN},
643 {108, eSIR_PASSIVE_SCAN},
644 {112, eSIR_PASSIVE_SCAN},
645 {116, eSIR_PASSIVE_SCAN},
646 {120, eSIR_PASSIVE_SCAN},
647 {124, eSIR_PASSIVE_SCAN},
648 {128, eSIR_PASSIVE_SCAN},
649 {132, eSIR_PASSIVE_SCAN},
650 {136, eSIR_PASSIVE_SCAN},
651 {140, eSIR_PASSIVE_SCAN},
652 //5745 - 5825
653 {149, eSIR_ACTIVE_SCAN},
654 {153, eSIR_ACTIVE_SCAN},
655 {157, eSIR_ACTIVE_SCAN},
656 {161, eSIR_ACTIVE_SCAN},
657 {165, eSIR_ACTIVE_SCAN},
658 //4.9GHz
659 //4920 - 5080
660 {240, eSIR_ACTIVE_SCAN},
661 {244, eSIR_ACTIVE_SCAN},
662 {248, eSIR_ACTIVE_SCAN},
663 {252, eSIR_ACTIVE_SCAN},
664 {208, eSIR_ACTIVE_SCAN},
665 {212, eSIR_ACTIVE_SCAN},
666 {216, eSIR_ACTIVE_SCAN},
667 //2,4GHz
668 {1, eSIR_ACTIVE_SCAN},
669 {2, eSIR_ACTIVE_SCAN},
670 {3, eSIR_ACTIVE_SCAN},
671 {4, eSIR_ACTIVE_SCAN},
672 {5, eSIR_ACTIVE_SCAN},
673 {6, eSIR_ACTIVE_SCAN},
674 {7, eSIR_ACTIVE_SCAN},
675 {8, eSIR_ACTIVE_SCAN},
676 {9, eSIR_ACTIVE_SCAN},
677 {10, eSIR_ACTIVE_SCAN},
678 {11, eSIR_ACTIVE_SCAN},
679 {12, eSIR_ACTIVE_SCAN},
680 {13, eSIR_ACTIVE_SCAN},
681 {14, eSIR_ACTIVE_SCAN},
682 }
683 },
684 //REG_DOMAIN_ETSI
685 {
686 REG_DOMAIN_ETSI,
687 45, //Num channels
688 //Channels
689 {
690 //5GHz
691 //5180 - 5240
692 {36, eSIR_ACTIVE_SCAN},
693 {40, eSIR_ACTIVE_SCAN},
694 {44, eSIR_ACTIVE_SCAN},
695 {48, eSIR_ACTIVE_SCAN},
696 //5250 to 5350
697 {52, eSIR_PASSIVE_SCAN},
698 {56, eSIR_PASSIVE_SCAN},
699 {60, eSIR_PASSIVE_SCAN},
700 {64, eSIR_PASSIVE_SCAN},
701 //5470 to 5725
702 {100, eSIR_PASSIVE_SCAN},
703 {104, eSIR_PASSIVE_SCAN},
704 {108, eSIR_PASSIVE_SCAN},
705 {112, eSIR_PASSIVE_SCAN},
706 {116, eSIR_PASSIVE_SCAN},
707 {120, eSIR_PASSIVE_SCAN},
708 {124, eSIR_PASSIVE_SCAN},
709 {128, eSIR_PASSIVE_SCAN},
710 {132, eSIR_PASSIVE_SCAN},
711 {136, eSIR_PASSIVE_SCAN},
712 {140, eSIR_PASSIVE_SCAN},
713 //5745 - 5825
714 {149, eSIR_ACTIVE_SCAN},
715 {153, eSIR_ACTIVE_SCAN},
716 {157, eSIR_ACTIVE_SCAN},
717 {161, eSIR_ACTIVE_SCAN},
718 {165, eSIR_ACTIVE_SCAN},
719 //4.9GHz
720 //4920 - 5080
721 {240, eSIR_ACTIVE_SCAN},
722 {244, eSIR_ACTIVE_SCAN},
723 {248, eSIR_ACTIVE_SCAN},
724 {252, eSIR_ACTIVE_SCAN},
725 {208, eSIR_ACTIVE_SCAN},
726 {212, eSIR_ACTIVE_SCAN},
727 {216, eSIR_ACTIVE_SCAN},
728 //2,4GHz
729 {1, eSIR_ACTIVE_SCAN},
730 {2, eSIR_ACTIVE_SCAN},
731 {3, eSIR_ACTIVE_SCAN},
732 {4, eSIR_ACTIVE_SCAN},
733 {5, eSIR_ACTIVE_SCAN},
734 {6, eSIR_ACTIVE_SCAN},
735 {7, eSIR_ACTIVE_SCAN},
736 {8, eSIR_ACTIVE_SCAN},
737 {9, eSIR_ACTIVE_SCAN},
738 {10, eSIR_ACTIVE_SCAN},
739 {11, eSIR_ACTIVE_SCAN},
740 {12, eSIR_ACTIVE_SCAN},
741 {13, eSIR_ACTIVE_SCAN},
742 {14, eSIR_ACTIVE_SCAN},
743 }
744 },
745 //REG_DOMAIN_JAPAN
746 {
747 REG_DOMAIN_JAPAN,
748 45, //Num channels
749 //Channels
750 {
751 //5GHz
752 //5180 - 5240
753 {36, eSIR_ACTIVE_SCAN},
754 {40, eSIR_ACTIVE_SCAN},
755 {44, eSIR_ACTIVE_SCAN},
756 {48, eSIR_ACTIVE_SCAN},
757 //5250 to 5350
758 {52, eSIR_PASSIVE_SCAN},
759 {56, eSIR_PASSIVE_SCAN},
760 {60, eSIR_PASSIVE_SCAN},
761 {64, eSIR_PASSIVE_SCAN},
762 //5470 to 5725
763 {100, eSIR_PASSIVE_SCAN},
764 {104, eSIR_PASSIVE_SCAN},
765 {108, eSIR_PASSIVE_SCAN},
766 {112, eSIR_PASSIVE_SCAN},
767 {116, eSIR_PASSIVE_SCAN},
768 {120, eSIR_PASSIVE_SCAN},
769 {124, eSIR_PASSIVE_SCAN},
770 {128, eSIR_PASSIVE_SCAN},
771 {132, eSIR_PASSIVE_SCAN},
772 {136, eSIR_PASSIVE_SCAN},
773 {140, eSIR_PASSIVE_SCAN},
774 //5745 - 5825
775 {149, eSIR_ACTIVE_SCAN},
776 {153, eSIR_ACTIVE_SCAN},
777 {157, eSIR_ACTIVE_SCAN},
778 {161, eSIR_ACTIVE_SCAN},
779 {165, eSIR_ACTIVE_SCAN},
780 //4.9GHz
781 //4920 - 5080
782 {240, eSIR_ACTIVE_SCAN},
783 {244, eSIR_ACTIVE_SCAN},
784 {248, eSIR_ACTIVE_SCAN},
785 {252, eSIR_ACTIVE_SCAN},
786 {208, eSIR_ACTIVE_SCAN},
787 {212, eSIR_ACTIVE_SCAN},
788 {216, eSIR_ACTIVE_SCAN},
789 //2,4GHz
790 {1, eSIR_ACTIVE_SCAN},
791 {2, eSIR_ACTIVE_SCAN},
792 {3, eSIR_ACTIVE_SCAN},
793 {4, eSIR_ACTIVE_SCAN},
794 {5, eSIR_ACTIVE_SCAN},
795 {6, eSIR_ACTIVE_SCAN},
796 {7, eSIR_ACTIVE_SCAN},
797 {8, eSIR_ACTIVE_SCAN},
798 {9, eSIR_ACTIVE_SCAN},
799 {10, eSIR_ACTIVE_SCAN},
800 {11, eSIR_ACTIVE_SCAN},
801 {12, eSIR_ACTIVE_SCAN},
802 {13, eSIR_ACTIVE_SCAN},
803 {14, eSIR_ACTIVE_SCAN},
804 }
805 },
806 //REG_DOMAIN_WORLD
807 {
808 REG_DOMAIN_WORLD,
809 45, //Num channels
810 //Channels
811 {
812 //5GHz
813 //5180 - 5240
814 {36, eSIR_ACTIVE_SCAN},
815 {40, eSIR_ACTIVE_SCAN},
816 {44, eSIR_ACTIVE_SCAN},
817 {48, eSIR_ACTIVE_SCAN},
818 //5250 to 5350
819 {52, eSIR_ACTIVE_SCAN},
820 {56, eSIR_ACTIVE_SCAN},
821 {60, eSIR_ACTIVE_SCAN},
822 {64, eSIR_ACTIVE_SCAN},
823 //5470 to 5725
824 {100, eSIR_ACTIVE_SCAN},
825 {104, eSIR_ACTIVE_SCAN},
826 {108, eSIR_ACTIVE_SCAN},
827 {112, eSIR_ACTIVE_SCAN},
828 {116, eSIR_ACTIVE_SCAN},
829 {120, eSIR_ACTIVE_SCAN},
830 {124, eSIR_ACTIVE_SCAN},
831 {128, eSIR_ACTIVE_SCAN},
832 {132, eSIR_ACTIVE_SCAN},
833 {136, eSIR_ACTIVE_SCAN},
834 {140, eSIR_ACTIVE_SCAN},
835 //5745 - 5825
836 {149, eSIR_ACTIVE_SCAN},
837 {153, eSIR_ACTIVE_SCAN},
838 {157, eSIR_ACTIVE_SCAN},
839 {161, eSIR_ACTIVE_SCAN},
840 {165, eSIR_ACTIVE_SCAN},
841 //4.9GHz
842 //4920 - 5080
843 {240, eSIR_ACTIVE_SCAN},
844 {244, eSIR_ACTIVE_SCAN},
845 {248, eSIR_ACTIVE_SCAN},
846 {252, eSIR_ACTIVE_SCAN},
847 {208, eSIR_ACTIVE_SCAN},
848 {212, eSIR_ACTIVE_SCAN},
849 {216, eSIR_ACTIVE_SCAN},
850 //2,4GHz
851 {1, eSIR_ACTIVE_SCAN},
852 {2, eSIR_ACTIVE_SCAN},
853 {3, eSIR_ACTIVE_SCAN},
854 {4, eSIR_ACTIVE_SCAN},
855 {5, eSIR_ACTIVE_SCAN},
856 {6, eSIR_ACTIVE_SCAN},
857 {7, eSIR_ACTIVE_SCAN},
858 {8, eSIR_ACTIVE_SCAN},
859 {9, eSIR_ACTIVE_SCAN},
860 {10, eSIR_ACTIVE_SCAN},
861 {11, eSIR_ACTIVE_SCAN},
862 {12, eSIR_ACTIVE_SCAN},
863 {13, eSIR_ACTIVE_SCAN},
864 {14, eSIR_ACTIVE_SCAN},
865 }
866 },
867 //REG_DOMAIN_N_AMER_EXC_FCC
868 {
869 REG_DOMAIN_N_AMER_EXC_FCC,
870 45, //Num channels
871 //Channels
872 {
873 //5GHz
874 //5180 - 5240
875 {36, eSIR_ACTIVE_SCAN},
876 {40, eSIR_ACTIVE_SCAN},
877 {44, eSIR_ACTIVE_SCAN},
878 {48, eSIR_ACTIVE_SCAN},
879 //5250 to 5350
880 {52, eSIR_PASSIVE_SCAN},
881 {56, eSIR_PASSIVE_SCAN},
882 {60, eSIR_PASSIVE_SCAN},
883 {64, eSIR_PASSIVE_SCAN},
884 //5470 to 5725
885 {100, eSIR_ACTIVE_SCAN},
886 {104, eSIR_ACTIVE_SCAN},
887 {108, eSIR_ACTIVE_SCAN},
888 {112, eSIR_ACTIVE_SCAN},
889 {116, eSIR_ACTIVE_SCAN},
890 {120, eSIR_ACTIVE_SCAN},
891 {124, eSIR_ACTIVE_SCAN},
892 {128, eSIR_ACTIVE_SCAN},
893 {132, eSIR_ACTIVE_SCAN},
894 {136, eSIR_ACTIVE_SCAN},
895 {140, eSIR_ACTIVE_SCAN},
896 //5745 - 5825
897 {149, eSIR_ACTIVE_SCAN},
898 {153, eSIR_ACTIVE_SCAN},
899 {157, eSIR_ACTIVE_SCAN},
900 {161, eSIR_ACTIVE_SCAN},
901 {165, eSIR_ACTIVE_SCAN},
902 //4.9GHz
903 //4920 - 5080
904 {240, eSIR_ACTIVE_SCAN},
905 {244, eSIR_ACTIVE_SCAN},
906 {248, eSIR_ACTIVE_SCAN},
907 {252, eSIR_ACTIVE_SCAN},
908 {208, eSIR_ACTIVE_SCAN},
909 {212, eSIR_ACTIVE_SCAN},
910 {216, eSIR_ACTIVE_SCAN},
911 //2,4GHz
912 {1, eSIR_ACTIVE_SCAN},
913 {2, eSIR_ACTIVE_SCAN},
914 {3, eSIR_ACTIVE_SCAN},
915 {4, eSIR_ACTIVE_SCAN},
916 {5, eSIR_ACTIVE_SCAN},
917 {6, eSIR_ACTIVE_SCAN},
918 {7, eSIR_ACTIVE_SCAN},
919 {8, eSIR_ACTIVE_SCAN},
920 {9, eSIR_ACTIVE_SCAN},
921 {10, eSIR_ACTIVE_SCAN},
922 {11, eSIR_ACTIVE_SCAN},
923 {12, eSIR_ACTIVE_SCAN},
924 {13, eSIR_ACTIVE_SCAN},
925 {14, eSIR_ACTIVE_SCAN},
926 }
927 },
928 //REG_DOMAIN_APAC
929 {
930 REG_DOMAIN_APAC,
931 45, //Num channels
932 //Channels
933 {
934 //5GHz
935 //5180 - 5240
936 {36, eSIR_ACTIVE_SCAN},
937 {40, eSIR_ACTIVE_SCAN},
938 {44, eSIR_ACTIVE_SCAN},
939 {48, eSIR_ACTIVE_SCAN},
940 //5250 to 5350
941 {52, eSIR_PASSIVE_SCAN},
942 {56, eSIR_PASSIVE_SCAN},
943 {60, eSIR_PASSIVE_SCAN},
944 {64, eSIR_PASSIVE_SCAN},
945 //5470 to 5725
946 {100, eSIR_ACTIVE_SCAN},
947 {104, eSIR_ACTIVE_SCAN},
948 {108, eSIR_ACTIVE_SCAN},
949 {112, eSIR_ACTIVE_SCAN},
950 {116, eSIR_ACTIVE_SCAN},
951 {120, eSIR_ACTIVE_SCAN},
952 {124, eSIR_ACTIVE_SCAN},
953 {128, eSIR_ACTIVE_SCAN},
954 {132, eSIR_ACTIVE_SCAN},
955 {136, eSIR_ACTIVE_SCAN},
956 {140, eSIR_ACTIVE_SCAN},
957 //5745 - 5825
958 {149, eSIR_ACTIVE_SCAN},
959 {153, eSIR_ACTIVE_SCAN},
960 {157, eSIR_ACTIVE_SCAN},
961 {161, eSIR_ACTIVE_SCAN},
962 {165, eSIR_ACTIVE_SCAN},
963 //4.9GHz
964 //4920 - 5080
965 {240, eSIR_ACTIVE_SCAN},
966 {244, eSIR_ACTIVE_SCAN},
967 {248, eSIR_ACTIVE_SCAN},
968 {252, eSIR_ACTIVE_SCAN},
969 {208, eSIR_ACTIVE_SCAN},
970 {212, eSIR_ACTIVE_SCAN},
971 {216, eSIR_ACTIVE_SCAN},
972 //2,4GHz
973 {1, eSIR_ACTIVE_SCAN},
974 {2, eSIR_ACTIVE_SCAN},
975 {3, eSIR_ACTIVE_SCAN},
976 {4, eSIR_ACTIVE_SCAN},
977 {5, eSIR_ACTIVE_SCAN},
978 {6, eSIR_ACTIVE_SCAN},
979 {7, eSIR_ACTIVE_SCAN},
980 {8, eSIR_ACTIVE_SCAN},
981 {9, eSIR_ACTIVE_SCAN},
982 {10, eSIR_ACTIVE_SCAN},
983 {11, eSIR_ACTIVE_SCAN},
984 {12, eSIR_ACTIVE_SCAN},
985 {13, eSIR_ACTIVE_SCAN},
986 {14, eSIR_ACTIVE_SCAN},
987 }
988 },
989 //REG_DOMAIN_KOREA
990 {
991 REG_DOMAIN_KOREA,
992 45, //Num channels
993 //Channels
994 {
995 //5GHz
996 //5180 - 5240
997 {36, eSIR_ACTIVE_SCAN},
998 {40, eSIR_ACTIVE_SCAN},
999 {44, eSIR_ACTIVE_SCAN},
1000 {48, eSIR_ACTIVE_SCAN},
1001 //5250 to 5350
1002 {52, eSIR_PASSIVE_SCAN},
1003 {56, eSIR_PASSIVE_SCAN},
1004 {60, eSIR_PASSIVE_SCAN},
1005 {64, eSIR_PASSIVE_SCAN},
1006 //5470 to 5725
1007 {100, eSIR_PASSIVE_SCAN},
1008 {104, eSIR_PASSIVE_SCAN},
1009 {108, eSIR_PASSIVE_SCAN},
1010 {112, eSIR_PASSIVE_SCAN},
1011 {116, eSIR_PASSIVE_SCAN},
1012 {120, eSIR_PASSIVE_SCAN},
1013 {124, eSIR_PASSIVE_SCAN},
1014 {128, eSIR_PASSIVE_SCAN},
1015 {132, eSIR_PASSIVE_SCAN},
1016 {136, eSIR_PASSIVE_SCAN},
1017 {140, eSIR_PASSIVE_SCAN},
1018 //5745 - 5825
1019 {149, eSIR_ACTIVE_SCAN},
1020 {153, eSIR_ACTIVE_SCAN},
1021 {157, eSIR_ACTIVE_SCAN},
1022 {161, eSIR_ACTIVE_SCAN},
1023 {165, eSIR_ACTIVE_SCAN},
1024 //4.9GHz
1025 //4920 - 5080
1026 {240, eSIR_ACTIVE_SCAN},
1027 {244, eSIR_ACTIVE_SCAN},
1028 {248, eSIR_ACTIVE_SCAN},
1029 {252, eSIR_ACTIVE_SCAN},
1030 {208, eSIR_ACTIVE_SCAN},
1031 {212, eSIR_ACTIVE_SCAN},
1032 {216, eSIR_ACTIVE_SCAN},
1033 //2,4GHz
1034 {1, eSIR_ACTIVE_SCAN},
1035 {2, eSIR_ACTIVE_SCAN},
1036 {3, eSIR_ACTIVE_SCAN},
1037 {4, eSIR_ACTIVE_SCAN},
1038 {5, eSIR_ACTIVE_SCAN},
1039 {6, eSIR_ACTIVE_SCAN},
1040 {7, eSIR_ACTIVE_SCAN},
1041 {8, eSIR_ACTIVE_SCAN},
1042 {9, eSIR_ACTIVE_SCAN},
1043 {10, eSIR_ACTIVE_SCAN},
1044 {11, eSIR_ACTIVE_SCAN},
1045 {12, eSIR_ACTIVE_SCAN},
1046 {13, eSIR_ACTIVE_SCAN},
1047 {14, eSIR_ACTIVE_SCAN},
1048 }
1049 },
1050 //REG_DOMAIN_HI_5GHZ
1051 {
1052 REG_DOMAIN_HI_5GHZ,
1053 45, //Num channels
1054 //Channels
1055 {
1056 //5GHz
1057 //5180 - 5240
1058 {36, eSIR_ACTIVE_SCAN},
1059 {40, eSIR_ACTIVE_SCAN},
1060 {44, eSIR_ACTIVE_SCAN},
1061 {48, eSIR_ACTIVE_SCAN},
1062 //5250 to 5350
1063 {52, eSIR_ACTIVE_SCAN},
1064 {56, eSIR_ACTIVE_SCAN},
1065 {60, eSIR_ACTIVE_SCAN},
1066 {64, eSIR_ACTIVE_SCAN},
1067 //5470 to 5725
1068 {100, eSIR_ACTIVE_SCAN},
1069 {104, eSIR_ACTIVE_SCAN},
1070 {108, eSIR_ACTIVE_SCAN},
1071 {112, eSIR_ACTIVE_SCAN},
1072 {116, eSIR_ACTIVE_SCAN},
1073 {120, eSIR_ACTIVE_SCAN},
1074 {124, eSIR_ACTIVE_SCAN},
1075 {128, eSIR_ACTIVE_SCAN},
1076 {132, eSIR_ACTIVE_SCAN},
1077 {136, eSIR_ACTIVE_SCAN},
1078 {140, eSIR_ACTIVE_SCAN},
1079 //5745 - 5825
1080 {149, eSIR_ACTIVE_SCAN},
1081 {153, eSIR_ACTIVE_SCAN},
1082 {157, eSIR_ACTIVE_SCAN},
1083 {161, eSIR_ACTIVE_SCAN},
1084 {165, eSIR_ACTIVE_SCAN},
1085 //4.9GHz
1086 //4920 - 5080
1087 {240, eSIR_ACTIVE_SCAN},
1088 {244, eSIR_ACTIVE_SCAN},
1089 {248, eSIR_ACTIVE_SCAN},
1090 {252, eSIR_ACTIVE_SCAN},
1091 {208, eSIR_ACTIVE_SCAN},
1092 {212, eSIR_ACTIVE_SCAN},
1093 {216, eSIR_ACTIVE_SCAN},
1094 //2,4GHz
1095 {1, eSIR_ACTIVE_SCAN},
1096 {2, eSIR_ACTIVE_SCAN},
1097 {3, eSIR_ACTIVE_SCAN},
1098 {4, eSIR_ACTIVE_SCAN},
1099 {5, eSIR_ACTIVE_SCAN},
1100 {6, eSIR_ACTIVE_SCAN},
1101 {7, eSIR_ACTIVE_SCAN},
1102 {8, eSIR_ACTIVE_SCAN},
1103 {9, eSIR_ACTIVE_SCAN},
1104 {10, eSIR_ACTIVE_SCAN},
1105 {11, eSIR_ACTIVE_SCAN},
1106 {12, eSIR_ACTIVE_SCAN},
1107 {13, eSIR_ACTIVE_SCAN},
1108 {14, eSIR_ACTIVE_SCAN},
1109 }
1110 },
1111 //REG_DOMAIN_NO_5GHZ
1112 {
1113 REG_DOMAIN_NO_5GHZ,
1114 45, //Num channels
1115 //Channels
1116 {
1117 //5GHz
1118 //5180 - 5240
1119 {36, eSIR_ACTIVE_SCAN},
1120 {40, eSIR_ACTIVE_SCAN},
1121 {44, eSIR_ACTIVE_SCAN},
1122 {48, eSIR_ACTIVE_SCAN},
1123 //5250 to 5350
1124 {52, eSIR_ACTIVE_SCAN},
1125 {56, eSIR_ACTIVE_SCAN},
1126 {60, eSIR_ACTIVE_SCAN},
1127 {64, eSIR_ACTIVE_SCAN},
1128 //5470 to 5725
1129 {100, eSIR_ACTIVE_SCAN},
1130 {104, eSIR_ACTIVE_SCAN},
1131 {108, eSIR_ACTIVE_SCAN},
1132 {112, eSIR_ACTIVE_SCAN},
1133 {116, eSIR_ACTIVE_SCAN},
1134 {120, eSIR_ACTIVE_SCAN},
1135 {124, eSIR_ACTIVE_SCAN},
1136 {128, eSIR_ACTIVE_SCAN},
1137 {132, eSIR_ACTIVE_SCAN},
1138 {136, eSIR_ACTIVE_SCAN},
1139 {140, eSIR_ACTIVE_SCAN},
1140 //5745 - 5825
1141 {149, eSIR_ACTIVE_SCAN},
1142 {153, eSIR_ACTIVE_SCAN},
1143 {157, eSIR_ACTIVE_SCAN},
1144 {161, eSIR_ACTIVE_SCAN},
1145 {165, eSIR_ACTIVE_SCAN},
1146 //4.9GHz
1147 //4920 - 5080
1148 {240, eSIR_ACTIVE_SCAN},
1149 {244, eSIR_ACTIVE_SCAN},
1150 {248, eSIR_ACTIVE_SCAN},
1151 {252, eSIR_ACTIVE_SCAN},
1152 {208, eSIR_ACTIVE_SCAN},
1153 {212, eSIR_ACTIVE_SCAN},
1154 {216, eSIR_ACTIVE_SCAN},
1155 //2,4GHz
1156 {1, eSIR_ACTIVE_SCAN},
1157 {2, eSIR_ACTIVE_SCAN},
1158 {3, eSIR_ACTIVE_SCAN},
1159 {4, eSIR_ACTIVE_SCAN},
1160 {5, eSIR_ACTIVE_SCAN},
1161 {6, eSIR_ACTIVE_SCAN},
1162 {7, eSIR_ACTIVE_SCAN},
1163 {8, eSIR_ACTIVE_SCAN},
1164 {9, eSIR_ACTIVE_SCAN},
1165 {10, eSIR_ACTIVE_SCAN},
1166 {11, eSIR_ACTIVE_SCAN},
1167 {12, eSIR_ACTIVE_SCAN},
1168 {13, eSIR_ACTIVE_SCAN},
1169 {14, eSIR_ACTIVE_SCAN},
1170 }
1171 },
1172};
1173#endif
1174
1175extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
1176
Jeff Johnson295189b2012-06-20 16:38:30 -07001177////////////////////////////////////////////////////////////////////////
1178
1179/**
1180 * \var gPhyRatesSuppt
1181 *
1182 * \brief Rate support lookup table
1183 *
1184 *
1185 * This is a lookup table indexing rates & configuration parameters to
1186 * support. Given a rate (in unites of 0.5Mpbs) & three booleans (MIMO
1187 * Enabled, Channel Bonding Enabled, & Concatenation Enabled), one can
1188 * determine whether the given rate is supported by computing two
1189 * indices. The first maps the rate to table row as indicated below
1190 * (i.e. eHddSuppRate_6Mbps maps to row zero, eHddSuppRate_9Mbps to row
1191 * 1, and so on). Index two can be computed like so:
1192 *
1193 * \code
1194 idx2 = ( fEsf ? 0x4 : 0x0 ) |
1195 ( fCb ? 0x2 : 0x0 ) |
1196 ( fMimo ? 0x1 : 0x0 );
1197 * \endcode
1198 *
1199 *
1200 * Given that:
1201 *
1202 \code
1203 fSupported = gPhyRatesSuppt[idx1][idx2];
1204 \endcode
1205 *
1206 *
1207 * This table is based on the document "PHY Supported Rates.doc". This
1208 * table is permissive in that a rate is reflected as being supported
1209 * even when turning off an enabled feature would be required. For
1210 * instance, "PHY Supported Rates" lists 42Mpbs as unsupported when CB,
1211 * ESF, & MIMO are all on. However, if we turn off either of CB or
1212 * MIMO, it then becomes supported. Therefore, we mark it as supported
1213 * even in index 7 of this table.
1214 *
1215 *
1216 */
1217
1218static const tANI_BOOLEAN gPhyRatesSuppt[24][8] = {
1219
1220 // SSF SSF SSF SSF ESF ESF ESF ESF
1221 // SIMO MIMO SIMO MIMO SIMO MIMO SIMO MIMO
1222 // No CB No CB CB CB No CB No CB CB CB
1223 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 6Mbps
1224 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 9Mbps
1225 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 12Mbps
1226 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 18Mbps
1227 { FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE }, // 20Mbps
1228 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 24Mbps
1229 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 36Mbps
1230 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 40Mbps
1231 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 42Mbps
1232 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 48Mbps
1233 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 54Mbps
1234 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 72Mbps
1235 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 80Mbps
1236 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 84Mbps
1237 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 96Mbps
1238 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 108Mbps
1239 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 120Mbps
1240 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 126Mbps
1241 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 144Mbps
1242 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 160Mbps
1243 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 168Mbps
1244 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 192Mbps
1245 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 216Mbps
1246 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 240Mbps
1247
1248};
1249
1250#define CASE_RETURN_STR(n) case (n): return (#n)
1251
1252const char *
1253get_eRoamCmdStatus_str(eRoamCmdStatus val)
1254{
1255 switch (val)
1256 {
1257 CASE_RETURN_STR(eCSR_ROAM_CANCELLED);
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05301258 CASE_RETURN_STR(eCSR_ROAM_FAILED);
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 CASE_RETURN_STR(eCSR_ROAM_ROAMING_START);
1260 CASE_RETURN_STR(eCSR_ROAM_ROAMING_COMPLETION);
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05301261 CASE_RETURN_STR(eCSR_ROAM_CONNECT_COMPLETION);
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_START);
1263 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_COMPLETION);
1264 CASE_RETURN_STR(eCSR_ROAM_DISASSOCIATED);
1265 CASE_RETURN_STR(eCSR_ROAM_SHOULD_ROAM);
1266 CASE_RETURN_STR(eCSR_ROAM_SCAN_FOUND_NEW_BSS);
1267 CASE_RETURN_STR(eCSR_ROAM_LOSTLINK);
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05301268 CASE_RETURN_STR(eCSR_ROAM_LOSTLINK_DETECTED);
1269 CASE_RETURN_STR(eCSR_ROAM_MIC_ERROR_IND);
1270 CASE_RETURN_STR(eCSR_ROAM_IBSS_IND);
1271 CASE_RETURN_STR(eCSR_ROAM_CONNECT_STATUS_UPDATE);
1272 CASE_RETURN_STR(eCSR_ROAM_GEN_INFO);
1273 CASE_RETURN_STR(eCSR_ROAM_SET_KEY_COMPLETE);
1274 CASE_RETURN_STR(eCSR_ROAM_REMOVE_KEY_COMPLETE);
1275 CASE_RETURN_STR(eCSR_ROAM_IBSS_LEAVE);
1276 CASE_RETURN_STR(eCSR_ROAM_WDS_IND);
1277 CASE_RETURN_STR(eCSR_ROAM_INFRA_IND);
1278 CASE_RETURN_STR(eCSR_ROAM_WPS_PBC_PROBE_REQ_IND);
1279#ifdef WLAN_FEATURE_VOWIFI_11R
1280 CASE_RETURN_STR(eCSR_ROAM_FT_RESPONSE);
1281#endif
1282 CASE_RETURN_STR(eCSR_ROAM_FT_START);
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05301283 CASE_RETURN_STR(eCSR_ROAM_REMAIN_CHAN_READY);
1284 CASE_RETURN_STR(eCSR_ROAM_SEND_ACTION_CNF);
1285 CASE_RETURN_STR(eCSR_ROAM_SESSION_OPENED);
1286 CASE_RETURN_STR(eCSR_ROAM_FT_REASSOC_FAILED);
1287#ifdef FEATURE_WLAN_LFR
1288 CASE_RETURN_STR(eCSR_ROAM_PMK_NOTIFY);
1289#endif
1290#ifdef FEATURE_WLAN_LFR_METRICS
1291 CASE_RETURN_STR(eCSR_ROAM_PREAUTH_INIT_NOTIFY);
1292 CASE_RETURN_STR(eCSR_ROAM_PREAUTH_STATUS_SUCCESS);
1293 CASE_RETURN_STR(eCSR_ROAM_PREAUTH_STATUS_FAILURE);
1294 CASE_RETURN_STR(eCSR_ROAM_HANDOVER_SUCCESS);
1295#endif
1296#ifdef FEATURE_WLAN_TDLS
1297 CASE_RETURN_STR(eCSR_ROAM_TDLS_STATUS_UPDATE);
1298 CASE_RETURN_STR(eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND);
1299#endif
1300 CASE_RETURN_STR(eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS);
1301 CASE_RETURN_STR(eCSR_ROAM_SEND_P2P_STOP_BSS);
1302#ifdef WLAN_FEATURE_11W
1303 CASE_RETURN_STR(eCSR_ROAM_UNPROT_MGMT_FRAME_IND);
1304#endif
1305#ifdef WLAN_FEATURE_RMC
1306 CASE_RETURN_STR(eCSR_ROAM_IBSS_PEER_INFO_COMPLETE);
1307#endif
1308#ifdef WLAN_FEATURE_AP_HT40_24G
1309 CASE_RETURN_STR(eCSR_ROAM_2040_COEX_INFO_IND);
1310#endif
1311#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1312 CASE_RETURN_STR(eCSR_ROAM_TSM_IE_IND);
1313 CASE_RETURN_STR(eCSR_ROAM_CCKM_PREAUTH_NOTIFY);
1314 CASE_RETURN_STR(eCSR_ROAM_ESE_ADJ_AP_REPORT_IND);
1315 CASE_RETURN_STR(eCSR_ROAM_ESE_BCN_REPORT_IND);
1316#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
1317 CASE_RETURN_STR(eCSR_ROAM_UPDATE_MAX_RATE_IND);
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05301318 CASE_RETURN_STR(eCSR_ROAM_LOST_LINK_PARAMS_IND);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05301319 CASE_RETURN_STR(eCSR_ROAM_ECSA_BCN_TX_IND);
1320 CASE_RETURN_STR(eCSR_ROAM_ECSA_CHAN_CHANGE_RSP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 default:
1322 return "unknown";
1323 }
1324}
1325
1326const char *
1327get_eCsrRoamResult_str(eCsrRoamResult val)
1328{
1329 switch (val)
1330 {
1331 CASE_RETURN_STR(eCSR_ROAM_RESULT_NONE);
1332 CASE_RETURN_STR(eCSR_ROAM_RESULT_FAILURE);
1333 CASE_RETURN_STR(eCSR_ROAM_RESULT_ASSOCIATED);
1334 CASE_RETURN_STR(eCSR_ROAM_RESULT_NOT_ASSOCIATED);
1335 CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_FAILURE);
1336 CASE_RETURN_STR(eCSR_ROAM_RESULT_FORCED);
1337 CASE_RETURN_STR(eCSR_ROAM_RESULT_DISASSOC_IND);
1338 CASE_RETURN_STR(eCSR_ROAM_RESULT_DEAUTH_IND);
1339 CASE_RETURN_STR(eCSR_ROAM_RESULT_CAP_CHANGED);
1340 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_CONNECT);
1341 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_INACTIVE);
1342 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_NEW_PEER);
1343 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_COALESCED);
1344 default:
1345 return "unknown";
1346 }
1347}
1348
1349
1350
1351tANI_BOOLEAN csrGetBssIdBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tCsrBssid *pBssId )
1352{
Kiet Lam64c1b492013-07-12 13:56:44 +05301353 vos_mem_copy(pBssId, &pSirBssDesc->bssId[ 0 ], sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 return( TRUE );
1355}
1356
1357
1358tANI_BOOLEAN csrIsBssIdEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 )
1359{
1360 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1361 tANI_BOOLEAN fEqual = FALSE;
1362 tCsrBssid bssId1;
1363 tCsrBssid bssId2;
1364
1365 do {
1366 if ( !pSirBssDesc1 ) break;
1367 if ( !pSirBssDesc2 ) break;
1368
1369 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc1, &bssId1 ) ) break;
1370 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc2, &bssId2 ) ) break;
1371
1372 //sirCompareMacAddr
1373 fEqual = csrIsMacAddressEqual(pMac, &bssId1, &bssId2);
1374
1375 } while( 0 );
1376
1377 return( fEqual );
1378}
1379
1380tANI_BOOLEAN csrIsConnStateConnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1381{
1382 return( eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1383}
1384
1385tANI_BOOLEAN csrIsConnStateDisconnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1386{
1387 return( eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1388}
1389
1390tANI_BOOLEAN csrIsConnStateConnectedInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1391{
1392 return( eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == pMac->roam.roamSession[sessionId].connectState );
1393}
1394
1395tANI_BOOLEAN csrIsConnStateConnected( tpAniSirGlobal pMac, tANI_U32 sessionId )
1396{
1397 if( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateConnectedInfra( pMac, sessionId ) || csrIsConnStateConnectedWds( pMac, sessionId) )
1398 return TRUE;
1399 else
1400 return FALSE;
1401}
1402
1403tANI_BOOLEAN csrIsConnStateInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1404{
1405 return( csrIsConnStateConnectedInfra( pMac, sessionId ) );
1406}
1407
1408tANI_BOOLEAN csrIsConnStateIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1409{
1410 return( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateDisconnectedIbss( pMac, sessionId ) );
1411}
1412
1413
1414tANI_BOOLEAN csrIsConnStateConnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1415{
1416 return( eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1417}
1418
Jeff Johnson295189b2012-06-20 16:38:30 -07001419tANI_BOOLEAN csrIsConnStateConnectedInfraAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1420{
1421 return( (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == pMac->roam.roamSession[sessionId].connectState) ||
1422 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState ) );
1423}
Jeff Johnson295189b2012-06-20 16:38:30 -07001424
1425tANI_BOOLEAN csrIsConnStateDisconnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1426{
1427 return( eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1428}
1429
1430tANI_BOOLEAN csrIsConnStateWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1431{
1432 return( csrIsConnStateConnectedWds( pMac, sessionId ) ||
1433 csrIsConnStateDisconnectedWds( pMac, sessionId ) );
1434}
1435
Jeff Johnsone7245742012-09-05 17:12:55 -07001436tANI_BOOLEAN csrIsConnStateAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1437{
1438 tCsrRoamSession *pSession;
1439 pSession = CSR_GET_SESSION(pMac, sessionId);
1440 if (!pSession)
1441 return eANI_BOOLEAN_FALSE;
1442 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
1443 {
1444 return eANI_BOOLEAN_TRUE;
1445 }
1446 return eANI_BOOLEAN_FALSE;
1447}
1448
Jeff Johnson295189b2012-06-20 16:38:30 -07001449tANI_BOOLEAN csrIsAnySessionInConnectState( tpAniSirGlobal pMac )
1450{
1451 tANI_U32 i;
1452 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1453
1454 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1455 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001456 if( CSR_IS_SESSION_VALID( pMac, i ) &&
1457 ( csrIsConnStateInfra( pMac, i )
1458 || csrIsConnStateIbss( pMac, i )
1459 || csrIsConnStateAp( pMac, i) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 {
1461 fRc = eANI_BOOLEAN_TRUE;
1462 break;
1463 }
1464 }
1465
1466 return ( fRc );
1467}
1468
1469tANI_S8 csrGetInfraSessionId( tpAniSirGlobal pMac )
1470{
1471 tANI_U8 i;
1472 tANI_S8 sessionid = -1;
1473
1474 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1475 {
1476 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateInfra( pMac, i ) )
1477 {
1478 sessionid = i;
1479 break;
1480 }
1481 }
1482
1483 return ( sessionid );
1484}
1485
1486tANI_U8 csrGetInfraOperationChannel( tpAniSirGlobal pMac, tANI_U8 sessionId)
1487{
1488 tANI_U8 channel;
1489
1490 if( CSR_IS_SESSION_VALID( pMac, sessionId ))
1491 {
1492 channel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
1493 }
1494 else
1495 {
1496 channel = 0;
1497 }
1498 return channel;
1499}
1500
Sushant Kaushik1d732562014-05-21 14:15:37 +05301501tANI_BOOLEAN csrIsSessionClientAndConnected(tpAniSirGlobal pMac, tANI_U8 sessionId)
1502{
1503 tCsrRoamSession *pSession = NULL;
1504 if ( CSR_IS_SESSION_VALID( pMac, sessionId) && csrIsConnStateInfra( pMac, sessionId))
1505 {
1506 pSession = CSR_GET_SESSION( pMac, sessionId);
Kaushik, Sushant79901762014-08-23 17:51:02 +05301507 if (NULL != pSession->pCurRoamProfile)
Sushant Kaushik1d732562014-05-21 14:15:37 +05301508 {
Kaushik, Sushant79901762014-08-23 17:51:02 +05301509 if ((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1510 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE))
1511 {
1512 return TRUE;
1513 }
Sushant Kaushik1d732562014-05-21 14:15:37 +05301514 }
1515 }
1516 return FALSE;
1517}
Jeff Johnson295189b2012-06-20 16:38:30 -07001518//This routine will return operating channel on FIRST BSS that is active/operating to be used for concurrency mode.
1519//If other BSS is not up or not connected it will return 0
1520
1521tANI_U8 csrGetConcurrentOperationChannel( tpAniSirGlobal pMac )
1522{
1523 tCsrRoamSession *pSession = NULL;
1524 tANI_U8 i = 0;
1525
1526 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1527 {
1528 if( CSR_IS_SESSION_VALID( pMac, i ) )
1529 {
1530 pSession = CSR_GET_SESSION( pMac, i );
1531
1532 if (NULL != pSession->pCurRoamProfile)
1533 {
1534 if (
1535 (((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1536 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE)) &&
1537 (pSession->connectState == eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED))
1538 ||
1539 (((pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) ||
1540 (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE)) &&
1541 (pSession->connectState != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
1542 )
1543 return (pSession->connectedProfile.operationChannel);
1544 }
1545
1546 }
1547 }
1548 return 0;
1549}
1550
1551tANI_BOOLEAN csrIsAllSessionDisconnected( tpAniSirGlobal pMac )
1552{
1553 tANI_U32 i;
1554 tANI_BOOLEAN fRc = eANI_BOOLEAN_TRUE;
1555
1556 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1557 {
1558 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1559 {
1560 fRc = eANI_BOOLEAN_FALSE;
1561 break;
1562 }
1563 }
1564
1565 return ( fRc );
1566}
1567
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001568tANI_BOOLEAN csrIsStaSessionConnected( tpAniSirGlobal pMac )
1569{
1570 tANI_U32 i;
1571 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1572 tCsrRoamSession *pSession = NULL;
1573 tANI_U32 countSta = 0;
1574
1575 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1576 {
1577 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1578 {
1579 pSession = CSR_GET_SESSION( pMac, i );
1580
1581 if (NULL != pSession->pCurRoamProfile)
1582 {
1583 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) {
1584 countSta++;
1585 }
1586 }
1587 }
1588 }
1589
1590 /* return TRUE if one of the following conditions is TRUE:
1591 * - more than one STA session connected
1592 */
1593 if ( countSta > 0) {
1594 fRc = eANI_BOOLEAN_TRUE;
1595 }
1596
1597 return( fRc );
1598}
1599
Bala Venkatesh5bfddc22019-02-13 14:42:05 +05301600tANI_BOOLEAN csrIsP2pGoSessionConnected( tpAniSirGlobal pMac )
1601{
1602 tANI_U32 i;
1603 tCsrRoamSession *pSession = NULL;
1604
1605 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1606 {
1607 if(CSR_IS_SESSION_VALID( pMac, i) &&
1608 !csrIsConnStateDisconnected(pMac, i))
1609 {
1610 pSession = CSR_GET_SESSION(pMac, i);
1611
1612 if (NULL != pSession->pCurRoamProfile)
1613 {
1614 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1615 return eANI_BOOLEAN_TRUE;
1616 }
1617 }
1618 }
1619 }
1620
1621 return eANI_BOOLEAN_FALSE;
1622}
1623
1624
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001625tANI_BOOLEAN csrIsP2pSessionConnected( tpAniSirGlobal pMac )
1626{
1627 tANI_U32 i;
1628 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1629 tCsrRoamSession *pSession = NULL;
1630 tANI_U32 countP2pCli = 0;
1631 tANI_U32 countP2pGo = 0;
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001632 tANI_U32 countSAP = 0;
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001633
1634 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1635 {
1636 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1637 {
1638 pSession = CSR_GET_SESSION( pMac, i );
1639
1640 if (NULL != pSession->pCurRoamProfile)
1641 {
1642 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE) {
1643 countP2pCli++;
1644 }
1645
1646 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1647 countP2pGo++;
1648 }
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001649
1650 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE) {
1651 countSAP++;
1652 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001653 }
1654 }
1655 }
1656
1657 /* return TRUE if one of the following conditions is TRUE:
1658 * - at least one P2P CLI session is connected
1659 * - at least one P2P GO session is connected
1660 */
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001661 if ( (countP2pCli > 0) || (countP2pGo > 0 ) || (countSAP > 0 ) ) {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001662 fRc = eANI_BOOLEAN_TRUE;
1663 }
1664
1665 return( fRc );
1666}
1667
Madan Mohan Koyyalamudid3d22592012-09-24 14:01:29 -07001668tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac )
1669{
1670 tANI_U32 i, count;
1671 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1672
1673 count = 0;
1674 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1675 {
1676 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1677 {
1678 count++;
1679 }
1680 }
1681
1682 if (count > 0)
1683 {
1684 fRc = eANI_BOOLEAN_TRUE;
1685 }
1686 return( fRc );
1687}
Jeff Johnson295189b2012-06-20 16:38:30 -07001688
1689tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac )
1690{
1691 tANI_U32 i;
1692 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1693
1694 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1695 {
1696 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1697 {
1698 fRc = eANI_BOOLEAN_TRUE;
1699 break;
1700 }
1701 }
1702
1703 return ( fRc );
1704}
1705
1706tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac )
1707{
1708 tANI_U32 i, noOfConnectedInfra = 0;
1709
1710 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1711
1712 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1713 {
1714 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1715 {
1716 ++noOfConnectedInfra;
1717 }
1718 }
1719
1720 // More than one Infra Sta Connected
1721 if(noOfConnectedInfra > 1)
1722 {
1723 fRc = eANI_BOOLEAN_TRUE;
1724 }
1725
1726 return ( fRc );
1727}
1728
1729tANI_BOOLEAN csrIsIBSSStarted( tpAniSirGlobal pMac )
1730{
1731 tANI_U32 i;
1732 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1733
1734 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1735 {
1736 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateIbss( pMac, i ) )
1737 {
1738 fRc = eANI_BOOLEAN_TRUE;
1739 break;
1740 }
1741 }
1742
1743 return ( fRc );
1744}
1745
1746
1747tANI_BOOLEAN csrIsBTAMPStarted( tpAniSirGlobal pMac )
1748{
1749 tANI_U32 i;
1750 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1751
1752 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1753 {
1754 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedWds( pMac, i ) )
1755 {
1756 fRc = eANI_BOOLEAN_TRUE;
1757 break;
1758 }
1759 }
1760
1761 return ( fRc );
1762}
1763
Jeff Johnsone7245742012-09-05 17:12:55 -07001764tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac )
1765{
1766 tANI_U32 sessionId, noOfCocurrentSession = 0;
1767 eCsrConnectState connectState;
1768
1769 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1770
1771 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1772 {
1773 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1774 {
1775 connectState = pMac->roam.roamSession[sessionId].connectState;
1776 if( (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == connectState) ||
1777 (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == connectState) ||
1778 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == connectState) )
1779 {
1780 ++noOfCocurrentSession;
1781 }
1782 }
1783 }
1784
1785 // More than one session is Up and Running
1786 if(noOfCocurrentSession > 1)
1787 {
1788 fRc = eANI_BOOLEAN_TRUE;
1789 }
1790
1791 return ( fRc );
1792}
1793
Jeff Johnsone7245742012-09-05 17:12:55 -07001794tANI_BOOLEAN csrIsInfraApStarted( tpAniSirGlobal pMac )
1795{
1796 tANI_U32 sessionId;
1797 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1798
1799 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1800 {
1801 if( CSR_IS_SESSION_VALID( pMac, sessionId ) && (csrIsConnStateConnectedInfraAp(pMac, sessionId)) )
1802 {
1803 fRc = eANI_BOOLEAN_TRUE;
1804 break;
1805 }
1806 }
1807
1808 return ( fRc );
1809
1810}
Jeff Johnsone7245742012-09-05 17:12:55 -07001811
Jeff Johnson295189b2012-06-20 16:38:30 -07001812tANI_BOOLEAN csrIsBTAMP( tpAniSirGlobal pMac, tANI_U32 sessionId )
1813{
1814 return ( csrIsConnStateConnectedWds( pMac, sessionId ) );
1815}
1816
1817
1818tANI_BOOLEAN csrIsConnStateDisconnected(tpAniSirGlobal pMac, tANI_U32 sessionId)
1819{
1820 return (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED == pMac->roam.roamSession[sessionId].connectState);
1821}
1822
Jeff Johnsone7245742012-09-05 17:12:55 -07001823tANI_BOOLEAN csrIsValidMcConcurrentSession(tpAniSirGlobal pMac, tANI_U32 sessionId,
1824 tSirBssDescription *pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001825{
1826 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07001827 eAniBoolean status = eANI_BOOLEAN_FALSE;
1828
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 //Check for MCC support
1830 if (!pMac->roam.configParam.fenableMCCMode)
1831 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001832 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 }
1834
Jeff Johnsone7245742012-09-05 17:12:55 -07001835 //Validate BeaconInterval
1836 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1837 {
1838 pSession = CSR_GET_SESSION( pMac, sessionId );
1839 if (NULL != pSession->pCurRoamProfile)
1840 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001841 if (csrIsconcurrentsessionValid (pMac, sessionId,
1842 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001843 == eHAL_STATUS_SUCCESS )
1844 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001845 if (csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId,
1846 &pBssDesc->beaconInterval, sessionId,
1847 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001848 != eHAL_STATUS_SUCCESS)
1849 {
1850 status = eANI_BOOLEAN_FALSE;
1851 }
1852 else
1853 {
1854 status = eANI_BOOLEAN_TRUE;
1855 }
1856 }
1857 else
1858 {
1859 status = eANI_BOOLEAN_FALSE;
1860 }
1861 }
1862 }
1863 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001864}
1865
1866static tSirMacCapabilityInfo csrGetBssCapabilities( tSirBssDescription *pSirBssDesc )
1867{
1868 tSirMacCapabilityInfo dot11Caps;
1869
1870 //tSirMacCapabilityInfo is 16-bit
1871 pal_get_U16( (tANI_U8 *)&pSirBssDesc->capabilityInfo, (tANI_U16 *)&dot11Caps );
1872
1873 return( dot11Caps );
1874}
1875
1876tANI_BOOLEAN csrIsInfraBssDesc( tSirBssDescription *pSirBssDesc )
1877{
1878 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1879
1880 return( (tANI_BOOLEAN)dot11Caps.ess );
1881}
1882
1883
1884tANI_BOOLEAN csrIsIbssBssDesc( tSirBssDescription *pSirBssDesc )
1885{
1886 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1887
1888 return( (tANI_BOOLEAN)dot11Caps.ibss );
1889}
1890
1891tANI_BOOLEAN csrIsQoSBssDesc( tSirBssDescription *pSirBssDesc )
1892{
1893 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1894
1895 return( (tANI_BOOLEAN)dot11Caps.qos );
1896}
1897
1898tANI_BOOLEAN csrIsPrivacy( tSirBssDescription *pSirBssDesc )
1899{
1900 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1901
1902 return( (tANI_BOOLEAN)dot11Caps.privacy );
1903}
1904
1905
1906tANI_BOOLEAN csrIs11dSupported(tpAniSirGlobal pMac)
1907{
1908 return(pMac->roam.configParam.Is11dSupportEnabled);
1909}
1910
1911
1912tANI_BOOLEAN csrIs11hSupported(tpAniSirGlobal pMac)
1913{
1914 return(pMac->roam.configParam.Is11hSupportEnabled);
1915}
1916
1917
1918tANI_BOOLEAN csrIs11eSupported(tpAniSirGlobal pMac)
1919{
1920 return(pMac->roam.configParam.Is11eSupportEnabled);
1921}
1922
1923tANI_BOOLEAN csrIsMCCSupported ( tpAniSirGlobal pMac )
1924{
1925 return(pMac->roam.configParam.fenableMCCMode);
1926
1927}
1928
1929tANI_BOOLEAN csrIsWmmSupported(tpAniSirGlobal pMac)
1930{
1931 if(eCsrRoamWmmNoQos == pMac->roam.configParam.WMMSupportMode)
1932 {
1933 return eANI_BOOLEAN_FALSE;
1934 }
1935 else
1936 {
1937 return eANI_BOOLEAN_TRUE;
1938 }
1939}
1940
1941
1942
1943
1944//pIes is the IEs for pSirBssDesc2
1945tANI_BOOLEAN csrIsSsidEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1,
1946 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2 )
1947{
1948 tANI_BOOLEAN fEqual = FALSE;
1949 tSirMacSSid Ssid1, Ssid2;
1950 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1951 tDot11fBeaconIEs *pIes1 = NULL;
1952 tDot11fBeaconIEs *pIesLocal = pIes2;
1953
1954 do {
1955 if( ( NULL == pSirBssDesc1 ) || ( NULL == pSirBssDesc2 ) ) break;
1956 if( !pIesLocal && !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesLocal)) )
1957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001958 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 break;
1960 }
1961 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
1962 {
1963 break;
1964 }
1965 if( ( !pIes1->SSID.present ) || ( !pIesLocal->SSID.present ) ) break;
1966 if ( pIes1->SSID.num_ssid != pIesLocal->SSID.num_ssid ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301967 vos_mem_copy(Ssid1.ssId, pIes1->SSID.ssid, pIes1->SSID.num_ssid);
1968 vos_mem_copy(Ssid2.ssId, pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001969
Kiet Lam64c1b492013-07-12 13:56:44 +05301970 fEqual = vos_mem_compare(Ssid1.ssId, Ssid2.ssId, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001971
1972 } while( 0 );
1973 if(pIes1)
1974 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301975 vos_mem_free(pIes1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 }
1977 if( pIesLocal && !pIes2 )
1978 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301979 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 }
1981
1982 return( fEqual );
1983}
1984
1985tANI_BOOLEAN csrIsAniWmeSupported(tDot11fIEAirgo *pIeAirgo)
1986{
1987 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
1988
1989 if(pIeAirgo && pIeAirgo->present && pIeAirgo->PropCapability.present)
1990 {
1991 fRet = (tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability ));
1992 }
1993
1994 return fRet;
1995}
1996
1997
1998
1999
2000//pIes can be passed in as NULL if the caller doesn't have one prepared
2001tANI_BOOLEAN csrIsBssDescriptionWme( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
2002{
2003 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2004 // Assume that WME is found...
2005 tANI_BOOLEAN fWme = TRUE;
2006 tDot11fBeaconIEs *pIesTemp = pIes;
2007
2008 do
2009 {
2010 if(pIesTemp == NULL)
2011 {
2012 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp)) )
2013 {
2014 fWme = FALSE;
2015 break;
2016 }
2017 }
2018 // if the AirgoProprietary indicator is found, then WME is supported...
2019 if ( csrIsAniWmeSupported(&pIesTemp->Airgo) ) break;
2020 // if the Wme Info IE is found, then WME is supported...
2021 if ( CSR_IS_QOS_BSS(pIesTemp) ) break;
2022 // if none of these are found, then WME is NOT supported...
2023 fWme = FALSE;
2024 } while( 0 );
2025 if( !csrIsWmmSupported( pMac ) && fWme)
2026 {
2027 if( !pIesTemp->HTCaps.present )
2028 {
2029 fWme = FALSE;
2030 }
2031 }
2032 if( ( pIes == NULL ) && ( NULL != pIesTemp ) )
2033 {
2034 //we allocate memory here so free it before returning
Kiet Lam64c1b492013-07-12 13:56:44 +05302035 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 }
2037
2038 return( fWme );
2039}
2040
2041tANI_BOOLEAN csrIsHcfEnabled( tDot11fIEAirgo *pIeAirgo )
2042{
2043 tANI_BOOLEAN fHcfSupported = FALSE;
2044
2045 fHcfSupported = ((tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability )) ||
2046 (pIeAirgo->present && pIeAirgo->HCF.present && pIeAirgo->HCF.enabled));
2047
2048 return( fHcfSupported );
2049}
2050
2051
2052eCsrMediaAccessType csrGetQoSFromBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc,
2053 tDot11fBeaconIEs *pIes )
2054{
2055 eCsrMediaAccessType qosType = eCSR_MEDIUM_ACCESS_DCF;
2056
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07002058
2059 do
2060 {
2061 // if we find WMM in the Bss Description, then we let this
2062 // override and use WMM.
2063 if ( csrIsBssDescriptionWme( hHal, pSirBssDesc, pIes ) )
2064 {
2065 qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2066 }
2067 else
2068 {
2069 // if the QoS bit is on, then the AP is advertising 11E QoS...
2070 if ( csrIsQoSBssDesc( pSirBssDesc ) )
2071 {
2072 // which could be HCF or eDCF.
2073 if ( csrIsHcfEnabled( &pIes->Airgo ) )
2074 {
2075 qosType = eCSR_MEDIUM_ACCESS_11e_HCF;
2076 }
2077 else
2078 {
2079 qosType = eCSR_MEDIUM_ACCESS_11e_eDCF;
2080 }
2081 }
2082 else
2083 {
2084 qosType = eCSR_MEDIUM_ACCESS_DCF;
2085 }
2086 // scale back based on the types turned on for the adapter...
2087 if ( eCSR_MEDIUM_ACCESS_11e_eDCF == qosType && !csrIs11eSupported( hHal ) )
2088 {
2089 qosType = eCSR_MEDIUM_ACCESS_DCF;
2090 }
2091 }
2092
2093 } while(0);
2094
2095 return( qosType );
2096}
2097
2098
2099
2100
2101//Caller allocates memory for pIEStruct
2102eHalStatus csrParseBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIEStruct)
2103{
2104 eHalStatus status = eHAL_STATUS_FAILURE;
2105 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Abhishek Singhbad2b322016-10-21 11:22:33 +05302106 int ieLen = (int)GET_IE_LEN_IN_BSS(pBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002107
2108 if(ieLen > 0 && pIEStruct)
2109 {
2110 if(!DOT11F_FAILED(dot11fUnpackBeaconIEs( pMac, (tANI_U8 *)pBssDesc->ieFields, ieLen, pIEStruct )))
2111 {
2112 status = eHAL_STATUS_SUCCESS;
2113 }
2114 }
2115
2116 return (status);
2117}
2118
2119
2120//This function will allocate memory for the parsed IEs to the caller. Caller must free the memory
2121//after it is done with the data only if this function succeeds
2122eHalStatus csrGetParsedBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs **ppIEStruct)
2123{
2124 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2125 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2126
2127 if(pBssDesc && ppIEStruct)
2128 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302129 *ppIEStruct = vos_mem_malloc(sizeof(tDot11fBeaconIEs));
2130 if ( (*ppIEStruct) != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302132 vos_mem_set((void *)*ppIEStruct, sizeof(tDot11fBeaconIEs), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 status = csrParseBssDescriptionIEs(hHal, pBssDesc, *ppIEStruct);
2134 if(!HAL_STATUS_SUCCESS(status))
2135 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302136 vos_mem_free(*ppIEStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 *ppIEStruct = NULL;
2138 }
2139 }
2140 else
2141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002142 smsLog( pMac, LOGE, FL(" failed to allocate memory") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002143 VOS_ASSERT( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +05302144 return eHAL_STATUS_FAILURE;
2145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 }
2147
2148 return (status);
2149}
2150
Siddharth Bhal64246172015-02-27 01:04:37 +05302151eHalStatus csrProcessGetFrameLogCommand( tpAniSirGlobal pMac,
2152 tSmeCmd *pCommand )
2153{
2154 tAniGetFrameLogReq *pMsg;
2155 tANI_U16 msgLen;
2156 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002157
Siddharth Bhal64246172015-02-27 01:04:37 +05302158 msgLen = sizeof(tAniGetFrameLogReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002159
Siddharth Bhal64246172015-02-27 01:04:37 +05302160 if ( NULL == pCommand )
2161 {
2162 smsLog( pMac, LOGE, FL("cannot process. cmd is null") );
2163 return eHAL_STATUS_FAILURE;
2164 }
2165
2166 pMsg = vos_mem_malloc(msgLen);
2167 if ( NULL == pMsg )
2168 {
2169 smsLog( pMac, LOGE, FL("fail to allocate memory") );
2170 return eHAL_STATUS_FAILURE;
2171 }
2172
2173 pMsg->msgType= pal_cpu_to_be16((tANI_U16)WDA_GET_FRAME_LOG_REQ);
2174 pMsg->msgLen= pal_cpu_to_be16(msgLen);
2175
Siddharth Bhal64246172015-02-27 01:04:37 +05302176 pMsg->getFrameLogCmdFlag = pCommand->u.getFramelogCmd.getFrameLogCmdFlag;
2177
2178 status = palSendMBMessage(pMac->hHdd, pMsg);
2179
2180 return( status );
2181}
Jeff Johnson295189b2012-06-20 16:38:30 -07002182
2183tANI_BOOLEAN csrIsNULLSSID( tANI_U8 *pBssSsid, tANI_U8 len )
2184{
2185 tANI_BOOLEAN fNullSsid = FALSE;
2186
2187 tANI_U32 SsidLength;
2188 tANI_U8 *pSsidStr;
2189
2190 do
2191 {
2192 if ( 0 == len )
2193 {
2194 fNullSsid = TRUE;
2195 break;
2196 }
2197
2198 //Consider 0 or space for hidden SSID
2199 if ( 0 == pBssSsid[0] )
2200 {
2201 fNullSsid = TRUE;
2202 break;
2203 }
2204
2205 SsidLength = len;
2206 pSsidStr = pBssSsid;
2207
2208 while ( SsidLength )
2209 {
2210 if( *pSsidStr )
2211 break;
2212
2213 pSsidStr++;
2214 SsidLength--;
2215 }
2216
2217 if( 0 == SsidLength )
2218 {
2219 fNullSsid = TRUE;
2220 break;
2221 }
2222 }
2223 while( 0 );
2224
2225 return fNullSsid;
2226}
2227
2228
2229tANI_U32 csrGetFragThresh( tHalHandle hHal )
2230{
2231 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2232
2233 return pMac->roam.configParam.FragmentationThreshold;
2234}
2235
2236tANI_U32 csrGetRTSThresh( tHalHandle hHal )
2237{
2238 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2239
2240 return pMac->roam.configParam.RTSThreshold;
2241}
2242
2243eCsrPhyMode csrTranslateToPhyModeFromBssDesc( tSirBssDescription *pSirBssDesc )
2244{
2245 eCsrPhyMode phyMode;
2246
2247 switch ( pSirBssDesc->nwType )
2248 {
2249 case eSIR_11A_NW_TYPE:
2250 phyMode = eCSR_DOT11_MODE_11a;
2251 break;
2252
2253 case eSIR_11B_NW_TYPE:
2254 phyMode = eCSR_DOT11_MODE_11b;
2255 break;
2256
2257 case eSIR_11G_NW_TYPE:
2258 phyMode = eCSR_DOT11_MODE_11g;
2259 break;
2260
2261 case eSIR_11N_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 phyMode = eCSR_DOT11_MODE_11n;
2263 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002264#ifdef WLAN_FEATURE_11AC
2265 case eSIR_11AC_NW_TYPE:
2266 default:
2267 phyMode = eCSR_DOT11_MODE_11ac;
2268#else
2269 default:
2270 phyMode = eCSR_DOT11_MODE_11n;
2271#endif
2272 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 return( phyMode );
2275}
2276
2277
2278tANI_U32 csrTranslateToWNICfgDot11Mode(tpAniSirGlobal pMac, eCsrCfgDot11Mode csrDot11Mode)
2279{
2280 tANI_U32 ret;
2281
2282 switch(csrDot11Mode)
2283 {
2284 case eCSR_CFG_DOT11_MODE_AUTO:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002285 smsLog(pMac, LOGW, FL(" Warning: sees eCSR_CFG_DOT11_MODE_AUTO "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 //We cannot decide until now.
2287 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2288 {
2289 ret = WNI_CFG_DOT11_MODE_TAURUS;
2290 }
2291 else
2292 {
Mukul Sharma45063942015-04-01 20:07:59 +05302293#ifdef WLAN_FEATURE_11AC
2294 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2295 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2296 ret = WNI_CFG_DOT11_MODE_11AC;
2297 else
2298 ret = WNI_CFG_DOT11_MODE_11N;
2299#else
2300 ret = WNI_CFG_DOT11_MODE_11N;
2301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 }
2303 break;
2304 case eCSR_CFG_DOT11_MODE_TAURUS:
2305 ret = WNI_CFG_DOT11_MODE_TAURUS;
2306 break;
2307 case eCSR_CFG_DOT11_MODE_11A:
2308 ret = WNI_CFG_DOT11_MODE_11A;
2309 break;
2310 case eCSR_CFG_DOT11_MODE_11B:
2311 ret = WNI_CFG_DOT11_MODE_11B;
2312 break;
2313 case eCSR_CFG_DOT11_MODE_11G:
2314 ret = WNI_CFG_DOT11_MODE_11G;
2315 break;
2316 case eCSR_CFG_DOT11_MODE_11N:
2317 ret = WNI_CFG_DOT11_MODE_11N;
2318 break;
2319 case eCSR_CFG_DOT11_MODE_POLARIS:
2320 ret = WNI_CFG_DOT11_MODE_POLARIS;
2321 break;
2322 case eCSR_CFG_DOT11_MODE_TITAN:
2323 ret = WNI_CFG_DOT11_MODE_TITAN;
2324 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 case eCSR_CFG_DOT11_MODE_11G_ONLY:
Mukul Sharma45063942015-04-01 20:07:59 +05302326 ret = WNI_CFG_DOT11_MODE_11G_ONLY;
2327 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 case eCSR_CFG_DOT11_MODE_11N_ONLY:
Mukul Sharma45063942015-04-01 20:07:59 +05302329 ret = WNI_CFG_DOT11_MODE_11N_ONLY;
2330 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002331
2332#ifdef WLAN_FEATURE_11AC
Mukul Sharma45063942015-04-01 20:07:59 +05302333 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
2334 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2335 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2336 ret = WNI_CFG_DOT11_MODE_11AC_ONLY;
2337 else
2338 ret = WNI_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002339 break;
Mukul Sharma45063942015-04-01 20:07:59 +05302340 case eCSR_CFG_DOT11_MODE_11AC:
2341 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2342 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2343 ret = WNI_CFG_DOT11_MODE_11AC;
2344 else
2345 ret = WNI_CFG_DOT11_MODE_11N;
2346 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002347#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002349 smsLog(pMac, LOGW, FL("doesn't expect %d as csrDo11Mode"), csrDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 if(eCSR_BAND_24 == pMac->roam.configParam.eBand)
2351 {
2352 ret = WNI_CFG_DOT11_MODE_11G;
2353 }
2354 else
2355 {
2356 ret = WNI_CFG_DOT11_MODE_11A;
2357 }
2358 break;
2359 }
2360
2361 return (ret);
2362}
2363
2364
2365//This function should only return the super set of supported modes. 11n implies 11b/g/a/n.
2366eHalStatus csrGetPhyModeFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription,
2367 eCsrPhyMode *pPhyMode, tDot11fBeaconIEs *pIes)
2368{
2369 eHalStatus status = eHAL_STATUS_SUCCESS;
2370 eCsrPhyMode phyMode = csrTranslateToPhyModeFromBssDesc(pBSSDescription);
2371
2372 if( pIes )
2373 {
2374 if(pIes->Airgo.present)
2375 {
2376 if(pIes->Airgo.PropCapability.present)
2377 {
2378 if( PROP_CAPABILITY_GET( TAURUS, pIes->Airgo.PropCapability.capability ))
2379 {
2380 phyMode = eCSR_DOT11_MODE_TAURUS;
2381 }
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302382 }
2383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 if(pIes->HTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2385 {
2386 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002387#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05302388 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302389 {
2390 phyMode = eCSR_DOT11_MODE_11ac;
2391 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002392#endif
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 *pPhyMode = phyMode;
2395 }
2396
2397 return (status);
2398
2399}
2400
2401
2402//This function returns the correct eCSR_CFG_DOT11_MODE is the two phyModes matches
2403//bssPhyMode is the mode derived from the BSS description
2404//f5GhzBand is derived from the channel id of BSS description
2405tANI_BOOLEAN csrGetPhyModeInUse( eCsrPhyMode phyModeIn, eCsrPhyMode bssPhyMode, tANI_BOOLEAN f5GhzBand,
2406 eCsrCfgDot11Mode *pCfgDot11ModeToUse )
2407{
2408 tANI_BOOLEAN fMatch = FALSE;
2409 eCsrCfgDot11Mode cfgDot11Mode;
2410
2411 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; // to suppress compiler warning
2412
2413 switch( phyModeIn )
2414 {
2415 case eCSR_DOT11_MODE_abg: //11a or 11b or 11g
2416 if( f5GhzBand )
2417 {
2418 fMatch = TRUE;
2419 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2420 }
2421 else if( eCSR_DOT11_MODE_11b == bssPhyMode )
2422 {
2423 fMatch = TRUE;
2424 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2425 }
2426 else
2427 {
2428 fMatch = TRUE;
2429 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2430 }
2431 break;
2432
2433 case eCSR_DOT11_MODE_11a: //11a
2434 if( f5GhzBand )
2435 {
2436 fMatch = TRUE;
2437 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2438 }
2439 break;
2440
2441 case eCSR_DOT11_MODE_11a_ONLY: //11a
2442 if( eCSR_DOT11_MODE_11a == bssPhyMode )
2443 {
2444 fMatch = TRUE;
2445 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2446 }
2447 break;
2448
2449 case eCSR_DOT11_MODE_11g:
2450 if(!f5GhzBand)
2451 {
2452 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2453 {
2454 fMatch = TRUE;
2455 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2456 }
2457 else
2458 {
2459 fMatch = TRUE;
2460 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2461 }
2462 }
2463 break;
2464
2465 case eCSR_DOT11_MODE_11g_ONLY:
2466 if( eCSR_DOT11_MODE_11g == bssPhyMode )
2467 {
2468 fMatch = TRUE;
2469 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2470 }
2471 break;
2472
2473 case eCSR_DOT11_MODE_11b:
2474 if( !f5GhzBand )
2475 {
2476 fMatch = TRUE;
2477 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2478 }
2479 break;
2480
2481 case eCSR_DOT11_MODE_11b_ONLY:
2482 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2483 {
2484 fMatch = TRUE;
2485 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2486 }
2487 break;
2488
2489 case eCSR_DOT11_MODE_11n:
2490 fMatch = TRUE;
2491 switch(bssPhyMode)
2492 {
2493 case eCSR_DOT11_MODE_11g:
2494 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2495 break;
2496 case eCSR_DOT11_MODE_11b:
2497 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2498 break;
2499 case eCSR_DOT11_MODE_11a:
2500 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2501 break;
2502 case eCSR_DOT11_MODE_11n:
Jeff Johnsone7245742012-09-05 17:12:55 -07002503#ifdef WLAN_FEATURE_11AC
2504 case eCSR_DOT11_MODE_11ac:
2505#endif
2506 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2507 break;
2508
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 case eCSR_DOT11_MODE_TAURUS:
2510 default:
Jeff Johnsone7245742012-09-05 17:12:55 -07002511#ifdef WLAN_FEATURE_11AC
2512 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2513#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002515#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 break;
2517 }
2518 break;
2519
2520 case eCSR_DOT11_MODE_11n_ONLY:
2521 if((eCSR_DOT11_MODE_11n == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2522 {
2523 fMatch = TRUE;
2524 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002525
2526 }
2527
2528 break;
2529#ifdef WLAN_FEATURE_11AC
2530 case eCSR_DOT11_MODE_11ac:
2531 fMatch = TRUE;
2532 switch(bssPhyMode)
2533 {
2534 case eCSR_DOT11_MODE_11g:
2535 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2536 break;
2537 case eCSR_DOT11_MODE_11b:
2538 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2539 break;
2540 case eCSR_DOT11_MODE_11a:
2541 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2542 break;
2543 case eCSR_DOT11_MODE_11n:
2544 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2545 break;
2546 case eCSR_DOT11_MODE_11ac:
2547 case eCSR_DOT11_MODE_TAURUS:
2548 default:
2549 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2550 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 }
2552 break;
2553
Jeff Johnsone7245742012-09-05 17:12:55 -07002554 case eCSR_DOT11_MODE_11ac_ONLY:
2555 if((eCSR_DOT11_MODE_11ac == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2556 {
2557 fMatch = TRUE;
2558 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2559 }
2560 break;
2561#endif
2562
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 case eCSR_DOT11_MODE_TAURUS:
2564 default:
2565 fMatch = TRUE;
2566 switch(bssPhyMode)
2567 {
2568 case eCSR_DOT11_MODE_11g:
2569 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2570 break;
2571 case eCSR_DOT11_MODE_11b:
2572 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2573 break;
2574 case eCSR_DOT11_MODE_11a:
2575 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2576 break;
2577 case eCSR_DOT11_MODE_11n:
2578 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2579 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002580#ifdef WLAN_FEATURE_11AC
2581 case eCSR_DOT11_MODE_11ac:
2582 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2583 break;
2584#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 case eCSR_DOT11_MODE_TAURUS:
2586 default:
2587 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
2588 break;
2589 }
2590 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 }
2592
2593 if ( fMatch && pCfgDot11ModeToUse )
2594 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002595#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudief5dd972012-10-11 15:06:09 -07002596 if(cfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC && (!IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)))
Jeff Johnsone7245742012-09-05 17:12:55 -07002597 {
2598 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2599 }
2600 else
2601#endif
2602 {
2603 *pCfgDot11ModeToUse = cfgDot11Mode;
2604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 return( fMatch );
2607}
2608
2609
2610//This function decides whether the one of the bit of phyMode is matching the mode in the BSS and allowed by the user
2611//setting, pMac->roam.configParam.uCfgDot11Mode. It returns the mode that fits the criteria.
2612tANI_BOOLEAN csrIsPhyModeMatch( tpAniSirGlobal pMac, tANI_U32 phyMode,
2613 tSirBssDescription *pSirBssDesc, tCsrRoamProfile *pProfile,
2614 eCsrCfgDot11Mode *pReturnCfgDot11Mode,
2615 tDot11fBeaconIEs *pIes)
2616{
2617 tANI_BOOLEAN fMatch = FALSE;
2618 eCsrPhyMode phyModeInBssDesc, phyMode2;
2619 eCsrCfgDot11Mode cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_TAURUS;
2620 tANI_U32 bitMask, loopCount;
2621
2622 if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pSirBssDesc, &phyModeInBssDesc, pIes )))
2623 {
2624 //In case some change change eCSR_DOT11_MODE_TAURUS to non-0
2625 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2626 {
2627 //Taurus means anything
2628 if ( eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode )
2629 {
2630 phyMode = eCSR_DOT11_MODE_abg;
2631 }
2632 else if(eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode)
2633 {
2634 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2635 {
2636 phyMode = eCSR_DOT11_MODE_TAURUS;
2637 }
2638 else
2639 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002640
2641#ifdef WLAN_FEATURE_11AC
2642 phyMode = eCSR_DOT11_MODE_11ac;
2643#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002645#endif
2646
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 }
2648 }
2649 else
2650 {
2651 //user's pick
2652 phyMode = pMac->roam.configParam.phyMode;
2653 }
2654 }
2655 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode) )
2656 {
2657 if(0 != phyMode)
2658 {
2659 if(eCSR_DOT11_MODE_AUTO & phyMode)
2660 {
2661 phyMode2 = eCSR_DOT11_MODE_AUTO & phyMode;
2662 }
2663 else
2664 {
2665 phyMode2 = eCSR_DOT11_MODE_TAURUS & phyMode;
2666 }
2667 }
2668 else
2669 {
2670 phyMode2 = phyMode;
2671 }
2672 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2673 &cfgDot11ModeToUse );
2674 }
2675 else
2676 {
2677 bitMask = 1;
2678 loopCount = 0;
2679 while(loopCount < eCSR_NUM_PHY_MODE)
2680 {
2681 if(0 != ( phyMode2 = (phyMode & (bitMask << loopCount++)) ))
2682 {
2683 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2684 &cfgDot11ModeToUse );
2685 if(fMatch) break;
2686 }
2687 }
2688 }
2689 if ( fMatch && pReturnCfgDot11Mode )
2690 {
2691 if( pProfile )
2692 {
2693 /* IEEE 11n spec (8.4.3): HT STA shall eliminate TKIP as a
2694 * choice for the pairwise cipher suite if CCMP is advertised
2695 * by the AP or if the AP included an HT capabilities element
2696 * in its Beacons and Probe Response.
2697 */
2698 if( (!CSR_IS_11n_ALLOWED( pProfile->negotiatedUCEncryptionType )) &&
2699 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11ModeToUse) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002700#ifdef WLAN_FEATURE_11AC
2701 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11ModeToUse) ||
2702#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11ModeToUse)) )
2704 {
2705 //We cannot do 11n here
2706 if( !CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId) )
2707 {
2708 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2709 }
2710 else
2711 {
2712 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2713 }
2714 }
2715 }
2716 *pReturnCfgDot11Mode = cfgDot11ModeToUse;
2717 }
2718 }
2719
2720 return( fMatch );
2721}
2722
2723
2724eCsrCfgDot11Mode csrFindBestPhyMode( tpAniSirGlobal pMac, tANI_U32 phyMode )
2725{
2726 eCsrCfgDot11Mode cfgDot11ModeToUse;
2727 eCsrBand eBand = pMac->roam.configParam.eBand;
2728
Jeff Johnsone7245742012-09-05 17:12:55 -07002729
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302730 if ((0 == phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002731#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302732 (eCSR_DOT11_MODE_11ac & phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002733#endif
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302734 (eCSR_DOT11_MODE_AUTO & phyMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 {
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302736#ifdef WLAN_FEATURE_11AC
2737 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2738 {
2739 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC;
2740 }
2741 else
2742#endif
2743 {
2744 /* Default to 11N mode if user has configured 11ac mode
2745 * and FW doesn't supports 11ac mode .
2746 */
2747 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 }
2750 else
2751 {
2752 if( ( eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY ) & phyMode )
2753 {
2754 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2755 }
2756 else if ( eCSR_DOT11_MODE_abg & phyMode )
2757 {
2758 if( eCSR_BAND_24 != eBand )
2759 {
2760 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2761 }
2762 else
2763 {
2764 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2765 }
2766 }
2767 else if( ( eCSR_DOT11_MODE_11a | eCSR_DOT11_MODE_11a_ONLY ) & phyMode )
2768 {
2769 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2770 }
2771 else if( ( eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY ) & phyMode )
2772 {
2773 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2774 }
2775 else
2776 {
2777 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B;
2778 }
2779 }
2780
2781 return ( cfgDot11ModeToUse );
2782}
2783
2784
2785
2786
2787tANI_U32 csrGet11hPowerConstraint( tHalHandle hHal, tDot11fIEPowerConstraints *pPowerConstraint )
2788{
2789 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2790 tANI_U32 localPowerConstraint = 0;
2791
2792 // check if .11h support is enabled, if not, the power constraint is 0.
2793 if(pMac->roam.configParam.Is11hSupportEnabled && pPowerConstraint->present)
2794 {
2795 localPowerConstraint = pPowerConstraint->localPowerConstraints;
2796 }
2797
2798 return( localPowerConstraint );
2799}
2800
2801
2802tANI_BOOLEAN csrIsProfileWpa( tCsrRoamProfile *pProfile )
2803{
2804 tANI_BOOLEAN fWpaProfile = FALSE;
2805
2806 switch ( pProfile->negotiatedAuthType )
2807 {
2808 case eCSR_AUTH_TYPE_WPA:
2809 case eCSR_AUTH_TYPE_WPA_PSK:
2810 case eCSR_AUTH_TYPE_WPA_NONE:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002811#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 case eCSR_AUTH_TYPE_CCKM_WPA:
2813#endif
2814 fWpaProfile = TRUE;
2815 break;
2816
2817 default:
2818 fWpaProfile = FALSE;
2819 break;
2820 }
2821
2822 if ( fWpaProfile )
2823 {
2824 switch ( pProfile->negotiatedUCEncryptionType )
2825 {
2826 case eCSR_ENCRYPT_TYPE_WEP40:
2827 case eCSR_ENCRYPT_TYPE_WEP104:
2828 case eCSR_ENCRYPT_TYPE_TKIP:
2829 case eCSR_ENCRYPT_TYPE_AES:
2830 fWpaProfile = TRUE;
2831 break;
2832
2833 default:
2834 fWpaProfile = FALSE;
2835 break;
2836 }
2837 }
2838 return( fWpaProfile );
2839}
2840
2841tANI_BOOLEAN csrIsProfileRSN( tCsrRoamProfile *pProfile )
2842{
2843 tANI_BOOLEAN fRSNProfile = FALSE;
2844
2845 switch ( pProfile->negotiatedAuthType )
2846 {
2847 case eCSR_AUTH_TYPE_RSN:
2848 case eCSR_AUTH_TYPE_RSN_PSK:
2849#ifdef WLAN_FEATURE_VOWIFI_11R
2850 case eCSR_AUTH_TYPE_FT_RSN:
2851 case eCSR_AUTH_TYPE_FT_RSN_PSK:
2852#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002853#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 case eCSR_AUTH_TYPE_CCKM_RSN:
2855#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002856#ifdef WLAN_FEATURE_11W
2857 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05302858 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07002859#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 fRSNProfile = TRUE;
2861 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05302862 case eCSR_AUTH_TYPE_SAE:
2863 fRSNProfile = true;
2864 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002865
2866 default:
2867 fRSNProfile = FALSE;
2868 break;
2869 }
2870
2871 if ( fRSNProfile )
2872 {
2873 switch ( pProfile->negotiatedUCEncryptionType )
2874 {
2875 // !!REVIEW - For WPA2, use of RSN IE mandates
2876 // use of AES as encryption. Here, we qualify
2877 // even if encryption type is WEP or TKIP
2878 case eCSR_ENCRYPT_TYPE_WEP40:
2879 case eCSR_ENCRYPT_TYPE_WEP104:
2880 case eCSR_ENCRYPT_TYPE_TKIP:
2881 case eCSR_ENCRYPT_TYPE_AES:
2882 fRSNProfile = TRUE;
2883 break;
2884
2885 default:
2886 fRSNProfile = FALSE;
2887 break;
2888 }
2889 }
2890 return( fRSNProfile );
2891}
2892
Jeff Johnsone7245742012-09-05 17:12:55 -07002893eHalStatus
2894csrIsconcurrentsessionValid(tpAniSirGlobal pMac,tANI_U32 cursessionId,
2895 tVOS_CON_MODE currBssPersona)
2896{
2897 tANI_U32 sessionId = 0;
2898
2899 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2900 {
2901 if (cursessionId != sessionId )
2902 {
2903 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2904 {
2905 continue;
2906 }
2907
2908 switch (currBssPersona)
2909 {
2910 case VOS_STA_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -07002911 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05302912 smsLog(pMac, LOG4, FL(" Second session for persona %d"), currBssPersona);
Agarwal Ashishe16e1212014-05-15 14:51:36 +05302913 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07002914 }
2915 break;
2916
2917 case VOS_STA_SAP_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302918 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2919 == VOS_STA_SAP_MODE)&&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002920 (pMac->roam.roamSession[sessionId].connectState
2921 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002922 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002923 smsLog(pMac, LOGE, FL(" ****SoftAP mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002924 return eHAL_STATUS_FAILURE;
2925 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002926 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2927 == VOS_P2P_GO_MODE &&
2928 pMac->roam.roamSession[sessionId].connectState
2929 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2930 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2931 == VOS_IBSS_MODE &&
2932 pMac->roam.roamSession[sessionId].connectState
2933 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002934 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002935 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002936 return eHAL_STATUS_FAILURE;
2937 }
2938 break;
2939
2940 case VOS_P2P_CLIENT_MODE:
2941 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002942 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002943 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002945 smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002946 return eHAL_STATUS_FAILURE;
2947 }
2948 break;
2949
2950 case VOS_P2P_GO_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302951 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2952 == VOS_P2P_GO_MODE) &&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002953 (pMac->roam.roamSession[sessionId].connectState
2954 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002955 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002956 smsLog(pMac, LOGE, FL(" ****P2P GO mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002957 return eHAL_STATUS_FAILURE;
2958 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002959 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2960 == VOS_STA_SAP_MODE &&
2961 pMac->roam.roamSession[sessionId].connectState
2962 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2963 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2964 == VOS_IBSS_MODE &&
2965 pMac->roam.roamSession[sessionId].connectState
2966 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002967 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002968 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002969 return eHAL_STATUS_FAILURE;
2970 }
2971 break;
Ravi Joshia96ceb42013-05-20 18:52:39 -07002972 case VOS_IBSS_MODE:
2973 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2974 == VOS_IBSS_MODE) &&
2975 (pMac->roam.roamSession[sessionId].connectState
2976 != eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED))
2977 {
2978 smsLog(pMac, LOGE, FL(" ****IBSS mode already exists ****"));
2979 return eHAL_STATUS_FAILURE;
2980 }
2981 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2982 == VOS_P2P_GO_MODE ||
2983 pMac->roam.roamSession[sessionId].bssParams.bssPersona
2984 == VOS_STA_SAP_MODE) &&
2985 pMac->roam.roamSession[sessionId].connectState
2986 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)
2987 {
2988 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
2989 return eHAL_STATUS_FAILURE;
2990 }
2991 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002992 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002993 smsLog(pMac, LOGE, FL("***Persona not handled = %d*****"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07002994 break;
2995 }
2996 }
2997 }
2998 return eHAL_STATUS_SUCCESS;
2999
3000}
3001
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003002eHalStatus csrUpdateMCCp2pBeaconInterval(tpAniSirGlobal pMac)
Jeff Johnsone7245742012-09-05 17:12:55 -07003003{
3004 tANI_U32 sessionId = 0;
3005
3006 //If MCC is not supported just break and return SUCCESS
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003007 if ( !pMac->roam.configParam.fenableMCCMode){
3008 return eHAL_STATUS_FAILURE;
3009 }
3010
3011 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
3012 {
3013 /* If GO in MCC support different beacon interval,
3014 * change the BI of the P2P-GO */
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003015 if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3016 == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003017 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003018 /* Handle different BI scneario based on the configuration set.
3019 * If Config is set to 0x02 then Disconnect all the P2P clients
3020 * associated. If config is set to 0x04 then update the BI
3021 * without disconnecting all the clients
3022 */
3023 if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
3024 (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
3025 {
3026 return csrSendChngMCCBeaconInterval( pMac, sessionId);
3027 }
3028 //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
3029 else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
3030 {
3031 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
3032 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003033 }
3034 }
3035 return eHAL_STATUS_FAILURE;
3036}
3037
3038tANI_U16 csrCalculateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U16 sta_bi, tANI_U16 go_gbi)
3039{
3040 tANI_U8 num_beacons = 0;
3041 tANI_U8 is_multiple = 0;
3042 tANI_U16 go_cbi = 0;
3043 tANI_U16 go_fbi = 0;
3044 tANI_U16 sta_cbi = 0;
3045
3046 //If GO's given beacon Interval is less than 100
3047 if(go_gbi < 100)
3048 go_cbi = 100;
3049 //if GO's given beacon Interval is greater than or equal to 100
3050 else
3051 go_cbi = 100 + (go_gbi % 100);
3052
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05303053 if ( sta_bi == 0 )
3054 {
3055 /* There is possibility to receive zero as value.
3056 Which will cause divide by zero. Hence initialise with 100
3057 */
3058 sta_bi = 100;
3059 smsLog(pMac, LOGW,
3060 FL("sta_bi 2nd parameter is zero, initialise to %d"), sta_bi);
3061 }
3062
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003063 // check, if either one is multiple of another
3064 if (sta_bi > go_cbi)
3065 {
3066 is_multiple = !(sta_bi % go_cbi);
3067 }
3068 else
3069 {
3070 is_multiple = !(go_cbi % sta_bi);
3071 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08003072 // if it is multiple, then accept GO's beacon interval range [100,199] as it is
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003073 if (is_multiple)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003074 {
3075 return go_cbi;
3076 }
3077 //else , if it is not multiple, then then check for number of beacons to be
3078 //inserted based on sta BI
3079 num_beacons = sta_bi / 100;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003080 if (num_beacons)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003081 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08003082 // GO's final beacon interval will be aligned to sta beacon interval, but
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003083 //in the range of [100, 199].
3084 sta_cbi = sta_bi / num_beacons;
3085 go_fbi = sta_cbi;
3086 }
3087 else
3088 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08003089 // if STA beacon interval is less than 100, use GO's change bacon interval
3090 //instead of updating to STA's beacon interval.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003091 go_fbi = go_cbi;
3092 }
3093 return go_fbi;
3094}
3095
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003096eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003097 tANI_U16 *beaconInterval, tANI_U32 cursessionId,
3098 tVOS_CON_MODE currBssPersona)
3099{
3100 tANI_U32 sessionId = 0;
3101 tANI_U16 new_beaconInterval = 0;
3102
3103 //If MCC is not supported just break
3104 if (!pMac->roam.configParam.fenableMCCMode){
Jeff Johnsone7245742012-09-05 17:12:55 -07003105 return eHAL_STATUS_FAILURE;
3106 }
3107
3108 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
3109 {
3110 if (cursessionId != sessionId )
3111 {
3112 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
3113 {
3114 continue;
3115 }
3116
3117 switch (currBssPersona)
3118 {
3119 case VOS_STA_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003120 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3121 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003122 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
3123 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003124 smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003125 }
3126 //IF SAP has started and STA wants to connect on different channel MCC should
3127 //MCC should not be enabled so making it false to enforce on same channel
3128 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3129 == VOS_STA_SAP_MODE)
3130 {
3131 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3132 != channelId )
3133 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05303134 smsLog(pMac, LOGE, FL("*** MCC with SAP+STA sessions ****"));
3135 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07003136 }
3137 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003138 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003139 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3140 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003141 /* if GO in MCC support different beacon interval,
3142 * change the BI of the P2P-GO */
3143 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
Jeff Johnsone7245742012-09-05 17:12:55 -07003144 != channelId ) &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003145 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003146 != *beaconInterval))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003147 {
3148 /* if GO in MCC support different beacon interval, return success */
3149 if ( pMac->roam.configParam.fAllowMCCGODiffBI == 0x01)
3150 {
3151 return eHAL_STATUS_SUCCESS;
3152 }
3153 // Send only Broadcast disassoc and update beaconInterval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003154 //If configuration is set to 0x04 then dont
3155 // disconnect all the station
3156 else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
3157 (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003158 {
3159 //Check to pass the right beacon Interval
3160 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval,
3161 pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003162 smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003163 //Update the becon Interval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003164 if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003165 {
3166 //Update the beaconInterval now
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003167 smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
3168 pMac->roam.configParam.fAllowMCCGODiffBI);
3169
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003170 pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
3171 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003172 return csrUpdateMCCp2pBeaconInterval(pMac);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003173 }
3174 return eHAL_STATUS_SUCCESS;
3175 }
3176 //Disconnect the P2P session
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003177 else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003178 {
3179 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
3180 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
3181 }
3182 else
3183 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003184 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to preferred AP..."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003185 return eHAL_STATUS_FAILURE;
3186 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003187 }
3188 }
3189 break;
3190
3191 case VOS_P2P_CLIENT_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003192 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3193 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003194 == VOS_STA_MODE)) //check for P2P client mode
3195 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003196 smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003197 }
3198 //IF SAP has started and STA wants to connect on different channel MCC should
3199 //MCC should not be enabled so making it false to enforce on same channel
3200 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3201 == VOS_STA_SAP_MODE)
3202 {
3203 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3204 != channelId )
3205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003206 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP + CLIENT****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003207 return eHAL_STATUS_FAILURE;
3208 }
3209 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003210 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003211 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3212 {
3213 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
3214 != channelId ) &&
3215 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
3216 != *beaconInterval))
3217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003218 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to P2P_GO network ..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003219 return eHAL_STATUS_FAILURE;
3220 }
3221 }
3222 break;
3223
3224 case VOS_P2P_GO_MODE :
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003225 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003226 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3227 ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003228 == VOS_P2P_CLIENT_MODE) ||
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003229 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003230 == VOS_STA_MODE))) //check for P2P_client scenario
3231 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003232 if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003233 == 0 )&&
3234 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
3235 == 0))
3236 {
3237 continue;
3238 }
3239
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05303240 //Assert if connected profile beacon internal is ZERO
3241 if(!pMac->roam.roamSession[sessionId].\
3242 connectedProfile.beaconInterval)
3243 {
3244 smsLog( pMac, LOGE, FL(" Connected profile "
3245 "beacon interval is zero") );
3246 }
3247
Jeff Johnsone7245742012-09-05 17:12:55 -07003248
3249 if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003250 (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003251 != channelId ) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003252 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003253 != *beaconInterval))
3254 {
3255 /*
3256 * Updated beaconInterval should be used only when we are starting a new BSS
3257 * not incase of client or STA case
3258 */
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003259 //Calculate beacon Interval for P2P-GO incase of MCC
3260 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac,
Chet Lanctot4c986162013-05-08 13:59:56 -07003261 pMac->roam.roamSession[sessionId].bssParams.beaconInterval,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003262 *beaconInterval );
3263 if(*beaconInterval != new_beaconInterval)
3264 *beaconInterval = new_beaconInterval;
Jeff Johnsone7245742012-09-05 17:12:55 -07003265 return eHAL_STATUS_SUCCESS;
3266 }
3267 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003268 }
3269 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003270
3271 default :
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303272 smsLog(pMac, LOGE, FL(" Persona not supported : %d"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003273 return eHAL_STATUS_FAILURE;
3274 }
3275 }
3276 }
3277
3278 return eHAL_STATUS_SUCCESS;
3279}
Jeff Johnson295189b2012-06-20 16:38:30 -07003280
3281#ifdef WLAN_FEATURE_VOWIFI_11R
3282/* Function to return TRUE if the authtype is 11r */
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003283tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -07003284{
3285 switch ( AuthType )
3286 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003287 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3288 if(mdiePresent)
3289 return TRUE;
3290 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3292 case eCSR_AUTH_TYPE_FT_RSN:
3293 return TRUE;
3294 break;
3295 default:
3296 break;
3297 }
3298 return FALSE;
3299}
3300
3301/* Function to return TRUE if the profile is 11r */
3302tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
3303{
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003304 return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
Jeff Johnson295189b2012-06-20 16:38:30 -07003305}
3306
3307#endif
3308
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003309#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003310
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003311/* Function to return TRUE if the authtype is ESE */
3312tANI_BOOLEAN csrIsAuthTypeESE( eCsrAuthType AuthType )
Jeff Johnson295189b2012-06-20 16:38:30 -07003313{
3314 switch ( AuthType )
3315 {
3316 case eCSR_AUTH_TYPE_CCKM_WPA:
3317 case eCSR_AUTH_TYPE_CCKM_RSN:
3318 return TRUE;
3319 break;
3320 default:
3321 break;
3322 }
3323 return FALSE;
3324}
3325
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003326/* Function to return TRUE if the profile is ESE */
3327tANI_BOOLEAN csrIsProfileESE( tCsrRoamProfile *pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003328{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003329 return (csrIsAuthTypeESE( pProfile->negotiatedAuthType ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003330}
3331
3332#endif
3333
3334#ifdef FEATURE_WLAN_WAPI
3335tANI_BOOLEAN csrIsProfileWapi( tCsrRoamProfile *pProfile )
3336{
3337 tANI_BOOLEAN fWapiProfile = FALSE;
3338
3339 switch ( pProfile->negotiatedAuthType )
3340 {
3341 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
3342 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
3343 fWapiProfile = TRUE;
3344 break;
3345
3346 default:
3347 fWapiProfile = FALSE;
3348 break;
3349 }
3350
3351 if ( fWapiProfile )
3352 {
3353 switch ( pProfile->negotiatedUCEncryptionType )
3354 {
3355 case eCSR_ENCRYPT_TYPE_WPI:
3356 fWapiProfile = TRUE;
3357 break;
3358
3359 default:
3360 fWapiProfile = FALSE;
3361 break;
3362 }
3363 }
3364 return( fWapiProfile );
3365}
3366
3367static tANI_BOOLEAN csrIsWapiOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3368{
Kiet Lam64c1b492013-07-12 13:56:44 +05303369 return (vos_mem_compare(Oui1, Oui2, CSR_WAPI_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003370}
3371
3372static tANI_BOOLEAN csrIsWapiOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3373 tANI_U8 cAllCyphers,
3374 tANI_U8 Cypher[],
3375 tANI_U8 Oui[] )
3376{
3377 tANI_BOOLEAN fYes = FALSE;
3378 tANI_U8 idx;
3379
3380 for ( idx = 0; idx < cAllCyphers; idx++ )
3381 {
3382 if ( csrIsWapiOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3383 {
3384 fYes = TRUE;
3385 break;
3386 }
3387 }
3388
3389 if ( fYes && Oui )
3390 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303391 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 }
3393
3394 return( fYes );
3395}
3396#endif /* FEATURE_WLAN_WAPI */
3397
3398static tANI_BOOLEAN csrIsWpaOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3399{
Kiet Lam64c1b492013-07-12 13:56:44 +05303400 return(vos_mem_compare(Oui1, Oui2, CSR_WPA_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003401}
3402
3403static tANI_BOOLEAN csrIsOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3404 tANI_U8 cAllCyphers,
3405 tANI_U8 Cypher[],
3406 tANI_U8 Oui[] )
3407{
3408 tANI_BOOLEAN fYes = FALSE;
3409 tANI_U8 idx;
3410
3411 for ( idx = 0; idx < cAllCyphers; idx++ )
3412 {
3413 if ( csrIsWpaOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3414 {
3415 fYes = TRUE;
3416 break;
3417 }
3418 }
3419
3420 if ( fYes && Oui )
3421 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303422 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 }
3424
3425 return( fYes );
3426}
3427
3428static tANI_BOOLEAN csrMatchRSNOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3429 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3430 tANI_U8 Oui[] )
3431{
3432 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui[ouiIndex], Oui ) );
3433
3434}
3435
3436#ifdef FEATURE_WLAN_WAPI
3437static tANI_BOOLEAN csrMatchWapiOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3438 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3439 tANI_U8 Oui[] )
3440{
Kaushik, Sushantfe230152014-04-08 14:37:47 +05303441 if (ouiIndex < CSR_WAPI_OUI_ROW_SIZE)// since csrWapiOui row size is 3 .
3442 return( csrIsWapiOuiMatch( pMac, AllCyphers, cAllCyphers,
3443 csrWapiOui[ouiIndex], Oui ) );
3444 else
3445 return FALSE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07003446
3447}
3448#endif /* FEATURE_WLAN_WAPI */
3449
3450static tANI_BOOLEAN csrMatchWPAOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3451 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3452 tANI_U8 Oui[] )
3453{
3454 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui[ouiIndex], Oui ) );
3455
3456}
3457
3458#if 0
3459static tANI_BOOLEAN csrIsRSNUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3460 tANI_U8 cAllCyphers,
3461 tANI_U8 Oui[] )
3462{
3463 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui00, Oui ) );
3464}
3465
3466static tANI_BOOLEAN csrIsRSNMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3467 tANI_U8 cAllCyphers,
3468 tANI_U8 Oui[] )
3469{
3470 tANI_BOOLEAN fYes = FALSE;
3471
3472 // Check Wep 104 first, if fails, then check Wep40.
3473 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui05, Oui );
3474
3475 if ( !fYes )
3476 {
3477 // if not Wep-104, check Wep-40
3478 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui01, Oui );
3479 }
3480
3481 return( fYes );
3482}
3483
3484
3485static tANI_BOOLEAN csrIsRSNUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3486 tANI_U8 cAllCyphers,
3487 tANI_U8 Oui[] )
3488{
3489 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3490}
3491
3492
3493static tANI_BOOLEAN csrIsRSNMulticastTkip( 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
3500static tANI_BOOLEAN csrIsRSNUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3501 tANI_U8 cAllCyphers,
3502 tANI_U8 Oui[] )
3503{
3504 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3505}
3506
3507static tANI_BOOLEAN csrIsRSNMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3508 tANI_U8 cAllCyphers,
3509 tANI_U8 Oui[] )
3510{
3511 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3512}
3513#endif
3514#ifdef FEATURE_WLAN_WAPI
3515static tANI_BOOLEAN csrIsAuthWapiCert( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3516 tANI_U8 cAllSuites,
3517 tANI_U8 Oui[] )
3518{
3519 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[1], Oui ) );
3520}
3521static tANI_BOOLEAN csrIsAuthWapiPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3522 tANI_U8 cAllSuites,
3523 tANI_U8 Oui[] )
3524{
3525 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[2], Oui ) );
3526}
3527#endif /* FEATURE_WLAN_WAPI */
3528
3529#ifdef WLAN_FEATURE_VOWIFI_11R
3530
3531/*
3532 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3533 * here. This matches for FT Auth with the 802.1X exchange.
3534 *
3535 */
3536static tANI_BOOLEAN csrIsFTAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3537 tANI_U8 cAllSuites,
3538 tANI_U8 Oui[] )
3539{
3540 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[03], Oui ) );
3541}
3542
3543/*
3544 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3545 * here. This matches for FT Auth with the PSK.
3546 *
3547 */
3548static tANI_BOOLEAN csrIsFTAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3549 tANI_U8 cAllSuites,
3550 tANI_U8 Oui[] )
3551{
3552 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[04], Oui ) );
3553}
3554
3555#endif
3556
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003557#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003558
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003559/*
3560 * Function for ESE CCKM AKM Authentication. We match the CCKM AKM Authentication Key Management suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 * here. This matches for CCKM AKM Auth with the 802.1X exchange.
3562 *
3563 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003564static tANI_BOOLEAN csrIsEseCckmAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 tANI_U8 cAllSuites,
3566 tANI_U8 Oui[] )
3567{
3568 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[06], Oui ) );
3569}
3570
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003571static tANI_BOOLEAN csrIsEseCckmAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 tANI_U8 cAllSuites,
3573 tANI_U8 Oui[] )
3574{
3575 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[06], Oui ) );
3576}
3577
3578#endif
3579
3580static tANI_BOOLEAN csrIsAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3581 tANI_U8 cAllSuites,
3582 tANI_U8 Oui[] )
3583{
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[01], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003585}
3586static tANI_BOOLEAN csrIsAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3587 tANI_U8 cAllSuites,
3588 tANI_U8 Oui[] )
3589{
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[02], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003591}
3592
Chet Lanctot186b5732013-03-18 10:26:30 -07003593#ifdef WLAN_FEATURE_11W
3594static tANI_BOOLEAN csrIsAuthRSNPskSha256( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3595 tANI_U8 cAllSuites,
3596 tANI_U8 Oui[] )
3597{
Chet Lanctot4c986162013-05-08 13:59:56 -07003598 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[07], Oui );
Chet Lanctot186b5732013-03-18 10:26:30 -07003599}
Abhishek Singhae408032014-09-25 17:22:04 +05303600static tANI_BOOLEAN csrIsAuthRSN8021xSha256(tpAniSirGlobal pMac,
3601 tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3602 tANI_U8 cAllSuites,
3603 tANI_U8 Oui[] )
3604{
3605 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[8], Oui );
3606}
Chet Lanctot186b5732013-03-18 10:26:30 -07003607#endif
3608
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303609#ifdef WLAN_FEATURE_SAE
3610/**
3611 * csr_is_auth_wpa_sae() - check whether oui is SAE
3612 * @mac: Global MAC context
3613 * @all_suites: pointer to all supported akm suites
3614 * @suite_count: all supported akm suites count
3615 * @oui: Oui needs to be matched
3616 *
3617 * Return: True if OUI is SAE, false otherwise
3618 */
3619static bool csr_is_auth_wpa_sae(tpAniSirGlobal mac,
3620 uint8_t all_suites[][CSR_RSN_OUI_SIZE],
3621 uint8_t suite_count, uint8_t oui[])
3622{
3623 return csrIsOuiMatch(mac, all_suites, suite_count, csrRSNOui[ENUM_SAE],
3624 oui);
3625}
3626#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003627static tANI_BOOLEAN csrIsAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3628 tANI_U8 cAllSuites,
3629 tANI_U8 Oui[] )
3630{
3631 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[01], Oui ) );
3632}
3633
3634#ifdef NOT_CURRENTLY_USED
3635static tANI_BOOLEAN csrIsAuth802_1x( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3636 tANI_U8 cAllSuites,
3637 tANI_U8 Oui[] )
3638{
3639 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[00], Oui ) );
3640}
3641#endif // NOT_CURRENTLY_USED
3642
3643static tANI_BOOLEAN csrIsAuthWpaPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3644 tANI_U8 cAllSuites,
3645 tANI_U8 Oui[] )
3646{
3647 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[02], Oui ) );
3648}
3649#if 0
3650static tANI_BOOLEAN csrIsUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3651 tANI_U8 cAllCyphers,
3652 tANI_U8 Oui[] )
3653{
3654 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui00, Oui ) );
3655}
3656
3657static tANI_BOOLEAN csrIsUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3658 tANI_U8 cAllCyphers,
3659 tANI_U8 Oui[] )
3660{
3661 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3662}
3663
3664static tANI_BOOLEAN csrIsUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3665 tANI_U8 cAllCyphers,
3666 tANI_U8 Oui[] )
3667{
3668 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3669}
3670
3671
3672static tANI_BOOLEAN csrIsMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3673 tANI_U8 cAllCyphers,
3674 tANI_U8 Oui[] )
3675{
3676 tANI_BOOLEAN fYes = FALSE;
3677
3678 // Check Wep 104 first, if fails, then check Wep40.
3679 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui05, Oui );
3680
3681 if ( !fYes )
3682 {
3683 // if not Wep-104, check Wep-40
3684 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui01, Oui );
3685 }
3686
3687 return( fYes );
3688}
3689
3690
3691static tANI_BOOLEAN csrIsMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3692 tANI_U8 cAllCyphers,
3693 tANI_U8 Oui[] )
3694{
3695 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3696}
3697
3698
3699static tANI_BOOLEAN csrIsMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3700 tANI_U8 cAllCyphers,
3701 tANI_U8 Oui[] )
3702{
3703 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3704}
3705
3706#endif
3707
3708tANI_U8 csrGetOUIIndexFromCipher( eCsrEncryptionType enType )
3709{
3710 tANI_U8 OUIIndex;
3711
3712 switch ( enType )
3713 {
3714 case eCSR_ENCRYPT_TYPE_WEP40:
3715 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3716 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX;
3717 break;
3718 case eCSR_ENCRYPT_TYPE_WEP104:
3719 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3720 OUIIndex = CSR_OUI_WEP104_INDEX;
3721 break;
3722 case eCSR_ENCRYPT_TYPE_TKIP:
3723 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX;
3724 break;
3725 case eCSR_ENCRYPT_TYPE_AES:
3726 OUIIndex = CSR_OUI_AES_INDEX;
3727 break;
3728 case eCSR_ENCRYPT_TYPE_NONE:
3729 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX;
3730 break;
3731#ifdef FEATURE_WLAN_WAPI
3732 case eCSR_ENCRYPT_TYPE_WPI:
3733 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX;
3734 break;
3735#endif /* FEATURE_WLAN_WAPI */
3736 default: //HOWTO handle this?
3737 OUIIndex = CSR_OUI_RESERVED_INDEX;
3738 break;
3739 }//switch
3740
3741 return OUIIndex;
3742}
3743
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303744#ifdef WLAN_FEATURE_SAE
3745/**
3746 * csr_check_sae_auth() - update negotiated auth if matches to SAE auth type
3747 * @mac_ctx: pointer to mac context
3748 * @authsuites: auth suites
3749 * @c_auth_suites: auth suites count
3750 * @authentication: authentication
3751 * @auth_type: authentication type list
3752 * @index: current counter
3753 * @neg_authtype: pointer to negotiated auth
3754 *
3755 * Return: None
3756 */
3757static void csr_check_sae_auth(tpAniSirGlobal mac_ctx,
3758 uint8_t authsuites[][CSR_RSN_OUI_SIZE],
3759 uint8_t c_auth_suites,
3760 uint8_t authentication[],
3761 tCsrAuthList *auth_type,
3762 uint8_t index, eCsrAuthType *neg_authtype)
3763{
3764 if ((*neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) &&
3765 csr_is_auth_wpa_sae(mac_ctx, authsuites, c_auth_suites,
3766 authentication)) {
3767 if (eCSR_AUTH_TYPE_SAE == auth_type->authType[index])
3768 *neg_authtype = eCSR_AUTH_TYPE_SAE;
3769 }
3770 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3771 FL("negotiated auth type is %d"), *neg_authtype);
3772}
3773#else
3774static void csr_check_sae_auth(tpAniSirGlobal mac_ctx,
3775 uint8_t authsuites[][CSR_RSN_OUI_SIZE],
3776 uint8_t c_auth_suites,
3777 uint8_t authentication[],
3778 tCsrAuthList *auth_type,
3779 uint8_t index, eCsrAuthType *neg_authtype)
3780{
3781}
3782#endif
3783
Jeff Johnson295189b2012-06-20 16:38:30 -07003784tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3785 tDot11fIERSN *pRSNIe,
3786 tANI_U8 *UnicastCypher,
3787 tANI_U8 *MulticastCypher,
3788 tANI_U8 *AuthSuite,
3789 tCsrRSNCapabilities *Capabilities,
3790 eCsrAuthType *pNegotiatedAuthtype,
3791 eCsrEncryptionType *pNegotiatedMCCipher )
3792{
3793 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3794 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3795 tANI_U8 cUnicastCyphers = 0;
3796 tANI_U8 cMulticastCyphers = 0;
3797 tANI_U8 cAuthSuites = 0, i;
3798 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3799 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3800 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3801 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3802 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3803 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3804
3805 do{
3806 if ( pRSNIe->present )
3807 {
3808 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303809 vos_mem_copy(MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05303811 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_cnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3813 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303814 vos_mem_copy((void *)&AuthSuites[i],
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05303815 (void *)&pRSNIe->akm_suite[i],
Kiet Lam64c1b492013-07-12 13:56:44 +05303816 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 }
3818
3819 //Check - Is requested Unicast Cipher supported by the BSS.
3820 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3821 csrGetOUIIndexFromCipher( enType ), Unicast );
3822
3823 if( !fAcceptableCyphers ) break;
3824
3825
3826 //Unicast is supported. Pick the first matching Group cipher, if any.
3827 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3828 {
3829 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3830 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3831 if(fAcceptableCyphers)
3832 {
3833 break;
3834 }
3835 }
3836 if( !fAcceptableCyphers ) break;
3837
3838 if( pNegotiatedMCCipher )
3839 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3840
3841 /* Initializing with FALSE as it has TRUE value already */
3842 fAcceptableCyphers = FALSE;
3843 for (i = 0 ; i < pAuthType->numEntries; i++)
3844 {
3845 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303846
3847 /* Set SAE as first preference */
3848 csr_check_sae_auth(pMac, AuthSuites, cAuthSuites,
3849 Authentication, pAuthType, i, &negAuthType);
3850
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 #ifdef WLAN_FEATURE_VOWIFI_11R
3852 /* Changed the AKM suites according to order of preference */
3853 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3854 {
3855 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3856 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3857 }
3858 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3859 {
3860 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3861 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3862 }
3863#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003864#ifdef FEATURE_WLAN_ESE
3865 /* ESE only supports 802.1X. No PSK. */
3866 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 {
3868 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3869 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3870 }
3871#endif
3872 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3873 {
3874 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3875 negAuthType = eCSR_AUTH_TYPE_RSN;
3876 }
3877 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3878 {
3879 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3880 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3881 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003882#ifdef WLAN_FEATURE_11W
3883 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3884 {
3885 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3886 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3887 }
Abhishek Singhae408032014-09-25 17:22:04 +05303888 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) &&
3889 csrIsAuthRSN8021xSha256(pMac, AuthSuites,
3890 cAuthSuites, Authentication)) {
3891 if (eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
3892 pAuthType->authType[i])
3893 negAuthType = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3894 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003896
3897 // The 1st auth type in the APs RSN IE, to match stations connecting
3898 // profiles auth type will cause us to exit this loop
3899 // This is added as some APs advertise multiple akms in the RSN IE.
3900 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3901 {
3902 fAcceptableCyphers = TRUE;
3903 break;
3904 }
3905 } // for
3906 }
3907
3908 }while (0);
3909
3910 if ( fAcceptableCyphers )
3911 {
3912 if ( MulticastCypher )
3913 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303914 vos_mem_copy(MulticastCypher, Multicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 }
3916
3917 if ( UnicastCypher )
3918 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303919 vos_mem_copy(UnicastCypher, Unicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 }
3921
3922 if ( AuthSuite )
3923 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303924 vos_mem_copy(AuthSuite, Authentication, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 }
3926
3927 if ( pNegotiatedAuthtype )
3928 {
3929 *pNegotiatedAuthtype = negAuthType;
3930 }
3931 if ( Capabilities )
3932 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003933 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3934 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3935 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003936 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
Abhishek Singhf53e89d2015-06-18 12:30:00 +05303937#ifdef WLAN_FEATURE_11W
Chet Lanctot186b5732013-03-18 10:26:30 -07003938 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3939 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
Abhishek Singhf53e89d2015-06-18 12:30:00 +05303940#else
3941 Capabilities->MFPRequired = 0 ; // Bit 6 MFPR
3942 Capabilities->MFPCapable = 0 ; // Bit 7 MFPC
3943#endif
3944
Chet Lanctot186b5732013-03-18 10:26:30 -07003945 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 }
3947 }
3948 return( fAcceptableCyphers );
3949}
3950
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303951#ifdef WLAN_FEATURE_11W
3952/* ---------------------------------------------------------------------------
3953 \fn csrIsPMFCapabilitiesInRSNMatch
Jeff Johnson295189b2012-06-20 16:38:30 -07003954
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303955 \brief this function is to match our current capabilities with the AP
3956 to which we are expecting make the connection.
3957
3958 \param hHal - HAL Pointer
3959 pFilterMFPEnabled - given by supplicant to us to specify what kind
3960 of connection supplicant is expecting to make
3961 if it is enabled then make PMF connection.
3962 if it is disabled then make normal connection.
3963 pFilterMFPRequired - given by supplicant based on our configuration
3964 if it is 1 then we will require mandatory
3965 PMF connection and if it is 0 then we PMF
3966 connection is optional.
3967 pFilterMFPCapable - given by supplicant based on our configuration
3968 if it 1 then we are PMF capable and if it 0
3969 then we are not PMF capable.
3970 pRSNIe - RSNIe from Beacon/probe response of
3971 neighbor AP against which we will compare
3972 our capabilities.
3973
3974 \return tANI_BOOLEAN - if our PMF capabilities matches with AP then we
3975 will return true to indicate that we are good
3976 to make connection with it. Else we will return
3977 false.
3978 -------------------------------------------------------------------------------*/
3979static tANI_BOOLEAN
3980csrIsPMFCapabilitiesInRSNMatch( tHalHandle hHal,
3981 tANI_BOOLEAN *pFilterMFPEnabled,
3982 tANI_U8 *pFilterMFPRequired,
3983 tANI_U8 *pFilterMFPCapable,
3984 tDot11fIERSN *pRSNIe)
3985{
3986 tANI_U8 apProfileMFPCapable = 0;
3987 tANI_U8 apProfileMFPRequired = 0;
3988 if (pRSNIe && pFilterMFPEnabled && pFilterMFPCapable && pFilterMFPRequired)
3989 {
3990 /* Extracting MFPCapable bit from RSN Ie */
3991 apProfileMFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1;
3992 apProfileMFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1;
3993 if (*pFilterMFPEnabled && *pFilterMFPCapable && *pFilterMFPRequired
3994 && (apProfileMFPCapable == 0))
3995 {
3996 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3997 "AP is not capable to make PMF connection");
3998 return VOS_FALSE;
3999 }
4000 else if (*pFilterMFPEnabled && *pFilterMFPCapable &&
4001 !(*pFilterMFPRequired) && (apProfileMFPCapable == 0))
4002 {
4003 /*
4004 * This is tricky, because supplicant asked us to make mandatory
4005 * PMF connection eventhough PMF connection is optional here.
4006 * so if AP is not capable of PMF then drop it. Don't try to
4007 * connect with it.
4008 */
4009 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4010 "we need PMF connection & AP isn't capable to make PMF connection");
4011 return VOS_FALSE;
4012 }
4013 else if (!(*pFilterMFPCapable) &&
4014 apProfileMFPCapable && apProfileMFPRequired)
4015 {
4016 /*
4017 * In this case, AP with whom we trying to connect requires
4018 * mandatory PMF connections and we are not capable so this AP
4019 * is not good choice to connect
4020 */
4021 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4022 "AP needs PMF connection and we are not capable of pmf connection");
4023 return VOS_FALSE;
4024 }
4025 else if (!(*pFilterMFPEnabled) && *pFilterMFPCapable &&
4026 (apProfileMFPCapable == 1))
4027 {
4028 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4029 "we don't need PMF connection eventhough both parties are capable");
4030 return VOS_FALSE;
4031 }
4032 }
4033 return VOS_TRUE;
4034}
4035#endif
4036
4037tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType,
4038 eCsrEncryptionType enType,
4039 tCsrEncryptionList *pEnMcType,
4040 tANI_BOOLEAN *pMFPEnabled, tANI_U8 *pMFPRequired,
4041 tANI_U8 *pMFPCapable,
4042 tDot11fBeaconIEs *pIes,
4043 eCsrAuthType *pNegotiatedAuthType,
4044 eCsrEncryptionType *pNegotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07004045{
4046 tANI_BOOLEAN fRSNMatch = FALSE;
4047
4048 // See if the cyphers in the Bss description match with the settings in the profile.
4049 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
4050 pNegotiatedAuthType, pNegotiatedMCCipher );
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05304051#ifdef WLAN_FEATURE_11W
4052 /* If all the filter matches then finally checks for PMF capabilities */
4053 if (fRSNMatch)
4054 {
4055 fRSNMatch = csrIsPMFCapabilitiesInRSNMatch( hHal, pMFPEnabled,
4056 pMFPRequired, pMFPCapable,
4057 &pIes->RSN);
4058 }
4059#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004060
4061 return( fRSNMatch );
4062}
4063
4064
4065tANI_BOOLEAN csrLookupPMKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pPMKId )
4066{
4067 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4068 tANI_U32 Index;
4069 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4070
Jeff Johnson32d95a32012-09-10 13:15:23 -07004071 if(!pSession)
4072 {
4073 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4074 return FALSE;
4075 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07004076 /* to force the AP initiate fresh 802.1x authentication after re-association should not
4077 * fill the PMKID from cache this is needed
4078 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
4079
4080 if(pSession->fIgnorePMKIDCache)
4081 {
4082 pSession->fIgnorePMKIDCache = FALSE;
4083 return fRC;
4084 }
4085
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 do
4087 {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304088 for( Index=0; Index < CSR_MAX_PMKID_ALLOWED; Index++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304090 if( vos_mem_compare(pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 {
4092 // match found
4093 fMatchFound = TRUE;
4094 break;
4095 }
4096 }
4097
4098 if( !fMatchFound ) break;
4099
Kiet Lam64c1b492013-07-12 13:56:44 +05304100 vos_mem_copy(pPMKId, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004101
4102 fRC = TRUE;
4103 }
4104 while( 0 );
Sushant Kaushik0b343422015-05-25 17:15:55 +05304105 smsLog(pMac, LOG1, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 fRC, pSession->NumPmkidCache);
4107
4108 return fRC;
4109}
4110
4111
4112tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4113 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
4114{
4115 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4116 tANI_BOOLEAN fRSNMatch;
4117 tANI_U8 cbRSNIe = 0;
4118 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
4119 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
4120 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
4121 tCsrRSNAuthIe *pAuthSuite;
4122 tCsrRSNCapabilities RSNCapabilities;
4123 tCsrRSNPMKIe *pPMK;
4124 tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304125 uint32_t ret;
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004126#ifdef WLAN_FEATURE_11W
4127 tANI_U8 *pGroupMgmtCipherSuite;
4128#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 tDot11fBeaconIEs *pIesLocal = pIes;
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304130 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
Abhinav Kumar12560c32018-08-27 18:14:00 +05304131 tDot11fIERSN rsn_ie = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07004132
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004133 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004134
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 do
4136 {
4137 if ( !csrIsProfileRSN( pProfile ) ) break;
4138
4139 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4140 {
4141 break;
4142 }
4143
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304144 /* Use intersection of the RSN cap sent by user space and
4145 * the AP, so that only common capability are enabled.
4146 */
4147 if (pProfile->pRSNReqIE && pProfile->nRSNReqIELength) {
4148 ret = dot11fUnpackIeRSN(pMac, pProfile->pRSNReqIE + 2,
4149 pProfile->nRSNReqIELength -2, &rsn_ie);
4150 if (DOT11F_SUCCEEDED(ret)) {
4151 pIesLocal->RSN.RSN_Cap[0] = pIesLocal->RSN.RSN_Cap[0] &
4152 rsn_ie.RSN_Cap[0];
4153 pIesLocal->RSN.RSN_Cap[1] = pIesLocal->RSN.RSN_Cap[1] &
4154 rsn_ie.RSN_Cap[1];
4155 }
4156 }
4157
4158 /* See if the cyphers in the Bss description match with the settings in the profile */
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4160 &pProfile->mcEncryptionType, &pIesLocal->RSN,
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304161 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, &negAuthType, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 if ( !fRSNMatch ) break;
4163
4164 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
4165
4166 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
4167
Kiet Lam64c1b492013-07-12 13:56:44 +05304168 vos_mem_copy(pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004169
4170 pRSNIe->cUnicastCyphers = 1;
4171
Kiet Lam64c1b492013-07-12 13:56:44 +05304172 vos_mem_copy(&pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004173
4174 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
4175
4176 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304177 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004178
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304179 /* PreAuthSupported is an AP only capability */
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 RSNCapabilities.PreAuthSupported = 0;
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304181
4182 /* Use the Management Frame Protection values given by the supplicant,
4183 * if AP and STA both are MFP capable.
4184 */
Chet Lanctot186b5732013-03-18 10:26:30 -07004185#ifdef WLAN_FEATURE_11W
4186 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
4187 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
4188#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
4190
4191 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
4192
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304193 if (
4194#ifdef FEATURE_WLAN_ESE
4195 (eCSR_AUTH_TYPE_CCKM_RSN != negAuthType) &&
4196#endif
4197 csrLookupPMKID( pMac, sessionId, pSirBssDesc->bssId, &(PMKId[0]) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 {
4199 pPMK->cPMKIDs = 1;
4200
Kiet Lam64c1b492013-07-12 13:56:44 +05304201 vos_mem_copy(pPMK->PMKIDList[0].PMKID, PMKId, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 }
4203 else
4204 {
4205 pPMK->cPMKIDs = 0;
4206 }
4207
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004208#ifdef WLAN_FEATURE_11W
4209 if ( pProfile->MFPEnabled )
4210 {
4211 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
4212 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
Kiet Lam64c1b492013-07-12 13:56:44 +05304213 vos_mem_copy(pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE);
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004214 }
4215#endif
4216
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4218 // Add in the size of the Auth suite (count plus a single OUI)
4219 // Add in the RSN caps field.
4220 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004221 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
4223 sizeof( *pAuthSuite ) +
4224 sizeof( tCsrRSNCapabilities ));
4225 if(pPMK->cPMKIDs)
4226 {
4227 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
4228 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
4229 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004230#ifdef WLAN_FEATURE_11W
4231 if ( pProfile->MFPEnabled )
4232 {
4233 if ( 0 == pPMK->cPMKIDs )
4234 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
4235 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
4236 }
4237#endif
4238
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 // return the size of the IE header (total) constructed...
4240 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
4241
4242 } while( 0 );
4243
4244 if( !pIes && pIesLocal )
4245 {
4246 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304247 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 }
4249
4250 return( cbRSNIe );
4251}
4252
4253
4254#ifdef FEATURE_WLAN_WAPI
4255tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4256 tDot11fIEWAPI *pWapiIe,
4257 tANI_U8 *UnicastCypher,
4258 tANI_U8 *MulticastCypher,
4259 tANI_U8 *AuthSuite,
4260 eCsrAuthType *pNegotiatedAuthtype,
4261 eCsrEncryptionType *pNegotiatedMCCipher )
4262{
4263 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4264 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4265 tANI_U8 cUnicastCyphers = 0;
4266 tANI_U8 cMulticastCyphers = 0;
4267 tANI_U8 cAuthSuites = 0, i;
4268 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
4269 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
4270 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
4271 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
4272 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
4273 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4274
4275 do{
4276 if ( pWapiIe->present )
4277 {
4278 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05304279 vos_mem_copy(MulticastCyphers, pWapiIe->multicast_cipher_suite,
4280 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
4282 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
4283 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
4284 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304285 vos_mem_copy((void *)&AuthSuites[i], (void *)&pWapiIe->akm_suites[i],
4286 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 }
4288
4289 //Check - Is requested Unicast Cipher supported by the BSS.
4290 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
4291 csrGetOUIIndexFromCipher( enType ), Unicast );
4292
4293 if( !fAcceptableCyphers ) break;
4294
4295
4296 //Unicast is supported. Pick the first matching Group cipher, if any.
4297 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4298 {
4299 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4300 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
4301 if(fAcceptableCyphers)
4302 {
4303 break;
4304 }
4305 }
4306 if( !fAcceptableCyphers ) break;
4307
4308 if( pNegotiatedMCCipher )
4309 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4310
4311 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4312 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
4313 {
4314 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4315 }
4316 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
4317 {
4318 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4319 }
4320 else
4321 {
4322 fAcceptableCyphers = FALSE;
4323 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4324 }
4325 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
4326 {
4327 //Caller doesn't care about auth type, or BSS doesn't match
4328 break;
4329 }
4330 fAcceptableCyphers = FALSE;
4331 for( i = 0 ; i < pAuthType->numEntries; i++ )
4332 {
4333 if( pAuthType->authType[i] == negAuthType )
4334 {
4335 fAcceptableCyphers = TRUE;
4336 break;
4337 }
4338 }
4339 }
4340 }while (0);
4341
4342 if ( fAcceptableCyphers )
4343 {
4344 if ( MulticastCypher )
4345 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304346 vos_mem_copy(MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 }
4348
4349 if ( UnicastCypher )
4350 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304351 vos_mem_copy(UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 }
4353
4354 if ( AuthSuite )
4355 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304356 vos_mem_copy(AuthSuite, Authentication, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 }
4358
4359 if ( pNegotiatedAuthtype )
4360 {
4361 *pNegotiatedAuthtype = negAuthType;
4362 }
4363 }
4364 return( fAcceptableCyphers );
4365}
4366
4367tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4368 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
4369{
4370 tANI_BOOLEAN fWapiMatch = FALSE;
4371
4372 // See if the cyphers in the Bss description match with the settings in the profile.
4373 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4374 pNegotiatedAuthType, pNegotiatedMCCipher );
4375
4376 return( fWapiMatch );
4377}
4378
4379tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4380{
4381 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4382 tANI_U32 Index;
4383 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4384
Jeff Johnson32d95a32012-09-10 13:15:23 -07004385 if(!pSession)
4386 {
4387 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4388 return FALSE;
4389 }
4390
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 do
4392 {
4393 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4394 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004395 smsLog(pMac, LOGW, "match BKID "MAC_ADDRESS_STR" to ",
4396 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05304397 if (vos_mem_compare(pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 {
4399 // match found
4400 fMatchFound = TRUE;
4401 break;
4402 }
4403 }
4404
4405 if( !fMatchFound ) break;
4406
Kiet Lam64c1b492013-07-12 13:56:44 +05304407 vos_mem_copy(pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004408
4409 fRC = TRUE;
4410 }
4411 while( 0 );
4412 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4413
4414 return fRC;
4415}
4416
4417tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4418 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4419{
4420 tANI_BOOLEAN fWapiMatch = FALSE;
4421 tANI_U8 cbWapiIe = 0;
4422 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4423 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4424 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4425 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4426 tANI_U8 *pWapi = NULL;
4427 tANI_BOOLEAN fBKIDFound = FALSE;
4428 tDot11fBeaconIEs *pIesLocal = pIes;
4429
4430 do
4431 {
4432 if ( !csrIsProfileWapi( pProfile ) ) break;
4433
4434 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4435 {
4436 break;
4437 }
4438
4439 // See if the cyphers in the Bss description match with the settings in the profile.
4440 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4441 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4442 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4443 if ( !fWapiMatch ) break;
4444
Kiet Lam64c1b492013-07-12 13:56:44 +05304445 vos_mem_set(pWapiIe, sizeof(tCsrWapiIe), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004446
4447 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4448
4449 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4450
4451 pWapiIe->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304452 vos_mem_copy(&pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004453
4454 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4455
4456 *pWapi = (tANI_U16)1; //cUnicastCyphers
4457 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304458 vos_mem_copy(pWapi, UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 pWapi += sizeof( UnicastCypher );
4460
Kiet Lam64c1b492013-07-12 13:56:44 +05304461 vos_mem_copy(pWapi, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 pWapi += sizeof( MulticastCypher );
4463
4464
4465 // WAPI capabilities follows the Auth Suite (two octects)
4466 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4467 // & since we already did a memset pWapiIe to 0, skip these fields
4468 pWapi +=2;
4469
4470 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4471
4472
4473 if( fBKIDFound )
4474 {
4475 /* Do we need to change the endianness here */
4476 *pWapi = (tANI_U16)1; //cBKIDs
4477 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304478 vos_mem_copy(pWapi, BKId, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 }
4480 else
4481 {
4482 *pWapi = 0;
4483 pWapi+=1;
4484 *pWapi = 0;
4485 pWapi+=1;
4486 }
4487
4488 // Add in the IE fields except the IE header
4489 // Add BKID count and BKID (if any)
4490 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4491
4492 /*2 bytes for BKID Count field*/
4493 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4494
4495 if(fBKIDFound)
4496 {
4497 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4498 }
4499 // return the size of the IE header (total) constructed...
4500 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4501
4502 } while( 0 );
4503
4504 if( !pIes && pIesLocal )
4505 {
4506 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304507 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 }
4509
4510 return( cbWapiIe );
4511}
4512#endif /* FEATURE_WLAN_WAPI */
4513
4514tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4515 tDot11fIEWPA *pWpaIe,
4516 tANI_U8 *UnicastCypher,
4517 tANI_U8 *MulticastCypher,
4518 tANI_U8 *AuthSuite,
4519 eCsrAuthType *pNegotiatedAuthtype,
4520 eCsrEncryptionType *pNegotiatedMCCipher )
4521{
4522 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4523 tANI_U8 cUnicastCyphers = 0;
4524 tANI_U8 cMulticastCyphers = 0;
4525 tANI_U8 cAuthSuites = 0;
4526 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4527 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4528 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4529 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4530 tANI_U8 i;
4531 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4532
4533 do
4534 {
4535 if ( pWpaIe->present )
4536 {
4537 cMulticastCyphers = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304538 vos_mem_copy(MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4540 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4541
4542 //Check - Is requested Unicast Cipher supported by the BSS.
4543 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4544 csrGetOUIIndexFromCipher( enType ), Unicast );
4545
4546 if( !fAcceptableCyphers ) break;
4547
4548
4549 //Unicast is supported. Pick the first matching Group cipher, if any.
4550 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4551 {
4552 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4553 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4554 if(fAcceptableCyphers)
4555 {
4556 break;
4557 }
4558 }
4559 if( !fAcceptableCyphers ) break;
4560
4561 if( pNegotiatedMCCipher )
4562 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4563
4564 /* Initializing with FALSE as it has TRUE value already */
4565 fAcceptableCyphers = FALSE;
4566 for (i = 0 ; i < pAuthType->numEntries; i++)
4567 {
4568 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4569 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4570 {
4571 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4572 negAuthType = eCSR_AUTH_TYPE_WPA;
4573 }
4574 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4575 {
4576 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4577 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4578 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004579#ifdef FEATURE_WLAN_ESE
4580 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 {
4582 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4583 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4584 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004585#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004586
4587 // The 1st auth type in the APs WPA IE, to match stations connecting
4588 // profiles auth type will cause us to exit this loop
4589 // This is added as some APs advertise multiple akms in the WPA IE.
4590 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4591 {
4592 fAcceptableCyphers = TRUE;
4593 break;
4594 }
4595 } // for
4596 }
4597 }while(0);
4598
4599 if ( fAcceptableCyphers )
4600 {
4601 if ( MulticastCypher )
4602 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304603 vos_mem_copy((tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 }
4605
4606 if ( UnicastCypher )
4607 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304608 vos_mem_copy((tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 }
4610
4611 if ( AuthSuite )
4612 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304613 vos_mem_copy((tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 }
4615
4616 if( pNegotiatedAuthtype )
4617 {
4618 *pNegotiatedAuthtype = negAuthType;
4619 }
4620 }
4621
4622 return( fAcceptableCyphers );
4623}
4624
4625
4626
4627tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4628 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4629{
4630 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4631
4632 // See if the cyphers in the Bss description match with the settings in the profile.
4633 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4634
4635 return( fWpaMatch );
4636}
4637
4638
4639tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4640 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4641{
4642 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4643 tANI_BOOLEAN fWpaMatch;
4644 tANI_U8 cbWpaIe = 0;
4645 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4646 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4647 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4648 tCsrWpaAuthIe *pAuthSuite;
4649 tDot11fBeaconIEs *pIesLocal = pIes;
4650
4651 do
4652 {
4653 if ( !csrIsProfileWpa( pProfile ) ) break;
4654
4655 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4656 {
4657 break;
4658 }
4659 // See if the cyphers in the Bss description match with the settings in the profile.
4660 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4661 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4662 if ( !fWpaMatch ) break;
4663
4664 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4665
Kiet Lam64c1b492013-07-12 13:56:44 +05304666 vos_mem_copy(pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004667
4668 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4669
Kiet Lam64c1b492013-07-12 13:56:44 +05304670 vos_mem_copy(pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004671
4672 pWpaIe->cUnicastCyphers = 1;
4673
Kiet Lam64c1b492013-07-12 13:56:44 +05304674 vos_mem_copy(&pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004675
4676 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4677
4678 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304679 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004680
4681 // The WPA capabilities follows the Auth Suite (two octects)--
4682 // this field is optional, and we always "send" zero, so just
4683 // remove it. This is consistent with our assumptions in the
4684 // frames compiler; c.f. bug 15234:
4685 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4686
4687 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4688 // Add in the size of the Auth suite (count plus a single OUI)
4689 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4690 sizeof( *pAuthSuite );
4691
4692 // return the size of the IE header (total) constructed...
4693 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4694
4695 } while( 0 );
4696
4697 if( !pIes && pIesLocal )
4698 {
4699 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304700 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 }
4702
4703 return( cbWpaIe );
4704}
4705
4706
4707tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4708 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4709{
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 tDot11IEHeader *pIEHeader;
4711 tSirMacPropIE *pSirMacPropIE;
4712 tANI_U32 cbParsed;
4713 tANI_U32 cbIE;
4714 int cExpectedIEs = 0;
4715 int cFoundIEs = 0;
4716 int cbPropIETotal;
4717
4718 pIEHeader = (tDot11IEHeader *)pIes;
4719 if(pWpaIe) cExpectedIEs++;
4720 if(pRSNIe) cExpectedIEs++;
4721
4722 // bss description length includes all fields other than the length itself
4723 cbParsed = 0;
4724
4725 // Loop as long as there is data left in the IE of the Bss Description
4726 // and the number of Expected IEs is NOT found yet.
4727 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4728 {
4729 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4730
4731 if ( ( cbIE + cbParsed ) > len ) break;
4732
4733 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4734 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4735 {
4736 switch( pIEHeader->ElementID )
4737 {
4738 // Parse the 221 (0xdd) Proprietary IEs here...
4739 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4740 // Airgo proprietary IE information.
4741 case SIR_MAC_WPA_EID:
4742 {
4743 tANI_U32 aniOUI;
4744 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4745
4746 pOui++;
4747 aniOUI = ANI_OUI;
4748 aniOUI = i_ntohl( aniOUI );
4749
4750 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4751 cbPropIETotal = pSirMacPropIE->length;
4752
4753 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4754 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4755 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4756 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4757 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4758 {
4759 }
4760 else
4761 {
4762 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4763
4764 if(!pWpaIe || !pcbWpaIe) break;
4765 // Check if this is a valid WPA IE. Then check that the
4766 // WPA OUI is in place and the version is one that we support.
4767 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
Kiet Lam64c1b492013-07-12 13:56:44 +05304768 ( vos_mem_compare( pIe->Oui, (void *)csrWpaOui[1],
4769 sizeof( pIe->Oui ) ) ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4771 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304772 vos_mem_copy(pWpaIe, pIe,
4773 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004774 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4775 cFoundIEs++;
4776
4777 break;
4778 }
4779 }
4780
4781 break;
4782 }
4783
4784 case SIR_MAC_RSN_EID:
4785 {
4786 tCsrRSNIe *pIe;
4787
4788 if(!pcbRSNIe || !pRSNIe) break;
4789 pIe = (tCsrRSNIe *)pIEHeader;
4790
4791 // Check the length of the RSN Ie to assure it is valid. Then check that the
4792 // version is one that we support.
4793
4794 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4795 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4796
4797 cFoundIEs++;
4798
4799 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4800 // the buffer passed in.
4801 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05304802 vos_mem_copy(pRSNIe, pIe,
4803 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4805
4806 break;
4807 }
4808
4809 // Add support for other IE here...
4810 default:
4811 break;
4812 }
4813 }
4814
4815 cbParsed += cbIE;
4816
4817 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4818
4819 }
4820
4821 // return a BOOL that tells if all of the IEs asked for were found...
4822 return( cFoundIEs == cExpectedIEs );
4823}
4824
4825
4826//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4827//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4828tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4829 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4830{
4831 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4832 tANI_U8 cbWpaIe = 0;
4833
4834 do
4835 {
4836 if ( !csrIsProfileWpa( pProfile ) ) break;
4837 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4838 {
4839 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4840 {
4841 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304842 vos_mem_copy(pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 }
4844 else
4845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004846 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 }
4848 }
4849 else
4850 {
4851 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4852 }
4853 }while(0);
4854
4855 return (cbWpaIe);
4856}
4857
4858
4859//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4860//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4861tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4862 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4863{
4864 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4865 tANI_U8 cbRsnIe = 0;
4866
4867 do
4868 {
4869 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004870#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304871 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004872 {
4873 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4874 // scratch. So it contains the current PMK-IDs
4875 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4876 }
4877 else
4878#endif
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304879 if(pProfile->force_rsne_override &&
4880 pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 {
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304882 smsLog(pMac, LOGW, "force_rsne_override, copy RSN IE provided by user");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004883 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4885 {
4886 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304887 vos_mem_copy(pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 }
4889 else
4890 {
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304891 smsLog(pMac, LOGW, "csrRetrieveRsnIe detect invalid RSN IE length (%d)",
4892 pProfile->nRSNReqIELength);
4893 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 }
4895 }
4896 else
4897 {
4898 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4899 }
4900 }while(0);
4901
4902 return (cbRsnIe);
4903}
4904
4905
4906#ifdef FEATURE_WLAN_WAPI
4907//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
4908//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
4909tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
4910 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4911 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4912{
4913 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4914 tANI_U8 cbWapiIe = 0;
4915
4916 do
4917 {
4918 if ( !csrIsProfileWapi( pProfile ) ) break;
4919 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
4920 {
4921 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
4922 {
4923 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304924 vos_mem_copy(pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 }
4926 else
4927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004928 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 }
4930 }
4931 else
4932 {
4933 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
4934 }
4935 }while(0);
4936
4937 return (cbWapiIe);
4938}
4939#endif /* FEATURE_WLAN_WAPI */
4940
4941tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
4942{
4943 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4944 tListElem *pEntry;
4945 tANI_U16 i;
4946 tANI_U16 startingChannel;
4947 tANI_BOOLEAN found = FALSE;
4948 tCsrChannelSet *pChannelGroup;
4949
4950 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
4951
4952 while ( pEntry )
4953 {
4954 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
4955 startingChannel = pChannelGroup->firstChannel;
4956 for ( i = 0; i < pChannelGroup->numChannels; i++ )
4957 {
4958 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
4959 {
4960 found = TRUE;
4961 break;
4962 }
4963 }
4964
4965 if ( found )
4966 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304967 vos_mem_copy(returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 break;
4969 }
4970 else
4971 {
4972 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
4973 }
4974 }
4975
4976 return( found );
4977}
4978
4979tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
4980{
4981 tANI_BOOLEAN fSupported = FALSE;
4982 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4983
4984 switch ( nonBasicRate )
4985 {
4986 case eCsrSuppRate_1Mbps:
4987 case eCsrSuppRate_2Mbps:
4988 case eCsrSuppRate_5_5Mbps:
4989 case eCsrSuppRate_11Mbps:
4990 fSupported = TRUE;
4991 break;
4992
4993 default:
4994 break;
4995 }
4996
4997 return( fSupported );
4998}
4999
5000tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
5001{
5002 tANI_BOOLEAN fSupported = FALSE;
5003 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
5004
5005 switch ( nonBasicRate )
5006 {
5007 case eCsrSuppRate_6Mbps:
5008 case eCsrSuppRate_9Mbps:
5009 case eCsrSuppRate_12Mbps:
5010 case eCsrSuppRate_18Mbps:
5011 case eCsrSuppRate_24Mbps:
5012 case eCsrSuppRate_36Mbps:
5013 case eCsrSuppRate_48Mbps:
5014 case eCsrSuppRate_54Mbps:
5015 fSupported = TRUE;
5016 break;
5017
5018 default:
5019 break;
5020 }
5021
5022 return( fSupported );
5023}
5024
5025
5026
5027tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
5028{
5029 tAniEdType edType;
5030
5031 switch ( EncryptType )
5032 {
5033 default:
5034 case eCSR_ENCRYPT_TYPE_NONE:
5035 edType = eSIR_ED_NONE;
5036 break;
5037
5038 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5039 case eCSR_ENCRYPT_TYPE_WEP40:
5040 edType = eSIR_ED_WEP40;
5041 break;
5042
5043 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5044 case eCSR_ENCRYPT_TYPE_WEP104:
5045 edType = eSIR_ED_WEP104;
5046 break;
5047
5048 case eCSR_ENCRYPT_TYPE_TKIP:
5049 edType = eSIR_ED_TKIP;
5050 break;
5051
5052 case eCSR_ENCRYPT_TYPE_AES:
5053 edType = eSIR_ED_CCMP;
5054 break;
5055#ifdef FEATURE_WLAN_WAPI
5056 case eCSR_ENCRYPT_TYPE_WPI:
5057 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05305058 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005059#endif
5060#ifdef WLAN_FEATURE_11W
5061 //11w BIP
5062 case eCSR_ENCRYPT_TYPE_AES_CMAC:
5063 edType = eSIR_ED_AES_128_CMAC;
5064 break;
5065#endif
5066 }
5067
5068 return( edType );
5069}
5070
5071
5072//pIes can be NULL
5073tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
5074 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
5075 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
5076 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
5077{
5078 tANI_U32 idx;
5079 tANI_BOOLEAN fMatch = FALSE;
5080 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5081 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
5082
5083 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
5084
5085 do
5086 {
5087 //If privacy bit is not set, consider no match
5088 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
5089
5090 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
5091 {
5092 switch( pMCEncryptionList->encryptionType[idx] )
5093 {
5094 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5095 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5096 case eCSR_ENCRYPT_TYPE_WEP40:
5097 case eCSR_ENCRYPT_TYPE_WEP104:
5098 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
5099 */
5100 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
5101 {
5102 fMatch = TRUE;
5103 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
5104 }
5105 break;
5106 default:
5107 fMatch = FALSE;
5108 break;
5109 }
5110 if(fMatch) break;
5111 }
5112
5113 if(!fMatch) break;
5114
5115 for( idx = 0; idx < pAuthList->numEntries; idx++ )
5116 {
5117 switch( pAuthList->authType[idx] )
5118 {
5119 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5120 case eCSR_AUTH_TYPE_SHARED_KEY:
5121 case eCSR_AUTH_TYPE_AUTOSWITCH:
5122 fMatch = TRUE;
5123 negotiatedAuth = pAuthList->authType[idx];
5124 break;
5125 default:
5126 fMatch = FALSE;
5127 }
5128 if (fMatch) break;
5129 }
5130
5131 if(!fMatch) break;
5132 //In case of WPA / WPA2, check whether it supports WEP as well
5133 if(pIes)
5134 {
5135 //Prepare the encryption type for WPA/WPA2 functions
5136 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
5137 {
5138 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
5139 }
5140 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
5141 {
5142 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5143 }
5144 //else we can use the encryption type directly
Kiet Lam64c1b492013-07-12 13:56:44 +05305145 if ( pIes->WPA.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305147 fMatch = vos_mem_compare(pIes->WPA.multicast_cipher,
5148 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
5149 CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 if( fMatch ) break;
5151 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305152 if ( pIes->RSN.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305154 fMatch = vos_mem_compare(pIes->RSN.gp_cipher_suite,
5155 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
5156 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 }
5158 }
5159
5160 }while(0);
5161
5162 if( fMatch )
5163 {
5164 if( pNegotiatedAuthType )
5165 *pNegotiatedAuthType = negotiatedAuth;
5166
5167 if( pNegotiatedMCEncryption )
5168 *pNegotiatedMCEncryption = negotiatedMCCipher;
5169 }
5170
5171
5172 return fMatch;
5173}
5174
5175
5176//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305177tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType,
5178 tCsrEncryptionList *pUCEncryptionType,
5179 tCsrEncryptionList *pMCEncryptionType,
5180 tANI_BOOLEAN *pMFPEnabled,
5181 tANI_U8 *pMFPRequired, tANI_U8 *pMFPCapable,
5182 tSirBssDescription *pSirBssDesc,
5183 tDot11fBeaconIEs *pIes,
5184 eCsrAuthType *negotiatedAuthtype,
5185 eCsrEncryptionType *negotiatedUCCipher,
5186 eCsrEncryptionType *negotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07005187{
5188 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5189 tANI_BOOLEAN fMatch = FALSE;
5190 tANI_U8 i,idx;
5191 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
5192 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
5193
5194 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
5195 {
5196 ucCipher = pUCEncryptionType->encryptionType[i];
5197 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
5198 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
5199 // encryption type.
5200 switch ( ucCipher )
5201 {
5202 case eCSR_ENCRYPT_TYPE_NONE:
5203 {
5204 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
5205 // required so we have to reject this Bss.
5206 if ( csrIsPrivacy( pSirBssDesc ) )
5207 {
5208 fMatch = FALSE;
5209 }
5210 else
5211 {
5212 fMatch = TRUE;
5213 }
5214
5215 if ( fMatch )
5216 {
5217 fMatch = FALSE;
5218 //Check Multicast cipher requested and Auth type requested.
5219 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
5220 {
5221 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
5222 {
5223 fMatch = TRUE; //Multicast can only be none.
5224 mcCipher = pMCEncryptionType->encryptionType[idx];
5225 break;
5226 }
5227 }
5228 if (!fMatch) break;
5229
5230 fMatch = FALSE;
5231 //Check Auth list. It should contain AuthOpen.
5232 for( idx = 0 ; idx < authType->numEntries ; idx++ )
5233 {
5234 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
5235 {
5236 fMatch = TRUE;
5237 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5238 break;
5239 }
5240 }
5241 if (!fMatch) break;
5242
5243 }
5244 break;
5245 }
5246
5247 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5248 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5249 // !! might want to check for WEP keys set in the Profile.... ?
5250 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
5251 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
5252 // encryption is not allowed without the Privacy bit turned on.
5253 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5254
5255 break;
5256
5257 // these are all of the WPA encryption types...
5258 case eCSR_ENCRYPT_TYPE_WEP40:
5259 case eCSR_ENCRYPT_TYPE_WEP104:
5260 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5261 break;
5262
5263 case eCSR_ENCRYPT_TYPE_TKIP:
5264 case eCSR_ENCRYPT_TYPE_AES:
5265 {
5266 if(pIes)
5267 {
5268 // First check if there is a RSN match
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305269 fMatch = csrIsRSNMatch( pMac, authType, ucCipher,
5270 pMCEncryptionType, pMFPEnabled,
5271 pMFPRequired, pMFPCapable,
5272 pIes, &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 if( !fMatch )
5274 {
5275 // If not RSN, then check if there is a WPA match
5276 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
5277 &negAuthType, &mcCipher );
5278 }
5279 }
5280 else
5281 {
5282 fMatch = FALSE;
5283 }
5284 break;
5285 }
5286#ifdef FEATURE_WLAN_WAPI
5287 case eCSR_ENCRYPT_TYPE_WPI://WAPI
5288 {
5289 if(pIes)
5290 {
5291 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5292 }
5293 else
5294 {
5295 fMatch = FALSE;
5296 }
5297 break;
5298 }
5299#endif /* FEATURE_WLAN_WAPI */
5300 case eCSR_ENCRYPT_TYPE_ANY:
5301 default:
5302 {
5303 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
5304
5305 fMatch = eANI_BOOLEAN_TRUE;
5306 //It is allowed to match anything. Try the more secured ones first.
5307 if(pIes)
5308 {
5309 //Check AES first
5310 ucCipher = eCSR_ENCRYPT_TYPE_AES;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305311 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5312 pMCEncryptionType, pMFPEnabled,
5313 pMFPRequired, pMFPCapable, pIes,
5314 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 if(!fMatchAny)
5316 {
5317 //Check TKIP
5318 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305319 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5320 pMCEncryptionType,
5321 pMFPEnabled, pMFPRequired,
5322 pMFPCapable, pIes,
5323 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 }
5325#ifdef FEATURE_WLAN_WAPI
5326 if(!fMatchAny)
5327 {
5328 //Check WAPI
5329 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
5330 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5331 }
5332#endif /* FEATURE_WLAN_WAPI */
5333 }
5334 if(!fMatchAny)
5335 {
5336 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
5337 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5338 {
5339 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
5340 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5341 {
5342 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5343 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5344 {
5345 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5346 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5347 {
5348 //It must be open and no encryption
5349 if ( csrIsPrivacy( pSirBssDesc ) )
5350 {
5351 //This is not right
5352 fMatch = eANI_BOOLEAN_FALSE;
5353 }
5354 else
5355 {
5356 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5357 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
5358 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
5359 }
5360 }
5361 }
5362 }
5363 }
5364 }
5365 break;
5366 }
5367 }
5368
5369 }
5370
5371 if( fMatch )
5372 {
5373 if( negotiatedUCCipher )
5374 *negotiatedUCCipher = ucCipher;
5375
5376 if( negotiatedMCCipher )
5377 *negotiatedMCCipher = mcCipher;
5378
5379 if( negotiatedAuthtype )
5380 *negotiatedAuthtype = negAuthType;
5381 }
5382
5383 return( fMatch );
5384}
5385
5386
5387tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
5388 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
5389{
5390 tANI_BOOLEAN fMatch = FALSE;
5391
5392 do {
Padma, Santhosh Kumara43e06c2015-05-21 14:58:13 +05305393 // Check for the specification of the Broadcast SSID at the beginning
5394 // of the list. If specified, then all SSIDs are matches
5395 // (broadcast SSID means accept all SSIDs).
5396 if ( ssid1Len == 0 )
5397 {
5398 fMatch = TRUE;
5399 break;
5400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005401
5402 // There are a few special cases. If the Bss description has a Broadcast SSID,
5403 // then our Profile must have a single SSID without Wildcards so we can program
5404 // the SSID.
5405 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5406 // but the SSID value is all NULL characters. That condition is trated same
5407 // as NULL SSID
5408 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5409 {
5410 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5411 {
5412 fMatch = TRUE;
5413 }
5414 break;
5415 }
5416
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 if(ssid1Len != bssSsidLen) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05305418 if (vos_mem_compare(bssSsid, ssid1, bssSsidLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 {
5420 fMatch = TRUE;
5421 break;
5422 }
5423
5424 } while( 0 );
5425
5426 return( fMatch );
5427}
5428
5429
5430//Null ssid means match
5431tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5432{
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 tANI_BOOLEAN fMatch = FALSE;
5434 tANI_U32 i;
5435
5436 if ( pSsidList && pSsid )
5437 {
5438 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5439 {
5440 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
Kiet Lam64c1b492013-07-12 13:56:44 +05305441 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5442 vos_mem_compare(pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 {
5444 fMatch = TRUE;
5445 break;
5446 }
5447 }
5448 }
5449
5450 return (fMatch);
5451}
5452
5453//like to use sirCompareMacAddr
5454tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5455{
5456 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5457
Kiet Lam64c1b492013-07-12 13:56:44 +05305458 return (vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005459}
5460
5461//like to use sirCompareMacAddr
5462tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5463{
5464 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5465
Kiet Lam64c1b492013-07-12 13:56:44 +05305466 return(vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005467}
5468
5469
5470//like to use sirCompareMacAddr
5471tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5472{
Kiet Lam64c1b492013-07-12 13:56:44 +05305473 return(vos_mem_compare(pMacAddr1, pMacAddr2, sizeof(tCsrBssid)));
Jeff Johnson295189b2012-06-20 16:38:30 -07005474}
5475
5476
5477tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5478{
5479 tANI_BOOLEAN fMatch = FALSE;
5480 tCsrBssid ProfileBssid;
5481 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5482
5483 // for efficiency of the MAC_ADDRESS functions, move the
5484 // Bssid's into MAC_ADDRESS structs.
Kiet Lam64c1b492013-07-12 13:56:44 +05305485 vos_mem_copy(&ProfileBssid, pProfBssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005486
5487 do {
5488
5489 // Give the profile the benefit of the doubt... accept either all 0 or
5490 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5491 // match any Bssids).
5492 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5493 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5494 {
5495 fMatch = TRUE;
5496 break;
5497 }
5498
5499 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5500 {
5501 fMatch = TRUE;
5502 break;
5503 }
5504
5505 } while( 0 );
5506
5507 return( fMatch );
5508}
5509
5510
5511tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5512{
5513 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5514 return eANI_BOOLEAN_FALSE;
5515 else
5516 return eANI_BOOLEAN_TRUE;
5517}
5518
5519
5520tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5521{
5522 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5523}
5524
5525tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5526{
5527 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5528}
5529
5530tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5531{
5532 tANI_BOOLEAN fMatch = TRUE;
5533
5534 do
5535 {
5536 switch( bssType )
5537 {
5538 case eCSR_BSS_TYPE_ANY:
5539 break;
5540
5541 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5542 case eCSR_BSS_TYPE_WDS_STA:
5543 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5544 fMatch = FALSE;
5545
5546 break;
5547
5548 case eCSR_BSS_TYPE_IBSS:
5549 case eCSR_BSS_TYPE_START_IBSS:
5550 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5551 fMatch = FALSE;
5552
5553 break;
5554
5555 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5556 default:
5557 fMatch = FALSE;
5558 break;
5559 }
5560 }
5561 while( 0 );
5562
5563
5564 return( fMatch );
5565}
5566
5567static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5568{
5569 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5570}
5571
5572
5573
5574static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5575{
5576 tANI_BOOLEAN fMatch = TRUE;
5577
5578 do
5579 {
5580 // if the channel is ANY, then always match...
5581 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5582 if ( Channel == pSirBssDesc->channelId ) break;
5583
5584 // didn't match anything.. so return NO match
5585 fMatch = FALSE;
5586
5587 } while( 0 );
5588
5589 return( fMatch );
5590}
5591
5592
5593tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5594{
5595 tANI_BOOLEAN fMatch = TRUE;
5596
5597 do
5598 {
5599 // if the profile says Any channel AND the global settings says ANY channel, then we
5600 // always match...
5601 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5602
5603 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5604 {
5605 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5606 }
5607
5608 } while( 0 );
5609
5610 return( fMatch );
5611}
5612
5613
5614/**
5615 * \brief Enquire as to whether a given rate is supported by the
5616 * adapter as currently configured
5617 *
5618 *
5619 * \param nRate A rate in units of 500kbps
5620 *
5621 * \return TRUE if the adapter is currently capable of supporting this
5622 * rate, FALSE else
5623 *
5624 *
5625 * The rate encoding is just as in 802.11 Information Elements, except
5626 * that the high bit is \em not interpreted as indicating a Basic Rate,
5627 * and proprietary rates are allowed, too.
5628 *
5629 * Note that if the adapter's dot11Mode is g, we don't restrict the
5630 * rates. According to hwReadEepromParameters, this will happen when:
5631 *
5632 * ... the card is configured for ALL bands through the property
5633 * page. If this occurs, and the card is not an ABG card ,then this
5634 * code is setting the dot11Mode to assume the mode that the
5635 * hardware can support. For example, if the card is an 11BG card
5636 * and we are configured to support ALL bands, then we change the
5637 * dot11Mode to 11g because ALL in this case is only what the
5638 * hardware can support.
5639 *
5640 *
5641 */
5642
5643static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5644{
5645 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5646 tANI_U16 idx, newRate;
5647
5648 //In case basic rate flag is set
5649 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5650 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5651 {
5652 switch ( newRate )
5653 {
5654 case eCsrSuppRate_6Mbps:
5655 case eCsrSuppRate_9Mbps:
5656 case eCsrSuppRate_12Mbps:
5657 case eCsrSuppRate_18Mbps:
5658 case eCsrSuppRate_24Mbps:
5659 case eCsrSuppRate_36Mbps:
5660 case eCsrSuppRate_48Mbps:
5661 case eCsrSuppRate_54Mbps:
5662 fSupported = TRUE;
5663 break;
5664 default:
5665 fSupported = FALSE;
5666 break;
5667 }
5668
5669 }
5670 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5671 {
5672 switch ( newRate )
5673 {
5674 case eCsrSuppRate_1Mbps:
5675 case eCsrSuppRate_2Mbps:
5676 case eCsrSuppRate_5_5Mbps:
5677 case eCsrSuppRate_11Mbps:
5678 fSupported = TRUE;
5679 break;
5680 default:
5681 fSupported = FALSE;
5682 break;
5683 }
5684 }
5685 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5686 {
5687
5688 switch ( newRate )
5689 {
5690 case eCsrSuppRate_1Mbps:
5691 case eCsrSuppRate_2Mbps:
5692 case eCsrSuppRate_5_5Mbps:
5693 case eCsrSuppRate_6Mbps:
5694 case eCsrSuppRate_9Mbps:
5695 case eCsrSuppRate_11Mbps:
5696 case eCsrSuppRate_12Mbps:
5697 case eCsrSuppRate_18Mbps:
5698 case eCsrSuppRate_24Mbps:
5699 case eCsrSuppRate_36Mbps:
5700 case eCsrSuppRate_48Mbps:
5701 case eCsrSuppRate_54Mbps:
5702 fSupported = TRUE;
5703 break;
5704 default:
5705 fSupported = FALSE;
5706 break;
5707 }
5708
5709 }
5710 else {
5711
5712 if ( eCsrSuppRate_1Mbps == newRate ||
5713 eCsrSuppRate_2Mbps == newRate ||
5714 eCsrSuppRate_5_5Mbps == newRate ||
5715 eCsrSuppRate_11Mbps == newRate )
5716 {
5717 fSupported = TRUE;
5718 }
5719 else {
5720 idx = 0x1;
5721
5722 switch ( newRate )
5723 {
5724 case eCsrSuppRate_6Mbps:
5725 fSupported = gPhyRatesSuppt[0][idx];
5726 break;
5727 case eCsrSuppRate_9Mbps:
5728 fSupported = gPhyRatesSuppt[1][idx];
5729 break;
5730 case eCsrSuppRate_12Mbps:
5731 fSupported = gPhyRatesSuppt[2][idx];
5732 break;
5733 case eCsrSuppRate_18Mbps:
5734 fSupported = gPhyRatesSuppt[3][idx];
5735 break;
5736 case eCsrSuppRate_20Mbps:
5737 fSupported = gPhyRatesSuppt[4][idx];
5738 break;
5739 case eCsrSuppRate_24Mbps:
5740 fSupported = gPhyRatesSuppt[5][idx];
5741 break;
5742 case eCsrSuppRate_36Mbps:
5743 fSupported = gPhyRatesSuppt[6][idx];
5744 break;
5745 case eCsrSuppRate_40Mbps:
5746 fSupported = gPhyRatesSuppt[7][idx];
5747 break;
5748 case eCsrSuppRate_42Mbps:
5749 fSupported = gPhyRatesSuppt[8][idx];
5750 break;
5751 case eCsrSuppRate_48Mbps:
5752 fSupported = gPhyRatesSuppt[9][idx];
5753 break;
5754 case eCsrSuppRate_54Mbps:
5755 fSupported = gPhyRatesSuppt[10][idx];
5756 break;
5757 case eCsrSuppRate_72Mbps:
5758 fSupported = gPhyRatesSuppt[11][idx];
5759 break;
5760 case eCsrSuppRate_80Mbps:
5761 fSupported = gPhyRatesSuppt[12][idx];
5762 break;
5763 case eCsrSuppRate_84Mbps:
5764 fSupported = gPhyRatesSuppt[13][idx];
5765 break;
5766 case eCsrSuppRate_96Mbps:
5767 fSupported = gPhyRatesSuppt[14][idx];
5768 break;
5769 case eCsrSuppRate_108Mbps:
5770 fSupported = gPhyRatesSuppt[15][idx];
5771 break;
5772 case eCsrSuppRate_120Mbps:
5773 fSupported = gPhyRatesSuppt[16][idx];
5774 break;
5775 case eCsrSuppRate_126Mbps:
5776 fSupported = gPhyRatesSuppt[17][idx];
5777 break;
5778 case eCsrSuppRate_144Mbps:
5779 fSupported = gPhyRatesSuppt[18][idx];
5780 break;
5781 case eCsrSuppRate_160Mbps:
5782 fSupported = gPhyRatesSuppt[19][idx];
5783 break;
5784 case eCsrSuppRate_168Mbps:
5785 fSupported = gPhyRatesSuppt[20][idx];
5786 break;
5787 case eCsrSuppRate_192Mbps:
5788 fSupported = gPhyRatesSuppt[21][idx];
5789 break;
5790 case eCsrSuppRate_216Mbps:
5791 fSupported = gPhyRatesSuppt[22][idx];
5792 break;
5793 case eCsrSuppRate_240Mbps:
5794 fSupported = gPhyRatesSuppt[23][idx];
5795 break;
5796 default:
5797 fSupported = FALSE;
5798 break;
5799 }
5800 }
5801 }
5802
5803 return fSupported;
5804}
5805
5806
5807
5808static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5809 tDot11fIESuppRates *pBssSuppRates,
5810 tDot11fIEExtSuppRates *pBssExtSuppRates )
5811{
5812 tANI_BOOLEAN fMatch = TRUE;
5813 tANI_U32 i;
5814
5815
5816 // Validate that all of the Basic rates advertised in the Bss description are supported.
5817 if ( pBssSuppRates )
5818 {
5819 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5820 {
5821 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5822 {
5823 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5824 {
5825 fMatch = FALSE;
5826 break;
5827 }
5828 }
5829 }
5830 }
5831
5832 if ( fMatch && pBssExtSuppRates )
5833 {
5834 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5835 {
5836 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5837 {
5838 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5839 {
5840 fMatch = FALSE;
5841 break;
5842 }
5843 }
5844 }
5845 }
5846
5847 return( fMatch );
5848
5849}
5850
Pragaspathi Thilagaraje548fab2018-06-22 11:55:55 +05305851/**
5852 * csr_match_security() - wrapper to check if the security is matching
5853 * @mac_ctx: mac context
5854 * @filter: scan filter
5855 * @bss_desc: BSS Descriptor
5856 * @ies_ptr: Pointer to the IE fields
5857 * @neg_auth_type: Negotiated Auth type with the AP
5858 * @neg_uc_cipher: Negotiated unicast cipher suite
5859 * @neg_mc_cipher: Negotiated multicast cipher
5860 *
5861 * Return: true if matched else false.
5862 */
5863#ifdef WLAN_FEATURE_11W
5864static inline bool csr_match_security(tpAniSirGlobal pMac,
5865 tCsrScanResultFilter *filter, tSirBssDescription *bss_desc,
5866 tDot11fBeaconIEs *ies_ptr, eCsrAuthType *neg_auth,
5867 eCsrEncryptionType *neg_uc,
5868 eCsrEncryptionType *neg_mc)
5869{
5870
5871 if (!filter)
5872 return false;
5873
5874 if (filter->bWPSAssociation || filter->bOSENAssociation)
5875 return true;
5876
5877 if (filter->ignore_pmf_cap)
5878 return csrIsSecurityMatch(pMac, &filter->authType,
5879 &filter->EncryptionType,
5880 &filter->mcEncryptionType,
5881 NULL, NULL, NULL,
5882 bss_desc, ies_ptr, neg_auth,
5883 neg_uc, neg_mc);
5884 else
5885 return csrIsSecurityMatch(pMac, &filter->authType,
5886 &filter->EncryptionType,
5887 &filter->mcEncryptionType,
5888 &filter->MFPEnabled,
5889 &filter->MFPRequired,
5890 &filter->MFPCapable,
5891 bss_desc, ies_ptr, neg_auth,
5892 neg_uc, neg_mc);
5893
5894}
5895#else
5896static inline bool csr_match_security(tpAniSirGlobal mac_ctx,
5897 tCsrScanResultFilter *filter, tSirBssDescription *bss_desc,
5898 tDot11fBeaconIEs *ies_ptr, eCsrAuthType *neg_auth,
5899 eCsrEncryptionType *neg_uc,
5900 eCsrEncryptionType *neg_mc)
5901
5902{
5903 if (!filter)
5904 return false;
5905
5906 if (filter->bWPSAssociation || filter->bOSENAssociation)
5907 return true;
5908
5909 return csrIsSecurityMatch(mac_ctx, &filter->authType,
5910 &filter->EncryptionType,
5911 &filter->mcEncryptionType,
5912 NULL, NULL, NULL,
5913 bss_desc, ies_ptr, neg_auth,
5914 neg_uc, neg_mc);
5915}
5916#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005917
5918//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
5919tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
5920 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
5921 tDot11fBeaconIEs **ppIes)
5922{
5923 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5924 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5925 tANI_U32 i;
5926 tDot11fBeaconIEs *pIes = NULL;
5927 tANI_U8 *pb;
5928
5929 do {
5930 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
5931 {
5932 //If no IEs passed in, get our own.
5933 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
5934 {
5935 break;
5936 }
5937 }
5938 else
5939 {
5940 //Save the one pass in for local use
5941 pIes = *ppIes;
5942 }
5943
5944 //Check if caller wants P2P
5945 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
5946 if(!fCheck) break;
5947
5948 if(pIes->SSID.present)
5949 {
5950 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
5951 {
5952 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
5953 pIes->SSID.ssid,
5954 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
5955 if ( fCheck ) break;
5956 }
5957 if(!fCheck) break;
5958 }
5959 fCheck = eANI_BOOLEAN_TRUE;
5960 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
5961 {
5962 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
5963 if ( fCheck ) break;
5964
5965 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
5966 {
5967 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
5968 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
5969
5970 if ( fCheck ) break;
5971 }
5972 }
5973 if(!fCheck) break;
5974
5975 fCheck = eANI_BOOLEAN_TRUE;
5976 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
5977 {
5978 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
5979 if ( fCheck ) break;
5980 }
5981 if(!fCheck)
5982 break;
5983#if defined WLAN_FEATURE_VOWIFI
5984 /* If this is for measurement filtering */
5985 if( pFilter->fMeasurement )
5986 {
5987 fRC = eANI_BOOLEAN_TRUE;
5988 break;
5989 }
5990#endif
5991 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
Pragaspathi Thilagaraje548fab2018-06-22 11:55:55 +05305992 if ( !csr_match_security(pMac, pFilter, pBssDesc, pIes, pNegAuth, pNegUc, pNegMc)) break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
5994 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
5995 //Tush-QoS: validate first if asked for APSD or WMM association
5996 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
5997 !CSR_IS_QOS_BSS(pIes) )
5998 break;
5999 //Check country. check even when pb is NULL because we may want to make sure
6000 //AP has a country code in it if fEnforceCountryCodeMatch is set.
6001 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
6002
6003 fCheck = csrMatchCountryCode( pMac, pb, pIes );
6004 if(!fCheck)
6005 break;
6006
6007#ifdef WLAN_FEATURE_VOWIFI_11R
Hema Aparna Medicharlaf9dec8d2015-04-29 12:37:06 +05306008 if (pFilter->MDID.mdiePresent && csrRoamIs11rAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 {
6010 if (pBssDesc->mdiePresent)
6011 {
6012 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
6013 break;
6014 }
6015 else
6016 break;
6017 }
6018#endif
6019 fRC = eANI_BOOLEAN_TRUE;
6020
6021 } while( 0 );
6022 if( ppIes )
6023 {
6024 *ppIes = pIes;
6025 }
6026 else if( pIes )
6027 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306028 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 }
6030
6031 return( fRC );
6032}
6033
6034tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
6035 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
6036{
6037 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
6038 tCsrAuthList authList;
6039
6040 ucEncryptionList.numEntries = 1;
6041 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
6042
6043 mcEncryptionList.numEntries = 1;
6044 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
6045
6046 authList.numEntries = 1;
6047 authList.authType[0] = pProfile->AuthType;
6048
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05306049 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList,
6050 &mcEncryptionList, NULL, NULL, NULL,
6051 pBssDesc, pIes, NULL, NULL, NULL ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006052
6053}
6054
6055
6056tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
6057 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
6058{
6059 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6060 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
6061 tDot11fBeaconIEs *pIesLocal = pIes;
6062
6063 do {
6064 if( !pIes )
6065 {
6066 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
6067 {
6068 break;
6069 }
6070 }
6071 fCheck = eANI_BOOLEAN_TRUE;
6072 if(pIesLocal->SSID.present)
6073 {
6074 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
6075 if(pProfile->SSID.length)
6076 {
6077 fCheckSsid = eANI_BOOLEAN_TRUE;
6078 }
6079 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
6080 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
6081 if(!fCheck) break;
6082 }
6083 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
6084 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
6085 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
6086 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
6087 if(!fCheck)
6088 break;
6089
6090 fRC = eANI_BOOLEAN_TRUE;
6091
6092 } while( 0 );
6093
6094 if( !pIes && pIesLocal )
6095 {
6096 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05306097 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 }
6099
6100 return( fRC );
6101}
6102
6103
6104
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05306105void csrAddRateBitmap(tANI_U8 rate, tANI_U16 *pRateBitmap)
6106{
6107 tANI_U16 rateBitmap;
6108 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6109 rateBitmap = *pRateBitmap;
6110 switch(n)
6111 {
6112 case SIR_MAC_RATE_1:
6113 rateBitmap |= SIR_MAC_RATE_1_BITMAP;
6114 break;
6115 case SIR_MAC_RATE_2:
6116 rateBitmap |= SIR_MAC_RATE_2_BITMAP;
6117 break;
6118 case SIR_MAC_RATE_5_5:
6119 rateBitmap |= SIR_MAC_RATE_5_5_BITMAP;
6120 break;
6121 case SIR_MAC_RATE_11:
6122 rateBitmap |= SIR_MAC_RATE_11_BITMAP;
6123 break;
6124 case SIR_MAC_RATE_6:
6125 rateBitmap |= SIR_MAC_RATE_6_BITMAP;
6126 break;
6127 case SIR_MAC_RATE_9:
6128 rateBitmap |= SIR_MAC_RATE_9_BITMAP;
6129 break;
6130 case SIR_MAC_RATE_12:
6131 rateBitmap |= SIR_MAC_RATE_12_BITMAP;
6132 break;
6133 case SIR_MAC_RATE_18:
6134 rateBitmap |= SIR_MAC_RATE_18_BITMAP;
6135 break;
6136 case SIR_MAC_RATE_24:
6137 rateBitmap |= SIR_MAC_RATE_24_BITMAP;
6138 break;
6139 case SIR_MAC_RATE_36:
6140 rateBitmap |= SIR_MAC_RATE_36_BITMAP;
6141 break;
6142 case SIR_MAC_RATE_48:
6143 rateBitmap |= SIR_MAC_RATE_48_BITMAP;
6144 break;
6145 case SIR_MAC_RATE_54:
6146 rateBitmap |= SIR_MAC_RATE_54_BITMAP;
6147 break;
6148 }
6149 *pRateBitmap = rateBitmap;
6150}
6151
6152
6153
6154tANI_BOOLEAN csrIsRateAlreadyPresent(tANI_U8 rate, tANI_U16 rateBitmap)
6155{
6156 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6157
6158 switch(n)
6159 {
6160 case SIR_MAC_RATE_1:
6161 rateBitmap &= SIR_MAC_RATE_1_BITMAP;
6162 break;
6163 case SIR_MAC_RATE_2:
6164 rateBitmap &= SIR_MAC_RATE_2_BITMAP;
6165 break;
6166 case SIR_MAC_RATE_5_5:
6167 rateBitmap &= SIR_MAC_RATE_5_5_BITMAP;
6168 break;
6169 case SIR_MAC_RATE_11:
6170 rateBitmap &= SIR_MAC_RATE_11_BITMAP;
6171 break;
6172 case SIR_MAC_RATE_6:
6173 rateBitmap &= SIR_MAC_RATE_6_BITMAP;
6174 break;
6175 case SIR_MAC_RATE_9:
6176 rateBitmap &= SIR_MAC_RATE_9_BITMAP;
6177 break;
6178 case SIR_MAC_RATE_12:
6179 rateBitmap &= SIR_MAC_RATE_12_BITMAP;
6180 break;
6181 case SIR_MAC_RATE_18:
6182 rateBitmap &= SIR_MAC_RATE_18_BITMAP;
6183 break;
6184 case SIR_MAC_RATE_24:
6185 rateBitmap &= SIR_MAC_RATE_24_BITMAP;
6186 break;
6187 case SIR_MAC_RATE_36:
6188 rateBitmap &= SIR_MAC_RATE_36_BITMAP;
6189 break;
6190 case SIR_MAC_RATE_48:
6191 rateBitmap &= SIR_MAC_RATE_48_BITMAP;
6192 break;
6193 case SIR_MAC_RATE_54:
6194 rateBitmap &= SIR_MAC_RATE_54_BITMAP;
6195 break;
6196 }
6197 return !!rateBitmap;
6198}
6199
6200
6201
Jeff Johnson295189b2012-06-20 16:38:30 -07006202tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
6203{
6204 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6205 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6206
6207 return csrIsAggregateRateSupported( pMac, n );
6208}
6209
6210
6211tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
6212{
6213 tANI_U16 ConvertedRate = Rate;
6214
6215 switch( Rate )
6216 {
6217 case SIR_MAC_RATE_1:
6218 ConvertedRate = 2;
6219 break;
6220 case SIR_MAC_RATE_2:
6221 ConvertedRate = 4;
6222 break;
6223 case SIR_MAC_RATE_5_5:
6224 ConvertedRate = 11;
6225 break;
6226 case SIR_MAC_RATE_11:
6227 ConvertedRate = 22;
6228 break;
6229
6230 case SIR_MAC_RATE_6:
6231 ConvertedRate = 12;
6232 break;
6233 case SIR_MAC_RATE_9:
6234 ConvertedRate = 18;
6235 break;
6236 case SIR_MAC_RATE_12:
6237 ConvertedRate = 24;
6238 break;
6239 case SIR_MAC_RATE_18:
6240 ConvertedRate = 36;
6241 break;
6242 case SIR_MAC_RATE_24:
6243 ConvertedRate = 48;
6244 break;
6245 case SIR_MAC_RATE_36:
6246 ConvertedRate = 72;
6247 break;
6248 case SIR_MAC_RATE_42:
6249 ConvertedRate = 84;
6250 break;
6251 case SIR_MAC_RATE_48:
6252 ConvertedRate = 96;
6253 break;
6254 case SIR_MAC_RATE_54:
6255 ConvertedRate = 108;
6256 break;
6257
6258 case SIR_MAC_RATE_72:
6259 ConvertedRate = 144;
6260 break;
6261 case SIR_MAC_RATE_84:
6262 ConvertedRate = 168;
6263 break;
6264 case SIR_MAC_RATE_96:
6265 ConvertedRate = 192;
6266 break;
6267 case SIR_MAC_RATE_108:
6268 ConvertedRate = 216;
6269 break;
6270 case SIR_MAC_RATE_126:
6271 ConvertedRate = 252;
6272 break;
6273 case SIR_MAC_RATE_144:
6274 ConvertedRate = 288;
6275 break;
6276 case SIR_MAC_RATE_168:
6277 ConvertedRate = 336;
6278 break;
6279 case SIR_MAC_RATE_192:
6280 ConvertedRate = 384;
6281 break;
6282 case SIR_MAC_RATE_216:
6283 ConvertedRate = 432;
6284 break;
6285 case SIR_MAC_RATE_240:
6286 ConvertedRate = 480;
6287 break;
6288
6289 case 0xff:
6290 ConvertedRate = 0;
6291 break;
6292 }
6293
6294 return ConvertedRate;
6295}
6296
6297
6298tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
6299{
6300 tANI_U8 i;
6301 tANI_U16 nBest;
6302
6303 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
6304
6305 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
6306 {
6307 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
6308 }
6309
6310 for ( i = 1U; i < pSuppRates->numRates; ++i )
6311 {
6312 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6313 }
6314
6315 if ( NULL != pExtRates )
6316 {
6317 for ( i = 0U; i < pExtRates->numRates; ++i )
6318 {
6319 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6320 }
6321 }
6322
6323 if ( NULL != pPropRates )
6324 {
6325 for ( i = 0U; i < pPropRates->numPropRates; ++i )
6326 {
6327 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
6328 }
6329 }
6330
6331 return nBest;
6332}
6333
6334
6335void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
6336{
6337 if(pProfile)
6338 {
6339 if(pProfile->BSSIDs.bssid)
6340 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306341 vos_mem_free(pProfile->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 pProfile->BSSIDs.bssid = NULL;
6343 }
6344 if(pProfile->SSIDs.SSIDList)
6345 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306346 vos_mem_free(pProfile->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 pProfile->SSIDs.SSIDList = NULL;
6348 }
6349 if(pProfile->pWPAReqIE)
6350 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306351 vos_mem_free(pProfile->pWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 pProfile->pWPAReqIE = NULL;
6353 }
6354 if(pProfile->pRSNReqIE)
6355 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306356 vos_mem_free(pProfile->pRSNReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 pProfile->pRSNReqIE = NULL;
6358 }
6359#ifdef FEATURE_WLAN_WAPI
6360 if(pProfile->pWAPIReqIE)
6361 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306362 vos_mem_free(pProfile->pWAPIReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 pProfile->pWAPIReqIE = NULL;
6364 }
6365#endif /* FEATURE_WLAN_WAPI */
6366
Agarwal Ashish4f616132013-12-30 23:32:50 +05306367 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306369 memset(pProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306370 pProfile->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 }
6372
6373 if(pProfile->pAddIEAssoc)
6374 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306375 vos_mem_free(pProfile->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 pProfile->pAddIEAssoc = NULL;
6377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 if(pProfile->ChannelInfo.ChannelList)
6379 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306380 vos_mem_free(pProfile->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 pProfile->ChannelInfo.ChannelList = NULL;
6382 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306383 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 }
6385}
6386
6387void csrFreeScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
6388{
6389 if(pScanFilter->BSSIDs.bssid)
6390 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306391 vos_mem_free(pScanFilter->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 pScanFilter->BSSIDs.bssid = NULL;
6393 }
6394 if(pScanFilter->ChannelInfo.ChannelList)
6395 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306396 vos_mem_free(pScanFilter->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 pScanFilter->ChannelInfo.ChannelList = NULL;
6398 }
6399 if(pScanFilter->SSIDs.SSIDList)
6400 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306401 vos_mem_free(pScanFilter->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006402 pScanFilter->SSIDs.SSIDList = NULL;
6403 }
6404}
6405
6406
6407void csrFreeRoamProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6408{
6409 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6410
6411 if(pSession->pCurRoamProfile)
6412 {
6413 csrReleaseProfile(pMac, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306414 vos_mem_free(pSession->pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 pSession->pCurRoamProfile = NULL;
6416 }
6417}
6418
6419
6420void csrFreeConnectBssDesc(tpAniSirGlobal pMac, tANI_U32 sessionId)
6421{
6422 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6423
6424 if(pSession->pConnectBssDesc)
6425 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306426 vos_mem_free(pSession->pConnectBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 pSession->pConnectBssDesc = NULL;
6428 }
6429}
6430
6431
6432
6433tSirResultCodes csrGetDisassocRspStatusCode( tSirSmeDisassocRsp *pSmeDisassocRsp )
6434{
6435 tANI_U8 *pBuffer = (tANI_U8 *)pSmeDisassocRsp;
6436 tANI_U32 ret;
6437
6438 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
6439 //tSirResultCodes is an enum, assuming is 32bit
6440 //If we cannot make this assumption, use copymemory
6441 pal_get_U32( pBuffer, &ret );
6442
6443 return( ( tSirResultCodes )ret );
6444}
6445
6446
6447tSirResultCodes csrGetDeAuthRspStatusCode( tSirSmeDeauthRsp *pSmeRsp )
6448{
6449 tANI_U8 *pBuffer = (tANI_U8 *)pSmeRsp;
6450 tANI_U32 ret;
6451
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006452 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tANI_U8) + sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 //tSirResultCodes is an enum, assuming is 32bit
6454 //If we cannot make this assumption, use copymemory
6455 pal_get_U32( pBuffer, &ret );
6456
6457 return( ( tSirResultCodes )ret );
6458}
6459
6460#if 0
6461tSirScanType csrGetScanType(tANI_U8 chnId, eRegDomainId domainId, tANI_U8 *countryCode)
6462{
6463 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6464 tANI_U8 cc = 0;
6465
6466 while (cc++ < gCsrDomainChnInfo[domainId].numChannels)
6467 {
6468 if(chnId == gCsrDomainChnInfo[domainId].chnInfo[cc].chnId)
6469 {
6470 scanType = gCsrDomainChnInfo[domainId].chnInfo[cc].scanType;
6471 break;
6472 }
6473 }
6474
6475 return (scanType);
6476}
6477#endif
6478
6479tSirScanType csrGetScanType(tpAniSirGlobal pMac, tANI_U8 chnId)
6480{
6481 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6482 eNVChannelEnabledType channelEnabledType;
6483
6484 channelEnabledType = vos_nv_getChannelEnabledState(chnId);
6485 if( NV_CHANNEL_ENABLE == channelEnabledType)
6486 {
6487 scanType = eSIR_ACTIVE_SCAN;
6488 }
6489 return (scanType);
6490}
6491
6492
6493tANI_U8 csrToUpper( tANI_U8 ch )
6494{
6495 tANI_U8 chOut;
6496
6497 if ( ch >= 'a' && ch <= 'z' )
6498 {
6499 chOut = ch - 'a' + 'A';
6500 }
6501 else
6502 {
6503 chOut = ch;
6504 }
6505 return( chOut );
6506}
6507
6508
6509tSirBssType csrTranslateBsstypeToMacType(eCsrRoamBssType csrtype)
6510{
6511 tSirBssType ret;
6512
6513 switch(csrtype)
6514 {
6515 case eCSR_BSS_TYPE_INFRASTRUCTURE:
6516 ret = eSIR_INFRASTRUCTURE_MODE;
6517 break;
6518 case eCSR_BSS_TYPE_IBSS:
6519 case eCSR_BSS_TYPE_START_IBSS:
6520 ret = eSIR_IBSS_MODE;
6521 break;
6522 case eCSR_BSS_TYPE_WDS_AP:
6523 ret = eSIR_BTAMP_AP_MODE;
6524 break;
6525 case eCSR_BSS_TYPE_WDS_STA:
6526 ret = eSIR_BTAMP_STA_MODE;
6527 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 case eCSR_BSS_TYPE_INFRA_AP:
6529 ret = eSIR_INFRA_AP_MODE;
6530 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006531 case eCSR_BSS_TYPE_ANY:
6532 default:
6533 ret = eSIR_AUTO_MODE;
6534 break;
6535 }
6536
6537 return (ret);
6538}
6539
6540
6541//This function use the parameters to decide the CFG value.
6542//CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG
6543//So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value
Jeff Johnson295189b2012-06-20 16:38:30 -07006544eCsrCfgDot11Mode csrGetCfgDot11ModeFromCsrPhyMode(tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tANI_BOOLEAN fProprietary)
Jeff Johnson295189b2012-06-20 16:38:30 -07006545{
6546 tANI_U32 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6547
6548 switch(phyMode)
6549 {
6550 case eCSR_DOT11_MODE_11a:
6551 case eCSR_DOT11_MODE_11a_ONLY:
6552 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
6553 break;
6554 case eCSR_DOT11_MODE_11b:
6555 case eCSR_DOT11_MODE_11b_ONLY:
6556 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
6557 break;
6558 case eCSR_DOT11_MODE_11g:
6559 case eCSR_DOT11_MODE_11g_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 if(pProfile && (CSR_IS_INFRA_AP(pProfile)) && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
6561 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
6562 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
6564 break;
6565 case eCSR_DOT11_MODE_11n:
6566 if(fProprietary)
6567 {
6568 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6569 }
6570 else
6571 {
6572 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6573 }
6574 break;
6575 case eCSR_DOT11_MODE_11n_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 if(pProfile && CSR_IS_INFRA_AP(pProfile))
6577 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
6578 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6580 break;
6581 case eCSR_DOT11_MODE_TAURUS:
6582 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6583 break;
6584 case eCSR_DOT11_MODE_abg:
6585 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6586 break;
6587 case eCSR_DOT11_MODE_AUTO:
6588 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
6589 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07006590
6591#ifdef WLAN_FEATURE_11AC
6592 case eCSR_DOT11_MODE_11ac:
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006593 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6594 {
6595 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
6596 }
6597 else
6598 {
Ravi Joshia96ceb42013-05-20 18:52:39 -07006599 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006600 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006601 break;
6602 case eCSR_DOT11_MODE_11ac_ONLY:
Ravi Joshia96ceb42013-05-20 18:52:39 -07006603 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6604 {
6605 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
6606 }
6607 else
6608 {
6609 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6610 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006611 break;
6612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006613 default:
6614 //No need to assign anything here
6615 break;
6616 }
6617
6618 return (cfgDot11Mode);
6619}
6620
6621
6622eHalStatus csrSetRegulatoryDomain(tpAniSirGlobal pMac, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6623{
6624 eHalStatus status = eHAL_STATUS_SUCCESS;
6625 tANI_BOOLEAN fRestart;
6626
6627 if(pMac->scan.domainIdCurrent == domainId)
6628 {
6629 //no change
6630 fRestart = eANI_BOOLEAN_FALSE;
6631 }
6632 else if( !pMac->roam.configParam.fEnforceDefaultDomain )
6633 {
6634 pMac->scan.domainIdCurrent = domainId;
6635 fRestart = eANI_BOOLEAN_TRUE;
6636 }
6637 else
6638 {
6639 //We cannot change the domain
6640 status = eHAL_STATUS_CSR_WRONG_STATE;
6641 fRestart = eANI_BOOLEAN_FALSE;
6642 }
6643 if(pfRestartNeeded)
6644 {
6645 *pfRestartNeeded = fRestart;
6646 }
6647
6648 return (status);
6649}
6650
6651
6652v_REGDOMAIN_t csrGetCurrentRegulatoryDomain(tpAniSirGlobal pMac)
6653{
6654 return (pMac->scan.domainIdCurrent);
6655}
6656
Jeff Johnson295189b2012-06-20 16:38:30 -07006657
Kiet Lam6c583332013-10-14 05:37:09 +05306658eHalStatus csrGetRegulatoryDomainForCountry
6659(
6660tpAniSirGlobal pMac,
6661tANI_U8 *pCountry,
6662v_REGDOMAIN_t *pDomainId,
6663v_CountryInfoSource_t source
6664)
Jeff Johnson295189b2012-06-20 16:38:30 -07006665{
6666 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6667 VOS_STATUS vosStatus;
6668 v_COUNTRYCODE_t countryCode;
6669 v_REGDOMAIN_t domainId;
6670
6671 if(pCountry)
6672 {
6673 countryCode[0] = pCountry[0];
6674 countryCode[1] = pCountry[1];
Kiet Lam6c583332013-10-14 05:37:09 +05306675 vosStatus = vos_nv_getRegDomainFromCountryCode(&domainId,
6676 countryCode,
6677 source);
6678
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
6680 {
6681 if( pDomainId )
6682 {
6683 *pDomainId = domainId;
6684 }
6685 status = eHAL_STATUS_SUCCESS;
6686 }
6687 else
6688 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306689 smsLog(pMac, LOGW, FL(" Couldn't find domain for country code %c%c"), pCountry[0], pCountry[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 status = eHAL_STATUS_INVALID_PARAMETER;
6691 }
6692 }
6693
6694 return (status);
6695}
6696
6697//To check whether a country code matches the one in the IE
6698//Only check the first two characters, ignoring in/outdoor
6699//pCountry -- caller allocated buffer contain the country code that is checking against
6700//the one in pIes. It can be NULL.
6701//caller must provide pIes, it cannot be NULL
6702//This function always return TRUE if 11d support is not turned on.
6703tANI_BOOLEAN csrMatchCountryCode( tpAniSirGlobal pMac, tANI_U8 *pCountry, tDot11fBeaconIEs *pIes )
6704{
6705 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson43971f52012-07-17 12:26:56 -07006706 v_REGDOMAIN_t domainId = REGDOMAIN_COUNT; //This is init to invalid value
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 eHalStatus status;
6708
6709 do
6710 {
6711 if( !csrIs11dSupported( pMac) )
6712 {
6713 break;
6714 }
6715 if( !pIes )
6716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006717 smsLog(pMac, LOGE, FL(" No IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 break;
6719 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006720 if( pMac->roam.configParam.fEnforceDefaultDomain ||
6721 pMac->roam.configParam.fEnforceCountryCodeMatch )
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006723 //Make sure this country is recognizable
6724 if( pIes->Country.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07006725 {
Kiet Lam6c583332013-10-14 05:37:09 +05306726 status = csrGetRegulatoryDomainForCountry(pMac,
6727 pIes->Country.country,
6728 &domainId, COUNTRY_QUERY);
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006729 if( !HAL_STATUS_SUCCESS( status ) )
6730 {
Kiet Lam6c583332013-10-14 05:37:09 +05306731 status = csrGetRegulatoryDomainForCountry(pMac,
6732 pMac->scan.countryCode11d,
6733 (v_REGDOMAIN_t *) &domainId,
6734 COUNTRY_QUERY);
Gowri Deepthiff9adf92012-12-13 15:09:56 -08006735 if( !HAL_STATUS_SUCCESS( status ) )
6736 {
6737 fRet = eANI_BOOLEAN_FALSE;
6738 break;
6739 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006742 //check whether it is needed to enforce to the default regulatory domain first
6743 if( pMac->roam.configParam.fEnforceDefaultDomain )
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006745 if( domainId != pMac->scan.domainIdCurrent )
6746 {
6747 fRet = eANI_BOOLEAN_FALSE;
6748 break;
6749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006750 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006751 if( pMac->roam.configParam.fEnforceCountryCodeMatch )
6752 {
Jeff Johnson43971f52012-07-17 12:26:56 -07006753 if( domainId >= REGDOMAIN_COUNT )
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006754 {
6755 fRet = eANI_BOOLEAN_FALSE;
6756 break;
6757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 }
6759 }
6760 if( pCountry )
6761 {
6762 tANI_U32 i;
6763
6764 if( !pIes->Country.present )
6765 {
6766 fRet = eANI_BOOLEAN_FALSE;
6767 break;
6768 }
6769 // Convert the CountryCode characters to upper
6770 for ( i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++ )
6771 {
6772 pCountry[i] = csrToUpper( pCountry[i] );
6773 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306774 if (!vos_mem_compare(pIes->Country.country, pCountry,
6775 WNI_CFG_COUNTRY_CODE_LEN - 1))
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 {
6777 fRet = eANI_BOOLEAN_FALSE;
6778 break;
6779 }
6780 }
6781 } while(0);
6782
6783 return (fRet);
6784}
6785
6786#if 0
6787eHalStatus csrSetCountryDomainMapping(tpAniSirGlobal pMac, tCsrCountryDomainMapping *pCountryDomainMapping)
6788{
6789 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6790 tANI_U32 i, j;
6791 tANI_BOOLEAN fDomainChanged = eANI_BOOLEAN_FALSE;
6792 tANI_U8 countryCode[WNI_CFG_COUNTRY_CODE_LEN];
6793
6794 i = WNI_CFG_COUNTRY_CODE_LEN;
6795 //Get the currently used country code
6796 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, countryCode, &i);
6797 if(HAL_STATUS_SUCCESS(status))
6798 {
6799 if(pCountryDomainMapping && pCountryDomainMapping->numEntry)
6800 {
6801 for(i = 0; i < pCountryDomainMapping->numEntry; i++)
6802 {
6803 for(j = 0; j < eCSR_NUM_COUNTRY_INDEX; j++)
6804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306805 if (vos_mem_compare(gCsrCountryInfo[j].countryCode,
6806 pCountryDomainMapping->pCountryInfo[i].countryCode,
6807 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 {
6809 if(gCsrCountryInfo[j].domainId != pCountryDomainMapping->pCountryInfo[i].domainId)
6810 {
6811 gCsrCountryInfo[j].domainId = pCountryDomainMapping->pCountryInfo[i].domainId;
6812 //Check whether it matches the currently used country code
6813 //If matching, need to update base on the new domain setting.
Kiet Lam64c1b492013-07-12 13:56:44 +05306814 if (vos_mem_compare(countryCode,
6815 pCountryDomainMapping->pCountryInfo[i].countryCode,
6816 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 {
6818 fDomainChanged = eANI_BOOLEAN_TRUE;
6819 }
6820 }
6821 break;
6822 }
6823 }
6824 }
6825 status = eHAL_STATUS_SUCCESS;
6826 if(fDomainChanged)
6827 {
6828 tCsrChannel *pChannelList;
6829
6830 if(pMac->scan.f11dInfoApplied)
6831 {
6832 //11d info already applied. Let's reapply with the new domain setting
6833 if(pMac->scan.channels11d.numChannels)
6834 {
6835 pChannelList = &pMac->scan.channels11d;
6836 }
6837 else
6838 {
6839 pChannelList = &pMac->scan.base20MHzChannels;
6840 }
6841 }
6842 else
6843 {
6844 //no 11d so we use the base channelist from EEPROM
6845 pChannelList = &pMac->scan.base20MHzChannels;
6846 }
6847 //set the new domain's scan requirement to CFG
6848 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
6849 }
6850 }
6851 }
6852
6853 return (status);
6854}
6855
6856eHalStatus csrSetDomainScanSetting(tpAniSirGlobal pMac, tCsrDomainFreqInfo *pDomainFreqInfo)
6857{
6858 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6859 tANI_U32 i, j;
6860 tANI_U16 freq;
6861
6862 if(pDomainFreqInfo && pDomainFreqInfo->numEntry && (pDomainFreqInfo->domainId < NUM_REG_DOMAINS))
6863 {
6864 tCsrDomainChnInfo *pDomainChnInfo = &gCsrDomainChnInfo[pDomainFreqInfo->domainId];
6865
6866 for(j = 0; j < pDomainChnInfo->numChannels; j++)
6867 {
6868 if(HAL_STATUS_SUCCESS(halPhyChIdToFreqConversion(pDomainChnInfo->chnInfo[j].chnId, &freq)))
6869 {
6870 for(i = 0; i < pDomainFreqInfo->numEntry; i++)
6871 {
6872 if((pDomainFreqInfo->pCsrScanFreqInfo[i].nStartFreq <= freq) &&
6873 (freq <= pDomainFreqInfo->pCsrScanFreqInfo[i].nEndFreq))
6874 {
6875 pDomainChnInfo->chnInfo[j].scanType = pDomainFreqInfo->pCsrScanFreqInfo[i].scanType;
6876 break;
6877 }
6878 }
6879 }
6880 else
6881 {
6882 smsLog(pMac, LOGW, " Failed to get frequency of channel %d", pDomainChnInfo->chnInfo[j].chnId);
6883 }
6884 }
6885 status = eHAL_STATUS_SUCCESS;
6886 }
6887
6888 return (status);
6889}
6890#endif
6891
6892eHalStatus csrGetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6893 tCsrRoamModifyProfileFields *pModifyProfileFields)
6894{
6895
6896 if(!pModifyProfileFields)
6897 {
6898 return eHAL_STATUS_FAILURE;
6899 }
6900
Kiet Lam64c1b492013-07-12 13:56:44 +05306901 vos_mem_copy(pModifyProfileFields,
6902 &pMac->roam.roamSession[sessionId].connectedProfile.modifyProfileFields,
6903 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006904
6905 return eHAL_STATUS_SUCCESS;
6906}
6907
6908eHalStatus csrSetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6909 tCsrRoamModifyProfileFields *pModifyProfileFields)
6910{
6911 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6912
Kiet Lam64c1b492013-07-12 13:56:44 +05306913 vos_mem_copy(&pSession->connectedProfile.modifyProfileFields,
6914 pModifyProfileFields,
6915 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006916
6917 return eHAL_STATUS_SUCCESS;
6918}
6919
6920
6921#if 0
6922/* ---------------------------------------------------------------------------
6923 \fn csrGetSupportedCountryCode
6924 \brief this function is to get a list of the country code current being supported
6925 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6926 this has the country code list. 3 bytes for each country code. This may be NULL if
6927 caller wants to know the needed bytes.
6928 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6929 this contains the length of the data in pBuf
6930 \return eHalStatus
6931 -------------------------------------------------------------------------------*/
6932eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6933{
6934 tANI_U32 numOfCountry = sizeof( gCsrCountryInfo ) / sizeof( gCsrCountryInfo[0] );
6935 tANI_U32 numBytes = 0;
6936 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6937
6938 if( pbLen )
6939 {
6940 numBytes = *pbLen;
6941 //Consider it ok, at least we can return the number of bytes needed;
6942 *pbLen = numOfCountry * WNI_CFG_COUNTRY_CODE_LEN;
6943 status = eHAL_STATUS_SUCCESS;
6944 if( pBuf && ( numBytes >= *pbLen ) )
6945 {
6946 //The ugly part starts.
6947 //We may need to alter the data structure and find a way to make this faster.
6948 tANI_U32 i;
6949
Kiet Lam64c1b492013-07-12 13:56:44 +05306950 for ( i = 0; i < numOfCountry; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306952 vos_mem_copy(pBuf + ( i * WNI_CFG_COUNTRY_CODE_LEN ),
6953 gCsrCountryInfo[i].countryCode,
6954 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006955 }
6956 }
6957 }
6958
6959 return ( status );
6960}
6961#endif
6962
6963/* ---------------------------------------------------------------------------
6964 \fn csrGetSupportedCountryCode
6965 \brief this function is to get a list of the country code current being supported
6966 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6967 this has the country code list. 3 bytes for each country code. This may be NULL if
6968 caller wants to know the needed bytes.
6969 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6970 this contains the length of the data in pBuf
6971 \return eHalStatus
6972 -------------------------------------------------------------------------------*/
6973eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6974{
6975 eHalStatus status = eHAL_STATUS_SUCCESS;
6976 VOS_STATUS vosStatus;
6977 v_SIZE_t size = (v_SIZE_t)*pbLen;
6978
6979 vosStatus = vos_nv_getSupportedCountryCode( pBuf, &size, 1 );
6980 //eiter way, return the value back
6981 *pbLen = (tANI_U32)size;
6982
6983 //If pBuf is NULL, caller just want to get the size, consider it success
6984 if(pBuf)
6985 {
6986 if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
6987 {
6988 tANI_U32 i, n = *pbLen / 3;
6989
6990 for( i = 0; i < n; i++ )
6991 {
6992 pBuf[i*3 + 2] = ' ';
6993 }
6994 }
6995 else
6996 {
6997 status = eHAL_STATUS_FAILURE;
6998 }
6999 }
7000
7001 return (status);
7002}
7003
7004
7005
7006//Upper layer to get the list of the base channels to scan for passively 11d info from csr
7007eHalStatus csrScanGetBaseChannels( tpAniSirGlobal pMac, tCsrChannelInfo * pChannelInfo )
7008{
7009 eHalStatus status = eHAL_STATUS_FAILURE;
7010
7011 do
7012 {
7013
7014 if(!pMac->scan.baseChannels.numChannels || !pChannelInfo)
7015 {
7016 break;
7017 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307018 pChannelInfo->ChannelList = vos_mem_malloc(pMac->scan.baseChannels.numChannels);
7019 if ( NULL == pChannelInfo->ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007021 smsLog( pMac, LOGE, FL("csrScanGetBaseChannels: fail to allocate memory") );
Kiet Lam64c1b492013-07-12 13:56:44 +05307022 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007023 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307024 vos_mem_copy(pChannelInfo->ChannelList,
7025 pMac->scan.baseChannels.channelList,
7026 pMac->scan.baseChannels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 pChannelInfo->numOfChannels = pMac->scan.baseChannels.numChannels;
7028
7029 }while(0);
7030
7031 return ( status );
7032}
7033
7034
7035tANI_BOOLEAN csrIsSetKeyAllowed(tpAniSirGlobal pMac, tANI_U32 sessionId)
7036{
7037 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 tCsrRoamSession *pSession;
7039
7040 pSession =CSR_GET_SESSION(pMac, sessionId);
7041
7042 /*This condition is not working for infra state. When infra is in not-connected state
7043 * the pSession->pCurRoamProfile is NULL. And this function returns TRUE, that is incorrect.
7044 * Since SAP requires to set key without any BSS started, it needs this condition to be met.
7045 * In other words, this function is useless.
7046 * The current work-around is to process setcontext_rsp and removekey_rsp no matter what the
7047 * state is.
7048 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007049 smsLog( pMac, LOG2, FL(" is not what it intends to. Must be revisit or removed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 if( (NULL == pSession) ||
7051 ( csrIsConnStateDisconnected( pMac, sessionId ) &&
7052 (pSession->pCurRoamProfile != NULL) &&
7053 (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) )
7054 )
7055 {
7056 fRet = eANI_BOOLEAN_FALSE;
7057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007058
7059 return ( fRet );
7060}
7061
7062//no need to acquire lock for this basic function
7063tANI_U16 sme_ChnToFreq(tANI_U8 chanNum)
7064{
7065 int i;
7066
7067 for (i = 0; i < NUM_RF_CHANNELS; i++)
7068 {
7069 if (rfChannels[i].channelNum == chanNum)
7070 {
7071 return rfChannels[i].targetFreq;
7072 }
7073 }
7074
7075 return (0);
7076}
7077
7078/* Disconnect all active sessions by sending disassoc. This is mainly used to disconnect the remaining session when we
7079 * transition from concurrent sessions to a single session. The use case is Infra STA and wifi direct multiple sessions are up and
7080 * P2P session is removed. The Infra STA session remains and should resume BMPS if BMPS is enabled by default. However, there
7081 * are some issues seen with BMPS resume during this transition and this is a workaround which will allow the Infra STA session to
7082 * disconnect and auto connect back and enter BMPS this giving the same effect as resuming BMPS
7083 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007084
7085//Remove this code once SLM_Sessionization is supported
7086//BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnson295189b2012-06-20 16:38:30 -07007087void csrDisconnectAllActiveSessions(tpAniSirGlobal pMac)
7088{
7089 tANI_U8 i;
7090
7091 /* Disconnect all the active sessions */
7092 for (i=0; i<CSR_ROAM_SESSION_MAX; i++)
7093 {
7094 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
7095 {
7096 csrRoamDisconnectInternal(pMac, i, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7097 }
7098 }
7099}
Mohit Khanna349bc392012-09-11 17:24:52 -07007100
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07007101#ifdef FEATURE_WLAN_LFR
7102tANI_BOOLEAN csrIsChannelPresentInList(
7103 tANI_U8 *pChannelList,
7104 int numChannels,
7105 tANI_U8 channel
7106 )
7107{
7108 int i = 0;
7109
7110 // Check for NULL pointer
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08007111 if (!pChannelList || (numChannels == 0))
7112 {
7113 return FALSE;
7114 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07007115
7116 // Look for the channel in the list
7117 for (i = 0; i < numChannels; i++)
7118 {
7119 if (pChannelList[i] == channel)
7120 return TRUE;
7121 }
7122
7123 return FALSE;
7124}
7125
7126VOS_STATUS csrAddToChannelListFront(
7127 tANI_U8 *pChannelList,
7128 int numChannels,
7129 tANI_U8 channel
7130 )
7131{
7132 int i = 0;
7133
7134 // Check for NULL pointer
7135 if (!pChannelList) return eHAL_STATUS_E_NULL_VALUE;
7136
7137 // Make room for the addition. (Start moving from the back.)
7138 for (i = numChannels; i > 0; i--)
7139 {
7140 pChannelList[i] = pChannelList[i-1];
7141 }
7142
7143 // Now add the NEW channel...at the front
7144 pChannelList[0] = channel;
7145
7146 return eHAL_STATUS_SUCCESS;
7147}
7148#endif
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307149const char * sme_requestTypetoString(const v_U8_t requestType)
7150{
7151 switch (requestType)
7152 {
7153 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_11D_SCAN );
7154 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_FULL_SCAN );
7155 CASE_RETURN_STRING( eCSR_SCAN_IDLE_MODE_SCAN );
7156 CASE_RETURN_STRING( eCSR_SCAN_HO_BG_SCAN );
7157 CASE_RETURN_STRING( eCSR_SCAN_HO_PROBE_SCAN );
7158 CASE_RETURN_STRING( eCSR_SCAN_HO_NT_BG_SCAN );
7159 CASE_RETURN_STRING( eCSR_SCAN_P2P_DISCOVERY );
7160 CASE_RETURN_STRING( eCSR_SCAN_SOFTAP_CHANNEL_RANGE );
7161 CASE_RETURN_STRING( eCSR_SCAN_P2P_FIND_PEER );
7162 default:
7163 return "Unknown Scan Request Type";
7164 }
7165}