blob: 4b9cff879fb8bf2f17454e8335555a2e66860e97 [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
Jeff Johnson295189b2012-06-20 16:38:30 -070067#ifdef FEATURE_WLAN_CCX
68#include "vos_utils.h"
69#include "csrCcx.h"
70#endif /* FEATURE_WLAN_CCX */
71
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{
1305 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1306 palCopyMemory( pMac->hHdd, pBssId, &pSirBssDesc->bssId[ 0 ], sizeof(tCsrBssid) );
1307 return( TRUE );
1308}
1309
1310
1311tANI_BOOLEAN csrIsBssIdEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 )
1312{
1313 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1314 tANI_BOOLEAN fEqual = FALSE;
1315 tCsrBssid bssId1;
1316 tCsrBssid bssId2;
1317
1318 do {
1319 if ( !pSirBssDesc1 ) break;
1320 if ( !pSirBssDesc2 ) break;
1321
1322 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc1, &bssId1 ) ) break;
1323 if ( !csrGetBssIdBssDesc( pMac, pSirBssDesc2, &bssId2 ) ) break;
1324
1325 //sirCompareMacAddr
1326 fEqual = csrIsMacAddressEqual(pMac, &bssId1, &bssId2);
1327
1328 } while( 0 );
1329
1330 return( fEqual );
1331}
1332
1333tANI_BOOLEAN csrIsConnStateConnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1334{
1335 return( eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1336}
1337
1338tANI_BOOLEAN csrIsConnStateDisconnectedIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1339{
1340 return( eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1341}
1342
1343tANI_BOOLEAN csrIsConnStateConnectedInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1344{
1345 return( eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == pMac->roam.roamSession[sessionId].connectState );
1346}
1347
1348tANI_BOOLEAN csrIsConnStateConnected( tpAniSirGlobal pMac, tANI_U32 sessionId )
1349{
1350 if( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateConnectedInfra( pMac, sessionId ) || csrIsConnStateConnectedWds( pMac, sessionId) )
1351 return TRUE;
1352 else
1353 return FALSE;
1354}
1355
1356tANI_BOOLEAN csrIsConnStateInfra( tpAniSirGlobal pMac, tANI_U32 sessionId )
1357{
1358 return( csrIsConnStateConnectedInfra( pMac, sessionId ) );
1359}
1360
1361tANI_BOOLEAN csrIsConnStateIbss( tpAniSirGlobal pMac, tANI_U32 sessionId )
1362{
1363 return( csrIsConnStateConnectedIbss( pMac, sessionId ) || csrIsConnStateDisconnectedIbss( pMac, sessionId ) );
1364}
1365
1366
1367tANI_BOOLEAN csrIsConnStateConnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1368{
1369 return( eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED == pMac->roam.roamSession[sessionId].connectState );
1370}
1371
Jeff Johnson295189b2012-06-20 16:38:30 -07001372tANI_BOOLEAN csrIsConnStateConnectedInfraAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1373{
1374 return( (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == pMac->roam.roamSession[sessionId].connectState) ||
1375 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState ) );
1376}
Jeff Johnson295189b2012-06-20 16:38:30 -07001377
1378tANI_BOOLEAN csrIsConnStateDisconnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1379{
1380 return( eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED == pMac->roam.roamSession[sessionId].connectState );
1381}
1382
1383tANI_BOOLEAN csrIsConnStateWds( tpAniSirGlobal pMac, tANI_U32 sessionId )
1384{
1385 return( csrIsConnStateConnectedWds( pMac, sessionId ) ||
1386 csrIsConnStateDisconnectedWds( pMac, sessionId ) );
1387}
1388
Jeff Johnsone7245742012-09-05 17:12:55 -07001389tANI_BOOLEAN csrIsConnStateAp( tpAniSirGlobal pMac, tANI_U32 sessionId )
1390{
1391 tCsrRoamSession *pSession;
1392 pSession = CSR_GET_SESSION(pMac, sessionId);
1393 if (!pSession)
1394 return eANI_BOOLEAN_FALSE;
1395 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
1396 {
1397 return eANI_BOOLEAN_TRUE;
1398 }
1399 return eANI_BOOLEAN_FALSE;
1400}
1401
Jeff Johnson295189b2012-06-20 16:38:30 -07001402tANI_BOOLEAN csrIsAnySessionInConnectState( tpAniSirGlobal pMac )
1403{
1404 tANI_U32 i;
1405 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1406
1407 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1408 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001409 if( CSR_IS_SESSION_VALID( pMac, i ) &&
1410 ( csrIsConnStateInfra( pMac, i )
1411 || csrIsConnStateIbss( pMac, i )
1412 || csrIsConnStateAp( pMac, i) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 {
1414 fRc = eANI_BOOLEAN_TRUE;
1415 break;
1416 }
1417 }
1418
1419 return ( fRc );
1420}
1421
1422tANI_S8 csrGetInfraSessionId( tpAniSirGlobal pMac )
1423{
1424 tANI_U8 i;
1425 tANI_S8 sessionid = -1;
1426
1427 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1428 {
1429 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateInfra( pMac, i ) )
1430 {
1431 sessionid = i;
1432 break;
1433 }
1434 }
1435
1436 return ( sessionid );
1437}
1438
1439tANI_U8 csrGetInfraOperationChannel( tpAniSirGlobal pMac, tANI_U8 sessionId)
1440{
1441 tANI_U8 channel;
1442
1443 if( CSR_IS_SESSION_VALID( pMac, sessionId ))
1444 {
1445 channel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
1446 }
1447 else
1448 {
1449 channel = 0;
1450 }
1451 return channel;
1452}
1453
1454//This routine will return operating channel on FIRST BSS that is active/operating to be used for concurrency mode.
1455//If other BSS is not up or not connected it will return 0
1456
1457tANI_U8 csrGetConcurrentOperationChannel( tpAniSirGlobal pMac )
1458{
1459 tCsrRoamSession *pSession = NULL;
1460 tANI_U8 i = 0;
1461
1462 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1463 {
1464 if( CSR_IS_SESSION_VALID( pMac, i ) )
1465 {
1466 pSession = CSR_GET_SESSION( pMac, i );
1467
1468 if (NULL != pSession->pCurRoamProfile)
1469 {
1470 if (
1471 (((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1472 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE)) &&
1473 (pSession->connectState == eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED))
1474 ||
1475 (((pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) ||
1476 (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE)) &&
1477 (pSession->connectState != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
1478 )
1479 return (pSession->connectedProfile.operationChannel);
1480 }
1481
1482 }
1483 }
1484 return 0;
1485}
1486
1487tANI_BOOLEAN csrIsAllSessionDisconnected( tpAniSirGlobal pMac )
1488{
1489 tANI_U32 i;
1490 tANI_BOOLEAN fRc = eANI_BOOLEAN_TRUE;
1491
1492 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1493 {
1494 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1495 {
1496 fRc = eANI_BOOLEAN_FALSE;
1497 break;
1498 }
1499 }
1500
1501 return ( fRc );
1502}
1503
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001504tANI_BOOLEAN csrIsStaSessionConnected( tpAniSirGlobal pMac )
1505{
1506 tANI_U32 i;
1507 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1508 tCsrRoamSession *pSession = NULL;
1509 tANI_U32 countSta = 0;
1510
1511 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1512 {
1513 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1514 {
1515 pSession = CSR_GET_SESSION( pMac, i );
1516
1517 if (NULL != pSession->pCurRoamProfile)
1518 {
1519 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) {
1520 countSta++;
1521 }
1522 }
1523 }
1524 }
1525
1526 /* return TRUE if one of the following conditions is TRUE:
1527 * - more than one STA session connected
1528 */
1529 if ( countSta > 0) {
1530 fRc = eANI_BOOLEAN_TRUE;
1531 }
1532
1533 return( fRc );
1534}
1535
1536tANI_BOOLEAN csrIsP2pSessionConnected( tpAniSirGlobal pMac )
1537{
1538 tANI_U32 i;
1539 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1540 tCsrRoamSession *pSession = NULL;
1541 tANI_U32 countP2pCli = 0;
1542 tANI_U32 countP2pGo = 0;
1543
1544 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1545 {
1546 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1547 {
1548 pSession = CSR_GET_SESSION( pMac, i );
1549
1550 if (NULL != pSession->pCurRoamProfile)
1551 {
1552 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE) {
1553 countP2pCli++;
1554 }
1555
1556 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1557 countP2pGo++;
1558 }
1559 }
1560 }
1561 }
1562
1563 /* return TRUE if one of the following conditions is TRUE:
1564 * - at least one P2P CLI session is connected
1565 * - at least one P2P GO session is connected
1566 */
1567 if ( (countP2pCli > 0) || (countP2pGo > 0 ) ) {
1568 fRc = eANI_BOOLEAN_TRUE;
1569 }
1570
1571 return( fRc );
1572}
1573
Madan Mohan Koyyalamudid3d22592012-09-24 14:01:29 -07001574tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac )
1575{
1576 tANI_U32 i, count;
1577 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1578
1579 count = 0;
1580 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1581 {
1582 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1583 {
1584 count++;
1585 }
1586 }
1587
1588 if (count > 0)
1589 {
1590 fRc = eANI_BOOLEAN_TRUE;
1591 }
1592 return( fRc );
1593}
Jeff Johnson295189b2012-06-20 16:38:30 -07001594
1595tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac )
1596{
1597 tANI_U32 i;
1598 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1599
1600 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1601 {
1602 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1603 {
1604 fRc = eANI_BOOLEAN_TRUE;
1605 break;
1606 }
1607 }
1608
1609 return ( fRc );
1610}
1611
1612tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac )
1613{
1614 tANI_U32 i, noOfConnectedInfra = 0;
1615
1616 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1617
1618 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1619 {
1620 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1621 {
1622 ++noOfConnectedInfra;
1623 }
1624 }
1625
1626 // More than one Infra Sta Connected
1627 if(noOfConnectedInfra > 1)
1628 {
1629 fRc = eANI_BOOLEAN_TRUE;
1630 }
1631
1632 return ( fRc );
1633}
1634
1635tANI_BOOLEAN csrIsIBSSStarted( tpAniSirGlobal pMac )
1636{
1637 tANI_U32 i;
1638 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1639
1640 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1641 {
1642 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateIbss( pMac, i ) )
1643 {
1644 fRc = eANI_BOOLEAN_TRUE;
1645 break;
1646 }
1647 }
1648
1649 return ( fRc );
1650}
1651
1652
1653tANI_BOOLEAN csrIsBTAMPStarted( tpAniSirGlobal pMac )
1654{
1655 tANI_U32 i;
1656 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1657
1658 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1659 {
1660 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedWds( pMac, i ) )
1661 {
1662 fRc = eANI_BOOLEAN_TRUE;
1663 break;
1664 }
1665 }
1666
1667 return ( fRc );
1668}
1669
Jeff Johnsone7245742012-09-05 17:12:55 -07001670tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac )
1671{
1672 tANI_U32 sessionId, noOfCocurrentSession = 0;
1673 eCsrConnectState connectState;
1674
1675 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1676
1677 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1678 {
1679 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1680 {
1681 connectState = pMac->roam.roamSession[sessionId].connectState;
1682 if( (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == connectState) ||
1683 (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == connectState) ||
1684 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == connectState) )
1685 {
1686 ++noOfCocurrentSession;
1687 }
1688 }
1689 }
1690
1691 // More than one session is Up and Running
1692 if(noOfCocurrentSession > 1)
1693 {
1694 fRc = eANI_BOOLEAN_TRUE;
1695 }
1696
1697 return ( fRc );
1698}
1699
Jeff Johnsone7245742012-09-05 17:12:55 -07001700tANI_BOOLEAN csrIsInfraApStarted( tpAniSirGlobal pMac )
1701{
1702 tANI_U32 sessionId;
1703 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1704
1705 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1706 {
1707 if( CSR_IS_SESSION_VALID( pMac, sessionId ) && (csrIsConnStateConnectedInfraAp(pMac, sessionId)) )
1708 {
1709 fRc = eANI_BOOLEAN_TRUE;
1710 break;
1711 }
1712 }
1713
1714 return ( fRc );
1715
1716}
Jeff Johnsone7245742012-09-05 17:12:55 -07001717
Jeff Johnson295189b2012-06-20 16:38:30 -07001718tANI_BOOLEAN csrIsBTAMP( tpAniSirGlobal pMac, tANI_U32 sessionId )
1719{
1720 return ( csrIsConnStateConnectedWds( pMac, sessionId ) );
1721}
1722
1723
1724tANI_BOOLEAN csrIsConnStateDisconnected(tpAniSirGlobal pMac, tANI_U32 sessionId)
1725{
1726 return (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED == pMac->roam.roamSession[sessionId].connectState);
1727}
1728
Jeff Johnsone7245742012-09-05 17:12:55 -07001729tANI_BOOLEAN csrIsValidMcConcurrentSession(tpAniSirGlobal pMac, tANI_U32 sessionId,
1730 tSirBssDescription *pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001731{
1732 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07001733 eAniBoolean status = eANI_BOOLEAN_FALSE;
1734
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 //Check for MCC support
1736 if (!pMac->roam.configParam.fenableMCCMode)
1737 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001738 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 }
1740
Jeff Johnsone7245742012-09-05 17:12:55 -07001741 //Validate BeaconInterval
1742 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1743 {
1744 pSession = CSR_GET_SESSION( pMac, sessionId );
1745 if (NULL != pSession->pCurRoamProfile)
1746 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001747 if (csrIsconcurrentsessionValid (pMac, sessionId,
1748 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001749 == eHAL_STATUS_SUCCESS )
1750 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001751 if (csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId,
1752 &pBssDesc->beaconInterval, sessionId,
1753 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001754 != eHAL_STATUS_SUCCESS)
1755 {
1756 status = eANI_BOOLEAN_FALSE;
1757 }
1758 else
1759 {
1760 status = eANI_BOOLEAN_TRUE;
1761 }
1762 }
1763 else
1764 {
1765 status = eANI_BOOLEAN_FALSE;
1766 }
1767 }
1768 }
1769 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001770}
1771
1772static tSirMacCapabilityInfo csrGetBssCapabilities( tSirBssDescription *pSirBssDesc )
1773{
1774 tSirMacCapabilityInfo dot11Caps;
1775
1776 //tSirMacCapabilityInfo is 16-bit
1777 pal_get_U16( (tANI_U8 *)&pSirBssDesc->capabilityInfo, (tANI_U16 *)&dot11Caps );
1778
1779 return( dot11Caps );
1780}
1781
1782tANI_BOOLEAN csrIsInfraBssDesc( tSirBssDescription *pSirBssDesc )
1783{
1784 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1785
1786 return( (tANI_BOOLEAN)dot11Caps.ess );
1787}
1788
1789
1790tANI_BOOLEAN csrIsIbssBssDesc( tSirBssDescription *pSirBssDesc )
1791{
1792 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1793
1794 return( (tANI_BOOLEAN)dot11Caps.ibss );
1795}
1796
1797tANI_BOOLEAN csrIsQoSBssDesc( tSirBssDescription *pSirBssDesc )
1798{
1799 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1800
1801 return( (tANI_BOOLEAN)dot11Caps.qos );
1802}
1803
1804tANI_BOOLEAN csrIsPrivacy( tSirBssDescription *pSirBssDesc )
1805{
1806 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1807
1808 return( (tANI_BOOLEAN)dot11Caps.privacy );
1809}
1810
1811
1812tANI_BOOLEAN csrIs11dSupported(tpAniSirGlobal pMac)
1813{
1814 return(pMac->roam.configParam.Is11dSupportEnabled);
1815}
1816
1817
1818tANI_BOOLEAN csrIs11hSupported(tpAniSirGlobal pMac)
1819{
1820 return(pMac->roam.configParam.Is11hSupportEnabled);
1821}
1822
1823
1824tANI_BOOLEAN csrIs11eSupported(tpAniSirGlobal pMac)
1825{
1826 return(pMac->roam.configParam.Is11eSupportEnabled);
1827}
1828
1829tANI_BOOLEAN csrIsMCCSupported ( tpAniSirGlobal pMac )
1830{
1831 return(pMac->roam.configParam.fenableMCCMode);
1832
1833}
1834
1835tANI_BOOLEAN csrIsWmmSupported(tpAniSirGlobal pMac)
1836{
1837 if(eCsrRoamWmmNoQos == pMac->roam.configParam.WMMSupportMode)
1838 {
1839 return eANI_BOOLEAN_FALSE;
1840 }
1841 else
1842 {
1843 return eANI_BOOLEAN_TRUE;
1844 }
1845}
1846
1847
1848
1849
1850//pIes is the IEs for pSirBssDesc2
1851tANI_BOOLEAN csrIsSsidEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1,
1852 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2 )
1853{
1854 tANI_BOOLEAN fEqual = FALSE;
1855 tSirMacSSid Ssid1, Ssid2;
1856 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1857 tDot11fBeaconIEs *pIes1 = NULL;
1858 tDot11fBeaconIEs *pIesLocal = pIes2;
1859
1860 do {
1861 if( ( NULL == pSirBssDesc1 ) || ( NULL == pSirBssDesc2 ) ) break;
1862 if( !pIesLocal && !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesLocal)) )
1863 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001864 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 break;
1866 }
1867 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
1868 {
1869 break;
1870 }
1871 if( ( !pIes1->SSID.present ) || ( !pIesLocal->SSID.present ) ) break;
1872 if ( pIes1->SSID.num_ssid != pIesLocal->SSID.num_ssid ) break;
1873 palCopyMemory(pMac->hHdd, Ssid1.ssId, pIes1->SSID.ssid, pIes1->SSID.num_ssid);
1874 palCopyMemory(pMac->hHdd, Ssid2.ssId, pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid);
1875
1876 fEqual = palEqualMemory(pMac->hHdd, Ssid1.ssId, Ssid2.ssId, pIesLocal->SSID.num_ssid );
1877
1878 } while( 0 );
1879 if(pIes1)
1880 {
1881 palFreeMemory(pMac->hHdd, pIes1);
1882 }
1883 if( pIesLocal && !pIes2 )
1884 {
1885 palFreeMemory(pMac->hHdd, pIesLocal);
1886 }
1887
1888 return( fEqual );
1889}
1890
1891tANI_BOOLEAN csrIsAniWmeSupported(tDot11fIEAirgo *pIeAirgo)
1892{
1893 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
1894
1895 if(pIeAirgo && pIeAirgo->present && pIeAirgo->PropCapability.present)
1896 {
1897 fRet = (tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability ));
1898 }
1899
1900 return fRet;
1901}
1902
1903
1904
1905
1906//pIes can be passed in as NULL if the caller doesn't have one prepared
1907tANI_BOOLEAN csrIsBssDescriptionWme( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
1908{
1909 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1910 // Assume that WME is found...
1911 tANI_BOOLEAN fWme = TRUE;
1912 tDot11fBeaconIEs *pIesTemp = pIes;
1913
1914 do
1915 {
1916 if(pIesTemp == NULL)
1917 {
1918 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp)) )
1919 {
1920 fWme = FALSE;
1921 break;
1922 }
1923 }
1924 // if the AirgoProprietary indicator is found, then WME is supported...
1925 if ( csrIsAniWmeSupported(&pIesTemp->Airgo) ) break;
1926 // if the Wme Info IE is found, then WME is supported...
1927 if ( CSR_IS_QOS_BSS(pIesTemp) ) break;
1928 // if none of these are found, then WME is NOT supported...
1929 fWme = FALSE;
1930 } while( 0 );
1931 if( !csrIsWmmSupported( pMac ) && fWme)
1932 {
1933 if( !pIesTemp->HTCaps.present )
1934 {
1935 fWme = FALSE;
1936 }
1937 }
1938 if( ( pIes == NULL ) && ( NULL != pIesTemp ) )
1939 {
1940 //we allocate memory here so free it before returning
1941 palFreeMemory(pMac->hHdd, pIesTemp);
1942 }
1943
1944 return( fWme );
1945}
1946
1947tANI_BOOLEAN csrIsHcfEnabled( tDot11fIEAirgo *pIeAirgo )
1948{
1949 tANI_BOOLEAN fHcfSupported = FALSE;
1950
1951 fHcfSupported = ((tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability )) ||
1952 (pIeAirgo->present && pIeAirgo->HCF.present && pIeAirgo->HCF.enabled));
1953
1954 return( fHcfSupported );
1955}
1956
1957
1958eCsrMediaAccessType csrGetQoSFromBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc,
1959 tDot11fBeaconIEs *pIes )
1960{
1961 eCsrMediaAccessType qosType = eCSR_MEDIUM_ACCESS_DCF;
1962
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001964
1965 do
1966 {
1967 // if we find WMM in the Bss Description, then we let this
1968 // override and use WMM.
1969 if ( csrIsBssDescriptionWme( hHal, pSirBssDesc, pIes ) )
1970 {
1971 qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
1972 }
1973 else
1974 {
1975 // if the QoS bit is on, then the AP is advertising 11E QoS...
1976 if ( csrIsQoSBssDesc( pSirBssDesc ) )
1977 {
1978 // which could be HCF or eDCF.
1979 if ( csrIsHcfEnabled( &pIes->Airgo ) )
1980 {
1981 qosType = eCSR_MEDIUM_ACCESS_11e_HCF;
1982 }
1983 else
1984 {
1985 qosType = eCSR_MEDIUM_ACCESS_11e_eDCF;
1986 }
1987 }
1988 else
1989 {
1990 qosType = eCSR_MEDIUM_ACCESS_DCF;
1991 }
1992 // scale back based on the types turned on for the adapter...
1993 if ( eCSR_MEDIUM_ACCESS_11e_eDCF == qosType && !csrIs11eSupported( hHal ) )
1994 {
1995 qosType = eCSR_MEDIUM_ACCESS_DCF;
1996 }
1997 }
1998
1999 } while(0);
2000
2001 return( qosType );
2002}
2003
2004
2005
2006
2007//Caller allocates memory for pIEStruct
2008eHalStatus csrParseBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIEStruct)
2009{
2010 eHalStatus status = eHAL_STATUS_FAILURE;
2011 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2012 int ieLen = (int)(pBssDesc->length + sizeof( pBssDesc->length ) - GET_FIELD_OFFSET( tSirBssDescription, ieFields ));
2013
2014 if(ieLen > 0 && pIEStruct)
2015 {
2016 if(!DOT11F_FAILED(dot11fUnpackBeaconIEs( pMac, (tANI_U8 *)pBssDesc->ieFields, ieLen, pIEStruct )))
2017 {
2018 status = eHAL_STATUS_SUCCESS;
2019 }
2020 }
2021
2022 return (status);
2023}
2024
2025
2026//This function will allocate memory for the parsed IEs to the caller. Caller must free the memory
2027//after it is done with the data only if this function succeeds
2028eHalStatus csrGetParsedBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs **ppIEStruct)
2029{
2030 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2031 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2032
2033 if(pBssDesc && ppIEStruct)
2034 {
2035 status = palAllocateMemory(pMac->hHdd, (void **)ppIEStruct, sizeof(tDot11fBeaconIEs));
2036 if(HAL_STATUS_SUCCESS(status))
2037 {
2038 palZeroMemory(pMac->hHdd, (void *)*ppIEStruct, sizeof(tDot11fBeaconIEs));
2039 status = csrParseBssDescriptionIEs(hHal, pBssDesc, *ppIEStruct);
2040 if(!HAL_STATUS_SUCCESS(status))
2041 {
2042 palFreeMemory(pMac->hHdd, *ppIEStruct);
2043 *ppIEStruct = NULL;
2044 }
2045 }
2046 else
2047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002048 smsLog( pMac, LOGE, FL(" failed to allocate memory") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 VOS_ASSERT( 0 );
2050 }
2051 }
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
2591#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudief5dd972012-10-11 15:06:09 -07002592 if ((0 == phyMode) || ((eCSR_DOT11_MODE_AUTO & phyMode) && (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)))
2593 || ((eCSR_DOT11_MODE_11ac & phyMode) && (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))))
Jeff Johnsone7245742012-09-05 17:12:55 -07002594 {
2595 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC;
2596 }
2597 else
2598#endif
2599
Madan Mohan Koyyalamudief5dd972012-10-11 15:06:09 -07002600 if ((0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 {
2602 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2603 }
2604 else
2605 {
2606 if( ( eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY ) & phyMode )
2607 {
2608 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2609 }
2610 else if ( eCSR_DOT11_MODE_abg & phyMode )
2611 {
2612 if( eCSR_BAND_24 != eBand )
2613 {
2614 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2615 }
2616 else
2617 {
2618 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2619 }
2620 }
2621 else if( ( eCSR_DOT11_MODE_11a | eCSR_DOT11_MODE_11a_ONLY ) & phyMode )
2622 {
2623 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2624 }
2625 else if( ( eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY ) & phyMode )
2626 {
2627 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2628 }
2629 else
2630 {
2631 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B;
2632 }
2633 }
2634
2635 return ( cfgDot11ModeToUse );
2636}
2637
2638
2639
2640
2641tANI_U32 csrGet11hPowerConstraint( tHalHandle hHal, tDot11fIEPowerConstraints *pPowerConstraint )
2642{
2643 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2644 tANI_U32 localPowerConstraint = 0;
2645
2646 // check if .11h support is enabled, if not, the power constraint is 0.
2647 if(pMac->roam.configParam.Is11hSupportEnabled && pPowerConstraint->present)
2648 {
2649 localPowerConstraint = pPowerConstraint->localPowerConstraints;
2650 }
2651
2652 return( localPowerConstraint );
2653}
2654
2655
2656tANI_BOOLEAN csrIsProfileWpa( tCsrRoamProfile *pProfile )
2657{
2658 tANI_BOOLEAN fWpaProfile = FALSE;
2659
2660 switch ( pProfile->negotiatedAuthType )
2661 {
2662 case eCSR_AUTH_TYPE_WPA:
2663 case eCSR_AUTH_TYPE_WPA_PSK:
2664 case eCSR_AUTH_TYPE_WPA_NONE:
2665#ifdef FEATURE_WLAN_CCX
2666 case eCSR_AUTH_TYPE_CCKM_WPA:
2667#endif
2668 fWpaProfile = TRUE;
2669 break;
2670
2671 default:
2672 fWpaProfile = FALSE;
2673 break;
2674 }
2675
2676 if ( fWpaProfile )
2677 {
2678 switch ( pProfile->negotiatedUCEncryptionType )
2679 {
2680 case eCSR_ENCRYPT_TYPE_WEP40:
2681 case eCSR_ENCRYPT_TYPE_WEP104:
2682 case eCSR_ENCRYPT_TYPE_TKIP:
2683 case eCSR_ENCRYPT_TYPE_AES:
2684 fWpaProfile = TRUE;
2685 break;
2686
2687 default:
2688 fWpaProfile = FALSE;
2689 break;
2690 }
2691 }
2692 return( fWpaProfile );
2693}
2694
2695tANI_BOOLEAN csrIsProfileRSN( tCsrRoamProfile *pProfile )
2696{
2697 tANI_BOOLEAN fRSNProfile = FALSE;
2698
2699 switch ( pProfile->negotiatedAuthType )
2700 {
2701 case eCSR_AUTH_TYPE_RSN:
2702 case eCSR_AUTH_TYPE_RSN_PSK:
2703#ifdef WLAN_FEATURE_VOWIFI_11R
2704 case eCSR_AUTH_TYPE_FT_RSN:
2705 case eCSR_AUTH_TYPE_FT_RSN_PSK:
2706#endif
2707#ifdef FEATURE_WLAN_CCX
2708 case eCSR_AUTH_TYPE_CCKM_RSN:
2709#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002710#ifdef WLAN_FEATURE_11W
2711 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
2712#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 fRSNProfile = TRUE;
2714 break;
2715
2716 default:
2717 fRSNProfile = FALSE;
2718 break;
2719 }
2720
2721 if ( fRSNProfile )
2722 {
2723 switch ( pProfile->negotiatedUCEncryptionType )
2724 {
2725 // !!REVIEW - For WPA2, use of RSN IE mandates
2726 // use of AES as encryption. Here, we qualify
2727 // even if encryption type is WEP or TKIP
2728 case eCSR_ENCRYPT_TYPE_WEP40:
2729 case eCSR_ENCRYPT_TYPE_WEP104:
2730 case eCSR_ENCRYPT_TYPE_TKIP:
2731 case eCSR_ENCRYPT_TYPE_AES:
2732 fRSNProfile = TRUE;
2733 break;
2734
2735 default:
2736 fRSNProfile = FALSE;
2737 break;
2738 }
2739 }
2740 return( fRSNProfile );
2741}
2742
Jeff Johnsone7245742012-09-05 17:12:55 -07002743eHalStatus
2744csrIsconcurrentsessionValid(tpAniSirGlobal pMac,tANI_U32 cursessionId,
2745 tVOS_CON_MODE currBssPersona)
2746{
2747 tANI_U32 sessionId = 0;
2748
2749 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2750 {
2751 if (cursessionId != sessionId )
2752 {
2753 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2754 {
2755 continue;
2756 }
2757
2758 switch (currBssPersona)
2759 {
2760 case VOS_STA_MODE:
2761 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002762 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002763 == VOS_STA_MODE)) //check for P2P client mode
2764 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002765 smsLog(pMac, LOGE, FL(" ****STA mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002766 return eHAL_STATUS_FAILURE;
2767 }
2768 break;
2769
2770 case VOS_STA_SAP_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302771 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2772 == VOS_STA_SAP_MODE)&&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002773 (pMac->roam.roamSession[sessionId].connectState
2774 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002776 smsLog(pMac, LOGE, FL(" ****SoftAP mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002777 return eHAL_STATUS_FAILURE;
2778 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002779 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2780 == VOS_P2P_GO_MODE &&
2781 pMac->roam.roamSession[sessionId].connectState
2782 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2783 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2784 == VOS_IBSS_MODE &&
2785 pMac->roam.roamSession[sessionId].connectState
2786 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002787 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002788 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002789 return eHAL_STATUS_FAILURE;
2790 }
2791 break;
2792
2793 case VOS_P2P_CLIENT_MODE:
2794 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002795 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002796 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2797 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002798 smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002799 return eHAL_STATUS_FAILURE;
2800 }
2801 break;
2802
2803 case VOS_P2P_GO_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302804 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2805 == VOS_P2P_GO_MODE) &&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002806 (pMac->roam.roamSession[sessionId].connectState
2807 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002809 smsLog(pMac, LOGE, FL(" ****P2P GO mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002810 return eHAL_STATUS_FAILURE;
2811 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002812 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2813 == VOS_STA_SAP_MODE &&
2814 pMac->roam.roamSession[sessionId].connectState
2815 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2816 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2817 == VOS_IBSS_MODE &&
2818 pMac->roam.roamSession[sessionId].connectState
2819 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002821 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002822 return eHAL_STATUS_FAILURE;
2823 }
2824 break;
Ravi Joshia96ceb42013-05-20 18:52:39 -07002825 case VOS_IBSS_MODE:
2826 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2827 == VOS_IBSS_MODE) &&
2828 (pMac->roam.roamSession[sessionId].connectState
2829 != eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED))
2830 {
2831 smsLog(pMac, LOGE, FL(" ****IBSS mode already exists ****"));
2832 return eHAL_STATUS_FAILURE;
2833 }
2834 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2835 == VOS_P2P_GO_MODE ||
2836 pMac->roam.roamSession[sessionId].bssParams.bssPersona
2837 == VOS_STA_SAP_MODE) &&
2838 pMac->roam.roamSession[sessionId].connectState
2839 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)
2840 {
2841 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
2842 return eHAL_STATUS_FAILURE;
2843 }
2844 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002845 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002846 smsLog(pMac, LOGE, FL("***Persona not handled = %d*****"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07002847 break;
2848 }
2849 }
2850 }
2851 return eHAL_STATUS_SUCCESS;
2852
2853}
2854
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002855eHalStatus csrUpdateMCCp2pBeaconInterval(tpAniSirGlobal pMac)
Jeff Johnsone7245742012-09-05 17:12:55 -07002856{
2857 tANI_U32 sessionId = 0;
2858
2859 //If MCC is not supported just break and return SUCCESS
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002860 if ( !pMac->roam.configParam.fenableMCCMode){
2861 return eHAL_STATUS_FAILURE;
2862 }
2863
2864 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2865 {
2866 /* If GO in MCC support different beacon interval,
2867 * change the BI of the P2P-GO */
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002868 if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2869 == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002870 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002871 /* Handle different BI scneario based on the configuration set.
2872 * If Config is set to 0x02 then Disconnect all the P2P clients
2873 * associated. If config is set to 0x04 then update the BI
2874 * without disconnecting all the clients
2875 */
2876 if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
2877 (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
2878 {
2879 return csrSendChngMCCBeaconInterval( pMac, sessionId);
2880 }
2881 //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
2882 else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
2883 {
2884 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
2885 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002886 }
2887 }
2888 return eHAL_STATUS_FAILURE;
2889}
2890
2891tANI_U16 csrCalculateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U16 sta_bi, tANI_U16 go_gbi)
2892{
2893 tANI_U8 num_beacons = 0;
2894 tANI_U8 is_multiple = 0;
2895 tANI_U16 go_cbi = 0;
2896 tANI_U16 go_fbi = 0;
2897 tANI_U16 sta_cbi = 0;
2898
2899 //If GO's given beacon Interval is less than 100
2900 if(go_gbi < 100)
2901 go_cbi = 100;
2902 //if GO's given beacon Interval is greater than or equal to 100
2903 else
2904 go_cbi = 100 + (go_gbi % 100);
2905
2906 // check, if either one is multiple of another
2907 if (sta_bi > go_cbi)
2908 {
2909 is_multiple = !(sta_bi % go_cbi);
2910 }
2911 else
2912 {
2913 is_multiple = !(go_cbi % sta_bi);
2914 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002915 // if it is multiple, then accept GO's beacon interval range [100,199] as it is
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002916 if (is_multiple)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002917 {
2918 return go_cbi;
2919 }
2920 //else , if it is not multiple, then then check for number of beacons to be
2921 //inserted based on sta BI
2922 num_beacons = sta_bi / 100;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002923 if (num_beacons)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002924 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002925 // GO's final beacon interval will be aligned to sta beacon interval, but
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002926 //in the range of [100, 199].
2927 sta_cbi = sta_bi / num_beacons;
2928 go_fbi = sta_cbi;
2929 }
2930 else
2931 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002932 // if STA beacon interval is less than 100, use GO's change bacon interval
2933 //instead of updating to STA's beacon interval.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002934 go_fbi = go_cbi;
2935 }
2936 return go_fbi;
2937}
2938
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002939eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002940 tANI_U16 *beaconInterval, tANI_U32 cursessionId,
2941 tVOS_CON_MODE currBssPersona)
2942{
2943 tANI_U32 sessionId = 0;
2944 tANI_U16 new_beaconInterval = 0;
2945
2946 //If MCC is not supported just break
2947 if (!pMac->roam.configParam.fenableMCCMode){
Jeff Johnsone7245742012-09-05 17:12:55 -07002948 return eHAL_STATUS_FAILURE;
2949 }
2950
2951 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2952 {
2953 if (cursessionId != sessionId )
2954 {
2955 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2956 {
2957 continue;
2958 }
2959
2960 switch (currBssPersona)
2961 {
2962 case VOS_STA_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002963 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
2964 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002965 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2966 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002967 smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002968 }
2969 //IF SAP has started and STA wants to connect on different channel MCC should
2970 //MCC should not be enabled so making it false to enforce on same channel
2971 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2972 == VOS_STA_SAP_MODE)
2973 {
2974 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
2975 != channelId )
2976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002977 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP +STA****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002978 return eHAL_STATUS_FAILURE;
2979 }
2980 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002981 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002982 == VOS_P2P_GO_MODE) //Check for P2P go scenario
2983 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002984 /* if GO in MCC support different beacon interval,
2985 * change the BI of the P2P-GO */
2986 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
Jeff Johnsone7245742012-09-05 17:12:55 -07002987 != channelId ) &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002988 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07002989 != *beaconInterval))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002990 {
2991 /* if GO in MCC support different beacon interval, return success */
2992 if ( pMac->roam.configParam.fAllowMCCGODiffBI == 0x01)
2993 {
2994 return eHAL_STATUS_SUCCESS;
2995 }
2996 // Send only Broadcast disassoc and update beaconInterval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002997 //If configuration is set to 0x04 then dont
2998 // disconnect all the station
2999 else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
3000 (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003001 {
3002 //Check to pass the right beacon Interval
3003 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval,
3004 pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003005 smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003006 //Update the becon Interval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003007 if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003008 {
3009 //Update the beaconInterval now
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003010 smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
3011 pMac->roam.configParam.fAllowMCCGODiffBI);
3012
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003013 pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
3014 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003015 return csrUpdateMCCp2pBeaconInterval(pMac);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003016 }
3017 return eHAL_STATUS_SUCCESS;
3018 }
3019 //Disconnect the P2P session
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003020 else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003021 {
3022 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
3023 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
3024 }
3025 else
3026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003027 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to preferred AP..."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003028 return eHAL_STATUS_FAILURE;
3029 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003030 }
3031 }
3032 break;
3033
3034 case VOS_P2P_CLIENT_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003035 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3036 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003037 == VOS_STA_MODE)) //check for P2P client mode
3038 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003039 smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003040 }
3041 //IF SAP has started and STA wants to connect on different channel MCC should
3042 //MCC should not be enabled so making it false to enforce on same channel
3043 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3044 == VOS_STA_SAP_MODE)
3045 {
3046 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3047 != channelId )
3048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003049 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP + CLIENT****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003050 return eHAL_STATUS_FAILURE;
3051 }
3052 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003053 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003054 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3055 {
3056 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
3057 != channelId ) &&
3058 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
3059 != *beaconInterval))
3060 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003061 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to P2P_GO network ..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003062 return eHAL_STATUS_FAILURE;
3063 }
3064 }
3065 break;
3066
3067 case VOS_P2P_GO_MODE :
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003068 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003069 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3070 ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003071 == VOS_P2P_CLIENT_MODE) ||
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003072 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003073 == VOS_STA_MODE))) //check for P2P_client scenario
3074 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003075 if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003076 == 0 )&&
3077 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
3078 == 0))
3079 {
3080 continue;
3081 }
3082
3083
3084 if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003085 (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003086 != channelId ) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003087 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003088 != *beaconInterval))
3089 {
3090 /*
3091 * Updated beaconInterval should be used only when we are starting a new BSS
3092 * not incase of client or STA case
3093 */
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003094 //Calculate beacon Interval for P2P-GO incase of MCC
3095 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac,
Chet Lanctot4c986162013-05-08 13:59:56 -07003096 pMac->roam.roamSession[sessionId].bssParams.beaconInterval,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003097 *beaconInterval );
3098 if(*beaconInterval != new_beaconInterval)
3099 *beaconInterval = new_beaconInterval;
Jeff Johnsone7245742012-09-05 17:12:55 -07003100 return eHAL_STATUS_SUCCESS;
3101 }
3102 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003103 }
3104 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003105
3106 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003107 smsLog(pMac, LOG1, FL(" Persona not supported : %d"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003108 return eHAL_STATUS_FAILURE;
3109 }
3110 }
3111 }
3112
3113 return eHAL_STATUS_SUCCESS;
3114}
Jeff Johnson295189b2012-06-20 16:38:30 -07003115
3116#ifdef WLAN_FEATURE_VOWIFI_11R
3117/* Function to return TRUE if the authtype is 11r */
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003118tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -07003119{
3120 switch ( AuthType )
3121 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003122 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3123 if(mdiePresent)
3124 return TRUE;
3125 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3127 case eCSR_AUTH_TYPE_FT_RSN:
3128 return TRUE;
3129 break;
3130 default:
3131 break;
3132 }
3133 return FALSE;
3134}
3135
3136/* Function to return TRUE if the profile is 11r */
3137tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
3138{
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003139 return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
Jeff Johnson295189b2012-06-20 16:38:30 -07003140}
3141
3142#endif
3143
3144#ifdef FEATURE_WLAN_CCX
3145
3146/* Function to return TRUE if the authtype is CCX */
3147tANI_BOOLEAN csrIsAuthTypeCCX( eCsrAuthType AuthType )
3148{
3149 switch ( AuthType )
3150 {
3151 case eCSR_AUTH_TYPE_CCKM_WPA:
3152 case eCSR_AUTH_TYPE_CCKM_RSN:
3153 return TRUE;
3154 break;
3155 default:
3156 break;
3157 }
3158 return FALSE;
3159}
3160
3161/* Function to return TRUE if the profile is CCX */
3162tANI_BOOLEAN csrIsProfileCCX( tCsrRoamProfile *pProfile )
3163{
3164 return (csrIsAuthTypeCCX( pProfile->negotiatedAuthType ));
3165}
3166
3167#endif
3168
3169#ifdef FEATURE_WLAN_WAPI
3170tANI_BOOLEAN csrIsProfileWapi( tCsrRoamProfile *pProfile )
3171{
3172 tANI_BOOLEAN fWapiProfile = FALSE;
3173
3174 switch ( pProfile->negotiatedAuthType )
3175 {
3176 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
3177 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
3178 fWapiProfile = TRUE;
3179 break;
3180
3181 default:
3182 fWapiProfile = FALSE;
3183 break;
3184 }
3185
3186 if ( fWapiProfile )
3187 {
3188 switch ( pProfile->negotiatedUCEncryptionType )
3189 {
3190 case eCSR_ENCRYPT_TYPE_WPI:
3191 fWapiProfile = TRUE;
3192 break;
3193
3194 default:
3195 fWapiProfile = FALSE;
3196 break;
3197 }
3198 }
3199 return( fWapiProfile );
3200}
3201
3202static tANI_BOOLEAN csrIsWapiOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3203{
3204 return( palEqualMemory(pMac->hHdd, Oui1, Oui2, CSR_WAPI_OUI_SIZE ) );
3205}
3206
3207static tANI_BOOLEAN csrIsWapiOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3208 tANI_U8 cAllCyphers,
3209 tANI_U8 Cypher[],
3210 tANI_U8 Oui[] )
3211{
3212 tANI_BOOLEAN fYes = FALSE;
3213 tANI_U8 idx;
3214
3215 for ( idx = 0; idx < cAllCyphers; idx++ )
3216 {
3217 if ( csrIsWapiOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3218 {
3219 fYes = TRUE;
3220 break;
3221 }
3222 }
3223
3224 if ( fYes && Oui )
3225 {
3226 palCopyMemory( pMac->hHdd, Oui, AllCyphers[ idx ], CSR_WAPI_OUI_SIZE );
3227 }
3228
3229 return( fYes );
3230}
3231#endif /* FEATURE_WLAN_WAPI */
3232
3233static tANI_BOOLEAN csrIsWpaOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3234{
3235 return( palEqualMemory(pMac->hHdd, Oui1, Oui2, CSR_WPA_OUI_SIZE ) );
3236}
3237
3238static tANI_BOOLEAN csrIsOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3239 tANI_U8 cAllCyphers,
3240 tANI_U8 Cypher[],
3241 tANI_U8 Oui[] )
3242{
3243 tANI_BOOLEAN fYes = FALSE;
3244 tANI_U8 idx;
3245
3246 for ( idx = 0; idx < cAllCyphers; idx++ )
3247 {
3248 if ( csrIsWpaOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3249 {
3250 fYes = TRUE;
3251 break;
3252 }
3253 }
3254
3255 if ( fYes && Oui )
3256 {
3257 palCopyMemory( pMac->hHdd, Oui, AllCyphers[ idx ], CSR_WPA_OUI_SIZE );
3258 }
3259
3260 return( fYes );
3261}
3262
3263static tANI_BOOLEAN csrMatchRSNOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3264 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3265 tANI_U8 Oui[] )
3266{
3267 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui[ouiIndex], Oui ) );
3268
3269}
3270
3271#ifdef FEATURE_WLAN_WAPI
3272static tANI_BOOLEAN csrMatchWapiOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3273 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3274 tANI_U8 Oui[] )
3275{
3276 return( csrIsWapiOuiMatch( pMac, AllCyphers, cAllCyphers, csrWapiOui[ouiIndex], Oui ) );
3277
3278}
3279#endif /* FEATURE_WLAN_WAPI */
3280
3281static tANI_BOOLEAN csrMatchWPAOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3282 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3283 tANI_U8 Oui[] )
3284{
3285 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui[ouiIndex], Oui ) );
3286
3287}
3288
3289#if 0
3290static tANI_BOOLEAN csrIsRSNUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3291 tANI_U8 cAllCyphers,
3292 tANI_U8 Oui[] )
3293{
3294 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui00, Oui ) );
3295}
3296
3297static tANI_BOOLEAN csrIsRSNMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3298 tANI_U8 cAllCyphers,
3299 tANI_U8 Oui[] )
3300{
3301 tANI_BOOLEAN fYes = FALSE;
3302
3303 // Check Wep 104 first, if fails, then check Wep40.
3304 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui05, Oui );
3305
3306 if ( !fYes )
3307 {
3308 // if not Wep-104, check Wep-40
3309 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui01, Oui );
3310 }
3311
3312 return( fYes );
3313}
3314
3315
3316static tANI_BOOLEAN csrIsRSNUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3317 tANI_U8 cAllCyphers,
3318 tANI_U8 Oui[] )
3319{
3320 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3321}
3322
3323
3324static tANI_BOOLEAN csrIsRSNMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3325 tANI_U8 cAllCyphers,
3326 tANI_U8 Oui[] )
3327{
3328 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3329}
3330
3331static tANI_BOOLEAN csrIsRSNUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3332 tANI_U8 cAllCyphers,
3333 tANI_U8 Oui[] )
3334{
3335 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3336}
3337
3338static tANI_BOOLEAN csrIsRSNMulticastAes( 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#endif
3345#ifdef FEATURE_WLAN_WAPI
3346static tANI_BOOLEAN csrIsAuthWapiCert( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3347 tANI_U8 cAllSuites,
3348 tANI_U8 Oui[] )
3349{
3350 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[1], Oui ) );
3351}
3352static tANI_BOOLEAN csrIsAuthWapiPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3353 tANI_U8 cAllSuites,
3354 tANI_U8 Oui[] )
3355{
3356 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[2], Oui ) );
3357}
3358#endif /* FEATURE_WLAN_WAPI */
3359
3360#ifdef WLAN_FEATURE_VOWIFI_11R
3361
3362/*
3363 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3364 * here. This matches for FT Auth with the 802.1X exchange.
3365 *
3366 */
3367static tANI_BOOLEAN csrIsFTAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3368 tANI_U8 cAllSuites,
3369 tANI_U8 Oui[] )
3370{
3371 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[03], Oui ) );
3372}
3373
3374/*
3375 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3376 * here. This matches for FT Auth with the PSK.
3377 *
3378 */
3379static tANI_BOOLEAN csrIsFTAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3380 tANI_U8 cAllSuites,
3381 tANI_U8 Oui[] )
3382{
3383 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[04], Oui ) );
3384}
3385
3386#endif
3387
3388#ifdef FEATURE_WLAN_CCX
3389
3390/*
3391 * Function for CCX CCKM AKM Authentication. We match the CCKM AKM Authentication Key Management suite
3392 * here. This matches for CCKM AKM Auth with the 802.1X exchange.
3393 *
3394 */
3395static tANI_BOOLEAN csrIsCcxCckmAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3396 tANI_U8 cAllSuites,
3397 tANI_U8 Oui[] )
3398{
3399 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[06], Oui ) );
3400}
3401
3402static tANI_BOOLEAN csrIsCcxCckmAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3403 tANI_U8 cAllSuites,
3404 tANI_U8 Oui[] )
3405{
3406 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[06], Oui ) );
3407}
3408
3409#endif
3410
3411static tANI_BOOLEAN csrIsAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3412 tANI_U8 cAllSuites,
3413 tANI_U8 Oui[] )
3414{
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[01], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003416}
3417static tANI_BOOLEAN csrIsAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3418 tANI_U8 cAllSuites,
3419 tANI_U8 Oui[] )
3420{
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[02], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003422}
3423
Chet Lanctot186b5732013-03-18 10:26:30 -07003424#ifdef WLAN_FEATURE_11W
3425static tANI_BOOLEAN csrIsAuthRSNPskSha256( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3426 tANI_U8 cAllSuites,
3427 tANI_U8 Oui[] )
3428{
Chet Lanctot4c986162013-05-08 13:59:56 -07003429 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[07], Oui );
Chet Lanctot186b5732013-03-18 10:26:30 -07003430}
3431#endif
3432
Jeff Johnson295189b2012-06-20 16:38:30 -07003433static tANI_BOOLEAN csrIsAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3434 tANI_U8 cAllSuites,
3435 tANI_U8 Oui[] )
3436{
3437 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[01], Oui ) );
3438}
3439
3440#ifdef NOT_CURRENTLY_USED
3441static tANI_BOOLEAN csrIsAuth802_1x( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3442 tANI_U8 cAllSuites,
3443 tANI_U8 Oui[] )
3444{
3445 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[00], Oui ) );
3446}
3447#endif // NOT_CURRENTLY_USED
3448
3449static tANI_BOOLEAN csrIsAuthWpaPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3450 tANI_U8 cAllSuites,
3451 tANI_U8 Oui[] )
3452{
3453 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[02], Oui ) );
3454}
3455#if 0
3456static tANI_BOOLEAN csrIsUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3457 tANI_U8 cAllCyphers,
3458 tANI_U8 Oui[] )
3459{
3460 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui00, Oui ) );
3461}
3462
3463static tANI_BOOLEAN csrIsUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3464 tANI_U8 cAllCyphers,
3465 tANI_U8 Oui[] )
3466{
3467 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3468}
3469
3470static tANI_BOOLEAN csrIsUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3471 tANI_U8 cAllCyphers,
3472 tANI_U8 Oui[] )
3473{
3474 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3475}
3476
3477
3478static tANI_BOOLEAN csrIsMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3479 tANI_U8 cAllCyphers,
3480 tANI_U8 Oui[] )
3481{
3482 tANI_BOOLEAN fYes = FALSE;
3483
3484 // Check Wep 104 first, if fails, then check Wep40.
3485 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui05, Oui );
3486
3487 if ( !fYes )
3488 {
3489 // if not Wep-104, check Wep-40
3490 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui01, Oui );
3491 }
3492
3493 return( fYes );
3494}
3495
3496
3497static tANI_BOOLEAN csrIsMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3498 tANI_U8 cAllCyphers,
3499 tANI_U8 Oui[] )
3500{
3501 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3502}
3503
3504
3505static tANI_BOOLEAN csrIsMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3506 tANI_U8 cAllCyphers,
3507 tANI_U8 Oui[] )
3508{
3509 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3510}
3511
3512#endif
3513
3514tANI_U8 csrGetOUIIndexFromCipher( eCsrEncryptionType enType )
3515{
3516 tANI_U8 OUIIndex;
3517
3518 switch ( enType )
3519 {
3520 case eCSR_ENCRYPT_TYPE_WEP40:
3521 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3522 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX;
3523 break;
3524 case eCSR_ENCRYPT_TYPE_WEP104:
3525 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3526 OUIIndex = CSR_OUI_WEP104_INDEX;
3527 break;
3528 case eCSR_ENCRYPT_TYPE_TKIP:
3529 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX;
3530 break;
3531 case eCSR_ENCRYPT_TYPE_AES:
3532 OUIIndex = CSR_OUI_AES_INDEX;
3533 break;
3534 case eCSR_ENCRYPT_TYPE_NONE:
3535 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX;
3536 break;
3537#ifdef FEATURE_WLAN_WAPI
3538 case eCSR_ENCRYPT_TYPE_WPI:
3539 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX;
3540 break;
3541#endif /* FEATURE_WLAN_WAPI */
3542 default: //HOWTO handle this?
3543 OUIIndex = CSR_OUI_RESERVED_INDEX;
3544 break;
3545 }//switch
3546
3547 return OUIIndex;
3548}
3549
3550tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3551 tDot11fIERSN *pRSNIe,
3552 tANI_U8 *UnicastCypher,
3553 tANI_U8 *MulticastCypher,
3554 tANI_U8 *AuthSuite,
3555 tCsrRSNCapabilities *Capabilities,
3556 eCsrAuthType *pNegotiatedAuthtype,
3557 eCsrEncryptionType *pNegotiatedMCCipher )
3558{
3559 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3560 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3561 tANI_U8 cUnicastCyphers = 0;
3562 tANI_U8 cMulticastCyphers = 0;
3563 tANI_U8 cAuthSuites = 0, i;
3564 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3565 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3566 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3567 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3568 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3569 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3570
3571 do{
3572 if ( pRSNIe->present )
3573 {
3574 cMulticastCyphers++;
3575 palCopyMemory(pMac->hHdd, MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
3576 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
3577 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_count);
3578 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3579 {
3580 palCopyMemory(pMac->hHdd, (void *)&AuthSuites[i],
3581 (void *)&pRSNIe->akm_suites[i], CSR_RSN_OUI_SIZE);
3582 }
3583
3584 //Check - Is requested Unicast Cipher supported by the BSS.
3585 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3586 csrGetOUIIndexFromCipher( enType ), Unicast );
3587
3588 if( !fAcceptableCyphers ) break;
3589
3590
3591 //Unicast is supported. Pick the first matching Group cipher, if any.
3592 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3593 {
3594 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3595 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3596 if(fAcceptableCyphers)
3597 {
3598 break;
3599 }
3600 }
3601 if( !fAcceptableCyphers ) break;
3602
3603 if( pNegotiatedMCCipher )
3604 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3605
3606 /* Initializing with FALSE as it has TRUE value already */
3607 fAcceptableCyphers = FALSE;
3608 for (i = 0 ; i < pAuthType->numEntries; i++)
3609 {
3610 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3611 #ifdef WLAN_FEATURE_VOWIFI_11R
3612 /* Changed the AKM suites according to order of preference */
3613 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3614 {
3615 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3616 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3617 }
3618 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3619 {
3620 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3621 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3622 }
3623#endif
3624#ifdef FEATURE_WLAN_CCX
3625 /* CCX only supports 802.1X. No PSK. */
3626 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsCcxCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3627 {
3628 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3629 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3630 }
3631#endif
3632 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3633 {
3634 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3635 negAuthType = eCSR_AUTH_TYPE_RSN;
3636 }
3637 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3638 {
3639 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3640 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3641 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003642#ifdef WLAN_FEATURE_11W
3643 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3644 {
3645 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3646 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3647 }
3648#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003649
3650 // The 1st auth type in the APs RSN IE, to match stations connecting
3651 // profiles auth type will cause us to exit this loop
3652 // This is added as some APs advertise multiple akms in the RSN IE.
3653 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3654 {
3655 fAcceptableCyphers = TRUE;
3656 break;
3657 }
3658 } // for
3659 }
3660
3661 }while (0);
3662
3663 if ( fAcceptableCyphers )
3664 {
3665 if ( MulticastCypher )
3666 {
3667 palCopyMemory( pMac->hHdd, MulticastCypher, Multicast, CSR_RSN_OUI_SIZE );
3668 }
3669
3670 if ( UnicastCypher )
3671 {
3672 palCopyMemory( pMac->hHdd, UnicastCypher, Unicast, CSR_RSN_OUI_SIZE );
3673 }
3674
3675 if ( AuthSuite )
3676 {
3677 palCopyMemory( pMac->hHdd, AuthSuite, Authentication, CSR_RSN_OUI_SIZE );
3678 }
3679
3680 if ( pNegotiatedAuthtype )
3681 {
3682 *pNegotiatedAuthtype = negAuthType;
3683 }
3684 if ( Capabilities )
3685 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003686 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3687 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3688 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003689 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
3690#ifdef WLAN_FEATURE_11W
3691 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3692 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
3693#endif
3694 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 }
3696 }
3697 return( fAcceptableCyphers );
3698}
3699
3700
3701tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
3702 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
3703{
3704 tANI_BOOLEAN fRSNMatch = FALSE;
3705
3706 // See if the cyphers in the Bss description match with the settings in the profile.
3707 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
3708 pNegotiatedAuthType, pNegotiatedMCCipher );
3709
3710 return( fRSNMatch );
3711}
3712
3713
3714tANI_BOOLEAN csrLookupPMKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pPMKId )
3715{
3716 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
3717 tANI_U32 Index;
3718 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3719
Jeff Johnson32d95a32012-09-10 13:15:23 -07003720 if(!pSession)
3721 {
3722 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3723 return FALSE;
3724 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003725 /* to force the AP initiate fresh 802.1x authentication after re-association should not
3726 * fill the PMKID from cache this is needed
3727 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
3728
3729 if(pSession->fIgnorePMKIDCache)
3730 {
3731 pSession->fIgnorePMKIDCache = FALSE;
3732 return fRC;
3733 }
3734
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 do
3736 {
3737 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
3738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003739 smsLog(pMac, LOGW, "match PMKID %02X-%02X-%02X-%02X-%02X-%02X to ",
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 pBSSId[0], pBSSId[1], pBSSId[2], pBSSId[3], pBSSId[4], pBSSId[5]);
3741 if( palEqualMemory( pMac->hHdd, pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
3742 {
3743 // match found
3744 fMatchFound = TRUE;
3745 break;
3746 }
3747 }
3748
3749 if( !fMatchFound ) break;
3750
3751 palCopyMemory( pMac->hHdd, pPMKId, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE );
3752
3753 fRC = TRUE;
3754 }
3755 while( 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003756 smsLog(pMac, LOGW, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 fRC, pSession->NumPmkidCache);
3758
3759 return fRC;
3760}
3761
3762
3763tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3764 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
3765{
3766 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3767 tANI_BOOLEAN fRSNMatch;
3768 tANI_U8 cbRSNIe = 0;
3769 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
3770 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
3771 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
3772 tCsrRSNAuthIe *pAuthSuite;
3773 tCsrRSNCapabilities RSNCapabilities;
3774 tCsrRSNPMKIe *pPMK;
3775 tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003776#ifdef WLAN_FEATURE_11W
3777 tANI_U8 *pGroupMgmtCipherSuite;
3778#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 tDot11fBeaconIEs *pIesLocal = pIes;
3780
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003781 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003782
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 do
3784 {
3785 if ( !csrIsProfileRSN( pProfile ) ) break;
3786
3787 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
3788 {
3789 break;
3790 }
3791
3792 // See if the cyphers in the Bss description match with the settings in the profile.
3793 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
3794 &pProfile->mcEncryptionType, &pIesLocal->RSN,
3795 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, NULL, NULL );
3796 if ( !fRSNMatch ) break;
3797
3798 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
3799
3800 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
3801
3802 palCopyMemory( pMac->hHdd, pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ) );
3803
3804 pRSNIe->cUnicastCyphers = 1;
3805
3806 palCopyMemory( pMac->hHdd, &pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ) );
3807
3808 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
3809
3810 pAuthSuite->cAuthenticationSuites = 1;
3811 palCopyMemory( pMac->hHdd, &pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ) );
3812
3813 // RSN capabilities follows the Auth Suite (two octects)
3814 // !!REVIEW - What should STA put in RSN capabilities, currently
3815 // just putting back APs capabilities
3816 // 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 -07003817 // For another, we should use the Management Frame Protection values given by the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 RSNCapabilities.PreAuthSupported = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003819#ifdef WLAN_FEATURE_11W
3820 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
3821 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
3822#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
3824
3825 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
3826
3827 if( csrLookupPMKID( pMac, sessionId, pSirBssDesc->bssId, &(PMKId[0]) ) )
3828 {
3829 pPMK->cPMKIDs = 1;
3830
3831 palCopyMemory( pMac->hHdd, pPMK->PMKIDList[0].PMKID, PMKId, CSR_RSN_PMKID_SIZE );
3832 }
3833 else
3834 {
3835 pPMK->cPMKIDs = 0;
3836 }
3837
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003838#ifdef WLAN_FEATURE_11W
3839 if ( pProfile->MFPEnabled )
3840 {
3841 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
3842 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
3843 palCopyMemory( pMac->hHdd, pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE );
3844 }
3845#endif
3846
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
3848 // Add in the size of the Auth suite (count plus a single OUI)
3849 // Add in the RSN caps field.
3850 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003851 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
3853 sizeof( *pAuthSuite ) +
3854 sizeof( tCsrRSNCapabilities ));
3855 if(pPMK->cPMKIDs)
3856 {
3857 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
3858 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
3859 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003860#ifdef WLAN_FEATURE_11W
3861 if ( pProfile->MFPEnabled )
3862 {
3863 if ( 0 == pPMK->cPMKIDs )
3864 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
3865 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
3866 }
3867#endif
3868
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 // return the size of the IE header (total) constructed...
3870 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
3871
3872 } while( 0 );
3873
3874 if( !pIes && pIesLocal )
3875 {
3876 //locally allocated
3877 palFreeMemory(pMac->hHdd, pIesLocal);
3878 }
3879
3880 return( cbRSNIe );
3881}
3882
3883
3884#ifdef FEATURE_WLAN_WAPI
3885tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3886 tDot11fIEWAPI *pWapiIe,
3887 tANI_U8 *UnicastCypher,
3888 tANI_U8 *MulticastCypher,
3889 tANI_U8 *AuthSuite,
3890 eCsrAuthType *pNegotiatedAuthtype,
3891 eCsrEncryptionType *pNegotiatedMCCipher )
3892{
3893 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3894 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3895 tANI_U8 cUnicastCyphers = 0;
3896 tANI_U8 cMulticastCyphers = 0;
3897 tANI_U8 cAuthSuites = 0, i;
3898 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
3899 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
3900 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
3901 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
3902 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
3903 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3904
3905 do{
3906 if ( pWapiIe->present )
3907 {
3908 cMulticastCyphers++;
3909 palCopyMemory(pMac->hHdd, MulticastCyphers, pWapiIe->multicast_cipher_suite, CSR_WAPI_OUI_SIZE);
3910 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
3911 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
3912 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
3913 {
3914 palCopyMemory(pMac->hHdd, (void *)&AuthSuites[i],
3915 (void *)&pWapiIe->akm_suites[i], CSR_WAPI_OUI_SIZE);
3916 }
3917
3918 //Check - Is requested Unicast Cipher supported by the BSS.
3919 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
3920 csrGetOUIIndexFromCipher( enType ), Unicast );
3921
3922 if( !fAcceptableCyphers ) break;
3923
3924
3925 //Unicast is supported. Pick the first matching Group cipher, if any.
3926 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3927 {
3928 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3929 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3930 if(fAcceptableCyphers)
3931 {
3932 break;
3933 }
3934 }
3935 if( !fAcceptableCyphers ) break;
3936
3937 if( pNegotiatedMCCipher )
3938 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3939
3940 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3941 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
3942 {
3943 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3944 }
3945 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3946 {
3947 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3948 }
3949 else
3950 {
3951 fAcceptableCyphers = FALSE;
3952 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3953 }
3954 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
3955 {
3956 //Caller doesn't care about auth type, or BSS doesn't match
3957 break;
3958 }
3959 fAcceptableCyphers = FALSE;
3960 for( i = 0 ; i < pAuthType->numEntries; i++ )
3961 {
3962 if( pAuthType->authType[i] == negAuthType )
3963 {
3964 fAcceptableCyphers = TRUE;
3965 break;
3966 }
3967 }
3968 }
3969 }while (0);
3970
3971 if ( fAcceptableCyphers )
3972 {
3973 if ( MulticastCypher )
3974 {
3975 palCopyMemory( pMac->hHdd, MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE );
3976 }
3977
3978 if ( UnicastCypher )
3979 {
3980 palCopyMemory( pMac->hHdd, UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE );
3981 }
3982
3983 if ( AuthSuite )
3984 {
3985 palCopyMemory( pMac->hHdd, AuthSuite, Authentication, CSR_WAPI_OUI_SIZE );
3986 }
3987
3988 if ( pNegotiatedAuthtype )
3989 {
3990 *pNegotiatedAuthtype = negAuthType;
3991 }
3992 }
3993 return( fAcceptableCyphers );
3994}
3995
3996tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
3997 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
3998{
3999 tANI_BOOLEAN fWapiMatch = FALSE;
4000
4001 // See if the cyphers in the Bss description match with the settings in the profile.
4002 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4003 pNegotiatedAuthType, pNegotiatedMCCipher );
4004
4005 return( fWapiMatch );
4006}
4007
4008tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4009{
4010 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4011 tANI_U32 Index;
4012 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4013
Jeff Johnson32d95a32012-09-10 13:15:23 -07004014 if(!pSession)
4015 {
4016 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4017 return FALSE;
4018 }
4019
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 do
4021 {
4022 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004024 smsLog(pMac, LOGW, "match BKID %02X-%02X-%02X-%02X-%02X-%02X to ",
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 pBSSId[0], pBSSId[1], pBSSId[2], pBSSId[3], pBSSId[4], pBSSId[5]);
4026 if( palEqualMemory( pMac->hHdd, pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
4027 {
4028 // match found
4029 fMatchFound = TRUE;
4030 break;
4031 }
4032 }
4033
4034 if( !fMatchFound ) break;
4035
4036 palCopyMemory( pMac->hHdd, pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE );
4037
4038 fRC = TRUE;
4039 }
4040 while( 0 );
4041 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4042
4043 return fRC;
4044}
4045
4046tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4047 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4048{
4049 tANI_BOOLEAN fWapiMatch = FALSE;
4050 tANI_U8 cbWapiIe = 0;
4051 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4052 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4053 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4054 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4055 tANI_U8 *pWapi = NULL;
4056 tANI_BOOLEAN fBKIDFound = FALSE;
4057 tDot11fBeaconIEs *pIesLocal = pIes;
4058
4059 do
4060 {
4061 if ( !csrIsProfileWapi( pProfile ) ) break;
4062
4063 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4064 {
4065 break;
4066 }
4067
4068 // See if the cyphers in the Bss description match with the settings in the profile.
4069 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4070 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4071 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4072 if ( !fWapiMatch ) break;
4073
4074 palZeroMemory(pMac->hHdd, pWapiIe, sizeof(tCsrWapiIe));
4075
4076 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4077
4078 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4079
4080 pWapiIe->cAuthenticationSuites = 1;
4081 palCopyMemory( pMac->hHdd, &pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ) );
4082
4083 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4084
4085 *pWapi = (tANI_U16)1; //cUnicastCyphers
4086 pWapi+=2;
4087 palCopyMemory( pMac->hHdd, pWapi, UnicastCypher, sizeof( UnicastCypher ) );
4088 pWapi += sizeof( UnicastCypher );
4089
4090 palCopyMemory( pMac->hHdd, pWapi, MulticastCypher, sizeof( MulticastCypher ) );
4091 pWapi += sizeof( MulticastCypher );
4092
4093
4094 // WAPI capabilities follows the Auth Suite (two octects)
4095 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4096 // & since we already did a memset pWapiIe to 0, skip these fields
4097 pWapi +=2;
4098
4099 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4100
4101
4102 if( fBKIDFound )
4103 {
4104 /* Do we need to change the endianness here */
4105 *pWapi = (tANI_U16)1; //cBKIDs
4106 pWapi+=2;
4107 palCopyMemory( pMac->hHdd, pWapi, BKId, CSR_WAPI_BKID_SIZE );
4108 }
4109 else
4110 {
4111 *pWapi = 0;
4112 pWapi+=1;
4113 *pWapi = 0;
4114 pWapi+=1;
4115 }
4116
4117 // Add in the IE fields except the IE header
4118 // Add BKID count and BKID (if any)
4119 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4120
4121 /*2 bytes for BKID Count field*/
4122 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4123
4124 if(fBKIDFound)
4125 {
4126 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4127 }
4128 // return the size of the IE header (total) constructed...
4129 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4130
4131 } while( 0 );
4132
4133 if( !pIes && pIesLocal )
4134 {
4135 //locally allocated
4136 palFreeMemory(pMac->hHdd, pIesLocal);
4137 }
4138
4139 return( cbWapiIe );
4140}
4141#endif /* FEATURE_WLAN_WAPI */
4142
4143tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4144 tDot11fIEWPA *pWpaIe,
4145 tANI_U8 *UnicastCypher,
4146 tANI_U8 *MulticastCypher,
4147 tANI_U8 *AuthSuite,
4148 eCsrAuthType *pNegotiatedAuthtype,
4149 eCsrEncryptionType *pNegotiatedMCCipher )
4150{
4151 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4152 tANI_U8 cUnicastCyphers = 0;
4153 tANI_U8 cMulticastCyphers = 0;
4154 tANI_U8 cAuthSuites = 0;
4155 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4156 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4157 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4158 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4159 tANI_U8 i;
4160 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4161
4162 do
4163 {
4164 if ( pWpaIe->present )
4165 {
4166 cMulticastCyphers = 1;
4167 palCopyMemory(pMac->hHdd, MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
4168 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4169 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4170
4171 //Check - Is requested Unicast Cipher supported by the BSS.
4172 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4173 csrGetOUIIndexFromCipher( enType ), Unicast );
4174
4175 if( !fAcceptableCyphers ) break;
4176
4177
4178 //Unicast is supported. Pick the first matching Group cipher, if any.
4179 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4180 {
4181 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4182 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4183 if(fAcceptableCyphers)
4184 {
4185 break;
4186 }
4187 }
4188 if( !fAcceptableCyphers ) break;
4189
4190 if( pNegotiatedMCCipher )
4191 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4192
4193 /* Initializing with FALSE as it has TRUE value already */
4194 fAcceptableCyphers = FALSE;
4195 for (i = 0 ; i < pAuthType->numEntries; i++)
4196 {
4197 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4198 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4199 {
4200 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4201 negAuthType = eCSR_AUTH_TYPE_WPA;
4202 }
4203 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4204 {
4205 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4206 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4207 }
4208#ifdef FEATURE_WLAN_CCX
4209 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsCcxCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4210 {
4211 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4212 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4213 }
4214#endif /* FEATURE_WLAN_CCX */
4215
4216 // The 1st auth type in the APs WPA IE, to match stations connecting
4217 // profiles auth type will cause us to exit this loop
4218 // This is added as some APs advertise multiple akms in the WPA IE.
4219 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4220 {
4221 fAcceptableCyphers = TRUE;
4222 break;
4223 }
4224 } // for
4225 }
4226 }while(0);
4227
4228 if ( fAcceptableCyphers )
4229 {
4230 if ( MulticastCypher )
4231 {
4232 palCopyMemory( pMac->hHdd, (tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE );
4233 }
4234
4235 if ( UnicastCypher )
4236 {
4237 palCopyMemory( pMac->hHdd, (tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE );
4238 }
4239
4240 if ( AuthSuite )
4241 {
4242 palCopyMemory( pMac->hHdd, (tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE );
4243 }
4244
4245 if( pNegotiatedAuthtype )
4246 {
4247 *pNegotiatedAuthtype = negAuthType;
4248 }
4249 }
4250
4251 return( fAcceptableCyphers );
4252}
4253
4254
4255
4256tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4257 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4258{
4259 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4260
4261 // See if the cyphers in the Bss description match with the settings in the profile.
4262 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4263
4264 return( fWpaMatch );
4265}
4266
4267
4268tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4269 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4270{
4271 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4272 tANI_BOOLEAN fWpaMatch;
4273 tANI_U8 cbWpaIe = 0;
4274 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4275 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4276 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4277 tCsrWpaAuthIe *pAuthSuite;
4278 tDot11fBeaconIEs *pIesLocal = pIes;
4279
4280 do
4281 {
4282 if ( !csrIsProfileWpa( pProfile ) ) break;
4283
4284 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4285 {
4286 break;
4287 }
4288 // See if the cyphers in the Bss description match with the settings in the profile.
4289 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4290 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4291 if ( !fWpaMatch ) break;
4292
4293 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4294
4295 palCopyMemory( pMac->hHdd, pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ) );
4296
4297 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4298
4299 palCopyMemory( pMac->hHdd, pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ) );
4300
4301 pWpaIe->cUnicastCyphers = 1;
4302
4303 palCopyMemory( pMac->hHdd, &pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ) );
4304
4305 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4306
4307 pAuthSuite->cAuthenticationSuites = 1;
4308 palCopyMemory( pMac->hHdd, &pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ) );
4309
4310 // The WPA capabilities follows the Auth Suite (two octects)--
4311 // this field is optional, and we always "send" zero, so just
4312 // remove it. This is consistent with our assumptions in the
4313 // frames compiler; c.f. bug 15234:
4314 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4315
4316 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4317 // Add in the size of the Auth suite (count plus a single OUI)
4318 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4319 sizeof( *pAuthSuite );
4320
4321 // return the size of the IE header (total) constructed...
4322 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4323
4324 } while( 0 );
4325
4326 if( !pIes && pIesLocal )
4327 {
4328 //locally allocated
4329 palFreeMemory(pMac->hHdd, pIesLocal);
4330 }
4331
4332 return( cbWpaIe );
4333}
4334
4335
4336tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4337 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4338{
4339 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4340 tDot11IEHeader *pIEHeader;
4341 tSirMacPropIE *pSirMacPropIE;
4342 tANI_U32 cbParsed;
4343 tANI_U32 cbIE;
4344 int cExpectedIEs = 0;
4345 int cFoundIEs = 0;
4346 int cbPropIETotal;
4347
4348 pIEHeader = (tDot11IEHeader *)pIes;
4349 if(pWpaIe) cExpectedIEs++;
4350 if(pRSNIe) cExpectedIEs++;
4351
4352 // bss description length includes all fields other than the length itself
4353 cbParsed = 0;
4354
4355 // Loop as long as there is data left in the IE of the Bss Description
4356 // and the number of Expected IEs is NOT found yet.
4357 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4358 {
4359 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4360
4361 if ( ( cbIE + cbParsed ) > len ) break;
4362
4363 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4364 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4365 {
4366 switch( pIEHeader->ElementID )
4367 {
4368 // Parse the 221 (0xdd) Proprietary IEs here...
4369 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4370 // Airgo proprietary IE information.
4371 case SIR_MAC_WPA_EID:
4372 {
4373 tANI_U32 aniOUI;
4374 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4375
4376 pOui++;
4377 aniOUI = ANI_OUI;
4378 aniOUI = i_ntohl( aniOUI );
4379
4380 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4381 cbPropIETotal = pSirMacPropIE->length;
4382
4383 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4384 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4385 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4386 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4387 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4388 {
4389 }
4390 else
4391 {
4392 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4393
4394 if(!pWpaIe || !pcbWpaIe) break;
4395 // Check if this is a valid WPA IE. Then check that the
4396 // WPA OUI is in place and the version is one that we support.
4397 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
4398 ( palEqualMemory(pMac->hHdd, pIe->Oui, (void *)csrWpaOui[1], sizeof( pIe->Oui ) ) ) &&
4399 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4400 {
4401 palCopyMemory(pMac->hHdd, pWpaIe, pIe, pIe->IeHeader.Length + sizeof( pIe->IeHeader ) );
4402 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4403 cFoundIEs++;
4404
4405 break;
4406 }
4407 }
4408
4409 break;
4410 }
4411
4412 case SIR_MAC_RSN_EID:
4413 {
4414 tCsrRSNIe *pIe;
4415
4416 if(!pcbRSNIe || !pRSNIe) break;
4417 pIe = (tCsrRSNIe *)pIEHeader;
4418
4419 // Check the length of the RSN Ie to assure it is valid. Then check that the
4420 // version is one that we support.
4421
4422 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4423 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4424
4425 cFoundIEs++;
4426
4427 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4428 // the buffer passed in.
4429 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
4430 palCopyMemory(pMac->hHdd, pRSNIe, pIe, pIe->IeHeader.Length + sizeof( pIe->IeHeader ) );
4431 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4432
4433 break;
4434 }
4435
4436 // Add support for other IE here...
4437 default:
4438 break;
4439 }
4440 }
4441
4442 cbParsed += cbIE;
4443
4444 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4445
4446 }
4447
4448 // return a BOOL that tells if all of the IEs asked for were found...
4449 return( cFoundIEs == cExpectedIEs );
4450}
4451
4452
4453//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4454//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4455tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4456 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4457{
4458 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4459 tANI_U8 cbWpaIe = 0;
4460
4461 do
4462 {
4463 if ( !csrIsProfileWpa( pProfile ) ) break;
4464 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4465 {
4466 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4467 {
4468 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
4469 palCopyMemory(pMac->hHdd, pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
4470 }
4471 else
4472 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004473 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 }
4475 }
4476 else
4477 {
4478 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4479 }
4480 }while(0);
4481
4482 return (cbWpaIe);
4483}
4484
4485
4486//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4487//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4488tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4489 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4490{
4491 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4492 tANI_U8 cbRsnIe = 0;
4493
4494 do
4495 {
4496 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004497#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304498 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004499 {
4500 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4501 // scratch. So it contains the current PMK-IDs
4502 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4503 }
4504 else
4505#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 if(pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
4507 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004508 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4510 {
4511 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
4512 palCopyMemory(pMac->hHdd, pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
4513 }
4514 else
4515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004516 smsLog(pMac, LOGW, " csrRetrieveRsnIe detect invalid RSN IE length (%d) ", pProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 }
4518 }
4519 else
4520 {
4521 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4522 }
4523 }while(0);
4524
4525 return (cbRsnIe);
4526}
4527
4528
4529#ifdef FEATURE_WLAN_WAPI
4530//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
4531//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
4532tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
4533 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4534 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4535{
4536 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4537 tANI_U8 cbWapiIe = 0;
4538
4539 do
4540 {
4541 if ( !csrIsProfileWapi( pProfile ) ) break;
4542 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
4543 {
4544 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
4545 {
4546 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
4547 palCopyMemory(pMac->hHdd, pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
4548 }
4549 else
4550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004551 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 }
4553 }
4554 else
4555 {
4556 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
4557 }
4558 }while(0);
4559
4560 return (cbWapiIe);
4561}
4562#endif /* FEATURE_WLAN_WAPI */
4563
4564tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
4565{
4566 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4567 tListElem *pEntry;
4568 tANI_U16 i;
4569 tANI_U16 startingChannel;
4570 tANI_BOOLEAN found = FALSE;
4571 tCsrChannelSet *pChannelGroup;
4572
4573 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
4574
4575 while ( pEntry )
4576 {
4577 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
4578 startingChannel = pChannelGroup->firstChannel;
4579 for ( i = 0; i < pChannelGroup->numChannels; i++ )
4580 {
4581 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
4582 {
4583 found = TRUE;
4584 break;
4585 }
4586 }
4587
4588 if ( found )
4589 {
4590 palCopyMemory(pMac->hHdd, returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
4591 break;
4592 }
4593 else
4594 {
4595 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
4596 }
4597 }
4598
4599 return( found );
4600}
4601
4602tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
4603{
4604 tANI_BOOLEAN fSupported = FALSE;
4605 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4606
4607 switch ( nonBasicRate )
4608 {
4609 case eCsrSuppRate_1Mbps:
4610 case eCsrSuppRate_2Mbps:
4611 case eCsrSuppRate_5_5Mbps:
4612 case eCsrSuppRate_11Mbps:
4613 fSupported = TRUE;
4614 break;
4615
4616 default:
4617 break;
4618 }
4619
4620 return( fSupported );
4621}
4622
4623tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
4624{
4625 tANI_BOOLEAN fSupported = FALSE;
4626 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4627
4628 switch ( nonBasicRate )
4629 {
4630 case eCsrSuppRate_6Mbps:
4631 case eCsrSuppRate_9Mbps:
4632 case eCsrSuppRate_12Mbps:
4633 case eCsrSuppRate_18Mbps:
4634 case eCsrSuppRate_24Mbps:
4635 case eCsrSuppRate_36Mbps:
4636 case eCsrSuppRate_48Mbps:
4637 case eCsrSuppRate_54Mbps:
4638 fSupported = TRUE;
4639 break;
4640
4641 default:
4642 break;
4643 }
4644
4645 return( fSupported );
4646}
4647
4648
4649
4650tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
4651{
4652 tAniEdType edType;
4653
4654 switch ( EncryptType )
4655 {
4656 default:
4657 case eCSR_ENCRYPT_TYPE_NONE:
4658 edType = eSIR_ED_NONE;
4659 break;
4660
4661 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4662 case eCSR_ENCRYPT_TYPE_WEP40:
4663 edType = eSIR_ED_WEP40;
4664 break;
4665
4666 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4667 case eCSR_ENCRYPT_TYPE_WEP104:
4668 edType = eSIR_ED_WEP104;
4669 break;
4670
4671 case eCSR_ENCRYPT_TYPE_TKIP:
4672 edType = eSIR_ED_TKIP;
4673 break;
4674
4675 case eCSR_ENCRYPT_TYPE_AES:
4676 edType = eSIR_ED_CCMP;
4677 break;
4678#ifdef FEATURE_WLAN_WAPI
4679 case eCSR_ENCRYPT_TYPE_WPI:
4680 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05304681 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004682#endif
4683#ifdef WLAN_FEATURE_11W
4684 //11w BIP
4685 case eCSR_ENCRYPT_TYPE_AES_CMAC:
4686 edType = eSIR_ED_AES_128_CMAC;
4687 break;
4688#endif
4689 }
4690
4691 return( edType );
4692}
4693
4694
4695//pIes can be NULL
4696tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
4697 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
4698 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
4699 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
4700{
4701 tANI_U32 idx;
4702 tANI_BOOLEAN fMatch = FALSE;
4703 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4704 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4705
4706 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
4707
4708 do
4709 {
4710 //If privacy bit is not set, consider no match
4711 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
4712
4713 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
4714 {
4715 switch( pMCEncryptionList->encryptionType[idx] )
4716 {
4717 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4718 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4719 case eCSR_ENCRYPT_TYPE_WEP40:
4720 case eCSR_ENCRYPT_TYPE_WEP104:
4721 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
4722 */
4723 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
4724 {
4725 fMatch = TRUE;
4726 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
4727 }
4728 break;
4729 default:
4730 fMatch = FALSE;
4731 break;
4732 }
4733 if(fMatch) break;
4734 }
4735
4736 if(!fMatch) break;
4737
4738 for( idx = 0; idx < pAuthList->numEntries; idx++ )
4739 {
4740 switch( pAuthList->authType[idx] )
4741 {
4742 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4743 case eCSR_AUTH_TYPE_SHARED_KEY:
4744 case eCSR_AUTH_TYPE_AUTOSWITCH:
4745 fMatch = TRUE;
4746 negotiatedAuth = pAuthList->authType[idx];
4747 break;
4748 default:
4749 fMatch = FALSE;
4750 }
4751 if (fMatch) break;
4752 }
4753
4754 if(!fMatch) break;
4755 //In case of WPA / WPA2, check whether it supports WEP as well
4756 if(pIes)
4757 {
4758 //Prepare the encryption type for WPA/WPA2 functions
4759 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
4760 {
4761 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4762 }
4763 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
4764 {
4765 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4766 }
4767 //else we can use the encryption type directly
4768 if( pIes->WPA.present )
4769 {
4770 fMatch = palEqualMemory(pMac->hHdd, pIes->WPA.multicast_cipher,
4771 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )], CSR_WPA_OUI_SIZE );
4772 if( fMatch ) break;
4773 }
4774 if( pIes->RSN.present )
4775 {
4776 fMatch = palEqualMemory(pMac->hHdd, pIes->RSN.gp_cipher_suite,
4777 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )], CSR_RSN_OUI_SIZE );
4778 }
4779 }
4780
4781 }while(0);
4782
4783 if( fMatch )
4784 {
4785 if( pNegotiatedAuthType )
4786 *pNegotiatedAuthType = negotiatedAuth;
4787
4788 if( pNegotiatedMCEncryption )
4789 *pNegotiatedMCEncryption = negotiatedMCCipher;
4790 }
4791
4792
4793 return fMatch;
4794}
4795
4796
4797//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
4798tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType, tCsrEncryptionList *pUCEncryptionType, tCsrEncryptionList *pMCEncryptionType,
4799 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
4800 eCsrAuthType *negotiatedAuthtype, eCsrEncryptionType *negotiatedUCCipher, eCsrEncryptionType *negotiatedMCCipher )
4801{
4802 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4803 tANI_BOOLEAN fMatch = FALSE;
4804 tANI_U8 i,idx;
4805 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4806 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4807
4808 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
4809 {
4810 ucCipher = pUCEncryptionType->encryptionType[i];
4811 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
4812 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
4813 // encryption type.
4814 switch ( ucCipher )
4815 {
4816 case eCSR_ENCRYPT_TYPE_NONE:
4817 {
4818 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
4819 // required so we have to reject this Bss.
4820 if ( csrIsPrivacy( pSirBssDesc ) )
4821 {
4822 fMatch = FALSE;
4823 }
4824 else
4825 {
4826 fMatch = TRUE;
4827 }
4828
4829 if ( fMatch )
4830 {
4831 fMatch = FALSE;
4832 //Check Multicast cipher requested and Auth type requested.
4833 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
4834 {
4835 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
4836 {
4837 fMatch = TRUE; //Multicast can only be none.
4838 mcCipher = pMCEncryptionType->encryptionType[idx];
4839 break;
4840 }
4841 }
4842 if (!fMatch) break;
4843
4844 fMatch = FALSE;
4845 //Check Auth list. It should contain AuthOpen.
4846 for( idx = 0 ; idx < authType->numEntries ; idx++ )
4847 {
4848 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
4849 {
4850 fMatch = TRUE;
4851 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4852 break;
4853 }
4854 }
4855 if (!fMatch) break;
4856
4857 }
4858 break;
4859 }
4860
4861 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4862 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4863 // !! might want to check for WEP keys set in the Profile.... ?
4864 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
4865 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
4866 // encryption is not allowed without the Privacy bit turned on.
4867 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4868
4869 break;
4870
4871 // these are all of the WPA encryption types...
4872 case eCSR_ENCRYPT_TYPE_WEP40:
4873 case eCSR_ENCRYPT_TYPE_WEP104:
4874 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4875 break;
4876
4877 case eCSR_ENCRYPT_TYPE_TKIP:
4878 case eCSR_ENCRYPT_TYPE_AES:
4879 {
4880 if(pIes)
4881 {
4882 // First check if there is a RSN match
4883 fMatch = csrIsRSNMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4884 if( !fMatch )
4885 {
4886 // If not RSN, then check if there is a WPA match
4887 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
4888 &negAuthType, &mcCipher );
4889 }
4890 }
4891 else
4892 {
4893 fMatch = FALSE;
4894 }
4895 break;
4896 }
4897#ifdef FEATURE_WLAN_WAPI
4898 case eCSR_ENCRYPT_TYPE_WPI://WAPI
4899 {
4900 if(pIes)
4901 {
4902 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4903 }
4904 else
4905 {
4906 fMatch = FALSE;
4907 }
4908 break;
4909 }
4910#endif /* FEATURE_WLAN_WAPI */
4911 case eCSR_ENCRYPT_TYPE_ANY:
4912 default:
4913 {
4914 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
4915
4916 fMatch = eANI_BOOLEAN_TRUE;
4917 //It is allowed to match anything. Try the more secured ones first.
4918 if(pIes)
4919 {
4920 //Check AES first
4921 ucCipher = eCSR_ENCRYPT_TYPE_AES;
4922 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4923 if(!fMatchAny)
4924 {
4925 //Check TKIP
4926 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
4927 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4928 }
4929#ifdef FEATURE_WLAN_WAPI
4930 if(!fMatchAny)
4931 {
4932 //Check WAPI
4933 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
4934 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4935 }
4936#endif /* FEATURE_WLAN_WAPI */
4937 }
4938 if(!fMatchAny)
4939 {
4940 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
4941 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4942 {
4943 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
4944 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4945 {
4946 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4947 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4948 {
4949 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4950 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4951 {
4952 //It must be open and no encryption
4953 if ( csrIsPrivacy( pSirBssDesc ) )
4954 {
4955 //This is not right
4956 fMatch = eANI_BOOLEAN_FALSE;
4957 }
4958 else
4959 {
4960 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4961 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
4962 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
4963 }
4964 }
4965 }
4966 }
4967 }
4968 }
4969 break;
4970 }
4971 }
4972
4973 }
4974
4975 if( fMatch )
4976 {
4977 if( negotiatedUCCipher )
4978 *negotiatedUCCipher = ucCipher;
4979
4980 if( negotiatedMCCipher )
4981 *negotiatedMCCipher = mcCipher;
4982
4983 if( negotiatedAuthtype )
4984 *negotiatedAuthtype = negAuthType;
4985 }
4986
4987 return( fMatch );
4988}
4989
4990
4991tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
4992 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
4993{
4994 tANI_BOOLEAN fMatch = FALSE;
4995
4996 do {
4997
4998 // There are a few special cases. If the Bss description has a Broadcast SSID,
4999 // then our Profile must have a single SSID without Wildcards so we can program
5000 // the SSID.
5001 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5002 // but the SSID value is all NULL characters. That condition is trated same
5003 // as NULL SSID
5004 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5005 {
5006 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5007 {
5008 fMatch = TRUE;
5009 }
5010 break;
5011 }
5012
5013 // Check for the specification of the Broadcast SSID at the beginning of the list.
5014 // If specified, then all SSIDs are matches (broadcast SSID means accept all SSIDs).
5015 if ( ssid1Len == 0 )
5016 {
5017 fMatch = TRUE;
5018 break;
5019 }
5020
5021 if(ssid1Len != bssSsidLen) break;
5022 if(palEqualMemory(pMac->hHdd, bssSsid, ssid1, bssSsidLen))
5023 {
5024 fMatch = TRUE;
5025 break;
5026 }
5027
5028 } while( 0 );
5029
5030 return( fMatch );
5031}
5032
5033
5034//Null ssid means match
5035tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5036{
5037 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5038 tANI_BOOLEAN fMatch = FALSE;
5039 tANI_U32 i;
5040
5041 if ( pSsidList && pSsid )
5042 {
5043 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5044 {
5045 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
5046 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5047 palEqualMemory(pMac->hHdd, pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
5048 {
5049 fMatch = TRUE;
5050 break;
5051 }
5052 }
5053 }
5054
5055 return (fMatch);
5056}
5057
5058//like to use sirCompareMacAddr
5059tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5060{
5061 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5062
5063 return( palEqualMemory(pMac->hHdd, bssid, pMacAddr, WNI_CFG_BSSID_LEN));
5064}
5065
5066//like to use sirCompareMacAddr
5067tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5068{
5069 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5070
5071 return( palEqualMemory(pMac->hHdd, bssid, pMacAddr, WNI_CFG_BSSID_LEN));
5072}
5073
5074
5075//like to use sirCompareMacAddr
5076tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5077{
5078 return( palEqualMemory(pMac->hHdd, pMacAddr1, pMacAddr2, sizeof(tCsrBssid)) );
5079}
5080
5081
5082tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5083{
5084 tANI_BOOLEAN fMatch = FALSE;
5085 tCsrBssid ProfileBssid;
5086 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5087
5088 // for efficiency of the MAC_ADDRESS functions, move the
5089 // Bssid's into MAC_ADDRESS structs.
5090 palCopyMemory( pMac->hHdd, &ProfileBssid, pProfBssid, sizeof(tCsrBssid) );
5091
5092 do {
5093
5094 // Give the profile the benefit of the doubt... accept either all 0 or
5095 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5096 // match any Bssids).
5097 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5098 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5099 {
5100 fMatch = TRUE;
5101 break;
5102 }
5103
5104 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5105 {
5106 fMatch = TRUE;
5107 break;
5108 }
5109
5110 } while( 0 );
5111
5112 return( fMatch );
5113}
5114
5115
5116tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5117{
5118 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5119 return eANI_BOOLEAN_FALSE;
5120 else
5121 return eANI_BOOLEAN_TRUE;
5122}
5123
5124
5125tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5126{
5127 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5128}
5129
5130tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5131{
5132 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5133}
5134
5135tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5136{
5137 tANI_BOOLEAN fMatch = TRUE;
5138
5139 do
5140 {
5141 switch( bssType )
5142 {
5143 case eCSR_BSS_TYPE_ANY:
5144 break;
5145
5146 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5147 case eCSR_BSS_TYPE_WDS_STA:
5148 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5149 fMatch = FALSE;
5150
5151 break;
5152
5153 case eCSR_BSS_TYPE_IBSS:
5154 case eCSR_BSS_TYPE_START_IBSS:
5155 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5156 fMatch = FALSE;
5157
5158 break;
5159
5160 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5161 default:
5162 fMatch = FALSE;
5163 break;
5164 }
5165 }
5166 while( 0 );
5167
5168
5169 return( fMatch );
5170}
5171
5172static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5173{
5174 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5175}
5176
5177
5178
5179static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5180{
5181 tANI_BOOLEAN fMatch = TRUE;
5182
5183 do
5184 {
5185 // if the channel is ANY, then always match...
5186 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5187 if ( Channel == pSirBssDesc->channelId ) break;
5188
5189 // didn't match anything.. so return NO match
5190 fMatch = FALSE;
5191
5192 } while( 0 );
5193
5194 return( fMatch );
5195}
5196
5197
5198tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5199{
5200 tANI_BOOLEAN fMatch = TRUE;
5201
5202 do
5203 {
5204 // if the profile says Any channel AND the global settings says ANY channel, then we
5205 // always match...
5206 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5207
5208 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5209 {
5210 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5211 }
5212
5213 } while( 0 );
5214
5215 return( fMatch );
5216}
5217
5218
5219/**
5220 * \brief Enquire as to whether a given rate is supported by the
5221 * adapter as currently configured
5222 *
5223 *
5224 * \param nRate A rate in units of 500kbps
5225 *
5226 * \return TRUE if the adapter is currently capable of supporting this
5227 * rate, FALSE else
5228 *
5229 *
5230 * The rate encoding is just as in 802.11 Information Elements, except
5231 * that the high bit is \em not interpreted as indicating a Basic Rate,
5232 * and proprietary rates are allowed, too.
5233 *
5234 * Note that if the adapter's dot11Mode is g, we don't restrict the
5235 * rates. According to hwReadEepromParameters, this will happen when:
5236 *
5237 * ... the card is configured for ALL bands through the property
5238 * page. If this occurs, and the card is not an ABG card ,then this
5239 * code is setting the dot11Mode to assume the mode that the
5240 * hardware can support. For example, if the card is an 11BG card
5241 * and we are configured to support ALL bands, then we change the
5242 * dot11Mode to 11g because ALL in this case is only what the
5243 * hardware can support.
5244 *
5245 *
5246 */
5247
5248static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5249{
5250 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5251 tANI_U16 idx, newRate;
5252
5253 //In case basic rate flag is set
5254 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5255 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5256 {
5257 switch ( newRate )
5258 {
5259 case eCsrSuppRate_6Mbps:
5260 case eCsrSuppRate_9Mbps:
5261 case eCsrSuppRate_12Mbps:
5262 case eCsrSuppRate_18Mbps:
5263 case eCsrSuppRate_24Mbps:
5264 case eCsrSuppRate_36Mbps:
5265 case eCsrSuppRate_48Mbps:
5266 case eCsrSuppRate_54Mbps:
5267 fSupported = TRUE;
5268 break;
5269 default:
5270 fSupported = FALSE;
5271 break;
5272 }
5273
5274 }
5275 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5276 {
5277 switch ( newRate )
5278 {
5279 case eCsrSuppRate_1Mbps:
5280 case eCsrSuppRate_2Mbps:
5281 case eCsrSuppRate_5_5Mbps:
5282 case eCsrSuppRate_11Mbps:
5283 fSupported = TRUE;
5284 break;
5285 default:
5286 fSupported = FALSE;
5287 break;
5288 }
5289 }
5290 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5291 {
5292
5293 switch ( newRate )
5294 {
5295 case eCsrSuppRate_1Mbps:
5296 case eCsrSuppRate_2Mbps:
5297 case eCsrSuppRate_5_5Mbps:
5298 case eCsrSuppRate_6Mbps:
5299 case eCsrSuppRate_9Mbps:
5300 case eCsrSuppRate_11Mbps:
5301 case eCsrSuppRate_12Mbps:
5302 case eCsrSuppRate_18Mbps:
5303 case eCsrSuppRate_24Mbps:
5304 case eCsrSuppRate_36Mbps:
5305 case eCsrSuppRate_48Mbps:
5306 case eCsrSuppRate_54Mbps:
5307 fSupported = TRUE;
5308 break;
5309 default:
5310 fSupported = FALSE;
5311 break;
5312 }
5313
5314 }
5315 else {
5316
5317 if ( eCsrSuppRate_1Mbps == newRate ||
5318 eCsrSuppRate_2Mbps == newRate ||
5319 eCsrSuppRate_5_5Mbps == newRate ||
5320 eCsrSuppRate_11Mbps == newRate )
5321 {
5322 fSupported = TRUE;
5323 }
5324 else {
5325 idx = 0x1;
5326
5327 switch ( newRate )
5328 {
5329 case eCsrSuppRate_6Mbps:
5330 fSupported = gPhyRatesSuppt[0][idx];
5331 break;
5332 case eCsrSuppRate_9Mbps:
5333 fSupported = gPhyRatesSuppt[1][idx];
5334 break;
5335 case eCsrSuppRate_12Mbps:
5336 fSupported = gPhyRatesSuppt[2][idx];
5337 break;
5338 case eCsrSuppRate_18Mbps:
5339 fSupported = gPhyRatesSuppt[3][idx];
5340 break;
5341 case eCsrSuppRate_20Mbps:
5342 fSupported = gPhyRatesSuppt[4][idx];
5343 break;
5344 case eCsrSuppRate_24Mbps:
5345 fSupported = gPhyRatesSuppt[5][idx];
5346 break;
5347 case eCsrSuppRate_36Mbps:
5348 fSupported = gPhyRatesSuppt[6][idx];
5349 break;
5350 case eCsrSuppRate_40Mbps:
5351 fSupported = gPhyRatesSuppt[7][idx];
5352 break;
5353 case eCsrSuppRate_42Mbps:
5354 fSupported = gPhyRatesSuppt[8][idx];
5355 break;
5356 case eCsrSuppRate_48Mbps:
5357 fSupported = gPhyRatesSuppt[9][idx];
5358 break;
5359 case eCsrSuppRate_54Mbps:
5360 fSupported = gPhyRatesSuppt[10][idx];
5361 break;
5362 case eCsrSuppRate_72Mbps:
5363 fSupported = gPhyRatesSuppt[11][idx];
5364 break;
5365 case eCsrSuppRate_80Mbps:
5366 fSupported = gPhyRatesSuppt[12][idx];
5367 break;
5368 case eCsrSuppRate_84Mbps:
5369 fSupported = gPhyRatesSuppt[13][idx];
5370 break;
5371 case eCsrSuppRate_96Mbps:
5372 fSupported = gPhyRatesSuppt[14][idx];
5373 break;
5374 case eCsrSuppRate_108Mbps:
5375 fSupported = gPhyRatesSuppt[15][idx];
5376 break;
5377 case eCsrSuppRate_120Mbps:
5378 fSupported = gPhyRatesSuppt[16][idx];
5379 break;
5380 case eCsrSuppRate_126Mbps:
5381 fSupported = gPhyRatesSuppt[17][idx];
5382 break;
5383 case eCsrSuppRate_144Mbps:
5384 fSupported = gPhyRatesSuppt[18][idx];
5385 break;
5386 case eCsrSuppRate_160Mbps:
5387 fSupported = gPhyRatesSuppt[19][idx];
5388 break;
5389 case eCsrSuppRate_168Mbps:
5390 fSupported = gPhyRatesSuppt[20][idx];
5391 break;
5392 case eCsrSuppRate_192Mbps:
5393 fSupported = gPhyRatesSuppt[21][idx];
5394 break;
5395 case eCsrSuppRate_216Mbps:
5396 fSupported = gPhyRatesSuppt[22][idx];
5397 break;
5398 case eCsrSuppRate_240Mbps:
5399 fSupported = gPhyRatesSuppt[23][idx];
5400 break;
5401 default:
5402 fSupported = FALSE;
5403 break;
5404 }
5405 }
5406 }
5407
5408 return fSupported;
5409}
5410
5411
5412
5413static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5414 tDot11fIESuppRates *pBssSuppRates,
5415 tDot11fIEExtSuppRates *pBssExtSuppRates )
5416{
5417 tANI_BOOLEAN fMatch = TRUE;
5418 tANI_U32 i;
5419
5420
5421 // Validate that all of the Basic rates advertised in the Bss description are supported.
5422 if ( pBssSuppRates )
5423 {
5424 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5425 {
5426 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5427 {
5428 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5429 {
5430 fMatch = FALSE;
5431 break;
5432 }
5433 }
5434 }
5435 }
5436
5437 if ( fMatch && pBssExtSuppRates )
5438 {
5439 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5440 {
5441 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5442 {
5443 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5444 {
5445 fMatch = FALSE;
5446 break;
5447 }
5448 }
5449 }
5450 }
5451
5452 return( fMatch );
5453
5454}
5455
5456
5457//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
5458tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
5459 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
5460 tDot11fBeaconIEs **ppIes)
5461{
5462 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5463 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5464 tANI_U32 i;
5465 tDot11fBeaconIEs *pIes = NULL;
5466 tANI_U8 *pb;
5467
5468 do {
5469 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
5470 {
5471 //If no IEs passed in, get our own.
5472 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
5473 {
5474 break;
5475 }
5476 }
5477 else
5478 {
5479 //Save the one pass in for local use
5480 pIes = *ppIes;
5481 }
5482
5483 //Check if caller wants P2P
5484 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
5485 if(!fCheck) break;
5486
5487 if(pIes->SSID.present)
5488 {
5489 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
5490 {
5491 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
5492 pIes->SSID.ssid,
5493 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
5494 if ( fCheck ) break;
5495 }
5496 if(!fCheck) break;
5497 }
5498 fCheck = eANI_BOOLEAN_TRUE;
5499 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
5500 {
5501 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
5502 if ( fCheck ) break;
5503
5504 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
5505 {
5506 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
5507 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
5508
5509 if ( fCheck ) break;
5510 }
5511 }
5512 if(!fCheck) break;
5513
5514 fCheck = eANI_BOOLEAN_TRUE;
5515 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
5516 {
5517 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
5518 if ( fCheck ) break;
5519 }
5520 if(!fCheck)
5521 break;
5522#if defined WLAN_FEATURE_VOWIFI
5523 /* If this is for measurement filtering */
5524 if( pFilter->fMeasurement )
5525 {
5526 fRC = eANI_BOOLEAN_TRUE;
5527 break;
5528 }
5529#endif
5530 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
5531 if ( (!pFilter->bWPSAssociation) &&
5532 !csrIsSecurityMatch( pMac, &pFilter->authType, &pFilter->EncryptionType, &pFilter->mcEncryptionType,
5533 pBssDesc, pIes, pNegAuth, pNegUc, pNegMc ) ) break;
5534 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
5535 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
5536 //Tush-QoS: validate first if asked for APSD or WMM association
5537 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
5538 !CSR_IS_QOS_BSS(pIes) )
5539 break;
5540 //Check country. check even when pb is NULL because we may want to make sure
5541 //AP has a country code in it if fEnforceCountryCodeMatch is set.
5542 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
5543
5544 fCheck = csrMatchCountryCode( pMac, pb, pIes );
5545 if(!fCheck)
5546 break;
5547
5548#ifdef WLAN_FEATURE_VOWIFI_11R
5549 if (pFilter->MDID.mdiePresent)
5550 {
5551 if (pBssDesc->mdiePresent)
5552 {
5553 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
5554 break;
5555 }
5556 else
5557 break;
5558 }
5559#endif
5560 fRC = eANI_BOOLEAN_TRUE;
5561
5562 } while( 0 );
5563 if( ppIes )
5564 {
5565 *ppIes = pIes;
5566 }
5567 else if( pIes )
5568 {
5569 palFreeMemory(pMac->hHdd, pIes);
5570 }
5571
5572 return( fRC );
5573}
5574
5575tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
5576 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
5577{
5578 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
5579 tCsrAuthList authList;
5580
5581 ucEncryptionList.numEntries = 1;
5582 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
5583
5584 mcEncryptionList.numEntries = 1;
5585 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
5586
5587 authList.numEntries = 1;
5588 authList.authType[0] = pProfile->AuthType;
5589
5590 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList, &mcEncryptionList, pBssDesc, pIes, NULL, NULL, NULL ));
5591
5592}
5593
5594
5595tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
5596 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
5597{
5598 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5599 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5600 tDot11fBeaconIEs *pIesLocal = pIes;
5601
5602 do {
5603 if( !pIes )
5604 {
5605 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
5606 {
5607 break;
5608 }
5609 }
5610 fCheck = eANI_BOOLEAN_TRUE;
5611 if(pIesLocal->SSID.present)
5612 {
5613 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
5614 if(pProfile->SSID.length)
5615 {
5616 fCheckSsid = eANI_BOOLEAN_TRUE;
5617 }
5618 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
5619 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
5620 if(!fCheck) break;
5621 }
5622 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
5623 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
5624 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
5625 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
5626 if(!fCheck)
5627 break;
5628
5629 fRC = eANI_BOOLEAN_TRUE;
5630
5631 } while( 0 );
5632
5633 if( !pIes && pIesLocal )
5634 {
5635 //locally allocated
5636 palFreeMemory(pMac->hHdd, pIesLocal);
5637 }
5638
5639 return( fRC );
5640}
5641
5642
5643
5644tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
5645{
5646 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5647 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
5648
5649 return csrIsAggregateRateSupported( pMac, n );
5650}
5651
5652
5653tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
5654{
5655 tANI_U16 ConvertedRate = Rate;
5656
5657 switch( Rate )
5658 {
5659 case SIR_MAC_RATE_1:
5660 ConvertedRate = 2;
5661 break;
5662 case SIR_MAC_RATE_2:
5663 ConvertedRate = 4;
5664 break;
5665 case SIR_MAC_RATE_5_5:
5666 ConvertedRate = 11;
5667 break;
5668 case SIR_MAC_RATE_11:
5669 ConvertedRate = 22;
5670 break;
5671
5672 case SIR_MAC_RATE_6:
5673 ConvertedRate = 12;
5674 break;
5675 case SIR_MAC_RATE_9:
5676 ConvertedRate = 18;
5677 break;
5678 case SIR_MAC_RATE_12:
5679 ConvertedRate = 24;
5680 break;
5681 case SIR_MAC_RATE_18:
5682 ConvertedRate = 36;
5683 break;
5684 case SIR_MAC_RATE_24:
5685 ConvertedRate = 48;
5686 break;
5687 case SIR_MAC_RATE_36:
5688 ConvertedRate = 72;
5689 break;
5690 case SIR_MAC_RATE_42:
5691 ConvertedRate = 84;
5692 break;
5693 case SIR_MAC_RATE_48:
5694 ConvertedRate = 96;
5695 break;
5696 case SIR_MAC_RATE_54:
5697 ConvertedRate = 108;
5698 break;
5699
5700 case SIR_MAC_RATE_72:
5701 ConvertedRate = 144;
5702 break;
5703 case SIR_MAC_RATE_84:
5704 ConvertedRate = 168;
5705 break;
5706 case SIR_MAC_RATE_96:
5707 ConvertedRate = 192;
5708 break;
5709 case SIR_MAC_RATE_108:
5710 ConvertedRate = 216;
5711 break;
5712 case SIR_MAC_RATE_126:
5713 ConvertedRate = 252;
5714 break;
5715 case SIR_MAC_RATE_144:
5716 ConvertedRate = 288;
5717 break;
5718 case SIR_MAC_RATE_168:
5719 ConvertedRate = 336;
5720 break;
5721 case SIR_MAC_RATE_192:
5722 ConvertedRate = 384;
5723 break;
5724 case SIR_MAC_RATE_216:
5725 ConvertedRate = 432;
5726 break;
5727 case SIR_MAC_RATE_240:
5728 ConvertedRate = 480;
5729 break;
5730
5731 case 0xff:
5732 ConvertedRate = 0;
5733 break;
5734 }
5735
5736 return ConvertedRate;
5737}
5738
5739
5740tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
5741{
5742 tANI_U8 i;
5743 tANI_U16 nBest;
5744
5745 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
5746
5747 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
5748 {
5749 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
5750 }
5751
5752 for ( i = 1U; i < pSuppRates->numRates; ++i )
5753 {
5754 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5755 }
5756
5757 if ( NULL != pExtRates )
5758 {
5759 for ( i = 0U; i < pExtRates->numRates; ++i )
5760 {
5761 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5762 }
5763 }
5764
5765 if ( NULL != pPropRates )
5766 {
5767 for ( i = 0U; i < pPropRates->numPropRates; ++i )
5768 {
5769 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
5770 }
5771 }
5772
5773 return nBest;
5774}
5775
5776
5777void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
5778{
5779 if(pProfile)
5780 {
5781 if(pProfile->BSSIDs.bssid)
5782 {
5783 palFreeMemory(pMac->hHdd, pProfile->BSSIDs.bssid);
5784 pProfile->BSSIDs.bssid = NULL;
5785 }
5786 if(pProfile->SSIDs.SSIDList)
5787 {
5788 palFreeMemory(pMac->hHdd, pProfile->SSIDs.SSIDList);
5789 pProfile->SSIDs.SSIDList = NULL;
5790 }
5791 if(pProfile->pWPAReqIE)
5792 {
5793 palFreeMemory(pMac->hHdd, pProfile->pWPAReqIE);
5794 pProfile->pWPAReqIE = NULL;
5795 }
5796 if(pProfile->pRSNReqIE)
5797 {
5798 palFreeMemory(pMac->hHdd, pProfile->pRSNReqIE);
5799 pProfile->pRSNReqIE = NULL;
5800 }
5801#ifdef FEATURE_WLAN_WAPI
5802 if(pProfile->pWAPIReqIE)
5803 {
5804 palFreeMemory(pMac->hHdd, pProfile->pWAPIReqIE);
5805 pProfile->pWAPIReqIE = NULL;
5806 }
5807#endif /* FEATURE_WLAN_WAPI */
5808
5809 if(pProfile->pAddIEScan)
5810 {
5811 palFreeMemory(pMac->hHdd, pProfile->pAddIEScan);
5812 pProfile->pAddIEScan = NULL;
5813 }
5814
5815 if(pProfile->pAddIEAssoc)
5816 {
5817 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
5818 pProfile->pAddIEAssoc = NULL;
5819 }
5820 {
5821 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
5822 pProfile->pAddIEAssoc = NULL;
5823 }
5824
5825 if(pProfile->ChannelInfo.ChannelList)
5826 {
5827 palFreeMemory(pMac->hHdd, pProfile->ChannelInfo.ChannelList);
5828 pProfile->ChannelInfo.ChannelList = NULL;
5829 }
5830
5831
5832 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
5833 }
5834}
5835
5836void csrFreeScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
5837{
5838 if(pScanFilter->BSSIDs.bssid)
5839 {
5840 palFreeMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid);
5841 pScanFilter->BSSIDs.bssid = NULL;
5842 }
5843 if(pScanFilter->ChannelInfo.ChannelList)
5844 {
5845 palFreeMemory(pMac->hHdd, pScanFilter->ChannelInfo.ChannelList);
5846 pScanFilter->ChannelInfo.ChannelList = NULL;
5847 }
5848 if(pScanFilter->SSIDs.SSIDList)
5849 {
5850 palFreeMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList);
5851 pScanFilter->SSIDs.SSIDList = NULL;
5852 }
5853}
5854
5855
5856void csrFreeRoamProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
5857{
5858 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
5859
5860 if(pSession->pCurRoamProfile)
5861 {
5862 csrReleaseProfile(pMac, pSession->pCurRoamProfile);
5863 palFreeMemory(pMac->hHdd, pSession->pCurRoamProfile);
5864 pSession->pCurRoamProfile = NULL;
5865 }
5866}
5867
5868
5869void csrFreeConnectBssDesc(tpAniSirGlobal pMac, tANI_U32 sessionId)
5870{
5871 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
5872
5873 if(pSession->pConnectBssDesc)
5874 {
5875 palFreeMemory(pMac->hHdd, pSession->pConnectBssDesc);
5876 pSession->pConnectBssDesc = NULL;
5877 }
5878}
5879
5880
5881
5882tSirResultCodes csrGetDisassocRspStatusCode( tSirSmeDisassocRsp *pSmeDisassocRsp )
5883{
5884 tANI_U8 *pBuffer = (tANI_U8 *)pSmeDisassocRsp;
5885 tANI_U32 ret;
5886
5887 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
5888 //tSirResultCodes is an enum, assuming is 32bit
5889 //If we cannot make this assumption, use copymemory
5890 pal_get_U32( pBuffer, &ret );
5891
5892 return( ( tSirResultCodes )ret );
5893}
5894
5895
5896tSirResultCodes csrGetDeAuthRspStatusCode( tSirSmeDeauthRsp *pSmeRsp )
5897{
5898 tANI_U8 *pBuffer = (tANI_U8 *)pSmeRsp;
5899 tANI_U32 ret;
5900
5901 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
5902 //tSirResultCodes is an enum, assuming is 32bit
5903 //If we cannot make this assumption, use copymemory
5904 pal_get_U32( pBuffer, &ret );
5905
5906 return( ( tSirResultCodes )ret );
5907}
5908
5909#if 0
5910tSirScanType csrGetScanType(tANI_U8 chnId, eRegDomainId domainId, tANI_U8 *countryCode)
5911{
5912 tSirScanType scanType = eSIR_PASSIVE_SCAN;
5913 tANI_U8 cc = 0;
5914
5915 while (cc++ < gCsrDomainChnInfo[domainId].numChannels)
5916 {
5917 if(chnId == gCsrDomainChnInfo[domainId].chnInfo[cc].chnId)
5918 {
5919 scanType = gCsrDomainChnInfo[domainId].chnInfo[cc].scanType;
5920 break;
5921 }
5922 }
5923
5924 return (scanType);
5925}
5926#endif
5927
5928tSirScanType csrGetScanType(tpAniSirGlobal pMac, tANI_U8 chnId)
5929{
5930 tSirScanType scanType = eSIR_PASSIVE_SCAN;
5931 eNVChannelEnabledType channelEnabledType;
5932
5933 channelEnabledType = vos_nv_getChannelEnabledState(chnId);
5934 if( NV_CHANNEL_ENABLE == channelEnabledType)
5935 {
5936 scanType = eSIR_ACTIVE_SCAN;
5937 }
5938 return (scanType);
5939}
5940
5941
5942tANI_U8 csrToUpper( tANI_U8 ch )
5943{
5944 tANI_U8 chOut;
5945
5946 if ( ch >= 'a' && ch <= 'z' )
5947 {
5948 chOut = ch - 'a' + 'A';
5949 }
5950 else
5951 {
5952 chOut = ch;
5953 }
5954 return( chOut );
5955}
5956
5957
5958tSirBssType csrTranslateBsstypeToMacType(eCsrRoamBssType csrtype)
5959{
5960 tSirBssType ret;
5961
5962 switch(csrtype)
5963 {
5964 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5965 ret = eSIR_INFRASTRUCTURE_MODE;
5966 break;
5967 case eCSR_BSS_TYPE_IBSS:
5968 case eCSR_BSS_TYPE_START_IBSS:
5969 ret = eSIR_IBSS_MODE;
5970 break;
5971 case eCSR_BSS_TYPE_WDS_AP:
5972 ret = eSIR_BTAMP_AP_MODE;
5973 break;
5974 case eCSR_BSS_TYPE_WDS_STA:
5975 ret = eSIR_BTAMP_STA_MODE;
5976 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 case eCSR_BSS_TYPE_INFRA_AP:
5978 ret = eSIR_INFRA_AP_MODE;
5979 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 case eCSR_BSS_TYPE_ANY:
5981 default:
5982 ret = eSIR_AUTO_MODE;
5983 break;
5984 }
5985
5986 return (ret);
5987}
5988
5989
5990//This function use the parameters to decide the CFG value.
5991//CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG
5992//So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value
Jeff Johnson295189b2012-06-20 16:38:30 -07005993eCsrCfgDot11Mode csrGetCfgDot11ModeFromCsrPhyMode(tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tANI_BOOLEAN fProprietary)
Jeff Johnson295189b2012-06-20 16:38:30 -07005994{
5995 tANI_U32 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
5996
5997 switch(phyMode)
5998 {
5999 case eCSR_DOT11_MODE_11a:
6000 case eCSR_DOT11_MODE_11a_ONLY:
6001 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
6002 break;
6003 case eCSR_DOT11_MODE_11b:
6004 case eCSR_DOT11_MODE_11b_ONLY:
6005 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
6006 break;
6007 case eCSR_DOT11_MODE_11g:
6008 case eCSR_DOT11_MODE_11g_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 if(pProfile && (CSR_IS_INFRA_AP(pProfile)) && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
6010 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
6011 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
6013 break;
6014 case eCSR_DOT11_MODE_11n:
6015 if(fProprietary)
6016 {
6017 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6018 }
6019 else
6020 {
6021 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6022 }
6023 break;
6024 case eCSR_DOT11_MODE_11n_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 if(pProfile && CSR_IS_INFRA_AP(pProfile))
6026 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
6027 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6029 break;
6030 case eCSR_DOT11_MODE_TAURUS:
6031 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6032 break;
6033 case eCSR_DOT11_MODE_abg:
6034 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6035 break;
6036 case eCSR_DOT11_MODE_AUTO:
6037 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
6038 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07006039
6040#ifdef WLAN_FEATURE_11AC
6041 case eCSR_DOT11_MODE_11ac:
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006042 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6043 {
6044 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
6045 }
6046 else
6047 {
Ravi Joshia96ceb42013-05-20 18:52:39 -07006048 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006049 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006050 break;
6051 case eCSR_DOT11_MODE_11ac_ONLY:
Ravi Joshia96ceb42013-05-20 18:52:39 -07006052 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6053 {
6054 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
6055 }
6056 else
6057 {
6058 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6059 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006060 break;
6061#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 default:
6063 //No need to assign anything here
6064 break;
6065 }
6066
6067 return (cfgDot11Mode);
6068}
6069
6070
6071eHalStatus csrSetRegulatoryDomain(tpAniSirGlobal pMac, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6072{
6073 eHalStatus status = eHAL_STATUS_SUCCESS;
6074 tANI_BOOLEAN fRestart;
6075
6076 if(pMac->scan.domainIdCurrent == domainId)
6077 {
6078 //no change
6079 fRestart = eANI_BOOLEAN_FALSE;
6080 }
6081 else if( !pMac->roam.configParam.fEnforceDefaultDomain )
6082 {
6083 pMac->scan.domainIdCurrent = domainId;
6084 fRestart = eANI_BOOLEAN_TRUE;
6085 }
6086 else
6087 {
6088 //We cannot change the domain
6089 status = eHAL_STATUS_CSR_WRONG_STATE;
6090 fRestart = eANI_BOOLEAN_FALSE;
6091 }
6092 if(pfRestartNeeded)
6093 {
6094 *pfRestartNeeded = fRestart;
6095 }
6096
6097 return (status);
6098}
6099
6100
6101v_REGDOMAIN_t csrGetCurrentRegulatoryDomain(tpAniSirGlobal pMac)
6102{
6103 return (pMac->scan.domainIdCurrent);
6104}
6105
Jeff Johnson295189b2012-06-20 16:38:30 -07006106
6107eHalStatus csrGetRegulatoryDomainForCountry(tpAniSirGlobal pMac, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
6108{
6109 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6110 VOS_STATUS vosStatus;
6111 v_COUNTRYCODE_t countryCode;
6112 v_REGDOMAIN_t domainId;
6113
6114 if(pCountry)
6115 {
6116 countryCode[0] = pCountry[0];
6117 countryCode[1] = pCountry[1];
6118 vosStatus = vos_nv_getRegDomainFromCountryCode( &domainId, countryCode );
6119 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
6120 {
6121 if( pDomainId )
6122 {
6123 *pDomainId = domainId;
6124 }
6125 status = eHAL_STATUS_SUCCESS;
6126 }
6127 else
6128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006129 smsLog(pMac, LOGW, FL(" doesn't match country %c%c"), pCountry[0], pCountry[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 status = eHAL_STATUS_INVALID_PARAMETER;
6131 }
6132 }
6133
6134 return (status);
6135}
6136
6137//To check whether a country code matches the one in the IE
6138//Only check the first two characters, ignoring in/outdoor
6139//pCountry -- caller allocated buffer contain the country code that is checking against
6140//the one in pIes. It can be NULL.
6141//caller must provide pIes, it cannot be NULL
6142//This function always return TRUE if 11d support is not turned on.
6143tANI_BOOLEAN csrMatchCountryCode( tpAniSirGlobal pMac, tANI_U8 *pCountry, tDot11fBeaconIEs *pIes )
6144{
6145 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson43971f52012-07-17 12:26:56 -07006146 v_REGDOMAIN_t domainId = REGDOMAIN_COUNT; //This is init to invalid value
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 eHalStatus status;
6148
6149 do
6150 {
6151 if( !csrIs11dSupported( pMac) )
6152 {
6153 break;
6154 }
6155 if( !pIes )
6156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006157 smsLog(pMac, LOGE, FL(" No IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006158 break;
6159 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006160 if( pMac->roam.configParam.fEnforceDefaultDomain ||
6161 pMac->roam.configParam.fEnforceCountryCodeMatch )
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006163 //Make sure this country is recognizable
6164 if( pIes->Country.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006166 status = csrGetRegulatoryDomainForCountry( pMac, pIes->Country.country, &domainId );
6167 if( !HAL_STATUS_SUCCESS( status ) )
6168 {
Gowri Deepthiff9adf92012-12-13 15:09:56 -08006169 status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCode11d,(v_REGDOMAIN_t *) &domainId );
6170 if( !HAL_STATUS_SUCCESS( status ) )
6171 {
6172 fRet = eANI_BOOLEAN_FALSE;
6173 break;
6174 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006177 //check whether it is needed to enforce to the default regulatory domain first
6178 if( pMac->roam.configParam.fEnforceDefaultDomain )
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006180 if( domainId != pMac->scan.domainIdCurrent )
6181 {
6182 fRet = eANI_BOOLEAN_FALSE;
6183 break;
6184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006186 if( pMac->roam.configParam.fEnforceCountryCodeMatch )
6187 {
Jeff Johnson43971f52012-07-17 12:26:56 -07006188 if( domainId >= REGDOMAIN_COUNT )
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006189 {
6190 fRet = eANI_BOOLEAN_FALSE;
6191 break;
6192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 }
6194 }
6195 if( pCountry )
6196 {
6197 tANI_U32 i;
6198
6199 if( !pIes->Country.present )
6200 {
6201 fRet = eANI_BOOLEAN_FALSE;
6202 break;
6203 }
6204 // Convert the CountryCode characters to upper
6205 for ( i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++ )
6206 {
6207 pCountry[i] = csrToUpper( pCountry[i] );
6208 }
6209 if( !palEqualMemory(pMac->hHdd, pIes->Country.country, pCountry, WNI_CFG_COUNTRY_CODE_LEN - 1) )
6210 {
6211 fRet = eANI_BOOLEAN_FALSE;
6212 break;
6213 }
6214 }
6215 } while(0);
6216
6217 return (fRet);
6218}
6219
6220#if 0
6221eHalStatus csrSetCountryDomainMapping(tpAniSirGlobal pMac, tCsrCountryDomainMapping *pCountryDomainMapping)
6222{
6223 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6224 tANI_U32 i, j;
6225 tANI_BOOLEAN fDomainChanged = eANI_BOOLEAN_FALSE;
6226 tANI_U8 countryCode[WNI_CFG_COUNTRY_CODE_LEN];
6227
6228 i = WNI_CFG_COUNTRY_CODE_LEN;
6229 //Get the currently used country code
6230 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, countryCode, &i);
6231 if(HAL_STATUS_SUCCESS(status))
6232 {
6233 if(pCountryDomainMapping && pCountryDomainMapping->numEntry)
6234 {
6235 for(i = 0; i < pCountryDomainMapping->numEntry; i++)
6236 {
6237 for(j = 0; j < eCSR_NUM_COUNTRY_INDEX; j++)
6238 {
6239 if(palEqualMemory(pMac->hHdd, gCsrCountryInfo[j].countryCode,
6240 pCountryDomainMapping->pCountryInfo[i].countryCode, 2))
6241 {
6242 if(gCsrCountryInfo[j].domainId != pCountryDomainMapping->pCountryInfo[i].domainId)
6243 {
6244 gCsrCountryInfo[j].domainId = pCountryDomainMapping->pCountryInfo[i].domainId;
6245 //Check whether it matches the currently used country code
6246 //If matching, need to update base on the new domain setting.
6247 if(palEqualMemory(pMac->hHdd, countryCode,
6248 pCountryDomainMapping->pCountryInfo[i].countryCode, 2))
6249 {
6250 fDomainChanged = eANI_BOOLEAN_TRUE;
6251 }
6252 }
6253 break;
6254 }
6255 }
6256 }
6257 status = eHAL_STATUS_SUCCESS;
6258 if(fDomainChanged)
6259 {
6260 tCsrChannel *pChannelList;
6261
6262 if(pMac->scan.f11dInfoApplied)
6263 {
6264 //11d info already applied. Let's reapply with the new domain setting
6265 if(pMac->scan.channels11d.numChannels)
6266 {
6267 pChannelList = &pMac->scan.channels11d;
6268 }
6269 else
6270 {
6271 pChannelList = &pMac->scan.base20MHzChannels;
6272 }
6273 }
6274 else
6275 {
6276 //no 11d so we use the base channelist from EEPROM
6277 pChannelList = &pMac->scan.base20MHzChannels;
6278 }
6279 //set the new domain's scan requirement to CFG
6280 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
6281 }
6282 }
6283 }
6284
6285 return (status);
6286}
6287
6288eHalStatus csrSetDomainScanSetting(tpAniSirGlobal pMac, tCsrDomainFreqInfo *pDomainFreqInfo)
6289{
6290 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6291 tANI_U32 i, j;
6292 tANI_U16 freq;
6293
6294 if(pDomainFreqInfo && pDomainFreqInfo->numEntry && (pDomainFreqInfo->domainId < NUM_REG_DOMAINS))
6295 {
6296 tCsrDomainChnInfo *pDomainChnInfo = &gCsrDomainChnInfo[pDomainFreqInfo->domainId];
6297
6298 for(j = 0; j < pDomainChnInfo->numChannels; j++)
6299 {
6300 if(HAL_STATUS_SUCCESS(halPhyChIdToFreqConversion(pDomainChnInfo->chnInfo[j].chnId, &freq)))
6301 {
6302 for(i = 0; i < pDomainFreqInfo->numEntry; i++)
6303 {
6304 if((pDomainFreqInfo->pCsrScanFreqInfo[i].nStartFreq <= freq) &&
6305 (freq <= pDomainFreqInfo->pCsrScanFreqInfo[i].nEndFreq))
6306 {
6307 pDomainChnInfo->chnInfo[j].scanType = pDomainFreqInfo->pCsrScanFreqInfo[i].scanType;
6308 break;
6309 }
6310 }
6311 }
6312 else
6313 {
6314 smsLog(pMac, LOGW, " Failed to get frequency of channel %d", pDomainChnInfo->chnInfo[j].chnId);
6315 }
6316 }
6317 status = eHAL_STATUS_SUCCESS;
6318 }
6319
6320 return (status);
6321}
6322#endif
6323
6324eHalStatus csrGetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6325 tCsrRoamModifyProfileFields *pModifyProfileFields)
6326{
6327
6328 if(!pModifyProfileFields)
6329 {
6330 return eHAL_STATUS_FAILURE;
6331 }
6332
6333 palCopyMemory( pMac->hHdd, pModifyProfileFields,
6334 &pMac->roam.roamSession[sessionId].connectedProfile.modifyProfileFields,
6335 sizeof(tCsrRoamModifyProfileFields) );
6336
6337 return eHAL_STATUS_SUCCESS;
6338}
6339
6340eHalStatus csrSetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6341 tCsrRoamModifyProfileFields *pModifyProfileFields)
6342{
6343 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6344
6345 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.modifyProfileFields,
6346 pModifyProfileFields,
6347 sizeof(tCsrRoamModifyProfileFields) );
6348
6349 return eHAL_STATUS_SUCCESS;
6350}
6351
6352
6353#if 0
6354/* ---------------------------------------------------------------------------
6355 \fn csrGetSupportedCountryCode
6356 \brief this function is to get a list of the country code current being supported
6357 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6358 this has the country code list. 3 bytes for each country code. This may be NULL if
6359 caller wants to know the needed bytes.
6360 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6361 this contains the length of the data in pBuf
6362 \return eHalStatus
6363 -------------------------------------------------------------------------------*/
6364eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6365{
6366 tANI_U32 numOfCountry = sizeof( gCsrCountryInfo ) / sizeof( gCsrCountryInfo[0] );
6367 tANI_U32 numBytes = 0;
6368 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6369
6370 if( pbLen )
6371 {
6372 numBytes = *pbLen;
6373 //Consider it ok, at least we can return the number of bytes needed;
6374 *pbLen = numOfCountry * WNI_CFG_COUNTRY_CODE_LEN;
6375 status = eHAL_STATUS_SUCCESS;
6376 if( pBuf && ( numBytes >= *pbLen ) )
6377 {
6378 //The ugly part starts.
6379 //We may need to alter the data structure and find a way to make this faster.
6380 tANI_U32 i;
6381
6382 for( i = 0; i < numOfCountry; i++ )
6383 {
6384 palCopyMemory( pMac->hHdd, pBuf + ( i * WNI_CFG_COUNTRY_CODE_LEN ),
6385 gCsrCountryInfo[i].countryCode, WNI_CFG_COUNTRY_CODE_LEN );
6386 }
6387 }
6388 }
6389
6390 return ( status );
6391}
6392#endif
6393
6394/* ---------------------------------------------------------------------------
6395 \fn csrGetSupportedCountryCode
6396 \brief this function is to get a list of the country code current being supported
6397 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6398 this has the country code list. 3 bytes for each country code. This may be NULL if
6399 caller wants to know the needed bytes.
6400 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6401 this contains the length of the data in pBuf
6402 \return eHalStatus
6403 -------------------------------------------------------------------------------*/
6404eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6405{
6406 eHalStatus status = eHAL_STATUS_SUCCESS;
6407 VOS_STATUS vosStatus;
6408 v_SIZE_t size = (v_SIZE_t)*pbLen;
6409
6410 vosStatus = vos_nv_getSupportedCountryCode( pBuf, &size, 1 );
6411 //eiter way, return the value back
6412 *pbLen = (tANI_U32)size;
6413
6414 //If pBuf is NULL, caller just want to get the size, consider it success
6415 if(pBuf)
6416 {
6417 if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
6418 {
6419 tANI_U32 i, n = *pbLen / 3;
6420
6421 for( i = 0; i < n; i++ )
6422 {
6423 pBuf[i*3 + 2] = ' ';
6424 }
6425 }
6426 else
6427 {
6428 status = eHAL_STATUS_FAILURE;
6429 }
6430 }
6431
6432 return (status);
6433}
6434
6435
6436
6437//Upper layer to get the list of the base channels to scan for passively 11d info from csr
6438eHalStatus csrScanGetBaseChannels( tpAniSirGlobal pMac, tCsrChannelInfo * pChannelInfo )
6439{
6440 eHalStatus status = eHAL_STATUS_FAILURE;
6441
6442 do
6443 {
6444
6445 if(!pMac->scan.baseChannels.numChannels || !pChannelInfo)
6446 {
6447 break;
6448 }
6449 status = palAllocateMemory( pMac->hHdd, (void **)&pChannelInfo->ChannelList,
6450 pMac->scan.baseChannels.numChannels );
6451 if( !HAL_STATUS_SUCCESS( status ) )
6452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006453 smsLog( pMac, LOGE, FL("csrScanGetBaseChannels: fail to allocate memory") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 break;
6455 }
6456 status = palCopyMemory( pMac->hHdd, pChannelInfo->ChannelList, pMac->scan.baseChannels.channelList,
6457 pMac->scan.baseChannels.numChannels );
6458 if( !HAL_STATUS_SUCCESS( status ) )
6459 {
6460 break;
6461 }
6462 pChannelInfo->numOfChannels = pMac->scan.baseChannels.numChannels;
6463
6464 }while(0);
6465
6466 return ( status );
6467}
6468
6469
6470tANI_BOOLEAN csrIsSetKeyAllowed(tpAniSirGlobal pMac, tANI_U32 sessionId)
6471{
6472 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 tCsrRoamSession *pSession;
6474
6475 pSession =CSR_GET_SESSION(pMac, sessionId);
6476
6477 /*This condition is not working for infra state. When infra is in not-connected state
6478 * the pSession->pCurRoamProfile is NULL. And this function returns TRUE, that is incorrect.
6479 * Since SAP requires to set key without any BSS started, it needs this condition to be met.
6480 * In other words, this function is useless.
6481 * The current work-around is to process setcontext_rsp and removekey_rsp no matter what the
6482 * state is.
6483 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006484 smsLog( pMac, LOG2, FL(" is not what it intends to. Must be revisit or removed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 if( (NULL == pSession) ||
6486 ( csrIsConnStateDisconnected( pMac, sessionId ) &&
6487 (pSession->pCurRoamProfile != NULL) &&
6488 (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) )
6489 )
6490 {
6491 fRet = eANI_BOOLEAN_FALSE;
6492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006493
6494 return ( fRet );
6495}
6496
6497//no need to acquire lock for this basic function
6498tANI_U16 sme_ChnToFreq(tANI_U8 chanNum)
6499{
6500 int i;
6501
6502 for (i = 0; i < NUM_RF_CHANNELS; i++)
6503 {
6504 if (rfChannels[i].channelNum == chanNum)
6505 {
6506 return rfChannels[i].targetFreq;
6507 }
6508 }
6509
6510 return (0);
6511}
6512
6513/* Disconnect all active sessions by sending disassoc. This is mainly used to disconnect the remaining session when we
6514 * transition from concurrent sessions to a single session. The use case is Infra STA and wifi direct multiple sessions are up and
6515 * P2P session is removed. The Infra STA session remains and should resume BMPS if BMPS is enabled by default. However, there
6516 * are some issues seen with BMPS resume during this transition and this is a workaround which will allow the Infra STA session to
6517 * disconnect and auto connect back and enter BMPS this giving the same effect as resuming BMPS
6518 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006519
6520//Remove this code once SLM_Sessionization is supported
6521//BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnson295189b2012-06-20 16:38:30 -07006522void csrDisconnectAllActiveSessions(tpAniSirGlobal pMac)
6523{
6524 tANI_U8 i;
6525
6526 /* Disconnect all the active sessions */
6527 for (i=0; i<CSR_ROAM_SESSION_MAX; i++)
6528 {
6529 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
6530 {
6531 csrRoamDisconnectInternal(pMac, i, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6532 }
6533 }
6534}
Mohit Khanna349bc392012-09-11 17:24:52 -07006535
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006536#ifdef FEATURE_WLAN_LFR
6537tANI_BOOLEAN csrIsChannelPresentInList(
6538 tANI_U8 *pChannelList,
6539 int numChannels,
6540 tANI_U8 channel
6541 )
6542{
6543 int i = 0;
6544
6545 // Check for NULL pointer
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08006546 if (!pChannelList || (numChannels == 0))
6547 {
6548 return FALSE;
6549 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006550
6551 // Look for the channel in the list
6552 for (i = 0; i < numChannels; i++)
6553 {
6554 if (pChannelList[i] == channel)
6555 return TRUE;
6556 }
6557
6558 return FALSE;
6559}
6560
6561VOS_STATUS csrAddToChannelListFront(
6562 tANI_U8 *pChannelList,
6563 int numChannels,
6564 tANI_U8 channel
6565 )
6566{
6567 int i = 0;
6568
6569 // Check for NULL pointer
6570 if (!pChannelList) return eHAL_STATUS_E_NULL_VALUE;
6571
6572 // Make room for the addition. (Start moving from the back.)
6573 for (i = numChannels; i > 0; i--)
6574 {
6575 pChannelList[i] = pChannelList[i-1];
6576 }
6577
6578 // Now add the NEW channel...at the front
6579 pChannelList[0] = channel;
6580
6581 return eHAL_STATUS_SUCCESS;
6582}
6583#endif