blob: 8ca6034e381e876f4a6600129ba7b41592d39807 [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
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302591 if ((0 == phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002592#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302593 (eCSR_DOT11_MODE_11ac & phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002594#endif
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302595 (eCSR_DOT11_MODE_AUTO & phyMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 {
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302597#ifdef WLAN_FEATURE_11AC
2598 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2599 {
2600 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC;
2601 }
2602 else
2603#endif
2604 {
2605 /* Default to 11N mode if user has configured 11ac mode
2606 * and FW doesn't supports 11ac mode .
2607 */
2608 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 }
2611 else
2612 {
2613 if( ( eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY ) & phyMode )
2614 {
2615 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2616 }
2617 else if ( eCSR_DOT11_MODE_abg & phyMode )
2618 {
2619 if( eCSR_BAND_24 != eBand )
2620 {
2621 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2622 }
2623 else
2624 {
2625 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2626 }
2627 }
2628 else if( ( eCSR_DOT11_MODE_11a | eCSR_DOT11_MODE_11a_ONLY ) & phyMode )
2629 {
2630 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2631 }
2632 else if( ( eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY ) & phyMode )
2633 {
2634 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2635 }
2636 else
2637 {
2638 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B;
2639 }
2640 }
2641
2642 return ( cfgDot11ModeToUse );
2643}
2644
2645
2646
2647
2648tANI_U32 csrGet11hPowerConstraint( tHalHandle hHal, tDot11fIEPowerConstraints *pPowerConstraint )
2649{
2650 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2651 tANI_U32 localPowerConstraint = 0;
2652
2653 // check if .11h support is enabled, if not, the power constraint is 0.
2654 if(pMac->roam.configParam.Is11hSupportEnabled && pPowerConstraint->present)
2655 {
2656 localPowerConstraint = pPowerConstraint->localPowerConstraints;
2657 }
2658
2659 return( localPowerConstraint );
2660}
2661
2662
2663tANI_BOOLEAN csrIsProfileWpa( tCsrRoamProfile *pProfile )
2664{
2665 tANI_BOOLEAN fWpaProfile = FALSE;
2666
2667 switch ( pProfile->negotiatedAuthType )
2668 {
2669 case eCSR_AUTH_TYPE_WPA:
2670 case eCSR_AUTH_TYPE_WPA_PSK:
2671 case eCSR_AUTH_TYPE_WPA_NONE:
2672#ifdef FEATURE_WLAN_CCX
2673 case eCSR_AUTH_TYPE_CCKM_WPA:
2674#endif
2675 fWpaProfile = TRUE;
2676 break;
2677
2678 default:
2679 fWpaProfile = FALSE;
2680 break;
2681 }
2682
2683 if ( fWpaProfile )
2684 {
2685 switch ( pProfile->negotiatedUCEncryptionType )
2686 {
2687 case eCSR_ENCRYPT_TYPE_WEP40:
2688 case eCSR_ENCRYPT_TYPE_WEP104:
2689 case eCSR_ENCRYPT_TYPE_TKIP:
2690 case eCSR_ENCRYPT_TYPE_AES:
2691 fWpaProfile = TRUE;
2692 break;
2693
2694 default:
2695 fWpaProfile = FALSE;
2696 break;
2697 }
2698 }
2699 return( fWpaProfile );
2700}
2701
2702tANI_BOOLEAN csrIsProfileRSN( tCsrRoamProfile *pProfile )
2703{
2704 tANI_BOOLEAN fRSNProfile = FALSE;
2705
2706 switch ( pProfile->negotiatedAuthType )
2707 {
2708 case eCSR_AUTH_TYPE_RSN:
2709 case eCSR_AUTH_TYPE_RSN_PSK:
2710#ifdef WLAN_FEATURE_VOWIFI_11R
2711 case eCSR_AUTH_TYPE_FT_RSN:
2712 case eCSR_AUTH_TYPE_FT_RSN_PSK:
2713#endif
2714#ifdef FEATURE_WLAN_CCX
2715 case eCSR_AUTH_TYPE_CCKM_RSN:
2716#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002717#ifdef WLAN_FEATURE_11W
2718 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
2719#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 fRSNProfile = TRUE;
2721 break;
2722
2723 default:
2724 fRSNProfile = FALSE;
2725 break;
2726 }
2727
2728 if ( fRSNProfile )
2729 {
2730 switch ( pProfile->negotiatedUCEncryptionType )
2731 {
2732 // !!REVIEW - For WPA2, use of RSN IE mandates
2733 // use of AES as encryption. Here, we qualify
2734 // even if encryption type is WEP or TKIP
2735 case eCSR_ENCRYPT_TYPE_WEP40:
2736 case eCSR_ENCRYPT_TYPE_WEP104:
2737 case eCSR_ENCRYPT_TYPE_TKIP:
2738 case eCSR_ENCRYPT_TYPE_AES:
2739 fRSNProfile = TRUE;
2740 break;
2741
2742 default:
2743 fRSNProfile = FALSE;
2744 break;
2745 }
2746 }
2747 return( fRSNProfile );
2748}
2749
Jeff Johnsone7245742012-09-05 17:12:55 -07002750eHalStatus
2751csrIsconcurrentsessionValid(tpAniSirGlobal pMac,tANI_U32 cursessionId,
2752 tVOS_CON_MODE currBssPersona)
2753{
2754 tANI_U32 sessionId = 0;
2755
2756 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2757 {
2758 if (cursessionId != sessionId )
2759 {
2760 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2761 {
2762 continue;
2763 }
2764
2765 switch (currBssPersona)
2766 {
2767 case VOS_STA_MODE:
2768 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002769 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002770 == VOS_STA_MODE)) //check for P2P client mode
2771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002772 smsLog(pMac, LOGE, FL(" ****STA mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002773 return eHAL_STATUS_FAILURE;
2774 }
2775 break;
2776
2777 case VOS_STA_SAP_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302778 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2779 == VOS_STA_SAP_MODE)&&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002780 (pMac->roam.roamSession[sessionId].connectState
2781 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002783 smsLog(pMac, LOGE, FL(" ****SoftAP mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002784 return eHAL_STATUS_FAILURE;
2785 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002786 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2787 == VOS_P2P_GO_MODE &&
2788 pMac->roam.roamSession[sessionId].connectState
2789 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2790 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2791 == VOS_IBSS_MODE &&
2792 pMac->roam.roamSession[sessionId].connectState
2793 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002795 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002796 return eHAL_STATUS_FAILURE;
2797 }
2798 break;
2799
2800 case VOS_P2P_CLIENT_MODE:
2801 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002802 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002803 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2804 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002805 smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002806 return eHAL_STATUS_FAILURE;
2807 }
2808 break;
2809
2810 case VOS_P2P_GO_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302811 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2812 == VOS_P2P_GO_MODE) &&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002813 (pMac->roam.roamSession[sessionId].connectState
2814 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002816 smsLog(pMac, LOGE, FL(" ****P2P GO mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002817 return eHAL_STATUS_FAILURE;
2818 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002819 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2820 == VOS_STA_SAP_MODE &&
2821 pMac->roam.roamSession[sessionId].connectState
2822 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2823 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2824 == VOS_IBSS_MODE &&
2825 pMac->roam.roamSession[sessionId].connectState
2826 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002828 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002829 return eHAL_STATUS_FAILURE;
2830 }
2831 break;
Ravi Joshia96ceb42013-05-20 18:52:39 -07002832 case VOS_IBSS_MODE:
2833 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2834 == VOS_IBSS_MODE) &&
2835 (pMac->roam.roamSession[sessionId].connectState
2836 != eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED))
2837 {
2838 smsLog(pMac, LOGE, FL(" ****IBSS mode already exists ****"));
2839 return eHAL_STATUS_FAILURE;
2840 }
2841 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2842 == VOS_P2P_GO_MODE ||
2843 pMac->roam.roamSession[sessionId].bssParams.bssPersona
2844 == VOS_STA_SAP_MODE) &&
2845 pMac->roam.roamSession[sessionId].connectState
2846 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)
2847 {
2848 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
2849 return eHAL_STATUS_FAILURE;
2850 }
2851 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002852 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002853 smsLog(pMac, LOGE, FL("***Persona not handled = %d*****"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07002854 break;
2855 }
2856 }
2857 }
2858 return eHAL_STATUS_SUCCESS;
2859
2860}
2861
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002862eHalStatus csrUpdateMCCp2pBeaconInterval(tpAniSirGlobal pMac)
Jeff Johnsone7245742012-09-05 17:12:55 -07002863{
2864 tANI_U32 sessionId = 0;
2865
2866 //If MCC is not supported just break and return SUCCESS
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002867 if ( !pMac->roam.configParam.fenableMCCMode){
2868 return eHAL_STATUS_FAILURE;
2869 }
2870
2871 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2872 {
2873 /* If GO in MCC support different beacon interval,
2874 * change the BI of the P2P-GO */
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002875 if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2876 == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002877 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002878 /* Handle different BI scneario based on the configuration set.
2879 * If Config is set to 0x02 then Disconnect all the P2P clients
2880 * associated. If config is set to 0x04 then update the BI
2881 * without disconnecting all the clients
2882 */
2883 if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
2884 (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
2885 {
2886 return csrSendChngMCCBeaconInterval( pMac, sessionId);
2887 }
2888 //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
2889 else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
2890 {
2891 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
2892 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002893 }
2894 }
2895 return eHAL_STATUS_FAILURE;
2896}
2897
2898tANI_U16 csrCalculateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U16 sta_bi, tANI_U16 go_gbi)
2899{
2900 tANI_U8 num_beacons = 0;
2901 tANI_U8 is_multiple = 0;
2902 tANI_U16 go_cbi = 0;
2903 tANI_U16 go_fbi = 0;
2904 tANI_U16 sta_cbi = 0;
2905
2906 //If GO's given beacon Interval is less than 100
2907 if(go_gbi < 100)
2908 go_cbi = 100;
2909 //if GO's given beacon Interval is greater than or equal to 100
2910 else
2911 go_cbi = 100 + (go_gbi % 100);
2912
2913 // check, if either one is multiple of another
2914 if (sta_bi > go_cbi)
2915 {
2916 is_multiple = !(sta_bi % go_cbi);
2917 }
2918 else
2919 {
2920 is_multiple = !(go_cbi % sta_bi);
2921 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002922 // if it is multiple, then accept GO's beacon interval range [100,199] as it is
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002923 if (is_multiple)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002924 {
2925 return go_cbi;
2926 }
2927 //else , if it is not multiple, then then check for number of beacons to be
2928 //inserted based on sta BI
2929 num_beacons = sta_bi / 100;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002930 if (num_beacons)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002931 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002932 // GO's final beacon interval will be aligned to sta beacon interval, but
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002933 //in the range of [100, 199].
2934 sta_cbi = sta_bi / num_beacons;
2935 go_fbi = sta_cbi;
2936 }
2937 else
2938 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002939 // if STA beacon interval is less than 100, use GO's change bacon interval
2940 //instead of updating to STA's beacon interval.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002941 go_fbi = go_cbi;
2942 }
2943 return go_fbi;
2944}
2945
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002946eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002947 tANI_U16 *beaconInterval, tANI_U32 cursessionId,
2948 tVOS_CON_MODE currBssPersona)
2949{
2950 tANI_U32 sessionId = 0;
2951 tANI_U16 new_beaconInterval = 0;
2952
2953 //If MCC is not supported just break
2954 if (!pMac->roam.configParam.fenableMCCMode){
Jeff Johnsone7245742012-09-05 17:12:55 -07002955 return eHAL_STATUS_FAILURE;
2956 }
2957
2958 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2959 {
2960 if (cursessionId != sessionId )
2961 {
2962 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2963 {
2964 continue;
2965 }
2966
2967 switch (currBssPersona)
2968 {
2969 case VOS_STA_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002970 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
2971 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002972 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002974 smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002975 }
2976 //IF SAP has started and STA wants to connect on different channel MCC should
2977 //MCC should not be enabled so making it false to enforce on same channel
2978 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2979 == VOS_STA_SAP_MODE)
2980 {
2981 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
2982 != channelId )
2983 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002984 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP +STA****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002985 return eHAL_STATUS_FAILURE;
2986 }
2987 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002988 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002989 == VOS_P2P_GO_MODE) //Check for P2P go scenario
2990 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002991 /* if GO in MCC support different beacon interval,
2992 * change the BI of the P2P-GO */
2993 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
Jeff Johnsone7245742012-09-05 17:12:55 -07002994 != channelId ) &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002995 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07002996 != *beaconInterval))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002997 {
2998 /* if GO in MCC support different beacon interval, return success */
2999 if ( pMac->roam.configParam.fAllowMCCGODiffBI == 0x01)
3000 {
3001 return eHAL_STATUS_SUCCESS;
3002 }
3003 // Send only Broadcast disassoc and update beaconInterval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003004 //If configuration is set to 0x04 then dont
3005 // disconnect all the station
3006 else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
3007 (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003008 {
3009 //Check to pass the right beacon Interval
3010 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval,
3011 pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003012 smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003013 //Update the becon Interval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003014 if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003015 {
3016 //Update the beaconInterval now
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003017 smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
3018 pMac->roam.configParam.fAllowMCCGODiffBI);
3019
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003020 pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
3021 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003022 return csrUpdateMCCp2pBeaconInterval(pMac);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003023 }
3024 return eHAL_STATUS_SUCCESS;
3025 }
3026 //Disconnect the P2P session
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003027 else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003028 {
3029 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
3030 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
3031 }
3032 else
3033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003034 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to preferred AP..."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003035 return eHAL_STATUS_FAILURE;
3036 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003037 }
3038 }
3039 break;
3040
3041 case VOS_P2P_CLIENT_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003042 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3043 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003044 == VOS_STA_MODE)) //check for P2P client mode
3045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003046 smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003047 }
3048 //IF SAP has started and STA wants to connect on different channel MCC should
3049 //MCC should not be enabled so making it false to enforce on same channel
3050 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3051 == VOS_STA_SAP_MODE)
3052 {
3053 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3054 != channelId )
3055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003056 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP + CLIENT****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003057 return eHAL_STATUS_FAILURE;
3058 }
3059 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003060 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003061 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3062 {
3063 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
3064 != channelId ) &&
3065 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
3066 != *beaconInterval))
3067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003068 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to P2P_GO network ..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003069 return eHAL_STATUS_FAILURE;
3070 }
3071 }
3072 break;
3073
3074 case VOS_P2P_GO_MODE :
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003075 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003076 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3077 ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003078 == VOS_P2P_CLIENT_MODE) ||
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003079 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003080 == VOS_STA_MODE))) //check for P2P_client scenario
3081 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003082 if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003083 == 0 )&&
3084 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
3085 == 0))
3086 {
3087 continue;
3088 }
3089
3090
3091 if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003092 (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003093 != channelId ) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003094 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003095 != *beaconInterval))
3096 {
3097 /*
3098 * Updated beaconInterval should be used only when we are starting a new BSS
3099 * not incase of client or STA case
3100 */
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003101 //Calculate beacon Interval for P2P-GO incase of MCC
3102 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac,
Chet Lanctot4c986162013-05-08 13:59:56 -07003103 pMac->roam.roamSession[sessionId].bssParams.beaconInterval,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003104 *beaconInterval );
3105 if(*beaconInterval != new_beaconInterval)
3106 *beaconInterval = new_beaconInterval;
Jeff Johnsone7245742012-09-05 17:12:55 -07003107 return eHAL_STATUS_SUCCESS;
3108 }
3109 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003110 }
3111 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003112
3113 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003114 smsLog(pMac, LOG1, FL(" Persona not supported : %d"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003115 return eHAL_STATUS_FAILURE;
3116 }
3117 }
3118 }
3119
3120 return eHAL_STATUS_SUCCESS;
3121}
Jeff Johnson295189b2012-06-20 16:38:30 -07003122
3123#ifdef WLAN_FEATURE_VOWIFI_11R
3124/* Function to return TRUE if the authtype is 11r */
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003125tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -07003126{
3127 switch ( AuthType )
3128 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003129 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3130 if(mdiePresent)
3131 return TRUE;
3132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3134 case eCSR_AUTH_TYPE_FT_RSN:
3135 return TRUE;
3136 break;
3137 default:
3138 break;
3139 }
3140 return FALSE;
3141}
3142
3143/* Function to return TRUE if the profile is 11r */
3144tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
3145{
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003146 return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
Jeff Johnson295189b2012-06-20 16:38:30 -07003147}
3148
3149#endif
3150
3151#ifdef FEATURE_WLAN_CCX
3152
3153/* Function to return TRUE if the authtype is CCX */
3154tANI_BOOLEAN csrIsAuthTypeCCX( eCsrAuthType AuthType )
3155{
3156 switch ( AuthType )
3157 {
3158 case eCSR_AUTH_TYPE_CCKM_WPA:
3159 case eCSR_AUTH_TYPE_CCKM_RSN:
3160 return TRUE;
3161 break;
3162 default:
3163 break;
3164 }
3165 return FALSE;
3166}
3167
3168/* Function to return TRUE if the profile is CCX */
3169tANI_BOOLEAN csrIsProfileCCX( tCsrRoamProfile *pProfile )
3170{
3171 return (csrIsAuthTypeCCX( pProfile->negotiatedAuthType ));
3172}
3173
3174#endif
3175
3176#ifdef FEATURE_WLAN_WAPI
3177tANI_BOOLEAN csrIsProfileWapi( tCsrRoamProfile *pProfile )
3178{
3179 tANI_BOOLEAN fWapiProfile = FALSE;
3180
3181 switch ( pProfile->negotiatedAuthType )
3182 {
3183 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
3184 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
3185 fWapiProfile = TRUE;
3186 break;
3187
3188 default:
3189 fWapiProfile = FALSE;
3190 break;
3191 }
3192
3193 if ( fWapiProfile )
3194 {
3195 switch ( pProfile->negotiatedUCEncryptionType )
3196 {
3197 case eCSR_ENCRYPT_TYPE_WPI:
3198 fWapiProfile = TRUE;
3199 break;
3200
3201 default:
3202 fWapiProfile = FALSE;
3203 break;
3204 }
3205 }
3206 return( fWapiProfile );
3207}
3208
3209static tANI_BOOLEAN csrIsWapiOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3210{
3211 return( palEqualMemory(pMac->hHdd, Oui1, Oui2, CSR_WAPI_OUI_SIZE ) );
3212}
3213
3214static tANI_BOOLEAN csrIsWapiOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3215 tANI_U8 cAllCyphers,
3216 tANI_U8 Cypher[],
3217 tANI_U8 Oui[] )
3218{
3219 tANI_BOOLEAN fYes = FALSE;
3220 tANI_U8 idx;
3221
3222 for ( idx = 0; idx < cAllCyphers; idx++ )
3223 {
3224 if ( csrIsWapiOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3225 {
3226 fYes = TRUE;
3227 break;
3228 }
3229 }
3230
3231 if ( fYes && Oui )
3232 {
3233 palCopyMemory( pMac->hHdd, Oui, AllCyphers[ idx ], CSR_WAPI_OUI_SIZE );
3234 }
3235
3236 return( fYes );
3237}
3238#endif /* FEATURE_WLAN_WAPI */
3239
3240static tANI_BOOLEAN csrIsWpaOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3241{
3242 return( palEqualMemory(pMac->hHdd, Oui1, Oui2, CSR_WPA_OUI_SIZE ) );
3243}
3244
3245static tANI_BOOLEAN csrIsOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3246 tANI_U8 cAllCyphers,
3247 tANI_U8 Cypher[],
3248 tANI_U8 Oui[] )
3249{
3250 tANI_BOOLEAN fYes = FALSE;
3251 tANI_U8 idx;
3252
3253 for ( idx = 0; idx < cAllCyphers; idx++ )
3254 {
3255 if ( csrIsWpaOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3256 {
3257 fYes = TRUE;
3258 break;
3259 }
3260 }
3261
3262 if ( fYes && Oui )
3263 {
3264 palCopyMemory( pMac->hHdd, Oui, AllCyphers[ idx ], CSR_WPA_OUI_SIZE );
3265 }
3266
3267 return( fYes );
3268}
3269
3270static tANI_BOOLEAN csrMatchRSNOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3271 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3272 tANI_U8 Oui[] )
3273{
3274 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui[ouiIndex], Oui ) );
3275
3276}
3277
3278#ifdef FEATURE_WLAN_WAPI
3279static tANI_BOOLEAN csrMatchWapiOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3280 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3281 tANI_U8 Oui[] )
3282{
3283 return( csrIsWapiOuiMatch( pMac, AllCyphers, cAllCyphers, csrWapiOui[ouiIndex], Oui ) );
3284
3285}
3286#endif /* FEATURE_WLAN_WAPI */
3287
3288static tANI_BOOLEAN csrMatchWPAOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3289 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3290 tANI_U8 Oui[] )
3291{
3292 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui[ouiIndex], Oui ) );
3293
3294}
3295
3296#if 0
3297static tANI_BOOLEAN csrIsRSNUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3298 tANI_U8 cAllCyphers,
3299 tANI_U8 Oui[] )
3300{
3301 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui00, Oui ) );
3302}
3303
3304static tANI_BOOLEAN csrIsRSNMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3305 tANI_U8 cAllCyphers,
3306 tANI_U8 Oui[] )
3307{
3308 tANI_BOOLEAN fYes = FALSE;
3309
3310 // Check Wep 104 first, if fails, then check Wep40.
3311 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui05, Oui );
3312
3313 if ( !fYes )
3314 {
3315 // if not Wep-104, check Wep-40
3316 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui01, Oui );
3317 }
3318
3319 return( fYes );
3320}
3321
3322
3323static tANI_BOOLEAN csrIsRSNUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3324 tANI_U8 cAllCyphers,
3325 tANI_U8 Oui[] )
3326{
3327 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3328}
3329
3330
3331static tANI_BOOLEAN csrIsRSNMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3332 tANI_U8 cAllCyphers,
3333 tANI_U8 Oui[] )
3334{
3335 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3336}
3337
3338static tANI_BOOLEAN csrIsRSNUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3339 tANI_U8 cAllCyphers,
3340 tANI_U8 Oui[] )
3341{
3342 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3343}
3344
3345static tANI_BOOLEAN csrIsRSNMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3346 tANI_U8 cAllCyphers,
3347 tANI_U8 Oui[] )
3348{
3349 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3350}
3351#endif
3352#ifdef FEATURE_WLAN_WAPI
3353static tANI_BOOLEAN csrIsAuthWapiCert( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3354 tANI_U8 cAllSuites,
3355 tANI_U8 Oui[] )
3356{
3357 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[1], Oui ) );
3358}
3359static tANI_BOOLEAN csrIsAuthWapiPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3360 tANI_U8 cAllSuites,
3361 tANI_U8 Oui[] )
3362{
3363 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[2], Oui ) );
3364}
3365#endif /* FEATURE_WLAN_WAPI */
3366
3367#ifdef WLAN_FEATURE_VOWIFI_11R
3368
3369/*
3370 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3371 * here. This matches for FT Auth with the 802.1X exchange.
3372 *
3373 */
3374static tANI_BOOLEAN csrIsFTAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3375 tANI_U8 cAllSuites,
3376 tANI_U8 Oui[] )
3377{
3378 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[03], Oui ) );
3379}
3380
3381/*
3382 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3383 * here. This matches for FT Auth with the PSK.
3384 *
3385 */
3386static tANI_BOOLEAN csrIsFTAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3387 tANI_U8 cAllSuites,
3388 tANI_U8 Oui[] )
3389{
3390 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[04], Oui ) );
3391}
3392
3393#endif
3394
3395#ifdef FEATURE_WLAN_CCX
3396
3397/*
3398 * Function for CCX CCKM AKM Authentication. We match the CCKM AKM Authentication Key Management suite
3399 * here. This matches for CCKM AKM Auth with the 802.1X exchange.
3400 *
3401 */
3402static tANI_BOOLEAN csrIsCcxCckmAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3403 tANI_U8 cAllSuites,
3404 tANI_U8 Oui[] )
3405{
3406 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[06], Oui ) );
3407}
3408
3409static tANI_BOOLEAN csrIsCcxCckmAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3410 tANI_U8 cAllSuites,
3411 tANI_U8 Oui[] )
3412{
3413 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[06], Oui ) );
3414}
3415
3416#endif
3417
3418static tANI_BOOLEAN csrIsAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3419 tANI_U8 cAllSuites,
3420 tANI_U8 Oui[] )
3421{
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[01], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003423}
3424static tANI_BOOLEAN csrIsAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3425 tANI_U8 cAllSuites,
3426 tANI_U8 Oui[] )
3427{
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[02], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003429}
3430
Chet Lanctot186b5732013-03-18 10:26:30 -07003431#ifdef WLAN_FEATURE_11W
3432static tANI_BOOLEAN csrIsAuthRSNPskSha256( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3433 tANI_U8 cAllSuites,
3434 tANI_U8 Oui[] )
3435{
Chet Lanctot4c986162013-05-08 13:59:56 -07003436 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[07], Oui );
Chet Lanctot186b5732013-03-18 10:26:30 -07003437}
3438#endif
3439
Jeff Johnson295189b2012-06-20 16:38:30 -07003440static tANI_BOOLEAN csrIsAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3441 tANI_U8 cAllSuites,
3442 tANI_U8 Oui[] )
3443{
3444 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[01], Oui ) );
3445}
3446
3447#ifdef NOT_CURRENTLY_USED
3448static tANI_BOOLEAN csrIsAuth802_1x( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3449 tANI_U8 cAllSuites,
3450 tANI_U8 Oui[] )
3451{
3452 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[00], Oui ) );
3453}
3454#endif // NOT_CURRENTLY_USED
3455
3456static tANI_BOOLEAN csrIsAuthWpaPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3457 tANI_U8 cAllSuites,
3458 tANI_U8 Oui[] )
3459{
3460 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[02], Oui ) );
3461}
3462#if 0
3463static tANI_BOOLEAN csrIsUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3464 tANI_U8 cAllCyphers,
3465 tANI_U8 Oui[] )
3466{
3467 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui00, Oui ) );
3468}
3469
3470static tANI_BOOLEAN csrIsUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3471 tANI_U8 cAllCyphers,
3472 tANI_U8 Oui[] )
3473{
3474 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3475}
3476
3477static tANI_BOOLEAN csrIsUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3478 tANI_U8 cAllCyphers,
3479 tANI_U8 Oui[] )
3480{
3481 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3482}
3483
3484
3485static tANI_BOOLEAN csrIsMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3486 tANI_U8 cAllCyphers,
3487 tANI_U8 Oui[] )
3488{
3489 tANI_BOOLEAN fYes = FALSE;
3490
3491 // Check Wep 104 first, if fails, then check Wep40.
3492 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui05, Oui );
3493
3494 if ( !fYes )
3495 {
3496 // if not Wep-104, check Wep-40
3497 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui01, Oui );
3498 }
3499
3500 return( fYes );
3501}
3502
3503
3504static tANI_BOOLEAN csrIsMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3505 tANI_U8 cAllCyphers,
3506 tANI_U8 Oui[] )
3507{
3508 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3509}
3510
3511
3512static tANI_BOOLEAN csrIsMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3513 tANI_U8 cAllCyphers,
3514 tANI_U8 Oui[] )
3515{
3516 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3517}
3518
3519#endif
3520
3521tANI_U8 csrGetOUIIndexFromCipher( eCsrEncryptionType enType )
3522{
3523 tANI_U8 OUIIndex;
3524
3525 switch ( enType )
3526 {
3527 case eCSR_ENCRYPT_TYPE_WEP40:
3528 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3529 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX;
3530 break;
3531 case eCSR_ENCRYPT_TYPE_WEP104:
3532 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3533 OUIIndex = CSR_OUI_WEP104_INDEX;
3534 break;
3535 case eCSR_ENCRYPT_TYPE_TKIP:
3536 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX;
3537 break;
3538 case eCSR_ENCRYPT_TYPE_AES:
3539 OUIIndex = CSR_OUI_AES_INDEX;
3540 break;
3541 case eCSR_ENCRYPT_TYPE_NONE:
3542 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX;
3543 break;
3544#ifdef FEATURE_WLAN_WAPI
3545 case eCSR_ENCRYPT_TYPE_WPI:
3546 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX;
3547 break;
3548#endif /* FEATURE_WLAN_WAPI */
3549 default: //HOWTO handle this?
3550 OUIIndex = CSR_OUI_RESERVED_INDEX;
3551 break;
3552 }//switch
3553
3554 return OUIIndex;
3555}
3556
3557tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3558 tDot11fIERSN *pRSNIe,
3559 tANI_U8 *UnicastCypher,
3560 tANI_U8 *MulticastCypher,
3561 tANI_U8 *AuthSuite,
3562 tCsrRSNCapabilities *Capabilities,
3563 eCsrAuthType *pNegotiatedAuthtype,
3564 eCsrEncryptionType *pNegotiatedMCCipher )
3565{
3566 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3567 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3568 tANI_U8 cUnicastCyphers = 0;
3569 tANI_U8 cMulticastCyphers = 0;
3570 tANI_U8 cAuthSuites = 0, i;
3571 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3572 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3573 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3574 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3575 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3576 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3577
3578 do{
3579 if ( pRSNIe->present )
3580 {
3581 cMulticastCyphers++;
3582 palCopyMemory(pMac->hHdd, MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
3583 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
3584 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_count);
3585 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3586 {
3587 palCopyMemory(pMac->hHdd, (void *)&AuthSuites[i],
3588 (void *)&pRSNIe->akm_suites[i], CSR_RSN_OUI_SIZE);
3589 }
3590
3591 //Check - Is requested Unicast Cipher supported by the BSS.
3592 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3593 csrGetOUIIndexFromCipher( enType ), Unicast );
3594
3595 if( !fAcceptableCyphers ) break;
3596
3597
3598 //Unicast is supported. Pick the first matching Group cipher, if any.
3599 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3600 {
3601 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3602 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3603 if(fAcceptableCyphers)
3604 {
3605 break;
3606 }
3607 }
3608 if( !fAcceptableCyphers ) break;
3609
3610 if( pNegotiatedMCCipher )
3611 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3612
3613 /* Initializing with FALSE as it has TRUE value already */
3614 fAcceptableCyphers = FALSE;
3615 for (i = 0 ; i < pAuthType->numEntries; i++)
3616 {
3617 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3618 #ifdef WLAN_FEATURE_VOWIFI_11R
3619 /* Changed the AKM suites according to order of preference */
3620 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3621 {
3622 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3623 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3624 }
3625 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3626 {
3627 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3628 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3629 }
3630#endif
3631#ifdef FEATURE_WLAN_CCX
3632 /* CCX only supports 802.1X. No PSK. */
3633 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsCcxCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3634 {
3635 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3636 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3637 }
3638#endif
3639 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3640 {
3641 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3642 negAuthType = eCSR_AUTH_TYPE_RSN;
3643 }
3644 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3645 {
3646 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3647 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3648 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003649#ifdef WLAN_FEATURE_11W
3650 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3651 {
3652 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3653 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3654 }
3655#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003656
3657 // The 1st auth type in the APs RSN IE, to match stations connecting
3658 // profiles auth type will cause us to exit this loop
3659 // This is added as some APs advertise multiple akms in the RSN IE.
3660 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3661 {
3662 fAcceptableCyphers = TRUE;
3663 break;
3664 }
3665 } // for
3666 }
3667
3668 }while (0);
3669
3670 if ( fAcceptableCyphers )
3671 {
3672 if ( MulticastCypher )
3673 {
3674 palCopyMemory( pMac->hHdd, MulticastCypher, Multicast, CSR_RSN_OUI_SIZE );
3675 }
3676
3677 if ( UnicastCypher )
3678 {
3679 palCopyMemory( pMac->hHdd, UnicastCypher, Unicast, CSR_RSN_OUI_SIZE );
3680 }
3681
3682 if ( AuthSuite )
3683 {
3684 palCopyMemory( pMac->hHdd, AuthSuite, Authentication, CSR_RSN_OUI_SIZE );
3685 }
3686
3687 if ( pNegotiatedAuthtype )
3688 {
3689 *pNegotiatedAuthtype = negAuthType;
3690 }
3691 if ( Capabilities )
3692 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003693 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3694 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3695 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003696 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003697 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3698 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
Chet Lanctot186b5732013-03-18 10:26:30 -07003699 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 }
3701 }
3702 return( fAcceptableCyphers );
3703}
3704
3705
3706tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
3707 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
3708{
3709 tANI_BOOLEAN fRSNMatch = FALSE;
3710
3711 // See if the cyphers in the Bss description match with the settings in the profile.
3712 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
3713 pNegotiatedAuthType, pNegotiatedMCCipher );
3714
3715 return( fRSNMatch );
3716}
3717
3718
3719tANI_BOOLEAN csrLookupPMKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pPMKId )
3720{
3721 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
3722 tANI_U32 Index;
3723 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3724
Jeff Johnson32d95a32012-09-10 13:15:23 -07003725 if(!pSession)
3726 {
3727 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3728 return FALSE;
3729 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003730 /* to force the AP initiate fresh 802.1x authentication after re-association should not
3731 * fill the PMKID from cache this is needed
3732 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
3733
3734 if(pSession->fIgnorePMKIDCache)
3735 {
3736 pSession->fIgnorePMKIDCache = FALSE;
3737 return fRC;
3738 }
3739
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 do
3741 {
3742 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
3743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003744 smsLog(pMac, LOGW, "match PMKID %02X-%02X-%02X-%02X-%02X-%02X to ",
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 pBSSId[0], pBSSId[1], pBSSId[2], pBSSId[3], pBSSId[4], pBSSId[5]);
3746 if( palEqualMemory( pMac->hHdd, pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
3747 {
3748 // match found
3749 fMatchFound = TRUE;
3750 break;
3751 }
3752 }
3753
3754 if( !fMatchFound ) break;
3755
3756 palCopyMemory( pMac->hHdd, pPMKId, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE );
3757
3758 fRC = TRUE;
3759 }
3760 while( 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003761 smsLog(pMac, LOGW, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 fRC, pSession->NumPmkidCache);
3763
3764 return fRC;
3765}
3766
3767
3768tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3769 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
3770{
3771 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3772 tANI_BOOLEAN fRSNMatch;
3773 tANI_U8 cbRSNIe = 0;
3774 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
3775 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
3776 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
3777 tCsrRSNAuthIe *pAuthSuite;
3778 tCsrRSNCapabilities RSNCapabilities;
3779 tCsrRSNPMKIe *pPMK;
3780 tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003781#ifdef WLAN_FEATURE_11W
3782 tANI_U8 *pGroupMgmtCipherSuite;
3783#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 tDot11fBeaconIEs *pIesLocal = pIes;
3785
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003786 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003787
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 do
3789 {
3790 if ( !csrIsProfileRSN( pProfile ) ) break;
3791
3792 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
3793 {
3794 break;
3795 }
3796
3797 // See if the cyphers in the Bss description match with the settings in the profile.
3798 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
3799 &pProfile->mcEncryptionType, &pIesLocal->RSN,
3800 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, NULL, NULL );
3801 if ( !fRSNMatch ) break;
3802
3803 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
3804
3805 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
3806
3807 palCopyMemory( pMac->hHdd, pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ) );
3808
3809 pRSNIe->cUnicastCyphers = 1;
3810
3811 palCopyMemory( pMac->hHdd, &pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ) );
3812
3813 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
3814
3815 pAuthSuite->cAuthenticationSuites = 1;
3816 palCopyMemory( pMac->hHdd, &pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ) );
3817
3818 // RSN capabilities follows the Auth Suite (two octects)
3819 // !!REVIEW - What should STA put in RSN capabilities, currently
3820 // just putting back APs capabilities
3821 // 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 -07003822 // For another, we should use the Management Frame Protection values given by the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 RSNCapabilities.PreAuthSupported = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003824#ifdef WLAN_FEATURE_11W
3825 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
3826 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
3827#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
3829
3830 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
3831
3832 if( csrLookupPMKID( pMac, sessionId, pSirBssDesc->bssId, &(PMKId[0]) ) )
3833 {
3834 pPMK->cPMKIDs = 1;
3835
3836 palCopyMemory( pMac->hHdd, pPMK->PMKIDList[0].PMKID, PMKId, CSR_RSN_PMKID_SIZE );
3837 }
3838 else
3839 {
3840 pPMK->cPMKIDs = 0;
3841 }
3842
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003843#ifdef WLAN_FEATURE_11W
3844 if ( pProfile->MFPEnabled )
3845 {
3846 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
3847 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
3848 palCopyMemory( pMac->hHdd, pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE );
3849 }
3850#endif
3851
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
3853 // Add in the size of the Auth suite (count plus a single OUI)
3854 // Add in the RSN caps field.
3855 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003856 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
3858 sizeof( *pAuthSuite ) +
3859 sizeof( tCsrRSNCapabilities ));
3860 if(pPMK->cPMKIDs)
3861 {
3862 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
3863 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
3864 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003865#ifdef WLAN_FEATURE_11W
3866 if ( pProfile->MFPEnabled )
3867 {
3868 if ( 0 == pPMK->cPMKIDs )
3869 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
3870 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
3871 }
3872#endif
3873
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 // return the size of the IE header (total) constructed...
3875 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
3876
3877 } while( 0 );
3878
3879 if( !pIes && pIesLocal )
3880 {
3881 //locally allocated
3882 palFreeMemory(pMac->hHdd, pIesLocal);
3883 }
3884
3885 return( cbRSNIe );
3886}
3887
3888
3889#ifdef FEATURE_WLAN_WAPI
3890tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3891 tDot11fIEWAPI *pWapiIe,
3892 tANI_U8 *UnicastCypher,
3893 tANI_U8 *MulticastCypher,
3894 tANI_U8 *AuthSuite,
3895 eCsrAuthType *pNegotiatedAuthtype,
3896 eCsrEncryptionType *pNegotiatedMCCipher )
3897{
3898 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3899 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3900 tANI_U8 cUnicastCyphers = 0;
3901 tANI_U8 cMulticastCyphers = 0;
3902 tANI_U8 cAuthSuites = 0, i;
3903 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
3904 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
3905 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
3906 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
3907 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
3908 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3909
3910 do{
3911 if ( pWapiIe->present )
3912 {
3913 cMulticastCyphers++;
3914 palCopyMemory(pMac->hHdd, MulticastCyphers, pWapiIe->multicast_cipher_suite, CSR_WAPI_OUI_SIZE);
3915 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
3916 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
3917 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
3918 {
3919 palCopyMemory(pMac->hHdd, (void *)&AuthSuites[i],
3920 (void *)&pWapiIe->akm_suites[i], CSR_WAPI_OUI_SIZE);
3921 }
3922
3923 //Check - Is requested Unicast Cipher supported by the BSS.
3924 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
3925 csrGetOUIIndexFromCipher( enType ), Unicast );
3926
3927 if( !fAcceptableCyphers ) break;
3928
3929
3930 //Unicast is supported. Pick the first matching Group cipher, if any.
3931 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3932 {
3933 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3934 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3935 if(fAcceptableCyphers)
3936 {
3937 break;
3938 }
3939 }
3940 if( !fAcceptableCyphers ) break;
3941
3942 if( pNegotiatedMCCipher )
3943 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3944
3945 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3946 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
3947 {
3948 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3949 }
3950 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3951 {
3952 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3953 }
3954 else
3955 {
3956 fAcceptableCyphers = FALSE;
3957 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3958 }
3959 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
3960 {
3961 //Caller doesn't care about auth type, or BSS doesn't match
3962 break;
3963 }
3964 fAcceptableCyphers = FALSE;
3965 for( i = 0 ; i < pAuthType->numEntries; i++ )
3966 {
3967 if( pAuthType->authType[i] == negAuthType )
3968 {
3969 fAcceptableCyphers = TRUE;
3970 break;
3971 }
3972 }
3973 }
3974 }while (0);
3975
3976 if ( fAcceptableCyphers )
3977 {
3978 if ( MulticastCypher )
3979 {
3980 palCopyMemory( pMac->hHdd, MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE );
3981 }
3982
3983 if ( UnicastCypher )
3984 {
3985 palCopyMemory( pMac->hHdd, UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE );
3986 }
3987
3988 if ( AuthSuite )
3989 {
3990 palCopyMemory( pMac->hHdd, AuthSuite, Authentication, CSR_WAPI_OUI_SIZE );
3991 }
3992
3993 if ( pNegotiatedAuthtype )
3994 {
3995 *pNegotiatedAuthtype = negAuthType;
3996 }
3997 }
3998 return( fAcceptableCyphers );
3999}
4000
4001tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4002 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
4003{
4004 tANI_BOOLEAN fWapiMatch = FALSE;
4005
4006 // See if the cyphers in the Bss description match with the settings in the profile.
4007 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4008 pNegotiatedAuthType, pNegotiatedMCCipher );
4009
4010 return( fWapiMatch );
4011}
4012
4013tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4014{
4015 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4016 tANI_U32 Index;
4017 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4018
Jeff Johnson32d95a32012-09-10 13:15:23 -07004019 if(!pSession)
4020 {
4021 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4022 return FALSE;
4023 }
4024
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 do
4026 {
4027 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4028 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004029 smsLog(pMac, LOGW, "match BKID %02X-%02X-%02X-%02X-%02X-%02X to ",
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 pBSSId[0], pBSSId[1], pBSSId[2], pBSSId[3], pBSSId[4], pBSSId[5]);
4031 if( palEqualMemory( pMac->hHdd, pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
4032 {
4033 // match found
4034 fMatchFound = TRUE;
4035 break;
4036 }
4037 }
4038
4039 if( !fMatchFound ) break;
4040
4041 palCopyMemory( pMac->hHdd, pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE );
4042
4043 fRC = TRUE;
4044 }
4045 while( 0 );
4046 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4047
4048 return fRC;
4049}
4050
4051tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4052 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4053{
4054 tANI_BOOLEAN fWapiMatch = FALSE;
4055 tANI_U8 cbWapiIe = 0;
4056 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4057 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4058 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4059 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4060 tANI_U8 *pWapi = NULL;
4061 tANI_BOOLEAN fBKIDFound = FALSE;
4062 tDot11fBeaconIEs *pIesLocal = pIes;
4063
4064 do
4065 {
4066 if ( !csrIsProfileWapi( pProfile ) ) break;
4067
4068 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4069 {
4070 break;
4071 }
4072
4073 // See if the cyphers in the Bss description match with the settings in the profile.
4074 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4075 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4076 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4077 if ( !fWapiMatch ) break;
4078
4079 palZeroMemory(pMac->hHdd, pWapiIe, sizeof(tCsrWapiIe));
4080
4081 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4082
4083 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4084
4085 pWapiIe->cAuthenticationSuites = 1;
4086 palCopyMemory( pMac->hHdd, &pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ) );
4087
4088 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4089
4090 *pWapi = (tANI_U16)1; //cUnicastCyphers
4091 pWapi+=2;
4092 palCopyMemory( pMac->hHdd, pWapi, UnicastCypher, sizeof( UnicastCypher ) );
4093 pWapi += sizeof( UnicastCypher );
4094
4095 palCopyMemory( pMac->hHdd, pWapi, MulticastCypher, sizeof( MulticastCypher ) );
4096 pWapi += sizeof( MulticastCypher );
4097
4098
4099 // WAPI capabilities follows the Auth Suite (two octects)
4100 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4101 // & since we already did a memset pWapiIe to 0, skip these fields
4102 pWapi +=2;
4103
4104 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4105
4106
4107 if( fBKIDFound )
4108 {
4109 /* Do we need to change the endianness here */
4110 *pWapi = (tANI_U16)1; //cBKIDs
4111 pWapi+=2;
4112 palCopyMemory( pMac->hHdd, pWapi, BKId, CSR_WAPI_BKID_SIZE );
4113 }
4114 else
4115 {
4116 *pWapi = 0;
4117 pWapi+=1;
4118 *pWapi = 0;
4119 pWapi+=1;
4120 }
4121
4122 // Add in the IE fields except the IE header
4123 // Add BKID count and BKID (if any)
4124 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4125
4126 /*2 bytes for BKID Count field*/
4127 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4128
4129 if(fBKIDFound)
4130 {
4131 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4132 }
4133 // return the size of the IE header (total) constructed...
4134 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4135
4136 } while( 0 );
4137
4138 if( !pIes && pIesLocal )
4139 {
4140 //locally allocated
4141 palFreeMemory(pMac->hHdd, pIesLocal);
4142 }
4143
4144 return( cbWapiIe );
4145}
4146#endif /* FEATURE_WLAN_WAPI */
4147
4148tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4149 tDot11fIEWPA *pWpaIe,
4150 tANI_U8 *UnicastCypher,
4151 tANI_U8 *MulticastCypher,
4152 tANI_U8 *AuthSuite,
4153 eCsrAuthType *pNegotiatedAuthtype,
4154 eCsrEncryptionType *pNegotiatedMCCipher )
4155{
4156 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4157 tANI_U8 cUnicastCyphers = 0;
4158 tANI_U8 cMulticastCyphers = 0;
4159 tANI_U8 cAuthSuites = 0;
4160 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4161 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4162 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4163 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4164 tANI_U8 i;
4165 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4166
4167 do
4168 {
4169 if ( pWpaIe->present )
4170 {
4171 cMulticastCyphers = 1;
4172 palCopyMemory(pMac->hHdd, MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
4173 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4174 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4175
4176 //Check - Is requested Unicast Cipher supported by the BSS.
4177 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4178 csrGetOUIIndexFromCipher( enType ), Unicast );
4179
4180 if( !fAcceptableCyphers ) break;
4181
4182
4183 //Unicast is supported. Pick the first matching Group cipher, if any.
4184 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4185 {
4186 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4187 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4188 if(fAcceptableCyphers)
4189 {
4190 break;
4191 }
4192 }
4193 if( !fAcceptableCyphers ) break;
4194
4195 if( pNegotiatedMCCipher )
4196 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4197
4198 /* Initializing with FALSE as it has TRUE value already */
4199 fAcceptableCyphers = FALSE;
4200 for (i = 0 ; i < pAuthType->numEntries; i++)
4201 {
4202 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4203 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4204 {
4205 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4206 negAuthType = eCSR_AUTH_TYPE_WPA;
4207 }
4208 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4209 {
4210 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4211 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4212 }
4213#ifdef FEATURE_WLAN_CCX
4214 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsCcxCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4215 {
4216 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4217 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4218 }
4219#endif /* FEATURE_WLAN_CCX */
4220
4221 // The 1st auth type in the APs WPA IE, to match stations connecting
4222 // profiles auth type will cause us to exit this loop
4223 // This is added as some APs advertise multiple akms in the WPA IE.
4224 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4225 {
4226 fAcceptableCyphers = TRUE;
4227 break;
4228 }
4229 } // for
4230 }
4231 }while(0);
4232
4233 if ( fAcceptableCyphers )
4234 {
4235 if ( MulticastCypher )
4236 {
4237 palCopyMemory( pMac->hHdd, (tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE );
4238 }
4239
4240 if ( UnicastCypher )
4241 {
4242 palCopyMemory( pMac->hHdd, (tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE );
4243 }
4244
4245 if ( AuthSuite )
4246 {
4247 palCopyMemory( pMac->hHdd, (tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE );
4248 }
4249
4250 if( pNegotiatedAuthtype )
4251 {
4252 *pNegotiatedAuthtype = negAuthType;
4253 }
4254 }
4255
4256 return( fAcceptableCyphers );
4257}
4258
4259
4260
4261tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4262 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4263{
4264 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4265
4266 // See if the cyphers in the Bss description match with the settings in the profile.
4267 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4268
4269 return( fWpaMatch );
4270}
4271
4272
4273tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4274 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4275{
4276 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4277 tANI_BOOLEAN fWpaMatch;
4278 tANI_U8 cbWpaIe = 0;
4279 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4280 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4281 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4282 tCsrWpaAuthIe *pAuthSuite;
4283 tDot11fBeaconIEs *pIesLocal = pIes;
4284
4285 do
4286 {
4287 if ( !csrIsProfileWpa( pProfile ) ) break;
4288
4289 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4290 {
4291 break;
4292 }
4293 // See if the cyphers in the Bss description match with the settings in the profile.
4294 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4295 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4296 if ( !fWpaMatch ) break;
4297
4298 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4299
4300 palCopyMemory( pMac->hHdd, pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ) );
4301
4302 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4303
4304 palCopyMemory( pMac->hHdd, pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ) );
4305
4306 pWpaIe->cUnicastCyphers = 1;
4307
4308 palCopyMemory( pMac->hHdd, &pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ) );
4309
4310 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4311
4312 pAuthSuite->cAuthenticationSuites = 1;
4313 palCopyMemory( pMac->hHdd, &pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ) );
4314
4315 // The WPA capabilities follows the Auth Suite (two octects)--
4316 // this field is optional, and we always "send" zero, so just
4317 // remove it. This is consistent with our assumptions in the
4318 // frames compiler; c.f. bug 15234:
4319 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4320
4321 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4322 // Add in the size of the Auth suite (count plus a single OUI)
4323 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4324 sizeof( *pAuthSuite );
4325
4326 // return the size of the IE header (total) constructed...
4327 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4328
4329 } while( 0 );
4330
4331 if( !pIes && pIesLocal )
4332 {
4333 //locally allocated
4334 palFreeMemory(pMac->hHdd, pIesLocal);
4335 }
4336
4337 return( cbWpaIe );
4338}
4339
4340
4341tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4342 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4343{
4344 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4345 tDot11IEHeader *pIEHeader;
4346 tSirMacPropIE *pSirMacPropIE;
4347 tANI_U32 cbParsed;
4348 tANI_U32 cbIE;
4349 int cExpectedIEs = 0;
4350 int cFoundIEs = 0;
4351 int cbPropIETotal;
4352
4353 pIEHeader = (tDot11IEHeader *)pIes;
4354 if(pWpaIe) cExpectedIEs++;
4355 if(pRSNIe) cExpectedIEs++;
4356
4357 // bss description length includes all fields other than the length itself
4358 cbParsed = 0;
4359
4360 // Loop as long as there is data left in the IE of the Bss Description
4361 // and the number of Expected IEs is NOT found yet.
4362 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4363 {
4364 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4365
4366 if ( ( cbIE + cbParsed ) > len ) break;
4367
4368 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4369 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4370 {
4371 switch( pIEHeader->ElementID )
4372 {
4373 // Parse the 221 (0xdd) Proprietary IEs here...
4374 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4375 // Airgo proprietary IE information.
4376 case SIR_MAC_WPA_EID:
4377 {
4378 tANI_U32 aniOUI;
4379 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4380
4381 pOui++;
4382 aniOUI = ANI_OUI;
4383 aniOUI = i_ntohl( aniOUI );
4384
4385 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4386 cbPropIETotal = pSirMacPropIE->length;
4387
4388 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4389 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4390 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4391 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4392 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4393 {
4394 }
4395 else
4396 {
4397 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4398
4399 if(!pWpaIe || !pcbWpaIe) break;
4400 // Check if this is a valid WPA IE. Then check that the
4401 // WPA OUI is in place and the version is one that we support.
4402 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
4403 ( palEqualMemory(pMac->hHdd, pIe->Oui, (void *)csrWpaOui[1], sizeof( pIe->Oui ) ) ) &&
4404 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4405 {
4406 palCopyMemory(pMac->hHdd, pWpaIe, pIe, pIe->IeHeader.Length + sizeof( pIe->IeHeader ) );
4407 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4408 cFoundIEs++;
4409
4410 break;
4411 }
4412 }
4413
4414 break;
4415 }
4416
4417 case SIR_MAC_RSN_EID:
4418 {
4419 tCsrRSNIe *pIe;
4420
4421 if(!pcbRSNIe || !pRSNIe) break;
4422 pIe = (tCsrRSNIe *)pIEHeader;
4423
4424 // Check the length of the RSN Ie to assure it is valid. Then check that the
4425 // version is one that we support.
4426
4427 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4428 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4429
4430 cFoundIEs++;
4431
4432 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4433 // the buffer passed in.
4434 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
4435 palCopyMemory(pMac->hHdd, pRSNIe, pIe, pIe->IeHeader.Length + sizeof( pIe->IeHeader ) );
4436 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4437
4438 break;
4439 }
4440
4441 // Add support for other IE here...
4442 default:
4443 break;
4444 }
4445 }
4446
4447 cbParsed += cbIE;
4448
4449 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4450
4451 }
4452
4453 // return a BOOL that tells if all of the IEs asked for were found...
4454 return( cFoundIEs == cExpectedIEs );
4455}
4456
4457
4458//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4459//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4460tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4461 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4462{
4463 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4464 tANI_U8 cbWpaIe = 0;
4465
4466 do
4467 {
4468 if ( !csrIsProfileWpa( pProfile ) ) break;
4469 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4470 {
4471 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4472 {
4473 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
4474 palCopyMemory(pMac->hHdd, pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
4475 }
4476 else
4477 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004478 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 }
4480 }
4481 else
4482 {
4483 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4484 }
4485 }while(0);
4486
4487 return (cbWpaIe);
4488}
4489
4490
4491//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4492//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4493tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4494 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4495{
4496 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4497 tANI_U8 cbRsnIe = 0;
4498
4499 do
4500 {
4501 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004502#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304503 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004504 {
4505 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4506 // scratch. So it contains the current PMK-IDs
4507 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4508 }
4509 else
4510#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 if(pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
4512 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004513 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4515 {
4516 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
4517 palCopyMemory(pMac->hHdd, pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
4518 }
4519 else
4520 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004521 smsLog(pMac, LOGW, " csrRetrieveRsnIe detect invalid RSN IE length (%d) ", pProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 }
4523 }
4524 else
4525 {
4526 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4527 }
4528 }while(0);
4529
4530 return (cbRsnIe);
4531}
4532
4533
4534#ifdef FEATURE_WLAN_WAPI
4535//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
4536//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
4537tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
4538 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4539 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4540{
4541 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4542 tANI_U8 cbWapiIe = 0;
4543
4544 do
4545 {
4546 if ( !csrIsProfileWapi( pProfile ) ) break;
4547 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
4548 {
4549 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
4550 {
4551 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
4552 palCopyMemory(pMac->hHdd, pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
4553 }
4554 else
4555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004556 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 }
4558 }
4559 else
4560 {
4561 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
4562 }
4563 }while(0);
4564
4565 return (cbWapiIe);
4566}
4567#endif /* FEATURE_WLAN_WAPI */
4568
4569tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
4570{
4571 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4572 tListElem *pEntry;
4573 tANI_U16 i;
4574 tANI_U16 startingChannel;
4575 tANI_BOOLEAN found = FALSE;
4576 tCsrChannelSet *pChannelGroup;
4577
4578 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
4579
4580 while ( pEntry )
4581 {
4582 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
4583 startingChannel = pChannelGroup->firstChannel;
4584 for ( i = 0; i < pChannelGroup->numChannels; i++ )
4585 {
4586 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
4587 {
4588 found = TRUE;
4589 break;
4590 }
4591 }
4592
4593 if ( found )
4594 {
4595 palCopyMemory(pMac->hHdd, returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
4596 break;
4597 }
4598 else
4599 {
4600 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
4601 }
4602 }
4603
4604 return( found );
4605}
4606
4607tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
4608{
4609 tANI_BOOLEAN fSupported = FALSE;
4610 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4611
4612 switch ( nonBasicRate )
4613 {
4614 case eCsrSuppRate_1Mbps:
4615 case eCsrSuppRate_2Mbps:
4616 case eCsrSuppRate_5_5Mbps:
4617 case eCsrSuppRate_11Mbps:
4618 fSupported = TRUE;
4619 break;
4620
4621 default:
4622 break;
4623 }
4624
4625 return( fSupported );
4626}
4627
4628tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
4629{
4630 tANI_BOOLEAN fSupported = FALSE;
4631 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4632
4633 switch ( nonBasicRate )
4634 {
4635 case eCsrSuppRate_6Mbps:
4636 case eCsrSuppRate_9Mbps:
4637 case eCsrSuppRate_12Mbps:
4638 case eCsrSuppRate_18Mbps:
4639 case eCsrSuppRate_24Mbps:
4640 case eCsrSuppRate_36Mbps:
4641 case eCsrSuppRate_48Mbps:
4642 case eCsrSuppRate_54Mbps:
4643 fSupported = TRUE;
4644 break;
4645
4646 default:
4647 break;
4648 }
4649
4650 return( fSupported );
4651}
4652
4653
4654
4655tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
4656{
4657 tAniEdType edType;
4658
4659 switch ( EncryptType )
4660 {
4661 default:
4662 case eCSR_ENCRYPT_TYPE_NONE:
4663 edType = eSIR_ED_NONE;
4664 break;
4665
4666 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4667 case eCSR_ENCRYPT_TYPE_WEP40:
4668 edType = eSIR_ED_WEP40;
4669 break;
4670
4671 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4672 case eCSR_ENCRYPT_TYPE_WEP104:
4673 edType = eSIR_ED_WEP104;
4674 break;
4675
4676 case eCSR_ENCRYPT_TYPE_TKIP:
4677 edType = eSIR_ED_TKIP;
4678 break;
4679
4680 case eCSR_ENCRYPT_TYPE_AES:
4681 edType = eSIR_ED_CCMP;
4682 break;
4683#ifdef FEATURE_WLAN_WAPI
4684 case eCSR_ENCRYPT_TYPE_WPI:
4685 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05304686 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004687#endif
4688#ifdef WLAN_FEATURE_11W
4689 //11w BIP
4690 case eCSR_ENCRYPT_TYPE_AES_CMAC:
4691 edType = eSIR_ED_AES_128_CMAC;
4692 break;
4693#endif
4694 }
4695
4696 return( edType );
4697}
4698
4699
4700//pIes can be NULL
4701tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
4702 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
4703 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
4704 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
4705{
4706 tANI_U32 idx;
4707 tANI_BOOLEAN fMatch = FALSE;
4708 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4709 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4710
4711 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
4712
4713 do
4714 {
4715 //If privacy bit is not set, consider no match
4716 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
4717
4718 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
4719 {
4720 switch( pMCEncryptionList->encryptionType[idx] )
4721 {
4722 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4723 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4724 case eCSR_ENCRYPT_TYPE_WEP40:
4725 case eCSR_ENCRYPT_TYPE_WEP104:
4726 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
4727 */
4728 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
4729 {
4730 fMatch = TRUE;
4731 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
4732 }
4733 break;
4734 default:
4735 fMatch = FALSE;
4736 break;
4737 }
4738 if(fMatch) break;
4739 }
4740
4741 if(!fMatch) break;
4742
4743 for( idx = 0; idx < pAuthList->numEntries; idx++ )
4744 {
4745 switch( pAuthList->authType[idx] )
4746 {
4747 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4748 case eCSR_AUTH_TYPE_SHARED_KEY:
4749 case eCSR_AUTH_TYPE_AUTOSWITCH:
4750 fMatch = TRUE;
4751 negotiatedAuth = pAuthList->authType[idx];
4752 break;
4753 default:
4754 fMatch = FALSE;
4755 }
4756 if (fMatch) break;
4757 }
4758
4759 if(!fMatch) break;
4760 //In case of WPA / WPA2, check whether it supports WEP as well
4761 if(pIes)
4762 {
4763 //Prepare the encryption type for WPA/WPA2 functions
4764 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
4765 {
4766 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4767 }
4768 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
4769 {
4770 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4771 }
4772 //else we can use the encryption type directly
4773 if( pIes->WPA.present )
4774 {
4775 fMatch = palEqualMemory(pMac->hHdd, pIes->WPA.multicast_cipher,
4776 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )], CSR_WPA_OUI_SIZE );
4777 if( fMatch ) break;
4778 }
4779 if( pIes->RSN.present )
4780 {
4781 fMatch = palEqualMemory(pMac->hHdd, pIes->RSN.gp_cipher_suite,
4782 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )], CSR_RSN_OUI_SIZE );
4783 }
4784 }
4785
4786 }while(0);
4787
4788 if( fMatch )
4789 {
4790 if( pNegotiatedAuthType )
4791 *pNegotiatedAuthType = negotiatedAuth;
4792
4793 if( pNegotiatedMCEncryption )
4794 *pNegotiatedMCEncryption = negotiatedMCCipher;
4795 }
4796
4797
4798 return fMatch;
4799}
4800
4801
4802//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
4803tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType, tCsrEncryptionList *pUCEncryptionType, tCsrEncryptionList *pMCEncryptionType,
4804 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
4805 eCsrAuthType *negotiatedAuthtype, eCsrEncryptionType *negotiatedUCCipher, eCsrEncryptionType *negotiatedMCCipher )
4806{
4807 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4808 tANI_BOOLEAN fMatch = FALSE;
4809 tANI_U8 i,idx;
4810 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4811 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4812
4813 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
4814 {
4815 ucCipher = pUCEncryptionType->encryptionType[i];
4816 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
4817 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
4818 // encryption type.
4819 switch ( ucCipher )
4820 {
4821 case eCSR_ENCRYPT_TYPE_NONE:
4822 {
4823 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
4824 // required so we have to reject this Bss.
4825 if ( csrIsPrivacy( pSirBssDesc ) )
4826 {
4827 fMatch = FALSE;
4828 }
4829 else
4830 {
4831 fMatch = TRUE;
4832 }
4833
4834 if ( fMatch )
4835 {
4836 fMatch = FALSE;
4837 //Check Multicast cipher requested and Auth type requested.
4838 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
4839 {
4840 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
4841 {
4842 fMatch = TRUE; //Multicast can only be none.
4843 mcCipher = pMCEncryptionType->encryptionType[idx];
4844 break;
4845 }
4846 }
4847 if (!fMatch) break;
4848
4849 fMatch = FALSE;
4850 //Check Auth list. It should contain AuthOpen.
4851 for( idx = 0 ; idx < authType->numEntries ; idx++ )
4852 {
4853 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
4854 {
4855 fMatch = TRUE;
4856 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4857 break;
4858 }
4859 }
4860 if (!fMatch) break;
4861
4862 }
4863 break;
4864 }
4865
4866 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4867 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4868 // !! might want to check for WEP keys set in the Profile.... ?
4869 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
4870 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
4871 // encryption is not allowed without the Privacy bit turned on.
4872 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4873
4874 break;
4875
4876 // these are all of the WPA encryption types...
4877 case eCSR_ENCRYPT_TYPE_WEP40:
4878 case eCSR_ENCRYPT_TYPE_WEP104:
4879 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4880 break;
4881
4882 case eCSR_ENCRYPT_TYPE_TKIP:
4883 case eCSR_ENCRYPT_TYPE_AES:
4884 {
4885 if(pIes)
4886 {
4887 // First check if there is a RSN match
4888 fMatch = csrIsRSNMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4889 if( !fMatch )
4890 {
4891 // If not RSN, then check if there is a WPA match
4892 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
4893 &negAuthType, &mcCipher );
4894 }
4895 }
4896 else
4897 {
4898 fMatch = FALSE;
4899 }
4900 break;
4901 }
4902#ifdef FEATURE_WLAN_WAPI
4903 case eCSR_ENCRYPT_TYPE_WPI://WAPI
4904 {
4905 if(pIes)
4906 {
4907 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4908 }
4909 else
4910 {
4911 fMatch = FALSE;
4912 }
4913 break;
4914 }
4915#endif /* FEATURE_WLAN_WAPI */
4916 case eCSR_ENCRYPT_TYPE_ANY:
4917 default:
4918 {
4919 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
4920
4921 fMatch = eANI_BOOLEAN_TRUE;
4922 //It is allowed to match anything. Try the more secured ones first.
4923 if(pIes)
4924 {
4925 //Check AES first
4926 ucCipher = eCSR_ENCRYPT_TYPE_AES;
4927 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4928 if(!fMatchAny)
4929 {
4930 //Check TKIP
4931 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
4932 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4933 }
4934#ifdef FEATURE_WLAN_WAPI
4935 if(!fMatchAny)
4936 {
4937 //Check WAPI
4938 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
4939 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4940 }
4941#endif /* FEATURE_WLAN_WAPI */
4942 }
4943 if(!fMatchAny)
4944 {
4945 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
4946 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4947 {
4948 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
4949 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4950 {
4951 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4952 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4953 {
4954 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4955 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4956 {
4957 //It must be open and no encryption
4958 if ( csrIsPrivacy( pSirBssDesc ) )
4959 {
4960 //This is not right
4961 fMatch = eANI_BOOLEAN_FALSE;
4962 }
4963 else
4964 {
4965 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4966 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
4967 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
4968 }
4969 }
4970 }
4971 }
4972 }
4973 }
4974 break;
4975 }
4976 }
4977
4978 }
4979
4980 if( fMatch )
4981 {
4982 if( negotiatedUCCipher )
4983 *negotiatedUCCipher = ucCipher;
4984
4985 if( negotiatedMCCipher )
4986 *negotiatedMCCipher = mcCipher;
4987
4988 if( negotiatedAuthtype )
4989 *negotiatedAuthtype = negAuthType;
4990 }
4991
4992 return( fMatch );
4993}
4994
4995
4996tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
4997 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
4998{
4999 tANI_BOOLEAN fMatch = FALSE;
5000
5001 do {
5002
5003 // There are a few special cases. If the Bss description has a Broadcast SSID,
5004 // then our Profile must have a single SSID without Wildcards so we can program
5005 // the SSID.
5006 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5007 // but the SSID value is all NULL characters. That condition is trated same
5008 // as NULL SSID
5009 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5010 {
5011 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5012 {
5013 fMatch = TRUE;
5014 }
5015 break;
5016 }
5017
5018 // Check for the specification of the Broadcast SSID at the beginning of the list.
5019 // If specified, then all SSIDs are matches (broadcast SSID means accept all SSIDs).
5020 if ( ssid1Len == 0 )
5021 {
5022 fMatch = TRUE;
5023 break;
5024 }
5025
5026 if(ssid1Len != bssSsidLen) break;
5027 if(palEqualMemory(pMac->hHdd, bssSsid, ssid1, bssSsidLen))
5028 {
5029 fMatch = TRUE;
5030 break;
5031 }
5032
5033 } while( 0 );
5034
5035 return( fMatch );
5036}
5037
5038
5039//Null ssid means match
5040tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5041{
5042 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5043 tANI_BOOLEAN fMatch = FALSE;
5044 tANI_U32 i;
5045
5046 if ( pSsidList && pSsid )
5047 {
5048 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5049 {
5050 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
5051 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5052 palEqualMemory(pMac->hHdd, pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
5053 {
5054 fMatch = TRUE;
5055 break;
5056 }
5057 }
5058 }
5059
5060 return (fMatch);
5061}
5062
5063//like to use sirCompareMacAddr
5064tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5065{
5066 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5067
5068 return( palEqualMemory(pMac->hHdd, bssid, pMacAddr, WNI_CFG_BSSID_LEN));
5069}
5070
5071//like to use sirCompareMacAddr
5072tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5073{
5074 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5075
5076 return( palEqualMemory(pMac->hHdd, bssid, pMacAddr, WNI_CFG_BSSID_LEN));
5077}
5078
5079
5080//like to use sirCompareMacAddr
5081tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5082{
5083 return( palEqualMemory(pMac->hHdd, pMacAddr1, pMacAddr2, sizeof(tCsrBssid)) );
5084}
5085
5086
5087tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5088{
5089 tANI_BOOLEAN fMatch = FALSE;
5090 tCsrBssid ProfileBssid;
5091 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5092
5093 // for efficiency of the MAC_ADDRESS functions, move the
5094 // Bssid's into MAC_ADDRESS structs.
5095 palCopyMemory( pMac->hHdd, &ProfileBssid, pProfBssid, sizeof(tCsrBssid) );
5096
5097 do {
5098
5099 // Give the profile the benefit of the doubt... accept either all 0 or
5100 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5101 // match any Bssids).
5102 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5103 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5104 {
5105 fMatch = TRUE;
5106 break;
5107 }
5108
5109 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5110 {
5111 fMatch = TRUE;
5112 break;
5113 }
5114
5115 } while( 0 );
5116
5117 return( fMatch );
5118}
5119
5120
5121tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5122{
5123 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5124 return eANI_BOOLEAN_FALSE;
5125 else
5126 return eANI_BOOLEAN_TRUE;
5127}
5128
5129
5130tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5131{
5132 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5133}
5134
5135tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5136{
5137 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5138}
5139
5140tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5141{
5142 tANI_BOOLEAN fMatch = TRUE;
5143
5144 do
5145 {
5146 switch( bssType )
5147 {
5148 case eCSR_BSS_TYPE_ANY:
5149 break;
5150
5151 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5152 case eCSR_BSS_TYPE_WDS_STA:
5153 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5154 fMatch = FALSE;
5155
5156 break;
5157
5158 case eCSR_BSS_TYPE_IBSS:
5159 case eCSR_BSS_TYPE_START_IBSS:
5160 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5161 fMatch = FALSE;
5162
5163 break;
5164
5165 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5166 default:
5167 fMatch = FALSE;
5168 break;
5169 }
5170 }
5171 while( 0 );
5172
5173
5174 return( fMatch );
5175}
5176
5177static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5178{
5179 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5180}
5181
5182
5183
5184static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5185{
5186 tANI_BOOLEAN fMatch = TRUE;
5187
5188 do
5189 {
5190 // if the channel is ANY, then always match...
5191 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5192 if ( Channel == pSirBssDesc->channelId ) break;
5193
5194 // didn't match anything.. so return NO match
5195 fMatch = FALSE;
5196
5197 } while( 0 );
5198
5199 return( fMatch );
5200}
5201
5202
5203tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5204{
5205 tANI_BOOLEAN fMatch = TRUE;
5206
5207 do
5208 {
5209 // if the profile says Any channel AND the global settings says ANY channel, then we
5210 // always match...
5211 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5212
5213 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5214 {
5215 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5216 }
5217
5218 } while( 0 );
5219
5220 return( fMatch );
5221}
5222
5223
5224/**
5225 * \brief Enquire as to whether a given rate is supported by the
5226 * adapter as currently configured
5227 *
5228 *
5229 * \param nRate A rate in units of 500kbps
5230 *
5231 * \return TRUE if the adapter is currently capable of supporting this
5232 * rate, FALSE else
5233 *
5234 *
5235 * The rate encoding is just as in 802.11 Information Elements, except
5236 * that the high bit is \em not interpreted as indicating a Basic Rate,
5237 * and proprietary rates are allowed, too.
5238 *
5239 * Note that if the adapter's dot11Mode is g, we don't restrict the
5240 * rates. According to hwReadEepromParameters, this will happen when:
5241 *
5242 * ... the card is configured for ALL bands through the property
5243 * page. If this occurs, and the card is not an ABG card ,then this
5244 * code is setting the dot11Mode to assume the mode that the
5245 * hardware can support. For example, if the card is an 11BG card
5246 * and we are configured to support ALL bands, then we change the
5247 * dot11Mode to 11g because ALL in this case is only what the
5248 * hardware can support.
5249 *
5250 *
5251 */
5252
5253static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5254{
5255 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5256 tANI_U16 idx, newRate;
5257
5258 //In case basic rate flag is set
5259 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5260 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5261 {
5262 switch ( newRate )
5263 {
5264 case eCsrSuppRate_6Mbps:
5265 case eCsrSuppRate_9Mbps:
5266 case eCsrSuppRate_12Mbps:
5267 case eCsrSuppRate_18Mbps:
5268 case eCsrSuppRate_24Mbps:
5269 case eCsrSuppRate_36Mbps:
5270 case eCsrSuppRate_48Mbps:
5271 case eCsrSuppRate_54Mbps:
5272 fSupported = TRUE;
5273 break;
5274 default:
5275 fSupported = FALSE;
5276 break;
5277 }
5278
5279 }
5280 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5281 {
5282 switch ( newRate )
5283 {
5284 case eCsrSuppRate_1Mbps:
5285 case eCsrSuppRate_2Mbps:
5286 case eCsrSuppRate_5_5Mbps:
5287 case eCsrSuppRate_11Mbps:
5288 fSupported = TRUE;
5289 break;
5290 default:
5291 fSupported = FALSE;
5292 break;
5293 }
5294 }
5295 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5296 {
5297
5298 switch ( newRate )
5299 {
5300 case eCsrSuppRate_1Mbps:
5301 case eCsrSuppRate_2Mbps:
5302 case eCsrSuppRate_5_5Mbps:
5303 case eCsrSuppRate_6Mbps:
5304 case eCsrSuppRate_9Mbps:
5305 case eCsrSuppRate_11Mbps:
5306 case eCsrSuppRate_12Mbps:
5307 case eCsrSuppRate_18Mbps:
5308 case eCsrSuppRate_24Mbps:
5309 case eCsrSuppRate_36Mbps:
5310 case eCsrSuppRate_48Mbps:
5311 case eCsrSuppRate_54Mbps:
5312 fSupported = TRUE;
5313 break;
5314 default:
5315 fSupported = FALSE;
5316 break;
5317 }
5318
5319 }
5320 else {
5321
5322 if ( eCsrSuppRate_1Mbps == newRate ||
5323 eCsrSuppRate_2Mbps == newRate ||
5324 eCsrSuppRate_5_5Mbps == newRate ||
5325 eCsrSuppRate_11Mbps == newRate )
5326 {
5327 fSupported = TRUE;
5328 }
5329 else {
5330 idx = 0x1;
5331
5332 switch ( newRate )
5333 {
5334 case eCsrSuppRate_6Mbps:
5335 fSupported = gPhyRatesSuppt[0][idx];
5336 break;
5337 case eCsrSuppRate_9Mbps:
5338 fSupported = gPhyRatesSuppt[1][idx];
5339 break;
5340 case eCsrSuppRate_12Mbps:
5341 fSupported = gPhyRatesSuppt[2][idx];
5342 break;
5343 case eCsrSuppRate_18Mbps:
5344 fSupported = gPhyRatesSuppt[3][idx];
5345 break;
5346 case eCsrSuppRate_20Mbps:
5347 fSupported = gPhyRatesSuppt[4][idx];
5348 break;
5349 case eCsrSuppRate_24Mbps:
5350 fSupported = gPhyRatesSuppt[5][idx];
5351 break;
5352 case eCsrSuppRate_36Mbps:
5353 fSupported = gPhyRatesSuppt[6][idx];
5354 break;
5355 case eCsrSuppRate_40Mbps:
5356 fSupported = gPhyRatesSuppt[7][idx];
5357 break;
5358 case eCsrSuppRate_42Mbps:
5359 fSupported = gPhyRatesSuppt[8][idx];
5360 break;
5361 case eCsrSuppRate_48Mbps:
5362 fSupported = gPhyRatesSuppt[9][idx];
5363 break;
5364 case eCsrSuppRate_54Mbps:
5365 fSupported = gPhyRatesSuppt[10][idx];
5366 break;
5367 case eCsrSuppRate_72Mbps:
5368 fSupported = gPhyRatesSuppt[11][idx];
5369 break;
5370 case eCsrSuppRate_80Mbps:
5371 fSupported = gPhyRatesSuppt[12][idx];
5372 break;
5373 case eCsrSuppRate_84Mbps:
5374 fSupported = gPhyRatesSuppt[13][idx];
5375 break;
5376 case eCsrSuppRate_96Mbps:
5377 fSupported = gPhyRatesSuppt[14][idx];
5378 break;
5379 case eCsrSuppRate_108Mbps:
5380 fSupported = gPhyRatesSuppt[15][idx];
5381 break;
5382 case eCsrSuppRate_120Mbps:
5383 fSupported = gPhyRatesSuppt[16][idx];
5384 break;
5385 case eCsrSuppRate_126Mbps:
5386 fSupported = gPhyRatesSuppt[17][idx];
5387 break;
5388 case eCsrSuppRate_144Mbps:
5389 fSupported = gPhyRatesSuppt[18][idx];
5390 break;
5391 case eCsrSuppRate_160Mbps:
5392 fSupported = gPhyRatesSuppt[19][idx];
5393 break;
5394 case eCsrSuppRate_168Mbps:
5395 fSupported = gPhyRatesSuppt[20][idx];
5396 break;
5397 case eCsrSuppRate_192Mbps:
5398 fSupported = gPhyRatesSuppt[21][idx];
5399 break;
5400 case eCsrSuppRate_216Mbps:
5401 fSupported = gPhyRatesSuppt[22][idx];
5402 break;
5403 case eCsrSuppRate_240Mbps:
5404 fSupported = gPhyRatesSuppt[23][idx];
5405 break;
5406 default:
5407 fSupported = FALSE;
5408 break;
5409 }
5410 }
5411 }
5412
5413 return fSupported;
5414}
5415
5416
5417
5418static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5419 tDot11fIESuppRates *pBssSuppRates,
5420 tDot11fIEExtSuppRates *pBssExtSuppRates )
5421{
5422 tANI_BOOLEAN fMatch = TRUE;
5423 tANI_U32 i;
5424
5425
5426 // Validate that all of the Basic rates advertised in the Bss description are supported.
5427 if ( pBssSuppRates )
5428 {
5429 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5430 {
5431 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5432 {
5433 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5434 {
5435 fMatch = FALSE;
5436 break;
5437 }
5438 }
5439 }
5440 }
5441
5442 if ( fMatch && pBssExtSuppRates )
5443 {
5444 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5445 {
5446 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5447 {
5448 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5449 {
5450 fMatch = FALSE;
5451 break;
5452 }
5453 }
5454 }
5455 }
5456
5457 return( fMatch );
5458
5459}
5460
5461
5462//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
5463tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
5464 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
5465 tDot11fBeaconIEs **ppIes)
5466{
5467 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5468 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5469 tANI_U32 i;
5470 tDot11fBeaconIEs *pIes = NULL;
5471 tANI_U8 *pb;
5472
5473 do {
5474 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
5475 {
5476 //If no IEs passed in, get our own.
5477 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
5478 {
5479 break;
5480 }
5481 }
5482 else
5483 {
5484 //Save the one pass in for local use
5485 pIes = *ppIes;
5486 }
5487
5488 //Check if caller wants P2P
5489 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
5490 if(!fCheck) break;
5491
5492 if(pIes->SSID.present)
5493 {
5494 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
5495 {
5496 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
5497 pIes->SSID.ssid,
5498 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
5499 if ( fCheck ) break;
5500 }
5501 if(!fCheck) break;
5502 }
5503 fCheck = eANI_BOOLEAN_TRUE;
5504 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
5505 {
5506 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
5507 if ( fCheck ) break;
5508
5509 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
5510 {
5511 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
5512 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
5513
5514 if ( fCheck ) break;
5515 }
5516 }
5517 if(!fCheck) break;
5518
5519 fCheck = eANI_BOOLEAN_TRUE;
5520 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
5521 {
5522 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
5523 if ( fCheck ) break;
5524 }
5525 if(!fCheck)
5526 break;
5527#if defined WLAN_FEATURE_VOWIFI
5528 /* If this is for measurement filtering */
5529 if( pFilter->fMeasurement )
5530 {
5531 fRC = eANI_BOOLEAN_TRUE;
5532 break;
5533 }
5534#endif
5535 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
5536 if ( (!pFilter->bWPSAssociation) &&
5537 !csrIsSecurityMatch( pMac, &pFilter->authType, &pFilter->EncryptionType, &pFilter->mcEncryptionType,
5538 pBssDesc, pIes, pNegAuth, pNegUc, pNegMc ) ) break;
5539 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
5540 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
5541 //Tush-QoS: validate first if asked for APSD or WMM association
5542 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
5543 !CSR_IS_QOS_BSS(pIes) )
5544 break;
5545 //Check country. check even when pb is NULL because we may want to make sure
5546 //AP has a country code in it if fEnforceCountryCodeMatch is set.
5547 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
5548
5549 fCheck = csrMatchCountryCode( pMac, pb, pIes );
5550 if(!fCheck)
5551 break;
5552
5553#ifdef WLAN_FEATURE_VOWIFI_11R
5554 if (pFilter->MDID.mdiePresent)
5555 {
5556 if (pBssDesc->mdiePresent)
5557 {
5558 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
5559 break;
5560 }
5561 else
5562 break;
5563 }
5564#endif
5565 fRC = eANI_BOOLEAN_TRUE;
5566
5567 } while( 0 );
5568 if( ppIes )
5569 {
5570 *ppIes = pIes;
5571 }
5572 else if( pIes )
5573 {
5574 palFreeMemory(pMac->hHdd, pIes);
5575 }
5576
5577 return( fRC );
5578}
5579
5580tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
5581 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
5582{
5583 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
5584 tCsrAuthList authList;
5585
5586 ucEncryptionList.numEntries = 1;
5587 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
5588
5589 mcEncryptionList.numEntries = 1;
5590 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
5591
5592 authList.numEntries = 1;
5593 authList.authType[0] = pProfile->AuthType;
5594
5595 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList, &mcEncryptionList, pBssDesc, pIes, NULL, NULL, NULL ));
5596
5597}
5598
5599
5600tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
5601 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
5602{
5603 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5604 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5605 tDot11fBeaconIEs *pIesLocal = pIes;
5606
5607 do {
5608 if( !pIes )
5609 {
5610 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
5611 {
5612 break;
5613 }
5614 }
5615 fCheck = eANI_BOOLEAN_TRUE;
5616 if(pIesLocal->SSID.present)
5617 {
5618 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
5619 if(pProfile->SSID.length)
5620 {
5621 fCheckSsid = eANI_BOOLEAN_TRUE;
5622 }
5623 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
5624 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
5625 if(!fCheck) break;
5626 }
5627 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
5628 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
5629 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
5630 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
5631 if(!fCheck)
5632 break;
5633
5634 fRC = eANI_BOOLEAN_TRUE;
5635
5636 } while( 0 );
5637
5638 if( !pIes && pIesLocal )
5639 {
5640 //locally allocated
5641 palFreeMemory(pMac->hHdd, pIesLocal);
5642 }
5643
5644 return( fRC );
5645}
5646
5647
5648
5649tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
5650{
5651 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5652 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
5653
5654 return csrIsAggregateRateSupported( pMac, n );
5655}
5656
5657
5658tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
5659{
5660 tANI_U16 ConvertedRate = Rate;
5661
5662 switch( Rate )
5663 {
5664 case SIR_MAC_RATE_1:
5665 ConvertedRate = 2;
5666 break;
5667 case SIR_MAC_RATE_2:
5668 ConvertedRate = 4;
5669 break;
5670 case SIR_MAC_RATE_5_5:
5671 ConvertedRate = 11;
5672 break;
5673 case SIR_MAC_RATE_11:
5674 ConvertedRate = 22;
5675 break;
5676
5677 case SIR_MAC_RATE_6:
5678 ConvertedRate = 12;
5679 break;
5680 case SIR_MAC_RATE_9:
5681 ConvertedRate = 18;
5682 break;
5683 case SIR_MAC_RATE_12:
5684 ConvertedRate = 24;
5685 break;
5686 case SIR_MAC_RATE_18:
5687 ConvertedRate = 36;
5688 break;
5689 case SIR_MAC_RATE_24:
5690 ConvertedRate = 48;
5691 break;
5692 case SIR_MAC_RATE_36:
5693 ConvertedRate = 72;
5694 break;
5695 case SIR_MAC_RATE_42:
5696 ConvertedRate = 84;
5697 break;
5698 case SIR_MAC_RATE_48:
5699 ConvertedRate = 96;
5700 break;
5701 case SIR_MAC_RATE_54:
5702 ConvertedRate = 108;
5703 break;
5704
5705 case SIR_MAC_RATE_72:
5706 ConvertedRate = 144;
5707 break;
5708 case SIR_MAC_RATE_84:
5709 ConvertedRate = 168;
5710 break;
5711 case SIR_MAC_RATE_96:
5712 ConvertedRate = 192;
5713 break;
5714 case SIR_MAC_RATE_108:
5715 ConvertedRate = 216;
5716 break;
5717 case SIR_MAC_RATE_126:
5718 ConvertedRate = 252;
5719 break;
5720 case SIR_MAC_RATE_144:
5721 ConvertedRate = 288;
5722 break;
5723 case SIR_MAC_RATE_168:
5724 ConvertedRate = 336;
5725 break;
5726 case SIR_MAC_RATE_192:
5727 ConvertedRate = 384;
5728 break;
5729 case SIR_MAC_RATE_216:
5730 ConvertedRate = 432;
5731 break;
5732 case SIR_MAC_RATE_240:
5733 ConvertedRate = 480;
5734 break;
5735
5736 case 0xff:
5737 ConvertedRate = 0;
5738 break;
5739 }
5740
5741 return ConvertedRate;
5742}
5743
5744
5745tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
5746{
5747 tANI_U8 i;
5748 tANI_U16 nBest;
5749
5750 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
5751
5752 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
5753 {
5754 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
5755 }
5756
5757 for ( i = 1U; i < pSuppRates->numRates; ++i )
5758 {
5759 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5760 }
5761
5762 if ( NULL != pExtRates )
5763 {
5764 for ( i = 0U; i < pExtRates->numRates; ++i )
5765 {
5766 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5767 }
5768 }
5769
5770 if ( NULL != pPropRates )
5771 {
5772 for ( i = 0U; i < pPropRates->numPropRates; ++i )
5773 {
5774 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
5775 }
5776 }
5777
5778 return nBest;
5779}
5780
5781
5782void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
5783{
5784 if(pProfile)
5785 {
5786 if(pProfile->BSSIDs.bssid)
5787 {
5788 palFreeMemory(pMac->hHdd, pProfile->BSSIDs.bssid);
5789 pProfile->BSSIDs.bssid = NULL;
5790 }
5791 if(pProfile->SSIDs.SSIDList)
5792 {
5793 palFreeMemory(pMac->hHdd, pProfile->SSIDs.SSIDList);
5794 pProfile->SSIDs.SSIDList = NULL;
5795 }
5796 if(pProfile->pWPAReqIE)
5797 {
5798 palFreeMemory(pMac->hHdd, pProfile->pWPAReqIE);
5799 pProfile->pWPAReqIE = NULL;
5800 }
5801 if(pProfile->pRSNReqIE)
5802 {
5803 palFreeMemory(pMac->hHdd, pProfile->pRSNReqIE);
5804 pProfile->pRSNReqIE = NULL;
5805 }
5806#ifdef FEATURE_WLAN_WAPI
5807 if(pProfile->pWAPIReqIE)
5808 {
5809 palFreeMemory(pMac->hHdd, pProfile->pWAPIReqIE);
5810 pProfile->pWAPIReqIE = NULL;
5811 }
5812#endif /* FEATURE_WLAN_WAPI */
5813
5814 if(pProfile->pAddIEScan)
5815 {
5816 palFreeMemory(pMac->hHdd, pProfile->pAddIEScan);
5817 pProfile->pAddIEScan = NULL;
5818 }
5819
5820 if(pProfile->pAddIEAssoc)
5821 {
5822 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
5823 pProfile->pAddIEAssoc = NULL;
5824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005825
5826 if(pProfile->ChannelInfo.ChannelList)
5827 {
5828 palFreeMemory(pMac->hHdd, pProfile->ChannelInfo.ChannelList);
5829 pProfile->ChannelInfo.ChannelList = NULL;
5830 }
5831
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 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