blob: 754e8906509f4ab8f7840d318a05bf6bfb2208ae [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
1432//This routine will return operating channel on FIRST BSS that is active/operating to be used for concurrency mode.
1433//If other BSS is not up or not connected it will return 0
1434
1435tANI_U8 csrGetConcurrentOperationChannel( tpAniSirGlobal pMac )
1436{
1437 tCsrRoamSession *pSession = NULL;
1438 tANI_U8 i = 0;
1439
1440 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1441 {
1442 if( CSR_IS_SESSION_VALID( pMac, i ) )
1443 {
1444 pSession = CSR_GET_SESSION( pMac, i );
1445
1446 if (NULL != pSession->pCurRoamProfile)
1447 {
1448 if (
1449 (((pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) ||
1450 (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE)) &&
1451 (pSession->connectState == eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED))
1452 ||
1453 (((pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) ||
1454 (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE)) &&
1455 (pSession->connectState != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
1456 )
1457 return (pSession->connectedProfile.operationChannel);
1458 }
1459
1460 }
1461 }
1462 return 0;
1463}
1464
1465tANI_BOOLEAN csrIsAllSessionDisconnected( tpAniSirGlobal pMac )
1466{
1467 tANI_U32 i;
1468 tANI_BOOLEAN fRc = eANI_BOOLEAN_TRUE;
1469
1470 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1471 {
1472 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1473 {
1474 fRc = eANI_BOOLEAN_FALSE;
1475 break;
1476 }
1477 }
1478
1479 return ( fRc );
1480}
1481
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001482tANI_BOOLEAN csrIsStaSessionConnected( tpAniSirGlobal pMac )
1483{
1484 tANI_U32 i;
1485 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1486 tCsrRoamSession *pSession = NULL;
1487 tANI_U32 countSta = 0;
1488
1489 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1490 {
1491 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1492 {
1493 pSession = CSR_GET_SESSION( pMac, i );
1494
1495 if (NULL != pSession->pCurRoamProfile)
1496 {
1497 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE) {
1498 countSta++;
1499 }
1500 }
1501 }
1502 }
1503
1504 /* return TRUE if one of the following conditions is TRUE:
1505 * - more than one STA session connected
1506 */
1507 if ( countSta > 0) {
1508 fRc = eANI_BOOLEAN_TRUE;
1509 }
1510
1511 return( fRc );
1512}
1513
1514tANI_BOOLEAN csrIsP2pSessionConnected( tpAniSirGlobal pMac )
1515{
1516 tANI_U32 i;
1517 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1518 tCsrRoamSession *pSession = NULL;
1519 tANI_U32 countP2pCli = 0;
1520 tANI_U32 countP2pGo = 0;
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001521 tANI_U32 countSAP = 0;
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001522
1523 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1524 {
1525 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1526 {
1527 pSession = CSR_GET_SESSION( pMac, i );
1528
1529 if (NULL != pSession->pCurRoamProfile)
1530 {
1531 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_CLIENT_MODE) {
1532 countP2pCli++;
1533 }
1534
1535 if (pSession->pCurRoamProfile->csrPersona == VOS_P2P_GO_MODE) {
1536 countP2pGo++;
1537 }
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001538
1539 if (pSession->pCurRoamProfile->csrPersona == VOS_STA_SAP_MODE) {
1540 countSAP++;
1541 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001542 }
1543 }
1544 }
1545
1546 /* return TRUE if one of the following conditions is TRUE:
1547 * - at least one P2P CLI session is connected
1548 * - at least one P2P GO session is connected
1549 */
Kalikinkar dhara96b4e7e2014-01-16 15:19:57 -08001550 if ( (countP2pCli > 0) || (countP2pGo > 0 ) || (countSAP > 0 ) ) {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08001551 fRc = eANI_BOOLEAN_TRUE;
1552 }
1553
1554 return( fRc );
1555}
1556
Madan Mohan Koyyalamudid3d22592012-09-24 14:01:29 -07001557tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac )
1558{
1559 tANI_U32 i, count;
1560 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1561
1562 count = 0;
1563 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1564 {
1565 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
1566 {
1567 count++;
1568 }
1569 }
1570
1571 if (count > 0)
1572 {
1573 fRc = eANI_BOOLEAN_TRUE;
1574 }
1575 return( fRc );
1576}
Jeff Johnson295189b2012-06-20 16:38:30 -07001577
1578tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac )
1579{
1580 tANI_U32 i;
1581 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1582
1583 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1584 {
1585 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1586 {
1587 fRc = eANI_BOOLEAN_TRUE;
1588 break;
1589 }
1590 }
1591
1592 return ( fRc );
1593}
1594
1595tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac )
1596{
1597 tANI_U32 i, noOfConnectedInfra = 0;
1598
1599 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1600
1601 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1602 {
1603 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedInfra( pMac, i ) )
1604 {
1605 ++noOfConnectedInfra;
1606 }
1607 }
1608
1609 // More than one Infra Sta Connected
1610 if(noOfConnectedInfra > 1)
1611 {
1612 fRc = eANI_BOOLEAN_TRUE;
1613 }
1614
1615 return ( fRc );
1616}
1617
1618tANI_BOOLEAN csrIsIBSSStarted( tpAniSirGlobal pMac )
1619{
1620 tANI_U32 i;
1621 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1622
1623 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1624 {
1625 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateIbss( pMac, i ) )
1626 {
1627 fRc = eANI_BOOLEAN_TRUE;
1628 break;
1629 }
1630 }
1631
1632 return ( fRc );
1633}
1634
1635
1636tANI_BOOLEAN csrIsBTAMPStarted( tpAniSirGlobal pMac )
1637{
1638 tANI_U32 i;
1639 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1640
1641 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
1642 {
1643 if( CSR_IS_SESSION_VALID( pMac, i ) && csrIsConnStateConnectedWds( pMac, i ) )
1644 {
1645 fRc = eANI_BOOLEAN_TRUE;
1646 break;
1647 }
1648 }
1649
1650 return ( fRc );
1651}
1652
Jeff Johnsone7245742012-09-05 17:12:55 -07001653tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac )
1654{
1655 tANI_U32 sessionId, noOfCocurrentSession = 0;
1656 eCsrConnectState connectState;
1657
1658 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1659
1660 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1661 {
1662 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1663 {
1664 connectState = pMac->roam.roamSession[sessionId].connectState;
1665 if( (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == connectState) ||
1666 (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == connectState) ||
1667 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == connectState) )
1668 {
1669 ++noOfCocurrentSession;
1670 }
1671 }
1672 }
1673
1674 // More than one session is Up and Running
1675 if(noOfCocurrentSession > 1)
1676 {
1677 fRc = eANI_BOOLEAN_TRUE;
1678 }
1679
1680 return ( fRc );
1681}
1682
Jeff Johnsone7245742012-09-05 17:12:55 -07001683tANI_BOOLEAN csrIsInfraApStarted( tpAniSirGlobal pMac )
1684{
1685 tANI_U32 sessionId;
1686 tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
1687
1688 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
1689 {
1690 if( CSR_IS_SESSION_VALID( pMac, sessionId ) && (csrIsConnStateConnectedInfraAp(pMac, sessionId)) )
1691 {
1692 fRc = eANI_BOOLEAN_TRUE;
1693 break;
1694 }
1695 }
1696
1697 return ( fRc );
1698
1699}
Jeff Johnsone7245742012-09-05 17:12:55 -07001700
Jeff Johnson295189b2012-06-20 16:38:30 -07001701tANI_BOOLEAN csrIsBTAMP( tpAniSirGlobal pMac, tANI_U32 sessionId )
1702{
1703 return ( csrIsConnStateConnectedWds( pMac, sessionId ) );
1704}
1705
1706
1707tANI_BOOLEAN csrIsConnStateDisconnected(tpAniSirGlobal pMac, tANI_U32 sessionId)
1708{
1709 return (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED == pMac->roam.roamSession[sessionId].connectState);
1710}
1711
Jeff Johnsone7245742012-09-05 17:12:55 -07001712tANI_BOOLEAN csrIsValidMcConcurrentSession(tpAniSirGlobal pMac, tANI_U32 sessionId,
1713 tSirBssDescription *pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07001714{
1715 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07001716 eAniBoolean status = eANI_BOOLEAN_FALSE;
1717
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 //Check for MCC support
1719 if (!pMac->roam.configParam.fenableMCCMode)
1720 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001721 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 }
1723
Jeff Johnsone7245742012-09-05 17:12:55 -07001724 //Validate BeaconInterval
1725 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
1726 {
1727 pSession = CSR_GET_SESSION( pMac, sessionId );
1728 if (NULL != pSession->pCurRoamProfile)
1729 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001730 if (csrIsconcurrentsessionValid (pMac, sessionId,
1731 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001732 == eHAL_STATUS_SUCCESS )
1733 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07001734 if (csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId,
1735 &pBssDesc->beaconInterval, sessionId,
1736 pSession->pCurRoamProfile->csrPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -07001737 != eHAL_STATUS_SUCCESS)
1738 {
1739 status = eANI_BOOLEAN_FALSE;
1740 }
1741 else
1742 {
1743 status = eANI_BOOLEAN_TRUE;
1744 }
1745 }
1746 else
1747 {
1748 status = eANI_BOOLEAN_FALSE;
1749 }
1750 }
1751 }
1752 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07001753}
1754
1755static tSirMacCapabilityInfo csrGetBssCapabilities( tSirBssDescription *pSirBssDesc )
1756{
1757 tSirMacCapabilityInfo dot11Caps;
1758
1759 //tSirMacCapabilityInfo is 16-bit
1760 pal_get_U16( (tANI_U8 *)&pSirBssDesc->capabilityInfo, (tANI_U16 *)&dot11Caps );
1761
1762 return( dot11Caps );
1763}
1764
1765tANI_BOOLEAN csrIsInfraBssDesc( tSirBssDescription *pSirBssDesc )
1766{
1767 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1768
1769 return( (tANI_BOOLEAN)dot11Caps.ess );
1770}
1771
1772
1773tANI_BOOLEAN csrIsIbssBssDesc( tSirBssDescription *pSirBssDesc )
1774{
1775 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1776
1777 return( (tANI_BOOLEAN)dot11Caps.ibss );
1778}
1779
1780tANI_BOOLEAN csrIsQoSBssDesc( tSirBssDescription *pSirBssDesc )
1781{
1782 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1783
1784 return( (tANI_BOOLEAN)dot11Caps.qos );
1785}
1786
1787tANI_BOOLEAN csrIsPrivacy( tSirBssDescription *pSirBssDesc )
1788{
1789 tSirMacCapabilityInfo dot11Caps = csrGetBssCapabilities( pSirBssDesc );
1790
1791 return( (tANI_BOOLEAN)dot11Caps.privacy );
1792}
1793
1794
1795tANI_BOOLEAN csrIs11dSupported(tpAniSirGlobal pMac)
1796{
1797 return(pMac->roam.configParam.Is11dSupportEnabled);
1798}
1799
1800
1801tANI_BOOLEAN csrIs11hSupported(tpAniSirGlobal pMac)
1802{
1803 return(pMac->roam.configParam.Is11hSupportEnabled);
1804}
1805
1806
1807tANI_BOOLEAN csrIs11eSupported(tpAniSirGlobal pMac)
1808{
1809 return(pMac->roam.configParam.Is11eSupportEnabled);
1810}
1811
1812tANI_BOOLEAN csrIsMCCSupported ( tpAniSirGlobal pMac )
1813{
1814 return(pMac->roam.configParam.fenableMCCMode);
1815
1816}
1817
1818tANI_BOOLEAN csrIsWmmSupported(tpAniSirGlobal pMac)
1819{
1820 if(eCsrRoamWmmNoQos == pMac->roam.configParam.WMMSupportMode)
1821 {
1822 return eANI_BOOLEAN_FALSE;
1823 }
1824 else
1825 {
1826 return eANI_BOOLEAN_TRUE;
1827 }
1828}
1829
1830
1831
1832
1833//pIes is the IEs for pSirBssDesc2
1834tANI_BOOLEAN csrIsSsidEqual( tHalHandle hHal, tSirBssDescription *pSirBssDesc1,
1835 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2 )
1836{
1837 tANI_BOOLEAN fEqual = FALSE;
1838 tSirMacSSid Ssid1, Ssid2;
1839 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1840 tDot11fBeaconIEs *pIes1 = NULL;
1841 tDot11fBeaconIEs *pIesLocal = pIes2;
1842
1843 do {
1844 if( ( NULL == pSirBssDesc1 ) || ( NULL == pSirBssDesc2 ) ) break;
1845 if( !pIesLocal && !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesLocal)) )
1846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001847 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 break;
1849 }
1850 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
1851 {
1852 break;
1853 }
1854 if( ( !pIes1->SSID.present ) || ( !pIesLocal->SSID.present ) ) break;
1855 if ( pIes1->SSID.num_ssid != pIesLocal->SSID.num_ssid ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301856 vos_mem_copy(Ssid1.ssId, pIes1->SSID.ssid, pIes1->SSID.num_ssid);
1857 vos_mem_copy(Ssid2.ssId, pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001858
Kiet Lam64c1b492013-07-12 13:56:44 +05301859 fEqual = vos_mem_compare(Ssid1.ssId, Ssid2.ssId, pIesLocal->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001860
1861 } while( 0 );
1862 if(pIes1)
1863 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301864 vos_mem_free(pIes1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 }
1866 if( pIesLocal && !pIes2 )
1867 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301868 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 }
1870
1871 return( fEqual );
1872}
1873
1874tANI_BOOLEAN csrIsAniWmeSupported(tDot11fIEAirgo *pIeAirgo)
1875{
1876 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
1877
1878 if(pIeAirgo && pIeAirgo->present && pIeAirgo->PropCapability.present)
1879 {
1880 fRet = (tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability ));
1881 }
1882
1883 return fRet;
1884}
1885
1886
1887
1888
1889//pIes can be passed in as NULL if the caller doesn't have one prepared
1890tANI_BOOLEAN csrIsBssDescriptionWme( tHalHandle hHal, tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
1891{
1892 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1893 // Assume that WME is found...
1894 tANI_BOOLEAN fWme = TRUE;
1895 tDot11fBeaconIEs *pIesTemp = pIes;
1896
1897 do
1898 {
1899 if(pIesTemp == NULL)
1900 {
1901 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp)) )
1902 {
1903 fWme = FALSE;
1904 break;
1905 }
1906 }
1907 // if the AirgoProprietary indicator is found, then WME is supported...
1908 if ( csrIsAniWmeSupported(&pIesTemp->Airgo) ) break;
1909 // if the Wme Info IE is found, then WME is supported...
1910 if ( CSR_IS_QOS_BSS(pIesTemp) ) break;
1911 // if none of these are found, then WME is NOT supported...
1912 fWme = FALSE;
1913 } while( 0 );
1914 if( !csrIsWmmSupported( pMac ) && fWme)
1915 {
1916 if( !pIesTemp->HTCaps.present )
1917 {
1918 fWme = FALSE;
1919 }
1920 }
1921 if( ( pIes == NULL ) && ( NULL != pIesTemp ) )
1922 {
1923 //we allocate memory here so free it before returning
Kiet Lam64c1b492013-07-12 13:56:44 +05301924 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 }
1926
1927 return( fWme );
1928}
1929
1930tANI_BOOLEAN csrIsHcfEnabled( tDot11fIEAirgo *pIeAirgo )
1931{
1932 tANI_BOOLEAN fHcfSupported = FALSE;
1933
1934 fHcfSupported = ((tANI_BOOLEAN)(PROP_CAPABILITY_GET( WME, pIeAirgo->PropCapability.capability )) ||
1935 (pIeAirgo->present && pIeAirgo->HCF.present && pIeAirgo->HCF.enabled));
1936
1937 return( fHcfSupported );
1938}
1939
1940
1941eCsrMediaAccessType csrGetQoSFromBssDesc( tHalHandle hHal, tSirBssDescription *pSirBssDesc,
1942 tDot11fBeaconIEs *pIes )
1943{
1944 eCsrMediaAccessType qosType = eCSR_MEDIUM_ACCESS_DCF;
1945
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001947
1948 do
1949 {
1950 // if we find WMM in the Bss Description, then we let this
1951 // override and use WMM.
1952 if ( csrIsBssDescriptionWme( hHal, pSirBssDesc, pIes ) )
1953 {
1954 qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
1955 }
1956 else
1957 {
1958 // if the QoS bit is on, then the AP is advertising 11E QoS...
1959 if ( csrIsQoSBssDesc( pSirBssDesc ) )
1960 {
1961 // which could be HCF or eDCF.
1962 if ( csrIsHcfEnabled( &pIes->Airgo ) )
1963 {
1964 qosType = eCSR_MEDIUM_ACCESS_11e_HCF;
1965 }
1966 else
1967 {
1968 qosType = eCSR_MEDIUM_ACCESS_11e_eDCF;
1969 }
1970 }
1971 else
1972 {
1973 qosType = eCSR_MEDIUM_ACCESS_DCF;
1974 }
1975 // scale back based on the types turned on for the adapter...
1976 if ( eCSR_MEDIUM_ACCESS_11e_eDCF == qosType && !csrIs11eSupported( hHal ) )
1977 {
1978 qosType = eCSR_MEDIUM_ACCESS_DCF;
1979 }
1980 }
1981
1982 } while(0);
1983
1984 return( qosType );
1985}
1986
1987
1988
1989
1990//Caller allocates memory for pIEStruct
1991eHalStatus csrParseBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIEStruct)
1992{
1993 eHalStatus status = eHAL_STATUS_FAILURE;
1994 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1995 int ieLen = (int)(pBssDesc->length + sizeof( pBssDesc->length ) - GET_FIELD_OFFSET( tSirBssDescription, ieFields ));
1996
1997 if(ieLen > 0 && pIEStruct)
1998 {
1999 if(!DOT11F_FAILED(dot11fUnpackBeaconIEs( pMac, (tANI_U8 *)pBssDesc->ieFields, ieLen, pIEStruct )))
2000 {
2001 status = eHAL_STATUS_SUCCESS;
2002 }
2003 }
2004
2005 return (status);
2006}
2007
2008
2009//This function will allocate memory for the parsed IEs to the caller. Caller must free the memory
2010//after it is done with the data only if this function succeeds
2011eHalStatus csrGetParsedBssDescriptionIEs(tHalHandle hHal, tSirBssDescription *pBssDesc, tDot11fBeaconIEs **ppIEStruct)
2012{
2013 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2014 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2015
2016 if(pBssDesc && ppIEStruct)
2017 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302018 *ppIEStruct = vos_mem_malloc(sizeof(tDot11fBeaconIEs));
2019 if ( (*ppIEStruct) != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302021 vos_mem_set((void *)*ppIEStruct, sizeof(tDot11fBeaconIEs), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 status = csrParseBssDescriptionIEs(hHal, pBssDesc, *ppIEStruct);
2023 if(!HAL_STATUS_SUCCESS(status))
2024 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302025 vos_mem_free(*ppIEStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 *ppIEStruct = NULL;
2027 }
2028 }
2029 else
2030 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002031 smsLog( pMac, LOGE, FL(" failed to allocate memory") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 VOS_ASSERT( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +05302033 return eHAL_STATUS_FAILURE;
2034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 }
2036
2037 return (status);
2038}
2039
2040
2041
2042
2043tANI_BOOLEAN csrIsNULLSSID( tANI_U8 *pBssSsid, tANI_U8 len )
2044{
2045 tANI_BOOLEAN fNullSsid = FALSE;
2046
2047 tANI_U32 SsidLength;
2048 tANI_U8 *pSsidStr;
2049
2050 do
2051 {
2052 if ( 0 == len )
2053 {
2054 fNullSsid = TRUE;
2055 break;
2056 }
2057
2058 //Consider 0 or space for hidden SSID
2059 if ( 0 == pBssSsid[0] )
2060 {
2061 fNullSsid = TRUE;
2062 break;
2063 }
2064
2065 SsidLength = len;
2066 pSsidStr = pBssSsid;
2067
2068 while ( SsidLength )
2069 {
2070 if( *pSsidStr )
2071 break;
2072
2073 pSsidStr++;
2074 SsidLength--;
2075 }
2076
2077 if( 0 == SsidLength )
2078 {
2079 fNullSsid = TRUE;
2080 break;
2081 }
2082 }
2083 while( 0 );
2084
2085 return fNullSsid;
2086}
2087
2088
2089tANI_U32 csrGetFragThresh( tHalHandle hHal )
2090{
2091 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2092
2093 return pMac->roam.configParam.FragmentationThreshold;
2094}
2095
2096tANI_U32 csrGetRTSThresh( tHalHandle hHal )
2097{
2098 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2099
2100 return pMac->roam.configParam.RTSThreshold;
2101}
2102
2103eCsrPhyMode csrTranslateToPhyModeFromBssDesc( tSirBssDescription *pSirBssDesc )
2104{
2105 eCsrPhyMode phyMode;
2106
2107 switch ( pSirBssDesc->nwType )
2108 {
2109 case eSIR_11A_NW_TYPE:
2110 phyMode = eCSR_DOT11_MODE_11a;
2111 break;
2112
2113 case eSIR_11B_NW_TYPE:
2114 phyMode = eCSR_DOT11_MODE_11b;
2115 break;
2116
2117 case eSIR_11G_NW_TYPE:
2118 phyMode = eCSR_DOT11_MODE_11g;
2119 break;
2120
2121 case eSIR_11N_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 phyMode = eCSR_DOT11_MODE_11n;
2123 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002124#ifdef WLAN_FEATURE_11AC
2125 case eSIR_11AC_NW_TYPE:
2126 default:
2127 phyMode = eCSR_DOT11_MODE_11ac;
2128#else
2129 default:
2130 phyMode = eCSR_DOT11_MODE_11n;
2131#endif
2132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 return( phyMode );
2135}
2136
2137
2138tANI_U32 csrTranslateToWNICfgDot11Mode(tpAniSirGlobal pMac, eCsrCfgDot11Mode csrDot11Mode)
2139{
2140 tANI_U32 ret;
2141
2142 switch(csrDot11Mode)
2143 {
2144 case eCSR_CFG_DOT11_MODE_AUTO:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002145 smsLog(pMac, LOGW, FL(" Warning: sees eCSR_CFG_DOT11_MODE_AUTO "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 //We cannot decide until now.
2147 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2148 {
2149 ret = WNI_CFG_DOT11_MODE_TAURUS;
2150 }
2151 else
2152 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002153 ret = WNI_CFG_DOT11_MODE_11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 }
2155 break;
2156 case eCSR_CFG_DOT11_MODE_TAURUS:
2157 ret = WNI_CFG_DOT11_MODE_TAURUS;
2158 break;
2159 case eCSR_CFG_DOT11_MODE_11A:
2160 ret = WNI_CFG_DOT11_MODE_11A;
2161 break;
2162 case eCSR_CFG_DOT11_MODE_11B:
2163 ret = WNI_CFG_DOT11_MODE_11B;
2164 break;
2165 case eCSR_CFG_DOT11_MODE_11G:
2166 ret = WNI_CFG_DOT11_MODE_11G;
2167 break;
2168 case eCSR_CFG_DOT11_MODE_11N:
2169 ret = WNI_CFG_DOT11_MODE_11N;
2170 break;
2171 case eCSR_CFG_DOT11_MODE_POLARIS:
2172 ret = WNI_CFG_DOT11_MODE_POLARIS;
2173 break;
2174 case eCSR_CFG_DOT11_MODE_TITAN:
2175 ret = WNI_CFG_DOT11_MODE_TITAN;
2176 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 case eCSR_CFG_DOT11_MODE_11G_ONLY:
2178 ret = WNI_CFG_DOT11_MODE_11G_ONLY;
2179 break;
2180 case eCSR_CFG_DOT11_MODE_11N_ONLY:
2181 ret = WNI_CFG_DOT11_MODE_11N_ONLY;
2182 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002183
2184#ifdef WLAN_FEATURE_11AC
2185 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
2186 ret = WNI_CFG_DOT11_MODE_11AC_ONLY;
2187 break;
2188 case eCSR_CFG_DOT11_MODE_11AC:
2189 ret = WNI_CFG_DOT11_MODE_11AC;
2190 break;
2191#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002193 smsLog(pMac, LOGW, FL("doesn't expect %d as csrDo11Mode"), csrDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 if(eCSR_BAND_24 == pMac->roam.configParam.eBand)
2195 {
2196 ret = WNI_CFG_DOT11_MODE_11G;
2197 }
2198 else
2199 {
2200 ret = WNI_CFG_DOT11_MODE_11A;
2201 }
2202 break;
2203 }
2204
2205 return (ret);
2206}
2207
2208
2209//This function should only return the super set of supported modes. 11n implies 11b/g/a/n.
2210eHalStatus csrGetPhyModeFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription,
2211 eCsrPhyMode *pPhyMode, tDot11fBeaconIEs *pIes)
2212{
2213 eHalStatus status = eHAL_STATUS_SUCCESS;
2214 eCsrPhyMode phyMode = csrTranslateToPhyModeFromBssDesc(pBSSDescription);
2215
2216 if( pIes )
2217 {
2218 if(pIes->Airgo.present)
2219 {
2220 if(pIes->Airgo.PropCapability.present)
2221 {
2222 if( PROP_CAPABILITY_GET( TAURUS, pIes->Airgo.PropCapability.capability ))
2223 {
2224 phyMode = eCSR_DOT11_MODE_TAURUS;
2225 }
2226 }
2227 }
2228 if(pIes->HTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2229 {
2230 phyMode = eCSR_DOT11_MODE_11n;
2231 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002232
2233#ifdef WLAN_FEATURE_11AC
2234 if ( pIes->VHTCaps.present && (eCSR_DOT11_MODE_TAURUS != phyMode))
2235 {
2236 phyMode = eCSR_DOT11_MODE_11ac;
2237 }
2238#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 *pPhyMode = phyMode;
2240 }
2241
2242 return (status);
2243
2244}
2245
2246
2247//This function returns the correct eCSR_CFG_DOT11_MODE is the two phyModes matches
2248//bssPhyMode is the mode derived from the BSS description
2249//f5GhzBand is derived from the channel id of BSS description
2250tANI_BOOLEAN csrGetPhyModeInUse( eCsrPhyMode phyModeIn, eCsrPhyMode bssPhyMode, tANI_BOOLEAN f5GhzBand,
2251 eCsrCfgDot11Mode *pCfgDot11ModeToUse )
2252{
2253 tANI_BOOLEAN fMatch = FALSE;
2254 eCsrCfgDot11Mode cfgDot11Mode;
2255
2256 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; // to suppress compiler warning
2257
2258 switch( phyModeIn )
2259 {
2260 case eCSR_DOT11_MODE_abg: //11a or 11b or 11g
2261 if( f5GhzBand )
2262 {
2263 fMatch = TRUE;
2264 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2265 }
2266 else if( eCSR_DOT11_MODE_11b == bssPhyMode )
2267 {
2268 fMatch = TRUE;
2269 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2270 }
2271 else
2272 {
2273 fMatch = TRUE;
2274 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2275 }
2276 break;
2277
2278 case eCSR_DOT11_MODE_11a: //11a
2279 if( f5GhzBand )
2280 {
2281 fMatch = TRUE;
2282 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2283 }
2284 break;
2285
2286 case eCSR_DOT11_MODE_11a_ONLY: //11a
2287 if( eCSR_DOT11_MODE_11a == bssPhyMode )
2288 {
2289 fMatch = TRUE;
2290 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2291 }
2292 break;
2293
2294 case eCSR_DOT11_MODE_11g:
2295 if(!f5GhzBand)
2296 {
2297 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2298 {
2299 fMatch = TRUE;
2300 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2301 }
2302 else
2303 {
2304 fMatch = TRUE;
2305 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2306 }
2307 }
2308 break;
2309
2310 case eCSR_DOT11_MODE_11g_ONLY:
2311 if( eCSR_DOT11_MODE_11g == bssPhyMode )
2312 {
2313 fMatch = TRUE;
2314 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2315 }
2316 break;
2317
2318 case eCSR_DOT11_MODE_11b:
2319 if( !f5GhzBand )
2320 {
2321 fMatch = TRUE;
2322 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2323 }
2324 break;
2325
2326 case eCSR_DOT11_MODE_11b_ONLY:
2327 if( eCSR_DOT11_MODE_11b == bssPhyMode )
2328 {
2329 fMatch = TRUE;
2330 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2331 }
2332 break;
2333
2334 case eCSR_DOT11_MODE_11n:
2335 fMatch = TRUE;
2336 switch(bssPhyMode)
2337 {
2338 case eCSR_DOT11_MODE_11g:
2339 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2340 break;
2341 case eCSR_DOT11_MODE_11b:
2342 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2343 break;
2344 case eCSR_DOT11_MODE_11a:
2345 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2346 break;
2347 case eCSR_DOT11_MODE_11n:
Jeff Johnsone7245742012-09-05 17:12:55 -07002348#ifdef WLAN_FEATURE_11AC
2349 case eCSR_DOT11_MODE_11ac:
2350#endif
2351 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2352 break;
2353
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 case eCSR_DOT11_MODE_TAURUS:
2355 default:
Jeff Johnsone7245742012-09-05 17:12:55 -07002356#ifdef WLAN_FEATURE_11AC
2357 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2358#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002360#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 break;
2362 }
2363 break;
2364
2365 case eCSR_DOT11_MODE_11n_ONLY:
2366 if((eCSR_DOT11_MODE_11n == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2367 {
2368 fMatch = TRUE;
2369 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Jeff Johnsone7245742012-09-05 17:12:55 -07002370
2371 }
2372
2373 break;
2374#ifdef WLAN_FEATURE_11AC
2375 case eCSR_DOT11_MODE_11ac:
2376 fMatch = TRUE;
2377 switch(bssPhyMode)
2378 {
2379 case eCSR_DOT11_MODE_11g:
2380 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2381 break;
2382 case eCSR_DOT11_MODE_11b:
2383 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2384 break;
2385 case eCSR_DOT11_MODE_11a:
2386 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2387 break;
2388 case eCSR_DOT11_MODE_11n:
2389 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2390 break;
2391 case eCSR_DOT11_MODE_11ac:
2392 case eCSR_DOT11_MODE_TAURUS:
2393 default:
2394 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2395 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 }
2397 break;
2398
Jeff Johnsone7245742012-09-05 17:12:55 -07002399 case eCSR_DOT11_MODE_11ac_ONLY:
2400 if((eCSR_DOT11_MODE_11ac == bssPhyMode) || (eCSR_DOT11_MODE_TAURUS == bssPhyMode))
2401 {
2402 fMatch = TRUE;
2403 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2404 }
2405 break;
2406#endif
2407
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 case eCSR_DOT11_MODE_TAURUS:
2409 default:
2410 fMatch = TRUE;
2411 switch(bssPhyMode)
2412 {
2413 case eCSR_DOT11_MODE_11g:
2414 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2415 break;
2416 case eCSR_DOT11_MODE_11b:
2417 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
2418 break;
2419 case eCSR_DOT11_MODE_11a:
2420 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2421 break;
2422 case eCSR_DOT11_MODE_11n:
2423 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
2424 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002425#ifdef WLAN_FEATURE_11AC
2426 case eCSR_DOT11_MODE_11ac:
2427 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
2428 break;
2429#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 case eCSR_DOT11_MODE_TAURUS:
2431 default:
2432 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
2433 break;
2434 }
2435 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 }
2437
2438 if ( fMatch && pCfgDot11ModeToUse )
2439 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002440#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudief5dd972012-10-11 15:06:09 -07002441 if(cfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC && (!IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)))
Jeff Johnsone7245742012-09-05 17:12:55 -07002442 {
2443 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2444 }
2445 else
2446#endif
2447 {
2448 *pCfgDot11ModeToUse = cfgDot11Mode;
2449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 return( fMatch );
2452}
2453
2454
2455//This function decides whether the one of the bit of phyMode is matching the mode in the BSS and allowed by the user
2456//setting, pMac->roam.configParam.uCfgDot11Mode. It returns the mode that fits the criteria.
2457tANI_BOOLEAN csrIsPhyModeMatch( tpAniSirGlobal pMac, tANI_U32 phyMode,
2458 tSirBssDescription *pSirBssDesc, tCsrRoamProfile *pProfile,
2459 eCsrCfgDot11Mode *pReturnCfgDot11Mode,
2460 tDot11fBeaconIEs *pIes)
2461{
2462 tANI_BOOLEAN fMatch = FALSE;
2463 eCsrPhyMode phyModeInBssDesc, phyMode2;
2464 eCsrCfgDot11Mode cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_TAURUS;
2465 tANI_U32 bitMask, loopCount;
2466
2467 if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pSirBssDesc, &phyModeInBssDesc, pIes )))
2468 {
2469 //In case some change change eCSR_DOT11_MODE_TAURUS to non-0
2470 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2471 {
2472 //Taurus means anything
2473 if ( eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode )
2474 {
2475 phyMode = eCSR_DOT11_MODE_abg;
2476 }
2477 else if(eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode)
2478 {
2479 if(pMac->roam.configParam.ProprietaryRatesEnabled)
2480 {
2481 phyMode = eCSR_DOT11_MODE_TAURUS;
2482 }
2483 else
2484 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002485
2486#ifdef WLAN_FEATURE_11AC
2487 phyMode = eCSR_DOT11_MODE_11ac;
2488#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 phyMode = eCSR_DOT11_MODE_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07002490#endif
2491
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 }
2493 }
2494 else
2495 {
2496 //user's pick
2497 phyMode = pMac->roam.configParam.phyMode;
2498 }
2499 }
2500 if ( (0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode) )
2501 {
2502 if(0 != phyMode)
2503 {
2504 if(eCSR_DOT11_MODE_AUTO & phyMode)
2505 {
2506 phyMode2 = eCSR_DOT11_MODE_AUTO & phyMode;
2507 }
2508 else
2509 {
2510 phyMode2 = eCSR_DOT11_MODE_TAURUS & phyMode;
2511 }
2512 }
2513 else
2514 {
2515 phyMode2 = phyMode;
2516 }
2517 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2518 &cfgDot11ModeToUse );
2519 }
2520 else
2521 {
2522 bitMask = 1;
2523 loopCount = 0;
2524 while(loopCount < eCSR_NUM_PHY_MODE)
2525 {
2526 if(0 != ( phyMode2 = (phyMode & (bitMask << loopCount++)) ))
2527 {
2528 fMatch = csrGetPhyModeInUse( phyMode2, phyModeInBssDesc, CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId),
2529 &cfgDot11ModeToUse );
2530 if(fMatch) break;
2531 }
2532 }
2533 }
2534 if ( fMatch && pReturnCfgDot11Mode )
2535 {
2536 if( pProfile )
2537 {
2538 /* IEEE 11n spec (8.4.3): HT STA shall eliminate TKIP as a
2539 * choice for the pairwise cipher suite if CCMP is advertised
2540 * by the AP or if the AP included an HT capabilities element
2541 * in its Beacons and Probe Response.
2542 */
2543 if( (!CSR_IS_11n_ALLOWED( pProfile->negotiatedUCEncryptionType )) &&
2544 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11ModeToUse) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002545#ifdef WLAN_FEATURE_11AC
2546 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11ModeToUse) ||
2547#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11ModeToUse)) )
2549 {
2550 //We cannot do 11n here
2551 if( !CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId) )
2552 {
2553 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2554 }
2555 else
2556 {
2557 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2558 }
2559 }
2560 }
2561 *pReturnCfgDot11Mode = cfgDot11ModeToUse;
2562 }
2563 }
2564
2565 return( fMatch );
2566}
2567
2568
2569eCsrCfgDot11Mode csrFindBestPhyMode( tpAniSirGlobal pMac, tANI_U32 phyMode )
2570{
2571 eCsrCfgDot11Mode cfgDot11ModeToUse;
2572 eCsrBand eBand = pMac->roam.configParam.eBand;
2573
Jeff Johnsone7245742012-09-05 17:12:55 -07002574
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302575 if ((0 == phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002576#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302577 (eCSR_DOT11_MODE_11ac & phyMode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07002578#endif
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302579 (eCSR_DOT11_MODE_AUTO & phyMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 {
Madan Mohan Koyyalamudi0dae8812013-07-15 19:22:49 +05302581#ifdef WLAN_FEATURE_11AC
2582 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
2583 {
2584 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC;
2585 }
2586 else
2587#endif
2588 {
2589 /* Default to 11N mode if user has configured 11ac mode
2590 * and FW doesn't supports 11ac mode .
2591 */
2592 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 }
2595 else
2596 {
2597 if( ( eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY ) & phyMode )
2598 {
2599 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N;
2600 }
2601 else if ( eCSR_DOT11_MODE_abg & phyMode )
2602 {
2603 if( eCSR_BAND_24 != eBand )
2604 {
2605 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2606 }
2607 else
2608 {
2609 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2610 }
2611 }
2612 else if( ( eCSR_DOT11_MODE_11a | eCSR_DOT11_MODE_11a_ONLY ) & phyMode )
2613 {
2614 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A;
2615 }
2616 else if( ( eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY ) & phyMode )
2617 {
2618 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G;
2619 }
2620 else
2621 {
2622 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B;
2623 }
2624 }
2625
2626 return ( cfgDot11ModeToUse );
2627}
2628
2629
2630
2631
2632tANI_U32 csrGet11hPowerConstraint( tHalHandle hHal, tDot11fIEPowerConstraints *pPowerConstraint )
2633{
2634 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2635 tANI_U32 localPowerConstraint = 0;
2636
2637 // check if .11h support is enabled, if not, the power constraint is 0.
2638 if(pMac->roam.configParam.Is11hSupportEnabled && pPowerConstraint->present)
2639 {
2640 localPowerConstraint = pPowerConstraint->localPowerConstraints;
2641 }
2642
2643 return( localPowerConstraint );
2644}
2645
2646
2647tANI_BOOLEAN csrIsProfileWpa( tCsrRoamProfile *pProfile )
2648{
2649 tANI_BOOLEAN fWpaProfile = FALSE;
2650
2651 switch ( pProfile->negotiatedAuthType )
2652 {
2653 case eCSR_AUTH_TYPE_WPA:
2654 case eCSR_AUTH_TYPE_WPA_PSK:
2655 case eCSR_AUTH_TYPE_WPA_NONE:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002656#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 case eCSR_AUTH_TYPE_CCKM_WPA:
2658#endif
2659 fWpaProfile = TRUE;
2660 break;
2661
2662 default:
2663 fWpaProfile = FALSE;
2664 break;
2665 }
2666
2667 if ( fWpaProfile )
2668 {
2669 switch ( pProfile->negotiatedUCEncryptionType )
2670 {
2671 case eCSR_ENCRYPT_TYPE_WEP40:
2672 case eCSR_ENCRYPT_TYPE_WEP104:
2673 case eCSR_ENCRYPT_TYPE_TKIP:
2674 case eCSR_ENCRYPT_TYPE_AES:
2675 fWpaProfile = TRUE;
2676 break;
2677
2678 default:
2679 fWpaProfile = FALSE;
2680 break;
2681 }
2682 }
2683 return( fWpaProfile );
2684}
2685
2686tANI_BOOLEAN csrIsProfileRSN( tCsrRoamProfile *pProfile )
2687{
2688 tANI_BOOLEAN fRSNProfile = FALSE;
2689
2690 switch ( pProfile->negotiatedAuthType )
2691 {
2692 case eCSR_AUTH_TYPE_RSN:
2693 case eCSR_AUTH_TYPE_RSN_PSK:
2694#ifdef WLAN_FEATURE_VOWIFI_11R
2695 case eCSR_AUTH_TYPE_FT_RSN:
2696 case eCSR_AUTH_TYPE_FT_RSN_PSK:
2697#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002698#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 case eCSR_AUTH_TYPE_CCKM_RSN:
2700#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002701#ifdef WLAN_FEATURE_11W
2702 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
2703#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 fRSNProfile = TRUE;
2705 break;
2706
2707 default:
2708 fRSNProfile = FALSE;
2709 break;
2710 }
2711
2712 if ( fRSNProfile )
2713 {
2714 switch ( pProfile->negotiatedUCEncryptionType )
2715 {
2716 // !!REVIEW - For WPA2, use of RSN IE mandates
2717 // use of AES as encryption. Here, we qualify
2718 // even if encryption type is WEP or TKIP
2719 case eCSR_ENCRYPT_TYPE_WEP40:
2720 case eCSR_ENCRYPT_TYPE_WEP104:
2721 case eCSR_ENCRYPT_TYPE_TKIP:
2722 case eCSR_ENCRYPT_TYPE_AES:
2723 fRSNProfile = TRUE;
2724 break;
2725
2726 default:
2727 fRSNProfile = FALSE;
2728 break;
2729 }
2730 }
2731 return( fRSNProfile );
2732}
2733
Jeff Johnsone7245742012-09-05 17:12:55 -07002734eHalStatus
2735csrIsconcurrentsessionValid(tpAniSirGlobal pMac,tANI_U32 cursessionId,
2736 tVOS_CON_MODE currBssPersona)
2737{
2738 tANI_U32 sessionId = 0;
2739
2740 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2741 {
2742 if (cursessionId != sessionId )
2743 {
2744 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2745 {
2746 continue;
2747 }
2748
2749 switch (currBssPersona)
2750 {
2751 case VOS_STA_MODE:
Jeff Johnsone7245742012-09-05 17:12:55 -07002752 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05302753 smsLog(pMac, LOG4, FL(" Second session for persona %d"), currBssPersona);
Agarwal Ashishe16e1212014-05-15 14:51:36 +05302754 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07002755 }
2756 break;
2757
2758 case VOS_STA_SAP_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302759 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2760 == VOS_STA_SAP_MODE)&&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002761 (pMac->roam.roamSession[sessionId].connectState
2762 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002764 smsLog(pMac, LOGE, FL(" ****SoftAP mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002765 return eHAL_STATUS_FAILURE;
2766 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002767 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2768 == VOS_P2P_GO_MODE &&
2769 pMac->roam.roamSession[sessionId].connectState
2770 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2771 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2772 == VOS_IBSS_MODE &&
2773 pMac->roam.roamSession[sessionId].connectState
2774 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002776 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002777 return eHAL_STATUS_FAILURE;
2778 }
2779 break;
2780
2781 case VOS_P2P_CLIENT_MODE:
2782 if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002783 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002784 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002786 smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002787 return eHAL_STATUS_FAILURE;
2788 }
2789 break;
2790
2791 case VOS_P2P_GO_MODE:
Gopichand Nakkala53fefcd2013-02-28 12:35:20 +05302792 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2793 == VOS_P2P_GO_MODE) &&
Ravi Joshia96ceb42013-05-20 18:52:39 -07002794 (pMac->roam.roamSession[sessionId].connectState
2795 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))
Jeff Johnsone7245742012-09-05 17:12:55 -07002796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002797 smsLog(pMac, LOGE, FL(" ****P2P GO mode already exists ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002798 return eHAL_STATUS_FAILURE;
2799 }
Ravi Joshia96ceb42013-05-20 18:52:39 -07002800 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2801 == VOS_STA_SAP_MODE &&
2802 pMac->roam.roamSession[sessionId].connectState
2803 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED) ||
2804 (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2805 == VOS_IBSS_MODE &&
2806 pMac->roam.roamSession[sessionId].connectState
2807 != eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002809 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002810 return eHAL_STATUS_FAILURE;
2811 }
2812 break;
Ravi Joshia96ceb42013-05-20 18:52:39 -07002813 case VOS_IBSS_MODE:
2814 if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
2815 == VOS_IBSS_MODE) &&
2816 (pMac->roam.roamSession[sessionId].connectState
2817 != eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED))
2818 {
2819 smsLog(pMac, LOGE, FL(" ****IBSS mode already exists ****"));
2820 return eHAL_STATUS_FAILURE;
2821 }
2822 else if( (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2823 == VOS_P2P_GO_MODE ||
2824 pMac->roam.roamSession[sessionId].bssParams.bssPersona
2825 == VOS_STA_SAP_MODE) &&
2826 pMac->roam.roamSession[sessionId].connectState
2827 != eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)
2828 {
2829 smsLog(pMac, LOGE, FL(" ****Cannot start Multiple Beaconing Role ****"));
2830 return eHAL_STATUS_FAILURE;
2831 }
2832 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07002833 default :
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002834 smsLog(pMac, LOGE, FL("***Persona not handled = %d*****"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07002835 break;
2836 }
2837 }
2838 }
2839 return eHAL_STATUS_SUCCESS;
2840
2841}
2842
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002843eHalStatus csrUpdateMCCp2pBeaconInterval(tpAniSirGlobal pMac)
Jeff Johnsone7245742012-09-05 17:12:55 -07002844{
2845 tANI_U32 sessionId = 0;
2846
2847 //If MCC is not supported just break and return SUCCESS
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002848 if ( !pMac->roam.configParam.fenableMCCMode){
2849 return eHAL_STATUS_FAILURE;
2850 }
2851
2852 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2853 {
2854 /* If GO in MCC support different beacon interval,
2855 * change the BI of the P2P-GO */
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002856 if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2857 == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002858 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002859 /* Handle different BI scneario based on the configuration set.
2860 * If Config is set to 0x02 then Disconnect all the P2P clients
2861 * associated. If config is set to 0x04 then update the BI
2862 * without disconnecting all the clients
2863 */
2864 if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
2865 (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
2866 {
2867 return csrSendChngMCCBeaconInterval( pMac, sessionId);
2868 }
2869 //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
2870 else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
2871 {
2872 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
2873 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002874 }
2875 }
2876 return eHAL_STATUS_FAILURE;
2877}
2878
2879tANI_U16 csrCalculateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U16 sta_bi, tANI_U16 go_gbi)
2880{
2881 tANI_U8 num_beacons = 0;
2882 tANI_U8 is_multiple = 0;
2883 tANI_U16 go_cbi = 0;
2884 tANI_U16 go_fbi = 0;
2885 tANI_U16 sta_cbi = 0;
2886
2887 //If GO's given beacon Interval is less than 100
2888 if(go_gbi < 100)
2889 go_cbi = 100;
2890 //if GO's given beacon Interval is greater than or equal to 100
2891 else
2892 go_cbi = 100 + (go_gbi % 100);
2893
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05302894 if ( sta_bi == 0 )
2895 {
2896 /* There is possibility to receive zero as value.
2897 Which will cause divide by zero. Hence initialise with 100
2898 */
2899 sta_bi = 100;
2900 smsLog(pMac, LOGW,
2901 FL("sta_bi 2nd parameter is zero, initialise to %d"), sta_bi);
2902 }
2903
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002904 // check, if either one is multiple of another
2905 if (sta_bi > go_cbi)
2906 {
2907 is_multiple = !(sta_bi % go_cbi);
2908 }
2909 else
2910 {
2911 is_multiple = !(go_cbi % sta_bi);
2912 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002913 // if it is multiple, then accept GO's beacon interval range [100,199] as it is
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002914 if (is_multiple)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002915 {
2916 return go_cbi;
2917 }
2918 //else , if it is not multiple, then then check for number of beacons to be
2919 //inserted based on sta BI
2920 num_beacons = sta_bi / 100;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002921 if (num_beacons)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002922 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002923 // GO's final beacon interval will be aligned to sta beacon interval, but
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002924 //in the range of [100, 199].
2925 sta_cbi = sta_bi / num_beacons;
2926 go_fbi = sta_cbi;
2927 }
2928 else
2929 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08002930 // if STA beacon interval is less than 100, use GO's change bacon interval
2931 //instead of updating to STA's beacon interval.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002932 go_fbi = go_cbi;
2933 }
2934 return go_fbi;
2935}
2936
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002937eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002938 tANI_U16 *beaconInterval, tANI_U32 cursessionId,
2939 tVOS_CON_MODE currBssPersona)
2940{
2941 tANI_U32 sessionId = 0;
2942 tANI_U16 new_beaconInterval = 0;
2943
2944 //If MCC is not supported just break
2945 if (!pMac->roam.configParam.fenableMCCMode){
Jeff Johnsone7245742012-09-05 17:12:55 -07002946 return eHAL_STATUS_FAILURE;
2947 }
2948
2949 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2950 {
2951 if (cursessionId != sessionId )
2952 {
2953 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
2954 {
2955 continue;
2956 }
2957
2958 switch (currBssPersona)
2959 {
2960 case VOS_STA_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002961 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
2962 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002963 == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
2964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002965 smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
Jeff Johnsone7245742012-09-05 17:12:55 -07002966 }
2967 //IF SAP has started and STA wants to connect on different channel MCC should
2968 //MCC should not be enabled so making it false to enforce on same channel
2969 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
2970 == VOS_STA_SAP_MODE)
2971 {
2972 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
2973 != channelId )
2974 {
Agarwal Ashish4cfa1e52014-05-09 20:25:11 +05302975 smsLog(pMac, LOGE, FL("*** MCC with SAP+STA sessions ****"));
2976 return eHAL_STATUS_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07002977 }
2978 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002979 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07002980 == VOS_P2P_GO_MODE) //Check for P2P go scenario
2981 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002982 /* if GO in MCC support different beacon interval,
2983 * change the BI of the P2P-GO */
2984 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
Jeff Johnsone7245742012-09-05 17:12:55 -07002985 != channelId ) &&
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002986 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07002987 != *beaconInterval))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002988 {
2989 /* if GO in MCC support different beacon interval, return success */
2990 if ( pMac->roam.configParam.fAllowMCCGODiffBI == 0x01)
2991 {
2992 return eHAL_STATUS_SUCCESS;
2993 }
2994 // Send only Broadcast disassoc and update beaconInterval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07002995 //If configuration is set to 0x04 then dont
2996 // disconnect all the station
2997 else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
2998 (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08002999 {
3000 //Check to pass the right beacon Interval
3001 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval,
3002 pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003003 smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003004 //Update the becon Interval
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003005 if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003006 {
3007 //Update the beaconInterval now
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003008 smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
3009 pMac->roam.configParam.fAllowMCCGODiffBI);
3010
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003011 pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
3012 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003013 return csrUpdateMCCp2pBeaconInterval(pMac);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003014 }
3015 return eHAL_STATUS_SUCCESS;
3016 }
3017 //Disconnect the P2P session
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003018 else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003019 {
3020 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
3021 return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
3022 }
3023 else
3024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003025 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to preferred AP..."));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003026 return eHAL_STATUS_FAILURE;
3027 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003028 }
3029 }
3030 break;
3031
3032 case VOS_P2P_CLIENT_MODE:
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003033 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3034 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003035 == VOS_STA_MODE)) //check for P2P client mode
3036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003037 smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003038 }
3039 //IF SAP has started and STA wants to connect on different channel MCC should
3040 //MCC should not be enabled so making it false to enforce on same channel
3041 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
3042 == VOS_STA_SAP_MODE)
3043 {
3044 if (pMac->roam.roamSession[sessionId].bssParams.operationChn
3045 != channelId )
3046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003047 smsLog(pMac, LOGE, FL("***MCC is not enabled for SAP + CLIENT****"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003048 return eHAL_STATUS_FAILURE;
3049 }
3050 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003051 else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003052 == VOS_P2P_GO_MODE) //Check for P2P go scenario
3053 {
3054 if ((pMac->roam.roamSession[sessionId].bssParams.operationChn
3055 != channelId ) &&
3056 (pMac->roam.roamSession[sessionId].bssParams.beaconInterval
3057 != *beaconInterval))
3058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003059 smsLog(pMac, LOGE, FL("BeaconInterval is different cannot connect to P2P_GO network ..."));
Jeff Johnsone7245742012-09-05 17:12:55 -07003060 return eHAL_STATUS_FAILURE;
3061 }
3062 }
3063 break;
3064
3065 case VOS_P2P_GO_MODE :
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003066 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003067 if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
3068 ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003069 == VOS_P2P_CLIENT_MODE) ||
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003070 (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
Jeff Johnsone7245742012-09-05 17:12:55 -07003071 == VOS_STA_MODE))) //check for P2P_client scenario
3072 {
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003073 if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003074 == 0 )&&
3075 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
3076 == 0))
3077 {
3078 continue;
3079 }
3080
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05303081 //Assert if connected profile beacon internal is ZERO
3082 if(!pMac->roam.roamSession[sessionId].\
3083 connectedProfile.beaconInterval)
3084 {
3085 smsLog( pMac, LOGE, FL(" Connected profile "
3086 "beacon interval is zero") );
3087 }
3088
Jeff Johnsone7245742012-09-05 17:12:55 -07003089
3090 if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003091 (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
Jeff Johnsone7245742012-09-05 17:12:55 -07003092 != channelId ) &&
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -07003093 (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
Jeff Johnsone7245742012-09-05 17:12:55 -07003094 != *beaconInterval))
3095 {
3096 /*
3097 * Updated beaconInterval should be used only when we are starting a new BSS
3098 * not incase of client or STA case
3099 */
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003100 //Calculate beacon Interval for P2P-GO incase of MCC
3101 new_beaconInterval = csrCalculateMCCBeaconInterval(pMac,
Chet Lanctot4c986162013-05-08 13:59:56 -07003102 pMac->roam.roamSession[sessionId].bssParams.beaconInterval,
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003103 *beaconInterval );
3104 if(*beaconInterval != new_beaconInterval)
3105 *beaconInterval = new_beaconInterval;
Jeff Johnsone7245742012-09-05 17:12:55 -07003106 return eHAL_STATUS_SUCCESS;
3107 }
3108 }
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08003109 }
3110 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07003111
3112 default :
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303113 smsLog(pMac, LOGE, FL(" Persona not supported : %d"),currBssPersona);
Jeff Johnsone7245742012-09-05 17:12:55 -07003114 return eHAL_STATUS_FAILURE;
3115 }
3116 }
3117 }
3118
3119 return eHAL_STATUS_SUCCESS;
3120}
Jeff Johnson295189b2012-06-20 16:38:30 -07003121
3122#ifdef WLAN_FEATURE_VOWIFI_11R
3123/* Function to return TRUE if the authtype is 11r */
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003124tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -07003125{
3126 switch ( AuthType )
3127 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003128 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3129 if(mdiePresent)
3130 return TRUE;
3131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3133 case eCSR_AUTH_TYPE_FT_RSN:
3134 return TRUE;
3135 break;
3136 default:
3137 break;
3138 }
3139 return FALSE;
3140}
3141
3142/* Function to return TRUE if the profile is 11r */
3143tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
3144{
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003145 return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
Jeff Johnson295189b2012-06-20 16:38:30 -07003146}
3147
3148#endif
3149
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003150#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003151
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003152/* Function to return TRUE if the authtype is ESE */
3153tANI_BOOLEAN csrIsAuthTypeESE( eCsrAuthType AuthType )
Jeff Johnson295189b2012-06-20 16:38:30 -07003154{
3155 switch ( AuthType )
3156 {
3157 case eCSR_AUTH_TYPE_CCKM_WPA:
3158 case eCSR_AUTH_TYPE_CCKM_RSN:
3159 return TRUE;
3160 break;
3161 default:
3162 break;
3163 }
3164 return FALSE;
3165}
3166
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003167/* Function to return TRUE if the profile is ESE */
3168tANI_BOOLEAN csrIsProfileESE( tCsrRoamProfile *pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003169{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003170 return (csrIsAuthTypeESE( pProfile->negotiatedAuthType ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003171}
3172
3173#endif
3174
3175#ifdef FEATURE_WLAN_WAPI
3176tANI_BOOLEAN csrIsProfileWapi( tCsrRoamProfile *pProfile )
3177{
3178 tANI_BOOLEAN fWapiProfile = FALSE;
3179
3180 switch ( pProfile->negotiatedAuthType )
3181 {
3182 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
3183 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
3184 fWapiProfile = TRUE;
3185 break;
3186
3187 default:
3188 fWapiProfile = FALSE;
3189 break;
3190 }
3191
3192 if ( fWapiProfile )
3193 {
3194 switch ( pProfile->negotiatedUCEncryptionType )
3195 {
3196 case eCSR_ENCRYPT_TYPE_WPI:
3197 fWapiProfile = TRUE;
3198 break;
3199
3200 default:
3201 fWapiProfile = FALSE;
3202 break;
3203 }
3204 }
3205 return( fWapiProfile );
3206}
3207
3208static tANI_BOOLEAN csrIsWapiOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3209{
Kiet Lam64c1b492013-07-12 13:56:44 +05303210 return (vos_mem_compare(Oui1, Oui2, CSR_WAPI_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003211}
3212
3213static tANI_BOOLEAN csrIsWapiOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3214 tANI_U8 cAllCyphers,
3215 tANI_U8 Cypher[],
3216 tANI_U8 Oui[] )
3217{
3218 tANI_BOOLEAN fYes = FALSE;
3219 tANI_U8 idx;
3220
3221 for ( idx = 0; idx < cAllCyphers; idx++ )
3222 {
3223 if ( csrIsWapiOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3224 {
3225 fYes = TRUE;
3226 break;
3227 }
3228 }
3229
3230 if ( fYes && Oui )
3231 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303232 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 }
3234
3235 return( fYes );
3236}
3237#endif /* FEATURE_WLAN_WAPI */
3238
3239static tANI_BOOLEAN csrIsWpaOuiEqual( tpAniSirGlobal pMac, tANI_U8 *Oui1, tANI_U8 *Oui2 )
3240{
Kiet Lam64c1b492013-07-12 13:56:44 +05303241 return(vos_mem_compare(Oui1, Oui2, CSR_WPA_OUI_SIZE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003242}
3243
3244static tANI_BOOLEAN csrIsOuiMatch( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3245 tANI_U8 cAllCyphers,
3246 tANI_U8 Cypher[],
3247 tANI_U8 Oui[] )
3248{
3249 tANI_BOOLEAN fYes = FALSE;
3250 tANI_U8 idx;
3251
3252 for ( idx = 0; idx < cAllCyphers; idx++ )
3253 {
3254 if ( csrIsWpaOuiEqual( pMac, AllCyphers[ idx ], Cypher ) )
3255 {
3256 fYes = TRUE;
3257 break;
3258 }
3259 }
3260
3261 if ( fYes && Oui )
3262 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303263 vos_mem_copy(Oui, AllCyphers[ idx ], CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 }
3265
3266 return( fYes );
3267}
3268
3269static tANI_BOOLEAN csrMatchRSNOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3270 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3271 tANI_U8 Oui[] )
3272{
3273 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui[ouiIndex], Oui ) );
3274
3275}
3276
3277#ifdef FEATURE_WLAN_WAPI
3278static tANI_BOOLEAN csrMatchWapiOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WAPI_OUI_SIZE],
3279 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3280 tANI_U8 Oui[] )
3281{
Kaushik, Sushantfe230152014-04-08 14:37:47 +05303282 if (ouiIndex < CSR_WAPI_OUI_ROW_SIZE)// since csrWapiOui row size is 3 .
3283 return( csrIsWapiOuiMatch( pMac, AllCyphers, cAllCyphers,
3284 csrWapiOui[ouiIndex], Oui ) );
3285 else
3286 return FALSE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07003287
3288}
3289#endif /* FEATURE_WLAN_WAPI */
3290
3291static tANI_BOOLEAN csrMatchWPAOUIIndex( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3292 tANI_U8 cAllCyphers, tANI_U8 ouiIndex,
3293 tANI_U8 Oui[] )
3294{
3295 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui[ouiIndex], Oui ) );
3296
3297}
3298
3299#if 0
3300static tANI_BOOLEAN csrIsRSNUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3301 tANI_U8 cAllCyphers,
3302 tANI_U8 Oui[] )
3303{
3304 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui00, Oui ) );
3305}
3306
3307static tANI_BOOLEAN csrIsRSNMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3308 tANI_U8 cAllCyphers,
3309 tANI_U8 Oui[] )
3310{
3311 tANI_BOOLEAN fYes = FALSE;
3312
3313 // Check Wep 104 first, if fails, then check Wep40.
3314 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui05, Oui );
3315
3316 if ( !fYes )
3317 {
3318 // if not Wep-104, check Wep-40
3319 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui01, Oui );
3320 }
3321
3322 return( fYes );
3323}
3324
3325
3326static tANI_BOOLEAN csrIsRSNUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3327 tANI_U8 cAllCyphers,
3328 tANI_U8 Oui[] )
3329{
3330 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3331}
3332
3333
3334static tANI_BOOLEAN csrIsRSNMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3335 tANI_U8 cAllCyphers,
3336 tANI_U8 Oui[] )
3337{
3338 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui02, Oui ) );
3339}
3340
3341static tANI_BOOLEAN csrIsRSNUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3342 tANI_U8 cAllCyphers,
3343 tANI_U8 Oui[] )
3344{
3345 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3346}
3347
3348static tANI_BOOLEAN csrIsRSNMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_RSN_OUI_SIZE],
3349 tANI_U8 cAllCyphers,
3350 tANI_U8 Oui[] )
3351{
3352 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrRSNOui04, Oui ) );
3353}
3354#endif
3355#ifdef FEATURE_WLAN_WAPI
3356static tANI_BOOLEAN csrIsAuthWapiCert( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3357 tANI_U8 cAllSuites,
3358 tANI_U8 Oui[] )
3359{
3360 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[1], Oui ) );
3361}
3362static tANI_BOOLEAN csrIsAuthWapiPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WAPI_OUI_SIZE],
3363 tANI_U8 cAllSuites,
3364 tANI_U8 Oui[] )
3365{
3366 return( csrIsWapiOuiMatch( pMac, AllSuites, cAllSuites, csrWapiOui[2], Oui ) );
3367}
3368#endif /* FEATURE_WLAN_WAPI */
3369
3370#ifdef WLAN_FEATURE_VOWIFI_11R
3371
3372/*
3373 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3374 * here. This matches for FT Auth with the 802.1X exchange.
3375 *
3376 */
3377static tANI_BOOLEAN csrIsFTAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3378 tANI_U8 cAllSuites,
3379 tANI_U8 Oui[] )
3380{
3381 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[03], Oui ) );
3382}
3383
3384/*
3385 * Function for 11R FT Authentication. We match the FT Authentication Cipher suite
3386 * here. This matches for FT Auth with the PSK.
3387 *
3388 */
3389static tANI_BOOLEAN csrIsFTAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3390 tANI_U8 cAllSuites,
3391 tANI_U8 Oui[] )
3392{
3393 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[04], Oui ) );
3394}
3395
3396#endif
3397
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003398#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003399
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003400/*
3401 * Function for ESE CCKM AKM Authentication. We match the CCKM AKM Authentication Key Management suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 * here. This matches for CCKM AKM Auth with the 802.1X exchange.
3403 *
3404 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003405static tANI_BOOLEAN csrIsEseCckmAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 tANI_U8 cAllSuites,
3407 tANI_U8 Oui[] )
3408{
3409 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[06], Oui ) );
3410}
3411
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003412static tANI_BOOLEAN csrIsEseCckmAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 tANI_U8 cAllSuites,
3414 tANI_U8 Oui[] )
3415{
3416 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[06], Oui ) );
3417}
3418
3419#endif
3420
3421static tANI_BOOLEAN csrIsAuthRSN( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3422 tANI_U8 cAllSuites,
3423 tANI_U8 Oui[] )
3424{
Jeff Johnson295189b2012-06-20 16:38:30 -07003425 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[01], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003426}
3427static tANI_BOOLEAN csrIsAuthRSNPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3428 tANI_U8 cAllSuites,
3429 tANI_U8 Oui[] )
3430{
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[02], Oui ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003432}
3433
Chet Lanctot186b5732013-03-18 10:26:30 -07003434#ifdef WLAN_FEATURE_11W
3435static tANI_BOOLEAN csrIsAuthRSNPskSha256( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_RSN_OUI_SIZE],
3436 tANI_U8 cAllSuites,
3437 tANI_U8 Oui[] )
3438{
Chet Lanctot4c986162013-05-08 13:59:56 -07003439 return csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrRSNOui[07], Oui );
Chet Lanctot186b5732013-03-18 10:26:30 -07003440}
3441#endif
3442
Jeff Johnson295189b2012-06-20 16:38:30 -07003443static tANI_BOOLEAN csrIsAuthWpa( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3444 tANI_U8 cAllSuites,
3445 tANI_U8 Oui[] )
3446{
3447 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[01], Oui ) );
3448}
3449
3450#ifdef NOT_CURRENTLY_USED
3451static tANI_BOOLEAN csrIsAuth802_1x( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3452 tANI_U8 cAllSuites,
3453 tANI_U8 Oui[] )
3454{
3455 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[00], Oui ) );
3456}
3457#endif // NOT_CURRENTLY_USED
3458
3459static tANI_BOOLEAN csrIsAuthWpaPsk( tpAniSirGlobal pMac, tANI_U8 AllSuites[][CSR_WPA_OUI_SIZE],
3460 tANI_U8 cAllSuites,
3461 tANI_U8 Oui[] )
3462{
3463 return( csrIsOuiMatch( pMac, AllSuites, cAllSuites, csrWpaOui[02], Oui ) );
3464}
3465#if 0
3466static tANI_BOOLEAN csrIsUnicastNone( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3467 tANI_U8 cAllCyphers,
3468 tANI_U8 Oui[] )
3469{
3470 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui00, Oui ) );
3471}
3472
3473static tANI_BOOLEAN csrIsUnicastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3474 tANI_U8 cAllCyphers,
3475 tANI_U8 Oui[] )
3476{
3477 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3478}
3479
3480static tANI_BOOLEAN csrIsUnicastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3481 tANI_U8 cAllCyphers,
3482 tANI_U8 Oui[] )
3483{
3484 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3485}
3486
3487
3488static tANI_BOOLEAN csrIsMulticastWep( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3489 tANI_U8 cAllCyphers,
3490 tANI_U8 Oui[] )
3491{
3492 tANI_BOOLEAN fYes = FALSE;
3493
3494 // Check Wep 104 first, if fails, then check Wep40.
3495 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui05, Oui );
3496
3497 if ( !fYes )
3498 {
3499 // if not Wep-104, check Wep-40
3500 fYes = csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui01, Oui );
3501 }
3502
3503 return( fYes );
3504}
3505
3506
3507static tANI_BOOLEAN csrIsMulticastTkip( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3508 tANI_U8 cAllCyphers,
3509 tANI_U8 Oui[] )
3510{
3511 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui02, Oui ) );
3512}
3513
3514
3515static tANI_BOOLEAN csrIsMulticastAes( tpAniSirGlobal pMac, tANI_U8 AllCyphers[][CSR_WPA_OUI_SIZE],
3516 tANI_U8 cAllCyphers,
3517 tANI_U8 Oui[] )
3518{
3519 return( csrIsOuiMatch( pMac, AllCyphers, cAllCyphers, csrWpaOui04, Oui ) );
3520}
3521
3522#endif
3523
3524tANI_U8 csrGetOUIIndexFromCipher( eCsrEncryptionType enType )
3525{
3526 tANI_U8 OUIIndex;
3527
3528 switch ( enType )
3529 {
3530 case eCSR_ENCRYPT_TYPE_WEP40:
3531 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3532 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX;
3533 break;
3534 case eCSR_ENCRYPT_TYPE_WEP104:
3535 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3536 OUIIndex = CSR_OUI_WEP104_INDEX;
3537 break;
3538 case eCSR_ENCRYPT_TYPE_TKIP:
3539 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX;
3540 break;
3541 case eCSR_ENCRYPT_TYPE_AES:
3542 OUIIndex = CSR_OUI_AES_INDEX;
3543 break;
3544 case eCSR_ENCRYPT_TYPE_NONE:
3545 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX;
3546 break;
3547#ifdef FEATURE_WLAN_WAPI
3548 case eCSR_ENCRYPT_TYPE_WPI:
3549 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX;
3550 break;
3551#endif /* FEATURE_WLAN_WAPI */
3552 default: //HOWTO handle this?
3553 OUIIndex = CSR_OUI_RESERVED_INDEX;
3554 break;
3555 }//switch
3556
3557 return OUIIndex;
3558}
3559
3560tANI_BOOLEAN csrGetRSNInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3561 tDot11fIERSN *pRSNIe,
3562 tANI_U8 *UnicastCypher,
3563 tANI_U8 *MulticastCypher,
3564 tANI_U8 *AuthSuite,
3565 tCsrRSNCapabilities *Capabilities,
3566 eCsrAuthType *pNegotiatedAuthtype,
3567 eCsrEncryptionType *pNegotiatedMCCipher )
3568{
3569 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3570 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3571 tANI_U8 cUnicastCyphers = 0;
3572 tANI_U8 cMulticastCyphers = 0;
3573 tANI_U8 cAuthSuites = 0, i;
3574 tANI_U8 Unicast[ CSR_RSN_OUI_SIZE ];
3575 tANI_U8 Multicast[ CSR_RSN_OUI_SIZE ];
3576 tANI_U8 AuthSuites[ CSR_RSN_MAX_AUTH_SUITES ][ CSR_RSN_OUI_SIZE ];
3577 tANI_U8 Authentication[ CSR_RSN_OUI_SIZE ];
3578 tANI_U8 MulticastCyphers[ CSR_RSN_MAX_MULTICAST_CYPHERS ][ CSR_RSN_OUI_SIZE ];
3579 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3580
3581 do{
3582 if ( pRSNIe->present )
3583 {
3584 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303585 vos_mem_copy(MulticastCyphers, pRSNIe->gp_cipher_suite, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 cUnicastCyphers = (tANI_U8)(pRSNIe->pwise_cipher_suite_count);
3587 cAuthSuites = (tANI_U8)(pRSNIe->akm_suite_count);
3588 for(i = 0; i < cAuthSuites && i < CSR_RSN_MAX_AUTH_SUITES; i++)
3589 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303590 vos_mem_copy((void *)&AuthSuites[i],
3591 (void *)&pRSNIe->akm_suites[i],
3592 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003593 }
3594
3595 //Check - Is requested Unicast Cipher supported by the BSS.
3596 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, pRSNIe->pwise_cipher_suites, cUnicastCyphers,
3597 csrGetOUIIndexFromCipher( enType ), Unicast );
3598
3599 if( !fAcceptableCyphers ) break;
3600
3601
3602 //Unicast is supported. Pick the first matching Group cipher, if any.
3603 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3604 {
3605 fAcceptableCyphers = csrMatchRSNOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3606 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3607 if(fAcceptableCyphers)
3608 {
3609 break;
3610 }
3611 }
3612 if( !fAcceptableCyphers ) break;
3613
3614 if( pNegotiatedMCCipher )
3615 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3616
3617 /* Initializing with FALSE as it has TRUE value already */
3618 fAcceptableCyphers = FALSE;
3619 for (i = 0 ; i < pAuthType->numEntries; i++)
3620 {
3621 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3622 #ifdef WLAN_FEATURE_VOWIFI_11R
3623 /* Changed the AKM suites according to order of preference */
3624 if ( csrIsFTAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3625 {
3626 if (eCSR_AUTH_TYPE_FT_RSN == pAuthType->authType[i])
3627 negAuthType = eCSR_AUTH_TYPE_FT_RSN;
3628 }
3629 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsFTAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3630 {
3631 if (eCSR_AUTH_TYPE_FT_RSN_PSK == pAuthType->authType[i])
3632 negAuthType = eCSR_AUTH_TYPE_FT_RSN_PSK;
3633 }
3634#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003635#ifdef FEATURE_WLAN_ESE
3636 /* ESE only supports 802.1X. No PSK. */
3637 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 {
3639 if (eCSR_AUTH_TYPE_CCKM_RSN == pAuthType->authType[i])
3640 negAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3641 }
3642#endif
3643 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSN( pMac, AuthSuites, cAuthSuites, Authentication ) )
3644 {
3645 if (eCSR_AUTH_TYPE_RSN == pAuthType->authType[i])
3646 negAuthType = eCSR_AUTH_TYPE_RSN;
3647 }
3648 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3649 {
3650 if (eCSR_AUTH_TYPE_RSN_PSK == pAuthType->authType[i])
3651 negAuthType = eCSR_AUTH_TYPE_RSN_PSK;
3652 }
Chet Lanctot186b5732013-03-18 10:26:30 -07003653#ifdef WLAN_FEATURE_11W
3654 if ((negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthRSNPskSha256( pMac, AuthSuites, cAuthSuites, Authentication ) )
3655 {
3656 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == pAuthType->authType[i])
3657 negAuthType = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3658 }
3659#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003660
3661 // The 1st auth type in the APs RSN IE, to match stations connecting
3662 // profiles auth type will cause us to exit this loop
3663 // This is added as some APs advertise multiple akms in the RSN IE.
3664 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
3665 {
3666 fAcceptableCyphers = TRUE;
3667 break;
3668 }
3669 } // for
3670 }
3671
3672 }while (0);
3673
3674 if ( fAcceptableCyphers )
3675 {
3676 if ( MulticastCypher )
3677 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303678 vos_mem_copy(MulticastCypher, Multicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 }
3680
3681 if ( UnicastCypher )
3682 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303683 vos_mem_copy(UnicastCypher, Unicast, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 }
3685
3686 if ( AuthSuite )
3687 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303688 vos_mem_copy(AuthSuite, Authentication, CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 }
3690
3691 if ( pNegotiatedAuthtype )
3692 {
3693 *pNegotiatedAuthtype = negAuthType;
3694 }
3695 if ( Capabilities )
3696 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08003697 Capabilities->PreAuthSupported = (pRSNIe->RSN_Cap[0] >> 0) & 0x1 ; // Bit 0 PreAuthentication
3698 Capabilities->NoPairwise = (pRSNIe->RSN_Cap[0] >> 1) & 0x1 ; // Bit 1 No Pairwise
3699 Capabilities->PTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 2) & 0x3 ; // Bit 2, 3 PTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003700 Capabilities->GTKSAReplayCounter = (pRSNIe->RSN_Cap[0] >> 4) & 0x3 ; // Bit 4, 5 GTKSA Replay Counter
Chet Lanctot186b5732013-03-18 10:26:30 -07003701 Capabilities->MFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1 ; // Bit 6 MFPR
3702 Capabilities->MFPCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1 ; // Bit 7 MFPC
Chet Lanctot186b5732013-03-18 10:26:30 -07003703 Capabilities->Reserved = pRSNIe->RSN_Cap[1] & 0xff ; // remaining reserved
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 }
3705 }
3706 return( fAcceptableCyphers );
3707}
3708
3709
3710tANI_BOOLEAN csrIsRSNMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
3711 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
3712{
3713 tANI_BOOLEAN fRSNMatch = FALSE;
3714
3715 // See if the cyphers in the Bss description match with the settings in the profile.
3716 fRSNMatch = csrGetRSNInformation( hHal, pAuthType, enType, pEnMcType, &pIes->RSN, NULL, NULL, NULL, NULL,
3717 pNegotiatedAuthType, pNegotiatedMCCipher );
3718
3719 return( fRSNMatch );
3720}
3721
3722
3723tANI_BOOLEAN csrLookupPMKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pPMKId )
3724{
3725 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
3726 tANI_U32 Index;
3727 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3728
Jeff Johnson32d95a32012-09-10 13:15:23 -07003729 if(!pSession)
3730 {
3731 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3732 return FALSE;
3733 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07003734 /* to force the AP initiate fresh 802.1x authentication after re-association should not
3735 * fill the PMKID from cache this is needed
3736 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
3737
3738 if(pSession->fIgnorePMKIDCache)
3739 {
3740 pSession->fIgnorePMKIDCache = FALSE;
3741 return fRC;
3742 }
3743
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 do
3745 {
3746 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
3747 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08003748 smsLog(pMac, LOGW, "match PMKID "MAC_ADDRESS_STR " to ",
3749 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05303750 if( vos_mem_compare(pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 {
3752 // match found
3753 fMatchFound = TRUE;
3754 break;
3755 }
3756 }
3757
3758 if( !fMatchFound ) break;
3759
Kiet Lam64c1b492013-07-12 13:56:44 +05303760 vos_mem_copy(pPMKId, pSession->PmkidCacheInfo[Index].PMKID, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003761
3762 fRC = TRUE;
3763 }
3764 while( 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003765 smsLog(pMac, LOGW, "csrLookupPMKID called return match = %d pMac->roam.NumPmkidCache = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 fRC, pSession->NumPmkidCache);
3767
3768 return fRC;
3769}
3770
3771
3772tANI_U8 csrConstructRSNIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3773 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe )
3774{
3775 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3776 tANI_BOOLEAN fRSNMatch;
3777 tANI_U8 cbRSNIe = 0;
3778 tANI_U8 UnicastCypher[ CSR_RSN_OUI_SIZE ];
3779 tANI_U8 MulticastCypher[ CSR_RSN_OUI_SIZE ];
3780 tANI_U8 AuthSuite[ CSR_RSN_OUI_SIZE ];
3781 tCsrRSNAuthIe *pAuthSuite;
3782 tCsrRSNCapabilities RSNCapabilities;
3783 tCsrRSNPMKIe *pPMK;
3784 tANI_U8 PMKId[CSR_RSN_PMKID_SIZE];
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003785#ifdef WLAN_FEATURE_11W
3786 tANI_U8 *pGroupMgmtCipherSuite;
3787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 tDot11fBeaconIEs *pIesLocal = pIes;
3789
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003790 smsLog(pMac, LOGW, "%s called...", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003791
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 do
3793 {
3794 if ( !csrIsProfileRSN( pProfile ) ) break;
3795
3796 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
3797 {
3798 break;
3799 }
3800
3801 // See if the cyphers in the Bss description match with the settings in the profile.
3802 fRSNMatch = csrGetRSNInformation( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
3803 &pProfile->mcEncryptionType, &pIesLocal->RSN,
3804 UnicastCypher, MulticastCypher, AuthSuite, &RSNCapabilities, NULL, NULL );
3805 if ( !fRSNMatch ) break;
3806
3807 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID;
3808
3809 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED;
3810
Kiet Lam64c1b492013-07-12 13:56:44 +05303811 vos_mem_copy(pRSNIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003812
3813 pRSNIe->cUnicastCyphers = 1;
3814
Kiet Lam64c1b492013-07-12 13:56:44 +05303815 vos_mem_copy(&pRSNIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003816
3817 pAuthSuite = (tCsrRSNAuthIe *)( &pRSNIe->UnicastOui[ pRSNIe->cUnicastCyphers ] );
3818
3819 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05303820 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003821
3822 // RSN capabilities follows the Auth Suite (two octects)
3823 // !!REVIEW - What should STA put in RSN capabilities, currently
3824 // just putting back APs capabilities
3825 // 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 -07003826 // For another, we should use the Management Frame Protection values given by the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 RSNCapabilities.PreAuthSupported = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003828#ifdef WLAN_FEATURE_11W
3829 RSNCapabilities.MFPRequired = pProfile->MFPRequired;
3830 RSNCapabilities.MFPCapable = pProfile->MFPCapable;
3831#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 *(tANI_U16 *)( &pAuthSuite->AuthOui[ 1 ] ) = *((tANI_U16 *)(&RSNCapabilities));
3833
3834 pPMK = (tCsrRSNPMKIe *)( ((tANI_U8 *)(&pAuthSuite->AuthOui[ 1 ])) + sizeof(tANI_U16) );
3835
3836 if( csrLookupPMKID( pMac, sessionId, pSirBssDesc->bssId, &(PMKId[0]) ) )
3837 {
3838 pPMK->cPMKIDs = 1;
3839
Kiet Lam64c1b492013-07-12 13:56:44 +05303840 vos_mem_copy(pPMK->PMKIDList[0].PMKID, PMKId, CSR_RSN_PMKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 }
3842 else
3843 {
3844 pPMK->cPMKIDs = 0;
3845 }
3846
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003847#ifdef WLAN_FEATURE_11W
3848 if ( pProfile->MFPEnabled )
3849 {
3850 pGroupMgmtCipherSuite = (tANI_U8 *) pPMK + sizeof ( tANI_U16 ) +
3851 ( pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE );
Kiet Lam64c1b492013-07-12 13:56:44 +05303852 vos_mem_copy(pGroupMgmtCipherSuite, csrRSNOui[07], CSR_WPA_OUI_SIZE);
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003853 }
3854#endif
3855
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
3857 // Add in the size of the Auth suite (count plus a single OUI)
3858 // Add in the RSN caps field.
3859 // Add PMKID count and PMKID (if any)
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003860 // Add group management cipher suite
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 pRSNIe->IeHeader.Length = (tANI_U8) (sizeof( *pRSNIe ) - sizeof ( pRSNIe->IeHeader ) +
3862 sizeof( *pAuthSuite ) +
3863 sizeof( tCsrRSNCapabilities ));
3864 if(pPMK->cPMKIDs)
3865 {
3866 pRSNIe->IeHeader.Length += (tANI_U8)(sizeof( tANI_U16 ) +
3867 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE));
3868 }
Chet Lanctotedf3dbe2013-05-15 13:21:28 -07003869#ifdef WLAN_FEATURE_11W
3870 if ( pProfile->MFPEnabled )
3871 {
3872 if ( 0 == pPMK->cPMKIDs )
3873 pRSNIe->IeHeader.Length += sizeof( tANI_U16 );
3874 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE;
3875 }
3876#endif
3877
Jeff Johnson295189b2012-06-20 16:38:30 -07003878 // return the size of the IE header (total) constructed...
3879 cbRSNIe = pRSNIe->IeHeader.Length + sizeof( pRSNIe->IeHeader );
3880
3881 } while( 0 );
3882
3883 if( !pIes && pIesLocal )
3884 {
3885 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05303886 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 }
3888
3889 return( cbRSNIe );
3890}
3891
3892
3893#ifdef FEATURE_WLAN_WAPI
3894tANI_BOOLEAN csrGetWapiInformation( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
3895 tDot11fIEWAPI *pWapiIe,
3896 tANI_U8 *UnicastCypher,
3897 tANI_U8 *MulticastCypher,
3898 tANI_U8 *AuthSuite,
3899 eCsrAuthType *pNegotiatedAuthtype,
3900 eCsrEncryptionType *pNegotiatedMCCipher )
3901{
3902 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3903 tANI_BOOLEAN fAcceptableCyphers = FALSE;
3904 tANI_U8 cUnicastCyphers = 0;
3905 tANI_U8 cMulticastCyphers = 0;
3906 tANI_U8 cAuthSuites = 0, i;
3907 tANI_U8 Unicast[ CSR_WAPI_OUI_SIZE ];
3908 tANI_U8 Multicast[ CSR_WAPI_OUI_SIZE ];
3909 tANI_U8 AuthSuites[ CSR_WAPI_MAX_AUTH_SUITES ][ CSR_WAPI_OUI_SIZE ];
3910 tANI_U8 Authentication[ CSR_WAPI_OUI_SIZE ];
3911 tANI_U8 MulticastCyphers[ CSR_WAPI_MAX_MULTICAST_CYPHERS ][ CSR_WAPI_OUI_SIZE ];
3912 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3913
3914 do{
3915 if ( pWapiIe->present )
3916 {
3917 cMulticastCyphers++;
Kiet Lam64c1b492013-07-12 13:56:44 +05303918 vos_mem_copy(MulticastCyphers, pWapiIe->multicast_cipher_suite,
3919 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 cUnicastCyphers = (tANI_U8)(pWapiIe->unicast_cipher_suite_count);
3921 cAuthSuites = (tANI_U8)(pWapiIe->akm_suite_count);
3922 for(i = 0; i < cAuthSuites && i < CSR_WAPI_MAX_AUTH_SUITES; i++)
3923 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303924 vos_mem_copy((void *)&AuthSuites[i], (void *)&pWapiIe->akm_suites[i],
3925 CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 }
3927
3928 //Check - Is requested Unicast Cipher supported by the BSS.
3929 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, pWapiIe->unicast_cipher_suites, cUnicastCyphers,
3930 csrGetOUIIndexFromCipher( enType ), Unicast );
3931
3932 if( !fAcceptableCyphers ) break;
3933
3934
3935 //Unicast is supported. Pick the first matching Group cipher, if any.
3936 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
3937 {
3938 fAcceptableCyphers = csrMatchWapiOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
3939 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i] ), Multicast );
3940 if(fAcceptableCyphers)
3941 {
3942 break;
3943 }
3944 }
3945 if( !fAcceptableCyphers ) break;
3946
3947 if( pNegotiatedMCCipher )
3948 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
3949
3950 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
3951 if ( csrIsAuthWapiCert( pMac, AuthSuites, cAuthSuites, Authentication ) )
3952 {
3953 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3954 }
3955 else if ( csrIsAuthWapiPsk( pMac, AuthSuites, cAuthSuites, Authentication ) )
3956 {
3957 negAuthType = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3958 }
3959 else
3960 {
3961 fAcceptableCyphers = FALSE;
3962 negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
3963 }
3964 if( ( 0 == pAuthType->numEntries ) || ( FALSE == fAcceptableCyphers ) )
3965 {
3966 //Caller doesn't care about auth type, or BSS doesn't match
3967 break;
3968 }
3969 fAcceptableCyphers = FALSE;
3970 for( i = 0 ; i < pAuthType->numEntries; i++ )
3971 {
3972 if( pAuthType->authType[i] == negAuthType )
3973 {
3974 fAcceptableCyphers = TRUE;
3975 break;
3976 }
3977 }
3978 }
3979 }while (0);
3980
3981 if ( fAcceptableCyphers )
3982 {
3983 if ( MulticastCypher )
3984 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303985 vos_mem_copy(MulticastCypher, Multicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 }
3987
3988 if ( UnicastCypher )
3989 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303990 vos_mem_copy(UnicastCypher, Unicast, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 }
3992
3993 if ( AuthSuite )
3994 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303995 vos_mem_copy(AuthSuite, Authentication, CSR_WAPI_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 }
3997
3998 if ( pNegotiatedAuthtype )
3999 {
4000 *pNegotiatedAuthtype = negAuthType;
4001 }
4002 }
4003 return( fAcceptableCyphers );
4004}
4005
4006tANI_BOOLEAN csrIsWapiMatch( tHalHandle hHal, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4007 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCCipher )
4008{
4009 tANI_BOOLEAN fWapiMatch = FALSE;
4010
4011 // See if the cyphers in the Bss description match with the settings in the profile.
4012 fWapiMatch = csrGetWapiInformation( hHal, pAuthType, enType, pEnMcType, &pIes->WAPI, NULL, NULL, NULL,
4013 pNegotiatedAuthType, pNegotiatedMCCipher );
4014
4015 return( fWapiMatch );
4016}
4017
4018tANI_BOOLEAN csrLookupBKID( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 *pBSSId, tANI_U8 *pBKId )
4019{
4020 tANI_BOOLEAN fRC = FALSE, fMatchFound = FALSE;
4021 tANI_U32 Index;
4022 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4023
Jeff Johnson32d95a32012-09-10 13:15:23 -07004024 if(!pSession)
4025 {
4026 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4027 return FALSE;
4028 }
4029
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 do
4031 {
4032 for( Index=0; Index < pSession->NumBkidCache; Index++ )
4033 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08004034 smsLog(pMac, LOGW, "match BKID "MAC_ADDRESS_STR" to ",
4035 MAC_ADDR_ARRAY(pBSSId));
Kiet Lam64c1b492013-07-12 13:56:44 +05304036 if (vos_mem_compare(pBSSId, pSession->BkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 {
4038 // match found
4039 fMatchFound = TRUE;
4040 break;
4041 }
4042 }
4043
4044 if( !fMatchFound ) break;
4045
Kiet Lam64c1b492013-07-12 13:56:44 +05304046 vos_mem_copy(pBKId, pSession->BkidCacheInfo[Index].BKID, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004047
4048 fRC = TRUE;
4049 }
4050 while( 0 );
4051 smsLog(pMac, LOGW, "csrLookupBKID called return match = %d pMac->roam.NumBkidCache = %d", fRC, pSession->NumBkidCache);
4052
4053 return fRC;
4054}
4055
4056tANI_U8 csrConstructWapiIe( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4057 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4058{
4059 tANI_BOOLEAN fWapiMatch = FALSE;
4060 tANI_U8 cbWapiIe = 0;
4061 tANI_U8 UnicastCypher[ CSR_WAPI_OUI_SIZE ];
4062 tANI_U8 MulticastCypher[ CSR_WAPI_OUI_SIZE ];
4063 tANI_U8 AuthSuite[ CSR_WAPI_OUI_SIZE ];
4064 tANI_U8 BKId[CSR_WAPI_BKID_SIZE];
4065 tANI_U8 *pWapi = NULL;
4066 tANI_BOOLEAN fBKIDFound = FALSE;
4067 tDot11fBeaconIEs *pIesLocal = pIes;
4068
4069 do
4070 {
4071 if ( !csrIsProfileWapi( pProfile ) ) break;
4072
4073 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4074 {
4075 break;
4076 }
4077
4078 // See if the cyphers in the Bss description match with the settings in the profile.
4079 fWapiMatch = csrGetWapiInformation( pMac, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType,
4080 &pProfile->mcEncryptionType, &pIesLocal->WAPI,
4081 UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4082 if ( !fWapiMatch ) break;
4083
Kiet Lam64c1b492013-07-12 13:56:44 +05304084 vos_mem_set(pWapiIe, sizeof(tCsrWapiIe), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004085
4086 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI;
4087
4088 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED;
4089
4090 pWapiIe->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304091 vos_mem_copy(&pWapiIe->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004092
4093 pWapi = (tANI_U8 *) (&pWapiIe->AuthOui[ 1 ]);
4094
4095 *pWapi = (tANI_U16)1; //cUnicastCyphers
4096 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304097 vos_mem_copy(pWapi, UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 pWapi += sizeof( UnicastCypher );
4099
Kiet Lam64c1b492013-07-12 13:56:44 +05304100 vos_mem_copy(pWapi, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 pWapi += sizeof( MulticastCypher );
4102
4103
4104 // WAPI capabilities follows the Auth Suite (two octects)
4105 // we shouldn't EVER be sending out "pre-auth supported". It is an AP only capability
4106 // & since we already did a memset pWapiIe to 0, skip these fields
4107 pWapi +=2;
4108
4109 fBKIDFound = csrLookupBKID( pMac, sessionId, pSirBssDesc->bssId, &(BKId[0]) );
4110
4111
4112 if( fBKIDFound )
4113 {
4114 /* Do we need to change the endianness here */
4115 *pWapi = (tANI_U16)1; //cBKIDs
4116 pWapi+=2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304117 vos_mem_copy(pWapi, BKId, CSR_WAPI_BKID_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 }
4119 else
4120 {
4121 *pWapi = 0;
4122 pWapi+=1;
4123 *pWapi = 0;
4124 pWapi+=1;
4125 }
4126
4127 // Add in the IE fields except the IE header
4128 // Add BKID count and BKID (if any)
4129 pWapiIe->IeHeader.Length = (tANI_U8) (sizeof( *pWapiIe ) - sizeof ( pWapiIe->IeHeader ));
4130
4131 /*2 bytes for BKID Count field*/
4132 pWapiIe->IeHeader.Length += sizeof( tANI_U16 );
4133
4134 if(fBKIDFound)
4135 {
4136 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE;
4137 }
4138 // return the size of the IE header (total) constructed...
4139 cbWapiIe = pWapiIe->IeHeader.Length + sizeof( pWapiIe->IeHeader );
4140
4141 } while( 0 );
4142
4143 if( !pIes && pIesLocal )
4144 {
4145 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304146 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 }
4148
4149 return( cbWapiIe );
4150}
4151#endif /* FEATURE_WLAN_WAPI */
4152
4153tANI_BOOLEAN csrGetWpaCyphers( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pMCEncryption,
4154 tDot11fIEWPA *pWpaIe,
4155 tANI_U8 *UnicastCypher,
4156 tANI_U8 *MulticastCypher,
4157 tANI_U8 *AuthSuite,
4158 eCsrAuthType *pNegotiatedAuthtype,
4159 eCsrEncryptionType *pNegotiatedMCCipher )
4160{
4161 tANI_BOOLEAN fAcceptableCyphers = FALSE;
4162 tANI_U8 cUnicastCyphers = 0;
4163 tANI_U8 cMulticastCyphers = 0;
4164 tANI_U8 cAuthSuites = 0;
4165 tANI_U8 Unicast[ CSR_WPA_OUI_SIZE ];
4166 tANI_U8 Multicast[ CSR_WPA_OUI_SIZE ];
4167 tANI_U8 Authentication[ CSR_WPA_OUI_SIZE ];
4168 tANI_U8 MulticastCyphers[ 1 ][ CSR_WPA_OUI_SIZE ];
4169 tANI_U8 i;
4170 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4171
4172 do
4173 {
4174 if ( pWpaIe->present )
4175 {
4176 cMulticastCyphers = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304177 vos_mem_copy(MulticastCyphers, pWpaIe->multicast_cipher, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 cUnicastCyphers = (tANI_U8)(pWpaIe->unicast_cipher_count);
4179 cAuthSuites = (tANI_U8)(pWpaIe->auth_suite_count);
4180
4181 //Check - Is requested Unicast Cipher supported by the BSS.
4182 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, pWpaIe->unicast_ciphers, cUnicastCyphers,
4183 csrGetOUIIndexFromCipher( enType ), Unicast );
4184
4185 if( !fAcceptableCyphers ) break;
4186
4187
4188 //Unicast is supported. Pick the first matching Group cipher, if any.
4189 for( i = 0 ; i < pMCEncryption->numEntries ; i++ )
4190 {
4191 fAcceptableCyphers = csrMatchWPAOUIIndex( pMac, MulticastCyphers, cMulticastCyphers,
4192 csrGetOUIIndexFromCipher( pMCEncryption->encryptionType[i]), Multicast );
4193 if(fAcceptableCyphers)
4194 {
4195 break;
4196 }
4197 }
4198 if( !fAcceptableCyphers ) break;
4199
4200 if( pNegotiatedMCCipher )
4201 *pNegotiatedMCCipher = pMCEncryption->encryptionType[i];
4202
4203 /* Initializing with FALSE as it has TRUE value already */
4204 fAcceptableCyphers = FALSE;
4205 for (i = 0 ; i < pAuthType->numEntries; i++)
4206 {
4207 //Ciphers are supported, Match authentication algorithm and pick first matching authtype.
4208 if ( csrIsAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4209 {
4210 if (eCSR_AUTH_TYPE_WPA == pAuthType->authType[i])
4211 negAuthType = eCSR_AUTH_TYPE_WPA;
4212 }
4213 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsAuthWpaPsk( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
4214 {
4215 if (eCSR_AUTH_TYPE_WPA_PSK == pAuthType->authType[i])
4216 negAuthType = eCSR_AUTH_TYPE_WPA_PSK;
4217 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004218#ifdef FEATURE_WLAN_ESE
4219 if ( (negAuthType == eCSR_AUTH_TYPE_UNKNOWN) && csrIsEseCckmAuthWpa( pMac, pWpaIe->auth_suites, cAuthSuites, Authentication ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 {
4221 if (eCSR_AUTH_TYPE_CCKM_WPA == pAuthType->authType[i])
4222 negAuthType = eCSR_AUTH_TYPE_CCKM_WPA;
4223 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004224#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004225
4226 // The 1st auth type in the APs WPA IE, to match stations connecting
4227 // profiles auth type will cause us to exit this loop
4228 // This is added as some APs advertise multiple akms in the WPA IE.
4229 if (eCSR_AUTH_TYPE_UNKNOWN != negAuthType)
4230 {
4231 fAcceptableCyphers = TRUE;
4232 break;
4233 }
4234 } // for
4235 }
4236 }while(0);
4237
4238 if ( fAcceptableCyphers )
4239 {
4240 if ( MulticastCypher )
4241 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304242 vos_mem_copy((tANI_U8 **)MulticastCypher, Multicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 }
4244
4245 if ( UnicastCypher )
4246 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304247 vos_mem_copy((tANI_U8 **)UnicastCypher, Unicast, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 }
4249
4250 if ( AuthSuite )
4251 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304252 vos_mem_copy((tANI_U8 **)AuthSuite, Authentication, CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 }
4254
4255 if( pNegotiatedAuthtype )
4256 {
4257 *pNegotiatedAuthtype = negAuthType;
4258 }
4259 }
4260
4261 return( fAcceptableCyphers );
4262}
4263
4264
4265
4266tANI_BOOLEAN csrIsWpaEncryptionMatch( tpAniSirGlobal pMac, tCsrAuthList *pAuthType, eCsrEncryptionType enType, tCsrEncryptionList *pEnMcType,
4267 tDot11fBeaconIEs *pIes, eCsrAuthType *pNegotiatedAuthtype, eCsrEncryptionType *pNegotiatedMCCipher )
4268{
4269 tANI_BOOLEAN fWpaMatch = eANI_BOOLEAN_FALSE;
4270
4271 // See if the cyphers in the Bss description match with the settings in the profile.
4272 fWpaMatch = csrGetWpaCyphers( pMac, pAuthType, enType, pEnMcType, &pIes->WPA, NULL, NULL, NULL, pNegotiatedAuthtype, pNegotiatedMCCipher );
4273
4274 return( fWpaMatch );
4275}
4276
4277
4278tANI_U8 csrConstructWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4279 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4280{
4281 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4282 tANI_BOOLEAN fWpaMatch;
4283 tANI_U8 cbWpaIe = 0;
4284 tANI_U8 UnicastCypher[ CSR_WPA_OUI_SIZE ];
4285 tANI_U8 MulticastCypher[ CSR_WPA_OUI_SIZE ];
4286 tANI_U8 AuthSuite[ CSR_WPA_OUI_SIZE ];
4287 tCsrWpaAuthIe *pAuthSuite;
4288 tDot11fBeaconIEs *pIesLocal = pIes;
4289
4290 do
4291 {
4292 if ( !csrIsProfileWpa( pProfile ) ) break;
4293
4294 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4295 {
4296 break;
4297 }
4298 // See if the cyphers in the Bss description match with the settings in the profile.
4299 fWpaMatch = csrGetWpaCyphers( hHal, &pProfile->AuthType, pProfile->negotiatedUCEncryptionType, &pProfile->mcEncryptionType,
4300 &pIesLocal->WPA, UnicastCypher, MulticastCypher, AuthSuite, NULL, NULL );
4301 if ( !fWpaMatch ) break;
4302
4303 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID;
4304
Kiet Lam64c1b492013-07-12 13:56:44 +05304305 vos_mem_copy(pWpaIe->Oui, csrWpaOui[01], sizeof( pWpaIe->Oui ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004306
4307 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED;
4308
Kiet Lam64c1b492013-07-12 13:56:44 +05304309 vos_mem_copy(pWpaIe->MulticastOui, MulticastCypher, sizeof( MulticastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004310
4311 pWpaIe->cUnicastCyphers = 1;
4312
Kiet Lam64c1b492013-07-12 13:56:44 +05304313 vos_mem_copy(&pWpaIe->UnicastOui[ 0 ], UnicastCypher, sizeof( UnicastCypher ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004314
4315 pAuthSuite = (tCsrWpaAuthIe *)( &pWpaIe->UnicastOui[ pWpaIe->cUnicastCyphers ] );
4316
4317 pAuthSuite->cAuthenticationSuites = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05304318 vos_mem_copy(&pAuthSuite->AuthOui[ 0 ], AuthSuite, sizeof( AuthSuite ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004319
4320 // The WPA capabilities follows the Auth Suite (two octects)--
4321 // this field is optional, and we always "send" zero, so just
4322 // remove it. This is consistent with our assumptions in the
4323 // frames compiler; c.f. bug 15234:
4324 // http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234
4325
4326 // Add in the fixed fields plus 1 Unicast cypher, less the IE Header length
4327 // Add in the size of the Auth suite (count plus a single OUI)
4328 pWpaIe->IeHeader.Length = sizeof( *pWpaIe ) - sizeof ( pWpaIe->IeHeader ) +
4329 sizeof( *pAuthSuite );
4330
4331 // return the size of the IE header (total) constructed...
4332 cbWpaIe = pWpaIe->IeHeader.Length + sizeof( pWpaIe->IeHeader );
4333
4334 } while( 0 );
4335
4336 if( !pIes && pIesLocal )
4337 {
4338 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304339 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 }
4341
4342 return( cbWpaIe );
4343}
4344
4345
4346tANI_BOOLEAN csrGetWpaRsnIe( tHalHandle hHal, tANI_U8 *pIes, tANI_U32 len,
4347 tANI_U8 *pWpaIe, tANI_U8 *pcbWpaIe, tANI_U8 *pRSNIe, tANI_U8 *pcbRSNIe)
4348{
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 tDot11IEHeader *pIEHeader;
4350 tSirMacPropIE *pSirMacPropIE;
4351 tANI_U32 cbParsed;
4352 tANI_U32 cbIE;
4353 int cExpectedIEs = 0;
4354 int cFoundIEs = 0;
4355 int cbPropIETotal;
4356
4357 pIEHeader = (tDot11IEHeader *)pIes;
4358 if(pWpaIe) cExpectedIEs++;
4359 if(pRSNIe) cExpectedIEs++;
4360
4361 // bss description length includes all fields other than the length itself
4362 cbParsed = 0;
4363
4364 // Loop as long as there is data left in the IE of the Bss Description
4365 // and the number of Expected IEs is NOT found yet.
4366 while( ( (cbParsed + sizeof( *pIEHeader )) <= len ) && ( cFoundIEs < cExpectedIEs ) )
4367 {
4368 cbIE = sizeof( *pIEHeader ) + pIEHeader->Length;
4369
4370 if ( ( cbIE + cbParsed ) > len ) break;
4371
4372 if ( ( pIEHeader->Length >= gCsrIELengthTable[ pIEHeader->ElementID ].min ) &&
4373 ( pIEHeader->Length <= gCsrIELengthTable[ pIEHeader->ElementID ].max ) )
4374 {
4375 switch( pIEHeader->ElementID )
4376 {
4377 // Parse the 221 (0xdd) Proprietary IEs here...
4378 // Note that the 221 IE is overloaded, containing the WPA IE, WMM/WME IE, and the
4379 // Airgo proprietary IE information.
4380 case SIR_MAC_WPA_EID:
4381 {
4382 tANI_U32 aniOUI;
4383 tANI_U8 *pOui = (tANI_U8 *)&aniOUI;
4384
4385 pOui++;
4386 aniOUI = ANI_OUI;
4387 aniOUI = i_ntohl( aniOUI );
4388
4389 pSirMacPropIE = ( tSirMacPropIE *)pIEHeader;
4390 cbPropIETotal = pSirMacPropIE->length;
4391
4392 // Validate the ANI OUI is in the OUI field in the proprietary IE...
4393 if ( ( pSirMacPropIE->length >= WNI_CFG_MANUFACTURER_OUI_LEN ) &&
4394 pOui[ 0 ] == pSirMacPropIE->oui[ 0 ] &&
4395 pOui[ 1 ] == pSirMacPropIE->oui[ 1 ] &&
4396 pOui[ 2 ] == pSirMacPropIE->oui[ 2 ] )
4397 {
4398 }
4399 else
4400 {
4401 tCsrWpaIe *pIe = ( tCsrWpaIe * )pIEHeader;
4402
4403 if(!pWpaIe || !pcbWpaIe) break;
4404 // Check if this is a valid WPA IE. Then check that the
4405 // WPA OUI is in place and the version is one that we support.
4406 if ( ( pIe->IeHeader.Length >= SIR_MAC_WPA_IE_MIN_LENGTH ) &&
Kiet Lam64c1b492013-07-12 13:56:44 +05304407 ( vos_mem_compare( pIe->Oui, (void *)csrWpaOui[1],
4408 sizeof( pIe->Oui ) ) ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 ( pIe->Version <= CSR_WPA_VERSION_SUPPORTED ) )
4410 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304411 vos_mem_copy(pWpaIe, pIe,
4412 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 *pcbWpaIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4414 cFoundIEs++;
4415
4416 break;
4417 }
4418 }
4419
4420 break;
4421 }
4422
4423 case SIR_MAC_RSN_EID:
4424 {
4425 tCsrRSNIe *pIe;
4426
4427 if(!pcbRSNIe || !pRSNIe) break;
4428 pIe = (tCsrRSNIe *)pIEHeader;
4429
4430 // Check the length of the RSN Ie to assure it is valid. Then check that the
4431 // version is one that we support.
4432
4433 if ( pIe->IeHeader.Length < SIR_MAC_RSN_IE_MIN_LENGTH ) break;
4434 if ( pIe->Version > CSR_RSN_VERSION_SUPPORTED ) break;
4435
4436 cFoundIEs++;
4437
4438 // if there is enough room in the WpaIE passed in, then copy the Wpa IE into
4439 // the buffer passed in.
4440 if ( *pcbRSNIe < pIe->IeHeader.Length + sizeof( pIe->IeHeader ) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05304441 vos_mem_copy(pRSNIe, pIe,
4442 pIe->IeHeader.Length + sizeof( pIe->IeHeader ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 *pcbRSNIe = pIe->IeHeader.Length + sizeof( pIe->IeHeader );
4444
4445 break;
4446 }
4447
4448 // Add support for other IE here...
4449 default:
4450 break;
4451 }
4452 }
4453
4454 cbParsed += cbIE;
4455
4456 pIEHeader = (tDot11IEHeader *)( ((tANI_U8 *)pIEHeader) + cbIE );
4457
4458 }
4459
4460 // return a BOOL that tells if all of the IEs asked for were found...
4461 return( cFoundIEs == cExpectedIEs );
4462}
4463
4464
4465//If a WPAIE exists in the profile, just use it. Or else construct one from the BSS
4466//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4467tANI_U8 csrRetrieveWpaIe( tHalHandle hHal, tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4468 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe )
4469{
4470 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4471 tANI_U8 cbWpaIe = 0;
4472
4473 do
4474 {
4475 if ( !csrIsProfileWpa( pProfile ) ) break;
4476 if(pProfile->nWPAReqIELength && pProfile->pWPAReqIE)
4477 {
4478 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nWPAReqIELength)
4479 {
4480 cbWpaIe = (tANI_U8)pProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304481 vos_mem_copy(pWpaIe, pProfile->pWPAReqIE, cbWpaIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 }
4483 else
4484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004485 smsLog(pMac, LOGW, " csrRetrieveWpaIe detect invalid WPA IE length (%d) ", pProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 }
4487 }
4488 else
4489 {
4490 cbWpaIe = csrConstructWpaIe(pMac, pProfile, pSirBssDesc, pIes, pWpaIe);
4491 }
4492 }while(0);
4493
4494 return (cbWpaIe);
4495}
4496
4497
4498//If a RSNIE exists in the profile, just use it. Or else construct one from the BSS
4499//Caller allocated memory for pWpaIe and guarrantee it can contain a max length WPA IE
4500tANI_U8 csrRetrieveRsnIe( tHalHandle hHal, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4501 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe )
4502{
4503 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4504 tANI_U8 cbRsnIe = 0;
4505
4506 do
4507 {
4508 if ( !csrIsProfileRSN( pProfile ) ) break;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004509#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304510 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004511 {
4512 // If "Legacy Fast Roaming" is enabled ALWAYS rebuild the RSN IE from
4513 // scratch. So it contains the current PMK-IDs
4514 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4515 }
4516 else
4517#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 if(pProfile->nRSNReqIELength && pProfile->pRSNReqIE)
4519 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004520 // If you have one started away, re-use it.
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 if(SIR_MAC_WPA_IE_MAX_LENGTH >= pProfile->nRSNReqIELength)
4522 {
4523 cbRsnIe = (tANI_U8)pProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304524 vos_mem_copy(pRsnIe, pProfile->pRSNReqIE, cbRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 }
4526 else
4527 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004528 smsLog(pMac, LOGW, " csrRetrieveRsnIe detect invalid RSN IE length (%d) ", pProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 }
4530 }
4531 else
4532 {
4533 cbRsnIe = csrConstructRSNIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pRsnIe);
4534 }
4535 }while(0);
4536
4537 return (cbRsnIe);
4538}
4539
4540
4541#ifdef FEATURE_WLAN_WAPI
4542//If a WAPI IE exists in the profile, just use it. Or else construct one from the BSS
4543//Caller allocated memory for pWapiIe and guarrantee it can contain a max length WAPI IE
4544tANI_U8 csrRetrieveWapiIe( tHalHandle hHal, tANI_U32 sessionId,
4545 tCsrRoamProfile *pProfile, tSirBssDescription *pSirBssDesc,
4546 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe )
4547{
4548 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4549 tANI_U8 cbWapiIe = 0;
4550
4551 do
4552 {
4553 if ( !csrIsProfileWapi( pProfile ) ) break;
4554 if(pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE)
4555 {
4556 if(DOT11F_IE_WAPI_MAX_LEN >= pProfile->nWAPIReqIELength)
4557 {
4558 cbWapiIe = (tANI_U8)pProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05304559 vos_mem_copy(pWapiIe, pProfile->pWAPIReqIE, cbWapiIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 }
4561 else
4562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004563 smsLog(pMac, LOGW, " csrRetrieveWapiIe detect invalid WAPI IE length (%d) ", pProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 }
4565 }
4566 else
4567 {
4568 cbWapiIe = csrConstructWapiIe(pMac, sessionId, pProfile, pSirBssDesc, pIes, pWapiIe);
4569 }
4570 }while(0);
4571
4572 return (cbWapiIe);
4573}
4574#endif /* FEATURE_WLAN_WAPI */
4575
4576tANI_BOOLEAN csrSearchChannelListForTxPower(tHalHandle hHal, tSirBssDescription *pBssDescription, tCsrChannelSet *returnChannelGroup)
4577{
4578 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4579 tListElem *pEntry;
4580 tANI_U16 i;
4581 tANI_U16 startingChannel;
4582 tANI_BOOLEAN found = FALSE;
4583 tCsrChannelSet *pChannelGroup;
4584
4585 pEntry = csrLLPeekHead( &pMac->roam.channelList5G, LL_ACCESS_LOCK );
4586
4587 while ( pEntry )
4588 {
4589 pChannelGroup = GET_BASE_ADDR( pEntry, tCsrChannelSet, channelListLink );
4590 startingChannel = pChannelGroup->firstChannel;
4591 for ( i = 0; i < pChannelGroup->numChannels; i++ )
4592 {
4593 if ( startingChannel + i * pChannelGroup->interChannelOffset == pBssDescription->channelId )
4594 {
4595 found = TRUE;
4596 break;
4597 }
4598 }
4599
4600 if ( found )
4601 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304602 vos_mem_copy(returnChannelGroup, pChannelGroup, sizeof(tCsrChannelSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 break;
4604 }
4605 else
4606 {
4607 pEntry = csrLLNext( &pMac->roam.channelList5G, pEntry, LL_ACCESS_LOCK );
4608 }
4609 }
4610
4611 return( found );
4612}
4613
4614tANI_BOOLEAN csrRatesIsDot11Rate11bSupportedRate( tANI_U8 dot11Rate )
4615{
4616 tANI_BOOLEAN fSupported = FALSE;
4617 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4618
4619 switch ( nonBasicRate )
4620 {
4621 case eCsrSuppRate_1Mbps:
4622 case eCsrSuppRate_2Mbps:
4623 case eCsrSuppRate_5_5Mbps:
4624 case eCsrSuppRate_11Mbps:
4625 fSupported = TRUE;
4626 break;
4627
4628 default:
4629 break;
4630 }
4631
4632 return( fSupported );
4633}
4634
4635tANI_BOOLEAN csrRatesIsDot11Rate11aSupportedRate( tANI_U8 dot11Rate )
4636{
4637 tANI_BOOLEAN fSupported = FALSE;
4638 tANI_U16 nonBasicRate = (tANI_U16)( BITS_OFF( dot11Rate, CSR_DOT11_BASIC_RATE_MASK ) );
4639
4640 switch ( nonBasicRate )
4641 {
4642 case eCsrSuppRate_6Mbps:
4643 case eCsrSuppRate_9Mbps:
4644 case eCsrSuppRate_12Mbps:
4645 case eCsrSuppRate_18Mbps:
4646 case eCsrSuppRate_24Mbps:
4647 case eCsrSuppRate_36Mbps:
4648 case eCsrSuppRate_48Mbps:
4649 case eCsrSuppRate_54Mbps:
4650 fSupported = TRUE;
4651 break;
4652
4653 default:
4654 break;
4655 }
4656
4657 return( fSupported );
4658}
4659
4660
4661
4662tAniEdType csrTranslateEncryptTypeToEdType( eCsrEncryptionType EncryptType )
4663{
4664 tAniEdType edType;
4665
4666 switch ( EncryptType )
4667 {
4668 default:
4669 case eCSR_ENCRYPT_TYPE_NONE:
4670 edType = eSIR_ED_NONE;
4671 break;
4672
4673 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4674 case eCSR_ENCRYPT_TYPE_WEP40:
4675 edType = eSIR_ED_WEP40;
4676 break;
4677
4678 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4679 case eCSR_ENCRYPT_TYPE_WEP104:
4680 edType = eSIR_ED_WEP104;
4681 break;
4682
4683 case eCSR_ENCRYPT_TYPE_TKIP:
4684 edType = eSIR_ED_TKIP;
4685 break;
4686
4687 case eCSR_ENCRYPT_TYPE_AES:
4688 edType = eSIR_ED_CCMP;
4689 break;
4690#ifdef FEATURE_WLAN_WAPI
4691 case eCSR_ENCRYPT_TYPE_WPI:
4692 edType = eSIR_ED_WPI;
Gopichand Nakkala39d9d7a2013-05-19 19:07:35 +05304693 break ;
Jeff Johnson295189b2012-06-20 16:38:30 -07004694#endif
4695#ifdef WLAN_FEATURE_11W
4696 //11w BIP
4697 case eCSR_ENCRYPT_TYPE_AES_CMAC:
4698 edType = eSIR_ED_AES_128_CMAC;
4699 break;
4700#endif
4701 }
4702
4703 return( edType );
4704}
4705
4706
4707//pIes can be NULL
4708tANI_BOOLEAN csrValidateWep( tpAniSirGlobal pMac, eCsrEncryptionType ucEncryptionType,
4709 tCsrAuthList *pAuthList, tCsrEncryptionList *pMCEncryptionList,
4710 eCsrAuthType *pNegotiatedAuthType, eCsrEncryptionType *pNegotiatedMCEncryption,
4711 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes )
4712{
4713 tANI_U32 idx;
4714 tANI_BOOLEAN fMatch = FALSE;
4715 eCsrAuthType negotiatedAuth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4716 eCsrEncryptionType negotiatedMCCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4717
4718 //This function just checks whether HDD is giving correct values for Multicast cipher and Auth.
4719
4720 do
4721 {
4722 //If privacy bit is not set, consider no match
4723 if ( !csrIsPrivacy( pSirBssDesc ) ) break;
4724
4725 for( idx = 0; idx < pMCEncryptionList->numEntries; idx++ )
4726 {
4727 switch( pMCEncryptionList->encryptionType[idx] )
4728 {
4729 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4730 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4731 case eCSR_ENCRYPT_TYPE_WEP40:
4732 case eCSR_ENCRYPT_TYPE_WEP104:
4733 /* Multicast list may contain WEP40/WEP104. Check whether it matches UC.
4734 */
4735 if( ucEncryptionType == pMCEncryptionList->encryptionType[idx] )
4736 {
4737 fMatch = TRUE;
4738 negotiatedMCCipher = pMCEncryptionList->encryptionType[idx];
4739 }
4740 break;
4741 default:
4742 fMatch = FALSE;
4743 break;
4744 }
4745 if(fMatch) break;
4746 }
4747
4748 if(!fMatch) break;
4749
4750 for( idx = 0; idx < pAuthList->numEntries; idx++ )
4751 {
4752 switch( pAuthList->authType[idx] )
4753 {
4754 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4755 case eCSR_AUTH_TYPE_SHARED_KEY:
4756 case eCSR_AUTH_TYPE_AUTOSWITCH:
4757 fMatch = TRUE;
4758 negotiatedAuth = pAuthList->authType[idx];
4759 break;
4760 default:
4761 fMatch = FALSE;
4762 }
4763 if (fMatch) break;
4764 }
4765
4766 if(!fMatch) break;
4767 //In case of WPA / WPA2, check whether it supports WEP as well
4768 if(pIes)
4769 {
4770 //Prepare the encryption type for WPA/WPA2 functions
4771 if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == ucEncryptionType )
4772 {
4773 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4774 }
4775 else if( eCSR_ENCRYPT_TYPE_WEP104 == ucEncryptionType )
4776 {
4777 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4778 }
4779 //else we can use the encryption type directly
Kiet Lam64c1b492013-07-12 13:56:44 +05304780 if ( pIes->WPA.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304782 fMatch = vos_mem_compare(pIes->WPA.multicast_cipher,
4783 csrWpaOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
4784 CSR_WPA_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 if( fMatch ) break;
4786 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304787 if ( pIes->RSN.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304789 fMatch = vos_mem_compare(pIes->RSN.gp_cipher_suite,
4790 csrRSNOui[csrGetOUIIndexFromCipher( ucEncryptionType )],
4791 CSR_RSN_OUI_SIZE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 }
4793 }
4794
4795 }while(0);
4796
4797 if( fMatch )
4798 {
4799 if( pNegotiatedAuthType )
4800 *pNegotiatedAuthType = negotiatedAuth;
4801
4802 if( pNegotiatedMCEncryption )
4803 *pNegotiatedMCEncryption = negotiatedMCCipher;
4804 }
4805
4806
4807 return fMatch;
4808}
4809
4810
4811//pIes shall contain IEs from pSirBssDesc. It shall be returned from function csrGetParsedBssDescriptionIEs
4812tANI_BOOLEAN csrIsSecurityMatch( tHalHandle hHal, tCsrAuthList *authType, tCsrEncryptionList *pUCEncryptionType, tCsrEncryptionList *pMCEncryptionType,
4813 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
4814 eCsrAuthType *negotiatedAuthtype, eCsrEncryptionType *negotiatedUCCipher, eCsrEncryptionType *negotiatedMCCipher )
4815{
4816 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4817 tANI_BOOLEAN fMatch = FALSE;
4818 tANI_U8 i,idx;
4819 eCsrEncryptionType mcCipher = eCSR_ENCRYPT_TYPE_UNKNOWN, ucCipher = eCSR_ENCRYPT_TYPE_UNKNOWN;
4820 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN;
4821
4822 for( i = 0 ; ((i < pUCEncryptionType->numEntries) && (!fMatch)) ; i++ )
4823 {
4824 ucCipher = pUCEncryptionType->encryptionType[i];
4825 // If the Bss description shows the Privacy bit is on, then we must have some sort of encryption configured
4826 // for the profile to work. Don't attempt to join networks with Privacy bit set when profiles say NONE for
4827 // encryption type.
4828 switch ( ucCipher )
4829 {
4830 case eCSR_ENCRYPT_TYPE_NONE:
4831 {
4832 // for NO encryption, if the Bss description has the Privacy bit turned on, then encryption is
4833 // required so we have to reject this Bss.
4834 if ( csrIsPrivacy( pSirBssDesc ) )
4835 {
4836 fMatch = FALSE;
4837 }
4838 else
4839 {
4840 fMatch = TRUE;
4841 }
4842
4843 if ( fMatch )
4844 {
4845 fMatch = FALSE;
4846 //Check Multicast cipher requested and Auth type requested.
4847 for( idx = 0 ; idx < pMCEncryptionType->numEntries ; idx++ )
4848 {
4849 if( eCSR_ENCRYPT_TYPE_NONE == pMCEncryptionType->encryptionType[idx] )
4850 {
4851 fMatch = TRUE; //Multicast can only be none.
4852 mcCipher = pMCEncryptionType->encryptionType[idx];
4853 break;
4854 }
4855 }
4856 if (!fMatch) break;
4857
4858 fMatch = FALSE;
4859 //Check Auth list. It should contain AuthOpen.
4860 for( idx = 0 ; idx < authType->numEntries ; idx++ )
4861 {
4862 if( eCSR_AUTH_TYPE_OPEN_SYSTEM == authType->authType[idx] )
4863 {
4864 fMatch = TRUE;
4865 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4866 break;
4867 }
4868 }
4869 if (!fMatch) break;
4870
4871 }
4872 break;
4873 }
4874
4875 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4876 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4877 // !! might want to check for WEP keys set in the Profile.... ?
4878 // !! don't need to have the privacy bit in the Bss description. Many AP policies make legacy
4879 // encryption 'optional' so we don't know if we can associate or not. The AP will reject if
4880 // encryption is not allowed without the Privacy bit turned on.
4881 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4882
4883 break;
4884
4885 // these are all of the WPA encryption types...
4886 case eCSR_ENCRYPT_TYPE_WEP40:
4887 case eCSR_ENCRYPT_TYPE_WEP104:
4888 fMatch = csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes);
4889 break;
4890
4891 case eCSR_ENCRYPT_TYPE_TKIP:
4892 case eCSR_ENCRYPT_TYPE_AES:
4893 {
4894 if(pIes)
4895 {
4896 // First check if there is a RSN match
4897 fMatch = csrIsRSNMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4898 if( !fMatch )
4899 {
4900 // If not RSN, then check if there is a WPA match
4901 fMatch = csrIsWpaEncryptionMatch( pMac, authType, ucCipher, pMCEncryptionType, pIes,
4902 &negAuthType, &mcCipher );
4903 }
4904 }
4905 else
4906 {
4907 fMatch = FALSE;
4908 }
4909 break;
4910 }
4911#ifdef FEATURE_WLAN_WAPI
4912 case eCSR_ENCRYPT_TYPE_WPI://WAPI
4913 {
4914 if(pIes)
4915 {
4916 fMatch = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4917 }
4918 else
4919 {
4920 fMatch = FALSE;
4921 }
4922 break;
4923 }
4924#endif /* FEATURE_WLAN_WAPI */
4925 case eCSR_ENCRYPT_TYPE_ANY:
4926 default:
4927 {
4928 tANI_BOOLEAN fMatchAny = eANI_BOOLEAN_FALSE;
4929
4930 fMatch = eANI_BOOLEAN_TRUE;
4931 //It is allowed to match anything. Try the more secured ones first.
4932 if(pIes)
4933 {
4934 //Check AES first
4935 ucCipher = eCSR_ENCRYPT_TYPE_AES;
4936 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4937 if(!fMatchAny)
4938 {
4939 //Check TKIP
4940 ucCipher = eCSR_ENCRYPT_TYPE_TKIP;
4941 fMatchAny = csrIsRSNMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4942 }
4943#ifdef FEATURE_WLAN_WAPI
4944 if(!fMatchAny)
4945 {
4946 //Check WAPI
4947 ucCipher = eCSR_ENCRYPT_TYPE_WPI;
4948 fMatchAny = csrIsWapiMatch( hHal, authType, ucCipher, pMCEncryptionType, pIes, &negAuthType, &mcCipher );
4949 }
4950#endif /* FEATURE_WLAN_WAPI */
4951 }
4952 if(!fMatchAny)
4953 {
4954 ucCipher = eCSR_ENCRYPT_TYPE_WEP104;
4955 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4956 {
4957 ucCipher = eCSR_ENCRYPT_TYPE_WEP40;
4958 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4959 {
4960 ucCipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4961 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4962 {
4963 ucCipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4964 if(!csrValidateWep( pMac, ucCipher, authType, pMCEncryptionType, &negAuthType, &mcCipher, pSirBssDesc, pIes))
4965 {
4966 //It must be open and no encryption
4967 if ( csrIsPrivacy( pSirBssDesc ) )
4968 {
4969 //This is not right
4970 fMatch = eANI_BOOLEAN_FALSE;
4971 }
4972 else
4973 {
4974 negAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4975 mcCipher = eCSR_ENCRYPT_TYPE_NONE;
4976 ucCipher = eCSR_ENCRYPT_TYPE_NONE;
4977 }
4978 }
4979 }
4980 }
4981 }
4982 }
4983 break;
4984 }
4985 }
4986
4987 }
4988
4989 if( fMatch )
4990 {
4991 if( negotiatedUCCipher )
4992 *negotiatedUCCipher = ucCipher;
4993
4994 if( negotiatedMCCipher )
4995 *negotiatedMCCipher = mcCipher;
4996
4997 if( negotiatedAuthtype )
4998 *negotiatedAuthtype = negAuthType;
4999 }
5000
5001 return( fMatch );
5002}
5003
5004
5005tANI_BOOLEAN csrIsSsidMatch( tpAniSirGlobal pMac, tANI_U8 *ssid1, tANI_U8 ssid1Len, tANI_U8 *bssSsid,
5006 tANI_U8 bssSsidLen, tANI_BOOLEAN fSsidRequired )
5007{
5008 tANI_BOOLEAN fMatch = FALSE;
5009
5010 do {
5011
5012 // There are a few special cases. If the Bss description has a Broadcast SSID,
5013 // then our Profile must have a single SSID without Wildcards so we can program
5014 // the SSID.
5015 // SSID could be suppressed in beacons. In that case SSID IE has valid length
5016 // but the SSID value is all NULL characters. That condition is trated same
5017 // as NULL SSID
5018 if ( csrIsNULLSSID( bssSsid, bssSsidLen ) )
5019 {
5020 if ( eANI_BOOLEAN_FALSE == fSsidRequired )
5021 {
5022 fMatch = TRUE;
5023 }
5024 break;
5025 }
5026
5027 // Check for the specification of the Broadcast SSID at the beginning of the list.
5028 // If specified, then all SSIDs are matches (broadcast SSID means accept all SSIDs).
5029 if ( ssid1Len == 0 )
5030 {
5031 fMatch = TRUE;
5032 break;
5033 }
5034
5035 if(ssid1Len != bssSsidLen) break;
Kiet Lam64c1b492013-07-12 13:56:44 +05305036 if (vos_mem_compare(bssSsid, ssid1, bssSsidLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 {
5038 fMatch = TRUE;
5039 break;
5040 }
5041
5042 } while( 0 );
5043
5044 return( fMatch );
5045}
5046
5047
5048//Null ssid means match
5049tANI_BOOLEAN csrIsSsidInList( tHalHandle hHal, tSirMacSSid *pSsid, tCsrSSIDs *pSsidList )
5050{
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 tANI_BOOLEAN fMatch = FALSE;
5052 tANI_U32 i;
5053
5054 if ( pSsidList && pSsid )
5055 {
5056 for(i = 0; i < pSsidList->numOfSSIDs; i++)
5057 {
5058 if(csrIsNULLSSID(pSsidList->SSIDList[i].SSID.ssId, pSsidList->SSIDList[i].SSID.length) ||
Kiet Lam64c1b492013-07-12 13:56:44 +05305059 ((pSsidList->SSIDList[i].SSID.length == pSsid->length) &&
5060 vos_mem_compare(pSsid->ssId, pSsidList->SSIDList[i].SSID.ssId, pSsid->length)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 {
5062 fMatch = TRUE;
5063 break;
5064 }
5065 }
5066 }
5067
5068 return (fMatch);
5069}
5070
5071//like to use sirCompareMacAddr
5072tANI_BOOLEAN csrIsMacAddressZero( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5073{
5074 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5075
Kiet Lam64c1b492013-07-12 13:56:44 +05305076 return (vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005077}
5078
5079//like to use sirCompareMacAddr
5080tANI_BOOLEAN csrIsMacAddressBroadcast( tpAniSirGlobal pMac, tCsrBssid *pMacAddr )
5081{
5082 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
5083
Kiet Lam64c1b492013-07-12 13:56:44 +05305084 return(vos_mem_compare(bssid, pMacAddr, WNI_CFG_BSSID_LEN));
Jeff Johnson295189b2012-06-20 16:38:30 -07005085}
5086
5087
5088//like to use sirCompareMacAddr
5089tANI_BOOLEAN csrIsMacAddressEqual( tpAniSirGlobal pMac, tCsrBssid *pMacAddr1, tCsrBssid *pMacAddr2 )
5090{
Kiet Lam64c1b492013-07-12 13:56:44 +05305091 return(vos_mem_compare(pMacAddr1, pMacAddr2, sizeof(tCsrBssid)));
Jeff Johnson295189b2012-06-20 16:38:30 -07005092}
5093
5094
5095tANI_BOOLEAN csrIsBssidMatch( tHalHandle hHal, tCsrBssid *pProfBssid, tCsrBssid *BssBssid )
5096{
5097 tANI_BOOLEAN fMatch = FALSE;
5098 tCsrBssid ProfileBssid;
5099 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5100
5101 // for efficiency of the MAC_ADDRESS functions, move the
5102 // Bssid's into MAC_ADDRESS structs.
Kiet Lam64c1b492013-07-12 13:56:44 +05305103 vos_mem_copy(&ProfileBssid, pProfBssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005104
5105 do {
5106
5107 // Give the profile the benefit of the doubt... accept either all 0 or
5108 // the real broadcast Bssid (all 0xff) as broadcast Bssids (meaning to
5109 // match any Bssids).
5110 if ( csrIsMacAddressZero( pMac, &ProfileBssid ) ||
5111 csrIsMacAddressBroadcast( pMac, &ProfileBssid ) )
5112 {
5113 fMatch = TRUE;
5114 break;
5115 }
5116
5117 if ( csrIsMacAddressEqual( pMac, BssBssid, &ProfileBssid ) )
5118 {
5119 fMatch = TRUE;
5120 break;
5121 }
5122
5123 } while( 0 );
5124
5125 return( fMatch );
5126}
5127
5128
5129tANI_BOOLEAN csrIsBSSTypeMatch(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2)
5130{
5131 if((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) && (bssType1 != bssType2))
5132 return eANI_BOOLEAN_FALSE;
5133 else
5134 return eANI_BOOLEAN_TRUE;
5135}
5136
5137
5138tANI_BOOLEAN csrIsBssTypeIBSS(eCsrRoamBssType bssType)
5139{
5140 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_START_IBSS == bssType || eCSR_BSS_TYPE_IBSS == bssType));
5141}
5142
5143tANI_BOOLEAN csrIsBssTypeWDS(eCsrRoamBssType bssType)
5144{
5145 return((tANI_BOOLEAN)(eCSR_BSS_TYPE_WDS_STA == bssType || eCSR_BSS_TYPE_WDS_AP == bssType));
5146}
5147
5148tANI_BOOLEAN csrIsBSSTypeCapsMatch( eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5149{
5150 tANI_BOOLEAN fMatch = TRUE;
5151
5152 do
5153 {
5154 switch( bssType )
5155 {
5156 case eCSR_BSS_TYPE_ANY:
5157 break;
5158
5159 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5160 case eCSR_BSS_TYPE_WDS_STA:
5161 if( !csrIsInfraBssDesc( pSirBssDesc ) )
5162 fMatch = FALSE;
5163
5164 break;
5165
5166 case eCSR_BSS_TYPE_IBSS:
5167 case eCSR_BSS_TYPE_START_IBSS:
5168 if( !csrIsIbssBssDesc( pSirBssDesc ) )
5169 fMatch = FALSE;
5170
5171 break;
5172
5173 case eCSR_BSS_TYPE_WDS_AP: //For WDS AP, no need to match anything
5174 default:
5175 fMatch = FALSE;
5176 break;
5177 }
5178 }
5179 while( 0 );
5180
5181
5182 return( fMatch );
5183}
5184
5185static tANI_BOOLEAN csrIsCapabilitiesMatch( tpAniSirGlobal pMac, eCsrRoamBssType bssType, tSirBssDescription *pSirBssDesc )
5186{
5187 return( csrIsBSSTypeCapsMatch( bssType, pSirBssDesc ) );
5188}
5189
5190
5191
5192static tANI_BOOLEAN csrIsSpecificChannelMatch( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, tANI_U8 Channel )
5193{
5194 tANI_BOOLEAN fMatch = TRUE;
5195
5196 do
5197 {
5198 // if the channel is ANY, then always match...
5199 if ( eCSR_OPERATING_CHANNEL_ANY == Channel ) break;
5200 if ( Channel == pSirBssDesc->channelId ) break;
5201
5202 // didn't match anything.. so return NO match
5203 fMatch = FALSE;
5204
5205 } while( 0 );
5206
5207 return( fMatch );
5208}
5209
5210
5211tANI_BOOLEAN csrIsChannelBandMatch( tpAniSirGlobal pMac, tANI_U8 channelId, tSirBssDescription *pSirBssDesc )
5212{
5213 tANI_BOOLEAN fMatch = TRUE;
5214
5215 do
5216 {
5217 // if the profile says Any channel AND the global settings says ANY channel, then we
5218 // always match...
5219 if ( eCSR_OPERATING_CHANNEL_ANY == channelId ) break;
5220
5221 if ( eCSR_OPERATING_CHANNEL_ANY != channelId )
5222 {
5223 fMatch = csrIsSpecificChannelMatch( pMac, pSirBssDesc, channelId );
5224 }
5225
5226 } while( 0 );
5227
5228 return( fMatch );
5229}
5230
5231
5232/**
5233 * \brief Enquire as to whether a given rate is supported by the
5234 * adapter as currently configured
5235 *
5236 *
5237 * \param nRate A rate in units of 500kbps
5238 *
5239 * \return TRUE if the adapter is currently capable of supporting this
5240 * rate, FALSE else
5241 *
5242 *
5243 * The rate encoding is just as in 802.11 Information Elements, except
5244 * that the high bit is \em not interpreted as indicating a Basic Rate,
5245 * and proprietary rates are allowed, too.
5246 *
5247 * Note that if the adapter's dot11Mode is g, we don't restrict the
5248 * rates. According to hwReadEepromParameters, this will happen when:
5249 *
5250 * ... the card is configured for ALL bands through the property
5251 * page. If this occurs, and the card is not an ABG card ,then this
5252 * code is setting the dot11Mode to assume the mode that the
5253 * hardware can support. For example, if the card is an 11BG card
5254 * and we are configured to support ALL bands, then we change the
5255 * dot11Mode to 11g because ALL in this case is only what the
5256 * hardware can support.
5257 *
5258 *
5259 */
5260
5261static tANI_BOOLEAN csrIsAggregateRateSupported( tpAniSirGlobal pMac, tANI_U16 rate )
5262{
5263 tANI_BOOLEAN fSupported = eANI_BOOLEAN_FALSE;
5264 tANI_U16 idx, newRate;
5265
5266 //In case basic rate flag is set
5267 newRate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK);
5268 if ( eCSR_CFG_DOT11_MODE_11A == pMac->roam.configParam.uCfgDot11Mode )
5269 {
5270 switch ( newRate )
5271 {
5272 case eCsrSuppRate_6Mbps:
5273 case eCsrSuppRate_9Mbps:
5274 case eCsrSuppRate_12Mbps:
5275 case eCsrSuppRate_18Mbps:
5276 case eCsrSuppRate_24Mbps:
5277 case eCsrSuppRate_36Mbps:
5278 case eCsrSuppRate_48Mbps:
5279 case eCsrSuppRate_54Mbps:
5280 fSupported = TRUE;
5281 break;
5282 default:
5283 fSupported = FALSE;
5284 break;
5285 }
5286
5287 }
5288 else if( eCSR_CFG_DOT11_MODE_11B == pMac->roam.configParam.uCfgDot11Mode )
5289 {
5290 switch ( newRate )
5291 {
5292 case eCsrSuppRate_1Mbps:
5293 case eCsrSuppRate_2Mbps:
5294 case eCsrSuppRate_5_5Mbps:
5295 case eCsrSuppRate_11Mbps:
5296 fSupported = TRUE;
5297 break;
5298 default:
5299 fSupported = FALSE;
5300 break;
5301 }
5302 }
5303 else if ( !pMac->roam.configParam.ProprietaryRatesEnabled )
5304 {
5305
5306 switch ( newRate )
5307 {
5308 case eCsrSuppRate_1Mbps:
5309 case eCsrSuppRate_2Mbps:
5310 case eCsrSuppRate_5_5Mbps:
5311 case eCsrSuppRate_6Mbps:
5312 case eCsrSuppRate_9Mbps:
5313 case eCsrSuppRate_11Mbps:
5314 case eCsrSuppRate_12Mbps:
5315 case eCsrSuppRate_18Mbps:
5316 case eCsrSuppRate_24Mbps:
5317 case eCsrSuppRate_36Mbps:
5318 case eCsrSuppRate_48Mbps:
5319 case eCsrSuppRate_54Mbps:
5320 fSupported = TRUE;
5321 break;
5322 default:
5323 fSupported = FALSE;
5324 break;
5325 }
5326
5327 }
5328 else {
5329
5330 if ( eCsrSuppRate_1Mbps == newRate ||
5331 eCsrSuppRate_2Mbps == newRate ||
5332 eCsrSuppRate_5_5Mbps == newRate ||
5333 eCsrSuppRate_11Mbps == newRate )
5334 {
5335 fSupported = TRUE;
5336 }
5337 else {
5338 idx = 0x1;
5339
5340 switch ( newRate )
5341 {
5342 case eCsrSuppRate_6Mbps:
5343 fSupported = gPhyRatesSuppt[0][idx];
5344 break;
5345 case eCsrSuppRate_9Mbps:
5346 fSupported = gPhyRatesSuppt[1][idx];
5347 break;
5348 case eCsrSuppRate_12Mbps:
5349 fSupported = gPhyRatesSuppt[2][idx];
5350 break;
5351 case eCsrSuppRate_18Mbps:
5352 fSupported = gPhyRatesSuppt[3][idx];
5353 break;
5354 case eCsrSuppRate_20Mbps:
5355 fSupported = gPhyRatesSuppt[4][idx];
5356 break;
5357 case eCsrSuppRate_24Mbps:
5358 fSupported = gPhyRatesSuppt[5][idx];
5359 break;
5360 case eCsrSuppRate_36Mbps:
5361 fSupported = gPhyRatesSuppt[6][idx];
5362 break;
5363 case eCsrSuppRate_40Mbps:
5364 fSupported = gPhyRatesSuppt[7][idx];
5365 break;
5366 case eCsrSuppRate_42Mbps:
5367 fSupported = gPhyRatesSuppt[8][idx];
5368 break;
5369 case eCsrSuppRate_48Mbps:
5370 fSupported = gPhyRatesSuppt[9][idx];
5371 break;
5372 case eCsrSuppRate_54Mbps:
5373 fSupported = gPhyRatesSuppt[10][idx];
5374 break;
5375 case eCsrSuppRate_72Mbps:
5376 fSupported = gPhyRatesSuppt[11][idx];
5377 break;
5378 case eCsrSuppRate_80Mbps:
5379 fSupported = gPhyRatesSuppt[12][idx];
5380 break;
5381 case eCsrSuppRate_84Mbps:
5382 fSupported = gPhyRatesSuppt[13][idx];
5383 break;
5384 case eCsrSuppRate_96Mbps:
5385 fSupported = gPhyRatesSuppt[14][idx];
5386 break;
5387 case eCsrSuppRate_108Mbps:
5388 fSupported = gPhyRatesSuppt[15][idx];
5389 break;
5390 case eCsrSuppRate_120Mbps:
5391 fSupported = gPhyRatesSuppt[16][idx];
5392 break;
5393 case eCsrSuppRate_126Mbps:
5394 fSupported = gPhyRatesSuppt[17][idx];
5395 break;
5396 case eCsrSuppRate_144Mbps:
5397 fSupported = gPhyRatesSuppt[18][idx];
5398 break;
5399 case eCsrSuppRate_160Mbps:
5400 fSupported = gPhyRatesSuppt[19][idx];
5401 break;
5402 case eCsrSuppRate_168Mbps:
5403 fSupported = gPhyRatesSuppt[20][idx];
5404 break;
5405 case eCsrSuppRate_192Mbps:
5406 fSupported = gPhyRatesSuppt[21][idx];
5407 break;
5408 case eCsrSuppRate_216Mbps:
5409 fSupported = gPhyRatesSuppt[22][idx];
5410 break;
5411 case eCsrSuppRate_240Mbps:
5412 fSupported = gPhyRatesSuppt[23][idx];
5413 break;
5414 default:
5415 fSupported = FALSE;
5416 break;
5417 }
5418 }
5419 }
5420
5421 return fSupported;
5422}
5423
5424
5425
5426static tANI_BOOLEAN csrIsRateSetMatch( tpAniSirGlobal pMac,
5427 tDot11fIESuppRates *pBssSuppRates,
5428 tDot11fIEExtSuppRates *pBssExtSuppRates )
5429{
5430 tANI_BOOLEAN fMatch = TRUE;
5431 tANI_U32 i;
5432
5433
5434 // Validate that all of the Basic rates advertised in the Bss description are supported.
5435 if ( pBssSuppRates )
5436 {
5437 for( i = 0; i < pBssSuppRates->num_rates; i++ )
5438 {
5439 if ( CSR_IS_BASIC_RATE( pBssSuppRates->rates[ i ] ) )
5440 {
5441 if ( !csrIsAggregateRateSupported( pMac, pBssSuppRates->rates[ i ] ) )
5442 {
5443 fMatch = FALSE;
5444 break;
5445 }
5446 }
5447 }
5448 }
5449
5450 if ( fMatch && pBssExtSuppRates )
5451 {
5452 for( i = 0; i < pBssExtSuppRates->num_rates; i++ )
5453 {
5454 if ( CSR_IS_BASIC_RATE( pBssExtSuppRates->rates[ i ] ) )
5455 {
5456 if ( !csrIsAggregateRateSupported( pMac, pBssExtSuppRates->rates[ i ] ) )
5457 {
5458 fMatch = FALSE;
5459 break;
5460 }
5461 }
5462 }
5463 }
5464
5465 return( fMatch );
5466
5467}
5468
5469
5470//ppIes can be NULL. If caller want to get the *ppIes allocated by this function, pass in *ppIes = NULL
5471tANI_BOOLEAN csrMatchBSS( tHalHandle hHal, tSirBssDescription *pBssDesc, tCsrScanResultFilter *pFilter,
5472 eCsrAuthType *pNegAuth, eCsrEncryptionType *pNegUc, eCsrEncryptionType *pNegMc,
5473 tDot11fBeaconIEs **ppIes)
5474{
5475 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5476 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5477 tANI_U32 i;
5478 tDot11fBeaconIEs *pIes = NULL;
5479 tANI_U8 *pb;
5480
5481 do {
5482 if( ( NULL == ppIes ) || ( *ppIes ) == NULL )
5483 {
5484 //If no IEs passed in, get our own.
5485 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
5486 {
5487 break;
5488 }
5489 }
5490 else
5491 {
5492 //Save the one pass in for local use
5493 pIes = *ppIes;
5494 }
5495
5496 //Check if caller wants P2P
5497 fCheck = (!pFilter->p2pResult || pIes->P2PBeaconProbeRes.present);
5498 if(!fCheck) break;
5499
5500 if(pIes->SSID.present)
5501 {
5502 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
5503 {
5504 fCheck = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
5505 pIes->SSID.ssid,
5506 pIes->SSID.num_ssid, eANI_BOOLEAN_TRUE );
5507 if ( fCheck ) break;
5508 }
5509 if(!fCheck) break;
5510 }
5511 fCheck = eANI_BOOLEAN_TRUE;
5512 for(i = 0; i < pFilter->BSSIDs.numOfBSSIDs; i++)
5513 {
5514 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i], (tCsrBssid *)pBssDesc->bssId );
5515 if ( fCheck ) break;
5516
5517 if (pFilter->p2pResult && pIes->P2PBeaconProbeRes.present)
5518 {
5519 fCheck = csrIsBssidMatch( pMac, (tCsrBssid *)&pFilter->BSSIDs.bssid[i],
5520 (tCsrBssid *)pIes->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress );
5521
5522 if ( fCheck ) break;
5523 }
5524 }
5525 if(!fCheck) break;
5526
5527 fCheck = eANI_BOOLEAN_TRUE;
5528 for(i = 0; i < pFilter->ChannelInfo.numOfChannels; i++)
5529 {
5530 fCheck = csrIsChannelBandMatch( pMac, pFilter->ChannelInfo.ChannelList[i], pBssDesc );
5531 if ( fCheck ) break;
5532 }
5533 if(!fCheck)
5534 break;
5535#if defined WLAN_FEATURE_VOWIFI
5536 /* If this is for measurement filtering */
5537 if( pFilter->fMeasurement )
5538 {
5539 fRC = eANI_BOOLEAN_TRUE;
5540 break;
5541 }
5542#endif
5543 if ( !csrIsPhyModeMatch( pMac, pFilter->phyMode, pBssDesc, NULL, NULL, pIes ) ) break;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07005544 if ( (!pFilter->bWPSAssociation) && (!pFilter->bOSENAssociation) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 !csrIsSecurityMatch( pMac, &pFilter->authType, &pFilter->EncryptionType, &pFilter->mcEncryptionType,
5546 pBssDesc, pIes, pNegAuth, pNegUc, pNegMc ) ) break;
5547 if ( !csrIsCapabilitiesMatch( pMac, pFilter->BSSType, pBssDesc ) ) break;
5548 if ( !csrIsRateSetMatch( pMac, &pIes->SuppRates, &pIes->ExtSuppRates ) ) break;
5549 //Tush-QoS: validate first if asked for APSD or WMM association
5550 if ( (eCsrRoamWmmQbssOnly == pMac->roam.configParam.WMMSupportMode) &&
5551 !CSR_IS_QOS_BSS(pIes) )
5552 break;
5553 //Check country. check even when pb is NULL because we may want to make sure
5554 //AP has a country code in it if fEnforceCountryCodeMatch is set.
5555 pb = ( pFilter->countryCode[0] ) ? ( pFilter->countryCode) : NULL;
5556
5557 fCheck = csrMatchCountryCode( pMac, pb, pIes );
5558 if(!fCheck)
5559 break;
5560
5561#ifdef WLAN_FEATURE_VOWIFI_11R
5562 if (pFilter->MDID.mdiePresent)
5563 {
5564 if (pBssDesc->mdiePresent)
5565 {
5566 if (pFilter->MDID.mobilityDomain != (pBssDesc->mdie[1] << 8 | pBssDesc->mdie[0]))
5567 break;
5568 }
5569 else
5570 break;
5571 }
5572#endif
5573 fRC = eANI_BOOLEAN_TRUE;
5574
5575 } while( 0 );
5576 if( ppIes )
5577 {
5578 *ppIes = pIes;
5579 }
5580 else if( pIes )
5581 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305582 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 }
5584
5585 return( fRC );
5586}
5587
5588tANI_BOOLEAN csrMatchConnectedBSSSecurity( tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile,
5589 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
5590{
5591 tCsrEncryptionList ucEncryptionList, mcEncryptionList;
5592 tCsrAuthList authList;
5593
5594 ucEncryptionList.numEntries = 1;
5595 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType;
5596
5597 mcEncryptionList.numEntries = 1;
5598 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType;
5599
5600 authList.numEntries = 1;
5601 authList.authType[0] = pProfile->AuthType;
5602
5603 return( csrIsSecurityMatch( pMac, &authList, &ucEncryptionList, &mcEncryptionList, pBssDesc, pIes, NULL, NULL, NULL ));
5604
5605}
5606
5607
5608tANI_BOOLEAN csrMatchBSSToConnectProfile( tHalHandle hHal, tCsrRoamConnectedProfile *pProfile,
5609 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
5610{
5611 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5612 tANI_BOOLEAN fRC = eANI_BOOLEAN_FALSE, fCheck;
5613 tDot11fBeaconIEs *pIesLocal = pIes;
5614
5615 do {
5616 if( !pIes )
5617 {
5618 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)))
5619 {
5620 break;
5621 }
5622 }
5623 fCheck = eANI_BOOLEAN_TRUE;
5624 if(pIesLocal->SSID.present)
5625 {
5626 tANI_BOOLEAN fCheckSsid = eANI_BOOLEAN_FALSE;
5627 if(pProfile->SSID.length)
5628 {
5629 fCheckSsid = eANI_BOOLEAN_TRUE;
5630 }
5631 fCheck = csrIsSsidMatch( pMac, pProfile->SSID.ssId, pProfile->SSID.length,
5632 pIesLocal->SSID.ssid, pIesLocal->SSID.num_ssid, fCheckSsid );
5633 if(!fCheck) break;
5634 }
5635 if ( !csrMatchConnectedBSSSecurity( pMac, pProfile, pBssDesc, pIesLocal) ) break;
5636 if ( !csrIsCapabilitiesMatch( pMac, pProfile->BSSType, pBssDesc ) ) break;
5637 if ( !csrIsRateSetMatch( pMac, &pIesLocal->SuppRates, &pIesLocal->ExtSuppRates ) ) break;
5638 fCheck = csrIsChannelBandMatch( pMac, pProfile->operationChannel, pBssDesc );
5639 if(!fCheck)
5640 break;
5641
5642 fRC = eANI_BOOLEAN_TRUE;
5643
5644 } while( 0 );
5645
5646 if( !pIes && pIesLocal )
5647 {
5648 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305649 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 }
5651
5652 return( fRC );
5653}
5654
5655
5656
5657tANI_BOOLEAN csrRatesIsDot11RateSupported( tHalHandle hHal, tANI_U8 rate )
5658{
5659 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5660 tANI_U16 n = BITS_OFF( rate, CSR_DOT11_BASIC_RATE_MASK );
5661
5662 return csrIsAggregateRateSupported( pMac, n );
5663}
5664
5665
5666tANI_U16 csrRatesMacPropToDot11( tANI_U16 Rate )
5667{
5668 tANI_U16 ConvertedRate = Rate;
5669
5670 switch( Rate )
5671 {
5672 case SIR_MAC_RATE_1:
5673 ConvertedRate = 2;
5674 break;
5675 case SIR_MAC_RATE_2:
5676 ConvertedRate = 4;
5677 break;
5678 case SIR_MAC_RATE_5_5:
5679 ConvertedRate = 11;
5680 break;
5681 case SIR_MAC_RATE_11:
5682 ConvertedRate = 22;
5683 break;
5684
5685 case SIR_MAC_RATE_6:
5686 ConvertedRate = 12;
5687 break;
5688 case SIR_MAC_RATE_9:
5689 ConvertedRate = 18;
5690 break;
5691 case SIR_MAC_RATE_12:
5692 ConvertedRate = 24;
5693 break;
5694 case SIR_MAC_RATE_18:
5695 ConvertedRate = 36;
5696 break;
5697 case SIR_MAC_RATE_24:
5698 ConvertedRate = 48;
5699 break;
5700 case SIR_MAC_RATE_36:
5701 ConvertedRate = 72;
5702 break;
5703 case SIR_MAC_RATE_42:
5704 ConvertedRate = 84;
5705 break;
5706 case SIR_MAC_RATE_48:
5707 ConvertedRate = 96;
5708 break;
5709 case SIR_MAC_RATE_54:
5710 ConvertedRate = 108;
5711 break;
5712
5713 case SIR_MAC_RATE_72:
5714 ConvertedRate = 144;
5715 break;
5716 case SIR_MAC_RATE_84:
5717 ConvertedRate = 168;
5718 break;
5719 case SIR_MAC_RATE_96:
5720 ConvertedRate = 192;
5721 break;
5722 case SIR_MAC_RATE_108:
5723 ConvertedRate = 216;
5724 break;
5725 case SIR_MAC_RATE_126:
5726 ConvertedRate = 252;
5727 break;
5728 case SIR_MAC_RATE_144:
5729 ConvertedRate = 288;
5730 break;
5731 case SIR_MAC_RATE_168:
5732 ConvertedRate = 336;
5733 break;
5734 case SIR_MAC_RATE_192:
5735 ConvertedRate = 384;
5736 break;
5737 case SIR_MAC_RATE_216:
5738 ConvertedRate = 432;
5739 break;
5740 case SIR_MAC_RATE_240:
5741 ConvertedRate = 480;
5742 break;
5743
5744 case 0xff:
5745 ConvertedRate = 0;
5746 break;
5747 }
5748
5749 return ConvertedRate;
5750}
5751
5752
5753tANI_U16 csrRatesFindBestRate( tSirMacRateSet *pSuppRates, tSirMacRateSet *pExtRates, tSirMacPropRateSet *pPropRates )
5754{
5755 tANI_U8 i;
5756 tANI_U16 nBest;
5757
5758 nBest = pSuppRates->rate[ 0 ] & ( ~CSR_DOT11_BASIC_RATE_MASK );
5759
5760 if(pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX)
5761 {
5762 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX;
5763 }
5764
5765 for ( i = 1U; i < pSuppRates->numRates; ++i )
5766 {
5767 nBest = (tANI_U16)CSR_MAX( nBest, pSuppRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5768 }
5769
5770 if ( NULL != pExtRates )
5771 {
5772 for ( i = 0U; i < pExtRates->numRates; ++i )
5773 {
5774 nBest = (tANI_U16)CSR_MAX( nBest, pExtRates->rate[ i ] & ( ~CSR_DOT11_BASIC_RATE_MASK ) );
5775 }
5776 }
5777
5778 if ( NULL != pPropRates )
5779 {
5780 for ( i = 0U; i < pPropRates->numPropRates; ++i )
5781 {
5782 nBest = (tANI_U16)CSR_MAX( nBest, csrRatesMacPropToDot11( pPropRates->propRate[ i ] ) );
5783 }
5784 }
5785
5786 return nBest;
5787}
5788
5789
5790void csrReleaseProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile)
5791{
5792 if(pProfile)
5793 {
5794 if(pProfile->BSSIDs.bssid)
5795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305796 vos_mem_free(pProfile->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 pProfile->BSSIDs.bssid = NULL;
5798 }
5799 if(pProfile->SSIDs.SSIDList)
5800 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305801 vos_mem_free(pProfile->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 pProfile->SSIDs.SSIDList = NULL;
5803 }
5804 if(pProfile->pWPAReqIE)
5805 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305806 vos_mem_free(pProfile->pWPAReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 pProfile->pWPAReqIE = NULL;
5808 }
5809 if(pProfile->pRSNReqIE)
5810 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305811 vos_mem_free(pProfile->pRSNReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 pProfile->pRSNReqIE = NULL;
5813 }
5814#ifdef FEATURE_WLAN_WAPI
5815 if(pProfile->pWAPIReqIE)
5816 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305817 vos_mem_free(pProfile->pWAPIReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 pProfile->pWAPIReqIE = NULL;
5819 }
5820#endif /* FEATURE_WLAN_WAPI */
5821
Agarwal Ashish4f616132013-12-30 23:32:50 +05305822 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05305824 memset(pProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH+2);
5825 pProfile->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 }
5827
5828 if(pProfile->pAddIEAssoc)
5829 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305830 vos_mem_free(pProfile->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 pProfile->pAddIEAssoc = NULL;
5832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 if(pProfile->ChannelInfo.ChannelList)
5834 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305835 vos_mem_free(pProfile->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 pProfile->ChannelInfo.ChannelList = NULL;
5837 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305838 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 }
5840}
5841
5842void csrFreeScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
5843{
5844 if(pScanFilter->BSSIDs.bssid)
5845 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305846 vos_mem_free(pScanFilter->BSSIDs.bssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 pScanFilter->BSSIDs.bssid = NULL;
5848 }
5849 if(pScanFilter->ChannelInfo.ChannelList)
5850 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305851 vos_mem_free(pScanFilter->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 pScanFilter->ChannelInfo.ChannelList = NULL;
5853 }
5854 if(pScanFilter->SSIDs.SSIDList)
5855 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305856 vos_mem_free(pScanFilter->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 pScanFilter->SSIDs.SSIDList = NULL;
5858 }
5859}
5860
5861
5862void csrFreeRoamProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
5863{
5864 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
5865
5866 if(pSession->pCurRoamProfile)
5867 {
5868 csrReleaseProfile(pMac, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05305869 vos_mem_free(pSession->pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 pSession->pCurRoamProfile = NULL;
5871 }
5872}
5873
5874
5875void csrFreeConnectBssDesc(tpAniSirGlobal pMac, tANI_U32 sessionId)
5876{
5877 tCsrRoamSession *pSession = &pMac->roam.roamSession[sessionId];
5878
5879 if(pSession->pConnectBssDesc)
5880 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305881 vos_mem_free(pSession->pConnectBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 pSession->pConnectBssDesc = NULL;
5883 }
5884}
5885
5886
5887
5888tSirResultCodes csrGetDisassocRspStatusCode( tSirSmeDisassocRsp *pSmeDisassocRsp )
5889{
5890 tANI_U8 *pBuffer = (tANI_U8 *)pSmeDisassocRsp;
5891 tANI_U32 ret;
5892
5893 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tSirMacAddr));
5894 //tSirResultCodes is an enum, assuming is 32bit
5895 //If we cannot make this assumption, use copymemory
5896 pal_get_U32( pBuffer, &ret );
5897
5898 return( ( tSirResultCodes )ret );
5899}
5900
5901
5902tSirResultCodes csrGetDeAuthRspStatusCode( tSirSmeDeauthRsp *pSmeRsp )
5903{
5904 tANI_U8 *pBuffer = (tANI_U8 *)pSmeRsp;
5905 tANI_U32 ret;
5906
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005907 pBuffer += (sizeof(tANI_U16) + sizeof(tANI_U16) + sizeof(tANI_U8) + sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 //tSirResultCodes is an enum, assuming is 32bit
5909 //If we cannot make this assumption, use copymemory
5910 pal_get_U32( pBuffer, &ret );
5911
5912 return( ( tSirResultCodes )ret );
5913}
5914
5915#if 0
5916tSirScanType csrGetScanType(tANI_U8 chnId, eRegDomainId domainId, tANI_U8 *countryCode)
5917{
5918 tSirScanType scanType = eSIR_PASSIVE_SCAN;
5919 tANI_U8 cc = 0;
5920
5921 while (cc++ < gCsrDomainChnInfo[domainId].numChannels)
5922 {
5923 if(chnId == gCsrDomainChnInfo[domainId].chnInfo[cc].chnId)
5924 {
5925 scanType = gCsrDomainChnInfo[domainId].chnInfo[cc].scanType;
5926 break;
5927 }
5928 }
5929
5930 return (scanType);
5931}
5932#endif
5933
5934tSirScanType csrGetScanType(tpAniSirGlobal pMac, tANI_U8 chnId)
5935{
5936 tSirScanType scanType = eSIR_PASSIVE_SCAN;
5937 eNVChannelEnabledType channelEnabledType;
5938
5939 channelEnabledType = vos_nv_getChannelEnabledState(chnId);
5940 if( NV_CHANNEL_ENABLE == channelEnabledType)
5941 {
5942 scanType = eSIR_ACTIVE_SCAN;
5943 }
5944 return (scanType);
5945}
5946
5947
5948tANI_U8 csrToUpper( tANI_U8 ch )
5949{
5950 tANI_U8 chOut;
5951
5952 if ( ch >= 'a' && ch <= 'z' )
5953 {
5954 chOut = ch - 'a' + 'A';
5955 }
5956 else
5957 {
5958 chOut = ch;
5959 }
5960 return( chOut );
5961}
5962
5963
5964tSirBssType csrTranslateBsstypeToMacType(eCsrRoamBssType csrtype)
5965{
5966 tSirBssType ret;
5967
5968 switch(csrtype)
5969 {
5970 case eCSR_BSS_TYPE_INFRASTRUCTURE:
5971 ret = eSIR_INFRASTRUCTURE_MODE;
5972 break;
5973 case eCSR_BSS_TYPE_IBSS:
5974 case eCSR_BSS_TYPE_START_IBSS:
5975 ret = eSIR_IBSS_MODE;
5976 break;
5977 case eCSR_BSS_TYPE_WDS_AP:
5978 ret = eSIR_BTAMP_AP_MODE;
5979 break;
5980 case eCSR_BSS_TYPE_WDS_STA:
5981 ret = eSIR_BTAMP_STA_MODE;
5982 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 case eCSR_BSS_TYPE_INFRA_AP:
5984 ret = eSIR_INFRA_AP_MODE;
5985 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 case eCSR_BSS_TYPE_ANY:
5987 default:
5988 ret = eSIR_AUTO_MODE;
5989 break;
5990 }
5991
5992 return (ret);
5993}
5994
5995
5996//This function use the parameters to decide the CFG value.
5997//CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG
5998//So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value
Jeff Johnson295189b2012-06-20 16:38:30 -07005999eCsrCfgDot11Mode csrGetCfgDot11ModeFromCsrPhyMode(tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tANI_BOOLEAN fProprietary)
Jeff Johnson295189b2012-06-20 16:38:30 -07006000{
6001 tANI_U32 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6002
6003 switch(phyMode)
6004 {
6005 case eCSR_DOT11_MODE_11a:
6006 case eCSR_DOT11_MODE_11a_ONLY:
6007 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
6008 break;
6009 case eCSR_DOT11_MODE_11b:
6010 case eCSR_DOT11_MODE_11b_ONLY:
6011 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
6012 break;
6013 case eCSR_DOT11_MODE_11g:
6014 case eCSR_DOT11_MODE_11g_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 if(pProfile && (CSR_IS_INFRA_AP(pProfile)) && (phyMode == eCSR_DOT11_MODE_11g_ONLY))
6016 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY;
6017 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
6019 break;
6020 case eCSR_DOT11_MODE_11n:
6021 if(fProprietary)
6022 {
6023 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6024 }
6025 else
6026 {
6027 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6028 }
6029 break;
6030 case eCSR_DOT11_MODE_11n_ONLY:
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 if(pProfile && CSR_IS_INFRA_AP(pProfile))
6032 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY;
6033 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6035 break;
6036 case eCSR_DOT11_MODE_TAURUS:
6037 cfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
6038 break;
6039 case eCSR_DOT11_MODE_abg:
6040 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG;
6041 break;
6042 case eCSR_DOT11_MODE_AUTO:
6043 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
6044 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07006045
6046#ifdef WLAN_FEATURE_11AC
6047 case eCSR_DOT11_MODE_11ac:
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006048 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6049 {
6050 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
6051 }
6052 else
6053 {
Ravi Joshia96ceb42013-05-20 18:52:39 -07006054 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07006055 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006056 break;
6057 case eCSR_DOT11_MODE_11ac_ONLY:
Ravi Joshia96ceb42013-05-20 18:52:39 -07006058 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
6059 {
6060 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
6061 }
6062 else
6063 {
6064 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
6065 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006066 break;
6067#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 default:
6069 //No need to assign anything here
6070 break;
6071 }
6072
6073 return (cfgDot11Mode);
6074}
6075
6076
6077eHalStatus csrSetRegulatoryDomain(tpAniSirGlobal pMac, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
6078{
6079 eHalStatus status = eHAL_STATUS_SUCCESS;
6080 tANI_BOOLEAN fRestart;
6081
6082 if(pMac->scan.domainIdCurrent == domainId)
6083 {
6084 //no change
6085 fRestart = eANI_BOOLEAN_FALSE;
6086 }
6087 else if( !pMac->roam.configParam.fEnforceDefaultDomain )
6088 {
6089 pMac->scan.domainIdCurrent = domainId;
6090 fRestart = eANI_BOOLEAN_TRUE;
6091 }
6092 else
6093 {
6094 //We cannot change the domain
6095 status = eHAL_STATUS_CSR_WRONG_STATE;
6096 fRestart = eANI_BOOLEAN_FALSE;
6097 }
6098 if(pfRestartNeeded)
6099 {
6100 *pfRestartNeeded = fRestart;
6101 }
6102
6103 return (status);
6104}
6105
6106
6107v_REGDOMAIN_t csrGetCurrentRegulatoryDomain(tpAniSirGlobal pMac)
6108{
6109 return (pMac->scan.domainIdCurrent);
6110}
6111
Jeff Johnson295189b2012-06-20 16:38:30 -07006112
Kiet Lam6c583332013-10-14 05:37:09 +05306113eHalStatus csrGetRegulatoryDomainForCountry
6114(
6115tpAniSirGlobal pMac,
6116tANI_U8 *pCountry,
6117v_REGDOMAIN_t *pDomainId,
6118v_CountryInfoSource_t source
6119)
Jeff Johnson295189b2012-06-20 16:38:30 -07006120{
6121 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6122 VOS_STATUS vosStatus;
6123 v_COUNTRYCODE_t countryCode;
6124 v_REGDOMAIN_t domainId;
6125
6126 if(pCountry)
6127 {
6128 countryCode[0] = pCountry[0];
6129 countryCode[1] = pCountry[1];
Kiet Lam6c583332013-10-14 05:37:09 +05306130 vosStatus = vos_nv_getRegDomainFromCountryCode(&domainId,
6131 countryCode,
6132 source);
6133
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 if( VOS_IS_STATUS_SUCCESS(vosStatus) )
6135 {
6136 if( pDomainId )
6137 {
6138 *pDomainId = domainId;
6139 }
6140 status = eHAL_STATUS_SUCCESS;
6141 }
6142 else
6143 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05306144 smsLog(pMac, LOGW, FL(" Couldn't find domain for country code %c%c"), pCountry[0], pCountry[1]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 status = eHAL_STATUS_INVALID_PARAMETER;
6146 }
6147 }
6148
6149 return (status);
6150}
6151
6152//To check whether a country code matches the one in the IE
6153//Only check the first two characters, ignoring in/outdoor
6154//pCountry -- caller allocated buffer contain the country code that is checking against
6155//the one in pIes. It can be NULL.
6156//caller must provide pIes, it cannot be NULL
6157//This function always return TRUE if 11d support is not turned on.
6158tANI_BOOLEAN csrMatchCountryCode( tpAniSirGlobal pMac, tANI_U8 *pCountry, tDot11fBeaconIEs *pIes )
6159{
6160 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson43971f52012-07-17 12:26:56 -07006161 v_REGDOMAIN_t domainId = REGDOMAIN_COUNT; //This is init to invalid value
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 eHalStatus status;
6163
6164 do
6165 {
6166 if( !csrIs11dSupported( pMac) )
6167 {
6168 break;
6169 }
6170 if( !pIes )
6171 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006172 smsLog(pMac, LOGE, FL(" No IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 break;
6174 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006175 if( pMac->roam.configParam.fEnforceDefaultDomain ||
6176 pMac->roam.configParam.fEnforceCountryCodeMatch )
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006178 //Make sure this country is recognizable
6179 if( pIes->Country.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 {
Kiet Lam6c583332013-10-14 05:37:09 +05306181 status = csrGetRegulatoryDomainForCountry(pMac,
6182 pIes->Country.country,
6183 &domainId, COUNTRY_QUERY);
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006184 if( !HAL_STATUS_SUCCESS( status ) )
6185 {
Kiet Lam6c583332013-10-14 05:37:09 +05306186 status = csrGetRegulatoryDomainForCountry(pMac,
6187 pMac->scan.countryCode11d,
6188 (v_REGDOMAIN_t *) &domainId,
6189 COUNTRY_QUERY);
Gowri Deepthiff9adf92012-12-13 15:09:56 -08006190 if( !HAL_STATUS_SUCCESS( status ) )
6191 {
6192 fRet = eANI_BOOLEAN_FALSE;
6193 break;
6194 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006197 //check whether it is needed to enforce to the default regulatory domain first
6198 if( pMac->roam.configParam.fEnforceDefaultDomain )
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 {
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006200 if( domainId != pMac->scan.domainIdCurrent )
6201 {
6202 fRet = eANI_BOOLEAN_FALSE;
6203 break;
6204 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 }
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006206 if( pMac->roam.configParam.fEnforceCountryCodeMatch )
6207 {
Jeff Johnson43971f52012-07-17 12:26:56 -07006208 if( domainId >= REGDOMAIN_COUNT )
Madan Mohan Koyyalamudi42af1782012-10-21 12:13:23 -07006209 {
6210 fRet = eANI_BOOLEAN_FALSE;
6211 break;
6212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 }
6214 }
6215 if( pCountry )
6216 {
6217 tANI_U32 i;
6218
6219 if( !pIes->Country.present )
6220 {
6221 fRet = eANI_BOOLEAN_FALSE;
6222 break;
6223 }
6224 // Convert the CountryCode characters to upper
6225 for ( i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++ )
6226 {
6227 pCountry[i] = csrToUpper( pCountry[i] );
6228 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306229 if (!vos_mem_compare(pIes->Country.country, pCountry,
6230 WNI_CFG_COUNTRY_CODE_LEN - 1))
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 {
6232 fRet = eANI_BOOLEAN_FALSE;
6233 break;
6234 }
6235 }
6236 } while(0);
6237
6238 return (fRet);
6239}
6240
6241#if 0
6242eHalStatus csrSetCountryDomainMapping(tpAniSirGlobal pMac, tCsrCountryDomainMapping *pCountryDomainMapping)
6243{
6244 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6245 tANI_U32 i, j;
6246 tANI_BOOLEAN fDomainChanged = eANI_BOOLEAN_FALSE;
6247 tANI_U8 countryCode[WNI_CFG_COUNTRY_CODE_LEN];
6248
6249 i = WNI_CFG_COUNTRY_CODE_LEN;
6250 //Get the currently used country code
6251 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, countryCode, &i);
6252 if(HAL_STATUS_SUCCESS(status))
6253 {
6254 if(pCountryDomainMapping && pCountryDomainMapping->numEntry)
6255 {
6256 for(i = 0; i < pCountryDomainMapping->numEntry; i++)
6257 {
6258 for(j = 0; j < eCSR_NUM_COUNTRY_INDEX; j++)
6259 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306260 if (vos_mem_compare(gCsrCountryInfo[j].countryCode,
6261 pCountryDomainMapping->pCountryInfo[i].countryCode,
6262 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 {
6264 if(gCsrCountryInfo[j].domainId != pCountryDomainMapping->pCountryInfo[i].domainId)
6265 {
6266 gCsrCountryInfo[j].domainId = pCountryDomainMapping->pCountryInfo[i].domainId;
6267 //Check whether it matches the currently used country code
6268 //If matching, need to update base on the new domain setting.
Kiet Lam64c1b492013-07-12 13:56:44 +05306269 if (vos_mem_compare(countryCode,
6270 pCountryDomainMapping->pCountryInfo[i].countryCode,
6271 2))
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 {
6273 fDomainChanged = eANI_BOOLEAN_TRUE;
6274 }
6275 }
6276 break;
6277 }
6278 }
6279 }
6280 status = eHAL_STATUS_SUCCESS;
6281 if(fDomainChanged)
6282 {
6283 tCsrChannel *pChannelList;
6284
6285 if(pMac->scan.f11dInfoApplied)
6286 {
6287 //11d info already applied. Let's reapply with the new domain setting
6288 if(pMac->scan.channels11d.numChannels)
6289 {
6290 pChannelList = &pMac->scan.channels11d;
6291 }
6292 else
6293 {
6294 pChannelList = &pMac->scan.base20MHzChannels;
6295 }
6296 }
6297 else
6298 {
6299 //no 11d so we use the base channelist from EEPROM
6300 pChannelList = &pMac->scan.base20MHzChannels;
6301 }
6302 //set the new domain's scan requirement to CFG
6303 csrSetCfgScanControlList(pMac, countryCode, pChannelList);
6304 }
6305 }
6306 }
6307
6308 return (status);
6309}
6310
6311eHalStatus csrSetDomainScanSetting(tpAniSirGlobal pMac, tCsrDomainFreqInfo *pDomainFreqInfo)
6312{
6313 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6314 tANI_U32 i, j;
6315 tANI_U16 freq;
6316
6317 if(pDomainFreqInfo && pDomainFreqInfo->numEntry && (pDomainFreqInfo->domainId < NUM_REG_DOMAINS))
6318 {
6319 tCsrDomainChnInfo *pDomainChnInfo = &gCsrDomainChnInfo[pDomainFreqInfo->domainId];
6320
6321 for(j = 0; j < pDomainChnInfo->numChannels; j++)
6322 {
6323 if(HAL_STATUS_SUCCESS(halPhyChIdToFreqConversion(pDomainChnInfo->chnInfo[j].chnId, &freq)))
6324 {
6325 for(i = 0; i < pDomainFreqInfo->numEntry; i++)
6326 {
6327 if((pDomainFreqInfo->pCsrScanFreqInfo[i].nStartFreq <= freq) &&
6328 (freq <= pDomainFreqInfo->pCsrScanFreqInfo[i].nEndFreq))
6329 {
6330 pDomainChnInfo->chnInfo[j].scanType = pDomainFreqInfo->pCsrScanFreqInfo[i].scanType;
6331 break;
6332 }
6333 }
6334 }
6335 else
6336 {
6337 smsLog(pMac, LOGW, " Failed to get frequency of channel %d", pDomainChnInfo->chnInfo[j].chnId);
6338 }
6339 }
6340 status = eHAL_STATUS_SUCCESS;
6341 }
6342
6343 return (status);
6344}
6345#endif
6346
6347eHalStatus csrGetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6348 tCsrRoamModifyProfileFields *pModifyProfileFields)
6349{
6350
6351 if(!pModifyProfileFields)
6352 {
6353 return eHAL_STATUS_FAILURE;
6354 }
6355
Kiet Lam64c1b492013-07-12 13:56:44 +05306356 vos_mem_copy(pModifyProfileFields,
6357 &pMac->roam.roamSession[sessionId].connectedProfile.modifyProfileFields,
6358 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006359
6360 return eHAL_STATUS_SUCCESS;
6361}
6362
6363eHalStatus csrSetModifyProfileFields(tpAniSirGlobal pMac, tANI_U32 sessionId,
6364 tCsrRoamModifyProfileFields *pModifyProfileFields)
6365{
6366 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6367
Kiet Lam64c1b492013-07-12 13:56:44 +05306368 vos_mem_copy(&pSession->connectedProfile.modifyProfileFields,
6369 pModifyProfileFields,
6370 sizeof(tCsrRoamModifyProfileFields));
Jeff Johnson295189b2012-06-20 16:38:30 -07006371
6372 return eHAL_STATUS_SUCCESS;
6373}
6374
6375
6376#if 0
6377/* ---------------------------------------------------------------------------
6378 \fn csrGetSupportedCountryCode
6379 \brief this function is to get a list of the country code current being supported
6380 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6381 this has the country code list. 3 bytes for each country code. This may be NULL if
6382 caller wants to know the needed bytes.
6383 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6384 this contains the length of the data in pBuf
6385 \return eHalStatus
6386 -------------------------------------------------------------------------------*/
6387eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6388{
6389 tANI_U32 numOfCountry = sizeof( gCsrCountryInfo ) / sizeof( gCsrCountryInfo[0] );
6390 tANI_U32 numBytes = 0;
6391 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6392
6393 if( pbLen )
6394 {
6395 numBytes = *pbLen;
6396 //Consider it ok, at least we can return the number of bytes needed;
6397 *pbLen = numOfCountry * WNI_CFG_COUNTRY_CODE_LEN;
6398 status = eHAL_STATUS_SUCCESS;
6399 if( pBuf && ( numBytes >= *pbLen ) )
6400 {
6401 //The ugly part starts.
6402 //We may need to alter the data structure and find a way to make this faster.
6403 tANI_U32 i;
6404
Kiet Lam64c1b492013-07-12 13:56:44 +05306405 for ( i = 0; i < numOfCountry; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306407 vos_mem_copy(pBuf + ( i * WNI_CFG_COUNTRY_CODE_LEN ),
6408 gCsrCountryInfo[i].countryCode,
6409 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 }
6411 }
6412 }
6413
6414 return ( status );
6415}
6416#endif
6417
6418/* ---------------------------------------------------------------------------
6419 \fn csrGetSupportedCountryCode
6420 \brief this function is to get a list of the country code current being supported
6421 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
6422 this has the country code list. 3 bytes for each country code. This may be NULL if
6423 caller wants to know the needed bytes.
6424 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
6425 this contains the length of the data in pBuf
6426 \return eHalStatus
6427 -------------------------------------------------------------------------------*/
6428eHalStatus csrGetSupportedCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U32 *pbLen)
6429{
6430 eHalStatus status = eHAL_STATUS_SUCCESS;
6431 VOS_STATUS vosStatus;
6432 v_SIZE_t size = (v_SIZE_t)*pbLen;
6433
6434 vosStatus = vos_nv_getSupportedCountryCode( pBuf, &size, 1 );
6435 //eiter way, return the value back
6436 *pbLen = (tANI_U32)size;
6437
6438 //If pBuf is NULL, caller just want to get the size, consider it success
6439 if(pBuf)
6440 {
6441 if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
6442 {
6443 tANI_U32 i, n = *pbLen / 3;
6444
6445 for( i = 0; i < n; i++ )
6446 {
6447 pBuf[i*3 + 2] = ' ';
6448 }
6449 }
6450 else
6451 {
6452 status = eHAL_STATUS_FAILURE;
6453 }
6454 }
6455
6456 return (status);
6457}
6458
6459
6460
6461//Upper layer to get the list of the base channels to scan for passively 11d info from csr
6462eHalStatus csrScanGetBaseChannels( tpAniSirGlobal pMac, tCsrChannelInfo * pChannelInfo )
6463{
6464 eHalStatus status = eHAL_STATUS_FAILURE;
6465
6466 do
6467 {
6468
6469 if(!pMac->scan.baseChannels.numChannels || !pChannelInfo)
6470 {
6471 break;
6472 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306473 pChannelInfo->ChannelList = vos_mem_malloc(pMac->scan.baseChannels.numChannels);
6474 if ( NULL == pChannelInfo->ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006476 smsLog( pMac, LOGE, FL("csrScanGetBaseChannels: fail to allocate memory") );
Kiet Lam64c1b492013-07-12 13:56:44 +05306477 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306479 vos_mem_copy(pChannelInfo->ChannelList,
6480 pMac->scan.baseChannels.channelList,
6481 pMac->scan.baseChannels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006482 pChannelInfo->numOfChannels = pMac->scan.baseChannels.numChannels;
6483
6484 }while(0);
6485
6486 return ( status );
6487}
6488
6489
6490tANI_BOOLEAN csrIsSetKeyAllowed(tpAniSirGlobal pMac, tANI_U32 sessionId)
6491{
6492 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 tCsrRoamSession *pSession;
6494
6495 pSession =CSR_GET_SESSION(pMac, sessionId);
6496
6497 /*This condition is not working for infra state. When infra is in not-connected state
6498 * the pSession->pCurRoamProfile is NULL. And this function returns TRUE, that is incorrect.
6499 * Since SAP requires to set key without any BSS started, it needs this condition to be met.
6500 * In other words, this function is useless.
6501 * The current work-around is to process setcontext_rsp and removekey_rsp no matter what the
6502 * state is.
6503 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006504 smsLog( pMac, LOG2, FL(" is not what it intends to. Must be revisit or removed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006505 if( (NULL == pSession) ||
6506 ( csrIsConnStateDisconnected( pMac, sessionId ) &&
6507 (pSession->pCurRoamProfile != NULL) &&
6508 (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) )
6509 )
6510 {
6511 fRet = eANI_BOOLEAN_FALSE;
6512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006513
6514 return ( fRet );
6515}
6516
6517//no need to acquire lock for this basic function
6518tANI_U16 sme_ChnToFreq(tANI_U8 chanNum)
6519{
6520 int i;
6521
6522 for (i = 0; i < NUM_RF_CHANNELS; i++)
6523 {
6524 if (rfChannels[i].channelNum == chanNum)
6525 {
6526 return rfChannels[i].targetFreq;
6527 }
6528 }
6529
6530 return (0);
6531}
6532
6533/* Disconnect all active sessions by sending disassoc. This is mainly used to disconnect the remaining session when we
6534 * transition from concurrent sessions to a single session. The use case is Infra STA and wifi direct multiple sessions are up and
6535 * P2P session is removed. The Infra STA session remains and should resume BMPS if BMPS is enabled by default. However, there
6536 * are some issues seen with BMPS resume during this transition and this is a workaround which will allow the Infra STA session to
6537 * disconnect and auto connect back and enter BMPS this giving the same effect as resuming BMPS
6538 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006539
6540//Remove this code once SLM_Sessionization is supported
6541//BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnson295189b2012-06-20 16:38:30 -07006542void csrDisconnectAllActiveSessions(tpAniSirGlobal pMac)
6543{
6544 tANI_U8 i;
6545
6546 /* Disconnect all the active sessions */
6547 for (i=0; i<CSR_ROAM_SESSION_MAX; i++)
6548 {
6549 if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
6550 {
6551 csrRoamDisconnectInternal(pMac, i, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6552 }
6553 }
6554}
Mohit Khanna349bc392012-09-11 17:24:52 -07006555
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006556#ifdef FEATURE_WLAN_LFR
6557tANI_BOOLEAN csrIsChannelPresentInList(
6558 tANI_U8 *pChannelList,
6559 int numChannels,
6560 tANI_U8 channel
6561 )
6562{
6563 int i = 0;
6564
6565 // Check for NULL pointer
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08006566 if (!pChannelList || (numChannels == 0))
6567 {
6568 return FALSE;
6569 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07006570
6571 // Look for the channel in the list
6572 for (i = 0; i < numChannels; i++)
6573 {
6574 if (pChannelList[i] == channel)
6575 return TRUE;
6576 }
6577
6578 return FALSE;
6579}
6580
6581VOS_STATUS csrAddToChannelListFront(
6582 tANI_U8 *pChannelList,
6583 int numChannels,
6584 tANI_U8 channel
6585 )
6586{
6587 int i = 0;
6588
6589 // Check for NULL pointer
6590 if (!pChannelList) return eHAL_STATUS_E_NULL_VALUE;
6591
6592 // Make room for the addition. (Start moving from the back.)
6593 for (i = numChannels; i > 0; i--)
6594 {
6595 pChannelList[i] = pChannelList[i-1];
6596 }
6597
6598 // Now add the NEW channel...at the front
6599 pChannelList[0] = channel;
6600
6601 return eHAL_STATUS_SUCCESS;
6602}
6603#endif
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306604const char * sme_requestTypetoString(const v_U8_t requestType)
6605{
6606 switch (requestType)
6607 {
6608 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_11D_SCAN );
6609 CASE_RETURN_STRING( eCSR_SCAN_REQUEST_FULL_SCAN );
6610 CASE_RETURN_STRING( eCSR_SCAN_IDLE_MODE_SCAN );
6611 CASE_RETURN_STRING( eCSR_SCAN_HO_BG_SCAN );
6612 CASE_RETURN_STRING( eCSR_SCAN_HO_PROBE_SCAN );
6613 CASE_RETURN_STRING( eCSR_SCAN_HO_NT_BG_SCAN );
6614 CASE_RETURN_STRING( eCSR_SCAN_P2P_DISCOVERY );
6615 CASE_RETURN_STRING( eCSR_SCAN_SOFTAP_CHANNEL_RANGE );
6616 CASE_RETURN_STRING( eCSR_SCAN_P2P_FIND_PEER );
6617 default:
6618 return "Unknown Scan Request Type";
6619 }
6620}