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