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