blob: 24035430eb48ffd57b9a2a9c4cd97f125f095e9b [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;
1542
1543 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1544 {
1545 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1546 {
1547 pSession = CSR_GET_SESSION( pMac, i );
1548
1549 if (NULL != pSession->pCurRoamProfile)
1550 {
1551 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE) {
1552 countP2pCli++;
1553 }
1554
1555 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1556 countP2pGo++;
1557 }
1558 }
1559 }
1560 }
1561
1562 /* return TRUE if one of the following conditions is TRUE:
1563 * - at least one P2P CLI session is connected
1564 * - at least one P2P GO session is connected
1565 */
1566 if ( (countP2pCli > 0) || (countP2pGo > 0 ) ) {
1567 fRc = eANI_BOOLEAN_TRUE;
1568 }
1569
1570 return( fRc );
1571}
1572
Madan Mohan Koyyalamudid3d22592012-09-24 14:01:29 -07001573tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac )
1574{
1575 tANI_U32 i, count;
1576 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1577
1578 count = 0;
1579 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1580 {
1581 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1582 {
1583 count++;
1584 }
1585 }
1586
1587 if (count > 0)
1588 {
1589 fRc = eANI_BOOLEAN_TRUE;
1590 }
1591 return( fRc );
1592}
Jeff Johnson295189b2012-06-20 16:38:30 -07001593
1594tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac )
1595{
1596 tANI_U32 i;
1597 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1598
1599 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1600 {
1601 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1602 {
1603 fRc = eANI_BOOLEAN_TRUE;
1604 break;
1605 }
1606 }
1607
1608 return ( fRc );
1609}
1610
1611tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac )
1612{
1613 tANI_U32 i, noOfConnectedInfra = 0;
1614
1615 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1616
1617 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1618 {
1619 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1620 {
1621 ++noOfConnectedInfra;
1622 }
1623 }
1624
1625 // More than one Infra Sta Connected
1626 if(noOfConnectedInfra > 1)
1627 {
1628 fRc = eANI_BOOLEAN_TRUE;
1629 }
1630
1631 return ( fRc );
1632}
1633
1634tANI_BOOLEAN csrIsIBSSStarted( tpAniSirGlobal pMac )
1635{
1636 tANI_U32 i;
1637 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1638
1639 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1640 {
1641 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateIbss( pMac, i ) )
1642 {
1643 fRc = eANI_BOOLEAN_TRUE;
1644 break;
1645 }
1646 }
1647
1648 return ( fRc );
1649}
1650
1651
1652tANI_BOOLEAN csrIsBTAMPStarted( tpAniSirGlobal pMac )
1653{
1654 tANI_U32 i;
1655 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1656
1657 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1658 {
1659 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedWds( pMac, i ) )
1660 {
1661 fRc = eANI_BOOLEAN_TRUE;
1662 break;
1663 }
1664 }
1665
1666 return ( fRc );
1667}
1668
Jeff Johnsone7245742012-09-05 17:12:55 -07001669tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac )
1670{
1671 tANI_U32 sessionId, noOfCocurrentSession = 0;
1672 eCsrConnectState connectState;
1673
1674 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1675
1676 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1677 {
1678 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1679 {
1680 connectState = pMac->roam.roamSession[sessionId].connectState;
1681 if( (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == connectState) ||
1682 (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == connectState) ||
1683 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == connectState) )
1684 {
1685 ++noOfCocurrentSession;
1686 }
1687 }
1688 }
1689
1690 // More than one session is Up and Running
1691 if(noOfCocurrentSession > 1)
1692 {
1693 fRc = eANI_BOOLEAN_TRUE;
1694 }
1695
1696 return ( fRc );
1697}
1698
Jeff Johnsone7245742012-09-05 17:12:55 -07001699tANI_BOOLEAN csrIsInfraApStarted( tpAniSirGlobal pMac )
1700{
1701 tANI_U32 sessionId;
1702 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1703
1704 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1705 {
1706 if( CSR_IS_SESSION_VALID( pMac, sessionId ) && (csrIsConnStateConnectedInfraAp(pMac, sessionId)) )
1707 {
1708 fRc = eANI_BOOLEAN_TRUE;
1709 break;
1710 }
1711 }
1712
1713 return ( fRc );
1714
1715}
Jeff Johnsone7245742012-09-05 17:12:55 -07001716
Jeff Johnson295189b2012-06-20 16:38:30 -07001717tANI_BOOLEAN csrIsBTAMP( tpAniSirGlobal pMac, tANI_U32 sessionId )
1718{
1719 return ( csrIsConnStateConnectedWds( pMac, sessionId ) );
1720}
1721
1722
1723tANI_BOOLEAN csrIsConnStateDisconnected(tpAniSirGlobal pMac, tANI_U32 sessionId)
1724{
1725 return (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED == pMac->roam.roamSession[sessionId].connectState);
1726}
1727
Jeff Johnsone7245742012-09-05 17:12:55 -07001728tANI_BOOLEAN csrIsValidMcConcurrentSession(tpAniSirGlobal pMac, tANI_U32 sessionId,
1729 tSirBssDescription *pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001730{
1731 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07001732 eAniBoolean status = eANI_BOOLEAN_FALSE;
1733
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 //Check for MCC support
1735 if (!pMac->roam.configParam.fenableMCCMode)
1736 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001737 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 }
1739
Jeff Johnsone7245742012-09-05 17:12:55 -07001740 //Validate BeaconInterval
1741 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1742 {
1743 pSession = CSR_GET_SESSION( pMac, sessionId );
1744 if (NULL != pSession->pCurRoamProfile)
1745 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001746 if (csrIsconcurrentsessionValid (pMac, sessionId,
1747 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001748 == eHAL_STATUS_SUCCESS )
1749 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001750 if (csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId,
1751 &pBssDesc->beaconInterval, sessionId,
1752 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001753 != eHAL_STATUS_SUCCESS)
1754 {
1755 status = eANI_BOOLEAN_FALSE;
1756 }
1757 else
1758 {
1759 status = eANI_BOOLEAN_TRUE;
1760 }
1761 }
1762 else
1763 {
1764 status = eANI_BOOLEAN_FALSE;
1765 }
1766 }
1767 }
1768 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001769}
1770
1771static tSirMacCapabilityInfo csrGetBssCapabilities( tSirBssDescription *pSirBssDesc )
1772{
1773 tSirMacCapabilityInfo dot11Caps;
1774
1775 //tSirMacCapabilityInfo is 16-bit
1776 pal_get_U16( (tANI_U8 *)&pSirBssDesc->capabilityInfo, (tANI_U16 *)&dot11Caps );
1777
1778 return( dot11Caps );
1779}
1780
1781tANI_BOOLEAN csrIsInfraBssDesc( tSirBssDescription *pSirBssDesc )
1782{
1783 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1784
1785 return( (tANI_BOOLEAN)dot11Caps.ess );
1786}
1787
1788
1789tANI_BOOLEAN csrIsIbssBssDesc( tSirBssDescription *pSirBssDesc )
1790{
1791 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1792
1793 return( (tANI_BOOLEAN)dot11Caps.ibss );
1794}
1795
1796tANI_BOOLEAN csrIsQoSBssDesc( tSirBssDescription *pSirBssDesc )
1797{
1798 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1799
1800 return( (tANI_BOOLEAN)dot11Caps.qos );
1801}
1802
1803tANI_BOOLEAN csrIsPrivacy( tSirBssDescription *pSirBssDesc )
1804{
1805 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1806
1807 return( (tANI_BOOLEAN)dot11Caps.privacy );
1808}
1809
1810
1811tANI_BOOLEAN csrIs11dSupported(tpAniSirGlobal pMac)
1812{
1813 return(pMac->roam.configParam.Is11dSupportEnabled);
1814}
1815
1816
1817tANI_BOOLEAN csrIs11hSupported(tpAniSirGlobal pMac)
1818{
1819 return(pMac->roam.configParam.Is11hSupportEnabled);
1820}
1821
1822
1823tANI_BOOLEAN csrIs11eSupported(tpAniSirGlobal pMac)
1824{
1825 return(pMac->roam.configParam.Is11eSupportEnabled);
1826}
1827
1828tANI_BOOLEAN csrIsMCCSupported ( tpAniSirGlobal pMac )
1829{
1830 return(pMac->roam.configParam.fenableMCCMode);
1831
1832}
1833
1834tANI_BOOLEAN csrIsWmmSupported(tpAniSirGlobal pMac)
1835{
1836 if(eCsrRoamWmmNoQos == pMac->roam.configParam.WMMSupportMode)
1837 {
1838 return eANI_BOOLEAN_FALSE;
1839 }
1840 else
1841 {
1842 return eANI_BOOLEAN_TRUE;
1843 }
1844}
1845
1846
1847
1848
1849//pIes is the IEs for pSirBssDesc2
1850tANI_BOOLEAN csrIsSsidEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1,
1851 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2 )
1852{
1853 tANI_BOOLEAN fEqual = FALSE;
1854 tSirMacSSid Ssid1, Ssid2;
1855 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1856 tDot11fBeaconIEs *pIes1 = NULL;
1857 tDot11fBeaconIEs *pIesLocal = pIes2;
1858
1859 do {
1860 if( ( NULL == pSirBssDesc1 ) || ( NULL == pSirBssDesc2 ) ) break;
1861 if( !pIesLocal && !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesLocal)) )
1862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001863 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 break;
1865 }
1866 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
1867 {
1868 break;
1869 }
1870 if( ( !pIes1->SSID.present ) || ( !pIesLocal->SSID.present ) ) break;
1871 if ( pIes1->SSID.num_ssid != pIesLocal->SSID.num_ssid ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301872 vos_mem_copy(Ssid1.ssId, pIes1->SSID.ssid, pIes1->SSID.num_ssid);
1873 vos_mem_copy(Ssid2.ssId, pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001874
Kiet Lam64c1b492013-07-12 13:56:44 +05301875 fEqual = vos_mem_compare(Ssid1.ssId, Ssid2.ssId, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001876
1877 } while( 0 );
1878 if(pIes1)
1879 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301880 vos_mem_free(pIes1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 }
1882 if( pIesLocal && !pIes2 )
1883 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301884 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 }
1886
1887 return( fEqual );
1888}
1889
1890tANI_BOOLEAN csrIsAniWmeSupported(tDot11fIEAirgo *pIeAirgo)
1891{
1892 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
1893
1894 if(pIeAirgo && pIeAirgo->present && pIeAirgo->PropCapability.present)
1895 {
1896 fRet = (tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability ));
1897 }
1898
1899 return fRet;
1900}
1901
1902
1903
1904
1905//pIes can be passed in as NULL if the caller doesn't have one prepared
1906tANI_BOOLEAN csrIsBssDescriptionWme( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
1907{
1908 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1909 // Assume that WME is found...
1910 tANI_BOOLEAN fWme = TRUE;
1911 tDot11fBeaconIEs *pIesTemp = pIes;
1912
1913 do
1914 {
1915 if(pIesTemp == NULL)
1916 {
1917 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp)) )
1918 {
1919 fWme = FALSE;
1920 break;
1921 }
1922 }
1923 // if the AirgoProprietary indicator is found, then WME is supported...
1924 if ( csrIsAniWmeSupported(&pIesTemp->Airgo) ) break;
1925 // if the Wme Info IE is found, then WME is supported...
1926 if ( CSR_IS_QOS_BSS(pIesTemp) ) break;
1927 // if none of these are found, then WME is NOT supported...
1928 fWme = FALSE;
1929 } while( 0 );
1930 if( !csrIsWmmSupported( pMac ) && fWme)
1931 {
1932 if( !pIesTemp->HTCaps.present )
1933 {
1934 fWme = FALSE;
1935 }
1936 }
1937 if( ( pIes == NULL ) && ( NULL != pIesTemp ) )
1938 {
1939 //we allocate memory here so free it before returning
Kiet Lam64c1b492013-07-12 13:56:44 +05301940 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07001941 }
1942
1943 return( fWme );
1944}
1945
1946tANI_BOOLEAN csrIsHcfEnabled( tDot11fIEAirgo *pIeAirgo )
1947{
1948 tANI_BOOLEAN fHcfSupported = FALSE;
1949
1950 fHcfSupported = ((tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability )) ||
1951 (pIeAirgo->present && pIeAirgo->HCF.present && pIeAirgo->HCF.enabled));
1952
1953 return( fHcfSupported );
1954}
1955
1956
1957eCsrMediaAccessType csrGetQoSFromBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc,
1958 tDot11fBeaconIEs *pIes )
1959{
1960 eCsrMediaAccessType qosType = eCSR_MEDIUM_ACCESS_DCF;
1961
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001963
1964 do
1965 {
1966 // if we find WMM in the Bss Description, then we let this
1967 // override and use WMM.
1968 if ( csrIsBssDescriptionWme( hHal, pSirBssDesc, pIes ) )
1969 {
1970 qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
1971 }
1972 else
1973 {
1974 // if the QoS bit is on, then the AP is advertising 11E QoS...
1975 if ( csrIsQoSBssDesc( pSirBssDesc ) )
1976 {
1977 // which could be HCF or eDCF.
1978 if ( csrIsHcfEnabled( &pIes->Airgo ) )
1979 {
1980 qosType = eCSR_MEDIUM_ACCESS_11e_HCF;
1981 }
1982 else
1983 {
1984 qosType = eCSR_MEDIUM_ACCESS_11e_eDCF;
1985 }
1986 }
1987 else
1988 {
1989 qosType = eCSR_MEDIUM_ACCESS_DCF;
1990 }
1991 // scale back based on the types turned on for the adapter...
1992 if ( eCSR_MEDIUM_ACCESS_11e_eDCF == qosType && !csrIs11eSupported( hHal ) )
1993 {
1994 qosType = eCSR_MEDIUM_ACCESS_DCF;
1995 }
1996 }
1997
1998 } while(0);
1999
2000 return( qosType );
2001}
2002
2003
2004
2005
2006//Caller allocates memory for pIEStruct
2007eHalStatus csrParseBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIEStruct)
2008{
2009 eHalStatus status = eHAL_STATUS_FAILURE;
2010 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2011 int ieLen = (int)(pBssDesc->length + sizeof( pBssDesc->length ) - GET_FIELD_OFFSET( tSirBssDescription, ieFields ));
2012
2013 if(ieLen > 0 && pIEStruct)
2014 {
2015 if(!DOT11F_FAILED(dot11fUnpackBeaconIEs( pMac, (tANI_U8 *)pBssDesc->ieFields, ieLen, pIEStruct )))
2016 {
2017 status = eHAL_STATUS_SUCCESS;
2018 }
2019 }
2020
2021 return (status);
2022}
2023
2024
2025//This function will allocate memory for the parsed IEs to the caller. Caller must free the memory
2026//after it is done with the data only if this function succeeds
2027eHalStatus csrGetParsedBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs **ppIEStruct)
2028{
2029 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2030 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2031
2032 if(pBssDesc && ppIEStruct)
2033 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302034 *ppIEStruct = vos_mem_malloc(sizeof(tDot11fBeaconIEs));
2035 if ( (*ppIEStruct) != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302037 vos_mem_set((void *)*ppIEStruct, sizeof(tDot11fBeaconIEs), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 status = csrParseBssDescriptionIEs(hHal, pBssDesc, *ppIEStruct);
2039 if(!HAL_STATUS_SUCCESS(status))
2040 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302041 vos_mem_free(*ppIEStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 *ppIEStruct = NULL;
2043 }
2044 }
2045 else
2046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002047 smsLog( pMac, LOGE, FL(" failed to allocate memory") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 VOS_ASSERT( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +05302049 return eHAL_STATUS_FAILURE;
2050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 }
2052
2053 return (status);
2054}
2055
2056
2057
2058
2059tANI_BOOLEAN csrIsNULLSSID( tANI_U8 *pBssSsid, tANI_U8 len )
2060{
2061 tANI_BOOLEAN fNullSsid = FALSE;
2062
2063 tANI_U32 SsidLength;
2064 tANI_U8 *pSsidStr;
2065
2066 do
2067 {
2068 if ( 0 == len )
2069 {
2070 fNullSsid = TRUE;
2071 break;
2072 }
2073
2074 //Consider 0 or space for hidden SSID
2075 if ( 0 == pBssSsid[0] )
2076 {
2077 fNullSsid = TRUE;
2078 break;
2079 }
2080
2081 SsidLength = len;
2082 pSsidStr = pBssSsid;
2083
2084 while ( SsidLength )
2085 {
2086 if( *pSsidStr )
2087 break;
2088
2089 pSsidStr++;
2090 SsidLength--;
2091 }
2092
2093 if( 0 == SsidLength )
2094 {
2095 fNullSsid = TRUE;
2096 break;
2097 }
2098 }
2099 while( 0 );
2100
2101 return fNullSsid;
2102}
2103
2104
2105tANI_U32 csrGetFragThresh( tHalHandle hHal )
2106{
2107 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2108
2109 return pMac->roam.configParam.FragmentationThreshold;
2110}
2111
2112tANI_U32 csrGetRTSThresh( tHalHandle hHal )
2113{
2114 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2115
2116 return pMac->roam.configParam.RTSThreshold;
2117}
2118
2119eCsrPhyMode csrTranslateToPhyModeFromBssDesc( tSirBssDescription *pSirBssDesc )
2120{
2121 eCsrPhyMode phyMode;
2122
2123 switch ( pSirBssDesc->nwType )
2124 {
2125 case eSIR_11A_NW_TYPE:
2126 phyMode = eCSR_DOT11_MODE_11a;
2127 break;
2128
2129 case eSIR_11B_NW_TYPE:
2130 phyMode = eCSR_DOT11_MODE_11b;
2131 break;
2132
2133 case eSIR_11G_NW_TYPE:
2134 phyMode = eCSR_DOT11_MODE_11g;
2135 break;
2136
2137 case eSIR_11N_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 phyMode = eCSR_DOT11_MODE_11n;
2139 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002140#ifdef WLAN_FEATURE_11AC
2141 case eSIR_11AC_NW_TYPE:
2142 default:
2143 phyMode = eCSR_DOT11_MODE_11ac;
2144#else
2145 default:
2146 phyMode = eCSR_DOT11_MODE_11n;
2147#endif
2148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 return( phyMode );
2151}
2152
2153
2154tANI_U32 csrTranslateToWNICfgDot11Mode(tpAniSirGlobal pMac, eCsrCfgDot11Mode csrDot11Mode)
2155{
2156 tANI_U32 ret;
2157
2158 switch(csrDot11Mode)
2159 {
2160 case eCSR_CFG_DOT11_MODE_AUTO:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002161 smsLog(pMac, LOGW, FL(" Warning: sees eCSR_CFG_DOT11_MODE_AUTO "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 //We cannot decide until now.
2163 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2164 {
2165 ret = WNI_CFG_DOT11_MODE_TAURUS;
2166 }
2167 else
2168 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002169 ret = WNI_CFG_DOT11_MODE_11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 }
2171 break;
2172 case eCSR_CFG_DOT11_MODE_TAURUS:
2173 ret = WNI_CFG_DOT11_MODE_TAURUS;
2174 break;
2175 case eCSR_CFG_DOT11_MODE_11A:
2176 ret = WNI_CFG_DOT11_MODE_11A;
2177 break;
2178 case eCSR_CFG_DOT11_MODE_11B:
2179 ret = WNI_CFG_DOT11_MODE_11B;
2180 break;
2181 case eCSR_CFG_DOT11_MODE_11G:
2182 ret = WNI_CFG_DOT11_MODE_11G;
2183 break;
2184 case eCSR_CFG_DOT11_MODE_11N:
2185 ret = WNI_CFG_DOT11_MODE_11N;
2186 break;
2187 case eCSR_CFG_DOT11_MODE_POLARIS:
2188 ret = WNI_CFG_DOT11_MODE_POLARIS;
2189 break;
2190 case eCSR_CFG_DOT11_MODE_TITAN:
2191 ret = WNI_CFG_DOT11_MODE_TITAN;
2192 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 case eCSR_CFG_DOT11_MODE_11G_ONLY:
2194 ret = WNI_CFG_DOT11_MODE_11G_ONLY;
2195 break;
2196 case eCSR_CFG_DOT11_MODE_11N_ONLY:
2197 ret = WNI_CFG_DOT11_MODE_11N_ONLY;
2198 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002199
2200#ifdef WLAN_FEATURE_11AC
2201 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
2202 ret = WNI_CFG_DOT11_MODE_11AC_ONLY;
2203 break;
2204 case eCSR_CFG_DOT11_MODE_11AC:
2205 ret = WNI_CFG_DOT11_MODE_11AC;
2206 break;
2207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002209 smsLog(pMac, LOGW, FL("doesn't expect %d as csrDo11Mode"), csrDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 if(eCSR_BAND_24 == pMac->roam.configParam.eBand)
2211 {
2212 ret = WNI_CFG_DOT11_MODE_11G;
2213 }
2214 else
2215 {
2216 ret = WNI_CFG_DOT11_MODE_11A;
2217 }
2218 break;
2219 }
2220
2221 return (ret);
2222}
2223
2224
2225//This function should only return the super set of supported modes. 11n implies 11b/g/a/n.
2226eHalStatus csrGetPhyModeFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription,
2227 eCsrPhyMode *pPhyMode, tDot11fBeaconIEs *pIes)
2228{
2229 eHalStatus status = eHAL_STATUS_SUCCESS;
2230 eCsrPhyMode phyMode = csrTranslateToPhyModeFromBssDesc(pBSSDescription);
2231
2232 if( pIes )
2233 {
2234 if(pIes->Airgo.present)
2235 {
2236 if(pIes->Airgo.PropCapability.present)
2237 {
2238 if( PROP_CAPABILITY_GET( TAURUS, pIes->Airgo.PropCapability.capability ))
2239 {
2240 phyMode = eCSR_DOT11_MODE_TAURUS;
2241 }
2242 }
2243 }
2244 if(pIes->HTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2245 {
2246 phyMode = eCSR_DOT11_MODE_11n;
2247 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002248
2249#ifdef WLAN_FEATURE_11AC
2250 if ( pIes->VHTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2251 {
2252 phyMode = eCSR_DOT11_MODE_11ac;
2253 }
2254#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 *pPhyMode = phyMode;
2256 }
2257
2258 return (status);
2259
2260}
2261
2262
2263//This function returns the correct eCSR_CFG_DOT11_MODE is the two phyModes matches
2264//bssPhyMode is the mode derived from the BSS description
2265//f5GhzBand is derived from the channel id of BSS description
2266tANI_BOOLEAN csrGetPhyModeInUse( eCsrPhyMode phyModeIn, eCsrPhyMode bssPhyMode, tANI_BOOLEAN f5GhzBand,
2267 eCsrCfgDot11Mode *pCfgDot11ModeToUse )
2268{
2269 tANI_BOOLEAN fMatch = FALSE;
2270 eCsrCfgDot11Mode cfgDot11Mode;
2271
2272 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; // to suppress compiler warning
2273
2274 switch( phyModeIn )
2275 {
2276 case eCSR_DOT11_MODE_abg: //11a or 11b or 11g
2277 if( f5GhzBand )
2278 {
2279 fMatch = TRUE;
2280 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2281 }
2282 else if( eCSR_DOT11_MODE_11b == bssPhyMode )
2283 {
2284 fMatch = TRUE;
2285 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2286 }
2287 else
2288 {
2289 fMatch = TRUE;
2290 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2291 }
2292 break;
2293
2294 case eCSR_DOT11_MODE_11a: //11a
2295 if( f5GhzBand )
2296 {
2297 fMatch = TRUE;
2298 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2299 }
2300 break;
2301
2302 case eCSR_DOT11_MODE_11a_ONLY: //11a
2303 if( eCSR_DOT11_MODE_11a == bssPhyMode )
2304 {
2305 fMatch = TRUE;
2306 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2307 }
2308 break;
2309
2310 case eCSR_DOT11_MODE_11g:
2311 if(!f5GhzBand)
2312 {
2313 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2314 {
2315 fMatch = TRUE;
2316 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2317 }
2318 else
2319 {
2320 fMatch = TRUE;
2321 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2322 }
2323 }
2324 break;
2325
2326 case eCSR_DOT11_MODE_11g_ONLY:
2327 if( eCSR_DOT11_MODE_11g == bssPhyMode )
2328 {
2329 fMatch = TRUE;
2330 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2331 }
2332 break;
2333
2334 case eCSR_DOT11_MODE_11b:
2335 if( !f5GhzBand )
2336 {
2337 fMatch = TRUE;
2338 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2339 }
2340 break;
2341
2342 case eCSR_DOT11_MODE_11b_ONLY:
2343 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2344 {
2345 fMatch = TRUE;
2346 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2347 }
2348 break;
2349
2350 case eCSR_DOT11_MODE_11n:
2351 fMatch = TRUE;
2352 switch(bssPhyMode)
2353 {
2354 case eCSR_DOT11_MODE_11g:
2355 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2356 break;
2357 case eCSR_DOT11_MODE_11b:
2358 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2359 break;
2360 case eCSR_DOT11_MODE_11a:
2361 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2362 break;
2363 case eCSR_DOT11_MODE_11n:
Jeff Johnsone7245742012-09-05 17:12:55 -07002364#ifdef WLAN_FEATURE_11AC
2365 case eCSR_DOT11_MODE_11ac:
2366#endif
2367 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2368 break;
2369
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 case eCSR_DOT11_MODE_TAURUS:
2371 default:
Jeff Johnsone7245742012-09-05 17:12:55 -07002372#ifdef WLAN_FEATURE_11AC
2373 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2374#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002376#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 break;
2378 }
2379 break;
2380
2381 case eCSR_DOT11_MODE_11n_ONLY:
2382 if((eCSR_DOT11_MODE_11n == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2383 {
2384 fMatch = TRUE;
2385 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002386
2387 }
2388
2389 break;
2390#ifdef WLAN_FEATURE_11AC
2391 case eCSR_DOT11_MODE_11ac:
2392 fMatch = TRUE;
2393 switch(bssPhyMode)
2394 {
2395 case eCSR_DOT11_MODE_11g:
2396 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2397 break;
2398 case eCSR_DOT11_MODE_11b:
2399 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2400 break;
2401 case eCSR_DOT11_MODE_11a:
2402 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2403 break;
2404 case eCSR_DOT11_MODE_11n:
2405 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2406 break;
2407 case eCSR_DOT11_MODE_11ac:
2408 case eCSR_DOT11_MODE_TAURUS:
2409 default:
2410 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2411 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002412 }
2413 break;
2414
Jeff Johnsone7245742012-09-05 17:12:55 -07002415 case eCSR_DOT11_MODE_11ac_ONLY:
2416 if((eCSR_DOT11_MODE_11ac == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2417 {
2418 fMatch = TRUE;
2419 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2420 }
2421 break;
2422#endif
2423
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 case eCSR_DOT11_MODE_TAURUS:
2425 default:
2426 fMatch = TRUE;
2427 switch(bssPhyMode)
2428 {
2429 case eCSR_DOT11_MODE_11g:
2430 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2431 break;
2432 case eCSR_DOT11_MODE_11b:
2433 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2434 break;
2435 case eCSR_DOT11_MODE_11a:
2436 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2437 break;
2438 case eCSR_DOT11_MODE_11n:
2439 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2440 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002441#ifdef WLAN_FEATURE_11AC
2442 case eCSR_DOT11_MODE_11ac:
2443 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2444 break;
2445#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 case eCSR_DOT11_MODE_TAURUS:
2447 default:
2448 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
2449 break;
2450 }
2451 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 }
2453
2454 if ( fMatch && pCfgDot11ModeToUse )
2455 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002456#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudief5dd972012-10-11 15:06:09 -07002457 if(cfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC && (!IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)))
Jeff Johnsone7245742012-09-05 17:12:55 -07002458 {
2459 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2460 }
2461 else
2462#endif
2463 {
2464 *pCfgDot11ModeToUse = cfgDot11Mode;
2465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 return( fMatch );
2468}
2469
2470
2471//This function decides whether the one of the bit of phyMode is matching the mode in the BSS and allowed by the user
2472//setting, pMac->roam.configParam.uCfgDot11Mode. It returns the mode that fits the criteria.
2473tANI_BOOLEAN csrIsPhyModeMatch( tpAniSirGlobal pMac, tANI_U32 phyMode,
2474 tSirBssDescription *pSirBssDesc, tCsrRoamProfile *pProfile,
2475 eCsrCfgDot11Mode *pReturnCfgDot11Mode,
2476 tDot11fBeaconIEs *pIes)
2477{
2478 tANI_BOOLEAN fMatch = FALSE;
2479 eCsrPhyMode phyModeInBssDesc, phyMode2;
2480 eCsrCfgDot11Mode cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_TAURUS;
2481 tANI_U32 bitMask, loopCount;
2482
2483 if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pSirBssDesc, &phyModeInBssDesc, pIes )))
2484 {
2485 //In case some change change eCSR_DOT11_MODE_TAURUS to non-0
2486 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2487 {
2488 //Taurus means anything
2489 if ( eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode )
2490 {
2491 phyMode = eCSR_DOT11_MODE_abg;
2492 }
2493 else if(eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode)
2494 {
2495 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2496 {
2497 phyMode = eCSR_DOT11_MODE_TAURUS;
2498 }
2499 else
2500 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002501
2502#ifdef WLAN_FEATURE_11AC
2503 phyMode = eCSR_DOT11_MODE_11ac;
2504#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002506#endif
2507
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 }
2509 }
2510 else
2511 {
2512 //user's pick
2513 phyMode = pMac->roam.configParam.phyMode;
2514 }
2515 }
2516 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode) )
2517 {
2518 if(0 != phyMode)
2519 {
2520 if(eCSR_DOT11_MODE_AUTO & phyMode)
2521 {
2522 phyMode2 = eCSR_DOT11_MODE_AUTO & phyMode;
2523 }
2524 else
2525 {
2526 phyMode2 = eCSR_DOT11_MODE_TAURUS & phyMode;
2527 }
2528 }
2529 else
2530 {
2531 phyMode2 = phyMode;
2532 }
2533 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2534 &cfgDot11ModeToUse );
2535 }
2536 else
2537 {
2538 bitMask = 1;
2539 loopCount = 0;
2540 while(loopCount < eCSR_NUM_PHY_MODE)
2541 {
2542 if(0 != ( phyMode2 = (phyMode & (bitMask << loopCount++)) ))
2543 {
2544 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2545 &cfgDot11ModeToUse );
2546 if(fMatch) break;
2547 }
2548 }
2549 }
2550 if ( fMatch && pReturnCfgDot11Mode )
2551 {
2552 if( pProfile )
2553 {
2554 /* IEEE 11n spec (8.4.3): HT STA shall eliminate TKIP as a
2555 * choice for the pairwise cipher suite if CCMP is advertised
2556 * by the AP or if the AP included an HT capabilities element
2557 * in its Beacons and Probe Response.
2558 */
2559 if( (!CSR_IS_11n_ALLOWED( pProfile->negotiatedUCEncryptionType )) &&
2560 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11ModeToUse) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002561#ifdef WLAN_FEATURE_11AC
2562 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11ModeToUse) ||
2563#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11ModeToUse)) )
2565 {
2566 //We cannot do 11n here
2567 if( !CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId) )
2568 {
2569 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2570 }
2571 else
2572 {
2573 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2574 }
2575 }
2576 }
2577 *pReturnCfgDot11Mode = cfgDot11ModeToUse;
2578 }
2579 }
2580
2581 return( fMatch );
2582}
2583
2584
2585eCsrCfgDot11Mode csrFindBestPhyMode( tpAniSirGlobal pMac, tANI_U32 phyMode )
2586{
2587 eCsrCfgDot11Mode cfgDot11ModeToUse;
2588 eCsrBand eBand = pMac->roam.configParam.eBand;
2589
Jeff Johnsone7245742012-09-05 17:12:55 -07002590
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302591 if ((0 == phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002592#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302593 (eCSR_DOT11_MODE_11ac & phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002594#endif
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302595 (eCSR_DOT11_MODE_AUTO & phyMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 {
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302597#ifdef WLAN_FEATURE_11AC
2598 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2599 {
2600 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC;
2601 }
2602 else
2603#endif
2604 {
2605 /* Default to 11N mode if user has configured 11ac mode
2606 * and FW doesn't supports 11ac mode .
2607 */
2608 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 }
2611 else
2612 {
2613 if( ( eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY ) & phyMode )
2614 {
2615 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2616 }
2617 else if ( eCSR_DOT11_MODE_abg & phyMode )
2618 {
2619 if( eCSR_BAND_24 != eBand )
2620 {
2621 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2622 }
2623 else
2624 {
2625 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2626 }
2627 }
2628 else if( ( eCSR_DOT11_MODE_11a | eCSR_DOT11_MODE_11a_ONLY ) & phyMode )
2629 {
2630 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2631 }
2632 else if( ( eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY ) & phyMode )
2633 {
2634 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2635 }
2636 else
2637 {
2638 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B;
2639 }
2640 }
2641
2642 return ( cfgDot11ModeToUse );
2643}
2644
2645
2646
2647
2648tANI_U32 csrGet11hPowerConstraint( tHalHandle hHal, tDot11fIEPowerConstraints *pPowerConstraint )
2649{
2650 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2651 tANI_U32 localPowerConstraint = 0;
2652
2653 // check if .11h support is enabled, if not, the power constraint is 0.
2654 if(pMac->roam.configParam.Is11hSupportEnabled && pPowerConstraint->present)
2655 {
2656 localPowerConstraint = pPowerConstraint->localPowerConstraints;
2657 }
2658
2659 return( localPowerConstraint );
2660}
2661
2662
2663tANI_BOOLEAN csrIsProfileWpa( tCsrRoamProfile *pProfile )
2664{
2665 tANI_BOOLEAN fWpaProfile = FALSE;
2666
2667 switch ( pProfile->negotiatedAuthType )
2668 {
2669 case eCSR_AUTH_TYPE_WPA:
2670 case eCSR_AUTH_TYPE_WPA_PSK:
2671 case eCSR_AUTH_TYPE_WPA_NONE:
2672#ifdef FEATURE_WLAN_CCX
2673 case eCSR_AUTH_TYPE_CCKM_WPA:
2674#endif
2675 fWpaProfile = TRUE;
2676 break;
2677
2678 default:
2679 fWpaProfile = FALSE;
2680 break;
2681 }
2682
2683 if ( fWpaProfile )
2684 {
2685 switch ( pProfile->negotiatedUCEncryptionType )
2686 {
2687 case eCSR_ENCRYPT_TYPE_WEP40:
2688 case eCSR_ENCRYPT_TYPE_WEP104:
2689 case eCSR_ENCRYPT_TYPE_TKIP:
2690 case eCSR_ENCRYPT_TYPE_AES:
2691 fWpaProfile = TRUE;
2692 break;
2693
2694 default:
2695 fWpaProfile = FALSE;
2696 break;
2697 }
2698 }
2699 return( fWpaProfile );
2700}
2701
2702tANI_BOOLEAN csrIsProfileRSN( tCsrRoamProfile *pProfile )
2703{
2704 tANI_BOOLEAN fRSNProfile = FALSE;
2705
2706 switch ( pProfile->negotiatedAuthType )
2707 {
2708 case eCSR_AUTH_TYPE_RSN:
2709 case eCSR_AUTH_TYPE_RSN_PSK:
2710#ifdef WLAN_FEATURE_VOWIFI_11R
2711 case eCSR_AUTH_TYPE_FT_RSN:
2712 case eCSR_AUTH_TYPE_FT_RSN_PSK:
2713#endif
2714#ifdef FEATURE_WLAN_CCX
2715 case eCSR_AUTH_TYPE_CCKM_RSN:
2716#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002717#ifdef WLAN_FEATURE_11W
2718 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
2719#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 fRSNProfile = TRUE;
2721 break;
2722
2723 default:
2724 fRSNProfile = FALSE;
2725 break;
2726 }
2727
2728 if ( fRSNProfile )
2729 {
2730 switch ( pProfile->negotiatedUCEncryptionType )
2731 {
2732 // !!REVIEW - For WPA2, use of RSN IE mandates
2733 // use of AES as encryption. Here, we qualify
2734 // even if encryption type is WEP or TKIP
2735 case eCSR_ENCRYPT_TYPE_WEP40:
2736 case eCSR_ENCRYPT_TYPE_WEP104:
2737 case eCSR_ENCRYPT_TYPE_TKIP:
2738 case eCSR_ENCRYPT_TYPE_AES:
2739 fRSNProfile = TRUE;
2740 break;
2741
2742 default:
2743 fRSNProfile = FALSE;
2744 break;
2745 }
2746 }
2747 return( fRSNProfile );
2748}
2749
Jeff Johnsone7245742012-09-05 17:12:55 -07002750eHalStatus
2751csrIsconcurrentsessionValid(tpAniSirGlobal pMac,tANI_U32 cursessionId,
2752 tVOS_CON_MODE currBssPersona)
2753{
2754 tANI_U32 sessionId = 0;
2755
2756 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2757 {
2758 if (cursessionId != sessionId )
2759 {
2760 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2761 {
2762 continue;
2763 }
2764
2765 switch (currBssPersona)
2766 {
2767 case VOS_STA_MODE:
2768 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002769 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002770 == VOS_STA_MODE)) //check for P2P client mode
2771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002772 smsLog(pMac, LOGE, FL(" ****STA mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002773 return eHAL_STATUS_FAILURE;
2774 }
2775 break;
2776
2777 case VOS_STA_SAP_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302778 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2779 == VOS_STA_SAP_MODE)&&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002780 (pMac->roam.roamSession[sessionId].connectState
2781 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002783 smsLog(pMac, LOGE, FL(" ****SoftAP mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002784 return eHAL_STATUS_FAILURE;
2785 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002786 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2787 == VOS_P2P_GO_MODE &&
2788 pMac->roam.roamSession[sessionId].connectState
2789 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2790 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2791 == VOS_IBSS_MODE &&
2792 pMac->roam.roamSession[sessionId].connectState
2793 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002795 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002796 return eHAL_STATUS_FAILURE;
2797 }
2798 break;
2799
2800 case VOS_P2P_CLIENT_MODE:
2801 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002802 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002803 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2804 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002805 smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002806 return eHAL_STATUS_FAILURE;
2807 }
2808 break;
2809
2810 case VOS_P2P_GO_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302811 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2812 == VOS_P2P_GO_MODE) &&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002813 (pMac->roam.roamSession[sessionId].connectState
2814 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002816 smsLog(pMac, LOGE, FL(" ****P2P GO mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002817 return eHAL_STATUS_FAILURE;
2818 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002819 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2820 == VOS_STA_SAP_MODE &&
2821 pMac->roam.roamSession[sessionId].connectState
2822 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2823 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2824 == VOS_IBSS_MODE &&
2825 pMac->roam.roamSession[sessionId].connectState
2826 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002828 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002829 return eHAL_STATUS_FAILURE;
2830 }
2831 break;
Ravi Joshia96ceb42013-05-20 18:52:39 -07002832 case VOS_IBSS_MODE:
2833 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2834 == VOS_IBSS_MODE) &&
2835 (pMac->roam.roamSession[sessionId].connectState
2836 != eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED))
2837 {
2838 smsLog(pMac, LOGE, FL(" ****IBSS mode already exists ****"));
2839 return eHAL_STATUS_FAILURE;
2840 }
2841 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2842 == VOS_P2P_GO_MODE ||
2843 pMac->roam.roamSession[sessionId].bssParams.bssPersona
2844 == VOS_STA_SAP_MODE) &&
2845 pMac->roam.roamSession[sessionId].connectState
2846 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)
2847 {
2848 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
2849 return eHAL_STATUS_FAILURE;
2850 }
2851 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002852 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002853 smsLog(pMac, LOGE, FL("***Persona not handled = %d*****"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07002854 break;
2855 }
2856 }
2857 }
2858 return eHAL_STATUS_SUCCESS;
2859
2860}
2861
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002862eHalStatus csrUpdateMCCp2pBeaconInterval(tpAniSirGlobal pMac)
Jeff Johnsone7245742012-09-05 17:12:55 -07002863{
2864 tANI_U32 sessionId = 0;
2865
2866 //If MCC is not supported just break and return SUCCESS
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002867 if ( !pMac->roam.configParam.fenableMCCMode){
2868 return eHAL_STATUS_FAILURE;
2869 }
2870
2871 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2872 {
2873 /* If GO in MCC support different beacon interval,
2874 * change the BI of the P2P-GO */
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002875 if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2876 == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002877 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002878 /* Handle different BI scneario based on the configuration set.
2879 * If Config is set to 0x02 then Disconnect all the P2P clients
2880 * associated. If config is set to 0x04 then update the BI
2881 * without disconnecting all the clients
2882 */
2883 if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
2884 (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
2885 {
2886 return csrSendChngMCCBeaconInterval( pMac, sessionId);
2887 }
2888 //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
2889 else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
2890 {
2891 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
2892 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002893 }
2894 }
2895 return eHAL_STATUS_FAILURE;
2896}
2897
2898tANI_U16 csrCalculateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U16 sta_bi, tANI_U16 go_gbi)
2899{
2900 tANI_U8 num_beacons = 0;
2901 tANI_U8 is_multiple = 0;
2902 tANI_U16 go_cbi = 0;
2903 tANI_U16 go_fbi = 0;
2904 tANI_U16 sta_cbi = 0;
2905
2906 //If GO's given beacon Interval is less than 100
2907 if(go_gbi < 100)
2908 go_cbi = 100;
2909 //if GO's given beacon Interval is greater than or equal to 100
2910 else
2911 go_cbi = 100 + (go_gbi % 100);
2912
2913 // check, if either one is multiple of another
2914 if (sta_bi > go_cbi)
2915 {
2916 is_multiple = !(sta_bi % go_cbi);
2917 }
2918 else
2919 {
2920 is_multiple = !(go_cbi % sta_bi);
2921 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002922 // if it is multiple, then accept GO's beacon interval range [100,199] as it is
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002923 if (is_multiple)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002924 {
2925 return go_cbi;
2926 }
2927 //else , if it is not multiple, then then check for number of beacons to be
2928 //inserted based on sta BI
2929 num_beacons = sta_bi / 100;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002930 if (num_beacons)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002931 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002932 // GO's final beacon interval will be aligned to sta beacon interval, but
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002933 //in the range of [100, 199].
2934 sta_cbi = sta_bi / num_beacons;
2935 go_fbi = sta_cbi;
2936 }
2937 else
2938 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002939 // if STA beacon interval is less than 100, use GO's change bacon interval
2940 //instead of updating to STA's beacon interval.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002941 go_fbi = go_cbi;
2942 }
2943 return go_fbi;
2944}
2945
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002946eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002947 tANI_U16 *beaconInterval, tANI_U32 cursessionId,
2948 tVOS_CON_MODE currBssPersona)
2949{
2950 tANI_U32 sessionId = 0;
2951 tANI_U16 new_beaconInterval = 0;
2952
2953 //If MCC is not supported just break
2954 if (!pMac->roam.configParam.fenableMCCMode){
Jeff Johnsone7245742012-09-05 17:12:55 -07002955 return eHAL_STATUS_FAILURE;
2956 }
2957
2958 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2959 {
2960 if (cursessionId != sessionId )
2961 {
2962 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2963 {
2964 continue;
2965 }
2966
2967 switch (currBssPersona)
2968 {
2969 case VOS_STA_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002970 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
2971 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002972 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002974 smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002975 }
2976 //IF SAP has started and STA wants to connect on different channel MCC should
2977 //MCC should not be enabled so making it false to enforce on same channel
2978 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2979 == VOS_STA_SAP_MODE)
2980 {
2981 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
2982 != channelId )
2983 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002984 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP +STA****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002985 return eHAL_STATUS_FAILURE;
2986 }
2987 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002988 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002989 == VOS_P2P_GO_MODE) //Check for P2P go scenario
2990 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002991 /* if GO in MCC support different beacon interval,
2992 * change the BI of the P2P-GO */
2993 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
Jeff Johnsone7245742012-09-05 17:12:55 -07002994 != channelId ) &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002995 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07002996 != *beaconInterval))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002997 {
2998 /* if GO in MCC support different beacon interval, return success */
2999 if ( pMac->roam.configParam.fAllowMCCGODiffBI == 0x01)
3000 {
3001 return eHAL_STATUS_SUCCESS;
3002 }
3003 // Send only Broadcast disassoc and update beaconInterval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003004 //If configuration is set to 0x04 then dont
3005 // disconnect all the station
3006 else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
3007 (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003008 {
3009 //Check to pass the right beacon Interval
3010 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval,
3011 pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003012 smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003013 //Update the becon Interval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003014 if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003015 {
3016 //Update the beaconInterval now
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003017 smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
3018 pMac->roam.configParam.fAllowMCCGODiffBI);
3019
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003020 pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
3021 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003022 return csrUpdateMCCp2pBeaconInterval(pMac);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003023 }
3024 return eHAL_STATUS_SUCCESS;
3025 }
3026 //Disconnect the P2P session
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003027 else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003028 {
3029 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
3030 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
3031 }
3032 else
3033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003034 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to preferred AP..."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003035 return eHAL_STATUS_FAILURE;
3036 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003037 }
3038 }
3039 break;
3040
3041 case VOS_P2P_CLIENT_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003042 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3043 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003044 == VOS_STA_MODE)) //check for P2P client mode
3045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003046 smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003047 }
3048 //IF SAP has started and STA wants to connect on different channel MCC should
3049 //MCC should not be enabled so making it false to enforce on same channel
3050 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3051 == VOS_STA_SAP_MODE)
3052 {
3053 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3054 != channelId )
3055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003056 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP + CLIENT****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003057 return eHAL_STATUS_FAILURE;
3058 }
3059 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003060 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003061 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3062 {
3063 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
3064 != channelId ) &&
3065 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
3066 != *beaconInterval))
3067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003068 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to P2P_GO network ..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003069 return eHAL_STATUS_FAILURE;
3070 }
3071 }
3072 break;
3073
3074 case VOS_P2P_GO_MODE :
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003075 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003076 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3077 ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003078 == VOS_P2P_CLIENT_MODE) ||
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003079 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003080 == VOS_STA_MODE))) //check for P2P_client scenario
3081 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003082 if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003083 == 0 )&&
3084 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
3085 == 0))
3086 {
3087 continue;
3088 }
3089
3090
3091 if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003092 (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003093 != channelId ) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003094 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003095 != *beaconInterval))
3096 {
3097 /*
3098 * Updated beaconInterval should be used only when we are starting a new BSS
3099 * not incase of client or STA case
3100 */
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003101 //Calculate beacon Interval for P2P-GO incase of MCC
3102 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac,
Chet Lanctot4c986162013-05-08 13:59:56 -07003103 pMac->roam.roamSession[sessionId].bssParams.beaconInterval,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003104 *beaconInterval );
3105 if(*beaconInterval != new_beaconInterval)
3106 *beaconInterval = new_beaconInterval;
Jeff Johnsone7245742012-09-05 17:12:55 -07003107 return eHAL_STATUS_SUCCESS;
3108 }
3109 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003110 }
3111 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003112
3113 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003114 smsLog(pMac, LOG1, FL(" Persona not supported : %d"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003115 return eHAL_STATUS_FAILURE;
3116 }
3117 }
3118 }
3119
3120 return eHAL_STATUS_SUCCESS;
3121}
Jeff Johnson295189b2012-06-20 16:38:30 -07003122
3123#ifdef WLAN_FEATURE_VOWIFI_11R
3124/* Function to return TRUE if the authtype is 11r */
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003125tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -07003126{
3127 switch ( AuthType )
3128 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003129 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3130 if(mdiePresent)
3131 return TRUE;
3132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3134 case eCSR_AUTH_TYPE_FT_RSN:
3135 return TRUE;
3136 break;
3137 default:
3138 break;
3139 }
3140 return FALSE;
3141}
3142
3143/* Function to return TRUE if the profile is 11r */
3144tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
3145{
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003146 return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
Jeff Johnson295189b2012-06-20 16:38:30 -07003147}
3148
3149#endif
3150
3151#ifdef FEATURE_WLAN_CCX
3152
3153/* Function to return TRUE if the authtype is CCX */
3154tANI_BOOLEAN csrIsAuthTypeCCX( eCsrAuthType AuthType )
3155{
3156 switch ( AuthType )
3157 {
3158 case eCSR_AUTH_TYPE_CCKM_WPA:
3159 case eCSR_AUTH_TYPE_CCKM_RSN:
3160 return TRUE;
3161 break;
3162 default:
3163 break;
3164 }
3165 return FALSE;
3166}
3167
3168/* Function to return TRUE if the profile is CCX */
3169tANI_BOOLEAN csrIsProfileCCX( tCsrRoamProfile *pProfile )
3170{
3171 return (csrIsAuthTypeCCX( pProfile->negotiatedAuthType ));
3172}
3173
3174#endif
3175
3176#ifdef FEATURE_WLAN_WAPI
3177tANI_BOOLEAN csrIsProfileWapi( tCsrRoamProfile *pProfile )
3178{
3179 tANI_BOOLEAN fWapiProfile = FALSE;
3180
3181 switch ( pProfile->negotiatedAuthType )
3182 {
3183 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
3184 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
3185 fWapiProfile = TRUE;
3186 break;
3187
3188 default:
3189 fWapiProfile = FALSE;
3190 break;
3191 }
3192
3193 if ( fWapiProfile )
3194 {
3195 switch ( pProfile->negotiatedUCEncryptionType )
3196 {
3197 case eCSR_ENCRYPT_TYPE_WPI:
3198 fWapiProfile = TRUE;
3199 break;
3200
3201 default:
3202 fWapiProfile = FALSE;
3203 break;
3204 }
3205 }
3206 return( fWapiProfile );
3207}
3208
3209static tANI_BOOLEAN csrIsWapiOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3210{
Kiet Lam64c1b492013-07-12 13:56:44 +05303211 return (vos_mem_compare(Oui1, Oui2, CSR_WAPI_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003212}
3213
3214static tANI_BOOLEAN csrIsWapiOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3215 tANI_U8 cAllCyphers,
3216 tANI_U8 Cypher[],
3217 tANI_U8 Oui[] )
3218{
3219 tANI_BOOLEAN fYes = FALSE;
3220 tANI_U8 idx;
3221
3222 for ( idx = 0; idx < cAllCyphers; idx++ )
3223 {
3224 if ( csrIsWapiOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3225 {
3226 fYes = TRUE;
3227 break;
3228 }
3229 }
3230
3231 if ( fYes && Oui )
3232 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303233 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 }
3235
3236 return( fYes );
3237}
3238#endif /* FEATURE_WLAN_WAPI */
3239
3240static tANI_BOOLEAN csrIsWpaOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3241{
Kiet Lam64c1b492013-07-12 13:56:44 +05303242 return(vos_mem_compare(Oui1, Oui2, CSR_WPA_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003243}
3244
3245static tANI_BOOLEAN csrIsOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3246 tANI_U8 cAllCyphers,
3247 tANI_U8 Cypher[],
3248 tANI_U8 Oui[] )
3249{
3250 tANI_BOOLEAN fYes = FALSE;
3251 tANI_U8 idx;
3252
3253 for ( idx = 0; idx < cAllCyphers; idx++ )
3254 {
3255 if ( csrIsWpaOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3256 {
3257 fYes = TRUE;
3258 break;
3259 }
3260 }
3261
3262 if ( fYes && Oui )
3263 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303264 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 }
3266
3267 return( fYes );
3268}
3269
3270static tANI_BOOLEAN csrMatchRSNOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3271 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3272 tANI_U8 Oui[] )
3273{
3274 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui[ouiIndex], Oui ) );
3275
3276}
3277
3278#ifdef FEATURE_WLAN_WAPI
3279static tANI_BOOLEAN csrMatchWapiOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3280 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3281 tANI_U8 Oui[] )
3282{
3283 return( csrIsWapiOuiMatch( pMac, AllCyphers, cAllCyphers, csrWapiOui[ouiIndex], Oui ) );
3284
3285}
3286#endif /* FEATURE_WLAN_WAPI */
3287
3288static tANI_BOOLEAN csrMatchWPAOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3289 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3290 tANI_U8 Oui[] )
3291{
3292 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui[ouiIndex], Oui ) );
3293
3294}
3295
3296#if 0
3297static tANI_BOOLEAN csrIsRSNUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3298 tANI_U8 cAllCyphers,
3299 tANI_U8 Oui[] )
3300{
3301 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui00, Oui ) );
3302}
3303
3304static tANI_BOOLEAN csrIsRSNMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3305 tANI_U8 cAllCyphers,
3306 tANI_U8 Oui[] )
3307{
3308 tANI_BOOLEAN fYes = FALSE;
3309
3310 // Check Wep 104 first, if fails, then check Wep40.
3311 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui05, Oui );
3312
3313 if ( !fYes )
3314 {
3315 // if not Wep-104, check Wep-40
3316 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui01, Oui );
3317 }
3318
3319 return( fYes );
3320}
3321
3322
3323static tANI_BOOLEAN csrIsRSNUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3324 tANI_U8 cAllCyphers,
3325 tANI_U8 Oui[] )
3326{
3327 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3328}
3329
3330
3331static tANI_BOOLEAN csrIsRSNMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3332 tANI_U8 cAllCyphers,
3333 tANI_U8 Oui[] )
3334{
3335 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3336}
3337
3338static tANI_BOOLEAN csrIsRSNUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3339 tANI_U8 cAllCyphers,
3340 tANI_U8 Oui[] )
3341{
3342 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3343}
3344
3345static tANI_BOOLEAN csrIsRSNMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3346 tANI_U8 cAllCyphers,
3347 tANI_U8 Oui[] )
3348{
3349 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3350}
3351#endif
3352#ifdef FEATURE_WLAN_WAPI
3353static tANI_BOOLEAN csrIsAuthWapiCert( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3354 tANI_U8 cAllSuites,
3355 tANI_U8 Oui[] )
3356{
3357 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[1], Oui ) );
3358}
3359static tANI_BOOLEAN csrIsAuthWapiPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3360 tANI_U8 cAllSuites,
3361 tANI_U8 Oui[] )
3362{
3363 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[2], Oui ) );
3364}
3365#endif /* FEATURE_WLAN_WAPI */
3366
3367#ifdef WLAN_FEATURE_VOWIFI_11R
3368
3369/*
3370 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3371 * here. This matches for FT Auth with the 802.1X exchange.
3372 *
3373 */
3374static tANI_BOOLEAN csrIsFTAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3375 tANI_U8 cAllSuites,
3376 tANI_U8 Oui[] )
3377{
3378 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[03], Oui ) );
3379}
3380
3381/*
3382 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3383 * here. This matches for FT Auth with the PSK.
3384 *
3385 */
3386static tANI_BOOLEAN csrIsFTAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3387 tANI_U8 cAllSuites,
3388 tANI_U8 Oui[] )
3389{
3390 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[04], Oui ) );
3391}
3392
3393#endif
3394
3395#ifdef FEATURE_WLAN_CCX
3396
3397/*
3398 * Function for CCX CCKM AKM Authentication. We match the CCKM AKM Authentication Key Management suite
3399 * here. This matches for CCKM AKM Auth with the 802.1X exchange.
3400 *
3401 */
3402static tANI_BOOLEAN csrIsCcxCckmAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3403 tANI_U8 cAllSuites,
3404 tANI_U8 Oui[] )
3405{
3406 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[06], Oui ) );
3407}
3408
3409static tANI_BOOLEAN csrIsCcxCckmAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3410 tANI_U8 cAllSuites,
3411 tANI_U8 Oui[] )
3412{
3413 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[06], Oui ) );
3414}
3415
3416#endif
3417
3418static tANI_BOOLEAN csrIsAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3419 tANI_U8 cAllSuites,
3420 tANI_U8 Oui[] )
3421{
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[01], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003423}
3424static tANI_BOOLEAN csrIsAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3425 tANI_U8 cAllSuites,
3426 tANI_U8 Oui[] )
3427{
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[02], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003429}
3430
Chet Lanctot186b5732013-03-18 10:26:30 -07003431#ifdef WLAN_FEATURE_11W
3432static tANI_BOOLEAN csrIsAuthRSNPskSha256( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3433 tANI_U8 cAllSuites,
3434 tANI_U8 Oui[] )
3435{
Chet Lanctot4c986162013-05-08 13:59:56 -07003436 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[07], Oui );
Chet Lanctot186b5732013-03-18 10:26:30 -07003437}
3438#endif
3439
Jeff Johnson295189b2012-06-20 16:38:30 -07003440static tANI_BOOLEAN csrIsAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3441 tANI_U8 cAllSuites,
3442 tANI_U8 Oui[] )
3443{
3444 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[01], Oui ) );
3445}
3446
3447#ifdef NOT_CURRENTLY_USED
3448static tANI_BOOLEAN csrIsAuth802_1x( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3449 tANI_U8 cAllSuites,
3450 tANI_U8 Oui[] )
3451{
3452 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[00], Oui ) );
3453}
3454#endif // NOT_CURRENTLY_USED
3455
3456static tANI_BOOLEAN csrIsAuthWpaPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3457 tANI_U8 cAllSuites,
3458 tANI_U8 Oui[] )
3459{
3460 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[02], Oui ) );
3461}
3462#if 0
3463static tANI_BOOLEAN csrIsUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3464 tANI_U8 cAllCyphers,
3465 tANI_U8 Oui[] )
3466{
3467 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui00, Oui ) );
3468}
3469
3470static tANI_BOOLEAN csrIsUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3471 tANI_U8 cAllCyphers,
3472 tANI_U8 Oui[] )
3473{
3474 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3475}
3476
3477static tANI_BOOLEAN csrIsUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3478 tANI_U8 cAllCyphers,
3479 tANI_U8 Oui[] )
3480{
3481 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3482}
3483
3484
3485static tANI_BOOLEAN csrIsMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3486 tANI_U8 cAllCyphers,
3487 tANI_U8 Oui[] )
3488{
3489 tANI_BOOLEAN fYes = FALSE;
3490
3491 // Check Wep 104 first, if fails, then check Wep40.
3492 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui05, Oui );
3493
3494 if ( !fYes )
3495 {
3496 // if not Wep-104, check Wep-40
3497 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui01, Oui );
3498 }
3499
3500 return( fYes );
3501}
3502
3503
3504static tANI_BOOLEAN csrIsMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3505 tANI_U8 cAllCyphers,
3506 tANI_U8 Oui[] )
3507{
3508 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3509}
3510
3511
3512static tANI_BOOLEAN csrIsMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3513 tANI_U8 cAllCyphers,
3514 tANI_U8 Oui[] )
3515{
3516 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3517}
3518
3519#endif
3520
3521tANI_U8 csrGetOUIIndexFromCipher( eCsrEncryptionType enType )
3522{
3523 tANI_U8 OUIIndex;
3524
3525 switch ( enType )
3526 {
3527 case eCSR_ENCRYPT_TYPE_WEP40:
3528 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3529 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX;
3530 break;
3531 case eCSR_ENCRYPT_TYPE_WEP104:
3532 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3533 OUIIndex = CSR_OUI_WEP104_INDEX;
3534 break;
3535 case eCSR_ENCRYPT_TYPE_TKIP:
3536 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX;
3537 break;
3538 case eCSR_ENCRYPT_TYPE_AES:
3539 OUIIndex = CSR_OUI_AES_INDEX;
3540 break;
3541 case eCSR_ENCRYPT_TYPE_NONE:
3542 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX;
3543 break;
3544#ifdef FEATURE_WLAN_WAPI
3545 case eCSR_ENCRYPT_TYPE_WPI:
3546 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX;
3547 break;
3548#endif /* FEATURE_WLAN_WAPI */
3549 default: //HOWTO handle this?
3550 OUIIndex = CSR_OUI_RESERVED_INDEX;
3551 break;
3552 }//switch
3553
3554 return OUIIndex;
3555}
3556
3557tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3558 tDot11fIERSN *pRSNIe,
3559 tANI_U8 *UnicastCypher,
3560 tANI_U8 *MulticastCypher,
3561 tANI_U8 *AuthSuite,
3562 tCsrRSNCapabilities *Capabilities,
3563 eCsrAuthType *pNegotiatedAuthtype,
3564 eCsrEncryptionType *pNegotiatedMCCipher )
3565{
3566 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3567 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3568 tANI_U8 cUnicastCyphers = 0;
3569 tANI_U8 cMulticastCyphers = 0;
3570 tANI_U8 cAuthSuites = 0, i;
3571 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3572 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3573 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3574 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3575 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3576 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3577
3578 do{
3579 if ( pRSNIe->present )
3580 {
3581 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303582 vos_mem_copy(MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
3584 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_count);
3585 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3586 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303587 vos_mem_copy((void *)&AuthSuites[i],
3588 (void *)&pRSNIe->akm_suites[i],
3589 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 }
3591
3592 //Check - Is requested Unicast Cipher supported by the BSS.
3593 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3594 csrGetOUIIndexFromCipher( enType ), Unicast );
3595
3596 if( !fAcceptableCyphers ) break;
3597
3598
3599 //Unicast is supported. Pick the first matching Group cipher, if any.
3600 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3601 {
3602 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3603 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3604 if(fAcceptableCyphers)
3605 {
3606 break;
3607 }
3608 }
3609 if( !fAcceptableCyphers ) break;
3610
3611 if( pNegotiatedMCCipher )
3612 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3613
3614 /* Initializing with FALSE as it has TRUE value already */
3615 fAcceptableCyphers = FALSE;
3616 for (i = 0 ; i < pAuthType->numEntries; i++)
3617 {
3618 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3619 #ifdef WLAN_FEATURE_VOWIFI_11R
3620 /* Changed the AKM suites according to order of preference */
3621 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3622 {
3623 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3624 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3625 }
3626 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3627 {
3628 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3629 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3630 }
3631#endif
3632#ifdef FEATURE_WLAN_CCX
3633 /* CCX only supports 802.1X. No PSK. */
3634 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsCcxCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3635 {
3636 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3637 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3638 }
3639#endif
3640 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3641 {
3642 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3643 negAuthType = eCSR_AUTH_TYPE_RSN;
3644 }
3645 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3646 {
3647 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3648 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3649 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003650#ifdef WLAN_FEATURE_11W
3651 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3652 {
3653 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3654 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3655 }
3656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003657
3658 // The 1st auth type in the APs RSN IE, to match stations connecting
3659 // profiles auth type will cause us to exit this loop
3660 // This is added as some APs advertise multiple akms in the RSN IE.
3661 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3662 {
3663 fAcceptableCyphers = TRUE;
3664 break;
3665 }
3666 } // for
3667 }
3668
3669 }while (0);
3670
3671 if ( fAcceptableCyphers )
3672 {
3673 if ( MulticastCypher )
3674 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303675 vos_mem_copy(MulticastCypher, Multicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 }
3677
3678 if ( UnicastCypher )
3679 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303680 vos_mem_copy(UnicastCypher, Unicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 }
3682
3683 if ( AuthSuite )
3684 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303685 vos_mem_copy(AuthSuite, Authentication, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 }
3687
3688 if ( pNegotiatedAuthtype )
3689 {
3690 *pNegotiatedAuthtype = negAuthType;
3691 }
3692 if ( Capabilities )
3693 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003694 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3695 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3696 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003697 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003698 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3699 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
Chet Lanctot186b5732013-03-18 10:26:30 -07003700 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 }
3702 }
3703 return( fAcceptableCyphers );
3704}
3705
3706
3707tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
3708 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
3709{
3710 tANI_BOOLEAN fRSNMatch = FALSE;
3711
3712 // See if the cyphers in the Bss description match with the settings in the profile.
3713 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
3714 pNegotiatedAuthType, pNegotiatedMCCipher );
3715
3716 return( fRSNMatch );
3717}
3718
3719
3720tANI_BOOLEAN csrLookupPMKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pPMKId )
3721{
3722 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
3723 tANI_U32 Index;
3724 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3725
Jeff Johnson32d95a32012-09-10 13:15:23 -07003726 if(!pSession)
3727 {
3728 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3729 return FALSE;
3730 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003731 /* to force the AP initiate fresh 802.1x authentication after re-association should not
3732 * fill the PMKID from cache this is needed
3733 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
3734
3735 if(pSession->fIgnorePMKIDCache)
3736 {
3737 pSession->fIgnorePMKIDCache = FALSE;
3738 return fRC;
3739 }
3740
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 do
3742 {
3743 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
3744 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08003745 smsLog(pMac, LOGW, "match PMKID "MAC_ADDRESS_STR " to ",
3746 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05303747 if( vos_mem_compare(pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 {
3749 // match found
3750 fMatchFound = TRUE;
3751 break;
3752 }
3753 }
3754
3755 if( !fMatchFound ) break;
3756
Kiet Lam64c1b492013-07-12 13:56:44 +05303757 vos_mem_copy(pPMKId, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003758
3759 fRC = TRUE;
3760 }
3761 while( 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003762 smsLog(pMac, LOGW, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 fRC, pSession->NumPmkidCache);
3764
3765 return fRC;
3766}
3767
3768
3769tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3770 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
3771{
3772 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3773 tANI_BOOLEAN fRSNMatch;
3774 tANI_U8 cbRSNIe = 0;
3775 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
3776 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
3777 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
3778 tCsrRSNAuthIe *pAuthSuite;
3779 tCsrRSNCapabilities RSNCapabilities;
3780 tCsrRSNPMKIe *pPMK;
3781 tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003782#ifdef WLAN_FEATURE_11W
3783 tANI_U8 *pGroupMgmtCipherSuite;
3784#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 tDot11fBeaconIEs *pIesLocal = pIes;
3786
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003787 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003788
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 do
3790 {
3791 if ( !csrIsProfileRSN( pProfile ) ) break;
3792
3793 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
3794 {
3795 break;
3796 }
3797
3798 // See if the cyphers in the Bss description match with the settings in the profile.
3799 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
3800 &pProfile->mcEncryptionType, &pIesLocal->RSN,
3801 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, NULL, NULL );
3802 if ( !fRSNMatch ) break;
3803
3804 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
3805
3806 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
3807
Kiet Lam64c1b492013-07-12 13:56:44 +05303808 vos_mem_copy(pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003809
3810 pRSNIe->cUnicastCyphers = 1;
3811
Kiet Lam64c1b492013-07-12 13:56:44 +05303812 vos_mem_copy(&pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003813
3814 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
3815
3816 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05303817 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003818
3819 // RSN capabilities follows the Auth Suite (two octects)
3820 // !!REVIEW - What should STA put in RSN capabilities, currently
3821 // just putting back APs capabilities
3822 // 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 -07003823 // For another, we should use the Management Frame Protection values given by the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 RSNCapabilities.PreAuthSupported = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003825#ifdef WLAN_FEATURE_11W
3826 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
3827 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
3828#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
3830
3831 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
3832
3833 if( csrLookupPMKID( pMac, sessionId, pSirBssDesc->bssId, &(PMKId[0]) ) )
3834 {
3835 pPMK->cPMKIDs = 1;
3836
Kiet Lam64c1b492013-07-12 13:56:44 +05303837 vos_mem_copy(pPMK->PMKIDList[0].PMKID, PMKId, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 }
3839 else
3840 {
3841 pPMK->cPMKIDs = 0;
3842 }
3843
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003844#ifdef WLAN_FEATURE_11W
3845 if ( pProfile->MFPEnabled )
3846 {
3847 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
3848 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
Kiet Lam64c1b492013-07-12 13:56:44 +05303849 vos_mem_copy(pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE);
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003850 }
3851#endif
3852
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
3854 // Add in the size of the Auth suite (count plus a single OUI)
3855 // Add in the RSN caps field.
3856 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003857 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
3859 sizeof( *pAuthSuite ) +
3860 sizeof( tCsrRSNCapabilities ));
3861 if(pPMK->cPMKIDs)
3862 {
3863 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
3864 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
3865 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003866#ifdef WLAN_FEATURE_11W
3867 if ( pProfile->MFPEnabled )
3868 {
3869 if ( 0 == pPMK->cPMKIDs )
3870 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
3871 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
3872 }
3873#endif
3874
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 // return the size of the IE header (total) constructed...
3876 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
3877
3878 } while( 0 );
3879
3880 if( !pIes && pIesLocal )
3881 {
3882 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05303883 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 }
3885
3886 return( cbRSNIe );
3887}
3888
3889
3890#ifdef FEATURE_WLAN_WAPI
3891tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3892 tDot11fIEWAPI *pWapiIe,
3893 tANI_U8 *UnicastCypher,
3894 tANI_U8 *MulticastCypher,
3895 tANI_U8 *AuthSuite,
3896 eCsrAuthType *pNegotiatedAuthtype,
3897 eCsrEncryptionType *pNegotiatedMCCipher )
3898{
3899 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3900 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3901 tANI_U8 cUnicastCyphers = 0;
3902 tANI_U8 cMulticastCyphers = 0;
3903 tANI_U8 cAuthSuites = 0, i;
3904 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
3905 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
3906 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
3907 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
3908 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
3909 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3910
3911 do{
3912 if ( pWapiIe->present )
3913 {
3914 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303915 vos_mem_copy(MulticastCyphers, pWapiIe->multicast_cipher_suite,
3916 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
3918 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
3919 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
3920 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303921 vos_mem_copy((void *)&AuthSuites[i], (void *)&pWapiIe->akm_suites[i],
3922 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 }
3924
3925 //Check - Is requested Unicast Cipher supported by the BSS.
3926 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
3927 csrGetOUIIndexFromCipher( enType ), Unicast );
3928
3929 if( !fAcceptableCyphers ) break;
3930
3931
3932 //Unicast is supported. Pick the first matching Group cipher, if any.
3933 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3934 {
3935 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3936 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3937 if(fAcceptableCyphers)
3938 {
3939 break;
3940 }
3941 }
3942 if( !fAcceptableCyphers ) break;
3943
3944 if( pNegotiatedMCCipher )
3945 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3946
3947 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3948 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
3949 {
3950 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3951 }
3952 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3953 {
3954 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3955 }
3956 else
3957 {
3958 fAcceptableCyphers = FALSE;
3959 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3960 }
3961 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
3962 {
3963 //Caller doesn't care about auth type, or BSS doesn't match
3964 break;
3965 }
3966 fAcceptableCyphers = FALSE;
3967 for( i = 0 ; i < pAuthType->numEntries; i++ )
3968 {
3969 if( pAuthType->authType[i] == negAuthType )
3970 {
3971 fAcceptableCyphers = TRUE;
3972 break;
3973 }
3974 }
3975 }
3976 }while (0);
3977
3978 if ( fAcceptableCyphers )
3979 {
3980 if ( MulticastCypher )
3981 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303982 vos_mem_copy(MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 }
3984
3985 if ( UnicastCypher )
3986 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303987 vos_mem_copy(UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 }
3989
3990 if ( AuthSuite )
3991 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303992 vos_mem_copy(AuthSuite, Authentication, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 }
3994
3995 if ( pNegotiatedAuthtype )
3996 {
3997 *pNegotiatedAuthtype = negAuthType;
3998 }
3999 }
4000 return( fAcceptableCyphers );
4001}
4002
4003tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4004 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
4005{
4006 tANI_BOOLEAN fWapiMatch = FALSE;
4007
4008 // See if the cyphers in the Bss description match with the settings in the profile.
4009 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4010 pNegotiatedAuthType, pNegotiatedMCCipher );
4011
4012 return( fWapiMatch );
4013}
4014
4015tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4016{
4017 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4018 tANI_U32 Index;
4019 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4020
Jeff Johnson32d95a32012-09-10 13:15:23 -07004021 if(!pSession)
4022 {
4023 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4024 return FALSE;
4025 }
4026
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 do
4028 {
4029 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4030 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004031 smsLog(pMac, LOGW, "match BKID "MAC_ADDRESS_STR" to ",
4032 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05304033 if (vos_mem_compare(pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 {
4035 // match found
4036 fMatchFound = TRUE;
4037 break;
4038 }
4039 }
4040
4041 if( !fMatchFound ) break;
4042
Kiet Lam64c1b492013-07-12 13:56:44 +05304043 vos_mem_copy(pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004044
4045 fRC = TRUE;
4046 }
4047 while( 0 );
4048 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4049
4050 return fRC;
4051}
4052
4053tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4054 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4055{
4056 tANI_BOOLEAN fWapiMatch = FALSE;
4057 tANI_U8 cbWapiIe = 0;
4058 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4059 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4060 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4061 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4062 tANI_U8 *pWapi = NULL;
4063 tANI_BOOLEAN fBKIDFound = FALSE;
4064 tDot11fBeaconIEs *pIesLocal = pIes;
4065
4066 do
4067 {
4068 if ( !csrIsProfileWapi( pProfile ) ) break;
4069
4070 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4071 {
4072 break;
4073 }
4074
4075 // See if the cyphers in the Bss description match with the settings in the profile.
4076 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4077 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4078 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4079 if ( !fWapiMatch ) break;
4080
Kiet Lam64c1b492013-07-12 13:56:44 +05304081 vos_mem_set(pWapiIe, sizeof(tCsrWapiIe), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004082
4083 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4084
4085 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4086
4087 pWapiIe->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304088 vos_mem_copy(&pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004089
4090 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4091
4092 *pWapi = (tANI_U16)1; //cUnicastCyphers
4093 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304094 vos_mem_copy(pWapi, UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 pWapi += sizeof( UnicastCypher );
4096
Kiet Lam64c1b492013-07-12 13:56:44 +05304097 vos_mem_copy(pWapi, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 pWapi += sizeof( MulticastCypher );
4099
4100
4101 // WAPI capabilities follows the Auth Suite (two octects)
4102 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4103 // & since we already did a memset pWapiIe to 0, skip these fields
4104 pWapi +=2;
4105
4106 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4107
4108
4109 if( fBKIDFound )
4110 {
4111 /* Do we need to change the endianness here */
4112 *pWapi = (tANI_U16)1; //cBKIDs
4113 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304114 vos_mem_copy(pWapi, BKId, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 }
4116 else
4117 {
4118 *pWapi = 0;
4119 pWapi+=1;
4120 *pWapi = 0;
4121 pWapi+=1;
4122 }
4123
4124 // Add in the IE fields except the IE header
4125 // Add BKID count and BKID (if any)
4126 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4127
4128 /*2 bytes for BKID Count field*/
4129 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4130
4131 if(fBKIDFound)
4132 {
4133 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4134 }
4135 // return the size of the IE header (total) constructed...
4136 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4137
4138 } while( 0 );
4139
4140 if( !pIes && pIesLocal )
4141 {
4142 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304143 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 }
4145
4146 return( cbWapiIe );
4147}
4148#endif /* FEATURE_WLAN_WAPI */
4149
4150tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4151 tDot11fIEWPA *pWpaIe,
4152 tANI_U8 *UnicastCypher,
4153 tANI_U8 *MulticastCypher,
4154 tANI_U8 *AuthSuite,
4155 eCsrAuthType *pNegotiatedAuthtype,
4156 eCsrEncryptionType *pNegotiatedMCCipher )
4157{
4158 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4159 tANI_U8 cUnicastCyphers = 0;
4160 tANI_U8 cMulticastCyphers = 0;
4161 tANI_U8 cAuthSuites = 0;
4162 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4163 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4164 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4165 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4166 tANI_U8 i;
4167 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4168
4169 do
4170 {
4171 if ( pWpaIe->present )
4172 {
4173 cMulticastCyphers = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304174 vos_mem_copy(MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4176 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4177
4178 //Check - Is requested Unicast Cipher supported by the BSS.
4179 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4180 csrGetOUIIndexFromCipher( enType ), Unicast );
4181
4182 if( !fAcceptableCyphers ) break;
4183
4184
4185 //Unicast is supported. Pick the first matching Group cipher, if any.
4186 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4187 {
4188 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4189 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4190 if(fAcceptableCyphers)
4191 {
4192 break;
4193 }
4194 }
4195 if( !fAcceptableCyphers ) break;
4196
4197 if( pNegotiatedMCCipher )
4198 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4199
4200 /* Initializing with FALSE as it has TRUE value already */
4201 fAcceptableCyphers = FALSE;
4202 for (i = 0 ; i < pAuthType->numEntries; i++)
4203 {
4204 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4205 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4206 {
4207 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4208 negAuthType = eCSR_AUTH_TYPE_WPA;
4209 }
4210 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4211 {
4212 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4213 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4214 }
4215#ifdef FEATURE_WLAN_CCX
4216 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsCcxCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4217 {
4218 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4219 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4220 }
4221#endif /* FEATURE_WLAN_CCX */
4222
4223 // The 1st auth type in the APs WPA IE, to match stations connecting
4224 // profiles auth type will cause us to exit this loop
4225 // This is added as some APs advertise multiple akms in the WPA IE.
4226 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4227 {
4228 fAcceptableCyphers = TRUE;
4229 break;
4230 }
4231 } // for
4232 }
4233 }while(0);
4234
4235 if ( fAcceptableCyphers )
4236 {
4237 if ( MulticastCypher )
4238 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304239 vos_mem_copy((tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 }
4241
4242 if ( UnicastCypher )
4243 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304244 vos_mem_copy((tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 }
4246
4247 if ( AuthSuite )
4248 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304249 vos_mem_copy((tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 }
4251
4252 if( pNegotiatedAuthtype )
4253 {
4254 *pNegotiatedAuthtype = negAuthType;
4255 }
4256 }
4257
4258 return( fAcceptableCyphers );
4259}
4260
4261
4262
4263tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4264 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4265{
4266 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4267
4268 // See if the cyphers in the Bss description match with the settings in the profile.
4269 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4270
4271 return( fWpaMatch );
4272}
4273
4274
4275tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4276 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4277{
4278 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4279 tANI_BOOLEAN fWpaMatch;
4280 tANI_U8 cbWpaIe = 0;
4281 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4282 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4283 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4284 tCsrWpaAuthIe *pAuthSuite;
4285 tDot11fBeaconIEs *pIesLocal = pIes;
4286
4287 do
4288 {
4289 if ( !csrIsProfileWpa( pProfile ) ) break;
4290
4291 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4292 {
4293 break;
4294 }
4295 // See if the cyphers in the Bss description match with the settings in the profile.
4296 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4297 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4298 if ( !fWpaMatch ) break;
4299
4300 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4301
Kiet Lam64c1b492013-07-12 13:56:44 +05304302 vos_mem_copy(pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004303
4304 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4305
Kiet Lam64c1b492013-07-12 13:56:44 +05304306 vos_mem_copy(pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004307
4308 pWpaIe->cUnicastCyphers = 1;
4309
Kiet Lam64c1b492013-07-12 13:56:44 +05304310 vos_mem_copy(&pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004311
4312 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4313
4314 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304315 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004316
4317 // The WPA capabilities follows the Auth Suite (two octects)--
4318 // this field is optional, and we always "send" zero, so just
4319 // remove it. This is consistent with our assumptions in the
4320 // frames compiler; c.f. bug 15234:
4321 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4322
4323 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4324 // Add in the size of the Auth suite (count plus a single OUI)
4325 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4326 sizeof( *pAuthSuite );
4327
4328 // return the size of the IE header (total) constructed...
4329 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4330
4331 } while( 0 );
4332
4333 if( !pIes && pIesLocal )
4334 {
4335 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304336 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 }
4338
4339 return( cbWpaIe );
4340}
4341
4342
4343tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4344 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4345{
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 tDot11IEHeader *pIEHeader;
4347 tSirMacPropIE *pSirMacPropIE;
4348 tANI_U32 cbParsed;
4349 tANI_U32 cbIE;
4350 int cExpectedIEs = 0;
4351 int cFoundIEs = 0;
4352 int cbPropIETotal;
4353
4354 pIEHeader = (tDot11IEHeader *)pIes;
4355 if(pWpaIe) cExpectedIEs++;
4356 if(pRSNIe) cExpectedIEs++;
4357
4358 // bss description length includes all fields other than the length itself
4359 cbParsed = 0;
4360
4361 // Loop as long as there is data left in the IE of the Bss Description
4362 // and the number of Expected IEs is NOT found yet.
4363 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4364 {
4365 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4366
4367 if ( ( cbIE + cbParsed ) > len ) break;
4368
4369 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4370 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4371 {
4372 switch( pIEHeader->ElementID )
4373 {
4374 // Parse the 221 (0xdd) Proprietary IEs here...
4375 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4376 // Airgo proprietary IE information.
4377 case SIR_MAC_WPA_EID:
4378 {
4379 tANI_U32 aniOUI;
4380 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4381
4382 pOui++;
4383 aniOUI = ANI_OUI;
4384 aniOUI = i_ntohl( aniOUI );
4385
4386 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4387 cbPropIETotal = pSirMacPropIE->length;
4388
4389 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4390 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4391 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4392 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4393 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4394 {
4395 }
4396 else
4397 {
4398 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4399
4400 if(!pWpaIe || !pcbWpaIe) break;
4401 // Check if this is a valid WPA IE. Then check that the
4402 // WPA OUI is in place and the version is one that we support.
4403 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
Kiet Lam64c1b492013-07-12 13:56:44 +05304404 ( vos_mem_compare( pIe->Oui, (void *)csrWpaOui[1],
4405 sizeof( pIe->Oui ) ) ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4407 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304408 vos_mem_copy(pWpaIe, pIe,
4409 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4411 cFoundIEs++;
4412
4413 break;
4414 }
4415 }
4416
4417 break;
4418 }
4419
4420 case SIR_MAC_RSN_EID:
4421 {
4422 tCsrRSNIe *pIe;
4423
4424 if(!pcbRSNIe || !pRSNIe) break;
4425 pIe = (tCsrRSNIe *)pIEHeader;
4426
4427 // Check the length of the RSN Ie to assure it is valid. Then check that the
4428 // version is one that we support.
4429
4430 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4431 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4432
4433 cFoundIEs++;
4434
4435 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4436 // the buffer passed in.
4437 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05304438 vos_mem_copy(pRSNIe, pIe,
4439 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4441
4442 break;
4443 }
4444
4445 // Add support for other IE here...
4446 default:
4447 break;
4448 }
4449 }
4450
4451 cbParsed += cbIE;
4452
4453 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4454
4455 }
4456
4457 // return a BOOL that tells if all of the IEs asked for were found...
4458 return( cFoundIEs == cExpectedIEs );
4459}
4460
4461
4462//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4463//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4464tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4465 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4466{
4467 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4468 tANI_U8 cbWpaIe = 0;
4469
4470 do
4471 {
4472 if ( !csrIsProfileWpa( pProfile ) ) break;
4473 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4474 {
4475 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4476 {
4477 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304478 vos_mem_copy(pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 }
4480 else
4481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004482 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 }
4484 }
4485 else
4486 {
4487 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4488 }
4489 }while(0);
4490
4491 return (cbWpaIe);
4492}
4493
4494
4495//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4496//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4497tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4498 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4499{
4500 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4501 tANI_U8 cbRsnIe = 0;
4502
4503 do
4504 {
4505 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004506#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304507 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004508 {
4509 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4510 // scratch. So it contains the current PMK-IDs
4511 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4512 }
4513 else
4514#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 if(pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
4516 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004517 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4519 {
4520 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304521 vos_mem_copy(pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 }
4523 else
4524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004525 smsLog(pMac, LOGW, " csrRetrieveRsnIe detect invalid RSN IE length (%d) ", pProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 }
4527 }
4528 else
4529 {
4530 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4531 }
4532 }while(0);
4533
4534 return (cbRsnIe);
4535}
4536
4537
4538#ifdef FEATURE_WLAN_WAPI
4539//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
4540//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
4541tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
4542 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4543 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4544{
4545 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4546 tANI_U8 cbWapiIe = 0;
4547
4548 do
4549 {
4550 if ( !csrIsProfileWapi( pProfile ) ) break;
4551 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
4552 {
4553 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
4554 {
4555 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304556 vos_mem_copy(pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 }
4558 else
4559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004560 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 }
4562 }
4563 else
4564 {
4565 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
4566 }
4567 }while(0);
4568
4569 return (cbWapiIe);
4570}
4571#endif /* FEATURE_WLAN_WAPI */
4572
4573tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
4574{
4575 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4576 tListElem *pEntry;
4577 tANI_U16 i;
4578 tANI_U16 startingChannel;
4579 tANI_BOOLEAN found = FALSE;
4580 tCsrChannelSet *pChannelGroup;
4581
4582 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
4583
4584 while ( pEntry )
4585 {
4586 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
4587 startingChannel = pChannelGroup->firstChannel;
4588 for ( i = 0; i < pChannelGroup->numChannels; i++ )
4589 {
4590 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
4591 {
4592 found = TRUE;
4593 break;
4594 }
4595 }
4596
4597 if ( found )
4598 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304599 vos_mem_copy(returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 break;
4601 }
4602 else
4603 {
4604 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
4605 }
4606 }
4607
4608 return( found );
4609}
4610
4611tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
4612{
4613 tANI_BOOLEAN fSupported = FALSE;
4614 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4615
4616 switch ( nonBasicRate )
4617 {
4618 case eCsrSuppRate_1Mbps:
4619 case eCsrSuppRate_2Mbps:
4620 case eCsrSuppRate_5_5Mbps:
4621 case eCsrSuppRate_11Mbps:
4622 fSupported = TRUE;
4623 break;
4624
4625 default:
4626 break;
4627 }
4628
4629 return( fSupported );
4630}
4631
4632tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
4633{
4634 tANI_BOOLEAN fSupported = FALSE;
4635 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4636
4637 switch ( nonBasicRate )
4638 {
4639 case eCsrSuppRate_6Mbps:
4640 case eCsrSuppRate_9Mbps:
4641 case eCsrSuppRate_12Mbps:
4642 case eCsrSuppRate_18Mbps:
4643 case eCsrSuppRate_24Mbps:
4644 case eCsrSuppRate_36Mbps:
4645 case eCsrSuppRate_48Mbps:
4646 case eCsrSuppRate_54Mbps:
4647 fSupported = TRUE;
4648 break;
4649
4650 default:
4651 break;
4652 }
4653
4654 return( fSupported );
4655}
4656
4657
4658
4659tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
4660{
4661 tAniEdType edType;
4662
4663 switch ( EncryptType )
4664 {
4665 default:
4666 case eCSR_ENCRYPT_TYPE_NONE:
4667 edType = eSIR_ED_NONE;
4668 break;
4669
4670 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4671 case eCSR_ENCRYPT_TYPE_WEP40:
4672 edType = eSIR_ED_WEP40;
4673 break;
4674
4675 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4676 case eCSR_ENCRYPT_TYPE_WEP104:
4677 edType = eSIR_ED_WEP104;
4678 break;
4679
4680 case eCSR_ENCRYPT_TYPE_TKIP:
4681 edType = eSIR_ED_TKIP;
4682 break;
4683
4684 case eCSR_ENCRYPT_TYPE_AES:
4685 edType = eSIR_ED_CCMP;
4686 break;
4687#ifdef FEATURE_WLAN_WAPI
4688 case eCSR_ENCRYPT_TYPE_WPI:
4689 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05304690 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004691#endif
4692#ifdef WLAN_FEATURE_11W
4693 //11w BIP
4694 case eCSR_ENCRYPT_TYPE_AES_CMAC:
4695 edType = eSIR_ED_AES_128_CMAC;
4696 break;
4697#endif
4698 }
4699
4700 return( edType );
4701}
4702
4703
4704//pIes can be NULL
4705tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
4706 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
4707 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
4708 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
4709{
4710 tANI_U32 idx;
4711 tANI_BOOLEAN fMatch = FALSE;
4712 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4713 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4714
4715 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
4716
4717 do
4718 {
4719 //If privacy bit is not set, consider no match
4720 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
4721
4722 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
4723 {
4724 switch( pMCEncryptionList->encryptionType[idx] )
4725 {
4726 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4727 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4728 case eCSR_ENCRYPT_TYPE_WEP40:
4729 case eCSR_ENCRYPT_TYPE_WEP104:
4730 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
4731 */
4732 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
4733 {
4734 fMatch = TRUE;
4735 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
4736 }
4737 break;
4738 default:
4739 fMatch = FALSE;
4740 break;
4741 }
4742 if(fMatch) break;
4743 }
4744
4745 if(!fMatch) break;
4746
4747 for( idx = 0; idx < pAuthList->numEntries; idx++ )
4748 {
4749 switch( pAuthList->authType[idx] )
4750 {
4751 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4752 case eCSR_AUTH_TYPE_SHARED_KEY:
4753 case eCSR_AUTH_TYPE_AUTOSWITCH:
4754 fMatch = TRUE;
4755 negotiatedAuth = pAuthList->authType[idx];
4756 break;
4757 default:
4758 fMatch = FALSE;
4759 }
4760 if (fMatch) break;
4761 }
4762
4763 if(!fMatch) break;
4764 //In case of WPA / WPA2, check whether it supports WEP as well
4765 if(pIes)
4766 {
4767 //Prepare the encryption type for WPA/WPA2 functions
4768 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
4769 {
4770 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4771 }
4772 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
4773 {
4774 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4775 }
4776 //else we can use the encryption type directly
Kiet Lam64c1b492013-07-12 13:56:44 +05304777 if ( pIes->WPA.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304779 fMatch = vos_mem_compare(pIes->WPA.multicast_cipher,
4780 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
4781 CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 if( fMatch ) break;
4783 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304784 if ( pIes->RSN.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304786 fMatch = vos_mem_compare(pIes->RSN.gp_cipher_suite,
4787 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
4788 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 }
4790 }
4791
4792 }while(0);
4793
4794 if( fMatch )
4795 {
4796 if( pNegotiatedAuthType )
4797 *pNegotiatedAuthType = negotiatedAuth;
4798
4799 if( pNegotiatedMCEncryption )
4800 *pNegotiatedMCEncryption = negotiatedMCCipher;
4801 }
4802
4803
4804 return fMatch;
4805}
4806
4807
4808//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
4809tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType, tCsrEncryptionList *pUCEncryptionType, tCsrEncryptionList *pMCEncryptionType,
4810 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
4811 eCsrAuthType *negotiatedAuthtype, eCsrEncryptionType *negotiatedUCCipher, eCsrEncryptionType *negotiatedMCCipher )
4812{
4813 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4814 tANI_BOOLEAN fMatch = FALSE;
4815 tANI_U8 i,idx;
4816 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4817 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4818
4819 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
4820 {
4821 ucCipher = pUCEncryptionType->encryptionType[i];
4822 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
4823 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
4824 // encryption type.
4825 switch ( ucCipher )
4826 {
4827 case eCSR_ENCRYPT_TYPE_NONE:
4828 {
4829 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
4830 // required so we have to reject this Bss.
4831 if ( csrIsPrivacy( pSirBssDesc ) )
4832 {
4833 fMatch = FALSE;
4834 }
4835 else
4836 {
4837 fMatch = TRUE;
4838 }
4839
4840 if ( fMatch )
4841 {
4842 fMatch = FALSE;
4843 //Check Multicast cipher requested and Auth type requested.
4844 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
4845 {
4846 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
4847 {
4848 fMatch = TRUE; //Multicast can only be none.
4849 mcCipher = pMCEncryptionType->encryptionType[idx];
4850 break;
4851 }
4852 }
4853 if (!fMatch) break;
4854
4855 fMatch = FALSE;
4856 //Check Auth list. It should contain AuthOpen.
4857 for( idx = 0 ; idx < authType->numEntries ; idx++ )
4858 {
4859 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
4860 {
4861 fMatch = TRUE;
4862 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4863 break;
4864 }
4865 }
4866 if (!fMatch) break;
4867
4868 }
4869 break;
4870 }
4871
4872 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4873 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4874 // !! might want to check for WEP keys set in the Profile.... ?
4875 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
4876 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
4877 // encryption is not allowed without the Privacy bit turned on.
4878 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4879
4880 break;
4881
4882 // these are all of the WPA encryption types...
4883 case eCSR_ENCRYPT_TYPE_WEP40:
4884 case eCSR_ENCRYPT_TYPE_WEP104:
4885 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4886 break;
4887
4888 case eCSR_ENCRYPT_TYPE_TKIP:
4889 case eCSR_ENCRYPT_TYPE_AES:
4890 {
4891 if(pIes)
4892 {
4893 // First check if there is a RSN match
4894 fMatch = csrIsRSNMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4895 if( !fMatch )
4896 {
4897 // If not RSN, then check if there is a WPA match
4898 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
4899 &negAuthType, &mcCipher );
4900 }
4901 }
4902 else
4903 {
4904 fMatch = FALSE;
4905 }
4906 break;
4907 }
4908#ifdef FEATURE_WLAN_WAPI
4909 case eCSR_ENCRYPT_TYPE_WPI://WAPI
4910 {
4911 if(pIes)
4912 {
4913 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4914 }
4915 else
4916 {
4917 fMatch = FALSE;
4918 }
4919 break;
4920 }
4921#endif /* FEATURE_WLAN_WAPI */
4922 case eCSR_ENCRYPT_TYPE_ANY:
4923 default:
4924 {
4925 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
4926
4927 fMatch = eANI_BOOLEAN_TRUE;
4928 //It is allowed to match anything. Try the more secured ones first.
4929 if(pIes)
4930 {
4931 //Check AES first
4932 ucCipher = eCSR_ENCRYPT_TYPE_AES;
4933 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4934 if(!fMatchAny)
4935 {
4936 //Check TKIP
4937 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
4938 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4939 }
4940#ifdef FEATURE_WLAN_WAPI
4941 if(!fMatchAny)
4942 {
4943 //Check WAPI
4944 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
4945 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4946 }
4947#endif /* FEATURE_WLAN_WAPI */
4948 }
4949 if(!fMatchAny)
4950 {
4951 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
4952 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4953 {
4954 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
4955 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4956 {
4957 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4958 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4959 {
4960 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4961 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4962 {
4963 //It must be open and no encryption
4964 if ( csrIsPrivacy( pSirBssDesc ) )
4965 {
4966 //This is not right
4967 fMatch = eANI_BOOLEAN_FALSE;
4968 }
4969 else
4970 {
4971 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4972 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
4973 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
4974 }
4975 }
4976 }
4977 }
4978 }
4979 }
4980 break;
4981 }
4982 }
4983
4984 }
4985
4986 if( fMatch )
4987 {
4988 if( negotiatedUCCipher )
4989 *negotiatedUCCipher = ucCipher;
4990
4991 if( negotiatedMCCipher )
4992 *negotiatedMCCipher = mcCipher;
4993
4994 if( negotiatedAuthtype )
4995 *negotiatedAuthtype = negAuthType;
4996 }
4997
4998 return( fMatch );
4999}
5000
5001
5002tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
5003 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
5004{
5005 tANI_BOOLEAN fMatch = FALSE;
5006
5007 do {
5008
5009 // There are a few special cases. If the Bss description has a Broadcast SSID,
5010 // then our Profile must have a single SSID without Wildcards so we can program
5011 // the SSID.
5012 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5013 // but the SSID value is all NULL characters. That condition is trated same
5014 // as NULL SSID
5015 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5016 {
5017 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5018 {
5019 fMatch = TRUE;
5020 }
5021 break;
5022 }
5023
5024 // Check for the specification of the Broadcast SSID at the beginning of the list.
5025 // If specified, then all SSIDs are matches (broadcast SSID means accept all SSIDs).
5026 if ( ssid1Len == 0 )
5027 {
5028 fMatch = TRUE;
5029 break;
5030 }
5031
5032 if(ssid1Len != bssSsidLen) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05305033 if (vos_mem_compare(bssSsid, ssid1, bssSsidLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 {
5035 fMatch = TRUE;
5036 break;
5037 }
5038
5039 } while( 0 );
5040
5041 return( fMatch );
5042}
5043
5044
5045//Null ssid means match
5046tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5047{
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 tANI_BOOLEAN fMatch = FALSE;
5049 tANI_U32 i;
5050
5051 if ( pSsidList && pSsid )
5052 {
5053 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5054 {
5055 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
Kiet Lam64c1b492013-07-12 13:56:44 +05305056 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5057 vos_mem_compare(pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 {
5059 fMatch = TRUE;
5060 break;
5061 }
5062 }
5063 }
5064
5065 return (fMatch);
5066}
5067
5068//like to use sirCompareMacAddr
5069tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5070{
5071 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5072
Kiet Lam64c1b492013-07-12 13:56:44 +05305073 return (vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005074}
5075
5076//like to use sirCompareMacAddr
5077tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5078{
5079 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5080
Kiet Lam64c1b492013-07-12 13:56:44 +05305081 return(vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005082}
5083
5084
5085//like to use sirCompareMacAddr
5086tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5087{
Kiet Lam64c1b492013-07-12 13:56:44 +05305088 return(vos_mem_compare(pMacAddr1, pMacAddr2, sizeof(tCsrBssid)));
Jeff Johnson295189b2012-06-20 16:38:30 -07005089}
5090
5091
5092tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5093{
5094 tANI_BOOLEAN fMatch = FALSE;
5095 tCsrBssid ProfileBssid;
5096 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5097
5098 // for efficiency of the MAC_ADDRESS functions, move the
5099 // Bssid's into MAC_ADDRESS structs.
Kiet Lam64c1b492013-07-12 13:56:44 +05305100 vos_mem_copy(&ProfileBssid, pProfBssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005101
5102 do {
5103
5104 // Give the profile the benefit of the doubt... accept either all 0 or
5105 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5106 // match any Bssids).
5107 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5108 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5109 {
5110 fMatch = TRUE;
5111 break;
5112 }
5113
5114 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5115 {
5116 fMatch = TRUE;
5117 break;
5118 }
5119
5120 } while( 0 );
5121
5122 return( fMatch );
5123}
5124
5125
5126tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5127{
5128 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5129 return eANI_BOOLEAN_FALSE;
5130 else
5131 return eANI_BOOLEAN_TRUE;
5132}
5133
5134
5135tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5136{
5137 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5138}
5139
5140tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5141{
5142 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5143}
5144
5145tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5146{
5147 tANI_BOOLEAN fMatch = TRUE;
5148
5149 do
5150 {
5151 switch( bssType )
5152 {
5153 case eCSR_BSS_TYPE_ANY:
5154 break;
5155
5156 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5157 case eCSR_BSS_TYPE_WDS_STA:
5158 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5159 fMatch = FALSE;
5160
5161 break;
5162
5163 case eCSR_BSS_TYPE_IBSS:
5164 case eCSR_BSS_TYPE_START_IBSS:
5165 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5166 fMatch = FALSE;
5167
5168 break;
5169
5170 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5171 default:
5172 fMatch = FALSE;
5173 break;
5174 }
5175 }
5176 while( 0 );
5177
5178
5179 return( fMatch );
5180}
5181
5182static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5183{
5184 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5185}
5186
5187
5188
5189static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5190{
5191 tANI_BOOLEAN fMatch = TRUE;
5192
5193 do
5194 {
5195 // if the channel is ANY, then always match...
5196 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5197 if ( Channel == pSirBssDesc->channelId ) break;
5198
5199 // didn't match anything.. so return NO match
5200 fMatch = FALSE;
5201
5202 } while( 0 );
5203
5204 return( fMatch );
5205}
5206
5207
5208tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5209{
5210 tANI_BOOLEAN fMatch = TRUE;
5211
5212 do
5213 {
5214 // if the profile says Any channel AND the global settings says ANY channel, then we
5215 // always match...
5216 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5217
5218 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5219 {
5220 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5221 }
5222
5223 } while( 0 );
5224
5225 return( fMatch );
5226}
5227
5228
5229/**
5230 * \brief Enquire as to whether a given rate is supported by the
5231 * adapter as currently configured
5232 *
5233 *
5234 * \param nRate A rate in units of 500kbps
5235 *
5236 * \return TRUE if the adapter is currently capable of supporting this
5237 * rate, FALSE else
5238 *
5239 *
5240 * The rate encoding is just as in 802.11 Information Elements, except
5241 * that the high bit is \em not interpreted as indicating a Basic Rate,
5242 * and proprietary rates are allowed, too.
5243 *
5244 * Note that if the adapter's dot11Mode is g, we don't restrict the
5245 * rates. According to hwReadEepromParameters, this will happen when:
5246 *
5247 * ... the card is configured for ALL bands through the property
5248 * page. If this occurs, and the card is not an ABG card ,then this
5249 * code is setting the dot11Mode to assume the mode that the
5250 * hardware can support. For example, if the card is an 11BG card
5251 * and we are configured to support ALL bands, then we change the
5252 * dot11Mode to 11g because ALL in this case is only what the
5253 * hardware can support.
5254 *
5255 *
5256 */
5257
5258static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5259{
5260 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5261 tANI_U16 idx, newRate;
5262
5263 //In case basic rate flag is set
5264 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5265 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5266 {
5267 switch ( newRate )
5268 {
5269 case eCsrSuppRate_6Mbps:
5270 case eCsrSuppRate_9Mbps:
5271 case eCsrSuppRate_12Mbps:
5272 case eCsrSuppRate_18Mbps:
5273 case eCsrSuppRate_24Mbps:
5274 case eCsrSuppRate_36Mbps:
5275 case eCsrSuppRate_48Mbps:
5276 case eCsrSuppRate_54Mbps:
5277 fSupported = TRUE;
5278 break;
5279 default:
5280 fSupported = FALSE;
5281 break;
5282 }
5283
5284 }
5285 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5286 {
5287 switch ( newRate )
5288 {
5289 case eCsrSuppRate_1Mbps:
5290 case eCsrSuppRate_2Mbps:
5291 case eCsrSuppRate_5_5Mbps:
5292 case eCsrSuppRate_11Mbps:
5293 fSupported = TRUE;
5294 break;
5295 default:
5296 fSupported = FALSE;
5297 break;
5298 }
5299 }
5300 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5301 {
5302
5303 switch ( newRate )
5304 {
5305 case eCsrSuppRate_1Mbps:
5306 case eCsrSuppRate_2Mbps:
5307 case eCsrSuppRate_5_5Mbps:
5308 case eCsrSuppRate_6Mbps:
5309 case eCsrSuppRate_9Mbps:
5310 case eCsrSuppRate_11Mbps:
5311 case eCsrSuppRate_12Mbps:
5312 case eCsrSuppRate_18Mbps:
5313 case eCsrSuppRate_24Mbps:
5314 case eCsrSuppRate_36Mbps:
5315 case eCsrSuppRate_48Mbps:
5316 case eCsrSuppRate_54Mbps:
5317 fSupported = TRUE;
5318 break;
5319 default:
5320 fSupported = FALSE;
5321 break;
5322 }
5323
5324 }
5325 else {
5326
5327 if ( eCsrSuppRate_1Mbps == newRate ||
5328 eCsrSuppRate_2Mbps == newRate ||
5329 eCsrSuppRate_5_5Mbps == newRate ||
5330 eCsrSuppRate_11Mbps == newRate )
5331 {
5332 fSupported = TRUE;
5333 }
5334 else {
5335 idx = 0x1;
5336
5337 switch ( newRate )
5338 {
5339 case eCsrSuppRate_6Mbps:
5340 fSupported = gPhyRatesSuppt[0][idx];
5341 break;
5342 case eCsrSuppRate_9Mbps:
5343 fSupported = gPhyRatesSuppt[1][idx];
5344 break;
5345 case eCsrSuppRate_12Mbps:
5346 fSupported = gPhyRatesSuppt[2][idx];
5347 break;
5348 case eCsrSuppRate_18Mbps:
5349 fSupported = gPhyRatesSuppt[3][idx];
5350 break;
5351 case eCsrSuppRate_20Mbps:
5352 fSupported = gPhyRatesSuppt[4][idx];
5353 break;
5354 case eCsrSuppRate_24Mbps:
5355 fSupported = gPhyRatesSuppt[5][idx];
5356 break;
5357 case eCsrSuppRate_36Mbps:
5358 fSupported = gPhyRatesSuppt[6][idx];
5359 break;
5360 case eCsrSuppRate_40Mbps:
5361 fSupported = gPhyRatesSuppt[7][idx];
5362 break;
5363 case eCsrSuppRate_42Mbps:
5364 fSupported = gPhyRatesSuppt[8][idx];
5365 break;
5366 case eCsrSuppRate_48Mbps:
5367 fSupported = gPhyRatesSuppt[9][idx];
5368 break;
5369 case eCsrSuppRate_54Mbps:
5370 fSupported = gPhyRatesSuppt[10][idx];
5371 break;
5372 case eCsrSuppRate_72Mbps:
5373 fSupported = gPhyRatesSuppt[11][idx];
5374 break;
5375 case eCsrSuppRate_80Mbps:
5376 fSupported = gPhyRatesSuppt[12][idx];
5377 break;
5378 case eCsrSuppRate_84Mbps:
5379 fSupported = gPhyRatesSuppt[13][idx];
5380 break;
5381 case eCsrSuppRate_96Mbps:
5382 fSupported = gPhyRatesSuppt[14][idx];
5383 break;
5384 case eCsrSuppRate_108Mbps:
5385 fSupported = gPhyRatesSuppt[15][idx];
5386 break;
5387 case eCsrSuppRate_120Mbps:
5388 fSupported = gPhyRatesSuppt[16][idx];
5389 break;
5390 case eCsrSuppRate_126Mbps:
5391 fSupported = gPhyRatesSuppt[17][idx];
5392 break;
5393 case eCsrSuppRate_144Mbps:
5394 fSupported = gPhyRatesSuppt[18][idx];
5395 break;
5396 case eCsrSuppRate_160Mbps:
5397 fSupported = gPhyRatesSuppt[19][idx];
5398 break;
5399 case eCsrSuppRate_168Mbps:
5400 fSupported = gPhyRatesSuppt[20][idx];
5401 break;
5402 case eCsrSuppRate_192Mbps:
5403 fSupported = gPhyRatesSuppt[21][idx];
5404 break;
5405 case eCsrSuppRate_216Mbps:
5406 fSupported = gPhyRatesSuppt[22][idx];
5407 break;
5408 case eCsrSuppRate_240Mbps:
5409 fSupported = gPhyRatesSuppt[23][idx];
5410 break;
5411 default:
5412 fSupported = FALSE;
5413 break;
5414 }
5415 }
5416 }
5417
5418 return fSupported;
5419}
5420
5421
5422
5423static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5424 tDot11fIESuppRates *pBssSuppRates,
5425 tDot11fIEExtSuppRates *pBssExtSuppRates )
5426{
5427 tANI_BOOLEAN fMatch = TRUE;
5428 tANI_U32 i;
5429
5430
5431 // Validate that all of the Basic rates advertised in the Bss description are supported.
5432 if ( pBssSuppRates )
5433 {
5434 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5435 {
5436 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5437 {
5438 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5439 {
5440 fMatch = FALSE;
5441 break;
5442 }
5443 }
5444 }
5445 }
5446
5447 if ( fMatch && pBssExtSuppRates )
5448 {
5449 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5450 {
5451 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5452 {
5453 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5454 {
5455 fMatch = FALSE;
5456 break;
5457 }
5458 }
5459 }
5460 }
5461
5462 return( fMatch );
5463
5464}
5465
5466
5467//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
5468tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
5469 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
5470 tDot11fBeaconIEs **ppIes)
5471{
5472 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5473 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5474 tANI_U32 i;
5475 tDot11fBeaconIEs *pIes = NULL;
5476 tANI_U8 *pb;
5477
5478 do {
5479 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
5480 {
5481 //If no IEs passed in, get our own.
5482 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
5483 {
5484 break;
5485 }
5486 }
5487 else
5488 {
5489 //Save the one pass in for local use
5490 pIes = *ppIes;
5491 }
5492
5493 //Check if caller wants P2P
5494 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
5495 if(!fCheck) break;
5496
5497 if(pIes->SSID.present)
5498 {
5499 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
5500 {
5501 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
5502 pIes->SSID.ssid,
5503 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
5504 if ( fCheck ) break;
5505 }
5506 if(!fCheck) break;
5507 }
5508 fCheck = eANI_BOOLEAN_TRUE;
5509 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
5510 {
5511 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
5512 if ( fCheck ) break;
5513
5514 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
5515 {
5516 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
5517 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
5518
5519 if ( fCheck ) break;
5520 }
5521 }
5522 if(!fCheck) break;
5523
5524 fCheck = eANI_BOOLEAN_TRUE;
5525 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
5526 {
5527 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
5528 if ( fCheck ) break;
5529 }
5530 if(!fCheck)
5531 break;
5532#if defined WLAN_FEATURE_VOWIFI
5533 /* If this is for measurement filtering */
5534 if( pFilter->fMeasurement )
5535 {
5536 fRC = eANI_BOOLEAN_TRUE;
5537 break;
5538 }
5539#endif
5540 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
5541 if ( (!pFilter->bWPSAssociation) &&
5542 !csrIsSecurityMatch( pMac, &pFilter->authType, &pFilter->EncryptionType, &pFilter->mcEncryptionType,
5543 pBssDesc, pIes, pNegAuth, pNegUc, pNegMc ) ) break;
5544 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
5545 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
5546 //Tush-QoS: validate first if asked for APSD or WMM association
5547 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
5548 !CSR_IS_QOS_BSS(pIes) )
5549 break;
5550 //Check country. check even when pb is NULL because we may want to make sure
5551 //AP has a country code in it if fEnforceCountryCodeMatch is set.
5552 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
5553
5554 fCheck = csrMatchCountryCode( pMac, pb, pIes );
5555 if(!fCheck)
5556 break;
5557
5558#ifdef WLAN_FEATURE_VOWIFI_11R
5559 if (pFilter->MDID.mdiePresent)
5560 {
5561 if (pBssDesc->mdiePresent)
5562 {
5563 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
5564 break;
5565 }
5566 else
5567 break;
5568 }
5569#endif
5570 fRC = eANI_BOOLEAN_TRUE;
5571
5572 } while( 0 );
5573 if( ppIes )
5574 {
5575 *ppIes = pIes;
5576 }
5577 else if( pIes )
5578 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305579 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 }
5581
5582 return( fRC );
5583}
5584
5585tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
5586 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
5587{
5588 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
5589 tCsrAuthList authList;
5590
5591 ucEncryptionList.numEntries = 1;
5592 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
5593
5594 mcEncryptionList.numEntries = 1;
5595 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
5596
5597 authList.numEntries = 1;
5598 authList.authType[0] = pProfile->AuthType;
5599
5600 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList, &mcEncryptionList, pBssDesc, pIes, NULL, NULL, NULL ));
5601
5602}
5603
5604
5605tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
5606 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
5607{
5608 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5609 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5610 tDot11fBeaconIEs *pIesLocal = pIes;
5611
5612 do {
5613 if( !pIes )
5614 {
5615 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
5616 {
5617 break;
5618 }
5619 }
5620 fCheck = eANI_BOOLEAN_TRUE;
5621 if(pIesLocal->SSID.present)
5622 {
5623 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
5624 if(pProfile->SSID.length)
5625 {
5626 fCheckSsid = eANI_BOOLEAN_TRUE;
5627 }
5628 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
5629 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
5630 if(!fCheck) break;
5631 }
5632 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
5633 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
5634 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
5635 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
5636 if(!fCheck)
5637 break;
5638
5639 fRC = eANI_BOOLEAN_TRUE;
5640
5641 } while( 0 );
5642
5643 if( !pIes && pIesLocal )
5644 {
5645 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305646 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 }
5648
5649 return( fRC );
5650}
5651
5652
5653
5654tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
5655{
5656 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5657 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
5658
5659 return csrIsAggregateRateSupported( pMac, n );
5660}
5661
5662
5663tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
5664{
5665 tANI_U16 ConvertedRate = Rate;
5666
5667 switch( Rate )
5668 {
5669 case SIR_MAC_RATE_1:
5670 ConvertedRate = 2;
5671 break;
5672 case SIR_MAC_RATE_2:
5673 ConvertedRate = 4;
5674 break;
5675 case SIR_MAC_RATE_5_5:
5676 ConvertedRate = 11;
5677 break;
5678 case SIR_MAC_RATE_11:
5679 ConvertedRate = 22;
5680 break;
5681
5682 case SIR_MAC_RATE_6:
5683 ConvertedRate = 12;
5684 break;
5685 case SIR_MAC_RATE_9:
5686 ConvertedRate = 18;
5687 break;
5688 case SIR_MAC_RATE_12:
5689 ConvertedRate = 24;
5690 break;
5691 case SIR_MAC_RATE_18:
5692 ConvertedRate = 36;
5693 break;
5694 case SIR_MAC_RATE_24:
5695 ConvertedRate = 48;
5696 break;
5697 case SIR_MAC_RATE_36:
5698 ConvertedRate = 72;
5699 break;
5700 case SIR_MAC_RATE_42:
5701 ConvertedRate = 84;
5702 break;
5703 case SIR_MAC_RATE_48:
5704 ConvertedRate = 96;
5705 break;
5706 case SIR_MAC_RATE_54:
5707 ConvertedRate = 108;
5708 break;
5709
5710 case SIR_MAC_RATE_72:
5711 ConvertedRate = 144;
5712 break;
5713 case SIR_MAC_RATE_84:
5714 ConvertedRate = 168;
5715 break;
5716 case SIR_MAC_RATE_96:
5717 ConvertedRate = 192;
5718 break;
5719 case SIR_MAC_RATE_108:
5720 ConvertedRate = 216;
5721 break;
5722 case SIR_MAC_RATE_126:
5723 ConvertedRate = 252;
5724 break;
5725 case SIR_MAC_RATE_144:
5726 ConvertedRate = 288;
5727 break;
5728 case SIR_MAC_RATE_168:
5729 ConvertedRate = 336;
5730 break;
5731 case SIR_MAC_RATE_192:
5732 ConvertedRate = 384;
5733 break;
5734 case SIR_MAC_RATE_216:
5735 ConvertedRate = 432;
5736 break;
5737 case SIR_MAC_RATE_240:
5738 ConvertedRate = 480;
5739 break;
5740
5741 case 0xff:
5742 ConvertedRate = 0;
5743 break;
5744 }
5745
5746 return ConvertedRate;
5747}
5748
5749
5750tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
5751{
5752 tANI_U8 i;
5753 tANI_U16 nBest;
5754
5755 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
5756
5757 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
5758 {
5759 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
5760 }
5761
5762 for ( i = 1U; i < pSuppRates->numRates; ++i )
5763 {
5764 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5765 }
5766
5767 if ( NULL != pExtRates )
5768 {
5769 for ( i = 0U; i < pExtRates->numRates; ++i )
5770 {
5771 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5772 }
5773 }
5774
5775 if ( NULL != pPropRates )
5776 {
5777 for ( i = 0U; i < pPropRates->numPropRates; ++i )
5778 {
5779 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
5780 }
5781 }
5782
5783 return nBest;
5784}
5785
5786
5787void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
5788{
5789 if(pProfile)
5790 {
5791 if(pProfile->BSSIDs.bssid)
5792 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305793 vos_mem_free(pProfile->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 pProfile->BSSIDs.bssid = NULL;
5795 }
5796 if(pProfile->SSIDs.SSIDList)
5797 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305798 vos_mem_free(pProfile->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 pProfile->SSIDs.SSIDList = NULL;
5800 }
5801 if(pProfile->pWPAReqIE)
5802 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305803 vos_mem_free(pProfile->pWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 pProfile->pWPAReqIE = NULL;
5805 }
5806 if(pProfile->pRSNReqIE)
5807 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305808 vos_mem_free(pProfile->pRSNReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 pProfile->pRSNReqIE = NULL;
5810 }
5811#ifdef FEATURE_WLAN_WAPI
5812 if(pProfile->pWAPIReqIE)
5813 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305814 vos_mem_free(pProfile->pWAPIReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 pProfile->pWAPIReqIE = NULL;
5816 }
5817#endif /* FEATURE_WLAN_WAPI */
5818
Agarwal Ashish4f616132013-12-30 23:32:50 +05305819 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05305821 memset(pProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
5822 pProfile->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 }
5824
5825 if(pProfile->pAddIEAssoc)
5826 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305827 vos_mem_free(pProfile->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 pProfile->pAddIEAssoc = NULL;
5829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 if(pProfile->ChannelInfo.ChannelList)
5831 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305832 vos_mem_free(pProfile->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 pProfile->ChannelInfo.ChannelList = NULL;
5834 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305835 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 }
5837}
5838
5839void csrFreeScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
5840{
5841 if(pScanFilter->BSSIDs.bssid)
5842 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305843 vos_mem_free(pScanFilter->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 pScanFilter->BSSIDs.bssid = NULL;
5845 }
5846 if(pScanFilter->ChannelInfo.ChannelList)
5847 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305848 vos_mem_free(pScanFilter->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 pScanFilter->ChannelInfo.ChannelList = NULL;
5850 }
5851 if(pScanFilter->SSIDs.SSIDList)
5852 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305853 vos_mem_free(pScanFilter->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 pScanFilter->SSIDs.SSIDList = NULL;
5855 }
5856}
5857
5858
5859void csrFreeRoamProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
5860{
5861 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
5862
5863 if(pSession->pCurRoamProfile)
5864 {
5865 csrReleaseProfile(pMac, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05305866 vos_mem_free(pSession->pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 pSession->pCurRoamProfile = NULL;
5868 }
5869}
5870
5871
5872void csrFreeConnectBssDesc(tpAniSirGlobal pMac, tANI_U32 sessionId)
5873{
5874 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
5875
5876 if(pSession->pConnectBssDesc)
5877 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305878 vos_mem_free(pSession->pConnectBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 pSession->pConnectBssDesc = NULL;
5880 }
5881}
5882
5883
5884
5885tSirResultCodes csrGetDisassocRspStatusCode( tSirSmeDisassocRsp *pSmeDisassocRsp )
5886{
5887 tANI_U8 *pBuffer = (tANI_U8 *)pSmeDisassocRsp;
5888 tANI_U32 ret;
5889
5890 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
5891 //tSirResultCodes is an enum, assuming is 32bit
5892 //If we cannot make this assumption, use copymemory
5893 pal_get_U32( pBuffer, &ret );
5894
5895 return( ( tSirResultCodes )ret );
5896}
5897
5898
5899tSirResultCodes csrGetDeAuthRspStatusCode( tSirSmeDeauthRsp *pSmeRsp )
5900{
5901 tANI_U8 *pBuffer = (tANI_U8 *)pSmeRsp;
5902 tANI_U32 ret;
5903
5904 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
5905 //tSirResultCodes is an enum, assuming is 32bit
5906 //If we cannot make this assumption, use copymemory
5907 pal_get_U32( pBuffer, &ret );
5908
5909 return( ( tSirResultCodes )ret );
5910}
5911
5912#if 0
5913tSirScanType csrGetScanType(tANI_U8 chnId, eRegDomainId domainId, tANI_U8 *countryCode)
5914{
5915 tSirScanType scanType = eSIR_PASSIVE_SCAN;
5916 tANI_U8 cc = 0;
5917
5918 while (cc++ < gCsrDomainChnInfo[domainId].numChannels)
5919 {
5920 if(chnId == gCsrDomainChnInfo[domainId].chnInfo[cc].chnId)
5921 {
5922 scanType = gCsrDomainChnInfo[domainId].chnInfo[cc].scanType;
5923 break;
5924 }
5925 }
5926
5927 return (scanType);
5928}
5929#endif
5930
5931tSirScanType csrGetScanType(tpAniSirGlobal pMac, tANI_U8 chnId)
5932{
5933 tSirScanType scanType = eSIR_PASSIVE_SCAN;
5934 eNVChannelEnabledType channelEnabledType;
5935
5936 channelEnabledType = vos_nv_getChannelEnabledState(chnId);
5937 if( NV_CHANNEL_ENABLE == channelEnabledType)
5938 {
5939 scanType = eSIR_ACTIVE_SCAN;
5940 }
5941 return (scanType);
5942}
5943
5944
5945tANI_U8 csrToUpper( tANI_U8 ch )
5946{
5947 tANI_U8 chOut;
5948
5949 if ( ch >= 'a' && ch <= 'z' )
5950 {
5951 chOut = ch - 'a' + 'A';
5952 }
5953 else
5954 {
5955 chOut = ch;
5956 }
5957 return( chOut );
5958}
5959
5960
5961tSirBssType csrTranslateBsstypeToMacType(eCsrRoamBssType csrtype)
5962{
5963 tSirBssType ret;
5964
5965 switch(csrtype)
5966 {
5967 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5968 ret = eSIR_INFRASTRUCTURE_MODE;
5969 break;
5970 case eCSR_BSS_TYPE_IBSS:
5971 case eCSR_BSS_TYPE_START_IBSS:
5972 ret = eSIR_IBSS_MODE;
5973 break;
5974 case eCSR_BSS_TYPE_WDS_AP:
5975 ret = eSIR_BTAMP_AP_MODE;
5976 break;
5977 case eCSR_BSS_TYPE_WDS_STA:
5978 ret = eSIR_BTAMP_STA_MODE;
5979 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 case eCSR_BSS_TYPE_INFRA_AP:
5981 ret = eSIR_INFRA_AP_MODE;
5982 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 case eCSR_BSS_TYPE_ANY:
5984 default:
5985 ret = eSIR_AUTO_MODE;
5986 break;
5987 }
5988
5989 return (ret);
5990}
5991
5992
5993//This function use the parameters to decide the CFG value.
5994//CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG
5995//So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value
Jeff Johnson295189b2012-06-20 16:38:30 -07005996eCsrCfgDot11Mode csrGetCfgDot11ModeFromCsrPhyMode(tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tANI_BOOLEAN fProprietary)
Jeff Johnson295189b2012-06-20 16:38:30 -07005997{
5998 tANI_U32 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
5999
6000 switch(phyMode)
6001 {
6002 case eCSR_DOT11_MODE_11a:
6003 case eCSR_DOT11_MODE_11a_ONLY:
6004 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
6005 break;
6006 case eCSR_DOT11_MODE_11b:
6007 case eCSR_DOT11_MODE_11b_ONLY:
6008 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
6009 break;
6010 case eCSR_DOT11_MODE_11g:
6011 case eCSR_DOT11_MODE_11g_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 if(pProfile && (CSR_IS_INFRA_AP(pProfile)) && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
6013 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
6014 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
6016 break;
6017 case eCSR_DOT11_MODE_11n:
6018 if(fProprietary)
6019 {
6020 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6021 }
6022 else
6023 {
6024 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6025 }
6026 break;
6027 case eCSR_DOT11_MODE_11n_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 if(pProfile && CSR_IS_INFRA_AP(pProfile))
6029 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
6030 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6032 break;
6033 case eCSR_DOT11_MODE_TAURUS:
6034 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6035 break;
6036 case eCSR_DOT11_MODE_abg:
6037 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6038 break;
6039 case eCSR_DOT11_MODE_AUTO:
6040 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
6041 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07006042
6043#ifdef WLAN_FEATURE_11AC
6044 case eCSR_DOT11_MODE_11ac:
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006045 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6046 {
6047 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
6048 }
6049 else
6050 {
Ravi Joshia96ceb42013-05-20 18:52:39 -07006051 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006052 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006053 break;
6054 case eCSR_DOT11_MODE_11ac_ONLY:
Ravi Joshia96ceb42013-05-20 18:52:39 -07006055 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6056 {
6057 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
6058 }
6059 else
6060 {
6061 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6062 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006063 break;
6064#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 default:
6066 //No need to assign anything here
6067 break;
6068 }
6069
6070 return (cfgDot11Mode);
6071}
6072
6073
6074eHalStatus csrSetRegulatoryDomain(tpAniSirGlobal pMac, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6075{
6076 eHalStatus status = eHAL_STATUS_SUCCESS;
6077 tANI_BOOLEAN fRestart;
6078
6079 if(pMac->scan.domainIdCurrent == domainId)
6080 {
6081 //no change
6082 fRestart = eANI_BOOLEAN_FALSE;
6083 }
6084 else if( !pMac->roam.configParam.fEnforceDefaultDomain )
6085 {
6086 pMac->scan.domainIdCurrent = domainId;
6087 fRestart = eANI_BOOLEAN_TRUE;
6088 }
6089 else
6090 {
6091 //We cannot change the domain
6092 status = eHAL_STATUS_CSR_WRONG_STATE;
6093 fRestart = eANI_BOOLEAN_FALSE;
6094 }
6095 if(pfRestartNeeded)
6096 {
6097 *pfRestartNeeded = fRestart;
6098 }
6099
6100 return (status);
6101}
6102
6103
6104v_REGDOMAIN_t csrGetCurrentRegulatoryDomain(tpAniSirGlobal pMac)
6105{
6106 return (pMac->scan.domainIdCurrent);
6107}
6108
Jeff Johnson295189b2012-06-20 16:38:30 -07006109
Kiet Lam6c583332013-10-14 05:37:09 +05306110eHalStatus csrGetRegulatoryDomainForCountry
6111(
6112tpAniSirGlobal pMac,
6113tANI_U8 *pCountry,
6114v_REGDOMAIN_t *pDomainId,
6115v_CountryInfoSource_t source
6116)
Jeff Johnson295189b2012-06-20 16:38:30 -07006117{
6118 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6119 VOS_STATUS vosStatus;
6120 v_COUNTRYCODE_t countryCode;
6121 v_REGDOMAIN_t domainId;
6122
6123 if(pCountry)
6124 {
6125 countryCode[0] = pCountry[0];
6126 countryCode[1] = pCountry[1];
Kiet Lam6c583332013-10-14 05:37:09 +05306127 vosStatus = vos_nv_getRegDomainFromCountryCode(&domainId,
6128 countryCode,
6129 source);
6130
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
6132 {
6133 if( pDomainId )
6134 {
6135 *pDomainId = domainId;
6136 }
6137 status = eHAL_STATUS_SUCCESS;
6138 }
6139 else
6140 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006141 smsLog(pMac, LOGW, FL(" doesn't match country %c%c"), pCountry[0], pCountry[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 status = eHAL_STATUS_INVALID_PARAMETER;
6143 }
6144 }
6145
6146 return (status);
6147}
6148
6149//To check whether a country code matches the one in the IE
6150//Only check the first two characters, ignoring in/outdoor
6151//pCountry -- caller allocated buffer contain the country code that is checking against
6152//the one in pIes. It can be NULL.
6153//caller must provide pIes, it cannot be NULL
6154//This function always return TRUE if 11d support is not turned on.
6155tANI_BOOLEAN csrMatchCountryCode( tpAniSirGlobal pMac, tANI_U8 *pCountry, tDot11fBeaconIEs *pIes )
6156{
6157 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson43971f52012-07-17 12:26:56 -07006158 v_REGDOMAIN_t domainId = REGDOMAIN_COUNT; //This is init to invalid value
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 eHalStatus status;
6160
6161 do
6162 {
6163 if( !csrIs11dSupported( pMac) )
6164 {
6165 break;
6166 }
6167 if( !pIes )
6168 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006169 smsLog(pMac, LOGE, FL(" No IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 break;
6171 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006172 if( pMac->roam.configParam.fEnforceDefaultDomain ||
6173 pMac->roam.configParam.fEnforceCountryCodeMatch )
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006175 //Make sure this country is recognizable
6176 if( pIes->Country.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 {
Kiet Lam6c583332013-10-14 05:37:09 +05306178 status = csrGetRegulatoryDomainForCountry(pMac,
6179 pIes->Country.country,
6180 &domainId, COUNTRY_QUERY);
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006181 if( !HAL_STATUS_SUCCESS( status ) )
6182 {
Kiet Lam6c583332013-10-14 05:37:09 +05306183 status = csrGetRegulatoryDomainForCountry(pMac,
6184 pMac->scan.countryCode11d,
6185 (v_REGDOMAIN_t *) &domainId,
6186 COUNTRY_QUERY);
Gowri Deepthiff9adf92012-12-13 15:09:56 -08006187 if( !HAL_STATUS_SUCCESS( status ) )
6188 {
6189 fRet = eANI_BOOLEAN_FALSE;
6190 break;
6191 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006194 //check whether it is needed to enforce to the default regulatory domain first
6195 if( pMac->roam.configParam.fEnforceDefaultDomain )
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006197 if( domainId != pMac->scan.domainIdCurrent )
6198 {
6199 fRet = eANI_BOOLEAN_FALSE;
6200 break;
6201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006203 if( pMac->roam.configParam.fEnforceCountryCodeMatch )
6204 {
Jeff Johnson43971f52012-07-17 12:26:56 -07006205 if( domainId >= REGDOMAIN_COUNT )
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006206 {
6207 fRet = eANI_BOOLEAN_FALSE;
6208 break;
6209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 }
6211 }
6212 if( pCountry )
6213 {
6214 tANI_U32 i;
6215
6216 if( !pIes->Country.present )
6217 {
6218 fRet = eANI_BOOLEAN_FALSE;
6219 break;
6220 }
6221 // Convert the CountryCode characters to upper
6222 for ( i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++ )
6223 {
6224 pCountry[i] = csrToUpper( pCountry[i] );
6225 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306226 if (!vos_mem_compare(pIes->Country.country, pCountry,
6227 WNI_CFG_COUNTRY_CODE_LEN - 1))
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 {
6229 fRet = eANI_BOOLEAN_FALSE;
6230 break;
6231 }
6232 }
6233 } while(0);
6234
6235 return (fRet);
6236}
6237
6238#if 0
6239eHalStatus csrSetCountryDomainMapping(tpAniSirGlobal pMac, tCsrCountryDomainMapping *pCountryDomainMapping)
6240{
6241 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6242 tANI_U32 i, j;
6243 tANI_BOOLEAN fDomainChanged = eANI_BOOLEAN_FALSE;
6244 tANI_U8 countryCode[WNI_CFG_COUNTRY_CODE_LEN];
6245
6246 i = WNI_CFG_COUNTRY_CODE_LEN;
6247 //Get the currently used country code
6248 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, countryCode, &i);
6249 if(HAL_STATUS_SUCCESS(status))
6250 {
6251 if(pCountryDomainMapping && pCountryDomainMapping->numEntry)
6252 {
6253 for(i = 0; i < pCountryDomainMapping->numEntry; i++)
6254 {
6255 for(j = 0; j < eCSR_NUM_COUNTRY_INDEX; j++)
6256 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306257 if (vos_mem_compare(gCsrCountryInfo[j].countryCode,
6258 pCountryDomainMapping->pCountryInfo[i].countryCode,
6259 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 {
6261 if(gCsrCountryInfo[j].domainId != pCountryDomainMapping->pCountryInfo[i].domainId)
6262 {
6263 gCsrCountryInfo[j].domainId = pCountryDomainMapping->pCountryInfo[i].domainId;
6264 //Check whether it matches the currently used country code
6265 //If matching, need to update base on the new domain setting.
Kiet Lam64c1b492013-07-12 13:56:44 +05306266 if (vos_mem_compare(countryCode,
6267 pCountryDomainMapping->pCountryInfo[i].countryCode,
6268 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 {
6270 fDomainChanged = eANI_BOOLEAN_TRUE;
6271 }
6272 }
6273 break;
6274 }
6275 }
6276 }
6277 status = eHAL_STATUS_SUCCESS;
6278 if(fDomainChanged)
6279 {
6280 tCsrChannel *pChannelList;
6281
6282 if(pMac->scan.f11dInfoApplied)
6283 {
6284 //11d info already applied. Let's reapply with the new domain setting
6285 if(pMac->scan.channels11d.numChannels)
6286 {
6287 pChannelList = &pMac->scan.channels11d;
6288 }
6289 else
6290 {
6291 pChannelList = &pMac->scan.base20MHzChannels;
6292 }
6293 }
6294 else
6295 {
6296 //no 11d so we use the base channelist from EEPROM
6297 pChannelList = &pMac->scan.base20MHzChannels;
6298 }
6299 //set the new domain's scan requirement to CFG
6300 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
6301 }
6302 }
6303 }
6304
6305 return (status);
6306}
6307
6308eHalStatus csrSetDomainScanSetting(tpAniSirGlobal pMac, tCsrDomainFreqInfo *pDomainFreqInfo)
6309{
6310 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6311 tANI_U32 i, j;
6312 tANI_U16 freq;
6313
6314 if(pDomainFreqInfo && pDomainFreqInfo->numEntry && (pDomainFreqInfo->domainId < NUM_REG_DOMAINS))
6315 {
6316 tCsrDomainChnInfo *pDomainChnInfo = &gCsrDomainChnInfo[pDomainFreqInfo->domainId];
6317
6318 for(j = 0; j < pDomainChnInfo->numChannels; j++)
6319 {
6320 if(HAL_STATUS_SUCCESS(halPhyChIdToFreqConversion(pDomainChnInfo->chnInfo[j].chnId, &freq)))
6321 {
6322 for(i = 0; i < pDomainFreqInfo->numEntry; i++)
6323 {
6324 if((pDomainFreqInfo->pCsrScanFreqInfo[i].nStartFreq <= freq) &&
6325 (freq <= pDomainFreqInfo->pCsrScanFreqInfo[i].nEndFreq))
6326 {
6327 pDomainChnInfo->chnInfo[j].scanType = pDomainFreqInfo->pCsrScanFreqInfo[i].scanType;
6328 break;
6329 }
6330 }
6331 }
6332 else
6333 {
6334 smsLog(pMac, LOGW, " Failed to get frequency of channel %d", pDomainChnInfo->chnInfo[j].chnId);
6335 }
6336 }
6337 status = eHAL_STATUS_SUCCESS;
6338 }
6339
6340 return (status);
6341}
6342#endif
6343
6344eHalStatus csrGetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6345 tCsrRoamModifyProfileFields *pModifyProfileFields)
6346{
6347
6348 if(!pModifyProfileFields)
6349 {
6350 return eHAL_STATUS_FAILURE;
6351 }
6352
Kiet Lam64c1b492013-07-12 13:56:44 +05306353 vos_mem_copy(pModifyProfileFields,
6354 &pMac->roam.roamSession[sessionId].connectedProfile.modifyProfileFields,
6355 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006356
6357 return eHAL_STATUS_SUCCESS;
6358}
6359
6360eHalStatus csrSetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6361 tCsrRoamModifyProfileFields *pModifyProfileFields)
6362{
6363 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6364
Kiet Lam64c1b492013-07-12 13:56:44 +05306365 vos_mem_copy(&pSession->connectedProfile.modifyProfileFields,
6366 pModifyProfileFields,
6367 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006368
6369 return eHAL_STATUS_SUCCESS;
6370}
6371
6372
6373#if 0
6374/* ---------------------------------------------------------------------------
6375 \fn csrGetSupportedCountryCode
6376 \brief this function is to get a list of the country code current being supported
6377 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6378 this has the country code list. 3 bytes for each country code. This may be NULL if
6379 caller wants to know the needed bytes.
6380 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6381 this contains the length of the data in pBuf
6382 \return eHalStatus
6383 -------------------------------------------------------------------------------*/
6384eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6385{
6386 tANI_U32 numOfCountry = sizeof( gCsrCountryInfo ) / sizeof( gCsrCountryInfo[0] );
6387 tANI_U32 numBytes = 0;
6388 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6389
6390 if( pbLen )
6391 {
6392 numBytes = *pbLen;
6393 //Consider it ok, at least we can return the number of bytes needed;
6394 *pbLen = numOfCountry * WNI_CFG_COUNTRY_CODE_LEN;
6395 status = eHAL_STATUS_SUCCESS;
6396 if( pBuf && ( numBytes >= *pbLen ) )
6397 {
6398 //The ugly part starts.
6399 //We may need to alter the data structure and find a way to make this faster.
6400 tANI_U32 i;
6401
Kiet Lam64c1b492013-07-12 13:56:44 +05306402 for ( i = 0; i < numOfCountry; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306404 vos_mem_copy(pBuf + ( i * WNI_CFG_COUNTRY_CODE_LEN ),
6405 gCsrCountryInfo[i].countryCode,
6406 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 }
6408 }
6409 }
6410
6411 return ( status );
6412}
6413#endif
6414
6415/* ---------------------------------------------------------------------------
6416 \fn csrGetSupportedCountryCode
6417 \brief this function is to get a list of the country code current being supported
6418 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6419 this has the country code list. 3 bytes for each country code. This may be NULL if
6420 caller wants to know the needed bytes.
6421 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6422 this contains the length of the data in pBuf
6423 \return eHalStatus
6424 -------------------------------------------------------------------------------*/
6425eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6426{
6427 eHalStatus status = eHAL_STATUS_SUCCESS;
6428 VOS_STATUS vosStatus;
6429 v_SIZE_t size = (v_SIZE_t)*pbLen;
6430
6431 vosStatus = vos_nv_getSupportedCountryCode( pBuf, &size, 1 );
6432 //eiter way, return the value back
6433 *pbLen = (tANI_U32)size;
6434
6435 //If pBuf is NULL, caller just want to get the size, consider it success
6436 if(pBuf)
6437 {
6438 if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
6439 {
6440 tANI_U32 i, n = *pbLen / 3;
6441
6442 for( i = 0; i < n; i++ )
6443 {
6444 pBuf[i*3 + 2] = ' ';
6445 }
6446 }
6447 else
6448 {
6449 status = eHAL_STATUS_FAILURE;
6450 }
6451 }
6452
6453 return (status);
6454}
6455
6456
6457
6458//Upper layer to get the list of the base channels to scan for passively 11d info from csr
6459eHalStatus csrScanGetBaseChannels( tpAniSirGlobal pMac, tCsrChannelInfo * pChannelInfo )
6460{
6461 eHalStatus status = eHAL_STATUS_FAILURE;
6462
6463 do
6464 {
6465
6466 if(!pMac->scan.baseChannels.numChannels || !pChannelInfo)
6467 {
6468 break;
6469 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306470 pChannelInfo->ChannelList = vos_mem_malloc(pMac->scan.baseChannels.numChannels);
6471 if ( NULL == pChannelInfo->ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006473 smsLog( pMac, LOGE, FL("csrScanGetBaseChannels: fail to allocate memory") );
Kiet Lam64c1b492013-07-12 13:56:44 +05306474 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306476 vos_mem_copy(pChannelInfo->ChannelList,
6477 pMac->scan.baseChannels.channelList,
6478 pMac->scan.baseChannels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 pChannelInfo->numOfChannels = pMac->scan.baseChannels.numChannels;
6480
6481 }while(0);
6482
6483 return ( status );
6484}
6485
6486
6487tANI_BOOLEAN csrIsSetKeyAllowed(tpAniSirGlobal pMac, tANI_U32 sessionId)
6488{
6489 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 tCsrRoamSession *pSession;
6491
6492 pSession =CSR_GET_SESSION(pMac, sessionId);
6493
6494 /*This condition is not working for infra state. When infra is in not-connected state
6495 * the pSession->pCurRoamProfile is NULL. And this function returns TRUE, that is incorrect.
6496 * Since SAP requires to set key without any BSS started, it needs this condition to be met.
6497 * In other words, this function is useless.
6498 * The current work-around is to process setcontext_rsp and removekey_rsp no matter what the
6499 * state is.
6500 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006501 smsLog( pMac, LOG2, FL(" is not what it intends to. Must be revisit or removed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006502 if( (NULL == pSession) ||
6503 ( csrIsConnStateDisconnected( pMac, sessionId ) &&
6504 (pSession->pCurRoamProfile != NULL) &&
6505 (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) )
6506 )
6507 {
6508 fRet = eANI_BOOLEAN_FALSE;
6509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006510
6511 return ( fRet );
6512}
6513
6514//no need to acquire lock for this basic function
6515tANI_U16 sme_ChnToFreq(tANI_U8 chanNum)
6516{
6517 int i;
6518
6519 for (i = 0; i < NUM_RF_CHANNELS; i++)
6520 {
6521 if (rfChannels[i].channelNum == chanNum)
6522 {
6523 return rfChannels[i].targetFreq;
6524 }
6525 }
6526
6527 return (0);
6528}
6529
6530/* Disconnect all active sessions by sending disassoc. This is mainly used to disconnect the remaining session when we
6531 * transition from concurrent sessions to a single session. The use case is Infra STA and wifi direct multiple sessions are up and
6532 * P2P session is removed. The Infra STA session remains and should resume BMPS if BMPS is enabled by default. However, there
6533 * are some issues seen with BMPS resume during this transition and this is a workaround which will allow the Infra STA session to
6534 * disconnect and auto connect back and enter BMPS this giving the same effect as resuming BMPS
6535 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006536
6537//Remove this code once SLM_Sessionization is supported
6538//BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnson295189b2012-06-20 16:38:30 -07006539void csrDisconnectAllActiveSessions(tpAniSirGlobal pMac)
6540{
6541 tANI_U8 i;
6542
6543 /* Disconnect all the active sessions */
6544 for (i=0; i<CSR_ROAM_SESSION_MAX; i++)
6545 {
6546 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
6547 {
6548 csrRoamDisconnectInternal(pMac, i, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6549 }
6550 }
6551}
Mohit Khanna349bc392012-09-11 17:24:52 -07006552
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006553#ifdef FEATURE_WLAN_LFR
6554tANI_BOOLEAN csrIsChannelPresentInList(
6555 tANI_U8 *pChannelList,
6556 int numChannels,
6557 tANI_U8 channel
6558 )
6559{
6560 int i = 0;
6561
6562 // Check for NULL pointer
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08006563 if (!pChannelList || (numChannels == 0))
6564 {
6565 return FALSE;
6566 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006567
6568 // Look for the channel in the list
6569 for (i = 0; i < numChannels; i++)
6570 {
6571 if (pChannelList[i] == channel)
6572 return TRUE;
6573 }
6574
6575 return FALSE;
6576}
6577
6578VOS_STATUS csrAddToChannelListFront(
6579 tANI_U8 *pChannelList,
6580 int numChannels,
6581 tANI_U8 channel
6582 )
6583{
6584 int i = 0;
6585
6586 // Check for NULL pointer
6587 if (!pChannelList) return eHAL_STATUS_E_NULL_VALUE;
6588
6589 // Make room for the addition. (Start moving from the back.)
6590 for (i = numChannels; i > 0; i--)
6591 {
6592 pChannelList[i] = pChannelList[i-1];
6593 }
6594
6595 // Now add the NEW channel...at the front
6596 pChannelList[0] = channel;
6597
6598 return eHAL_STATUS_SUCCESS;
6599}
6600#endif