blob: 63b0119ba5739343582cc486ab0f7e076756b1f4 [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);
Abhinav Kumard6d8dd22019-08-05 12:38:50 +05301321 CASE_RETURN_STR(eCSR_ROAM_SAE_COMPUTE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 default:
1323 return "unknown";
1324 }
1325}
1326
1327const char *
1328get_eCsrRoamResult_str(eCsrRoamResult val)
1329{
1330 switch (val)
1331 {
1332 CASE_RETURN_STR(eCSR_ROAM_RESULT_NONE);
1333 CASE_RETURN_STR(eCSR_ROAM_RESULT_FAILURE);
1334 CASE_RETURN_STR(eCSR_ROAM_RESULT_ASSOCIATED);
1335 CASE_RETURN_STR(eCSR_ROAM_RESULT_NOT_ASSOCIATED);
1336 CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_FAILURE);
1337 CASE_RETURN_STR(eCSR_ROAM_RESULT_FORCED);
1338 CASE_RETURN_STR(eCSR_ROAM_RESULT_DISASSOC_IND);
1339 CASE_RETURN_STR(eCSR_ROAM_RESULT_DEAUTH_IND);
1340 CASE_RETURN_STR(eCSR_ROAM_RESULT_CAP_CHANGED);
1341 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_CONNECT);
1342 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_INACTIVE);
1343 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_NEW_PEER);
1344 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_COALESCED);
1345 default:
1346 return "unknown";
1347 }
1348}
1349
1350
1351
1352tANI_BOOLEAN csrGetBssIdBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tCsrBssid *pBssId )
1353{
Kiet Lam64c1b492013-07-12 13:56:44 +05301354 vos_mem_copy(pBssId, &pSirBssDesc->bssId[ 0 ], sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 return( TRUE );
1356}
1357
1358
1359tANI_BOOLEAN csrIsBssIdEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 )
1360{
1361 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1362 tANI_BOOLEAN fEqual = FALSE;
1363 tCsrBssid bssId1;
1364 tCsrBssid bssId2;
1365
1366 do {
1367 if ( !pSirBssDesc1 ) break;
1368 if ( !pSirBssDesc2 ) break;
1369
1370 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc1, &bssId1 ) ) break;
1371 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc2, &bssId2 ) ) break;
1372
1373 //sirCompareMacAddr
1374 fEqual = csrIsMacAddressEqual(pMac, &bssId1, &bssId2);
1375
1376 } while( 0 );
1377
1378 return( fEqual );
1379}
1380
1381tANI_BOOLEAN csrIsConnStateConnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1382{
1383 return( eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1384}
1385
1386tANI_BOOLEAN csrIsConnStateDisconnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1387{
1388 return( eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1389}
1390
1391tANI_BOOLEAN csrIsConnStateConnectedInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1392{
1393 return( eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == pMac->roam.roamSession[sessionId].connectState );
1394}
1395
1396tANI_BOOLEAN csrIsConnStateConnected( tpAniSirGlobal pMac, tANI_U32 sessionId )
1397{
1398 if( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateConnectedInfra( pMac, sessionId ) || csrIsConnStateConnectedWds( pMac, sessionId) )
1399 return TRUE;
1400 else
1401 return FALSE;
1402}
1403
1404tANI_BOOLEAN csrIsConnStateInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1405{
1406 return( csrIsConnStateConnectedInfra( pMac, sessionId ) );
1407}
1408
1409tANI_BOOLEAN csrIsConnStateIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1410{
1411 return( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateDisconnectedIbss( pMac, sessionId ) );
1412}
1413
1414
1415tANI_BOOLEAN csrIsConnStateConnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1416{
1417 return( eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1418}
1419
Jeff Johnson295189b2012-06-20 16:38:30 -07001420tANI_BOOLEAN csrIsConnStateConnectedInfraAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1421{
1422 return( (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == pMac->roam.roamSession[sessionId].connectState) ||
1423 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState ) );
1424}
Jeff Johnson295189b2012-06-20 16:38:30 -07001425
1426tANI_BOOLEAN csrIsConnStateDisconnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1427{
1428 return( eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1429}
1430
1431tANI_BOOLEAN csrIsConnStateWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1432{
1433 return( csrIsConnStateConnectedWds( pMac, sessionId ) ||
1434 csrIsConnStateDisconnectedWds( pMac, sessionId ) );
1435}
1436
Jeff Johnsone7245742012-09-05 17:12:55 -07001437tANI_BOOLEAN csrIsConnStateAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1438{
1439 tCsrRoamSession *pSession;
1440 pSession = CSR_GET_SESSION(pMac, sessionId);
1441 if (!pSession)
1442 return eANI_BOOLEAN_FALSE;
1443 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
1444 {
1445 return eANI_BOOLEAN_TRUE;
1446 }
1447 return eANI_BOOLEAN_FALSE;
1448}
1449
Jeff Johnson295189b2012-06-20 16:38:30 -07001450tANI_BOOLEAN csrIsAnySessionInConnectState( tpAniSirGlobal pMac )
1451{
1452 tANI_U32 i;
1453 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1454
1455 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1456 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001457 if( CSR_IS_SESSION_VALID( pMac, i ) &&
1458 ( csrIsConnStateInfra( pMac, i )
1459 || csrIsConnStateIbss( pMac, i )
1460 || csrIsConnStateAp( pMac, i) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 {
1462 fRc = eANI_BOOLEAN_TRUE;
1463 break;
1464 }
1465 }
1466
1467 return ( fRc );
1468}
1469
1470tANI_S8 csrGetInfraSessionId( tpAniSirGlobal pMac )
1471{
1472 tANI_U8 i;
1473 tANI_S8 sessionid = -1;
1474
1475 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1476 {
1477 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateInfra( pMac, i ) )
1478 {
1479 sessionid = i;
1480 break;
1481 }
1482 }
1483
1484 return ( sessionid );
1485}
1486
1487tANI_U8 csrGetInfraOperationChannel( tpAniSirGlobal pMac, tANI_U8 sessionId)
1488{
1489 tANI_U8 channel;
1490
1491 if( CSR_IS_SESSION_VALID( pMac, sessionId ))
1492 {
1493 channel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
1494 }
1495 else
1496 {
1497 channel = 0;
1498 }
1499 return channel;
1500}
1501
Sushant Kaushik1d732562014-05-21 14:15:37 +05301502tANI_BOOLEAN csrIsSessionClientAndConnected(tpAniSirGlobal pMac, tANI_U8 sessionId)
1503{
1504 tCsrRoamSession *pSession = NULL;
1505 if ( CSR_IS_SESSION_VALID( pMac, sessionId) && csrIsConnStateInfra( pMac, sessionId))
1506 {
1507 pSession = CSR_GET_SESSION( pMac, sessionId);
Kaushik, Sushant79901762014-08-23 17:51:02 +05301508 if (NULL != pSession->pCurRoamProfile)
Sushant Kaushik1d732562014-05-21 14:15:37 +05301509 {
Kaushik, Sushant79901762014-08-23 17:51:02 +05301510 if ((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1511 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE))
1512 {
1513 return TRUE;
1514 }
Sushant Kaushik1d732562014-05-21 14:15:37 +05301515 }
1516 }
1517 return FALSE;
1518}
Jeff Johnson295189b2012-06-20 16:38:30 -07001519//This routine will return operating channel on FIRST BSS that is active/operating to be used for concurrency mode.
1520//If other BSS is not up or not connected it will return 0
1521
1522tANI_U8 csrGetConcurrentOperationChannel( tpAniSirGlobal pMac )
1523{
1524 tCsrRoamSession *pSession = NULL;
1525 tANI_U8 i = 0;
1526
1527 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1528 {
1529 if( CSR_IS_SESSION_VALID( pMac, i ) )
1530 {
1531 pSession = CSR_GET_SESSION( pMac, i );
1532
1533 if (NULL != pSession->pCurRoamProfile)
1534 {
1535 if (
1536 (((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1537 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE)) &&
1538 (pSession->connectState == eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED))
1539 ||
1540 (((pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) ||
1541 (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE)) &&
1542 (pSession->connectState != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
1543 )
1544 return (pSession->connectedProfile.operationChannel);
1545 }
1546
1547 }
1548 }
1549 return 0;
1550}
1551
1552tANI_BOOLEAN csrIsAllSessionDisconnected( tpAniSirGlobal pMac )
1553{
1554 tANI_U32 i;
1555 tANI_BOOLEAN fRc = eANI_BOOLEAN_TRUE;
1556
1557 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1558 {
1559 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1560 {
1561 fRc = eANI_BOOLEAN_FALSE;
1562 break;
1563 }
1564 }
1565
1566 return ( fRc );
1567}
1568
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001569tANI_BOOLEAN csrIsStaSessionConnected( tpAniSirGlobal pMac )
1570{
1571 tANI_U32 i;
1572 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1573 tCsrRoamSession *pSession = NULL;
1574 tANI_U32 countSta = 0;
1575
1576 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1577 {
1578 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1579 {
1580 pSession = CSR_GET_SESSION( pMac, i );
1581
1582 if (NULL != pSession->pCurRoamProfile)
1583 {
1584 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) {
1585 countSta++;
1586 }
1587 }
1588 }
1589 }
1590
1591 /* return TRUE if one of the following conditions is TRUE:
1592 * - more than one STA session connected
1593 */
1594 if ( countSta > 0) {
1595 fRc = eANI_BOOLEAN_TRUE;
1596 }
1597
1598 return( fRc );
1599}
1600
Bala Venkatesh5bfddc22019-02-13 14:42:05 +05301601tANI_BOOLEAN csrIsP2pGoSessionConnected( tpAniSirGlobal pMac )
1602{
1603 tANI_U32 i;
1604 tCsrRoamSession *pSession = NULL;
1605
1606 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1607 {
1608 if(CSR_IS_SESSION_VALID( pMac, i) &&
1609 !csrIsConnStateDisconnected(pMac, i))
1610 {
1611 pSession = CSR_GET_SESSION(pMac, i);
1612
1613 if (NULL != pSession->pCurRoamProfile)
1614 {
1615 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1616 return eANI_BOOLEAN_TRUE;
1617 }
1618 }
1619 }
1620 }
1621
1622 return eANI_BOOLEAN_FALSE;
1623}
1624
1625
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001626tANI_BOOLEAN csrIsP2pSessionConnected( tpAniSirGlobal pMac )
1627{
1628 tANI_U32 i;
1629 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1630 tCsrRoamSession *pSession = NULL;
1631 tANI_U32 countP2pCli = 0;
1632 tANI_U32 countP2pGo = 0;
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001633 tANI_U32 countSAP = 0;
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001634
1635 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1636 {
1637 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1638 {
1639 pSession = CSR_GET_SESSION( pMac, i );
1640
1641 if (NULL != pSession->pCurRoamProfile)
1642 {
1643 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE) {
1644 countP2pCli++;
1645 }
1646
1647 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1648 countP2pGo++;
1649 }
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001650
1651 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE) {
1652 countSAP++;
1653 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001654 }
1655 }
1656 }
1657
1658 /* return TRUE if one of the following conditions is TRUE:
1659 * - at least one P2P CLI session is connected
1660 * - at least one P2P GO session is connected
1661 */
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001662 if ( (countP2pCli > 0) || (countP2pGo > 0 ) || (countSAP > 0 ) ) {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001663 fRc = eANI_BOOLEAN_TRUE;
1664 }
1665
1666 return( fRc );
1667}
1668
Madan Mohan Koyyalamudid3d22592012-09-24 14:01:29 -07001669tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac )
1670{
1671 tANI_U32 i, count;
1672 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1673
1674 count = 0;
1675 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1676 {
1677 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1678 {
1679 count++;
1680 }
1681 }
1682
1683 if (count > 0)
1684 {
1685 fRc = eANI_BOOLEAN_TRUE;
1686 }
1687 return( fRc );
1688}
Jeff Johnson295189b2012-06-20 16:38:30 -07001689
1690tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac )
1691{
1692 tANI_U32 i;
1693 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1694
1695 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1696 {
1697 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1698 {
1699 fRc = eANI_BOOLEAN_TRUE;
1700 break;
1701 }
1702 }
1703
1704 return ( fRc );
1705}
1706
1707tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac )
1708{
1709 tANI_U32 i, noOfConnectedInfra = 0;
1710
1711 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1712
1713 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1714 {
1715 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1716 {
1717 ++noOfConnectedInfra;
1718 }
1719 }
1720
1721 // More than one Infra Sta Connected
1722 if(noOfConnectedInfra > 1)
1723 {
1724 fRc = eANI_BOOLEAN_TRUE;
1725 }
1726
1727 return ( fRc );
1728}
1729
1730tANI_BOOLEAN csrIsIBSSStarted( tpAniSirGlobal pMac )
1731{
1732 tANI_U32 i;
1733 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1734
1735 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1736 {
1737 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateIbss( pMac, i ) )
1738 {
1739 fRc = eANI_BOOLEAN_TRUE;
1740 break;
1741 }
1742 }
1743
1744 return ( fRc );
1745}
1746
1747
1748tANI_BOOLEAN csrIsBTAMPStarted( tpAniSirGlobal pMac )
1749{
1750 tANI_U32 i;
1751 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1752
1753 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1754 {
1755 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedWds( pMac, i ) )
1756 {
1757 fRc = eANI_BOOLEAN_TRUE;
1758 break;
1759 }
1760 }
1761
1762 return ( fRc );
1763}
1764
Jeff Johnsone7245742012-09-05 17:12:55 -07001765tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac )
1766{
1767 tANI_U32 sessionId, noOfCocurrentSession = 0;
1768 eCsrConnectState connectState;
1769
1770 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1771
1772 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1773 {
1774 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1775 {
1776 connectState = pMac->roam.roamSession[sessionId].connectState;
1777 if( (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == connectState) ||
1778 (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == connectState) ||
1779 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == connectState) )
1780 {
1781 ++noOfCocurrentSession;
1782 }
1783 }
1784 }
1785
1786 // More than one session is Up and Running
1787 if(noOfCocurrentSession > 1)
1788 {
1789 fRc = eANI_BOOLEAN_TRUE;
1790 }
1791
1792 return ( fRc );
1793}
1794
Jeff Johnsone7245742012-09-05 17:12:55 -07001795tANI_BOOLEAN csrIsInfraApStarted( tpAniSirGlobal pMac )
1796{
1797 tANI_U32 sessionId;
1798 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1799
1800 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1801 {
1802 if( CSR_IS_SESSION_VALID( pMac, sessionId ) && (csrIsConnStateConnectedInfraAp(pMac, sessionId)) )
1803 {
1804 fRc = eANI_BOOLEAN_TRUE;
1805 break;
1806 }
1807 }
1808
1809 return ( fRc );
1810
1811}
Jeff Johnsone7245742012-09-05 17:12:55 -07001812
Jeff Johnson295189b2012-06-20 16:38:30 -07001813tANI_BOOLEAN csrIsBTAMP( tpAniSirGlobal pMac, tANI_U32 sessionId )
1814{
1815 return ( csrIsConnStateConnectedWds( pMac, sessionId ) );
1816}
1817
1818
1819tANI_BOOLEAN csrIsConnStateDisconnected(tpAniSirGlobal pMac, tANI_U32 sessionId)
1820{
1821 return (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED == pMac->roam.roamSession[sessionId].connectState);
1822}
1823
Jeff Johnsone7245742012-09-05 17:12:55 -07001824tANI_BOOLEAN csrIsValidMcConcurrentSession(tpAniSirGlobal pMac, tANI_U32 sessionId,
1825 tSirBssDescription *pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001826{
1827 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07001828 eAniBoolean status = eANI_BOOLEAN_FALSE;
1829
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 //Check for MCC support
1831 if (!pMac->roam.configParam.fenableMCCMode)
1832 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001833 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 }
1835
Jeff Johnsone7245742012-09-05 17:12:55 -07001836 //Validate BeaconInterval
1837 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1838 {
1839 pSession = CSR_GET_SESSION( pMac, sessionId );
1840 if (NULL != pSession->pCurRoamProfile)
1841 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001842 if (csrIsconcurrentsessionValid (pMac, sessionId,
1843 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001844 == eHAL_STATUS_SUCCESS )
1845 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001846 if (csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId,
1847 &pBssDesc->beaconInterval, sessionId,
1848 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001849 != eHAL_STATUS_SUCCESS)
1850 {
1851 status = eANI_BOOLEAN_FALSE;
1852 }
1853 else
1854 {
1855 status = eANI_BOOLEAN_TRUE;
1856 }
1857 }
1858 else
1859 {
1860 status = eANI_BOOLEAN_FALSE;
1861 }
1862 }
1863 }
1864 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001865}
1866
1867static tSirMacCapabilityInfo csrGetBssCapabilities( tSirBssDescription *pSirBssDesc )
1868{
1869 tSirMacCapabilityInfo dot11Caps;
1870
1871 //tSirMacCapabilityInfo is 16-bit
1872 pal_get_U16( (tANI_U8 *)&pSirBssDesc->capabilityInfo, (tANI_U16 *)&dot11Caps );
1873
1874 return( dot11Caps );
1875}
1876
1877tANI_BOOLEAN csrIsInfraBssDesc( tSirBssDescription *pSirBssDesc )
1878{
1879 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1880
1881 return( (tANI_BOOLEAN)dot11Caps.ess );
1882}
1883
1884
1885tANI_BOOLEAN csrIsIbssBssDesc( tSirBssDescription *pSirBssDesc )
1886{
1887 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1888
1889 return( (tANI_BOOLEAN)dot11Caps.ibss );
1890}
1891
1892tANI_BOOLEAN csrIsQoSBssDesc( tSirBssDescription *pSirBssDesc )
1893{
1894 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1895
1896 return( (tANI_BOOLEAN)dot11Caps.qos );
1897}
1898
1899tANI_BOOLEAN csrIsPrivacy( tSirBssDescription *pSirBssDesc )
1900{
1901 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1902
1903 return( (tANI_BOOLEAN)dot11Caps.privacy );
1904}
1905
1906
1907tANI_BOOLEAN csrIs11dSupported(tpAniSirGlobal pMac)
1908{
1909 return(pMac->roam.configParam.Is11dSupportEnabled);
1910}
1911
1912
1913tANI_BOOLEAN csrIs11hSupported(tpAniSirGlobal pMac)
1914{
1915 return(pMac->roam.configParam.Is11hSupportEnabled);
1916}
1917
1918
1919tANI_BOOLEAN csrIs11eSupported(tpAniSirGlobal pMac)
1920{
1921 return(pMac->roam.configParam.Is11eSupportEnabled);
1922}
1923
1924tANI_BOOLEAN csrIsMCCSupported ( tpAniSirGlobal pMac )
1925{
1926 return(pMac->roam.configParam.fenableMCCMode);
1927
1928}
1929
1930tANI_BOOLEAN csrIsWmmSupported(tpAniSirGlobal pMac)
1931{
1932 if(eCsrRoamWmmNoQos == pMac->roam.configParam.WMMSupportMode)
1933 {
1934 return eANI_BOOLEAN_FALSE;
1935 }
1936 else
1937 {
1938 return eANI_BOOLEAN_TRUE;
1939 }
1940}
1941
1942
1943
1944
1945//pIes is the IEs for pSirBssDesc2
1946tANI_BOOLEAN csrIsSsidEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1,
1947 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2 )
1948{
1949 tANI_BOOLEAN fEqual = FALSE;
1950 tSirMacSSid Ssid1, Ssid2;
1951 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1952 tDot11fBeaconIEs *pIes1 = NULL;
1953 tDot11fBeaconIEs *pIesLocal = pIes2;
1954
1955 do {
1956 if( ( NULL == pSirBssDesc1 ) || ( NULL == pSirBssDesc2 ) ) break;
1957 if( !pIesLocal && !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesLocal)) )
1958 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001959 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 break;
1961 }
1962 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
1963 {
1964 break;
1965 }
1966 if( ( !pIes1->SSID.present ) || ( !pIesLocal->SSID.present ) ) break;
1967 if ( pIes1->SSID.num_ssid != pIesLocal->SSID.num_ssid ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301968 vos_mem_copy(Ssid1.ssId, pIes1->SSID.ssid, pIes1->SSID.num_ssid);
1969 vos_mem_copy(Ssid2.ssId, pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001970
Kiet Lam64c1b492013-07-12 13:56:44 +05301971 fEqual = vos_mem_compare(Ssid1.ssId, Ssid2.ssId, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001972
1973 } while( 0 );
1974 if(pIes1)
1975 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301976 vos_mem_free(pIes1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 }
1978 if( pIesLocal && !pIes2 )
1979 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301980 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 }
1982
1983 return( fEqual );
1984}
1985
1986tANI_BOOLEAN csrIsAniWmeSupported(tDot11fIEAirgo *pIeAirgo)
1987{
1988 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
1989
1990 if(pIeAirgo && pIeAirgo->present && pIeAirgo->PropCapability.present)
1991 {
1992 fRet = (tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability ));
1993 }
1994
1995 return fRet;
1996}
1997
1998
1999
2000
2001//pIes can be passed in as NULL if the caller doesn't have one prepared
2002tANI_BOOLEAN csrIsBssDescriptionWme( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
2003{
2004 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2005 // Assume that WME is found...
2006 tANI_BOOLEAN fWme = TRUE;
2007 tDot11fBeaconIEs *pIesTemp = pIes;
2008
2009 do
2010 {
2011 if(pIesTemp == NULL)
2012 {
2013 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp)) )
2014 {
2015 fWme = FALSE;
2016 break;
2017 }
2018 }
2019 // if the AirgoProprietary indicator is found, then WME is supported...
2020 if ( csrIsAniWmeSupported(&pIesTemp->Airgo) ) break;
2021 // if the Wme Info IE is found, then WME is supported...
2022 if ( CSR_IS_QOS_BSS(pIesTemp) ) break;
2023 // if none of these are found, then WME is NOT supported...
2024 fWme = FALSE;
2025 } while( 0 );
2026 if( !csrIsWmmSupported( pMac ) && fWme)
2027 {
2028 if( !pIesTemp->HTCaps.present )
2029 {
2030 fWme = FALSE;
2031 }
2032 }
2033 if( ( pIes == NULL ) && ( NULL != pIesTemp ) )
2034 {
2035 //we allocate memory here so free it before returning
Kiet Lam64c1b492013-07-12 13:56:44 +05302036 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 }
2038
2039 return( fWme );
2040}
2041
2042tANI_BOOLEAN csrIsHcfEnabled( tDot11fIEAirgo *pIeAirgo )
2043{
2044 tANI_BOOLEAN fHcfSupported = FALSE;
2045
2046 fHcfSupported = ((tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability )) ||
2047 (pIeAirgo->present && pIeAirgo->HCF.present && pIeAirgo->HCF.enabled));
2048
2049 return( fHcfSupported );
2050}
2051
2052
2053eCsrMediaAccessType csrGetQoSFromBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc,
2054 tDot11fBeaconIEs *pIes )
2055{
2056 eCsrMediaAccessType qosType = eCSR_MEDIUM_ACCESS_DCF;
2057
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07002059
2060 do
2061 {
2062 // if we find WMM in the Bss Description, then we let this
2063 // override and use WMM.
2064 if ( csrIsBssDescriptionWme( hHal, pSirBssDesc, pIes ) )
2065 {
2066 qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2067 }
2068 else
2069 {
2070 // if the QoS bit is on, then the AP is advertising 11E QoS...
2071 if ( csrIsQoSBssDesc( pSirBssDesc ) )
2072 {
2073 // which could be HCF or eDCF.
2074 if ( csrIsHcfEnabled( &pIes->Airgo ) )
2075 {
2076 qosType = eCSR_MEDIUM_ACCESS_11e_HCF;
2077 }
2078 else
2079 {
2080 qosType = eCSR_MEDIUM_ACCESS_11e_eDCF;
2081 }
2082 }
2083 else
2084 {
2085 qosType = eCSR_MEDIUM_ACCESS_DCF;
2086 }
2087 // scale back based on the types turned on for the adapter...
2088 if ( eCSR_MEDIUM_ACCESS_11e_eDCF == qosType && !csrIs11eSupported( hHal ) )
2089 {
2090 qosType = eCSR_MEDIUM_ACCESS_DCF;
2091 }
2092 }
2093
2094 } while(0);
2095
2096 return( qosType );
2097}
2098
2099
2100
2101
2102//Caller allocates memory for pIEStruct
2103eHalStatus csrParseBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIEStruct)
2104{
2105 eHalStatus status = eHAL_STATUS_FAILURE;
2106 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Abhishek Singhbad2b322016-10-21 11:22:33 +05302107 int ieLen = (int)GET_IE_LEN_IN_BSS(pBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07002108
2109 if(ieLen > 0 && pIEStruct)
2110 {
2111 if(!DOT11F_FAILED(dot11fUnpackBeaconIEs( pMac, (tANI_U8 *)pBssDesc->ieFields, ieLen, pIEStruct )))
2112 {
2113 status = eHAL_STATUS_SUCCESS;
2114 }
2115 }
2116
2117 return (status);
2118}
2119
2120
2121//This function will allocate memory for the parsed IEs to the caller. Caller must free the memory
2122//after it is done with the data only if this function succeeds
2123eHalStatus csrGetParsedBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs **ppIEStruct)
2124{
2125 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2126 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2127
2128 if(pBssDesc && ppIEStruct)
2129 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302130 *ppIEStruct = vos_mem_malloc(sizeof(tDot11fBeaconIEs));
2131 if ( (*ppIEStruct) != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302133 vos_mem_set((void *)*ppIEStruct, sizeof(tDot11fBeaconIEs), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 status = csrParseBssDescriptionIEs(hHal, pBssDesc, *ppIEStruct);
2135 if(!HAL_STATUS_SUCCESS(status))
2136 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302137 vos_mem_free(*ppIEStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 *ppIEStruct = NULL;
2139 }
2140 }
2141 else
2142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002143 smsLog( pMac, LOGE, FL(" failed to allocate memory") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 VOS_ASSERT( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +05302145 return eHAL_STATUS_FAILURE;
2146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 }
2148
2149 return (status);
2150}
2151
Siddharth Bhal64246172015-02-27 01:04:37 +05302152eHalStatus csrProcessGetFrameLogCommand( tpAniSirGlobal pMac,
2153 tSmeCmd *pCommand )
2154{
2155 tAniGetFrameLogReq *pMsg;
2156 tANI_U16 msgLen;
2157 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002158
Siddharth Bhal64246172015-02-27 01:04:37 +05302159 msgLen = sizeof(tAniGetFrameLogReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002160
Siddharth Bhal64246172015-02-27 01:04:37 +05302161 if ( NULL == pCommand )
2162 {
2163 smsLog( pMac, LOGE, FL("cannot process. cmd is null") );
2164 return eHAL_STATUS_FAILURE;
2165 }
2166
2167 pMsg = vos_mem_malloc(msgLen);
2168 if ( NULL == pMsg )
2169 {
2170 smsLog( pMac, LOGE, FL("fail to allocate memory") );
2171 return eHAL_STATUS_FAILURE;
2172 }
2173
2174 pMsg->msgType= pal_cpu_to_be16((tANI_U16)WDA_GET_FRAME_LOG_REQ);
2175 pMsg->msgLen= pal_cpu_to_be16(msgLen);
2176
Siddharth Bhal64246172015-02-27 01:04:37 +05302177 pMsg->getFrameLogCmdFlag = pCommand->u.getFramelogCmd.getFrameLogCmdFlag;
2178
2179 status = palSendMBMessage(pMac->hHdd, pMsg);
2180
2181 return( status );
2182}
Jeff Johnson295189b2012-06-20 16:38:30 -07002183
2184tANI_BOOLEAN csrIsNULLSSID( tANI_U8 *pBssSsid, tANI_U8 len )
2185{
2186 tANI_BOOLEAN fNullSsid = FALSE;
2187
2188 tANI_U32 SsidLength;
2189 tANI_U8 *pSsidStr;
2190
2191 do
2192 {
2193 if ( 0 == len )
2194 {
2195 fNullSsid = TRUE;
2196 break;
2197 }
2198
2199 //Consider 0 or space for hidden SSID
2200 if ( 0 == pBssSsid[0] )
2201 {
2202 fNullSsid = TRUE;
2203 break;
2204 }
2205
2206 SsidLength = len;
2207 pSsidStr = pBssSsid;
2208
2209 while ( SsidLength )
2210 {
2211 if( *pSsidStr )
2212 break;
2213
2214 pSsidStr++;
2215 SsidLength--;
2216 }
2217
2218 if( 0 == SsidLength )
2219 {
2220 fNullSsid = TRUE;
2221 break;
2222 }
2223 }
2224 while( 0 );
2225
2226 return fNullSsid;
2227}
2228
2229
2230tANI_U32 csrGetFragThresh( tHalHandle hHal )
2231{
2232 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2233
2234 return pMac->roam.configParam.FragmentationThreshold;
2235}
2236
2237tANI_U32 csrGetRTSThresh( tHalHandle hHal )
2238{
2239 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2240
2241 return pMac->roam.configParam.RTSThreshold;
2242}
2243
2244eCsrPhyMode csrTranslateToPhyModeFromBssDesc( tSirBssDescription *pSirBssDesc )
2245{
2246 eCsrPhyMode phyMode;
2247
2248 switch ( pSirBssDesc->nwType )
2249 {
2250 case eSIR_11A_NW_TYPE:
2251 phyMode = eCSR_DOT11_MODE_11a;
2252 break;
2253
2254 case eSIR_11B_NW_TYPE:
2255 phyMode = eCSR_DOT11_MODE_11b;
2256 break;
2257
2258 case eSIR_11G_NW_TYPE:
2259 phyMode = eCSR_DOT11_MODE_11g;
2260 break;
2261
2262 case eSIR_11N_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 phyMode = eCSR_DOT11_MODE_11n;
2264 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002265#ifdef WLAN_FEATURE_11AC
2266 case eSIR_11AC_NW_TYPE:
2267 default:
2268 phyMode = eCSR_DOT11_MODE_11ac;
2269#else
2270 default:
2271 phyMode = eCSR_DOT11_MODE_11n;
2272#endif
2273 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 return( phyMode );
2276}
2277
2278
2279tANI_U32 csrTranslateToWNICfgDot11Mode(tpAniSirGlobal pMac, eCsrCfgDot11Mode csrDot11Mode)
2280{
2281 tANI_U32 ret;
2282
2283 switch(csrDot11Mode)
2284 {
2285 case eCSR_CFG_DOT11_MODE_AUTO:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002286 smsLog(pMac, LOGW, FL(" Warning: sees eCSR_CFG_DOT11_MODE_AUTO "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 //We cannot decide until now.
2288 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2289 {
2290 ret = WNI_CFG_DOT11_MODE_TAURUS;
2291 }
2292 else
2293 {
Mukul Sharma45063942015-04-01 20:07:59 +05302294#ifdef WLAN_FEATURE_11AC
2295 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2296 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2297 ret = WNI_CFG_DOT11_MODE_11AC;
2298 else
2299 ret = WNI_CFG_DOT11_MODE_11N;
2300#else
2301 ret = WNI_CFG_DOT11_MODE_11N;
2302#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 }
2304 break;
2305 case eCSR_CFG_DOT11_MODE_TAURUS:
2306 ret = WNI_CFG_DOT11_MODE_TAURUS;
2307 break;
2308 case eCSR_CFG_DOT11_MODE_11A:
2309 ret = WNI_CFG_DOT11_MODE_11A;
2310 break;
2311 case eCSR_CFG_DOT11_MODE_11B:
2312 ret = WNI_CFG_DOT11_MODE_11B;
2313 break;
2314 case eCSR_CFG_DOT11_MODE_11G:
2315 ret = WNI_CFG_DOT11_MODE_11G;
2316 break;
2317 case eCSR_CFG_DOT11_MODE_11N:
2318 ret = WNI_CFG_DOT11_MODE_11N;
2319 break;
2320 case eCSR_CFG_DOT11_MODE_POLARIS:
2321 ret = WNI_CFG_DOT11_MODE_POLARIS;
2322 break;
2323 case eCSR_CFG_DOT11_MODE_TITAN:
2324 ret = WNI_CFG_DOT11_MODE_TITAN;
2325 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 case eCSR_CFG_DOT11_MODE_11G_ONLY:
Mukul Sharma45063942015-04-01 20:07:59 +05302327 ret = WNI_CFG_DOT11_MODE_11G_ONLY;
2328 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 case eCSR_CFG_DOT11_MODE_11N_ONLY:
Mukul Sharma45063942015-04-01 20:07:59 +05302330 ret = WNI_CFG_DOT11_MODE_11N_ONLY;
2331 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002332
2333#ifdef WLAN_FEATURE_11AC
Mukul Sharma45063942015-04-01 20:07:59 +05302334 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
2335 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2336 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2337 ret = WNI_CFG_DOT11_MODE_11AC_ONLY;
2338 else
2339 ret = WNI_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002340 break;
Mukul Sharma45063942015-04-01 20:07:59 +05302341 case eCSR_CFG_DOT11_MODE_11AC:
2342 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2343 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2344 ret = WNI_CFG_DOT11_MODE_11AC;
2345 else
2346 ret = WNI_CFG_DOT11_MODE_11N;
2347 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002348#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002350 smsLog(pMac, LOGW, FL("doesn't expect %d as csrDo11Mode"), csrDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 if(eCSR_BAND_24 == pMac->roam.configParam.eBand)
2352 {
2353 ret = WNI_CFG_DOT11_MODE_11G;
2354 }
2355 else
2356 {
2357 ret = WNI_CFG_DOT11_MODE_11A;
2358 }
2359 break;
2360 }
2361
2362 return (ret);
2363}
2364
2365
2366//This function should only return the super set of supported modes. 11n implies 11b/g/a/n.
2367eHalStatus csrGetPhyModeFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription,
2368 eCsrPhyMode *pPhyMode, tDot11fBeaconIEs *pIes)
2369{
2370 eHalStatus status = eHAL_STATUS_SUCCESS;
2371 eCsrPhyMode phyMode = csrTranslateToPhyModeFromBssDesc(pBSSDescription);
2372
2373 if( pIes )
2374 {
2375 if(pIes->Airgo.present)
2376 {
2377 if(pIes->Airgo.PropCapability.present)
2378 {
2379 if( PROP_CAPABILITY_GET( TAURUS, pIes->Airgo.PropCapability.capability ))
2380 {
2381 phyMode = eCSR_DOT11_MODE_TAURUS;
2382 }
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302383 }
2384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 if(pIes->HTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2386 {
2387 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002388#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05302389 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302390 {
2391 phyMode = eCSR_DOT11_MODE_11ac;
2392 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002393#endif
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 *pPhyMode = phyMode;
2396 }
2397
2398 return (status);
2399
2400}
2401
2402
2403//This function returns the correct eCSR_CFG_DOT11_MODE is the two phyModes matches
2404//bssPhyMode is the mode derived from the BSS description
2405//f5GhzBand is derived from the channel id of BSS description
2406tANI_BOOLEAN csrGetPhyModeInUse( eCsrPhyMode phyModeIn, eCsrPhyMode bssPhyMode, tANI_BOOLEAN f5GhzBand,
2407 eCsrCfgDot11Mode *pCfgDot11ModeToUse )
2408{
2409 tANI_BOOLEAN fMatch = FALSE;
2410 eCsrCfgDot11Mode cfgDot11Mode;
2411
2412 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; // to suppress compiler warning
2413
2414 switch( phyModeIn )
2415 {
2416 case eCSR_DOT11_MODE_abg: //11a or 11b or 11g
2417 if( f5GhzBand )
2418 {
2419 fMatch = TRUE;
2420 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2421 }
2422 else if( eCSR_DOT11_MODE_11b == bssPhyMode )
2423 {
2424 fMatch = TRUE;
2425 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2426 }
2427 else
2428 {
2429 fMatch = TRUE;
2430 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2431 }
2432 break;
2433
2434 case eCSR_DOT11_MODE_11a: //11a
2435 if( f5GhzBand )
2436 {
2437 fMatch = TRUE;
2438 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2439 }
2440 break;
2441
2442 case eCSR_DOT11_MODE_11a_ONLY: //11a
2443 if( eCSR_DOT11_MODE_11a == bssPhyMode )
2444 {
2445 fMatch = TRUE;
2446 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2447 }
2448 break;
2449
2450 case eCSR_DOT11_MODE_11g:
2451 if(!f5GhzBand)
2452 {
2453 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2454 {
2455 fMatch = TRUE;
2456 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2457 }
2458 else
2459 {
2460 fMatch = TRUE;
2461 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2462 }
2463 }
2464 break;
2465
2466 case eCSR_DOT11_MODE_11g_ONLY:
2467 if( eCSR_DOT11_MODE_11g == bssPhyMode )
2468 {
2469 fMatch = TRUE;
2470 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2471 }
2472 break;
2473
2474 case eCSR_DOT11_MODE_11b:
2475 if( !f5GhzBand )
2476 {
2477 fMatch = TRUE;
2478 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2479 }
2480 break;
2481
2482 case eCSR_DOT11_MODE_11b_ONLY:
2483 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2484 {
2485 fMatch = TRUE;
2486 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2487 }
2488 break;
2489
2490 case eCSR_DOT11_MODE_11n:
2491 fMatch = TRUE;
2492 switch(bssPhyMode)
2493 {
2494 case eCSR_DOT11_MODE_11g:
2495 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2496 break;
2497 case eCSR_DOT11_MODE_11b:
2498 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2499 break;
2500 case eCSR_DOT11_MODE_11a:
2501 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2502 break;
2503 case eCSR_DOT11_MODE_11n:
Jeff Johnsone7245742012-09-05 17:12:55 -07002504#ifdef WLAN_FEATURE_11AC
2505 case eCSR_DOT11_MODE_11ac:
2506#endif
2507 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2508 break;
2509
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 case eCSR_DOT11_MODE_TAURUS:
2511 default:
Jeff Johnsone7245742012-09-05 17:12:55 -07002512#ifdef WLAN_FEATURE_11AC
2513 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2514#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002516#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 break;
2518 }
2519 break;
2520
2521 case eCSR_DOT11_MODE_11n_ONLY:
2522 if((eCSR_DOT11_MODE_11n == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2523 {
2524 fMatch = TRUE;
2525 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002526
2527 }
2528
2529 break;
2530#ifdef WLAN_FEATURE_11AC
2531 case eCSR_DOT11_MODE_11ac:
2532 fMatch = TRUE;
2533 switch(bssPhyMode)
2534 {
2535 case eCSR_DOT11_MODE_11g:
2536 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2537 break;
2538 case eCSR_DOT11_MODE_11b:
2539 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2540 break;
2541 case eCSR_DOT11_MODE_11a:
2542 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2543 break;
2544 case eCSR_DOT11_MODE_11n:
2545 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2546 break;
2547 case eCSR_DOT11_MODE_11ac:
2548 case eCSR_DOT11_MODE_TAURUS:
2549 default:
2550 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2551 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 }
2553 break;
2554
Jeff Johnsone7245742012-09-05 17:12:55 -07002555 case eCSR_DOT11_MODE_11ac_ONLY:
2556 if((eCSR_DOT11_MODE_11ac == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2557 {
2558 fMatch = TRUE;
2559 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2560 }
2561 break;
2562#endif
2563
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 case eCSR_DOT11_MODE_TAURUS:
2565 default:
2566 fMatch = TRUE;
2567 switch(bssPhyMode)
2568 {
2569 case eCSR_DOT11_MODE_11g:
2570 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2571 break;
2572 case eCSR_DOT11_MODE_11b:
2573 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2574 break;
2575 case eCSR_DOT11_MODE_11a:
2576 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2577 break;
2578 case eCSR_DOT11_MODE_11n:
2579 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2580 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002581#ifdef WLAN_FEATURE_11AC
2582 case eCSR_DOT11_MODE_11ac:
2583 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2584 break;
2585#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 case eCSR_DOT11_MODE_TAURUS:
2587 default:
2588 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
2589 break;
2590 }
2591 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 }
2593
2594 if ( fMatch && pCfgDot11ModeToUse )
2595 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002596#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudief5dd972012-10-11 15:06:09 -07002597 if(cfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC && (!IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)))
Jeff Johnsone7245742012-09-05 17:12:55 -07002598 {
2599 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2600 }
2601 else
2602#endif
2603 {
2604 *pCfgDot11ModeToUse = cfgDot11Mode;
2605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 return( fMatch );
2608}
2609
2610
2611//This function decides whether the one of the bit of phyMode is matching the mode in the BSS and allowed by the user
2612//setting, pMac->roam.configParam.uCfgDot11Mode. It returns the mode that fits the criteria.
2613tANI_BOOLEAN csrIsPhyModeMatch( tpAniSirGlobal pMac, tANI_U32 phyMode,
2614 tSirBssDescription *pSirBssDesc, tCsrRoamProfile *pProfile,
2615 eCsrCfgDot11Mode *pReturnCfgDot11Mode,
2616 tDot11fBeaconIEs *pIes)
2617{
2618 tANI_BOOLEAN fMatch = FALSE;
2619 eCsrPhyMode phyModeInBssDesc, phyMode2;
2620 eCsrCfgDot11Mode cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_TAURUS;
2621 tANI_U32 bitMask, loopCount;
2622
2623 if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pSirBssDesc, &phyModeInBssDesc, pIes )))
2624 {
2625 //In case some change change eCSR_DOT11_MODE_TAURUS to non-0
2626 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2627 {
2628 //Taurus means anything
2629 if ( eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode )
2630 {
2631 phyMode = eCSR_DOT11_MODE_abg;
2632 }
2633 else if(eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode)
2634 {
2635 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2636 {
2637 phyMode = eCSR_DOT11_MODE_TAURUS;
2638 }
2639 else
2640 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002641
2642#ifdef WLAN_FEATURE_11AC
2643 phyMode = eCSR_DOT11_MODE_11ac;
2644#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002646#endif
2647
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 }
2649 }
2650 else
2651 {
2652 //user's pick
2653 phyMode = pMac->roam.configParam.phyMode;
2654 }
2655 }
2656 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode) )
2657 {
2658 if(0 != phyMode)
2659 {
2660 if(eCSR_DOT11_MODE_AUTO & phyMode)
2661 {
2662 phyMode2 = eCSR_DOT11_MODE_AUTO & phyMode;
2663 }
2664 else
2665 {
2666 phyMode2 = eCSR_DOT11_MODE_TAURUS & phyMode;
2667 }
2668 }
2669 else
2670 {
2671 phyMode2 = phyMode;
2672 }
2673 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2674 &cfgDot11ModeToUse );
2675 }
2676 else
2677 {
2678 bitMask = 1;
2679 loopCount = 0;
2680 while(loopCount < eCSR_NUM_PHY_MODE)
2681 {
2682 if(0 != ( phyMode2 = (phyMode & (bitMask << loopCount++)) ))
2683 {
2684 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2685 &cfgDot11ModeToUse );
2686 if(fMatch) break;
2687 }
2688 }
2689 }
2690 if ( fMatch && pReturnCfgDot11Mode )
2691 {
2692 if( pProfile )
2693 {
2694 /* IEEE 11n spec (8.4.3): HT STA shall eliminate TKIP as a
2695 * choice for the pairwise cipher suite if CCMP is advertised
2696 * by the AP or if the AP included an HT capabilities element
2697 * in its Beacons and Probe Response.
2698 */
2699 if( (!CSR_IS_11n_ALLOWED( pProfile->negotiatedUCEncryptionType )) &&
2700 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11ModeToUse) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002701#ifdef WLAN_FEATURE_11AC
2702 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11ModeToUse) ||
2703#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11ModeToUse)) )
2705 {
2706 //We cannot do 11n here
2707 if( !CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId) )
2708 {
2709 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2710 }
2711 else
2712 {
2713 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2714 }
2715 }
2716 }
2717 *pReturnCfgDot11Mode = cfgDot11ModeToUse;
2718 }
2719 }
2720
2721 return( fMatch );
2722}
2723
2724
2725eCsrCfgDot11Mode csrFindBestPhyMode( tpAniSirGlobal pMac, tANI_U32 phyMode )
2726{
2727 eCsrCfgDot11Mode cfgDot11ModeToUse;
2728 eCsrBand eBand = pMac->roam.configParam.eBand;
2729
Jeff Johnsone7245742012-09-05 17:12:55 -07002730
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302731 if ((0 == phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002732#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302733 (eCSR_DOT11_MODE_11ac & phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002734#endif
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302735 (eCSR_DOT11_MODE_AUTO & phyMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 {
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302737#ifdef WLAN_FEATURE_11AC
2738 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2739 {
2740 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC;
2741 }
2742 else
2743#endif
2744 {
2745 /* Default to 11N mode if user has configured 11ac mode
2746 * and FW doesn't supports 11ac mode .
2747 */
2748 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 }
2751 else
2752 {
2753 if( ( eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY ) & phyMode )
2754 {
2755 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2756 }
2757 else if ( eCSR_DOT11_MODE_abg & phyMode )
2758 {
2759 if( eCSR_BAND_24 != eBand )
2760 {
2761 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2762 }
2763 else
2764 {
2765 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2766 }
2767 }
2768 else if( ( eCSR_DOT11_MODE_11a | eCSR_DOT11_MODE_11a_ONLY ) & phyMode )
2769 {
2770 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2771 }
2772 else if( ( eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY ) & phyMode )
2773 {
2774 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2775 }
2776 else
2777 {
2778 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B;
2779 }
2780 }
2781
2782 return ( cfgDot11ModeToUse );
2783}
2784
2785
2786
2787
2788tANI_U32 csrGet11hPowerConstraint( tHalHandle hHal, tDot11fIEPowerConstraints *pPowerConstraint )
2789{
2790 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2791 tANI_U32 localPowerConstraint = 0;
2792
2793 // check if .11h support is enabled, if not, the power constraint is 0.
2794 if(pMac->roam.configParam.Is11hSupportEnabled && pPowerConstraint->present)
2795 {
2796 localPowerConstraint = pPowerConstraint->localPowerConstraints;
2797 }
2798
2799 return( localPowerConstraint );
2800}
2801
2802
2803tANI_BOOLEAN csrIsProfileWpa( tCsrRoamProfile *pProfile )
2804{
2805 tANI_BOOLEAN fWpaProfile = FALSE;
2806
2807 switch ( pProfile->negotiatedAuthType )
2808 {
2809 case eCSR_AUTH_TYPE_WPA:
2810 case eCSR_AUTH_TYPE_WPA_PSK:
2811 case eCSR_AUTH_TYPE_WPA_NONE:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002812#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 case eCSR_AUTH_TYPE_CCKM_WPA:
2814#endif
2815 fWpaProfile = TRUE;
2816 break;
2817
2818 default:
2819 fWpaProfile = FALSE;
2820 break;
2821 }
2822
2823 if ( fWpaProfile )
2824 {
2825 switch ( pProfile->negotiatedUCEncryptionType )
2826 {
2827 case eCSR_ENCRYPT_TYPE_WEP40:
2828 case eCSR_ENCRYPT_TYPE_WEP104:
2829 case eCSR_ENCRYPT_TYPE_TKIP:
2830 case eCSR_ENCRYPT_TYPE_AES:
2831 fWpaProfile = TRUE;
2832 break;
2833
2834 default:
2835 fWpaProfile = FALSE;
2836 break;
2837 }
2838 }
2839 return( fWpaProfile );
2840}
2841
2842tANI_BOOLEAN csrIsProfileRSN( tCsrRoamProfile *pProfile )
2843{
2844 tANI_BOOLEAN fRSNProfile = FALSE;
2845
2846 switch ( pProfile->negotiatedAuthType )
2847 {
2848 case eCSR_AUTH_TYPE_RSN:
2849 case eCSR_AUTH_TYPE_RSN_PSK:
2850#ifdef WLAN_FEATURE_VOWIFI_11R
2851 case eCSR_AUTH_TYPE_FT_RSN:
2852 case eCSR_AUTH_TYPE_FT_RSN_PSK:
2853#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002854#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 case eCSR_AUTH_TYPE_CCKM_RSN:
2856#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002857#ifdef WLAN_FEATURE_11W
2858 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05302859 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07002860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 fRSNProfile = TRUE;
2862 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05302863 case eCSR_AUTH_TYPE_SAE:
2864 fRSNProfile = true;
2865 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002866
2867 default:
2868 fRSNProfile = FALSE;
2869 break;
2870 }
2871
2872 if ( fRSNProfile )
2873 {
2874 switch ( pProfile->negotiatedUCEncryptionType )
2875 {
2876 // !!REVIEW - For WPA2, use of RSN IE mandates
2877 // use of AES as encryption. Here, we qualify
2878 // even if encryption type is WEP or TKIP
2879 case eCSR_ENCRYPT_TYPE_WEP40:
2880 case eCSR_ENCRYPT_TYPE_WEP104:
2881 case eCSR_ENCRYPT_TYPE_TKIP:
2882 case eCSR_ENCRYPT_TYPE_AES:
2883 fRSNProfile = TRUE;
2884 break;
2885
2886 default:
2887 fRSNProfile = FALSE;
2888 break;
2889 }
2890 }
2891 return( fRSNProfile );
2892}
2893
Jeff Johnsone7245742012-09-05 17:12:55 -07002894eHalStatus
2895csrIsconcurrentsessionValid(tpAniSirGlobal pMac,tANI_U32 cursessionId,
2896 tVOS_CON_MODE currBssPersona)
2897{
2898 tANI_U32 sessionId = 0;
2899
2900 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2901 {
2902 if (cursessionId != sessionId )
2903 {
2904 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2905 {
2906 continue;
2907 }
2908
2909 switch (currBssPersona)
2910 {
2911 case VOS_STA_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -07002912 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05302913 smsLog(pMac, LOG4, FL(" Second session for persona %d"), currBssPersona);
Agarwal Ashishe16e1212014-05-15 14:51:36 +05302914 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07002915 }
2916 break;
2917
2918 case VOS_STA_SAP_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302919 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2920 == VOS_STA_SAP_MODE)&&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002921 (pMac->roam.roamSession[sessionId].connectState
2922 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002924 smsLog(pMac, LOGE, FL(" ****SoftAP mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002925 return eHAL_STATUS_FAILURE;
2926 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002927 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2928 == VOS_P2P_GO_MODE &&
2929 pMac->roam.roamSession[sessionId].connectState
2930 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2931 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2932 == VOS_IBSS_MODE &&
2933 pMac->roam.roamSession[sessionId].connectState
2934 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002936 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002937 return eHAL_STATUS_FAILURE;
2938 }
2939 break;
2940
2941 case VOS_P2P_CLIENT_MODE:
2942 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002943 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002944 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2945 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002946 smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002947 return eHAL_STATUS_FAILURE;
2948 }
2949 break;
2950
2951 case VOS_P2P_GO_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302952 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2953 == VOS_P2P_GO_MODE) &&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002954 (pMac->roam.roamSession[sessionId].connectState
2955 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002957 smsLog(pMac, LOGE, FL(" ****P2P GO mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002958 return eHAL_STATUS_FAILURE;
2959 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002960 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2961 == VOS_STA_SAP_MODE &&
2962 pMac->roam.roamSession[sessionId].connectState
2963 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2964 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2965 == VOS_IBSS_MODE &&
2966 pMac->roam.roamSession[sessionId].connectState
2967 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002968 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002969 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002970 return eHAL_STATUS_FAILURE;
2971 }
2972 break;
Ravi Joshia96ceb42013-05-20 18:52:39 -07002973 case VOS_IBSS_MODE:
2974 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2975 == VOS_IBSS_MODE) &&
2976 (pMac->roam.roamSession[sessionId].connectState
2977 != eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED))
2978 {
2979 smsLog(pMac, LOGE, FL(" ****IBSS mode already exists ****"));
2980 return eHAL_STATUS_FAILURE;
2981 }
2982 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2983 == VOS_P2P_GO_MODE ||
2984 pMac->roam.roamSession[sessionId].bssParams.bssPersona
2985 == VOS_STA_SAP_MODE) &&
2986 pMac->roam.roamSession[sessionId].connectState
2987 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)
2988 {
2989 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
2990 return eHAL_STATUS_FAILURE;
2991 }
2992 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002993 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002994 smsLog(pMac, LOGE, FL("***Persona not handled = %d*****"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07002995 break;
2996 }
2997 }
2998 }
2999 return eHAL_STATUS_SUCCESS;
3000
3001}
3002
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003003eHalStatus csrUpdateMCCp2pBeaconInterval(tpAniSirGlobal pMac)
Jeff Johnsone7245742012-09-05 17:12:55 -07003004{
3005 tANI_U32 sessionId = 0;
3006
3007 //If MCC is not supported just break and return SUCCESS
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003008 if ( !pMac->roam.configParam.fenableMCCMode){
3009 return eHAL_STATUS_FAILURE;
3010 }
3011
3012 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
3013 {
3014 /* If GO in MCC support different beacon interval,
3015 * change the BI of the P2P-GO */
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003016 if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3017 == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003018 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003019 /* Handle different BI scneario based on the configuration set.
3020 * If Config is set to 0x02 then Disconnect all the P2P clients
3021 * associated. If config is set to 0x04 then update the BI
3022 * without disconnecting all the clients
3023 */
3024 if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
3025 (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
3026 {
3027 return csrSendChngMCCBeaconInterval( pMac, sessionId);
3028 }
3029 //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
3030 else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
3031 {
3032 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
3033 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003034 }
3035 }
3036 return eHAL_STATUS_FAILURE;
3037}
3038
3039tANI_U16 csrCalculateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U16 sta_bi, tANI_U16 go_gbi)
3040{
3041 tANI_U8 num_beacons = 0;
3042 tANI_U8 is_multiple = 0;
3043 tANI_U16 go_cbi = 0;
3044 tANI_U16 go_fbi = 0;
3045 tANI_U16 sta_cbi = 0;
3046
3047 //If GO's given beacon Interval is less than 100
3048 if(go_gbi < 100)
3049 go_cbi = 100;
3050 //if GO's given beacon Interval is greater than or equal to 100
3051 else
3052 go_cbi = 100 + (go_gbi % 100);
3053
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05303054 if ( sta_bi == 0 )
3055 {
3056 /* There is possibility to receive zero as value.
3057 Which will cause divide by zero. Hence initialise with 100
3058 */
3059 sta_bi = 100;
3060 smsLog(pMac, LOGW,
3061 FL("sta_bi 2nd parameter is zero, initialise to %d"), sta_bi);
3062 }
3063
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003064 // check, if either one is multiple of another
3065 if (sta_bi > go_cbi)
3066 {
3067 is_multiple = !(sta_bi % go_cbi);
3068 }
3069 else
3070 {
3071 is_multiple = !(go_cbi % sta_bi);
3072 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08003073 // if it is multiple, then accept GO's beacon interval range [100,199] as it is
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003074 if (is_multiple)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003075 {
3076 return go_cbi;
3077 }
3078 //else , if it is not multiple, then then check for number of beacons to be
3079 //inserted based on sta BI
3080 num_beacons = sta_bi / 100;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003081 if (num_beacons)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003082 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08003083 // GO's final beacon interval will be aligned to sta beacon interval, but
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003084 //in the range of [100, 199].
3085 sta_cbi = sta_bi / num_beacons;
3086 go_fbi = sta_cbi;
3087 }
3088 else
3089 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08003090 // if STA beacon interval is less than 100, use GO's change bacon interval
3091 //instead of updating to STA's beacon interval.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003092 go_fbi = go_cbi;
3093 }
3094 return go_fbi;
3095}
3096
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003097eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003098 tANI_U16 *beaconInterval, tANI_U32 cursessionId,
3099 tVOS_CON_MODE currBssPersona)
3100{
3101 tANI_U32 sessionId = 0;
3102 tANI_U16 new_beaconInterval = 0;
3103
3104 //If MCC is not supported just break
3105 if (!pMac->roam.configParam.fenableMCCMode){
Jeff Johnsone7245742012-09-05 17:12:55 -07003106 return eHAL_STATUS_FAILURE;
3107 }
3108
3109 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
3110 {
3111 if (cursessionId != sessionId )
3112 {
3113 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
3114 {
3115 continue;
3116 }
3117
3118 switch (currBssPersona)
3119 {
3120 case VOS_STA_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003121 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3122 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003123 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
3124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003125 smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003126 }
3127 //IF SAP has started and STA wants to connect on different channel MCC should
3128 //MCC should not be enabled so making it false to enforce on same channel
3129 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3130 == VOS_STA_SAP_MODE)
3131 {
3132 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3133 != channelId )
3134 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05303135 smsLog(pMac, LOGE, FL("*** MCC with SAP+STA sessions ****"));
3136 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07003137 }
3138 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003139 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003140 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3141 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003142 /* if GO in MCC support different beacon interval,
3143 * change the BI of the P2P-GO */
3144 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
Jeff Johnsone7245742012-09-05 17:12:55 -07003145 != channelId ) &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003146 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003147 != *beaconInterval))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003148 {
3149 /* if GO in MCC support different beacon interval, return success */
3150 if ( pMac->roam.configParam.fAllowMCCGODiffBI == 0x01)
3151 {
3152 return eHAL_STATUS_SUCCESS;
3153 }
3154 // Send only Broadcast disassoc and update beaconInterval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003155 //If configuration is set to 0x04 then dont
3156 // disconnect all the station
3157 else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
3158 (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003159 {
3160 //Check to pass the right beacon Interval
3161 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval,
3162 pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003163 smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003164 //Update the becon Interval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003165 if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003166 {
3167 //Update the beaconInterval now
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003168 smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
3169 pMac->roam.configParam.fAllowMCCGODiffBI);
3170
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003171 pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
3172 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003173 return csrUpdateMCCp2pBeaconInterval(pMac);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003174 }
3175 return eHAL_STATUS_SUCCESS;
3176 }
3177 //Disconnect the P2P session
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003178 else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003179 {
3180 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
3181 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
3182 }
3183 else
3184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003185 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to preferred AP..."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003186 return eHAL_STATUS_FAILURE;
3187 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003188 }
3189 }
3190 break;
3191
3192 case VOS_P2P_CLIENT_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003193 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3194 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003195 == VOS_STA_MODE)) //check for P2P client mode
3196 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003197 smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003198 }
3199 //IF SAP has started and STA wants to connect on different channel MCC should
3200 //MCC should not be enabled so making it false to enforce on same channel
3201 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3202 == VOS_STA_SAP_MODE)
3203 {
3204 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3205 != channelId )
3206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003207 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP + CLIENT****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003208 return eHAL_STATUS_FAILURE;
3209 }
3210 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003211 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003212 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3213 {
3214 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
3215 != channelId ) &&
3216 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
3217 != *beaconInterval))
3218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003219 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to P2P_GO network ..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003220 return eHAL_STATUS_FAILURE;
3221 }
3222 }
3223 break;
3224
3225 case VOS_P2P_GO_MODE :
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003226 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003227 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3228 ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003229 == VOS_P2P_CLIENT_MODE) ||
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003230 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003231 == VOS_STA_MODE))) //check for P2P_client scenario
3232 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003233 if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003234 == 0 )&&
3235 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
3236 == 0))
3237 {
3238 continue;
3239 }
3240
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05303241 //Assert if connected profile beacon internal is ZERO
3242 if(!pMac->roam.roamSession[sessionId].\
3243 connectedProfile.beaconInterval)
3244 {
3245 smsLog( pMac, LOGE, FL(" Connected profile "
3246 "beacon interval is zero") );
3247 }
3248
Jeff Johnsone7245742012-09-05 17:12:55 -07003249
3250 if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003251 (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003252 != channelId ) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003253 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003254 != *beaconInterval))
3255 {
3256 /*
3257 * Updated beaconInterval should be used only when we are starting a new BSS
3258 * not incase of client or STA case
3259 */
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003260 //Calculate beacon Interval for P2P-GO incase of MCC
3261 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac,
Chet Lanctot4c986162013-05-08 13:59:56 -07003262 pMac->roam.roamSession[sessionId].bssParams.beaconInterval,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003263 *beaconInterval );
3264 if(*beaconInterval != new_beaconInterval)
3265 *beaconInterval = new_beaconInterval;
Jeff Johnsone7245742012-09-05 17:12:55 -07003266 return eHAL_STATUS_SUCCESS;
3267 }
3268 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003269 }
3270 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003271
3272 default :
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303273 smsLog(pMac, LOGE, FL(" Persona not supported : %d"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003274 return eHAL_STATUS_FAILURE;
3275 }
3276 }
3277 }
3278
3279 return eHAL_STATUS_SUCCESS;
3280}
Jeff Johnson295189b2012-06-20 16:38:30 -07003281
3282#ifdef WLAN_FEATURE_VOWIFI_11R
3283/* Function to return TRUE if the authtype is 11r */
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003284tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -07003285{
3286 switch ( AuthType )
3287 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003288 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3289 if(mdiePresent)
3290 return TRUE;
3291 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3293 case eCSR_AUTH_TYPE_FT_RSN:
3294 return TRUE;
3295 break;
3296 default:
3297 break;
3298 }
3299 return FALSE;
3300}
3301
3302/* Function to return TRUE if the profile is 11r */
3303tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
3304{
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003305 return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
Jeff Johnson295189b2012-06-20 16:38:30 -07003306}
3307
3308#endif
3309
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003310#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003311
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003312/* Function to return TRUE if the authtype is ESE */
3313tANI_BOOLEAN csrIsAuthTypeESE( eCsrAuthType AuthType )
Jeff Johnson295189b2012-06-20 16:38:30 -07003314{
3315 switch ( AuthType )
3316 {
3317 case eCSR_AUTH_TYPE_CCKM_WPA:
3318 case eCSR_AUTH_TYPE_CCKM_RSN:
3319 return TRUE;
3320 break;
3321 default:
3322 break;
3323 }
3324 return FALSE;
3325}
3326
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003327/* Function to return TRUE if the profile is ESE */
3328tANI_BOOLEAN csrIsProfileESE( tCsrRoamProfile *pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003329{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003330 return (csrIsAuthTypeESE( pProfile->negotiatedAuthType ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003331}
3332
3333#endif
3334
3335#ifdef FEATURE_WLAN_WAPI
3336tANI_BOOLEAN csrIsProfileWapi( tCsrRoamProfile *pProfile )
3337{
3338 tANI_BOOLEAN fWapiProfile = FALSE;
3339
3340 switch ( pProfile->negotiatedAuthType )
3341 {
3342 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
3343 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
3344 fWapiProfile = TRUE;
3345 break;
3346
3347 default:
3348 fWapiProfile = FALSE;
3349 break;
3350 }
3351
3352 if ( fWapiProfile )
3353 {
3354 switch ( pProfile->negotiatedUCEncryptionType )
3355 {
3356 case eCSR_ENCRYPT_TYPE_WPI:
3357 fWapiProfile = TRUE;
3358 break;
3359
3360 default:
3361 fWapiProfile = FALSE;
3362 break;
3363 }
3364 }
3365 return( fWapiProfile );
3366}
3367
3368static tANI_BOOLEAN csrIsWapiOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3369{
Kiet Lam64c1b492013-07-12 13:56:44 +05303370 return (vos_mem_compare(Oui1, Oui2, CSR_WAPI_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003371}
3372
3373static tANI_BOOLEAN csrIsWapiOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3374 tANI_U8 cAllCyphers,
3375 tANI_U8 Cypher[],
3376 tANI_U8 Oui[] )
3377{
3378 tANI_BOOLEAN fYes = FALSE;
3379 tANI_U8 idx;
3380
3381 for ( idx = 0; idx < cAllCyphers; idx++ )
3382 {
3383 if ( csrIsWapiOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3384 {
3385 fYes = TRUE;
3386 break;
3387 }
3388 }
3389
3390 if ( fYes && Oui )
3391 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303392 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 }
3394
3395 return( fYes );
3396}
3397#endif /* FEATURE_WLAN_WAPI */
3398
3399static tANI_BOOLEAN csrIsWpaOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3400{
Kiet Lam64c1b492013-07-12 13:56:44 +05303401 return(vos_mem_compare(Oui1, Oui2, CSR_WPA_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003402}
3403
3404static tANI_BOOLEAN csrIsOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3405 tANI_U8 cAllCyphers,
3406 tANI_U8 Cypher[],
3407 tANI_U8 Oui[] )
3408{
3409 tANI_BOOLEAN fYes = FALSE;
3410 tANI_U8 idx;
3411
3412 for ( idx = 0; idx < cAllCyphers; idx++ )
3413 {
3414 if ( csrIsWpaOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3415 {
3416 fYes = TRUE;
3417 break;
3418 }
3419 }
3420
3421 if ( fYes && Oui )
3422 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303423 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 }
3425
3426 return( fYes );
3427}
3428
3429static tANI_BOOLEAN csrMatchRSNOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3430 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3431 tANI_U8 Oui[] )
3432{
3433 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui[ouiIndex], Oui ) );
3434
3435}
3436
3437#ifdef FEATURE_WLAN_WAPI
3438static tANI_BOOLEAN csrMatchWapiOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3439 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3440 tANI_U8 Oui[] )
3441{
Kaushik, Sushantfe230152014-04-08 14:37:47 +05303442 if (ouiIndex < CSR_WAPI_OUI_ROW_SIZE)// since csrWapiOui row size is 3 .
3443 return( csrIsWapiOuiMatch( pMac, AllCyphers, cAllCyphers,
3444 csrWapiOui[ouiIndex], Oui ) );
3445 else
3446 return FALSE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07003447
3448}
3449#endif /* FEATURE_WLAN_WAPI */
3450
3451static tANI_BOOLEAN csrMatchWPAOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3452 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3453 tANI_U8 Oui[] )
3454{
3455 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui[ouiIndex], Oui ) );
3456
3457}
3458
3459#if 0
3460static tANI_BOOLEAN csrIsRSNUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3461 tANI_U8 cAllCyphers,
3462 tANI_U8 Oui[] )
3463{
3464 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui00, Oui ) );
3465}
3466
3467static tANI_BOOLEAN csrIsRSNMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3468 tANI_U8 cAllCyphers,
3469 tANI_U8 Oui[] )
3470{
3471 tANI_BOOLEAN fYes = FALSE;
3472
3473 // Check Wep 104 first, if fails, then check Wep40.
3474 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui05, Oui );
3475
3476 if ( !fYes )
3477 {
3478 // if not Wep-104, check Wep-40
3479 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui01, Oui );
3480 }
3481
3482 return( fYes );
3483}
3484
3485
3486static tANI_BOOLEAN csrIsRSNUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3487 tANI_U8 cAllCyphers,
3488 tANI_U8 Oui[] )
3489{
3490 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3491}
3492
3493
3494static tANI_BOOLEAN csrIsRSNMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3495 tANI_U8 cAllCyphers,
3496 tANI_U8 Oui[] )
3497{
3498 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3499}
3500
3501static tANI_BOOLEAN csrIsRSNUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3502 tANI_U8 cAllCyphers,
3503 tANI_U8 Oui[] )
3504{
3505 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3506}
3507
3508static tANI_BOOLEAN csrIsRSNMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3509 tANI_U8 cAllCyphers,
3510 tANI_U8 Oui[] )
3511{
3512 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3513}
3514#endif
3515#ifdef FEATURE_WLAN_WAPI
3516static tANI_BOOLEAN csrIsAuthWapiCert( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3517 tANI_U8 cAllSuites,
3518 tANI_U8 Oui[] )
3519{
3520 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[1], Oui ) );
3521}
3522static tANI_BOOLEAN csrIsAuthWapiPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3523 tANI_U8 cAllSuites,
3524 tANI_U8 Oui[] )
3525{
3526 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[2], Oui ) );
3527}
3528#endif /* FEATURE_WLAN_WAPI */
3529
3530#ifdef WLAN_FEATURE_VOWIFI_11R
3531
3532/*
3533 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3534 * here. This matches for FT Auth with the 802.1X exchange.
3535 *
3536 */
3537static tANI_BOOLEAN csrIsFTAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3538 tANI_U8 cAllSuites,
3539 tANI_U8 Oui[] )
3540{
3541 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[03], Oui ) );
3542}
3543
3544/*
3545 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3546 * here. This matches for FT Auth with the PSK.
3547 *
3548 */
3549static tANI_BOOLEAN csrIsFTAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3550 tANI_U8 cAllSuites,
3551 tANI_U8 Oui[] )
3552{
3553 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[04], Oui ) );
3554}
3555
3556#endif
3557
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003558#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003559
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003560/*
3561 * Function for ESE CCKM AKM Authentication. We match the CCKM AKM Authentication Key Management suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 * here. This matches for CCKM AKM Auth with the 802.1X exchange.
3563 *
3564 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003565static tANI_BOOLEAN csrIsEseCckmAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 tANI_U8 cAllSuites,
3567 tANI_U8 Oui[] )
3568{
3569 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[06], Oui ) );
3570}
3571
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003572static tANI_BOOLEAN csrIsEseCckmAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 tANI_U8 cAllSuites,
3574 tANI_U8 Oui[] )
3575{
3576 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[06], Oui ) );
3577}
3578
3579#endif
3580
3581static tANI_BOOLEAN csrIsAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3582 tANI_U8 cAllSuites,
3583 tANI_U8 Oui[] )
3584{
Jeff Johnson295189b2012-06-20 16:38:30 -07003585 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[01], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003586}
3587static tANI_BOOLEAN csrIsAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3588 tANI_U8 cAllSuites,
3589 tANI_U8 Oui[] )
3590{
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[02], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003592}
3593
Chet Lanctot186b5732013-03-18 10:26:30 -07003594#ifdef WLAN_FEATURE_11W
3595static tANI_BOOLEAN csrIsAuthRSNPskSha256( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3596 tANI_U8 cAllSuites,
3597 tANI_U8 Oui[] )
3598{
Chet Lanctot4c986162013-05-08 13:59:56 -07003599 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[07], Oui );
Chet Lanctot186b5732013-03-18 10:26:30 -07003600}
Abhishek Singhae408032014-09-25 17:22:04 +05303601static tANI_BOOLEAN csrIsAuthRSN8021xSha256(tpAniSirGlobal pMac,
3602 tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3603 tANI_U8 cAllSuites,
3604 tANI_U8 Oui[] )
3605{
3606 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[8], Oui );
3607}
Chet Lanctot186b5732013-03-18 10:26:30 -07003608#endif
3609
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303610#ifdef WLAN_FEATURE_SAE
3611/**
3612 * csr_is_auth_wpa_sae() - check whether oui is SAE
3613 * @mac: Global MAC context
3614 * @all_suites: pointer to all supported akm suites
3615 * @suite_count: all supported akm suites count
3616 * @oui: Oui needs to be matched
3617 *
3618 * Return: True if OUI is SAE, false otherwise
3619 */
3620static bool csr_is_auth_wpa_sae(tpAniSirGlobal mac,
3621 uint8_t all_suites[][CSR_RSN_OUI_SIZE],
3622 uint8_t suite_count, uint8_t oui[])
3623{
3624 return csrIsOuiMatch(mac, all_suites, suite_count, csrRSNOui[ENUM_SAE],
3625 oui);
3626}
3627#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003628static tANI_BOOLEAN csrIsAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3629 tANI_U8 cAllSuites,
3630 tANI_U8 Oui[] )
3631{
3632 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[01], Oui ) );
3633}
3634
3635#ifdef NOT_CURRENTLY_USED
3636static tANI_BOOLEAN csrIsAuth802_1x( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3637 tANI_U8 cAllSuites,
3638 tANI_U8 Oui[] )
3639{
3640 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[00], Oui ) );
3641}
3642#endif // NOT_CURRENTLY_USED
3643
3644static tANI_BOOLEAN csrIsAuthWpaPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3645 tANI_U8 cAllSuites,
3646 tANI_U8 Oui[] )
3647{
3648 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[02], Oui ) );
3649}
3650#if 0
3651static tANI_BOOLEAN csrIsUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3652 tANI_U8 cAllCyphers,
3653 tANI_U8 Oui[] )
3654{
3655 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui00, Oui ) );
3656}
3657
3658static tANI_BOOLEAN csrIsUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3659 tANI_U8 cAllCyphers,
3660 tANI_U8 Oui[] )
3661{
3662 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3663}
3664
3665static tANI_BOOLEAN csrIsUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3666 tANI_U8 cAllCyphers,
3667 tANI_U8 Oui[] )
3668{
3669 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3670}
3671
3672
3673static tANI_BOOLEAN csrIsMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3674 tANI_U8 cAllCyphers,
3675 tANI_U8 Oui[] )
3676{
3677 tANI_BOOLEAN fYes = FALSE;
3678
3679 // Check Wep 104 first, if fails, then check Wep40.
3680 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui05, Oui );
3681
3682 if ( !fYes )
3683 {
3684 // if not Wep-104, check Wep-40
3685 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui01, Oui );
3686 }
3687
3688 return( fYes );
3689}
3690
3691
3692static tANI_BOOLEAN csrIsMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3693 tANI_U8 cAllCyphers,
3694 tANI_U8 Oui[] )
3695{
3696 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3697}
3698
3699
3700static tANI_BOOLEAN csrIsMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3701 tANI_U8 cAllCyphers,
3702 tANI_U8 Oui[] )
3703{
3704 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3705}
3706
3707#endif
3708
3709tANI_U8 csrGetOUIIndexFromCipher( eCsrEncryptionType enType )
3710{
3711 tANI_U8 OUIIndex;
3712
3713 switch ( enType )
3714 {
3715 case eCSR_ENCRYPT_TYPE_WEP40:
3716 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3717 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX;
3718 break;
3719 case eCSR_ENCRYPT_TYPE_WEP104:
3720 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3721 OUIIndex = CSR_OUI_WEP104_INDEX;
3722 break;
3723 case eCSR_ENCRYPT_TYPE_TKIP:
3724 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX;
3725 break;
3726 case eCSR_ENCRYPT_TYPE_AES:
3727 OUIIndex = CSR_OUI_AES_INDEX;
3728 break;
3729 case eCSR_ENCRYPT_TYPE_NONE:
3730 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX;
3731 break;
3732#ifdef FEATURE_WLAN_WAPI
3733 case eCSR_ENCRYPT_TYPE_WPI:
3734 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX;
3735 break;
3736#endif /* FEATURE_WLAN_WAPI */
3737 default: //HOWTO handle this?
3738 OUIIndex = CSR_OUI_RESERVED_INDEX;
3739 break;
3740 }//switch
3741
3742 return OUIIndex;
3743}
3744
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303745#ifdef WLAN_FEATURE_SAE
3746/**
3747 * csr_check_sae_auth() - update negotiated auth if matches to SAE auth type
3748 * @mac_ctx: pointer to mac context
3749 * @authsuites: auth suites
3750 * @c_auth_suites: auth suites count
3751 * @authentication: authentication
3752 * @auth_type: authentication type list
3753 * @index: current counter
3754 * @neg_authtype: pointer to negotiated auth
3755 *
3756 * Return: None
3757 */
3758static void csr_check_sae_auth(tpAniSirGlobal mac_ctx,
3759 uint8_t authsuites[][CSR_RSN_OUI_SIZE],
3760 uint8_t c_auth_suites,
3761 uint8_t authentication[],
3762 tCsrAuthList *auth_type,
3763 uint8_t index, eCsrAuthType *neg_authtype)
3764{
3765 if ((*neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) &&
3766 csr_is_auth_wpa_sae(mac_ctx, authsuites, c_auth_suites,
3767 authentication)) {
3768 if (eCSR_AUTH_TYPE_SAE == auth_type->authType[index])
3769 *neg_authtype = eCSR_AUTH_TYPE_SAE;
3770 }
3771 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3772 FL("negotiated auth type is %d"), *neg_authtype);
3773}
3774#else
3775static void csr_check_sae_auth(tpAniSirGlobal mac_ctx,
3776 uint8_t authsuites[][CSR_RSN_OUI_SIZE],
3777 uint8_t c_auth_suites,
3778 uint8_t authentication[],
3779 tCsrAuthList *auth_type,
3780 uint8_t index, eCsrAuthType *neg_authtype)
3781{
3782}
3783#endif
3784
Jeff Johnson295189b2012-06-20 16:38:30 -07003785tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3786 tDot11fIERSN *pRSNIe,
3787 tANI_U8 *UnicastCypher,
3788 tANI_U8 *MulticastCypher,
3789 tANI_U8 *AuthSuite,
3790 tCsrRSNCapabilities *Capabilities,
3791 eCsrAuthType *pNegotiatedAuthtype,
3792 eCsrEncryptionType *pNegotiatedMCCipher )
3793{
3794 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3795 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3796 tANI_U8 cUnicastCyphers = 0;
3797 tANI_U8 cMulticastCyphers = 0;
3798 tANI_U8 cAuthSuites = 0, i;
3799 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3800 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3801 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3802 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3803 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3804 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3805
3806 do{
3807 if ( pRSNIe->present )
3808 {
3809 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303810 vos_mem_copy(MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05303812 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_cnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3814 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303815 vos_mem_copy((void *)&AuthSuites[i],
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05303816 (void *)&pRSNIe->akm_suite[i],
Kiet Lam64c1b492013-07-12 13:56:44 +05303817 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 }
3819
3820 //Check - Is requested Unicast Cipher supported by the BSS.
3821 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3822 csrGetOUIIndexFromCipher( enType ), Unicast );
3823
3824 if( !fAcceptableCyphers ) break;
3825
3826
3827 //Unicast is supported. Pick the first matching Group cipher, if any.
3828 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3829 {
3830 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3831 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3832 if(fAcceptableCyphers)
3833 {
3834 break;
3835 }
3836 }
3837 if( !fAcceptableCyphers ) break;
3838
3839 if( pNegotiatedMCCipher )
3840 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3841
3842 /* Initializing with FALSE as it has TRUE value already */
3843 fAcceptableCyphers = FALSE;
3844 for (i = 0 ; i < pAuthType->numEntries; i++)
3845 {
3846 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
Abhinav Kumar4d44f632019-08-02 13:55:54 +05303847
3848 /* Set SAE as first preference */
3849 csr_check_sae_auth(pMac, AuthSuites, cAuthSuites,
3850 Authentication, pAuthType, i, &negAuthType);
3851
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 #ifdef WLAN_FEATURE_VOWIFI_11R
3853 /* Changed the AKM suites according to order of preference */
3854 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3855 {
3856 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3857 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3858 }
3859 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3860 {
3861 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3862 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3863 }
3864#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003865#ifdef FEATURE_WLAN_ESE
3866 /* ESE only supports 802.1X. No PSK. */
3867 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 {
3869 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3870 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3871 }
3872#endif
3873 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3874 {
3875 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3876 negAuthType = eCSR_AUTH_TYPE_RSN;
3877 }
3878 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3879 {
3880 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3881 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3882 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003883#ifdef WLAN_FEATURE_11W
3884 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3885 {
3886 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3887 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3888 }
Abhishek Singhae408032014-09-25 17:22:04 +05303889 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) &&
3890 csrIsAuthRSN8021xSha256(pMac, AuthSuites,
3891 cAuthSuites, Authentication)) {
3892 if (eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
3893 pAuthType->authType[i])
3894 negAuthType = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3895 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003896#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003897
3898 // The 1st auth type in the APs RSN IE, to match stations connecting
3899 // profiles auth type will cause us to exit this loop
3900 // This is added as some APs advertise multiple akms in the RSN IE.
3901 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3902 {
3903 fAcceptableCyphers = TRUE;
3904 break;
3905 }
3906 } // for
3907 }
3908
3909 }while (0);
3910
3911 if ( fAcceptableCyphers )
3912 {
3913 if ( MulticastCypher )
3914 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303915 vos_mem_copy(MulticastCypher, Multicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 }
3917
3918 if ( UnicastCypher )
3919 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303920 vos_mem_copy(UnicastCypher, Unicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 }
3922
3923 if ( AuthSuite )
3924 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303925 vos_mem_copy(AuthSuite, Authentication, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 }
3927
3928 if ( pNegotiatedAuthtype )
3929 {
3930 *pNegotiatedAuthtype = negAuthType;
3931 }
3932 if ( Capabilities )
3933 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003934 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3935 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3936 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003937 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
Abhishek Singhf53e89d2015-06-18 12:30:00 +05303938#ifdef WLAN_FEATURE_11W
Chet Lanctot186b5732013-03-18 10:26:30 -07003939 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3940 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
Abhishek Singhf53e89d2015-06-18 12:30:00 +05303941#else
3942 Capabilities->MFPRequired = 0 ; // Bit 6 MFPR
3943 Capabilities->MFPCapable = 0 ; // Bit 7 MFPC
3944#endif
3945
Chet Lanctot186b5732013-03-18 10:26:30 -07003946 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 }
3948 }
3949 return( fAcceptableCyphers );
3950}
3951
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303952#ifdef WLAN_FEATURE_11W
3953/* ---------------------------------------------------------------------------
3954 \fn csrIsPMFCapabilitiesInRSNMatch
Jeff Johnson295189b2012-06-20 16:38:30 -07003955
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303956 \brief this function is to match our current capabilities with the AP
3957 to which we are expecting make the connection.
3958
3959 \param hHal - HAL Pointer
3960 pFilterMFPEnabled - given by supplicant to us to specify what kind
3961 of connection supplicant is expecting to make
3962 if it is enabled then make PMF connection.
3963 if it is disabled then make normal connection.
3964 pFilterMFPRequired - given by supplicant based on our configuration
3965 if it is 1 then we will require mandatory
3966 PMF connection and if it is 0 then we PMF
3967 connection is optional.
3968 pFilterMFPCapable - given by supplicant based on our configuration
3969 if it 1 then we are PMF capable and if it 0
3970 then we are not PMF capable.
3971 pRSNIe - RSNIe from Beacon/probe response of
3972 neighbor AP against which we will compare
3973 our capabilities.
3974
3975 \return tANI_BOOLEAN - if our PMF capabilities matches with AP then we
3976 will return true to indicate that we are good
3977 to make connection with it. Else we will return
3978 false.
3979 -------------------------------------------------------------------------------*/
3980static tANI_BOOLEAN
3981csrIsPMFCapabilitiesInRSNMatch( tHalHandle hHal,
3982 tANI_BOOLEAN *pFilterMFPEnabled,
3983 tANI_U8 *pFilterMFPRequired,
3984 tANI_U8 *pFilterMFPCapable,
3985 tDot11fIERSN *pRSNIe)
3986{
3987 tANI_U8 apProfileMFPCapable = 0;
3988 tANI_U8 apProfileMFPRequired = 0;
3989 if (pRSNIe && pFilterMFPEnabled && pFilterMFPCapable && pFilterMFPRequired)
3990 {
3991 /* Extracting MFPCapable bit from RSN Ie */
3992 apProfileMFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1;
3993 apProfileMFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1;
3994 if (*pFilterMFPEnabled && *pFilterMFPCapable && *pFilterMFPRequired
3995 && (apProfileMFPCapable == 0))
3996 {
3997 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3998 "AP is not capable to make PMF connection");
3999 return VOS_FALSE;
4000 }
4001 else if (*pFilterMFPEnabled && *pFilterMFPCapable &&
4002 !(*pFilterMFPRequired) && (apProfileMFPCapable == 0))
4003 {
4004 /*
4005 * This is tricky, because supplicant asked us to make mandatory
4006 * PMF connection eventhough PMF connection is optional here.
4007 * so if AP is not capable of PMF then drop it. Don't try to
4008 * connect with it.
4009 */
4010 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4011 "we need PMF connection & AP isn't capable to make PMF connection");
4012 return VOS_FALSE;
4013 }
4014 else if (!(*pFilterMFPCapable) &&
4015 apProfileMFPCapable && apProfileMFPRequired)
4016 {
4017 /*
4018 * In this case, AP with whom we trying to connect requires
4019 * mandatory PMF connections and we are not capable so this AP
4020 * is not good choice to connect
4021 */
4022 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4023 "AP needs PMF connection and we are not capable of pmf connection");
4024 return VOS_FALSE;
4025 }
4026 else if (!(*pFilterMFPEnabled) && *pFilterMFPCapable &&
4027 (apProfileMFPCapable == 1))
4028 {
4029 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4030 "we don't need PMF connection eventhough both parties are capable");
4031 return VOS_FALSE;
4032 }
4033 }
4034 return VOS_TRUE;
4035}
4036#endif
4037
4038tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType,
4039 eCsrEncryptionType enType,
4040 tCsrEncryptionList *pEnMcType,
4041 tANI_BOOLEAN *pMFPEnabled, tANI_U8 *pMFPRequired,
4042 tANI_U8 *pMFPCapable,
4043 tDot11fBeaconIEs *pIes,
4044 eCsrAuthType *pNegotiatedAuthType,
4045 eCsrEncryptionType *pNegotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07004046{
4047 tANI_BOOLEAN fRSNMatch = FALSE;
4048
4049 // See if the cyphers in the Bss description match with the settings in the profile.
4050 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
4051 pNegotiatedAuthType, pNegotiatedMCCipher );
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05304052#ifdef WLAN_FEATURE_11W
4053 /* If all the filter matches then finally checks for PMF capabilities */
4054 if (fRSNMatch)
4055 {
4056 fRSNMatch = csrIsPMFCapabilitiesInRSNMatch( hHal, pMFPEnabled,
4057 pMFPRequired, pMFPCapable,
4058 &pIes->RSN);
4059 }
4060#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004061
4062 return( fRSNMatch );
4063}
4064
4065
4066tANI_BOOLEAN csrLookupPMKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pPMKId )
4067{
4068 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4069 tANI_U32 Index;
4070 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4071
Jeff Johnson32d95a32012-09-10 13:15:23 -07004072 if(!pSession)
4073 {
4074 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4075 return FALSE;
4076 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07004077 /* to force the AP initiate fresh 802.1x authentication after re-association should not
4078 * fill the PMKID from cache this is needed
4079 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
4080
4081 if(pSession->fIgnorePMKIDCache)
4082 {
4083 pSession->fIgnorePMKIDCache = FALSE;
4084 return fRC;
4085 }
4086
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 do
4088 {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304089 for( Index=0; Index < CSR_MAX_PMKID_ALLOWED; Index++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304091 if( vos_mem_compare(pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 {
4093 // match found
4094 fMatchFound = TRUE;
4095 break;
4096 }
4097 }
4098
4099 if( !fMatchFound ) break;
4100
Kiet Lam64c1b492013-07-12 13:56:44 +05304101 vos_mem_copy(pPMKId, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004102
4103 fRC = TRUE;
4104 }
4105 while( 0 );
Sushant Kaushik0b343422015-05-25 17:15:55 +05304106 smsLog(pMac, LOG1, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 fRC, pSession->NumPmkidCache);
4108
4109 return fRC;
4110}
4111
4112
4113tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4114 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
4115{
4116 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4117 tANI_BOOLEAN fRSNMatch;
4118 tANI_U8 cbRSNIe = 0;
4119 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
4120 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
4121 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
4122 tCsrRSNAuthIe *pAuthSuite;
4123 tCsrRSNCapabilities RSNCapabilities;
4124 tCsrRSNPMKIe *pPMK;
4125 tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304126 uint32_t ret;
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004127#ifdef WLAN_FEATURE_11W
4128 tANI_U8 *pGroupMgmtCipherSuite;
4129#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 tDot11fBeaconIEs *pIesLocal = pIes;
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304131 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
Abhinav Kumar12560c32018-08-27 18:14:00 +05304132 tDot11fIERSN rsn_ie = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07004133
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004134 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004135
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 do
4137 {
4138 if ( !csrIsProfileRSN( pProfile ) ) break;
4139
4140 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4141 {
4142 break;
4143 }
4144
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304145 /* Use intersection of the RSN cap sent by user space and
4146 * the AP, so that only common capability are enabled.
4147 */
4148 if (pProfile->pRSNReqIE && pProfile->nRSNReqIELength) {
4149 ret = dot11fUnpackIeRSN(pMac, pProfile->pRSNReqIE + 2,
4150 pProfile->nRSNReqIELength -2, &rsn_ie);
4151 if (DOT11F_SUCCEEDED(ret)) {
4152 pIesLocal->RSN.RSN_Cap[0] = pIesLocal->RSN.RSN_Cap[0] &
4153 rsn_ie.RSN_Cap[0];
4154 pIesLocal->RSN.RSN_Cap[1] = pIesLocal->RSN.RSN_Cap[1] &
4155 rsn_ie.RSN_Cap[1];
4156 }
4157 }
4158
4159 /* See if the cyphers in the Bss description match with the settings in the profile */
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4161 &pProfile->mcEncryptionType, &pIesLocal->RSN,
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304162 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, &negAuthType, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 if ( !fRSNMatch ) break;
4164
4165 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
4166
4167 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
4168
Kiet Lam64c1b492013-07-12 13:56:44 +05304169 vos_mem_copy(pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004170
4171 pRSNIe->cUnicastCyphers = 1;
4172
Kiet Lam64c1b492013-07-12 13:56:44 +05304173 vos_mem_copy(&pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004174
4175 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
4176
4177 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304178 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004179
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304180 /* PreAuthSupported is an AP only capability */
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 RSNCapabilities.PreAuthSupported = 0;
Pragaspathi Thilagaraj830d7cc2018-06-19 01:18:53 +05304182
4183 /* Use the Management Frame Protection values given by the supplicant,
4184 * if AP and STA both are MFP capable.
4185 */
Chet Lanctot186b5732013-03-18 10:26:30 -07004186#ifdef WLAN_FEATURE_11W
4187 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
4188 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
4189#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
4191
4192 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
4193
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304194 if (
4195#ifdef FEATURE_WLAN_ESE
4196 (eCSR_AUTH_TYPE_CCKM_RSN != negAuthType) &&
4197#endif
4198 csrLookupPMKID( pMac, sessionId, pSirBssDesc->bssId, &(PMKId[0]) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 {
4200 pPMK->cPMKIDs = 1;
4201
Kiet Lam64c1b492013-07-12 13:56:44 +05304202 vos_mem_copy(pPMK->PMKIDList[0].PMKID, PMKId, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 }
4204 else
4205 {
4206 pPMK->cPMKIDs = 0;
4207 }
4208
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004209#ifdef WLAN_FEATURE_11W
4210 if ( pProfile->MFPEnabled )
4211 {
4212 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
4213 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
Kiet Lam64c1b492013-07-12 13:56:44 +05304214 vos_mem_copy(pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE);
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004215 }
4216#endif
4217
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4219 // Add in the size of the Auth suite (count plus a single OUI)
4220 // Add in the RSN caps field.
4221 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004222 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
4224 sizeof( *pAuthSuite ) +
4225 sizeof( tCsrRSNCapabilities ));
4226 if(pPMK->cPMKIDs)
4227 {
4228 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
4229 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
4230 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004231#ifdef WLAN_FEATURE_11W
4232 if ( pProfile->MFPEnabled )
4233 {
4234 if ( 0 == pPMK->cPMKIDs )
4235 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
4236 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
4237 }
4238#endif
4239
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 // return the size of the IE header (total) constructed...
4241 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
4242
4243 } while( 0 );
4244
4245 if( !pIes && pIesLocal )
4246 {
4247 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304248 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 }
4250
4251 return( cbRSNIe );
4252}
4253
4254
4255#ifdef FEATURE_WLAN_WAPI
4256tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4257 tDot11fIEWAPI *pWapiIe,
4258 tANI_U8 *UnicastCypher,
4259 tANI_U8 *MulticastCypher,
4260 tANI_U8 *AuthSuite,
4261 eCsrAuthType *pNegotiatedAuthtype,
4262 eCsrEncryptionType *pNegotiatedMCCipher )
4263{
4264 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4265 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4266 tANI_U8 cUnicastCyphers = 0;
4267 tANI_U8 cMulticastCyphers = 0;
4268 tANI_U8 cAuthSuites = 0, i;
4269 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
4270 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
4271 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
4272 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
4273 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
4274 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4275
4276 do{
4277 if ( pWapiIe->present )
4278 {
4279 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05304280 vos_mem_copy(MulticastCyphers, pWapiIe->multicast_cipher_suite,
4281 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
4283 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
4284 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
4285 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304286 vos_mem_copy((void *)&AuthSuites[i], (void *)&pWapiIe->akm_suites[i],
4287 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 }
4289
4290 //Check - Is requested Unicast Cipher supported by the BSS.
4291 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
4292 csrGetOUIIndexFromCipher( enType ), Unicast );
4293
4294 if( !fAcceptableCyphers ) break;
4295
4296
4297 //Unicast is supported. Pick the first matching Group cipher, if any.
4298 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4299 {
4300 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4301 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
4302 if(fAcceptableCyphers)
4303 {
4304 break;
4305 }
4306 }
4307 if( !fAcceptableCyphers ) break;
4308
4309 if( pNegotiatedMCCipher )
4310 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4311
4312 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4313 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
4314 {
4315 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4316 }
4317 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
4318 {
4319 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4320 }
4321 else
4322 {
4323 fAcceptableCyphers = FALSE;
4324 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4325 }
4326 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
4327 {
4328 //Caller doesn't care about auth type, or BSS doesn't match
4329 break;
4330 }
4331 fAcceptableCyphers = FALSE;
4332 for( i = 0 ; i < pAuthType->numEntries; i++ )
4333 {
4334 if( pAuthType->authType[i] == negAuthType )
4335 {
4336 fAcceptableCyphers = TRUE;
4337 break;
4338 }
4339 }
4340 }
4341 }while (0);
4342
4343 if ( fAcceptableCyphers )
4344 {
4345 if ( MulticastCypher )
4346 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304347 vos_mem_copy(MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 }
4349
4350 if ( UnicastCypher )
4351 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304352 vos_mem_copy(UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 }
4354
4355 if ( AuthSuite )
4356 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304357 vos_mem_copy(AuthSuite, Authentication, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 }
4359
4360 if ( pNegotiatedAuthtype )
4361 {
4362 *pNegotiatedAuthtype = negAuthType;
4363 }
4364 }
4365 return( fAcceptableCyphers );
4366}
4367
4368tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4369 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
4370{
4371 tANI_BOOLEAN fWapiMatch = FALSE;
4372
4373 // See if the cyphers in the Bss description match with the settings in the profile.
4374 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4375 pNegotiatedAuthType, pNegotiatedMCCipher );
4376
4377 return( fWapiMatch );
4378}
4379
4380tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4381{
4382 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4383 tANI_U32 Index;
4384 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4385
Jeff Johnson32d95a32012-09-10 13:15:23 -07004386 if(!pSession)
4387 {
4388 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4389 return FALSE;
4390 }
4391
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 do
4393 {
4394 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4395 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004396 smsLog(pMac, LOGW, "match BKID "MAC_ADDRESS_STR" to ",
4397 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05304398 if (vos_mem_compare(pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 {
4400 // match found
4401 fMatchFound = TRUE;
4402 break;
4403 }
4404 }
4405
4406 if( !fMatchFound ) break;
4407
Kiet Lam64c1b492013-07-12 13:56:44 +05304408 vos_mem_copy(pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004409
4410 fRC = TRUE;
4411 }
4412 while( 0 );
4413 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4414
4415 return fRC;
4416}
4417
4418tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4419 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4420{
4421 tANI_BOOLEAN fWapiMatch = FALSE;
4422 tANI_U8 cbWapiIe = 0;
4423 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4424 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4425 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4426 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4427 tANI_U8 *pWapi = NULL;
4428 tANI_BOOLEAN fBKIDFound = FALSE;
4429 tDot11fBeaconIEs *pIesLocal = pIes;
4430
4431 do
4432 {
4433 if ( !csrIsProfileWapi( pProfile ) ) break;
4434
4435 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4436 {
4437 break;
4438 }
4439
4440 // See if the cyphers in the Bss description match with the settings in the profile.
4441 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4442 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4443 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4444 if ( !fWapiMatch ) break;
4445
Kiet Lam64c1b492013-07-12 13:56:44 +05304446 vos_mem_set(pWapiIe, sizeof(tCsrWapiIe), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004447
4448 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4449
4450 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4451
4452 pWapiIe->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304453 vos_mem_copy(&pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004454
4455 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4456
4457 *pWapi = (tANI_U16)1; //cUnicastCyphers
4458 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304459 vos_mem_copy(pWapi, UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 pWapi += sizeof( UnicastCypher );
4461
Kiet Lam64c1b492013-07-12 13:56:44 +05304462 vos_mem_copy(pWapi, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 pWapi += sizeof( MulticastCypher );
4464
4465
4466 // WAPI capabilities follows the Auth Suite (two octects)
4467 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4468 // & since we already did a memset pWapiIe to 0, skip these fields
4469 pWapi +=2;
4470
4471 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4472
4473
4474 if( fBKIDFound )
4475 {
4476 /* Do we need to change the endianness here */
4477 *pWapi = (tANI_U16)1; //cBKIDs
4478 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304479 vos_mem_copy(pWapi, BKId, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 }
4481 else
4482 {
4483 *pWapi = 0;
4484 pWapi+=1;
4485 *pWapi = 0;
4486 pWapi+=1;
4487 }
4488
4489 // Add in the IE fields except the IE header
4490 // Add BKID count and BKID (if any)
4491 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4492
4493 /*2 bytes for BKID Count field*/
4494 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4495
4496 if(fBKIDFound)
4497 {
4498 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4499 }
4500 // return the size of the IE header (total) constructed...
4501 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4502
4503 } while( 0 );
4504
4505 if( !pIes && pIesLocal )
4506 {
4507 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304508 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 }
4510
4511 return( cbWapiIe );
4512}
4513#endif /* FEATURE_WLAN_WAPI */
4514
4515tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4516 tDot11fIEWPA *pWpaIe,
4517 tANI_U8 *UnicastCypher,
4518 tANI_U8 *MulticastCypher,
4519 tANI_U8 *AuthSuite,
4520 eCsrAuthType *pNegotiatedAuthtype,
4521 eCsrEncryptionType *pNegotiatedMCCipher )
4522{
4523 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4524 tANI_U8 cUnicastCyphers = 0;
4525 tANI_U8 cMulticastCyphers = 0;
4526 tANI_U8 cAuthSuites = 0;
4527 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4528 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4529 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4530 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4531 tANI_U8 i;
4532 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4533
4534 do
4535 {
4536 if ( pWpaIe->present )
4537 {
4538 cMulticastCyphers = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304539 vos_mem_copy(MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4541 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4542
4543 //Check - Is requested Unicast Cipher supported by the BSS.
4544 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4545 csrGetOUIIndexFromCipher( enType ), Unicast );
4546
4547 if( !fAcceptableCyphers ) break;
4548
4549
4550 //Unicast is supported. Pick the first matching Group cipher, if any.
4551 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4552 {
4553 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4554 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4555 if(fAcceptableCyphers)
4556 {
4557 break;
4558 }
4559 }
4560 if( !fAcceptableCyphers ) break;
4561
4562 if( pNegotiatedMCCipher )
4563 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4564
4565 /* Initializing with FALSE as it has TRUE value already */
4566 fAcceptableCyphers = FALSE;
4567 for (i = 0 ; i < pAuthType->numEntries; i++)
4568 {
4569 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4570 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4571 {
4572 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4573 negAuthType = eCSR_AUTH_TYPE_WPA;
4574 }
4575 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4576 {
4577 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4578 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4579 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004580#ifdef FEATURE_WLAN_ESE
4581 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 {
4583 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4584 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4585 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004586#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004587
4588 // The 1st auth type in the APs WPA IE, to match stations connecting
4589 // profiles auth type will cause us to exit this loop
4590 // This is added as some APs advertise multiple akms in the WPA IE.
4591 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4592 {
4593 fAcceptableCyphers = TRUE;
4594 break;
4595 }
4596 } // for
4597 }
4598 }while(0);
4599
4600 if ( fAcceptableCyphers )
4601 {
4602 if ( MulticastCypher )
4603 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304604 vos_mem_copy((tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 }
4606
4607 if ( UnicastCypher )
4608 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304609 vos_mem_copy((tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 }
4611
4612 if ( AuthSuite )
4613 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304614 vos_mem_copy((tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 }
4616
4617 if( pNegotiatedAuthtype )
4618 {
4619 *pNegotiatedAuthtype = negAuthType;
4620 }
4621 }
4622
4623 return( fAcceptableCyphers );
4624}
4625
4626
4627
4628tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4629 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4630{
4631 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4632
4633 // See if the cyphers in the Bss description match with the settings in the profile.
4634 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4635
4636 return( fWpaMatch );
4637}
4638
4639
4640tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4641 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4642{
4643 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4644 tANI_BOOLEAN fWpaMatch;
4645 tANI_U8 cbWpaIe = 0;
4646 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4647 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4648 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4649 tCsrWpaAuthIe *pAuthSuite;
4650 tDot11fBeaconIEs *pIesLocal = pIes;
4651
4652 do
4653 {
4654 if ( !csrIsProfileWpa( pProfile ) ) break;
4655
4656 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4657 {
4658 break;
4659 }
4660 // See if the cyphers in the Bss description match with the settings in the profile.
4661 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4662 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4663 if ( !fWpaMatch ) break;
4664
4665 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4666
Kiet Lam64c1b492013-07-12 13:56:44 +05304667 vos_mem_copy(pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004668
4669 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4670
Kiet Lam64c1b492013-07-12 13:56:44 +05304671 vos_mem_copy(pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004672
4673 pWpaIe->cUnicastCyphers = 1;
4674
Kiet Lam64c1b492013-07-12 13:56:44 +05304675 vos_mem_copy(&pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004676
4677 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4678
4679 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304680 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004681
4682 // The WPA capabilities follows the Auth Suite (two octects)--
4683 // this field is optional, and we always "send" zero, so just
4684 // remove it. This is consistent with our assumptions in the
4685 // frames compiler; c.f. bug 15234:
4686 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4687
4688 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4689 // Add in the size of the Auth suite (count plus a single OUI)
4690 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4691 sizeof( *pAuthSuite );
4692
4693 // return the size of the IE header (total) constructed...
4694 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4695
4696 } while( 0 );
4697
4698 if( !pIes && pIesLocal )
4699 {
4700 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304701 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 }
4703
4704 return( cbWpaIe );
4705}
4706
4707
4708tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4709 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4710{
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 tDot11IEHeader *pIEHeader;
4712 tSirMacPropIE *pSirMacPropIE;
4713 tANI_U32 cbParsed;
4714 tANI_U32 cbIE;
4715 int cExpectedIEs = 0;
4716 int cFoundIEs = 0;
4717 int cbPropIETotal;
4718
4719 pIEHeader = (tDot11IEHeader *)pIes;
4720 if(pWpaIe) cExpectedIEs++;
4721 if(pRSNIe) cExpectedIEs++;
4722
4723 // bss description length includes all fields other than the length itself
4724 cbParsed = 0;
4725
4726 // Loop as long as there is data left in the IE of the Bss Description
4727 // and the number of Expected IEs is NOT found yet.
4728 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4729 {
4730 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4731
4732 if ( ( cbIE + cbParsed ) > len ) break;
4733
4734 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4735 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4736 {
4737 switch( pIEHeader->ElementID )
4738 {
4739 // Parse the 221 (0xdd) Proprietary IEs here...
4740 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4741 // Airgo proprietary IE information.
4742 case SIR_MAC_WPA_EID:
4743 {
4744 tANI_U32 aniOUI;
4745 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4746
4747 pOui++;
4748 aniOUI = ANI_OUI;
4749 aniOUI = i_ntohl( aniOUI );
4750
4751 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4752 cbPropIETotal = pSirMacPropIE->length;
4753
4754 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4755 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4756 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4757 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4758 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4759 {
4760 }
4761 else
4762 {
4763 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4764
4765 if(!pWpaIe || !pcbWpaIe) break;
4766 // Check if this is a valid WPA IE. Then check that the
4767 // WPA OUI is in place and the version is one that we support.
4768 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
Kiet Lam64c1b492013-07-12 13:56:44 +05304769 ( vos_mem_compare( pIe->Oui, (void *)csrWpaOui[1],
4770 sizeof( pIe->Oui ) ) ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4772 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304773 vos_mem_copy(pWpaIe, pIe,
4774 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4776 cFoundIEs++;
4777
4778 break;
4779 }
4780 }
4781
4782 break;
4783 }
4784
4785 case SIR_MAC_RSN_EID:
4786 {
4787 tCsrRSNIe *pIe;
4788
4789 if(!pcbRSNIe || !pRSNIe) break;
4790 pIe = (tCsrRSNIe *)pIEHeader;
4791
4792 // Check the length of the RSN Ie to assure it is valid. Then check that the
4793 // version is one that we support.
4794
4795 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4796 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4797
4798 cFoundIEs++;
4799
4800 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4801 // the buffer passed in.
4802 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05304803 vos_mem_copy(pRSNIe, pIe,
4804 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4806
4807 break;
4808 }
4809
4810 // Add support for other IE here...
4811 default:
4812 break;
4813 }
4814 }
4815
4816 cbParsed += cbIE;
4817
4818 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4819
4820 }
4821
4822 // return a BOOL that tells if all of the IEs asked for were found...
4823 return( cFoundIEs == cExpectedIEs );
4824}
4825
4826
4827//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4828//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4829tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4830 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4831{
4832 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4833 tANI_U8 cbWpaIe = 0;
4834
4835 do
4836 {
4837 if ( !csrIsProfileWpa( pProfile ) ) break;
4838 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4839 {
4840 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4841 {
4842 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304843 vos_mem_copy(pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 }
4845 else
4846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004847 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 }
4849 }
4850 else
4851 {
4852 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4853 }
4854 }while(0);
4855
4856 return (cbWpaIe);
4857}
4858
4859
4860//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4861//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4862tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4863 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4864{
4865 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4866 tANI_U8 cbRsnIe = 0;
4867
4868 do
4869 {
4870 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004871#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304872 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004873 {
4874 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4875 // scratch. So it contains the current PMK-IDs
4876 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4877 }
4878 else
4879#endif
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304880 if(pProfile->force_rsne_override &&
4881 pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 {
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304883 smsLog(pMac, LOGW, "force_rsne_override, copy RSN IE provided by user");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004884 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4886 {
4887 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304888 vos_mem_copy(pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 }
4890 else
4891 {
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304892 smsLog(pMac, LOGW, "csrRetrieveRsnIe detect invalid RSN IE length (%d)",
4893 pProfile->nRSNReqIELength);
4894 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 }
4896 }
4897 else
4898 {
4899 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4900 }
4901 }while(0);
4902
4903 return (cbRsnIe);
4904}
4905
4906
4907#ifdef FEATURE_WLAN_WAPI
4908//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
4909//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
4910tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
4911 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4912 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4913{
4914 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4915 tANI_U8 cbWapiIe = 0;
4916
4917 do
4918 {
4919 if ( !csrIsProfileWapi( pProfile ) ) break;
4920 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
4921 {
4922 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
4923 {
4924 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304925 vos_mem_copy(pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 }
4927 else
4928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004929 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 }
4931 }
4932 else
4933 {
4934 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
4935 }
4936 }while(0);
4937
4938 return (cbWapiIe);
4939}
4940#endif /* FEATURE_WLAN_WAPI */
4941
4942tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
4943{
4944 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4945 tListElem *pEntry;
4946 tANI_U16 i;
4947 tANI_U16 startingChannel;
4948 tANI_BOOLEAN found = FALSE;
4949 tCsrChannelSet *pChannelGroup;
4950
4951 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
4952
4953 while ( pEntry )
4954 {
4955 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
4956 startingChannel = pChannelGroup->firstChannel;
4957 for ( i = 0; i < pChannelGroup->numChannels; i++ )
4958 {
4959 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
4960 {
4961 found = TRUE;
4962 break;
4963 }
4964 }
4965
4966 if ( found )
4967 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304968 vos_mem_copy(returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 break;
4970 }
4971 else
4972 {
4973 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
4974 }
4975 }
4976
4977 return( found );
4978}
4979
4980tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
4981{
4982 tANI_BOOLEAN fSupported = FALSE;
4983 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4984
4985 switch ( nonBasicRate )
4986 {
4987 case eCsrSuppRate_1Mbps:
4988 case eCsrSuppRate_2Mbps:
4989 case eCsrSuppRate_5_5Mbps:
4990 case eCsrSuppRate_11Mbps:
4991 fSupported = TRUE;
4992 break;
4993
4994 default:
4995 break;
4996 }
4997
4998 return( fSupported );
4999}
5000
5001tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
5002{
5003 tANI_BOOLEAN fSupported = FALSE;
5004 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
5005
5006 switch ( nonBasicRate )
5007 {
5008 case eCsrSuppRate_6Mbps:
5009 case eCsrSuppRate_9Mbps:
5010 case eCsrSuppRate_12Mbps:
5011 case eCsrSuppRate_18Mbps:
5012 case eCsrSuppRate_24Mbps:
5013 case eCsrSuppRate_36Mbps:
5014 case eCsrSuppRate_48Mbps:
5015 case eCsrSuppRate_54Mbps:
5016 fSupported = TRUE;
5017 break;
5018
5019 default:
5020 break;
5021 }
5022
5023 return( fSupported );
5024}
5025
5026
5027
5028tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
5029{
5030 tAniEdType edType;
5031
5032 switch ( EncryptType )
5033 {
5034 default:
5035 case eCSR_ENCRYPT_TYPE_NONE:
5036 edType = eSIR_ED_NONE;
5037 break;
5038
5039 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5040 case eCSR_ENCRYPT_TYPE_WEP40:
5041 edType = eSIR_ED_WEP40;
5042 break;
5043
5044 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5045 case eCSR_ENCRYPT_TYPE_WEP104:
5046 edType = eSIR_ED_WEP104;
5047 break;
5048
5049 case eCSR_ENCRYPT_TYPE_TKIP:
5050 edType = eSIR_ED_TKIP;
5051 break;
5052
5053 case eCSR_ENCRYPT_TYPE_AES:
5054 edType = eSIR_ED_CCMP;
5055 break;
5056#ifdef FEATURE_WLAN_WAPI
5057 case eCSR_ENCRYPT_TYPE_WPI:
5058 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05305059 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07005060#endif
5061#ifdef WLAN_FEATURE_11W
5062 //11w BIP
5063 case eCSR_ENCRYPT_TYPE_AES_CMAC:
5064 edType = eSIR_ED_AES_128_CMAC;
5065 break;
5066#endif
5067 }
5068
5069 return( edType );
5070}
5071
5072
5073//pIes can be NULL
5074tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
5075 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
5076 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
5077 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
5078{
5079 tANI_U32 idx;
5080 tANI_BOOLEAN fMatch = FALSE;
5081 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5082 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
5083
5084 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
5085
5086 do
5087 {
5088 //If privacy bit is not set, consider no match
5089 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
5090
5091 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
5092 {
5093 switch( pMCEncryptionList->encryptionType[idx] )
5094 {
5095 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5096 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5097 case eCSR_ENCRYPT_TYPE_WEP40:
5098 case eCSR_ENCRYPT_TYPE_WEP104:
5099 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
5100 */
5101 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
5102 {
5103 fMatch = TRUE;
5104 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
5105 }
5106 break;
5107 default:
5108 fMatch = FALSE;
5109 break;
5110 }
5111 if(fMatch) break;
5112 }
5113
5114 if(!fMatch) break;
5115
5116 for( idx = 0; idx < pAuthList->numEntries; idx++ )
5117 {
5118 switch( pAuthList->authType[idx] )
5119 {
5120 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5121 case eCSR_AUTH_TYPE_SHARED_KEY:
5122 case eCSR_AUTH_TYPE_AUTOSWITCH:
5123 fMatch = TRUE;
5124 negotiatedAuth = pAuthList->authType[idx];
5125 break;
5126 default:
5127 fMatch = FALSE;
5128 }
5129 if (fMatch) break;
5130 }
5131
5132 if(!fMatch) break;
5133 //In case of WPA / WPA2, check whether it supports WEP as well
5134 if(pIes)
5135 {
5136 //Prepare the encryption type for WPA/WPA2 functions
5137 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
5138 {
5139 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
5140 }
5141 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
5142 {
5143 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5144 }
5145 //else we can use the encryption type directly
Kiet Lam64c1b492013-07-12 13:56:44 +05305146 if ( pIes->WPA.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305148 fMatch = vos_mem_compare(pIes->WPA.multicast_cipher,
5149 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
5150 CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 if( fMatch ) break;
5152 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305153 if ( pIes->RSN.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305155 fMatch = vos_mem_compare(pIes->RSN.gp_cipher_suite,
5156 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
5157 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 }
5159 }
5160
5161 }while(0);
5162
5163 if( fMatch )
5164 {
5165 if( pNegotiatedAuthType )
5166 *pNegotiatedAuthType = negotiatedAuth;
5167
5168 if( pNegotiatedMCEncryption )
5169 *pNegotiatedMCEncryption = negotiatedMCCipher;
5170 }
5171
5172
5173 return fMatch;
5174}
5175
5176
5177//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305178tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType,
5179 tCsrEncryptionList *pUCEncryptionType,
5180 tCsrEncryptionList *pMCEncryptionType,
5181 tANI_BOOLEAN *pMFPEnabled,
5182 tANI_U8 *pMFPRequired, tANI_U8 *pMFPCapable,
5183 tSirBssDescription *pSirBssDesc,
5184 tDot11fBeaconIEs *pIes,
5185 eCsrAuthType *negotiatedAuthtype,
5186 eCsrEncryptionType *negotiatedUCCipher,
5187 eCsrEncryptionType *negotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07005188{
5189 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5190 tANI_BOOLEAN fMatch = FALSE;
5191 tANI_U8 i,idx;
5192 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
5193 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
5194
5195 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
5196 {
5197 ucCipher = pUCEncryptionType->encryptionType[i];
5198 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
5199 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
5200 // encryption type.
5201 switch ( ucCipher )
5202 {
5203 case eCSR_ENCRYPT_TYPE_NONE:
5204 {
5205 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
5206 // required so we have to reject this Bss.
5207 if ( csrIsPrivacy( pSirBssDesc ) )
5208 {
5209 fMatch = FALSE;
5210 }
5211 else
5212 {
5213 fMatch = TRUE;
5214 }
5215
5216 if ( fMatch )
5217 {
5218 fMatch = FALSE;
5219 //Check Multicast cipher requested and Auth type requested.
5220 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
5221 {
5222 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
5223 {
5224 fMatch = TRUE; //Multicast can only be none.
5225 mcCipher = pMCEncryptionType->encryptionType[idx];
5226 break;
5227 }
5228 }
5229 if (!fMatch) break;
5230
5231 fMatch = FALSE;
5232 //Check Auth list. It should contain AuthOpen.
5233 for( idx = 0 ; idx < authType->numEntries ; idx++ )
5234 {
5235 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
5236 {
5237 fMatch = TRUE;
5238 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5239 break;
5240 }
5241 }
5242 if (!fMatch) break;
5243
5244 }
5245 break;
5246 }
5247
5248 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5249 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5250 // !! might want to check for WEP keys set in the Profile.... ?
5251 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
5252 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
5253 // encryption is not allowed without the Privacy bit turned on.
5254 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5255
5256 break;
5257
5258 // these are all of the WPA encryption types...
5259 case eCSR_ENCRYPT_TYPE_WEP40:
5260 case eCSR_ENCRYPT_TYPE_WEP104:
5261 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5262 break;
5263
5264 case eCSR_ENCRYPT_TYPE_TKIP:
5265 case eCSR_ENCRYPT_TYPE_AES:
5266 {
5267 if(pIes)
5268 {
5269 // First check if there is a RSN match
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305270 fMatch = csrIsRSNMatch( pMac, authType, ucCipher,
5271 pMCEncryptionType, pMFPEnabled,
5272 pMFPRequired, pMFPCapable,
5273 pIes, &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 if( !fMatch )
5275 {
5276 // If not RSN, then check if there is a WPA match
5277 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
5278 &negAuthType, &mcCipher );
5279 }
5280 }
5281 else
5282 {
5283 fMatch = FALSE;
5284 }
5285 break;
5286 }
5287#ifdef FEATURE_WLAN_WAPI
5288 case eCSR_ENCRYPT_TYPE_WPI://WAPI
5289 {
5290 if(pIes)
5291 {
5292 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5293 }
5294 else
5295 {
5296 fMatch = FALSE;
5297 }
5298 break;
5299 }
5300#endif /* FEATURE_WLAN_WAPI */
5301 case eCSR_ENCRYPT_TYPE_ANY:
5302 default:
5303 {
5304 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
5305
5306 fMatch = eANI_BOOLEAN_TRUE;
5307 //It is allowed to match anything. Try the more secured ones first.
5308 if(pIes)
5309 {
5310 //Check AES first
5311 ucCipher = eCSR_ENCRYPT_TYPE_AES;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305312 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5313 pMCEncryptionType, pMFPEnabled,
5314 pMFPRequired, pMFPCapable, pIes,
5315 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 if(!fMatchAny)
5317 {
5318 //Check TKIP
5319 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305320 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5321 pMCEncryptionType,
5322 pMFPEnabled, pMFPRequired,
5323 pMFPCapable, pIes,
5324 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 }
5326#ifdef FEATURE_WLAN_WAPI
5327 if(!fMatchAny)
5328 {
5329 //Check WAPI
5330 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
5331 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5332 }
5333#endif /* FEATURE_WLAN_WAPI */
5334 }
5335 if(!fMatchAny)
5336 {
5337 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
5338 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5339 {
5340 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
5341 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5342 {
5343 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5344 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5345 {
5346 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5347 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5348 {
5349 //It must be open and no encryption
5350 if ( csrIsPrivacy( pSirBssDesc ) )
5351 {
5352 //This is not right
5353 fMatch = eANI_BOOLEAN_FALSE;
5354 }
5355 else
5356 {
5357 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5358 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
5359 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
5360 }
5361 }
5362 }
5363 }
5364 }
5365 }
5366 break;
5367 }
5368 }
5369
5370 }
5371
5372 if( fMatch )
5373 {
5374 if( negotiatedUCCipher )
5375 *negotiatedUCCipher = ucCipher;
5376
5377 if( negotiatedMCCipher )
5378 *negotiatedMCCipher = mcCipher;
5379
5380 if( negotiatedAuthtype )
5381 *negotiatedAuthtype = negAuthType;
5382 }
5383
5384 return( fMatch );
5385}
5386
5387
5388tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
5389 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
5390{
5391 tANI_BOOLEAN fMatch = FALSE;
5392
5393 do {
Padma, Santhosh Kumara43e06c2015-05-21 14:58:13 +05305394 // Check for the specification of the Broadcast SSID at the beginning
5395 // of the list. If specified, then all SSIDs are matches
5396 // (broadcast SSID means accept all SSIDs).
5397 if ( ssid1Len == 0 )
5398 {
5399 fMatch = TRUE;
5400 break;
5401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005402
5403 // There are a few special cases. If the Bss description has a Broadcast SSID,
5404 // then our Profile must have a single SSID without Wildcards so we can program
5405 // the SSID.
5406 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5407 // but the SSID value is all NULL characters. That condition is trated same
5408 // as NULL SSID
5409 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5410 {
5411 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5412 {
5413 fMatch = TRUE;
5414 }
5415 break;
5416 }
5417
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 if(ssid1Len != bssSsidLen) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05305419 if (vos_mem_compare(bssSsid, ssid1, bssSsidLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 {
5421 fMatch = TRUE;
5422 break;
5423 }
5424
5425 } while( 0 );
5426
5427 return( fMatch );
5428}
5429
5430
5431//Null ssid means match
5432tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5433{
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 tANI_BOOLEAN fMatch = FALSE;
5435 tANI_U32 i;
5436
5437 if ( pSsidList && pSsid )
5438 {
5439 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5440 {
5441 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
Kiet Lam64c1b492013-07-12 13:56:44 +05305442 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5443 vos_mem_compare(pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 {
5445 fMatch = TRUE;
5446 break;
5447 }
5448 }
5449 }
5450
5451 return (fMatch);
5452}
5453
5454//like to use sirCompareMacAddr
5455tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5456{
5457 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5458
Kiet Lam64c1b492013-07-12 13:56:44 +05305459 return (vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005460}
5461
5462//like to use sirCompareMacAddr
5463tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5464{
5465 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5466
Kiet Lam64c1b492013-07-12 13:56:44 +05305467 return(vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005468}
5469
5470
5471//like to use sirCompareMacAddr
5472tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5473{
Kiet Lam64c1b492013-07-12 13:56:44 +05305474 return(vos_mem_compare(pMacAddr1, pMacAddr2, sizeof(tCsrBssid)));
Jeff Johnson295189b2012-06-20 16:38:30 -07005475}
5476
5477
5478tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5479{
5480 tANI_BOOLEAN fMatch = FALSE;
5481 tCsrBssid ProfileBssid;
5482 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5483
5484 // for efficiency of the MAC_ADDRESS functions, move the
5485 // Bssid's into MAC_ADDRESS structs.
Kiet Lam64c1b492013-07-12 13:56:44 +05305486 vos_mem_copy(&ProfileBssid, pProfBssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005487
5488 do {
5489
5490 // Give the profile the benefit of the doubt... accept either all 0 or
5491 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5492 // match any Bssids).
5493 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5494 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5495 {
5496 fMatch = TRUE;
5497 break;
5498 }
5499
5500 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5501 {
5502 fMatch = TRUE;
5503 break;
5504 }
5505
5506 } while( 0 );
5507
5508 return( fMatch );
5509}
5510
5511
5512tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5513{
5514 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5515 return eANI_BOOLEAN_FALSE;
5516 else
5517 return eANI_BOOLEAN_TRUE;
5518}
5519
5520
5521tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5522{
5523 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5524}
5525
5526tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5527{
5528 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5529}
5530
5531tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5532{
5533 tANI_BOOLEAN fMatch = TRUE;
5534
5535 do
5536 {
5537 switch( bssType )
5538 {
5539 case eCSR_BSS_TYPE_ANY:
5540 break;
5541
5542 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5543 case eCSR_BSS_TYPE_WDS_STA:
5544 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5545 fMatch = FALSE;
5546
5547 break;
5548
5549 case eCSR_BSS_TYPE_IBSS:
5550 case eCSR_BSS_TYPE_START_IBSS:
5551 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5552 fMatch = FALSE;
5553
5554 break;
5555
5556 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5557 default:
5558 fMatch = FALSE;
5559 break;
5560 }
5561 }
5562 while( 0 );
5563
5564
5565 return( fMatch );
5566}
5567
5568static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5569{
5570 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5571}
5572
5573
5574
5575static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5576{
5577 tANI_BOOLEAN fMatch = TRUE;
5578
5579 do
5580 {
5581 // if the channel is ANY, then always match...
5582 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5583 if ( Channel == pSirBssDesc->channelId ) break;
5584
5585 // didn't match anything.. so return NO match
5586 fMatch = FALSE;
5587
5588 } while( 0 );
5589
5590 return( fMatch );
5591}
5592
5593
5594tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5595{
5596 tANI_BOOLEAN fMatch = TRUE;
5597
5598 do
5599 {
5600 // if the profile says Any channel AND the global settings says ANY channel, then we
5601 // always match...
5602 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5603
5604 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5605 {
5606 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5607 }
5608
5609 } while( 0 );
5610
5611 return( fMatch );
5612}
5613
5614
5615/**
5616 * \brief Enquire as to whether a given rate is supported by the
5617 * adapter as currently configured
5618 *
5619 *
5620 * \param nRate A rate in units of 500kbps
5621 *
5622 * \return TRUE if the adapter is currently capable of supporting this
5623 * rate, FALSE else
5624 *
5625 *
5626 * The rate encoding is just as in 802.11 Information Elements, except
5627 * that the high bit is \em not interpreted as indicating a Basic Rate,
5628 * and proprietary rates are allowed, too.
5629 *
5630 * Note that if the adapter's dot11Mode is g, we don't restrict the
5631 * rates. According to hwReadEepromParameters, this will happen when:
5632 *
5633 * ... the card is configured for ALL bands through the property
5634 * page. If this occurs, and the card is not an ABG card ,then this
5635 * code is setting the dot11Mode to assume the mode that the
5636 * hardware can support. For example, if the card is an 11BG card
5637 * and we are configured to support ALL bands, then we change the
5638 * dot11Mode to 11g because ALL in this case is only what the
5639 * hardware can support.
5640 *
5641 *
5642 */
5643
5644static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5645{
5646 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5647 tANI_U16 idx, newRate;
5648
5649 //In case basic rate flag is set
5650 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5651 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5652 {
5653 switch ( newRate )
5654 {
5655 case eCsrSuppRate_6Mbps:
5656 case eCsrSuppRate_9Mbps:
5657 case eCsrSuppRate_12Mbps:
5658 case eCsrSuppRate_18Mbps:
5659 case eCsrSuppRate_24Mbps:
5660 case eCsrSuppRate_36Mbps:
5661 case eCsrSuppRate_48Mbps:
5662 case eCsrSuppRate_54Mbps:
5663 fSupported = TRUE;
5664 break;
5665 default:
5666 fSupported = FALSE;
5667 break;
5668 }
5669
5670 }
5671 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5672 {
5673 switch ( newRate )
5674 {
5675 case eCsrSuppRate_1Mbps:
5676 case eCsrSuppRate_2Mbps:
5677 case eCsrSuppRate_5_5Mbps:
5678 case eCsrSuppRate_11Mbps:
5679 fSupported = TRUE;
5680 break;
5681 default:
5682 fSupported = FALSE;
5683 break;
5684 }
5685 }
5686 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5687 {
5688
5689 switch ( newRate )
5690 {
5691 case eCsrSuppRate_1Mbps:
5692 case eCsrSuppRate_2Mbps:
5693 case eCsrSuppRate_5_5Mbps:
5694 case eCsrSuppRate_6Mbps:
5695 case eCsrSuppRate_9Mbps:
5696 case eCsrSuppRate_11Mbps:
5697 case eCsrSuppRate_12Mbps:
5698 case eCsrSuppRate_18Mbps:
5699 case eCsrSuppRate_24Mbps:
5700 case eCsrSuppRate_36Mbps:
5701 case eCsrSuppRate_48Mbps:
5702 case eCsrSuppRate_54Mbps:
5703 fSupported = TRUE;
5704 break;
5705 default:
5706 fSupported = FALSE;
5707 break;
5708 }
5709
5710 }
5711 else {
5712
5713 if ( eCsrSuppRate_1Mbps == newRate ||
5714 eCsrSuppRate_2Mbps == newRate ||
5715 eCsrSuppRate_5_5Mbps == newRate ||
5716 eCsrSuppRate_11Mbps == newRate )
5717 {
5718 fSupported = TRUE;
5719 }
5720 else {
5721 idx = 0x1;
5722
5723 switch ( newRate )
5724 {
5725 case eCsrSuppRate_6Mbps:
5726 fSupported = gPhyRatesSuppt[0][idx];
5727 break;
5728 case eCsrSuppRate_9Mbps:
5729 fSupported = gPhyRatesSuppt[1][idx];
5730 break;
5731 case eCsrSuppRate_12Mbps:
5732 fSupported = gPhyRatesSuppt[2][idx];
5733 break;
5734 case eCsrSuppRate_18Mbps:
5735 fSupported = gPhyRatesSuppt[3][idx];
5736 break;
5737 case eCsrSuppRate_20Mbps:
5738 fSupported = gPhyRatesSuppt[4][idx];
5739 break;
5740 case eCsrSuppRate_24Mbps:
5741 fSupported = gPhyRatesSuppt[5][idx];
5742 break;
5743 case eCsrSuppRate_36Mbps:
5744 fSupported = gPhyRatesSuppt[6][idx];
5745 break;
5746 case eCsrSuppRate_40Mbps:
5747 fSupported = gPhyRatesSuppt[7][idx];
5748 break;
5749 case eCsrSuppRate_42Mbps:
5750 fSupported = gPhyRatesSuppt[8][idx];
5751 break;
5752 case eCsrSuppRate_48Mbps:
5753 fSupported = gPhyRatesSuppt[9][idx];
5754 break;
5755 case eCsrSuppRate_54Mbps:
5756 fSupported = gPhyRatesSuppt[10][idx];
5757 break;
5758 case eCsrSuppRate_72Mbps:
5759 fSupported = gPhyRatesSuppt[11][idx];
5760 break;
5761 case eCsrSuppRate_80Mbps:
5762 fSupported = gPhyRatesSuppt[12][idx];
5763 break;
5764 case eCsrSuppRate_84Mbps:
5765 fSupported = gPhyRatesSuppt[13][idx];
5766 break;
5767 case eCsrSuppRate_96Mbps:
5768 fSupported = gPhyRatesSuppt[14][idx];
5769 break;
5770 case eCsrSuppRate_108Mbps:
5771 fSupported = gPhyRatesSuppt[15][idx];
5772 break;
5773 case eCsrSuppRate_120Mbps:
5774 fSupported = gPhyRatesSuppt[16][idx];
5775 break;
5776 case eCsrSuppRate_126Mbps:
5777 fSupported = gPhyRatesSuppt[17][idx];
5778 break;
5779 case eCsrSuppRate_144Mbps:
5780 fSupported = gPhyRatesSuppt[18][idx];
5781 break;
5782 case eCsrSuppRate_160Mbps:
5783 fSupported = gPhyRatesSuppt[19][idx];
5784 break;
5785 case eCsrSuppRate_168Mbps:
5786 fSupported = gPhyRatesSuppt[20][idx];
5787 break;
5788 case eCsrSuppRate_192Mbps:
5789 fSupported = gPhyRatesSuppt[21][idx];
5790 break;
5791 case eCsrSuppRate_216Mbps:
5792 fSupported = gPhyRatesSuppt[22][idx];
5793 break;
5794 case eCsrSuppRate_240Mbps:
5795 fSupported = gPhyRatesSuppt[23][idx];
5796 break;
5797 default:
5798 fSupported = FALSE;
5799 break;
5800 }
5801 }
5802 }
5803
5804 return fSupported;
5805}
5806
5807
5808
5809static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5810 tDot11fIESuppRates *pBssSuppRates,
5811 tDot11fIEExtSuppRates *pBssExtSuppRates )
5812{
5813 tANI_BOOLEAN fMatch = TRUE;
5814 tANI_U32 i;
5815
5816
5817 // Validate that all of the Basic rates advertised in the Bss description are supported.
5818 if ( pBssSuppRates )
5819 {
5820 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5821 {
5822 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5823 {
5824 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5825 {
5826 fMatch = FALSE;
5827 break;
5828 }
5829 }
5830 }
5831 }
5832
5833 if ( fMatch && pBssExtSuppRates )
5834 {
5835 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5836 {
5837 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5838 {
5839 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5840 {
5841 fMatch = FALSE;
5842 break;
5843 }
5844 }
5845 }
5846 }
5847
5848 return( fMatch );
5849
5850}
5851
Pragaspathi Thilagaraje548fab2018-06-22 11:55:55 +05305852/**
5853 * csr_match_security() - wrapper to check if the security is matching
5854 * @mac_ctx: mac context
5855 * @filter: scan filter
5856 * @bss_desc: BSS Descriptor
5857 * @ies_ptr: Pointer to the IE fields
5858 * @neg_auth_type: Negotiated Auth type with the AP
5859 * @neg_uc_cipher: Negotiated unicast cipher suite
5860 * @neg_mc_cipher: Negotiated multicast cipher
5861 *
5862 * Return: true if matched else false.
5863 */
5864#ifdef WLAN_FEATURE_11W
5865static inline bool csr_match_security(tpAniSirGlobal pMac,
5866 tCsrScanResultFilter *filter, tSirBssDescription *bss_desc,
5867 tDot11fBeaconIEs *ies_ptr, eCsrAuthType *neg_auth,
5868 eCsrEncryptionType *neg_uc,
5869 eCsrEncryptionType *neg_mc)
5870{
5871
5872 if (!filter)
5873 return false;
5874
5875 if (filter->bWPSAssociation || filter->bOSENAssociation)
5876 return true;
5877
5878 if (filter->ignore_pmf_cap)
5879 return csrIsSecurityMatch(pMac, &filter->authType,
5880 &filter->EncryptionType,
5881 &filter->mcEncryptionType,
5882 NULL, NULL, NULL,
5883 bss_desc, ies_ptr, neg_auth,
5884 neg_uc, neg_mc);
5885 else
5886 return csrIsSecurityMatch(pMac, &filter->authType,
5887 &filter->EncryptionType,
5888 &filter->mcEncryptionType,
5889 &filter->MFPEnabled,
5890 &filter->MFPRequired,
5891 &filter->MFPCapable,
5892 bss_desc, ies_ptr, neg_auth,
5893 neg_uc, neg_mc);
5894
5895}
5896#else
5897static inline bool csr_match_security(tpAniSirGlobal mac_ctx,
5898 tCsrScanResultFilter *filter, tSirBssDescription *bss_desc,
5899 tDot11fBeaconIEs *ies_ptr, eCsrAuthType *neg_auth,
5900 eCsrEncryptionType *neg_uc,
5901 eCsrEncryptionType *neg_mc)
5902
5903{
5904 if (!filter)
5905 return false;
5906
5907 if (filter->bWPSAssociation || filter->bOSENAssociation)
5908 return true;
5909
5910 return csrIsSecurityMatch(mac_ctx, &filter->authType,
5911 &filter->EncryptionType,
5912 &filter->mcEncryptionType,
5913 NULL, NULL, NULL,
5914 bss_desc, ies_ptr, neg_auth,
5915 neg_uc, neg_mc);
5916}
5917#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005918
5919//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
5920tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
5921 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
5922 tDot11fBeaconIEs **ppIes)
5923{
5924 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5925 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5926 tANI_U32 i;
5927 tDot11fBeaconIEs *pIes = NULL;
5928 tANI_U8 *pb;
5929
5930 do {
5931 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
5932 {
5933 //If no IEs passed in, get our own.
5934 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
5935 {
5936 break;
5937 }
5938 }
5939 else
5940 {
5941 //Save the one pass in for local use
5942 pIes = *ppIes;
5943 }
5944
5945 //Check if caller wants P2P
5946 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
5947 if(!fCheck) break;
5948
5949 if(pIes->SSID.present)
5950 {
5951 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
5952 {
5953 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
5954 pIes->SSID.ssid,
5955 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
5956 if ( fCheck ) break;
5957 }
5958 if(!fCheck) break;
5959 }
5960 fCheck = eANI_BOOLEAN_TRUE;
5961 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
5962 {
5963 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
5964 if ( fCheck ) break;
5965
5966 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
5967 {
5968 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
5969 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
5970
5971 if ( fCheck ) break;
5972 }
5973 }
5974 if(!fCheck) break;
5975
5976 fCheck = eANI_BOOLEAN_TRUE;
5977 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
5978 {
5979 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
5980 if ( fCheck ) break;
5981 }
5982 if(!fCheck)
5983 break;
5984#if defined WLAN_FEATURE_VOWIFI
5985 /* If this is for measurement filtering */
5986 if( pFilter->fMeasurement )
5987 {
5988 fRC = eANI_BOOLEAN_TRUE;
5989 break;
5990 }
5991#endif
5992 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
Pragaspathi Thilagaraje548fab2018-06-22 11:55:55 +05305993 if ( !csr_match_security(pMac, pFilter, pBssDesc, pIes, pNegAuth, pNegUc, pNegMc)) break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
5995 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
5996 //Tush-QoS: validate first if asked for APSD or WMM association
5997 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
5998 !CSR_IS_QOS_BSS(pIes) )
5999 break;
6000 //Check country. check even when pb is NULL because we may want to make sure
6001 //AP has a country code in it if fEnforceCountryCodeMatch is set.
6002 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
6003
6004 fCheck = csrMatchCountryCode( pMac, pb, pIes );
6005 if(!fCheck)
6006 break;
6007
6008#ifdef WLAN_FEATURE_VOWIFI_11R
Hema Aparna Medicharlaf9dec8d2015-04-29 12:37:06 +05306009 if (pFilter->MDID.mdiePresent && csrRoamIs11rAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 {
6011 if (pBssDesc->mdiePresent)
6012 {
6013 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
6014 break;
6015 }
6016 else
6017 break;
6018 }
6019#endif
6020 fRC = eANI_BOOLEAN_TRUE;
6021
6022 } while( 0 );
6023 if( ppIes )
6024 {
6025 *ppIes = pIes;
6026 }
6027 else if( pIes )
6028 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306029 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 }
6031
6032 return( fRC );
6033}
6034
6035tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
6036 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
6037{
6038 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
6039 tCsrAuthList authList;
6040
6041 ucEncryptionList.numEntries = 1;
6042 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
6043
6044 mcEncryptionList.numEntries = 1;
6045 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
6046
6047 authList.numEntries = 1;
6048 authList.authType[0] = pProfile->AuthType;
6049
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05306050 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList,
6051 &mcEncryptionList, NULL, NULL, NULL,
6052 pBssDesc, pIes, NULL, NULL, NULL ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006053
6054}
6055
6056
6057tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
6058 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
6059{
6060 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6061 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
6062 tDot11fBeaconIEs *pIesLocal = pIes;
6063
6064 do {
6065 if( !pIes )
6066 {
6067 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
6068 {
6069 break;
6070 }
6071 }
6072 fCheck = eANI_BOOLEAN_TRUE;
6073 if(pIesLocal->SSID.present)
6074 {
6075 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
6076 if(pProfile->SSID.length)
6077 {
6078 fCheckSsid = eANI_BOOLEAN_TRUE;
6079 }
6080 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
6081 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
6082 if(!fCheck) break;
6083 }
6084 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
6085 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
6086 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
6087 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
6088 if(!fCheck)
6089 break;
6090
6091 fRC = eANI_BOOLEAN_TRUE;
6092
6093 } while( 0 );
6094
6095 if( !pIes && pIesLocal )
6096 {
6097 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05306098 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 }
6100
6101 return( fRC );
6102}
6103
6104
6105
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05306106void csrAddRateBitmap(tANI_U8 rate, tANI_U16 *pRateBitmap)
6107{
6108 tANI_U16 rateBitmap;
6109 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6110 rateBitmap = *pRateBitmap;
6111 switch(n)
6112 {
6113 case SIR_MAC_RATE_1:
6114 rateBitmap |= SIR_MAC_RATE_1_BITMAP;
6115 break;
6116 case SIR_MAC_RATE_2:
6117 rateBitmap |= SIR_MAC_RATE_2_BITMAP;
6118 break;
6119 case SIR_MAC_RATE_5_5:
6120 rateBitmap |= SIR_MAC_RATE_5_5_BITMAP;
6121 break;
6122 case SIR_MAC_RATE_11:
6123 rateBitmap |= SIR_MAC_RATE_11_BITMAP;
6124 break;
6125 case SIR_MAC_RATE_6:
6126 rateBitmap |= SIR_MAC_RATE_6_BITMAP;
6127 break;
6128 case SIR_MAC_RATE_9:
6129 rateBitmap |= SIR_MAC_RATE_9_BITMAP;
6130 break;
6131 case SIR_MAC_RATE_12:
6132 rateBitmap |= SIR_MAC_RATE_12_BITMAP;
6133 break;
6134 case SIR_MAC_RATE_18:
6135 rateBitmap |= SIR_MAC_RATE_18_BITMAP;
6136 break;
6137 case SIR_MAC_RATE_24:
6138 rateBitmap |= SIR_MAC_RATE_24_BITMAP;
6139 break;
6140 case SIR_MAC_RATE_36:
6141 rateBitmap |= SIR_MAC_RATE_36_BITMAP;
6142 break;
6143 case SIR_MAC_RATE_48:
6144 rateBitmap |= SIR_MAC_RATE_48_BITMAP;
6145 break;
6146 case SIR_MAC_RATE_54:
6147 rateBitmap |= SIR_MAC_RATE_54_BITMAP;
6148 break;
6149 }
6150 *pRateBitmap = rateBitmap;
6151}
6152
6153
6154
6155tANI_BOOLEAN csrIsRateAlreadyPresent(tANI_U8 rate, tANI_U16 rateBitmap)
6156{
6157 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6158
6159 switch(n)
6160 {
6161 case SIR_MAC_RATE_1:
6162 rateBitmap &= SIR_MAC_RATE_1_BITMAP;
6163 break;
6164 case SIR_MAC_RATE_2:
6165 rateBitmap &= SIR_MAC_RATE_2_BITMAP;
6166 break;
6167 case SIR_MAC_RATE_5_5:
6168 rateBitmap &= SIR_MAC_RATE_5_5_BITMAP;
6169 break;
6170 case SIR_MAC_RATE_11:
6171 rateBitmap &= SIR_MAC_RATE_11_BITMAP;
6172 break;
6173 case SIR_MAC_RATE_6:
6174 rateBitmap &= SIR_MAC_RATE_6_BITMAP;
6175 break;
6176 case SIR_MAC_RATE_9:
6177 rateBitmap &= SIR_MAC_RATE_9_BITMAP;
6178 break;
6179 case SIR_MAC_RATE_12:
6180 rateBitmap &= SIR_MAC_RATE_12_BITMAP;
6181 break;
6182 case SIR_MAC_RATE_18:
6183 rateBitmap &= SIR_MAC_RATE_18_BITMAP;
6184 break;
6185 case SIR_MAC_RATE_24:
6186 rateBitmap &= SIR_MAC_RATE_24_BITMAP;
6187 break;
6188 case SIR_MAC_RATE_36:
6189 rateBitmap &= SIR_MAC_RATE_36_BITMAP;
6190 break;
6191 case SIR_MAC_RATE_48:
6192 rateBitmap &= SIR_MAC_RATE_48_BITMAP;
6193 break;
6194 case SIR_MAC_RATE_54:
6195 rateBitmap &= SIR_MAC_RATE_54_BITMAP;
6196 break;
6197 }
6198 return !!rateBitmap;
6199}
6200
6201
6202
Jeff Johnson295189b2012-06-20 16:38:30 -07006203tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
6204{
6205 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6206 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
6207
6208 return csrIsAggregateRateSupported( pMac, n );
6209}
6210
6211
6212tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
6213{
6214 tANI_U16 ConvertedRate = Rate;
6215
6216 switch( Rate )
6217 {
6218 case SIR_MAC_RATE_1:
6219 ConvertedRate = 2;
6220 break;
6221 case SIR_MAC_RATE_2:
6222 ConvertedRate = 4;
6223 break;
6224 case SIR_MAC_RATE_5_5:
6225 ConvertedRate = 11;
6226 break;
6227 case SIR_MAC_RATE_11:
6228 ConvertedRate = 22;
6229 break;
6230
6231 case SIR_MAC_RATE_6:
6232 ConvertedRate = 12;
6233 break;
6234 case SIR_MAC_RATE_9:
6235 ConvertedRate = 18;
6236 break;
6237 case SIR_MAC_RATE_12:
6238 ConvertedRate = 24;
6239 break;
6240 case SIR_MAC_RATE_18:
6241 ConvertedRate = 36;
6242 break;
6243 case SIR_MAC_RATE_24:
6244 ConvertedRate = 48;
6245 break;
6246 case SIR_MAC_RATE_36:
6247 ConvertedRate = 72;
6248 break;
6249 case SIR_MAC_RATE_42:
6250 ConvertedRate = 84;
6251 break;
6252 case SIR_MAC_RATE_48:
6253 ConvertedRate = 96;
6254 break;
6255 case SIR_MAC_RATE_54:
6256 ConvertedRate = 108;
6257 break;
6258
6259 case SIR_MAC_RATE_72:
6260 ConvertedRate = 144;
6261 break;
6262 case SIR_MAC_RATE_84:
6263 ConvertedRate = 168;
6264 break;
6265 case SIR_MAC_RATE_96:
6266 ConvertedRate = 192;
6267 break;
6268 case SIR_MAC_RATE_108:
6269 ConvertedRate = 216;
6270 break;
6271 case SIR_MAC_RATE_126:
6272 ConvertedRate = 252;
6273 break;
6274 case SIR_MAC_RATE_144:
6275 ConvertedRate = 288;
6276 break;
6277 case SIR_MAC_RATE_168:
6278 ConvertedRate = 336;
6279 break;
6280 case SIR_MAC_RATE_192:
6281 ConvertedRate = 384;
6282 break;
6283 case SIR_MAC_RATE_216:
6284 ConvertedRate = 432;
6285 break;
6286 case SIR_MAC_RATE_240:
6287 ConvertedRate = 480;
6288 break;
6289
6290 case 0xff:
6291 ConvertedRate = 0;
6292 break;
6293 }
6294
6295 return ConvertedRate;
6296}
6297
6298
6299tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
6300{
6301 tANI_U8 i;
6302 tANI_U16 nBest;
6303
6304 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
6305
6306 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
6307 {
6308 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
6309 }
6310
6311 for ( i = 1U; i < pSuppRates->numRates; ++i )
6312 {
6313 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6314 }
6315
6316 if ( NULL != pExtRates )
6317 {
6318 for ( i = 0U; i < pExtRates->numRates; ++i )
6319 {
6320 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6321 }
6322 }
6323
6324 if ( NULL != pPropRates )
6325 {
6326 for ( i = 0U; i < pPropRates->numPropRates; ++i )
6327 {
6328 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
6329 }
6330 }
6331
6332 return nBest;
6333}
6334
6335
6336void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
6337{
6338 if(pProfile)
6339 {
6340 if(pProfile->BSSIDs.bssid)
6341 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306342 vos_mem_free(pProfile->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 pProfile->BSSIDs.bssid = NULL;
6344 }
6345 if(pProfile->SSIDs.SSIDList)
6346 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306347 vos_mem_free(pProfile->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 pProfile->SSIDs.SSIDList = NULL;
6349 }
6350 if(pProfile->pWPAReqIE)
6351 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306352 vos_mem_free(pProfile->pWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 pProfile->pWPAReqIE = NULL;
6354 }
6355 if(pProfile->pRSNReqIE)
6356 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306357 vos_mem_free(pProfile->pRSNReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 pProfile->pRSNReqIE = NULL;
6359 }
6360#ifdef FEATURE_WLAN_WAPI
6361 if(pProfile->pWAPIReqIE)
6362 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306363 vos_mem_free(pProfile->pWAPIReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 pProfile->pWAPIReqIE = NULL;
6365 }
6366#endif /* FEATURE_WLAN_WAPI */
6367
Agarwal Ashish4f616132013-12-30 23:32:50 +05306368 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306370 memset(pProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306371 pProfile->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 }
6373
6374 if(pProfile->pAddIEAssoc)
6375 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306376 vos_mem_free(pProfile->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 pProfile->pAddIEAssoc = NULL;
6378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 if(pProfile->ChannelInfo.ChannelList)
6380 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306381 vos_mem_free(pProfile->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006382 pProfile->ChannelInfo.ChannelList = NULL;
6383 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306384 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 }
6386}
6387
6388void csrFreeScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
6389{
6390 if(pScanFilter->BSSIDs.bssid)
6391 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306392 vos_mem_free(pScanFilter->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 pScanFilter->BSSIDs.bssid = NULL;
6394 }
6395 if(pScanFilter->ChannelInfo.ChannelList)
6396 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306397 vos_mem_free(pScanFilter->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 pScanFilter->ChannelInfo.ChannelList = NULL;
6399 }
6400 if(pScanFilter->SSIDs.SSIDList)
6401 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306402 vos_mem_free(pScanFilter->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 pScanFilter->SSIDs.SSIDList = NULL;
6404 }
6405}
6406
6407
6408void csrFreeRoamProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6409{
6410 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6411
6412 if(pSession->pCurRoamProfile)
6413 {
6414 csrReleaseProfile(pMac, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306415 vos_mem_free(pSession->pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 pSession->pCurRoamProfile = NULL;
6417 }
6418}
6419
6420
6421void csrFreeConnectBssDesc(tpAniSirGlobal pMac, tANI_U32 sessionId)
6422{
6423 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6424
6425 if(pSession->pConnectBssDesc)
6426 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306427 vos_mem_free(pSession->pConnectBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 pSession->pConnectBssDesc = NULL;
6429 }
6430}
6431
6432
6433
6434tSirResultCodes csrGetDisassocRspStatusCode( tSirSmeDisassocRsp *pSmeDisassocRsp )
6435{
6436 tANI_U8 *pBuffer = (tANI_U8 *)pSmeDisassocRsp;
6437 tANI_U32 ret;
6438
6439 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
6440 //tSirResultCodes is an enum, assuming is 32bit
6441 //If we cannot make this assumption, use copymemory
6442 pal_get_U32( pBuffer, &ret );
6443
6444 return( ( tSirResultCodes )ret );
6445}
6446
6447
6448tSirResultCodes csrGetDeAuthRspStatusCode( tSirSmeDeauthRsp *pSmeRsp )
6449{
6450 tANI_U8 *pBuffer = (tANI_U8 *)pSmeRsp;
6451 tANI_U32 ret;
6452
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006453 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tANI_U8) + sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 //tSirResultCodes is an enum, assuming is 32bit
6455 //If we cannot make this assumption, use copymemory
6456 pal_get_U32( pBuffer, &ret );
6457
6458 return( ( tSirResultCodes )ret );
6459}
6460
6461#if 0
6462tSirScanType csrGetScanType(tANI_U8 chnId, eRegDomainId domainId, tANI_U8 *countryCode)
6463{
6464 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6465 tANI_U8 cc = 0;
6466
6467 while (cc++ < gCsrDomainChnInfo[domainId].numChannels)
6468 {
6469 if(chnId == gCsrDomainChnInfo[domainId].chnInfo[cc].chnId)
6470 {
6471 scanType = gCsrDomainChnInfo[domainId].chnInfo[cc].scanType;
6472 break;
6473 }
6474 }
6475
6476 return (scanType);
6477}
6478#endif
6479
6480tSirScanType csrGetScanType(tpAniSirGlobal pMac, tANI_U8 chnId)
6481{
6482 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6483 eNVChannelEnabledType channelEnabledType;
6484
6485 channelEnabledType = vos_nv_getChannelEnabledState(chnId);
6486 if( NV_CHANNEL_ENABLE == channelEnabledType)
6487 {
6488 scanType = eSIR_ACTIVE_SCAN;
6489 }
6490 return (scanType);
6491}
6492
6493
6494tANI_U8 csrToUpper( tANI_U8 ch )
6495{
6496 tANI_U8 chOut;
6497
6498 if ( ch >= 'a' && ch <= 'z' )
6499 {
6500 chOut = ch - 'a' + 'A';
6501 }
6502 else
6503 {
6504 chOut = ch;
6505 }
6506 return( chOut );
6507}
6508
6509
6510tSirBssType csrTranslateBsstypeToMacType(eCsrRoamBssType csrtype)
6511{
6512 tSirBssType ret;
6513
6514 switch(csrtype)
6515 {
6516 case eCSR_BSS_TYPE_INFRASTRUCTURE:
6517 ret = eSIR_INFRASTRUCTURE_MODE;
6518 break;
6519 case eCSR_BSS_TYPE_IBSS:
6520 case eCSR_BSS_TYPE_START_IBSS:
6521 ret = eSIR_IBSS_MODE;
6522 break;
6523 case eCSR_BSS_TYPE_WDS_AP:
6524 ret = eSIR_BTAMP_AP_MODE;
6525 break;
6526 case eCSR_BSS_TYPE_WDS_STA:
6527 ret = eSIR_BTAMP_STA_MODE;
6528 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 case eCSR_BSS_TYPE_INFRA_AP:
6530 ret = eSIR_INFRA_AP_MODE;
6531 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 case eCSR_BSS_TYPE_ANY:
6533 default:
6534 ret = eSIR_AUTO_MODE;
6535 break;
6536 }
6537
6538 return (ret);
6539}
6540
6541
6542//This function use the parameters to decide the CFG value.
6543//CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG
6544//So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value
Jeff Johnson295189b2012-06-20 16:38:30 -07006545eCsrCfgDot11Mode csrGetCfgDot11ModeFromCsrPhyMode(tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tANI_BOOLEAN fProprietary)
Jeff Johnson295189b2012-06-20 16:38:30 -07006546{
6547 tANI_U32 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6548
6549 switch(phyMode)
6550 {
6551 case eCSR_DOT11_MODE_11a:
6552 case eCSR_DOT11_MODE_11a_ONLY:
6553 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
6554 break;
6555 case eCSR_DOT11_MODE_11b:
6556 case eCSR_DOT11_MODE_11b_ONLY:
6557 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
6558 break;
6559 case eCSR_DOT11_MODE_11g:
6560 case eCSR_DOT11_MODE_11g_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 if(pProfile && (CSR_IS_INFRA_AP(pProfile)) && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
6562 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
6563 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
6565 break;
6566 case eCSR_DOT11_MODE_11n:
6567 if(fProprietary)
6568 {
6569 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6570 }
6571 else
6572 {
6573 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6574 }
6575 break;
6576 case eCSR_DOT11_MODE_11n_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 if(pProfile && CSR_IS_INFRA_AP(pProfile))
6578 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
6579 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6581 break;
6582 case eCSR_DOT11_MODE_TAURUS:
6583 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6584 break;
6585 case eCSR_DOT11_MODE_abg:
6586 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6587 break;
6588 case eCSR_DOT11_MODE_AUTO:
6589 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
6590 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07006591
6592#ifdef WLAN_FEATURE_11AC
6593 case eCSR_DOT11_MODE_11ac:
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006594 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6595 {
6596 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
6597 }
6598 else
6599 {
Ravi Joshia96ceb42013-05-20 18:52:39 -07006600 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006601 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006602 break;
6603 case eCSR_DOT11_MODE_11ac_ONLY:
Ravi Joshia96ceb42013-05-20 18:52:39 -07006604 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6605 {
6606 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
6607 }
6608 else
6609 {
6610 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6611 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006612 break;
6613#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 default:
6615 //No need to assign anything here
6616 break;
6617 }
6618
6619 return (cfgDot11Mode);
6620}
6621
6622
6623eHalStatus csrSetRegulatoryDomain(tpAniSirGlobal pMac, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6624{
6625 eHalStatus status = eHAL_STATUS_SUCCESS;
6626 tANI_BOOLEAN fRestart;
6627
6628 if(pMac->scan.domainIdCurrent == domainId)
6629 {
6630 //no change
6631 fRestart = eANI_BOOLEAN_FALSE;
6632 }
6633 else if( !pMac->roam.configParam.fEnforceDefaultDomain )
6634 {
6635 pMac->scan.domainIdCurrent = domainId;
6636 fRestart = eANI_BOOLEAN_TRUE;
6637 }
6638 else
6639 {
6640 //We cannot change the domain
6641 status = eHAL_STATUS_CSR_WRONG_STATE;
6642 fRestart = eANI_BOOLEAN_FALSE;
6643 }
6644 if(pfRestartNeeded)
6645 {
6646 *pfRestartNeeded = fRestart;
6647 }
6648
6649 return (status);
6650}
6651
6652
6653v_REGDOMAIN_t csrGetCurrentRegulatoryDomain(tpAniSirGlobal pMac)
6654{
6655 return (pMac->scan.domainIdCurrent);
6656}
6657
Jeff Johnson295189b2012-06-20 16:38:30 -07006658
Kiet Lam6c583332013-10-14 05:37:09 +05306659eHalStatus csrGetRegulatoryDomainForCountry
6660(
6661tpAniSirGlobal pMac,
6662tANI_U8 *pCountry,
6663v_REGDOMAIN_t *pDomainId,
6664v_CountryInfoSource_t source
6665)
Jeff Johnson295189b2012-06-20 16:38:30 -07006666{
6667 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6668 VOS_STATUS vosStatus;
6669 v_COUNTRYCODE_t countryCode;
6670 v_REGDOMAIN_t domainId;
6671
6672 if(pCountry)
6673 {
6674 countryCode[0] = pCountry[0];
6675 countryCode[1] = pCountry[1];
Kiet Lam6c583332013-10-14 05:37:09 +05306676 vosStatus = vos_nv_getRegDomainFromCountryCode(&domainId,
6677 countryCode,
6678 source);
6679
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
6681 {
6682 if( pDomainId )
6683 {
6684 *pDomainId = domainId;
6685 }
6686 status = eHAL_STATUS_SUCCESS;
6687 }
6688 else
6689 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306690 smsLog(pMac, LOGW, FL(" Couldn't find domain for country code %c%c"), pCountry[0], pCountry[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 status = eHAL_STATUS_INVALID_PARAMETER;
6692 }
6693 }
6694
6695 return (status);
6696}
6697
6698//To check whether a country code matches the one in the IE
6699//Only check the first two characters, ignoring in/outdoor
6700//pCountry -- caller allocated buffer contain the country code that is checking against
6701//the one in pIes. It can be NULL.
6702//caller must provide pIes, it cannot be NULL
6703//This function always return TRUE if 11d support is not turned on.
6704tANI_BOOLEAN csrMatchCountryCode( tpAniSirGlobal pMac, tANI_U8 *pCountry, tDot11fBeaconIEs *pIes )
6705{
6706 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson43971f52012-07-17 12:26:56 -07006707 v_REGDOMAIN_t domainId = REGDOMAIN_COUNT; //This is init to invalid value
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 eHalStatus status;
6709
6710 do
6711 {
6712 if( !csrIs11dSupported( pMac) )
6713 {
6714 break;
6715 }
6716 if( !pIes )
6717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006718 smsLog(pMac, LOGE, FL(" No IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 break;
6720 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006721 if( pMac->roam.configParam.fEnforceDefaultDomain ||
6722 pMac->roam.configParam.fEnforceCountryCodeMatch )
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006724 //Make sure this country is recognizable
6725 if( pIes->Country.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 {
Kiet Lam6c583332013-10-14 05:37:09 +05306727 status = csrGetRegulatoryDomainForCountry(pMac,
6728 pIes->Country.country,
6729 &domainId, COUNTRY_QUERY);
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006730 if( !HAL_STATUS_SUCCESS( status ) )
6731 {
Kiet Lam6c583332013-10-14 05:37:09 +05306732 status = csrGetRegulatoryDomainForCountry(pMac,
6733 pMac->scan.countryCode11d,
6734 (v_REGDOMAIN_t *) &domainId,
6735 COUNTRY_QUERY);
Gowri Deepthiff9adf92012-12-13 15:09:56 -08006736 if( !HAL_STATUS_SUCCESS( status ) )
6737 {
6738 fRet = eANI_BOOLEAN_FALSE;
6739 break;
6740 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006743 //check whether it is needed to enforce to the default regulatory domain first
6744 if( pMac->roam.configParam.fEnforceDefaultDomain )
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006746 if( domainId != pMac->scan.domainIdCurrent )
6747 {
6748 fRet = eANI_BOOLEAN_FALSE;
6749 break;
6750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006752 if( pMac->roam.configParam.fEnforceCountryCodeMatch )
6753 {
Jeff Johnson43971f52012-07-17 12:26:56 -07006754 if( domainId >= REGDOMAIN_COUNT )
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006755 {
6756 fRet = eANI_BOOLEAN_FALSE;
6757 break;
6758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 }
6760 }
6761 if( pCountry )
6762 {
6763 tANI_U32 i;
6764
6765 if( !pIes->Country.present )
6766 {
6767 fRet = eANI_BOOLEAN_FALSE;
6768 break;
6769 }
6770 // Convert the CountryCode characters to upper
6771 for ( i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++ )
6772 {
6773 pCountry[i] = csrToUpper( pCountry[i] );
6774 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306775 if (!vos_mem_compare(pIes->Country.country, pCountry,
6776 WNI_CFG_COUNTRY_CODE_LEN - 1))
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 {
6778 fRet = eANI_BOOLEAN_FALSE;
6779 break;
6780 }
6781 }
6782 } while(0);
6783
6784 return (fRet);
6785}
6786
6787#if 0
6788eHalStatus csrSetCountryDomainMapping(tpAniSirGlobal pMac, tCsrCountryDomainMapping *pCountryDomainMapping)
6789{
6790 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6791 tANI_U32 i, j;
6792 tANI_BOOLEAN fDomainChanged = eANI_BOOLEAN_FALSE;
6793 tANI_U8 countryCode[WNI_CFG_COUNTRY_CODE_LEN];
6794
6795 i = WNI_CFG_COUNTRY_CODE_LEN;
6796 //Get the currently used country code
6797 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, countryCode, &i);
6798 if(HAL_STATUS_SUCCESS(status))
6799 {
6800 if(pCountryDomainMapping && pCountryDomainMapping->numEntry)
6801 {
6802 for(i = 0; i < pCountryDomainMapping->numEntry; i++)
6803 {
6804 for(j = 0; j < eCSR_NUM_COUNTRY_INDEX; j++)
6805 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306806 if (vos_mem_compare(gCsrCountryInfo[j].countryCode,
6807 pCountryDomainMapping->pCountryInfo[i].countryCode,
6808 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 {
6810 if(gCsrCountryInfo[j].domainId != pCountryDomainMapping->pCountryInfo[i].domainId)
6811 {
6812 gCsrCountryInfo[j].domainId = pCountryDomainMapping->pCountryInfo[i].domainId;
6813 //Check whether it matches the currently used country code
6814 //If matching, need to update base on the new domain setting.
Kiet Lam64c1b492013-07-12 13:56:44 +05306815 if (vos_mem_compare(countryCode,
6816 pCountryDomainMapping->pCountryInfo[i].countryCode,
6817 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006818 {
6819 fDomainChanged = eANI_BOOLEAN_TRUE;
6820 }
6821 }
6822 break;
6823 }
6824 }
6825 }
6826 status = eHAL_STATUS_SUCCESS;
6827 if(fDomainChanged)
6828 {
6829 tCsrChannel *pChannelList;
6830
6831 if(pMac->scan.f11dInfoApplied)
6832 {
6833 //11d info already applied. Let's reapply with the new domain setting
6834 if(pMac->scan.channels11d.numChannels)
6835 {
6836 pChannelList = &pMac->scan.channels11d;
6837 }
6838 else
6839 {
6840 pChannelList = &pMac->scan.base20MHzChannels;
6841 }
6842 }
6843 else
6844 {
6845 //no 11d so we use the base channelist from EEPROM
6846 pChannelList = &pMac->scan.base20MHzChannels;
6847 }
6848 //set the new domain's scan requirement to CFG
6849 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
6850 }
6851 }
6852 }
6853
6854 return (status);
6855}
6856
6857eHalStatus csrSetDomainScanSetting(tpAniSirGlobal pMac, tCsrDomainFreqInfo *pDomainFreqInfo)
6858{
6859 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6860 tANI_U32 i, j;
6861 tANI_U16 freq;
6862
6863 if(pDomainFreqInfo && pDomainFreqInfo->numEntry && (pDomainFreqInfo->domainId < NUM_REG_DOMAINS))
6864 {
6865 tCsrDomainChnInfo *pDomainChnInfo = &gCsrDomainChnInfo[pDomainFreqInfo->domainId];
6866
6867 for(j = 0; j < pDomainChnInfo->numChannels; j++)
6868 {
6869 if(HAL_STATUS_SUCCESS(halPhyChIdToFreqConversion(pDomainChnInfo->chnInfo[j].chnId, &freq)))
6870 {
6871 for(i = 0; i < pDomainFreqInfo->numEntry; i++)
6872 {
6873 if((pDomainFreqInfo->pCsrScanFreqInfo[i].nStartFreq <= freq) &&
6874 (freq <= pDomainFreqInfo->pCsrScanFreqInfo[i].nEndFreq))
6875 {
6876 pDomainChnInfo->chnInfo[j].scanType = pDomainFreqInfo->pCsrScanFreqInfo[i].scanType;
6877 break;
6878 }
6879 }
6880 }
6881 else
6882 {
6883 smsLog(pMac, LOGW, " Failed to get frequency of channel %d", pDomainChnInfo->chnInfo[j].chnId);
6884 }
6885 }
6886 status = eHAL_STATUS_SUCCESS;
6887 }
6888
6889 return (status);
6890}
6891#endif
6892
6893eHalStatus csrGetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6894 tCsrRoamModifyProfileFields *pModifyProfileFields)
6895{
6896
6897 if(!pModifyProfileFields)
6898 {
6899 return eHAL_STATUS_FAILURE;
6900 }
6901
Kiet Lam64c1b492013-07-12 13:56:44 +05306902 vos_mem_copy(pModifyProfileFields,
6903 &pMac->roam.roamSession[sessionId].connectedProfile.modifyProfileFields,
6904 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006905
6906 return eHAL_STATUS_SUCCESS;
6907}
6908
6909eHalStatus csrSetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6910 tCsrRoamModifyProfileFields *pModifyProfileFields)
6911{
6912 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6913
Kiet Lam64c1b492013-07-12 13:56:44 +05306914 vos_mem_copy(&pSession->connectedProfile.modifyProfileFields,
6915 pModifyProfileFields,
6916 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006917
6918 return eHAL_STATUS_SUCCESS;
6919}
6920
6921
6922#if 0
6923/* ---------------------------------------------------------------------------
6924 \fn csrGetSupportedCountryCode
6925 \brief this function is to get a list of the country code current being supported
6926 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6927 this has the country code list. 3 bytes for each country code. This may be NULL if
6928 caller wants to know the needed bytes.
6929 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6930 this contains the length of the data in pBuf
6931 \return eHalStatus
6932 -------------------------------------------------------------------------------*/
6933eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6934{
6935 tANI_U32 numOfCountry = sizeof( gCsrCountryInfo ) / sizeof( gCsrCountryInfo[0] );
6936 tANI_U32 numBytes = 0;
6937 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6938
6939 if( pbLen )
6940 {
6941 numBytes = *pbLen;
6942 //Consider it ok, at least we can return the number of bytes needed;
6943 *pbLen = numOfCountry * WNI_CFG_COUNTRY_CODE_LEN;
6944 status = eHAL_STATUS_SUCCESS;
6945 if( pBuf && ( numBytes >= *pbLen ) )
6946 {
6947 //The ugly part starts.
6948 //We may need to alter the data structure and find a way to make this faster.
6949 tANI_U32 i;
6950
Kiet Lam64c1b492013-07-12 13:56:44 +05306951 for ( i = 0; i < numOfCountry; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306953 vos_mem_copy(pBuf + ( i * WNI_CFG_COUNTRY_CODE_LEN ),
6954 gCsrCountryInfo[i].countryCode,
6955 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006956 }
6957 }
6958 }
6959
6960 return ( status );
6961}
6962#endif
6963
6964/* ---------------------------------------------------------------------------
6965 \fn csrGetSupportedCountryCode
6966 \brief this function is to get a list of the country code current being supported
6967 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6968 this has the country code list. 3 bytes for each country code. This may be NULL if
6969 caller wants to know the needed bytes.
6970 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6971 this contains the length of the data in pBuf
6972 \return eHalStatus
6973 -------------------------------------------------------------------------------*/
6974eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6975{
6976 eHalStatus status = eHAL_STATUS_SUCCESS;
6977 VOS_STATUS vosStatus;
6978 v_SIZE_t size = (v_SIZE_t)*pbLen;
6979
6980 vosStatus = vos_nv_getSupportedCountryCode( pBuf, &size, 1 );
6981 //eiter way, return the value back
6982 *pbLen = (tANI_U32)size;
6983
6984 //If pBuf is NULL, caller just want to get the size, consider it success
6985 if(pBuf)
6986 {
6987 if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
6988 {
6989 tANI_U32 i, n = *pbLen / 3;
6990
6991 for( i = 0; i < n; i++ )
6992 {
6993 pBuf[i*3 + 2] = ' ';
6994 }
6995 }
6996 else
6997 {
6998 status = eHAL_STATUS_FAILURE;
6999 }
7000 }
7001
7002 return (status);
7003}
7004
7005
7006
7007//Upper layer to get the list of the base channels to scan for passively 11d info from csr
7008eHalStatus csrScanGetBaseChannels( tpAniSirGlobal pMac, tCsrChannelInfo * pChannelInfo )
7009{
7010 eHalStatus status = eHAL_STATUS_FAILURE;
7011
7012 do
7013 {
7014
7015 if(!pMac->scan.baseChannels.numChannels || !pChannelInfo)
7016 {
7017 break;
7018 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307019 pChannelInfo->ChannelList = vos_mem_malloc(pMac->scan.baseChannels.numChannels);
7020 if ( NULL == pChannelInfo->ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007022 smsLog( pMac, LOGE, FL("csrScanGetBaseChannels: fail to allocate memory") );
Kiet Lam64c1b492013-07-12 13:56:44 +05307023 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307025 vos_mem_copy(pChannelInfo->ChannelList,
7026 pMac->scan.baseChannels.channelList,
7027 pMac->scan.baseChannels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 pChannelInfo->numOfChannels = pMac->scan.baseChannels.numChannels;
7029
7030 }while(0);
7031
7032 return ( status );
7033}
7034
7035
7036tANI_BOOLEAN csrIsSetKeyAllowed(tpAniSirGlobal pMac, tANI_U32 sessionId)
7037{
7038 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 tCsrRoamSession *pSession;
7040
7041 pSession =CSR_GET_SESSION(pMac, sessionId);
7042
7043 /*This condition is not working for infra state. When infra is in not-connected state
7044 * the pSession->pCurRoamProfile is NULL. And this function returns TRUE, that is incorrect.
7045 * Since SAP requires to set key without any BSS started, it needs this condition to be met.
7046 * In other words, this function is useless.
7047 * The current work-around is to process setcontext_rsp and removekey_rsp no matter what the
7048 * state is.
7049 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007050 smsLog( pMac, LOG2, FL(" is not what it intends to. Must be revisit or removed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 if( (NULL == pSession) ||
7052 ( csrIsConnStateDisconnected( pMac, sessionId ) &&
7053 (pSession->pCurRoamProfile != NULL) &&
7054 (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) )
7055 )
7056 {
7057 fRet = eANI_BOOLEAN_FALSE;
7058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007059
7060 return ( fRet );
7061}
7062
7063//no need to acquire lock for this basic function
7064tANI_U16 sme_ChnToFreq(tANI_U8 chanNum)
7065{
7066 int i;
7067
7068 for (i = 0; i < NUM_RF_CHANNELS; i++)
7069 {
7070 if (rfChannels[i].channelNum == chanNum)
7071 {
7072 return rfChannels[i].targetFreq;
7073 }
7074 }
7075
7076 return (0);
7077}
7078
7079/* Disconnect all active sessions by sending disassoc. This is mainly used to disconnect the remaining session when we
7080 * transition from concurrent sessions to a single session. The use case is Infra STA and wifi direct multiple sessions are up and
7081 * P2P session is removed. The Infra STA session remains and should resume BMPS if BMPS is enabled by default. However, there
7082 * are some issues seen with BMPS resume during this transition and this is a workaround which will allow the Infra STA session to
7083 * disconnect and auto connect back and enter BMPS this giving the same effect as resuming BMPS
7084 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07007085
7086//Remove this code once SLM_Sessionization is supported
7087//BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnson295189b2012-06-20 16:38:30 -07007088void csrDisconnectAllActiveSessions(tpAniSirGlobal pMac)
7089{
7090 tANI_U8 i;
7091
7092 /* Disconnect all the active sessions */
7093 for (i=0; i<CSR_ROAM_SESSION_MAX; i++)
7094 {
7095 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
7096 {
7097 csrRoamDisconnectInternal(pMac, i, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7098 }
7099 }
7100}
Mohit Khanna349bc392012-09-11 17:24:52 -07007101
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07007102#ifdef FEATURE_WLAN_LFR
7103tANI_BOOLEAN csrIsChannelPresentInList(
7104 tANI_U8 *pChannelList,
7105 int numChannels,
7106 tANI_U8 channel
7107 )
7108{
7109 int i = 0;
7110
7111 // Check for NULL pointer
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08007112 if (!pChannelList || (numChannels == 0))
7113 {
7114 return FALSE;
7115 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07007116
7117 // Look for the channel in the list
7118 for (i = 0; i < numChannels; i++)
7119 {
7120 if (pChannelList[i] == channel)
7121 return TRUE;
7122 }
7123
7124 return FALSE;
7125}
7126
7127VOS_STATUS csrAddToChannelListFront(
7128 tANI_U8 *pChannelList,
7129 int numChannels,
7130 tANI_U8 channel
7131 )
7132{
7133 int i = 0;
7134
7135 // Check for NULL pointer
7136 if (!pChannelList) return eHAL_STATUS_E_NULL_VALUE;
7137
7138 // Make room for the addition. (Start moving from the back.)
7139 for (i = numChannels; i > 0; i--)
7140 {
7141 pChannelList[i] = pChannelList[i-1];
7142 }
7143
7144 // Now add the NEW channel...at the front
7145 pChannelList[0] = channel;
7146
7147 return eHAL_STATUS_SUCCESS;
7148}
7149#endif
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307150const char * sme_requestTypetoString(const v_U8_t requestType)
7151{
7152 switch (requestType)
7153 {
7154 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_11D_SCAN );
7155 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_FULL_SCAN );
7156 CASE_RETURN_STRING( eCSR_SCAN_IDLE_MODE_SCAN );
7157 CASE_RETURN_STRING( eCSR_SCAN_HO_BG_SCAN );
7158 CASE_RETURN_STRING( eCSR_SCAN_HO_PROBE_SCAN );
7159 CASE_RETURN_STRING( eCSR_SCAN_HO_NT_BG_SCAN );
7160 CASE_RETURN_STRING( eCSR_SCAN_P2P_DISCOVERY );
7161 CASE_RETURN_STRING( eCSR_SCAN_SOFTAP_CHANNEL_RANGE );
7162 CASE_RETURN_STRING( eCSR_SCAN_P2P_FIND_PEER );
7163 default:
7164 return "Unknown Scan Request Type";
7165 }
7166}