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