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