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