blob: 85cdd298a7cc6919deee1b5c4a71280a4f8e3ed4 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2011-2014 The Linux Foundation. All rights reserved.
3 *
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) */
73 { 0x00, 0x0F, 0xAC, 0x05 }
Jeff Johnson295189b2012-06-20 16:38:30 -070074};
75
76#ifdef FEATURE_WLAN_WAPI
Kaushik, Sushantfe230152014-04-08 14:37:47 +053077tANI_U8 csrWapiOui[CSR_WAPI_OUI_ROW_SIZE][ CSR_WAPI_OUI_SIZE ] = {
Jeff Johnson295189b2012-06-20 16:38:30 -070078 { 0x00, 0x14, 0x72, 0x00 }, // Reserved
79 { 0x00, 0x14, 0x72, 0x01 }, // WAI certificate or SMS4
80 { 0x00, 0x14, 0x72, 0x02 } // WAI PSK
81};
82#endif /* FEATURE_WLAN_WAPI */
83tANI_U8 csrWmeInfoOui[ CSR_WME_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
84tANI_U8 csrWmeParmOui[ CSR_WME_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
85
86static tCsrIELenInfo gCsrIELengthTable[] = {
87/* 000 */ { SIR_MAC_SSID_EID_MIN, SIR_MAC_SSID_EID_MAX },
88/* 001 */ { SIR_MAC_RATESET_EID_MIN, SIR_MAC_RATESET_EID_MAX },
89/* 002 */ { SIR_MAC_FH_PARAM_SET_EID_MIN, SIR_MAC_FH_PARAM_SET_EID_MAX },
90/* 003 */ { SIR_MAC_DS_PARAM_SET_EID_MIN, SIR_MAC_DS_PARAM_SET_EID_MAX },
91/* 004 */ { SIR_MAC_CF_PARAM_SET_EID_MIN, SIR_MAC_CF_PARAM_SET_EID_MAX },
92/* 005 */ { SIR_MAC_TIM_EID_MIN, SIR_MAC_TIM_EID_MAX },
93/* 006 */ { SIR_MAC_IBSS_PARAM_SET_EID_MIN, SIR_MAC_IBSS_PARAM_SET_EID_MAX },
94/* 007 */ { SIR_MAC_COUNTRY_EID_MIN, SIR_MAC_COUNTRY_EID_MAX },
95/* 008 */ { SIR_MAC_FH_PARAMS_EID_MIN, SIR_MAC_FH_PARAMS_EID_MAX },
96/* 009 */ { SIR_MAC_FH_PATTERN_EID_MIN, SIR_MAC_FH_PATTERN_EID_MAX },
97/* 010 */ { SIR_MAC_REQUEST_EID_MIN, SIR_MAC_REQUEST_EID_MAX },
98/* 011 */ { SIR_MAC_QBSS_LOAD_EID_MIN, SIR_MAC_QBSS_LOAD_EID_MAX },
99/* 012 */ { SIR_MAC_EDCA_PARAM_SET_EID_MIN, SIR_MAC_EDCA_PARAM_SET_EID_MAX },
100/* 013 */ { SIR_MAC_TSPEC_EID_MIN, SIR_MAC_TSPEC_EID_MAX },
101/* 014 */ { SIR_MAC_TCLAS_EID_MIN, SIR_MAC_TCLAS_EID_MAX },
102/* 015 */ { SIR_MAC_QOS_SCHEDULE_EID_MIN, SIR_MAC_QOS_SCHEDULE_EID_MAX },
103/* 016 */ { SIR_MAC_CHALLENGE_TEXT_EID_MIN, SIR_MAC_CHALLENGE_TEXT_EID_MAX },
104/* 017 */ { 0, 255 },
105/* 018 */ { 0, 255 },
106/* 019 */ { 0, 255 },
107/* 020 */ { 0, 255 },
108/* 021 */ { 0, 255 },
109/* 022 */ { 0, 255 },
110/* 023 */ { 0, 255 },
111/* 024 */ { 0, 255 },
112/* 025 */ { 0, 255 },
113/* 026 */ { 0, 255 },
114/* 027 */ { 0, 255 },
115/* 028 */ { 0, 255 },
116/* 029 */ { 0, 255 },
117/* 030 */ { 0, 255 },
118/* 031 */ { 0, 255 },
119/* 032 */ { SIR_MAC_PWR_CONSTRAINT_EID_MIN, SIR_MAC_PWR_CONSTRAINT_EID_MAX },
120/* 033 */ { SIR_MAC_PWR_CAPABILITY_EID_MIN, SIR_MAC_PWR_CAPABILITY_EID_MAX },
121/* 034 */ { SIR_MAC_TPC_REQ_EID_MIN, SIR_MAC_TPC_REQ_EID_MAX },
122/* 035 */ { SIR_MAC_TPC_RPT_EID_MIN, SIR_MAC_TPC_RPT_EID_MAX },
123/* 036 */ { SIR_MAC_SPRTD_CHNLS_EID_MIN, SIR_MAC_SPRTD_CHNLS_EID_MAX },
124/* 037 */ { SIR_MAC_CHNL_SWITCH_ANN_EID_MIN, SIR_MAC_CHNL_SWITCH_ANN_EID_MAX },
125/* 038 */ { SIR_MAC_MEAS_REQ_EID_MIN, SIR_MAC_MEAS_REQ_EID_MAX },
126/* 039 */ { SIR_MAC_MEAS_RPT_EID_MIN, SIR_MAC_MEAS_RPT_EID_MAX },
127/* 040 */ { SIR_MAC_QUIET_EID_MIN, SIR_MAC_QUIET_EID_MAX },
128/* 041 */ { SIR_MAC_IBSS_DFS_EID_MIN, SIR_MAC_IBSS_DFS_EID_MAX },
129/* 042 */ { SIR_MAC_ERP_INFO_EID_MIN, SIR_MAC_ERP_INFO_EID_MAX },
130/* 043 */ { SIR_MAC_TS_DELAY_EID_MIN, SIR_MAC_TS_DELAY_EID_MAX },
131/* 044 */ { SIR_MAC_TCLAS_PROC_EID_MIN, SIR_MAC_TCLAS_PROC_EID_MAX },
132/* 045 */ { SIR_MAC_QOS_ACTION_EID_MIN, SIR_MAC_QOS_ACTION_EID_MAX },
133/* 046 */ { SIR_MAC_QOS_CAPABILITY_EID_MIN, SIR_MAC_QOS_CAPABILITY_EID_MAX },
134/* 047 */ { 0, 255 },
135/* 048 */ { SIR_MAC_RSN_EID_MIN, SIR_MAC_RSN_EID_MAX },
136/* 049 */ { 0, 255 },
137/* 050 */ { SIR_MAC_EXTENDED_RATE_EID_MIN, SIR_MAC_EXTENDED_RATE_EID_MAX },
138/* 051 */ { 0, 255 },
139/* 052 */ { 0, 255 },
140/* 053 */ { 0, 255 },
141/* 054 */ { 0, 255 },
142/* 055 */ { 0, 255 },
143/* 056 */ { 0, 255 },
144/* 057 */ { 0, 255 },
145/* 058 */ { 0, 255 },
146/* 059 */ { 0, 255 },
147/* 060 */ { 0, 255 },
148/* 061 */ { 0, 255 },
149/* 062 */ { 0, 255 },
150/* 063 */ { 0, 255 },
151/* 064 */ { 0, 255 },
152/* 065 */ { 0, 255 },
153/* 066 */ { 0, 255 },
154/* 067 */ { 0, 255 },
155#ifdef FEATURE_WLAN_WAPI
156/* 068 */ { DOT11F_EID_WAPI, DOT11F_IE_WAPI_MAX_LEN },
157#else
158/* 068 */ { 0, 255 },
159#endif /* FEATURE_WLAN_WAPI */
160/* 069 */ { 0, 255 },
161/* 070 */ { 0, 255 },
162/* 071 */ { 0, 255 },
163/* 072 */ { 0, 255 },
164/* 073 */ { 0, 255 },
165/* 074 */ { 0, 255 },
166/* 075 */ { 0, 255 },
167/* 076 */ { 0, 255 },
168/* 077 */ { 0, 255 },
169/* 078 */ { 0, 255 },
170/* 079 */ { 0, 255 },
171/* 080 */ { 0, 255 },
172/* 081 */ { 0, 255 },
173/* 082 */ { 0, 255 },
174/* 083 */ { 0, 255 },
175/* 084 */ { 0, 255 },
176/* 085 */ { 0, 255 },
177/* 086 */ { 0, 255 },
178/* 087 */ { 0, 255 },
179/* 088 */ { 0, 255 },
180/* 089 */ { 0, 255 },
181/* 090 */ { 0, 255 },
182/* 091 */ { 0, 255 },
183/* 092 */ { 0, 255 },
184/* 093 */ { 0, 255 },
185/* 094 */ { 0, 255 },
186/* 095 */ { 0, 255 },
187/* 096 */ { 0, 255 },
188/* 097 */ { 0, 255 },
189/* 098 */ { 0, 255 },
190/* 099 */ { 0, 255 },
191/* 100 */ { 0, 255 },
192/* 101 */ { 0, 255 },
193/* 102 */ { 0, 255 },
194/* 103 */ { 0, 255 },
195/* 104 */ { 0, 255 },
196/* 105 */ { 0, 255 },
197/* 106 */ { 0, 255 },
198/* 107 */ { 0, 255 },
199/* 108 */ { 0, 255 },
200/* 109 */ { 0, 255 },
201/* 110 */ { 0, 255 },
202/* 111 */ { 0, 255 },
203/* 112 */ { 0, 255 },
204/* 113 */ { 0, 255 },
205/* 114 */ { 0, 255 },
206/* 115 */ { 0, 255 },
207/* 116 */ { 0, 255 },
208/* 117 */ { 0, 255 },
209/* 118 */ { 0, 255 },
210/* 119 */ { 0, 255 },
211/* 120 */ { 0, 255 },
212/* 121 */ { 0, 255 },
213/* 122 */ { 0, 255 },
214/* 123 */ { 0, 255 },
215/* 124 */ { 0, 255 },
216/* 125 */ { 0, 255 },
217/* 126 */ { 0, 255 },
218/* 127 */ { 0, 255 },
219/* 128 */ { 0, 255 },
220/* 129 */ { 0, 255 },
221/* 130 */ { 0, 255 },
222/* 131 */ { 0, 255 },
223/* 132 */ { 0, 255 },
224/* 133 */ { 0, 255 },
225/* 134 */ { 0, 255 },
226/* 135 */ { 0, 255 },
227/* 136 */ { 0, 255 },
228/* 137 */ { 0, 255 },
229/* 138 */ { 0, 255 },
230/* 139 */ { 0, 255 },
231/* 140 */ { 0, 255 },
232/* 141 */ { 0, 255 },
233/* 142 */ { 0, 255 },
234/* 143 */ { 0, 255 },
235/* 144 */ { 0, 255 },
236/* 145 */ { 0, 255 },
237/* 146 */ { 0, 255 },
238/* 147 */ { 0, 255 },
239/* 148 */ { 0, 255 },
240/* 149 */ { 0, 255 },
241/* 150 */ { 0, 255 },
242/* 151 */ { 0, 255 },
243/* 152 */ { 0, 255 },
244/* 153 */ { 0, 255 },
245/* 154 */ { 0, 255 },
246/* 155 */ { 0, 255 },
247/* 156 */ { 0, 255 },
248/* 157 */ { 0, 255 },
249/* 158 */ { 0, 255 },
250/* 159 */ { 0, 255 },
251/* 160 */ { 0, 255 },
252/* 161 */ { 0, 255 },
253/* 162 */ { 0, 255 },
254/* 163 */ { 0, 255 },
255/* 164 */ { 0, 255 },
256/* 165 */ { 0, 255 },
257/* 166 */ { 0, 255 },
258/* 167 */ { 0, 255 },
259/* 168 */ { 0, 255 },
260/* 169 */ { 0, 255 },
261/* 170 */ { 0, 255 },
262/* 171 */ { 0, 255 },
263/* 172 */ { 0, 255 },
264/* 173 */ { 0, 255 },
265/* 174 */ { 0, 255 },
266/* 175 */ { 0, 255 },
267/* 176 */ { 0, 255 },
268/* 177 */ { 0, 255 },
269/* 178 */ { 0, 255 },
270/* 179 */ { 0, 255 },
271/* 180 */ { 0, 255 },
272/* 181 */ { 0, 255 },
273/* 182 */ { 0, 255 },
274/* 183 */ { 0, 255 },
275/* 184 */ { 0, 255 },
276/* 185 */ { 0, 255 },
277/* 186 */ { 0, 255 },
278/* 187 */ { 0, 255 },
279/* 188 */ { 0, 255 },
280/* 189 */ { 0, 255 },
281/* 190 */ { 0, 255 },
282/* 191 */ { 0, 255 },
283/* 192 */ { 0, 255 },
284/* 193 */ { 0, 255 },
285/* 194 */ { 0, 255 },
286/* 195 */ { 0, 255 },
287/* 196 */ { 0, 255 },
288/* 197 */ { 0, 255 },
289/* 198 */ { 0, 255 },
290/* 199 */ { 0, 255 },
291/* 200 */ { 0, 255 },
292/* 201 */ { 0, 255 },
293/* 202 */ { 0, 255 },
294/* 203 */ { 0, 255 },
295/* 204 */ { 0, 255 },
296/* 205 */ { 0, 255 },
297/* 206 */ { 0, 255 },
298/* 207 */ { 0, 255 },
299/* 208 */ { 0, 255 },
300/* 209 */ { 0, 255 },
301/* 210 */ { 0, 255 },
302/* 211 */ { 0, 255 },
303/* 212 */ { 0, 255 },
304/* 213 */ { 0, 255 },
305/* 214 */ { 0, 255 },
306/* 215 */ { 0, 255 },
307/* 216 */ { 0, 255 },
308/* 217 */ { 0, 255 },
309/* 218 */ { 0, 255 },
310/* 219 */ { 0, 255 },
311/* 220 */ { 0, 255 },
312/* 221 */ { SIR_MAC_WPA_EID_MIN, SIR_MAC_WPA_EID_MAX },
313/* 222 */ { 0, 255 },
314/* 223 */ { 0, 255 },
315/* 224 */ { 0, 255 },
316/* 225 */ { 0, 255 },
317/* 226 */ { 0, 255 },
318/* 227 */ { 0, 255 },
319/* 228 */ { 0, 255 },
320/* 229 */ { 0, 255 },
321/* 230 */ { 0, 255 },
322/* 231 */ { 0, 255 },
323/* 232 */ { 0, 255 },
324/* 233 */ { 0, 255 },
325/* 234 */ { 0, 255 },
326/* 235 */ { 0, 255 },
327/* 236 */ { 0, 255 },
328/* 237 */ { 0, 255 },
329/* 238 */ { 0, 255 },
330/* 239 */ { 0, 255 },
331/* 240 */ { 0, 255 },
332/* 241 */ { 0, 255 },
333/* 242 */ { 0, 255 },
334/* 243 */ { 0, 255 },
335/* 244 */ { 0, 255 },
336/* 245 */ { 0, 255 },
337/* 246 */ { 0, 255 },
338/* 247 */ { 0, 255 },
339/* 248 */ { 0, 255 },
340/* 249 */ { 0, 255 },
341/* 250 */ { 0, 255 },
342/* 251 */ { 0, 255 },
343/* 252 */ { 0, 255 },
344/* 253 */ { 0, 255 },
345/* 254 */ { 0, 255 },
346/* 255 */ { SIR_MAC_ANI_WORKAROUND_EID_MIN, SIR_MAC_ANI_WORKAROUND_EID_MAX }
347};
348
349#if 0
350//Don't not insert entry into the table, put it to the end. If you have to insert, make sure it is also
351//reflected in eCsrCountryIndex
352static tCsrCountryInfo gCsrCountryInfo[eCSR_NUM_COUNTRY_INDEX] =
353{
354 {REG_DOMAIN_FCC, {'U', 'S', ' '}}, //USA/******The "US" MUST be at index 0*******/
355 {REG_DOMAIN_WORLD, {'A', 'D', ' '}}, //ANDORRA
356 {REG_DOMAIN_WORLD, {'A', 'E', ' '}}, //UAE
357 {REG_DOMAIN_WORLD, {'A', 'F', ' '}}, //AFGHANISTAN
358 {REG_DOMAIN_WORLD, {'A', 'G', ' '}}, //ANTIGUA AND BARBUDA
359 {REG_DOMAIN_WORLD, {'A', 'I', ' '}}, //ANGUILLA
360 {REG_DOMAIN_HI_5GHZ, {'A', 'L', ' '}}, //ALBANIA
361 {REG_DOMAIN_WORLD, {'A', 'M', ' '}}, //ARMENIA
362 {REG_DOMAIN_WORLD, {'A', 'N', ' '}}, //NETHERLANDS ANTILLES
363 {REG_DOMAIN_WORLD, {'A', 'O', ' '}}, //ANGOLA
364 {REG_DOMAIN_WORLD, {'A', 'Q', ' '}}, //ANTARCTICA
365 {REG_DOMAIN_HI_5GHZ, {'A', 'R', ' '}}, //ARGENTINA
366 {REG_DOMAIN_FCC, {'A', 'S', ' '}}, //AMERICAN SOMOA
367 {REG_DOMAIN_ETSI, {'A', 'T', ' '}}, //AUSTRIA
368 {REG_DOMAIN_ETSI, {'A', 'U', ' '}}, //AUSTRALIA
369 {REG_DOMAIN_WORLD, {'A', 'W', ' '}}, //ARUBA
370 {REG_DOMAIN_WORLD, {'A', 'X', ' '}}, //ALAND ISLANDS
371 {REG_DOMAIN_WORLD, {'A', 'Z', ' '}}, //AZERBAIJAN
372 {REG_DOMAIN_WORLD, {'B', 'A', ' '}}, //BOSNIA AND HERZEGOVINA
373 {REG_DOMAIN_WORLD, {'B', 'B', ' '}}, //BARBADOS
374 {REG_DOMAIN_WORLD, {'B', 'D', ' '}}, //BANGLADESH
375 {REG_DOMAIN_ETSI, {'B', 'E', ' '}}, //BELGIUM
376 {REG_DOMAIN_WORLD, {'B', 'F', ' '}}, //BURKINA FASO
377 {REG_DOMAIN_HI_5GHZ, {'B', 'G', ' '}}, //BULGARIA
378 {REG_DOMAIN_WORLD, {'B', 'H', ' '}}, //BAHRAIN
379 {REG_DOMAIN_WORLD, {'B', 'I', ' '}}, //BURUNDI
380 {REG_DOMAIN_WORLD, {'B', 'J', ' '}}, //BENIN
381 {REG_DOMAIN_WORLD, {'B', 'L', ' '}}, //SAINT BARTHELEMY
382 {REG_DOMAIN_ETSI, {'B', 'M', ' '}}, //BERMUDA
383 {REG_DOMAIN_WORLD, {'B', 'N', ' '}}, //BRUNEI DARUSSALAM
384 {REG_DOMAIN_WORLD, {'B', 'O', ' '}}, //BOLIVIA
385 {REG_DOMAIN_WORLD, {'B', 'R', ' '}}, //BRAZIL
386 {REG_DOMAIN_WORLD, {'B', 'S', ' '}}, //BAHAMAS
387 {REG_DOMAIN_WORLD, {'B', 'T', ' '}}, //BHUTAN
388 {REG_DOMAIN_WORLD, {'B', 'V', ' '}}, //BOUVET ISLAND
389 {REG_DOMAIN_WORLD, {'B', 'W', ' '}}, //BOTSWANA
390 {REG_DOMAIN_WORLD, {'B', 'Y', ' '}}, //BELARUS
391 {REG_DOMAIN_WORLD, {'B', 'Z', ' '}}, //BELIZE
392 {REG_DOMAIN_FCC, {'C', 'A', ' '}}, //CANADA
393 {REG_DOMAIN_WORLD, {'C', 'C', ' '}}, //COCOS (KEELING) ISLANDS
394 {REG_DOMAIN_WORLD, {'C', 'D', ' '}}, //CONGO, THE DEMOCRATIC REPUBLIC OF THE
395 {REG_DOMAIN_WORLD, {'C', 'F', ' '}}, //CENTRAL AFRICAN REPUBLIC
396 {REG_DOMAIN_WORLD, {'C', 'G', ' '}}, //CONGO
397 {REG_DOMAIN_ETSI, {'C', 'H', ' '}}, //SWITZERLAND
398 {REG_DOMAIN_WORLD, {'C', 'I', ' '}}, //COTE D'IVOIRE
399 {REG_DOMAIN_WORLD, {'C', 'K', ' '}}, //COOK ISLANDS
400 {REG_DOMAIN_WORLD, {'C', 'L', ' '}}, //CHILE
401 {REG_DOMAIN_WORLD, {'C', 'M', ' '}}, //CAMEROON
402 {REG_DOMAIN_HI_5GHZ, {'C', 'N', ' '}}, //CHINA
403 {REG_DOMAIN_WORLD, {'C', 'O', ' '}}, //COLOMBIA
404 {REG_DOMAIN_WORLD, {'C', 'R', ' '}}, //COSTA RICA
405 {REG_DOMAIN_WORLD, {'C', 'U', ' '}}, //CUBA
406 {REG_DOMAIN_WORLD, {'C', 'V', ' '}}, //CAPE VERDE
407 {REG_DOMAIN_WORLD, {'C', 'X', ' '}}, //CHRISTMAS ISLAND
408 {REG_DOMAIN_WORLD, {'C', 'Y', ' '}}, //CYPRUS
409 {REG_DOMAIN_HI_5GHZ, {'C', 'Z', ' '}}, //CZECH REPUBLIC
410 {REG_DOMAIN_ETSI, {'D', 'E', ' '}}, //GERMANY
411 {REG_DOMAIN_WORLD, {'D', 'J', ' '}}, //DJIBOUTI
412 {REG_DOMAIN_ETSI, {'D', 'K', ' '}}, //DENMARK
413 {REG_DOMAIN_WORLD, {'D', 'M', ' '}}, //DOMINICA
414 {REG_DOMAIN_WORLD, {'D', 'O', ' '}}, //DOMINICAN REPUBLIC
415 {REG_DOMAIN_WORLD, {'D', 'Z', ' '}}, //ALGERIA
416 {REG_DOMAIN_WORLD, {'E', 'C', ' '}}, //ECUADOR
417 {REG_DOMAIN_HI_5GHZ, {'E', 'E', ' '}}, //ESTONIA
418 {REG_DOMAIN_WORLD, {'E', 'G', ' '}}, //EGYPT
419 {REG_DOMAIN_WORLD, {'E', 'H', ' '}}, //WESTERN SAHARA
420 {REG_DOMAIN_WORLD, {'E', 'R', ' '}}, //ERITREA
421 {REG_DOMAIN_ETSI, {'E', 'S', ' '}}, //SPAIN
422 {REG_DOMAIN_WORLD, {'E', 'T', ' '}}, //ETHIOPIA
423 {REG_DOMAIN_WORLD, {'F', 'I', ' '}}, //FINLAND
424 {REG_DOMAIN_WORLD, {'F', 'J', ' '}}, //FIJI
425 {REG_DOMAIN_WORLD, {'F', 'K', ' '}}, //FALKLAND ISLANDS (MALVINAS)
426 {REG_DOMAIN_WORLD, {'F', 'M', ' '}}, //MICRONESIA, FEDERATED STATES OF
427 {REG_DOMAIN_WORLD, {'F', 'O', ' '}}, //FAROE ISLANDS
428 {REG_DOMAIN_ETSI, {'F', 'R', ' '}}, //FRANCE
429 {REG_DOMAIN_WORLD, {'G', 'A', ' '}}, //GABON
430 {REG_DOMAIN_ETSI, {'G', 'B', ' '}}, //UNITED KINGDOM
431 {REG_DOMAIN_WORLD, {'G', 'D', ' '}}, //GRENADA
432 {REG_DOMAIN_HI_5GHZ, {'G', 'E', ' '}}, //GEORGIA
433 {REG_DOMAIN_WORLD, {'G', 'F', ' '}}, //FRENCH GUIANA
434 {REG_DOMAIN_ETSI, {'G', 'G', ' '}}, //GUERNSEY
435 {REG_DOMAIN_WORLD, {'G', 'H', ' '}}, //GHANA
436 {REG_DOMAIN_WORLD, {'G', 'I', ' '}}, //GIBRALTAR
437 {REG_DOMAIN_WORLD, {'G', 'L', ' '}}, //GREENLAND
438 {REG_DOMAIN_WORLD, {'G', 'M', ' '}}, //GAMBIA
439 {REG_DOMAIN_WORLD, {'G', 'N', ' '}}, //GUINEA
440 {REG_DOMAIN_WORLD, {'G', 'P', ' '}}, //GUADELOUPE
441 {REG_DOMAIN_WORLD, {'G', 'Q', ' '}}, //EQUATORIAL GUINEA
442 {REG_DOMAIN_ETSI, {'G', 'R', ' '}}, //GREECE
443 {REG_DOMAIN_WORLD, {'G', 'S', ' '}}, //SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS
444 {REG_DOMAIN_WORLD, {'G', 'T', ' '}}, //GUATEMALA
445 {REG_DOMAIN_WORLD, {'G', 'U', ' '}}, //GUAM
446 {REG_DOMAIN_WORLD, {'G', 'W', ' '}}, //GUINEA-BISSAU
447 {REG_DOMAIN_WORLD, {'G', 'Y', ' '}}, //GUYANA
448 {REG_DOMAIN_WORLD, {'H', 'K', ' '}}, //HONGKONG
449 {REG_DOMAIN_WORLD, {'H', 'M', ' '}}, //HEARD ISLAND AND MCDONALD ISLANDS
450 {REG_DOMAIN_WORLD, {'H', 'N', ' '}}, //HONDURAS
451 {REG_DOMAIN_HI_5GHZ, {'H', 'R', ' '}}, //CROATIA
452 {REG_DOMAIN_WORLD, {'H', 'T', ' '}}, //HAITI
453 {REG_DOMAIN_HI_5GHZ, {'H', 'U', ' '}}, //HUNGARY
454 {REG_DOMAIN_APAC, {'I', 'D', ' '}}, //INDONESIA
455 {REG_DOMAIN_ETSI, {'I', 'E', ' '}}, //IRELAND
456 {REG_DOMAIN_WORLD, {'I', 'L', ' '}}, //ISREAL
457 {REG_DOMAIN_ETSI, {'I', 'M', ' '}}, //ISLE OF MAN
458 {REG_DOMAIN_WORLD, {'I', 'N', ' '}}, //INDIA
459 {REG_DOMAIN_ETSI, {'I', 'O', ' '}}, //BRITISH INDIAN OCEAN TERRITORY
460 {REG_DOMAIN_WORLD, {'I', 'Q', ' '}}, //IRAQ
461 {REG_DOMAIN_WORLD, {'I', 'R', ' '}}, //IRAN, ISLAMIC REPUBLIC OF
462 {REG_DOMAIN_WORLD, {'I', 'S', ' '}}, //ICELAND
463 {REG_DOMAIN_ETSI, {'I', 'T', ' '}}, //ITALY
464 {REG_DOMAIN_ETSI, {'J', 'E', ' '}}, //JERSEY
465 {REG_DOMAIN_WORLD, {'J', 'M', ' '}}, //JAMAICA
466 {REG_DOMAIN_WORLD, {'J', 'O', ' '}}, //JORDAN
467 {REG_DOMAIN_JAPAN, {'J', 'P', ' '}}, //JAPAN
468 {REG_DOMAIN_WORLD, {'K', 'E', ' '}}, //KENYA
469 {REG_DOMAIN_WORLD, {'K', 'G', ' '}}, //KYRGYZSTAN
470 {REG_DOMAIN_WORLD, {'K', 'H', ' '}}, //CAMBODIA
471 {REG_DOMAIN_WORLD, {'K', 'I', ' '}}, //KIRIBATI
472 {REG_DOMAIN_WORLD, {'K', 'M', ' '}}, //COMOROS
473 {REG_DOMAIN_WORLD, {'K', 'N', ' '}}, //SAINT KITTS AND NEVIS
474 {REG_DOMAIN_KOREA, {'K', 'P', ' '}}, //KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF
475 {REG_DOMAIN_KOREA, {'K', 'R', ' '}}, //KOREA, REPUBLIC OF
476 {REG_DOMAIN_WORLD, {'K', 'W', ' '}}, //KUWAIT
477 {REG_DOMAIN_WORLD, {'K', 'Y', ' '}}, //CAYMAN ISLANDS
478 {REG_DOMAIN_WORLD, {'K', 'Z', ' '}}, //KAZAKHSTAN
479 {REG_DOMAIN_WORLD, {'L', 'A', ' '}}, //LAO PEOPLE'S DEMOCRATIC REPUBLIC
480 {REG_DOMAIN_WORLD, {'L', 'B', ' '}}, //LEBANON
481 {REG_DOMAIN_WORLD, {'L', 'C', ' '}}, //SAINT LUCIA
482 {REG_DOMAIN_ETSI, {'L', 'I', ' '}}, //LIECHTENSTEIN
483 {REG_DOMAIN_WORLD, {'L', 'K', ' '}}, //SRI LANKA
484 {REG_DOMAIN_WORLD, {'L', 'R', ' '}}, //LIBERIA
485 {REG_DOMAIN_WORLD, {'L', 'S', ' '}}, //LESOTHO
486 {REG_DOMAIN_HI_5GHZ, {'L', 'T', ' '}}, //LITHUANIA
487 {REG_DOMAIN_ETSI, {'L', 'U', ' '}}, //LUXEMBOURG
488 {REG_DOMAIN_HI_5GHZ, {'L', 'V', ' '}}, //LATVIA
489 {REG_DOMAIN_WORLD, {'L', 'Y', ' '}}, //LIBYAN ARAB JAMAHIRIYA
490 {REG_DOMAIN_WORLD, {'M', 'A', ' '}}, //MOROCCO
491 {REG_DOMAIN_ETSI, {'M', 'C', ' '}}, //MONACO
492 {REG_DOMAIN_WORLD, {'M', 'D', ' '}}, //MOLDOVA, REPUBLIC OF
493 {REG_DOMAIN_WORLD, {'M', 'E', ' '}}, //MONTENEGRO
494 {REG_DOMAIN_WORLD, {'M', 'G', ' '}}, //MADAGASCAR
495 {REG_DOMAIN_WORLD, {'M', 'H', ' '}}, //MARSHALL ISLANDS
496 {REG_DOMAIN_WORLD, {'M', 'K', ' '}}, //MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF
497 {REG_DOMAIN_WORLD, {'M', 'L', ' '}}, //MALI
498 {REG_DOMAIN_WORLD, {'M', 'M', ' '}}, //MYANMAR
499 {REG_DOMAIN_HI_5GHZ, {'M', 'N', ' '}}, //MONGOLIA
500 {REG_DOMAIN_WORLD, {'M', 'O', ' '}}, //MACAO
501 {REG_DOMAIN_WORLD, {'M', 'P', ' '}}, //NORTHERN MARIANA ISLANDS
502 {REG_DOMAIN_WORLD, {'M', 'Q', ' '}}, //MARTINIQUE
503 {REG_DOMAIN_WORLD, {'M', 'R', ' '}}, //MAURITANIA
504 {REG_DOMAIN_WORLD, {'M', 'S', ' '}}, //MONTSERRAT
505 {REG_DOMAIN_WORLD, {'M', 'T', ' '}}, //MALTA
506 {REG_DOMAIN_WORLD, {'M', 'U', ' '}}, //MAURITIUS
507 {REG_DOMAIN_WORLD, {'M', 'V', ' '}}, //MALDIVES
508 {REG_DOMAIN_WORLD, {'M', 'W', ' '}}, //MALAWI
509 {REG_DOMAIN_WORLD, {'M', 'X', ' '}}, //MEXICO
510 {REG_DOMAIN_HI_5GHZ, {'M', 'Y', ' '}}, //MALAYSIA
511 {REG_DOMAIN_WORLD, {'M', 'Z', ' '}}, //MOZAMBIQUE
512 {REG_DOMAIN_WORLD, {'N', 'A', ' '}}, //NAMIBIA
513 {REG_DOMAIN_WORLD, {'N', 'C', ' '}}, //NEW CALEDONIA
514 {REG_DOMAIN_WORLD, {'N', 'E', ' '}}, //NIGER
515 {REG_DOMAIN_WORLD, {'N', 'F', ' '}}, //NORFOLD ISLAND
516 {REG_DOMAIN_WORLD, {'N', 'G', ' '}}, //NIGERIA
517 {REG_DOMAIN_WORLD, {'N', 'I', ' '}}, //NICARAGUA
518 {REG_DOMAIN_ETSI, {'N', 'L', ' '}}, //NETHERLANDS
519 {REG_DOMAIN_WORLD, {'N', 'O', ' '}}, //NORWAY
520 {REG_DOMAIN_WORLD, {'N', 'P', ' '}}, //NEPAL
521 {REG_DOMAIN_WORLD, {'N', 'R', ' '}}, //NAURU
522 {REG_DOMAIN_WORLD, {'N', 'U', ' '}}, //NIUE
523 {REG_DOMAIN_ETSI, {'N', 'Z', ' '}}, //NEW ZEALAND
524 {REG_DOMAIN_WORLD, {'O', 'M', ' '}}, //OMAN
525 {REG_DOMAIN_WORLD, {'P', 'A', ' '}}, //PANAMA
526 {REG_DOMAIN_WORLD, {'P', 'E', ' '}}, //PERU
527 {REG_DOMAIN_WORLD, {'P', 'F', ' '}}, //FRENCH POLYNESIA
528 {REG_DOMAIN_WORLD, {'P', 'G', ' '}}, //PAPUA NEW GUINEA
529 {REG_DOMAIN_WORLD, {'P', 'H', ' '}}, //PHILIPPINES
530 {REG_DOMAIN_WORLD, {'P', 'K', ' '}}, //PAKISTAN
531 {REG_DOMAIN_WORLD, {'P', 'L', ' '}}, //POLAND
532 {REG_DOMAIN_WORLD, {'P', 'M', ' '}}, //SAINT PIERRE AND MIQUELON
533 {REG_DOMAIN_WORLD, {'P', 'N', ' '}}, //PITCAIRN
534 {REG_DOMAIN_FCC, {'P', 'R', ' '}}, //PUERTO RICO
535 {REG_DOMAIN_WORLD, {'P', 'S', ' '}}, //PALESTINIAN TERRITORY, OCCUPIED
536 {REG_DOMAIN_ETSI, {'P', 'T', ' '}}, //PORTUGAL
537 {REG_DOMAIN_WORLD, {'P', 'W', ' '}}, //PALAU
538 {REG_DOMAIN_WORLD, {'P', 'Y', ' '}}, //PARAGUAY
539 {REG_DOMAIN_WORLD, {'Q', 'A', ' '}}, //QATAR
540 {REG_DOMAIN_WORLD, {'R', 'E', ' '}}, //REUNION
541 {REG_DOMAIN_HI_5GHZ, {'R', 'O', ' '}}, //ROMANIA
542 {REG_DOMAIN_HI_5GHZ, {'R', 'S', ' '}}, //SERBIA
543 {REG_DOMAIN_WORLD, {'R', 'U', ' '}}, //RUSSIA
544 {REG_DOMAIN_WORLD, {'R', 'W', ' '}}, //RWANDA
545 {REG_DOMAIN_WORLD, {'S', 'A', ' '}}, //SAUDI ARABIA
546 {REG_DOMAIN_WORLD, {'S', 'B', ' '}}, //SOLOMON ISLANDS
547 {REG_DOMAIN_ETSI, {'S', 'C', ' '}}, //SEYCHELLES
548 {REG_DOMAIN_WORLD, {'S', 'D', ' '}}, //SUDAN
549 {REG_DOMAIN_ETSI, {'S', 'E', ' '}}, //SWEDEN
550 {REG_DOMAIN_APAC, {'S', 'G', ' '}}, //SINGAPORE
551 {REG_DOMAIN_WORLD, {'S', 'H', ' '}}, //SAINT HELENA
552 {REG_DOMAIN_HI_5GHZ, {'S', 'I', ' '}}, //SLOVENNIA
553 {REG_DOMAIN_WORLD, {'S', 'J', ' '}}, //SVALBARD AND JAN MAYEN
554 {REG_DOMAIN_HI_5GHZ, {'S', 'K', ' '}}, //SLOVAKIA
555 {REG_DOMAIN_WORLD, {'S', 'L', ' '}}, //SIERRA LEONE
556 {REG_DOMAIN_WORLD, {'S', 'M', ' '}}, //SAN MARINO
557 {REG_DOMAIN_WORLD, {'S', 'N', ' '}}, //SENEGAL
558 {REG_DOMAIN_WORLD, {'S', 'O', ' '}}, //SOMALIA
559 {REG_DOMAIN_WORLD, {'S', 'R', ' '}}, //SURINAME
560 {REG_DOMAIN_WORLD, {'S', 'T', ' '}}, //SAO TOME AND PRINCIPE
561 {REG_DOMAIN_WORLD, {'S', 'V', ' '}}, //EL SALVADOR
562 {REG_DOMAIN_WORLD, {'S', 'Y', ' '}}, //SYRIAN ARAB REPUBLIC
563 {REG_DOMAIN_WORLD, {'S', 'Z', ' '}}, //SWAZILAND
564 {REG_DOMAIN_WORLD, {'T', 'C', ' '}}, //TURKS AND CAICOS ISLANDS
565 {REG_DOMAIN_WORLD, {'T', 'D', ' '}}, //CHAD
566 {REG_DOMAIN_WORLD, {'T', 'F', ' '}}, //FRENCH SOUTHERN TERRITORIES
567 {REG_DOMAIN_WORLD, {'T', 'G', ' '}}, //TOGO
568 {REG_DOMAIN_WORLD, {'T', 'H', ' '}}, //THAILAND
569 {REG_DOMAIN_WORLD, {'T', 'J', ' '}}, //TAJIKISTAN
570 {REG_DOMAIN_WORLD, {'T', 'K', ' '}}, //TOKELAU
571 {REG_DOMAIN_WORLD, {'T', 'L', ' '}}, //TIMOR-LESTE
572 {REG_DOMAIN_WORLD, {'T', 'M', ' '}}, //TURKMENISTAN
573 {REG_DOMAIN_WORLD, {'T', 'N', ' '}}, //TUNISIA
574 {REG_DOMAIN_WORLD, {'T', 'O', ' '}}, //TONGA
575 {REG_DOMAIN_WORLD, {'T', 'R', ' '}}, //TURKEY
576 {REG_DOMAIN_WORLD, {'T', 'T', ' '}}, //TRINIDAD AND TOBAGO
577 {REG_DOMAIN_WORLD, {'T', 'V', ' '}}, //TUVALU
578 {REG_DOMAIN_HI_5GHZ, {'T', 'W', ' '}}, //TAIWAN, PROVINCE OF CHINA
579 {REG_DOMAIN_WORLD, {'T', 'Z', ' '}}, //TANZANIA, UNITED REPUBLIC OF
580 {REG_DOMAIN_HI_5GHZ, {'U', 'A', ' '}}, //UKRAINE
581 {REG_DOMAIN_WORLD, {'U', 'G', ' '}}, //UGANDA
582 {REG_DOMAIN_FCC, {'U', 'M', ' '}}, //UNITED STATES MINOR OUTLYING ISLANDS
583 {REG_DOMAIN_WORLD, {'U', 'Y', ' '}}, //URUGUAY
584 {REG_DOMAIN_HI_5GHZ, {'U', 'Z', ' '}}, //UZBEKISTAN
585 {REG_DOMAIN_ETSI, {'V', 'A', ' '}}, //HOLY SEE (VATICAN CITY STATE)
586 {REG_DOMAIN_WORLD, {'V', 'C', ' '}}, //SAINT VINCENT AND THE GRENADINES
587 {REG_DOMAIN_HI_5GHZ, {'V', 'E', ' '}}, //VENEZUELA
588 {REG_DOMAIN_ETSI, {'V', 'G', ' '}}, //VIRGIN ISLANDS, BRITISH
589 {REG_DOMAIN_FCC, {'V', 'I', ' '}}, //VIRGIN ISLANDS, US
590 {REG_DOMAIN_WORLD, {'V', 'N', ' '}}, //VIET NAM
591 {REG_DOMAIN_WORLD, {'V', 'U', ' '}}, //VANUATU
592 {REG_DOMAIN_WORLD, {'W', 'F', ' '}}, //WALLIS AND FUTUNA
593 {REG_DOMAIN_WORLD, {'W', 'S', ' '}}, //SOMOA
594 {REG_DOMAIN_WORLD, {'Y', 'E', ' '}}, //YEMEN
595 {REG_DOMAIN_WORLD, {'Y', 'T', ' '}}, //MAYOTTE
596 {REG_DOMAIN_WORLD, {'Z', 'A', ' '}}, //SOUTH AFRICA
597 {REG_DOMAIN_WORLD, {'Z', 'M', ' '}}, //ZAMBIA
598 {REG_DOMAIN_WORLD, {'Z', 'W', ' '}}, //ZIMBABWE
599
600 {REG_DOMAIN_KOREA, {'K', '1', ' '}}, //Korea alternate 1
601 {REG_DOMAIN_KOREA, {'K', '2', ' '}}, //Korea alternate 2
602 {REG_DOMAIN_KOREA, {'K', '3', ' '}}, //Korea alternate 3
603 {REG_DOMAIN_KOREA, {'K', '4', ' '}}, //Korea alternate 4
604};
605
606
607//The channels listed here doesn't mean they are valid channels for certain domain. They are here only to present
608//whether they should be passive scanned.
609tCsrDomainChnInfo gCsrDomainChnInfo[NUM_REG_DOMAINS] =
610{
611 //REG_DOMAIN_FCC
612 {
613 REG_DOMAIN_FCC,
614 45, //Num channels
615 //Channels
616 {
617 //5GHz
618 //5180 - 5240
619 {36, eSIR_ACTIVE_SCAN},
620 {40, eSIR_ACTIVE_SCAN},
621 {44, eSIR_ACTIVE_SCAN},
622 {48, eSIR_ACTIVE_SCAN},
623 //5250 to 5350
624 {52, eSIR_PASSIVE_SCAN},
625 {56, eSIR_PASSIVE_SCAN},
626 {60, eSIR_PASSIVE_SCAN},
627 {64, eSIR_PASSIVE_SCAN},
628 //5470 to 5725
629 {100, eSIR_PASSIVE_SCAN},
630 {104, eSIR_PASSIVE_SCAN},
631 {108, eSIR_PASSIVE_SCAN},
632 {112, eSIR_PASSIVE_SCAN},
633 {116, eSIR_PASSIVE_SCAN},
634 {120, eSIR_PASSIVE_SCAN},
635 {124, eSIR_PASSIVE_SCAN},
636 {128, eSIR_PASSIVE_SCAN},
637 {132, eSIR_PASSIVE_SCAN},
638 {136, eSIR_PASSIVE_SCAN},
639 {140, eSIR_PASSIVE_SCAN},
640 //5745 - 5825
641 {149, eSIR_ACTIVE_SCAN},
642 {153, eSIR_ACTIVE_SCAN},
643 {157, eSIR_ACTIVE_SCAN},
644 {161, eSIR_ACTIVE_SCAN},
645 {165, eSIR_ACTIVE_SCAN},
646 //4.9GHz
647 //4920 - 5080
648 {240, eSIR_ACTIVE_SCAN},
649 {244, eSIR_ACTIVE_SCAN},
650 {248, eSIR_ACTIVE_SCAN},
651 {252, eSIR_ACTIVE_SCAN},
652 {208, eSIR_ACTIVE_SCAN},
653 {212, eSIR_ACTIVE_SCAN},
654 {216, eSIR_ACTIVE_SCAN},
655 //2,4GHz
656 {1, eSIR_ACTIVE_SCAN},
657 {2, eSIR_ACTIVE_SCAN},
658 {3, eSIR_ACTIVE_SCAN},
659 {4, eSIR_ACTIVE_SCAN},
660 {5, eSIR_ACTIVE_SCAN},
661 {6, eSIR_ACTIVE_SCAN},
662 {7, eSIR_ACTIVE_SCAN},
663 {8, eSIR_ACTIVE_SCAN},
664 {9, eSIR_ACTIVE_SCAN},
665 {10, eSIR_ACTIVE_SCAN},
666 {11, eSIR_ACTIVE_SCAN},
667 {12, eSIR_ACTIVE_SCAN},
668 {13, eSIR_ACTIVE_SCAN},
669 {14, eSIR_ACTIVE_SCAN},
670 }
671 },
672 //REG_DOMAIN_ETSI
673 {
674 REG_DOMAIN_ETSI,
675 45, //Num channels
676 //Channels
677 {
678 //5GHz
679 //5180 - 5240
680 {36, eSIR_ACTIVE_SCAN},
681 {40, eSIR_ACTIVE_SCAN},
682 {44, eSIR_ACTIVE_SCAN},
683 {48, eSIR_ACTIVE_SCAN},
684 //5250 to 5350
685 {52, eSIR_PASSIVE_SCAN},
686 {56, eSIR_PASSIVE_SCAN},
687 {60, eSIR_PASSIVE_SCAN},
688 {64, eSIR_PASSIVE_SCAN},
689 //5470 to 5725
690 {100, eSIR_PASSIVE_SCAN},
691 {104, eSIR_PASSIVE_SCAN},
692 {108, eSIR_PASSIVE_SCAN},
693 {112, eSIR_PASSIVE_SCAN},
694 {116, eSIR_PASSIVE_SCAN},
695 {120, eSIR_PASSIVE_SCAN},
696 {124, eSIR_PASSIVE_SCAN},
697 {128, eSIR_PASSIVE_SCAN},
698 {132, eSIR_PASSIVE_SCAN},
699 {136, eSIR_PASSIVE_SCAN},
700 {140, eSIR_PASSIVE_SCAN},
701 //5745 - 5825
702 {149, eSIR_ACTIVE_SCAN},
703 {153, eSIR_ACTIVE_SCAN},
704 {157, eSIR_ACTIVE_SCAN},
705 {161, eSIR_ACTIVE_SCAN},
706 {165, eSIR_ACTIVE_SCAN},
707 //4.9GHz
708 //4920 - 5080
709 {240, eSIR_ACTIVE_SCAN},
710 {244, eSIR_ACTIVE_SCAN},
711 {248, eSIR_ACTIVE_SCAN},
712 {252, eSIR_ACTIVE_SCAN},
713 {208, eSIR_ACTIVE_SCAN},
714 {212, eSIR_ACTIVE_SCAN},
715 {216, eSIR_ACTIVE_SCAN},
716 //2,4GHz
717 {1, eSIR_ACTIVE_SCAN},
718 {2, eSIR_ACTIVE_SCAN},
719 {3, eSIR_ACTIVE_SCAN},
720 {4, eSIR_ACTIVE_SCAN},
721 {5, eSIR_ACTIVE_SCAN},
722 {6, eSIR_ACTIVE_SCAN},
723 {7, eSIR_ACTIVE_SCAN},
724 {8, eSIR_ACTIVE_SCAN},
725 {9, eSIR_ACTIVE_SCAN},
726 {10, eSIR_ACTIVE_SCAN},
727 {11, eSIR_ACTIVE_SCAN},
728 {12, eSIR_ACTIVE_SCAN},
729 {13, eSIR_ACTIVE_SCAN},
730 {14, eSIR_ACTIVE_SCAN},
731 }
732 },
733 //REG_DOMAIN_JAPAN
734 {
735 REG_DOMAIN_JAPAN,
736 45, //Num channels
737 //Channels
738 {
739 //5GHz
740 //5180 - 5240
741 {36, eSIR_ACTIVE_SCAN},
742 {40, eSIR_ACTIVE_SCAN},
743 {44, eSIR_ACTIVE_SCAN},
744 {48, eSIR_ACTIVE_SCAN},
745 //5250 to 5350
746 {52, eSIR_PASSIVE_SCAN},
747 {56, eSIR_PASSIVE_SCAN},
748 {60, eSIR_PASSIVE_SCAN},
749 {64, eSIR_PASSIVE_SCAN},
750 //5470 to 5725
751 {100, eSIR_PASSIVE_SCAN},
752 {104, eSIR_PASSIVE_SCAN},
753 {108, eSIR_PASSIVE_SCAN},
754 {112, eSIR_PASSIVE_SCAN},
755 {116, eSIR_PASSIVE_SCAN},
756 {120, eSIR_PASSIVE_SCAN},
757 {124, eSIR_PASSIVE_SCAN},
758 {128, eSIR_PASSIVE_SCAN},
759 {132, eSIR_PASSIVE_SCAN},
760 {136, eSIR_PASSIVE_SCAN},
761 {140, eSIR_PASSIVE_SCAN},
762 //5745 - 5825
763 {149, eSIR_ACTIVE_SCAN},
764 {153, eSIR_ACTIVE_SCAN},
765 {157, eSIR_ACTIVE_SCAN},
766 {161, eSIR_ACTIVE_SCAN},
767 {165, eSIR_ACTIVE_SCAN},
768 //4.9GHz
769 //4920 - 5080
770 {240, eSIR_ACTIVE_SCAN},
771 {244, eSIR_ACTIVE_SCAN},
772 {248, eSIR_ACTIVE_SCAN},
773 {252, eSIR_ACTIVE_SCAN},
774 {208, eSIR_ACTIVE_SCAN},
775 {212, eSIR_ACTIVE_SCAN},
776 {216, eSIR_ACTIVE_SCAN},
777 //2,4GHz
778 {1, eSIR_ACTIVE_SCAN},
779 {2, eSIR_ACTIVE_SCAN},
780 {3, eSIR_ACTIVE_SCAN},
781 {4, eSIR_ACTIVE_SCAN},
782 {5, eSIR_ACTIVE_SCAN},
783 {6, eSIR_ACTIVE_SCAN},
784 {7, eSIR_ACTIVE_SCAN},
785 {8, eSIR_ACTIVE_SCAN},
786 {9, eSIR_ACTIVE_SCAN},
787 {10, eSIR_ACTIVE_SCAN},
788 {11, eSIR_ACTIVE_SCAN},
789 {12, eSIR_ACTIVE_SCAN},
790 {13, eSIR_ACTIVE_SCAN},
791 {14, eSIR_ACTIVE_SCAN},
792 }
793 },
794 //REG_DOMAIN_WORLD
795 {
796 REG_DOMAIN_WORLD,
797 45, //Num channels
798 //Channels
799 {
800 //5GHz
801 //5180 - 5240
802 {36, eSIR_ACTIVE_SCAN},
803 {40, eSIR_ACTIVE_SCAN},
804 {44, eSIR_ACTIVE_SCAN},
805 {48, eSIR_ACTIVE_SCAN},
806 //5250 to 5350
807 {52, eSIR_ACTIVE_SCAN},
808 {56, eSIR_ACTIVE_SCAN},
809 {60, eSIR_ACTIVE_SCAN},
810 {64, eSIR_ACTIVE_SCAN},
811 //5470 to 5725
812 {100, eSIR_ACTIVE_SCAN},
813 {104, eSIR_ACTIVE_SCAN},
814 {108, eSIR_ACTIVE_SCAN},
815 {112, eSIR_ACTIVE_SCAN},
816 {116, eSIR_ACTIVE_SCAN},
817 {120, eSIR_ACTIVE_SCAN},
818 {124, eSIR_ACTIVE_SCAN},
819 {128, eSIR_ACTIVE_SCAN},
820 {132, eSIR_ACTIVE_SCAN},
821 {136, eSIR_ACTIVE_SCAN},
822 {140, eSIR_ACTIVE_SCAN},
823 //5745 - 5825
824 {149, eSIR_ACTIVE_SCAN},
825 {153, eSIR_ACTIVE_SCAN},
826 {157, eSIR_ACTIVE_SCAN},
827 {161, eSIR_ACTIVE_SCAN},
828 {165, eSIR_ACTIVE_SCAN},
829 //4.9GHz
830 //4920 - 5080
831 {240, eSIR_ACTIVE_SCAN},
832 {244, eSIR_ACTIVE_SCAN},
833 {248, eSIR_ACTIVE_SCAN},
834 {252, eSIR_ACTIVE_SCAN},
835 {208, eSIR_ACTIVE_SCAN},
836 {212, eSIR_ACTIVE_SCAN},
837 {216, eSIR_ACTIVE_SCAN},
838 //2,4GHz
839 {1, eSIR_ACTIVE_SCAN},
840 {2, eSIR_ACTIVE_SCAN},
841 {3, eSIR_ACTIVE_SCAN},
842 {4, eSIR_ACTIVE_SCAN},
843 {5, eSIR_ACTIVE_SCAN},
844 {6, eSIR_ACTIVE_SCAN},
845 {7, eSIR_ACTIVE_SCAN},
846 {8, eSIR_ACTIVE_SCAN},
847 {9, eSIR_ACTIVE_SCAN},
848 {10, eSIR_ACTIVE_SCAN},
849 {11, eSIR_ACTIVE_SCAN},
850 {12, eSIR_ACTIVE_SCAN},
851 {13, eSIR_ACTIVE_SCAN},
852 {14, eSIR_ACTIVE_SCAN},
853 }
854 },
855 //REG_DOMAIN_N_AMER_EXC_FCC
856 {
857 REG_DOMAIN_N_AMER_EXC_FCC,
858 45, //Num channels
859 //Channels
860 {
861 //5GHz
862 //5180 - 5240
863 {36, eSIR_ACTIVE_SCAN},
864 {40, eSIR_ACTIVE_SCAN},
865 {44, eSIR_ACTIVE_SCAN},
866 {48, eSIR_ACTIVE_SCAN},
867 //5250 to 5350
868 {52, eSIR_PASSIVE_SCAN},
869 {56, eSIR_PASSIVE_SCAN},
870 {60, eSIR_PASSIVE_SCAN},
871 {64, eSIR_PASSIVE_SCAN},
872 //5470 to 5725
873 {100, eSIR_ACTIVE_SCAN},
874 {104, eSIR_ACTIVE_SCAN},
875 {108, eSIR_ACTIVE_SCAN},
876 {112, eSIR_ACTIVE_SCAN},
877 {116, eSIR_ACTIVE_SCAN},
878 {120, eSIR_ACTIVE_SCAN},
879 {124, eSIR_ACTIVE_SCAN},
880 {128, eSIR_ACTIVE_SCAN},
881 {132, eSIR_ACTIVE_SCAN},
882 {136, eSIR_ACTIVE_SCAN},
883 {140, eSIR_ACTIVE_SCAN},
884 //5745 - 5825
885 {149, eSIR_ACTIVE_SCAN},
886 {153, eSIR_ACTIVE_SCAN},
887 {157, eSIR_ACTIVE_SCAN},
888 {161, eSIR_ACTIVE_SCAN},
889 {165, eSIR_ACTIVE_SCAN},
890 //4.9GHz
891 //4920 - 5080
892 {240, eSIR_ACTIVE_SCAN},
893 {244, eSIR_ACTIVE_SCAN},
894 {248, eSIR_ACTIVE_SCAN},
895 {252, eSIR_ACTIVE_SCAN},
896 {208, eSIR_ACTIVE_SCAN},
897 {212, eSIR_ACTIVE_SCAN},
898 {216, eSIR_ACTIVE_SCAN},
899 //2,4GHz
900 {1, eSIR_ACTIVE_SCAN},
901 {2, eSIR_ACTIVE_SCAN},
902 {3, eSIR_ACTIVE_SCAN},
903 {4, eSIR_ACTIVE_SCAN},
904 {5, eSIR_ACTIVE_SCAN},
905 {6, eSIR_ACTIVE_SCAN},
906 {7, eSIR_ACTIVE_SCAN},
907 {8, eSIR_ACTIVE_SCAN},
908 {9, eSIR_ACTIVE_SCAN},
909 {10, eSIR_ACTIVE_SCAN},
910 {11, eSIR_ACTIVE_SCAN},
911 {12, eSIR_ACTIVE_SCAN},
912 {13, eSIR_ACTIVE_SCAN},
913 {14, eSIR_ACTIVE_SCAN},
914 }
915 },
916 //REG_DOMAIN_APAC
917 {
918 REG_DOMAIN_APAC,
919 45, //Num channels
920 //Channels
921 {
922 //5GHz
923 //5180 - 5240
924 {36, eSIR_ACTIVE_SCAN},
925 {40, eSIR_ACTIVE_SCAN},
926 {44, eSIR_ACTIVE_SCAN},
927 {48, eSIR_ACTIVE_SCAN},
928 //5250 to 5350
929 {52, eSIR_PASSIVE_SCAN},
930 {56, eSIR_PASSIVE_SCAN},
931 {60, eSIR_PASSIVE_SCAN},
932 {64, eSIR_PASSIVE_SCAN},
933 //5470 to 5725
934 {100, eSIR_ACTIVE_SCAN},
935 {104, eSIR_ACTIVE_SCAN},
936 {108, eSIR_ACTIVE_SCAN},
937 {112, eSIR_ACTIVE_SCAN},
938 {116, eSIR_ACTIVE_SCAN},
939 {120, eSIR_ACTIVE_SCAN},
940 {124, eSIR_ACTIVE_SCAN},
941 {128, eSIR_ACTIVE_SCAN},
942 {132, eSIR_ACTIVE_SCAN},
943 {136, eSIR_ACTIVE_SCAN},
944 {140, eSIR_ACTIVE_SCAN},
945 //5745 - 5825
946 {149, eSIR_ACTIVE_SCAN},
947 {153, eSIR_ACTIVE_SCAN},
948 {157, eSIR_ACTIVE_SCAN},
949 {161, eSIR_ACTIVE_SCAN},
950 {165, eSIR_ACTIVE_SCAN},
951 //4.9GHz
952 //4920 - 5080
953 {240, eSIR_ACTIVE_SCAN},
954 {244, eSIR_ACTIVE_SCAN},
955 {248, eSIR_ACTIVE_SCAN},
956 {252, eSIR_ACTIVE_SCAN},
957 {208, eSIR_ACTIVE_SCAN},
958 {212, eSIR_ACTIVE_SCAN},
959 {216, eSIR_ACTIVE_SCAN},
960 //2,4GHz
961 {1, eSIR_ACTIVE_SCAN},
962 {2, eSIR_ACTIVE_SCAN},
963 {3, eSIR_ACTIVE_SCAN},
964 {4, eSIR_ACTIVE_SCAN},
965 {5, eSIR_ACTIVE_SCAN},
966 {6, eSIR_ACTIVE_SCAN},
967 {7, eSIR_ACTIVE_SCAN},
968 {8, eSIR_ACTIVE_SCAN},
969 {9, eSIR_ACTIVE_SCAN},
970 {10, eSIR_ACTIVE_SCAN},
971 {11, eSIR_ACTIVE_SCAN},
972 {12, eSIR_ACTIVE_SCAN},
973 {13, eSIR_ACTIVE_SCAN},
974 {14, eSIR_ACTIVE_SCAN},
975 }
976 },
977 //REG_DOMAIN_KOREA
978 {
979 REG_DOMAIN_KOREA,
980 45, //Num channels
981 //Channels
982 {
983 //5GHz
984 //5180 - 5240
985 {36, eSIR_ACTIVE_SCAN},
986 {40, eSIR_ACTIVE_SCAN},
987 {44, eSIR_ACTIVE_SCAN},
988 {48, eSIR_ACTIVE_SCAN},
989 //5250 to 5350
990 {52, eSIR_PASSIVE_SCAN},
991 {56, eSIR_PASSIVE_SCAN},
992 {60, eSIR_PASSIVE_SCAN},
993 {64, eSIR_PASSIVE_SCAN},
994 //5470 to 5725
995 {100, eSIR_PASSIVE_SCAN},
996 {104, eSIR_PASSIVE_SCAN},
997 {108, eSIR_PASSIVE_SCAN},
998 {112, eSIR_PASSIVE_SCAN},
999 {116, eSIR_PASSIVE_SCAN},
1000 {120, eSIR_PASSIVE_SCAN},
1001 {124, eSIR_PASSIVE_SCAN},
1002 {128, eSIR_PASSIVE_SCAN},
1003 {132, eSIR_PASSIVE_SCAN},
1004 {136, eSIR_PASSIVE_SCAN},
1005 {140, eSIR_PASSIVE_SCAN},
1006 //5745 - 5825
1007 {149, eSIR_ACTIVE_SCAN},
1008 {153, eSIR_ACTIVE_SCAN},
1009 {157, eSIR_ACTIVE_SCAN},
1010 {161, eSIR_ACTIVE_SCAN},
1011 {165, eSIR_ACTIVE_SCAN},
1012 //4.9GHz
1013 //4920 - 5080
1014 {240, eSIR_ACTIVE_SCAN},
1015 {244, eSIR_ACTIVE_SCAN},
1016 {248, eSIR_ACTIVE_SCAN},
1017 {252, eSIR_ACTIVE_SCAN},
1018 {208, eSIR_ACTIVE_SCAN},
1019 {212, eSIR_ACTIVE_SCAN},
1020 {216, eSIR_ACTIVE_SCAN},
1021 //2,4GHz
1022 {1, eSIR_ACTIVE_SCAN},
1023 {2, eSIR_ACTIVE_SCAN},
1024 {3, eSIR_ACTIVE_SCAN},
1025 {4, eSIR_ACTIVE_SCAN},
1026 {5, eSIR_ACTIVE_SCAN},
1027 {6, eSIR_ACTIVE_SCAN},
1028 {7, eSIR_ACTIVE_SCAN},
1029 {8, eSIR_ACTIVE_SCAN},
1030 {9, eSIR_ACTIVE_SCAN},
1031 {10, eSIR_ACTIVE_SCAN},
1032 {11, eSIR_ACTIVE_SCAN},
1033 {12, eSIR_ACTIVE_SCAN},
1034 {13, eSIR_ACTIVE_SCAN},
1035 {14, eSIR_ACTIVE_SCAN},
1036 }
1037 },
1038 //REG_DOMAIN_HI_5GHZ
1039 {
1040 REG_DOMAIN_HI_5GHZ,
1041 45, //Num channels
1042 //Channels
1043 {
1044 //5GHz
1045 //5180 - 5240
1046 {36, eSIR_ACTIVE_SCAN},
1047 {40, eSIR_ACTIVE_SCAN},
1048 {44, eSIR_ACTIVE_SCAN},
1049 {48, eSIR_ACTIVE_SCAN},
1050 //5250 to 5350
1051 {52, eSIR_ACTIVE_SCAN},
1052 {56, eSIR_ACTIVE_SCAN},
1053 {60, eSIR_ACTIVE_SCAN},
1054 {64, eSIR_ACTIVE_SCAN},
1055 //5470 to 5725
1056 {100, eSIR_ACTIVE_SCAN},
1057 {104, eSIR_ACTIVE_SCAN},
1058 {108, eSIR_ACTIVE_SCAN},
1059 {112, eSIR_ACTIVE_SCAN},
1060 {116, eSIR_ACTIVE_SCAN},
1061 {120, eSIR_ACTIVE_SCAN},
1062 {124, eSIR_ACTIVE_SCAN},
1063 {128, eSIR_ACTIVE_SCAN},
1064 {132, eSIR_ACTIVE_SCAN},
1065 {136, eSIR_ACTIVE_SCAN},
1066 {140, eSIR_ACTIVE_SCAN},
1067 //5745 - 5825
1068 {149, eSIR_ACTIVE_SCAN},
1069 {153, eSIR_ACTIVE_SCAN},
1070 {157, eSIR_ACTIVE_SCAN},
1071 {161, eSIR_ACTIVE_SCAN},
1072 {165, eSIR_ACTIVE_SCAN},
1073 //4.9GHz
1074 //4920 - 5080
1075 {240, eSIR_ACTIVE_SCAN},
1076 {244, eSIR_ACTIVE_SCAN},
1077 {248, eSIR_ACTIVE_SCAN},
1078 {252, eSIR_ACTIVE_SCAN},
1079 {208, eSIR_ACTIVE_SCAN},
1080 {212, eSIR_ACTIVE_SCAN},
1081 {216, eSIR_ACTIVE_SCAN},
1082 //2,4GHz
1083 {1, eSIR_ACTIVE_SCAN},
1084 {2, eSIR_ACTIVE_SCAN},
1085 {3, eSIR_ACTIVE_SCAN},
1086 {4, eSIR_ACTIVE_SCAN},
1087 {5, eSIR_ACTIVE_SCAN},
1088 {6, eSIR_ACTIVE_SCAN},
1089 {7, eSIR_ACTIVE_SCAN},
1090 {8, eSIR_ACTIVE_SCAN},
1091 {9, eSIR_ACTIVE_SCAN},
1092 {10, eSIR_ACTIVE_SCAN},
1093 {11, eSIR_ACTIVE_SCAN},
1094 {12, eSIR_ACTIVE_SCAN},
1095 {13, eSIR_ACTIVE_SCAN},
1096 {14, eSIR_ACTIVE_SCAN},
1097 }
1098 },
1099 //REG_DOMAIN_NO_5GHZ
1100 {
1101 REG_DOMAIN_NO_5GHZ,
1102 45, //Num channels
1103 //Channels
1104 {
1105 //5GHz
1106 //5180 - 5240
1107 {36, eSIR_ACTIVE_SCAN},
1108 {40, eSIR_ACTIVE_SCAN},
1109 {44, eSIR_ACTIVE_SCAN},
1110 {48, eSIR_ACTIVE_SCAN},
1111 //5250 to 5350
1112 {52, eSIR_ACTIVE_SCAN},
1113 {56, eSIR_ACTIVE_SCAN},
1114 {60, eSIR_ACTIVE_SCAN},
1115 {64, eSIR_ACTIVE_SCAN},
1116 //5470 to 5725
1117 {100, eSIR_ACTIVE_SCAN},
1118 {104, eSIR_ACTIVE_SCAN},
1119 {108, eSIR_ACTIVE_SCAN},
1120 {112, eSIR_ACTIVE_SCAN},
1121 {116, eSIR_ACTIVE_SCAN},
1122 {120, eSIR_ACTIVE_SCAN},
1123 {124, eSIR_ACTIVE_SCAN},
1124 {128, eSIR_ACTIVE_SCAN},
1125 {132, eSIR_ACTIVE_SCAN},
1126 {136, eSIR_ACTIVE_SCAN},
1127 {140, eSIR_ACTIVE_SCAN},
1128 //5745 - 5825
1129 {149, eSIR_ACTIVE_SCAN},
1130 {153, eSIR_ACTIVE_SCAN},
1131 {157, eSIR_ACTIVE_SCAN},
1132 {161, eSIR_ACTIVE_SCAN},
1133 {165, eSIR_ACTIVE_SCAN},
1134 //4.9GHz
1135 //4920 - 5080
1136 {240, eSIR_ACTIVE_SCAN},
1137 {244, eSIR_ACTIVE_SCAN},
1138 {248, eSIR_ACTIVE_SCAN},
1139 {252, eSIR_ACTIVE_SCAN},
1140 {208, eSIR_ACTIVE_SCAN},
1141 {212, eSIR_ACTIVE_SCAN},
1142 {216, eSIR_ACTIVE_SCAN},
1143 //2,4GHz
1144 {1, eSIR_ACTIVE_SCAN},
1145 {2, eSIR_ACTIVE_SCAN},
1146 {3, eSIR_ACTIVE_SCAN},
1147 {4, eSIR_ACTIVE_SCAN},
1148 {5, eSIR_ACTIVE_SCAN},
1149 {6, eSIR_ACTIVE_SCAN},
1150 {7, eSIR_ACTIVE_SCAN},
1151 {8, eSIR_ACTIVE_SCAN},
1152 {9, eSIR_ACTIVE_SCAN},
1153 {10, eSIR_ACTIVE_SCAN},
1154 {11, eSIR_ACTIVE_SCAN},
1155 {12, eSIR_ACTIVE_SCAN},
1156 {13, eSIR_ACTIVE_SCAN},
1157 {14, eSIR_ACTIVE_SCAN},
1158 }
1159 },
1160};
1161#endif
1162
1163extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
1164
Jeff Johnson295189b2012-06-20 16:38:30 -07001165////////////////////////////////////////////////////////////////////////
1166
1167/**
1168 * \var gPhyRatesSuppt
1169 *
1170 * \brief Rate support lookup table
1171 *
1172 *
1173 * This is a lookup table indexing rates & configuration parameters to
1174 * support. Given a rate (in unites of 0.5Mpbs) & three booleans (MIMO
1175 * Enabled, Channel Bonding Enabled, & Concatenation Enabled), one can
1176 * determine whether the given rate is supported by computing two
1177 * indices. The first maps the rate to table row as indicated below
1178 * (i.e. eHddSuppRate_6Mbps maps to row zero, eHddSuppRate_9Mbps to row
1179 * 1, and so on). Index two can be computed like so:
1180 *
1181 * \code
1182 idx2 = ( fEsf ? 0x4 : 0x0 ) |
1183 ( fCb ? 0x2 : 0x0 ) |
1184 ( fMimo ? 0x1 : 0x0 );
1185 * \endcode
1186 *
1187 *
1188 * Given that:
1189 *
1190 \code
1191 fSupported = gPhyRatesSuppt[idx1][idx2];
1192 \endcode
1193 *
1194 *
1195 * This table is based on the document "PHY Supported Rates.doc". This
1196 * table is permissive in that a rate is reflected as being supported
1197 * even when turning off an enabled feature would be required. For
1198 * instance, "PHY Supported Rates" lists 42Mpbs as unsupported when CB,
1199 * ESF, & MIMO are all on. However, if we turn off either of CB or
1200 * MIMO, it then becomes supported. Therefore, we mark it as supported
1201 * even in index 7 of this table.
1202 *
1203 *
1204 */
1205
1206static const tANI_BOOLEAN gPhyRatesSuppt[24][8] = {
1207
1208 // SSF SSF SSF SSF ESF ESF ESF ESF
1209 // SIMO MIMO SIMO MIMO SIMO MIMO SIMO MIMO
1210 // No CB No CB CB CB No CB No CB CB CB
1211 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 6Mbps
1212 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 9Mbps
1213 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 12Mbps
1214 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 18Mbps
1215 { FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE }, // 20Mbps
1216 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 24Mbps
1217 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 36Mbps
1218 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 40Mbps
1219 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 42Mbps
1220 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 48Mbps
1221 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 54Mbps
1222 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 72Mbps
1223 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 80Mbps
1224 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 84Mbps
1225 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 96Mbps
1226 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 108Mbps
1227 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 120Mbps
1228 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 126Mbps
1229 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 144Mbps
1230 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 160Mbps
1231 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 168Mbps
1232 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 192Mbps
1233 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 216Mbps
1234 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 240Mbps
1235
1236};
1237
1238#define CASE_RETURN_STR(n) case (n): return (#n)
1239
1240const char *
1241get_eRoamCmdStatus_str(eRoamCmdStatus val)
1242{
1243 switch (val)
1244 {
1245 CASE_RETURN_STR(eCSR_ROAM_CANCELLED);
1246 CASE_RETURN_STR(eCSR_ROAM_ROAMING_START);
1247 CASE_RETURN_STR(eCSR_ROAM_ROAMING_COMPLETION);
1248 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_START);
1249 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_COMPLETION);
1250 CASE_RETURN_STR(eCSR_ROAM_DISASSOCIATED);
1251 CASE_RETURN_STR(eCSR_ROAM_SHOULD_ROAM);
1252 CASE_RETURN_STR(eCSR_ROAM_SCAN_FOUND_NEW_BSS);
1253 CASE_RETURN_STR(eCSR_ROAM_LOSTLINK);
1254 default:
1255 return "unknown";
1256 }
1257}
1258
1259const char *
1260get_eCsrRoamResult_str(eCsrRoamResult val)
1261{
1262 switch (val)
1263 {
1264 CASE_RETURN_STR(eCSR_ROAM_RESULT_NONE);
1265 CASE_RETURN_STR(eCSR_ROAM_RESULT_FAILURE);
1266 CASE_RETURN_STR(eCSR_ROAM_RESULT_ASSOCIATED);
1267 CASE_RETURN_STR(eCSR_ROAM_RESULT_NOT_ASSOCIATED);
1268 CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_FAILURE);
1269 CASE_RETURN_STR(eCSR_ROAM_RESULT_FORCED);
1270 CASE_RETURN_STR(eCSR_ROAM_RESULT_DISASSOC_IND);
1271 CASE_RETURN_STR(eCSR_ROAM_RESULT_DEAUTH_IND);
1272 CASE_RETURN_STR(eCSR_ROAM_RESULT_CAP_CHANGED);
1273 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_CONNECT);
1274 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_INACTIVE);
1275 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_NEW_PEER);
1276 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_COALESCED);
1277 default:
1278 return "unknown";
1279 }
1280}
1281
1282
1283
1284tANI_BOOLEAN csrGetBssIdBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tCsrBssid *pBssId )
1285{
Kiet Lam64c1b492013-07-12 13:56:44 +05301286 vos_mem_copy(pBssId, &pSirBssDesc->bssId[ 0 ], sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001287 return( TRUE );
1288}
1289
1290
1291tANI_BOOLEAN csrIsBssIdEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 )
1292{
1293 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1294 tANI_BOOLEAN fEqual = FALSE;
1295 tCsrBssid bssId1;
1296 tCsrBssid bssId2;
1297
1298 do {
1299 if ( !pSirBssDesc1 ) break;
1300 if ( !pSirBssDesc2 ) break;
1301
1302 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc1, &bssId1 ) ) break;
1303 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc2, &bssId2 ) ) break;
1304
1305 //sirCompareMacAddr
1306 fEqual = csrIsMacAddressEqual(pMac, &bssId1, &bssId2);
1307
1308 } while( 0 );
1309
1310 return( fEqual );
1311}
1312
1313tANI_BOOLEAN csrIsConnStateConnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1314{
1315 return( eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1316}
1317
1318tANI_BOOLEAN csrIsConnStateDisconnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1319{
1320 return( eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1321}
1322
1323tANI_BOOLEAN csrIsConnStateConnectedInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1324{
1325 return( eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == pMac->roam.roamSession[sessionId].connectState );
1326}
1327
1328tANI_BOOLEAN csrIsConnStateConnected( tpAniSirGlobal pMac, tANI_U32 sessionId )
1329{
1330 if( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateConnectedInfra( pMac, sessionId ) || csrIsConnStateConnectedWds( pMac, sessionId) )
1331 return TRUE;
1332 else
1333 return FALSE;
1334}
1335
1336tANI_BOOLEAN csrIsConnStateInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1337{
1338 return( csrIsConnStateConnectedInfra( pMac, sessionId ) );
1339}
1340
1341tANI_BOOLEAN csrIsConnStateIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1342{
1343 return( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateDisconnectedIbss( pMac, sessionId ) );
1344}
1345
1346
1347tANI_BOOLEAN csrIsConnStateConnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1348{
1349 return( eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1350}
1351
Jeff Johnson295189b2012-06-20 16:38:30 -07001352tANI_BOOLEAN csrIsConnStateConnectedInfraAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1353{
1354 return( (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == pMac->roam.roamSession[sessionId].connectState) ||
1355 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState ) );
1356}
Jeff Johnson295189b2012-06-20 16:38:30 -07001357
1358tANI_BOOLEAN csrIsConnStateDisconnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1359{
1360 return( eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1361}
1362
1363tANI_BOOLEAN csrIsConnStateWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1364{
1365 return( csrIsConnStateConnectedWds( pMac, sessionId ) ||
1366 csrIsConnStateDisconnectedWds( pMac, sessionId ) );
1367}
1368
Jeff Johnsone7245742012-09-05 17:12:55 -07001369tANI_BOOLEAN csrIsConnStateAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1370{
1371 tCsrRoamSession *pSession;
1372 pSession = CSR_GET_SESSION(pMac, sessionId);
1373 if (!pSession)
1374 return eANI_BOOLEAN_FALSE;
1375 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
1376 {
1377 return eANI_BOOLEAN_TRUE;
1378 }
1379 return eANI_BOOLEAN_FALSE;
1380}
1381
Jeff Johnson295189b2012-06-20 16:38:30 -07001382tANI_BOOLEAN csrIsAnySessionInConnectState( tpAniSirGlobal pMac )
1383{
1384 tANI_U32 i;
1385 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1386
1387 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1388 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001389 if( CSR_IS_SESSION_VALID( pMac, i ) &&
1390 ( csrIsConnStateInfra( pMac, i )
1391 || csrIsConnStateIbss( pMac, i )
1392 || csrIsConnStateAp( pMac, i) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 {
1394 fRc = eANI_BOOLEAN_TRUE;
1395 break;
1396 }
1397 }
1398
1399 return ( fRc );
1400}
1401
1402tANI_S8 csrGetInfraSessionId( tpAniSirGlobal pMac )
1403{
1404 tANI_U8 i;
1405 tANI_S8 sessionid = -1;
1406
1407 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1408 {
1409 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateInfra( pMac, i ) )
1410 {
1411 sessionid = i;
1412 break;
1413 }
1414 }
1415
1416 return ( sessionid );
1417}
1418
1419tANI_U8 csrGetInfraOperationChannel( tpAniSirGlobal pMac, tANI_U8 sessionId)
1420{
1421 tANI_U8 channel;
1422
1423 if( CSR_IS_SESSION_VALID( pMac, sessionId ))
1424 {
1425 channel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
1426 }
1427 else
1428 {
1429 channel = 0;
1430 }
1431 return channel;
1432}
1433
Sushant Kaushik1d732562014-05-21 14:15:37 +05301434tANI_BOOLEAN csrIsSessionClientAndConnected(tpAniSirGlobal pMac, tANI_U8 sessionId)
1435{
1436 tCsrRoamSession *pSession = NULL;
1437 if ( CSR_IS_SESSION_VALID( pMac, sessionId) && csrIsConnStateInfra( pMac, sessionId))
1438 {
1439 pSession = CSR_GET_SESSION( pMac, sessionId);
Kaushik, Sushant79901762014-08-23 17:51:02 +05301440 if (NULL != pSession->pCurRoamProfile)
Sushant Kaushik1d732562014-05-21 14:15:37 +05301441 {
Kaushik, Sushant79901762014-08-23 17:51:02 +05301442 if ((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1443 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE))
1444 {
1445 return TRUE;
1446 }
Sushant Kaushik1d732562014-05-21 14:15:37 +05301447 }
1448 }
1449 return FALSE;
1450}
Jeff Johnson295189b2012-06-20 16:38:30 -07001451//This routine will return operating channel on FIRST BSS that is active/operating to be used for concurrency mode.
1452//If other BSS is not up or not connected it will return 0
1453
1454tANI_U8 csrGetConcurrentOperationChannel( tpAniSirGlobal pMac )
1455{
1456 tCsrRoamSession *pSession = NULL;
1457 tANI_U8 i = 0;
1458
1459 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1460 {
1461 if( CSR_IS_SESSION_VALID( pMac, i ) )
1462 {
1463 pSession = CSR_GET_SESSION( pMac, i );
1464
1465 if (NULL != pSession->pCurRoamProfile)
1466 {
1467 if (
1468 (((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1469 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE)) &&
1470 (pSession->connectState == eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED))
1471 ||
1472 (((pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) ||
1473 (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE)) &&
1474 (pSession->connectState != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
1475 )
1476 return (pSession->connectedProfile.operationChannel);
1477 }
1478
1479 }
1480 }
1481 return 0;
1482}
1483
1484tANI_BOOLEAN csrIsAllSessionDisconnected( tpAniSirGlobal pMac )
1485{
1486 tANI_U32 i;
1487 tANI_BOOLEAN fRc = eANI_BOOLEAN_TRUE;
1488
1489 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1490 {
1491 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1492 {
1493 fRc = eANI_BOOLEAN_FALSE;
1494 break;
1495 }
1496 }
1497
1498 return ( fRc );
1499}
1500
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001501tANI_BOOLEAN csrIsStaSessionConnected( tpAniSirGlobal pMac )
1502{
1503 tANI_U32 i;
1504 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1505 tCsrRoamSession *pSession = NULL;
1506 tANI_U32 countSta = 0;
1507
1508 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1509 {
1510 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1511 {
1512 pSession = CSR_GET_SESSION( pMac, i );
1513
1514 if (NULL != pSession->pCurRoamProfile)
1515 {
1516 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) {
1517 countSta++;
1518 }
1519 }
1520 }
1521 }
1522
1523 /* return TRUE if one of the following conditions is TRUE:
1524 * - more than one STA session connected
1525 */
1526 if ( countSta > 0) {
1527 fRc = eANI_BOOLEAN_TRUE;
1528 }
1529
1530 return( fRc );
1531}
1532
1533tANI_BOOLEAN csrIsP2pSessionConnected( tpAniSirGlobal pMac )
1534{
1535 tANI_U32 i;
1536 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1537 tCsrRoamSession *pSession = NULL;
1538 tANI_U32 countP2pCli = 0;
1539 tANI_U32 countP2pGo = 0;
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001540 tANI_U32 countSAP = 0;
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001541
1542 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1543 {
1544 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1545 {
1546 pSession = CSR_GET_SESSION( pMac, i );
1547
1548 if (NULL != pSession->pCurRoamProfile)
1549 {
1550 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE) {
1551 countP2pCli++;
1552 }
1553
1554 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1555 countP2pGo++;
1556 }
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001557
1558 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE) {
1559 countSAP++;
1560 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001561 }
1562 }
1563 }
1564
1565 /* return TRUE if one of the following conditions is TRUE:
1566 * - at least one P2P CLI session is connected
1567 * - at least one P2P GO session is connected
1568 */
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001569 if ( (countP2pCli > 0) || (countP2pGo > 0 ) || (countSAP > 0 ) ) {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001570 fRc = eANI_BOOLEAN_TRUE;
1571 }
1572
1573 return( fRc );
1574}
1575
Madan Mohan Koyyalamudid3d22592012-09-24 14:01:29 -07001576tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac )
1577{
1578 tANI_U32 i, count;
1579 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1580
1581 count = 0;
1582 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1583 {
1584 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1585 {
1586 count++;
1587 }
1588 }
1589
1590 if (count > 0)
1591 {
1592 fRc = eANI_BOOLEAN_TRUE;
1593 }
1594 return( fRc );
1595}
Jeff Johnson295189b2012-06-20 16:38:30 -07001596
1597tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac )
1598{
1599 tANI_U32 i;
1600 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1601
1602 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1603 {
1604 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1605 {
1606 fRc = eANI_BOOLEAN_TRUE;
1607 break;
1608 }
1609 }
1610
1611 return ( fRc );
1612}
1613
1614tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac )
1615{
1616 tANI_U32 i, noOfConnectedInfra = 0;
1617
1618 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1619
1620 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1621 {
1622 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1623 {
1624 ++noOfConnectedInfra;
1625 }
1626 }
1627
1628 // More than one Infra Sta Connected
1629 if(noOfConnectedInfra > 1)
1630 {
1631 fRc = eANI_BOOLEAN_TRUE;
1632 }
1633
1634 return ( fRc );
1635}
1636
1637tANI_BOOLEAN csrIsIBSSStarted( tpAniSirGlobal pMac )
1638{
1639 tANI_U32 i;
1640 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1641
1642 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1643 {
1644 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateIbss( pMac, i ) )
1645 {
1646 fRc = eANI_BOOLEAN_TRUE;
1647 break;
1648 }
1649 }
1650
1651 return ( fRc );
1652}
1653
1654
1655tANI_BOOLEAN csrIsBTAMPStarted( tpAniSirGlobal pMac )
1656{
1657 tANI_U32 i;
1658 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1659
1660 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1661 {
1662 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedWds( pMac, i ) )
1663 {
1664 fRc = eANI_BOOLEAN_TRUE;
1665 break;
1666 }
1667 }
1668
1669 return ( fRc );
1670}
1671
Jeff Johnsone7245742012-09-05 17:12:55 -07001672tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac )
1673{
1674 tANI_U32 sessionId, noOfCocurrentSession = 0;
1675 eCsrConnectState connectState;
1676
1677 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1678
1679 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1680 {
1681 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1682 {
1683 connectState = pMac->roam.roamSession[sessionId].connectState;
1684 if( (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == connectState) ||
1685 (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == connectState) ||
1686 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == connectState) )
1687 {
1688 ++noOfCocurrentSession;
1689 }
1690 }
1691 }
1692
1693 // More than one session is Up and Running
1694 if(noOfCocurrentSession > 1)
1695 {
1696 fRc = eANI_BOOLEAN_TRUE;
1697 }
1698
1699 return ( fRc );
1700}
1701
Jeff Johnsone7245742012-09-05 17:12:55 -07001702tANI_BOOLEAN csrIsInfraApStarted( tpAniSirGlobal pMac )
1703{
1704 tANI_U32 sessionId;
1705 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1706
1707 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1708 {
1709 if( CSR_IS_SESSION_VALID( pMac, sessionId ) && (csrIsConnStateConnectedInfraAp(pMac, sessionId)) )
1710 {
1711 fRc = eANI_BOOLEAN_TRUE;
1712 break;
1713 }
1714 }
1715
1716 return ( fRc );
1717
1718}
Jeff Johnsone7245742012-09-05 17:12:55 -07001719
Jeff Johnson295189b2012-06-20 16:38:30 -07001720tANI_BOOLEAN csrIsBTAMP( tpAniSirGlobal pMac, tANI_U32 sessionId )
1721{
1722 return ( csrIsConnStateConnectedWds( pMac, sessionId ) );
1723}
1724
1725
1726tANI_BOOLEAN csrIsConnStateDisconnected(tpAniSirGlobal pMac, tANI_U32 sessionId)
1727{
1728 return (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED == pMac->roam.roamSession[sessionId].connectState);
1729}
1730
Jeff Johnsone7245742012-09-05 17:12:55 -07001731tANI_BOOLEAN csrIsValidMcConcurrentSession(tpAniSirGlobal pMac, tANI_U32 sessionId,
1732 tSirBssDescription *pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001733{
1734 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07001735 eAniBoolean status = eANI_BOOLEAN_FALSE;
1736
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 //Check for MCC support
1738 if (!pMac->roam.configParam.fenableMCCMode)
1739 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001740 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 }
1742
Jeff Johnsone7245742012-09-05 17:12:55 -07001743 //Validate BeaconInterval
1744 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1745 {
1746 pSession = CSR_GET_SESSION( pMac, sessionId );
1747 if (NULL != pSession->pCurRoamProfile)
1748 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001749 if (csrIsconcurrentsessionValid (pMac, sessionId,
1750 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001751 == eHAL_STATUS_SUCCESS )
1752 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001753 if (csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId,
1754 &pBssDesc->beaconInterval, sessionId,
1755 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001756 != eHAL_STATUS_SUCCESS)
1757 {
1758 status = eANI_BOOLEAN_FALSE;
1759 }
1760 else
1761 {
1762 status = eANI_BOOLEAN_TRUE;
1763 }
1764 }
1765 else
1766 {
1767 status = eANI_BOOLEAN_FALSE;
1768 }
1769 }
1770 }
1771 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001772}
1773
1774static tSirMacCapabilityInfo csrGetBssCapabilities( tSirBssDescription *pSirBssDesc )
1775{
1776 tSirMacCapabilityInfo dot11Caps;
1777
1778 //tSirMacCapabilityInfo is 16-bit
1779 pal_get_U16( (tANI_U8 *)&pSirBssDesc->capabilityInfo, (tANI_U16 *)&dot11Caps );
1780
1781 return( dot11Caps );
1782}
1783
1784tANI_BOOLEAN csrIsInfraBssDesc( tSirBssDescription *pSirBssDesc )
1785{
1786 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1787
1788 return( (tANI_BOOLEAN)dot11Caps.ess );
1789}
1790
1791
1792tANI_BOOLEAN csrIsIbssBssDesc( tSirBssDescription *pSirBssDesc )
1793{
1794 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1795
1796 return( (tANI_BOOLEAN)dot11Caps.ibss );
1797}
1798
1799tANI_BOOLEAN csrIsQoSBssDesc( tSirBssDescription *pSirBssDesc )
1800{
1801 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1802
1803 return( (tANI_BOOLEAN)dot11Caps.qos );
1804}
1805
1806tANI_BOOLEAN csrIsPrivacy( tSirBssDescription *pSirBssDesc )
1807{
1808 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1809
1810 return( (tANI_BOOLEAN)dot11Caps.privacy );
1811}
1812
1813
1814tANI_BOOLEAN csrIs11dSupported(tpAniSirGlobal pMac)
1815{
1816 return(pMac->roam.configParam.Is11dSupportEnabled);
1817}
1818
1819
1820tANI_BOOLEAN csrIs11hSupported(tpAniSirGlobal pMac)
1821{
1822 return(pMac->roam.configParam.Is11hSupportEnabled);
1823}
1824
1825
1826tANI_BOOLEAN csrIs11eSupported(tpAniSirGlobal pMac)
1827{
1828 return(pMac->roam.configParam.Is11eSupportEnabled);
1829}
1830
1831tANI_BOOLEAN csrIsMCCSupported ( tpAniSirGlobal pMac )
1832{
1833 return(pMac->roam.configParam.fenableMCCMode);
1834
1835}
1836
1837tANI_BOOLEAN csrIsWmmSupported(tpAniSirGlobal pMac)
1838{
1839 if(eCsrRoamWmmNoQos == pMac->roam.configParam.WMMSupportMode)
1840 {
1841 return eANI_BOOLEAN_FALSE;
1842 }
1843 else
1844 {
1845 return eANI_BOOLEAN_TRUE;
1846 }
1847}
1848
1849
1850
1851
1852//pIes is the IEs for pSirBssDesc2
1853tANI_BOOLEAN csrIsSsidEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1,
1854 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2 )
1855{
1856 tANI_BOOLEAN fEqual = FALSE;
1857 tSirMacSSid Ssid1, Ssid2;
1858 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1859 tDot11fBeaconIEs *pIes1 = NULL;
1860 tDot11fBeaconIEs *pIesLocal = pIes2;
1861
1862 do {
1863 if( ( NULL == pSirBssDesc1 ) || ( NULL == pSirBssDesc2 ) ) break;
1864 if( !pIesLocal && !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesLocal)) )
1865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001866 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 break;
1868 }
1869 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
1870 {
1871 break;
1872 }
1873 if( ( !pIes1->SSID.present ) || ( !pIesLocal->SSID.present ) ) break;
1874 if ( pIes1->SSID.num_ssid != pIesLocal->SSID.num_ssid ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301875 vos_mem_copy(Ssid1.ssId, pIes1->SSID.ssid, pIes1->SSID.num_ssid);
1876 vos_mem_copy(Ssid2.ssId, pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001877
Kiet Lam64c1b492013-07-12 13:56:44 +05301878 fEqual = vos_mem_compare(Ssid1.ssId, Ssid2.ssId, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001879
1880 } while( 0 );
1881 if(pIes1)
1882 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301883 vos_mem_free(pIes1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 }
1885 if( pIesLocal && !pIes2 )
1886 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301887 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 }
1889
1890 return( fEqual );
1891}
1892
1893tANI_BOOLEAN csrIsAniWmeSupported(tDot11fIEAirgo *pIeAirgo)
1894{
1895 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
1896
1897 if(pIeAirgo && pIeAirgo->present && pIeAirgo->PropCapability.present)
1898 {
1899 fRet = (tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability ));
1900 }
1901
1902 return fRet;
1903}
1904
1905
1906
1907
1908//pIes can be passed in as NULL if the caller doesn't have one prepared
1909tANI_BOOLEAN csrIsBssDescriptionWme( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
1910{
1911 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1912 // Assume that WME is found...
1913 tANI_BOOLEAN fWme = TRUE;
1914 tDot11fBeaconIEs *pIesTemp = pIes;
1915
1916 do
1917 {
1918 if(pIesTemp == NULL)
1919 {
1920 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp)) )
1921 {
1922 fWme = FALSE;
1923 break;
1924 }
1925 }
1926 // if the AirgoProprietary indicator is found, then WME is supported...
1927 if ( csrIsAniWmeSupported(&pIesTemp->Airgo) ) break;
1928 // if the Wme Info IE is found, then WME is supported...
1929 if ( CSR_IS_QOS_BSS(pIesTemp) ) break;
1930 // if none of these are found, then WME is NOT supported...
1931 fWme = FALSE;
1932 } while( 0 );
1933 if( !csrIsWmmSupported( pMac ) && fWme)
1934 {
1935 if( !pIesTemp->HTCaps.present )
1936 {
1937 fWme = FALSE;
1938 }
1939 }
1940 if( ( pIes == NULL ) && ( NULL != pIesTemp ) )
1941 {
1942 //we allocate memory here so free it before returning
Kiet Lam64c1b492013-07-12 13:56:44 +05301943 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 }
1945
1946 return( fWme );
1947}
1948
1949tANI_BOOLEAN csrIsHcfEnabled( tDot11fIEAirgo *pIeAirgo )
1950{
1951 tANI_BOOLEAN fHcfSupported = FALSE;
1952
1953 fHcfSupported = ((tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability )) ||
1954 (pIeAirgo->present && pIeAirgo->HCF.present && pIeAirgo->HCF.enabled));
1955
1956 return( fHcfSupported );
1957}
1958
1959
1960eCsrMediaAccessType csrGetQoSFromBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc,
1961 tDot11fBeaconIEs *pIes )
1962{
1963 eCsrMediaAccessType qosType = eCSR_MEDIUM_ACCESS_DCF;
1964
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001966
1967 do
1968 {
1969 // if we find WMM in the Bss Description, then we let this
1970 // override and use WMM.
1971 if ( csrIsBssDescriptionWme( hHal, pSirBssDesc, pIes ) )
1972 {
1973 qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
1974 }
1975 else
1976 {
1977 // if the QoS bit is on, then the AP is advertising 11E QoS...
1978 if ( csrIsQoSBssDesc( pSirBssDesc ) )
1979 {
1980 // which could be HCF or eDCF.
1981 if ( csrIsHcfEnabled( &pIes->Airgo ) )
1982 {
1983 qosType = eCSR_MEDIUM_ACCESS_11e_HCF;
1984 }
1985 else
1986 {
1987 qosType = eCSR_MEDIUM_ACCESS_11e_eDCF;
1988 }
1989 }
1990 else
1991 {
1992 qosType = eCSR_MEDIUM_ACCESS_DCF;
1993 }
1994 // scale back based on the types turned on for the adapter...
1995 if ( eCSR_MEDIUM_ACCESS_11e_eDCF == qosType && !csrIs11eSupported( hHal ) )
1996 {
1997 qosType = eCSR_MEDIUM_ACCESS_DCF;
1998 }
1999 }
2000
2001 } while(0);
2002
2003 return( qosType );
2004}
2005
2006
2007
2008
2009//Caller allocates memory for pIEStruct
2010eHalStatus csrParseBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIEStruct)
2011{
2012 eHalStatus status = eHAL_STATUS_FAILURE;
2013 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2014 int ieLen = (int)(pBssDesc->length + sizeof( pBssDesc->length ) - GET_FIELD_OFFSET( tSirBssDescription, ieFields ));
2015
2016 if(ieLen > 0 && pIEStruct)
2017 {
2018 if(!DOT11F_FAILED(dot11fUnpackBeaconIEs( pMac, (tANI_U8 *)pBssDesc->ieFields, ieLen, pIEStruct )))
2019 {
2020 status = eHAL_STATUS_SUCCESS;
2021 }
2022 }
2023
2024 return (status);
2025}
2026
2027
2028//This function will allocate memory for the parsed IEs to the caller. Caller must free the memory
2029//after it is done with the data only if this function succeeds
2030eHalStatus csrGetParsedBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs **ppIEStruct)
2031{
2032 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2033 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2034
2035 if(pBssDesc && ppIEStruct)
2036 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302037 *ppIEStruct = vos_mem_malloc(sizeof(tDot11fBeaconIEs));
2038 if ( (*ppIEStruct) != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302040 vos_mem_set((void *)*ppIEStruct, sizeof(tDot11fBeaconIEs), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 status = csrParseBssDescriptionIEs(hHal, pBssDesc, *ppIEStruct);
2042 if(!HAL_STATUS_SUCCESS(status))
2043 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302044 vos_mem_free(*ppIEStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07002045 *ppIEStruct = NULL;
2046 }
2047 }
2048 else
2049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002050 smsLog( pMac, LOGE, FL(" failed to allocate memory") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 VOS_ASSERT( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +05302052 return eHAL_STATUS_FAILURE;
2053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 }
2055
2056 return (status);
2057}
2058
Siddharth Bhal64246172015-02-27 01:04:37 +05302059eHalStatus csrProcessGetFrameLogCommand( tpAniSirGlobal pMac,
2060 tSmeCmd *pCommand )
2061{
2062 tAniGetFrameLogReq *pMsg;
2063 tANI_U16 msgLen;
2064 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002065
Siddharth Bhal64246172015-02-27 01:04:37 +05302066 msgLen = sizeof(tAniGetFrameLogReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002067
Siddharth Bhal64246172015-02-27 01:04:37 +05302068 if ( NULL == pCommand )
2069 {
2070 smsLog( pMac, LOGE, FL("cannot process. cmd is null") );
2071 return eHAL_STATUS_FAILURE;
2072 }
2073
2074 pMsg = vos_mem_malloc(msgLen);
2075 if ( NULL == pMsg )
2076 {
2077 smsLog( pMac, LOGE, FL("fail to allocate memory") );
2078 return eHAL_STATUS_FAILURE;
2079 }
2080
2081 pMsg->msgType= pal_cpu_to_be16((tANI_U16)WDA_GET_FRAME_LOG_REQ);
2082 pMsg->msgLen= pal_cpu_to_be16(msgLen);
2083
2084 pMsg->pDevContext = pCommand->u.getFramelogCmd.pDevContext;
2085 pMsg->getFramelogCallback= pCommand->u.getFramelogCmd.getFramelogCallback;
2086 pMsg->getFrameLogCmdFlag = pCommand->u.getFramelogCmd.getFrameLogCmdFlag;
2087
2088 status = palSendMBMessage(pMac->hHdd, pMsg);
2089
2090 return( status );
2091}
Jeff Johnson295189b2012-06-20 16:38:30 -07002092
2093tANI_BOOLEAN csrIsNULLSSID( tANI_U8 *pBssSsid, tANI_U8 len )
2094{
2095 tANI_BOOLEAN fNullSsid = FALSE;
2096
2097 tANI_U32 SsidLength;
2098 tANI_U8 *pSsidStr;
2099
2100 do
2101 {
2102 if ( 0 == len )
2103 {
2104 fNullSsid = TRUE;
2105 break;
2106 }
2107
2108 //Consider 0 or space for hidden SSID
2109 if ( 0 == pBssSsid[0] )
2110 {
2111 fNullSsid = TRUE;
2112 break;
2113 }
2114
2115 SsidLength = len;
2116 pSsidStr = pBssSsid;
2117
2118 while ( SsidLength )
2119 {
2120 if( *pSsidStr )
2121 break;
2122
2123 pSsidStr++;
2124 SsidLength--;
2125 }
2126
2127 if( 0 == SsidLength )
2128 {
2129 fNullSsid = TRUE;
2130 break;
2131 }
2132 }
2133 while( 0 );
2134
2135 return fNullSsid;
2136}
2137
2138
2139tANI_U32 csrGetFragThresh( tHalHandle hHal )
2140{
2141 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2142
2143 return pMac->roam.configParam.FragmentationThreshold;
2144}
2145
2146tANI_U32 csrGetRTSThresh( tHalHandle hHal )
2147{
2148 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2149
2150 return pMac->roam.configParam.RTSThreshold;
2151}
2152
2153eCsrPhyMode csrTranslateToPhyModeFromBssDesc( tSirBssDescription *pSirBssDesc )
2154{
2155 eCsrPhyMode phyMode;
2156
2157 switch ( pSirBssDesc->nwType )
2158 {
2159 case eSIR_11A_NW_TYPE:
2160 phyMode = eCSR_DOT11_MODE_11a;
2161 break;
2162
2163 case eSIR_11B_NW_TYPE:
2164 phyMode = eCSR_DOT11_MODE_11b;
2165 break;
2166
2167 case eSIR_11G_NW_TYPE:
2168 phyMode = eCSR_DOT11_MODE_11g;
2169 break;
2170
2171 case eSIR_11N_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 phyMode = eCSR_DOT11_MODE_11n;
2173 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002174#ifdef WLAN_FEATURE_11AC
2175 case eSIR_11AC_NW_TYPE:
2176 default:
2177 phyMode = eCSR_DOT11_MODE_11ac;
2178#else
2179 default:
2180 phyMode = eCSR_DOT11_MODE_11n;
2181#endif
2182 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 return( phyMode );
2185}
2186
2187
2188tANI_U32 csrTranslateToWNICfgDot11Mode(tpAniSirGlobal pMac, eCsrCfgDot11Mode csrDot11Mode)
2189{
2190 tANI_U32 ret;
2191
2192 switch(csrDot11Mode)
2193 {
2194 case eCSR_CFG_DOT11_MODE_AUTO:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002195 smsLog(pMac, LOGW, FL(" Warning: sees eCSR_CFG_DOT11_MODE_AUTO "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 //We cannot decide until now.
2197 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2198 {
2199 ret = WNI_CFG_DOT11_MODE_TAURUS;
2200 }
2201 else
2202 {
Mukul Sharma45063942015-04-01 20:07:59 +05302203#ifdef WLAN_FEATURE_11AC
2204 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2205 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2206 ret = WNI_CFG_DOT11_MODE_11AC;
2207 else
2208 ret = WNI_CFG_DOT11_MODE_11N;
2209#else
2210 ret = WNI_CFG_DOT11_MODE_11N;
2211#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 }
2213 break;
2214 case eCSR_CFG_DOT11_MODE_TAURUS:
2215 ret = WNI_CFG_DOT11_MODE_TAURUS;
2216 break;
2217 case eCSR_CFG_DOT11_MODE_11A:
2218 ret = WNI_CFG_DOT11_MODE_11A;
2219 break;
2220 case eCSR_CFG_DOT11_MODE_11B:
2221 ret = WNI_CFG_DOT11_MODE_11B;
2222 break;
2223 case eCSR_CFG_DOT11_MODE_11G:
2224 ret = WNI_CFG_DOT11_MODE_11G;
2225 break;
2226 case eCSR_CFG_DOT11_MODE_11N:
2227 ret = WNI_CFG_DOT11_MODE_11N;
2228 break;
2229 case eCSR_CFG_DOT11_MODE_POLARIS:
2230 ret = WNI_CFG_DOT11_MODE_POLARIS;
2231 break;
2232 case eCSR_CFG_DOT11_MODE_TITAN:
2233 ret = WNI_CFG_DOT11_MODE_TITAN;
2234 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 case eCSR_CFG_DOT11_MODE_11G_ONLY:
Mukul Sharma45063942015-04-01 20:07:59 +05302236 ret = WNI_CFG_DOT11_MODE_11G_ONLY;
2237 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 case eCSR_CFG_DOT11_MODE_11N_ONLY:
Mukul Sharma45063942015-04-01 20:07:59 +05302239 ret = WNI_CFG_DOT11_MODE_11N_ONLY;
2240 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002241
2242#ifdef WLAN_FEATURE_11AC
Mukul Sharma45063942015-04-01 20:07:59 +05302243 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
2244 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2245 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2246 ret = WNI_CFG_DOT11_MODE_11AC_ONLY;
2247 else
2248 ret = WNI_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002249 break;
Mukul Sharma45063942015-04-01 20:07:59 +05302250 case eCSR_CFG_DOT11_MODE_11AC:
2251 if ( IS_FEATURE_SUPPORTED_BY_DRIVER(DOT11AC) &&
2252 IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2253 ret = WNI_CFG_DOT11_MODE_11AC;
2254 else
2255 ret = WNI_CFG_DOT11_MODE_11N;
2256 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002257#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002259 smsLog(pMac, LOGW, FL("doesn't expect %d as csrDo11Mode"), csrDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 if(eCSR_BAND_24 == pMac->roam.configParam.eBand)
2261 {
2262 ret = WNI_CFG_DOT11_MODE_11G;
2263 }
2264 else
2265 {
2266 ret = WNI_CFG_DOT11_MODE_11A;
2267 }
2268 break;
2269 }
2270
2271 return (ret);
2272}
2273
2274
2275//This function should only return the super set of supported modes. 11n implies 11b/g/a/n.
2276eHalStatus csrGetPhyModeFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription,
2277 eCsrPhyMode *pPhyMode, tDot11fBeaconIEs *pIes)
2278{
2279 eHalStatus status = eHAL_STATUS_SUCCESS;
2280 eCsrPhyMode phyMode = csrTranslateToPhyModeFromBssDesc(pBSSDescription);
2281
2282 if( pIes )
2283 {
2284 if(pIes->Airgo.present)
2285 {
2286 if(pIes->Airgo.PropCapability.present)
2287 {
2288 if( PROP_CAPABILITY_GET( TAURUS, pIes->Airgo.PropCapability.capability ))
2289 {
2290 phyMode = eCSR_DOT11_MODE_TAURUS;
2291 }
2292 }
2293 }
2294 if(pIes->HTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2295 {
2296 phyMode = eCSR_DOT11_MODE_11n;
2297 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002298
2299#ifdef WLAN_FEATURE_11AC
2300 if ( pIes->VHTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2301 {
2302 phyMode = eCSR_DOT11_MODE_11ac;
2303 }
2304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 *pPhyMode = phyMode;
2306 }
2307
2308 return (status);
2309
2310}
2311
2312
2313//This function returns the correct eCSR_CFG_DOT11_MODE is the two phyModes matches
2314//bssPhyMode is the mode derived from the BSS description
2315//f5GhzBand is derived from the channel id of BSS description
2316tANI_BOOLEAN csrGetPhyModeInUse( eCsrPhyMode phyModeIn, eCsrPhyMode bssPhyMode, tANI_BOOLEAN f5GhzBand,
2317 eCsrCfgDot11Mode *pCfgDot11ModeToUse )
2318{
2319 tANI_BOOLEAN fMatch = FALSE;
2320 eCsrCfgDot11Mode cfgDot11Mode;
2321
2322 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; // to suppress compiler warning
2323
2324 switch( phyModeIn )
2325 {
2326 case eCSR_DOT11_MODE_abg: //11a or 11b or 11g
2327 if( f5GhzBand )
2328 {
2329 fMatch = TRUE;
2330 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2331 }
2332 else if( eCSR_DOT11_MODE_11b == bssPhyMode )
2333 {
2334 fMatch = TRUE;
2335 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2336 }
2337 else
2338 {
2339 fMatch = TRUE;
2340 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2341 }
2342 break;
2343
2344 case eCSR_DOT11_MODE_11a: //11a
2345 if( f5GhzBand )
2346 {
2347 fMatch = TRUE;
2348 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2349 }
2350 break;
2351
2352 case eCSR_DOT11_MODE_11a_ONLY: //11a
2353 if( eCSR_DOT11_MODE_11a == bssPhyMode )
2354 {
2355 fMatch = TRUE;
2356 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2357 }
2358 break;
2359
2360 case eCSR_DOT11_MODE_11g:
2361 if(!f5GhzBand)
2362 {
2363 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2364 {
2365 fMatch = TRUE;
2366 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2367 }
2368 else
2369 {
2370 fMatch = TRUE;
2371 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2372 }
2373 }
2374 break;
2375
2376 case eCSR_DOT11_MODE_11g_ONLY:
2377 if( eCSR_DOT11_MODE_11g == bssPhyMode )
2378 {
2379 fMatch = TRUE;
2380 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2381 }
2382 break;
2383
2384 case eCSR_DOT11_MODE_11b:
2385 if( !f5GhzBand )
2386 {
2387 fMatch = TRUE;
2388 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2389 }
2390 break;
2391
2392 case eCSR_DOT11_MODE_11b_ONLY:
2393 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2394 {
2395 fMatch = TRUE;
2396 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2397 }
2398 break;
2399
2400 case eCSR_DOT11_MODE_11n:
2401 fMatch = TRUE;
2402 switch(bssPhyMode)
2403 {
2404 case eCSR_DOT11_MODE_11g:
2405 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2406 break;
2407 case eCSR_DOT11_MODE_11b:
2408 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2409 break;
2410 case eCSR_DOT11_MODE_11a:
2411 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2412 break;
2413 case eCSR_DOT11_MODE_11n:
Jeff Johnsone7245742012-09-05 17:12:55 -07002414#ifdef WLAN_FEATURE_11AC
2415 case eCSR_DOT11_MODE_11ac:
2416#endif
2417 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2418 break;
2419
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 case eCSR_DOT11_MODE_TAURUS:
2421 default:
Jeff Johnsone7245742012-09-05 17:12:55 -07002422#ifdef WLAN_FEATURE_11AC
2423 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2424#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002426#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 break;
2428 }
2429 break;
2430
2431 case eCSR_DOT11_MODE_11n_ONLY:
2432 if((eCSR_DOT11_MODE_11n == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2433 {
2434 fMatch = TRUE;
2435 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002436
2437 }
2438
2439 break;
2440#ifdef WLAN_FEATURE_11AC
2441 case eCSR_DOT11_MODE_11ac:
2442 fMatch = TRUE;
2443 switch(bssPhyMode)
2444 {
2445 case eCSR_DOT11_MODE_11g:
2446 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2447 break;
2448 case eCSR_DOT11_MODE_11b:
2449 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2450 break;
2451 case eCSR_DOT11_MODE_11a:
2452 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2453 break;
2454 case eCSR_DOT11_MODE_11n:
2455 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2456 break;
2457 case eCSR_DOT11_MODE_11ac:
2458 case eCSR_DOT11_MODE_TAURUS:
2459 default:
2460 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2461 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002462 }
2463 break;
2464
Jeff Johnsone7245742012-09-05 17:12:55 -07002465 case eCSR_DOT11_MODE_11ac_ONLY:
2466 if((eCSR_DOT11_MODE_11ac == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2467 {
2468 fMatch = TRUE;
2469 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2470 }
2471 break;
2472#endif
2473
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 case eCSR_DOT11_MODE_TAURUS:
2475 default:
2476 fMatch = TRUE;
2477 switch(bssPhyMode)
2478 {
2479 case eCSR_DOT11_MODE_11g:
2480 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2481 break;
2482 case eCSR_DOT11_MODE_11b:
2483 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2484 break;
2485 case eCSR_DOT11_MODE_11a:
2486 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2487 break;
2488 case eCSR_DOT11_MODE_11n:
2489 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2490 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002491#ifdef WLAN_FEATURE_11AC
2492 case eCSR_DOT11_MODE_11ac:
2493 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2494 break;
2495#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 case eCSR_DOT11_MODE_TAURUS:
2497 default:
2498 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
2499 break;
2500 }
2501 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 }
2503
2504 if ( fMatch && pCfgDot11ModeToUse )
2505 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002506#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudief5dd972012-10-11 15:06:09 -07002507 if(cfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC && (!IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)))
Jeff Johnsone7245742012-09-05 17:12:55 -07002508 {
2509 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2510 }
2511 else
2512#endif
2513 {
2514 *pCfgDot11ModeToUse = cfgDot11Mode;
2515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 return( fMatch );
2518}
2519
2520
2521//This function decides whether the one of the bit of phyMode is matching the mode in the BSS and allowed by the user
2522//setting, pMac->roam.configParam.uCfgDot11Mode. It returns the mode that fits the criteria.
2523tANI_BOOLEAN csrIsPhyModeMatch( tpAniSirGlobal pMac, tANI_U32 phyMode,
2524 tSirBssDescription *pSirBssDesc, tCsrRoamProfile *pProfile,
2525 eCsrCfgDot11Mode *pReturnCfgDot11Mode,
2526 tDot11fBeaconIEs *pIes)
2527{
2528 tANI_BOOLEAN fMatch = FALSE;
2529 eCsrPhyMode phyModeInBssDesc, phyMode2;
2530 eCsrCfgDot11Mode cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_TAURUS;
2531 tANI_U32 bitMask, loopCount;
2532
2533 if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pSirBssDesc, &phyModeInBssDesc, pIes )))
2534 {
2535 //In case some change change eCSR_DOT11_MODE_TAURUS to non-0
2536 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2537 {
2538 //Taurus means anything
2539 if ( eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode )
2540 {
2541 phyMode = eCSR_DOT11_MODE_abg;
2542 }
2543 else if(eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode)
2544 {
2545 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2546 {
2547 phyMode = eCSR_DOT11_MODE_TAURUS;
2548 }
2549 else
2550 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002551
2552#ifdef WLAN_FEATURE_11AC
2553 phyMode = eCSR_DOT11_MODE_11ac;
2554#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002556#endif
2557
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 }
2559 }
2560 else
2561 {
2562 //user's pick
2563 phyMode = pMac->roam.configParam.phyMode;
2564 }
2565 }
2566 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode) )
2567 {
2568 if(0 != phyMode)
2569 {
2570 if(eCSR_DOT11_MODE_AUTO & phyMode)
2571 {
2572 phyMode2 = eCSR_DOT11_MODE_AUTO & phyMode;
2573 }
2574 else
2575 {
2576 phyMode2 = eCSR_DOT11_MODE_TAURUS & phyMode;
2577 }
2578 }
2579 else
2580 {
2581 phyMode2 = phyMode;
2582 }
2583 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2584 &cfgDot11ModeToUse );
2585 }
2586 else
2587 {
2588 bitMask = 1;
2589 loopCount = 0;
2590 while(loopCount < eCSR_NUM_PHY_MODE)
2591 {
2592 if(0 != ( phyMode2 = (phyMode & (bitMask << loopCount++)) ))
2593 {
2594 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2595 &cfgDot11ModeToUse );
2596 if(fMatch) break;
2597 }
2598 }
2599 }
2600 if ( fMatch && pReturnCfgDot11Mode )
2601 {
2602 if( pProfile )
2603 {
2604 /* IEEE 11n spec (8.4.3): HT STA shall eliminate TKIP as a
2605 * choice for the pairwise cipher suite if CCMP is advertised
2606 * by the AP or if the AP included an HT capabilities element
2607 * in its Beacons and Probe Response.
2608 */
2609 if( (!CSR_IS_11n_ALLOWED( pProfile->negotiatedUCEncryptionType )) &&
2610 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11ModeToUse) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002611#ifdef WLAN_FEATURE_11AC
2612 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11ModeToUse) ||
2613#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11ModeToUse)) )
2615 {
2616 //We cannot do 11n here
2617 if( !CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId) )
2618 {
2619 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2620 }
2621 else
2622 {
2623 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2624 }
2625 }
2626 }
2627 *pReturnCfgDot11Mode = cfgDot11ModeToUse;
2628 }
2629 }
2630
2631 return( fMatch );
2632}
2633
2634
2635eCsrCfgDot11Mode csrFindBestPhyMode( tpAniSirGlobal pMac, tANI_U32 phyMode )
2636{
2637 eCsrCfgDot11Mode cfgDot11ModeToUse;
2638 eCsrBand eBand = pMac->roam.configParam.eBand;
2639
Jeff Johnsone7245742012-09-05 17:12:55 -07002640
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302641 if ((0 == phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002642#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302643 (eCSR_DOT11_MODE_11ac & phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002644#endif
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302645 (eCSR_DOT11_MODE_AUTO & phyMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 {
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302647#ifdef WLAN_FEATURE_11AC
2648 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2649 {
2650 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC;
2651 }
2652 else
2653#endif
2654 {
2655 /* Default to 11N mode if user has configured 11ac mode
2656 * and FW doesn't supports 11ac mode .
2657 */
2658 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 }
2661 else
2662 {
2663 if( ( eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY ) & phyMode )
2664 {
2665 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2666 }
2667 else if ( eCSR_DOT11_MODE_abg & phyMode )
2668 {
2669 if( eCSR_BAND_24 != eBand )
2670 {
2671 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2672 }
2673 else
2674 {
2675 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2676 }
2677 }
2678 else if( ( eCSR_DOT11_MODE_11a | eCSR_DOT11_MODE_11a_ONLY ) & phyMode )
2679 {
2680 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2681 }
2682 else if( ( eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY ) & phyMode )
2683 {
2684 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2685 }
2686 else
2687 {
2688 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B;
2689 }
2690 }
2691
2692 return ( cfgDot11ModeToUse );
2693}
2694
2695
2696
2697
2698tANI_U32 csrGet11hPowerConstraint( tHalHandle hHal, tDot11fIEPowerConstraints *pPowerConstraint )
2699{
2700 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2701 tANI_U32 localPowerConstraint = 0;
2702
2703 // check if .11h support is enabled, if not, the power constraint is 0.
2704 if(pMac->roam.configParam.Is11hSupportEnabled && pPowerConstraint->present)
2705 {
2706 localPowerConstraint = pPowerConstraint->localPowerConstraints;
2707 }
2708
2709 return( localPowerConstraint );
2710}
2711
2712
2713tANI_BOOLEAN csrIsProfileWpa( tCsrRoamProfile *pProfile )
2714{
2715 tANI_BOOLEAN fWpaProfile = FALSE;
2716
2717 switch ( pProfile->negotiatedAuthType )
2718 {
2719 case eCSR_AUTH_TYPE_WPA:
2720 case eCSR_AUTH_TYPE_WPA_PSK:
2721 case eCSR_AUTH_TYPE_WPA_NONE:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002722#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 case eCSR_AUTH_TYPE_CCKM_WPA:
2724#endif
2725 fWpaProfile = TRUE;
2726 break;
2727
2728 default:
2729 fWpaProfile = FALSE;
2730 break;
2731 }
2732
2733 if ( fWpaProfile )
2734 {
2735 switch ( pProfile->negotiatedUCEncryptionType )
2736 {
2737 case eCSR_ENCRYPT_TYPE_WEP40:
2738 case eCSR_ENCRYPT_TYPE_WEP104:
2739 case eCSR_ENCRYPT_TYPE_TKIP:
2740 case eCSR_ENCRYPT_TYPE_AES:
2741 fWpaProfile = TRUE;
2742 break;
2743
2744 default:
2745 fWpaProfile = FALSE;
2746 break;
2747 }
2748 }
2749 return( fWpaProfile );
2750}
2751
2752tANI_BOOLEAN csrIsProfileRSN( tCsrRoamProfile *pProfile )
2753{
2754 tANI_BOOLEAN fRSNProfile = FALSE;
2755
2756 switch ( pProfile->negotiatedAuthType )
2757 {
2758 case eCSR_AUTH_TYPE_RSN:
2759 case eCSR_AUTH_TYPE_RSN_PSK:
2760#ifdef WLAN_FEATURE_VOWIFI_11R
2761 case eCSR_AUTH_TYPE_FT_RSN:
2762 case eCSR_AUTH_TYPE_FT_RSN_PSK:
2763#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002764#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 case eCSR_AUTH_TYPE_CCKM_RSN:
2766#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002767#ifdef WLAN_FEATURE_11W
2768 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05302769 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07002770#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 fRSNProfile = TRUE;
2772 break;
2773
2774 default:
2775 fRSNProfile = FALSE;
2776 break;
2777 }
2778
2779 if ( fRSNProfile )
2780 {
2781 switch ( pProfile->negotiatedUCEncryptionType )
2782 {
2783 // !!REVIEW - For WPA2, use of RSN IE mandates
2784 // use of AES as encryption. Here, we qualify
2785 // even if encryption type is WEP or TKIP
2786 case eCSR_ENCRYPT_TYPE_WEP40:
2787 case eCSR_ENCRYPT_TYPE_WEP104:
2788 case eCSR_ENCRYPT_TYPE_TKIP:
2789 case eCSR_ENCRYPT_TYPE_AES:
2790 fRSNProfile = TRUE;
2791 break;
2792
2793 default:
2794 fRSNProfile = FALSE;
2795 break;
2796 }
2797 }
2798 return( fRSNProfile );
2799}
2800
Jeff Johnsone7245742012-09-05 17:12:55 -07002801eHalStatus
2802csrIsconcurrentsessionValid(tpAniSirGlobal pMac,tANI_U32 cursessionId,
2803 tVOS_CON_MODE currBssPersona)
2804{
2805 tANI_U32 sessionId = 0;
2806
2807 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2808 {
2809 if (cursessionId != sessionId )
2810 {
2811 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2812 {
2813 continue;
2814 }
2815
2816 switch (currBssPersona)
2817 {
2818 case VOS_STA_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -07002819 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05302820 smsLog(pMac, LOG4, FL(" Second session for persona %d"), currBssPersona);
Agarwal Ashishe16e1212014-05-15 14:51:36 +05302821 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07002822 }
2823 break;
2824
2825 case VOS_STA_SAP_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302826 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2827 == VOS_STA_SAP_MODE)&&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002828 (pMac->roam.roamSession[sessionId].connectState
2829 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002831 smsLog(pMac, LOGE, FL(" ****SoftAP mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002832 return eHAL_STATUS_FAILURE;
2833 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002834 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2835 == VOS_P2P_GO_MODE &&
2836 pMac->roam.roamSession[sessionId].connectState
2837 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2838 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2839 == VOS_IBSS_MODE &&
2840 pMac->roam.roamSession[sessionId].connectState
2841 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002842 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002843 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002844 return eHAL_STATUS_FAILURE;
2845 }
2846 break;
2847
2848 case VOS_P2P_CLIENT_MODE:
2849 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002850 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002851 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2852 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002853 smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002854 return eHAL_STATUS_FAILURE;
2855 }
2856 break;
2857
2858 case VOS_P2P_GO_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302859 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2860 == VOS_P2P_GO_MODE) &&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002861 (pMac->roam.roamSession[sessionId].connectState
2862 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002863 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002864 smsLog(pMac, LOGE, FL(" ****P2P GO mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002865 return eHAL_STATUS_FAILURE;
2866 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002867 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2868 == VOS_STA_SAP_MODE &&
2869 pMac->roam.roamSession[sessionId].connectState
2870 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2871 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2872 == VOS_IBSS_MODE &&
2873 pMac->roam.roamSession[sessionId].connectState
2874 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002875 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002876 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002877 return eHAL_STATUS_FAILURE;
2878 }
2879 break;
Ravi Joshia96ceb42013-05-20 18:52:39 -07002880 case VOS_IBSS_MODE:
2881 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2882 == VOS_IBSS_MODE) &&
2883 (pMac->roam.roamSession[sessionId].connectState
2884 != eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED))
2885 {
2886 smsLog(pMac, LOGE, FL(" ****IBSS mode already exists ****"));
2887 return eHAL_STATUS_FAILURE;
2888 }
2889 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2890 == VOS_P2P_GO_MODE ||
2891 pMac->roam.roamSession[sessionId].bssParams.bssPersona
2892 == VOS_STA_SAP_MODE) &&
2893 pMac->roam.roamSession[sessionId].connectState
2894 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)
2895 {
2896 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
2897 return eHAL_STATUS_FAILURE;
2898 }
2899 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002900 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002901 smsLog(pMac, LOGE, FL("***Persona not handled = %d*****"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07002902 break;
2903 }
2904 }
2905 }
2906 return eHAL_STATUS_SUCCESS;
2907
2908}
2909
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002910eHalStatus csrUpdateMCCp2pBeaconInterval(tpAniSirGlobal pMac)
Jeff Johnsone7245742012-09-05 17:12:55 -07002911{
2912 tANI_U32 sessionId = 0;
2913
2914 //If MCC is not supported just break and return SUCCESS
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002915 if ( !pMac->roam.configParam.fenableMCCMode){
2916 return eHAL_STATUS_FAILURE;
2917 }
2918
2919 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2920 {
2921 /* If GO in MCC support different beacon interval,
2922 * change the BI of the P2P-GO */
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002923 if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2924 == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002925 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002926 /* Handle different BI scneario based on the configuration set.
2927 * If Config is set to 0x02 then Disconnect all the P2P clients
2928 * associated. If config is set to 0x04 then update the BI
2929 * without disconnecting all the clients
2930 */
2931 if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
2932 (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
2933 {
2934 return csrSendChngMCCBeaconInterval( pMac, sessionId);
2935 }
2936 //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
2937 else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
2938 {
2939 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
2940 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002941 }
2942 }
2943 return eHAL_STATUS_FAILURE;
2944}
2945
2946tANI_U16 csrCalculateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U16 sta_bi, tANI_U16 go_gbi)
2947{
2948 tANI_U8 num_beacons = 0;
2949 tANI_U8 is_multiple = 0;
2950 tANI_U16 go_cbi = 0;
2951 tANI_U16 go_fbi = 0;
2952 tANI_U16 sta_cbi = 0;
2953
2954 //If GO's given beacon Interval is less than 100
2955 if(go_gbi < 100)
2956 go_cbi = 100;
2957 //if GO's given beacon Interval is greater than or equal to 100
2958 else
2959 go_cbi = 100 + (go_gbi % 100);
2960
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05302961 if ( sta_bi == 0 )
2962 {
2963 /* There is possibility to receive zero as value.
2964 Which will cause divide by zero. Hence initialise with 100
2965 */
2966 sta_bi = 100;
2967 smsLog(pMac, LOGW,
2968 FL("sta_bi 2nd parameter is zero, initialise to %d"), sta_bi);
2969 }
2970
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002971 // check, if either one is multiple of another
2972 if (sta_bi > go_cbi)
2973 {
2974 is_multiple = !(sta_bi % go_cbi);
2975 }
2976 else
2977 {
2978 is_multiple = !(go_cbi % sta_bi);
2979 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002980 // if it is multiple, then accept GO's beacon interval range [100,199] as it is
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002981 if (is_multiple)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002982 {
2983 return go_cbi;
2984 }
2985 //else , if it is not multiple, then then check for number of beacons to be
2986 //inserted based on sta BI
2987 num_beacons = sta_bi / 100;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002988 if (num_beacons)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002989 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002990 // GO's final beacon interval will be aligned to sta beacon interval, but
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002991 //in the range of [100, 199].
2992 sta_cbi = sta_bi / num_beacons;
2993 go_fbi = sta_cbi;
2994 }
2995 else
2996 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002997 // if STA beacon interval is less than 100, use GO's change bacon interval
2998 //instead of updating to STA's beacon interval.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002999 go_fbi = go_cbi;
3000 }
3001 return go_fbi;
3002}
3003
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003004eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003005 tANI_U16 *beaconInterval, tANI_U32 cursessionId,
3006 tVOS_CON_MODE currBssPersona)
3007{
3008 tANI_U32 sessionId = 0;
3009 tANI_U16 new_beaconInterval = 0;
3010
3011 //If MCC is not supported just break
3012 if (!pMac->roam.configParam.fenableMCCMode){
Jeff Johnsone7245742012-09-05 17:12:55 -07003013 return eHAL_STATUS_FAILURE;
3014 }
3015
3016 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
3017 {
3018 if (cursessionId != sessionId )
3019 {
3020 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
3021 {
3022 continue;
3023 }
3024
3025 switch (currBssPersona)
3026 {
3027 case VOS_STA_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003028 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3029 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003030 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
3031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003032 smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003033 }
3034 //IF SAP has started and STA wants to connect on different channel MCC should
3035 //MCC should not be enabled so making it false to enforce on same channel
3036 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3037 == VOS_STA_SAP_MODE)
3038 {
3039 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3040 != channelId )
3041 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05303042 smsLog(pMac, LOGE, FL("*** MCC with SAP+STA sessions ****"));
3043 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07003044 }
3045 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003046 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003047 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3048 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003049 /* if GO in MCC support different beacon interval,
3050 * change the BI of the P2P-GO */
3051 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
Jeff Johnsone7245742012-09-05 17:12:55 -07003052 != channelId ) &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003053 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003054 != *beaconInterval))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003055 {
3056 /* if GO in MCC support different beacon interval, return success */
3057 if ( pMac->roam.configParam.fAllowMCCGODiffBI == 0x01)
3058 {
3059 return eHAL_STATUS_SUCCESS;
3060 }
3061 // Send only Broadcast disassoc and update beaconInterval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003062 //If configuration is set to 0x04 then dont
3063 // disconnect all the station
3064 else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
3065 (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003066 {
3067 //Check to pass the right beacon Interval
3068 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval,
3069 pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003070 smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003071 //Update the becon Interval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003072 if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003073 {
3074 //Update the beaconInterval now
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003075 smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
3076 pMac->roam.configParam.fAllowMCCGODiffBI);
3077
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003078 pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
3079 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003080 return csrUpdateMCCp2pBeaconInterval(pMac);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003081 }
3082 return eHAL_STATUS_SUCCESS;
3083 }
3084 //Disconnect the P2P session
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003085 else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003086 {
3087 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
3088 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
3089 }
3090 else
3091 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003092 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to preferred AP..."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003093 return eHAL_STATUS_FAILURE;
3094 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003095 }
3096 }
3097 break;
3098
3099 case VOS_P2P_CLIENT_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003100 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3101 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003102 == VOS_STA_MODE)) //check for P2P client mode
3103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003104 smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003105 }
3106 //IF SAP has started and STA wants to connect on different channel MCC should
3107 //MCC should not be enabled so making it false to enforce on same channel
3108 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3109 == VOS_STA_SAP_MODE)
3110 {
3111 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3112 != channelId )
3113 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003114 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP + CLIENT****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003115 return eHAL_STATUS_FAILURE;
3116 }
3117 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003118 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003119 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3120 {
3121 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
3122 != channelId ) &&
3123 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
3124 != *beaconInterval))
3125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003126 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to P2P_GO network ..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003127 return eHAL_STATUS_FAILURE;
3128 }
3129 }
3130 break;
3131
3132 case VOS_P2P_GO_MODE :
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003133 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003134 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3135 ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003136 == VOS_P2P_CLIENT_MODE) ||
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003137 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003138 == VOS_STA_MODE))) //check for P2P_client scenario
3139 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003140 if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003141 == 0 )&&
3142 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
3143 == 0))
3144 {
3145 continue;
3146 }
3147
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05303148 //Assert if connected profile beacon internal is ZERO
3149 if(!pMac->roam.roamSession[sessionId].\
3150 connectedProfile.beaconInterval)
3151 {
3152 smsLog( pMac, LOGE, FL(" Connected profile "
3153 "beacon interval is zero") );
3154 }
3155
Jeff Johnsone7245742012-09-05 17:12:55 -07003156
3157 if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003158 (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003159 != channelId ) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003160 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003161 != *beaconInterval))
3162 {
3163 /*
3164 * Updated beaconInterval should be used only when we are starting a new BSS
3165 * not incase of client or STA case
3166 */
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003167 //Calculate beacon Interval for P2P-GO incase of MCC
3168 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac,
Chet Lanctot4c986162013-05-08 13:59:56 -07003169 pMac->roam.roamSession[sessionId].bssParams.beaconInterval,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003170 *beaconInterval );
3171 if(*beaconInterval != new_beaconInterval)
3172 *beaconInterval = new_beaconInterval;
Jeff Johnsone7245742012-09-05 17:12:55 -07003173 return eHAL_STATUS_SUCCESS;
3174 }
3175 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003176 }
3177 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003178
3179 default :
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303180 smsLog(pMac, LOGE, FL(" Persona not supported : %d"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003181 return eHAL_STATUS_FAILURE;
3182 }
3183 }
3184 }
3185
3186 return eHAL_STATUS_SUCCESS;
3187}
Jeff Johnson295189b2012-06-20 16:38:30 -07003188
3189#ifdef WLAN_FEATURE_VOWIFI_11R
3190/* Function to return TRUE if the authtype is 11r */
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003191tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -07003192{
3193 switch ( AuthType )
3194 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003195 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3196 if(mdiePresent)
3197 return TRUE;
3198 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003199 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3200 case eCSR_AUTH_TYPE_FT_RSN:
3201 return TRUE;
3202 break;
3203 default:
3204 break;
3205 }
3206 return FALSE;
3207}
3208
3209/* Function to return TRUE if the profile is 11r */
3210tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
3211{
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003212 return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
Jeff Johnson295189b2012-06-20 16:38:30 -07003213}
3214
3215#endif
3216
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003217#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003218
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003219/* Function to return TRUE if the authtype is ESE */
3220tANI_BOOLEAN csrIsAuthTypeESE( eCsrAuthType AuthType )
Jeff Johnson295189b2012-06-20 16:38:30 -07003221{
3222 switch ( AuthType )
3223 {
3224 case eCSR_AUTH_TYPE_CCKM_WPA:
3225 case eCSR_AUTH_TYPE_CCKM_RSN:
3226 return TRUE;
3227 break;
3228 default:
3229 break;
3230 }
3231 return FALSE;
3232}
3233
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003234/* Function to return TRUE if the profile is ESE */
3235tANI_BOOLEAN csrIsProfileESE( tCsrRoamProfile *pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003236{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003237 return (csrIsAuthTypeESE( pProfile->negotiatedAuthType ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003238}
3239
3240#endif
3241
3242#ifdef FEATURE_WLAN_WAPI
3243tANI_BOOLEAN csrIsProfileWapi( tCsrRoamProfile *pProfile )
3244{
3245 tANI_BOOLEAN fWapiProfile = FALSE;
3246
3247 switch ( pProfile->negotiatedAuthType )
3248 {
3249 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
3250 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
3251 fWapiProfile = TRUE;
3252 break;
3253
3254 default:
3255 fWapiProfile = FALSE;
3256 break;
3257 }
3258
3259 if ( fWapiProfile )
3260 {
3261 switch ( pProfile->negotiatedUCEncryptionType )
3262 {
3263 case eCSR_ENCRYPT_TYPE_WPI:
3264 fWapiProfile = TRUE;
3265 break;
3266
3267 default:
3268 fWapiProfile = FALSE;
3269 break;
3270 }
3271 }
3272 return( fWapiProfile );
3273}
3274
3275static tANI_BOOLEAN csrIsWapiOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3276{
Kiet Lam64c1b492013-07-12 13:56:44 +05303277 return (vos_mem_compare(Oui1, Oui2, CSR_WAPI_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003278}
3279
3280static tANI_BOOLEAN csrIsWapiOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3281 tANI_U8 cAllCyphers,
3282 tANI_U8 Cypher[],
3283 tANI_U8 Oui[] )
3284{
3285 tANI_BOOLEAN fYes = FALSE;
3286 tANI_U8 idx;
3287
3288 for ( idx = 0; idx < cAllCyphers; idx++ )
3289 {
3290 if ( csrIsWapiOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3291 {
3292 fYes = TRUE;
3293 break;
3294 }
3295 }
3296
3297 if ( fYes && Oui )
3298 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303299 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 }
3301
3302 return( fYes );
3303}
3304#endif /* FEATURE_WLAN_WAPI */
3305
3306static tANI_BOOLEAN csrIsWpaOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3307{
Kiet Lam64c1b492013-07-12 13:56:44 +05303308 return(vos_mem_compare(Oui1, Oui2, CSR_WPA_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003309}
3310
3311static tANI_BOOLEAN csrIsOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3312 tANI_U8 cAllCyphers,
3313 tANI_U8 Cypher[],
3314 tANI_U8 Oui[] )
3315{
3316 tANI_BOOLEAN fYes = FALSE;
3317 tANI_U8 idx;
3318
3319 for ( idx = 0; idx < cAllCyphers; idx++ )
3320 {
3321 if ( csrIsWpaOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3322 {
3323 fYes = TRUE;
3324 break;
3325 }
3326 }
3327
3328 if ( fYes && Oui )
3329 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303330 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 }
3332
3333 return( fYes );
3334}
3335
3336static tANI_BOOLEAN csrMatchRSNOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3337 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3338 tANI_U8 Oui[] )
3339{
3340 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui[ouiIndex], Oui ) );
3341
3342}
3343
3344#ifdef FEATURE_WLAN_WAPI
3345static tANI_BOOLEAN csrMatchWapiOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3346 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3347 tANI_U8 Oui[] )
3348{
Kaushik, Sushantfe230152014-04-08 14:37:47 +05303349 if (ouiIndex < CSR_WAPI_OUI_ROW_SIZE)// since csrWapiOui row size is 3 .
3350 return( csrIsWapiOuiMatch( pMac, AllCyphers, cAllCyphers,
3351 csrWapiOui[ouiIndex], Oui ) );
3352 else
3353 return FALSE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07003354
3355}
3356#endif /* FEATURE_WLAN_WAPI */
3357
3358static tANI_BOOLEAN csrMatchWPAOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3359 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3360 tANI_U8 Oui[] )
3361{
3362 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui[ouiIndex], Oui ) );
3363
3364}
3365
3366#if 0
3367static tANI_BOOLEAN csrIsRSNUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3368 tANI_U8 cAllCyphers,
3369 tANI_U8 Oui[] )
3370{
3371 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui00, Oui ) );
3372}
3373
3374static tANI_BOOLEAN csrIsRSNMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3375 tANI_U8 cAllCyphers,
3376 tANI_U8 Oui[] )
3377{
3378 tANI_BOOLEAN fYes = FALSE;
3379
3380 // Check Wep 104 first, if fails, then check Wep40.
3381 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui05, Oui );
3382
3383 if ( !fYes )
3384 {
3385 // if not Wep-104, check Wep-40
3386 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui01, Oui );
3387 }
3388
3389 return( fYes );
3390}
3391
3392
3393static tANI_BOOLEAN csrIsRSNUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3394 tANI_U8 cAllCyphers,
3395 tANI_U8 Oui[] )
3396{
3397 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3398}
3399
3400
3401static tANI_BOOLEAN csrIsRSNMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3402 tANI_U8 cAllCyphers,
3403 tANI_U8 Oui[] )
3404{
3405 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3406}
3407
3408static tANI_BOOLEAN csrIsRSNUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3409 tANI_U8 cAllCyphers,
3410 tANI_U8 Oui[] )
3411{
3412 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3413}
3414
3415static tANI_BOOLEAN csrIsRSNMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3416 tANI_U8 cAllCyphers,
3417 tANI_U8 Oui[] )
3418{
3419 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3420}
3421#endif
3422#ifdef FEATURE_WLAN_WAPI
3423static tANI_BOOLEAN csrIsAuthWapiCert( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3424 tANI_U8 cAllSuites,
3425 tANI_U8 Oui[] )
3426{
3427 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[1], Oui ) );
3428}
3429static tANI_BOOLEAN csrIsAuthWapiPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3430 tANI_U8 cAllSuites,
3431 tANI_U8 Oui[] )
3432{
3433 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[2], Oui ) );
3434}
3435#endif /* FEATURE_WLAN_WAPI */
3436
3437#ifdef WLAN_FEATURE_VOWIFI_11R
3438
3439/*
3440 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3441 * here. This matches for FT Auth with the 802.1X exchange.
3442 *
3443 */
3444static tANI_BOOLEAN csrIsFTAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3445 tANI_U8 cAllSuites,
3446 tANI_U8 Oui[] )
3447{
3448 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[03], Oui ) );
3449}
3450
3451/*
3452 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3453 * here. This matches for FT Auth with the PSK.
3454 *
3455 */
3456static tANI_BOOLEAN csrIsFTAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3457 tANI_U8 cAllSuites,
3458 tANI_U8 Oui[] )
3459{
3460 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[04], Oui ) );
3461}
3462
3463#endif
3464
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003465#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003466
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003467/*
3468 * Function for ESE CCKM AKM Authentication. We match the CCKM AKM Authentication Key Management suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 * here. This matches for CCKM AKM Auth with the 802.1X exchange.
3470 *
3471 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003472static tANI_BOOLEAN csrIsEseCckmAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 tANI_U8 cAllSuites,
3474 tANI_U8 Oui[] )
3475{
3476 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[06], Oui ) );
3477}
3478
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003479static tANI_BOOLEAN csrIsEseCckmAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 tANI_U8 cAllSuites,
3481 tANI_U8 Oui[] )
3482{
3483 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[06], Oui ) );
3484}
3485
3486#endif
3487
3488static tANI_BOOLEAN csrIsAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3489 tANI_U8 cAllSuites,
3490 tANI_U8 Oui[] )
3491{
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[01], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003493}
3494static tANI_BOOLEAN csrIsAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3495 tANI_U8 cAllSuites,
3496 tANI_U8 Oui[] )
3497{
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[02], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003499}
3500
Chet Lanctot186b5732013-03-18 10:26:30 -07003501#ifdef WLAN_FEATURE_11W
3502static tANI_BOOLEAN csrIsAuthRSNPskSha256( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3503 tANI_U8 cAllSuites,
3504 tANI_U8 Oui[] )
3505{
Chet Lanctot4c986162013-05-08 13:59:56 -07003506 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[07], Oui );
Chet Lanctot186b5732013-03-18 10:26:30 -07003507}
Abhishek Singhae408032014-09-25 17:22:04 +05303508static tANI_BOOLEAN csrIsAuthRSN8021xSha256(tpAniSirGlobal pMac,
3509 tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3510 tANI_U8 cAllSuites,
3511 tANI_U8 Oui[] )
3512{
3513 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[8], Oui );
3514}
Chet Lanctot186b5732013-03-18 10:26:30 -07003515#endif
3516
Jeff Johnson295189b2012-06-20 16:38:30 -07003517static tANI_BOOLEAN csrIsAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3518 tANI_U8 cAllSuites,
3519 tANI_U8 Oui[] )
3520{
3521 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[01], Oui ) );
3522}
3523
3524#ifdef NOT_CURRENTLY_USED
3525static tANI_BOOLEAN csrIsAuth802_1x( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3526 tANI_U8 cAllSuites,
3527 tANI_U8 Oui[] )
3528{
3529 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[00], Oui ) );
3530}
3531#endif // NOT_CURRENTLY_USED
3532
3533static tANI_BOOLEAN csrIsAuthWpaPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3534 tANI_U8 cAllSuites,
3535 tANI_U8 Oui[] )
3536{
3537 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[02], Oui ) );
3538}
3539#if 0
3540static tANI_BOOLEAN csrIsUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3541 tANI_U8 cAllCyphers,
3542 tANI_U8 Oui[] )
3543{
3544 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui00, Oui ) );
3545}
3546
3547static tANI_BOOLEAN csrIsUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3548 tANI_U8 cAllCyphers,
3549 tANI_U8 Oui[] )
3550{
3551 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3552}
3553
3554static tANI_BOOLEAN csrIsUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3555 tANI_U8 cAllCyphers,
3556 tANI_U8 Oui[] )
3557{
3558 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3559}
3560
3561
3562static tANI_BOOLEAN csrIsMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3563 tANI_U8 cAllCyphers,
3564 tANI_U8 Oui[] )
3565{
3566 tANI_BOOLEAN fYes = FALSE;
3567
3568 // Check Wep 104 first, if fails, then check Wep40.
3569 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui05, Oui );
3570
3571 if ( !fYes )
3572 {
3573 // if not Wep-104, check Wep-40
3574 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui01, Oui );
3575 }
3576
3577 return( fYes );
3578}
3579
3580
3581static tANI_BOOLEAN csrIsMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3582 tANI_U8 cAllCyphers,
3583 tANI_U8 Oui[] )
3584{
3585 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3586}
3587
3588
3589static tANI_BOOLEAN csrIsMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3590 tANI_U8 cAllCyphers,
3591 tANI_U8 Oui[] )
3592{
3593 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3594}
3595
3596#endif
3597
3598tANI_U8 csrGetOUIIndexFromCipher( eCsrEncryptionType enType )
3599{
3600 tANI_U8 OUIIndex;
3601
3602 switch ( enType )
3603 {
3604 case eCSR_ENCRYPT_TYPE_WEP40:
3605 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3606 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX;
3607 break;
3608 case eCSR_ENCRYPT_TYPE_WEP104:
3609 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3610 OUIIndex = CSR_OUI_WEP104_INDEX;
3611 break;
3612 case eCSR_ENCRYPT_TYPE_TKIP:
3613 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX;
3614 break;
3615 case eCSR_ENCRYPT_TYPE_AES:
3616 OUIIndex = CSR_OUI_AES_INDEX;
3617 break;
3618 case eCSR_ENCRYPT_TYPE_NONE:
3619 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX;
3620 break;
3621#ifdef FEATURE_WLAN_WAPI
3622 case eCSR_ENCRYPT_TYPE_WPI:
3623 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX;
3624 break;
3625#endif /* FEATURE_WLAN_WAPI */
3626 default: //HOWTO handle this?
3627 OUIIndex = CSR_OUI_RESERVED_INDEX;
3628 break;
3629 }//switch
3630
3631 return OUIIndex;
3632}
3633
3634tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3635 tDot11fIERSN *pRSNIe,
3636 tANI_U8 *UnicastCypher,
3637 tANI_U8 *MulticastCypher,
3638 tANI_U8 *AuthSuite,
3639 tCsrRSNCapabilities *Capabilities,
3640 eCsrAuthType *pNegotiatedAuthtype,
3641 eCsrEncryptionType *pNegotiatedMCCipher )
3642{
3643 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3644 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3645 tANI_U8 cUnicastCyphers = 0;
3646 tANI_U8 cMulticastCyphers = 0;
3647 tANI_U8 cAuthSuites = 0, i;
3648 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3649 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3650 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3651 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3652 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3653 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3654
3655 do{
3656 if ( pRSNIe->present )
3657 {
3658 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303659 vos_mem_copy(MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
3661 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_count);
3662 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3663 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303664 vos_mem_copy((void *)&AuthSuites[i],
3665 (void *)&pRSNIe->akm_suites[i],
3666 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 }
3668
3669 //Check - Is requested Unicast Cipher supported by the BSS.
3670 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3671 csrGetOUIIndexFromCipher( enType ), Unicast );
3672
3673 if( !fAcceptableCyphers ) break;
3674
3675
3676 //Unicast is supported. Pick the first matching Group cipher, if any.
3677 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3678 {
3679 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3680 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3681 if(fAcceptableCyphers)
3682 {
3683 break;
3684 }
3685 }
3686 if( !fAcceptableCyphers ) break;
3687
3688 if( pNegotiatedMCCipher )
3689 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3690
3691 /* Initializing with FALSE as it has TRUE value already */
3692 fAcceptableCyphers = FALSE;
3693 for (i = 0 ; i < pAuthType->numEntries; i++)
3694 {
3695 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3696 #ifdef WLAN_FEATURE_VOWIFI_11R
3697 /* Changed the AKM suites according to order of preference */
3698 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3699 {
3700 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3701 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3702 }
3703 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3704 {
3705 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3706 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3707 }
3708#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003709#ifdef FEATURE_WLAN_ESE
3710 /* ESE only supports 802.1X. No PSK. */
3711 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 {
3713 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3714 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3715 }
3716#endif
3717 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3718 {
3719 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3720 negAuthType = eCSR_AUTH_TYPE_RSN;
3721 }
3722 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3723 {
3724 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3725 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3726 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003727#ifdef WLAN_FEATURE_11W
3728 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3729 {
3730 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3731 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3732 }
Abhishek Singhae408032014-09-25 17:22:04 +05303733 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) &&
3734 csrIsAuthRSN8021xSha256(pMac, AuthSuites,
3735 cAuthSuites, Authentication)) {
3736 if (eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
3737 pAuthType->authType[i])
3738 negAuthType = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3739 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003740#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003741
3742 // The 1st auth type in the APs RSN IE, to match stations connecting
3743 // profiles auth type will cause us to exit this loop
3744 // This is added as some APs advertise multiple akms in the RSN IE.
3745 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3746 {
3747 fAcceptableCyphers = TRUE;
3748 break;
3749 }
3750 } // for
3751 }
3752
3753 }while (0);
3754
3755 if ( fAcceptableCyphers )
3756 {
3757 if ( MulticastCypher )
3758 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303759 vos_mem_copy(MulticastCypher, Multicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 }
3761
3762 if ( UnicastCypher )
3763 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303764 vos_mem_copy(UnicastCypher, Unicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 }
3766
3767 if ( AuthSuite )
3768 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303769 vos_mem_copy(AuthSuite, Authentication, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 }
3771
3772 if ( pNegotiatedAuthtype )
3773 {
3774 *pNegotiatedAuthtype = negAuthType;
3775 }
3776 if ( Capabilities )
3777 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003778 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3779 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3780 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003781 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003782 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3783 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
Chet Lanctot186b5732013-03-18 10:26:30 -07003784 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 }
3786 }
3787 return( fAcceptableCyphers );
3788}
3789
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303790#ifdef WLAN_FEATURE_11W
3791/* ---------------------------------------------------------------------------
3792 \fn csrIsPMFCapabilitiesInRSNMatch
Jeff Johnson295189b2012-06-20 16:38:30 -07003793
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303794 \brief this function is to match our current capabilities with the AP
3795 to which we are expecting make the connection.
3796
3797 \param hHal - HAL Pointer
3798 pFilterMFPEnabled - given by supplicant to us to specify what kind
3799 of connection supplicant is expecting to make
3800 if it is enabled then make PMF connection.
3801 if it is disabled then make normal connection.
3802 pFilterMFPRequired - given by supplicant based on our configuration
3803 if it is 1 then we will require mandatory
3804 PMF connection and if it is 0 then we PMF
3805 connection is optional.
3806 pFilterMFPCapable - given by supplicant based on our configuration
3807 if it 1 then we are PMF capable and if it 0
3808 then we are not PMF capable.
3809 pRSNIe - RSNIe from Beacon/probe response of
3810 neighbor AP against which we will compare
3811 our capabilities.
3812
3813 \return tANI_BOOLEAN - if our PMF capabilities matches with AP then we
3814 will return true to indicate that we are good
3815 to make connection with it. Else we will return
3816 false.
3817 -------------------------------------------------------------------------------*/
3818static tANI_BOOLEAN
3819csrIsPMFCapabilitiesInRSNMatch( tHalHandle hHal,
3820 tANI_BOOLEAN *pFilterMFPEnabled,
3821 tANI_U8 *pFilterMFPRequired,
3822 tANI_U8 *pFilterMFPCapable,
3823 tDot11fIERSN *pRSNIe)
3824{
3825 tANI_U8 apProfileMFPCapable = 0;
3826 tANI_U8 apProfileMFPRequired = 0;
3827 if (pRSNIe && pFilterMFPEnabled && pFilterMFPCapable && pFilterMFPRequired)
3828 {
3829 /* Extracting MFPCapable bit from RSN Ie */
3830 apProfileMFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1;
3831 apProfileMFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1;
3832 if (*pFilterMFPEnabled && *pFilterMFPCapable && *pFilterMFPRequired
3833 && (apProfileMFPCapable == 0))
3834 {
3835 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3836 "AP is not capable to make PMF connection");
3837 return VOS_FALSE;
3838 }
3839 else if (*pFilterMFPEnabled && *pFilterMFPCapable &&
3840 !(*pFilterMFPRequired) && (apProfileMFPCapable == 0))
3841 {
3842 /*
3843 * This is tricky, because supplicant asked us to make mandatory
3844 * PMF connection eventhough PMF connection is optional here.
3845 * so if AP is not capable of PMF then drop it. Don't try to
3846 * connect with it.
3847 */
3848 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3849 "we need PMF connection & AP isn't capable to make PMF connection");
3850 return VOS_FALSE;
3851 }
3852 else if (!(*pFilterMFPCapable) &&
3853 apProfileMFPCapable && apProfileMFPRequired)
3854 {
3855 /*
3856 * In this case, AP with whom we trying to connect requires
3857 * mandatory PMF connections and we are not capable so this AP
3858 * is not good choice to connect
3859 */
3860 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3861 "AP needs PMF connection and we are not capable of pmf connection");
3862 return VOS_FALSE;
3863 }
3864 else if (!(*pFilterMFPEnabled) && *pFilterMFPCapable &&
3865 (apProfileMFPCapable == 1))
3866 {
3867 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3868 "we don't need PMF connection eventhough both parties are capable");
3869 return VOS_FALSE;
3870 }
3871 }
3872 return VOS_TRUE;
3873}
3874#endif
3875
3876tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType,
3877 eCsrEncryptionType enType,
3878 tCsrEncryptionList *pEnMcType,
3879 tANI_BOOLEAN *pMFPEnabled, tANI_U8 *pMFPRequired,
3880 tANI_U8 *pMFPCapable,
3881 tDot11fBeaconIEs *pIes,
3882 eCsrAuthType *pNegotiatedAuthType,
3883 eCsrEncryptionType *pNegotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07003884{
3885 tANI_BOOLEAN fRSNMatch = FALSE;
3886
3887 // See if the cyphers in the Bss description match with the settings in the profile.
3888 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
3889 pNegotiatedAuthType, pNegotiatedMCCipher );
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05303890#ifdef WLAN_FEATURE_11W
3891 /* If all the filter matches then finally checks for PMF capabilities */
3892 if (fRSNMatch)
3893 {
3894 fRSNMatch = csrIsPMFCapabilitiesInRSNMatch( hHal, pMFPEnabled,
3895 pMFPRequired, pMFPCapable,
3896 &pIes->RSN);
3897 }
3898#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003899
3900 return( fRSNMatch );
3901}
3902
3903
3904tANI_BOOLEAN csrLookupPMKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pPMKId )
3905{
3906 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
3907 tANI_U32 Index;
3908 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3909
Jeff Johnson32d95a32012-09-10 13:15:23 -07003910 if(!pSession)
3911 {
3912 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3913 return FALSE;
3914 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003915 /* to force the AP initiate fresh 802.1x authentication after re-association should not
3916 * fill the PMKID from cache this is needed
3917 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
3918
3919 if(pSession->fIgnorePMKIDCache)
3920 {
3921 pSession->fIgnorePMKIDCache = FALSE;
3922 return fRC;
3923 }
3924
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 do
3926 {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303927 for( Index=0; Index < CSR_MAX_PMKID_ALLOWED; Index++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303929 if( vos_mem_compare(pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 {
3931 // match found
3932 fMatchFound = TRUE;
3933 break;
3934 }
3935 }
3936
3937 if( !fMatchFound ) break;
3938
Kiet Lam64c1b492013-07-12 13:56:44 +05303939 vos_mem_copy(pPMKId, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003940
3941 fRC = TRUE;
3942 }
3943 while( 0 );
Sushant Kaushik0b343422015-05-25 17:15:55 +05303944 smsLog(pMac, LOG1, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 fRC, pSession->NumPmkidCache);
3946
3947 return fRC;
3948}
3949
3950
3951tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3952 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
3953{
3954 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3955 tANI_BOOLEAN fRSNMatch;
3956 tANI_U8 cbRSNIe = 0;
3957 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
3958 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
3959 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
3960 tCsrRSNAuthIe *pAuthSuite;
3961 tCsrRSNCapabilities RSNCapabilities;
3962 tCsrRSNPMKIe *pPMK;
3963 tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003964#ifdef WLAN_FEATURE_11W
3965 tANI_U8 *pGroupMgmtCipherSuite;
3966#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 tDot11fBeaconIEs *pIesLocal = pIes;
Sachin Ahuja4f06a792014-12-04 18:14:32 +05303968 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003969
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003970 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003971
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 do
3973 {
3974 if ( !csrIsProfileRSN( pProfile ) ) break;
3975
3976 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
3977 {
3978 break;
3979 }
3980
3981 // See if the cyphers in the Bss description match with the settings in the profile.
3982 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
3983 &pProfile->mcEncryptionType, &pIesLocal->RSN,
Sachin Ahuja4f06a792014-12-04 18:14:32 +05303984 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, &negAuthType, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 if ( !fRSNMatch ) break;
3986
3987 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
3988
3989 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
3990
Kiet Lam64c1b492013-07-12 13:56:44 +05303991 vos_mem_copy(pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003992
3993 pRSNIe->cUnicastCyphers = 1;
3994
Kiet Lam64c1b492013-07-12 13:56:44 +05303995 vos_mem_copy(&pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003996
3997 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
3998
3999 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304000 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004001
4002 // RSN capabilities follows the Auth Suite (two octects)
4003 // !!REVIEW - What should STA put in RSN capabilities, currently
4004 // just putting back APs capabilities
4005 // For one, we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
Chet Lanctot186b5732013-03-18 10:26:30 -07004006 // For another, we should use the Management Frame Protection values given by the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 RSNCapabilities.PreAuthSupported = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07004008#ifdef WLAN_FEATURE_11W
4009 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
4010 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
4011#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
4013
4014 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
4015
Sachin Ahuja4f06a792014-12-04 18:14:32 +05304016 if (
4017#ifdef FEATURE_WLAN_ESE
4018 (eCSR_AUTH_TYPE_CCKM_RSN != negAuthType) &&
4019#endif
4020 csrLookupPMKID( pMac, sessionId, pSirBssDesc->bssId, &(PMKId[0]) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 {
4022 pPMK->cPMKIDs = 1;
4023
Kiet Lam64c1b492013-07-12 13:56:44 +05304024 vos_mem_copy(pPMK->PMKIDList[0].PMKID, PMKId, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 }
4026 else
4027 {
4028 pPMK->cPMKIDs = 0;
4029 }
4030
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004031#ifdef WLAN_FEATURE_11W
4032 if ( pProfile->MFPEnabled )
4033 {
4034 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
4035 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
Kiet Lam64c1b492013-07-12 13:56:44 +05304036 vos_mem_copy(pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE);
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004037 }
4038#endif
4039
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4041 // Add in the size of the Auth suite (count plus a single OUI)
4042 // Add in the RSN caps field.
4043 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004044 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
4046 sizeof( *pAuthSuite ) +
4047 sizeof( tCsrRSNCapabilities ));
4048 if(pPMK->cPMKIDs)
4049 {
4050 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
4051 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
4052 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07004053#ifdef WLAN_FEATURE_11W
4054 if ( pProfile->MFPEnabled )
4055 {
4056 if ( 0 == pPMK->cPMKIDs )
4057 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
4058 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
4059 }
4060#endif
4061
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 // return the size of the IE header (total) constructed...
4063 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
4064
4065 } while( 0 );
4066
4067 if( !pIes && pIesLocal )
4068 {
4069 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304070 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 }
4072
4073 return( cbRSNIe );
4074}
4075
4076
4077#ifdef FEATURE_WLAN_WAPI
4078tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4079 tDot11fIEWAPI *pWapiIe,
4080 tANI_U8 *UnicastCypher,
4081 tANI_U8 *MulticastCypher,
4082 tANI_U8 *AuthSuite,
4083 eCsrAuthType *pNegotiatedAuthtype,
4084 eCsrEncryptionType *pNegotiatedMCCipher )
4085{
4086 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4087 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4088 tANI_U8 cUnicastCyphers = 0;
4089 tANI_U8 cMulticastCyphers = 0;
4090 tANI_U8 cAuthSuites = 0, i;
4091 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
4092 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
4093 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
4094 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
4095 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
4096 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4097
4098 do{
4099 if ( pWapiIe->present )
4100 {
4101 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05304102 vos_mem_copy(MulticastCyphers, pWapiIe->multicast_cipher_suite,
4103 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
4105 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
4106 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
4107 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304108 vos_mem_copy((void *)&AuthSuites[i], (void *)&pWapiIe->akm_suites[i],
4109 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 }
4111
4112 //Check - Is requested Unicast Cipher supported by the BSS.
4113 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
4114 csrGetOUIIndexFromCipher( enType ), Unicast );
4115
4116 if( !fAcceptableCyphers ) break;
4117
4118
4119 //Unicast is supported. Pick the first matching Group cipher, if any.
4120 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4121 {
4122 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4123 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
4124 if(fAcceptableCyphers)
4125 {
4126 break;
4127 }
4128 }
4129 if( !fAcceptableCyphers ) break;
4130
4131 if( pNegotiatedMCCipher )
4132 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4133
4134 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4135 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
4136 {
4137 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4138 }
4139 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
4140 {
4141 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4142 }
4143 else
4144 {
4145 fAcceptableCyphers = FALSE;
4146 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4147 }
4148 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
4149 {
4150 //Caller doesn't care about auth type, or BSS doesn't match
4151 break;
4152 }
4153 fAcceptableCyphers = FALSE;
4154 for( i = 0 ; i < pAuthType->numEntries; i++ )
4155 {
4156 if( pAuthType->authType[i] == negAuthType )
4157 {
4158 fAcceptableCyphers = TRUE;
4159 break;
4160 }
4161 }
4162 }
4163 }while (0);
4164
4165 if ( fAcceptableCyphers )
4166 {
4167 if ( MulticastCypher )
4168 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304169 vos_mem_copy(MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 }
4171
4172 if ( UnicastCypher )
4173 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304174 vos_mem_copy(UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 }
4176
4177 if ( AuthSuite )
4178 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304179 vos_mem_copy(AuthSuite, Authentication, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 }
4181
4182 if ( pNegotiatedAuthtype )
4183 {
4184 *pNegotiatedAuthtype = negAuthType;
4185 }
4186 }
4187 return( fAcceptableCyphers );
4188}
4189
4190tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4191 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
4192{
4193 tANI_BOOLEAN fWapiMatch = FALSE;
4194
4195 // See if the cyphers in the Bss description match with the settings in the profile.
4196 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4197 pNegotiatedAuthType, pNegotiatedMCCipher );
4198
4199 return( fWapiMatch );
4200}
4201
4202tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4203{
4204 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4205 tANI_U32 Index;
4206 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4207
Jeff Johnson32d95a32012-09-10 13:15:23 -07004208 if(!pSession)
4209 {
4210 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4211 return FALSE;
4212 }
4213
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 do
4215 {
4216 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4217 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004218 smsLog(pMac, LOGW, "match BKID "MAC_ADDRESS_STR" to ",
4219 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05304220 if (vos_mem_compare(pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 {
4222 // match found
4223 fMatchFound = TRUE;
4224 break;
4225 }
4226 }
4227
4228 if( !fMatchFound ) break;
4229
Kiet Lam64c1b492013-07-12 13:56:44 +05304230 vos_mem_copy(pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004231
4232 fRC = TRUE;
4233 }
4234 while( 0 );
4235 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4236
4237 return fRC;
4238}
4239
4240tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4241 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4242{
4243 tANI_BOOLEAN fWapiMatch = FALSE;
4244 tANI_U8 cbWapiIe = 0;
4245 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4246 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4247 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4248 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4249 tANI_U8 *pWapi = NULL;
4250 tANI_BOOLEAN fBKIDFound = FALSE;
4251 tDot11fBeaconIEs *pIesLocal = pIes;
4252
4253 do
4254 {
4255 if ( !csrIsProfileWapi( pProfile ) ) break;
4256
4257 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4258 {
4259 break;
4260 }
4261
4262 // See if the cyphers in the Bss description match with the settings in the profile.
4263 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4264 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4265 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4266 if ( !fWapiMatch ) break;
4267
Kiet Lam64c1b492013-07-12 13:56:44 +05304268 vos_mem_set(pWapiIe, sizeof(tCsrWapiIe), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004269
4270 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4271
4272 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4273
4274 pWapiIe->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304275 vos_mem_copy(&pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004276
4277 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4278
4279 *pWapi = (tANI_U16)1; //cUnicastCyphers
4280 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304281 vos_mem_copy(pWapi, UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 pWapi += sizeof( UnicastCypher );
4283
Kiet Lam64c1b492013-07-12 13:56:44 +05304284 vos_mem_copy(pWapi, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 pWapi += sizeof( MulticastCypher );
4286
4287
4288 // WAPI capabilities follows the Auth Suite (two octects)
4289 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4290 // & since we already did a memset pWapiIe to 0, skip these fields
4291 pWapi +=2;
4292
4293 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4294
4295
4296 if( fBKIDFound )
4297 {
4298 /* Do we need to change the endianness here */
4299 *pWapi = (tANI_U16)1; //cBKIDs
4300 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304301 vos_mem_copy(pWapi, BKId, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 }
4303 else
4304 {
4305 *pWapi = 0;
4306 pWapi+=1;
4307 *pWapi = 0;
4308 pWapi+=1;
4309 }
4310
4311 // Add in the IE fields except the IE header
4312 // Add BKID count and BKID (if any)
4313 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4314
4315 /*2 bytes for BKID Count field*/
4316 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4317
4318 if(fBKIDFound)
4319 {
4320 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4321 }
4322 // return the size of the IE header (total) constructed...
4323 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4324
4325 } while( 0 );
4326
4327 if( !pIes && pIesLocal )
4328 {
4329 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304330 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 }
4332
4333 return( cbWapiIe );
4334}
4335#endif /* FEATURE_WLAN_WAPI */
4336
4337tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4338 tDot11fIEWPA *pWpaIe,
4339 tANI_U8 *UnicastCypher,
4340 tANI_U8 *MulticastCypher,
4341 tANI_U8 *AuthSuite,
4342 eCsrAuthType *pNegotiatedAuthtype,
4343 eCsrEncryptionType *pNegotiatedMCCipher )
4344{
4345 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4346 tANI_U8 cUnicastCyphers = 0;
4347 tANI_U8 cMulticastCyphers = 0;
4348 tANI_U8 cAuthSuites = 0;
4349 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4350 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4351 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4352 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4353 tANI_U8 i;
4354 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4355
4356 do
4357 {
4358 if ( pWpaIe->present )
4359 {
4360 cMulticastCyphers = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304361 vos_mem_copy(MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4363 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4364
4365 //Check - Is requested Unicast Cipher supported by the BSS.
4366 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4367 csrGetOUIIndexFromCipher( enType ), Unicast );
4368
4369 if( !fAcceptableCyphers ) break;
4370
4371
4372 //Unicast is supported. Pick the first matching Group cipher, if any.
4373 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4374 {
4375 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4376 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4377 if(fAcceptableCyphers)
4378 {
4379 break;
4380 }
4381 }
4382 if( !fAcceptableCyphers ) break;
4383
4384 if( pNegotiatedMCCipher )
4385 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4386
4387 /* Initializing with FALSE as it has TRUE value already */
4388 fAcceptableCyphers = FALSE;
4389 for (i = 0 ; i < pAuthType->numEntries; i++)
4390 {
4391 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4392 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4393 {
4394 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4395 negAuthType = eCSR_AUTH_TYPE_WPA;
4396 }
4397 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4398 {
4399 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4400 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4401 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004402#ifdef FEATURE_WLAN_ESE
4403 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 {
4405 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4406 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4407 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004408#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004409
4410 // The 1st auth type in the APs WPA IE, to match stations connecting
4411 // profiles auth type will cause us to exit this loop
4412 // This is added as some APs advertise multiple akms in the WPA IE.
4413 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4414 {
4415 fAcceptableCyphers = TRUE;
4416 break;
4417 }
4418 } // for
4419 }
4420 }while(0);
4421
4422 if ( fAcceptableCyphers )
4423 {
4424 if ( MulticastCypher )
4425 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304426 vos_mem_copy((tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 }
4428
4429 if ( UnicastCypher )
4430 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304431 vos_mem_copy((tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 }
4433
4434 if ( AuthSuite )
4435 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304436 vos_mem_copy((tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 }
4438
4439 if( pNegotiatedAuthtype )
4440 {
4441 *pNegotiatedAuthtype = negAuthType;
4442 }
4443 }
4444
4445 return( fAcceptableCyphers );
4446}
4447
4448
4449
4450tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4451 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4452{
4453 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4454
4455 // See if the cyphers in the Bss description match with the settings in the profile.
4456 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4457
4458 return( fWpaMatch );
4459}
4460
4461
4462tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4463 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4464{
4465 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4466 tANI_BOOLEAN fWpaMatch;
4467 tANI_U8 cbWpaIe = 0;
4468 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4469 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4470 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4471 tCsrWpaAuthIe *pAuthSuite;
4472 tDot11fBeaconIEs *pIesLocal = pIes;
4473
4474 do
4475 {
4476 if ( !csrIsProfileWpa( pProfile ) ) break;
4477
4478 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4479 {
4480 break;
4481 }
4482 // See if the cyphers in the Bss description match with the settings in the profile.
4483 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4484 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4485 if ( !fWpaMatch ) break;
4486
4487 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4488
Kiet Lam64c1b492013-07-12 13:56:44 +05304489 vos_mem_copy(pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004490
4491 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4492
Kiet Lam64c1b492013-07-12 13:56:44 +05304493 vos_mem_copy(pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004494
4495 pWpaIe->cUnicastCyphers = 1;
4496
Kiet Lam64c1b492013-07-12 13:56:44 +05304497 vos_mem_copy(&pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004498
4499 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4500
4501 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304502 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004503
4504 // The WPA capabilities follows the Auth Suite (two octects)--
4505 // this field is optional, and we always "send" zero, so just
4506 // remove it. This is consistent with our assumptions in the
4507 // frames compiler; c.f. bug 15234:
4508 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4509
4510 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4511 // Add in the size of the Auth suite (count plus a single OUI)
4512 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4513 sizeof( *pAuthSuite );
4514
4515 // return the size of the IE header (total) constructed...
4516 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4517
4518 } while( 0 );
4519
4520 if( !pIes && pIesLocal )
4521 {
4522 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304523 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 }
4525
4526 return( cbWpaIe );
4527}
4528
4529
4530tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4531 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4532{
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 tDot11IEHeader *pIEHeader;
4534 tSirMacPropIE *pSirMacPropIE;
4535 tANI_U32 cbParsed;
4536 tANI_U32 cbIE;
4537 int cExpectedIEs = 0;
4538 int cFoundIEs = 0;
4539 int cbPropIETotal;
4540
4541 pIEHeader = (tDot11IEHeader *)pIes;
4542 if(pWpaIe) cExpectedIEs++;
4543 if(pRSNIe) cExpectedIEs++;
4544
4545 // bss description length includes all fields other than the length itself
4546 cbParsed = 0;
4547
4548 // Loop as long as there is data left in the IE of the Bss Description
4549 // and the number of Expected IEs is NOT found yet.
4550 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4551 {
4552 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4553
4554 if ( ( cbIE + cbParsed ) > len ) break;
4555
4556 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4557 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4558 {
4559 switch( pIEHeader->ElementID )
4560 {
4561 // Parse the 221 (0xdd) Proprietary IEs here...
4562 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4563 // Airgo proprietary IE information.
4564 case SIR_MAC_WPA_EID:
4565 {
4566 tANI_U32 aniOUI;
4567 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4568
4569 pOui++;
4570 aniOUI = ANI_OUI;
4571 aniOUI = i_ntohl( aniOUI );
4572
4573 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4574 cbPropIETotal = pSirMacPropIE->length;
4575
4576 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4577 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4578 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4579 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4580 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4581 {
4582 }
4583 else
4584 {
4585 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4586
4587 if(!pWpaIe || !pcbWpaIe) break;
4588 // Check if this is a valid WPA IE. Then check that the
4589 // WPA OUI is in place and the version is one that we support.
4590 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
Kiet Lam64c1b492013-07-12 13:56:44 +05304591 ( vos_mem_compare( pIe->Oui, (void *)csrWpaOui[1],
4592 sizeof( pIe->Oui ) ) ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4594 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304595 vos_mem_copy(pWpaIe, pIe,
4596 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4598 cFoundIEs++;
4599
4600 break;
4601 }
4602 }
4603
4604 break;
4605 }
4606
4607 case SIR_MAC_RSN_EID:
4608 {
4609 tCsrRSNIe *pIe;
4610
4611 if(!pcbRSNIe || !pRSNIe) break;
4612 pIe = (tCsrRSNIe *)pIEHeader;
4613
4614 // Check the length of the RSN Ie to assure it is valid. Then check that the
4615 // version is one that we support.
4616
4617 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4618 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4619
4620 cFoundIEs++;
4621
4622 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4623 // the buffer passed in.
4624 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05304625 vos_mem_copy(pRSNIe, pIe,
4626 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4628
4629 break;
4630 }
4631
4632 // Add support for other IE here...
4633 default:
4634 break;
4635 }
4636 }
4637
4638 cbParsed += cbIE;
4639
4640 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4641
4642 }
4643
4644 // return a BOOL that tells if all of the IEs asked for were found...
4645 return( cFoundIEs == cExpectedIEs );
4646}
4647
4648
4649//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4650//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4651tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4652 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4653{
4654 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4655 tANI_U8 cbWpaIe = 0;
4656
4657 do
4658 {
4659 if ( !csrIsProfileWpa( pProfile ) ) break;
4660 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4661 {
4662 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4663 {
4664 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304665 vos_mem_copy(pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004666 }
4667 else
4668 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004669 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 }
4671 }
4672 else
4673 {
4674 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4675 }
4676 }while(0);
4677
4678 return (cbWpaIe);
4679}
4680
4681
4682//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4683//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4684tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4685 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4686{
4687 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4688 tANI_U8 cbRsnIe = 0;
4689
4690 do
4691 {
4692 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004693#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304694 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004695 {
4696 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4697 // scratch. So it contains the current PMK-IDs
4698 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4699 }
4700 else
4701#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 if(pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
4703 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004704 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4706 {
4707 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304708 vos_mem_copy(pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 }
4710 else
4711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004712 smsLog(pMac, LOGW, " csrRetrieveRsnIe detect invalid RSN IE length (%d) ", pProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 }
4714 }
4715 else
4716 {
4717 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4718 }
4719 }while(0);
4720
4721 return (cbRsnIe);
4722}
4723
4724
4725#ifdef FEATURE_WLAN_WAPI
4726//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
4727//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
4728tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
4729 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4730 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4731{
4732 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4733 tANI_U8 cbWapiIe = 0;
4734
4735 do
4736 {
4737 if ( !csrIsProfileWapi( pProfile ) ) break;
4738 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
4739 {
4740 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
4741 {
4742 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304743 vos_mem_copy(pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 }
4745 else
4746 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004747 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 }
4749 }
4750 else
4751 {
4752 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
4753 }
4754 }while(0);
4755
4756 return (cbWapiIe);
4757}
4758#endif /* FEATURE_WLAN_WAPI */
4759
4760tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
4761{
4762 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4763 tListElem *pEntry;
4764 tANI_U16 i;
4765 tANI_U16 startingChannel;
4766 tANI_BOOLEAN found = FALSE;
4767 tCsrChannelSet *pChannelGroup;
4768
4769 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
4770
4771 while ( pEntry )
4772 {
4773 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
4774 startingChannel = pChannelGroup->firstChannel;
4775 for ( i = 0; i < pChannelGroup->numChannels; i++ )
4776 {
4777 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
4778 {
4779 found = TRUE;
4780 break;
4781 }
4782 }
4783
4784 if ( found )
4785 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304786 vos_mem_copy(returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 break;
4788 }
4789 else
4790 {
4791 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
4792 }
4793 }
4794
4795 return( found );
4796}
4797
4798tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
4799{
4800 tANI_BOOLEAN fSupported = FALSE;
4801 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4802
4803 switch ( nonBasicRate )
4804 {
4805 case eCsrSuppRate_1Mbps:
4806 case eCsrSuppRate_2Mbps:
4807 case eCsrSuppRate_5_5Mbps:
4808 case eCsrSuppRate_11Mbps:
4809 fSupported = TRUE;
4810 break;
4811
4812 default:
4813 break;
4814 }
4815
4816 return( fSupported );
4817}
4818
4819tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
4820{
4821 tANI_BOOLEAN fSupported = FALSE;
4822 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4823
4824 switch ( nonBasicRate )
4825 {
4826 case eCsrSuppRate_6Mbps:
4827 case eCsrSuppRate_9Mbps:
4828 case eCsrSuppRate_12Mbps:
4829 case eCsrSuppRate_18Mbps:
4830 case eCsrSuppRate_24Mbps:
4831 case eCsrSuppRate_36Mbps:
4832 case eCsrSuppRate_48Mbps:
4833 case eCsrSuppRate_54Mbps:
4834 fSupported = TRUE;
4835 break;
4836
4837 default:
4838 break;
4839 }
4840
4841 return( fSupported );
4842}
4843
4844
4845
4846tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
4847{
4848 tAniEdType edType;
4849
4850 switch ( EncryptType )
4851 {
4852 default:
4853 case eCSR_ENCRYPT_TYPE_NONE:
4854 edType = eSIR_ED_NONE;
4855 break;
4856
4857 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4858 case eCSR_ENCRYPT_TYPE_WEP40:
4859 edType = eSIR_ED_WEP40;
4860 break;
4861
4862 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4863 case eCSR_ENCRYPT_TYPE_WEP104:
4864 edType = eSIR_ED_WEP104;
4865 break;
4866
4867 case eCSR_ENCRYPT_TYPE_TKIP:
4868 edType = eSIR_ED_TKIP;
4869 break;
4870
4871 case eCSR_ENCRYPT_TYPE_AES:
4872 edType = eSIR_ED_CCMP;
4873 break;
4874#ifdef FEATURE_WLAN_WAPI
4875 case eCSR_ENCRYPT_TYPE_WPI:
4876 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05304877 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004878#endif
4879#ifdef WLAN_FEATURE_11W
4880 //11w BIP
4881 case eCSR_ENCRYPT_TYPE_AES_CMAC:
4882 edType = eSIR_ED_AES_128_CMAC;
4883 break;
4884#endif
4885 }
4886
4887 return( edType );
4888}
4889
4890
4891//pIes can be NULL
4892tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
4893 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
4894 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
4895 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
4896{
4897 tANI_U32 idx;
4898 tANI_BOOLEAN fMatch = FALSE;
4899 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4900 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4901
4902 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
4903
4904 do
4905 {
4906 //If privacy bit is not set, consider no match
4907 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
4908
4909 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
4910 {
4911 switch( pMCEncryptionList->encryptionType[idx] )
4912 {
4913 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4914 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4915 case eCSR_ENCRYPT_TYPE_WEP40:
4916 case eCSR_ENCRYPT_TYPE_WEP104:
4917 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
4918 */
4919 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
4920 {
4921 fMatch = TRUE;
4922 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
4923 }
4924 break;
4925 default:
4926 fMatch = FALSE;
4927 break;
4928 }
4929 if(fMatch) break;
4930 }
4931
4932 if(!fMatch) break;
4933
4934 for( idx = 0; idx < pAuthList->numEntries; idx++ )
4935 {
4936 switch( pAuthList->authType[idx] )
4937 {
4938 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4939 case eCSR_AUTH_TYPE_SHARED_KEY:
4940 case eCSR_AUTH_TYPE_AUTOSWITCH:
4941 fMatch = TRUE;
4942 negotiatedAuth = pAuthList->authType[idx];
4943 break;
4944 default:
4945 fMatch = FALSE;
4946 }
4947 if (fMatch) break;
4948 }
4949
4950 if(!fMatch) break;
4951 //In case of WPA / WPA2, check whether it supports WEP as well
4952 if(pIes)
4953 {
4954 //Prepare the encryption type for WPA/WPA2 functions
4955 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
4956 {
4957 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4958 }
4959 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
4960 {
4961 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4962 }
4963 //else we can use the encryption type directly
Kiet Lam64c1b492013-07-12 13:56:44 +05304964 if ( pIes->WPA.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304966 fMatch = vos_mem_compare(pIes->WPA.multicast_cipher,
4967 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
4968 CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 if( fMatch ) break;
4970 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304971 if ( pIes->RSN.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304973 fMatch = vos_mem_compare(pIes->RSN.gp_cipher_suite,
4974 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
4975 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 }
4977 }
4978
4979 }while(0);
4980
4981 if( fMatch )
4982 {
4983 if( pNegotiatedAuthType )
4984 *pNegotiatedAuthType = negotiatedAuth;
4985
4986 if( pNegotiatedMCEncryption )
4987 *pNegotiatedMCEncryption = negotiatedMCCipher;
4988 }
4989
4990
4991 return fMatch;
4992}
4993
4994
4995//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05304996tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType,
4997 tCsrEncryptionList *pUCEncryptionType,
4998 tCsrEncryptionList *pMCEncryptionType,
4999 tANI_BOOLEAN *pMFPEnabled,
5000 tANI_U8 *pMFPRequired, tANI_U8 *pMFPCapable,
5001 tSirBssDescription *pSirBssDesc,
5002 tDot11fBeaconIEs *pIes,
5003 eCsrAuthType *negotiatedAuthtype,
5004 eCsrEncryptionType *negotiatedUCCipher,
5005 eCsrEncryptionType *negotiatedMCCipher )
Jeff Johnson295189b2012-06-20 16:38:30 -07005006{
5007 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5008 tANI_BOOLEAN fMatch = FALSE;
5009 tANI_U8 i,idx;
5010 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
5011 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
5012
5013 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
5014 {
5015 ucCipher = pUCEncryptionType->encryptionType[i];
5016 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
5017 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
5018 // encryption type.
5019 switch ( ucCipher )
5020 {
5021 case eCSR_ENCRYPT_TYPE_NONE:
5022 {
5023 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
5024 // required so we have to reject this Bss.
5025 if ( csrIsPrivacy( pSirBssDesc ) )
5026 {
5027 fMatch = FALSE;
5028 }
5029 else
5030 {
5031 fMatch = TRUE;
5032 }
5033
5034 if ( fMatch )
5035 {
5036 fMatch = FALSE;
5037 //Check Multicast cipher requested and Auth type requested.
5038 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
5039 {
5040 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
5041 {
5042 fMatch = TRUE; //Multicast can only be none.
5043 mcCipher = pMCEncryptionType->encryptionType[idx];
5044 break;
5045 }
5046 }
5047 if (!fMatch) break;
5048
5049 fMatch = FALSE;
5050 //Check Auth list. It should contain AuthOpen.
5051 for( idx = 0 ; idx < authType->numEntries ; idx++ )
5052 {
5053 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
5054 {
5055 fMatch = TRUE;
5056 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5057 break;
5058 }
5059 }
5060 if (!fMatch) break;
5061
5062 }
5063 break;
5064 }
5065
5066 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5067 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5068 // !! might want to check for WEP keys set in the Profile.... ?
5069 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
5070 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
5071 // encryption is not allowed without the Privacy bit turned on.
5072 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5073
5074 break;
5075
5076 // these are all of the WPA encryption types...
5077 case eCSR_ENCRYPT_TYPE_WEP40:
5078 case eCSR_ENCRYPT_TYPE_WEP104:
5079 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
5080 break;
5081
5082 case eCSR_ENCRYPT_TYPE_TKIP:
5083 case eCSR_ENCRYPT_TYPE_AES:
5084 {
5085 if(pIes)
5086 {
5087 // First check if there is a RSN match
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305088 fMatch = csrIsRSNMatch( pMac, authType, ucCipher,
5089 pMCEncryptionType, pMFPEnabled,
5090 pMFPRequired, pMFPCapable,
5091 pIes, &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 if( !fMatch )
5093 {
5094 // If not RSN, then check if there is a WPA match
5095 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
5096 &negAuthType, &mcCipher );
5097 }
5098 }
5099 else
5100 {
5101 fMatch = FALSE;
5102 }
5103 break;
5104 }
5105#ifdef FEATURE_WLAN_WAPI
5106 case eCSR_ENCRYPT_TYPE_WPI://WAPI
5107 {
5108 if(pIes)
5109 {
5110 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5111 }
5112 else
5113 {
5114 fMatch = FALSE;
5115 }
5116 break;
5117 }
5118#endif /* FEATURE_WLAN_WAPI */
5119 case eCSR_ENCRYPT_TYPE_ANY:
5120 default:
5121 {
5122 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
5123
5124 fMatch = eANI_BOOLEAN_TRUE;
5125 //It is allowed to match anything. Try the more secured ones first.
5126 if(pIes)
5127 {
5128 //Check AES first
5129 ucCipher = eCSR_ENCRYPT_TYPE_AES;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305130 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5131 pMCEncryptionType, pMFPEnabled,
5132 pMFPRequired, pMFPCapable, pIes,
5133 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 if(!fMatchAny)
5135 {
5136 //Check TKIP
5137 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305138 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher,
5139 pMCEncryptionType,
5140 pMFPEnabled, pMFPRequired,
5141 pMFPCapable, pIes,
5142 &negAuthType, &mcCipher );
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 }
5144#ifdef FEATURE_WLAN_WAPI
5145 if(!fMatchAny)
5146 {
5147 //Check WAPI
5148 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
5149 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
5150 }
5151#endif /* FEATURE_WLAN_WAPI */
5152 }
5153 if(!fMatchAny)
5154 {
5155 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
5156 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5157 {
5158 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
5159 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5160 {
5161 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5162 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5163 {
5164 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5165 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
5166 {
5167 //It must be open and no encryption
5168 if ( csrIsPrivacy( pSirBssDesc ) )
5169 {
5170 //This is not right
5171 fMatch = eANI_BOOLEAN_FALSE;
5172 }
5173 else
5174 {
5175 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5176 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
5177 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
5178 }
5179 }
5180 }
5181 }
5182 }
5183 }
5184 break;
5185 }
5186 }
5187
5188 }
5189
5190 if( fMatch )
5191 {
5192 if( negotiatedUCCipher )
5193 *negotiatedUCCipher = ucCipher;
5194
5195 if( negotiatedMCCipher )
5196 *negotiatedMCCipher = mcCipher;
5197
5198 if( negotiatedAuthtype )
5199 *negotiatedAuthtype = negAuthType;
5200 }
5201
5202 return( fMatch );
5203}
5204
5205
5206tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
5207 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
5208{
5209 tANI_BOOLEAN fMatch = FALSE;
5210
5211 do {
Padma, Santhosh Kumara43e06c2015-05-21 14:58:13 +05305212 // Check for the specification of the Broadcast SSID at the beginning
5213 // of the list. If specified, then all SSIDs are matches
5214 // (broadcast SSID means accept all SSIDs).
5215 if ( ssid1Len == 0 )
5216 {
5217 fMatch = TRUE;
5218 break;
5219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005220
5221 // There are a few special cases. If the Bss description has a Broadcast SSID,
5222 // then our Profile must have a single SSID without Wildcards so we can program
5223 // the SSID.
5224 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5225 // but the SSID value is all NULL characters. That condition is trated same
5226 // as NULL SSID
5227 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5228 {
5229 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5230 {
5231 fMatch = TRUE;
5232 }
5233 break;
5234 }
5235
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 if(ssid1Len != bssSsidLen) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05305237 if (vos_mem_compare(bssSsid, ssid1, bssSsidLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 {
5239 fMatch = TRUE;
5240 break;
5241 }
5242
5243 } while( 0 );
5244
5245 return( fMatch );
5246}
5247
5248
5249//Null ssid means match
5250tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5251{
Jeff Johnson295189b2012-06-20 16:38:30 -07005252 tANI_BOOLEAN fMatch = FALSE;
5253 tANI_U32 i;
5254
5255 if ( pSsidList && pSsid )
5256 {
5257 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5258 {
5259 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
Kiet Lam64c1b492013-07-12 13:56:44 +05305260 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5261 vos_mem_compare(pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 {
5263 fMatch = TRUE;
5264 break;
5265 }
5266 }
5267 }
5268
5269 return (fMatch);
5270}
5271
5272//like to use sirCompareMacAddr
5273tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5274{
5275 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5276
Kiet Lam64c1b492013-07-12 13:56:44 +05305277 return (vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005278}
5279
5280//like to use sirCompareMacAddr
5281tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5282{
5283 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5284
Kiet Lam64c1b492013-07-12 13:56:44 +05305285 return(vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005286}
5287
5288
5289//like to use sirCompareMacAddr
5290tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5291{
Kiet Lam64c1b492013-07-12 13:56:44 +05305292 return(vos_mem_compare(pMacAddr1, pMacAddr2, sizeof(tCsrBssid)));
Jeff Johnson295189b2012-06-20 16:38:30 -07005293}
5294
5295
5296tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5297{
5298 tANI_BOOLEAN fMatch = FALSE;
5299 tCsrBssid ProfileBssid;
5300 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5301
5302 // for efficiency of the MAC_ADDRESS functions, move the
5303 // Bssid's into MAC_ADDRESS structs.
Kiet Lam64c1b492013-07-12 13:56:44 +05305304 vos_mem_copy(&ProfileBssid, pProfBssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005305
5306 do {
5307
5308 // Give the profile the benefit of the doubt... accept either all 0 or
5309 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5310 // match any Bssids).
5311 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5312 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5313 {
5314 fMatch = TRUE;
5315 break;
5316 }
5317
5318 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5319 {
5320 fMatch = TRUE;
5321 break;
5322 }
5323
5324 } while( 0 );
5325
5326 return( fMatch );
5327}
5328
5329
5330tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5331{
5332 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5333 return eANI_BOOLEAN_FALSE;
5334 else
5335 return eANI_BOOLEAN_TRUE;
5336}
5337
5338
5339tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5340{
5341 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5342}
5343
5344tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5345{
5346 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5347}
5348
5349tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5350{
5351 tANI_BOOLEAN fMatch = TRUE;
5352
5353 do
5354 {
5355 switch( bssType )
5356 {
5357 case eCSR_BSS_TYPE_ANY:
5358 break;
5359
5360 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5361 case eCSR_BSS_TYPE_WDS_STA:
5362 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5363 fMatch = FALSE;
5364
5365 break;
5366
5367 case eCSR_BSS_TYPE_IBSS:
5368 case eCSR_BSS_TYPE_START_IBSS:
5369 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5370 fMatch = FALSE;
5371
5372 break;
5373
5374 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5375 default:
5376 fMatch = FALSE;
5377 break;
5378 }
5379 }
5380 while( 0 );
5381
5382
5383 return( fMatch );
5384}
5385
5386static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5387{
5388 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5389}
5390
5391
5392
5393static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5394{
5395 tANI_BOOLEAN fMatch = TRUE;
5396
5397 do
5398 {
5399 // if the channel is ANY, then always match...
5400 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5401 if ( Channel == pSirBssDesc->channelId ) break;
5402
5403 // didn't match anything.. so return NO match
5404 fMatch = FALSE;
5405
5406 } while( 0 );
5407
5408 return( fMatch );
5409}
5410
5411
5412tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5413{
5414 tANI_BOOLEAN fMatch = TRUE;
5415
5416 do
5417 {
5418 // if the profile says Any channel AND the global settings says ANY channel, then we
5419 // always match...
5420 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5421
5422 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5423 {
5424 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5425 }
5426
5427 } while( 0 );
5428
5429 return( fMatch );
5430}
5431
5432
5433/**
5434 * \brief Enquire as to whether a given rate is supported by the
5435 * adapter as currently configured
5436 *
5437 *
5438 * \param nRate A rate in units of 500kbps
5439 *
5440 * \return TRUE if the adapter is currently capable of supporting this
5441 * rate, FALSE else
5442 *
5443 *
5444 * The rate encoding is just as in 802.11 Information Elements, except
5445 * that the high bit is \em not interpreted as indicating a Basic Rate,
5446 * and proprietary rates are allowed, too.
5447 *
5448 * Note that if the adapter's dot11Mode is g, we don't restrict the
5449 * rates. According to hwReadEepromParameters, this will happen when:
5450 *
5451 * ... the card is configured for ALL bands through the property
5452 * page. If this occurs, and the card is not an ABG card ,then this
5453 * code is setting the dot11Mode to assume the mode that the
5454 * hardware can support. For example, if the card is an 11BG card
5455 * and we are configured to support ALL bands, then we change the
5456 * dot11Mode to 11g because ALL in this case is only what the
5457 * hardware can support.
5458 *
5459 *
5460 */
5461
5462static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5463{
5464 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5465 tANI_U16 idx, newRate;
5466
5467 //In case basic rate flag is set
5468 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5469 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5470 {
5471 switch ( newRate )
5472 {
5473 case eCsrSuppRate_6Mbps:
5474 case eCsrSuppRate_9Mbps:
5475 case eCsrSuppRate_12Mbps:
5476 case eCsrSuppRate_18Mbps:
5477 case eCsrSuppRate_24Mbps:
5478 case eCsrSuppRate_36Mbps:
5479 case eCsrSuppRate_48Mbps:
5480 case eCsrSuppRate_54Mbps:
5481 fSupported = TRUE;
5482 break;
5483 default:
5484 fSupported = FALSE;
5485 break;
5486 }
5487
5488 }
5489 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5490 {
5491 switch ( newRate )
5492 {
5493 case eCsrSuppRate_1Mbps:
5494 case eCsrSuppRate_2Mbps:
5495 case eCsrSuppRate_5_5Mbps:
5496 case eCsrSuppRate_11Mbps:
5497 fSupported = TRUE;
5498 break;
5499 default:
5500 fSupported = FALSE;
5501 break;
5502 }
5503 }
5504 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5505 {
5506
5507 switch ( newRate )
5508 {
5509 case eCsrSuppRate_1Mbps:
5510 case eCsrSuppRate_2Mbps:
5511 case eCsrSuppRate_5_5Mbps:
5512 case eCsrSuppRate_6Mbps:
5513 case eCsrSuppRate_9Mbps:
5514 case eCsrSuppRate_11Mbps:
5515 case eCsrSuppRate_12Mbps:
5516 case eCsrSuppRate_18Mbps:
5517 case eCsrSuppRate_24Mbps:
5518 case eCsrSuppRate_36Mbps:
5519 case eCsrSuppRate_48Mbps:
5520 case eCsrSuppRate_54Mbps:
5521 fSupported = TRUE;
5522 break;
5523 default:
5524 fSupported = FALSE;
5525 break;
5526 }
5527
5528 }
5529 else {
5530
5531 if ( eCsrSuppRate_1Mbps == newRate ||
5532 eCsrSuppRate_2Mbps == newRate ||
5533 eCsrSuppRate_5_5Mbps == newRate ||
5534 eCsrSuppRate_11Mbps == newRate )
5535 {
5536 fSupported = TRUE;
5537 }
5538 else {
5539 idx = 0x1;
5540
5541 switch ( newRate )
5542 {
5543 case eCsrSuppRate_6Mbps:
5544 fSupported = gPhyRatesSuppt[0][idx];
5545 break;
5546 case eCsrSuppRate_9Mbps:
5547 fSupported = gPhyRatesSuppt[1][idx];
5548 break;
5549 case eCsrSuppRate_12Mbps:
5550 fSupported = gPhyRatesSuppt[2][idx];
5551 break;
5552 case eCsrSuppRate_18Mbps:
5553 fSupported = gPhyRatesSuppt[3][idx];
5554 break;
5555 case eCsrSuppRate_20Mbps:
5556 fSupported = gPhyRatesSuppt[4][idx];
5557 break;
5558 case eCsrSuppRate_24Mbps:
5559 fSupported = gPhyRatesSuppt[5][idx];
5560 break;
5561 case eCsrSuppRate_36Mbps:
5562 fSupported = gPhyRatesSuppt[6][idx];
5563 break;
5564 case eCsrSuppRate_40Mbps:
5565 fSupported = gPhyRatesSuppt[7][idx];
5566 break;
5567 case eCsrSuppRate_42Mbps:
5568 fSupported = gPhyRatesSuppt[8][idx];
5569 break;
5570 case eCsrSuppRate_48Mbps:
5571 fSupported = gPhyRatesSuppt[9][idx];
5572 break;
5573 case eCsrSuppRate_54Mbps:
5574 fSupported = gPhyRatesSuppt[10][idx];
5575 break;
5576 case eCsrSuppRate_72Mbps:
5577 fSupported = gPhyRatesSuppt[11][idx];
5578 break;
5579 case eCsrSuppRate_80Mbps:
5580 fSupported = gPhyRatesSuppt[12][idx];
5581 break;
5582 case eCsrSuppRate_84Mbps:
5583 fSupported = gPhyRatesSuppt[13][idx];
5584 break;
5585 case eCsrSuppRate_96Mbps:
5586 fSupported = gPhyRatesSuppt[14][idx];
5587 break;
5588 case eCsrSuppRate_108Mbps:
5589 fSupported = gPhyRatesSuppt[15][idx];
5590 break;
5591 case eCsrSuppRate_120Mbps:
5592 fSupported = gPhyRatesSuppt[16][idx];
5593 break;
5594 case eCsrSuppRate_126Mbps:
5595 fSupported = gPhyRatesSuppt[17][idx];
5596 break;
5597 case eCsrSuppRate_144Mbps:
5598 fSupported = gPhyRatesSuppt[18][idx];
5599 break;
5600 case eCsrSuppRate_160Mbps:
5601 fSupported = gPhyRatesSuppt[19][idx];
5602 break;
5603 case eCsrSuppRate_168Mbps:
5604 fSupported = gPhyRatesSuppt[20][idx];
5605 break;
5606 case eCsrSuppRate_192Mbps:
5607 fSupported = gPhyRatesSuppt[21][idx];
5608 break;
5609 case eCsrSuppRate_216Mbps:
5610 fSupported = gPhyRatesSuppt[22][idx];
5611 break;
5612 case eCsrSuppRate_240Mbps:
5613 fSupported = gPhyRatesSuppt[23][idx];
5614 break;
5615 default:
5616 fSupported = FALSE;
5617 break;
5618 }
5619 }
5620 }
5621
5622 return fSupported;
5623}
5624
5625
5626
5627static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5628 tDot11fIESuppRates *pBssSuppRates,
5629 tDot11fIEExtSuppRates *pBssExtSuppRates )
5630{
5631 tANI_BOOLEAN fMatch = TRUE;
5632 tANI_U32 i;
5633
5634
5635 // Validate that all of the Basic rates advertised in the Bss description are supported.
5636 if ( pBssSuppRates )
5637 {
5638 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5639 {
5640 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5641 {
5642 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5643 {
5644 fMatch = FALSE;
5645 break;
5646 }
5647 }
5648 }
5649 }
5650
5651 if ( fMatch && pBssExtSuppRates )
5652 {
5653 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5654 {
5655 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5656 {
5657 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5658 {
5659 fMatch = FALSE;
5660 break;
5661 }
5662 }
5663 }
5664 }
5665
5666 return( fMatch );
5667
5668}
5669
5670
5671//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
5672tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
5673 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
5674 tDot11fBeaconIEs **ppIes)
5675{
5676 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5677 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5678 tANI_U32 i;
5679 tDot11fBeaconIEs *pIes = NULL;
5680 tANI_U8 *pb;
5681
5682 do {
5683 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
5684 {
5685 //If no IEs passed in, get our own.
5686 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
5687 {
5688 break;
5689 }
5690 }
5691 else
5692 {
5693 //Save the one pass in for local use
5694 pIes = *ppIes;
5695 }
5696
5697 //Check if caller wants P2P
5698 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
5699 if(!fCheck) break;
5700
5701 if(pIes->SSID.present)
5702 {
5703 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
5704 {
5705 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
5706 pIes->SSID.ssid,
5707 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
5708 if ( fCheck ) break;
5709 }
5710 if(!fCheck) break;
5711 }
5712 fCheck = eANI_BOOLEAN_TRUE;
5713 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
5714 {
5715 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
5716 if ( fCheck ) break;
5717
5718 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
5719 {
5720 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
5721 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
5722
5723 if ( fCheck ) break;
5724 }
5725 }
5726 if(!fCheck) break;
5727
5728 fCheck = eANI_BOOLEAN_TRUE;
5729 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
5730 {
5731 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
5732 if ( fCheck ) break;
5733 }
5734 if(!fCheck)
5735 break;
5736#if defined WLAN_FEATURE_VOWIFI
5737 /* If this is for measurement filtering */
5738 if( pFilter->fMeasurement )
5739 {
5740 fRC = eANI_BOOLEAN_TRUE;
5741 break;
5742 }
5743#endif
5744 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07005745 if ( (!pFilter->bWPSAssociation) && (!pFilter->bOSENAssociation) &&
Abhishek Singh658d4de2014-06-26 10:53:15 +05305746#ifdef WLAN_FEATURE_11W
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305747 !csrIsSecurityMatch( pMac, &pFilter->authType,
5748 &pFilter->EncryptionType,
5749 &pFilter->mcEncryptionType,
5750 &pFilter->MFPEnabled,
5751 &pFilter->MFPRequired,
5752 &pFilter->MFPCapable,
5753 pBssDesc, pIes, pNegAuth,
Abhishek Singh658d4de2014-06-26 10:53:15 +05305754 pNegUc, pNegMc )
5755#else
5756 !csrIsSecurityMatch( pMac, &pFilter->authType,
5757 &pFilter->EncryptionType,
5758 &pFilter->mcEncryptionType,
5759 NULL, NULL, NULL,
5760 pBssDesc, pIes, pNegAuth,
5761 pNegUc, pNegMc )
5762#endif
5763 ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
5765 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
5766 //Tush-QoS: validate first if asked for APSD or WMM association
5767 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
5768 !CSR_IS_QOS_BSS(pIes) )
5769 break;
5770 //Check country. check even when pb is NULL because we may want to make sure
5771 //AP has a country code in it if fEnforceCountryCodeMatch is set.
5772 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
5773
5774 fCheck = csrMatchCountryCode( pMac, pb, pIes );
5775 if(!fCheck)
5776 break;
5777
5778#ifdef WLAN_FEATURE_VOWIFI_11R
Hema Aparna Medicharlaf9dec8d2015-04-29 12:37:06 +05305779 if (pFilter->MDID.mdiePresent && csrRoamIs11rAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 {
5781 if (pBssDesc->mdiePresent)
5782 {
5783 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
5784 break;
5785 }
5786 else
5787 break;
5788 }
5789#endif
5790 fRC = eANI_BOOLEAN_TRUE;
5791
5792 } while( 0 );
5793 if( ppIes )
5794 {
5795 *ppIes = pIes;
5796 }
5797 else if( pIes )
5798 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305799 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 }
5801
5802 return( fRC );
5803}
5804
5805tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
5806 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
5807{
5808 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
5809 tCsrAuthList authList;
5810
5811 ucEncryptionList.numEntries = 1;
5812 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
5813
5814 mcEncryptionList.numEntries = 1;
5815 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
5816
5817 authList.numEntries = 1;
5818 authList.authType[0] = pProfile->AuthType;
5819
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05305820 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList,
5821 &mcEncryptionList, NULL, NULL, NULL,
5822 pBssDesc, pIes, NULL, NULL, NULL ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005823
5824}
5825
5826
5827tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
5828 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
5829{
5830 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5831 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5832 tDot11fBeaconIEs *pIesLocal = pIes;
5833
5834 do {
5835 if( !pIes )
5836 {
5837 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
5838 {
5839 break;
5840 }
5841 }
5842 fCheck = eANI_BOOLEAN_TRUE;
5843 if(pIesLocal->SSID.present)
5844 {
5845 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
5846 if(pProfile->SSID.length)
5847 {
5848 fCheckSsid = eANI_BOOLEAN_TRUE;
5849 }
5850 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
5851 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
5852 if(!fCheck) break;
5853 }
5854 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
5855 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
5856 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
5857 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
5858 if(!fCheck)
5859 break;
5860
5861 fRC = eANI_BOOLEAN_TRUE;
5862
5863 } while( 0 );
5864
5865 if( !pIes && pIesLocal )
5866 {
5867 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305868 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 }
5870
5871 return( fRC );
5872}
5873
5874
5875
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05305876void csrAddRateBitmap(tANI_U8 rate, tANI_U16 *pRateBitmap)
5877{
5878 tANI_U16 rateBitmap;
5879 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
5880 rateBitmap = *pRateBitmap;
5881 switch(n)
5882 {
5883 case SIR_MAC_RATE_1:
5884 rateBitmap |= SIR_MAC_RATE_1_BITMAP;
5885 break;
5886 case SIR_MAC_RATE_2:
5887 rateBitmap |= SIR_MAC_RATE_2_BITMAP;
5888 break;
5889 case SIR_MAC_RATE_5_5:
5890 rateBitmap |= SIR_MAC_RATE_5_5_BITMAP;
5891 break;
5892 case SIR_MAC_RATE_11:
5893 rateBitmap |= SIR_MAC_RATE_11_BITMAP;
5894 break;
5895 case SIR_MAC_RATE_6:
5896 rateBitmap |= SIR_MAC_RATE_6_BITMAP;
5897 break;
5898 case SIR_MAC_RATE_9:
5899 rateBitmap |= SIR_MAC_RATE_9_BITMAP;
5900 break;
5901 case SIR_MAC_RATE_12:
5902 rateBitmap |= SIR_MAC_RATE_12_BITMAP;
5903 break;
5904 case SIR_MAC_RATE_18:
5905 rateBitmap |= SIR_MAC_RATE_18_BITMAP;
5906 break;
5907 case SIR_MAC_RATE_24:
5908 rateBitmap |= SIR_MAC_RATE_24_BITMAP;
5909 break;
5910 case SIR_MAC_RATE_36:
5911 rateBitmap |= SIR_MAC_RATE_36_BITMAP;
5912 break;
5913 case SIR_MAC_RATE_48:
5914 rateBitmap |= SIR_MAC_RATE_48_BITMAP;
5915 break;
5916 case SIR_MAC_RATE_54:
5917 rateBitmap |= SIR_MAC_RATE_54_BITMAP;
5918 break;
5919 }
5920 *pRateBitmap = rateBitmap;
5921}
5922
5923
5924
5925tANI_BOOLEAN csrIsRateAlreadyPresent(tANI_U8 rate, tANI_U16 rateBitmap)
5926{
5927 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
5928
5929 switch(n)
5930 {
5931 case SIR_MAC_RATE_1:
5932 rateBitmap &= SIR_MAC_RATE_1_BITMAP;
5933 break;
5934 case SIR_MAC_RATE_2:
5935 rateBitmap &= SIR_MAC_RATE_2_BITMAP;
5936 break;
5937 case SIR_MAC_RATE_5_5:
5938 rateBitmap &= SIR_MAC_RATE_5_5_BITMAP;
5939 break;
5940 case SIR_MAC_RATE_11:
5941 rateBitmap &= SIR_MAC_RATE_11_BITMAP;
5942 break;
5943 case SIR_MAC_RATE_6:
5944 rateBitmap &= SIR_MAC_RATE_6_BITMAP;
5945 break;
5946 case SIR_MAC_RATE_9:
5947 rateBitmap &= SIR_MAC_RATE_9_BITMAP;
5948 break;
5949 case SIR_MAC_RATE_12:
5950 rateBitmap &= SIR_MAC_RATE_12_BITMAP;
5951 break;
5952 case SIR_MAC_RATE_18:
5953 rateBitmap &= SIR_MAC_RATE_18_BITMAP;
5954 break;
5955 case SIR_MAC_RATE_24:
5956 rateBitmap &= SIR_MAC_RATE_24_BITMAP;
5957 break;
5958 case SIR_MAC_RATE_36:
5959 rateBitmap &= SIR_MAC_RATE_36_BITMAP;
5960 break;
5961 case SIR_MAC_RATE_48:
5962 rateBitmap &= SIR_MAC_RATE_48_BITMAP;
5963 break;
5964 case SIR_MAC_RATE_54:
5965 rateBitmap &= SIR_MAC_RATE_54_BITMAP;
5966 break;
5967 }
5968 return !!rateBitmap;
5969}
5970
5971
5972
Jeff Johnson295189b2012-06-20 16:38:30 -07005973tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
5974{
5975 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5976 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
5977
5978 return csrIsAggregateRateSupported( pMac, n );
5979}
5980
5981
5982tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
5983{
5984 tANI_U16 ConvertedRate = Rate;
5985
5986 switch( Rate )
5987 {
5988 case SIR_MAC_RATE_1:
5989 ConvertedRate = 2;
5990 break;
5991 case SIR_MAC_RATE_2:
5992 ConvertedRate = 4;
5993 break;
5994 case SIR_MAC_RATE_5_5:
5995 ConvertedRate = 11;
5996 break;
5997 case SIR_MAC_RATE_11:
5998 ConvertedRate = 22;
5999 break;
6000
6001 case SIR_MAC_RATE_6:
6002 ConvertedRate = 12;
6003 break;
6004 case SIR_MAC_RATE_9:
6005 ConvertedRate = 18;
6006 break;
6007 case SIR_MAC_RATE_12:
6008 ConvertedRate = 24;
6009 break;
6010 case SIR_MAC_RATE_18:
6011 ConvertedRate = 36;
6012 break;
6013 case SIR_MAC_RATE_24:
6014 ConvertedRate = 48;
6015 break;
6016 case SIR_MAC_RATE_36:
6017 ConvertedRate = 72;
6018 break;
6019 case SIR_MAC_RATE_42:
6020 ConvertedRate = 84;
6021 break;
6022 case SIR_MAC_RATE_48:
6023 ConvertedRate = 96;
6024 break;
6025 case SIR_MAC_RATE_54:
6026 ConvertedRate = 108;
6027 break;
6028
6029 case SIR_MAC_RATE_72:
6030 ConvertedRate = 144;
6031 break;
6032 case SIR_MAC_RATE_84:
6033 ConvertedRate = 168;
6034 break;
6035 case SIR_MAC_RATE_96:
6036 ConvertedRate = 192;
6037 break;
6038 case SIR_MAC_RATE_108:
6039 ConvertedRate = 216;
6040 break;
6041 case SIR_MAC_RATE_126:
6042 ConvertedRate = 252;
6043 break;
6044 case SIR_MAC_RATE_144:
6045 ConvertedRate = 288;
6046 break;
6047 case SIR_MAC_RATE_168:
6048 ConvertedRate = 336;
6049 break;
6050 case SIR_MAC_RATE_192:
6051 ConvertedRate = 384;
6052 break;
6053 case SIR_MAC_RATE_216:
6054 ConvertedRate = 432;
6055 break;
6056 case SIR_MAC_RATE_240:
6057 ConvertedRate = 480;
6058 break;
6059
6060 case 0xff:
6061 ConvertedRate = 0;
6062 break;
6063 }
6064
6065 return ConvertedRate;
6066}
6067
6068
6069tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
6070{
6071 tANI_U8 i;
6072 tANI_U16 nBest;
6073
6074 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
6075
6076 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
6077 {
6078 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
6079 }
6080
6081 for ( i = 1U; i < pSuppRates->numRates; ++i )
6082 {
6083 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6084 }
6085
6086 if ( NULL != pExtRates )
6087 {
6088 for ( i = 0U; i < pExtRates->numRates; ++i )
6089 {
6090 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
6091 }
6092 }
6093
6094 if ( NULL != pPropRates )
6095 {
6096 for ( i = 0U; i < pPropRates->numPropRates; ++i )
6097 {
6098 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
6099 }
6100 }
6101
6102 return nBest;
6103}
6104
6105
6106void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
6107{
6108 if(pProfile)
6109 {
6110 if(pProfile->BSSIDs.bssid)
6111 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306112 vos_mem_free(pProfile->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 pProfile->BSSIDs.bssid = NULL;
6114 }
6115 if(pProfile->SSIDs.SSIDList)
6116 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306117 vos_mem_free(pProfile->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 pProfile->SSIDs.SSIDList = NULL;
6119 }
6120 if(pProfile->pWPAReqIE)
6121 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306122 vos_mem_free(pProfile->pWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 pProfile->pWPAReqIE = NULL;
6124 }
6125 if(pProfile->pRSNReqIE)
6126 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306127 vos_mem_free(pProfile->pRSNReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 pProfile->pRSNReqIE = NULL;
6129 }
6130#ifdef FEATURE_WLAN_WAPI
6131 if(pProfile->pWAPIReqIE)
6132 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306133 vos_mem_free(pProfile->pWAPIReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 pProfile->pWAPIReqIE = NULL;
6135 }
6136#endif /* FEATURE_WLAN_WAPI */
6137
Agarwal Ashish4f616132013-12-30 23:32:50 +05306138 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306140 memset(pProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH+2);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306141 pProfile->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 }
6143
6144 if(pProfile->pAddIEAssoc)
6145 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306146 vos_mem_free(pProfile->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 pProfile->pAddIEAssoc = NULL;
6148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 if(pProfile->ChannelInfo.ChannelList)
6150 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306151 vos_mem_free(pProfile->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 pProfile->ChannelInfo.ChannelList = NULL;
6153 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306154 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 }
6156}
6157
6158void csrFreeScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
6159{
6160 if(pScanFilter->BSSIDs.bssid)
6161 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306162 vos_mem_free(pScanFilter->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 pScanFilter->BSSIDs.bssid = NULL;
6164 }
6165 if(pScanFilter->ChannelInfo.ChannelList)
6166 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306167 vos_mem_free(pScanFilter->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 pScanFilter->ChannelInfo.ChannelList = NULL;
6169 }
6170 if(pScanFilter->SSIDs.SSIDList)
6171 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306172 vos_mem_free(pScanFilter->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 pScanFilter->SSIDs.SSIDList = NULL;
6174 }
6175}
6176
6177
6178void csrFreeRoamProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6179{
6180 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6181
6182 if(pSession->pCurRoamProfile)
6183 {
6184 csrReleaseProfile(pMac, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306185 vos_mem_free(pSession->pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 pSession->pCurRoamProfile = NULL;
6187 }
6188}
6189
6190
6191void csrFreeConnectBssDesc(tpAniSirGlobal pMac, tANI_U32 sessionId)
6192{
6193 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
6194
6195 if(pSession->pConnectBssDesc)
6196 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306197 vos_mem_free(pSession->pConnectBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 pSession->pConnectBssDesc = NULL;
6199 }
6200}
6201
6202
6203
6204tSirResultCodes csrGetDisassocRspStatusCode( tSirSmeDisassocRsp *pSmeDisassocRsp )
6205{
6206 tANI_U8 *pBuffer = (tANI_U8 *)pSmeDisassocRsp;
6207 tANI_U32 ret;
6208
6209 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
6210 //tSirResultCodes is an enum, assuming is 32bit
6211 //If we cannot make this assumption, use copymemory
6212 pal_get_U32( pBuffer, &ret );
6213
6214 return( ( tSirResultCodes )ret );
6215}
6216
6217
6218tSirResultCodes csrGetDeAuthRspStatusCode( tSirSmeDeauthRsp *pSmeRsp )
6219{
6220 tANI_U8 *pBuffer = (tANI_U8 *)pSmeRsp;
6221 tANI_U32 ret;
6222
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006223 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tANI_U8) + sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 //tSirResultCodes is an enum, assuming is 32bit
6225 //If we cannot make this assumption, use copymemory
6226 pal_get_U32( pBuffer, &ret );
6227
6228 return( ( tSirResultCodes )ret );
6229}
6230
6231#if 0
6232tSirScanType csrGetScanType(tANI_U8 chnId, eRegDomainId domainId, tANI_U8 *countryCode)
6233{
6234 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6235 tANI_U8 cc = 0;
6236
6237 while (cc++ < gCsrDomainChnInfo[domainId].numChannels)
6238 {
6239 if(chnId == gCsrDomainChnInfo[domainId].chnInfo[cc].chnId)
6240 {
6241 scanType = gCsrDomainChnInfo[domainId].chnInfo[cc].scanType;
6242 break;
6243 }
6244 }
6245
6246 return (scanType);
6247}
6248#endif
6249
6250tSirScanType csrGetScanType(tpAniSirGlobal pMac, tANI_U8 chnId)
6251{
6252 tSirScanType scanType = eSIR_PASSIVE_SCAN;
6253 eNVChannelEnabledType channelEnabledType;
6254
6255 channelEnabledType = vos_nv_getChannelEnabledState(chnId);
6256 if( NV_CHANNEL_ENABLE == channelEnabledType)
6257 {
6258 scanType = eSIR_ACTIVE_SCAN;
6259 }
6260 return (scanType);
6261}
6262
6263
6264tANI_U8 csrToUpper( tANI_U8 ch )
6265{
6266 tANI_U8 chOut;
6267
6268 if ( ch >= 'a' && ch <= 'z' )
6269 {
6270 chOut = ch - 'a' + 'A';
6271 }
6272 else
6273 {
6274 chOut = ch;
6275 }
6276 return( chOut );
6277}
6278
6279
6280tSirBssType csrTranslateBsstypeToMacType(eCsrRoamBssType csrtype)
6281{
6282 tSirBssType ret;
6283
6284 switch(csrtype)
6285 {
6286 case eCSR_BSS_TYPE_INFRASTRUCTURE:
6287 ret = eSIR_INFRASTRUCTURE_MODE;
6288 break;
6289 case eCSR_BSS_TYPE_IBSS:
6290 case eCSR_BSS_TYPE_START_IBSS:
6291 ret = eSIR_IBSS_MODE;
6292 break;
6293 case eCSR_BSS_TYPE_WDS_AP:
6294 ret = eSIR_BTAMP_AP_MODE;
6295 break;
6296 case eCSR_BSS_TYPE_WDS_STA:
6297 ret = eSIR_BTAMP_STA_MODE;
6298 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 case eCSR_BSS_TYPE_INFRA_AP:
6300 ret = eSIR_INFRA_AP_MODE;
6301 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 case eCSR_BSS_TYPE_ANY:
6303 default:
6304 ret = eSIR_AUTO_MODE;
6305 break;
6306 }
6307
6308 return (ret);
6309}
6310
6311
6312//This function use the parameters to decide the CFG value.
6313//CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG
6314//So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value
Jeff Johnson295189b2012-06-20 16:38:30 -07006315eCsrCfgDot11Mode csrGetCfgDot11ModeFromCsrPhyMode(tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tANI_BOOLEAN fProprietary)
Jeff Johnson295189b2012-06-20 16:38:30 -07006316{
6317 tANI_U32 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6318
6319 switch(phyMode)
6320 {
6321 case eCSR_DOT11_MODE_11a:
6322 case eCSR_DOT11_MODE_11a_ONLY:
6323 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
6324 break;
6325 case eCSR_DOT11_MODE_11b:
6326 case eCSR_DOT11_MODE_11b_ONLY:
6327 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
6328 break;
6329 case eCSR_DOT11_MODE_11g:
6330 case eCSR_DOT11_MODE_11g_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 if(pProfile && (CSR_IS_INFRA_AP(pProfile)) && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
6332 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
6333 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
6335 break;
6336 case eCSR_DOT11_MODE_11n:
6337 if(fProprietary)
6338 {
6339 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6340 }
6341 else
6342 {
6343 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6344 }
6345 break;
6346 case eCSR_DOT11_MODE_11n_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 if(pProfile && CSR_IS_INFRA_AP(pProfile))
6348 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
6349 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6351 break;
6352 case eCSR_DOT11_MODE_TAURUS:
6353 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6354 break;
6355 case eCSR_DOT11_MODE_abg:
6356 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6357 break;
6358 case eCSR_DOT11_MODE_AUTO:
6359 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
6360 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07006361
6362#ifdef WLAN_FEATURE_11AC
6363 case eCSR_DOT11_MODE_11ac:
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006364 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6365 {
6366 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
6367 }
6368 else
6369 {
Ravi Joshia96ceb42013-05-20 18:52:39 -07006370 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006371 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006372 break;
6373 case eCSR_DOT11_MODE_11ac_ONLY:
Ravi Joshia96ceb42013-05-20 18:52:39 -07006374 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6375 {
6376 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
6377 }
6378 else
6379 {
6380 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6381 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006382 break;
6383#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 default:
6385 //No need to assign anything here
6386 break;
6387 }
6388
6389 return (cfgDot11Mode);
6390}
6391
6392
6393eHalStatus csrSetRegulatoryDomain(tpAniSirGlobal pMac, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6394{
6395 eHalStatus status = eHAL_STATUS_SUCCESS;
6396 tANI_BOOLEAN fRestart;
6397
6398 if(pMac->scan.domainIdCurrent == domainId)
6399 {
6400 //no change
6401 fRestart = eANI_BOOLEAN_FALSE;
6402 }
6403 else if( !pMac->roam.configParam.fEnforceDefaultDomain )
6404 {
6405 pMac->scan.domainIdCurrent = domainId;
6406 fRestart = eANI_BOOLEAN_TRUE;
6407 }
6408 else
6409 {
6410 //We cannot change the domain
6411 status = eHAL_STATUS_CSR_WRONG_STATE;
6412 fRestart = eANI_BOOLEAN_FALSE;
6413 }
6414 if(pfRestartNeeded)
6415 {
6416 *pfRestartNeeded = fRestart;
6417 }
6418
6419 return (status);
6420}
6421
6422
6423v_REGDOMAIN_t csrGetCurrentRegulatoryDomain(tpAniSirGlobal pMac)
6424{
6425 return (pMac->scan.domainIdCurrent);
6426}
6427
Jeff Johnson295189b2012-06-20 16:38:30 -07006428
Kiet Lam6c583332013-10-14 05:37:09 +05306429eHalStatus csrGetRegulatoryDomainForCountry
6430(
6431tpAniSirGlobal pMac,
6432tANI_U8 *pCountry,
6433v_REGDOMAIN_t *pDomainId,
6434v_CountryInfoSource_t source
6435)
Jeff Johnson295189b2012-06-20 16:38:30 -07006436{
6437 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6438 VOS_STATUS vosStatus;
6439 v_COUNTRYCODE_t countryCode;
6440 v_REGDOMAIN_t domainId;
6441
6442 if(pCountry)
6443 {
6444 countryCode[0] = pCountry[0];
6445 countryCode[1] = pCountry[1];
Kiet Lam6c583332013-10-14 05:37:09 +05306446 vosStatus = vos_nv_getRegDomainFromCountryCode(&domainId,
6447 countryCode,
6448 source);
6449
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
6451 {
6452 if( pDomainId )
6453 {
6454 *pDomainId = domainId;
6455 }
6456 status = eHAL_STATUS_SUCCESS;
6457 }
6458 else
6459 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306460 smsLog(pMac, LOGW, FL(" Couldn't find domain for country code %c%c"), pCountry[0], pCountry[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 status = eHAL_STATUS_INVALID_PARAMETER;
6462 }
6463 }
6464
6465 return (status);
6466}
6467
6468//To check whether a country code matches the one in the IE
6469//Only check the first two characters, ignoring in/outdoor
6470//pCountry -- caller allocated buffer contain the country code that is checking against
6471//the one in pIes. It can be NULL.
6472//caller must provide pIes, it cannot be NULL
6473//This function always return TRUE if 11d support is not turned on.
6474tANI_BOOLEAN csrMatchCountryCode( tpAniSirGlobal pMac, tANI_U8 *pCountry, tDot11fBeaconIEs *pIes )
6475{
6476 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson43971f52012-07-17 12:26:56 -07006477 v_REGDOMAIN_t domainId = REGDOMAIN_COUNT; //This is init to invalid value
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 eHalStatus status;
6479
6480 do
6481 {
6482 if( !csrIs11dSupported( pMac) )
6483 {
6484 break;
6485 }
6486 if( !pIes )
6487 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006488 smsLog(pMac, LOGE, FL(" No IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 break;
6490 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006491 if( pMac->roam.configParam.fEnforceDefaultDomain ||
6492 pMac->roam.configParam.fEnforceCountryCodeMatch )
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006494 //Make sure this country is recognizable
6495 if( pIes->Country.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 {
Kiet Lam6c583332013-10-14 05:37:09 +05306497 status = csrGetRegulatoryDomainForCountry(pMac,
6498 pIes->Country.country,
6499 &domainId, COUNTRY_QUERY);
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006500 if( !HAL_STATUS_SUCCESS( status ) )
6501 {
Kiet Lam6c583332013-10-14 05:37:09 +05306502 status = csrGetRegulatoryDomainForCountry(pMac,
6503 pMac->scan.countryCode11d,
6504 (v_REGDOMAIN_t *) &domainId,
6505 COUNTRY_QUERY);
Gowri Deepthiff9adf92012-12-13 15:09:56 -08006506 if( !HAL_STATUS_SUCCESS( status ) )
6507 {
6508 fRet = eANI_BOOLEAN_FALSE;
6509 break;
6510 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006513 //check whether it is needed to enforce to the default regulatory domain first
6514 if( pMac->roam.configParam.fEnforceDefaultDomain )
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006516 if( domainId != pMac->scan.domainIdCurrent )
6517 {
6518 fRet = eANI_BOOLEAN_FALSE;
6519 break;
6520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006522 if( pMac->roam.configParam.fEnforceCountryCodeMatch )
6523 {
Jeff Johnson43971f52012-07-17 12:26:56 -07006524 if( domainId >= REGDOMAIN_COUNT )
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006525 {
6526 fRet = eANI_BOOLEAN_FALSE;
6527 break;
6528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 }
6530 }
6531 if( pCountry )
6532 {
6533 tANI_U32 i;
6534
6535 if( !pIes->Country.present )
6536 {
6537 fRet = eANI_BOOLEAN_FALSE;
6538 break;
6539 }
6540 // Convert the CountryCode characters to upper
6541 for ( i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++ )
6542 {
6543 pCountry[i] = csrToUpper( pCountry[i] );
6544 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306545 if (!vos_mem_compare(pIes->Country.country, pCountry,
6546 WNI_CFG_COUNTRY_CODE_LEN - 1))
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 {
6548 fRet = eANI_BOOLEAN_FALSE;
6549 break;
6550 }
6551 }
6552 } while(0);
6553
6554 return (fRet);
6555}
6556
6557#if 0
6558eHalStatus csrSetCountryDomainMapping(tpAniSirGlobal pMac, tCsrCountryDomainMapping *pCountryDomainMapping)
6559{
6560 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6561 tANI_U32 i, j;
6562 tANI_BOOLEAN fDomainChanged = eANI_BOOLEAN_FALSE;
6563 tANI_U8 countryCode[WNI_CFG_COUNTRY_CODE_LEN];
6564
6565 i = WNI_CFG_COUNTRY_CODE_LEN;
6566 //Get the currently used country code
6567 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, countryCode, &i);
6568 if(HAL_STATUS_SUCCESS(status))
6569 {
6570 if(pCountryDomainMapping && pCountryDomainMapping->numEntry)
6571 {
6572 for(i = 0; i < pCountryDomainMapping->numEntry; i++)
6573 {
6574 for(j = 0; j < eCSR_NUM_COUNTRY_INDEX; j++)
6575 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306576 if (vos_mem_compare(gCsrCountryInfo[j].countryCode,
6577 pCountryDomainMapping->pCountryInfo[i].countryCode,
6578 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 {
6580 if(gCsrCountryInfo[j].domainId != pCountryDomainMapping->pCountryInfo[i].domainId)
6581 {
6582 gCsrCountryInfo[j].domainId = pCountryDomainMapping->pCountryInfo[i].domainId;
6583 //Check whether it matches the currently used country code
6584 //If matching, need to update base on the new domain setting.
Kiet Lam64c1b492013-07-12 13:56:44 +05306585 if (vos_mem_compare(countryCode,
6586 pCountryDomainMapping->pCountryInfo[i].countryCode,
6587 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 {
6589 fDomainChanged = eANI_BOOLEAN_TRUE;
6590 }
6591 }
6592 break;
6593 }
6594 }
6595 }
6596 status = eHAL_STATUS_SUCCESS;
6597 if(fDomainChanged)
6598 {
6599 tCsrChannel *pChannelList;
6600
6601 if(pMac->scan.f11dInfoApplied)
6602 {
6603 //11d info already applied. Let's reapply with the new domain setting
6604 if(pMac->scan.channels11d.numChannels)
6605 {
6606 pChannelList = &pMac->scan.channels11d;
6607 }
6608 else
6609 {
6610 pChannelList = &pMac->scan.base20MHzChannels;
6611 }
6612 }
6613 else
6614 {
6615 //no 11d so we use the base channelist from EEPROM
6616 pChannelList = &pMac->scan.base20MHzChannels;
6617 }
6618 //set the new domain's scan requirement to CFG
6619 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
6620 }
6621 }
6622 }
6623
6624 return (status);
6625}
6626
6627eHalStatus csrSetDomainScanSetting(tpAniSirGlobal pMac, tCsrDomainFreqInfo *pDomainFreqInfo)
6628{
6629 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6630 tANI_U32 i, j;
6631 tANI_U16 freq;
6632
6633 if(pDomainFreqInfo && pDomainFreqInfo->numEntry && (pDomainFreqInfo->domainId < NUM_REG_DOMAINS))
6634 {
6635 tCsrDomainChnInfo *pDomainChnInfo = &gCsrDomainChnInfo[pDomainFreqInfo->domainId];
6636
6637 for(j = 0; j < pDomainChnInfo->numChannels; j++)
6638 {
6639 if(HAL_STATUS_SUCCESS(halPhyChIdToFreqConversion(pDomainChnInfo->chnInfo[j].chnId, &freq)))
6640 {
6641 for(i = 0; i < pDomainFreqInfo->numEntry; i++)
6642 {
6643 if((pDomainFreqInfo->pCsrScanFreqInfo[i].nStartFreq <= freq) &&
6644 (freq <= pDomainFreqInfo->pCsrScanFreqInfo[i].nEndFreq))
6645 {
6646 pDomainChnInfo->chnInfo[j].scanType = pDomainFreqInfo->pCsrScanFreqInfo[i].scanType;
6647 break;
6648 }
6649 }
6650 }
6651 else
6652 {
6653 smsLog(pMac, LOGW, " Failed to get frequency of channel %d", pDomainChnInfo->chnInfo[j].chnId);
6654 }
6655 }
6656 status = eHAL_STATUS_SUCCESS;
6657 }
6658
6659 return (status);
6660}
6661#endif
6662
6663eHalStatus csrGetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6664 tCsrRoamModifyProfileFields *pModifyProfileFields)
6665{
6666
6667 if(!pModifyProfileFields)
6668 {
6669 return eHAL_STATUS_FAILURE;
6670 }
6671
Kiet Lam64c1b492013-07-12 13:56:44 +05306672 vos_mem_copy(pModifyProfileFields,
6673 &pMac->roam.roamSession[sessionId].connectedProfile.modifyProfileFields,
6674 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006675
6676 return eHAL_STATUS_SUCCESS;
6677}
6678
6679eHalStatus csrSetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6680 tCsrRoamModifyProfileFields *pModifyProfileFields)
6681{
6682 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6683
Kiet Lam64c1b492013-07-12 13:56:44 +05306684 vos_mem_copy(&pSession->connectedProfile.modifyProfileFields,
6685 pModifyProfileFields,
6686 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006687
6688 return eHAL_STATUS_SUCCESS;
6689}
6690
6691
6692#if 0
6693/* ---------------------------------------------------------------------------
6694 \fn csrGetSupportedCountryCode
6695 \brief this function is to get a list of the country code current being supported
6696 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6697 this has the country code list. 3 bytes for each country code. This may be NULL if
6698 caller wants to know the needed bytes.
6699 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6700 this contains the length of the data in pBuf
6701 \return eHalStatus
6702 -------------------------------------------------------------------------------*/
6703eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6704{
6705 tANI_U32 numOfCountry = sizeof( gCsrCountryInfo ) / sizeof( gCsrCountryInfo[0] );
6706 tANI_U32 numBytes = 0;
6707 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6708
6709 if( pbLen )
6710 {
6711 numBytes = *pbLen;
6712 //Consider it ok, at least we can return the number of bytes needed;
6713 *pbLen = numOfCountry * WNI_CFG_COUNTRY_CODE_LEN;
6714 status = eHAL_STATUS_SUCCESS;
6715 if( pBuf && ( numBytes >= *pbLen ) )
6716 {
6717 //The ugly part starts.
6718 //We may need to alter the data structure and find a way to make this faster.
6719 tANI_U32 i;
6720
Kiet Lam64c1b492013-07-12 13:56:44 +05306721 for ( i = 0; i < numOfCountry; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306723 vos_mem_copy(pBuf + ( i * WNI_CFG_COUNTRY_CODE_LEN ),
6724 gCsrCountryInfo[i].countryCode,
6725 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 }
6727 }
6728 }
6729
6730 return ( status );
6731}
6732#endif
6733
6734/* ---------------------------------------------------------------------------
6735 \fn csrGetSupportedCountryCode
6736 \brief this function is to get a list of the country code current being supported
6737 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6738 this has the country code list. 3 bytes for each country code. This may be NULL if
6739 caller wants to know the needed bytes.
6740 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6741 this contains the length of the data in pBuf
6742 \return eHalStatus
6743 -------------------------------------------------------------------------------*/
6744eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6745{
6746 eHalStatus status = eHAL_STATUS_SUCCESS;
6747 VOS_STATUS vosStatus;
6748 v_SIZE_t size = (v_SIZE_t)*pbLen;
6749
6750 vosStatus = vos_nv_getSupportedCountryCode( pBuf, &size, 1 );
6751 //eiter way, return the value back
6752 *pbLen = (tANI_U32)size;
6753
6754 //If pBuf is NULL, caller just want to get the size, consider it success
6755 if(pBuf)
6756 {
6757 if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
6758 {
6759 tANI_U32 i, n = *pbLen / 3;
6760
6761 for( i = 0; i < n; i++ )
6762 {
6763 pBuf[i*3 + 2] = ' ';
6764 }
6765 }
6766 else
6767 {
6768 status = eHAL_STATUS_FAILURE;
6769 }
6770 }
6771
6772 return (status);
6773}
6774
6775
6776
6777//Upper layer to get the list of the base channels to scan for passively 11d info from csr
6778eHalStatus csrScanGetBaseChannels( tpAniSirGlobal pMac, tCsrChannelInfo * pChannelInfo )
6779{
6780 eHalStatus status = eHAL_STATUS_FAILURE;
6781
6782 do
6783 {
6784
6785 if(!pMac->scan.baseChannels.numChannels || !pChannelInfo)
6786 {
6787 break;
6788 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306789 pChannelInfo->ChannelList = vos_mem_malloc(pMac->scan.baseChannels.numChannels);
6790 if ( NULL == pChannelInfo->ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006792 smsLog( pMac, LOGE, FL("csrScanGetBaseChannels: fail to allocate memory") );
Kiet Lam64c1b492013-07-12 13:56:44 +05306793 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306795 vos_mem_copy(pChannelInfo->ChannelList,
6796 pMac->scan.baseChannels.channelList,
6797 pMac->scan.baseChannels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 pChannelInfo->numOfChannels = pMac->scan.baseChannels.numChannels;
6799
6800 }while(0);
6801
6802 return ( status );
6803}
6804
6805
6806tANI_BOOLEAN csrIsSetKeyAllowed(tpAniSirGlobal pMac, tANI_U32 sessionId)
6807{
6808 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 tCsrRoamSession *pSession;
6810
6811 pSession =CSR_GET_SESSION(pMac, sessionId);
6812
6813 /*This condition is not working for infra state. When infra is in not-connected state
6814 * the pSession->pCurRoamProfile is NULL. And this function returns TRUE, that is incorrect.
6815 * Since SAP requires to set key without any BSS started, it needs this condition to be met.
6816 * In other words, this function is useless.
6817 * The current work-around is to process setcontext_rsp and removekey_rsp no matter what the
6818 * state is.
6819 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006820 smsLog( pMac, LOG2, FL(" is not what it intends to. Must be revisit or removed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 if( (NULL == pSession) ||
6822 ( csrIsConnStateDisconnected( pMac, sessionId ) &&
6823 (pSession->pCurRoamProfile != NULL) &&
6824 (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) )
6825 )
6826 {
6827 fRet = eANI_BOOLEAN_FALSE;
6828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006829
6830 return ( fRet );
6831}
6832
6833//no need to acquire lock for this basic function
6834tANI_U16 sme_ChnToFreq(tANI_U8 chanNum)
6835{
6836 int i;
6837
6838 for (i = 0; i < NUM_RF_CHANNELS; i++)
6839 {
6840 if (rfChannels[i].channelNum == chanNum)
6841 {
6842 return rfChannels[i].targetFreq;
6843 }
6844 }
6845
6846 return (0);
6847}
6848
6849/* Disconnect all active sessions by sending disassoc. This is mainly used to disconnect the remaining session when we
6850 * transition from concurrent sessions to a single session. The use case is Infra STA and wifi direct multiple sessions are up and
6851 * P2P session is removed. The Infra STA session remains and should resume BMPS if BMPS is enabled by default. However, there
6852 * are some issues seen with BMPS resume during this transition and this is a workaround which will allow the Infra STA session to
6853 * disconnect and auto connect back and enter BMPS this giving the same effect as resuming BMPS
6854 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006855
6856//Remove this code once SLM_Sessionization is supported
6857//BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnson295189b2012-06-20 16:38:30 -07006858void csrDisconnectAllActiveSessions(tpAniSirGlobal pMac)
6859{
6860 tANI_U8 i;
6861
6862 /* Disconnect all the active sessions */
6863 for (i=0; i<CSR_ROAM_SESSION_MAX; i++)
6864 {
6865 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
6866 {
6867 csrRoamDisconnectInternal(pMac, i, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6868 }
6869 }
6870}
Mohit Khanna349bc392012-09-11 17:24:52 -07006871
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006872#ifdef FEATURE_WLAN_LFR
6873tANI_BOOLEAN csrIsChannelPresentInList(
6874 tANI_U8 *pChannelList,
6875 int numChannels,
6876 tANI_U8 channel
6877 )
6878{
6879 int i = 0;
6880
6881 // Check for NULL pointer
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08006882 if (!pChannelList || (numChannels == 0))
6883 {
6884 return FALSE;
6885 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006886
6887 // Look for the channel in the list
6888 for (i = 0; i < numChannels; i++)
6889 {
6890 if (pChannelList[i] == channel)
6891 return TRUE;
6892 }
6893
6894 return FALSE;
6895}
6896
6897VOS_STATUS csrAddToChannelListFront(
6898 tANI_U8 *pChannelList,
6899 int numChannels,
6900 tANI_U8 channel
6901 )
6902{
6903 int i = 0;
6904
6905 // Check for NULL pointer
6906 if (!pChannelList) return eHAL_STATUS_E_NULL_VALUE;
6907
6908 // Make room for the addition. (Start moving from the back.)
6909 for (i = numChannels; i > 0; i--)
6910 {
6911 pChannelList[i] = pChannelList[i-1];
6912 }
6913
6914 // Now add the NEW channel...at the front
6915 pChannelList[0] = channel;
6916
6917 return eHAL_STATUS_SUCCESS;
6918}
6919#endif
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306920const char * sme_requestTypetoString(const v_U8_t requestType)
6921{
6922 switch (requestType)
6923 {
6924 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_11D_SCAN );
6925 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_FULL_SCAN );
6926 CASE_RETURN_STRING( eCSR_SCAN_IDLE_MODE_SCAN );
6927 CASE_RETURN_STRING( eCSR_SCAN_HO_BG_SCAN );
6928 CASE_RETURN_STRING( eCSR_SCAN_HO_PROBE_SCAN );
6929 CASE_RETURN_STRING( eCSR_SCAN_HO_NT_BG_SCAN );
6930 CASE_RETURN_STRING( eCSR_SCAN_P2P_DISCOVERY );
6931 CASE_RETURN_STRING( eCSR_SCAN_SOFTAP_CHANNEL_RANGE );
6932 CASE_RETURN_STRING( eCSR_SCAN_P2P_FIND_PEER );
6933 default:
6934 return "Unknown Scan Request Type";
6935 }
6936}