blob: 2bec2f3438f3ccb024c5a4694ee8340b395d6d7b [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 -070051
52tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ] = {
53 { 0x00, 0x50, 0xf2, 0x00 },
54 { 0x00, 0x50, 0xf2, 0x01 },
55 { 0x00, 0x50, 0xf2, 0x02 },
56 { 0x00, 0x50, 0xf2, 0x03 },
57 { 0x00, 0x50, 0xf2, 0x04 },
58 { 0x00, 0x50, 0xf2, 0x05 },
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080059#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070060 { 0x00, 0x40, 0x96, 0x00 }, // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080061#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070062};
63
64tANI_U8 csrRSNOui[][ CSR_RSN_OUI_SIZE ] = {
65 { 0x00, 0x0F, 0xAC, 0x00 }, // group cipher
66 { 0x00, 0x0F, 0xAC, 0x01 }, // WEP-40 or RSN
67 { 0x00, 0x0F, 0xAC, 0x02 }, // TKIP or RSN-PSK
68 { 0x00, 0x0F, 0xAC, 0x03 }, // Reserved
69 { 0x00, 0x0F, 0xAC, 0x04 }, // AES-CCMP
70 { 0x00, 0x0F, 0xAC, 0x05 }, // WEP-104
Chet Lanctot4c986162013-05-08 13:59:56 -070071 { 0x00, 0x40, 0x96, 0x00 }, // CCKM
72 { 0x00, 0x0F, 0xAC, 0x06 } // BIP (encryption type) or RSN-PSK-SHA256 (authentication type)
Jeff Johnson295189b2012-06-20 16:38:30 -070073};
74
75#ifdef FEATURE_WLAN_WAPI
Kaushik, Sushantfe230152014-04-08 14:37:47 +053076tANI_U8 csrWapiOui[CSR_WAPI_OUI_ROW_SIZE][ CSR_WAPI_OUI_SIZE ] = {
Jeff Johnson295189b2012-06-20 16:38:30 -070077 { 0x00, 0x14, 0x72, 0x00 }, // Reserved
78 { 0x00, 0x14, 0x72, 0x01 }, // WAI certificate or SMS4
79 { 0x00, 0x14, 0x72, 0x02 } // WAI PSK
80};
81#endif /* FEATURE_WLAN_WAPI */
82tANI_U8 csrWmeInfoOui[ CSR_WME_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
83tANI_U8 csrWmeParmOui[ CSR_WME_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
84
85static tCsrIELenInfo gCsrIELengthTable[] = {
86/* 000 */ { SIR_MAC_SSID_EID_MIN, SIR_MAC_SSID_EID_MAX },
87/* 001 */ { SIR_MAC_RATESET_EID_MIN, SIR_MAC_RATESET_EID_MAX },
88/* 002 */ { SIR_MAC_FH_PARAM_SET_EID_MIN, SIR_MAC_FH_PARAM_SET_EID_MAX },
89/* 003 */ { SIR_MAC_DS_PARAM_SET_EID_MIN, SIR_MAC_DS_PARAM_SET_EID_MAX },
90/* 004 */ { SIR_MAC_CF_PARAM_SET_EID_MIN, SIR_MAC_CF_PARAM_SET_EID_MAX },
91/* 005 */ { SIR_MAC_TIM_EID_MIN, SIR_MAC_TIM_EID_MAX },
92/* 006 */ { SIR_MAC_IBSS_PARAM_SET_EID_MIN, SIR_MAC_IBSS_PARAM_SET_EID_MAX },
93/* 007 */ { SIR_MAC_COUNTRY_EID_MIN, SIR_MAC_COUNTRY_EID_MAX },
94/* 008 */ { SIR_MAC_FH_PARAMS_EID_MIN, SIR_MAC_FH_PARAMS_EID_MAX },
95/* 009 */ { SIR_MAC_FH_PATTERN_EID_MIN, SIR_MAC_FH_PATTERN_EID_MAX },
96/* 010 */ { SIR_MAC_REQUEST_EID_MIN, SIR_MAC_REQUEST_EID_MAX },
97/* 011 */ { SIR_MAC_QBSS_LOAD_EID_MIN, SIR_MAC_QBSS_LOAD_EID_MAX },
98/* 012 */ { SIR_MAC_EDCA_PARAM_SET_EID_MIN, SIR_MAC_EDCA_PARAM_SET_EID_MAX },
99/* 013 */ { SIR_MAC_TSPEC_EID_MIN, SIR_MAC_TSPEC_EID_MAX },
100/* 014 */ { SIR_MAC_TCLAS_EID_MIN, SIR_MAC_TCLAS_EID_MAX },
101/* 015 */ { SIR_MAC_QOS_SCHEDULE_EID_MIN, SIR_MAC_QOS_SCHEDULE_EID_MAX },
102/* 016 */ { SIR_MAC_CHALLENGE_TEXT_EID_MIN, SIR_MAC_CHALLENGE_TEXT_EID_MAX },
103/* 017 */ { 0, 255 },
104/* 018 */ { 0, 255 },
105/* 019 */ { 0, 255 },
106/* 020 */ { 0, 255 },
107/* 021 */ { 0, 255 },
108/* 022 */ { 0, 255 },
109/* 023 */ { 0, 255 },
110/* 024 */ { 0, 255 },
111/* 025 */ { 0, 255 },
112/* 026 */ { 0, 255 },
113/* 027 */ { 0, 255 },
114/* 028 */ { 0, 255 },
115/* 029 */ { 0, 255 },
116/* 030 */ { 0, 255 },
117/* 031 */ { 0, 255 },
118/* 032 */ { SIR_MAC_PWR_CONSTRAINT_EID_MIN, SIR_MAC_PWR_CONSTRAINT_EID_MAX },
119/* 033 */ { SIR_MAC_PWR_CAPABILITY_EID_MIN, SIR_MAC_PWR_CAPABILITY_EID_MAX },
120/* 034 */ { SIR_MAC_TPC_REQ_EID_MIN, SIR_MAC_TPC_REQ_EID_MAX },
121/* 035 */ { SIR_MAC_TPC_RPT_EID_MIN, SIR_MAC_TPC_RPT_EID_MAX },
122/* 036 */ { SIR_MAC_SPRTD_CHNLS_EID_MIN, SIR_MAC_SPRTD_CHNLS_EID_MAX },
123/* 037 */ { SIR_MAC_CHNL_SWITCH_ANN_EID_MIN, SIR_MAC_CHNL_SWITCH_ANN_EID_MAX },
124/* 038 */ { SIR_MAC_MEAS_REQ_EID_MIN, SIR_MAC_MEAS_REQ_EID_MAX },
125/* 039 */ { SIR_MAC_MEAS_RPT_EID_MIN, SIR_MAC_MEAS_RPT_EID_MAX },
126/* 040 */ { SIR_MAC_QUIET_EID_MIN, SIR_MAC_QUIET_EID_MAX },
127/* 041 */ { SIR_MAC_IBSS_DFS_EID_MIN, SIR_MAC_IBSS_DFS_EID_MAX },
128/* 042 */ { SIR_MAC_ERP_INFO_EID_MIN, SIR_MAC_ERP_INFO_EID_MAX },
129/* 043 */ { SIR_MAC_TS_DELAY_EID_MIN, SIR_MAC_TS_DELAY_EID_MAX },
130/* 044 */ { SIR_MAC_TCLAS_PROC_EID_MIN, SIR_MAC_TCLAS_PROC_EID_MAX },
131/* 045 */ { SIR_MAC_QOS_ACTION_EID_MIN, SIR_MAC_QOS_ACTION_EID_MAX },
132/* 046 */ { SIR_MAC_QOS_CAPABILITY_EID_MIN, SIR_MAC_QOS_CAPABILITY_EID_MAX },
133/* 047 */ { 0, 255 },
134/* 048 */ { SIR_MAC_RSN_EID_MIN, SIR_MAC_RSN_EID_MAX },
135/* 049 */ { 0, 255 },
136/* 050 */ { SIR_MAC_EXTENDED_RATE_EID_MIN, SIR_MAC_EXTENDED_RATE_EID_MAX },
137/* 051 */ { 0, 255 },
138/* 052 */ { 0, 255 },
139/* 053 */ { 0, 255 },
140/* 054 */ { 0, 255 },
141/* 055 */ { 0, 255 },
142/* 056 */ { 0, 255 },
143/* 057 */ { 0, 255 },
144/* 058 */ { 0, 255 },
145/* 059 */ { 0, 255 },
146/* 060 */ { 0, 255 },
147/* 061 */ { 0, 255 },
148/* 062 */ { 0, 255 },
149/* 063 */ { 0, 255 },
150/* 064 */ { 0, 255 },
151/* 065 */ { 0, 255 },
152/* 066 */ { 0, 255 },
153/* 067 */ { 0, 255 },
154#ifdef FEATURE_WLAN_WAPI
155/* 068 */ { DOT11F_EID_WAPI, DOT11F_IE_WAPI_MAX_LEN },
156#else
157/* 068 */ { 0, 255 },
158#endif /* FEATURE_WLAN_WAPI */
159/* 069 */ { 0, 255 },
160/* 070 */ { 0, 255 },
161/* 071 */ { 0, 255 },
162/* 072 */ { 0, 255 },
163/* 073 */ { 0, 255 },
164/* 074 */ { 0, 255 },
165/* 075 */ { 0, 255 },
166/* 076 */ { 0, 255 },
167/* 077 */ { 0, 255 },
168/* 078 */ { 0, 255 },
169/* 079 */ { 0, 255 },
170/* 080 */ { 0, 255 },
171/* 081 */ { 0, 255 },
172/* 082 */ { 0, 255 },
173/* 083 */ { 0, 255 },
174/* 084 */ { 0, 255 },
175/* 085 */ { 0, 255 },
176/* 086 */ { 0, 255 },
177/* 087 */ { 0, 255 },
178/* 088 */ { 0, 255 },
179/* 089 */ { 0, 255 },
180/* 090 */ { 0, 255 },
181/* 091 */ { 0, 255 },
182/* 092 */ { 0, 255 },
183/* 093 */ { 0, 255 },
184/* 094 */ { 0, 255 },
185/* 095 */ { 0, 255 },
186/* 096 */ { 0, 255 },
187/* 097 */ { 0, 255 },
188/* 098 */ { 0, 255 },
189/* 099 */ { 0, 255 },
190/* 100 */ { 0, 255 },
191/* 101 */ { 0, 255 },
192/* 102 */ { 0, 255 },
193/* 103 */ { 0, 255 },
194/* 104 */ { 0, 255 },
195/* 105 */ { 0, 255 },
196/* 106 */ { 0, 255 },
197/* 107 */ { 0, 255 },
198/* 108 */ { 0, 255 },
199/* 109 */ { 0, 255 },
200/* 110 */ { 0, 255 },
201/* 111 */ { 0, 255 },
202/* 112 */ { 0, 255 },
203/* 113 */ { 0, 255 },
204/* 114 */ { 0, 255 },
205/* 115 */ { 0, 255 },
206/* 116 */ { 0, 255 },
207/* 117 */ { 0, 255 },
208/* 118 */ { 0, 255 },
209/* 119 */ { 0, 255 },
210/* 120 */ { 0, 255 },
211/* 121 */ { 0, 255 },
212/* 122 */ { 0, 255 },
213/* 123 */ { 0, 255 },
214/* 124 */ { 0, 255 },
215/* 125 */ { 0, 255 },
216/* 126 */ { 0, 255 },
217/* 127 */ { 0, 255 },
218/* 128 */ { 0, 255 },
219/* 129 */ { 0, 255 },
220/* 130 */ { 0, 255 },
221/* 131 */ { 0, 255 },
222/* 132 */ { 0, 255 },
223/* 133 */ { 0, 255 },
224/* 134 */ { 0, 255 },
225/* 135 */ { 0, 255 },
226/* 136 */ { 0, 255 },
227/* 137 */ { 0, 255 },
228/* 138 */ { 0, 255 },
229/* 139 */ { 0, 255 },
230/* 140 */ { 0, 255 },
231/* 141 */ { 0, 255 },
232/* 142 */ { 0, 255 },
233/* 143 */ { 0, 255 },
234/* 144 */ { 0, 255 },
235/* 145 */ { 0, 255 },
236/* 146 */ { 0, 255 },
237/* 147 */ { 0, 255 },
238/* 148 */ { 0, 255 },
239/* 149 */ { 0, 255 },
240/* 150 */ { 0, 255 },
241/* 151 */ { 0, 255 },
242/* 152 */ { 0, 255 },
243/* 153 */ { 0, 255 },
244/* 154 */ { 0, 255 },
245/* 155 */ { 0, 255 },
246/* 156 */ { 0, 255 },
247/* 157 */ { 0, 255 },
248/* 158 */ { 0, 255 },
249/* 159 */ { 0, 255 },
250/* 160 */ { 0, 255 },
251/* 161 */ { 0, 255 },
252/* 162 */ { 0, 255 },
253/* 163 */ { 0, 255 },
254/* 164 */ { 0, 255 },
255/* 165 */ { 0, 255 },
256/* 166 */ { 0, 255 },
257/* 167 */ { 0, 255 },
258/* 168 */ { 0, 255 },
259/* 169 */ { 0, 255 },
260/* 170 */ { 0, 255 },
261/* 171 */ { 0, 255 },
262/* 172 */ { 0, 255 },
263/* 173 */ { 0, 255 },
264/* 174 */ { 0, 255 },
265/* 175 */ { 0, 255 },
266/* 176 */ { 0, 255 },
267/* 177 */ { 0, 255 },
268/* 178 */ { 0, 255 },
269/* 179 */ { 0, 255 },
270/* 180 */ { 0, 255 },
271/* 181 */ { 0, 255 },
272/* 182 */ { 0, 255 },
273/* 183 */ { 0, 255 },
274/* 184 */ { 0, 255 },
275/* 185 */ { 0, 255 },
276/* 186 */ { 0, 255 },
277/* 187 */ { 0, 255 },
278/* 188 */ { 0, 255 },
279/* 189 */ { 0, 255 },
280/* 190 */ { 0, 255 },
281/* 191 */ { 0, 255 },
282/* 192 */ { 0, 255 },
283/* 193 */ { 0, 255 },
284/* 194 */ { 0, 255 },
285/* 195 */ { 0, 255 },
286/* 196 */ { 0, 255 },
287/* 197 */ { 0, 255 },
288/* 198 */ { 0, 255 },
289/* 199 */ { 0, 255 },
290/* 200 */ { 0, 255 },
291/* 201 */ { 0, 255 },
292/* 202 */ { 0, 255 },
293/* 203 */ { 0, 255 },
294/* 204 */ { 0, 255 },
295/* 205 */ { 0, 255 },
296/* 206 */ { 0, 255 },
297/* 207 */ { 0, 255 },
298/* 208 */ { 0, 255 },
299/* 209 */ { 0, 255 },
300/* 210 */ { 0, 255 },
301/* 211 */ { 0, 255 },
302/* 212 */ { 0, 255 },
303/* 213 */ { 0, 255 },
304/* 214 */ { 0, 255 },
305/* 215 */ { 0, 255 },
306/* 216 */ { 0, 255 },
307/* 217 */ { 0, 255 },
308/* 218 */ { 0, 255 },
309/* 219 */ { 0, 255 },
310/* 220 */ { 0, 255 },
311/* 221 */ { SIR_MAC_WPA_EID_MIN, SIR_MAC_WPA_EID_MAX },
312/* 222 */ { 0, 255 },
313/* 223 */ { 0, 255 },
314/* 224 */ { 0, 255 },
315/* 225 */ { 0, 255 },
316/* 226 */ { 0, 255 },
317/* 227 */ { 0, 255 },
318/* 228 */ { 0, 255 },
319/* 229 */ { 0, 255 },
320/* 230 */ { 0, 255 },
321/* 231 */ { 0, 255 },
322/* 232 */ { 0, 255 },
323/* 233 */ { 0, 255 },
324/* 234 */ { 0, 255 },
325/* 235 */ { 0, 255 },
326/* 236 */ { 0, 255 },
327/* 237 */ { 0, 255 },
328/* 238 */ { 0, 255 },
329/* 239 */ { 0, 255 },
330/* 240 */ { 0, 255 },
331/* 241 */ { 0, 255 },
332/* 242 */ { 0, 255 },
333/* 243 */ { 0, 255 },
334/* 244 */ { 0, 255 },
335/* 245 */ { 0, 255 },
336/* 246 */ { 0, 255 },
337/* 247 */ { 0, 255 },
338/* 248 */ { 0, 255 },
339/* 249 */ { 0, 255 },
340/* 250 */ { 0, 255 },
341/* 251 */ { 0, 255 },
342/* 252 */ { 0, 255 },
343/* 253 */ { 0, 255 },
344/* 254 */ { 0, 255 },
345/* 255 */ { SIR_MAC_ANI_WORKAROUND_EID_MIN, SIR_MAC_ANI_WORKAROUND_EID_MAX }
346};
347
348#if 0
349//Don't not insert entry into the table, put it to the end. If you have to insert, make sure it is also
350//reflected in eCsrCountryIndex
351static tCsrCountryInfo gCsrCountryInfo[eCSR_NUM_COUNTRY_INDEX] =
352{
353 {REG_DOMAIN_FCC, {'U', 'S', ' '}}, //USA/******The "US" MUST be at index 0*******/
354 {REG_DOMAIN_WORLD, {'A', 'D', ' '}}, //ANDORRA
355 {REG_DOMAIN_WORLD, {'A', 'E', ' '}}, //UAE
356 {REG_DOMAIN_WORLD, {'A', 'F', ' '}}, //AFGHANISTAN
357 {REG_DOMAIN_WORLD, {'A', 'G', ' '}}, //ANTIGUA AND BARBUDA
358 {REG_DOMAIN_WORLD, {'A', 'I', ' '}}, //ANGUILLA
359 {REG_DOMAIN_HI_5GHZ, {'A', 'L', ' '}}, //ALBANIA
360 {REG_DOMAIN_WORLD, {'A', 'M', ' '}}, //ARMENIA
361 {REG_DOMAIN_WORLD, {'A', 'N', ' '}}, //NETHERLANDS ANTILLES
362 {REG_DOMAIN_WORLD, {'A', 'O', ' '}}, //ANGOLA
363 {REG_DOMAIN_WORLD, {'A', 'Q', ' '}}, //ANTARCTICA
364 {REG_DOMAIN_HI_5GHZ, {'A', 'R', ' '}}, //ARGENTINA
365 {REG_DOMAIN_FCC, {'A', 'S', ' '}}, //AMERICAN SOMOA
366 {REG_DOMAIN_ETSI, {'A', 'T', ' '}}, //AUSTRIA
367 {REG_DOMAIN_ETSI, {'A', 'U', ' '}}, //AUSTRALIA
368 {REG_DOMAIN_WORLD, {'A', 'W', ' '}}, //ARUBA
369 {REG_DOMAIN_WORLD, {'A', 'X', ' '}}, //ALAND ISLANDS
370 {REG_DOMAIN_WORLD, {'A', 'Z', ' '}}, //AZERBAIJAN
371 {REG_DOMAIN_WORLD, {'B', 'A', ' '}}, //BOSNIA AND HERZEGOVINA
372 {REG_DOMAIN_WORLD, {'B', 'B', ' '}}, //BARBADOS
373 {REG_DOMAIN_WORLD, {'B', 'D', ' '}}, //BANGLADESH
374 {REG_DOMAIN_ETSI, {'B', 'E', ' '}}, //BELGIUM
375 {REG_DOMAIN_WORLD, {'B', 'F', ' '}}, //BURKINA FASO
376 {REG_DOMAIN_HI_5GHZ, {'B', 'G', ' '}}, //BULGARIA
377 {REG_DOMAIN_WORLD, {'B', 'H', ' '}}, //BAHRAIN
378 {REG_DOMAIN_WORLD, {'B', 'I', ' '}}, //BURUNDI
379 {REG_DOMAIN_WORLD, {'B', 'J', ' '}}, //BENIN
380 {REG_DOMAIN_WORLD, {'B', 'L', ' '}}, //SAINT BARTHELEMY
381 {REG_DOMAIN_ETSI, {'B', 'M', ' '}}, //BERMUDA
382 {REG_DOMAIN_WORLD, {'B', 'N', ' '}}, //BRUNEI DARUSSALAM
383 {REG_DOMAIN_WORLD, {'B', 'O', ' '}}, //BOLIVIA
384 {REG_DOMAIN_WORLD, {'B', 'R', ' '}}, //BRAZIL
385 {REG_DOMAIN_WORLD, {'B', 'S', ' '}}, //BAHAMAS
386 {REG_DOMAIN_WORLD, {'B', 'T', ' '}}, //BHUTAN
387 {REG_DOMAIN_WORLD, {'B', 'V', ' '}}, //BOUVET ISLAND
388 {REG_DOMAIN_WORLD, {'B', 'W', ' '}}, //BOTSWANA
389 {REG_DOMAIN_WORLD, {'B', 'Y', ' '}}, //BELARUS
390 {REG_DOMAIN_WORLD, {'B', 'Z', ' '}}, //BELIZE
391 {REG_DOMAIN_FCC, {'C', 'A', ' '}}, //CANADA
392 {REG_DOMAIN_WORLD, {'C', 'C', ' '}}, //COCOS (KEELING) ISLANDS
393 {REG_DOMAIN_WORLD, {'C', 'D', ' '}}, //CONGO, THE DEMOCRATIC REPUBLIC OF THE
394 {REG_DOMAIN_WORLD, {'C', 'F', ' '}}, //CENTRAL AFRICAN REPUBLIC
395 {REG_DOMAIN_WORLD, {'C', 'G', ' '}}, //CONGO
396 {REG_DOMAIN_ETSI, {'C', 'H', ' '}}, //SWITZERLAND
397 {REG_DOMAIN_WORLD, {'C', 'I', ' '}}, //COTE D'IVOIRE
398 {REG_DOMAIN_WORLD, {'C', 'K', ' '}}, //COOK ISLANDS
399 {REG_DOMAIN_WORLD, {'C', 'L', ' '}}, //CHILE
400 {REG_DOMAIN_WORLD, {'C', 'M', ' '}}, //CAMEROON
401 {REG_DOMAIN_HI_5GHZ, {'C', 'N', ' '}}, //CHINA
402 {REG_DOMAIN_WORLD, {'C', 'O', ' '}}, //COLOMBIA
403 {REG_DOMAIN_WORLD, {'C', 'R', ' '}}, //COSTA RICA
404 {REG_DOMAIN_WORLD, {'C', 'U', ' '}}, //CUBA
405 {REG_DOMAIN_WORLD, {'C', 'V', ' '}}, //CAPE VERDE
406 {REG_DOMAIN_WORLD, {'C', 'X', ' '}}, //CHRISTMAS ISLAND
407 {REG_DOMAIN_WORLD, {'C', 'Y', ' '}}, //CYPRUS
408 {REG_DOMAIN_HI_5GHZ, {'C', 'Z', ' '}}, //CZECH REPUBLIC
409 {REG_DOMAIN_ETSI, {'D', 'E', ' '}}, //GERMANY
410 {REG_DOMAIN_WORLD, {'D', 'J', ' '}}, //DJIBOUTI
411 {REG_DOMAIN_ETSI, {'D', 'K', ' '}}, //DENMARK
412 {REG_DOMAIN_WORLD, {'D', 'M', ' '}}, //DOMINICA
413 {REG_DOMAIN_WORLD, {'D', 'O', ' '}}, //DOMINICAN REPUBLIC
414 {REG_DOMAIN_WORLD, {'D', 'Z', ' '}}, //ALGERIA
415 {REG_DOMAIN_WORLD, {'E', 'C', ' '}}, //ECUADOR
416 {REG_DOMAIN_HI_5GHZ, {'E', 'E', ' '}}, //ESTONIA
417 {REG_DOMAIN_WORLD, {'E', 'G', ' '}}, //EGYPT
418 {REG_DOMAIN_WORLD, {'E', 'H', ' '}}, //WESTERN SAHARA
419 {REG_DOMAIN_WORLD, {'E', 'R', ' '}}, //ERITREA
420 {REG_DOMAIN_ETSI, {'E', 'S', ' '}}, //SPAIN
421 {REG_DOMAIN_WORLD, {'E', 'T', ' '}}, //ETHIOPIA
422 {REG_DOMAIN_WORLD, {'F', 'I', ' '}}, //FINLAND
423 {REG_DOMAIN_WORLD, {'F', 'J', ' '}}, //FIJI
424 {REG_DOMAIN_WORLD, {'F', 'K', ' '}}, //FALKLAND ISLANDS (MALVINAS)
425 {REG_DOMAIN_WORLD, {'F', 'M', ' '}}, //MICRONESIA, FEDERATED STATES OF
426 {REG_DOMAIN_WORLD, {'F', 'O', ' '}}, //FAROE ISLANDS
427 {REG_DOMAIN_ETSI, {'F', 'R', ' '}}, //FRANCE
428 {REG_DOMAIN_WORLD, {'G', 'A', ' '}}, //GABON
429 {REG_DOMAIN_ETSI, {'G', 'B', ' '}}, //UNITED KINGDOM
430 {REG_DOMAIN_WORLD, {'G', 'D', ' '}}, //GRENADA
431 {REG_DOMAIN_HI_5GHZ, {'G', 'E', ' '}}, //GEORGIA
432 {REG_DOMAIN_WORLD, {'G', 'F', ' '}}, //FRENCH GUIANA
433 {REG_DOMAIN_ETSI, {'G', 'G', ' '}}, //GUERNSEY
434 {REG_DOMAIN_WORLD, {'G', 'H', ' '}}, //GHANA
435 {REG_DOMAIN_WORLD, {'G', 'I', ' '}}, //GIBRALTAR
436 {REG_DOMAIN_WORLD, {'G', 'L', ' '}}, //GREENLAND
437 {REG_DOMAIN_WORLD, {'G', 'M', ' '}}, //GAMBIA
438 {REG_DOMAIN_WORLD, {'G', 'N', ' '}}, //GUINEA
439 {REG_DOMAIN_WORLD, {'G', 'P', ' '}}, //GUADELOUPE
440 {REG_DOMAIN_WORLD, {'G', 'Q', ' '}}, //EQUATORIAL GUINEA
441 {REG_DOMAIN_ETSI, {'G', 'R', ' '}}, //GREECE
442 {REG_DOMAIN_WORLD, {'G', 'S', ' '}}, //SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS
443 {REG_DOMAIN_WORLD, {'G', 'T', ' '}}, //GUATEMALA
444 {REG_DOMAIN_WORLD, {'G', 'U', ' '}}, //GUAM
445 {REG_DOMAIN_WORLD, {'G', 'W', ' '}}, //GUINEA-BISSAU
446 {REG_DOMAIN_WORLD, {'G', 'Y', ' '}}, //GUYANA
447 {REG_DOMAIN_WORLD, {'H', 'K', ' '}}, //HONGKONG
448 {REG_DOMAIN_WORLD, {'H', 'M', ' '}}, //HEARD ISLAND AND MCDONALD ISLANDS
449 {REG_DOMAIN_WORLD, {'H', 'N', ' '}}, //HONDURAS
450 {REG_DOMAIN_HI_5GHZ, {'H', 'R', ' '}}, //CROATIA
451 {REG_DOMAIN_WORLD, {'H', 'T', ' '}}, //HAITI
452 {REG_DOMAIN_HI_5GHZ, {'H', 'U', ' '}}, //HUNGARY
453 {REG_DOMAIN_APAC, {'I', 'D', ' '}}, //INDONESIA
454 {REG_DOMAIN_ETSI, {'I', 'E', ' '}}, //IRELAND
455 {REG_DOMAIN_WORLD, {'I', 'L', ' '}}, //ISREAL
456 {REG_DOMAIN_ETSI, {'I', 'M', ' '}}, //ISLE OF MAN
457 {REG_DOMAIN_WORLD, {'I', 'N', ' '}}, //INDIA
458 {REG_DOMAIN_ETSI, {'I', 'O', ' '}}, //BRITISH INDIAN OCEAN TERRITORY
459 {REG_DOMAIN_WORLD, {'I', 'Q', ' '}}, //IRAQ
460 {REG_DOMAIN_WORLD, {'I', 'R', ' '}}, //IRAN, ISLAMIC REPUBLIC OF
461 {REG_DOMAIN_WORLD, {'I', 'S', ' '}}, //ICELAND
462 {REG_DOMAIN_ETSI, {'I', 'T', ' '}}, //ITALY
463 {REG_DOMAIN_ETSI, {'J', 'E', ' '}}, //JERSEY
464 {REG_DOMAIN_WORLD, {'J', 'M', ' '}}, //JAMAICA
465 {REG_DOMAIN_WORLD, {'J', 'O', ' '}}, //JORDAN
466 {REG_DOMAIN_JAPAN, {'J', 'P', ' '}}, //JAPAN
467 {REG_DOMAIN_WORLD, {'K', 'E', ' '}}, //KENYA
468 {REG_DOMAIN_WORLD, {'K', 'G', ' '}}, //KYRGYZSTAN
469 {REG_DOMAIN_WORLD, {'K', 'H', ' '}}, //CAMBODIA
470 {REG_DOMAIN_WORLD, {'K', 'I', ' '}}, //KIRIBATI
471 {REG_DOMAIN_WORLD, {'K', 'M', ' '}}, //COMOROS
472 {REG_DOMAIN_WORLD, {'K', 'N', ' '}}, //SAINT KITTS AND NEVIS
473 {REG_DOMAIN_KOREA, {'K', 'P', ' '}}, //KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF
474 {REG_DOMAIN_KOREA, {'K', 'R', ' '}}, //KOREA, REPUBLIC OF
475 {REG_DOMAIN_WORLD, {'K', 'W', ' '}}, //KUWAIT
476 {REG_DOMAIN_WORLD, {'K', 'Y', ' '}}, //CAYMAN ISLANDS
477 {REG_DOMAIN_WORLD, {'K', 'Z', ' '}}, //KAZAKHSTAN
478 {REG_DOMAIN_WORLD, {'L', 'A', ' '}}, //LAO PEOPLE'S DEMOCRATIC REPUBLIC
479 {REG_DOMAIN_WORLD, {'L', 'B', ' '}}, //LEBANON
480 {REG_DOMAIN_WORLD, {'L', 'C', ' '}}, //SAINT LUCIA
481 {REG_DOMAIN_ETSI, {'L', 'I', ' '}}, //LIECHTENSTEIN
482 {REG_DOMAIN_WORLD, {'L', 'K', ' '}}, //SRI LANKA
483 {REG_DOMAIN_WORLD, {'L', 'R', ' '}}, //LIBERIA
484 {REG_DOMAIN_WORLD, {'L', 'S', ' '}}, //LESOTHO
485 {REG_DOMAIN_HI_5GHZ, {'L', 'T', ' '}}, //LITHUANIA
486 {REG_DOMAIN_ETSI, {'L', 'U', ' '}}, //LUXEMBOURG
487 {REG_DOMAIN_HI_5GHZ, {'L', 'V', ' '}}, //LATVIA
488 {REG_DOMAIN_WORLD, {'L', 'Y', ' '}}, //LIBYAN ARAB JAMAHIRIYA
489 {REG_DOMAIN_WORLD, {'M', 'A', ' '}}, //MOROCCO
490 {REG_DOMAIN_ETSI, {'M', 'C', ' '}}, //MONACO
491 {REG_DOMAIN_WORLD, {'M', 'D', ' '}}, //MOLDOVA, REPUBLIC OF
492 {REG_DOMAIN_WORLD, {'M', 'E', ' '}}, //MONTENEGRO
493 {REG_DOMAIN_WORLD, {'M', 'G', ' '}}, //MADAGASCAR
494 {REG_DOMAIN_WORLD, {'M', 'H', ' '}}, //MARSHALL ISLANDS
495 {REG_DOMAIN_WORLD, {'M', 'K', ' '}}, //MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF
496 {REG_DOMAIN_WORLD, {'M', 'L', ' '}}, //MALI
497 {REG_DOMAIN_WORLD, {'M', 'M', ' '}}, //MYANMAR
498 {REG_DOMAIN_HI_5GHZ, {'M', 'N', ' '}}, //MONGOLIA
499 {REG_DOMAIN_WORLD, {'M', 'O', ' '}}, //MACAO
500 {REG_DOMAIN_WORLD, {'M', 'P', ' '}}, //NORTHERN MARIANA ISLANDS
501 {REG_DOMAIN_WORLD, {'M', 'Q', ' '}}, //MARTINIQUE
502 {REG_DOMAIN_WORLD, {'M', 'R', ' '}}, //MAURITANIA
503 {REG_DOMAIN_WORLD, {'M', 'S', ' '}}, //MONTSERRAT
504 {REG_DOMAIN_WORLD, {'M', 'T', ' '}}, //MALTA
505 {REG_DOMAIN_WORLD, {'M', 'U', ' '}}, //MAURITIUS
506 {REG_DOMAIN_WORLD, {'M', 'V', ' '}}, //MALDIVES
507 {REG_DOMAIN_WORLD, {'M', 'W', ' '}}, //MALAWI
508 {REG_DOMAIN_WORLD, {'M', 'X', ' '}}, //MEXICO
509 {REG_DOMAIN_HI_5GHZ, {'M', 'Y', ' '}}, //MALAYSIA
510 {REG_DOMAIN_WORLD, {'M', 'Z', ' '}}, //MOZAMBIQUE
511 {REG_DOMAIN_WORLD, {'N', 'A', ' '}}, //NAMIBIA
512 {REG_DOMAIN_WORLD, {'N', 'C', ' '}}, //NEW CALEDONIA
513 {REG_DOMAIN_WORLD, {'N', 'E', ' '}}, //NIGER
514 {REG_DOMAIN_WORLD, {'N', 'F', ' '}}, //NORFOLD ISLAND
515 {REG_DOMAIN_WORLD, {'N', 'G', ' '}}, //NIGERIA
516 {REG_DOMAIN_WORLD, {'N', 'I', ' '}}, //NICARAGUA
517 {REG_DOMAIN_ETSI, {'N', 'L', ' '}}, //NETHERLANDS
518 {REG_DOMAIN_WORLD, {'N', 'O', ' '}}, //NORWAY
519 {REG_DOMAIN_WORLD, {'N', 'P', ' '}}, //NEPAL
520 {REG_DOMAIN_WORLD, {'N', 'R', ' '}}, //NAURU
521 {REG_DOMAIN_WORLD, {'N', 'U', ' '}}, //NIUE
522 {REG_DOMAIN_ETSI, {'N', 'Z', ' '}}, //NEW ZEALAND
523 {REG_DOMAIN_WORLD, {'O', 'M', ' '}}, //OMAN
524 {REG_DOMAIN_WORLD, {'P', 'A', ' '}}, //PANAMA
525 {REG_DOMAIN_WORLD, {'P', 'E', ' '}}, //PERU
526 {REG_DOMAIN_WORLD, {'P', 'F', ' '}}, //FRENCH POLYNESIA
527 {REG_DOMAIN_WORLD, {'P', 'G', ' '}}, //PAPUA NEW GUINEA
528 {REG_DOMAIN_WORLD, {'P', 'H', ' '}}, //PHILIPPINES
529 {REG_DOMAIN_WORLD, {'P', 'K', ' '}}, //PAKISTAN
530 {REG_DOMAIN_WORLD, {'P', 'L', ' '}}, //POLAND
531 {REG_DOMAIN_WORLD, {'P', 'M', ' '}}, //SAINT PIERRE AND MIQUELON
532 {REG_DOMAIN_WORLD, {'P', 'N', ' '}}, //PITCAIRN
533 {REG_DOMAIN_FCC, {'P', 'R', ' '}}, //PUERTO RICO
534 {REG_DOMAIN_WORLD, {'P', 'S', ' '}}, //PALESTINIAN TERRITORY, OCCUPIED
535 {REG_DOMAIN_ETSI, {'P', 'T', ' '}}, //PORTUGAL
536 {REG_DOMAIN_WORLD, {'P', 'W', ' '}}, //PALAU
537 {REG_DOMAIN_WORLD, {'P', 'Y', ' '}}, //PARAGUAY
538 {REG_DOMAIN_WORLD, {'Q', 'A', ' '}}, //QATAR
539 {REG_DOMAIN_WORLD, {'R', 'E', ' '}}, //REUNION
540 {REG_DOMAIN_HI_5GHZ, {'R', 'O', ' '}}, //ROMANIA
541 {REG_DOMAIN_HI_5GHZ, {'R', 'S', ' '}}, //SERBIA
542 {REG_DOMAIN_WORLD, {'R', 'U', ' '}}, //RUSSIA
543 {REG_DOMAIN_WORLD, {'R', 'W', ' '}}, //RWANDA
544 {REG_DOMAIN_WORLD, {'S', 'A', ' '}}, //SAUDI ARABIA
545 {REG_DOMAIN_WORLD, {'S', 'B', ' '}}, //SOLOMON ISLANDS
546 {REG_DOMAIN_ETSI, {'S', 'C', ' '}}, //SEYCHELLES
547 {REG_DOMAIN_WORLD, {'S', 'D', ' '}}, //SUDAN
548 {REG_DOMAIN_ETSI, {'S', 'E', ' '}}, //SWEDEN
549 {REG_DOMAIN_APAC, {'S', 'G', ' '}}, //SINGAPORE
550 {REG_DOMAIN_WORLD, {'S', 'H', ' '}}, //SAINT HELENA
551 {REG_DOMAIN_HI_5GHZ, {'S', 'I', ' '}}, //SLOVENNIA
552 {REG_DOMAIN_WORLD, {'S', 'J', ' '}}, //SVALBARD AND JAN MAYEN
553 {REG_DOMAIN_HI_5GHZ, {'S', 'K', ' '}}, //SLOVAKIA
554 {REG_DOMAIN_WORLD, {'S', 'L', ' '}}, //SIERRA LEONE
555 {REG_DOMAIN_WORLD, {'S', 'M', ' '}}, //SAN MARINO
556 {REG_DOMAIN_WORLD, {'S', 'N', ' '}}, //SENEGAL
557 {REG_DOMAIN_WORLD, {'S', 'O', ' '}}, //SOMALIA
558 {REG_DOMAIN_WORLD, {'S', 'R', ' '}}, //SURINAME
559 {REG_DOMAIN_WORLD, {'S', 'T', ' '}}, //SAO TOME AND PRINCIPE
560 {REG_DOMAIN_WORLD, {'S', 'V', ' '}}, //EL SALVADOR
561 {REG_DOMAIN_WORLD, {'S', 'Y', ' '}}, //SYRIAN ARAB REPUBLIC
562 {REG_DOMAIN_WORLD, {'S', 'Z', ' '}}, //SWAZILAND
563 {REG_DOMAIN_WORLD, {'T', 'C', ' '}}, //TURKS AND CAICOS ISLANDS
564 {REG_DOMAIN_WORLD, {'T', 'D', ' '}}, //CHAD
565 {REG_DOMAIN_WORLD, {'T', 'F', ' '}}, //FRENCH SOUTHERN TERRITORIES
566 {REG_DOMAIN_WORLD, {'T', 'G', ' '}}, //TOGO
567 {REG_DOMAIN_WORLD, {'T', 'H', ' '}}, //THAILAND
568 {REG_DOMAIN_WORLD, {'T', 'J', ' '}}, //TAJIKISTAN
569 {REG_DOMAIN_WORLD, {'T', 'K', ' '}}, //TOKELAU
570 {REG_DOMAIN_WORLD, {'T', 'L', ' '}}, //TIMOR-LESTE
571 {REG_DOMAIN_WORLD, {'T', 'M', ' '}}, //TURKMENISTAN
572 {REG_DOMAIN_WORLD, {'T', 'N', ' '}}, //TUNISIA
573 {REG_DOMAIN_WORLD, {'T', 'O', ' '}}, //TONGA
574 {REG_DOMAIN_WORLD, {'T', 'R', ' '}}, //TURKEY
575 {REG_DOMAIN_WORLD, {'T', 'T', ' '}}, //TRINIDAD AND TOBAGO
576 {REG_DOMAIN_WORLD, {'T', 'V', ' '}}, //TUVALU
577 {REG_DOMAIN_HI_5GHZ, {'T', 'W', ' '}}, //TAIWAN, PROVINCE OF CHINA
578 {REG_DOMAIN_WORLD, {'T', 'Z', ' '}}, //TANZANIA, UNITED REPUBLIC OF
579 {REG_DOMAIN_HI_5GHZ, {'U', 'A', ' '}}, //UKRAINE
580 {REG_DOMAIN_WORLD, {'U', 'G', ' '}}, //UGANDA
581 {REG_DOMAIN_FCC, {'U', 'M', ' '}}, //UNITED STATES MINOR OUTLYING ISLANDS
582 {REG_DOMAIN_WORLD, {'U', 'Y', ' '}}, //URUGUAY
583 {REG_DOMAIN_HI_5GHZ, {'U', 'Z', ' '}}, //UZBEKISTAN
584 {REG_DOMAIN_ETSI, {'V', 'A', ' '}}, //HOLY SEE (VATICAN CITY STATE)
585 {REG_DOMAIN_WORLD, {'V', 'C', ' '}}, //SAINT VINCENT AND THE GRENADINES
586 {REG_DOMAIN_HI_5GHZ, {'V', 'E', ' '}}, //VENEZUELA
587 {REG_DOMAIN_ETSI, {'V', 'G', ' '}}, //VIRGIN ISLANDS, BRITISH
588 {REG_DOMAIN_FCC, {'V', 'I', ' '}}, //VIRGIN ISLANDS, US
589 {REG_DOMAIN_WORLD, {'V', 'N', ' '}}, //VIET NAM
590 {REG_DOMAIN_WORLD, {'V', 'U', ' '}}, //VANUATU
591 {REG_DOMAIN_WORLD, {'W', 'F', ' '}}, //WALLIS AND FUTUNA
592 {REG_DOMAIN_WORLD, {'W', 'S', ' '}}, //SOMOA
593 {REG_DOMAIN_WORLD, {'Y', 'E', ' '}}, //YEMEN
594 {REG_DOMAIN_WORLD, {'Y', 'T', ' '}}, //MAYOTTE
595 {REG_DOMAIN_WORLD, {'Z', 'A', ' '}}, //SOUTH AFRICA
596 {REG_DOMAIN_WORLD, {'Z', 'M', ' '}}, //ZAMBIA
597 {REG_DOMAIN_WORLD, {'Z', 'W', ' '}}, //ZIMBABWE
598
599 {REG_DOMAIN_KOREA, {'K', '1', ' '}}, //Korea alternate 1
600 {REG_DOMAIN_KOREA, {'K', '2', ' '}}, //Korea alternate 2
601 {REG_DOMAIN_KOREA, {'K', '3', ' '}}, //Korea alternate 3
602 {REG_DOMAIN_KOREA, {'K', '4', ' '}}, //Korea alternate 4
603};
604
605
606//The channels listed here doesn't mean they are valid channels for certain domain. They are here only to present
607//whether they should be passive scanned.
608tCsrDomainChnInfo gCsrDomainChnInfo[NUM_REG_DOMAINS] =
609{
610 //REG_DOMAIN_FCC
611 {
612 REG_DOMAIN_FCC,
613 45, //Num channels
614 //Channels
615 {
616 //5GHz
617 //5180 - 5240
618 {36, eSIR_ACTIVE_SCAN},
619 {40, eSIR_ACTIVE_SCAN},
620 {44, eSIR_ACTIVE_SCAN},
621 {48, eSIR_ACTIVE_SCAN},
622 //5250 to 5350
623 {52, eSIR_PASSIVE_SCAN},
624 {56, eSIR_PASSIVE_SCAN},
625 {60, eSIR_PASSIVE_SCAN},
626 {64, eSIR_PASSIVE_SCAN},
627 //5470 to 5725
628 {100, eSIR_PASSIVE_SCAN},
629 {104, eSIR_PASSIVE_SCAN},
630 {108, eSIR_PASSIVE_SCAN},
631 {112, eSIR_PASSIVE_SCAN},
632 {116, eSIR_PASSIVE_SCAN},
633 {120, eSIR_PASSIVE_SCAN},
634 {124, eSIR_PASSIVE_SCAN},
635 {128, eSIR_PASSIVE_SCAN},
636 {132, eSIR_PASSIVE_SCAN},
637 {136, eSIR_PASSIVE_SCAN},
638 {140, eSIR_PASSIVE_SCAN},
639 //5745 - 5825
640 {149, eSIR_ACTIVE_SCAN},
641 {153, eSIR_ACTIVE_SCAN},
642 {157, eSIR_ACTIVE_SCAN},
643 {161, eSIR_ACTIVE_SCAN},
644 {165, eSIR_ACTIVE_SCAN},
645 //4.9GHz
646 //4920 - 5080
647 {240, eSIR_ACTIVE_SCAN},
648 {244, eSIR_ACTIVE_SCAN},
649 {248, eSIR_ACTIVE_SCAN},
650 {252, eSIR_ACTIVE_SCAN},
651 {208, eSIR_ACTIVE_SCAN},
652 {212, eSIR_ACTIVE_SCAN},
653 {216, eSIR_ACTIVE_SCAN},
654 //2,4GHz
655 {1, eSIR_ACTIVE_SCAN},
656 {2, eSIR_ACTIVE_SCAN},
657 {3, eSIR_ACTIVE_SCAN},
658 {4, eSIR_ACTIVE_SCAN},
659 {5, eSIR_ACTIVE_SCAN},
660 {6, eSIR_ACTIVE_SCAN},
661 {7, eSIR_ACTIVE_SCAN},
662 {8, eSIR_ACTIVE_SCAN},
663 {9, eSIR_ACTIVE_SCAN},
664 {10, eSIR_ACTIVE_SCAN},
665 {11, eSIR_ACTIVE_SCAN},
666 {12, eSIR_ACTIVE_SCAN},
667 {13, eSIR_ACTIVE_SCAN},
668 {14, eSIR_ACTIVE_SCAN},
669 }
670 },
671 //REG_DOMAIN_ETSI
672 {
673 REG_DOMAIN_ETSI,
674 45, //Num channels
675 //Channels
676 {
677 //5GHz
678 //5180 - 5240
679 {36, eSIR_ACTIVE_SCAN},
680 {40, eSIR_ACTIVE_SCAN},
681 {44, eSIR_ACTIVE_SCAN},
682 {48, eSIR_ACTIVE_SCAN},
683 //5250 to 5350
684 {52, eSIR_PASSIVE_SCAN},
685 {56, eSIR_PASSIVE_SCAN},
686 {60, eSIR_PASSIVE_SCAN},
687 {64, eSIR_PASSIVE_SCAN},
688 //5470 to 5725
689 {100, eSIR_PASSIVE_SCAN},
690 {104, eSIR_PASSIVE_SCAN},
691 {108, eSIR_PASSIVE_SCAN},
692 {112, eSIR_PASSIVE_SCAN},
693 {116, eSIR_PASSIVE_SCAN},
694 {120, eSIR_PASSIVE_SCAN},
695 {124, eSIR_PASSIVE_SCAN},
696 {128, eSIR_PASSIVE_SCAN},
697 {132, eSIR_PASSIVE_SCAN},
698 {136, eSIR_PASSIVE_SCAN},
699 {140, eSIR_PASSIVE_SCAN},
700 //5745 - 5825
701 {149, eSIR_ACTIVE_SCAN},
702 {153, eSIR_ACTIVE_SCAN},
703 {157, eSIR_ACTIVE_SCAN},
704 {161, eSIR_ACTIVE_SCAN},
705 {165, eSIR_ACTIVE_SCAN},
706 //4.9GHz
707 //4920 - 5080
708 {240, eSIR_ACTIVE_SCAN},
709 {244, eSIR_ACTIVE_SCAN},
710 {248, eSIR_ACTIVE_SCAN},
711 {252, eSIR_ACTIVE_SCAN},
712 {208, eSIR_ACTIVE_SCAN},
713 {212, eSIR_ACTIVE_SCAN},
714 {216, eSIR_ACTIVE_SCAN},
715 //2,4GHz
716 {1, eSIR_ACTIVE_SCAN},
717 {2, eSIR_ACTIVE_SCAN},
718 {3, eSIR_ACTIVE_SCAN},
719 {4, eSIR_ACTIVE_SCAN},
720 {5, eSIR_ACTIVE_SCAN},
721 {6, eSIR_ACTIVE_SCAN},
722 {7, eSIR_ACTIVE_SCAN},
723 {8, eSIR_ACTIVE_SCAN},
724 {9, eSIR_ACTIVE_SCAN},
725 {10, eSIR_ACTIVE_SCAN},
726 {11, eSIR_ACTIVE_SCAN},
727 {12, eSIR_ACTIVE_SCAN},
728 {13, eSIR_ACTIVE_SCAN},
729 {14, eSIR_ACTIVE_SCAN},
730 }
731 },
732 //REG_DOMAIN_JAPAN
733 {
734 REG_DOMAIN_JAPAN,
735 45, //Num channels
736 //Channels
737 {
738 //5GHz
739 //5180 - 5240
740 {36, eSIR_ACTIVE_SCAN},
741 {40, eSIR_ACTIVE_SCAN},
742 {44, eSIR_ACTIVE_SCAN},
743 {48, eSIR_ACTIVE_SCAN},
744 //5250 to 5350
745 {52, eSIR_PASSIVE_SCAN},
746 {56, eSIR_PASSIVE_SCAN},
747 {60, eSIR_PASSIVE_SCAN},
748 {64, eSIR_PASSIVE_SCAN},
749 //5470 to 5725
750 {100, eSIR_PASSIVE_SCAN},
751 {104, eSIR_PASSIVE_SCAN},
752 {108, eSIR_PASSIVE_SCAN},
753 {112, eSIR_PASSIVE_SCAN},
754 {116, eSIR_PASSIVE_SCAN},
755 {120, eSIR_PASSIVE_SCAN},
756 {124, eSIR_PASSIVE_SCAN},
757 {128, eSIR_PASSIVE_SCAN},
758 {132, eSIR_PASSIVE_SCAN},
759 {136, eSIR_PASSIVE_SCAN},
760 {140, eSIR_PASSIVE_SCAN},
761 //5745 - 5825
762 {149, eSIR_ACTIVE_SCAN},
763 {153, eSIR_ACTIVE_SCAN},
764 {157, eSIR_ACTIVE_SCAN},
765 {161, eSIR_ACTIVE_SCAN},
766 {165, eSIR_ACTIVE_SCAN},
767 //4.9GHz
768 //4920 - 5080
769 {240, eSIR_ACTIVE_SCAN},
770 {244, eSIR_ACTIVE_SCAN},
771 {248, eSIR_ACTIVE_SCAN},
772 {252, eSIR_ACTIVE_SCAN},
773 {208, eSIR_ACTIVE_SCAN},
774 {212, eSIR_ACTIVE_SCAN},
775 {216, eSIR_ACTIVE_SCAN},
776 //2,4GHz
777 {1, eSIR_ACTIVE_SCAN},
778 {2, eSIR_ACTIVE_SCAN},
779 {3, eSIR_ACTIVE_SCAN},
780 {4, eSIR_ACTIVE_SCAN},
781 {5, eSIR_ACTIVE_SCAN},
782 {6, eSIR_ACTIVE_SCAN},
783 {7, eSIR_ACTIVE_SCAN},
784 {8, eSIR_ACTIVE_SCAN},
785 {9, eSIR_ACTIVE_SCAN},
786 {10, eSIR_ACTIVE_SCAN},
787 {11, eSIR_ACTIVE_SCAN},
788 {12, eSIR_ACTIVE_SCAN},
789 {13, eSIR_ACTIVE_SCAN},
790 {14, eSIR_ACTIVE_SCAN},
791 }
792 },
793 //REG_DOMAIN_WORLD
794 {
795 REG_DOMAIN_WORLD,
796 45, //Num channels
797 //Channels
798 {
799 //5GHz
800 //5180 - 5240
801 {36, eSIR_ACTIVE_SCAN},
802 {40, eSIR_ACTIVE_SCAN},
803 {44, eSIR_ACTIVE_SCAN},
804 {48, eSIR_ACTIVE_SCAN},
805 //5250 to 5350
806 {52, eSIR_ACTIVE_SCAN},
807 {56, eSIR_ACTIVE_SCAN},
808 {60, eSIR_ACTIVE_SCAN},
809 {64, eSIR_ACTIVE_SCAN},
810 //5470 to 5725
811 {100, eSIR_ACTIVE_SCAN},
812 {104, eSIR_ACTIVE_SCAN},
813 {108, eSIR_ACTIVE_SCAN},
814 {112, eSIR_ACTIVE_SCAN},
815 {116, eSIR_ACTIVE_SCAN},
816 {120, eSIR_ACTIVE_SCAN},
817 {124, eSIR_ACTIVE_SCAN},
818 {128, eSIR_ACTIVE_SCAN},
819 {132, eSIR_ACTIVE_SCAN},
820 {136, eSIR_ACTIVE_SCAN},
821 {140, eSIR_ACTIVE_SCAN},
822 //5745 - 5825
823 {149, eSIR_ACTIVE_SCAN},
824 {153, eSIR_ACTIVE_SCAN},
825 {157, eSIR_ACTIVE_SCAN},
826 {161, eSIR_ACTIVE_SCAN},
827 {165, eSIR_ACTIVE_SCAN},
828 //4.9GHz
829 //4920 - 5080
830 {240, eSIR_ACTIVE_SCAN},
831 {244, eSIR_ACTIVE_SCAN},
832 {248, eSIR_ACTIVE_SCAN},
833 {252, eSIR_ACTIVE_SCAN},
834 {208, eSIR_ACTIVE_SCAN},
835 {212, eSIR_ACTIVE_SCAN},
836 {216, eSIR_ACTIVE_SCAN},
837 //2,4GHz
838 {1, eSIR_ACTIVE_SCAN},
839 {2, eSIR_ACTIVE_SCAN},
840 {3, eSIR_ACTIVE_SCAN},
841 {4, eSIR_ACTIVE_SCAN},
842 {5, eSIR_ACTIVE_SCAN},
843 {6, eSIR_ACTIVE_SCAN},
844 {7, eSIR_ACTIVE_SCAN},
845 {8, eSIR_ACTIVE_SCAN},
846 {9, eSIR_ACTIVE_SCAN},
847 {10, eSIR_ACTIVE_SCAN},
848 {11, eSIR_ACTIVE_SCAN},
849 {12, eSIR_ACTIVE_SCAN},
850 {13, eSIR_ACTIVE_SCAN},
851 {14, eSIR_ACTIVE_SCAN},
852 }
853 },
854 //REG_DOMAIN_N_AMER_EXC_FCC
855 {
856 REG_DOMAIN_N_AMER_EXC_FCC,
857 45, //Num channels
858 //Channels
859 {
860 //5GHz
861 //5180 - 5240
862 {36, eSIR_ACTIVE_SCAN},
863 {40, eSIR_ACTIVE_SCAN},
864 {44, eSIR_ACTIVE_SCAN},
865 {48, eSIR_ACTIVE_SCAN},
866 //5250 to 5350
867 {52, eSIR_PASSIVE_SCAN},
868 {56, eSIR_PASSIVE_SCAN},
869 {60, eSIR_PASSIVE_SCAN},
870 {64, eSIR_PASSIVE_SCAN},
871 //5470 to 5725
872 {100, eSIR_ACTIVE_SCAN},
873 {104, eSIR_ACTIVE_SCAN},
874 {108, eSIR_ACTIVE_SCAN},
875 {112, eSIR_ACTIVE_SCAN},
876 {116, eSIR_ACTIVE_SCAN},
877 {120, eSIR_ACTIVE_SCAN},
878 {124, eSIR_ACTIVE_SCAN},
879 {128, eSIR_ACTIVE_SCAN},
880 {132, eSIR_ACTIVE_SCAN},
881 {136, eSIR_ACTIVE_SCAN},
882 {140, eSIR_ACTIVE_SCAN},
883 //5745 - 5825
884 {149, eSIR_ACTIVE_SCAN},
885 {153, eSIR_ACTIVE_SCAN},
886 {157, eSIR_ACTIVE_SCAN},
887 {161, eSIR_ACTIVE_SCAN},
888 {165, eSIR_ACTIVE_SCAN},
889 //4.9GHz
890 //4920 - 5080
891 {240, eSIR_ACTIVE_SCAN},
892 {244, eSIR_ACTIVE_SCAN},
893 {248, eSIR_ACTIVE_SCAN},
894 {252, eSIR_ACTIVE_SCAN},
895 {208, eSIR_ACTIVE_SCAN},
896 {212, eSIR_ACTIVE_SCAN},
897 {216, eSIR_ACTIVE_SCAN},
898 //2,4GHz
899 {1, eSIR_ACTIVE_SCAN},
900 {2, eSIR_ACTIVE_SCAN},
901 {3, eSIR_ACTIVE_SCAN},
902 {4, eSIR_ACTIVE_SCAN},
903 {5, eSIR_ACTIVE_SCAN},
904 {6, eSIR_ACTIVE_SCAN},
905 {7, eSIR_ACTIVE_SCAN},
906 {8, eSIR_ACTIVE_SCAN},
907 {9, eSIR_ACTIVE_SCAN},
908 {10, eSIR_ACTIVE_SCAN},
909 {11, eSIR_ACTIVE_SCAN},
910 {12, eSIR_ACTIVE_SCAN},
911 {13, eSIR_ACTIVE_SCAN},
912 {14, eSIR_ACTIVE_SCAN},
913 }
914 },
915 //REG_DOMAIN_APAC
916 {
917 REG_DOMAIN_APAC,
918 45, //Num channels
919 //Channels
920 {
921 //5GHz
922 //5180 - 5240
923 {36, eSIR_ACTIVE_SCAN},
924 {40, eSIR_ACTIVE_SCAN},
925 {44, eSIR_ACTIVE_SCAN},
926 {48, eSIR_ACTIVE_SCAN},
927 //5250 to 5350
928 {52, eSIR_PASSIVE_SCAN},
929 {56, eSIR_PASSIVE_SCAN},
930 {60, eSIR_PASSIVE_SCAN},
931 {64, eSIR_PASSIVE_SCAN},
932 //5470 to 5725
933 {100, eSIR_ACTIVE_SCAN},
934 {104, eSIR_ACTIVE_SCAN},
935 {108, eSIR_ACTIVE_SCAN},
936 {112, eSIR_ACTIVE_SCAN},
937 {116, eSIR_ACTIVE_SCAN},
938 {120, eSIR_ACTIVE_SCAN},
939 {124, eSIR_ACTIVE_SCAN},
940 {128, eSIR_ACTIVE_SCAN},
941 {132, eSIR_ACTIVE_SCAN},
942 {136, eSIR_ACTIVE_SCAN},
943 {140, eSIR_ACTIVE_SCAN},
944 //5745 - 5825
945 {149, eSIR_ACTIVE_SCAN},
946 {153, eSIR_ACTIVE_SCAN},
947 {157, eSIR_ACTIVE_SCAN},
948 {161, eSIR_ACTIVE_SCAN},
949 {165, eSIR_ACTIVE_SCAN},
950 //4.9GHz
951 //4920 - 5080
952 {240, eSIR_ACTIVE_SCAN},
953 {244, eSIR_ACTIVE_SCAN},
954 {248, eSIR_ACTIVE_SCAN},
955 {252, eSIR_ACTIVE_SCAN},
956 {208, eSIR_ACTIVE_SCAN},
957 {212, eSIR_ACTIVE_SCAN},
958 {216, eSIR_ACTIVE_SCAN},
959 //2,4GHz
960 {1, eSIR_ACTIVE_SCAN},
961 {2, eSIR_ACTIVE_SCAN},
962 {3, eSIR_ACTIVE_SCAN},
963 {4, eSIR_ACTIVE_SCAN},
964 {5, eSIR_ACTIVE_SCAN},
965 {6, eSIR_ACTIVE_SCAN},
966 {7, eSIR_ACTIVE_SCAN},
967 {8, eSIR_ACTIVE_SCAN},
968 {9, eSIR_ACTIVE_SCAN},
969 {10, eSIR_ACTIVE_SCAN},
970 {11, eSIR_ACTIVE_SCAN},
971 {12, eSIR_ACTIVE_SCAN},
972 {13, eSIR_ACTIVE_SCAN},
973 {14, eSIR_ACTIVE_SCAN},
974 }
975 },
976 //REG_DOMAIN_KOREA
977 {
978 REG_DOMAIN_KOREA,
979 45, //Num channels
980 //Channels
981 {
982 //5GHz
983 //5180 - 5240
984 {36, eSIR_ACTIVE_SCAN},
985 {40, eSIR_ACTIVE_SCAN},
986 {44, eSIR_ACTIVE_SCAN},
987 {48, eSIR_ACTIVE_SCAN},
988 //5250 to 5350
989 {52, eSIR_PASSIVE_SCAN},
990 {56, eSIR_PASSIVE_SCAN},
991 {60, eSIR_PASSIVE_SCAN},
992 {64, eSIR_PASSIVE_SCAN},
993 //5470 to 5725
994 {100, eSIR_PASSIVE_SCAN},
995 {104, eSIR_PASSIVE_SCAN},
996 {108, eSIR_PASSIVE_SCAN},
997 {112, eSIR_PASSIVE_SCAN},
998 {116, eSIR_PASSIVE_SCAN},
999 {120, eSIR_PASSIVE_SCAN},
1000 {124, eSIR_PASSIVE_SCAN},
1001 {128, eSIR_PASSIVE_SCAN},
1002 {132, eSIR_PASSIVE_SCAN},
1003 {136, eSIR_PASSIVE_SCAN},
1004 {140, eSIR_PASSIVE_SCAN},
1005 //5745 - 5825
1006 {149, eSIR_ACTIVE_SCAN},
1007 {153, eSIR_ACTIVE_SCAN},
1008 {157, eSIR_ACTIVE_SCAN},
1009 {161, eSIR_ACTIVE_SCAN},
1010 {165, eSIR_ACTIVE_SCAN},
1011 //4.9GHz
1012 //4920 - 5080
1013 {240, eSIR_ACTIVE_SCAN},
1014 {244, eSIR_ACTIVE_SCAN},
1015 {248, eSIR_ACTIVE_SCAN},
1016 {252, eSIR_ACTIVE_SCAN},
1017 {208, eSIR_ACTIVE_SCAN},
1018 {212, eSIR_ACTIVE_SCAN},
1019 {216, eSIR_ACTIVE_SCAN},
1020 //2,4GHz
1021 {1, eSIR_ACTIVE_SCAN},
1022 {2, eSIR_ACTIVE_SCAN},
1023 {3, eSIR_ACTIVE_SCAN},
1024 {4, eSIR_ACTIVE_SCAN},
1025 {5, eSIR_ACTIVE_SCAN},
1026 {6, eSIR_ACTIVE_SCAN},
1027 {7, eSIR_ACTIVE_SCAN},
1028 {8, eSIR_ACTIVE_SCAN},
1029 {9, eSIR_ACTIVE_SCAN},
1030 {10, eSIR_ACTIVE_SCAN},
1031 {11, eSIR_ACTIVE_SCAN},
1032 {12, eSIR_ACTIVE_SCAN},
1033 {13, eSIR_ACTIVE_SCAN},
1034 {14, eSIR_ACTIVE_SCAN},
1035 }
1036 },
1037 //REG_DOMAIN_HI_5GHZ
1038 {
1039 REG_DOMAIN_HI_5GHZ,
1040 45, //Num channels
1041 //Channels
1042 {
1043 //5GHz
1044 //5180 - 5240
1045 {36, eSIR_ACTIVE_SCAN},
1046 {40, eSIR_ACTIVE_SCAN},
1047 {44, eSIR_ACTIVE_SCAN},
1048 {48, eSIR_ACTIVE_SCAN},
1049 //5250 to 5350
1050 {52, eSIR_ACTIVE_SCAN},
1051 {56, eSIR_ACTIVE_SCAN},
1052 {60, eSIR_ACTIVE_SCAN},
1053 {64, eSIR_ACTIVE_SCAN},
1054 //5470 to 5725
1055 {100, eSIR_ACTIVE_SCAN},
1056 {104, eSIR_ACTIVE_SCAN},
1057 {108, eSIR_ACTIVE_SCAN},
1058 {112, eSIR_ACTIVE_SCAN},
1059 {116, eSIR_ACTIVE_SCAN},
1060 {120, eSIR_ACTIVE_SCAN},
1061 {124, eSIR_ACTIVE_SCAN},
1062 {128, eSIR_ACTIVE_SCAN},
1063 {132, eSIR_ACTIVE_SCAN},
1064 {136, eSIR_ACTIVE_SCAN},
1065 {140, eSIR_ACTIVE_SCAN},
1066 //5745 - 5825
1067 {149, eSIR_ACTIVE_SCAN},
1068 {153, eSIR_ACTIVE_SCAN},
1069 {157, eSIR_ACTIVE_SCAN},
1070 {161, eSIR_ACTIVE_SCAN},
1071 {165, eSIR_ACTIVE_SCAN},
1072 //4.9GHz
1073 //4920 - 5080
1074 {240, eSIR_ACTIVE_SCAN},
1075 {244, eSIR_ACTIVE_SCAN},
1076 {248, eSIR_ACTIVE_SCAN},
1077 {252, eSIR_ACTIVE_SCAN},
1078 {208, eSIR_ACTIVE_SCAN},
1079 {212, eSIR_ACTIVE_SCAN},
1080 {216, eSIR_ACTIVE_SCAN},
1081 //2,4GHz
1082 {1, eSIR_ACTIVE_SCAN},
1083 {2, eSIR_ACTIVE_SCAN},
1084 {3, eSIR_ACTIVE_SCAN},
1085 {4, eSIR_ACTIVE_SCAN},
1086 {5, eSIR_ACTIVE_SCAN},
1087 {6, eSIR_ACTIVE_SCAN},
1088 {7, eSIR_ACTIVE_SCAN},
1089 {8, eSIR_ACTIVE_SCAN},
1090 {9, eSIR_ACTIVE_SCAN},
1091 {10, eSIR_ACTIVE_SCAN},
1092 {11, eSIR_ACTIVE_SCAN},
1093 {12, eSIR_ACTIVE_SCAN},
1094 {13, eSIR_ACTIVE_SCAN},
1095 {14, eSIR_ACTIVE_SCAN},
1096 }
1097 },
1098 //REG_DOMAIN_NO_5GHZ
1099 {
1100 REG_DOMAIN_NO_5GHZ,
1101 45, //Num channels
1102 //Channels
1103 {
1104 //5GHz
1105 //5180 - 5240
1106 {36, eSIR_ACTIVE_SCAN},
1107 {40, eSIR_ACTIVE_SCAN},
1108 {44, eSIR_ACTIVE_SCAN},
1109 {48, eSIR_ACTIVE_SCAN},
1110 //5250 to 5350
1111 {52, eSIR_ACTIVE_SCAN},
1112 {56, eSIR_ACTIVE_SCAN},
1113 {60, eSIR_ACTIVE_SCAN},
1114 {64, eSIR_ACTIVE_SCAN},
1115 //5470 to 5725
1116 {100, eSIR_ACTIVE_SCAN},
1117 {104, eSIR_ACTIVE_SCAN},
1118 {108, eSIR_ACTIVE_SCAN},
1119 {112, eSIR_ACTIVE_SCAN},
1120 {116, eSIR_ACTIVE_SCAN},
1121 {120, eSIR_ACTIVE_SCAN},
1122 {124, eSIR_ACTIVE_SCAN},
1123 {128, eSIR_ACTIVE_SCAN},
1124 {132, eSIR_ACTIVE_SCAN},
1125 {136, eSIR_ACTIVE_SCAN},
1126 {140, eSIR_ACTIVE_SCAN},
1127 //5745 - 5825
1128 {149, eSIR_ACTIVE_SCAN},
1129 {153, eSIR_ACTIVE_SCAN},
1130 {157, eSIR_ACTIVE_SCAN},
1131 {161, eSIR_ACTIVE_SCAN},
1132 {165, eSIR_ACTIVE_SCAN},
1133 //4.9GHz
1134 //4920 - 5080
1135 {240, eSIR_ACTIVE_SCAN},
1136 {244, eSIR_ACTIVE_SCAN},
1137 {248, eSIR_ACTIVE_SCAN},
1138 {252, eSIR_ACTIVE_SCAN},
1139 {208, eSIR_ACTIVE_SCAN},
1140 {212, eSIR_ACTIVE_SCAN},
1141 {216, eSIR_ACTIVE_SCAN},
1142 //2,4GHz
1143 {1, eSIR_ACTIVE_SCAN},
1144 {2, eSIR_ACTIVE_SCAN},
1145 {3, eSIR_ACTIVE_SCAN},
1146 {4, eSIR_ACTIVE_SCAN},
1147 {5, eSIR_ACTIVE_SCAN},
1148 {6, eSIR_ACTIVE_SCAN},
1149 {7, eSIR_ACTIVE_SCAN},
1150 {8, eSIR_ACTIVE_SCAN},
1151 {9, eSIR_ACTIVE_SCAN},
1152 {10, eSIR_ACTIVE_SCAN},
1153 {11, eSIR_ACTIVE_SCAN},
1154 {12, eSIR_ACTIVE_SCAN},
1155 {13, eSIR_ACTIVE_SCAN},
1156 {14, eSIR_ACTIVE_SCAN},
1157 }
1158 },
1159};
1160#endif
1161
1162extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
1163
Jeff Johnson295189b2012-06-20 16:38:30 -07001164////////////////////////////////////////////////////////////////////////
1165
1166/**
1167 * \var gPhyRatesSuppt
1168 *
1169 * \brief Rate support lookup table
1170 *
1171 *
1172 * This is a lookup table indexing rates & configuration parameters to
1173 * support. Given a rate (in unites of 0.5Mpbs) & three booleans (MIMO
1174 * Enabled, Channel Bonding Enabled, & Concatenation Enabled), one can
1175 * determine whether the given rate is supported by computing two
1176 * indices. The first maps the rate to table row as indicated below
1177 * (i.e. eHddSuppRate_6Mbps maps to row zero, eHddSuppRate_9Mbps to row
1178 * 1, and so on). Index two can be computed like so:
1179 *
1180 * \code
1181 idx2 = ( fEsf ? 0x4 : 0x0 ) |
1182 ( fCb ? 0x2 : 0x0 ) |
1183 ( fMimo ? 0x1 : 0x0 );
1184 * \endcode
1185 *
1186 *
1187 * Given that:
1188 *
1189 \code
1190 fSupported = gPhyRatesSuppt[idx1][idx2];
1191 \endcode
1192 *
1193 *
1194 * This table is based on the document "PHY Supported Rates.doc". This
1195 * table is permissive in that a rate is reflected as being supported
1196 * even when turning off an enabled feature would be required. For
1197 * instance, "PHY Supported Rates" lists 42Mpbs as unsupported when CB,
1198 * ESF, & MIMO are all on. However, if we turn off either of CB or
1199 * MIMO, it then becomes supported. Therefore, we mark it as supported
1200 * even in index 7 of this table.
1201 *
1202 *
1203 */
1204
1205static const tANI_BOOLEAN gPhyRatesSuppt[24][8] = {
1206
1207 // SSF SSF SSF SSF ESF ESF ESF ESF
1208 // SIMO MIMO SIMO MIMO SIMO MIMO SIMO MIMO
1209 // No CB No CB CB CB No CB No CB CB CB
1210 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 6Mbps
1211 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 9Mbps
1212 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 12Mbps
1213 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 18Mbps
1214 { FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE }, // 20Mbps
1215 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 24Mbps
1216 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 36Mbps
1217 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 40Mbps
1218 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 42Mbps
1219 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 48Mbps
1220 { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, // 54Mbps
1221 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 72Mbps
1222 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 80Mbps
1223 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 84Mbps
1224 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 96Mbps
1225 { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 108Mbps
1226 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 120Mbps
1227 { FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE }, // 126Mbps
1228 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 144Mbps
1229 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 160Mbps
1230 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 168Mbps
1231 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 192Mbps
1232 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 216Mbps
1233 { FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE }, // 240Mbps
1234
1235};
1236
1237#define CASE_RETURN_STR(n) case (n): return (#n)
1238
1239const char *
1240get_eRoamCmdStatus_str(eRoamCmdStatus val)
1241{
1242 switch (val)
1243 {
1244 CASE_RETURN_STR(eCSR_ROAM_CANCELLED);
1245 CASE_RETURN_STR(eCSR_ROAM_ROAMING_START);
1246 CASE_RETURN_STR(eCSR_ROAM_ROAMING_COMPLETION);
1247 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_START);
1248 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_COMPLETION);
1249 CASE_RETURN_STR(eCSR_ROAM_DISASSOCIATED);
1250 CASE_RETURN_STR(eCSR_ROAM_SHOULD_ROAM);
1251 CASE_RETURN_STR(eCSR_ROAM_SCAN_FOUND_NEW_BSS);
1252 CASE_RETURN_STR(eCSR_ROAM_LOSTLINK);
1253 default:
1254 return "unknown";
1255 }
1256}
1257
1258const char *
1259get_eCsrRoamResult_str(eCsrRoamResult val)
1260{
1261 switch (val)
1262 {
1263 CASE_RETURN_STR(eCSR_ROAM_RESULT_NONE);
1264 CASE_RETURN_STR(eCSR_ROAM_RESULT_FAILURE);
1265 CASE_RETURN_STR(eCSR_ROAM_RESULT_ASSOCIATED);
1266 CASE_RETURN_STR(eCSR_ROAM_RESULT_NOT_ASSOCIATED);
1267 CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_FAILURE);
1268 CASE_RETURN_STR(eCSR_ROAM_RESULT_FORCED);
1269 CASE_RETURN_STR(eCSR_ROAM_RESULT_DISASSOC_IND);
1270 CASE_RETURN_STR(eCSR_ROAM_RESULT_DEAUTH_IND);
1271 CASE_RETURN_STR(eCSR_ROAM_RESULT_CAP_CHANGED);
1272 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_CONNECT);
1273 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_INACTIVE);
1274 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_NEW_PEER);
1275 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_COALESCED);
1276 default:
1277 return "unknown";
1278 }
1279}
1280
1281
1282
1283tANI_BOOLEAN csrGetBssIdBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tCsrBssid *pBssId )
1284{
Kiet Lam64c1b492013-07-12 13:56:44 +05301285 vos_mem_copy(pBssId, &pSirBssDesc->bssId[ 0 ], sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 return( TRUE );
1287}
1288
1289
1290tANI_BOOLEAN csrIsBssIdEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 )
1291{
1292 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1293 tANI_BOOLEAN fEqual = FALSE;
1294 tCsrBssid bssId1;
1295 tCsrBssid bssId2;
1296
1297 do {
1298 if ( !pSirBssDesc1 ) break;
1299 if ( !pSirBssDesc2 ) break;
1300
1301 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc1, &bssId1 ) ) break;
1302 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc2, &bssId2 ) ) break;
1303
1304 //sirCompareMacAddr
1305 fEqual = csrIsMacAddressEqual(pMac, &bssId1, &bssId2);
1306
1307 } while( 0 );
1308
1309 return( fEqual );
1310}
1311
1312tANI_BOOLEAN csrIsConnStateConnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1313{
1314 return( eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1315}
1316
1317tANI_BOOLEAN csrIsConnStateDisconnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1318{
1319 return( eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1320}
1321
1322tANI_BOOLEAN csrIsConnStateConnectedInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1323{
1324 return( eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == pMac->roam.roamSession[sessionId].connectState );
1325}
1326
1327tANI_BOOLEAN csrIsConnStateConnected( tpAniSirGlobal pMac, tANI_U32 sessionId )
1328{
1329 if( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateConnectedInfra( pMac, sessionId ) || csrIsConnStateConnectedWds( pMac, sessionId) )
1330 return TRUE;
1331 else
1332 return FALSE;
1333}
1334
1335tANI_BOOLEAN csrIsConnStateInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1336{
1337 return( csrIsConnStateConnectedInfra( pMac, sessionId ) );
1338}
1339
1340tANI_BOOLEAN csrIsConnStateIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1341{
1342 return( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateDisconnectedIbss( pMac, sessionId ) );
1343}
1344
1345
1346tANI_BOOLEAN csrIsConnStateConnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1347{
1348 return( eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1349}
1350
Jeff Johnson295189b2012-06-20 16:38:30 -07001351tANI_BOOLEAN csrIsConnStateConnectedInfraAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1352{
1353 return( (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == pMac->roam.roamSession[sessionId].connectState) ||
1354 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState ) );
1355}
Jeff Johnson295189b2012-06-20 16:38:30 -07001356
1357tANI_BOOLEAN csrIsConnStateDisconnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1358{
1359 return( eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1360}
1361
1362tANI_BOOLEAN csrIsConnStateWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1363{
1364 return( csrIsConnStateConnectedWds( pMac, sessionId ) ||
1365 csrIsConnStateDisconnectedWds( pMac, sessionId ) );
1366}
1367
Jeff Johnsone7245742012-09-05 17:12:55 -07001368tANI_BOOLEAN csrIsConnStateAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1369{
1370 tCsrRoamSession *pSession;
1371 pSession = CSR_GET_SESSION(pMac, sessionId);
1372 if (!pSession)
1373 return eANI_BOOLEAN_FALSE;
1374 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
1375 {
1376 return eANI_BOOLEAN_TRUE;
1377 }
1378 return eANI_BOOLEAN_FALSE;
1379}
1380
Jeff Johnson295189b2012-06-20 16:38:30 -07001381tANI_BOOLEAN csrIsAnySessionInConnectState( tpAniSirGlobal pMac )
1382{
1383 tANI_U32 i;
1384 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1385
1386 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1387 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001388 if( CSR_IS_SESSION_VALID( pMac, i ) &&
1389 ( csrIsConnStateInfra( pMac, i )
1390 || csrIsConnStateIbss( pMac, i )
1391 || csrIsConnStateAp( pMac, i) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 {
1393 fRc = eANI_BOOLEAN_TRUE;
1394 break;
1395 }
1396 }
1397
1398 return ( fRc );
1399}
1400
1401tANI_S8 csrGetInfraSessionId( tpAniSirGlobal pMac )
1402{
1403 tANI_U8 i;
1404 tANI_S8 sessionid = -1;
1405
1406 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1407 {
1408 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateInfra( pMac, i ) )
1409 {
1410 sessionid = i;
1411 break;
1412 }
1413 }
1414
1415 return ( sessionid );
1416}
1417
1418tANI_U8 csrGetInfraOperationChannel( tpAniSirGlobal pMac, tANI_U8 sessionId)
1419{
1420 tANI_U8 channel;
1421
1422 if( CSR_IS_SESSION_VALID( pMac, sessionId ))
1423 {
1424 channel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
1425 }
1426 else
1427 {
1428 channel = 0;
1429 }
1430 return channel;
1431}
1432
1433//This routine will return operating channel on FIRST BSS that is active/operating to be used for concurrency mode.
1434//If other BSS is not up or not connected it will return 0
1435
1436tANI_U8 csrGetConcurrentOperationChannel( tpAniSirGlobal pMac )
1437{
1438 tCsrRoamSession *pSession = NULL;
1439 tANI_U8 i = 0;
1440
1441 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1442 {
1443 if( CSR_IS_SESSION_VALID( pMac, i ) )
1444 {
1445 pSession = CSR_GET_SESSION( pMac, i );
1446
1447 if (NULL != pSession->pCurRoamProfile)
1448 {
1449 if (
1450 (((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1451 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE)) &&
1452 (pSession->connectState == eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED))
1453 ||
1454 (((pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) ||
1455 (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE)) &&
1456 (pSession->connectState != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
1457 )
1458 return (pSession->connectedProfile.operationChannel);
1459 }
1460
1461 }
1462 }
1463 return 0;
1464}
1465
1466tANI_BOOLEAN csrIsAllSessionDisconnected( tpAniSirGlobal pMac )
1467{
1468 tANI_U32 i;
1469 tANI_BOOLEAN fRc = eANI_BOOLEAN_TRUE;
1470
1471 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1472 {
1473 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1474 {
1475 fRc = eANI_BOOLEAN_FALSE;
1476 break;
1477 }
1478 }
1479
1480 return ( fRc );
1481}
1482
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001483tANI_BOOLEAN csrIsStaSessionConnected( tpAniSirGlobal pMac )
1484{
1485 tANI_U32 i;
1486 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1487 tCsrRoamSession *pSession = NULL;
1488 tANI_U32 countSta = 0;
1489
1490 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1491 {
1492 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1493 {
1494 pSession = CSR_GET_SESSION( pMac, i );
1495
1496 if (NULL != pSession->pCurRoamProfile)
1497 {
1498 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) {
1499 countSta++;
1500 }
1501 }
1502 }
1503 }
1504
1505 /* return TRUE if one of the following conditions is TRUE:
1506 * - more than one STA session connected
1507 */
1508 if ( countSta > 0) {
1509 fRc = eANI_BOOLEAN_TRUE;
1510 }
1511
1512 return( fRc );
1513}
1514
1515tANI_BOOLEAN csrIsP2pSessionConnected( tpAniSirGlobal pMac )
1516{
1517 tANI_U32 i;
1518 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1519 tCsrRoamSession *pSession = NULL;
1520 tANI_U32 countP2pCli = 0;
1521 tANI_U32 countP2pGo = 0;
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001522 tANI_U32 countSAP = 0;
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001523
1524 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1525 {
1526 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1527 {
1528 pSession = CSR_GET_SESSION( pMac, i );
1529
1530 if (NULL != pSession->pCurRoamProfile)
1531 {
1532 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE) {
1533 countP2pCli++;
1534 }
1535
1536 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1537 countP2pGo++;
1538 }
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001539
1540 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE) {
1541 countSAP++;
1542 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001543 }
1544 }
1545 }
1546
1547 /* return TRUE if one of the following conditions is TRUE:
1548 * - at least one P2P CLI session is connected
1549 * - at least one P2P GO session is connected
1550 */
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001551 if ( (countP2pCli > 0) || (countP2pGo > 0 ) || (countSAP > 0 ) ) {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001552 fRc = eANI_BOOLEAN_TRUE;
1553 }
1554
1555 return( fRc );
1556}
1557
Madan Mohan Koyyalamudid3d22592012-09-24 14:01:29 -07001558tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac )
1559{
1560 tANI_U32 i, count;
1561 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1562
1563 count = 0;
1564 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1565 {
1566 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1567 {
1568 count++;
1569 }
1570 }
1571
1572 if (count > 0)
1573 {
1574 fRc = eANI_BOOLEAN_TRUE;
1575 }
1576 return( fRc );
1577}
Jeff Johnson295189b2012-06-20 16:38:30 -07001578
1579tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac )
1580{
1581 tANI_U32 i;
1582 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1583
1584 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1585 {
1586 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1587 {
1588 fRc = eANI_BOOLEAN_TRUE;
1589 break;
1590 }
1591 }
1592
1593 return ( fRc );
1594}
1595
1596tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac )
1597{
1598 tANI_U32 i, noOfConnectedInfra = 0;
1599
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 ++noOfConnectedInfra;
1607 }
1608 }
1609
1610 // More than one Infra Sta Connected
1611 if(noOfConnectedInfra > 1)
1612 {
1613 fRc = eANI_BOOLEAN_TRUE;
1614 }
1615
1616 return ( fRc );
1617}
1618
1619tANI_BOOLEAN csrIsIBSSStarted( tpAniSirGlobal pMac )
1620{
1621 tANI_U32 i;
1622 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1623
1624 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1625 {
1626 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateIbss( pMac, i ) )
1627 {
1628 fRc = eANI_BOOLEAN_TRUE;
1629 break;
1630 }
1631 }
1632
1633 return ( fRc );
1634}
1635
1636
1637tANI_BOOLEAN csrIsBTAMPStarted( 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 ) && csrIsConnStateConnectedWds( pMac, i ) )
1645 {
1646 fRc = eANI_BOOLEAN_TRUE;
1647 break;
1648 }
1649 }
1650
1651 return ( fRc );
1652}
1653
Jeff Johnsone7245742012-09-05 17:12:55 -07001654tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac )
1655{
1656 tANI_U32 sessionId, noOfCocurrentSession = 0;
1657 eCsrConnectState connectState;
1658
1659 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1660
1661 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1662 {
1663 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1664 {
1665 connectState = pMac->roam.roamSession[sessionId].connectState;
1666 if( (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == connectState) ||
1667 (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == connectState) ||
1668 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == connectState) )
1669 {
1670 ++noOfCocurrentSession;
1671 }
1672 }
1673 }
1674
1675 // More than one session is Up and Running
1676 if(noOfCocurrentSession > 1)
1677 {
1678 fRc = eANI_BOOLEAN_TRUE;
1679 }
1680
1681 return ( fRc );
1682}
1683
Jeff Johnsone7245742012-09-05 17:12:55 -07001684tANI_BOOLEAN csrIsInfraApStarted( tpAniSirGlobal pMac )
1685{
1686 tANI_U32 sessionId;
1687 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1688
1689 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1690 {
1691 if( CSR_IS_SESSION_VALID( pMac, sessionId ) && (csrIsConnStateConnectedInfraAp(pMac, sessionId)) )
1692 {
1693 fRc = eANI_BOOLEAN_TRUE;
1694 break;
1695 }
1696 }
1697
1698 return ( fRc );
1699
1700}
Jeff Johnsone7245742012-09-05 17:12:55 -07001701
Jeff Johnson295189b2012-06-20 16:38:30 -07001702tANI_BOOLEAN csrIsBTAMP( tpAniSirGlobal pMac, tANI_U32 sessionId )
1703{
1704 return ( csrIsConnStateConnectedWds( pMac, sessionId ) );
1705}
1706
1707
1708tANI_BOOLEAN csrIsConnStateDisconnected(tpAniSirGlobal pMac, tANI_U32 sessionId)
1709{
1710 return (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED == pMac->roam.roamSession[sessionId].connectState);
1711}
1712
Jeff Johnsone7245742012-09-05 17:12:55 -07001713tANI_BOOLEAN csrIsValidMcConcurrentSession(tpAniSirGlobal pMac, tANI_U32 sessionId,
1714 tSirBssDescription *pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001715{
1716 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07001717 eAniBoolean status = eANI_BOOLEAN_FALSE;
1718
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 //Check for MCC support
1720 if (!pMac->roam.configParam.fenableMCCMode)
1721 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001722 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 }
1724
Jeff Johnsone7245742012-09-05 17:12:55 -07001725 //Validate BeaconInterval
1726 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1727 {
1728 pSession = CSR_GET_SESSION( pMac, sessionId );
1729 if (NULL != pSession->pCurRoamProfile)
1730 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001731 if (csrIsconcurrentsessionValid (pMac, sessionId,
1732 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001733 == eHAL_STATUS_SUCCESS )
1734 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001735 if (csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId,
1736 &pBssDesc->beaconInterval, sessionId,
1737 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001738 != eHAL_STATUS_SUCCESS)
1739 {
1740 status = eANI_BOOLEAN_FALSE;
1741 }
1742 else
1743 {
1744 status = eANI_BOOLEAN_TRUE;
1745 }
1746 }
1747 else
1748 {
1749 status = eANI_BOOLEAN_FALSE;
1750 }
1751 }
1752 }
1753 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001754}
1755
1756static tSirMacCapabilityInfo csrGetBssCapabilities( tSirBssDescription *pSirBssDesc )
1757{
1758 tSirMacCapabilityInfo dot11Caps;
1759
1760 //tSirMacCapabilityInfo is 16-bit
1761 pal_get_U16( (tANI_U8 *)&pSirBssDesc->capabilityInfo, (tANI_U16 *)&dot11Caps );
1762
1763 return( dot11Caps );
1764}
1765
1766tANI_BOOLEAN csrIsInfraBssDesc( tSirBssDescription *pSirBssDesc )
1767{
1768 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1769
1770 return( (tANI_BOOLEAN)dot11Caps.ess );
1771}
1772
1773
1774tANI_BOOLEAN csrIsIbssBssDesc( tSirBssDescription *pSirBssDesc )
1775{
1776 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1777
1778 return( (tANI_BOOLEAN)dot11Caps.ibss );
1779}
1780
1781tANI_BOOLEAN csrIsQoSBssDesc( tSirBssDescription *pSirBssDesc )
1782{
1783 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1784
1785 return( (tANI_BOOLEAN)dot11Caps.qos );
1786}
1787
1788tANI_BOOLEAN csrIsPrivacy( tSirBssDescription *pSirBssDesc )
1789{
1790 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1791
1792 return( (tANI_BOOLEAN)dot11Caps.privacy );
1793}
1794
1795
1796tANI_BOOLEAN csrIs11dSupported(tpAniSirGlobal pMac)
1797{
1798 return(pMac->roam.configParam.Is11dSupportEnabled);
1799}
1800
1801
1802tANI_BOOLEAN csrIs11hSupported(tpAniSirGlobal pMac)
1803{
1804 return(pMac->roam.configParam.Is11hSupportEnabled);
1805}
1806
1807
1808tANI_BOOLEAN csrIs11eSupported(tpAniSirGlobal pMac)
1809{
1810 return(pMac->roam.configParam.Is11eSupportEnabled);
1811}
1812
1813tANI_BOOLEAN csrIsMCCSupported ( tpAniSirGlobal pMac )
1814{
1815 return(pMac->roam.configParam.fenableMCCMode);
1816
1817}
1818
1819tANI_BOOLEAN csrIsWmmSupported(tpAniSirGlobal pMac)
1820{
1821 if(eCsrRoamWmmNoQos == pMac->roam.configParam.WMMSupportMode)
1822 {
1823 return eANI_BOOLEAN_FALSE;
1824 }
1825 else
1826 {
1827 return eANI_BOOLEAN_TRUE;
1828 }
1829}
1830
1831
1832
1833
1834//pIes is the IEs for pSirBssDesc2
1835tANI_BOOLEAN csrIsSsidEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1,
1836 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2 )
1837{
1838 tANI_BOOLEAN fEqual = FALSE;
1839 tSirMacSSid Ssid1, Ssid2;
1840 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1841 tDot11fBeaconIEs *pIes1 = NULL;
1842 tDot11fBeaconIEs *pIesLocal = pIes2;
1843
1844 do {
1845 if( ( NULL == pSirBssDesc1 ) || ( NULL == pSirBssDesc2 ) ) break;
1846 if( !pIesLocal && !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesLocal)) )
1847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001848 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 break;
1850 }
1851 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
1852 {
1853 break;
1854 }
1855 if( ( !pIes1->SSID.present ) || ( !pIesLocal->SSID.present ) ) break;
1856 if ( pIes1->SSID.num_ssid != pIesLocal->SSID.num_ssid ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301857 vos_mem_copy(Ssid1.ssId, pIes1->SSID.ssid, pIes1->SSID.num_ssid);
1858 vos_mem_copy(Ssid2.ssId, pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001859
Kiet Lam64c1b492013-07-12 13:56:44 +05301860 fEqual = vos_mem_compare(Ssid1.ssId, Ssid2.ssId, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001861
1862 } while( 0 );
1863 if(pIes1)
1864 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301865 vos_mem_free(pIes1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 }
1867 if( pIesLocal && !pIes2 )
1868 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301869 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 }
1871
1872 return( fEqual );
1873}
1874
1875tANI_BOOLEAN csrIsAniWmeSupported(tDot11fIEAirgo *pIeAirgo)
1876{
1877 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
1878
1879 if(pIeAirgo && pIeAirgo->present && pIeAirgo->PropCapability.present)
1880 {
1881 fRet = (tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability ));
1882 }
1883
1884 return fRet;
1885}
1886
1887
1888
1889
1890//pIes can be passed in as NULL if the caller doesn't have one prepared
1891tANI_BOOLEAN csrIsBssDescriptionWme( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
1892{
1893 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1894 // Assume that WME is found...
1895 tANI_BOOLEAN fWme = TRUE;
1896 tDot11fBeaconIEs *pIesTemp = pIes;
1897
1898 do
1899 {
1900 if(pIesTemp == NULL)
1901 {
1902 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp)) )
1903 {
1904 fWme = FALSE;
1905 break;
1906 }
1907 }
1908 // if the AirgoProprietary indicator is found, then WME is supported...
1909 if ( csrIsAniWmeSupported(&pIesTemp->Airgo) ) break;
1910 // if the Wme Info IE is found, then WME is supported...
1911 if ( CSR_IS_QOS_BSS(pIesTemp) ) break;
1912 // if none of these are found, then WME is NOT supported...
1913 fWme = FALSE;
1914 } while( 0 );
1915 if( !csrIsWmmSupported( pMac ) && fWme)
1916 {
1917 if( !pIesTemp->HTCaps.present )
1918 {
1919 fWme = FALSE;
1920 }
1921 }
1922 if( ( pIes == NULL ) && ( NULL != pIesTemp ) )
1923 {
1924 //we allocate memory here so free it before returning
Kiet Lam64c1b492013-07-12 13:56:44 +05301925 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 }
1927
1928 return( fWme );
1929}
1930
1931tANI_BOOLEAN csrIsHcfEnabled( tDot11fIEAirgo *pIeAirgo )
1932{
1933 tANI_BOOLEAN fHcfSupported = FALSE;
1934
1935 fHcfSupported = ((tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability )) ||
1936 (pIeAirgo->present && pIeAirgo->HCF.present && pIeAirgo->HCF.enabled));
1937
1938 return( fHcfSupported );
1939}
1940
1941
1942eCsrMediaAccessType csrGetQoSFromBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc,
1943 tDot11fBeaconIEs *pIes )
1944{
1945 eCsrMediaAccessType qosType = eCSR_MEDIUM_ACCESS_DCF;
1946
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001948
1949 do
1950 {
1951 // if we find WMM in the Bss Description, then we let this
1952 // override and use WMM.
1953 if ( csrIsBssDescriptionWme( hHal, pSirBssDesc, pIes ) )
1954 {
1955 qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
1956 }
1957 else
1958 {
1959 // if the QoS bit is on, then the AP is advertising 11E QoS...
1960 if ( csrIsQoSBssDesc( pSirBssDesc ) )
1961 {
1962 // which could be HCF or eDCF.
1963 if ( csrIsHcfEnabled( &pIes->Airgo ) )
1964 {
1965 qosType = eCSR_MEDIUM_ACCESS_11e_HCF;
1966 }
1967 else
1968 {
1969 qosType = eCSR_MEDIUM_ACCESS_11e_eDCF;
1970 }
1971 }
1972 else
1973 {
1974 qosType = eCSR_MEDIUM_ACCESS_DCF;
1975 }
1976 // scale back based on the types turned on for the adapter...
1977 if ( eCSR_MEDIUM_ACCESS_11e_eDCF == qosType && !csrIs11eSupported( hHal ) )
1978 {
1979 qosType = eCSR_MEDIUM_ACCESS_DCF;
1980 }
1981 }
1982
1983 } while(0);
1984
1985 return( qosType );
1986}
1987
1988
1989
1990
1991//Caller allocates memory for pIEStruct
1992eHalStatus csrParseBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIEStruct)
1993{
1994 eHalStatus status = eHAL_STATUS_FAILURE;
1995 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1996 int ieLen = (int)(pBssDesc->length + sizeof( pBssDesc->length ) - GET_FIELD_OFFSET( tSirBssDescription, ieFields ));
1997
1998 if(ieLen > 0 && pIEStruct)
1999 {
2000 if(!DOT11F_FAILED(dot11fUnpackBeaconIEs( pMac, (tANI_U8 *)pBssDesc->ieFields, ieLen, pIEStruct )))
2001 {
2002 status = eHAL_STATUS_SUCCESS;
2003 }
2004 }
2005
2006 return (status);
2007}
2008
2009
2010//This function will allocate memory for the parsed IEs to the caller. Caller must free the memory
2011//after it is done with the data only if this function succeeds
2012eHalStatus csrGetParsedBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs **ppIEStruct)
2013{
2014 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2015 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2016
2017 if(pBssDesc && ppIEStruct)
2018 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302019 *ppIEStruct = vos_mem_malloc(sizeof(tDot11fBeaconIEs));
2020 if ( (*ppIEStruct) != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302022 vos_mem_set((void *)*ppIEStruct, sizeof(tDot11fBeaconIEs), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 status = csrParseBssDescriptionIEs(hHal, pBssDesc, *ppIEStruct);
2024 if(!HAL_STATUS_SUCCESS(status))
2025 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302026 vos_mem_free(*ppIEStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07002027 *ppIEStruct = NULL;
2028 }
2029 }
2030 else
2031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002032 smsLog( pMac, LOGE, FL(" failed to allocate memory") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 VOS_ASSERT( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +05302034 return eHAL_STATUS_FAILURE;
2035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 }
2037
2038 return (status);
2039}
2040
2041
2042
2043
2044tANI_BOOLEAN csrIsNULLSSID( tANI_U8 *pBssSsid, tANI_U8 len )
2045{
2046 tANI_BOOLEAN fNullSsid = FALSE;
2047
2048 tANI_U32 SsidLength;
2049 tANI_U8 *pSsidStr;
2050
2051 do
2052 {
2053 if ( 0 == len )
2054 {
2055 fNullSsid = TRUE;
2056 break;
2057 }
2058
2059 //Consider 0 or space for hidden SSID
2060 if ( 0 == pBssSsid[0] )
2061 {
2062 fNullSsid = TRUE;
2063 break;
2064 }
2065
2066 SsidLength = len;
2067 pSsidStr = pBssSsid;
2068
2069 while ( SsidLength )
2070 {
2071 if( *pSsidStr )
2072 break;
2073
2074 pSsidStr++;
2075 SsidLength--;
2076 }
2077
2078 if( 0 == SsidLength )
2079 {
2080 fNullSsid = TRUE;
2081 break;
2082 }
2083 }
2084 while( 0 );
2085
2086 return fNullSsid;
2087}
2088
2089
2090tANI_U32 csrGetFragThresh( tHalHandle hHal )
2091{
2092 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2093
2094 return pMac->roam.configParam.FragmentationThreshold;
2095}
2096
2097tANI_U32 csrGetRTSThresh( tHalHandle hHal )
2098{
2099 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2100
2101 return pMac->roam.configParam.RTSThreshold;
2102}
2103
2104eCsrPhyMode csrTranslateToPhyModeFromBssDesc( tSirBssDescription *pSirBssDesc )
2105{
2106 eCsrPhyMode phyMode;
2107
2108 switch ( pSirBssDesc->nwType )
2109 {
2110 case eSIR_11A_NW_TYPE:
2111 phyMode = eCSR_DOT11_MODE_11a;
2112 break;
2113
2114 case eSIR_11B_NW_TYPE:
2115 phyMode = eCSR_DOT11_MODE_11b;
2116 break;
2117
2118 case eSIR_11G_NW_TYPE:
2119 phyMode = eCSR_DOT11_MODE_11g;
2120 break;
2121
2122 case eSIR_11N_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 phyMode = eCSR_DOT11_MODE_11n;
2124 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002125#ifdef WLAN_FEATURE_11AC
2126 case eSIR_11AC_NW_TYPE:
2127 default:
2128 phyMode = eCSR_DOT11_MODE_11ac;
2129#else
2130 default:
2131 phyMode = eCSR_DOT11_MODE_11n;
2132#endif
2133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 return( phyMode );
2136}
2137
2138
2139tANI_U32 csrTranslateToWNICfgDot11Mode(tpAniSirGlobal pMac, eCsrCfgDot11Mode csrDot11Mode)
2140{
2141 tANI_U32 ret;
2142
2143 switch(csrDot11Mode)
2144 {
2145 case eCSR_CFG_DOT11_MODE_AUTO:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002146 smsLog(pMac, LOGW, FL(" Warning: sees eCSR_CFG_DOT11_MODE_AUTO "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 //We cannot decide until now.
2148 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2149 {
2150 ret = WNI_CFG_DOT11_MODE_TAURUS;
2151 }
2152 else
2153 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002154 ret = WNI_CFG_DOT11_MODE_11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 }
2156 break;
2157 case eCSR_CFG_DOT11_MODE_TAURUS:
2158 ret = WNI_CFG_DOT11_MODE_TAURUS;
2159 break;
2160 case eCSR_CFG_DOT11_MODE_11A:
2161 ret = WNI_CFG_DOT11_MODE_11A;
2162 break;
2163 case eCSR_CFG_DOT11_MODE_11B:
2164 ret = WNI_CFG_DOT11_MODE_11B;
2165 break;
2166 case eCSR_CFG_DOT11_MODE_11G:
2167 ret = WNI_CFG_DOT11_MODE_11G;
2168 break;
2169 case eCSR_CFG_DOT11_MODE_11N:
2170 ret = WNI_CFG_DOT11_MODE_11N;
2171 break;
2172 case eCSR_CFG_DOT11_MODE_POLARIS:
2173 ret = WNI_CFG_DOT11_MODE_POLARIS;
2174 break;
2175 case eCSR_CFG_DOT11_MODE_TITAN:
2176 ret = WNI_CFG_DOT11_MODE_TITAN;
2177 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 case eCSR_CFG_DOT11_MODE_11G_ONLY:
2179 ret = WNI_CFG_DOT11_MODE_11G_ONLY;
2180 break;
2181 case eCSR_CFG_DOT11_MODE_11N_ONLY:
2182 ret = WNI_CFG_DOT11_MODE_11N_ONLY;
2183 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002184
2185#ifdef WLAN_FEATURE_11AC
2186 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
2187 ret = WNI_CFG_DOT11_MODE_11AC_ONLY;
2188 break;
2189 case eCSR_CFG_DOT11_MODE_11AC:
2190 ret = WNI_CFG_DOT11_MODE_11AC;
2191 break;
2192#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002194 smsLog(pMac, LOGW, FL("doesn't expect %d as csrDo11Mode"), csrDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 if(eCSR_BAND_24 == pMac->roam.configParam.eBand)
2196 {
2197 ret = WNI_CFG_DOT11_MODE_11G;
2198 }
2199 else
2200 {
2201 ret = WNI_CFG_DOT11_MODE_11A;
2202 }
2203 break;
2204 }
2205
2206 return (ret);
2207}
2208
2209
2210//This function should only return the super set of supported modes. 11n implies 11b/g/a/n.
2211eHalStatus csrGetPhyModeFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription,
2212 eCsrPhyMode *pPhyMode, tDot11fBeaconIEs *pIes)
2213{
2214 eHalStatus status = eHAL_STATUS_SUCCESS;
2215 eCsrPhyMode phyMode = csrTranslateToPhyModeFromBssDesc(pBSSDescription);
2216
2217 if( pIes )
2218 {
2219 if(pIes->Airgo.present)
2220 {
2221 if(pIes->Airgo.PropCapability.present)
2222 {
2223 if( PROP_CAPABILITY_GET( TAURUS, pIes->Airgo.PropCapability.capability ))
2224 {
2225 phyMode = eCSR_DOT11_MODE_TAURUS;
2226 }
2227 }
2228 }
2229 if(pIes->HTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2230 {
2231 phyMode = eCSR_DOT11_MODE_11n;
2232 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002233
2234#ifdef WLAN_FEATURE_11AC
2235 if ( pIes->VHTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2236 {
2237 phyMode = eCSR_DOT11_MODE_11ac;
2238 }
2239#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 *pPhyMode = phyMode;
2241 }
2242
2243 return (status);
2244
2245}
2246
2247
2248//This function returns the correct eCSR_CFG_DOT11_MODE is the two phyModes matches
2249//bssPhyMode is the mode derived from the BSS description
2250//f5GhzBand is derived from the channel id of BSS description
2251tANI_BOOLEAN csrGetPhyModeInUse( eCsrPhyMode phyModeIn, eCsrPhyMode bssPhyMode, tANI_BOOLEAN f5GhzBand,
2252 eCsrCfgDot11Mode *pCfgDot11ModeToUse )
2253{
2254 tANI_BOOLEAN fMatch = FALSE;
2255 eCsrCfgDot11Mode cfgDot11Mode;
2256
2257 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; // to suppress compiler warning
2258
2259 switch( phyModeIn )
2260 {
2261 case eCSR_DOT11_MODE_abg: //11a or 11b or 11g
2262 if( f5GhzBand )
2263 {
2264 fMatch = TRUE;
2265 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2266 }
2267 else if( eCSR_DOT11_MODE_11b == bssPhyMode )
2268 {
2269 fMatch = TRUE;
2270 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2271 }
2272 else
2273 {
2274 fMatch = TRUE;
2275 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2276 }
2277 break;
2278
2279 case eCSR_DOT11_MODE_11a: //11a
2280 if( f5GhzBand )
2281 {
2282 fMatch = TRUE;
2283 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2284 }
2285 break;
2286
2287 case eCSR_DOT11_MODE_11a_ONLY: //11a
2288 if( eCSR_DOT11_MODE_11a == bssPhyMode )
2289 {
2290 fMatch = TRUE;
2291 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2292 }
2293 break;
2294
2295 case eCSR_DOT11_MODE_11g:
2296 if(!f5GhzBand)
2297 {
2298 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2299 {
2300 fMatch = TRUE;
2301 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2302 }
2303 else
2304 {
2305 fMatch = TRUE;
2306 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2307 }
2308 }
2309 break;
2310
2311 case eCSR_DOT11_MODE_11g_ONLY:
2312 if( eCSR_DOT11_MODE_11g == bssPhyMode )
2313 {
2314 fMatch = TRUE;
2315 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2316 }
2317 break;
2318
2319 case eCSR_DOT11_MODE_11b:
2320 if( !f5GhzBand )
2321 {
2322 fMatch = TRUE;
2323 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2324 }
2325 break;
2326
2327 case eCSR_DOT11_MODE_11b_ONLY:
2328 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2329 {
2330 fMatch = TRUE;
2331 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2332 }
2333 break;
2334
2335 case eCSR_DOT11_MODE_11n:
2336 fMatch = TRUE;
2337 switch(bssPhyMode)
2338 {
2339 case eCSR_DOT11_MODE_11g:
2340 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2341 break;
2342 case eCSR_DOT11_MODE_11b:
2343 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2344 break;
2345 case eCSR_DOT11_MODE_11a:
2346 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2347 break;
2348 case eCSR_DOT11_MODE_11n:
Jeff Johnsone7245742012-09-05 17:12:55 -07002349#ifdef WLAN_FEATURE_11AC
2350 case eCSR_DOT11_MODE_11ac:
2351#endif
2352 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2353 break;
2354
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 case eCSR_DOT11_MODE_TAURUS:
2356 default:
Jeff Johnsone7245742012-09-05 17:12:55 -07002357#ifdef WLAN_FEATURE_11AC
2358 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2359#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002361#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 break;
2363 }
2364 break;
2365
2366 case eCSR_DOT11_MODE_11n_ONLY:
2367 if((eCSR_DOT11_MODE_11n == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2368 {
2369 fMatch = TRUE;
2370 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002371
2372 }
2373
2374 break;
2375#ifdef WLAN_FEATURE_11AC
2376 case eCSR_DOT11_MODE_11ac:
2377 fMatch = TRUE;
2378 switch(bssPhyMode)
2379 {
2380 case eCSR_DOT11_MODE_11g:
2381 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2382 break;
2383 case eCSR_DOT11_MODE_11b:
2384 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2385 break;
2386 case eCSR_DOT11_MODE_11a:
2387 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2388 break;
2389 case eCSR_DOT11_MODE_11n:
2390 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2391 break;
2392 case eCSR_DOT11_MODE_11ac:
2393 case eCSR_DOT11_MODE_TAURUS:
2394 default:
2395 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2396 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 }
2398 break;
2399
Jeff Johnsone7245742012-09-05 17:12:55 -07002400 case eCSR_DOT11_MODE_11ac_ONLY:
2401 if((eCSR_DOT11_MODE_11ac == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2402 {
2403 fMatch = TRUE;
2404 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2405 }
2406 break;
2407#endif
2408
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 case eCSR_DOT11_MODE_TAURUS:
2410 default:
2411 fMatch = TRUE;
2412 switch(bssPhyMode)
2413 {
2414 case eCSR_DOT11_MODE_11g:
2415 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2416 break;
2417 case eCSR_DOT11_MODE_11b:
2418 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2419 break;
2420 case eCSR_DOT11_MODE_11a:
2421 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2422 break;
2423 case eCSR_DOT11_MODE_11n:
2424 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2425 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002426#ifdef WLAN_FEATURE_11AC
2427 case eCSR_DOT11_MODE_11ac:
2428 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2429 break;
2430#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 case eCSR_DOT11_MODE_TAURUS:
2432 default:
2433 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
2434 break;
2435 }
2436 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 }
2438
2439 if ( fMatch && pCfgDot11ModeToUse )
2440 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002441#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudief5dd972012-10-11 15:06:09 -07002442 if(cfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC && (!IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)))
Jeff Johnsone7245742012-09-05 17:12:55 -07002443 {
2444 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2445 }
2446 else
2447#endif
2448 {
2449 *pCfgDot11ModeToUse = cfgDot11Mode;
2450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 return( fMatch );
2453}
2454
2455
2456//This function decides whether the one of the bit of phyMode is matching the mode in the BSS and allowed by the user
2457//setting, pMac->roam.configParam.uCfgDot11Mode. It returns the mode that fits the criteria.
2458tANI_BOOLEAN csrIsPhyModeMatch( tpAniSirGlobal pMac, tANI_U32 phyMode,
2459 tSirBssDescription *pSirBssDesc, tCsrRoamProfile *pProfile,
2460 eCsrCfgDot11Mode *pReturnCfgDot11Mode,
2461 tDot11fBeaconIEs *pIes)
2462{
2463 tANI_BOOLEAN fMatch = FALSE;
2464 eCsrPhyMode phyModeInBssDesc, phyMode2;
2465 eCsrCfgDot11Mode cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_TAURUS;
2466 tANI_U32 bitMask, loopCount;
2467
2468 if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pSirBssDesc, &phyModeInBssDesc, pIes )))
2469 {
2470 //In case some change change eCSR_DOT11_MODE_TAURUS to non-0
2471 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2472 {
2473 //Taurus means anything
2474 if ( eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode )
2475 {
2476 phyMode = eCSR_DOT11_MODE_abg;
2477 }
2478 else if(eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode)
2479 {
2480 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2481 {
2482 phyMode = eCSR_DOT11_MODE_TAURUS;
2483 }
2484 else
2485 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002486
2487#ifdef WLAN_FEATURE_11AC
2488 phyMode = eCSR_DOT11_MODE_11ac;
2489#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002490 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002491#endif
2492
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 }
2494 }
2495 else
2496 {
2497 //user's pick
2498 phyMode = pMac->roam.configParam.phyMode;
2499 }
2500 }
2501 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode) )
2502 {
2503 if(0 != phyMode)
2504 {
2505 if(eCSR_DOT11_MODE_AUTO & phyMode)
2506 {
2507 phyMode2 = eCSR_DOT11_MODE_AUTO & phyMode;
2508 }
2509 else
2510 {
2511 phyMode2 = eCSR_DOT11_MODE_TAURUS & phyMode;
2512 }
2513 }
2514 else
2515 {
2516 phyMode2 = phyMode;
2517 }
2518 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2519 &cfgDot11ModeToUse );
2520 }
2521 else
2522 {
2523 bitMask = 1;
2524 loopCount = 0;
2525 while(loopCount < eCSR_NUM_PHY_MODE)
2526 {
2527 if(0 != ( phyMode2 = (phyMode & (bitMask << loopCount++)) ))
2528 {
2529 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2530 &cfgDot11ModeToUse );
2531 if(fMatch) break;
2532 }
2533 }
2534 }
2535 if ( fMatch && pReturnCfgDot11Mode )
2536 {
2537 if( pProfile )
2538 {
2539 /* IEEE 11n spec (8.4.3): HT STA shall eliminate TKIP as a
2540 * choice for the pairwise cipher suite if CCMP is advertised
2541 * by the AP or if the AP included an HT capabilities element
2542 * in its Beacons and Probe Response.
2543 */
2544 if( (!CSR_IS_11n_ALLOWED( pProfile->negotiatedUCEncryptionType )) &&
2545 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11ModeToUse) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002546#ifdef WLAN_FEATURE_11AC
2547 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11ModeToUse) ||
2548#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11ModeToUse)) )
2550 {
2551 //We cannot do 11n here
2552 if( !CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId) )
2553 {
2554 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2555 }
2556 else
2557 {
2558 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2559 }
2560 }
2561 }
2562 *pReturnCfgDot11Mode = cfgDot11ModeToUse;
2563 }
2564 }
2565
2566 return( fMatch );
2567}
2568
2569
2570eCsrCfgDot11Mode csrFindBestPhyMode( tpAniSirGlobal pMac, tANI_U32 phyMode )
2571{
2572 eCsrCfgDot11Mode cfgDot11ModeToUse;
2573 eCsrBand eBand = pMac->roam.configParam.eBand;
2574
Jeff Johnsone7245742012-09-05 17:12:55 -07002575
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302576 if ((0 == phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002577#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302578 (eCSR_DOT11_MODE_11ac & phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002579#endif
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302580 (eCSR_DOT11_MODE_AUTO & phyMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 {
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302582#ifdef WLAN_FEATURE_11AC
2583 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2584 {
2585 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC;
2586 }
2587 else
2588#endif
2589 {
2590 /* Default to 11N mode if user has configured 11ac mode
2591 * and FW doesn't supports 11ac mode .
2592 */
2593 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 }
2596 else
2597 {
2598 if( ( eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY ) & phyMode )
2599 {
2600 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2601 }
2602 else if ( eCSR_DOT11_MODE_abg & phyMode )
2603 {
2604 if( eCSR_BAND_24 != eBand )
2605 {
2606 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2607 }
2608 else
2609 {
2610 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2611 }
2612 }
2613 else if( ( eCSR_DOT11_MODE_11a | eCSR_DOT11_MODE_11a_ONLY ) & phyMode )
2614 {
2615 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2616 }
2617 else if( ( eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY ) & phyMode )
2618 {
2619 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2620 }
2621 else
2622 {
2623 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B;
2624 }
2625 }
2626
2627 return ( cfgDot11ModeToUse );
2628}
2629
2630
2631
2632
2633tANI_U32 csrGet11hPowerConstraint( tHalHandle hHal, tDot11fIEPowerConstraints *pPowerConstraint )
2634{
2635 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2636 tANI_U32 localPowerConstraint = 0;
2637
2638 // check if .11h support is enabled, if not, the power constraint is 0.
2639 if(pMac->roam.configParam.Is11hSupportEnabled && pPowerConstraint->present)
2640 {
2641 localPowerConstraint = pPowerConstraint->localPowerConstraints;
2642 }
2643
2644 return( localPowerConstraint );
2645}
2646
2647
2648tANI_BOOLEAN csrIsProfileWpa( tCsrRoamProfile *pProfile )
2649{
2650 tANI_BOOLEAN fWpaProfile = FALSE;
2651
2652 switch ( pProfile->negotiatedAuthType )
2653 {
2654 case eCSR_AUTH_TYPE_WPA:
2655 case eCSR_AUTH_TYPE_WPA_PSK:
2656 case eCSR_AUTH_TYPE_WPA_NONE:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002657#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 case eCSR_AUTH_TYPE_CCKM_WPA:
2659#endif
2660 fWpaProfile = TRUE;
2661 break;
2662
2663 default:
2664 fWpaProfile = FALSE;
2665 break;
2666 }
2667
2668 if ( fWpaProfile )
2669 {
2670 switch ( pProfile->negotiatedUCEncryptionType )
2671 {
2672 case eCSR_ENCRYPT_TYPE_WEP40:
2673 case eCSR_ENCRYPT_TYPE_WEP104:
2674 case eCSR_ENCRYPT_TYPE_TKIP:
2675 case eCSR_ENCRYPT_TYPE_AES:
2676 fWpaProfile = TRUE;
2677 break;
2678
2679 default:
2680 fWpaProfile = FALSE;
2681 break;
2682 }
2683 }
2684 return( fWpaProfile );
2685}
2686
2687tANI_BOOLEAN csrIsProfileRSN( tCsrRoamProfile *pProfile )
2688{
2689 tANI_BOOLEAN fRSNProfile = FALSE;
2690
2691 switch ( pProfile->negotiatedAuthType )
2692 {
2693 case eCSR_AUTH_TYPE_RSN:
2694 case eCSR_AUTH_TYPE_RSN_PSK:
2695#ifdef WLAN_FEATURE_VOWIFI_11R
2696 case eCSR_AUTH_TYPE_FT_RSN:
2697 case eCSR_AUTH_TYPE_FT_RSN_PSK:
2698#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002699#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 case eCSR_AUTH_TYPE_CCKM_RSN:
2701#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002702#ifdef WLAN_FEATURE_11W
2703 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
2704#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 fRSNProfile = TRUE;
2706 break;
2707
2708 default:
2709 fRSNProfile = FALSE;
2710 break;
2711 }
2712
2713 if ( fRSNProfile )
2714 {
2715 switch ( pProfile->negotiatedUCEncryptionType )
2716 {
2717 // !!REVIEW - For WPA2, use of RSN IE mandates
2718 // use of AES as encryption. Here, we qualify
2719 // even if encryption type is WEP or TKIP
2720 case eCSR_ENCRYPT_TYPE_WEP40:
2721 case eCSR_ENCRYPT_TYPE_WEP104:
2722 case eCSR_ENCRYPT_TYPE_TKIP:
2723 case eCSR_ENCRYPT_TYPE_AES:
2724 fRSNProfile = TRUE;
2725 break;
2726
2727 default:
2728 fRSNProfile = FALSE;
2729 break;
2730 }
2731 }
2732 return( fRSNProfile );
2733}
2734
Jeff Johnsone7245742012-09-05 17:12:55 -07002735eHalStatus
2736csrIsconcurrentsessionValid(tpAniSirGlobal pMac,tANI_U32 cursessionId,
2737 tVOS_CON_MODE currBssPersona)
2738{
2739 tANI_U32 sessionId = 0;
2740
2741 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2742 {
2743 if (cursessionId != sessionId )
2744 {
2745 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2746 {
2747 continue;
2748 }
2749
2750 switch (currBssPersona)
2751 {
2752 case VOS_STA_MODE:
2753 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002754 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002755 == VOS_STA_MODE)) //check for P2P client mode
2756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002757 smsLog(pMac, LOGE, FL(" ****STA mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002758 return eHAL_STATUS_FAILURE;
2759 }
2760 break;
2761
2762 case VOS_STA_SAP_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302763 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2764 == VOS_STA_SAP_MODE)&&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002765 (pMac->roam.roamSession[sessionId].connectState
2766 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002768 smsLog(pMac, LOGE, FL(" ****SoftAP mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002769 return eHAL_STATUS_FAILURE;
2770 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002771 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2772 == VOS_P2P_GO_MODE &&
2773 pMac->roam.roamSession[sessionId].connectState
2774 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2775 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2776 == VOS_IBSS_MODE &&
2777 pMac->roam.roamSession[sessionId].connectState
2778 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002780 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002781 return eHAL_STATUS_FAILURE;
2782 }
2783 break;
2784
2785 case VOS_P2P_CLIENT_MODE:
2786 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002787 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002788 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2789 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002790 smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002791 return eHAL_STATUS_FAILURE;
2792 }
2793 break;
2794
2795 case VOS_P2P_GO_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302796 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2797 == VOS_P2P_GO_MODE) &&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002798 (pMac->roam.roamSession[sessionId].connectState
2799 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002801 smsLog(pMac, LOGE, FL(" ****P2P GO mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002802 return eHAL_STATUS_FAILURE;
2803 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002804 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2805 == VOS_STA_SAP_MODE &&
2806 pMac->roam.roamSession[sessionId].connectState
2807 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2808 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2809 == VOS_IBSS_MODE &&
2810 pMac->roam.roamSession[sessionId].connectState
2811 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002813 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002814 return eHAL_STATUS_FAILURE;
2815 }
2816 break;
Ravi Joshia96ceb42013-05-20 18:52:39 -07002817 case VOS_IBSS_MODE:
2818 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2819 == VOS_IBSS_MODE) &&
2820 (pMac->roam.roamSession[sessionId].connectState
2821 != eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED))
2822 {
2823 smsLog(pMac, LOGE, FL(" ****IBSS mode already exists ****"));
2824 return eHAL_STATUS_FAILURE;
2825 }
2826 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2827 == VOS_P2P_GO_MODE ||
2828 pMac->roam.roamSession[sessionId].bssParams.bssPersona
2829 == VOS_STA_SAP_MODE) &&
2830 pMac->roam.roamSession[sessionId].connectState
2831 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)
2832 {
2833 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
2834 return eHAL_STATUS_FAILURE;
2835 }
2836 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002837 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002838 smsLog(pMac, LOGE, FL("***Persona not handled = %d*****"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07002839 break;
2840 }
2841 }
2842 }
2843 return eHAL_STATUS_SUCCESS;
2844
2845}
2846
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002847eHalStatus csrUpdateMCCp2pBeaconInterval(tpAniSirGlobal pMac)
Jeff Johnsone7245742012-09-05 17:12:55 -07002848{
2849 tANI_U32 sessionId = 0;
2850
2851 //If MCC is not supported just break and return SUCCESS
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002852 if ( !pMac->roam.configParam.fenableMCCMode){
2853 return eHAL_STATUS_FAILURE;
2854 }
2855
2856 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2857 {
2858 /* If GO in MCC support different beacon interval,
2859 * change the BI of the P2P-GO */
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002860 if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2861 == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002862 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002863 /* Handle different BI scneario based on the configuration set.
2864 * If Config is set to 0x02 then Disconnect all the P2P clients
2865 * associated. If config is set to 0x04 then update the BI
2866 * without disconnecting all the clients
2867 */
2868 if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
2869 (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
2870 {
2871 return csrSendChngMCCBeaconInterval( pMac, sessionId);
2872 }
2873 //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
2874 else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
2875 {
2876 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
2877 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002878 }
2879 }
2880 return eHAL_STATUS_FAILURE;
2881}
2882
2883tANI_U16 csrCalculateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U16 sta_bi, tANI_U16 go_gbi)
2884{
2885 tANI_U8 num_beacons = 0;
2886 tANI_U8 is_multiple = 0;
2887 tANI_U16 go_cbi = 0;
2888 tANI_U16 go_fbi = 0;
2889 tANI_U16 sta_cbi = 0;
2890
2891 //If GO's given beacon Interval is less than 100
2892 if(go_gbi < 100)
2893 go_cbi = 100;
2894 //if GO's given beacon Interval is greater than or equal to 100
2895 else
2896 go_cbi = 100 + (go_gbi % 100);
2897
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05302898 if ( sta_bi == 0 )
2899 {
2900 /* There is possibility to receive zero as value.
2901 Which will cause divide by zero. Hence initialise with 100
2902 */
2903 sta_bi = 100;
2904 smsLog(pMac, LOGW,
2905 FL("sta_bi 2nd parameter is zero, initialise to %d"), sta_bi);
2906 }
2907
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002908 // check, if either one is multiple of another
2909 if (sta_bi > go_cbi)
2910 {
2911 is_multiple = !(sta_bi % go_cbi);
2912 }
2913 else
2914 {
2915 is_multiple = !(go_cbi % sta_bi);
2916 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002917 // if it is multiple, then accept GO's beacon interval range [100,199] as it is
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002918 if (is_multiple)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002919 {
2920 return go_cbi;
2921 }
2922 //else , if it is not multiple, then then check for number of beacons to be
2923 //inserted based on sta BI
2924 num_beacons = sta_bi / 100;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002925 if (num_beacons)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002926 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002927 // GO's final beacon interval will be aligned to sta beacon interval, but
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002928 //in the range of [100, 199].
2929 sta_cbi = sta_bi / num_beacons;
2930 go_fbi = sta_cbi;
2931 }
2932 else
2933 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002934 // if STA beacon interval is less than 100, use GO's change bacon interval
2935 //instead of updating to STA's beacon interval.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002936 go_fbi = go_cbi;
2937 }
2938 return go_fbi;
2939}
2940
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002941eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002942 tANI_U16 *beaconInterval, tANI_U32 cursessionId,
2943 tVOS_CON_MODE currBssPersona)
2944{
2945 tANI_U32 sessionId = 0;
2946 tANI_U16 new_beaconInterval = 0;
2947
2948 //If MCC is not supported just break
2949 if (!pMac->roam.configParam.fenableMCCMode){
Jeff Johnsone7245742012-09-05 17:12:55 -07002950 return eHAL_STATUS_FAILURE;
2951 }
2952
2953 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2954 {
2955 if (cursessionId != sessionId )
2956 {
2957 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2958 {
2959 continue;
2960 }
2961
2962 switch (currBssPersona)
2963 {
2964 case VOS_STA_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002965 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
2966 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002967 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2968 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002969 smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002970 }
2971 //IF SAP has started and STA wants to connect on different channel MCC should
2972 //MCC should not be enabled so making it false to enforce on same channel
2973 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2974 == VOS_STA_SAP_MODE)
2975 {
2976 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
2977 != channelId )
2978 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002979 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP +STA****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002980 return eHAL_STATUS_FAILURE;
2981 }
2982 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002983 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002984 == VOS_P2P_GO_MODE) //Check for P2P go scenario
2985 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002986 /* if GO in MCC support different beacon interval,
2987 * change the BI of the P2P-GO */
2988 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
Jeff Johnsone7245742012-09-05 17:12:55 -07002989 != channelId ) &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002990 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07002991 != *beaconInterval))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002992 {
2993 /* if GO in MCC support different beacon interval, return success */
2994 if ( pMac->roam.configParam.fAllowMCCGODiffBI == 0x01)
2995 {
2996 return eHAL_STATUS_SUCCESS;
2997 }
2998 // Send only Broadcast disassoc and update beaconInterval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002999 //If configuration is set to 0x04 then dont
3000 // disconnect all the station
3001 else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
3002 (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003003 {
3004 //Check to pass the right beacon Interval
3005 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval,
3006 pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003007 smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003008 //Update the becon Interval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003009 if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003010 {
3011 //Update the beaconInterval now
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003012 smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
3013 pMac->roam.configParam.fAllowMCCGODiffBI);
3014
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003015 pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
3016 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003017 return csrUpdateMCCp2pBeaconInterval(pMac);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003018 }
3019 return eHAL_STATUS_SUCCESS;
3020 }
3021 //Disconnect the P2P session
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003022 else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003023 {
3024 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
3025 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
3026 }
3027 else
3028 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003029 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to preferred AP..."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003030 return eHAL_STATUS_FAILURE;
3031 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003032 }
3033 }
3034 break;
3035
3036 case VOS_P2P_CLIENT_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003037 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3038 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003039 == VOS_STA_MODE)) //check for P2P client mode
3040 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003041 smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003042 }
3043 //IF SAP has started and STA wants to connect on different channel MCC should
3044 //MCC should not be enabled so making it false to enforce on same channel
3045 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3046 == VOS_STA_SAP_MODE)
3047 {
3048 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3049 != channelId )
3050 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003051 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP + CLIENT****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003052 return eHAL_STATUS_FAILURE;
3053 }
3054 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003055 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003056 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3057 {
3058 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
3059 != channelId ) &&
3060 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
3061 != *beaconInterval))
3062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003063 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to P2P_GO network ..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003064 return eHAL_STATUS_FAILURE;
3065 }
3066 }
3067 break;
3068
3069 case VOS_P2P_GO_MODE :
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003070 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003071 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3072 ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003073 == VOS_P2P_CLIENT_MODE) ||
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003074 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003075 == VOS_STA_MODE))) //check for P2P_client scenario
3076 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003077 if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003078 == 0 )&&
3079 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
3080 == 0))
3081 {
3082 continue;
3083 }
3084
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05303085 //Assert if connected profile beacon internal is ZERO
3086 if(!pMac->roam.roamSession[sessionId].\
3087 connectedProfile.beaconInterval)
3088 {
3089 smsLog( pMac, LOGE, FL(" Connected profile "
3090 "beacon interval is zero") );
3091 }
3092
Jeff Johnsone7245742012-09-05 17:12:55 -07003093
3094 if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003095 (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003096 != channelId ) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003097 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003098 != *beaconInterval))
3099 {
3100 /*
3101 * Updated beaconInterval should be used only when we are starting a new BSS
3102 * not incase of client or STA case
3103 */
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003104 //Calculate beacon Interval for P2P-GO incase of MCC
3105 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac,
Chet Lanctot4c986162013-05-08 13:59:56 -07003106 pMac->roam.roamSession[sessionId].bssParams.beaconInterval,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003107 *beaconInterval );
3108 if(*beaconInterval != new_beaconInterval)
3109 *beaconInterval = new_beaconInterval;
Jeff Johnsone7245742012-09-05 17:12:55 -07003110 return eHAL_STATUS_SUCCESS;
3111 }
3112 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003113 }
3114 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003115
3116 default :
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303117 smsLog(pMac, LOGE, FL(" Persona not supported : %d"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003118 return eHAL_STATUS_FAILURE;
3119 }
3120 }
3121 }
3122
3123 return eHAL_STATUS_SUCCESS;
3124}
Jeff Johnson295189b2012-06-20 16:38:30 -07003125
3126#ifdef WLAN_FEATURE_VOWIFI_11R
3127/* Function to return TRUE if the authtype is 11r */
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003128tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -07003129{
3130 switch ( AuthType )
3131 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003132 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3133 if(mdiePresent)
3134 return TRUE;
3135 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3137 case eCSR_AUTH_TYPE_FT_RSN:
3138 return TRUE;
3139 break;
3140 default:
3141 break;
3142 }
3143 return FALSE;
3144}
3145
3146/* Function to return TRUE if the profile is 11r */
3147tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
3148{
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003149 return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
Jeff Johnson295189b2012-06-20 16:38:30 -07003150}
3151
3152#endif
3153
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003154#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003155
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003156/* Function to return TRUE if the authtype is ESE */
3157tANI_BOOLEAN csrIsAuthTypeESE( eCsrAuthType AuthType )
Jeff Johnson295189b2012-06-20 16:38:30 -07003158{
3159 switch ( AuthType )
3160 {
3161 case eCSR_AUTH_TYPE_CCKM_WPA:
3162 case eCSR_AUTH_TYPE_CCKM_RSN:
3163 return TRUE;
3164 break;
3165 default:
3166 break;
3167 }
3168 return FALSE;
3169}
3170
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003171/* Function to return TRUE if the profile is ESE */
3172tANI_BOOLEAN csrIsProfileESE( tCsrRoamProfile *pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003173{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003174 return (csrIsAuthTypeESE( pProfile->negotiatedAuthType ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003175}
3176
3177#endif
3178
3179#ifdef FEATURE_WLAN_WAPI
3180tANI_BOOLEAN csrIsProfileWapi( tCsrRoamProfile *pProfile )
3181{
3182 tANI_BOOLEAN fWapiProfile = FALSE;
3183
3184 switch ( pProfile->negotiatedAuthType )
3185 {
3186 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
3187 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
3188 fWapiProfile = TRUE;
3189 break;
3190
3191 default:
3192 fWapiProfile = FALSE;
3193 break;
3194 }
3195
3196 if ( fWapiProfile )
3197 {
3198 switch ( pProfile->negotiatedUCEncryptionType )
3199 {
3200 case eCSR_ENCRYPT_TYPE_WPI:
3201 fWapiProfile = TRUE;
3202 break;
3203
3204 default:
3205 fWapiProfile = FALSE;
3206 break;
3207 }
3208 }
3209 return( fWapiProfile );
3210}
3211
3212static tANI_BOOLEAN csrIsWapiOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3213{
Kiet Lam64c1b492013-07-12 13:56:44 +05303214 return (vos_mem_compare(Oui1, Oui2, CSR_WAPI_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003215}
3216
3217static tANI_BOOLEAN csrIsWapiOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3218 tANI_U8 cAllCyphers,
3219 tANI_U8 Cypher[],
3220 tANI_U8 Oui[] )
3221{
3222 tANI_BOOLEAN fYes = FALSE;
3223 tANI_U8 idx;
3224
3225 for ( idx = 0; idx < cAllCyphers; idx++ )
3226 {
3227 if ( csrIsWapiOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3228 {
3229 fYes = TRUE;
3230 break;
3231 }
3232 }
3233
3234 if ( fYes && Oui )
3235 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303236 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 }
3238
3239 return( fYes );
3240}
3241#endif /* FEATURE_WLAN_WAPI */
3242
3243static tANI_BOOLEAN csrIsWpaOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3244{
Kiet Lam64c1b492013-07-12 13:56:44 +05303245 return(vos_mem_compare(Oui1, Oui2, CSR_WPA_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003246}
3247
3248static tANI_BOOLEAN csrIsOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3249 tANI_U8 cAllCyphers,
3250 tANI_U8 Cypher[],
3251 tANI_U8 Oui[] )
3252{
3253 tANI_BOOLEAN fYes = FALSE;
3254 tANI_U8 idx;
3255
3256 for ( idx = 0; idx < cAllCyphers; idx++ )
3257 {
3258 if ( csrIsWpaOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3259 {
3260 fYes = TRUE;
3261 break;
3262 }
3263 }
3264
3265 if ( fYes && Oui )
3266 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303267 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 }
3269
3270 return( fYes );
3271}
3272
3273static tANI_BOOLEAN csrMatchRSNOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3274 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3275 tANI_U8 Oui[] )
3276{
3277 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui[ouiIndex], Oui ) );
3278
3279}
3280
3281#ifdef FEATURE_WLAN_WAPI
3282static tANI_BOOLEAN csrMatchWapiOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3283 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3284 tANI_U8 Oui[] )
3285{
Kaushik, Sushantfe230152014-04-08 14:37:47 +05303286 if (ouiIndex < CSR_WAPI_OUI_ROW_SIZE)// since csrWapiOui row size is 3 .
3287 return( csrIsWapiOuiMatch( pMac, AllCyphers, cAllCyphers,
3288 csrWapiOui[ouiIndex], Oui ) );
3289 else
3290 return FALSE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07003291
3292}
3293#endif /* FEATURE_WLAN_WAPI */
3294
3295static tANI_BOOLEAN csrMatchWPAOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3296 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3297 tANI_U8 Oui[] )
3298{
3299 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui[ouiIndex], Oui ) );
3300
3301}
3302
3303#if 0
3304static tANI_BOOLEAN csrIsRSNUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3305 tANI_U8 cAllCyphers,
3306 tANI_U8 Oui[] )
3307{
3308 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui00, Oui ) );
3309}
3310
3311static tANI_BOOLEAN csrIsRSNMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3312 tANI_U8 cAllCyphers,
3313 tANI_U8 Oui[] )
3314{
3315 tANI_BOOLEAN fYes = FALSE;
3316
3317 // Check Wep 104 first, if fails, then check Wep40.
3318 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui05, Oui );
3319
3320 if ( !fYes )
3321 {
3322 // if not Wep-104, check Wep-40
3323 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui01, Oui );
3324 }
3325
3326 return( fYes );
3327}
3328
3329
3330static tANI_BOOLEAN csrIsRSNUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3331 tANI_U8 cAllCyphers,
3332 tANI_U8 Oui[] )
3333{
3334 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3335}
3336
3337
3338static tANI_BOOLEAN csrIsRSNMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3339 tANI_U8 cAllCyphers,
3340 tANI_U8 Oui[] )
3341{
3342 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3343}
3344
3345static tANI_BOOLEAN csrIsRSNUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3346 tANI_U8 cAllCyphers,
3347 tANI_U8 Oui[] )
3348{
3349 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3350}
3351
3352static tANI_BOOLEAN csrIsRSNMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3353 tANI_U8 cAllCyphers,
3354 tANI_U8 Oui[] )
3355{
3356 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3357}
3358#endif
3359#ifdef FEATURE_WLAN_WAPI
3360static tANI_BOOLEAN csrIsAuthWapiCert( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3361 tANI_U8 cAllSuites,
3362 tANI_U8 Oui[] )
3363{
3364 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[1], Oui ) );
3365}
3366static tANI_BOOLEAN csrIsAuthWapiPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3367 tANI_U8 cAllSuites,
3368 tANI_U8 Oui[] )
3369{
3370 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[2], Oui ) );
3371}
3372#endif /* FEATURE_WLAN_WAPI */
3373
3374#ifdef WLAN_FEATURE_VOWIFI_11R
3375
3376/*
3377 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3378 * here. This matches for FT Auth with the 802.1X exchange.
3379 *
3380 */
3381static tANI_BOOLEAN csrIsFTAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3382 tANI_U8 cAllSuites,
3383 tANI_U8 Oui[] )
3384{
3385 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[03], Oui ) );
3386}
3387
3388/*
3389 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3390 * here. This matches for FT Auth with the PSK.
3391 *
3392 */
3393static tANI_BOOLEAN csrIsFTAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3394 tANI_U8 cAllSuites,
3395 tANI_U8 Oui[] )
3396{
3397 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[04], Oui ) );
3398}
3399
3400#endif
3401
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003402#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003403
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003404/*
3405 * Function for ESE CCKM AKM Authentication. We match the CCKM AKM Authentication Key Management suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 * here. This matches for CCKM AKM Auth with the 802.1X exchange.
3407 *
3408 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003409static tANI_BOOLEAN csrIsEseCckmAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 tANI_U8 cAllSuites,
3411 tANI_U8 Oui[] )
3412{
3413 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[06], Oui ) );
3414}
3415
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003416static tANI_BOOLEAN csrIsEseCckmAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 tANI_U8 cAllSuites,
3418 tANI_U8 Oui[] )
3419{
3420 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[06], Oui ) );
3421}
3422
3423#endif
3424
3425static tANI_BOOLEAN csrIsAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3426 tANI_U8 cAllSuites,
3427 tANI_U8 Oui[] )
3428{
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[01], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003430}
3431static tANI_BOOLEAN csrIsAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3432 tANI_U8 cAllSuites,
3433 tANI_U8 Oui[] )
3434{
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[02], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003436}
3437
Chet Lanctot186b5732013-03-18 10:26:30 -07003438#ifdef WLAN_FEATURE_11W
3439static tANI_BOOLEAN csrIsAuthRSNPskSha256( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3440 tANI_U8 cAllSuites,
3441 tANI_U8 Oui[] )
3442{
Chet Lanctot4c986162013-05-08 13:59:56 -07003443 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[07], Oui );
Chet Lanctot186b5732013-03-18 10:26:30 -07003444}
3445#endif
3446
Jeff Johnson295189b2012-06-20 16:38:30 -07003447static tANI_BOOLEAN csrIsAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3448 tANI_U8 cAllSuites,
3449 tANI_U8 Oui[] )
3450{
3451 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[01], Oui ) );
3452}
3453
3454#ifdef NOT_CURRENTLY_USED
3455static tANI_BOOLEAN csrIsAuth802_1x( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3456 tANI_U8 cAllSuites,
3457 tANI_U8 Oui[] )
3458{
3459 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[00], Oui ) );
3460}
3461#endif // NOT_CURRENTLY_USED
3462
3463static tANI_BOOLEAN csrIsAuthWpaPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3464 tANI_U8 cAllSuites,
3465 tANI_U8 Oui[] )
3466{
3467 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[02], Oui ) );
3468}
3469#if 0
3470static tANI_BOOLEAN csrIsUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3471 tANI_U8 cAllCyphers,
3472 tANI_U8 Oui[] )
3473{
3474 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui00, Oui ) );
3475}
3476
3477static tANI_BOOLEAN csrIsUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3478 tANI_U8 cAllCyphers,
3479 tANI_U8 Oui[] )
3480{
3481 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3482}
3483
3484static tANI_BOOLEAN csrIsUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3485 tANI_U8 cAllCyphers,
3486 tANI_U8 Oui[] )
3487{
3488 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3489}
3490
3491
3492static tANI_BOOLEAN csrIsMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3493 tANI_U8 cAllCyphers,
3494 tANI_U8 Oui[] )
3495{
3496 tANI_BOOLEAN fYes = FALSE;
3497
3498 // Check Wep 104 first, if fails, then check Wep40.
3499 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui05, Oui );
3500
3501 if ( !fYes )
3502 {
3503 // if not Wep-104, check Wep-40
3504 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui01, Oui );
3505 }
3506
3507 return( fYes );
3508}
3509
3510
3511static tANI_BOOLEAN csrIsMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3512 tANI_U8 cAllCyphers,
3513 tANI_U8 Oui[] )
3514{
3515 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3516}
3517
3518
3519static tANI_BOOLEAN csrIsMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3520 tANI_U8 cAllCyphers,
3521 tANI_U8 Oui[] )
3522{
3523 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3524}
3525
3526#endif
3527
3528tANI_U8 csrGetOUIIndexFromCipher( eCsrEncryptionType enType )
3529{
3530 tANI_U8 OUIIndex;
3531
3532 switch ( enType )
3533 {
3534 case eCSR_ENCRYPT_TYPE_WEP40:
3535 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3536 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX;
3537 break;
3538 case eCSR_ENCRYPT_TYPE_WEP104:
3539 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3540 OUIIndex = CSR_OUI_WEP104_INDEX;
3541 break;
3542 case eCSR_ENCRYPT_TYPE_TKIP:
3543 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX;
3544 break;
3545 case eCSR_ENCRYPT_TYPE_AES:
3546 OUIIndex = CSR_OUI_AES_INDEX;
3547 break;
3548 case eCSR_ENCRYPT_TYPE_NONE:
3549 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX;
3550 break;
3551#ifdef FEATURE_WLAN_WAPI
3552 case eCSR_ENCRYPT_TYPE_WPI:
3553 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX;
3554 break;
3555#endif /* FEATURE_WLAN_WAPI */
3556 default: //HOWTO handle this?
3557 OUIIndex = CSR_OUI_RESERVED_INDEX;
3558 break;
3559 }//switch
3560
3561 return OUIIndex;
3562}
3563
3564tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3565 tDot11fIERSN *pRSNIe,
3566 tANI_U8 *UnicastCypher,
3567 tANI_U8 *MulticastCypher,
3568 tANI_U8 *AuthSuite,
3569 tCsrRSNCapabilities *Capabilities,
3570 eCsrAuthType *pNegotiatedAuthtype,
3571 eCsrEncryptionType *pNegotiatedMCCipher )
3572{
3573 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3574 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3575 tANI_U8 cUnicastCyphers = 0;
3576 tANI_U8 cMulticastCyphers = 0;
3577 tANI_U8 cAuthSuites = 0, i;
3578 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3579 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3580 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3581 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3582 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3583 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3584
3585 do{
3586 if ( pRSNIe->present )
3587 {
3588 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303589 vos_mem_copy(MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
3591 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_count);
3592 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3593 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303594 vos_mem_copy((void *)&AuthSuites[i],
3595 (void *)&pRSNIe->akm_suites[i],
3596 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 }
3598
3599 //Check - Is requested Unicast Cipher supported by the BSS.
3600 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3601 csrGetOUIIndexFromCipher( enType ), Unicast );
3602
3603 if( !fAcceptableCyphers ) break;
3604
3605
3606 //Unicast is supported. Pick the first matching Group cipher, if any.
3607 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3608 {
3609 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3610 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3611 if(fAcceptableCyphers)
3612 {
3613 break;
3614 }
3615 }
3616 if( !fAcceptableCyphers ) break;
3617
3618 if( pNegotiatedMCCipher )
3619 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3620
3621 /* Initializing with FALSE as it has TRUE value already */
3622 fAcceptableCyphers = FALSE;
3623 for (i = 0 ; i < pAuthType->numEntries; i++)
3624 {
3625 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3626 #ifdef WLAN_FEATURE_VOWIFI_11R
3627 /* Changed the AKM suites according to order of preference */
3628 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3629 {
3630 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3631 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3632 }
3633 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3634 {
3635 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3636 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3637 }
3638#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003639#ifdef FEATURE_WLAN_ESE
3640 /* ESE only supports 802.1X. No PSK. */
3641 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 {
3643 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3644 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3645 }
3646#endif
3647 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3648 {
3649 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3650 negAuthType = eCSR_AUTH_TYPE_RSN;
3651 }
3652 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3653 {
3654 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3655 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3656 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003657#ifdef WLAN_FEATURE_11W
3658 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3659 {
3660 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3661 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3662 }
3663#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003664
3665 // The 1st auth type in the APs RSN IE, to match stations connecting
3666 // profiles auth type will cause us to exit this loop
3667 // This is added as some APs advertise multiple akms in the RSN IE.
3668 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3669 {
3670 fAcceptableCyphers = TRUE;
3671 break;
3672 }
3673 } // for
3674 }
3675
3676 }while (0);
3677
3678 if ( fAcceptableCyphers )
3679 {
3680 if ( MulticastCypher )
3681 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303682 vos_mem_copy(MulticastCypher, Multicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 }
3684
3685 if ( UnicastCypher )
3686 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303687 vos_mem_copy(UnicastCypher, Unicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 }
3689
3690 if ( AuthSuite )
3691 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303692 vos_mem_copy(AuthSuite, Authentication, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 }
3694
3695 if ( pNegotiatedAuthtype )
3696 {
3697 *pNegotiatedAuthtype = negAuthType;
3698 }
3699 if ( Capabilities )
3700 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003701 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3702 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3703 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003704 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003705 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3706 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
Chet Lanctot186b5732013-03-18 10:26:30 -07003707 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 }
3709 }
3710 return( fAcceptableCyphers );
3711}
3712
3713
3714tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
3715 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
3716{
3717 tANI_BOOLEAN fRSNMatch = FALSE;
3718
3719 // See if the cyphers in the Bss description match with the settings in the profile.
3720 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
3721 pNegotiatedAuthType, pNegotiatedMCCipher );
3722
3723 return( fRSNMatch );
3724}
3725
3726
3727tANI_BOOLEAN csrLookupPMKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pPMKId )
3728{
3729 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
3730 tANI_U32 Index;
3731 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3732
Jeff Johnson32d95a32012-09-10 13:15:23 -07003733 if(!pSession)
3734 {
3735 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3736 return FALSE;
3737 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003738 /* to force the AP initiate fresh 802.1x authentication after re-association should not
3739 * fill the PMKID from cache this is needed
3740 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
3741
3742 if(pSession->fIgnorePMKIDCache)
3743 {
3744 pSession->fIgnorePMKIDCache = FALSE;
3745 return fRC;
3746 }
3747
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 do
3749 {
3750 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
3751 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08003752 smsLog(pMac, LOGW, "match PMKID "MAC_ADDRESS_STR " to ",
3753 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05303754 if( vos_mem_compare(pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 {
3756 // match found
3757 fMatchFound = TRUE;
3758 break;
3759 }
3760 }
3761
3762 if( !fMatchFound ) break;
3763
Kiet Lam64c1b492013-07-12 13:56:44 +05303764 vos_mem_copy(pPMKId, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003765
3766 fRC = TRUE;
3767 }
3768 while( 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003769 smsLog(pMac, LOGW, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 fRC, pSession->NumPmkidCache);
3771
3772 return fRC;
3773}
3774
3775
3776tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3777 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
3778{
3779 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3780 tANI_BOOLEAN fRSNMatch;
3781 tANI_U8 cbRSNIe = 0;
3782 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
3783 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
3784 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
3785 tCsrRSNAuthIe *pAuthSuite;
3786 tCsrRSNCapabilities RSNCapabilities;
3787 tCsrRSNPMKIe *pPMK;
3788 tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003789#ifdef WLAN_FEATURE_11W
3790 tANI_U8 *pGroupMgmtCipherSuite;
3791#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 tDot11fBeaconIEs *pIesLocal = pIes;
3793
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003794 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003795
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 do
3797 {
3798 if ( !csrIsProfileRSN( pProfile ) ) break;
3799
3800 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
3801 {
3802 break;
3803 }
3804
3805 // See if the cyphers in the Bss description match with the settings in the profile.
3806 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
3807 &pProfile->mcEncryptionType, &pIesLocal->RSN,
3808 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, NULL, NULL );
3809 if ( !fRSNMatch ) break;
3810
3811 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
3812
3813 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
3814
Kiet Lam64c1b492013-07-12 13:56:44 +05303815 vos_mem_copy(pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003816
3817 pRSNIe->cUnicastCyphers = 1;
3818
Kiet Lam64c1b492013-07-12 13:56:44 +05303819 vos_mem_copy(&pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003820
3821 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
3822
3823 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05303824 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003825
3826 // RSN capabilities follows the Auth Suite (two octects)
3827 // !!REVIEW - What should STA put in RSN capabilities, currently
3828 // just putting back APs capabilities
3829 // 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 -07003830 // For another, we should use the Management Frame Protection values given by the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 RSNCapabilities.PreAuthSupported = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003832#ifdef WLAN_FEATURE_11W
3833 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
3834 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
3835#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
3837
3838 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
3839
3840 if( csrLookupPMKID( pMac, sessionId, pSirBssDesc->bssId, &(PMKId[0]) ) )
3841 {
3842 pPMK->cPMKIDs = 1;
3843
Kiet Lam64c1b492013-07-12 13:56:44 +05303844 vos_mem_copy(pPMK->PMKIDList[0].PMKID, PMKId, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 }
3846 else
3847 {
3848 pPMK->cPMKIDs = 0;
3849 }
3850
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003851#ifdef WLAN_FEATURE_11W
3852 if ( pProfile->MFPEnabled )
3853 {
3854 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
3855 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
Kiet Lam64c1b492013-07-12 13:56:44 +05303856 vos_mem_copy(pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE);
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003857 }
3858#endif
3859
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
3861 // Add in the size of the Auth suite (count plus a single OUI)
3862 // Add in the RSN caps field.
3863 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003864 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
3866 sizeof( *pAuthSuite ) +
3867 sizeof( tCsrRSNCapabilities ));
3868 if(pPMK->cPMKIDs)
3869 {
3870 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
3871 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
3872 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003873#ifdef WLAN_FEATURE_11W
3874 if ( pProfile->MFPEnabled )
3875 {
3876 if ( 0 == pPMK->cPMKIDs )
3877 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
3878 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
3879 }
3880#endif
3881
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 // return the size of the IE header (total) constructed...
3883 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
3884
3885 } while( 0 );
3886
3887 if( !pIes && pIesLocal )
3888 {
3889 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05303890 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 }
3892
3893 return( cbRSNIe );
3894}
3895
3896
3897#ifdef FEATURE_WLAN_WAPI
3898tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3899 tDot11fIEWAPI *pWapiIe,
3900 tANI_U8 *UnicastCypher,
3901 tANI_U8 *MulticastCypher,
3902 tANI_U8 *AuthSuite,
3903 eCsrAuthType *pNegotiatedAuthtype,
3904 eCsrEncryptionType *pNegotiatedMCCipher )
3905{
3906 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3907 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3908 tANI_U8 cUnicastCyphers = 0;
3909 tANI_U8 cMulticastCyphers = 0;
3910 tANI_U8 cAuthSuites = 0, i;
3911 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
3912 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
3913 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
3914 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
3915 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
3916 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3917
3918 do{
3919 if ( pWapiIe->present )
3920 {
3921 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303922 vos_mem_copy(MulticastCyphers, pWapiIe->multicast_cipher_suite,
3923 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
3925 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
3926 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
3927 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303928 vos_mem_copy((void *)&AuthSuites[i], (void *)&pWapiIe->akm_suites[i],
3929 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 }
3931
3932 //Check - Is requested Unicast Cipher supported by the BSS.
3933 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
3934 csrGetOUIIndexFromCipher( enType ), Unicast );
3935
3936 if( !fAcceptableCyphers ) break;
3937
3938
3939 //Unicast is supported. Pick the first matching Group cipher, if any.
3940 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3941 {
3942 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3943 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3944 if(fAcceptableCyphers)
3945 {
3946 break;
3947 }
3948 }
3949 if( !fAcceptableCyphers ) break;
3950
3951 if( pNegotiatedMCCipher )
3952 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3953
3954 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3955 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
3956 {
3957 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3958 }
3959 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3960 {
3961 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3962 }
3963 else
3964 {
3965 fAcceptableCyphers = FALSE;
3966 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3967 }
3968 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
3969 {
3970 //Caller doesn't care about auth type, or BSS doesn't match
3971 break;
3972 }
3973 fAcceptableCyphers = FALSE;
3974 for( i = 0 ; i < pAuthType->numEntries; i++ )
3975 {
3976 if( pAuthType->authType[i] == negAuthType )
3977 {
3978 fAcceptableCyphers = TRUE;
3979 break;
3980 }
3981 }
3982 }
3983 }while (0);
3984
3985 if ( fAcceptableCyphers )
3986 {
3987 if ( MulticastCypher )
3988 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303989 vos_mem_copy(MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 }
3991
3992 if ( UnicastCypher )
3993 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303994 vos_mem_copy(UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 }
3996
3997 if ( AuthSuite )
3998 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303999 vos_mem_copy(AuthSuite, Authentication, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 }
4001
4002 if ( pNegotiatedAuthtype )
4003 {
4004 *pNegotiatedAuthtype = negAuthType;
4005 }
4006 }
4007 return( fAcceptableCyphers );
4008}
4009
4010tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4011 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
4012{
4013 tANI_BOOLEAN fWapiMatch = FALSE;
4014
4015 // See if the cyphers in the Bss description match with the settings in the profile.
4016 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4017 pNegotiatedAuthType, pNegotiatedMCCipher );
4018
4019 return( fWapiMatch );
4020}
4021
4022tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4023{
4024 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4025 tANI_U32 Index;
4026 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4027
Jeff Johnson32d95a32012-09-10 13:15:23 -07004028 if(!pSession)
4029 {
4030 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4031 return FALSE;
4032 }
4033
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 do
4035 {
4036 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4037 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004038 smsLog(pMac, LOGW, "match BKID "MAC_ADDRESS_STR" to ",
4039 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05304040 if (vos_mem_compare(pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 {
4042 // match found
4043 fMatchFound = TRUE;
4044 break;
4045 }
4046 }
4047
4048 if( !fMatchFound ) break;
4049
Kiet Lam64c1b492013-07-12 13:56:44 +05304050 vos_mem_copy(pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004051
4052 fRC = TRUE;
4053 }
4054 while( 0 );
4055 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4056
4057 return fRC;
4058}
4059
4060tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4061 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4062{
4063 tANI_BOOLEAN fWapiMatch = FALSE;
4064 tANI_U8 cbWapiIe = 0;
4065 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4066 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4067 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4068 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4069 tANI_U8 *pWapi = NULL;
4070 tANI_BOOLEAN fBKIDFound = FALSE;
4071 tDot11fBeaconIEs *pIesLocal = pIes;
4072
4073 do
4074 {
4075 if ( !csrIsProfileWapi( pProfile ) ) break;
4076
4077 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4078 {
4079 break;
4080 }
4081
4082 // See if the cyphers in the Bss description match with the settings in the profile.
4083 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4084 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4085 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4086 if ( !fWapiMatch ) break;
4087
Kiet Lam64c1b492013-07-12 13:56:44 +05304088 vos_mem_set(pWapiIe, sizeof(tCsrWapiIe), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004089
4090 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4091
4092 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4093
4094 pWapiIe->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304095 vos_mem_copy(&pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004096
4097 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4098
4099 *pWapi = (tANI_U16)1; //cUnicastCyphers
4100 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304101 vos_mem_copy(pWapi, UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 pWapi += sizeof( UnicastCypher );
4103
Kiet Lam64c1b492013-07-12 13:56:44 +05304104 vos_mem_copy(pWapi, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 pWapi += sizeof( MulticastCypher );
4106
4107
4108 // WAPI capabilities follows the Auth Suite (two octects)
4109 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4110 // & since we already did a memset pWapiIe to 0, skip these fields
4111 pWapi +=2;
4112
4113 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4114
4115
4116 if( fBKIDFound )
4117 {
4118 /* Do we need to change the endianness here */
4119 *pWapi = (tANI_U16)1; //cBKIDs
4120 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304121 vos_mem_copy(pWapi, BKId, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 }
4123 else
4124 {
4125 *pWapi = 0;
4126 pWapi+=1;
4127 *pWapi = 0;
4128 pWapi+=1;
4129 }
4130
4131 // Add in the IE fields except the IE header
4132 // Add BKID count and BKID (if any)
4133 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4134
4135 /*2 bytes for BKID Count field*/
4136 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4137
4138 if(fBKIDFound)
4139 {
4140 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4141 }
4142 // return the size of the IE header (total) constructed...
4143 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4144
4145 } while( 0 );
4146
4147 if( !pIes && pIesLocal )
4148 {
4149 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304150 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 }
4152
4153 return( cbWapiIe );
4154}
4155#endif /* FEATURE_WLAN_WAPI */
4156
4157tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4158 tDot11fIEWPA *pWpaIe,
4159 tANI_U8 *UnicastCypher,
4160 tANI_U8 *MulticastCypher,
4161 tANI_U8 *AuthSuite,
4162 eCsrAuthType *pNegotiatedAuthtype,
4163 eCsrEncryptionType *pNegotiatedMCCipher )
4164{
4165 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4166 tANI_U8 cUnicastCyphers = 0;
4167 tANI_U8 cMulticastCyphers = 0;
4168 tANI_U8 cAuthSuites = 0;
4169 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4170 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4171 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4172 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4173 tANI_U8 i;
4174 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4175
4176 do
4177 {
4178 if ( pWpaIe->present )
4179 {
4180 cMulticastCyphers = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304181 vos_mem_copy(MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4183 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4184
4185 //Check - Is requested Unicast Cipher supported by the BSS.
4186 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4187 csrGetOUIIndexFromCipher( enType ), Unicast );
4188
4189 if( !fAcceptableCyphers ) break;
4190
4191
4192 //Unicast is supported. Pick the first matching Group cipher, if any.
4193 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4194 {
4195 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4196 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4197 if(fAcceptableCyphers)
4198 {
4199 break;
4200 }
4201 }
4202 if( !fAcceptableCyphers ) break;
4203
4204 if( pNegotiatedMCCipher )
4205 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4206
4207 /* Initializing with FALSE as it has TRUE value already */
4208 fAcceptableCyphers = FALSE;
4209 for (i = 0 ; i < pAuthType->numEntries; i++)
4210 {
4211 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4212 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4213 {
4214 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4215 negAuthType = eCSR_AUTH_TYPE_WPA;
4216 }
4217 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4218 {
4219 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4220 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4221 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004222#ifdef FEATURE_WLAN_ESE
4223 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 {
4225 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4226 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4227 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004228#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004229
4230 // The 1st auth type in the APs WPA IE, to match stations connecting
4231 // profiles auth type will cause us to exit this loop
4232 // This is added as some APs advertise multiple akms in the WPA IE.
4233 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4234 {
4235 fAcceptableCyphers = TRUE;
4236 break;
4237 }
4238 } // for
4239 }
4240 }while(0);
4241
4242 if ( fAcceptableCyphers )
4243 {
4244 if ( MulticastCypher )
4245 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304246 vos_mem_copy((tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 }
4248
4249 if ( UnicastCypher )
4250 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304251 vos_mem_copy((tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 }
4253
4254 if ( AuthSuite )
4255 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304256 vos_mem_copy((tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 }
4258
4259 if( pNegotiatedAuthtype )
4260 {
4261 *pNegotiatedAuthtype = negAuthType;
4262 }
4263 }
4264
4265 return( fAcceptableCyphers );
4266}
4267
4268
4269
4270tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4271 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4272{
4273 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4274
4275 // See if the cyphers in the Bss description match with the settings in the profile.
4276 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4277
4278 return( fWpaMatch );
4279}
4280
4281
4282tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4283 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4284{
4285 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4286 tANI_BOOLEAN fWpaMatch;
4287 tANI_U8 cbWpaIe = 0;
4288 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4289 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4290 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4291 tCsrWpaAuthIe *pAuthSuite;
4292 tDot11fBeaconIEs *pIesLocal = pIes;
4293
4294 do
4295 {
4296 if ( !csrIsProfileWpa( pProfile ) ) break;
4297
4298 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4299 {
4300 break;
4301 }
4302 // See if the cyphers in the Bss description match with the settings in the profile.
4303 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4304 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4305 if ( !fWpaMatch ) break;
4306
4307 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4308
Kiet Lam64c1b492013-07-12 13:56:44 +05304309 vos_mem_copy(pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004310
4311 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4312
Kiet Lam64c1b492013-07-12 13:56:44 +05304313 vos_mem_copy(pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004314
4315 pWpaIe->cUnicastCyphers = 1;
4316
Kiet Lam64c1b492013-07-12 13:56:44 +05304317 vos_mem_copy(&pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004318
4319 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4320
4321 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304322 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004323
4324 // The WPA capabilities follows the Auth Suite (two octects)--
4325 // this field is optional, and we always "send" zero, so just
4326 // remove it. This is consistent with our assumptions in the
4327 // frames compiler; c.f. bug 15234:
4328 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4329
4330 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4331 // Add in the size of the Auth suite (count plus a single OUI)
4332 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4333 sizeof( *pAuthSuite );
4334
4335 // return the size of the IE header (total) constructed...
4336 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4337
4338 } while( 0 );
4339
4340 if( !pIes && pIesLocal )
4341 {
4342 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304343 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 }
4345
4346 return( cbWpaIe );
4347}
4348
4349
4350tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4351 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4352{
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 tDot11IEHeader *pIEHeader;
4354 tSirMacPropIE *pSirMacPropIE;
4355 tANI_U32 cbParsed;
4356 tANI_U32 cbIE;
4357 int cExpectedIEs = 0;
4358 int cFoundIEs = 0;
4359 int cbPropIETotal;
4360
4361 pIEHeader = (tDot11IEHeader *)pIes;
4362 if(pWpaIe) cExpectedIEs++;
4363 if(pRSNIe) cExpectedIEs++;
4364
4365 // bss description length includes all fields other than the length itself
4366 cbParsed = 0;
4367
4368 // Loop as long as there is data left in the IE of the Bss Description
4369 // and the number of Expected IEs is NOT found yet.
4370 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4371 {
4372 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4373
4374 if ( ( cbIE + cbParsed ) > len ) break;
4375
4376 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4377 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4378 {
4379 switch( pIEHeader->ElementID )
4380 {
4381 // Parse the 221 (0xdd) Proprietary IEs here...
4382 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4383 // Airgo proprietary IE information.
4384 case SIR_MAC_WPA_EID:
4385 {
4386 tANI_U32 aniOUI;
4387 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4388
4389 pOui++;
4390 aniOUI = ANI_OUI;
4391 aniOUI = i_ntohl( aniOUI );
4392
4393 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4394 cbPropIETotal = pSirMacPropIE->length;
4395
4396 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4397 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4398 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4399 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4400 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4401 {
4402 }
4403 else
4404 {
4405 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4406
4407 if(!pWpaIe || !pcbWpaIe) break;
4408 // Check if this is a valid WPA IE. Then check that the
4409 // WPA OUI is in place and the version is one that we support.
4410 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
Kiet Lam64c1b492013-07-12 13:56:44 +05304411 ( vos_mem_compare( pIe->Oui, (void *)csrWpaOui[1],
4412 sizeof( pIe->Oui ) ) ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4414 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304415 vos_mem_copy(pWpaIe, pIe,
4416 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4418 cFoundIEs++;
4419
4420 break;
4421 }
4422 }
4423
4424 break;
4425 }
4426
4427 case SIR_MAC_RSN_EID:
4428 {
4429 tCsrRSNIe *pIe;
4430
4431 if(!pcbRSNIe || !pRSNIe) break;
4432 pIe = (tCsrRSNIe *)pIEHeader;
4433
4434 // Check the length of the RSN Ie to assure it is valid. Then check that the
4435 // version is one that we support.
4436
4437 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4438 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4439
4440 cFoundIEs++;
4441
4442 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4443 // the buffer passed in.
4444 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05304445 vos_mem_copy(pRSNIe, pIe,
4446 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4448
4449 break;
4450 }
4451
4452 // Add support for other IE here...
4453 default:
4454 break;
4455 }
4456 }
4457
4458 cbParsed += cbIE;
4459
4460 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4461
4462 }
4463
4464 // return a BOOL that tells if all of the IEs asked for were found...
4465 return( cFoundIEs == cExpectedIEs );
4466}
4467
4468
4469//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4470//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4471tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4472 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4473{
4474 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4475 tANI_U8 cbWpaIe = 0;
4476
4477 do
4478 {
4479 if ( !csrIsProfileWpa( pProfile ) ) break;
4480 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4481 {
4482 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4483 {
4484 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304485 vos_mem_copy(pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 }
4487 else
4488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004489 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 }
4491 }
4492 else
4493 {
4494 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4495 }
4496 }while(0);
4497
4498 return (cbWpaIe);
4499}
4500
4501
4502//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4503//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4504tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4505 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4506{
4507 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4508 tANI_U8 cbRsnIe = 0;
4509
4510 do
4511 {
4512 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004513#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304514 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004515 {
4516 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4517 // scratch. So it contains the current PMK-IDs
4518 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4519 }
4520 else
4521#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 if(pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
4523 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004524 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4526 {
4527 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304528 vos_mem_copy(pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 }
4530 else
4531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004532 smsLog(pMac, LOGW, " csrRetrieveRsnIe detect invalid RSN IE length (%d) ", pProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 }
4534 }
4535 else
4536 {
4537 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4538 }
4539 }while(0);
4540
4541 return (cbRsnIe);
4542}
4543
4544
4545#ifdef FEATURE_WLAN_WAPI
4546//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
4547//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
4548tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
4549 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4550 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4551{
4552 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4553 tANI_U8 cbWapiIe = 0;
4554
4555 do
4556 {
4557 if ( !csrIsProfileWapi( pProfile ) ) break;
4558 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
4559 {
4560 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
4561 {
4562 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304563 vos_mem_copy(pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 }
4565 else
4566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004567 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 }
4569 }
4570 else
4571 {
4572 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
4573 }
4574 }while(0);
4575
4576 return (cbWapiIe);
4577}
4578#endif /* FEATURE_WLAN_WAPI */
4579
4580tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
4581{
4582 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4583 tListElem *pEntry;
4584 tANI_U16 i;
4585 tANI_U16 startingChannel;
4586 tANI_BOOLEAN found = FALSE;
4587 tCsrChannelSet *pChannelGroup;
4588
4589 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
4590
4591 while ( pEntry )
4592 {
4593 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
4594 startingChannel = pChannelGroup->firstChannel;
4595 for ( i = 0; i < pChannelGroup->numChannels; i++ )
4596 {
4597 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
4598 {
4599 found = TRUE;
4600 break;
4601 }
4602 }
4603
4604 if ( found )
4605 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304606 vos_mem_copy(returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 break;
4608 }
4609 else
4610 {
4611 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
4612 }
4613 }
4614
4615 return( found );
4616}
4617
4618tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
4619{
4620 tANI_BOOLEAN fSupported = FALSE;
4621 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4622
4623 switch ( nonBasicRate )
4624 {
4625 case eCsrSuppRate_1Mbps:
4626 case eCsrSuppRate_2Mbps:
4627 case eCsrSuppRate_5_5Mbps:
4628 case eCsrSuppRate_11Mbps:
4629 fSupported = TRUE;
4630 break;
4631
4632 default:
4633 break;
4634 }
4635
4636 return( fSupported );
4637}
4638
4639tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
4640{
4641 tANI_BOOLEAN fSupported = FALSE;
4642 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4643
4644 switch ( nonBasicRate )
4645 {
4646 case eCsrSuppRate_6Mbps:
4647 case eCsrSuppRate_9Mbps:
4648 case eCsrSuppRate_12Mbps:
4649 case eCsrSuppRate_18Mbps:
4650 case eCsrSuppRate_24Mbps:
4651 case eCsrSuppRate_36Mbps:
4652 case eCsrSuppRate_48Mbps:
4653 case eCsrSuppRate_54Mbps:
4654 fSupported = TRUE;
4655 break;
4656
4657 default:
4658 break;
4659 }
4660
4661 return( fSupported );
4662}
4663
4664
4665
4666tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
4667{
4668 tAniEdType edType;
4669
4670 switch ( EncryptType )
4671 {
4672 default:
4673 case eCSR_ENCRYPT_TYPE_NONE:
4674 edType = eSIR_ED_NONE;
4675 break;
4676
4677 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4678 case eCSR_ENCRYPT_TYPE_WEP40:
4679 edType = eSIR_ED_WEP40;
4680 break;
4681
4682 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4683 case eCSR_ENCRYPT_TYPE_WEP104:
4684 edType = eSIR_ED_WEP104;
4685 break;
4686
4687 case eCSR_ENCRYPT_TYPE_TKIP:
4688 edType = eSIR_ED_TKIP;
4689 break;
4690
4691 case eCSR_ENCRYPT_TYPE_AES:
4692 edType = eSIR_ED_CCMP;
4693 break;
4694#ifdef FEATURE_WLAN_WAPI
4695 case eCSR_ENCRYPT_TYPE_WPI:
4696 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05304697 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004698#endif
4699#ifdef WLAN_FEATURE_11W
4700 //11w BIP
4701 case eCSR_ENCRYPT_TYPE_AES_CMAC:
4702 edType = eSIR_ED_AES_128_CMAC;
4703 break;
4704#endif
4705 }
4706
4707 return( edType );
4708}
4709
4710
4711//pIes can be NULL
4712tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
4713 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
4714 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
4715 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
4716{
4717 tANI_U32 idx;
4718 tANI_BOOLEAN fMatch = FALSE;
4719 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4720 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4721
4722 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
4723
4724 do
4725 {
4726 //If privacy bit is not set, consider no match
4727 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
4728
4729 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
4730 {
4731 switch( pMCEncryptionList->encryptionType[idx] )
4732 {
4733 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4734 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4735 case eCSR_ENCRYPT_TYPE_WEP40:
4736 case eCSR_ENCRYPT_TYPE_WEP104:
4737 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
4738 */
4739 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
4740 {
4741 fMatch = TRUE;
4742 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
4743 }
4744 break;
4745 default:
4746 fMatch = FALSE;
4747 break;
4748 }
4749 if(fMatch) break;
4750 }
4751
4752 if(!fMatch) break;
4753
4754 for( idx = 0; idx < pAuthList->numEntries; idx++ )
4755 {
4756 switch( pAuthList->authType[idx] )
4757 {
4758 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4759 case eCSR_AUTH_TYPE_SHARED_KEY:
4760 case eCSR_AUTH_TYPE_AUTOSWITCH:
4761 fMatch = TRUE;
4762 negotiatedAuth = pAuthList->authType[idx];
4763 break;
4764 default:
4765 fMatch = FALSE;
4766 }
4767 if (fMatch) break;
4768 }
4769
4770 if(!fMatch) break;
4771 //In case of WPA / WPA2, check whether it supports WEP as well
4772 if(pIes)
4773 {
4774 //Prepare the encryption type for WPA/WPA2 functions
4775 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
4776 {
4777 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4778 }
4779 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
4780 {
4781 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4782 }
4783 //else we can use the encryption type directly
Kiet Lam64c1b492013-07-12 13:56:44 +05304784 if ( pIes->WPA.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304786 fMatch = vos_mem_compare(pIes->WPA.multicast_cipher,
4787 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
4788 CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 if( fMatch ) break;
4790 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304791 if ( pIes->RSN.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304793 fMatch = vos_mem_compare(pIes->RSN.gp_cipher_suite,
4794 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
4795 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 }
4797 }
4798
4799 }while(0);
4800
4801 if( fMatch )
4802 {
4803 if( pNegotiatedAuthType )
4804 *pNegotiatedAuthType = negotiatedAuth;
4805
4806 if( pNegotiatedMCEncryption )
4807 *pNegotiatedMCEncryption = negotiatedMCCipher;
4808 }
4809
4810
4811 return fMatch;
4812}
4813
4814
4815//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
4816tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType, tCsrEncryptionList *pUCEncryptionType, tCsrEncryptionList *pMCEncryptionType,
4817 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
4818 eCsrAuthType *negotiatedAuthtype, eCsrEncryptionType *negotiatedUCCipher, eCsrEncryptionType *negotiatedMCCipher )
4819{
4820 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4821 tANI_BOOLEAN fMatch = FALSE;
4822 tANI_U8 i,idx;
4823 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4824 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4825
4826 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
4827 {
4828 ucCipher = pUCEncryptionType->encryptionType[i];
4829 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
4830 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
4831 // encryption type.
4832 switch ( ucCipher )
4833 {
4834 case eCSR_ENCRYPT_TYPE_NONE:
4835 {
4836 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
4837 // required so we have to reject this Bss.
4838 if ( csrIsPrivacy( pSirBssDesc ) )
4839 {
4840 fMatch = FALSE;
4841 }
4842 else
4843 {
4844 fMatch = TRUE;
4845 }
4846
4847 if ( fMatch )
4848 {
4849 fMatch = FALSE;
4850 //Check Multicast cipher requested and Auth type requested.
4851 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
4852 {
4853 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
4854 {
4855 fMatch = TRUE; //Multicast can only be none.
4856 mcCipher = pMCEncryptionType->encryptionType[idx];
4857 break;
4858 }
4859 }
4860 if (!fMatch) break;
4861
4862 fMatch = FALSE;
4863 //Check Auth list. It should contain AuthOpen.
4864 for( idx = 0 ; idx < authType->numEntries ; idx++ )
4865 {
4866 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
4867 {
4868 fMatch = TRUE;
4869 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4870 break;
4871 }
4872 }
4873 if (!fMatch) break;
4874
4875 }
4876 break;
4877 }
4878
4879 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4880 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4881 // !! might want to check for WEP keys set in the Profile.... ?
4882 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
4883 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
4884 // encryption is not allowed without the Privacy bit turned on.
4885 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4886
4887 break;
4888
4889 // these are all of the WPA encryption types...
4890 case eCSR_ENCRYPT_TYPE_WEP40:
4891 case eCSR_ENCRYPT_TYPE_WEP104:
4892 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4893 break;
4894
4895 case eCSR_ENCRYPT_TYPE_TKIP:
4896 case eCSR_ENCRYPT_TYPE_AES:
4897 {
4898 if(pIes)
4899 {
4900 // First check if there is a RSN match
4901 fMatch = csrIsRSNMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4902 if( !fMatch )
4903 {
4904 // If not RSN, then check if there is a WPA match
4905 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
4906 &negAuthType, &mcCipher );
4907 }
4908 }
4909 else
4910 {
4911 fMatch = FALSE;
4912 }
4913 break;
4914 }
4915#ifdef FEATURE_WLAN_WAPI
4916 case eCSR_ENCRYPT_TYPE_WPI://WAPI
4917 {
4918 if(pIes)
4919 {
4920 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4921 }
4922 else
4923 {
4924 fMatch = FALSE;
4925 }
4926 break;
4927 }
4928#endif /* FEATURE_WLAN_WAPI */
4929 case eCSR_ENCRYPT_TYPE_ANY:
4930 default:
4931 {
4932 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
4933
4934 fMatch = eANI_BOOLEAN_TRUE;
4935 //It is allowed to match anything. Try the more secured ones first.
4936 if(pIes)
4937 {
4938 //Check AES first
4939 ucCipher = eCSR_ENCRYPT_TYPE_AES;
4940 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4941 if(!fMatchAny)
4942 {
4943 //Check TKIP
4944 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
4945 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4946 }
4947#ifdef FEATURE_WLAN_WAPI
4948 if(!fMatchAny)
4949 {
4950 //Check WAPI
4951 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
4952 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4953 }
4954#endif /* FEATURE_WLAN_WAPI */
4955 }
4956 if(!fMatchAny)
4957 {
4958 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
4959 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4960 {
4961 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
4962 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4963 {
4964 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4965 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4966 {
4967 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4968 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4969 {
4970 //It must be open and no encryption
4971 if ( csrIsPrivacy( pSirBssDesc ) )
4972 {
4973 //This is not right
4974 fMatch = eANI_BOOLEAN_FALSE;
4975 }
4976 else
4977 {
4978 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4979 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
4980 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
4981 }
4982 }
4983 }
4984 }
4985 }
4986 }
4987 break;
4988 }
4989 }
4990
4991 }
4992
4993 if( fMatch )
4994 {
4995 if( negotiatedUCCipher )
4996 *negotiatedUCCipher = ucCipher;
4997
4998 if( negotiatedMCCipher )
4999 *negotiatedMCCipher = mcCipher;
5000
5001 if( negotiatedAuthtype )
5002 *negotiatedAuthtype = negAuthType;
5003 }
5004
5005 return( fMatch );
5006}
5007
5008
5009tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
5010 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
5011{
5012 tANI_BOOLEAN fMatch = FALSE;
5013
5014 do {
5015
5016 // There are a few special cases. If the Bss description has a Broadcast SSID,
5017 // then our Profile must have a single SSID without Wildcards so we can program
5018 // the SSID.
5019 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5020 // but the SSID value is all NULL characters. That condition is trated same
5021 // as NULL SSID
5022 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5023 {
5024 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5025 {
5026 fMatch = TRUE;
5027 }
5028 break;
5029 }
5030
5031 // Check for the specification of the Broadcast SSID at the beginning of the list.
5032 // If specified, then all SSIDs are matches (broadcast SSID means accept all SSIDs).
5033 if ( ssid1Len == 0 )
5034 {
5035 fMatch = TRUE;
5036 break;
5037 }
5038
5039 if(ssid1Len != bssSsidLen) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05305040 if (vos_mem_compare(bssSsid, ssid1, bssSsidLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 {
5042 fMatch = TRUE;
5043 break;
5044 }
5045
5046 } while( 0 );
5047
5048 return( fMatch );
5049}
5050
5051
5052//Null ssid means match
5053tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5054{
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 tANI_BOOLEAN fMatch = FALSE;
5056 tANI_U32 i;
5057
5058 if ( pSsidList && pSsid )
5059 {
5060 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5061 {
5062 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
Kiet Lam64c1b492013-07-12 13:56:44 +05305063 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5064 vos_mem_compare(pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 {
5066 fMatch = TRUE;
5067 break;
5068 }
5069 }
5070 }
5071
5072 return (fMatch);
5073}
5074
5075//like to use sirCompareMacAddr
5076tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5077{
5078 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5079
Kiet Lam64c1b492013-07-12 13:56:44 +05305080 return (vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005081}
5082
5083//like to use sirCompareMacAddr
5084tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5085{
5086 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5087
Kiet Lam64c1b492013-07-12 13:56:44 +05305088 return(vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005089}
5090
5091
5092//like to use sirCompareMacAddr
5093tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5094{
Kiet Lam64c1b492013-07-12 13:56:44 +05305095 return(vos_mem_compare(pMacAddr1, pMacAddr2, sizeof(tCsrBssid)));
Jeff Johnson295189b2012-06-20 16:38:30 -07005096}
5097
5098
5099tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5100{
5101 tANI_BOOLEAN fMatch = FALSE;
5102 tCsrBssid ProfileBssid;
5103 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5104
5105 // for efficiency of the MAC_ADDRESS functions, move the
5106 // Bssid's into MAC_ADDRESS structs.
Kiet Lam64c1b492013-07-12 13:56:44 +05305107 vos_mem_copy(&ProfileBssid, pProfBssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005108
5109 do {
5110
5111 // Give the profile the benefit of the doubt... accept either all 0 or
5112 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5113 // match any Bssids).
5114 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5115 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5116 {
5117 fMatch = TRUE;
5118 break;
5119 }
5120
5121 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5122 {
5123 fMatch = TRUE;
5124 break;
5125 }
5126
5127 } while( 0 );
5128
5129 return( fMatch );
5130}
5131
5132
5133tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5134{
5135 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5136 return eANI_BOOLEAN_FALSE;
5137 else
5138 return eANI_BOOLEAN_TRUE;
5139}
5140
5141
5142tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5143{
5144 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5145}
5146
5147tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5148{
5149 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5150}
5151
5152tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5153{
5154 tANI_BOOLEAN fMatch = TRUE;
5155
5156 do
5157 {
5158 switch( bssType )
5159 {
5160 case eCSR_BSS_TYPE_ANY:
5161 break;
5162
5163 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5164 case eCSR_BSS_TYPE_WDS_STA:
5165 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5166 fMatch = FALSE;
5167
5168 break;
5169
5170 case eCSR_BSS_TYPE_IBSS:
5171 case eCSR_BSS_TYPE_START_IBSS:
5172 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5173 fMatch = FALSE;
5174
5175 break;
5176
5177 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5178 default:
5179 fMatch = FALSE;
5180 break;
5181 }
5182 }
5183 while( 0 );
5184
5185
5186 return( fMatch );
5187}
5188
5189static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5190{
5191 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5192}
5193
5194
5195
5196static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5197{
5198 tANI_BOOLEAN fMatch = TRUE;
5199
5200 do
5201 {
5202 // if the channel is ANY, then always match...
5203 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5204 if ( Channel == pSirBssDesc->channelId ) break;
5205
5206 // didn't match anything.. so return NO match
5207 fMatch = FALSE;
5208
5209 } while( 0 );
5210
5211 return( fMatch );
5212}
5213
5214
5215tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5216{
5217 tANI_BOOLEAN fMatch = TRUE;
5218
5219 do
5220 {
5221 // if the profile says Any channel AND the global settings says ANY channel, then we
5222 // always match...
5223 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5224
5225 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5226 {
5227 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5228 }
5229
5230 } while( 0 );
5231
5232 return( fMatch );
5233}
5234
5235
5236/**
5237 * \brief Enquire as to whether a given rate is supported by the
5238 * adapter as currently configured
5239 *
5240 *
5241 * \param nRate A rate in units of 500kbps
5242 *
5243 * \return TRUE if the adapter is currently capable of supporting this
5244 * rate, FALSE else
5245 *
5246 *
5247 * The rate encoding is just as in 802.11 Information Elements, except
5248 * that the high bit is \em not interpreted as indicating a Basic Rate,
5249 * and proprietary rates are allowed, too.
5250 *
5251 * Note that if the adapter's dot11Mode is g, we don't restrict the
5252 * rates. According to hwReadEepromParameters, this will happen when:
5253 *
5254 * ... the card is configured for ALL bands through the property
5255 * page. If this occurs, and the card is not an ABG card ,then this
5256 * code is setting the dot11Mode to assume the mode that the
5257 * hardware can support. For example, if the card is an 11BG card
5258 * and we are configured to support ALL bands, then we change the
5259 * dot11Mode to 11g because ALL in this case is only what the
5260 * hardware can support.
5261 *
5262 *
5263 */
5264
5265static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5266{
5267 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5268 tANI_U16 idx, newRate;
5269
5270 //In case basic rate flag is set
5271 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5272 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5273 {
5274 switch ( newRate )
5275 {
5276 case eCsrSuppRate_6Mbps:
5277 case eCsrSuppRate_9Mbps:
5278 case eCsrSuppRate_12Mbps:
5279 case eCsrSuppRate_18Mbps:
5280 case eCsrSuppRate_24Mbps:
5281 case eCsrSuppRate_36Mbps:
5282 case eCsrSuppRate_48Mbps:
5283 case eCsrSuppRate_54Mbps:
5284 fSupported = TRUE;
5285 break;
5286 default:
5287 fSupported = FALSE;
5288 break;
5289 }
5290
5291 }
5292 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5293 {
5294 switch ( newRate )
5295 {
5296 case eCsrSuppRate_1Mbps:
5297 case eCsrSuppRate_2Mbps:
5298 case eCsrSuppRate_5_5Mbps:
5299 case eCsrSuppRate_11Mbps:
5300 fSupported = TRUE;
5301 break;
5302 default:
5303 fSupported = FALSE;
5304 break;
5305 }
5306 }
5307 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5308 {
5309
5310 switch ( newRate )
5311 {
5312 case eCsrSuppRate_1Mbps:
5313 case eCsrSuppRate_2Mbps:
5314 case eCsrSuppRate_5_5Mbps:
5315 case eCsrSuppRate_6Mbps:
5316 case eCsrSuppRate_9Mbps:
5317 case eCsrSuppRate_11Mbps:
5318 case eCsrSuppRate_12Mbps:
5319 case eCsrSuppRate_18Mbps:
5320 case eCsrSuppRate_24Mbps:
5321 case eCsrSuppRate_36Mbps:
5322 case eCsrSuppRate_48Mbps:
5323 case eCsrSuppRate_54Mbps:
5324 fSupported = TRUE;
5325 break;
5326 default:
5327 fSupported = FALSE;
5328 break;
5329 }
5330
5331 }
5332 else {
5333
5334 if ( eCsrSuppRate_1Mbps == newRate ||
5335 eCsrSuppRate_2Mbps == newRate ||
5336 eCsrSuppRate_5_5Mbps == newRate ||
5337 eCsrSuppRate_11Mbps == newRate )
5338 {
5339 fSupported = TRUE;
5340 }
5341 else {
5342 idx = 0x1;
5343
5344 switch ( newRate )
5345 {
5346 case eCsrSuppRate_6Mbps:
5347 fSupported = gPhyRatesSuppt[0][idx];
5348 break;
5349 case eCsrSuppRate_9Mbps:
5350 fSupported = gPhyRatesSuppt[1][idx];
5351 break;
5352 case eCsrSuppRate_12Mbps:
5353 fSupported = gPhyRatesSuppt[2][idx];
5354 break;
5355 case eCsrSuppRate_18Mbps:
5356 fSupported = gPhyRatesSuppt[3][idx];
5357 break;
5358 case eCsrSuppRate_20Mbps:
5359 fSupported = gPhyRatesSuppt[4][idx];
5360 break;
5361 case eCsrSuppRate_24Mbps:
5362 fSupported = gPhyRatesSuppt[5][idx];
5363 break;
5364 case eCsrSuppRate_36Mbps:
5365 fSupported = gPhyRatesSuppt[6][idx];
5366 break;
5367 case eCsrSuppRate_40Mbps:
5368 fSupported = gPhyRatesSuppt[7][idx];
5369 break;
5370 case eCsrSuppRate_42Mbps:
5371 fSupported = gPhyRatesSuppt[8][idx];
5372 break;
5373 case eCsrSuppRate_48Mbps:
5374 fSupported = gPhyRatesSuppt[9][idx];
5375 break;
5376 case eCsrSuppRate_54Mbps:
5377 fSupported = gPhyRatesSuppt[10][idx];
5378 break;
5379 case eCsrSuppRate_72Mbps:
5380 fSupported = gPhyRatesSuppt[11][idx];
5381 break;
5382 case eCsrSuppRate_80Mbps:
5383 fSupported = gPhyRatesSuppt[12][idx];
5384 break;
5385 case eCsrSuppRate_84Mbps:
5386 fSupported = gPhyRatesSuppt[13][idx];
5387 break;
5388 case eCsrSuppRate_96Mbps:
5389 fSupported = gPhyRatesSuppt[14][idx];
5390 break;
5391 case eCsrSuppRate_108Mbps:
5392 fSupported = gPhyRatesSuppt[15][idx];
5393 break;
5394 case eCsrSuppRate_120Mbps:
5395 fSupported = gPhyRatesSuppt[16][idx];
5396 break;
5397 case eCsrSuppRate_126Mbps:
5398 fSupported = gPhyRatesSuppt[17][idx];
5399 break;
5400 case eCsrSuppRate_144Mbps:
5401 fSupported = gPhyRatesSuppt[18][idx];
5402 break;
5403 case eCsrSuppRate_160Mbps:
5404 fSupported = gPhyRatesSuppt[19][idx];
5405 break;
5406 case eCsrSuppRate_168Mbps:
5407 fSupported = gPhyRatesSuppt[20][idx];
5408 break;
5409 case eCsrSuppRate_192Mbps:
5410 fSupported = gPhyRatesSuppt[21][idx];
5411 break;
5412 case eCsrSuppRate_216Mbps:
5413 fSupported = gPhyRatesSuppt[22][idx];
5414 break;
5415 case eCsrSuppRate_240Mbps:
5416 fSupported = gPhyRatesSuppt[23][idx];
5417 break;
5418 default:
5419 fSupported = FALSE;
5420 break;
5421 }
5422 }
5423 }
5424
5425 return fSupported;
5426}
5427
5428
5429
5430static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5431 tDot11fIESuppRates *pBssSuppRates,
5432 tDot11fIEExtSuppRates *pBssExtSuppRates )
5433{
5434 tANI_BOOLEAN fMatch = TRUE;
5435 tANI_U32 i;
5436
5437
5438 // Validate that all of the Basic rates advertised in the Bss description are supported.
5439 if ( pBssSuppRates )
5440 {
5441 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5442 {
5443 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5444 {
5445 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5446 {
5447 fMatch = FALSE;
5448 break;
5449 }
5450 }
5451 }
5452 }
5453
5454 if ( fMatch && pBssExtSuppRates )
5455 {
5456 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5457 {
5458 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5459 {
5460 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5461 {
5462 fMatch = FALSE;
5463 break;
5464 }
5465 }
5466 }
5467 }
5468
5469 return( fMatch );
5470
5471}
5472
5473
5474//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
5475tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
5476 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
5477 tDot11fBeaconIEs **ppIes)
5478{
5479 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5480 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5481 tANI_U32 i;
5482 tDot11fBeaconIEs *pIes = NULL;
5483 tANI_U8 *pb;
5484
5485 do {
5486 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
5487 {
5488 //If no IEs passed in, get our own.
5489 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
5490 {
5491 break;
5492 }
5493 }
5494 else
5495 {
5496 //Save the one pass in for local use
5497 pIes = *ppIes;
5498 }
5499
5500 //Check if caller wants P2P
5501 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
5502 if(!fCheck) break;
5503
5504 if(pIes->SSID.present)
5505 {
5506 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
5507 {
5508 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
5509 pIes->SSID.ssid,
5510 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
5511 if ( fCheck ) break;
5512 }
5513 if(!fCheck) break;
5514 }
5515 fCheck = eANI_BOOLEAN_TRUE;
5516 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
5517 {
5518 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
5519 if ( fCheck ) break;
5520
5521 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
5522 {
5523 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
5524 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
5525
5526 if ( fCheck ) break;
5527 }
5528 }
5529 if(!fCheck) break;
5530
5531 fCheck = eANI_BOOLEAN_TRUE;
5532 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
5533 {
5534 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
5535 if ( fCheck ) break;
5536 }
5537 if(!fCheck)
5538 break;
5539#if defined WLAN_FEATURE_VOWIFI
5540 /* If this is for measurement filtering */
5541 if( pFilter->fMeasurement )
5542 {
5543 fRC = eANI_BOOLEAN_TRUE;
5544 break;
5545 }
5546#endif
5547 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07005548 if ( (!pFilter->bWPSAssociation) && (!pFilter->bOSENAssociation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 !csrIsSecurityMatch( pMac, &pFilter->authType, &pFilter->EncryptionType, &pFilter->mcEncryptionType,
5550 pBssDesc, pIes, pNegAuth, pNegUc, pNegMc ) ) break;
5551 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
5552 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
5553 //Tush-QoS: validate first if asked for APSD or WMM association
5554 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
5555 !CSR_IS_QOS_BSS(pIes) )
5556 break;
5557 //Check country. check even when pb is NULL because we may want to make sure
5558 //AP has a country code in it if fEnforceCountryCodeMatch is set.
5559 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
5560
5561 fCheck = csrMatchCountryCode( pMac, pb, pIes );
5562 if(!fCheck)
5563 break;
5564
5565#ifdef WLAN_FEATURE_VOWIFI_11R
5566 if (pFilter->MDID.mdiePresent)
5567 {
5568 if (pBssDesc->mdiePresent)
5569 {
5570 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
5571 break;
5572 }
5573 else
5574 break;
5575 }
5576#endif
5577 fRC = eANI_BOOLEAN_TRUE;
5578
5579 } while( 0 );
5580 if( ppIes )
5581 {
5582 *ppIes = pIes;
5583 }
5584 else if( pIes )
5585 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305586 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005587 }
5588
5589 return( fRC );
5590}
5591
5592tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
5593 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
5594{
5595 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
5596 tCsrAuthList authList;
5597
5598 ucEncryptionList.numEntries = 1;
5599 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
5600
5601 mcEncryptionList.numEntries = 1;
5602 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
5603
5604 authList.numEntries = 1;
5605 authList.authType[0] = pProfile->AuthType;
5606
5607 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList, &mcEncryptionList, pBssDesc, pIes, NULL, NULL, NULL ));
5608
5609}
5610
5611
5612tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
5613 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
5614{
5615 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5616 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5617 tDot11fBeaconIEs *pIesLocal = pIes;
5618
5619 do {
5620 if( !pIes )
5621 {
5622 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
5623 {
5624 break;
5625 }
5626 }
5627 fCheck = eANI_BOOLEAN_TRUE;
5628 if(pIesLocal->SSID.present)
5629 {
5630 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
5631 if(pProfile->SSID.length)
5632 {
5633 fCheckSsid = eANI_BOOLEAN_TRUE;
5634 }
5635 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
5636 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
5637 if(!fCheck) break;
5638 }
5639 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
5640 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
5641 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
5642 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
5643 if(!fCheck)
5644 break;
5645
5646 fRC = eANI_BOOLEAN_TRUE;
5647
5648 } while( 0 );
5649
5650 if( !pIes && pIesLocal )
5651 {
5652 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305653 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 }
5655
5656 return( fRC );
5657}
5658
5659
5660
5661tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
5662{
5663 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5664 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
5665
5666 return csrIsAggregateRateSupported( pMac, n );
5667}
5668
5669
5670tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
5671{
5672 tANI_U16 ConvertedRate = Rate;
5673
5674 switch( Rate )
5675 {
5676 case SIR_MAC_RATE_1:
5677 ConvertedRate = 2;
5678 break;
5679 case SIR_MAC_RATE_2:
5680 ConvertedRate = 4;
5681 break;
5682 case SIR_MAC_RATE_5_5:
5683 ConvertedRate = 11;
5684 break;
5685 case SIR_MAC_RATE_11:
5686 ConvertedRate = 22;
5687 break;
5688
5689 case SIR_MAC_RATE_6:
5690 ConvertedRate = 12;
5691 break;
5692 case SIR_MAC_RATE_9:
5693 ConvertedRate = 18;
5694 break;
5695 case SIR_MAC_RATE_12:
5696 ConvertedRate = 24;
5697 break;
5698 case SIR_MAC_RATE_18:
5699 ConvertedRate = 36;
5700 break;
5701 case SIR_MAC_RATE_24:
5702 ConvertedRate = 48;
5703 break;
5704 case SIR_MAC_RATE_36:
5705 ConvertedRate = 72;
5706 break;
5707 case SIR_MAC_RATE_42:
5708 ConvertedRate = 84;
5709 break;
5710 case SIR_MAC_RATE_48:
5711 ConvertedRate = 96;
5712 break;
5713 case SIR_MAC_RATE_54:
5714 ConvertedRate = 108;
5715 break;
5716
5717 case SIR_MAC_RATE_72:
5718 ConvertedRate = 144;
5719 break;
5720 case SIR_MAC_RATE_84:
5721 ConvertedRate = 168;
5722 break;
5723 case SIR_MAC_RATE_96:
5724 ConvertedRate = 192;
5725 break;
5726 case SIR_MAC_RATE_108:
5727 ConvertedRate = 216;
5728 break;
5729 case SIR_MAC_RATE_126:
5730 ConvertedRate = 252;
5731 break;
5732 case SIR_MAC_RATE_144:
5733 ConvertedRate = 288;
5734 break;
5735 case SIR_MAC_RATE_168:
5736 ConvertedRate = 336;
5737 break;
5738 case SIR_MAC_RATE_192:
5739 ConvertedRate = 384;
5740 break;
5741 case SIR_MAC_RATE_216:
5742 ConvertedRate = 432;
5743 break;
5744 case SIR_MAC_RATE_240:
5745 ConvertedRate = 480;
5746 break;
5747
5748 case 0xff:
5749 ConvertedRate = 0;
5750 break;
5751 }
5752
5753 return ConvertedRate;
5754}
5755
5756
5757tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
5758{
5759 tANI_U8 i;
5760 tANI_U16 nBest;
5761
5762 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
5763
5764 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
5765 {
5766 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
5767 }
5768
5769 for ( i = 1U; i < pSuppRates->numRates; ++i )
5770 {
5771 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5772 }
5773
5774 if ( NULL != pExtRates )
5775 {
5776 for ( i = 0U; i < pExtRates->numRates; ++i )
5777 {
5778 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5779 }
5780 }
5781
5782 if ( NULL != pPropRates )
5783 {
5784 for ( i = 0U; i < pPropRates->numPropRates; ++i )
5785 {
5786 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
5787 }
5788 }
5789
5790 return nBest;
5791}
5792
5793
5794void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
5795{
5796 if(pProfile)
5797 {
5798 if(pProfile->BSSIDs.bssid)
5799 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305800 vos_mem_free(pProfile->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 pProfile->BSSIDs.bssid = NULL;
5802 }
5803 if(pProfile->SSIDs.SSIDList)
5804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305805 vos_mem_free(pProfile->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 pProfile->SSIDs.SSIDList = NULL;
5807 }
5808 if(pProfile->pWPAReqIE)
5809 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305810 vos_mem_free(pProfile->pWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 pProfile->pWPAReqIE = NULL;
5812 }
5813 if(pProfile->pRSNReqIE)
5814 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305815 vos_mem_free(pProfile->pRSNReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 pProfile->pRSNReqIE = NULL;
5817 }
5818#ifdef FEATURE_WLAN_WAPI
5819 if(pProfile->pWAPIReqIE)
5820 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305821 vos_mem_free(pProfile->pWAPIReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 pProfile->pWAPIReqIE = NULL;
5823 }
5824#endif /* FEATURE_WLAN_WAPI */
5825
Agarwal Ashish4f616132013-12-30 23:32:50 +05305826 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05305828 memset(pProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
5829 pProfile->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 }
5831
5832 if(pProfile->pAddIEAssoc)
5833 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305834 vos_mem_free(pProfile->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 pProfile->pAddIEAssoc = NULL;
5836 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 if(pProfile->ChannelInfo.ChannelList)
5838 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305839 vos_mem_free(pProfile->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 pProfile->ChannelInfo.ChannelList = NULL;
5841 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305842 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 }
5844}
5845
5846void csrFreeScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
5847{
5848 if(pScanFilter->BSSIDs.bssid)
5849 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305850 vos_mem_free(pScanFilter->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 pScanFilter->BSSIDs.bssid = NULL;
5852 }
5853 if(pScanFilter->ChannelInfo.ChannelList)
5854 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305855 vos_mem_free(pScanFilter->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 pScanFilter->ChannelInfo.ChannelList = NULL;
5857 }
5858 if(pScanFilter->SSIDs.SSIDList)
5859 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305860 vos_mem_free(pScanFilter->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 pScanFilter->SSIDs.SSIDList = NULL;
5862 }
5863}
5864
5865
5866void csrFreeRoamProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
5867{
5868 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
5869
5870 if(pSession->pCurRoamProfile)
5871 {
5872 csrReleaseProfile(pMac, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05305873 vos_mem_free(pSession->pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 pSession->pCurRoamProfile = NULL;
5875 }
5876}
5877
5878
5879void csrFreeConnectBssDesc(tpAniSirGlobal pMac, tANI_U32 sessionId)
5880{
5881 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
5882
5883 if(pSession->pConnectBssDesc)
5884 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305885 vos_mem_free(pSession->pConnectBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 pSession->pConnectBssDesc = NULL;
5887 }
5888}
5889
5890
5891
5892tSirResultCodes csrGetDisassocRspStatusCode( tSirSmeDisassocRsp *pSmeDisassocRsp )
5893{
5894 tANI_U8 *pBuffer = (tANI_U8 *)pSmeDisassocRsp;
5895 tANI_U32 ret;
5896
5897 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
5898 //tSirResultCodes is an enum, assuming is 32bit
5899 //If we cannot make this assumption, use copymemory
5900 pal_get_U32( pBuffer, &ret );
5901
5902 return( ( tSirResultCodes )ret );
5903}
5904
5905
5906tSirResultCodes csrGetDeAuthRspStatusCode( tSirSmeDeauthRsp *pSmeRsp )
5907{
5908 tANI_U8 *pBuffer = (tANI_U8 *)pSmeRsp;
5909 tANI_U32 ret;
5910
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005911 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tANI_U8) + sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 //tSirResultCodes is an enum, assuming is 32bit
5913 //If we cannot make this assumption, use copymemory
5914 pal_get_U32( pBuffer, &ret );
5915
5916 return( ( tSirResultCodes )ret );
5917}
5918
5919#if 0
5920tSirScanType csrGetScanType(tANI_U8 chnId, eRegDomainId domainId, tANI_U8 *countryCode)
5921{
5922 tSirScanType scanType = eSIR_PASSIVE_SCAN;
5923 tANI_U8 cc = 0;
5924
5925 while (cc++ < gCsrDomainChnInfo[domainId].numChannels)
5926 {
5927 if(chnId == gCsrDomainChnInfo[domainId].chnInfo[cc].chnId)
5928 {
5929 scanType = gCsrDomainChnInfo[domainId].chnInfo[cc].scanType;
5930 break;
5931 }
5932 }
5933
5934 return (scanType);
5935}
5936#endif
5937
5938tSirScanType csrGetScanType(tpAniSirGlobal pMac, tANI_U8 chnId)
5939{
5940 tSirScanType scanType = eSIR_PASSIVE_SCAN;
5941 eNVChannelEnabledType channelEnabledType;
5942
5943 channelEnabledType = vos_nv_getChannelEnabledState(chnId);
5944 if( NV_CHANNEL_ENABLE == channelEnabledType)
5945 {
5946 scanType = eSIR_ACTIVE_SCAN;
5947 }
5948 return (scanType);
5949}
5950
5951
5952tANI_U8 csrToUpper( tANI_U8 ch )
5953{
5954 tANI_U8 chOut;
5955
5956 if ( ch >= 'a' && ch <= 'z' )
5957 {
5958 chOut = ch - 'a' + 'A';
5959 }
5960 else
5961 {
5962 chOut = ch;
5963 }
5964 return( chOut );
5965}
5966
5967
5968tSirBssType csrTranslateBsstypeToMacType(eCsrRoamBssType csrtype)
5969{
5970 tSirBssType ret;
5971
5972 switch(csrtype)
5973 {
5974 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5975 ret = eSIR_INFRASTRUCTURE_MODE;
5976 break;
5977 case eCSR_BSS_TYPE_IBSS:
5978 case eCSR_BSS_TYPE_START_IBSS:
5979 ret = eSIR_IBSS_MODE;
5980 break;
5981 case eCSR_BSS_TYPE_WDS_AP:
5982 ret = eSIR_BTAMP_AP_MODE;
5983 break;
5984 case eCSR_BSS_TYPE_WDS_STA:
5985 ret = eSIR_BTAMP_STA_MODE;
5986 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 case eCSR_BSS_TYPE_INFRA_AP:
5988 ret = eSIR_INFRA_AP_MODE;
5989 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 case eCSR_BSS_TYPE_ANY:
5991 default:
5992 ret = eSIR_AUTO_MODE;
5993 break;
5994 }
5995
5996 return (ret);
5997}
5998
5999
6000//This function use the parameters to decide the CFG value.
6001//CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG
6002//So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value
Jeff Johnson295189b2012-06-20 16:38:30 -07006003eCsrCfgDot11Mode csrGetCfgDot11ModeFromCsrPhyMode(tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tANI_BOOLEAN fProprietary)
Jeff Johnson295189b2012-06-20 16:38:30 -07006004{
6005 tANI_U32 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6006
6007 switch(phyMode)
6008 {
6009 case eCSR_DOT11_MODE_11a:
6010 case eCSR_DOT11_MODE_11a_ONLY:
6011 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
6012 break;
6013 case eCSR_DOT11_MODE_11b:
6014 case eCSR_DOT11_MODE_11b_ONLY:
6015 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
6016 break;
6017 case eCSR_DOT11_MODE_11g:
6018 case eCSR_DOT11_MODE_11g_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 if(pProfile && (CSR_IS_INFRA_AP(pProfile)) && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
6020 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
6021 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
6023 break;
6024 case eCSR_DOT11_MODE_11n:
6025 if(fProprietary)
6026 {
6027 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6028 }
6029 else
6030 {
6031 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6032 }
6033 break;
6034 case eCSR_DOT11_MODE_11n_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 if(pProfile && CSR_IS_INFRA_AP(pProfile))
6036 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
6037 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6039 break;
6040 case eCSR_DOT11_MODE_TAURUS:
6041 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6042 break;
6043 case eCSR_DOT11_MODE_abg:
6044 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6045 break;
6046 case eCSR_DOT11_MODE_AUTO:
6047 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
6048 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07006049
6050#ifdef WLAN_FEATURE_11AC
6051 case eCSR_DOT11_MODE_11ac:
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006052 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6053 {
6054 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
6055 }
6056 else
6057 {
Ravi Joshia96ceb42013-05-20 18:52:39 -07006058 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006059 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006060 break;
6061 case eCSR_DOT11_MODE_11ac_ONLY:
Ravi Joshia96ceb42013-05-20 18:52:39 -07006062 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6063 {
6064 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
6065 }
6066 else
6067 {
6068 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6069 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006070 break;
6071#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 default:
6073 //No need to assign anything here
6074 break;
6075 }
6076
6077 return (cfgDot11Mode);
6078}
6079
6080
6081eHalStatus csrSetRegulatoryDomain(tpAniSirGlobal pMac, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6082{
6083 eHalStatus status = eHAL_STATUS_SUCCESS;
6084 tANI_BOOLEAN fRestart;
6085
6086 if(pMac->scan.domainIdCurrent == domainId)
6087 {
6088 //no change
6089 fRestart = eANI_BOOLEAN_FALSE;
6090 }
6091 else if( !pMac->roam.configParam.fEnforceDefaultDomain )
6092 {
6093 pMac->scan.domainIdCurrent = domainId;
6094 fRestart = eANI_BOOLEAN_TRUE;
6095 }
6096 else
6097 {
6098 //We cannot change the domain
6099 status = eHAL_STATUS_CSR_WRONG_STATE;
6100 fRestart = eANI_BOOLEAN_FALSE;
6101 }
6102 if(pfRestartNeeded)
6103 {
6104 *pfRestartNeeded = fRestart;
6105 }
6106
6107 return (status);
6108}
6109
6110
6111v_REGDOMAIN_t csrGetCurrentRegulatoryDomain(tpAniSirGlobal pMac)
6112{
6113 return (pMac->scan.domainIdCurrent);
6114}
6115
Jeff Johnson295189b2012-06-20 16:38:30 -07006116
Kiet Lam6c583332013-10-14 05:37:09 +05306117eHalStatus csrGetRegulatoryDomainForCountry
6118(
6119tpAniSirGlobal pMac,
6120tANI_U8 *pCountry,
6121v_REGDOMAIN_t *pDomainId,
6122v_CountryInfoSource_t source
6123)
Jeff Johnson295189b2012-06-20 16:38:30 -07006124{
6125 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6126 VOS_STATUS vosStatus;
6127 v_COUNTRYCODE_t countryCode;
6128 v_REGDOMAIN_t domainId;
6129
6130 if(pCountry)
6131 {
6132 countryCode[0] = pCountry[0];
6133 countryCode[1] = pCountry[1];
Kiet Lam6c583332013-10-14 05:37:09 +05306134 vosStatus = vos_nv_getRegDomainFromCountryCode(&domainId,
6135 countryCode,
6136 source);
6137
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
6139 {
6140 if( pDomainId )
6141 {
6142 *pDomainId = domainId;
6143 }
6144 status = eHAL_STATUS_SUCCESS;
6145 }
6146 else
6147 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306148 smsLog(pMac, LOGW, FL(" Couldn't find domain for country code %c%c"), pCountry[0], pCountry[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 status = eHAL_STATUS_INVALID_PARAMETER;
6150 }
6151 }
6152
6153 return (status);
6154}
6155
6156//To check whether a country code matches the one in the IE
6157//Only check the first two characters, ignoring in/outdoor
6158//pCountry -- caller allocated buffer contain the country code that is checking against
6159//the one in pIes. It can be NULL.
6160//caller must provide pIes, it cannot be NULL
6161//This function always return TRUE if 11d support is not turned on.
6162tANI_BOOLEAN csrMatchCountryCode( tpAniSirGlobal pMac, tANI_U8 *pCountry, tDot11fBeaconIEs *pIes )
6163{
6164 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson43971f52012-07-17 12:26:56 -07006165 v_REGDOMAIN_t domainId = REGDOMAIN_COUNT; //This is init to invalid value
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 eHalStatus status;
6167
6168 do
6169 {
6170 if( !csrIs11dSupported( pMac) )
6171 {
6172 break;
6173 }
6174 if( !pIes )
6175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006176 smsLog(pMac, LOGE, FL(" No IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 break;
6178 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006179 if( pMac->roam.configParam.fEnforceDefaultDomain ||
6180 pMac->roam.configParam.fEnforceCountryCodeMatch )
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006182 //Make sure this country is recognizable
6183 if( pIes->Country.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07006184 {
Kiet Lam6c583332013-10-14 05:37:09 +05306185 status = csrGetRegulatoryDomainForCountry(pMac,
6186 pIes->Country.country,
6187 &domainId, COUNTRY_QUERY);
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006188 if( !HAL_STATUS_SUCCESS( status ) )
6189 {
Kiet Lam6c583332013-10-14 05:37:09 +05306190 status = csrGetRegulatoryDomainForCountry(pMac,
6191 pMac->scan.countryCode11d,
6192 (v_REGDOMAIN_t *) &domainId,
6193 COUNTRY_QUERY);
Gowri Deepthiff9adf92012-12-13 15:09:56 -08006194 if( !HAL_STATUS_SUCCESS( status ) )
6195 {
6196 fRet = eANI_BOOLEAN_FALSE;
6197 break;
6198 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006201 //check whether it is needed to enforce to the default regulatory domain first
6202 if( pMac->roam.configParam.fEnforceDefaultDomain )
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006204 if( domainId != pMac->scan.domainIdCurrent )
6205 {
6206 fRet = eANI_BOOLEAN_FALSE;
6207 break;
6208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006210 if( pMac->roam.configParam.fEnforceCountryCodeMatch )
6211 {
Jeff Johnson43971f52012-07-17 12:26:56 -07006212 if( domainId >= REGDOMAIN_COUNT )
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006213 {
6214 fRet = eANI_BOOLEAN_FALSE;
6215 break;
6216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 }
6218 }
6219 if( pCountry )
6220 {
6221 tANI_U32 i;
6222
6223 if( !pIes->Country.present )
6224 {
6225 fRet = eANI_BOOLEAN_FALSE;
6226 break;
6227 }
6228 // Convert the CountryCode characters to upper
6229 for ( i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++ )
6230 {
6231 pCountry[i] = csrToUpper( pCountry[i] );
6232 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306233 if (!vos_mem_compare(pIes->Country.country, pCountry,
6234 WNI_CFG_COUNTRY_CODE_LEN - 1))
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 {
6236 fRet = eANI_BOOLEAN_FALSE;
6237 break;
6238 }
6239 }
6240 } while(0);
6241
6242 return (fRet);
6243}
6244
6245#if 0
6246eHalStatus csrSetCountryDomainMapping(tpAniSirGlobal pMac, tCsrCountryDomainMapping *pCountryDomainMapping)
6247{
6248 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6249 tANI_U32 i, j;
6250 tANI_BOOLEAN fDomainChanged = eANI_BOOLEAN_FALSE;
6251 tANI_U8 countryCode[WNI_CFG_COUNTRY_CODE_LEN];
6252
6253 i = WNI_CFG_COUNTRY_CODE_LEN;
6254 //Get the currently used country code
6255 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, countryCode, &i);
6256 if(HAL_STATUS_SUCCESS(status))
6257 {
6258 if(pCountryDomainMapping && pCountryDomainMapping->numEntry)
6259 {
6260 for(i = 0; i < pCountryDomainMapping->numEntry; i++)
6261 {
6262 for(j = 0; j < eCSR_NUM_COUNTRY_INDEX; j++)
6263 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306264 if (vos_mem_compare(gCsrCountryInfo[j].countryCode,
6265 pCountryDomainMapping->pCountryInfo[i].countryCode,
6266 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 {
6268 if(gCsrCountryInfo[j].domainId != pCountryDomainMapping->pCountryInfo[i].domainId)
6269 {
6270 gCsrCountryInfo[j].domainId = pCountryDomainMapping->pCountryInfo[i].domainId;
6271 //Check whether it matches the currently used country code
6272 //If matching, need to update base on the new domain setting.
Kiet Lam64c1b492013-07-12 13:56:44 +05306273 if (vos_mem_compare(countryCode,
6274 pCountryDomainMapping->pCountryInfo[i].countryCode,
6275 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 {
6277 fDomainChanged = eANI_BOOLEAN_TRUE;
6278 }
6279 }
6280 break;
6281 }
6282 }
6283 }
6284 status = eHAL_STATUS_SUCCESS;
6285 if(fDomainChanged)
6286 {
6287 tCsrChannel *pChannelList;
6288
6289 if(pMac->scan.f11dInfoApplied)
6290 {
6291 //11d info already applied. Let's reapply with the new domain setting
6292 if(pMac->scan.channels11d.numChannels)
6293 {
6294 pChannelList = &pMac->scan.channels11d;
6295 }
6296 else
6297 {
6298 pChannelList = &pMac->scan.base20MHzChannels;
6299 }
6300 }
6301 else
6302 {
6303 //no 11d so we use the base channelist from EEPROM
6304 pChannelList = &pMac->scan.base20MHzChannels;
6305 }
6306 //set the new domain's scan requirement to CFG
6307 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
6308 }
6309 }
6310 }
6311
6312 return (status);
6313}
6314
6315eHalStatus csrSetDomainScanSetting(tpAniSirGlobal pMac, tCsrDomainFreqInfo *pDomainFreqInfo)
6316{
6317 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6318 tANI_U32 i, j;
6319 tANI_U16 freq;
6320
6321 if(pDomainFreqInfo && pDomainFreqInfo->numEntry && (pDomainFreqInfo->domainId < NUM_REG_DOMAINS))
6322 {
6323 tCsrDomainChnInfo *pDomainChnInfo = &gCsrDomainChnInfo[pDomainFreqInfo->domainId];
6324
6325 for(j = 0; j < pDomainChnInfo->numChannels; j++)
6326 {
6327 if(HAL_STATUS_SUCCESS(halPhyChIdToFreqConversion(pDomainChnInfo->chnInfo[j].chnId, &freq)))
6328 {
6329 for(i = 0; i < pDomainFreqInfo->numEntry; i++)
6330 {
6331 if((pDomainFreqInfo->pCsrScanFreqInfo[i].nStartFreq <= freq) &&
6332 (freq <= pDomainFreqInfo->pCsrScanFreqInfo[i].nEndFreq))
6333 {
6334 pDomainChnInfo->chnInfo[j].scanType = pDomainFreqInfo->pCsrScanFreqInfo[i].scanType;
6335 break;
6336 }
6337 }
6338 }
6339 else
6340 {
6341 smsLog(pMac, LOGW, " Failed to get frequency of channel %d", pDomainChnInfo->chnInfo[j].chnId);
6342 }
6343 }
6344 status = eHAL_STATUS_SUCCESS;
6345 }
6346
6347 return (status);
6348}
6349#endif
6350
6351eHalStatus csrGetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6352 tCsrRoamModifyProfileFields *pModifyProfileFields)
6353{
6354
6355 if(!pModifyProfileFields)
6356 {
6357 return eHAL_STATUS_FAILURE;
6358 }
6359
Kiet Lam64c1b492013-07-12 13:56:44 +05306360 vos_mem_copy(pModifyProfileFields,
6361 &pMac->roam.roamSession[sessionId].connectedProfile.modifyProfileFields,
6362 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006363
6364 return eHAL_STATUS_SUCCESS;
6365}
6366
6367eHalStatus csrSetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6368 tCsrRoamModifyProfileFields *pModifyProfileFields)
6369{
6370 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6371
Kiet Lam64c1b492013-07-12 13:56:44 +05306372 vos_mem_copy(&pSession->connectedProfile.modifyProfileFields,
6373 pModifyProfileFields,
6374 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006375
6376 return eHAL_STATUS_SUCCESS;
6377}
6378
6379
6380#if 0
6381/* ---------------------------------------------------------------------------
6382 \fn csrGetSupportedCountryCode
6383 \brief this function is to get a list of the country code current being supported
6384 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6385 this has the country code list. 3 bytes for each country code. This may be NULL if
6386 caller wants to know the needed bytes.
6387 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6388 this contains the length of the data in pBuf
6389 \return eHalStatus
6390 -------------------------------------------------------------------------------*/
6391eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6392{
6393 tANI_U32 numOfCountry = sizeof( gCsrCountryInfo ) / sizeof( gCsrCountryInfo[0] );
6394 tANI_U32 numBytes = 0;
6395 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6396
6397 if( pbLen )
6398 {
6399 numBytes = *pbLen;
6400 //Consider it ok, at least we can return the number of bytes needed;
6401 *pbLen = numOfCountry * WNI_CFG_COUNTRY_CODE_LEN;
6402 status = eHAL_STATUS_SUCCESS;
6403 if( pBuf && ( numBytes >= *pbLen ) )
6404 {
6405 //The ugly part starts.
6406 //We may need to alter the data structure and find a way to make this faster.
6407 tANI_U32 i;
6408
Kiet Lam64c1b492013-07-12 13:56:44 +05306409 for ( i = 0; i < numOfCountry; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306411 vos_mem_copy(pBuf + ( i * WNI_CFG_COUNTRY_CODE_LEN ),
6412 gCsrCountryInfo[i].countryCode,
6413 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 }
6415 }
6416 }
6417
6418 return ( status );
6419}
6420#endif
6421
6422/* ---------------------------------------------------------------------------
6423 \fn csrGetSupportedCountryCode
6424 \brief this function is to get a list of the country code current being supported
6425 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6426 this has the country code list. 3 bytes for each country code. This may be NULL if
6427 caller wants to know the needed bytes.
6428 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6429 this contains the length of the data in pBuf
6430 \return eHalStatus
6431 -------------------------------------------------------------------------------*/
6432eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6433{
6434 eHalStatus status = eHAL_STATUS_SUCCESS;
6435 VOS_STATUS vosStatus;
6436 v_SIZE_t size = (v_SIZE_t)*pbLen;
6437
6438 vosStatus = vos_nv_getSupportedCountryCode( pBuf, &size, 1 );
6439 //eiter way, return the value back
6440 *pbLen = (tANI_U32)size;
6441
6442 //If pBuf is NULL, caller just want to get the size, consider it success
6443 if(pBuf)
6444 {
6445 if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
6446 {
6447 tANI_U32 i, n = *pbLen / 3;
6448
6449 for( i = 0; i < n; i++ )
6450 {
6451 pBuf[i*3 + 2] = ' ';
6452 }
6453 }
6454 else
6455 {
6456 status = eHAL_STATUS_FAILURE;
6457 }
6458 }
6459
6460 return (status);
6461}
6462
6463
6464
6465//Upper layer to get the list of the base channels to scan for passively 11d info from csr
6466eHalStatus csrScanGetBaseChannels( tpAniSirGlobal pMac, tCsrChannelInfo * pChannelInfo )
6467{
6468 eHalStatus status = eHAL_STATUS_FAILURE;
6469
6470 do
6471 {
6472
6473 if(!pMac->scan.baseChannels.numChannels || !pChannelInfo)
6474 {
6475 break;
6476 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306477 pChannelInfo->ChannelList = vos_mem_malloc(pMac->scan.baseChannels.numChannels);
6478 if ( NULL == pChannelInfo->ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006480 smsLog( pMac, LOGE, FL("csrScanGetBaseChannels: fail to allocate memory") );
Kiet Lam64c1b492013-07-12 13:56:44 +05306481 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006482 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306483 vos_mem_copy(pChannelInfo->ChannelList,
6484 pMac->scan.baseChannels.channelList,
6485 pMac->scan.baseChannels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 pChannelInfo->numOfChannels = pMac->scan.baseChannels.numChannels;
6487
6488 }while(0);
6489
6490 return ( status );
6491}
6492
6493
6494tANI_BOOLEAN csrIsSetKeyAllowed(tpAniSirGlobal pMac, tANI_U32 sessionId)
6495{
6496 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 tCsrRoamSession *pSession;
6498
6499 pSession =CSR_GET_SESSION(pMac, sessionId);
6500
6501 /*This condition is not working for infra state. When infra is in not-connected state
6502 * the pSession->pCurRoamProfile is NULL. And this function returns TRUE, that is incorrect.
6503 * Since SAP requires to set key without any BSS started, it needs this condition to be met.
6504 * In other words, this function is useless.
6505 * The current work-around is to process setcontext_rsp and removekey_rsp no matter what the
6506 * state is.
6507 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006508 smsLog( pMac, LOG2, FL(" is not what it intends to. Must be revisit or removed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 if( (NULL == pSession) ||
6510 ( csrIsConnStateDisconnected( pMac, sessionId ) &&
6511 (pSession->pCurRoamProfile != NULL) &&
6512 (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) )
6513 )
6514 {
6515 fRet = eANI_BOOLEAN_FALSE;
6516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006517
6518 return ( fRet );
6519}
6520
6521//no need to acquire lock for this basic function
6522tANI_U16 sme_ChnToFreq(tANI_U8 chanNum)
6523{
6524 int i;
6525
6526 for (i = 0; i < NUM_RF_CHANNELS; i++)
6527 {
6528 if (rfChannels[i].channelNum == chanNum)
6529 {
6530 return rfChannels[i].targetFreq;
6531 }
6532 }
6533
6534 return (0);
6535}
6536
6537/* Disconnect all active sessions by sending disassoc. This is mainly used to disconnect the remaining session when we
6538 * transition from concurrent sessions to a single session. The use case is Infra STA and wifi direct multiple sessions are up and
6539 * P2P session is removed. The Infra STA session remains and should resume BMPS if BMPS is enabled by default. However, there
6540 * are some issues seen with BMPS resume during this transition and this is a workaround which will allow the Infra STA session to
6541 * disconnect and auto connect back and enter BMPS this giving the same effect as resuming BMPS
6542 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006543
6544//Remove this code once SLM_Sessionization is supported
6545//BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnson295189b2012-06-20 16:38:30 -07006546void csrDisconnectAllActiveSessions(tpAniSirGlobal pMac)
6547{
6548 tANI_U8 i;
6549
6550 /* Disconnect all the active sessions */
6551 for (i=0; i<CSR_ROAM_SESSION_MAX; i++)
6552 {
6553 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
6554 {
6555 csrRoamDisconnectInternal(pMac, i, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6556 }
6557 }
6558}
Mohit Khanna349bc392012-09-11 17:24:52 -07006559
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006560#ifdef FEATURE_WLAN_LFR
6561tANI_BOOLEAN csrIsChannelPresentInList(
6562 tANI_U8 *pChannelList,
6563 int numChannels,
6564 tANI_U8 channel
6565 )
6566{
6567 int i = 0;
6568
6569 // Check for NULL pointer
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08006570 if (!pChannelList || (numChannels == 0))
6571 {
6572 return FALSE;
6573 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006574
6575 // Look for the channel in the list
6576 for (i = 0; i < numChannels; i++)
6577 {
6578 if (pChannelList[i] == channel)
6579 return TRUE;
6580 }
6581
6582 return FALSE;
6583}
6584
6585VOS_STATUS csrAddToChannelListFront(
6586 tANI_U8 *pChannelList,
6587 int numChannels,
6588 tANI_U8 channel
6589 )
6590{
6591 int i = 0;
6592
6593 // Check for NULL pointer
6594 if (!pChannelList) return eHAL_STATUS_E_NULL_VALUE;
6595
6596 // Make room for the addition. (Start moving from the back.)
6597 for (i = numChannels; i > 0; i--)
6598 {
6599 pChannelList[i] = pChannelList[i-1];
6600 }
6601
6602 // Now add the NEW channel...at the front
6603 pChannelList[0] = channel;
6604
6605 return eHAL_STATUS_SUCCESS;
6606}
6607#endif