Commit | Line | Data |
---|---|---|
36c7928c BZ |
1 | /* |
2 | ************************************************************************* | |
3 | * Ralink Tech Inc. | |
4 | * 5F., No.36, Taiyuan St., Jhubei City, | |
5 | * Hsinchu County 302, | |
6 | * Taiwan, R.O.C. | |
7 | * | |
8 | * (c) Copyright 2002-2007, Ralink Technology, Inc. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify * | |
11 | * it under the terms of the GNU General Public License as published by * | |
12 | * the Free Software Foundation; either version 2 of the License, or * | |
13 | * (at your option) any later version. * | |
14 | * * | |
15 | * This program is distributed in the hope that it will be useful, * | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
18 | * GNU General Public License for more details. * | |
19 | * * | |
20 | * You should have received a copy of the GNU General Public License * | |
21 | * along with this program; if not, write to the * | |
22 | * Free Software Foundation, Inc., * | |
23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | |
24 | * * | |
25 | ************************************************************************* | |
26 | ||
27 | Module Name: | |
28 | sta_ioctl.c | |
29 | ||
30 | Abstract: | |
31 | IOCTL related subroutines | |
32 | ||
33 | Revision History: | |
34 | Who When What | |
35 | -------- ---------- ---------------------------------------------- | |
36 | Rory Chen 01-03-2003 created | |
37 | Rory Chen 02-14-2005 modify to support RT61 | |
38 | */ | |
39 | ||
40 | #include "rt_config.h" | |
41 | ||
42 | #ifdef DBG | |
43 | extern ULONG RTDebugLevel; | |
44 | #endif | |
45 | ||
46 | #define NR_WEP_KEYS 4 | |
47 | #define WEP_SMALL_KEY_LEN (40/8) | |
48 | #define WEP_LARGE_KEY_LEN (104/8) | |
49 | ||
50 | #define GROUP_KEY_NO 4 | |
51 | ||
52 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) | |
53 | #define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_A, _B, _C, _D, _E) | |
54 | #define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_A, _B, _C, _D, _E) | |
55 | #define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_A, _B, _C, _D, _E, _F) | |
56 | #else | |
57 | #define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E) iwe_stream_add_event(_B, _C, _D, _E) | |
58 | #define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E) iwe_stream_add_point(_B, _C, _D, _E) | |
59 | #define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F) iwe_stream_add_value(_B, _C, _D, _E, _F) | |
60 | #endif | |
61 | ||
62 | extern UCHAR CipherWpa2Template[]; | |
63 | ||
64 | typedef struct PACKED _RT_VERSION_INFO{ | |
65 | UCHAR DriverVersionW; | |
66 | UCHAR DriverVersionX; | |
67 | UCHAR DriverVersionY; | |
68 | UCHAR DriverVersionZ; | |
69 | UINT DriverBuildYear; | |
70 | UINT DriverBuildMonth; | |
71 | UINT DriverBuildDay; | |
72 | } RT_VERSION_INFO, *PRT_VERSION_INFO; | |
73 | ||
74 | struct iw_priv_args privtab[] = { | |
75 | { RTPRIV_IOCTL_SET, | |
76 | IW_PRIV_TYPE_CHAR | 1024, 0, | |
77 | "set"}, | |
78 | ||
79 | { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, | |
80 | ""}, | |
81 | /* --- sub-ioctls definitions --- */ | |
82 | { SHOW_CONN_STATUS, | |
83 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" }, | |
84 | { SHOW_DRVIER_VERION, | |
85 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" }, | |
86 | { SHOW_BA_INFO, | |
87 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" }, | |
88 | { SHOW_DESC_INFO, | |
89 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" }, | |
90 | { RAIO_OFF, | |
91 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" }, | |
92 | { RAIO_ON, | |
93 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" }, | |
94 | #ifdef QOS_DLS_SUPPORT | |
95 | { SHOW_DLS_ENTRY_INFO, | |
96 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" }, | |
97 | #endif // QOS_DLS_SUPPORT // | |
98 | { SHOW_CFG_VALUE, | |
99 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" }, | |
100 | { SHOW_ADHOC_ENTRY_INFO, | |
101 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" }, | |
102 | /* --- sub-ioctls relations --- */ | |
103 | ||
104 | #ifdef DBG | |
105 | { RTPRIV_IOCTL_BBP, | |
106 | IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, | |
107 | "bbp"}, | |
108 | { RTPRIV_IOCTL_MAC, | |
109 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024, | |
110 | "mac"}, | |
111 | #ifdef RTMP_RF_RW_SUPPORT | |
112 | { RTPRIV_IOCTL_RF, | |
113 | IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, | |
114 | "rf"}, | |
115 | #endif // RTMP_RF_RW_SUPPORT // | |
116 | { RTPRIV_IOCTL_E2P, | |
117 | IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024, | |
118 | "e2p"}, | |
119 | #endif /* DBG */ | |
120 | ||
121 | { RTPRIV_IOCTL_STATISTICS, | |
122 | 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, | |
123 | "stat"}, | |
124 | { RTPRIV_IOCTL_GSITESURVEY, | |
125 | 0, IW_PRIV_TYPE_CHAR | 1024, | |
126 | "get_site_survey"}, | |
127 | ||
128 | ||
129 | }; | |
130 | ||
131 | static __s32 ralinkrate[] = | |
132 | {2, 4, 11, 22, // CCK | |
133 | 12, 18, 24, 36, 48, 72, 96, 108, // OFDM | |
134 | 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15 | |
135 | 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23 | |
136 | 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15 | |
137 | 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23 | |
138 | 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15 | |
139 | 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23 | |
140 | 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15 | |
141 | 90, 180, 270, 360, 540, 720, 810, 900}; | |
142 | ||
143 | ||
144 | ||
145 | INT Set_SSID_Proc( | |
146 | IN PRTMP_ADAPTER pAdapter, | |
147 | IN PSTRING arg); | |
148 | ||
149 | #ifdef WMM_SUPPORT | |
150 | INT Set_WmmCapable_Proc( | |
151 | IN PRTMP_ADAPTER pAd, | |
152 | IN PSTRING arg); | |
153 | #endif | |
154 | ||
155 | INT Set_NetworkType_Proc( | |
156 | IN PRTMP_ADAPTER pAdapter, | |
157 | IN PSTRING arg); | |
158 | ||
159 | INT Set_AuthMode_Proc( | |
160 | IN PRTMP_ADAPTER pAdapter, | |
161 | IN PSTRING arg); | |
162 | ||
163 | INT Set_EncrypType_Proc( | |
164 | IN PRTMP_ADAPTER pAdapter, | |
165 | IN PSTRING arg); | |
166 | ||
167 | INT Set_DefaultKeyID_Proc( | |
168 | IN PRTMP_ADAPTER pAdapter, | |
169 | IN PSTRING arg); | |
170 | ||
171 | INT Set_Key1_Proc( | |
172 | IN PRTMP_ADAPTER pAdapter, | |
173 | IN PSTRING arg); | |
174 | ||
175 | INT Set_Key2_Proc( | |
176 | IN PRTMP_ADAPTER pAdapter, | |
177 | IN PSTRING arg); | |
178 | ||
179 | INT Set_Key3_Proc( | |
180 | IN PRTMP_ADAPTER pAdapter, | |
181 | IN PSTRING arg); | |
182 | ||
183 | INT Set_Key4_Proc( | |
184 | IN PRTMP_ADAPTER pAdapter, | |
185 | IN PSTRING arg); | |
186 | ||
187 | INT Set_WPAPSK_Proc( | |
188 | IN PRTMP_ADAPTER pAdapter, | |
189 | IN PSTRING arg); | |
190 | ||
191 | ||
192 | INT Set_PSMode_Proc( | |
193 | IN PRTMP_ADAPTER pAdapter, | |
194 | IN PSTRING arg); | |
195 | ||
196 | #ifdef RT3090 | |
197 | INT Set_PCIePSLevel_Proc( | |
198 | IN PRTMP_ADAPTER pAdapter, | |
199 | IN PUCHAR arg); | |
200 | #endif // RT3090 // | |
201 | #ifdef WPA_SUPPLICANT_SUPPORT | |
202 | INT Set_Wpa_Support( | |
203 | IN PRTMP_ADAPTER pAd, | |
204 | IN PSTRING arg); | |
205 | #endif // WPA_SUPPLICANT_SUPPORT // | |
206 | ||
207 | #ifdef DBG | |
208 | ||
209 | VOID RTMPIoctlMAC( | |
210 | IN PRTMP_ADAPTER pAdapter, | |
211 | IN struct iwreq *wrq); | |
212 | ||
213 | VOID RTMPIoctlE2PROM( | |
214 | IN PRTMP_ADAPTER pAdapter, | |
215 | IN struct iwreq *wrq); | |
216 | #endif // DBG // | |
217 | ||
218 | ||
219 | NDIS_STATUS RTMPWPANoneAddKeyProc( | |
220 | IN PRTMP_ADAPTER pAd, | |
221 | IN PVOID pBuf); | |
222 | ||
223 | INT Set_FragTest_Proc( | |
224 | IN PRTMP_ADAPTER pAdapter, | |
225 | IN PSTRING arg); | |
226 | ||
227 | #ifdef DOT11_N_SUPPORT | |
228 | INT Set_TGnWifiTest_Proc( | |
229 | IN PRTMP_ADAPTER pAd, | |
230 | IN PSTRING arg); | |
231 | #endif // DOT11_N_SUPPORT // | |
232 | ||
233 | INT Set_LongRetryLimit_Proc( | |
234 | IN PRTMP_ADAPTER pAdapter, | |
235 | IN PSTRING arg); | |
236 | ||
237 | INT Set_ShortRetryLimit_Proc( | |
238 | IN PRTMP_ADAPTER pAdapter, | |
239 | IN PSTRING arg); | |
240 | ||
241 | #ifdef EXT_BUILD_CHANNEL_LIST | |
242 | INT Set_Ieee80211dClientMode_Proc( | |
243 | IN PRTMP_ADAPTER pAdapter, | |
244 | IN PSTRING arg); | |
245 | #endif // EXT_BUILD_CHANNEL_LIST // | |
246 | ||
247 | #ifdef CARRIER_DETECTION_SUPPORT | |
248 | INT Set_CarrierDetect_Proc( | |
249 | IN PRTMP_ADAPTER pAd, | |
250 | IN PSTRING arg); | |
251 | #endif // CARRIER_DETECTION_SUPPORT // | |
252 | ||
253 | INT Show_Adhoc_MacTable_Proc( | |
254 | IN PRTMP_ADAPTER pAd, | |
255 | IN PSTRING extra); | |
256 | ||
257 | #ifdef RTMP_RF_RW_SUPPORT | |
258 | VOID RTMPIoctlRF( | |
259 | IN PRTMP_ADAPTER pAdapter, | |
260 | IN struct iwreq *wrq); | |
261 | #endif // RTMP_RF_RW_SUPPORT // | |
262 | ||
263 | ||
264 | INT Set_BeaconLostTime_Proc( | |
265 | IN PRTMP_ADAPTER pAd, | |
266 | IN PSTRING arg); | |
267 | ||
268 | INT Set_AutoRoaming_Proc( | |
269 | IN PRTMP_ADAPTER pAd, | |
270 | IN PSTRING arg); | |
271 | ||
272 | INT Set_SiteSurvey_Proc( | |
273 | IN PRTMP_ADAPTER pAd, | |
274 | IN PSTRING arg); | |
275 | ||
276 | INT Set_ForceTxBurst_Proc( | |
277 | IN PRTMP_ADAPTER pAd, | |
278 | IN PSTRING arg); | |
279 | ||
280 | #ifdef ANT_DIVERSITY_SUPPORT | |
281 | INT Set_Antenna_Proc( | |
282 | IN PRTMP_ADAPTER pAd, | |
283 | IN PUCHAR arg); | |
284 | #endif // ANT_DIVERSITY_SUPPORT // | |
285 | ||
286 | static struct { | |
287 | PSTRING name; | |
288 | INT (*set_proc)(PRTMP_ADAPTER pAdapter, PSTRING arg); | |
289 | } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = { | |
290 | {"DriverVersion", Set_DriverVersion_Proc}, | |
291 | {"CountryRegion", Set_CountryRegion_Proc}, | |
292 | {"CountryRegionABand", Set_CountryRegionABand_Proc}, | |
293 | {"SSID", Set_SSID_Proc}, | |
294 | {"WirelessMode", Set_WirelessMode_Proc}, | |
295 | {"TxBurst", Set_TxBurst_Proc}, | |
296 | {"TxPreamble", Set_TxPreamble_Proc}, | |
297 | {"TxPower", Set_TxPower_Proc}, | |
298 | {"Channel", Set_Channel_Proc}, | |
299 | {"BGProtection", Set_BGProtection_Proc}, | |
300 | {"RTSThreshold", Set_RTSThreshold_Proc}, | |
301 | {"FragThreshold", Set_FragThreshold_Proc}, | |
302 | #ifdef DOT11_N_SUPPORT | |
303 | {"HtBw", Set_HtBw_Proc}, | |
304 | {"HtMcs", Set_HtMcs_Proc}, | |
305 | {"HtGi", Set_HtGi_Proc}, | |
306 | {"HtOpMode", Set_HtOpMode_Proc}, | |
307 | {"HtExtcha", Set_HtExtcha_Proc}, | |
308 | {"HtMpduDensity", Set_HtMpduDensity_Proc}, | |
309 | {"HtBaWinSize", Set_HtBaWinSize_Proc}, | |
310 | {"HtRdg", Set_HtRdg_Proc}, | |
311 | {"HtAmsdu", Set_HtAmsdu_Proc}, | |
312 | {"HtAutoBa", Set_HtAutoBa_Proc}, | |
313 | {"HtBaDecline", Set_BADecline_Proc}, | |
314 | {"HtProtect", Set_HtProtect_Proc}, | |
315 | {"HtMimoPs", Set_HtMimoPs_Proc}, | |
316 | {"HtDisallowTKIP", Set_HtDisallowTKIP_Proc}, | |
317 | #endif // DOT11_N_SUPPORT // | |
318 | ||
319 | #ifdef AGGREGATION_SUPPORT | |
320 | {"PktAggregate", Set_PktAggregate_Proc}, | |
321 | #endif // AGGREGATION_SUPPORT // | |
322 | ||
323 | #ifdef WMM_SUPPORT | |
324 | {"WmmCapable", Set_WmmCapable_Proc}, | |
325 | #endif | |
326 | {"IEEE80211H", Set_IEEE80211H_Proc}, | |
327 | {"NetworkType", Set_NetworkType_Proc}, | |
328 | {"AuthMode", Set_AuthMode_Proc}, | |
329 | {"EncrypType", Set_EncrypType_Proc}, | |
330 | {"DefaultKeyID", Set_DefaultKeyID_Proc}, | |
331 | {"Key1", Set_Key1_Proc}, | |
332 | {"Key2", Set_Key2_Proc}, | |
333 | {"Key3", Set_Key3_Proc}, | |
334 | {"Key4", Set_Key4_Proc}, | |
335 | {"WPAPSK", Set_WPAPSK_Proc}, | |
336 | {"ResetCounter", Set_ResetStatCounter_Proc}, | |
337 | {"PSMode", Set_PSMode_Proc}, | |
338 | #ifdef DBG | |
339 | {"Debug", Set_Debug_Proc}, | |
340 | #endif // DBG // | |
341 | ||
342 | #ifdef RALINK_ATE | |
343 | {"ATE", Set_ATE_Proc}, | |
344 | {"ATEDA", Set_ATE_DA_Proc}, | |
345 | {"ATESA", Set_ATE_SA_Proc}, | |
346 | {"ATEBSSID", Set_ATE_BSSID_Proc}, | |
347 | {"ATECHANNEL", Set_ATE_CHANNEL_Proc}, | |
348 | {"ATETXPOW0", Set_ATE_TX_POWER0_Proc}, | |
349 | {"ATETXPOW1", Set_ATE_TX_POWER1_Proc}, | |
350 | {"ATETXANT", Set_ATE_TX_Antenna_Proc}, | |
351 | {"ATERXANT", Set_ATE_RX_Antenna_Proc}, | |
352 | {"ATETXFREQOFFSET", Set_ATE_TX_FREQOFFSET_Proc}, | |
353 | {"ATETXBW", Set_ATE_TX_BW_Proc}, | |
354 | {"ATETXLEN", Set_ATE_TX_LENGTH_Proc}, | |
355 | {"ATETXCNT", Set_ATE_TX_COUNT_Proc}, | |
356 | {"ATETXMCS", Set_ATE_TX_MCS_Proc}, | |
357 | {"ATETXMODE", Set_ATE_TX_MODE_Proc}, | |
358 | {"ATETXGI", Set_ATE_TX_GI_Proc}, | |
359 | {"ATERXFER", Set_ATE_RX_FER_Proc}, | |
360 | {"ATERRF", Set_ATE_Read_RF_Proc}, | |
361 | {"ATEWRF1", Set_ATE_Write_RF1_Proc}, | |
362 | {"ATEWRF2", Set_ATE_Write_RF2_Proc}, | |
363 | {"ATEWRF3", Set_ATE_Write_RF3_Proc}, | |
364 | {"ATEWRF4", Set_ATE_Write_RF4_Proc}, | |
365 | {"ATELDE2P", Set_ATE_Load_E2P_Proc}, | |
366 | {"ATERE2P", Set_ATE_Read_E2P_Proc}, | |
367 | {"ATESHOW", Set_ATE_Show_Proc}, | |
368 | {"ATEHELP", Set_ATE_Help_Proc}, | |
369 | ||
370 | #ifdef RALINK_28xx_QA | |
371 | {"TxStop", Set_TxStop_Proc}, | |
372 | {"RxStop", Set_RxStop_Proc}, | |
373 | #endif // RALINK_28xx_QA // | |
374 | #endif // RALINK_ATE // | |
375 | ||
376 | #ifdef WPA_SUPPLICANT_SUPPORT | |
377 | {"WpaSupport", Set_Wpa_Support}, | |
378 | #endif // WPA_SUPPLICANT_SUPPORT // | |
379 | ||
380 | ||
381 | ||
382 | ||
383 | ||
384 | {"FixedTxMode", Set_FixedTxMode_Proc}, | |
385 | #ifdef CONFIG_APSTA_MIXED_SUPPORT | |
386 | {"OpMode", Set_OpMode_Proc}, | |
387 | #endif // CONFIG_APSTA_MIXED_SUPPORT // | |
388 | #ifdef DOT11_N_SUPPORT | |
389 | {"TGnWifiTest", Set_TGnWifiTest_Proc}, | |
390 | {"ForceGF", Set_ForceGF_Proc}, | |
391 | #endif // DOT11_N_SUPPORT // | |
392 | #ifdef QOS_DLS_SUPPORT | |
393 | {"DlsAddEntry", Set_DlsAddEntry_Proc}, | |
394 | {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc}, | |
395 | #endif // QOS_DLS_SUPPORT // | |
396 | {"LongRetry", Set_LongRetryLimit_Proc}, | |
397 | {"ShortRetry", Set_ShortRetryLimit_Proc}, | |
398 | #ifdef EXT_BUILD_CHANNEL_LIST | |
399 | {"11dClientMode", Set_Ieee80211dClientMode_Proc}, | |
400 | #endif // EXT_BUILD_CHANNEL_LIST // | |
401 | #ifdef CARRIER_DETECTION_SUPPORT | |
402 | {"CarrierDetect", Set_CarrierDetect_Proc}, | |
403 | #endif // CARRIER_DETECTION_SUPPORT // | |
404 | ||
405 | ||
406 | //2008/09/11:KH add to support efuse<-- | |
407 | #ifdef RT30xx | |
408 | #ifdef RTMP_EFUSE_SUPPORT | |
409 | {"efuseFreeNumber", set_eFuseGetFreeBlockCount_Proc}, | |
410 | {"efuseDump", set_eFusedump_Proc}, | |
411 | {"efuseLoadFromBin", set_eFuseLoadFromBin_Proc}, | |
412 | {"efuseBufferModeWriteBack", set_eFuseBufferModeWriteBack_Proc}, | |
413 | #endif // RTMP_EFUSE_SUPPORT // | |
414 | #ifdef ANT_DIVERSITY_SUPPORT | |
415 | {"ant", Set_Antenna_Proc}, | |
416 | #endif // ANT_DIVERSITY_SUPPORT // | |
417 | #endif // RT30xx // | |
418 | //2008/09/11:KH add to support efuse--> | |
419 | ||
420 | {"BeaconLostTime", Set_BeaconLostTime_Proc}, | |
421 | {"AutoRoaming", Set_AutoRoaming_Proc}, | |
422 | {"SiteSurvey", Set_SiteSurvey_Proc}, | |
423 | {"ForceTxBurst", Set_ForceTxBurst_Proc}, | |
424 | ||
425 | {NULL,} | |
426 | }; | |
427 | ||
428 | ||
429 | VOID RTMPAddKey( | |
430 | IN PRTMP_ADAPTER pAd, | |
431 | IN PNDIS_802_11_KEY pKey) | |
432 | { | |
433 | ULONG KeyIdx; | |
434 | MAC_TABLE_ENTRY *pEntry; | |
435 | ||
436 | DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n")); | |
437 | ||
438 | if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
439 | { | |
440 | if (pKey->KeyIndex & 0x80000000) | |
441 | { | |
442 | if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) | |
443 | { | |
444 | NdisZeroMemory(pAd->StaCfg.PMK, 32); | |
445 | NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength); | |
446 | goto end; | |
447 | } | |
448 | // Update PTK | |
449 | NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY)); | |
450 | pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK; | |
451 | NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK); | |
452 | #ifdef WPA_SUPPLICANT_SUPPORT | |
453 | if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled) | |
454 | { | |
455 | NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK); | |
456 | NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK); | |
457 | } | |
458 | else | |
459 | #endif // WPA_SUPPLICANT_SUPPORT // | |
460 | { | |
461 | NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK); | |
462 | NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK); | |
463 | } | |
464 | ||
465 | // Decide its ChiperAlg | |
466 | if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled) | |
467 | pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP; | |
468 | else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) | |
469 | pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES; | |
470 | else | |
471 | pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE; | |
472 | ||
473 | // Update these related information to MAC_TABLE_ENTRY | |
474 | pEntry = &pAd->MacTab.Content[BSSID_WCID]; | |
475 | NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK); | |
476 | NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK); | |
477 | NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK); | |
478 | pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg; | |
479 | ||
480 | // Update pairwise key information to ASIC Shared Key Table | |
481 | AsicAddSharedKeyEntry(pAd, | |
482 | BSS0, | |
483 | 0, | |
484 | pAd->SharedKey[BSS0][0].CipherAlg, | |
485 | pAd->SharedKey[BSS0][0].Key, | |
486 | pAd->SharedKey[BSS0][0].TxMic, | |
487 | pAd->SharedKey[BSS0][0].RxMic); | |
488 | ||
489 | // Update ASIC WCID attribute table and IVEIV table | |
490 | RTMPAddWcidAttributeEntry(pAd, | |
491 | BSS0, | |
492 | 0, | |
493 | pAd->SharedKey[BSS0][0].CipherAlg, | |
494 | pEntry); | |
495 | ||
496 | if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2) | |
497 | { | |
498 | // set 802.1x port control | |
499 | //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
500 | STA_PORT_SECURED(pAd); | |
501 | ||
502 | // Indicate Connected for GUI | |
503 | pAd->IndicateMediaState = NdisMediaStateConnected; | |
504 | } | |
505 | } | |
506 | else | |
507 | { | |
508 | // Update GTK | |
509 | pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF); | |
510 | NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY)); | |
511 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK; | |
512 | NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK); | |
513 | #ifdef WPA_SUPPLICANT_SUPPORT | |
514 | if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled) | |
515 | { | |
516 | NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK); | |
517 | NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK); | |
518 | } | |
519 | else | |
520 | #endif // WPA_SUPPLICANT_SUPPORT // | |
521 | { | |
522 | NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK); | |
523 | NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK); | |
524 | } | |
525 | ||
526 | // Update Shared Key CipherAlg | |
527 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE; | |
528 | if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled) | |
529 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP; | |
530 | else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled) | |
531 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES; | |
532 | ||
533 | // Update group key information to ASIC Shared Key Table | |
534 | AsicAddSharedKeyEntry(pAd, | |
535 | BSS0, | |
536 | pAd->StaCfg.DefaultKeyId, | |
537 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg, | |
538 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, | |
539 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, | |
540 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic); | |
541 | ||
542 | // Update ASIC WCID attribute table and IVEIV table | |
543 | RTMPAddWcidAttributeEntry(pAd, | |
544 | BSS0, | |
545 | pAd->StaCfg.DefaultKeyId, | |
546 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg, | |
547 | NULL); | |
548 | ||
549 | // set 802.1x port control | |
550 | //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
551 | STA_PORT_SECURED(pAd); | |
552 | ||
553 | // Indicate Connected for GUI | |
554 | pAd->IndicateMediaState = NdisMediaStateConnected; | |
555 | } | |
556 | } | |
557 | else // dynamic WEP from wpa_supplicant | |
558 | { | |
559 | UCHAR CipherAlg; | |
560 | PUCHAR Key; | |
561 | ||
562 | if(pKey->KeyLength == 32) | |
563 | goto end; | |
564 | ||
565 | KeyIdx = pKey->KeyIndex & 0x0fffffff; | |
566 | ||
567 | if (KeyIdx < 4) | |
568 | { | |
569 | // it is a default shared key, for Pairwise key setting | |
570 | if (pKey->KeyIndex & 0x80000000) | |
571 | { | |
572 | pEntry = MacTableLookup(pAd, pKey->BSSID); | |
573 | ||
574 | if (pEntry) | |
575 | { | |
576 | DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n")); | |
577 | ||
578 | // set key material and key length | |
579 | pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength; | |
580 | NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength); | |
581 | ||
582 | // set Cipher type | |
583 | if (pKey->KeyLength == 5) | |
584 | pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64; | |
585 | else | |
586 | pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128; | |
587 | ||
588 | // Add Pair-wise key to Asic | |
589 | AsicAddPairwiseKeyEntry( | |
590 | pAd, | |
591 | pEntry->Addr, | |
592 | (UCHAR)pEntry->Aid, | |
593 | &pEntry->PairwiseKey); | |
594 | ||
595 | // update WCID attribute table and IVEIV table for this entry | |
596 | RTMPAddWcidAttributeEntry( | |
597 | pAd, | |
598 | BSS0, | |
599 | KeyIdx, // The value may be not zero | |
600 | pEntry->PairwiseKey.CipherAlg, | |
601 | pEntry); | |
602 | ||
603 | } | |
604 | } | |
605 | else | |
606 | { | |
607 | // Default key for tx (shared key) | |
608 | pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx; | |
609 | ||
610 | // set key material and key length | |
611 | pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength; | |
612 | NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength); | |
613 | ||
614 | // Set Ciper type | |
615 | if (pKey->KeyLength == 5) | |
616 | pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64; | |
617 | else | |
618 | pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128; | |
619 | ||
620 | CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg; | |
621 | Key = pAd->SharedKey[BSS0][KeyIdx].Key; | |
622 | ||
623 | // Set Group key material to Asic | |
624 | AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL); | |
625 | ||
626 | // Update WCID attribute table and IVEIV table for this group key table | |
627 | RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL); | |
628 | ||
629 | } | |
630 | } | |
631 | } | |
632 | end: | |
633 | return; | |
634 | } | |
635 | ||
636 | char * rtstrchr(const char * s, int c) | |
637 | { | |
638 | for(; *s != (char) c; ++s) | |
639 | if (*s == '\0') | |
640 | return NULL; | |
641 | return (char *) s; | |
642 | } | |
643 | ||
644 | /* | |
645 | This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function | |
646 | */ | |
647 | ||
648 | int | |
649 | rt_ioctl_giwname(struct net_device *dev, | |
650 | struct iw_request_info *info, | |
651 | char *name, char *extra) | |
652 | { | |
653 | ||
654 | #ifdef RTMP_MAC_PCI | |
655 | strncpy(name, "RT2860 Wireless", IFNAMSIZ); | |
656 | #endif // RTMP_MAC_PCI // | |
657 | return 0; | |
658 | } | |
659 | ||
660 | int rt_ioctl_siwfreq(struct net_device *dev, | |
661 | struct iw_request_info *info, | |
662 | struct iw_freq *freq, char *extra) | |
663 | { | |
664 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
665 | int chan = -1; | |
666 | ||
667 | //check if the interface is down | |
668 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
669 | { | |
670 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
671 | return -ENETDOWN; | |
672 | } | |
673 | ||
674 | ||
675 | if (freq->e > 1) | |
676 | return -EINVAL; | |
677 | ||
678 | if((freq->e == 0) && (freq->m <= 1000)) | |
679 | chan = freq->m; // Setting by channel number | |
680 | else | |
681 | MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G, | |
682 | ||
683 | if (ChannelSanity(pAdapter, chan) == TRUE) | |
684 | { | |
685 | pAdapter->CommonCfg.Channel = chan; | |
686 | DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel)); | |
687 | } | |
688 | else | |
689 | return -EINVAL; | |
690 | ||
691 | return 0; | |
692 | } | |
693 | ||
694 | ||
695 | int rt_ioctl_giwfreq(struct net_device *dev, | |
696 | struct iw_request_info *info, | |
697 | struct iw_freq *freq, char *extra) | |
698 | { | |
699 | PRTMP_ADAPTER pAdapter = NULL; | |
700 | UCHAR ch; | |
701 | ULONG m = 2412000; | |
702 | ||
703 | pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
704 | if (pAdapter == NULL) | |
705 | { | |
706 | /* if 1st open fail, pAd will be free; | |
707 | So the net_dev->priv will be NULL in 2rd open */ | |
708 | return -ENETDOWN; | |
709 | } | |
710 | ||
711 | ch = pAdapter->CommonCfg.Channel; | |
712 | ||
713 | DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch)); | |
714 | ||
715 | MAP_CHANNEL_ID_TO_KHZ(ch, m); | |
716 | freq->m = m * 100; | |
717 | freq->e = 1; | |
718 | return 0; | |
719 | } | |
720 | ||
721 | ||
722 | int rt_ioctl_siwmode(struct net_device *dev, | |
723 | struct iw_request_info *info, | |
724 | __u32 *mode, char *extra) | |
725 | { | |
726 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
727 | ||
728 | //check if the interface is down | |
729 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
730 | { | |
731 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
732 | return -ENETDOWN; | |
733 | } | |
734 | ||
735 | switch (*mode) | |
736 | { | |
737 | case IW_MODE_ADHOC: | |
738 | Set_NetworkType_Proc(pAdapter, "Adhoc"); | |
739 | break; | |
740 | case IW_MODE_INFRA: | |
741 | Set_NetworkType_Proc(pAdapter, "Infra"); | |
742 | break; | |
743 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20)) | |
744 | case IW_MODE_MONITOR: | |
745 | Set_NetworkType_Proc(pAdapter, "Monitor"); | |
746 | break; | |
747 | #endif | |
748 | default: | |
749 | DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode)); | |
750 | return -EINVAL; | |
751 | } | |
752 | ||
753 | // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key | |
754 | pAdapter->StaCfg.WpaState = SS_NOTUSE; | |
755 | ||
756 | return 0; | |
757 | } | |
758 | ||
759 | ||
760 | int rt_ioctl_giwmode(struct net_device *dev, | |
761 | struct iw_request_info *info, | |
762 | __u32 *mode, char *extra) | |
763 | { | |
764 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
765 | ||
766 | if (pAdapter == NULL) | |
767 | { | |
768 | /* if 1st open fail, pAd will be free; | |
769 | So the net_dev->priv will be NULL in 2rd open */ | |
770 | return -ENETDOWN; | |
771 | } | |
772 | ||
773 | if (ADHOC_ON(pAdapter)) | |
774 | *mode = IW_MODE_ADHOC; | |
775 | else if (INFRA_ON(pAdapter)) | |
776 | *mode = IW_MODE_INFRA; | |
777 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20)) | |
778 | else if (MONITOR_ON(pAdapter)) | |
779 | { | |
780 | *mode = IW_MODE_MONITOR; | |
781 | } | |
782 | #endif | |
783 | else | |
784 | *mode = IW_MODE_AUTO; | |
785 | ||
786 | DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode)); | |
787 | return 0; | |
788 | } | |
789 | ||
790 | int rt_ioctl_siwsens(struct net_device *dev, | |
791 | struct iw_request_info *info, | |
792 | char *name, char *extra) | |
793 | { | |
794 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
795 | ||
796 | //check if the interface is down | |
797 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
798 | { | |
799 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
800 | return -ENETDOWN; | |
801 | } | |
802 | ||
803 | return 0; | |
804 | } | |
805 | ||
806 | int rt_ioctl_giwsens(struct net_device *dev, | |
807 | struct iw_request_info *info, | |
808 | char *name, char *extra) | |
809 | { | |
810 | return 0; | |
811 | } | |
812 | ||
813 | int rt_ioctl_giwrange(struct net_device *dev, | |
814 | struct iw_request_info *info, | |
815 | struct iw_point *data, char *extra) | |
816 | { | |
817 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
818 | struct iw_range *range = (struct iw_range *) extra; | |
819 | u16 val; | |
820 | int i; | |
821 | ||
822 | if (pAdapter == NULL) | |
823 | { | |
824 | /* if 1st open fail, pAd will be free; | |
825 | So the net_dev->priv will be NULL in 2rd open */ | |
826 | return -ENETDOWN; | |
827 | } | |
828 | ||
829 | DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n")); | |
830 | data->length = sizeof(struct iw_range); | |
831 | memset(range, 0, sizeof(struct iw_range)); | |
832 | ||
833 | range->txpower_capa = IW_TXPOW_DBM; | |
834 | ||
835 | if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter)) | |
836 | { | |
837 | range->min_pmp = 1 * 1024; | |
838 | range->max_pmp = 65535 * 1024; | |
839 | range->min_pmt = 1 * 1024; | |
840 | range->max_pmt = 1000 * 1024; | |
841 | range->pmp_flags = IW_POWER_PERIOD; | |
842 | range->pmt_flags = IW_POWER_TIMEOUT; | |
843 | range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | | |
844 | IW_POWER_UNICAST_R | IW_POWER_ALL_R; | |
845 | } | |
846 | ||
847 | range->we_version_compiled = WIRELESS_EXT; | |
848 | range->we_version_source = 14; | |
849 | ||
850 | range->retry_capa = IW_RETRY_LIMIT; | |
851 | range->retry_flags = IW_RETRY_LIMIT; | |
852 | range->min_retry = 0; | |
853 | range->max_retry = 255; | |
854 | ||
855 | range->num_channels = pAdapter->ChannelListNum; | |
856 | ||
857 | val = 0; | |
858 | for (i = 1; i <= range->num_channels; i++) | |
859 | { | |
860 | u32 m = 2412000; | |
861 | range->freq[val].i = pAdapter->ChannelList[i-1].Channel; | |
862 | MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m); | |
863 | range->freq[val].m = m * 100; /* OS_HZ */ | |
864 | ||
865 | range->freq[val].e = 1; | |
866 | val++; | |
867 | if (val == IW_MAX_FREQUENCIES) | |
868 | break; | |
869 | } | |
870 | range->num_frequency = val; | |
871 | ||
872 | range->max_qual.qual = 100; /* what is correct max? This was not | |
873 | * documented exactly. At least | |
874 | * 69 has been observed. */ | |
875 | range->max_qual.level = 0; /* dB */ | |
876 | range->max_qual.noise = 0; /* dB */ | |
877 | ||
878 | /* What would be suitable values for "average/typical" qual? */ | |
879 | range->avg_qual.qual = 20; | |
880 | range->avg_qual.level = -60; | |
881 | range->avg_qual.noise = -95; | |
882 | range->sensitivity = 3; | |
883 | ||
884 | range->max_encoding_tokens = NR_WEP_KEYS; | |
885 | range->num_encoding_sizes = 2; | |
886 | range->encoding_size[0] = 5; | |
887 | range->encoding_size[1] = 13; | |
888 | ||
889 | range->min_rts = 0; | |
890 | range->max_rts = 2347; | |
891 | range->min_frag = 256; | |
892 | range->max_frag = 2346; | |
893 | ||
894 | #if WIRELESS_EXT > 17 | |
895 | /* IW_ENC_CAPA_* bit field */ | |
896 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | | |
897 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; | |
898 | #endif | |
899 | ||
900 | return 0; | |
901 | } | |
902 | ||
903 | int rt_ioctl_siwap(struct net_device *dev, | |
904 | struct iw_request_info *info, | |
905 | struct sockaddr *ap_addr, char *extra) | |
906 | { | |
907 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
908 | NDIS_802_11_MAC_ADDRESS Bssid; | |
909 | ||
910 | //check if the interface is down | |
911 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
912 | { | |
913 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
914 | return -ENETDOWN; | |
915 | } | |
916 | ||
917 | if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) | |
918 | { | |
919 | RTMP_MLME_RESET_STATE_MACHINE(pAdapter); | |
920 | DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n")); | |
921 | } | |
922 | ||
923 | // tell CNTL state machine to call NdisMSetInformationComplete() after completing | |
924 | // this request, because this request is initiated by NDIS. | |
925 | pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE; | |
926 | // Prevent to connect AP again in STAMlmePeriodicExec | |
927 | pAdapter->MlmeAux.AutoReconnectSsidLen= 32; | |
928 | ||
929 | memset(Bssid, 0, MAC_ADDR_LEN); | |
930 | memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN); | |
931 | MlmeEnqueue(pAdapter, | |
932 | MLME_CNTL_STATE_MACHINE, | |
933 | OID_802_11_BSSID, | |
934 | sizeof(NDIS_802_11_MAC_ADDRESS), | |
935 | (VOID *)&Bssid); | |
936 | ||
937 | DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n", | |
938 | Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5])); | |
939 | ||
940 | return 0; | |
941 | } | |
942 | ||
943 | int rt_ioctl_giwap(struct net_device *dev, | |
944 | struct iw_request_info *info, | |
945 | struct sockaddr *ap_addr, char *extra) | |
946 | { | |
947 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
948 | ||
949 | if (pAdapter == NULL) | |
950 | { | |
951 | /* if 1st open fail, pAd will be free; | |
952 | So the net_dev->priv will be NULL in 2rd open */ | |
953 | return -ENETDOWN; | |
954 | } | |
955 | ||
956 | if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter)) | |
957 | { | |
958 | ap_addr->sa_family = ARPHRD_ETHER; | |
959 | memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN); | |
960 | } | |
961 | #ifdef WPA_SUPPLICANT_SUPPORT | |
962 | // Add for RT2870 | |
963 | else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) | |
964 | { | |
965 | ap_addr->sa_family = ARPHRD_ETHER; | |
966 | memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN); | |
967 | } | |
968 | #endif // WPA_SUPPLICANT_SUPPORT // | |
969 | else | |
970 | { | |
971 | DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n")); | |
972 | return -ENOTCONN; | |
973 | } | |
974 | ||
975 | return 0; | |
976 | } | |
977 | ||
978 | /* | |
979 | * Units are in db above the noise floor. That means the | |
980 | * rssi values reported in the tx/rx descriptors in the | |
981 | * driver are the SNR expressed in db. | |
982 | * | |
983 | * If you assume that the noise floor is -95, which is an | |
984 | * excellent assumption 99.5 % of the time, then you can | |
985 | * derive the absolute signal level (i.e. -95 + rssi). | |
986 | * There are some other slight factors to take into account | |
987 | * depending on whether the rssi measurement is from 11b, | |
988 | * 11g, or 11a. These differences are at most 2db and | |
989 | * can be documented. | |
990 | * | |
991 | * NB: various calculations are based on the orinoco/wavelan | |
992 | * drivers for compatibility | |
993 | */ | |
994 | static void set_quality(PRTMP_ADAPTER pAdapter, | |
995 | struct iw_quality *iq, | |
996 | signed char rssi) | |
997 | { | |
998 | __u8 ChannelQuality; | |
999 | ||
1000 | // Normalize Rssi | |
1001 | if (rssi >= -50) | |
1002 | ChannelQuality = 100; | |
1003 | else if (rssi >= -80) // between -50 ~ -80dbm | |
1004 | ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10); | |
1005 | else if (rssi >= -90) // between -80 ~ -90dbm | |
1006 | ChannelQuality = (__u8)((rssi + 90) * 26)/10; | |
1007 | else | |
1008 | ChannelQuality = 0; | |
1009 | ||
1010 | iq->qual = (__u8)ChannelQuality; | |
1011 | ||
1012 | iq->level = (__u8)(rssi); | |
1013 | iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm) | |
1014 | iq->noise += 256 - 143; | |
1015 | iq->updated = pAdapter->iw_stats.qual.updated; | |
1016 | } | |
1017 | ||
1018 | int rt_ioctl_iwaplist(struct net_device *dev, | |
1019 | struct iw_request_info *info, | |
1020 | struct iw_point *data, char *extra) | |
1021 | { | |
1022 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1023 | ||
1024 | struct sockaddr addr[IW_MAX_AP]; | |
1025 | struct iw_quality qual[IW_MAX_AP]; | |
1026 | int i; | |
1027 | ||
1028 | //check if the interface is down | |
1029 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1030 | { | |
1031 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1032 | data->length = 0; | |
1033 | return 0; | |
1034 | //return -ENETDOWN; | |
1035 | } | |
1036 | ||
1037 | for (i = 0; i <IW_MAX_AP ; i++) | |
1038 | { | |
1039 | if (i >= pAdapter->ScanTab.BssNr) | |
1040 | break; | |
1041 | addr[i].sa_family = ARPHRD_ETHER; | |
1042 | memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN); | |
1043 | set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi); | |
1044 | } | |
1045 | data->length = i; | |
1046 | memcpy(extra, &addr, i*sizeof(addr[0])); | |
1047 | data->flags = 1; /* signal quality present (sort of) */ | |
1048 | memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i])); | |
1049 | ||
1050 | return 0; | |
1051 | } | |
1052 | ||
1053 | #ifdef SIOCGIWSCAN | |
1054 | int rt_ioctl_siwscan(struct net_device *dev, | |
1055 | struct iw_request_info *info, | |
1056 | struct iw_point *data, char *extra) | |
1057 | { | |
1058 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1059 | ||
1060 | ULONG Now; | |
1061 | int Status = NDIS_STATUS_SUCCESS; | |
1062 | ||
1063 | //check if the interface is down | |
1064 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1065 | { | |
1066 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1067 | return -ENETDOWN; | |
1068 | } | |
1069 | ||
1070 | if (MONITOR_ON(pAdapter)) | |
1071 | { | |
1072 | DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n")); | |
1073 | return -EINVAL; | |
1074 | } | |
1075 | ||
1076 | ||
1077 | #ifdef WPA_SUPPLICANT_SUPPORT | |
1078 | if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) | |
1079 | { | |
1080 | pAdapter->StaCfg.WpaSupplicantScanCount++; | |
1081 | } | |
1082 | #endif // WPA_SUPPLICANT_SUPPORT // | |
1083 | ||
1084 | pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE; | |
1085 | if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) | |
1086 | return NDIS_STATUS_SUCCESS; | |
1087 | do{ | |
1088 | Now = jiffies; | |
1089 | ||
1090 | #ifdef WPA_SUPPLICANT_SUPPORT | |
1091 | if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) && | |
1092 | (pAdapter->StaCfg.WpaSupplicantScanCount > 3)) | |
1093 | { | |
1094 | DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n")); | |
1095 | Status = NDIS_STATUS_SUCCESS; | |
1096 | break; | |
1097 | } | |
1098 | #endif // WPA_SUPPLICANT_SUPPORT // | |
1099 | ||
1100 | if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) && | |
1101 | ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || | |
1102 | (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) && | |
1103 | (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) | |
1104 | { | |
1105 | DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n")); | |
1106 | Status = NDIS_STATUS_SUCCESS; | |
1107 | break; | |
1108 | } | |
1109 | ||
1110 | if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) | |
1111 | { | |
1112 | RTMP_MLME_RESET_STATE_MACHINE(pAdapter); | |
1113 | DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n")); | |
1114 | } | |
1115 | ||
1116 | // tell CNTL state machine to call NdisMSetInformationComplete() after completing | |
1117 | // this request, because this request is initiated by NDIS. | |
1118 | pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE; | |
1119 | // Reset allowed scan retries | |
1120 | pAdapter->StaCfg.ScanCnt = 0; | |
1121 | pAdapter->StaCfg.LastScanTime = Now; | |
1122 | ||
1123 | MlmeEnqueue(pAdapter, | |
1124 | MLME_CNTL_STATE_MACHINE, | |
1125 | OID_802_11_BSSID_LIST_SCAN, | |
1126 | 0, | |
1127 | NULL); | |
1128 | ||
1129 | Status = NDIS_STATUS_SUCCESS; | |
1130 | RTMP_MLME_HANDLER(pAdapter); | |
1131 | }while(0); | |
1132 | return NDIS_STATUS_SUCCESS; | |
1133 | } | |
1134 | ||
1135 | int rt_ioctl_giwscan(struct net_device *dev, | |
1136 | struct iw_request_info *info, | |
1137 | struct iw_point *data, char *extra) | |
1138 | { | |
1139 | ||
1140 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1141 | int i=0; | |
1142 | PSTRING current_ev = extra, previous_ev = extra; | |
1143 | PSTRING end_buf; | |
1144 | PSTRING current_val; | |
1145 | STRING custom[MAX_CUSTOM_LEN] = {0}; | |
1146 | #ifndef IWEVGENIE | |
1147 | unsigned char idx; | |
1148 | #endif // IWEVGENIE // | |
1149 | struct iw_event iwe; | |
1150 | ||
1151 | if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) | |
1152 | { | |
1153 | /* | |
1154 | * Still scanning, indicate the caller should try again. | |
1155 | */ | |
1156 | return -EAGAIN; | |
1157 | } | |
1158 | ||
1159 | ||
1160 | #ifdef WPA_SUPPLICANT_SUPPORT | |
1161 | if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) | |
1162 | { | |
1163 | pAdapter->StaCfg.WpaSupplicantScanCount = 0; | |
1164 | } | |
1165 | #endif // WPA_SUPPLICANT_SUPPORT // | |
1166 | ||
1167 | if (pAdapter->ScanTab.BssNr == 0) | |
1168 | { | |
1169 | data->length = 0; | |
1170 | return 0; | |
1171 | } | |
1172 | ||
1173 | #if WIRELESS_EXT >= 17 | |
1174 | if (data->length > 0) | |
1175 | end_buf = extra + data->length; | |
1176 | else | |
1177 | end_buf = extra + IW_SCAN_MAX_DATA; | |
1178 | #else | |
1179 | end_buf = extra + IW_SCAN_MAX_DATA; | |
1180 | #endif | |
1181 | ||
1182 | for (i = 0; i < pAdapter->ScanTab.BssNr; i++) | |
1183 | { | |
1184 | if (current_ev >= end_buf) | |
1185 | { | |
1186 | #if WIRELESS_EXT >= 17 | |
1187 | return -E2BIG; | |
1188 | #else | |
1189 | break; | |
1190 | #endif | |
1191 | } | |
1192 | ||
1193 | //MAC address | |
1194 | //================================ | |
1195 | memset(&iwe, 0, sizeof(iwe)); | |
1196 | iwe.cmd = SIOCGIWAP; | |
1197 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | |
1198 | memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN); | |
1199 | ||
1200 | previous_ev = current_ev; | |
1201 | current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN); | |
1202 | if (current_ev == previous_ev) | |
1203 | #if WIRELESS_EXT >= 17 | |
1204 | return -E2BIG; | |
1205 | #else | |
1206 | break; | |
1207 | #endif | |
1208 | ||
1209 | /* | |
1210 | Protocol: | |
1211 | it will show scanned AP's WirelessMode . | |
1212 | it might be | |
1213 | 802.11a | |
1214 | 802.11a/n | |
1215 | 802.11g/n | |
1216 | 802.11b/g/n | |
1217 | 802.11g | |
1218 | 802.11b/g | |
1219 | */ | |
1220 | memset(&iwe, 0, sizeof(iwe)); | |
1221 | iwe.cmd = SIOCGIWNAME; | |
1222 | ||
1223 | ||
1224 | { | |
1225 | PBSS_ENTRY pBssEntry=&pAdapter->ScanTab.BssEntry[i]; | |
1226 | BOOLEAN isGonly=FALSE; | |
1227 | int rateCnt=0; | |
1228 | ||
1229 | if (pBssEntry->Channel>14) | |
1230 | { | |
1231 | if (pBssEntry->HtCapabilityLen!=0) | |
1232 | strcpy(iwe.u.name,"802.11a/n"); | |
1233 | else | |
1234 | strcpy(iwe.u.name,"802.11a"); | |
1235 | } | |
1236 | else | |
1237 | { | |
1238 | /* | |
1239 | if one of non B mode rate is set supported rate . it mean G only. | |
1240 | */ | |
1241 | for (rateCnt=0;rateCnt<pBssEntry->SupRateLen;rateCnt++) | |
1242 | { | |
1243 | /* | |
1244 | 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only. | |
1245 | */ | |
1246 | if (pBssEntry->SupRate[rateCnt]==140 || pBssEntry->SupRate[rateCnt]==146 || pBssEntry->SupRate[rateCnt]>=152) | |
1247 | isGonly=TRUE; | |
1248 | } | |
1249 | ||
1250 | for (rateCnt=0;rateCnt<pBssEntry->ExtRateLen;rateCnt++) | |
1251 | { | |
1252 | if (pBssEntry->ExtRate[rateCnt]==140 || pBssEntry->ExtRate[rateCnt]==146 || pBssEntry->ExtRate[rateCnt]>=152) | |
1253 | isGonly=TRUE; | |
1254 | } | |
1255 | ||
1256 | ||
1257 | if (pBssEntry->HtCapabilityLen!=0) | |
1258 | { | |
1259 | if (isGonly==TRUE) | |
1260 | strcpy(iwe.u.name,"802.11g/n"); | |
1261 | else | |
1262 | strcpy(iwe.u.name,"802.11b/g/n"); | |
1263 | } | |
1264 | else | |
1265 | { | |
1266 | if (isGonly==TRUE) | |
1267 | strcpy(iwe.u.name,"802.11g"); | |
1268 | else | |
1269 | { | |
1270 | if (pBssEntry->SupRateLen==4 && pBssEntry->ExtRateLen==0) | |
1271 | strcpy(iwe.u.name,"802.11b"); | |
1272 | else | |
1273 | strcpy(iwe.u.name,"802.11b/g"); | |
1274 | } | |
1275 | } | |
1276 | } | |
1277 | } | |
1278 | ||
1279 | previous_ev = current_ev; | |
1280 | current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN); | |
1281 | if (current_ev == previous_ev) | |
1282 | #if WIRELESS_EXT >= 17 | |
1283 | return -E2BIG; | |
1284 | #else | |
1285 | break; | |
1286 | #endif | |
1287 | ||
1288 | //ESSID | |
1289 | //================================ | |
1290 | memset(&iwe, 0, sizeof(iwe)); | |
1291 | iwe.cmd = SIOCGIWESSID; | |
1292 | iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen; | |
1293 | iwe.u.data.flags = 1; | |
1294 | ||
1295 | previous_ev = current_ev; | |
1296 | current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, (PSTRING) pAdapter->ScanTab.BssEntry[i].Ssid); | |
1297 | if (current_ev == previous_ev) | |
1298 | #if WIRELESS_EXT >= 17 | |
1299 | return -E2BIG; | |
1300 | #else | |
1301 | break; | |
1302 | #endif | |
1303 | ||
1304 | //Network Type | |
1305 | //================================ | |
1306 | memset(&iwe, 0, sizeof(iwe)); | |
1307 | iwe.cmd = SIOCGIWMODE; | |
1308 | if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS) | |
1309 | { | |
1310 | iwe.u.mode = IW_MODE_ADHOC; | |
1311 | } | |
1312 | else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure) | |
1313 | { | |
1314 | iwe.u.mode = IW_MODE_INFRA; | |
1315 | } | |
1316 | else | |
1317 | { | |
1318 | iwe.u.mode = IW_MODE_AUTO; | |
1319 | } | |
1320 | iwe.len = IW_EV_UINT_LEN; | |
1321 | ||
1322 | previous_ev = current_ev; | |
1323 | current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); | |
1324 | if (current_ev == previous_ev) | |
1325 | #if WIRELESS_EXT >= 17 | |
1326 | return -E2BIG; | |
1327 | #else | |
1328 | break; | |
1329 | #endif | |
1330 | ||
1331 | //Channel and Frequency | |
1332 | //================================ | |
1333 | memset(&iwe, 0, sizeof(iwe)); | |
1334 | iwe.cmd = SIOCGIWFREQ; | |
1335 | if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter)) | |
1336 | iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel; | |
1337 | else | |
1338 | iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel; | |
1339 | iwe.u.freq.e = 0; | |
1340 | iwe.u.freq.i = 0; | |
1341 | ||
1342 | previous_ev = current_ev; | |
1343 | current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN); | |
1344 | if (current_ev == previous_ev) | |
1345 | #if WIRELESS_EXT >= 17 | |
1346 | return -E2BIG; | |
1347 | #else | |
1348 | break; | |
1349 | #endif | |
1350 | ||
1351 | //Add quality statistics | |
1352 | //================================ | |
1353 | memset(&iwe, 0, sizeof(iwe)); | |
1354 | iwe.cmd = IWEVQUAL; | |
1355 | iwe.u.qual.level = 0; | |
1356 | iwe.u.qual.noise = 0; | |
1357 | set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi); | |
1358 | current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); | |
1359 | if (current_ev == previous_ev) | |
1360 | #if WIRELESS_EXT >= 17 | |
1361 | return -E2BIG; | |
1362 | #else | |
1363 | break; | |
1364 | #endif | |
1365 | ||
1366 | //Encyption key | |
1367 | //================================ | |
1368 | memset(&iwe, 0, sizeof(iwe)); | |
1369 | iwe.cmd = SIOCGIWENCODE; | |
1370 | if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo )) | |
1371 | iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; | |
1372 | else | |
1373 | iwe.u.data.flags = IW_ENCODE_DISABLED; | |
1374 | ||
1375 | previous_ev = current_ev; | |
1376 | current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key); | |
1377 | if (current_ev == previous_ev) | |
1378 | #if WIRELESS_EXT >= 17 | |
1379 | return -E2BIG; | |
1380 | #else | |
1381 | break; | |
1382 | #endif | |
1383 | ||
1384 | //Bit Rate | |
1385 | //================================ | |
1386 | if (pAdapter->ScanTab.BssEntry[i].SupRateLen) | |
1387 | { | |
1388 | UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1]; | |
1389 | memset(&iwe, 0, sizeof(iwe)); | |
1390 | iwe.cmd = SIOCGIWRATE; | |
1391 | current_val = current_ev + IW_EV_LCP_LEN; | |
1392 | if (tmpRate == 0x82) | |
1393 | iwe.u.bitrate.value = 1 * 1000000; | |
1394 | else if (tmpRate == 0x84) | |
1395 | iwe.u.bitrate.value = 2 * 1000000; | |
1396 | else if (tmpRate == 0x8B) | |
1397 | iwe.u.bitrate.value = 5.5 * 1000000; | |
1398 | else if (tmpRate == 0x96) | |
1399 | iwe.u.bitrate.value = 11 * 1000000; | |
1400 | else | |
1401 | iwe.u.bitrate.value = (tmpRate/2) * 1000000; | |
1402 | ||
1403 | if (tmpRate == 0x6c && pAdapter->ScanTab.BssEntry[i].HtCapabilityLen > 0) | |
1404 | { | |
1405 | int rate_count = sizeof(ralinkrate)/sizeof(__s32); | |
1406 | HT_CAP_INFO capInfo = pAdapter->ScanTab.BssEntry[i].HtCapability.HtCapInfo; | |
1407 | int shortGI = capInfo.ChannelWidth ? capInfo.ShortGIfor40 : capInfo.ShortGIfor20; | |
1408 | int maxMCS = pAdapter->ScanTab.BssEntry[i].HtCapability.MCSSet[1] ? 15 : 7; | |
1409 | int rate_index = 12 + ((UCHAR)capInfo.ChannelWidth * 24) + ((UCHAR)shortGI *48) + ((UCHAR)maxMCS); | |
1410 | if (rate_index < 0) | |
1411 | rate_index = 0; | |
1412 | if (rate_index > rate_count) | |
1413 | rate_index = rate_count; | |
1414 | iwe.u.bitrate.value = ralinkrate[rate_index] * 500000; | |
1415 | } | |
1416 | ||
1417 | iwe.u.bitrate.disabled = 0; | |
1418 | current_val = IWE_STREAM_ADD_VALUE(info, current_ev, | |
1419 | current_val, end_buf, &iwe, | |
1420 | IW_EV_PARAM_LEN); | |
1421 | ||
1422 | if((current_val-current_ev)>IW_EV_LCP_LEN) | |
1423 | current_ev = current_val; | |
1424 | else | |
1425 | #if WIRELESS_EXT >= 17 | |
1426 | return -E2BIG; | |
1427 | #else | |
1428 | break; | |
1429 | #endif | |
1430 | } | |
1431 | ||
1432 | #ifdef IWEVGENIE | |
1433 | //WPA IE | |
1434 | if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0) | |
1435 | { | |
1436 | memset(&iwe, 0, sizeof(iwe)); | |
1437 | memset(&custom[0], 0, MAX_CUSTOM_LEN); | |
1438 | memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]), | |
1439 | pAdapter->ScanTab.BssEntry[i].WpaIE.IELen); | |
1440 | iwe.cmd = IWEVGENIE; | |
1441 | iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; | |
1442 | current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); | |
1443 | if (current_ev == previous_ev) | |
1444 | #if WIRELESS_EXT >= 17 | |
1445 | return -E2BIG; | |
1446 | #else | |
1447 | break; | |
1448 | #endif | |
1449 | } | |
1450 | ||
1451 | //WPA2 IE | |
1452 | if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0) | |
1453 | { | |
1454 | memset(&iwe, 0, sizeof(iwe)); | |
1455 | memset(&custom[0], 0, MAX_CUSTOM_LEN); | |
1456 | memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]), | |
1457 | pAdapter->ScanTab.BssEntry[i].RsnIE.IELen); | |
1458 | iwe.cmd = IWEVGENIE; | |
1459 | iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; | |
1460 | current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); | |
1461 | if (current_ev == previous_ev) | |
1462 | #if WIRELESS_EXT >= 17 | |
1463 | return -E2BIG; | |
1464 | #else | |
1465 | break; | |
1466 | #endif | |
1467 | } | |
1468 | #else | |
1469 | //WPA IE | |
1470 | //================================ | |
1471 | if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0) | |
1472 | { | |
1473 | NdisZeroMemory(&iwe, sizeof(iwe)); | |
1474 | memset(&custom[0], 0, MAX_CUSTOM_LEN); | |
1475 | iwe.cmd = IWEVCUSTOM; | |
1476 | iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7; | |
1477 | NdisMoveMemory(custom, "wpa_ie=", 7); | |
1478 | for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++) | |
1479 | sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]); | |
1480 | previous_ev = current_ev; | |
1481 | current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); | |
1482 | if (current_ev == previous_ev) | |
1483 | #if WIRELESS_EXT >= 17 | |
1484 | return -E2BIG; | |
1485 | #else | |
1486 | break; | |
1487 | #endif | |
1488 | } | |
1489 | ||
1490 | //WPA2 IE | |
1491 | if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0) | |
1492 | { | |
1493 | NdisZeroMemory(&iwe, sizeof(iwe)); | |
1494 | memset(&custom[0], 0, MAX_CUSTOM_LEN); | |
1495 | iwe.cmd = IWEVCUSTOM; | |
1496 | iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7; | |
1497 | NdisMoveMemory(custom, "rsn_ie=", 7); | |
1498 | for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++) | |
1499 | sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]); | |
1500 | previous_ev = current_ev; | |
1501 | current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); | |
1502 | if (current_ev == previous_ev) | |
1503 | #if WIRELESS_EXT >= 17 | |
1504 | return -E2BIG; | |
1505 | #else | |
1506 | break; | |
1507 | #endif | |
1508 | } | |
1509 | #endif // IWEVGENIE // | |
1510 | } | |
1511 | ||
1512 | data->length = current_ev - extra; | |
1513 | pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE; | |
1514 | DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length)); | |
1515 | return 0; | |
1516 | } | |
1517 | #endif | |
1518 | ||
1519 | int rt_ioctl_siwessid(struct net_device *dev, | |
1520 | struct iw_request_info *info, | |
1521 | struct iw_point *data, char *essid) | |
1522 | { | |
1523 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1524 | ||
1525 | //check if the interface is down | |
1526 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1527 | { | |
1528 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1529 | return -ENETDOWN; | |
1530 | } | |
1531 | ||
1532 | if (data->flags) | |
1533 | { | |
1534 | PSTRING pSsidString = NULL; | |
1535 | ||
1536 | // Includes null character. | |
1537 | if (data->length > (IW_ESSID_MAX_SIZE + 1)) | |
1538 | return -E2BIG; | |
1539 | ||
1540 | pSsidString = kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG); | |
1541 | if (pSsidString) | |
1542 | { | |
1543 | NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1); | |
1544 | NdisMoveMemory(pSsidString, essid, data->length); | |
1545 | if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE) | |
1546 | return -EINVAL; | |
1547 | } | |
1548 | else | |
1549 | return -ENOMEM; | |
1550 | } | |
1551 | else | |
1552 | { | |
1553 | // ANY ssid | |
1554 | if (Set_SSID_Proc(pAdapter, "") == FALSE) | |
1555 | return -EINVAL; | |
1556 | } | |
1557 | return 0; | |
1558 | } | |
1559 | ||
1560 | int rt_ioctl_giwessid(struct net_device *dev, | |
1561 | struct iw_request_info *info, | |
1562 | struct iw_point *data, char *essid) | |
1563 | { | |
1564 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1565 | ||
1566 | if (pAdapter == NULL) | |
1567 | { | |
1568 | /* if 1st open fail, pAd will be free; | |
1569 | So the net_dev->priv will be NULL in 2rd open */ | |
1570 | return -ENETDOWN; | |
1571 | } | |
1572 | ||
1573 | data->flags = 1; | |
1574 | if (MONITOR_ON(pAdapter)) | |
1575 | { | |
1576 | data->length = 0; | |
1577 | return 0; | |
1578 | } | |
1579 | ||
1580 | if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) | |
1581 | { | |
1582 | DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n")); | |
1583 | data->length = pAdapter->CommonCfg.SsidLen; | |
1584 | memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen); | |
1585 | } | |
1586 | else | |
1587 | {//the ANY ssid was specified | |
1588 | data->length = 0; | |
1589 | DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n")); | |
1590 | } | |
1591 | ||
1592 | return 0; | |
1593 | ||
1594 | } | |
1595 | ||
1596 | int rt_ioctl_siwnickn(struct net_device *dev, | |
1597 | struct iw_request_info *info, | |
1598 | struct iw_point *data, char *nickname) | |
1599 | { | |
1600 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1601 | ||
1602 | //check if the interface is down | |
1603 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1604 | { | |
1605 | DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n")); | |
1606 | return -ENETDOWN; | |
1607 | } | |
1608 | ||
1609 | if (data->length > IW_ESSID_MAX_SIZE) | |
1610 | return -EINVAL; | |
1611 | ||
1612 | memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1); | |
1613 | memcpy(pAdapter->nickname, nickname, data->length); | |
1614 | ||
1615 | ||
1616 | return 0; | |
1617 | } | |
1618 | ||
1619 | int rt_ioctl_giwnickn(struct net_device *dev, | |
1620 | struct iw_request_info *info, | |
1621 | struct iw_point *data, char *nickname) | |
1622 | { | |
1623 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1624 | ||
1625 | if (pAdapter == NULL) | |
1626 | { | |
1627 | /* if 1st open fail, pAd will be free; | |
1628 | So the net_dev->priv will be NULL in 2rd open */ | |
1629 | return -ENETDOWN; | |
1630 | } | |
1631 | ||
1632 | if (data->length > strlen((PSTRING) pAdapter->nickname) + 1) | |
1633 | data->length = strlen((PSTRING) pAdapter->nickname) + 1; | |
1634 | if (data->length > 0) { | |
1635 | memcpy(nickname, pAdapter->nickname, data->length-1); | |
1636 | nickname[data->length-1] = '\0'; | |
1637 | } | |
1638 | return 0; | |
1639 | } | |
1640 | ||
1641 | int rt_ioctl_siwrts(struct net_device *dev, | |
1642 | struct iw_request_info *info, | |
1643 | struct iw_param *rts, char *extra) | |
1644 | { | |
1645 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1646 | u16 val; | |
1647 | ||
1648 | //check if the interface is down | |
1649 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1650 | { | |
1651 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1652 | return -ENETDOWN; | |
1653 | } | |
1654 | ||
1655 | if (rts->disabled) | |
1656 | val = MAX_RTS_THRESHOLD; | |
1657 | else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD) | |
1658 | return -EINVAL; | |
1659 | else if (rts->value == 0) | |
1660 | val = MAX_RTS_THRESHOLD; | |
1661 | else | |
1662 | val = rts->value; | |
1663 | ||
1664 | if (val != pAdapter->CommonCfg.RtsThreshold) | |
1665 | pAdapter->CommonCfg.RtsThreshold = val; | |
1666 | ||
1667 | return 0; | |
1668 | } | |
1669 | ||
1670 | int rt_ioctl_giwrts(struct net_device *dev, | |
1671 | struct iw_request_info *info, | |
1672 | struct iw_param *rts, char *extra) | |
1673 | { | |
1674 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1675 | ||
1676 | if (pAdapter == NULL) | |
1677 | { | |
1678 | /* if 1st open fail, pAd will be free; | |
1679 | So the net_dev->priv will be NULL in 2rd open */ | |
1680 | return -ENETDOWN; | |
1681 | } | |
1682 | ||
1683 | //check if the interface is down | |
1684 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1685 | { | |
1686 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1687 | return -ENETDOWN; | |
1688 | } | |
1689 | ||
1690 | rts->value = pAdapter->CommonCfg.RtsThreshold; | |
1691 | rts->disabled = (rts->value == MAX_RTS_THRESHOLD); | |
1692 | rts->fixed = 1; | |
1693 | ||
1694 | return 0; | |
1695 | } | |
1696 | ||
1697 | int rt_ioctl_siwfrag(struct net_device *dev, | |
1698 | struct iw_request_info *info, | |
1699 | struct iw_param *frag, char *extra) | |
1700 | { | |
1701 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1702 | u16 val; | |
1703 | ||
1704 | //check if the interface is down | |
1705 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1706 | { | |
1707 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1708 | return -ENETDOWN; | |
1709 | } | |
1710 | ||
1711 | if (frag->disabled) | |
1712 | val = MAX_FRAG_THRESHOLD; | |
1713 | else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD) | |
1714 | val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */ | |
1715 | else if (frag->value == 0) | |
1716 | val = MAX_FRAG_THRESHOLD; | |
1717 | else | |
1718 | return -EINVAL; | |
1719 | ||
1720 | pAdapter->CommonCfg.FragmentThreshold = val; | |
1721 | return 0; | |
1722 | } | |
1723 | ||
1724 | int rt_ioctl_giwfrag(struct net_device *dev, | |
1725 | struct iw_request_info *info, | |
1726 | struct iw_param *frag, char *extra) | |
1727 | { | |
1728 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1729 | ||
1730 | if (pAdapter == NULL) | |
1731 | { | |
1732 | /* if 1st open fail, pAd will be free; | |
1733 | So the net_dev->priv will be NULL in 2rd open */ | |
1734 | return -ENETDOWN; | |
1735 | } | |
1736 | ||
1737 | //check if the interface is down | |
1738 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1739 | { | |
1740 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1741 | return -ENETDOWN; | |
1742 | } | |
1743 | ||
1744 | frag->value = pAdapter->CommonCfg.FragmentThreshold; | |
1745 | frag->disabled = (frag->value == MAX_FRAG_THRESHOLD); | |
1746 | frag->fixed = 1; | |
1747 | ||
1748 | return 0; | |
1749 | } | |
1750 | ||
1751 | #define MAX_WEP_KEY_SIZE 13 | |
1752 | #define MIN_WEP_KEY_SIZE 5 | |
1753 | int rt_ioctl_siwencode(struct net_device *dev, | |
1754 | struct iw_request_info *info, | |
1755 | struct iw_point *erq, char *extra) | |
1756 | { | |
1757 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1758 | ||
1759 | //check if the interface is down | |
1760 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1761 | { | |
1762 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1763 | return -ENETDOWN; | |
1764 | } | |
1765 | ||
1766 | if ((erq->length == 0) && | |
1767 | (erq->flags & IW_ENCODE_DISABLED)) | |
1768 | { | |
1769 | pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled; | |
1770 | pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled; | |
1771 | pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled; | |
1772 | pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; | |
1773 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen; | |
1774 | goto done; | |
1775 | } | |
1776 | else if (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN) | |
1777 | { | |
1778 | //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
1779 | STA_PORT_SECURED(pAdapter); | |
1780 | pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled; | |
1781 | pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled; | |
1782 | pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled; | |
1783 | pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; | |
1784 | if (erq->flags & IW_ENCODE_RESTRICTED) | |
1785 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared; | |
1786 | else | |
1787 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen; | |
1788 | } | |
1789 | ||
1790 | if (erq->length > 0) | |
1791 | { | |
1792 | int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1; | |
1793 | /* Check the size of the key */ | |
1794 | if (erq->length > MAX_WEP_KEY_SIZE) | |
1795 | { | |
1796 | return -EINVAL; | |
1797 | } | |
1798 | /* Check key index */ | |
1799 | if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS)) | |
1800 | { | |
1801 | DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n", | |
1802 | keyIdx, pAdapter->StaCfg.DefaultKeyId)); | |
1803 | ||
1804 | //Using default key | |
1805 | keyIdx = pAdapter->StaCfg.DefaultKeyId; | |
1806 | } | |
1807 | else | |
1808 | pAdapter->StaCfg.DefaultKeyId = keyIdx; | |
1809 | ||
1810 | NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16); | |
1811 | ||
1812 | if (erq->length == MAX_WEP_KEY_SIZE) | |
1813 | { | |
1814 | pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE; | |
1815 | pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128; | |
1816 | } | |
1817 | else if (erq->length == MIN_WEP_KEY_SIZE) | |
1818 | { | |
1819 | pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE; | |
1820 | pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64; | |
1821 | } | |
1822 | else | |
1823 | /* Disable the key */ | |
1824 | pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0; | |
1825 | ||
1826 | /* Check if the key is not marked as invalid */ | |
1827 | if(!(erq->flags & IW_ENCODE_NOKEY)) | |
1828 | { | |
1829 | /* Copy the key in the driver */ | |
1830 | NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length); | |
1831 | } | |
1832 | } | |
1833 | else | |
1834 | { | |
1835 | /* Do we want to just set the transmit key index ? */ | |
1836 | int index = (erq->flags & IW_ENCODE_INDEX) - 1; | |
1837 | if ((index >= 0) && (index < 4)) | |
1838 | { | |
1839 | pAdapter->StaCfg.DefaultKeyId = index; | |
1840 | } | |
1841 | else | |
1842 | /* Don't complain if only change the mode */ | |
2e9ab1e7 JL |
1843 | if (!(erq->flags & IW_ENCODE_MODE)) |
1844 | return -EINVAL; | |
36c7928c BZ |
1845 | } |
1846 | ||
1847 | done: | |
1848 | DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags)); | |
1849 | DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode)); | |
1850 | DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen)); | |
1851 | DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus)); | |
1852 | return 0; | |
1853 | } | |
1854 | ||
1855 | int | |
1856 | rt_ioctl_giwencode(struct net_device *dev, | |
1857 | struct iw_request_info *info, | |
1858 | struct iw_point *erq, char *key) | |
1859 | { | |
1860 | int kid; | |
1861 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1862 | ||
1863 | if (pAdapter == NULL) | |
1864 | { | |
1865 | /* if 1st open fail, pAd will be free; | |
1866 | So the net_dev->priv will be NULL in 2rd open */ | |
1867 | return -ENETDOWN; | |
1868 | } | |
1869 | ||
1870 | //check if the interface is down | |
1871 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1872 | { | |
1873 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1874 | return -ENETDOWN; | |
1875 | } | |
1876 | ||
1877 | kid = erq->flags & IW_ENCODE_INDEX; | |
1878 | DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX)); | |
1879 | ||
1880 | if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) | |
1881 | { | |
1882 | erq->length = 0; | |
1883 | erq->flags = IW_ENCODE_DISABLED; | |
1884 | } | |
1885 | else if ((kid > 0) && (kid <=4)) | |
1886 | { | |
1887 | // copy wep key | |
1888 | erq->flags = kid ; /* NB: base 1 */ | |
1889 | if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen) | |
1890 | erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen; | |
1891 | memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length); | |
1892 | //if ((kid == pAdapter->PortCfg.DefaultKeyId)) | |
1893 | //erq->flags |= IW_ENCODE_ENABLED; /* XXX */ | |
1894 | if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) | |
1895 | erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */ | |
1896 | else | |
1897 | erq->flags |= IW_ENCODE_OPEN; /* XXX */ | |
1898 | ||
1899 | } | |
1900 | else if (kid == 0) | |
1901 | { | |
1902 | if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) | |
1903 | erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */ | |
1904 | else | |
1905 | erq->flags |= IW_ENCODE_OPEN; /* XXX */ | |
1906 | erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen; | |
1907 | memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length); | |
1908 | // copy default key ID | |
1909 | if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) | |
1910 | erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */ | |
1911 | else | |
1912 | erq->flags |= IW_ENCODE_OPEN; /* XXX */ | |
1913 | erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */ | |
1914 | erq->flags |= IW_ENCODE_ENABLED; /* XXX */ | |
1915 | } | |
1916 | ||
1917 | return 0; | |
1918 | ||
1919 | } | |
1920 | ||
1921 | static int | |
1922 | rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info, | |
1923 | void *w, char *extra) | |
1924 | { | |
1925 | PRTMP_ADAPTER pAdapter; | |
1926 | POS_COOKIE pObj; | |
1927 | PSTRING this_char = extra; | |
1928 | PSTRING value; | |
1929 | int Status=0; | |
1930 | ||
1931 | pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1932 | if (pAdapter == NULL) | |
1933 | { | |
1934 | /* if 1st open fail, pAd will be free; | |
1935 | So the net_dev->priv will be NULL in 2rd open */ | |
1936 | return -ENETDOWN; | |
1937 | } | |
1938 | ||
1939 | pObj = (POS_COOKIE) pAdapter->OS_Cookie; | |
1940 | { | |
1941 | pObj->ioctl_if_type = INT_MAIN; | |
1942 | pObj->ioctl_if = MAIN_MBSSID; | |
1943 | } | |
1944 | ||
1945 | //check if the interface is down | |
1946 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
1947 | { | |
1948 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
1949 | return -ENETDOWN; | |
1950 | } | |
1951 | ||
1952 | if (!*this_char) | |
1953 | return -EINVAL; | |
1954 | ||
1955 | if ((value = rtstrchr(this_char, '=')) != NULL) | |
1956 | *value++ = 0; | |
1957 | ||
1958 | if (!value && (strcmp(this_char, "SiteSurvey") != 0)) | |
1959 | return -EINVAL; | |
1960 | else | |
1961 | goto SET_PROC; | |
1962 | ||
1963 | // reject setting nothing besides ANY ssid(ssidLen=0) | |
1964 | if (!*value && (strcmp(this_char, "SSID") != 0)) | |
1965 | return -EINVAL; | |
1966 | ||
1967 | SET_PROC: | |
1968 | for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++) | |
1969 | { | |
1970 | if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0) | |
1971 | { | |
1972 | if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value)) | |
1973 | { //FALSE:Set private failed then return Invalid argument | |
1974 | Status = -EINVAL; | |
1975 | } | |
1976 | break; //Exit for loop. | |
1977 | } | |
1978 | } | |
1979 | ||
1980 | if(PRTMP_PRIVATE_SET_PROC->name == NULL) | |
1981 | { //Not found argument | |
1982 | Status = -EINVAL; | |
1983 | DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value)); | |
1984 | } | |
1985 | ||
1986 | return Status; | |
1987 | } | |
1988 | ||
1989 | ||
1990 | static int | |
1991 | rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info, | |
1992 | struct iw_point *wrq, char *extra) | |
1993 | { | |
1994 | INT Status = 0; | |
1995 | PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev); | |
1996 | ||
1997 | if (extra == NULL) | |
1998 | { | |
1999 | wrq->length = 0; | |
2000 | return -EIO; | |
2001 | } | |
2002 | ||
2003 | memset(extra, 0x00, IW_PRIV_SIZE_MASK); | |
2004 | sprintf(extra, "\n\n"); | |
2005 | ||
2006 | #ifdef RALINK_ATE | |
2007 | if (ATE_ON(pAd)) | |
2008 | { | |
2009 | sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->ate.TxDoneCount); | |
2010 | //sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->ate.TxDoneCount); | |
2011 | } | |
2012 | else | |
2013 | #endif // RALINK_ATE // | |
2014 | { | |
2015 | sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart); | |
2016 | sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart); | |
2017 | } | |
2018 | sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart); | |
2019 | sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart); | |
2020 | sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart); | |
2021 | sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart); | |
2022 | ||
2023 | sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart); | |
2024 | sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart); | |
2025 | sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer); | |
2026 | sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart); | |
2027 | ||
2028 | sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt); | |
2029 | ||
2030 | #ifdef RALINK_ATE | |
2031 | if (ATE_ON(pAd)) | |
2032 | { | |
2033 | if (pAd->ate.RxAntennaSel == 0) | |
2034 | { | |
2035 | sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta)); | |
2036 | sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->ate.LastRssi1 - pAd->BbpRssiToDbmDelta)); | |
2037 | sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->ate.LastRssi2 - pAd->BbpRssiToDbmDelta)); | |
2038 | } | |
2039 | else | |
2040 | { | |
2041 | sprintf(extra+strlen(extra), "RSSI = %ld\n", (LONG)(pAd->ate.LastRssi0 - pAd->BbpRssiToDbmDelta)); | |
2042 | } | |
2043 | } | |
2044 | else | |
2045 | #endif // RALINK_ATE // | |
2046 | { | |
2047 | sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta)); | |
2048 | sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta)); | |
2049 | sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta)); | |
2050 | } | |
2051 | #ifdef WPA_SUPPLICANT_SUPPORT | |
2052 | sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP); | |
2053 | #endif // WPA_SUPPLICANT_SUPPORT // | |
2054 | ||
2055 | ||
2056 | ||
2057 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
2058 | DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length)); | |
2059 | ||
2060 | return Status; | |
2061 | } | |
2062 | ||
2063 | #ifdef DOT11_N_SUPPORT | |
2064 | void getBaInfo( | |
2065 | IN PRTMP_ADAPTER pAd, | |
2066 | IN PSTRING pOutBuf) | |
2067 | { | |
2068 | INT i, j; | |
2069 | BA_ORI_ENTRY *pOriBAEntry; | |
2070 | BA_REC_ENTRY *pRecBAEntry; | |
2071 | ||
2072 | for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++) | |
2073 | { | |
2074 | PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i]; | |
2075 | if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC)) | |
2076 | || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh)) | |
2077 | { | |
2078 | sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n", | |
2079 | pOutBuf, | |
2080 | pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2], | |
2081 | pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid); | |
2082 | ||
2083 | sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf); | |
2084 | for (j=0; j < NUM_OF_TID; j++) | |
2085 | { | |
2086 | if (pEntry->BARecWcidArray[j] != 0) | |
2087 | { | |
2088 | pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]]; | |
2089 | sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen); | |
2090 | } | |
2091 | } | |
2092 | sprintf(pOutBuf, "%s\n", pOutBuf); | |
2093 | ||
2094 | sprintf(pOutBuf, "%s[Originator]\n", pOutBuf); | |
2095 | for (j=0; j < NUM_OF_TID; j++) | |
2096 | { | |
2097 | if (pEntry->BAOriWcidArray[j] != 0) | |
2098 | { | |
2099 | pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]]; | |
2100 | sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]); | |
2101 | } | |
2102 | } | |
2103 | sprintf(pOutBuf, "%s\n\n", pOutBuf); | |
2104 | } | |
2105 | if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30)) | |
2106 | break; | |
2107 | } | |
2108 | ||
2109 | return; | |
2110 | } | |
2111 | #endif // DOT11_N_SUPPORT // | |
2112 | ||
2113 | static int | |
2114 | rt_private_show(struct net_device *dev, struct iw_request_info *info, | |
2115 | struct iw_point *wrq, PSTRING extra) | |
2116 | { | |
2117 | INT Status = 0; | |
2118 | PRTMP_ADAPTER pAd; | |
2119 | POS_COOKIE pObj; | |
2120 | u32 subcmd = wrq->flags; | |
2121 | ||
2122 | pAd = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2123 | if (pAd == NULL) | |
2124 | { | |
2125 | /* if 1st open fail, pAd will be free; | |
2126 | So the net_dev->priv will be NULL in 2rd open */ | |
2127 | return -ENETDOWN; | |
2128 | } | |
2129 | ||
2130 | pObj = (POS_COOKIE) pAd->OS_Cookie; | |
2131 | if (extra == NULL) | |
2132 | { | |
2133 | wrq->length = 0; | |
2134 | return -EIO; | |
2135 | } | |
2136 | memset(extra, 0x00, IW_PRIV_SIZE_MASK); | |
2137 | ||
2138 | { | |
2139 | pObj->ioctl_if_type = INT_MAIN; | |
2140 | pObj->ioctl_if = MAIN_MBSSID; | |
2141 | } | |
2142 | ||
2143 | switch(subcmd) | |
2144 | { | |
2145 | ||
2146 | case SHOW_CONN_STATUS: | |
2147 | if (MONITOR_ON(pAd)) | |
2148 | { | |
2149 | #ifdef DOT11_N_SUPPORT | |
2150 | if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED && | |
2151 | pAd->CommonCfg.RegTransmitSetting.field.BW) | |
2152 | sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel); | |
2153 | else | |
2154 | #endif // DOT11_N_SUPPORT // | |
2155 | sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel); | |
2156 | } | |
2157 | else | |
2158 | { | |
2159 | if (pAd->IndicateMediaState == NdisMediaStateConnected) | |
2160 | { | |
2161 | if (INFRA_ON(pAd)) | |
2162 | { | |
2163 | sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n", | |
2164 | pAd->CommonCfg.Ssid, | |
2165 | pAd->CommonCfg.Bssid[0], | |
2166 | pAd->CommonCfg.Bssid[1], | |
2167 | pAd->CommonCfg.Bssid[2], | |
2168 | pAd->CommonCfg.Bssid[3], | |
2169 | pAd->CommonCfg.Bssid[4], | |
2170 | pAd->CommonCfg.Bssid[5]); | |
2171 | DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen)); | |
2172 | } | |
2173 | else if (ADHOC_ON(pAd)) | |
2174 | sprintf(extra, "Connected\n"); | |
2175 | } | |
2176 | else | |
2177 | { | |
2178 | sprintf(extra, "Disconnected\n"); | |
2179 | DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n")); | |
2180 | } | |
2181 | } | |
2182 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
2183 | break; | |
2184 | case SHOW_DRVIER_VERION: | |
2185 | sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ ); | |
2186 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
2187 | break; | |
2188 | #ifdef DOT11_N_SUPPORT | |
2189 | case SHOW_BA_INFO: | |
2190 | getBaInfo(pAd, extra); | |
2191 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
2192 | break; | |
2193 | #endif // DOT11_N_SUPPORT // | |
2194 | case SHOW_DESC_INFO: | |
2195 | { | |
2196 | Show_DescInfo_Proc(pAd, NULL); | |
2197 | wrq->length = 0; // 1: size of '\0' | |
2198 | } | |
2199 | break; | |
2200 | case RAIO_OFF: | |
2201 | if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) | |
2202 | { | |
2203 | if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) | |
2204 | { | |
2205 | RTMP_MLME_RESET_STATE_MACHINE(pAd); | |
2206 | DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n")); | |
2207 | } | |
2208 | } | |
2209 | pAd->StaCfg.bSwRadio = FALSE; | |
2210 | if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio)) | |
2211 | { | |
2212 | pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio); | |
2213 | if (pAd->StaCfg.bRadio == FALSE) | |
2214 | { | |
2215 | MlmeRadioOff(pAd); | |
2216 | // Update extra information | |
2217 | pAd->ExtraInfo = SW_RADIO_OFF; | |
2218 | } | |
2219 | } | |
2220 | sprintf(extra, "Radio Off\n"); | |
2221 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
2222 | break; | |
2223 | case RAIO_ON: | |
2224 | pAd->StaCfg.bSwRadio = TRUE; | |
2225 | //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio)) | |
2226 | { | |
2227 | pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio); | |
2228 | if (pAd->StaCfg.bRadio == TRUE) | |
2229 | { | |
2230 | MlmeRadioOn(pAd); | |
2231 | // Update extra information | |
2232 | pAd->ExtraInfo = EXTRA_INFO_CLEAR; | |
2233 | } | |
2234 | } | |
2235 | sprintf(extra, "Radio On\n"); | |
2236 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
2237 | break; | |
2238 | ||
2239 | ||
2240 | #ifdef QOS_DLS_SUPPORT | |
2241 | case SHOW_DLS_ENTRY_INFO: | |
2242 | { | |
2243 | Set_DlsEntryInfo_Display_Proc(pAd, NULL); | |
2244 | wrq->length = 0; // 1: size of '\0' | |
2245 | } | |
2246 | break; | |
2247 | #endif // QOS_DLS_SUPPORT // | |
2248 | ||
2249 | case SHOW_CFG_VALUE: | |
2250 | { | |
2251 | Status = RTMPShowCfgValue(pAd, (PSTRING) wrq->pointer, extra); | |
2252 | if (Status == 0) | |
2253 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
2254 | } | |
2255 | break; | |
2256 | case SHOW_ADHOC_ENTRY_INFO: | |
2257 | Show_Adhoc_MacTable_Proc(pAd, extra); | |
2258 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
2259 | break; | |
2260 | default: | |
2261 | DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd)); | |
2262 | break; | |
2263 | } | |
2264 | ||
2265 | return Status; | |
2266 | } | |
2267 | ||
2268 | #ifdef SIOCSIWMLME | |
2269 | int rt_ioctl_siwmlme(struct net_device *dev, | |
2270 | struct iw_request_info *info, | |
2271 | union iwreq_data *wrqu, | |
2272 | char *extra) | |
2273 | { | |
2274 | PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2275 | struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer; | |
2276 | MLME_QUEUE_ELEM MsgElem; | |
2277 | MLME_DISASSOC_REQ_STRUCT DisAssocReq; | |
2278 | MLME_DEAUTH_REQ_STRUCT DeAuthReq; | |
2279 | ||
2280 | DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__)); | |
2281 | ||
2282 | if (pMlme == NULL) | |
2283 | return -EINVAL; | |
2284 | ||
2285 | switch(pMlme->cmd) | |
2286 | { | |
2287 | #ifdef IW_MLME_DEAUTH | |
2288 | case IW_MLME_DEAUTH: | |
2289 | DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__)); | |
2290 | COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid); | |
2291 | DeAuthReq.Reason = pMlme->reason_code; | |
2292 | MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT); | |
2293 | NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT)); | |
2294 | MlmeDeauthReqAction(pAd, &MsgElem); | |
2295 | if (INFRA_ON(pAd)) | |
2296 | { | |
2297 | LinkDown(pAd, FALSE); | |
2298 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; | |
2299 | } | |
2300 | break; | |
2301 | #endif // IW_MLME_DEAUTH // | |
2302 | #ifdef IW_MLME_DISASSOC | |
2303 | case IW_MLME_DISASSOC: | |
2304 | DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __FUNCTION__)); | |
2305 | COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid); | |
2306 | DisAssocReq.Reason = pMlme->reason_code; | |
2307 | ||
2308 | MsgElem.Machine = ASSOC_STATE_MACHINE; | |
2309 | MsgElem.MsgType = MT2_MLME_DISASSOC_REQ; | |
2310 | MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT); | |
2311 | NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT)); | |
2312 | ||
2313 | pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC; | |
2314 | MlmeDisassocReqAction(pAd, &MsgElem); | |
2315 | break; | |
2316 | #endif // IW_MLME_DISASSOC // | |
2317 | default: | |
2318 | DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__)); | |
2319 | break; | |
2320 | } | |
2321 | ||
2322 | return 0; | |
2323 | } | |
2324 | #endif // SIOCSIWMLME // | |
2325 | ||
2326 | #if WIRELESS_EXT > 17 | |
2327 | int rt_ioctl_siwauth(struct net_device *dev, | |
2328 | struct iw_request_info *info, | |
2329 | union iwreq_data *wrqu, char *extra) | |
2330 | { | |
2331 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2332 | struct iw_param *param = &wrqu->param; | |
2333 | ||
2334 | //check if the interface is down | |
2335 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
2336 | { | |
2337 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
2338 | return -ENETDOWN; | |
2339 | } | |
2340 | switch (param->flags & IW_AUTH_INDEX) { | |
2341 | case IW_AUTH_WPA_VERSION: | |
2342 | if (param->value == IW_AUTH_WPA_VERSION_WPA) | |
2343 | { | |
2344 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK; | |
2345 | if (pAdapter->StaCfg.BssType == BSS_ADHOC) | |
2346 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone; | |
2347 | } | |
2348 | else if (param->value == IW_AUTH_WPA_VERSION_WPA2) | |
2349 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK; | |
2350 | ||
2351 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); | |
2352 | break; | |
2353 | case IW_AUTH_CIPHER_PAIRWISE: | |
2354 | if (param->value == IW_AUTH_CIPHER_NONE) | |
2355 | { | |
2356 | pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled; | |
2357 | pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; | |
2358 | pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled; | |
2359 | } | |
2360 | else if (param->value == IW_AUTH_CIPHER_WEP40 || | |
2361 | param->value == IW_AUTH_CIPHER_WEP104) | |
2362 | { | |
2363 | pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled; | |
2364 | pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; | |
2365 | pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled; | |
2366 | #ifdef WPA_SUPPLICANT_SUPPORT | |
2367 | pAdapter->StaCfg.IEEE8021X = FALSE; | |
2368 | #endif // WPA_SUPPLICANT_SUPPORT // | |
2369 | } | |
2370 | else if (param->value == IW_AUTH_CIPHER_TKIP) | |
2371 | { | |
2372 | pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled; | |
2373 | pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; | |
2374 | pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled; | |
2375 | } | |
2376 | else if (param->value == IW_AUTH_CIPHER_CCMP) | |
2377 | { | |
2378 | pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled; | |
2379 | pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; | |
2380 | pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled; | |
2381 | } | |
2382 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__, param->value)); | |
2383 | break; | |
2384 | case IW_AUTH_CIPHER_GROUP: | |
2385 | if (param->value == IW_AUTH_CIPHER_NONE) | |
2386 | { | |
2387 | pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled; | |
2388 | } | |
2389 | else if (param->value == IW_AUTH_CIPHER_WEP40 || | |
2390 | param->value == IW_AUTH_CIPHER_WEP104) | |
2391 | { | |
2392 | pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled; | |
2393 | } | |
2394 | else if (param->value == IW_AUTH_CIPHER_TKIP) | |
2395 | { | |
2396 | pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled; | |
2397 | } | |
2398 | else if (param->value == IW_AUTH_CIPHER_CCMP) | |
2399 | { | |
2400 | pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled; | |
2401 | } | |
2402 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__, param->value)); | |
2403 | break; | |
2404 | case IW_AUTH_KEY_MGMT: | |
2405 | if (param->value == IW_AUTH_KEY_MGMT_802_1X) | |
2406 | { | |
2407 | if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) | |
2408 | { | |
2409 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA; | |
2410 | #ifdef WPA_SUPPLICANT_SUPPORT | |
2411 | pAdapter->StaCfg.IEEE8021X = FALSE; | |
2412 | #endif // WPA_SUPPLICANT_SUPPORT // | |
2413 | } | |
2414 | else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) | |
2415 | { | |
2416 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2; | |
2417 | #ifdef WPA_SUPPLICANT_SUPPORT | |
2418 | pAdapter->StaCfg.IEEE8021X = FALSE; | |
2419 | #endif // WPA_SUPPLICANT_SUPPORT // | |
2420 | } | |
2421 | #ifdef WPA_SUPPLICANT_SUPPORT | |
2422 | else | |
2423 | // WEP 1x | |
2424 | pAdapter->StaCfg.IEEE8021X = TRUE; | |
2425 | #endif // WPA_SUPPLICANT_SUPPORT // | |
2426 | } | |
2427 | else if (param->value == 0) | |
2428 | { | |
2429 | //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
2430 | STA_PORT_SECURED(pAdapter); | |
2431 | } | |
2432 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__, param->value)); | |
2433 | break; | |
2434 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: | |
2435 | break; | |
2436 | case IW_AUTH_PRIVACY_INVOKED: | |
2437 | /*if (param->value == 0) | |
2438 | { | |
2439 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen; | |
2440 | pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled; | |
2441 | pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; | |
2442 | pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled; | |
2443 | pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled; | |
2444 | }*/ | |
2445 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__, param->value)); | |
2446 | break; | |
2447 | case IW_AUTH_DROP_UNENCRYPTED: | |
2448 | if (param->value != 0) | |
2449 | pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; | |
2450 | else | |
2451 | { | |
2452 | //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
2453 | STA_PORT_SECURED(pAdapter); | |
2454 | } | |
2455 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); | |
2456 | break; | |
2457 | case IW_AUTH_80211_AUTH_ALG: | |
2458 | if (param->value & IW_AUTH_ALG_SHARED_KEY) | |
2459 | { | |
2460 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared; | |
2461 | } | |
2462 | else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) | |
2463 | { | |
2464 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen; | |
2465 | } | |
2466 | else | |
2467 | return -EINVAL; | |
2468 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value)); | |
2469 | break; | |
2470 | case IW_AUTH_WPA_ENABLED: | |
2471 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __FUNCTION__, param->value)); | |
2472 | break; | |
2473 | default: | |
2474 | return -EOPNOTSUPP; | |
2475 | } | |
2476 | ||
2477 | return 0; | |
2478 | } | |
2479 | ||
2480 | int rt_ioctl_giwauth(struct net_device *dev, | |
2481 | struct iw_request_info *info, | |
2482 | union iwreq_data *wrqu, char *extra) | |
2483 | { | |
2484 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2485 | struct iw_param *param = &wrqu->param; | |
2486 | ||
2487 | //check if the interface is down | |
2488 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
2489 | { | |
2490 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
2491 | return -ENETDOWN; | |
2492 | } | |
2493 | ||
2494 | switch (param->flags & IW_AUTH_INDEX) { | |
2495 | case IW_AUTH_DROP_UNENCRYPTED: | |
2496 | param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1; | |
2497 | break; | |
2498 | ||
2499 | case IW_AUTH_80211_AUTH_ALG: | |
2500 | param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM; | |
2501 | break; | |
2502 | ||
2503 | case IW_AUTH_WPA_ENABLED: | |
2504 | param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0; | |
2505 | break; | |
2506 | ||
2507 | default: | |
2508 | return -EOPNOTSUPP; | |
2509 | } | |
2510 | DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value)); | |
2511 | return 0; | |
2512 | } | |
2513 | ||
2514 | void fnSetCipherKey( | |
2515 | IN PRTMP_ADAPTER pAdapter, | |
2516 | IN INT keyIdx, | |
2517 | IN UCHAR CipherAlg, | |
2518 | IN BOOLEAN bGTK, | |
2519 | IN struct iw_encode_ext *ext) | |
2520 | { | |
2521 | NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY)); | |
2522 | pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK; | |
2523 | NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK); | |
2524 | NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK); | |
2525 | NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK); | |
2526 | pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg; | |
2527 | ||
2528 | // Update group key information to ASIC Shared Key Table | |
2529 | AsicAddSharedKeyEntry(pAdapter, | |
2530 | BSS0, | |
2531 | keyIdx, | |
2532 | pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, | |
2533 | pAdapter->SharedKey[BSS0][keyIdx].Key, | |
2534 | pAdapter->SharedKey[BSS0][keyIdx].TxMic, | |
2535 | pAdapter->SharedKey[BSS0][keyIdx].RxMic); | |
2536 | ||
2537 | if (bGTK) | |
2538 | // Update ASIC WCID attribute table and IVEIV table | |
2539 | RTMPAddWcidAttributeEntry(pAdapter, | |
2540 | BSS0, | |
2541 | keyIdx, | |
2542 | pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, | |
2543 | NULL); | |
2544 | else | |
2545 | // Update ASIC WCID attribute table and IVEIV table | |
2546 | RTMPAddWcidAttributeEntry(pAdapter, | |
2547 | BSS0, | |
2548 | keyIdx, | |
2549 | pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, | |
2550 | &pAdapter->MacTab.Content[BSSID_WCID]); | |
2551 | } | |
2552 | ||
2553 | int rt_ioctl_siwencodeext(struct net_device *dev, | |
2554 | struct iw_request_info *info, | |
2555 | union iwreq_data *wrqu, | |
2556 | char *extra) | |
2557 | { | |
2558 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2559 | struct iw_point *encoding = &wrqu->encoding; | |
2560 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; | |
2561 | int keyIdx, alg = ext->alg; | |
2562 | ||
2563 | //check if the interface is down | |
2564 | if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
2565 | { | |
2566 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
2567 | return -ENETDOWN; | |
2568 | } | |
2569 | ||
2570 | if (encoding->flags & IW_ENCODE_DISABLED) | |
2571 | { | |
2572 | keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1; | |
2573 | // set BSSID wcid entry of the Pair-wise Key table as no-security mode | |
2574 | AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID); | |
2575 | pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0; | |
2576 | pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE; | |
2577 | AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx); | |
2578 | NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY)); | |
2579 | DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __FUNCTION__, encoding->flags)); | |
2580 | } | |
2581 | else | |
2582 | { | |
2583 | // Get Key Index and convet to our own defined key index | |
2584 | keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1; | |
2585 | if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS)) | |
2586 | return -EINVAL; | |
2587 | ||
2588 | if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) | |
2589 | { | |
2590 | pAdapter->StaCfg.DefaultKeyId = keyIdx; | |
2591 | DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __FUNCTION__, pAdapter->StaCfg.DefaultKeyId)); | |
2592 | } | |
2593 | ||
2594 | switch (alg) { | |
2595 | case IW_ENCODE_ALG_NONE: | |
2596 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__)); | |
2597 | break; | |
2598 | case IW_ENCODE_ALG_WEP: | |
2599 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx)); | |
2600 | if (ext->key_len == MAX_WEP_KEY_SIZE) | |
2601 | { | |
2602 | pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE; | |
2603 | pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128; | |
2604 | } | |
2605 | else if (ext->key_len == MIN_WEP_KEY_SIZE) | |
2606 | { | |
2607 | pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE; | |
2608 | pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64; | |
2609 | } | |
2610 | else | |
2611 | return -EINVAL; | |
2612 | ||
2613 | NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16); | |
2614 | NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len); | |
2615 | ||
2616 | if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled || | |
2617 | pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled) | |
2618 | { | |
2619 | // Set Group key material to Asic | |
2620 | AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL); | |
2621 | // Update WCID attribute table and IVEIV table for this group key table | |
2622 | RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL); | |
2623 | STA_PORT_SECURED(pAdapter); | |
2624 | // Indicate Connected for GUI | |
2625 | pAdapter->IndicateMediaState = NdisMediaStateConnected; | |
2626 | } | |
2627 | break; | |
2628 | case IW_ENCODE_ALG_TKIP: | |
2629 | DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __FUNCTION__, keyIdx, ext->key_len)); | |
2630 | if (ext->key_len == 32) | |
2631 | { | |
2632 | if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) | |
2633 | { | |
2634 | fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext); | |
2635 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2) | |
2636 | { | |
2637 | //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
2638 | STA_PORT_SECURED(pAdapter); | |
2639 | pAdapter->IndicateMediaState = NdisMediaStateConnected; | |
2640 | } | |
2641 | } | |
2642 | else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) | |
2643 | { | |
2644 | fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext); | |
2645 | ||
2646 | // set 802.1x port control | |
2647 | //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
2648 | STA_PORT_SECURED(pAdapter); | |
2649 | pAdapter->IndicateMediaState = NdisMediaStateConnected; | |
2650 | } | |
2651 | } | |
2652 | else | |
2653 | return -EINVAL; | |
2654 | break; | |
2655 | case IW_ENCODE_ALG_CCMP: | |
2656 | if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) | |
2657 | { | |
2658 | fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext); | |
2659 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2) | |
2660 | //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
2661 | STA_PORT_SECURED(pAdapter); | |
2662 | pAdapter->IndicateMediaState = NdisMediaStateConnected; | |
2663 | } | |
2664 | else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) | |
2665 | { | |
2666 | fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext); | |
2667 | ||
2668 | // set 802.1x port control | |
2669 | //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
2670 | STA_PORT_SECURED(pAdapter); | |
2671 | pAdapter->IndicateMediaState = NdisMediaStateConnected; | |
2672 | } | |
2673 | break; | |
2674 | default: | |
2675 | return -EINVAL; | |
2676 | } | |
2677 | } | |
2678 | ||
2679 | return 0; | |
2680 | } | |
2681 | ||
2682 | int | |
2683 | rt_ioctl_giwencodeext(struct net_device *dev, | |
2684 | struct iw_request_info *info, | |
2685 | union iwreq_data *wrqu, char *extra) | |
2686 | { | |
2687 | PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2688 | PCHAR pKey = NULL; | |
2689 | struct iw_point *encoding = &wrqu->encoding; | |
2690 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; | |
2691 | int idx, max_key_len; | |
2692 | ||
2693 | DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n")); | |
2694 | ||
2695 | max_key_len = encoding->length - sizeof(*ext); | |
2696 | if (max_key_len < 0) | |
2697 | return -EINVAL; | |
2698 | ||
2699 | idx = encoding->flags & IW_ENCODE_INDEX; | |
2700 | if (idx) | |
2701 | { | |
2702 | if (idx < 1 || idx > 4) | |
2703 | return -EINVAL; | |
2704 | idx--; | |
2705 | ||
2706 | if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) || | |
2707 | (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)) | |
2708 | { | |
2709 | if (idx != pAd->StaCfg.DefaultKeyId) | |
2710 | { | |
2711 | ext->key_len = 0; | |
2712 | return 0; | |
2713 | } | |
2714 | } | |
2715 | } | |
2716 | else | |
2717 | idx = pAd->StaCfg.DefaultKeyId; | |
2718 | ||
2719 | encoding->flags = idx + 1; | |
2720 | memset(ext, 0, sizeof(*ext)); | |
2721 | ||
2722 | ext->key_len = 0; | |
2723 | switch(pAd->StaCfg.WepStatus) { | |
2724 | case Ndis802_11WEPDisabled: | |
2725 | ext->alg = IW_ENCODE_ALG_NONE; | |
2726 | encoding->flags |= IW_ENCODE_DISABLED; | |
2727 | break; | |
2728 | case Ndis802_11WEPEnabled: | |
2729 | ext->alg = IW_ENCODE_ALG_WEP; | |
2730 | if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len) | |
2731 | return -E2BIG; | |
2732 | else | |
2733 | { | |
2734 | ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen; | |
2735 | pKey = (PCHAR)&(pAd->SharedKey[BSS0][idx].Key[0]); | |
2736 | } | |
2737 | break; | |
2738 | case Ndis802_11Encryption2Enabled: | |
2739 | case Ndis802_11Encryption3Enabled: | |
2740 | if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) | |
2741 | ext->alg = IW_ENCODE_ALG_TKIP; | |
2742 | else | |
2743 | ext->alg = IW_ENCODE_ALG_CCMP; | |
2744 | ||
2745 | if (max_key_len < 32) | |
2746 | return -E2BIG; | |
2747 | else | |
2748 | { | |
2749 | ext->key_len = 32; | |
2750 | pKey = (PCHAR)&pAd->StaCfg.PMK[0]; | |
2751 | } | |
2752 | break; | |
2753 | default: | |
2754 | return -EINVAL; | |
2755 | } | |
2756 | ||
2757 | if (ext->key_len && pKey) | |
2758 | { | |
2759 | encoding->flags |= IW_ENCODE_ENABLED; | |
2760 | memcpy(ext->key, pKey, ext->key_len); | |
2761 | } | |
2762 | ||
2763 | return 0; | |
2764 | } | |
2765 | ||
2766 | #ifdef SIOCSIWGENIE | |
2767 | int rt_ioctl_siwgenie(struct net_device *dev, | |
2768 | struct iw_request_info *info, | |
2769 | union iwreq_data *wrqu, char *extra) | |
2770 | { | |
2771 | PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2772 | ||
2773 | DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwgenie\n")); | |
2774 | #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT | |
2775 | pAd->StaCfg.bRSN_IE_FromWpaSupplicant = FALSE; | |
2776 | #endif // NATIVE_WPA_SUPPLICANT_SUPPORT // | |
2777 | if (wrqu->data.length > MAX_LEN_OF_RSNIE || | |
2778 | (wrqu->data.length && extra == NULL)) | |
2779 | return -EINVAL; | |
2780 | ||
2781 | if (wrqu->data.length) | |
2782 | { | |
2783 | pAd->StaCfg.RSNIE_Len = wrqu->data.length; | |
2784 | NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len); | |
2785 | #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT | |
2786 | pAd->StaCfg.bRSN_IE_FromWpaSupplicant = TRUE; | |
2787 | #endif // NATIVE_WPA_SUPPLICANT_SUPPORT // | |
2788 | } | |
2789 | else | |
2790 | { | |
2791 | pAd->StaCfg.RSNIE_Len = 0; | |
2792 | NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE); | |
2793 | } | |
2794 | ||
2795 | return 0; | |
2796 | } | |
2797 | #endif // SIOCSIWGENIE // | |
2798 | ||
2799 | int rt_ioctl_giwgenie(struct net_device *dev, | |
2800 | struct iw_request_info *info, | |
2801 | union iwreq_data *wrqu, char *extra) | |
2802 | { | |
2803 | PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2804 | ||
2805 | if ((pAd->StaCfg.RSNIE_Len == 0) || | |
2806 | (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)) | |
2807 | { | |
2808 | wrqu->data.length = 0; | |
2809 | return 0; | |
2810 | } | |
2811 | ||
2812 | #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT | |
2813 | #ifdef SIOCSIWGENIE | |
2814 | if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) | |
2815 | { | |
2816 | if (wrqu->data.length < pAd->StaCfg.RSNIE_Len) | |
2817 | return -E2BIG; | |
2818 | ||
2819 | wrqu->data.length = pAd->StaCfg.RSNIE_Len; | |
2820 | memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len); | |
2821 | } | |
2822 | else | |
2823 | #endif // SIOCSIWGENIE // | |
2824 | #endif // NATIVE_WPA_SUPPLICANT_SUPPORT // | |
2825 | { | |
2826 | UCHAR RSNIe = IE_WPA; | |
2827 | ||
2828 | if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len | |
2829 | return -E2BIG; | |
2830 | wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2; | |
2831 | ||
2832 | if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) || | |
2833 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)) | |
2834 | RSNIe = IE_RSN; | |
2835 | ||
2836 | extra[0] = (char)RSNIe; | |
2837 | extra[1] = pAd->StaCfg.RSNIE_Len; | |
2838 | memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len); | |
2839 | } | |
2840 | ||
2841 | return 0; | |
2842 | } | |
2843 | ||
2844 | int rt_ioctl_siwpmksa(struct net_device *dev, | |
2845 | struct iw_request_info *info, | |
2846 | union iwreq_data *wrqu, | |
2847 | char *extra) | |
2848 | { | |
2849 | PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2850 | struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer; | |
2851 | INT CachedIdx = 0, idx = 0; | |
2852 | ||
2853 | if (pPmksa == NULL) | |
2854 | return -EINVAL; | |
2855 | ||
2856 | DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n")); | |
2857 | switch(pPmksa->cmd) | |
2858 | { | |
2859 | case IW_PMKSA_FLUSH: | |
2860 | NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO); | |
2861 | DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n")); | |
2862 | break; | |
2863 | case IW_PMKSA_REMOVE: | |
2864 | for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++) | |
2865 | { | |
2866 | // compare the BSSID | |
2867 | if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN)) | |
2868 | { | |
2869 | NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN); | |
2870 | NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16); | |
2871 | for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++) | |
2872 | { | |
2873 | NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN); | |
2874 | NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16); | |
2875 | } | |
2876 | pAd->StaCfg.SavedPMKNum--; | |
2877 | break; | |
2878 | } | |
2879 | } | |
2880 | ||
2881 | DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n")); | |
2882 | break; | |
2883 | case IW_PMKSA_ADD: | |
2884 | for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++) | |
2885 | { | |
2886 | // compare the BSSID | |
2887 | if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN)) | |
2888 | break; | |
2889 | } | |
2890 | ||
2891 | // Found, replace it | |
2892 | if (CachedIdx < PMKID_NO) | |
2893 | { | |
2894 | DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx)); | |
2895 | NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN); | |
2896 | NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16); | |
2897 | pAd->StaCfg.SavedPMKNum++; | |
2898 | } | |
2899 | // Not found, replace the last one | |
2900 | else | |
2901 | { | |
2902 | // Randomly replace one | |
2903 | CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO); | |
2904 | DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx)); | |
2905 | NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN); | |
2906 | NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16); | |
2907 | } | |
2908 | ||
2909 | DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n")); | |
2910 | break; | |
2911 | default: | |
2912 | DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n")); | |
2913 | break; | |
2914 | } | |
2915 | ||
2916 | return 0; | |
2917 | } | |
2918 | #endif // #if WIRELESS_EXT > 17 | |
2919 | ||
2920 | #ifdef DBG | |
2921 | static int | |
2922 | rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info, | |
2923 | struct iw_point *wrq, char *extra) | |
2924 | { | |
2925 | PSTRING this_char; | |
2926 | PSTRING value = NULL; | |
2927 | UCHAR regBBP = 0; | |
2928 | // CHAR arg[255]={0}; | |
2929 | UINT32 bbpId; | |
2930 | UINT32 bbpValue; | |
2931 | BOOLEAN bIsPrintAllBBP = FALSE; | |
2932 | INT Status = 0; | |
2933 | PRTMP_ADAPTER pAdapter = RTMP_OS_NETDEV_GET_PRIV(dev); | |
2934 | ||
2935 | ||
2936 | memset(extra, 0x00, IW_PRIV_SIZE_MASK); | |
2937 | ||
2938 | if (wrq->length > 1) //No parameters. | |
2939 | { | |
2940 | sprintf(extra, "\n"); | |
2941 | ||
2942 | //Parsing Read or Write | |
2943 | this_char = wrq->pointer; | |
2944 | DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char)); | |
2945 | if (!*this_char) | |
2946 | goto next; | |
2947 | ||
2948 | if ((value = rtstrchr(this_char, '=')) != NULL) | |
2949 | *value++ = 0; | |
2950 | ||
2951 | if (!value || !*value) | |
2952 | { //Read | |
2953 | DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value)); | |
2954 | if (sscanf(this_char, "%d", &(bbpId)) == 1) | |
2955 | { | |
2956 | if (bbpId <= MAX_BBP_ID) | |
2957 | { | |
2958 | #ifdef RALINK_ATE | |
2959 | if (ATE_ON(pAdapter)) | |
2960 | { | |
2961 | ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); | |
2962 | } | |
2963 | else | |
2964 | #endif // RALINK_ATE // | |
2965 | { | |
2966 | RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); | |
2967 | } | |
2968 | sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId, regBBP); | |
2969 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
2970 | DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra)); | |
2971 | } | |
2972 | else | |
2973 | {//Invalid parametes, so default printk all bbp | |
2974 | bIsPrintAllBBP = TRUE; | |
2975 | goto next; | |
2976 | } | |
2977 | } | |
2978 | else | |
2979 | { //Invalid parametes, so default printk all bbp | |
2980 | bIsPrintAllBBP = TRUE; | |
2981 | goto next; | |
2982 | } | |
2983 | } | |
2984 | else | |
2985 | { //Write | |
2986 | if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1)) | |
2987 | { | |
2988 | if (bbpId <= MAX_BBP_ID) | |
2989 | { | |
2990 | #ifdef RALINK_ATE | |
2991 | if (ATE_ON(pAdapter)) | |
2992 | { | |
2993 | ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue); | |
2994 | /* read it back for showing */ | |
2995 | ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); | |
2996 | } | |
2997 | else | |
2998 | #endif // RALINK_ATE // | |
2999 | { | |
3000 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue); | |
3001 | /* read it back for showing */ | |
3002 | RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); | |
3003 | } | |
3004 | sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId, regBBP); | |
3005 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
3006 | DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra)); | |
3007 | } | |
3008 | else | |
3009 | {//Invalid parametes, so default printk all bbp | |
3010 | bIsPrintAllBBP = TRUE; | |
3011 | goto next; | |
3012 | } | |
3013 | } | |
3014 | else | |
3015 | { //Invalid parametes, so default printk all bbp | |
3016 | bIsPrintAllBBP = TRUE; | |
3017 | goto next; | |
3018 | } | |
3019 | } | |
3020 | } | |
3021 | else | |
3022 | bIsPrintAllBBP = TRUE; | |
3023 | ||
3024 | next: | |
3025 | if (bIsPrintAllBBP) | |
3026 | { | |
3027 | memset(extra, 0x00, IW_PRIV_SIZE_MASK); | |
3028 | sprintf(extra, "\n"); | |
3029 | for (bbpId = 0; bbpId <= MAX_BBP_ID; bbpId++) | |
3030 | { | |
3031 | if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 20)) | |
3032 | break; | |
3033 | #ifdef RALINK_ATE | |
3034 | if (ATE_ON(pAdapter)) | |
3035 | { | |
3036 | ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); | |
3037 | } | |
3038 | else | |
3039 | #endif // RALINK_ATE // | |
3040 | RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); | |
3041 | sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId, regBBP); | |
3042 | if (bbpId%5 == 4) | |
3043 | sprintf(extra+strlen(extra), "%03d = %02X\n", bbpId, regBBP); // edit by johnli, change display format | |
3044 | } | |
3045 | ||
3046 | wrq->length = strlen(extra) + 1; // 1: size of '\0' | |
3047 | DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length)); | |
3048 | } | |
3049 | ||
3050 | DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n")); | |
3051 | ||
3052 | return Status; | |
3053 | } | |
3054 | #endif // DBG // | |
3055 | ||
3056 | int rt_ioctl_siwrate(struct net_device *dev, | |
3057 | struct iw_request_info *info, | |
3058 | union iwreq_data *wrqu, char *extra) | |
3059 | { | |
3060 | PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev); | |
3061 | UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed; | |
3062 | ||
3063 | //check if the interface is down | |
3064 | if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
3065 | { | |
3066 | DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n")); | |
3067 | return -ENETDOWN; | |
3068 | } | |
3069 | ||
3070 | DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed)); | |
3071 | /* rate = -1 => auto rate | |
3072 | rate = X, fixed = 1 => (fixed rate X) | |
3073 | */ | |
3074 | if (rate == -1) | |
3075 | { | |
3076 | //Auto Rate | |
3077 | pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO; | |
3078 | pAd->StaCfg.bAutoTxRateSwitch = TRUE; | |
3079 | if ((pAd->CommonCfg.PhyMode <= PHY_11G) || | |
3080 | (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)) | |
3081 | RTMPSetDesiredRates(pAd, -1); | |
3082 | ||
3083 | #ifdef DOT11_N_SUPPORT | |
3084 | SetCommonHT(pAd); | |
3085 | #endif // DOT11_N_SUPPORT // | |
3086 | } | |
3087 | else | |
3088 | { | |
3089 | if (fixed) | |
3090 | { | |
3091 | pAd->StaCfg.bAutoTxRateSwitch = FALSE; | |
3092 | if ((pAd->CommonCfg.PhyMode <= PHY_11G) || | |
3093 | (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)) | |
3094 | RTMPSetDesiredRates(pAd, rate); | |
3095 | else | |
3096 | { | |
3097 | pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO; | |
3098 | #ifdef DOT11_N_SUPPORT | |
3099 | SetCommonHT(pAd); | |
3100 | #endif // DOT11_N_SUPPORT // | |
3101 | } | |
3102 | DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS)); | |
3103 | } | |
3104 | else | |
3105 | { | |
3106 | // TODO: rate = X, fixed = 0 => (rates <= X) | |
3107 | return -EOPNOTSUPP; | |
3108 | } | |
3109 | } | |
3110 | ||
3111 | return 0; | |
3112 | } | |
3113 | ||
3114 | int rt_ioctl_giwrate(struct net_device *dev, | |
3115 | struct iw_request_info *info, | |
3116 | union iwreq_data *wrqu, char *extra) | |
3117 | { | |
3118 | PRTMP_ADAPTER pAd = RTMP_OS_NETDEV_GET_PRIV(dev); | |
3119 | int rate_index = 0, rate_count = 0; | |
3120 | HTTRANSMIT_SETTING ht_setting; | |
3121 | /* Remove to global variable | |
3122 | __s32 ralinkrate[] = | |
3123 | {2, 4, 11, 22, // CCK | |
3124 | 12, 18, 24, 36, 48, 72, 96, 108, // OFDM | |
3125 | 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15 | |
3126 | 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23 | |
3127 | 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15 | |
3128 | 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23 | |
3129 | 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15 | |
3130 | 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23 | |
3131 | 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15 | |
3132 | 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23 | |
3133 | */ | |
3134 | ||
3135 | rate_count = sizeof(ralinkrate)/sizeof(__s32); | |
3136 | //check if the interface is down | |
3137 | if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
3138 | { | |
3139 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
3140 | return -ENETDOWN; | |
3141 | } | |
3142 | ||
3143 | if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) && | |
3144 | (INFRA_ON(pAd)) && | |
3145 | ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))) | |
3146 | ht_setting.word = pAd->StaCfg.HTPhyMode.word; | |
3147 | else | |
3148 | ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word; | |
3149 | ||
3150 | #ifdef DOT11_N_SUPPORT | |
3151 | if (ht_setting.field.MODE >= MODE_HTMIX) | |
3152 | { | |
3153 | // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS); | |
3154 | rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS); | |
3155 | } | |
3156 | else | |
3157 | #endif // DOT11_N_SUPPORT // | |
3158 | if (ht_setting.field.MODE == MODE_OFDM) | |
3159 | rate_index = (UCHAR)(ht_setting.field.MCS) + 4; | |
3160 | else if (ht_setting.field.MODE == MODE_CCK) | |
3161 | rate_index = (UCHAR)(ht_setting.field.MCS); | |
3162 | ||
3163 | if (rate_index < 0) | |
3164 | rate_index = 0; | |
3165 | ||
3166 | if (rate_index > rate_count) | |
3167 | rate_index = rate_count; | |
3168 | ||
3169 | wrqu->bitrate.value = ralinkrate[rate_index] * 500000; | |
3170 | wrqu->bitrate.disabled = 0; | |
3171 | ||
3172 | return 0; | |
3173 | } | |
3174 | ||
3175 | static const iw_handler rt_handler[] = | |
3176 | { | |
3177 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ | |
3178 | (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */ | |
3179 | (iw_handler) NULL, /* SIOCSIWNWID */ | |
3180 | (iw_handler) NULL, /* SIOCGIWNWID */ | |
3181 | (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */ | |
3182 | (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */ | |
3183 | (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */ | |
3184 | (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */ | |
3185 | (iw_handler) NULL, /* SIOCSIWSENS */ | |
3186 | (iw_handler) NULL, /* SIOCGIWSENS */ | |
3187 | (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */ | |
3188 | (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */ | |
3189 | (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */ | |
3190 | (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */ | |
3191 | (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */ | |
3192 | (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */ | |
3193 | (iw_handler) NULL, /* SIOCSIWSPY */ | |
3194 | (iw_handler) NULL, /* SIOCGIWSPY */ | |
3195 | (iw_handler) NULL, /* SIOCSIWTHRSPY */ | |
3196 | (iw_handler) NULL, /* SIOCGIWTHRSPY */ | |
3197 | (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */ | |
3198 | (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */ | |
3199 | #ifdef SIOCSIWMLME | |
3200 | (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */ | |
3201 | #else | |
3202 | (iw_handler) NULL, /* SIOCSIWMLME */ | |
3203 | #endif // SIOCSIWMLME // | |
3204 | (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */ | |
3205 | #ifdef SIOCGIWSCAN | |
3206 | (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */ | |
3207 | (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */ | |
3208 | #else | |
3209 | (iw_handler) NULL, /* SIOCSIWSCAN */ | |
3210 | (iw_handler) NULL, /* SIOCGIWSCAN */ | |
3211 | #endif /* SIOCGIWSCAN */ | |
3212 | (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */ | |
3213 | (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */ | |
3214 | (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */ | |
3215 | (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */ | |
3216 | (iw_handler) NULL, /* -- hole -- */ | |
3217 | (iw_handler) NULL, /* -- hole -- */ | |
3218 | (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */ | |
3219 | (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */ | |
3220 | (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */ | |
3221 | (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */ | |
3222 | (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */ | |
3223 | (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */ | |
3224 | (iw_handler) NULL, /* SIOCSIWTXPOW */ | |
3225 | (iw_handler) NULL, /* SIOCGIWTXPOW */ | |
3226 | (iw_handler) NULL, /* SIOCSIWRETRY */ | |
3227 | (iw_handler) NULL, /* SIOCGIWRETRY */ | |
3228 | (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */ | |
3229 | (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */ | |
3230 | (iw_handler) NULL, /* SIOCSIWPOWER */ | |
3231 | (iw_handler) NULL, /* SIOCGIWPOWER */ | |
3232 | (iw_handler) NULL, /* -- hole -- */ | |
3233 | (iw_handler) NULL, /* -- hole -- */ | |
3234 | #if WIRELESS_EXT > 17 | |
3235 | (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */ | |
3236 | (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */ | |
3237 | (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */ | |
3238 | (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */ | |
3239 | (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */ | |
3240 | (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */ | |
3241 | (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */ | |
3242 | #endif | |
3243 | }; | |
3244 | ||
3245 | static const iw_handler rt_priv_handlers[] = { | |
3246 | (iw_handler) NULL, /* + 0x00 */ | |
3247 | (iw_handler) NULL, /* + 0x01 */ | |
3248 | (iw_handler) rt_ioctl_setparam, /* + 0x02 */ | |
3249 | #ifdef DBG | |
3250 | (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */ | |
3251 | #else | |
3252 | (iw_handler) NULL, /* + 0x03 */ | |
3253 | #endif | |
3254 | (iw_handler) NULL, /* + 0x04 */ | |
3255 | (iw_handler) NULL, /* + 0x05 */ | |
3256 | (iw_handler) NULL, /* + 0x06 */ | |
3257 | (iw_handler) NULL, /* + 0x07 */ | |
3258 | (iw_handler) NULL, /* + 0x08 */ | |
3259 | (iw_handler) rt_private_get_statistics, /* + 0x09 */ | |
3260 | (iw_handler) NULL, /* + 0x0A */ | |
3261 | (iw_handler) NULL, /* + 0x0B */ | |
3262 | (iw_handler) NULL, /* + 0x0C */ | |
3263 | (iw_handler) NULL, /* + 0x0D */ | |
3264 | (iw_handler) NULL, /* + 0x0E */ | |
3265 | (iw_handler) NULL, /* + 0x0F */ | |
3266 | (iw_handler) NULL, /* + 0x10 */ | |
3267 | (iw_handler) rt_private_show, /* + 0x11 */ | |
3268 | (iw_handler) NULL, /* + 0x12 */ | |
3269 | (iw_handler) NULL, /* + 0x13 */ | |
3270 | (iw_handler) NULL, /* + 0x14 */ | |
3271 | (iw_handler) NULL, /* + 0x15 */ | |
3272 | (iw_handler) NULL, /* + 0x16 */ | |
3273 | (iw_handler) NULL, /* + 0x17 */ | |
3274 | (iw_handler) NULL, /* + 0x18 */ | |
3275 | }; | |
3276 | ||
3277 | const struct iw_handler_def rt28xx_iw_handler_def = | |
3278 | { | |
3279 | #define N(a) (sizeof (a) / sizeof (a[0])) | |
3280 | .standard = (iw_handler *) rt_handler, | |
3281 | .num_standard = sizeof(rt_handler) / sizeof(iw_handler), | |
3282 | .private = (iw_handler *) rt_priv_handlers, | |
3283 | .num_private = N(rt_priv_handlers), | |
3284 | .private_args = (struct iw_priv_args *) privtab, | |
3285 | .num_private_args = N(privtab), | |
3286 | #if IW_HANDLER_VERSION >= 7 | |
3287 | .get_wireless_stats = rt28xx_get_wireless_stats, | |
3288 | #endif | |
3289 | }; | |
3290 | ||
3291 | INT RTMPSetInformation( | |
3292 | IN PRTMP_ADAPTER pAd, | |
3293 | IN OUT struct ifreq *rq, | |
3294 | IN INT cmd) | |
3295 | { | |
3296 | struct iwreq *wrq = (struct iwreq *) rq; | |
3297 | NDIS_802_11_SSID Ssid; | |
3298 | NDIS_802_11_MAC_ADDRESS Bssid; | |
3299 | RT_802_11_PHY_MODE PhyMode; | |
3300 | RT_802_11_STA_CONFIG StaConfig; | |
3301 | NDIS_802_11_RATES aryRates; | |
3302 | RT_802_11_PREAMBLE Preamble; | |
3303 | NDIS_802_11_WEP_STATUS WepStatus; | |
3304 | NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax; | |
3305 | NDIS_802_11_NETWORK_INFRASTRUCTURE BssType; | |
3306 | NDIS_802_11_RTS_THRESHOLD RtsThresh; | |
3307 | NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh; | |
3308 | NDIS_802_11_POWER_MODE PowerMode; | |
3309 | PNDIS_802_11_KEY pKey = NULL; | |
3310 | PNDIS_802_11_WEP pWepKey =NULL; | |
3311 | PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL; | |
3312 | NDIS_802_11_CONFIGURATION Config, *pConfig = NULL; | |
3313 | NDIS_802_11_NETWORK_TYPE NetType; | |
3314 | ULONG Now; | |
3315 | UINT KeyIdx = 0; | |
3316 | INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G; | |
3317 | ULONG PowerTemp; | |
3318 | BOOLEAN RadioState; | |
3319 | BOOLEAN StateMachineTouched = FALSE; | |
3320 | PNDIS_802_11_PASSPHRASE ppassphrase = NULL; | |
3321 | #ifdef DOT11_N_SUPPORT | |
3322 | OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy | |
3323 | #endif // DOT11_N_SUPPORT // | |
3324 | #ifdef WPA_SUPPLICANT_SUPPORT | |
3325 | PNDIS_802_11_PMKID pPmkId = NULL; | |
3326 | BOOLEAN IEEE8021xState = FALSE; | |
3327 | BOOLEAN IEEE8021x_required_keys = FALSE; | |
3328 | UCHAR wpa_supplicant_enable = 0; | |
3329 | #endif // WPA_SUPPLICANT_SUPPORT // | |
3330 | ||
3331 | #ifdef SNMP_SUPPORT | |
3332 | TX_RTY_CFG_STRUC tx_rty_cfg; | |
3333 | ULONG ShortRetryLimit, LongRetryLimit; | |
3334 | UCHAR ctmp; | |
3335 | #endif // SNMP_SUPPORT // | |
3336 | ||
3337 | ||
3338 | ||
3339 | ||
3340 | #ifdef DOT11_N_SUPPORT | |
3341 | MaxPhyMode = PHY_11N_5G; | |
3342 | #endif // DOT11_N_SUPPORT // | |
3343 | ||
3344 | DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF)); | |
3345 | switch(cmd & 0x7FFF) { | |
3346 | case RT_OID_802_11_COUNTRY_REGION: | |
3347 | if (wrq->u.data.length < sizeof(UCHAR)) | |
3348 | Status = -EINVAL; | |
3349 | // Only avaliable when EEPROM not programming | |
3350 | else if (!(pAd->CommonCfg.CountryRegion & 0x80) && !(pAd->CommonCfg.CountryRegionForABand & 0x80)) | |
3351 | { | |
3352 | ULONG Country; | |
3353 | UCHAR TmpPhy; | |
3354 | ||
3355 | Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length); | |
3356 | pAd->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF); | |
3357 | pAd->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF); | |
3358 | TmpPhy = pAd->CommonCfg.PhyMode; | |
3359 | pAd->CommonCfg.PhyMode = 0xff; | |
3360 | // Build all corresponding channel information | |
3361 | RTMPSetPhyMode(pAd, TmpPhy); | |
3362 | #ifdef DOT11_N_SUPPORT | |
3363 | SetCommonHT(pAd); | |
3364 | #endif // DOT11_N_SUPPORT // | |
3365 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAd->CommonCfg.CountryRegionForABand, | |
3366 | pAd->CommonCfg.CountryRegion)); | |
3367 | } | |
3368 | break; | |
3369 | case OID_802_11_BSSID_LIST_SCAN: | |
3370 | Now = jiffies; | |
3371 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAd->RalinkCounters.LastOneSecTotalTxCount)); | |
3372 | ||
3373 | if (MONITOR_ON(pAd)) | |
3374 | { | |
3375 | DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n")); | |
3376 | break; | |
3377 | } | |
3378 | ||
3379 | //Benson add 20080527, when radio off, sta don't need to scan | |
3380 | if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) | |
3381 | break; | |
3382 | ||
3383 | if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) | |
3384 | { | |
3385 | DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n")); | |
3386 | pAd->StaCfg.bScanReqIsFromWebUI = TRUE; | |
3387 | Status = NDIS_STATUS_SUCCESS; | |
3388 | break; | |
3389 | } | |
3390 | ||
3391 | if (pAd->RalinkCounters.LastOneSecTotalTxCount > 100) | |
3392 | { | |
3393 | DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n")); | |
3394 | Status = NDIS_STATUS_SUCCESS; | |
3395 | pAd->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID | |
3396 | break; | |
3397 | } | |
3398 | ||
3399 | if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) && | |
3400 | ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || | |
3401 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) || | |
3402 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || | |
3403 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) && | |
3404 | (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) | |
3405 | { | |
3406 | DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n")); | |
3407 | Status = NDIS_STATUS_SUCCESS; | |
3408 | pAd->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID | |
3409 | break; | |
3410 | } | |
3411 | ||
3412 | ||
3413 | if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) | |
3414 | { | |
3415 | RTMP_MLME_RESET_STATE_MACHINE(pAd); | |
3416 | DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n")); | |
3417 | } | |
3418 | ||
3419 | // tell CNTL state machine to call NdisMSetInformationComplete() after completing | |
3420 | // this request, because this request is initiated by NDIS. | |
3421 | pAd->MlmeAux.CurrReqIsFromNdis = FALSE; | |
3422 | // Reset allowed scan retries | |
3423 | pAd->StaCfg.ScanCnt = 0; | |
3424 | pAd->StaCfg.LastScanTime = Now; | |
3425 | ||
3426 | pAd->StaCfg.bScanReqIsFromWebUI = TRUE; | |
3427 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); | |
3428 | MlmeEnqueue(pAd, | |
3429 | MLME_CNTL_STATE_MACHINE, | |
3430 | OID_802_11_BSSID_LIST_SCAN, | |
3431 | 0, | |
3432 | NULL); | |
3433 | ||
3434 | Status = NDIS_STATUS_SUCCESS; | |
3435 | StateMachineTouched = TRUE; | |
3436 | break; | |
3437 | case OID_802_11_SSID: | |
3438 | if (wrq->u.data.length != sizeof(NDIS_802_11_SSID)) | |
3439 | Status = -EINVAL; | |
3440 | else | |
3441 | { | |
3442 | PSTRING pSsidString = NULL; | |
3443 | Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length); | |
3444 | ||
3445 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid)); | |
3446 | if (Ssid.SsidLength > MAX_LEN_OF_SSID) | |
3447 | Status = -EINVAL; | |
3448 | else | |
3449 | { | |
3450 | if (Ssid.SsidLength == 0) | |
3451 | { | |
3452 | Set_SSID_Proc(pAd, ""); | |
3453 | } | |
3454 | else | |
3455 | { | |
3456 | pSsidString = (PSTRING)kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG); | |
3457 | if (pSsidString) | |
3458 | { | |
3459 | NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1); | |
3460 | NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength); | |
3461 | Set_SSID_Proc(pAd, pSsidString); | |
3462 | kfree(pSsidString); | |
3463 | } | |
3464 | else | |
3465 | Status = -ENOMEM; | |
3466 | } | |
3467 | } | |
3468 | } | |
3469 | break; | |
3470 | case OID_802_11_SET_PASSPHRASE: | |
3471 | ppassphrase= kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG); | |
3472 | ||
3473 | if(ppassphrase== NULL) | |
3474 | { | |
3475 | Status = -ENOMEM; | |
3476 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_PASSPHRASE, Failed!!\n")); | |
3477 | break; | |
3478 | } | |
3479 | else | |
3480 | { | |
3481 | Status = copy_from_user(ppassphrase, wrq->u.data.pointer, wrq->u.data.length); | |
3482 | ||
3483 | if (Status) | |
3484 | { | |
3485 | Status = -EINVAL; | |
3486 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_PASSPHRASE, Failed (length mismatch)!!\n")); | |
3487 | } | |
3488 | else | |
3489 | { | |
3490 | if(ppassphrase->KeyLength < 8 || ppassphrase->KeyLength > 64) | |
3491 | { | |
3492 | Status = -EINVAL; | |
3493 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_PASSPHRASE, Failed (len less than 8 or greater than 64)!!\n")); | |
3494 | } | |
3495 | else | |
3496 | { | |
3497 | // set key passphrase and length | |
3498 | NdisZeroMemory(pAd->StaCfg.WpaPassPhrase, 64); | |
3499 | NdisMoveMemory(pAd->StaCfg.WpaPassPhrase, &ppassphrase->KeyMaterial, ppassphrase->KeyLength); | |
3500 | pAd->StaCfg.WpaPassPhraseLen = ppassphrase->KeyLength; | |
3501 | hex_dump("pAd->StaCfg.WpaPassPhrase", pAd->StaCfg.WpaPassPhrase, 64); | |
3502 | printk("WpaPassPhrase=%s\n",pAd->StaCfg.WpaPassPhrase); | |
3503 | } | |
3504 | } | |
3505 | } | |
3506 | kfree(ppassphrase); | |
3507 | break; | |
3508 | ||
3509 | case OID_802_11_BSSID: | |
3510 | if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS)) | |
3511 | Status = -EINVAL; | |
3512 | else | |
3513 | { | |
3514 | Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length); | |
3515 | ||
3516 | // tell CNTL state machine to call NdisMSetInformationComplete() after completing | |
3517 | // this request, because this request is initiated by NDIS. | |
3518 | pAd->MlmeAux.CurrReqIsFromNdis = FALSE; | |
3519 | ||
3520 | // Prevent to connect AP again in STAMlmePeriodicExec | |
3521 | pAd->MlmeAux.AutoReconnectSsidLen= 32; | |
3522 | ||
3523 | // Reset allowed scan retries | |
3524 | pAd->StaCfg.ScanCnt = 0; | |
3525 | ||
3526 | if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) | |
3527 | { | |
3528 | RTMP_MLME_RESET_STATE_MACHINE(pAd); | |
3529 | DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n")); | |
3530 | } | |
3531 | MlmeEnqueue(pAd, | |
3532 | MLME_CNTL_STATE_MACHINE, | |
3533 | OID_802_11_BSSID, | |
3534 | sizeof(NDIS_802_11_MAC_ADDRESS), | |
3535 | (VOID *)&Bssid); | |
3536 | Status = NDIS_STATUS_SUCCESS; | |
3537 | StateMachineTouched = TRUE; | |
3538 | ||
3539 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n", | |
3540 | Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5])); | |
3541 | } | |
3542 | break; | |
3543 | case RT_OID_802_11_RADIO: | |
3544 | if (wrq->u.data.length != sizeof(BOOLEAN)) | |
3545 | Status = -EINVAL; | |
3546 | else | |
3547 | { | |
3548 | Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length); | |
3549 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState)); | |
3550 | if (pAd->StaCfg.bSwRadio != RadioState) | |
3551 | { | |
3552 | pAd->StaCfg.bSwRadio = RadioState; | |
3553 | if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio)) | |
3554 | { | |
3555 | pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio); | |
3556 | if (pAd->StaCfg.bRadio == TRUE) | |
3557 | { | |
3558 | MlmeRadioOn(pAd); | |
3559 | // Update extra information | |
3560 | pAd->ExtraInfo = EXTRA_INFO_CLEAR; | |
3561 | } | |
3562 | else | |
3563 | { | |
3564 | if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) | |
3565 | { | |
3566 | if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) | |
3567 | { | |
3568 | RTMP_MLME_RESET_STATE_MACHINE(pAd); | |
3569 | DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n")); | |
3570 | } | |
3571 | } | |
3572 | ||
3573 | MlmeRadioOff(pAd); | |
3574 | // Update extra information | |
3575 | pAd->ExtraInfo = SW_RADIO_OFF; | |
3576 | } | |
3577 | } | |
3578 | } | |
3579 | } | |
3580 | break; | |
3581 | case RT_OID_802_11_PHY_MODE: | |
3582 | if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE)) | |
3583 | Status = -EINVAL; | |
3584 | else | |
3585 | { | |
3586 | Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length); | |
3587 | if (PhyMode <= MaxPhyMode) | |
3588 | { | |
3589 | RTMPSetPhyMode(pAd, PhyMode); | |
3590 | #ifdef DOT11_N_SUPPORT | |
3591 | SetCommonHT(pAd); | |
3592 | #endif // DOT11_N_SUPPORT // | |
3593 | } | |
3594 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode)); | |
3595 | } | |
3596 | break; | |
3597 | case RT_OID_802_11_STA_CONFIG: | |
3598 | if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG)) | |
3599 | Status = -EINVAL; | |
3600 | else | |
3601 | { | |
3602 | UINT32 Value; | |
3603 | ||
3604 | Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length); | |
3605 | pAd->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst; | |
3606 | pAd->CommonCfg.UseBGProtection = StaConfig.UseBGProtection; | |
3607 | pAd->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable | |
3608 | if ((pAd->CommonCfg.PhyMode != StaConfig.AdhocMode) && | |
3609 | (StaConfig.AdhocMode <= MaxPhyMode)) | |
3610 | { | |
3611 | // allow dynamic change of "USE OFDM rate or not" in ADHOC mode | |
3612 | // if setting changed, need to reset current TX rate as well as BEACON frame format | |
3613 | if (pAd->StaCfg.BssType == BSS_ADHOC) | |
3614 | { | |
3615 | pAd->CommonCfg.PhyMode = StaConfig.AdhocMode; | |
3616 | RTMPSetPhyMode(pAd, PhyMode); | |
3617 | MlmeUpdateTxRates(pAd, FALSE, 0); | |
3618 | MakeIbssBeacon(pAd); // re-build BEACON frame | |
3619 | AsicEnableIbssSync(pAd); // copy to on-chip memory | |
3620 | } | |
3621 | } | |
3622 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n", | |
3623 | pAd->CommonCfg.bEnableTxBurst, | |
3624 | pAd->CommonCfg.UseBGProtection, | |
3625 | pAd->CommonCfg.bUseShortSlotTime)); | |
3626 | ||
3627 | if (pAd->CommonCfg.PSPXlink) | |
3628 | Value = PSPXLINK; | |
3629 | else | |
3630 | Value = STANORMAL; | |
3631 | RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, Value); | |
3632 | Value = 0; | |
3633 | RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value); | |
3634 | Value &= (~0x80); | |
3635 | RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value); | |
3636 | } | |
3637 | break; | |
3638 | case OID_802_11_DESIRED_RATES: | |
3639 | if (wrq->u.data.length != sizeof(NDIS_802_11_RATES)) | |
3640 | Status = -EINVAL; | |
3641 | else | |
3642 | { | |
3643 | Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length); | |
3644 | NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES); | |
3645 | NdisMoveMemory(pAd->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES)); | |
3646 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n", | |
3647 | pAd->CommonCfg.DesireRate[0],pAd->CommonCfg.DesireRate[1], | |
3648 | pAd->CommonCfg.DesireRate[2],pAd->CommonCfg.DesireRate[3], | |
3649 | pAd->CommonCfg.DesireRate[4],pAd->CommonCfg.DesireRate[5], | |
3650 | pAd->CommonCfg.DesireRate[6],pAd->CommonCfg.DesireRate[7] )); | |
3651 | // Changing DesiredRate may affect the MAX TX rate we used to TX frames out | |
3652 | MlmeUpdateTxRates(pAd, FALSE, 0); | |
3653 | } | |
3654 | break; | |
3655 | case RT_OID_802_11_PREAMBLE: | |
3656 | if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE)) | |
3657 | Status = -EINVAL; | |
3658 | else | |
3659 | { | |
3660 | Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length); | |
3661 | if (Preamble == Rt802_11PreambleShort) | |
3662 | { | |
3663 | pAd->CommonCfg.TxPreamble = Preamble; | |
3664 | MlmeSetTxPreamble(pAd, Rt802_11PreambleShort); | |
3665 | } | |
3666 | else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto)) | |
3667 | { | |
3668 | // if user wants AUTO, initialize to LONG here, then change according to AP's | |
3669 | // capability upon association. | |
3670 | pAd->CommonCfg.TxPreamble = Preamble; | |
3671 | MlmeSetTxPreamble(pAd, Rt802_11PreambleLong); | |
3672 | } | |
3673 | else | |
3674 | { | |
3675 | Status = -EINVAL; | |
3676 | break; | |
3677 | } | |
3678 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble)); | |
3679 | } | |
3680 | break; | |
3681 | case OID_802_11_WEP_STATUS: | |
3682 | if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS)) | |
3683 | Status = -EINVAL; | |
3684 | else | |
3685 | { | |
3686 | Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length); | |
3687 | // Since TKIP, AES, WEP are all supported. It should not have any invalid setting | |
3688 | if (WepStatus <= Ndis802_11Encryption3KeyAbsent) | |
3689 | { | |
3690 | if (pAd->StaCfg.WepStatus != WepStatus) | |
3691 | { | |
3692 | // Config has changed | |
3693 | pAd->bConfigChanged = TRUE; | |
3694 | } | |
3695 | pAd->StaCfg.WepStatus = WepStatus; | |
3696 | pAd->StaCfg.OrigWepStatus = WepStatus; | |
3697 | pAd->StaCfg.PairCipher = WepStatus; | |
3698 | pAd->StaCfg.GroupCipher = WepStatus; | |
3699 | } | |
3700 | else | |
3701 | { | |
3702 | Status = -EINVAL; | |
3703 | break; | |
3704 | } | |
3705 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus)); | |
3706 | } | |
3707 | break; | |
3708 | case OID_802_11_AUTHENTICATION_MODE: | |
3709 | if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE)) | |
3710 | Status = -EINVAL; | |
3711 | else | |
3712 | { | |
3713 | Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length); | |
3714 | if (AuthMode > Ndis802_11AuthModeMax) | |
3715 | { | |
3716 | Status = -EINVAL; | |
3717 | break; | |
3718 | } | |
3719 | else | |
3720 | { | |
3721 | if (pAd->StaCfg.AuthMode != AuthMode) | |
3722 | { | |
3723 | // Config has changed | |
3724 | pAd->bConfigChanged = TRUE; | |
3725 | } | |
3726 | pAd->StaCfg.AuthMode = AuthMode; | |
3727 | } | |
3728 | pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; | |
3729 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAd->StaCfg.AuthMode)); | |
3730 | } | |
3731 | break; | |
3732 | case OID_802_11_INFRASTRUCTURE_MODE: | |
3733 | if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE)) | |
3734 | Status = -EINVAL; | |
3735 | else | |
3736 | { | |
3737 | Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length); | |
3738 | ||
3739 | if (BssType == Ndis802_11IBSS) | |
3740 | Set_NetworkType_Proc(pAd, "Adhoc"); | |
3741 | else if (BssType == Ndis802_11Infrastructure) | |
3742 | Set_NetworkType_Proc(pAd, "Infra"); | |
3743 | else if (BssType == Ndis802_11Monitor) | |
3744 | Set_NetworkType_Proc(pAd, "Monitor"); | |
3745 | else | |
3746 | { | |
3747 | Status = -EINVAL; | |
3748 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n")); | |
3749 | } | |
3750 | } | |
3751 | break; | |
3752 | case OID_802_11_REMOVE_WEP: | |
3753 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n")); | |
3754 | if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX)) | |
3755 | { | |
3756 | Status = -EINVAL; | |
3757 | } | |
3758 | else | |
3759 | { | |
3760 | KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer; | |
3761 | ||
3762 | if (KeyIdx & 0x80000000) | |
3763 | { | |
3764 | // Should never set default bit when remove key | |
3765 | Status = -EINVAL; | |
3766 | } | |
3767 | else | |
3768 | { | |
3769 | KeyIdx = KeyIdx & 0x0fffffff; | |
3770 | if (KeyIdx >= 4){ | |
3771 | Status = -EINVAL; | |
3772 | } | |
3773 | else | |
3774 | { | |
3775 | pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0; | |
3776 | pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE; | |
3777 | AsicRemoveSharedKeyEntry(pAd, 0, (UCHAR)KeyIdx); | |
3778 | } | |
3779 | } | |
3780 | } | |
3781 | break; | |
3782 | case RT_OID_802_11_RESET_COUNTERS: | |
3783 | NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11)); | |
3784 | NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3)); | |
3785 | NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK)); | |
3786 | pAd->Counters8023.RxNoBuffer = 0; | |
3787 | pAd->Counters8023.GoodReceives = 0; | |
3788 | pAd->Counters8023.RxNoBuffer = 0; | |
3789 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n")); | |
3790 | break; | |
3791 | case OID_802_11_RTS_THRESHOLD: | |
3792 | if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD)) | |
3793 | Status = -EINVAL; | |
3794 | else | |
3795 | { | |
3796 | Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length); | |
3797 | if (RtsThresh > MAX_RTS_THRESHOLD) | |
3798 | Status = -EINVAL; | |
3799 | else | |
3800 | pAd->CommonCfg.RtsThreshold = (USHORT)RtsThresh; | |
3801 | } | |
3802 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh)); | |
3803 | break; | |
3804 | case OID_802_11_FRAGMENTATION_THRESHOLD: | |
3805 | if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD)) | |
3806 | Status = -EINVAL; | |
3807 | else | |
3808 | { | |
3809 | Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length); | |
3810 | pAd->CommonCfg.bUseZeroToDisableFragment = FALSE; | |
3811 | if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD) | |
3812 | { | |
3813 | if (FragThresh == 0) | |
3814 | { | |
3815 | pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD; | |
3816 | pAd->CommonCfg.bUseZeroToDisableFragment = TRUE; | |
3817 | } | |
3818 | else | |
3819 | Status = -EINVAL; | |
3820 | } | |
3821 | else | |
3822 | pAd->CommonCfg.FragmentThreshold = (USHORT)FragThresh; | |
3823 | } | |
3824 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh)); | |
3825 | break; | |
3826 | case OID_802_11_POWER_MODE: | |
3827 | if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE)) | |
3828 | Status = -EINVAL; | |
3829 | else | |
3830 | { | |
3831 | Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length); | |
3832 | if (PowerMode == Ndis802_11PowerModeCAM) | |
3833 | Set_PSMode_Proc(pAd, "CAM"); | |
3834 | else if (PowerMode == Ndis802_11PowerModeMAX_PSP) | |
3835 | Set_PSMode_Proc(pAd, "Max_PSP"); | |
3836 | else if (PowerMode == Ndis802_11PowerModeFast_PSP) | |
3837 | Set_PSMode_Proc(pAd, "Fast_PSP"); | |
3838 | else if (PowerMode == Ndis802_11PowerModeLegacy_PSP) | |
3839 | Set_PSMode_Proc(pAd, "Legacy_PSP"); | |
3840 | else | |
3841 | Status = -EINVAL; | |
3842 | } | |
3843 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode)); | |
3844 | break; | |
3845 | case RT_OID_802_11_TX_POWER_LEVEL_1: | |
3846 | if (wrq->u.data.length < sizeof(ULONG)) | |
3847 | Status = -EINVAL; | |
3848 | else | |
3849 | { | |
3850 | Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length); | |
3851 | if (PowerTemp > 100) | |
3852 | PowerTemp = 0xffffffff; // AUTO | |
3853 | pAd->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting. | |
3854 | pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault; | |
3855 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAd->CommonCfg.TxPowerPercentage)); | |
3856 | } | |
3857 | break; | |
3858 | case OID_802_11_NETWORK_TYPE_IN_USE: | |
3859 | if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE)) | |
3860 | Status = -EINVAL; | |
3861 | else | |
3862 | { | |
3863 | Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length); | |
3864 | ||
3865 | if (NetType == Ndis802_11DS) | |
3866 | RTMPSetPhyMode(pAd, PHY_11B); | |
3867 | else if (NetType == Ndis802_11OFDM24) | |
3868 | RTMPSetPhyMode(pAd, PHY_11BG_MIXED); | |
3869 | else if (NetType == Ndis802_11OFDM5) | |
3870 | RTMPSetPhyMode(pAd, PHY_11A); | |
3871 | else | |
3872 | Status = -EINVAL; | |
3873 | #ifdef DOT11_N_SUPPORT | |
3874 | if (Status == NDIS_STATUS_SUCCESS) | |
3875 | SetCommonHT(pAd); | |
3876 | #endif // DOT11_N_SUPPORT // | |
3877 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType)); | |
3878 | } | |
3879 | break; | |
3880 | // For WPA PSK PMK key | |
3881 | case RT_OID_802_11_ADD_WPA: | |
3882 | pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG); | |
3883 | if(pKey == NULL) | |
3884 | { | |
3885 | Status = -ENOMEM; | |
3886 | break; | |
3887 | } | |
3888 | ||
3889 | Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length); | |
3890 | if (pKey->Length != wrq->u.data.length) | |
3891 | { | |
3892 | Status = -EINVAL; | |
3893 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n")); | |
3894 | } | |
3895 | else | |
3896 | { | |
3897 | if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) && | |
3898 | (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) && | |
3899 | (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) ) | |
3900 | { | |
3901 | Status = -EOPNOTSUPP; | |
3902 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n")); | |
3903 | } | |
3904 | else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) || | |
3905 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) || | |
3906 | (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode | |
3907 | { | |
3908 | NdisMoveMemory(pAd->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength); | |
3909 | // Use RaConfig as PSK agent. | |
3910 | // Start STA supplicant state machine | |
3911 | if (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) | |
3912 | pAd->StaCfg.WpaState = SS_START; | |
3913 | ||
3914 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength)); | |
3915 | } | |
3916 | else | |
3917 | { | |
3918 | pAd->StaCfg.WpaState = SS_NOTUSE; | |
3919 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength)); | |
3920 | } | |
3921 | } | |
3922 | kfree(pKey); | |
3923 | break; | |
3924 | case OID_802_11_REMOVE_KEY: | |
3925 | pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG); | |
3926 | if(pRemoveKey == NULL) | |
3927 | { | |
3928 | Status = -ENOMEM; | |
3929 | break; | |
3930 | } | |
3931 | ||
3932 | Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length); | |
3933 | if (pRemoveKey->Length != wrq->u.data.length) | |
3934 | { | |
3935 | Status = -EINVAL; | |
3936 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n")); | |
3937 | } | |
3938 | else | |
3939 | { | |
3940 | if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
3941 | { | |
3942 | RTMPWPARemoveKeyProc(pAd, pRemoveKey); | |
3943 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n")); | |
3944 | } | |
3945 | else | |
3946 | { | |
3947 | KeyIdx = pRemoveKey->KeyIndex; | |
3948 | ||
3949 | if (KeyIdx & 0x80000000) | |
3950 | { | |
3951 | // Should never set default bit when remove key | |
3952 | Status = -EINVAL; | |
3953 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n")); | |
3954 | } | |
3955 | else | |
3956 | { | |
3957 | KeyIdx = KeyIdx & 0x0fffffff; | |
3958 | if (KeyIdx > 3) | |
3959 | { | |
3960 | Status = -EINVAL; | |
3961 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx)); | |
3962 | } | |
3963 | else | |
3964 | { | |
3965 | pAd->SharedKey[BSS0][KeyIdx].KeyLen = 0; | |
3966 | pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE; | |
3967 | AsicRemoveSharedKeyEntry(pAd, 0, (UCHAR)KeyIdx); | |
3968 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length)); | |
3969 | } | |
3970 | } | |
3971 | } | |
3972 | } | |
3973 | kfree(pRemoveKey); | |
3974 | break; | |
3975 | // New for WPA | |
3976 | case OID_802_11_ADD_KEY: | |
3977 | pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG); | |
3978 | if(pKey == NULL) | |
3979 | { | |
3980 | Status = -ENOMEM; | |
3981 | break; | |
3982 | } | |
3983 | Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length); | |
3984 | if (pKey->Length != wrq->u.data.length) | |
3985 | { | |
3986 | Status = -EINVAL; | |
3987 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n")); | |
3988 | } | |
3989 | else | |
3990 | { | |
3991 | RTMPAddKey(pAd, pKey); | |
3992 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength)); | |
3993 | } | |
3994 | kfree(pKey); | |
3995 | break; | |
3996 | case OID_802_11_CONFIGURATION: | |
3997 | if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION)) | |
3998 | Status = -EINVAL; | |
3999 | else | |
4000 | { | |
4001 | Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length); | |
4002 | pConfig = &Config; | |
4003 | ||
4004 | if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400)) | |
4005 | pAd->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod; | |
4006 | ||
4007 | pAd->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow; | |
4008 | MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAd->CommonCfg.Channel); | |
4009 | // | |
4010 | // Save the channel on MlmeAux for CntlOidRTBssidProc used. | |
4011 | // | |
4012 | pAd->MlmeAux.Channel = pAd->CommonCfg.Channel; | |
4013 | ||
4014 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n", | |
4015 | pConfig->BeaconPeriod, pConfig->ATIMWindow, pAd->CommonCfg.Channel)); | |
4016 | // Config has changed | |
4017 | pAd->bConfigChanged = TRUE; | |
4018 | } | |
4019 | break; | |
4020 | #ifdef DOT11_N_SUPPORT | |
4021 | case RT_OID_802_11_SET_HT_PHYMODE: | |
4022 | if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE)) | |
4023 | Status = -EINVAL; | |
4024 | else | |
4025 | { | |
4026 | POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode; | |
4027 | ||
4028 | Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length); | |
4029 | DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n", | |
4030 | pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset, | |
4031 | pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI)); | |
4032 | if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) | |
4033 | RTMPSetHT(pAd, pHTPhyMode); | |
4034 | } | |
4035 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n", | |
4036 | pAd->StaCfg.HTPhyMode.field.MCS, pAd->StaCfg.HTPhyMode.field.BW, pAd->StaCfg.HTPhyMode.field.ShortGI, | |
4037 | pAd->StaCfg.HTPhyMode.field.STBC)); | |
4038 | break; | |
4039 | #endif // DOT11_N_SUPPORT // | |
4040 | case RT_OID_802_11_SET_APSD_SETTING: | |
4041 | if (wrq->u.data.length != sizeof(ULONG)) | |
4042 | Status = -EINVAL; | |
4043 | else | |
4044 | { | |
4045 | ULONG apsd ; | |
4046 | Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length); | |
4047 | ||
4048 | /*------------------------------------------------------------------- | |
4049 | |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 | | |
4050 | --------------------------------------------------------------------- | |
4051 | | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable | | |
4052 | ---------------------------------------------------------------------*/ | |
4053 | pAd->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE; | |
4054 | pAd->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE; | |
4055 | pAd->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE; | |
4056 | pAd->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE; | |
4057 | pAd->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE; | |
4058 | pAd->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5); | |
4059 | ||
4060 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_SETTING (apsd=0x%lx, APSDCap=%d, [BE,BK,VI,VO]=[%d/%d/%d/%d], MaxSPLen=%d)\n", apsd, pAd->CommonCfg.bAPSDCapable, | |
4061 | pAd->CommonCfg.bAPSDAC_BE, pAd->CommonCfg.bAPSDAC_BK, pAd->CommonCfg.bAPSDAC_VI, pAd->CommonCfg.bAPSDAC_VO, pAd->CommonCfg.MaxSPLength)); | |
4062 | } | |
4063 | break; | |
4064 | ||
4065 | case RT_OID_802_11_SET_APSD_PSM: | |
4066 | if (wrq->u.data.length != sizeof(ULONG)) | |
4067 | Status = -EINVAL; | |
4068 | else | |
4069 | { | |
4070 | // Driver needs to notify AP when PSM changes | |
4071 | Status = copy_from_user(&pAd->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length); | |
4072 | if (pAd->CommonCfg.bAPSDForcePowerSave != pAd->StaCfg.Psm) | |
4073 | { | |
4074 | RTMP_SET_PSM_BIT(pAd, pAd->CommonCfg.bAPSDForcePowerSave); | |
4075 | RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE); | |
4076 | } | |
4077 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAd->CommonCfg.bAPSDForcePowerSave)); | |
4078 | } | |
4079 | break; | |
4080 | #ifdef QOS_DLS_SUPPORT | |
4081 | case RT_OID_802_11_SET_DLS: | |
4082 | if (wrq->u.data.length != sizeof(ULONG)) | |
4083 | Status = -EINVAL; | |
4084 | else | |
4085 | { | |
4086 | BOOLEAN oldvalue = pAd->CommonCfg.bDLSCapable; | |
4087 | Status = copy_from_user(&pAd->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length); | |
4088 | if (oldvalue && !pAd->CommonCfg.bDLSCapable) | |
4089 | { | |
4090 | int i; | |
4091 | // tear down local dls table entry | |
4092 | for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++) | |
4093 | { | |
4094 | if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) | |
4095 | { | |
4096 | pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; | |
4097 | pAd->StaCfg.DLSEntry[i].Valid = FALSE; | |
4098 | RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); | |
4099 | } | |
4100 | } | |
4101 | ||
4102 | // tear down peer dls table entry | |
4103 | for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++) | |
4104 | { | |
4105 | if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)) | |
4106 | { | |
4107 | pAd->StaCfg.DLSEntry[i].Status = DLS_NONE; | |
4108 | pAd->StaCfg.DLSEntry[i].Valid = FALSE; | |
4109 | RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr); | |
4110 | } | |
4111 | } | |
4112 | } | |
4113 | ||
4114 | DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAd->CommonCfg.bDLSCapable)); | |
4115 | } | |
4116 | break; | |
4117 | ||
4118 | case RT_OID_802_11_SET_DLS_PARAM: | |
4119 | if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI)) | |
4120 | Status = -EINVAL; | |
4121 | else | |
4122 | { | |
4123 | RT_802_11_DLS Dls; | |
4124 | ||
4125 | NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS)); | |
4126 | RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI)); | |
4127 | MlmeEnqueue(pAd, | |
4128 | MLME_CNTL_STATE_MACHINE, | |
4129 | RT_OID_802_11_SET_DLS_PARAM, | |
4130 | sizeof(RT_802_11_DLS), | |
4131 | &Dls); | |
4132 | DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n")); | |
4133 | } | |
4134 | break; | |
4135 | #endif // QOS_DLS_SUPPORT // | |
4136 | case RT_OID_802_11_SET_WMM: | |
4137 | if (wrq->u.data.length != sizeof(BOOLEAN)) | |
4138 | Status = -EINVAL; | |
4139 | else | |
4140 | { | |
4141 | Status = copy_from_user(&pAd->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length); | |
4142 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAd->CommonCfg.bWmmCapable)); | |
4143 | } | |
4144 | break; | |
4145 | ||
4146 | case OID_802_11_DISASSOCIATE: | |
4147 | // | |
4148 | // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff. | |
4149 | // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0 | |
4150 | // when query OID_802_11_BSSID_LIST. | |
4151 | // | |
4152 | // TRUE: NumberOfItems will set to 0. | |
4153 | // FALSE: NumberOfItems no change. | |
4154 | // | |
4155 | pAd->CommonCfg.NdisRadioStateOff = TRUE; | |
4156 | // Set to immediately send the media disconnect event | |
4157 | pAd->MlmeAux.CurrReqIsFromNdis = TRUE; | |
4158 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n")); | |
4159 | ||
4160 | ||
4161 | if (INFRA_ON(pAd)) | |
4162 | { | |
4163 | if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) | |
4164 | { | |
4165 | RTMP_MLME_RESET_STATE_MACHINE(pAd); | |
4166 | DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n")); | |
4167 | } | |
4168 | ||
4169 | MlmeEnqueue(pAd, | |
4170 | MLME_CNTL_STATE_MACHINE, | |
4171 | OID_802_11_DISASSOCIATE, | |
4172 | 0, | |
4173 | NULL); | |
4174 | ||
4175 | StateMachineTouched = TRUE; | |
4176 | } | |
4177 | break; | |
4178 | ||
4179 | #ifdef DOT11_N_SUPPORT | |
4180 | case RT_OID_802_11_SET_IMME_BA_CAP: | |
4181 | if (wrq->u.data.length != sizeof(OID_BACAP_STRUC)) | |
4182 | Status = -EINVAL; | |
4183 | else | |
4184 | { | |
4185 | OID_BACAP_STRUC Orde ; | |
4186 | Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length); | |
4187 | if (Orde.Policy > BA_NOTUSE) | |
4188 | { | |
4189 | Status = NDIS_STATUS_INVALID_DATA; | |
4190 | } | |
4191 | else if (Orde.Policy == BA_NOTUSE) | |
4192 | { | |
4193 | pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE; | |
4194 | pAd->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity; | |
4195 | pAd->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity; | |
4196 | pAd->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable; | |
4197 | pAd->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize; | |
4198 | pAd->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode; | |
4199 | pAd->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode; | |
4200 | // UPdata to HT IE | |
4201 | pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode; | |
4202 | pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize; | |
4203 | pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity; | |
4204 | } | |
4205 | else | |
4206 | { | |
4207 | pAd->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA; | |
4208 | pAd->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA. | |
4209 | pAd->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity; | |
4210 | pAd->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity; | |
4211 | pAd->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable; | |
4212 | pAd->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize; | |
4213 | pAd->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode; | |
4214 | pAd->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode; | |
4215 | ||
4216 | // UPdata to HT IE | |
4217 | pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode; | |
4218 | pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize; | |
4219 | pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity; | |
4220 | ||
4221 | if (pAd->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF) | |
4222 | pAd->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF; | |
4223 | ||
4224 | } | |
4225 | ||
4226 | pAd->CommonCfg.REGBACapability.word = pAd->CommonCfg.BACapability.word; | |
4227 | DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAd->CommonCfg.BACapability.field.Policy, | |
4228 | pAd->CommonCfg.BACapability.field.RxBAWinLimit,pAd->CommonCfg.BACapability.field.TxBAWinLimit, pAd->CommonCfg.BACapability.field.AutoBA)); | |
4229 | DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAd->CommonCfg.DesiredHtPhy.MimoPs, pAd->CommonCfg.DesiredHtPhy.AmsduEnable, | |
4230 | pAd->CommonCfg.DesiredHtPhy.AmsduSize, pAd->CommonCfg.DesiredHtPhy.MpduDensity)); | |
4231 | } | |
4232 | ||
4233 | break; | |
4234 | case RT_OID_802_11_ADD_IMME_BA: | |
4235 | DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n")); | |
4236 | if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY)) | |
4237 | Status = -EINVAL; | |
4238 | else | |
4239 | { | |
4240 | UCHAR index; | |
4241 | OID_ADD_BA_ENTRY BA; | |
4242 | MAC_TABLE_ENTRY *pEntry; | |
4243 | ||
4244 | Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length); | |
4245 | if (BA.TID > 15) | |
4246 | { | |
4247 | Status = NDIS_STATUS_INVALID_DATA; | |
4248 | break; | |
4249 | } | |
4250 | else | |
4251 | { | |
4252 | //BATableInsertEntry | |
4253 | //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID. | |
4254 | index = BA.TID; | |
4255 | // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too | |
4256 | pEntry = MacTableLookup(pAd, BA.MACAddr); | |
4257 | if (!pEntry) | |
4258 | { | |
4259 | DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5])); | |
4260 | break; | |
4261 | } | |
4262 | if (BA.IsRecipient == FALSE) | |
4263 | { | |
4264 | if (pEntry->bIAmBadAtheros == TRUE) | |
4265 | pAd->CommonCfg.BACapability.field.RxBAWinLimit = 0x10; | |
4266 | ||
4267 | BAOriSessionSetUp(pAd, pEntry, index, 0, 100, TRUE); | |
4268 | } | |
4269 | else | |
4270 | { | |
4271 | //BATableInsertEntry(pAd, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient); | |
4272 | } | |
4273 | ||
4274 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n", | |
4275 | BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2] | |
4276 | , BA.MACAddr[4], BA.MACAddr[5])); | |
4277 | } | |
4278 | } | |
4279 | break; | |
4280 | ||
4281 | case RT_OID_802_11_TEAR_IMME_BA: | |
4282 | DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n")); | |
4283 | if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY)) | |
4284 | Status = -EINVAL; | |
4285 | else | |
4286 | { | |
4287 | POID_ADD_BA_ENTRY pBA; | |
4288 | MAC_TABLE_ENTRY *pEntry; | |
4289 | ||
4290 | pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG); | |
4291 | ||
4292 | if (pBA == NULL) | |
4293 | { | |
4294 | DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n")); | |
4295 | Status = NDIS_STATUS_FAILURE; | |
4296 | } | |
4297 | else | |
4298 | { | |
4299 | Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length); | |
4300 | DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid)); | |
4301 | ||
4302 | if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID)) | |
4303 | { | |
4304 | Status = NDIS_STATUS_INVALID_DATA; | |
4305 | break; | |
4306 | } | |
4307 | ||
4308 | if (pBA->IsRecipient == FALSE) | |
4309 | { | |
4310 | pEntry = MacTableLookup(pAd, pBA->MACAddr); | |
4311 | DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n")); | |
4312 | if (pEntry) | |
4313 | { | |
4314 | DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n")); | |
4315 | BAOriSessionTearDown(pAd, pEntry->Aid, pBA->TID, FALSE, TRUE); | |
4316 | } | |
4317 | else | |
4318 | DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n")); | |
4319 | } | |
4320 | else | |
4321 | { | |
4322 | pEntry = MacTableLookup(pAd, pBA->MACAddr); | |
4323 | if (pEntry) | |
4324 | { | |
4325 | BARecSessionTearDown( pAd, (UCHAR)pEntry->Aid, pBA->TID, TRUE); | |
4326 | } | |
4327 | else | |
4328 | DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n")); | |
4329 | } | |
4330 | kfree(pBA); | |
4331 | } | |
4332 | } | |
4333 | break; | |
4334 | #endif // DOT11_N_SUPPORT // | |
4335 | ||
4336 | // For WPA_SUPPLICANT to set static wep key | |
4337 | case OID_802_11_ADD_WEP: | |
4338 | pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG); | |
4339 | ||
4340 | if(pWepKey == NULL) | |
4341 | { | |
4342 | Status = -ENOMEM; | |
4343 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n")); | |
4344 | break; | |
4345 | } | |
4346 | Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length); | |
4347 | if (Status) | |
4348 | { | |
4349 | Status = -EINVAL; | |
4350 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n")); | |
4351 | } | |
4352 | else | |
4353 | { | |
4354 | KeyIdx = pWepKey->KeyIndex & 0x0fffffff; | |
4355 | // KeyIdx must be 0 ~ 3 | |
4356 | if (KeyIdx > 4) | |
4357 | { | |
4358 | Status = -EINVAL; | |
4359 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n")); | |
4360 | } | |
4361 | else | |
4362 | { | |
4363 | UCHAR CipherAlg = 0; | |
4364 | PUCHAR Key; | |
4365 | ||
4366 | // set key material and key length | |
4367 | NdisZeroMemory(pAd->SharedKey[BSS0][KeyIdx].Key, 16); | |
4368 | pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength; | |
4369 | NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength); | |
4370 | ||
4371 | switch(pWepKey->KeyLength) | |
4372 | { | |
4373 | case 5: | |
4374 | CipherAlg = CIPHER_WEP64; | |
4375 | break; | |
4376 | case 13: | |
4377 | CipherAlg = CIPHER_WEP128; | |
4378 | break; | |
4379 | default: | |
4380 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n")); | |
4381 | Status = -EINVAL; | |
4382 | break; | |
4383 | } | |
4384 | pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg; | |
4385 | ||
4386 | // Default key for tx (shared key) | |
4387 | if (pWepKey->KeyIndex & 0x80000000) | |
4388 | { | |
4389 | #ifdef WPA_SUPPLICANT_SUPPORT | |
4390 | // set key material and key length | |
4391 | NdisZeroMemory(pAd->StaCfg.DesireSharedKey[KeyIdx].Key, 16); | |
4392 | pAd->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength; | |
4393 | NdisMoveMemory(pAd->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength); | |
4394 | pAd->StaCfg.DesireSharedKeyId = KeyIdx; | |
4395 | pAd->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg; | |
4396 | #endif // WPA_SUPPLICANT_SUPPORT // | |
4397 | pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx; | |
4398 | } | |
4399 | ||
4400 | #ifdef WPA_SUPPLICANT_SUPPORT | |
4401 | if ((pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) && | |
4402 | (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)) | |
4403 | { | |
4404 | Key = pWepKey->KeyMaterial; | |
4405 | ||
4406 | // Set Group key material to Asic | |
4407 | AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL); | |
4408 | ||
4409 | // Update WCID attribute table and IVEIV table for this group key table | |
4410 | RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL); | |
4411 | ||
4412 | STA_PORT_SECURED(pAd); | |
4413 | ||
4414 | // Indicate Connected for GUI | |
4415 | pAd->IndicateMediaState = NdisMediaStateConnected; | |
4416 | } | |
4417 | else if (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) | |
4418 | #endif // WPA_SUPPLICANT_SUPPORT | |
4419 | { | |
4420 | Key = pAd->SharedKey[BSS0][KeyIdx].Key; | |
4421 | ||
4422 | // Set key material and cipherAlg to Asic | |
4423 | AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL); | |
4424 | ||
4425 | if (pWepKey->KeyIndex & 0x80000000) | |
4426 | { | |
4427 | PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[BSSID_WCID]; | |
4428 | // Assign group key info | |
4429 | RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL); | |
4430 | // Assign pairwise key info | |
4431 | RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, pEntry); | |
4432 | } | |
4433 | } | |
4434 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured")); | |
4435 | } | |
4436 | } | |
4437 | kfree(pWepKey); | |
4438 | break; | |
4439 | #ifdef WPA_SUPPLICANT_SUPPORT | |
4440 | case OID_SET_COUNTERMEASURES: | |
4441 | if (wrq->u.data.length != sizeof(int)) | |
4442 | Status = -EINVAL; | |
4443 | else | |
4444 | { | |
4445 | int enabled = 0; | |
4446 | Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length); | |
4447 | if (enabled == 1) | |
4448 | pAd->StaCfg.bBlockAssoc = TRUE; | |
4449 | else | |
4450 | // WPA MIC error should block association attempt for 60 seconds | |
4451 | pAd->StaCfg.bBlockAssoc = FALSE; | |
4452 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAd->StaCfg.bBlockAssoc ? "TRUE":"FALSE")); | |
4453 | } | |
4454 | break; | |
4455 | case RT_OID_WPA_SUPPLICANT_SUPPORT: | |
4456 | if (wrq->u.data.length != sizeof(UCHAR)) | |
4457 | Status = -EINVAL; | |
4458 | else | |
4459 | { | |
4460 | Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length); | |
4461 | pAd->StaCfg.WpaSupplicantUP = wpa_supplicant_enable; | |
4462 | DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAd->StaCfg.WpaSupplicantUP)); | |
4463 | } | |
4464 | break; | |
4465 | case OID_802_11_DEAUTHENTICATION: | |
4466 | if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT)) | |
4467 | Status = -EINVAL; | |
4468 | else | |
4469 | { | |
4470 | MLME_DEAUTH_REQ_STRUCT *pInfo; | |
4471 | MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG); | |
4472 | if (MsgElem == NULL) | |
4473 | { | |
4474 | DBGPRINT(RT_DEBUG_ERROR, ("%s():alloc memory failed!\n", __FUNCTION__)); | |
4475 | return -EINVAL; | |
4476 | } | |
4477 | ||
4478 | pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg; | |
4479 | Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length); | |
4480 | MlmeDeauthReqAction(pAd, MsgElem); | |
4481 | kfree(MsgElem); | |
4482 | ||
4483 | if (INFRA_ON(pAd)) | |
4484 | { | |
4485 | LinkDown(pAd, FALSE); | |
4486 | pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; | |
4487 | } | |
4488 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason)); | |
4489 | } | |
4490 | break; | |
4491 | case OID_802_11_DROP_UNENCRYPTED: | |
4492 | if (wrq->u.data.length != sizeof(int)) | |
4493 | Status = -EINVAL; | |
4494 | else | |
4495 | { | |
4496 | int enabled = 0; | |
4497 | Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length); | |
4498 | if (enabled == 1) | |
4499 | pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; | |
4500 | else | |
4501 | pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; | |
4502 | NdisAcquireSpinLock(&pAd->MacTabLock); | |
4503 | pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured; | |
4504 | NdisReleaseSpinLock(&pAd->MacTabLock); | |
4505 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled)); | |
4506 | } | |
4507 | break; | |
4508 | case OID_802_11_SET_IEEE8021X: | |
4509 | if (wrq->u.data.length != sizeof(BOOLEAN)) | |
4510 | Status = -EINVAL; | |
4511 | else | |
4512 | { | |
4513 | Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length); | |
4514 | pAd->StaCfg.IEEE8021X = IEEE8021xState; | |
4515 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState)); | |
4516 | } | |
4517 | break; | |
4518 | case OID_802_11_SET_IEEE8021X_REQUIRE_KEY: | |
4519 | if (wrq->u.data.length != sizeof(BOOLEAN)) | |
4520 | Status = -EINVAL; | |
4521 | else | |
4522 | { | |
4523 | Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length); | |
4524 | pAd->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys; | |
4525 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys)); | |
4526 | } | |
4527 | break; | |
4528 | case OID_802_11_PMKID: | |
4529 | pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG); | |
4530 | ||
4531 | if(pPmkId == NULL) { | |
4532 | Status = -ENOMEM; | |
4533 | break; | |
4534 | } | |
4535 | Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length); | |
4536 | ||
4537 | // check the PMKID information | |
4538 | if (pPmkId->BSSIDInfoCount == 0) | |
4539 | NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO); | |
4540 | else | |
4541 | { | |
4542 | PBSSID_INFO pBssIdInfo; | |
4543 | UINT BssIdx; | |
4544 | UINT CachedIdx; | |
4545 | ||
4546 | for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++) | |
4547 | { | |
4548 | // point to the indexed BSSID_INFO structure | |
4549 | pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO)); | |
4550 | // Find the entry in the saved data base. | |
4551 | for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++) | |
4552 | { | |
4553 | // compare the BSSID | |
4554 | if (NdisEqualMemory(pBssIdInfo->BSSID, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS))) | |
4555 | break; | |
4556 | } | |
4557 | ||
4558 | // Found, replace it | |
4559 | if (CachedIdx < PMKID_NO) | |
4560 | { | |
4561 | DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx)); | |
4562 | NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO)); | |
4563 | pAd->StaCfg.SavedPMKNum++; | |
4564 | } | |
4565 | // Not found, replace the last one | |
4566 | else | |
4567 | { | |
4568 | // Randomly replace one | |
4569 | CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO); | |
4570 | DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx)); | |
4571 | NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO)); | |
4572 | } | |
4573 | } | |
4574 | } | |
4575 | if(pPmkId) | |
4576 | kfree(pPmkId); | |
4577 | break; | |
4578 | #endif // WPA_SUPPLICANT_SUPPORT // | |
4579 | ||
4580 | ||
4581 | ||
4582 | #ifdef SNMP_SUPPORT | |
4583 | case OID_802_11_SHORTRETRYLIMIT: | |
4584 | if (wrq->u.data.length != sizeof(ULONG)) | |
4585 | Status = -EINVAL; | |
4586 | else | |
4587 | { | |
4588 | Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length); | |
4589 | RTMP_IO_READ32(pAd, TX_RTY_CFG, &tx_rty_cfg.word); | |
4590 | tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit; | |
4591 | RTMP_IO_WRITE32(pAd, TX_RTY_CFG, tx_rty_cfg.word); | |
4592 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit)); | |
4593 | } | |
4594 | break; | |
4595 | ||
4596 | case OID_802_11_LONGRETRYLIMIT: | |
4597 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n")); | |
4598 | if (wrq->u.data.length != sizeof(ULONG)) | |
4599 | Status = -EINVAL; | |
4600 | else | |
4601 | { | |
4602 | Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length); | |
4603 | RTMP_IO_READ32(pAd, TX_RTY_CFG, &tx_rty_cfg.word); | |
4604 | tx_rty_cfg.field.LongRtyLimit = LongRetryLimit; | |
4605 | RTMP_IO_WRITE32(pAd, TX_RTY_CFG, tx_rty_cfg.word); | |
4606 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit)); | |
4607 | } | |
4608 | break; | |
4609 | ||
4610 | case OID_802_11_WEPDEFAULTKEYVALUE: | |
4611 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n")); | |
4612 | pKey = kmalloc(wrq->u.data.length, GFP_KERNEL); | |
4613 | Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length); | |
4614 | //pKey = &WepKey; | |
4615 | ||
4616 | if ( pKey->Length != wrq->u.data.length) | |
4617 | { | |
4618 | Status = -EINVAL; | |
4619 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n")); | |
4620 | } | |
4621 | KeyIdx = pKey->KeyIndex & 0x0fffffff; | |
4622 | DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength)); | |
4623 | ||
4624 | // it is a shared key | |
4625 | if (KeyIdx > 4) | |
4626 | Status = -EINVAL; | |
4627 | else | |
4628 | { | |
4629 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength; | |
4630 | NdisMoveMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength); | |
4631 | if (pKey->KeyIndex & 0x80000000) | |
4632 | { | |
4633 | // Default key for tx (shared key) | |
4634 | pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx; | |
4635 | } | |
4636 | //RestartAPIsRequired = TRUE; | |
4637 | } | |
4638 | break; | |
4639 | ||
4640 | ||
4641 | case OID_802_11_WEPDEFAULTKEYID: | |
4642 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n")); | |
4643 | ||
4644 | if (wrq->u.data.length != sizeof(UCHAR)) | |
4645 | Status = -EINVAL; | |
4646 | else | |
4647 | Status = copy_from_user(&pAd->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length); | |
4648 | ||
4649 | break; | |
4650 | ||
4651 | ||
4652 | case OID_802_11_CURRENTCHANNEL: | |
4653 | DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n")); | |
4654 | if (wrq->u.data.length != sizeof(UCHAR)) | |
4655 | Status = -EINVAL; | |
4656 | else | |
4657 | { | |
4658 | Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length); | |
4659 | sprintf((PSTRING)&ctmp,"%d", ctmp); | |
4660 | Set_Channel_Proc(pAd, (PSTRING)&ctmp); | |
4661 | } | |
4662 | break; | |
4663 | #endif | |
4664 | ||
4665 | ||
4666 | ||
4667 | case RT_OID_802_11_SET_PSPXLINK_MODE: | |
4668 | if (wrq->u.data.length != sizeof(BOOLEAN)) | |
4669 | Status = -EINVAL; | |
4670 | else | |
4671 | { | |
4672 | Status = copy_from_user(&pAd->CommonCfg.PSPXlink, wrq->u.data.pointer, wrq->u.data.length); | |
4673 | /*if (pAd->CommonCfg.PSPXlink) | |
4674 | RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_PROMISCUOUS)*/ | |
4675 | DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_PSPXLINK_MODE(=%d) \n", pAd->CommonCfg.PSPXlink)); | |
4676 | } | |
4677 | break; | |
4678 | ||
4679 | ||
4680 | default: | |
4681 | DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd)); | |
4682 | Status = -EOPNOTSUPP; | |
4683 | break; | |
4684 | } | |
4685 | ||
4686 | ||
4687 | return Status; | |
4688 | } | |
4689 | ||
4690 | INT RTMPQueryInformation( | |
4691 | IN PRTMP_ADAPTER pAd, | |
4692 | IN OUT struct ifreq *rq, | |
4693 | IN INT cmd) | |
4694 | { | |
4695 | struct iwreq *wrq = (struct iwreq *) rq; | |
4696 | NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL; | |
4697 | PNDIS_WLAN_BSSID_EX pBss; | |
4698 | NDIS_802_11_SSID Ssid; | |
4699 | NDIS_802_11_CONFIGURATION *pConfiguration = NULL; | |
4700 | RT_802_11_LINK_STATUS *pLinkStatus = NULL; | |
4701 | RT_802_11_STA_CONFIG *pStaConfig = NULL; | |
4702 | NDIS_802_11_STATISTICS *pStatistics = NULL; | |
4703 | NDIS_802_11_RTS_THRESHOLD RtsThresh; | |
4704 | NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh; | |
4705 | NDIS_802_11_POWER_MODE PowerMode; | |
4706 | NDIS_802_11_NETWORK_INFRASTRUCTURE BssType; | |
4707 | RT_802_11_PREAMBLE PreamType; | |
4708 | NDIS_802_11_AUTHENTICATION_MODE AuthMode; | |
4709 | NDIS_802_11_WEP_STATUS WepStatus; | |
4710 | NDIS_MEDIA_STATE MediaState; | |
4711 | ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0; | |
4712 | USHORT BssLen = 0; | |
4713 | PUCHAR pBuf = NULL, pPtr; | |
4714 | INT Status = NDIS_STATUS_SUCCESS; | |
4715 | UINT we_version_compiled; | |
4716 | UCHAR i, Padding = 0; | |
4717 | BOOLEAN RadioState; | |
4718 | STRING driverVersion[8]; | |
4719 | OID_SET_HT_PHYMODE *pHTPhyMode = NULL; | |
4720 | ||
4721 | ||
4722 | #ifdef SNMP_SUPPORT | |
4723 | //for snmp, kathy | |
4724 | DefaultKeyIdxValue *pKeyIdxValue; | |
4725 | INT valueLen; | |
4726 | TX_RTY_CFG_STRUC tx_rty_cfg; | |
4727 | ULONG ShortRetryLimit, LongRetryLimit; | |
4728 | UCHAR tmp[64]; | |
4729 | #endif //SNMP | |
4730 | ||
4731 | switch(cmd) | |
4732 | { | |
4733 | case RT_OID_DEVICE_NAME: | |
4734 | wrq->u.data.length = sizeof(pAd->nickname); | |
4735 | Status = copy_to_user(wrq->u.data.pointer, pAd->nickname, wrq->u.data.length); | |
4736 | break; | |
4737 | case RT_OID_VERSION_INFO: | |
4738 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n")); | |
4739 | wrq->u.data.length = 8*sizeof(CHAR); | |
4740 | sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION); | |
4741 | driverVersion[7] = '\0'; | |
4742 | if (copy_to_user(wrq->u.data.pointer, &driverVersion[0], wrq->u.data.length)) | |
4743 | { | |
4744 | Status = -EFAULT; | |
4745 | } | |
4746 | break; | |
4747 | ||
4748 | case OID_802_11_BSSID_LIST: | |
4749 | if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) | |
4750 | { | |
4751 | /* | |
4752 | * Still scanning, indicate the caller should try again. | |
4753 | */ | |
4754 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n")); | |
4755 | return -EAGAIN; | |
4756 | } | |
4757 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAd->ScanTab.BssNr)); | |
4758 | pAd->StaCfg.bScanReqIsFromWebUI = FALSE; | |
4759 | // Claculate total buffer size required | |
4760 | BssBufSize = sizeof(ULONG); | |
4761 | ||
4762 | for (i = 0; i < pAd->ScanTab.BssNr; i++) | |
4763 | { | |
4764 | // Align pointer to 4 bytes boundary. | |
4765 | //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003); | |
4766 | //if (Padding == 4) | |
4767 | // Padding = 0; | |
4768 | BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAd->ScanTab.BssEntry[i].VarIELen + Padding); | |
4769 | } | |
4770 | ||
4771 | // For safety issue, we add 256 bytes just in case | |
4772 | BssBufSize += 256; | |
4773 | // Allocate the same size as passed from higher layer | |
4774 | pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG); | |
4775 | if(pBuf == NULL) | |
4776 | { | |
4777 | Status = -ENOMEM; | |
4778 | break; | |
4779 | } | |
4780 | // Init 802_11_BSSID_LIST_EX structure | |
4781 | NdisZeroMemory(pBuf, BssBufSize); | |
4782 | pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf; | |
4783 | pBssidList->NumberOfItems = pAd->ScanTab.BssNr; | |
4784 | ||
4785 | // Calculate total buffer length | |
4786 | BssLen = 4; // Consist of NumberOfItems | |
4787 | // Point to start of NDIS_WLAN_BSSID_EX | |
4788 | // pPtr = pBuf + sizeof(ULONG); | |
4789 | pPtr = (PUCHAR) &pBssidList->Bssid[0]; | |
4790 | for (i = 0; i < pAd->ScanTab.BssNr; i++) | |
4791 | { | |
4792 | pBss = (PNDIS_WLAN_BSSID_EX) pPtr; | |
4793 | NdisMoveMemory(&pBss->MacAddress, &pAd->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN); | |
4794 | if ((pAd->ScanTab.BssEntry[i].Hidden == 1) && (pAd->StaCfg.bShowHiddenSSID == FALSE)) | |
4795 | { | |
4796 | // | |
4797 | // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation | |
4798 | // and then failed to send EAPOl farame. | |
4799 | // | |
4800 | if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAd->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED)) | |
4801 | { | |
4802 | pBss->Ssid.SsidLength = pAd->ScanTab.BssEntry[i].SsidLen; | |
4803 | NdisMoveMemory(pBss->Ssid.Ssid, pAd->ScanTab.BssEntry[i].Ssid, pAd->ScanTab.BssEntry[i].SsidLen); | |
4804 | } | |
4805 | else | |
4806 | pBss->Ssid.SsidLength = 0; | |
4807 | } | |
4808 | else | |
4809 | { | |
4810 | pBss->Ssid.SsidLength = pAd->ScanTab.BssEntry[i].SsidLen; | |
4811 | NdisMoveMemory(pBss->Ssid.Ssid, pAd->ScanTab.BssEntry[i].Ssid, pAd->ScanTab.BssEntry[i].SsidLen); | |
4812 | } | |
4813 | pBss->Privacy = pAd->ScanTab.BssEntry[i].Privacy; | |
4814 | pBss->Rssi = pAd->ScanTab.BssEntry[i].Rssi - pAd->BbpRssiToDbmDelta; | |
4815 | pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAd->ScanTab.BssEntry[i]); | |
4816 | pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION); | |
4817 | pBss->Configuration.BeaconPeriod = pAd->ScanTab.BssEntry[i].BeaconPeriod; | |
4818 | pBss->Configuration.ATIMWindow = pAd->ScanTab.BssEntry[i].AtimWin; | |
4819 | ||
4820 | MAP_CHANNEL_ID_TO_KHZ(pAd->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig); | |
4821 | ||
4822 | if (pAd->ScanTab.BssEntry[i].BssType == BSS_INFRA) | |
4823 | pBss->InfrastructureMode = Ndis802_11Infrastructure; | |
4824 | else | |
4825 | pBss->InfrastructureMode = Ndis802_11IBSS; | |
4826 | ||
4827 | NdisMoveMemory(pBss->SupportedRates, pAd->ScanTab.BssEntry[i].SupRate, pAd->ScanTab.BssEntry[i].SupRateLen); | |
4828 | NdisMoveMemory(pBss->SupportedRates + pAd->ScanTab.BssEntry[i].SupRateLen, | |
4829 | pAd->ScanTab.BssEntry[i].ExtRate, | |
4830 | pAd->ScanTab.BssEntry[i].ExtRateLen); | |
4831 | ||
4832 | if (pAd->ScanTab.BssEntry[i].VarIELen == 0) | |
4833 | { | |
4834 | pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs); | |
4835 | NdisMoveMemory(pBss->IEs, &pAd->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs)); | |
4836 | pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs); | |
4837 | } | |
4838 | else | |
4839 | { | |
4840 | pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAd->ScanTab.BssEntry[i].VarIELen); | |
4841 | pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs); | |
4842 | NdisMoveMemory(pBss->IEs, &pAd->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs)); | |
4843 | NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAd->ScanTab.BssEntry[i].VarIEs, pAd->ScanTab.BssEntry[i].VarIELen); | |
4844 | pPtr += pAd->ScanTab.BssEntry[i].VarIELen; | |
4845 | } | |
4846 | pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAd->ScanTab.BssEntry[i].VarIELen + Padding); | |
4847 | ||
4848 | #if WIRELESS_EXT < 17 | |
4849 | if ((BssLen + pBss->Length) < wrq->u.data.length) | |
4850 | BssLen += pBss->Length; | |
4851 | else | |
4852 | { | |
4853 | pBssidList->NumberOfItems = i; | |
4854 | break; | |
4855 | } | |
4856 | #else | |
4857 | BssLen += pBss->Length; | |
4858 | #endif | |
4859 | } | |
4860 | ||
4861 | #if WIRELESS_EXT < 17 | |
4862 | wrq->u.data.length = BssLen; | |
4863 | #else | |
4864 | if (BssLen > wrq->u.data.length) | |
4865 | { | |
4866 | kfree(pBssidList); | |
4867 | return -E2BIG; | |
4868 | } | |
4869 | else | |
4870 | wrq->u.data.length = BssLen; | |
4871 | #endif | |
4872 | Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen); | |
4873 | kfree(pBssidList); | |
4874 | break; | |
4875 | case OID_802_3_CURRENT_ADDRESS: | |
4876 | wrq->u.data.length = MAC_ADDR_LEN; | |
4877 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CurrentAddress, wrq->u.data.length); | |
4878 | break; | |
4879 | case OID_GEN_MEDIA_CONNECT_STATUS: | |
4880 | if (pAd->IndicateMediaState == NdisMediaStateConnected) | |
4881 | MediaState = NdisMediaStateConnected; | |
4882 | else | |
4883 | MediaState = NdisMediaStateDisconnected; | |
4884 | ||
4885 | wrq->u.data.length = sizeof(NDIS_MEDIA_STATE); | |
4886 | Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length); | |
4887 | break; | |
4888 | case OID_802_11_BSSID: | |
4889 | if (INFRA_ON(pAd) || ADHOC_ON(pAd)) | |
4890 | { | |
4891 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS)); | |
4892 | ||
4893 | } | |
4894 | else | |
4895 | { | |
4896 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n")); | |
4897 | Status = -ENOTCONN; | |
4898 | } | |
4899 | break; | |
4900 | case OID_802_11_SSID: | |
4901 | NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID)); | |
4902 | NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID); | |
4903 | Ssid.SsidLength = pAd->CommonCfg.SsidLen; | |
4904 | memcpy(Ssid.Ssid, pAd->CommonCfg.Ssid, Ssid.SsidLength); | |
4905 | wrq->u.data.length = sizeof(NDIS_802_11_SSID); | |
4906 | Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length); | |
4907 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid)); | |
4908 | break; | |
4909 | case RT_OID_802_11_QUERY_LINK_STATUS: | |
4910 | pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG); | |
4911 | if (pLinkStatus) | |
4912 | { | |
4913 | pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAd->CommonCfg.TxRate]; // unit : 500 kbps | |
4914 | pLinkStatus->ChannelQuality = pAd->Mlme.ChannelQuality; | |
4915 | pLinkStatus->RxByteCount = pAd->RalinkCounters.ReceivedByteCount; | |
4916 | pLinkStatus->TxByteCount = pAd->RalinkCounters.TransmittedByteCount; | |
4917 | pLinkStatus->CentralChannel = pAd->CommonCfg.CentralChannel; | |
4918 | wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS); | |
4919 | Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length); | |
4920 | kfree(pLinkStatus); | |
4921 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n")); | |
4922 | } | |
4923 | else | |
4924 | { | |
4925 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n")); | |
4926 | Status = -EFAULT; | |
4927 | } | |
4928 | break; | |
4929 | case OID_802_11_CONFIGURATION: | |
4930 | pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG); | |
4931 | if (pConfiguration) | |
4932 | { | |
4933 | pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION); | |
4934 | pConfiguration->BeaconPeriod = pAd->CommonCfg.BeaconPeriod; | |
4935 | pConfiguration->ATIMWindow = pAd->StaActive.AtimWin; | |
4936 | MAP_CHANNEL_ID_TO_KHZ(pAd->CommonCfg.Channel, pConfiguration->DSConfig); | |
4937 | wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION); | |
4938 | Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length); | |
4939 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n", | |
4940 | pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAd->CommonCfg.Channel)); | |
4941 | kfree(pConfiguration); | |
4942 | } | |
4943 | else | |
4944 | { | |
4945 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n")); | |
4946 | Status = -EFAULT; | |
4947 | } | |
4948 | break; | |
4949 | case RT_OID_802_11_SNR_0: | |
4950 | if ((pAd->StaCfg.LastSNR0 > 0)) | |
4951 | { | |
4952 | ulInfo = ((0xeb - pAd->StaCfg.LastSNR0) * 3) / 16 ; | |
4953 | wrq->u.data.length = sizeof(ulInfo); | |
4954 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
4955 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo)); | |
4956 | } | |
4957 | else | |
4958 | Status = -EFAULT; | |
4959 | break; | |
4960 | case RT_OID_802_11_SNR_1: | |
4961 | if ((pAd->Antenna.field.RxPath > 1) && | |
4962 | (pAd->StaCfg.LastSNR1 > 0)) | |
4963 | { | |
4964 | ulInfo = ((0xeb - pAd->StaCfg.LastSNR1) * 3) / 16 ; | |
4965 | wrq->u.data.length = sizeof(ulInfo); | |
4966 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
4967 | DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo)); | |
4968 | } | |
4969 | else | |
4970 | Status = -EFAULT; | |
4971 | DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAd->StaCfg.LastSNR1=%d)\n",pAd->StaCfg.LastSNR1)); | |
4972 | break; | |
4973 | case OID_802_11_RSSI_TRIGGER: | |
4974 | ulInfo = pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta; | |
4975 | wrq->u.data.length = sizeof(ulInfo); | |
4976 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
4977 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo)); | |
4978 | break; | |
4979 | case OID_802_11_RSSI: | |
4980 | case RT_OID_802_11_RSSI: | |
4981 | ulInfo = pAd->StaCfg.RssiSample.LastRssi0; | |
4982 | wrq->u.data.length = sizeof(ulInfo); | |
4983 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
4984 | break; | |
4985 | case RT_OID_802_11_RSSI_1: | |
4986 | ulInfo = pAd->StaCfg.RssiSample.LastRssi1; | |
4987 | wrq->u.data.length = sizeof(ulInfo); | |
4988 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
4989 | break; | |
4990 | case RT_OID_802_11_RSSI_2: | |
4991 | ulInfo = pAd->StaCfg.RssiSample.LastRssi2; | |
4992 | wrq->u.data.length = sizeof(ulInfo); | |
4993 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
4994 | break; | |
4995 | case OID_802_11_STATISTICS: | |
4996 | pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG); | |
4997 | if (pStatistics) | |
4998 | { | |
4999 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n")); | |
5000 | // add the most up-to-date h/w raw counters into software counters | |
5001 | NICUpdateRawCounters(pAd); | |
5002 | ||
5003 | // Sanity check for calculation of sucessful count | |
5004 | if (pAd->WlanCounters.TransmittedFragmentCount.QuadPart < pAd->WlanCounters.RetryCount.QuadPart) | |
5005 | pAd->WlanCounters.TransmittedFragmentCount.QuadPart = pAd->WlanCounters.RetryCount.QuadPart; | |
5006 | ||
5007 | pStatistics->TransmittedFragmentCount.QuadPart = pAd->WlanCounters.TransmittedFragmentCount.QuadPart; | |
5008 | pStatistics->MulticastTransmittedFrameCount.QuadPart = pAd->WlanCounters.MulticastTransmittedFrameCount.QuadPart; | |
5009 | pStatistics->FailedCount.QuadPart = pAd->WlanCounters.FailedCount.QuadPart; | |
5010 | pStatistics->RetryCount.QuadPart = pAd->WlanCounters.RetryCount.QuadPart; | |
5011 | pStatistics->MultipleRetryCount.QuadPart = pAd->WlanCounters.MultipleRetryCount.QuadPart; | |
5012 | pStatistics->RTSSuccessCount.QuadPart = pAd->WlanCounters.RTSSuccessCount.QuadPart; | |
5013 | pStatistics->RTSFailureCount.QuadPart = pAd->WlanCounters.RTSFailureCount.QuadPart; | |
5014 | pStatistics->ACKFailureCount.QuadPart = pAd->WlanCounters.ACKFailureCount.QuadPart; | |
5015 | pStatistics->FrameDuplicateCount.QuadPart = pAd->WlanCounters.FrameDuplicateCount.QuadPart; | |
5016 | pStatistics->ReceivedFragmentCount.QuadPart = pAd->WlanCounters.ReceivedFragmentCount.QuadPart; | |
5017 | pStatistics->MulticastReceivedFrameCount.QuadPart = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart; | |
5018 | #ifdef DBG | |
5019 | pStatistics->FCSErrorCount = pAd->RalinkCounters.RealFcsErrCount; | |
5020 | #else | |
5021 | pStatistics->FCSErrorCount.QuadPart = pAd->WlanCounters.FCSErrorCount.QuadPart; | |
5022 | pStatistics->FrameDuplicateCount.u.LowPart = pAd->WlanCounters.FrameDuplicateCount.u.LowPart / 100; | |
5023 | #endif | |
5024 | wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS); | |
5025 | Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length); | |
5026 | kfree(pStatistics); | |
5027 | } | |
5028 | else | |
5029 | { | |
5030 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n")); | |
5031 | Status = -EFAULT; | |
5032 | } | |
5033 | break; | |
5034 | case OID_GEN_RCV_OK: | |
5035 | ulInfo = pAd->Counters8023.GoodReceives; | |
5036 | wrq->u.data.length = sizeof(ulInfo); | |
5037 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
5038 | break; | |
5039 | case OID_GEN_RCV_NO_BUFFER: | |
5040 | ulInfo = pAd->Counters8023.RxNoBuffer; | |
5041 | wrq->u.data.length = sizeof(ulInfo); | |
5042 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
5043 | break; | |
5044 | case RT_OID_802_11_PHY_MODE: | |
5045 | ulInfo = (ULONG)pAd->CommonCfg.PhyMode; | |
5046 | wrq->u.data.length = sizeof(ulInfo); | |
5047 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
5048 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo)); | |
5049 | break; | |
5050 | case RT_OID_802_11_STA_CONFIG: | |
5051 | pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG); | |
5052 | if (pStaConfig) | |
5053 | { | |
5054 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n")); | |
5055 | pStaConfig->EnableTxBurst = pAd->CommonCfg.bEnableTxBurst; | |
5056 | pStaConfig->EnableTurboRate = 0; | |
5057 | pStaConfig->UseBGProtection = pAd->CommonCfg.UseBGProtection; | |
5058 | pStaConfig->UseShortSlotTime = pAd->CommonCfg.bUseShortSlotTime; | |
5059 | //pStaConfig->AdhocMode = pAd->StaCfg.AdhocMode; | |
5060 | pStaConfig->HwRadioStatus = (pAd->StaCfg.bHwRadio == TRUE) ? 1 : 0; | |
5061 | pStaConfig->Rsv1 = 0; | |
5062 | pStaConfig->SystemErrorBitmap = pAd->SystemErrorBitmap; | |
5063 | wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG); | |
5064 | Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length); | |
5065 | kfree(pStaConfig); | |
5066 | } | |
5067 | else | |
5068 | { | |
5069 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n")); | |
5070 | Status = -EFAULT; | |
5071 | } | |
5072 | break; | |
5073 | case OID_802_11_RTS_THRESHOLD: | |
5074 | RtsThresh = pAd->CommonCfg.RtsThreshold; | |
5075 | wrq->u.data.length = sizeof(RtsThresh); | |
5076 | Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length); | |
5077 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh)); | |
5078 | break; | |
5079 | case OID_802_11_FRAGMENTATION_THRESHOLD: | |
5080 | FragThresh = pAd->CommonCfg.FragmentThreshold; | |
5081 | if (pAd->CommonCfg.bUseZeroToDisableFragment == TRUE) | |
5082 | FragThresh = 0; | |
5083 | wrq->u.data.length = sizeof(FragThresh); | |
5084 | Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length); | |
5085 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh)); | |
5086 | break; | |
5087 | case OID_802_11_POWER_MODE: | |
5088 | PowerMode = pAd->StaCfg.WindowsPowerMode; | |
5089 | wrq->u.data.length = sizeof(PowerMode); | |
5090 | Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length); | |
5091 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode)); | |
5092 | break; | |
5093 | case RT_OID_802_11_RADIO: | |
5094 | RadioState = (BOOLEAN) pAd->StaCfg.bSwRadio; | |
5095 | wrq->u.data.length = sizeof(RadioState); | |
5096 | Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length); | |
5097 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState)); | |
5098 | break; | |
5099 | case OID_802_11_INFRASTRUCTURE_MODE: | |
5100 | if (pAd->StaCfg.BssType == BSS_ADHOC) | |
5101 | BssType = Ndis802_11IBSS; | |
5102 | else if (pAd->StaCfg.BssType == BSS_INFRA) | |
5103 | BssType = Ndis802_11Infrastructure; | |
5104 | else if (pAd->StaCfg.BssType == BSS_MONITOR) | |
5105 | BssType = Ndis802_11Monitor; | |
5106 | else | |
5107 | BssType = Ndis802_11AutoUnknown; | |
5108 | ||
5109 | wrq->u.data.length = sizeof(BssType); | |
5110 | Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length); | |
5111 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType)); | |
5112 | break; | |
5113 | case RT_OID_802_11_PREAMBLE: | |
5114 | PreamType = pAd->CommonCfg.TxPreamble; | |
5115 | wrq->u.data.length = sizeof(PreamType); | |
5116 | Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length); | |
5117 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType)); | |
5118 | break; | |
5119 | case OID_802_11_AUTHENTICATION_MODE: | |
5120 | AuthMode = pAd->StaCfg.AuthMode; | |
5121 | wrq->u.data.length = sizeof(AuthMode); | |
5122 | Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length); | |
5123 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode)); | |
5124 | break; | |
5125 | case OID_802_11_WEP_STATUS: | |
5126 | WepStatus = pAd->StaCfg.WepStatus; | |
5127 | wrq->u.data.length = sizeof(WepStatus); | |
5128 | Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length); | |
5129 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus)); | |
5130 | break; | |
5131 | case OID_802_11_TX_POWER_LEVEL: | |
5132 | wrq->u.data.length = sizeof(ULONG); | |
5133 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.TxPower, wrq->u.data.length); | |
5134 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAd->CommonCfg.TxPower)); | |
5135 | break; | |
5136 | case RT_OID_802_11_TX_POWER_LEVEL_1: | |
5137 | wrq->u.data.length = sizeof(ULONG); | |
5138 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.TxPowerPercentage, wrq->u.data.length); | |
5139 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAd->CommonCfg.TxPowerPercentage)); | |
5140 | break; | |
5141 | case OID_802_11_NETWORK_TYPES_SUPPORTED: | |
5142 | if ((pAd->RfIcType == RFIC_2850) || (pAd->RfIcType == RFIC_2750) || (pAd->RfIcType == RFIC_3052)) | |
5143 | { | |
5144 | NetworkTypeList[0] = 3; // NumberOfItems = 3 | |
5145 | NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b | |
5146 | NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g | |
5147 | NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a | |
5148 | wrq->u.data.length = 16; | |
5149 | Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length); | |
5150 | } | |
5151 | else | |
5152 | { | |
5153 | NetworkTypeList[0] = 2; // NumberOfItems = 2 | |
5154 | NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b | |
5155 | NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g | |
5156 | wrq->u.data.length = 12; | |
5157 | Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length); | |
5158 | } | |
5159 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n")); | |
5160 | break; | |
5161 | case OID_802_11_NETWORK_TYPE_IN_USE: | |
5162 | wrq->u.data.length = sizeof(ULONG); | |
5163 | if (pAd->CommonCfg.PhyMode == PHY_11A) | |
5164 | ulInfo = Ndis802_11OFDM5; | |
5165 | else if ((pAd->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11G)) | |
5166 | ulInfo = Ndis802_11OFDM24; | |
5167 | else | |
5168 | ulInfo = Ndis802_11DS; | |
5169 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
5170 | break; | |
5171 | case RT_OID_802_11_QUERY_LAST_RX_RATE: | |
5172 | ulInfo = (ULONG)pAd->LastRxRate; | |
5173 | wrq->u.data.length = sizeof(ulInfo); | |
5174 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
5175 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo)); | |
5176 | break; | |
5177 | case RT_OID_802_11_QUERY_LAST_TX_RATE: | |
5178 | //ulInfo = (ULONG)pAd->LastTxRate; | |
5179 | ulInfo = (ULONG)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word; | |
5180 | wrq->u.data.length = sizeof(ulInfo); | |
5181 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
5182 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo)); | |
5183 | break; | |
5184 | case RT_OID_802_11_QUERY_EEPROM_VERSION: | |
5185 | wrq->u.data.length = sizeof(ULONG); | |
5186 | Status = copy_to_user(wrq->u.data.pointer, &pAd->EepromVersion, wrq->u.data.length); | |
5187 | break; | |
5188 | case RT_OID_802_11_QUERY_FIRMWARE_VERSION: | |
5189 | wrq->u.data.length = sizeof(ULONG); | |
5190 | Status = copy_to_user(wrq->u.data.pointer, &pAd->FirmwareVersion, wrq->u.data.length); | |
5191 | break; | |
5192 | case RT_OID_802_11_QUERY_NOISE_LEVEL: | |
5193 | wrq->u.data.length = sizeof(UCHAR); | |
5194 | Status = copy_to_user(wrq->u.data.pointer, &pAd->BbpWriteLatch[66], wrq->u.data.length); | |
5195 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAd->BbpWriteLatch[66])); | |
5196 | break; | |
5197 | case RT_OID_802_11_EXTRA_INFO: | |
5198 | wrq->u.data.length = sizeof(ULONG); | |
5199 | Status = copy_to_user(wrq->u.data.pointer, &pAd->ExtraInfo, wrq->u.data.length); | |
5200 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAd->ExtraInfo)); | |
5201 | break; | |
5202 | case RT_OID_WE_VERSION_COMPILED: | |
5203 | wrq->u.data.length = sizeof(UINT); | |
5204 | we_version_compiled = WIRELESS_EXT; | |
5205 | Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length); | |
5206 | break; | |
5207 | case RT_OID_802_11_QUERY_APSD_SETTING: | |
5208 | apsd = (pAd->CommonCfg.bAPSDCapable | (pAd->CommonCfg.bAPSDAC_BE << 1) | (pAd->CommonCfg.bAPSDAC_BK << 2) | |
5209 | | (pAd->CommonCfg.bAPSDAC_VI << 3) | (pAd->CommonCfg.bAPSDAC_VO << 4) | (pAd->CommonCfg.MaxSPLength << 5)); | |
5210 | ||
5211 | wrq->u.data.length = sizeof(ULONG); | |
5212 | Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length); | |
5213 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_SETTING (=0x%lx,APSDCap=%d,AC_BE=%d,AC_BK=%d,AC_VI=%d,AC_VO=%d,MAXSPLen=%d)\n", | |
5214 | apsd,pAd->CommonCfg.bAPSDCapable,pAd->CommonCfg.bAPSDAC_BE,pAd->CommonCfg.bAPSDAC_BK,pAd->CommonCfg.bAPSDAC_VI,pAd->CommonCfg.bAPSDAC_VO,pAd->CommonCfg.MaxSPLength)); | |
5215 | break; | |
5216 | case RT_OID_802_11_QUERY_APSD_PSM: | |
5217 | wrq->u.data.length = sizeof(ULONG); | |
5218 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length); | |
5219 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAd->CommonCfg.bAPSDForcePowerSave)); | |
5220 | break; | |
5221 | case RT_OID_802_11_QUERY_WMM: | |
5222 | wrq->u.data.length = sizeof(BOOLEAN); | |
5223 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.bWmmCapable, wrq->u.data.length); | |
5224 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAd->CommonCfg.bWmmCapable)); | |
5225 | break; | |
5226 | #ifdef WPA_SUPPLICANT_SUPPORT | |
5227 | case RT_OID_NEW_DRIVER: | |
5228 | { | |
5229 | UCHAR enabled = 1; | |
5230 | wrq->u.data.length = sizeof(UCHAR); | |
5231 | Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length); | |
5232 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled)); | |
5233 | } | |
5234 | break; | |
5235 | case RT_OID_WPA_SUPPLICANT_SUPPORT: | |
5236 | wrq->u.data.length = sizeof(UCHAR); | |
5237 | Status = copy_to_user(wrq->u.data.pointer, &pAd->StaCfg.WpaSupplicantUP, wrq->u.data.length); | |
5238 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAd->StaCfg.WpaSupplicantUP)); | |
5239 | break; | |
5240 | #endif // WPA_SUPPLICANT_SUPPORT // | |
5241 | ||
5242 | case RT_OID_DRIVER_DEVICE_NAME: | |
5243 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n")); | |
5244 | wrq->u.data.length = 16; | |
5245 | if (copy_to_user(wrq->u.data.pointer, pAd->StaCfg.dev_name, wrq->u.data.length)) | |
5246 | { | |
5247 | Status = -EFAULT; | |
5248 | } | |
5249 | break; | |
5250 | case RT_OID_802_11_QUERY_HT_PHYMODE: | |
5251 | pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG); | |
5252 | if (pHTPhyMode) | |
5253 | { | |
5254 | pHTPhyMode->PhyMode = pAd->CommonCfg.PhyMode; | |
5255 | pHTPhyMode->HtMode = (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE; | |
5256 | pHTPhyMode->BW = (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW; | |
5257 | pHTPhyMode->MCS= (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS; | |
5258 | pHTPhyMode->SHORTGI= (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI; | |
5259 | pHTPhyMode->STBC= (UCHAR)pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC; | |
5260 | ||
5261 | pHTPhyMode->ExtOffset = ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE)); | |
5262 | wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE); | |
5263 | if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length)) | |
5264 | { | |
5265 | Status = -EFAULT; | |
5266 | } | |
5267 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n", | |
5268 | pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset)); | |
5269 | DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word)); | |
5270 | } | |
5271 | else | |
5272 | { | |
5273 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n")); | |
5274 | Status = -EFAULT; | |
5275 | } | |
5276 | break; | |
5277 | case RT_OID_802_11_COUNTRY_REGION: | |
5278 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n")); | |
5279 | wrq->u.data.length = sizeof(ulInfo); | |
5280 | ulInfo = pAd->CommonCfg.CountryRegionForABand; | |
5281 | ulInfo = (ulInfo << 8)|(pAd->CommonCfg.CountryRegion); | |
5282 | if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length)) | |
5283 | { | |
5284 | Status = -EFAULT; | |
5285 | } | |
5286 | break; | |
5287 | case RT_OID_802_11_QUERY_DAT_HT_PHYMODE: | |
5288 | pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG); | |
5289 | if (pHTPhyMode) | |
5290 | { | |
5291 | pHTPhyMode->PhyMode = pAd->CommonCfg.PhyMode; | |
5292 | pHTPhyMode->HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE; | |
5293 | pHTPhyMode->BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW; | |
5294 | pHTPhyMode->MCS= (UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.MCS; | |
5295 | pHTPhyMode->SHORTGI= (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI; | |
5296 | pHTPhyMode->STBC= (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC; | |
5297 | ||
5298 | wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE); | |
5299 | if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length)) | |
5300 | { | |
5301 | Status = -EFAULT; | |
5302 | } | |
5303 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n", | |
5304 | pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset)); | |
5305 | DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word)); | |
5306 | } | |
5307 | else | |
5308 | { | |
5309 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n")); | |
5310 | Status = -EFAULT; | |
5311 | } | |
5312 | break; | |
5313 | case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT: | |
5314 | wrq->u.data.length = sizeof(UCHAR); | |
5315 | i = 0; | |
5316 | #ifdef MULTIPLE_CARD_SUPPORT | |
5317 | i = 1; | |
5318 | #endif // MULTIPLE_CARD_SUPPORT // | |
5319 | if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length)) | |
5320 | { | |
5321 | Status = -EFAULT; | |
5322 | } | |
5323 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i)); | |
5324 | break; | |
5325 | #ifdef SNMP_SUPPORT | |
5326 | case RT_OID_802_11_MAC_ADDRESS: | |
5327 | wrq->u.data.length = MAC_ADDR_LEN; | |
5328 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CurrentAddress, wrq->u.data.length); | |
5329 | break; | |
5330 | ||
5331 | case RT_OID_802_11_MANUFACTUREROUI: | |
5332 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n")); | |
5333 | wrq->u.data.length = ManufacturerOUI_LEN; | |
5334 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CurrentAddress, wrq->u.data.length); | |
5335 | break; | |
5336 | ||
5337 | case RT_OID_802_11_MANUFACTURERNAME: | |
5338 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n")); | |
5339 | wrq->u.data.length = strlen(ManufacturerNAME); | |
5340 | Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length); | |
5341 | break; | |
5342 | ||
5343 | case RT_OID_802_11_RESOURCETYPEIDNAME: | |
5344 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n")); | |
5345 | wrq->u.data.length = strlen(ResourceTypeIdName); | |
5346 | Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length); | |
5347 | break; | |
5348 | ||
5349 | case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED: | |
5350 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n")); | |
5351 | ulInfo = 1; // 1 is support wep else 2 is not support. | |
5352 | wrq->u.data.length = sizeof(ulInfo); | |
5353 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
5354 | break; | |
5355 | ||
5356 | case RT_OID_802_11_POWERMANAGEMENTMODE: | |
5357 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n")); | |
5358 | if (pAd->StaCfg.Psm == PSMP_ACTION) | |
5359 | ulInfo = 1; // 1 is power active else 2 is power save. | |
5360 | else | |
5361 | ulInfo = 2; | |
5362 | ||
5363 | wrq->u.data.length = sizeof(ulInfo); | |
5364 | Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length); | |
5365 | break; | |
5366 | ||
5367 | case OID_802_11_WEPDEFAULTKEYVALUE: | |
5368 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n")); | |
5369 | //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId; | |
5370 | pKeyIdxValue = wrq->u.data.pointer; | |
5371 | DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx)); | |
5372 | valueLen = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen; | |
5373 | NdisMoveMemory(pKeyIdxValue->Value, | |
5374 | &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, | |
5375 | valueLen); | |
5376 | pKeyIdxValue->Value[valueLen]='\0'; | |
5377 | ||
5378 | wrq->u.data.length = sizeof(DefaultKeyIdxValue); | |
5379 | ||
5380 | Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length); | |
5381 | DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", | |
5382 | pAd->StaCfg.DefaultKeyId, | |
5383 | wrq->u.data.length, | |
5384 | pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen, | |
5385 | pAd->SharedKey[BSS0][0].Key[0], | |
5386 | pAd->SharedKey[BSS0][1].Key[0], | |
5387 | pAd->SharedKey[BSS0][2].Key[0], | |
5388 | pAd->SharedKey[BSS0][3].Key[0])); | |
5389 | break; | |
5390 | ||
5391 | case OID_802_11_WEPDEFAULTKEYID: | |
5392 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n")); | |
5393 | wrq->u.data.length = sizeof(UCHAR); | |
5394 | Status = copy_to_user(wrq->u.data.pointer, &pAd->StaCfg.DefaultKeyId, wrq->u.data.length); | |
5395 | DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAd->StaCfg.DefaultKeyId)); | |
5396 | break; | |
5397 | ||
5398 | case RT_OID_802_11_WEPKEYMAPPINGLENGTH: | |
5399 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n")); | |
5400 | wrq->u.data.length = sizeof(UCHAR); | |
5401 | Status = copy_to_user(wrq->u.data.pointer, | |
5402 | &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen, | |
5403 | wrq->u.data.length); | |
5404 | break; | |
5405 | ||
5406 | case OID_802_11_SHORTRETRYLIMIT: | |
5407 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n")); | |
5408 | wrq->u.data.length = sizeof(ULONG); | |
5409 | RTMP_IO_READ32(pAd, TX_RTY_CFG, &tx_rty_cfg.word); | |
5410 | ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit; | |
5411 | DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit)); | |
5412 | Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length); | |
5413 | break; | |
5414 | ||
5415 | case OID_802_11_LONGRETRYLIMIT: | |
5416 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n")); | |
5417 | wrq->u.data.length = sizeof(ULONG); | |
5418 | RTMP_IO_READ32(pAd, TX_RTY_CFG, &tx_rty_cfg.word); | |
5419 | LongRetryLimit = tx_rty_cfg.field.LongRtyLimit; | |
5420 | DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit)); | |
5421 | Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length); | |
5422 | break; | |
5423 | ||
5424 | case RT_OID_802_11_PRODUCTID: | |
5425 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n")); | |
5426 | ||
5427 | #ifdef RTMP_MAC_PCI | |
5428 | { | |
5429 | ||
5430 | USHORT device_id; | |
5431 | if (((POS_COOKIE)pAd->OS_Cookie)->pci_dev != NULL) | |
5432 | pci_read_config_word(((POS_COOKIE)pAd->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id); | |
5433 | else | |
5434 | DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n")); | |
5435 | sprintf((PSTRING)tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id); | |
5436 | } | |
5437 | #endif // RTMP_MAC_PCI // | |
5438 | wrq->u.data.length = strlen((PSTRING)tmp); | |
5439 | Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length); | |
5440 | break; | |
5441 | ||
5442 | case RT_OID_802_11_MANUFACTUREID: | |
5443 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n")); | |
5444 | wrq->u.data.length = strlen(ManufacturerNAME); | |
5445 | Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length); | |
5446 | break; | |
5447 | ||
5448 | case OID_802_11_CURRENTCHANNEL: | |
5449 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n")); | |
5450 | wrq->u.data.length = sizeof(UCHAR); | |
5451 | DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAd->CommonCfg.Channel)); | |
5452 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.Channel, wrq->u.data.length); | |
5453 | DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status)); | |
5454 | break; | |
5455 | #endif //SNMP_SUPPORT | |
5456 | ||
5457 | case OID_802_11_BUILD_CHANNEL_EX: | |
5458 | { | |
5459 | UCHAR value; | |
5460 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n")); | |
5461 | wrq->u.data.length = sizeof(UCHAR); | |
5462 | #ifdef EXT_BUILD_CHANNEL_LIST | |
5463 | DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n")); | |
5464 | value = 1; | |
5465 | #else | |
5466 | DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n")); | |
5467 | value = 0; | |
5468 | #endif // EXT_BUILD_CHANNEL_LIST // | |
5469 | Status = copy_to_user(wrq->u.data.pointer, &value, 1); | |
5470 | DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status)); | |
5471 | } | |
5472 | break; | |
5473 | ||
5474 | case OID_802_11_GET_CH_LIST: | |
5475 | { | |
5476 | PRT_CHANNEL_LIST_INFO pChListBuf; | |
5477 | ||
5478 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n")); | |
5479 | if (pAd->ChannelListNum == 0) | |
5480 | { | |
5481 | wrq->u.data.length = 0; | |
5482 | break; | |
5483 | } | |
5484 | ||
5485 | pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG); | |
5486 | if (pChListBuf == NULL) | |
5487 | { | |
5488 | wrq->u.data.length = 0; | |
5489 | break; | |
5490 | } | |
5491 | ||
5492 | pChListBuf->ChannelListNum = pAd->ChannelListNum; | |
5493 | for (i = 0; i < pChListBuf->ChannelListNum; i++) | |
5494 | pChListBuf->ChannelList[i] = pAd->ChannelList[i].Channel; | |
5495 | ||
5496 | wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO); | |
5497 | Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO)); | |
5498 | DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status)); | |
5499 | ||
5500 | if (pChListBuf) | |
5501 | kfree(pChListBuf); | |
5502 | } | |
5503 | break; | |
5504 | ||
5505 | case OID_802_11_GET_COUNTRY_CODE: | |
5506 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n")); | |
5507 | wrq->u.data.length = 2; | |
5508 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.CountryCode, 2); | |
5509 | DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status)); | |
5510 | break; | |
5511 | ||
5512 | case OID_802_11_GET_CHANNEL_GEOGRAPHY: | |
5513 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n")); | |
5514 | wrq->u.data.length = 1; | |
5515 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.Geography, 1); | |
5516 | DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status)); | |
5517 | break; | |
5518 | ||
5519 | ||
5520 | #ifdef QOS_DLS_SUPPORT | |
5521 | case RT_OID_802_11_QUERY_DLS: | |
5522 | wrq->u.data.length = sizeof(BOOLEAN); | |
5523 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.bDLSCapable, wrq->u.data.length); | |
5524 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAd->CommonCfg.bDLSCapable)); | |
5525 | break; | |
5526 | ||
5527 | case RT_OID_802_11_QUERY_DLS_PARAM: | |
5528 | { | |
5529 | PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC); | |
5530 | if (pDlsInfo == NULL) | |
5531 | break; | |
5532 | ||
5533 | for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++) | |
5534 | { | |
5535 | RTMPMoveMemory(&pDlsInfo->Entry[i], &pAd->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI)); | |
5536 | } | |
5537 | ||
5538 | pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY; | |
5539 | wrq->u.data.length = sizeof(RT_802_11_DLS_INFO); | |
5540 | Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length); | |
5541 | DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n")); | |
5542 | ||
5543 | if (pDlsInfo) | |
5544 | kfree(pDlsInfo); | |
5545 | } | |
5546 | break; | |
5547 | #endif // QOS_DLS_SUPPORT // | |
5548 | ||
5549 | case OID_802_11_SET_PSPXLINK_MODE: | |
5550 | wrq->u.data.length = sizeof(BOOLEAN); | |
5551 | Status = copy_to_user(wrq->u.data.pointer, &pAd->CommonCfg.PSPXlink, wrq->u.data.length); | |
5552 | DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SET_PSPXLINK_MODE(=%d)\n", pAd->CommonCfg.PSPXlink)); | |
5553 | break; | |
5554 | ||
5555 | ||
5556 | default: | |
5557 | DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd)); | |
5558 | Status = -EOPNOTSUPP; | |
5559 | break; | |
5560 | } | |
5561 | return Status; | |
5562 | } | |
5563 | ||
5564 | INT rt28xx_sta_ioctl( | |
5565 | IN struct net_device *net_dev, | |
5566 | IN OUT struct ifreq *rq, | |
5567 | IN INT cmd) | |
5568 | { | |
5569 | POS_COOKIE pObj; | |
5570 | RTMP_ADAPTER *pAd = NULL; | |
5571 | struct iwreq *wrq = (struct iwreq *) rq; | |
5572 | BOOLEAN StateMachineTouched = FALSE; | |
5573 | INT Status = NDIS_STATUS_SUCCESS; | |
5574 | USHORT subcmd; | |
5575 | ||
5576 | ||
5577 | pAd = RTMP_OS_NETDEV_GET_PRIV(net_dev); | |
5578 | if (pAd == NULL) | |
5579 | { | |
5580 | /* if 1st open fail, pAd will be free; | |
5581 | So the net_dev->priv will be NULL in 2rd open */ | |
5582 | return -ENETDOWN; | |
5583 | } | |
5584 | pObj = (POS_COOKIE) pAd->OS_Cookie; | |
5585 | ||
5586 | //check if the interface is down | |
5587 | if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
5588 | { | |
5589 | #ifdef CONFIG_APSTA_MIXED_SUPPORT | |
5590 | if (wrq->u.data.pointer == NULL) | |
5591 | { | |
5592 | return Status; | |
5593 | } | |
5594 | ||
5595 | if (strstr(wrq->u.data.pointer, "OpMode") == NULL) | |
5596 | #endif // CONFIG_APSTA_MIXED_SUPPORT // | |
5597 | { | |
5598 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
5599 | return -ENETDOWN; | |
5600 | } | |
5601 | } | |
5602 | ||
5603 | { // determine this ioctl command is comming from which interface. | |
5604 | pObj->ioctl_if_type = INT_MAIN; | |
5605 | pObj->ioctl_if = MAIN_MBSSID; | |
5606 | } | |
5607 | ||
5608 | switch(cmd) | |
5609 | { | |
5610 | #ifdef RALINK_ATE | |
5611 | #ifdef RALINK_28xx_QA | |
5612 | case RTPRIV_IOCTL_ATE: | |
5613 | { | |
5614 | RtmpDoAte(pAd, wrq); | |
5615 | } | |
5616 | break; | |
5617 | #endif // RALINK_28xx_QA // | |
5618 | #endif // RALINK_ATE // | |
5619 | case SIOCGIFHWADDR: | |
5620 | DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n")); | |
5621 | memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN); | |
5622 | break; | |
5623 | case SIOCGIWNAME: | |
5624 | { | |
5625 | char *name=&wrq->u.name[0]; | |
5626 | rt_ioctl_giwname(net_dev, NULL, name, NULL); | |
5627 | break; | |
5628 | } | |
5629 | case SIOCGIWESSID: //Get ESSID | |
5630 | { | |
5631 | struct iw_point *essid=&wrq->u.essid; | |
5632 | rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer); | |
5633 | break; | |
5634 | } | |
5635 | case SIOCSIWESSID: //Set ESSID | |
5636 | { | |
5637 | struct iw_point *essid=&wrq->u.essid; | |
5638 | rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer); | |
5639 | break; | |
5640 | } | |
5641 | case SIOCSIWNWID: // set network id (the cell) | |
5642 | case SIOCGIWNWID: // get network id | |
5643 | Status = -EOPNOTSUPP; | |
5644 | break; | |
5645 | case SIOCSIWFREQ: //set channel/frequency (Hz) | |
5646 | { | |
5647 | struct iw_freq *freq=&wrq->u.freq; | |
5648 | rt_ioctl_siwfreq(net_dev, NULL, freq, NULL); | |
5649 | break; | |
5650 | } | |
5651 | case SIOCGIWFREQ: // get channel/frequency (Hz) | |
5652 | { | |
5653 | struct iw_freq *freq=&wrq->u.freq; | |
5654 | rt_ioctl_giwfreq(net_dev, NULL, freq, NULL); | |
5655 | break; | |
5656 | } | |
5657 | case SIOCSIWNICKN: //set node name/nickname | |
5658 | { | |
5659 | //struct iw_point *data=&wrq->u.data; | |
5660 | //rt_ioctl_siwnickn(net_dev, NULL, data, NULL); | |
5661 | break; | |
5662 | } | |
5663 | case SIOCGIWNICKN: //get node name/nickname | |
5664 | { | |
5665 | struct iw_point *erq = NULL; | |
5666 | erq = &wrq->u.data; | |
5667 | erq->length = strlen((PSTRING) pAd->nickname); | |
5668 | Status = copy_to_user(erq->pointer, pAd->nickname, erq->length); | |
5669 | break; | |
5670 | } | |
5671 | case SIOCGIWRATE: //get default bit rate (bps) | |
5672 | rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL); | |
5673 | break; | |
5674 | case SIOCSIWRATE: //set default bit rate (bps) | |
5675 | rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL); | |
5676 | break; | |
5677 | case SIOCGIWRTS: // get RTS/CTS threshold (bytes) | |
5678 | { | |
5679 | struct iw_param *rts=&wrq->u.rts; | |
5680 | rt_ioctl_giwrts(net_dev, NULL, rts, NULL); | |
5681 | break; | |
5682 | } | |
5683 | case SIOCSIWRTS: //set RTS/CTS threshold (bytes) | |
5684 | { | |
5685 | struct iw_param *rts=&wrq->u.rts; | |
5686 | rt_ioctl_siwrts(net_dev, NULL, rts, NULL); | |
5687 | break; | |
5688 | } | |
5689 | case SIOCGIWFRAG: //get fragmentation thr (bytes) | |
5690 | { | |
5691 | struct iw_param *frag=&wrq->u.frag; | |
5692 | rt_ioctl_giwfrag(net_dev, NULL, frag, NULL); | |
5693 | break; | |
5694 | } | |
5695 | case SIOCSIWFRAG: //set fragmentation thr (bytes) | |
5696 | { | |
5697 | struct iw_param *frag=&wrq->u.frag; | |
5698 | rt_ioctl_siwfrag(net_dev, NULL, frag, NULL); | |
5699 | break; | |
5700 | } | |
5701 | case SIOCGIWENCODE: //get encoding token & mode | |
5702 | { | |
5703 | struct iw_point *erq=&wrq->u.encoding; | |
5704 | if(erq) | |
5705 | rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer); | |
5706 | break; | |
5707 | } | |
5708 | case SIOCSIWENCODE: //set encoding token & mode | |
5709 | { | |
5710 | struct iw_point *erq=&wrq->u.encoding; | |
5711 | if(erq) | |
5712 | rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer); | |
5713 | break; | |
5714 | } | |
5715 | case SIOCGIWAP: //get access point MAC addresses | |
5716 | { | |
5717 | struct sockaddr *ap_addr=&wrq->u.ap_addr; | |
5718 | rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data); | |
5719 | break; | |
5720 | } | |
5721 | case SIOCSIWAP: //set access point MAC addresses | |
5722 | { | |
5723 | struct sockaddr *ap_addr=&wrq->u.ap_addr; | |
5724 | rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data); | |
5725 | break; | |
5726 | } | |
5727 | case SIOCGIWMODE: //get operation mode | |
5728 | { | |
5729 | __u32 *mode=&wrq->u.mode; | |
5730 | rt_ioctl_giwmode(net_dev, NULL, mode, NULL); | |
5731 | break; | |
5732 | } | |
5733 | case SIOCSIWMODE: //set operation mode | |
5734 | { | |
5735 | __u32 *mode=&wrq->u.mode; | |
5736 | rt_ioctl_siwmode(net_dev, NULL, mode, NULL); | |
5737 | break; | |
5738 | } | |
5739 | case SIOCGIWSENS: //get sensitivity (dBm) | |
5740 | case SIOCSIWSENS: //set sensitivity (dBm) | |
5741 | case SIOCGIWPOWER: //get Power Management settings | |
5742 | case SIOCSIWPOWER: //set Power Management settings | |
5743 | case SIOCGIWTXPOW: //get transmit power (dBm) | |
5744 | case SIOCSIWTXPOW: //set transmit power (dBm) | |
5745 | case SIOCGIWRANGE: //Get range of parameters | |
5746 | case SIOCGIWRETRY: //get retry limits and lifetime | |
5747 | case SIOCSIWRETRY: //set retry limits and lifetime | |
5748 | Status = -EOPNOTSUPP; | |
5749 | break; | |
5750 | case RT_PRIV_IOCTL: | |
5751 | case RT_PRIV_IOCTL_EXT: | |
5752 | subcmd = wrq->u.data.flags; | |
5753 | if( subcmd & OID_GET_SET_TOGGLE) | |
5754 | Status = RTMPSetInformation(pAd, rq, subcmd); | |
5755 | else | |
5756 | Status = RTMPQueryInformation(pAd, rq, subcmd); | |
5757 | break; | |
5758 | case SIOCGIWPRIV: | |
5759 | if (wrq->u.data.pointer) | |
5760 | { | |
5761 | if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE) | |
5762 | break; | |
5763 | wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]); | |
5764 | if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab))) | |
5765 | Status = -EFAULT; | |
5766 | } | |
5767 | break; | |
5768 | case RTPRIV_IOCTL_SET: | |
5769 | if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE) | |
5770 | break; | |
5771 | rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer); | |
5772 | break; | |
5773 | case RTPRIV_IOCTL_GSITESURVEY: | |
5774 | RTMPIoctlGetSiteSurvey(pAd, wrq); | |
5775 | break; | |
5776 | #ifdef DBG | |
5777 | case RTPRIV_IOCTL_MAC: | |
5778 | RTMPIoctlMAC(pAd, wrq); | |
5779 | break; | |
5780 | case RTPRIV_IOCTL_E2P: | |
5781 | RTMPIoctlE2PROM(pAd, wrq); | |
5782 | break; | |
5783 | #ifdef RTMP_RF_RW_SUPPORT | |
5784 | case RTPRIV_IOCTL_RF: | |
5785 | RTMPIoctlRF(pAd, wrq); | |
5786 | break; | |
5787 | #endif // RTMP_RF_RW_SUPPORT // | |
5788 | #endif // DBG // | |
5789 | ||
5790 | case SIOCETHTOOL: | |
5791 | break; | |
5792 | default: | |
5793 | DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd)); | |
5794 | Status = -EOPNOTSUPP; | |
5795 | break; | |
5796 | } | |
5797 | ||
5798 | if(StateMachineTouched) // Upper layer sent a MLME-related operations | |
5799 | RTMP_MLME_HANDLER(pAd); | |
5800 | ||
5801 | return Status; | |
5802 | } | |
5803 | ||
5804 | /* | |
5805 | ========================================================================== | |
5806 | Description: | |
5807 | Set SSID | |
5808 | Return: | |
5809 | TRUE if all parameters are OK, FALSE otherwise | |
5810 | ========================================================================== | |
5811 | */ | |
5812 | INT Set_SSID_Proc( | |
5813 | IN PRTMP_ADAPTER pAdapter, | |
5814 | IN PSTRING arg) | |
5815 | { | |
5816 | NDIS_802_11_SSID Ssid, *pSsid=NULL; | |
5817 | BOOLEAN StateMachineTouched = FALSE; | |
5818 | int success = TRUE; | |
5819 | ||
5820 | if( strlen(arg) <= MAX_LEN_OF_SSID) | |
5821 | { | |
5822 | NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID)); | |
5823 | if (strlen(arg) != 0) | |
5824 | { | |
5825 | NdisMoveMemory(Ssid.Ssid, arg, strlen(arg)); | |
5826 | Ssid.SsidLength = strlen(arg); | |
5827 | } | |
5828 | else //ANY ssid | |
5829 | { | |
5830 | Ssid.SsidLength = 0; | |
5831 | memcpy(Ssid.Ssid, "", 0); | |
5832 | pAdapter->StaCfg.BssType = BSS_INFRA; | |
5833 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen; | |
5834 | pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled; | |
5835 | } | |
5836 | pSsid = &Ssid; | |
5837 | ||
5838 | if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) | |
5839 | { | |
5840 | RTMP_MLME_RESET_STATE_MACHINE(pAdapter); | |
5841 | DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n")); | |
5842 | } | |
5843 | ||
5844 | if ((pAdapter->StaCfg.WpaPassPhraseLen >= 8) && | |
5845 | (pAdapter->StaCfg.WpaPassPhraseLen <= 64)) | |
5846 | { | |
5847 | STRING passphrase_str[65] = {0}; | |
5848 | UCHAR keyMaterial[40]; | |
5849 | ||
5850 | RTMPMoveMemory(passphrase_str, pAdapter->StaCfg.WpaPassPhrase, pAdapter->StaCfg.WpaPassPhraseLen); | |
5851 | RTMPZeroMemory(pAdapter->StaCfg.PMK, 32); | |
5852 | if (pAdapter->StaCfg.WpaPassPhraseLen == 64) | |
5853 | { | |
5854 | AtoH((PSTRING) pAdapter->StaCfg.WpaPassPhrase, pAdapter->StaCfg.PMK, 32); | |
5855 | } | |
5856 | else | |
5857 | { | |
5858 | PasswordHash((PSTRING) pAdapter->StaCfg.WpaPassPhrase, Ssid.Ssid, Ssid.SsidLength, keyMaterial); | |
5859 | NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32); | |
5860 | } | |
5861 | } | |
5862 | ||
5863 | pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE; | |
5864 | pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE; | |
5865 | pAdapter->bConfigChanged = TRUE; | |
5866 | ||
5867 | MlmeEnqueue(pAdapter, | |
5868 | MLME_CNTL_STATE_MACHINE, | |
5869 | OID_802_11_SSID, | |
5870 | sizeof(NDIS_802_11_SSID), | |
5871 | (VOID *)pSsid); | |
5872 | ||
5873 | StateMachineTouched = TRUE; | |
5874 | DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid)); | |
5875 | } | |
5876 | else | |
5877 | success = FALSE; | |
5878 | ||
5879 | if (StateMachineTouched) // Upper layer sent a MLME-related operations | |
5880 | RTMP_MLME_HANDLER(pAdapter); | |
5881 | ||
5882 | return success; | |
5883 | } | |
5884 | ||
5885 | #ifdef WMM_SUPPORT | |
5886 | /* | |
5887 | ========================================================================== | |
5888 | Description: | |
5889 | Set WmmCapable Enable or Disable | |
5890 | Return: | |
5891 | TRUE if all parameters are OK, FALSE otherwise | |
5892 | ========================================================================== | |
5893 | */ | |
5894 | INT Set_WmmCapable_Proc( | |
5895 | IN PRTMP_ADAPTER pAd, | |
5896 | IN PSTRING arg) | |
5897 | { | |
5898 | BOOLEAN bWmmCapable; | |
5899 | ||
5900 | bWmmCapable = simple_strtol(arg, 0, 10); | |
5901 | ||
5902 | if ((bWmmCapable == 1) | |
5903 | ) | |
5904 | pAd->CommonCfg.bWmmCapable = TRUE; | |
5905 | else if (bWmmCapable == 0) | |
5906 | pAd->CommonCfg.bWmmCapable = FALSE; | |
5907 | else | |
5908 | return FALSE; //Invalid argument | |
5909 | ||
5910 | DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n", | |
5911 | pAd->CommonCfg.bWmmCapable)); | |
5912 | ||
5913 | return TRUE; | |
5914 | } | |
5915 | #endif // WMM_SUPPORT // | |
5916 | ||
5917 | /* | |
5918 | ========================================================================== | |
5919 | Description: | |
5920 | Set Network Type(Infrastructure/Adhoc mode) | |
5921 | Return: | |
5922 | TRUE if all parameters are OK, FALSE otherwise | |
5923 | ========================================================================== | |
5924 | */ | |
5925 | INT Set_NetworkType_Proc( | |
5926 | IN PRTMP_ADAPTER pAdapter, | |
5927 | IN PSTRING arg) | |
5928 | { | |
5929 | UINT32 Value = 0; | |
5930 | ||
5931 | if (strcmp(arg, "Adhoc") == 0) | |
5932 | { | |
5933 | if (pAdapter->StaCfg.BssType != BSS_ADHOC) | |
5934 | { | |
5935 | // Config has changed | |
5936 | pAdapter->bConfigChanged = TRUE; | |
5937 | if (MONITOR_ON(pAdapter)) | |
5938 | { | |
5939 | RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL); | |
5940 | RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value); | |
5941 | Value &= (~0x80); | |
5942 | RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value); | |
5943 | OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED); | |
5944 | pAdapter->StaCfg.bAutoReconnect = TRUE; | |
5945 | LinkDown(pAdapter, FALSE); | |
5946 | } | |
5947 | if (INFRA_ON(pAdapter)) | |
5948 | { | |
5949 | //BOOLEAN Cancelled; | |
5950 | // Set the AutoReconnectSsid to prevent it reconnect to old SSID | |
5951 | // Since calling this indicate user don't want to connect to that SSID anymore. | |
5952 | pAdapter->MlmeAux.AutoReconnectSsidLen= 32; | |
5953 | NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen); | |
5954 | ||
5955 | LinkDown(pAdapter, FALSE); | |
5956 | ||
5957 | DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n")); | |
5958 | } | |
5959 | } | |
5960 | pAdapter->StaCfg.BssType = BSS_ADHOC; | |
5961 | pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType; | |
5962 | DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n")); | |
5963 | } | |
5964 | else if (strcmp(arg, "Infra") == 0) | |
5965 | { | |
5966 | if (pAdapter->StaCfg.BssType != BSS_INFRA) | |
5967 | { | |
5968 | // Config has changed | |
5969 | pAdapter->bConfigChanged = TRUE; | |
5970 | if (MONITOR_ON(pAdapter)) | |
5971 | { | |
5972 | RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL); | |
5973 | RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value); | |
5974 | Value &= (~0x80); | |
5975 | RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value); | |
5976 | OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED); | |
5977 | pAdapter->StaCfg.bAutoReconnect = TRUE; | |
5978 | LinkDown(pAdapter, FALSE); | |
5979 | } | |
5980 | if (ADHOC_ON(pAdapter)) | |
5981 | { | |
5982 | // Set the AutoReconnectSsid to prevent it reconnect to old SSID | |
5983 | // Since calling this indicate user don't want to connect to that SSID anymore. | |
5984 | pAdapter->MlmeAux.AutoReconnectSsidLen= 32; | |
5985 | NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen); | |
5986 | ||
5987 | LinkDown(pAdapter, FALSE); | |
5988 | } | |
5989 | } | |
5990 | pAdapter->StaCfg.BssType = BSS_INFRA; | |
5991 | pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType; | |
5992 | DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n")); | |
5993 | } | |
5994 | else if (strcmp(arg, "Monitor") == 0) | |
5995 | { | |
5996 | UCHAR bbpValue = 0; | |
5997 | BCN_TIME_CFG_STRUC csr; | |
5998 | OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON); | |
5999 | OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON); | |
6000 | OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED); | |
6001 | // disable all periodic state machine | |
6002 | pAdapter->StaCfg.bAutoReconnect = FALSE; | |
6003 | // reset all mlme state machine | |
6004 | RTMP_MLME_RESET_STATE_MACHINE(pAdapter); | |
6005 | DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n")); | |
6006 | if (pAdapter->CommonCfg.CentralChannel == 0) | |
6007 | { | |
6008 | #ifdef DOT11_N_SUPPORT | |
6009 | if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED) | |
6010 | pAdapter->CommonCfg.CentralChannel = 36; | |
6011 | else | |
6012 | #endif // DOT11_N_SUPPORT // | |
6013 | pAdapter->CommonCfg.CentralChannel = 6; | |
6014 | } | |
6015 | #ifdef DOT11_N_SUPPORT | |
6016 | else | |
6017 | N_ChannelCheck(pAdapter); | |
6018 | #endif // DOT11_N_SUPPORT // | |
6019 | ||
6020 | #ifdef DOT11_N_SUPPORT | |
6021 | if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED && | |
6022 | pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 && | |
6023 | pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE) | |
6024 | { | |
6025 | // 40MHz ,control channel at lower | |
6026 | RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue); | |
6027 | bbpValue &= (~0x18); | |
6028 | bbpValue |= 0x10; | |
6029 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue); | |
6030 | pAdapter->CommonCfg.BBPCurrentBW = BW_40; | |
6031 | // RX : control channel at lower | |
6032 | RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue); | |
6033 | bbpValue &= (~0x20); | |
6034 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue); | |
6035 | ||
6036 | RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value); | |
6037 | Value &= 0xfffffffe; | |
6038 | RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value); | |
6039 | pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2; | |
6040 | AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE); | |
6041 | AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel); | |
6042 | DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n", | |
6043 | pAdapter->CommonCfg.Channel, | |
6044 | pAdapter->CommonCfg.CentralChannel)); | |
6045 | } | |
6046 | else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED && | |
6047 | pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 && | |
6048 | pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW) | |
6049 | { | |
6050 | // 40MHz ,control channel at upper | |
6051 | RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue); | |
6052 | bbpValue &= (~0x18); | |
6053 | bbpValue |= 0x10; | |
6054 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue); | |
6055 | pAdapter->CommonCfg.BBPCurrentBW = BW_40; | |
6056 | RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value); | |
6057 | Value |= 0x1; | |
6058 | RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value); | |
6059 | ||
6060 | RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue); | |
6061 | bbpValue |= (0x20); | |
6062 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue); | |
6063 | pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2; | |
6064 | AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE); | |
6065 | AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel); | |
6066 | DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n", | |
6067 | pAdapter->CommonCfg.Channel, | |
6068 | pAdapter->CommonCfg.CentralChannel)); | |
6069 | } | |
6070 | else | |
6071 | #endif // DOT11_N_SUPPORT // | |
6072 | { | |
6073 | // 20MHz | |
6074 | RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue); | |
6075 | bbpValue &= (~0x18); | |
6076 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue); | |
6077 | pAdapter->CommonCfg.BBPCurrentBW = BW_20; | |
6078 | AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE); | |
6079 | AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel); | |
6080 | DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel)); | |
6081 | } | |
6082 | // Enable Rx with promiscuous reception | |
6083 | RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3); | |
6084 | // ASIC supporsts sniffer function with replacing RSSI with timestamp. | |
6085 | //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value); | |
6086 | //Value |= (0x80); | |
6087 | //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value); | |
6088 | // disable sync | |
6089 | RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word); | |
6090 | csr.field.bBeaconGen = 0; | |
6091 | csr.field.bTBTTEnable = 0; | |
6092 | csr.field.TsfSyncMode = 0; | |
6093 | RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word); | |
6094 | ||
6095 | pAdapter->StaCfg.BssType = BSS_MONITOR; | |
6096 | pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211 | |
6097 | DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n")); | |
6098 | } | |
6099 | ||
6100 | // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key | |
6101 | pAdapter->StaCfg.WpaState = SS_NOTUSE; | |
6102 | ||
6103 | DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType)); | |
6104 | ||
6105 | return TRUE; | |
6106 | } | |
6107 | ||
6108 | /* | |
6109 | ========================================================================== | |
6110 | Description: | |
6111 | Set Authentication mode | |
6112 | Return: | |
6113 | TRUE if all parameters are OK, FALSE otherwise | |
6114 | ========================================================================== | |
6115 | */ | |
6116 | INT Set_AuthMode_Proc( | |
6117 | IN PRTMP_ADAPTER pAdapter, | |
6118 | IN PSTRING arg) | |
6119 | { | |
6120 | if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0)) | |
6121 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch; | |
6122 | else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0)) | |
6123 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen; | |
6124 | else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0)) | |
6125 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared; | |
6126 | else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0)) | |
6127 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK; | |
6128 | else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0)) | |
6129 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone; | |
6130 | else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0)) | |
6131 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK; | |
6132 | #ifdef WPA_SUPPLICANT_SUPPORT | |
6133 | else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0)) | |
6134 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA; | |
6135 | else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0)) | |
6136 | pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2; | |
6137 | #endif // WPA_SUPPLICANT_SUPPORT // | |
6138 | else | |
6139 | return FALSE; | |
6140 | ||
6141 | pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; | |
6142 | ||
6143 | DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode)); | |
6144 | ||
6145 | return TRUE; | |
6146 | } | |
6147 | ||
6148 | /* | |
6149 | ========================================================================== | |
6150 | Description: | |
6151 | Set Encryption Type | |
6152 | Return: | |
6153 | TRUE if all parameters are OK, FALSE otherwise | |
6154 | ========================================================================== | |
6155 | */ | |
6156 | INT Set_EncrypType_Proc( | |
6157 | IN PRTMP_ADAPTER pAdapter, | |
6158 | IN PSTRING arg) | |
6159 | { | |
6160 | if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0)) | |
6161 | { | |
6162 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6163 | return TRUE; // do nothing | |
6164 | ||
6165 | pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled; | |
6166 | pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled; | |
6167 | pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled; | |
6168 | } | |
6169 | else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0)) | |
6170 | { | |
6171 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6172 | return TRUE; // do nothing | |
6173 | ||
6174 | pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled; | |
6175 | pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled; | |
6176 | pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled; | |
6177 | } | |
6178 | else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0)) | |
6179 | { | |
6180 | if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA) | |
6181 | return TRUE; // do nothing | |
6182 | ||
6183 | pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled; | |
6184 | pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled; | |
6185 | pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled; | |
6186 | } | |
6187 | else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0)) | |
6188 | { | |
6189 | if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA) | |
6190 | return TRUE; // do nothing | |
6191 | ||
6192 | pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled; | |
6193 | pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled; | |
6194 | pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled; | |
6195 | } | |
6196 | else | |
6197 | return FALSE; | |
6198 | ||
6199 | pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; | |
6200 | ||
6201 | DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus)); | |
6202 | ||
6203 | return TRUE; | |
6204 | } | |
6205 | ||
6206 | /* | |
6207 | ========================================================================== | |
6208 | Description: | |
6209 | Set Default Key ID | |
6210 | Return: | |
6211 | TRUE if all parameters are OK, FALSE otherwise | |
6212 | ========================================================================== | |
6213 | */ | |
6214 | INT Set_DefaultKeyID_Proc( | |
6215 | IN PRTMP_ADAPTER pAdapter, | |
6216 | IN PSTRING arg) | |
6217 | { | |
6218 | ULONG KeyIdx; | |
6219 | ||
6220 | KeyIdx = simple_strtol(arg, 0, 10); | |
6221 | if((KeyIdx >= 1 ) && (KeyIdx <= 4)) | |
6222 | pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 ); | |
6223 | else | |
6224 | return FALSE; //Invalid argument | |
6225 | ||
6226 | DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId)); | |
6227 | ||
6228 | return TRUE; | |
6229 | } | |
6230 | ||
6231 | /* | |
6232 | ========================================================================== | |
6233 | Description: | |
6234 | Set WEP KEY1 | |
6235 | Return: | |
6236 | TRUE if all parameters are OK, FALSE otherwise | |
6237 | ========================================================================== | |
6238 | */ | |
6239 | INT Set_Key1_Proc( | |
6240 | IN PRTMP_ADAPTER pAdapter, | |
6241 | IN PSTRING arg) | |
6242 | { | |
6243 | int KeyLen; | |
6244 | int i; | |
6245 | UCHAR CipherAlg=CIPHER_WEP64; | |
6246 | ||
6247 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6248 | return TRUE; // do nothing | |
6249 | ||
6250 | KeyLen = strlen(arg); | |
6251 | ||
6252 | switch (KeyLen) | |
6253 | { | |
6254 | case 5: //wep 40 Ascii type | |
6255 | pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen; | |
6256 | memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen); | |
6257 | CipherAlg = CIPHER_WEP64; | |
6258 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii")); | |
6259 | break; | |
6260 | case 10: //wep 40 Hex type | |
6261 | for(i=0; i < KeyLen; i++) | |
6262 | { | |
6263 | if( !isxdigit(*(arg+i)) ) | |
6264 | return FALSE; //Not Hex value; | |
6265 | } | |
6266 | pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ; | |
6267 | AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2); | |
6268 | CipherAlg = CIPHER_WEP64; | |
6269 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex")); | |
6270 | break; | |
6271 | case 13: //wep 104 Ascii type | |
6272 | pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen; | |
6273 | memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen); | |
6274 | CipherAlg = CIPHER_WEP128; | |
6275 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii")); | |
6276 | break; | |
6277 | case 26: //wep 104 Hex type | |
6278 | for(i=0; i < KeyLen; i++) | |
6279 | { | |
6280 | if( !isxdigit(*(arg+i)) ) | |
6281 | return FALSE; //Not Hex value; | |
6282 | } | |
6283 | pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ; | |
6284 | AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2); | |
6285 | CipherAlg = CIPHER_WEP128; | |
6286 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex")); | |
6287 | break; | |
6288 | default: //Invalid argument | |
6289 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg)); | |
6290 | return FALSE; | |
6291 | } | |
6292 | ||
6293 | pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg; | |
6294 | ||
6295 | // Set keys (into ASIC) | |
6296 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6297 | ; // not support | |
6298 | else // Old WEP stuff | |
6299 | { | |
6300 | AsicAddSharedKeyEntry(pAdapter, | |
6301 | 0, | |
6302 | 0, | |
6303 | pAdapter->SharedKey[BSS0][0].CipherAlg, | |
6304 | pAdapter->SharedKey[BSS0][0].Key, | |
6305 | NULL, | |
6306 | NULL); | |
6307 | } | |
6308 | ||
6309 | return TRUE; | |
6310 | } | |
6311 | /* | |
6312 | ========================================================================== | |
6313 | ||
6314 | Description: | |
6315 | Set WEP KEY2 | |
6316 | Return: | |
6317 | TRUE if all parameters are OK, FALSE otherwise | |
6318 | ========================================================================== | |
6319 | */ | |
6320 | INT Set_Key2_Proc( | |
6321 | IN PRTMP_ADAPTER pAdapter, | |
6322 | IN PSTRING arg) | |
6323 | { | |
6324 | int KeyLen; | |
6325 | int i; | |
6326 | UCHAR CipherAlg=CIPHER_WEP64; | |
6327 | ||
6328 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6329 | return TRUE; // do nothing | |
6330 | ||
6331 | KeyLen = strlen(arg); | |
6332 | ||
6333 | switch (KeyLen) | |
6334 | { | |
6335 | case 5: //wep 40 Ascii type | |
6336 | pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen; | |
6337 | memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen); | |
6338 | CipherAlg = CIPHER_WEP64; | |
6339 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii")); | |
6340 | break; | |
6341 | case 10: //wep 40 Hex type | |
6342 | for(i=0; i < KeyLen; i++) | |
6343 | { | |
6344 | if( !isxdigit(*(arg+i)) ) | |
6345 | return FALSE; //Not Hex value; | |
6346 | } | |
6347 | pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ; | |
6348 | AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2); | |
6349 | CipherAlg = CIPHER_WEP64; | |
6350 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex")); | |
6351 | break; | |
6352 | case 13: //wep 104 Ascii type | |
6353 | pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen; | |
6354 | memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen); | |
6355 | CipherAlg = CIPHER_WEP128; | |
6356 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii")); | |
6357 | break; | |
6358 | case 26: //wep 104 Hex type | |
6359 | for(i=0; i < KeyLen; i++) | |
6360 | { | |
6361 | if( !isxdigit(*(arg+i)) ) | |
6362 | return FALSE; //Not Hex value; | |
6363 | } | |
6364 | pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ; | |
6365 | AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2); | |
6366 | CipherAlg = CIPHER_WEP128; | |
6367 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex")); | |
6368 | break; | |
6369 | default: //Invalid argument | |
6370 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg)); | |
6371 | return FALSE; | |
6372 | } | |
6373 | pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg; | |
6374 | ||
6375 | // Set keys (into ASIC) | |
6376 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6377 | ; // not support | |
6378 | else // Old WEP stuff | |
6379 | { | |
6380 | AsicAddSharedKeyEntry(pAdapter, | |
6381 | 0, | |
6382 | 1, | |
6383 | pAdapter->SharedKey[BSS0][1].CipherAlg, | |
6384 | pAdapter->SharedKey[BSS0][1].Key, | |
6385 | NULL, | |
6386 | NULL); | |
6387 | } | |
6388 | ||
6389 | return TRUE; | |
6390 | } | |
6391 | /* | |
6392 | ========================================================================== | |
6393 | Description: | |
6394 | Set WEP KEY3 | |
6395 | Return: | |
6396 | TRUE if all parameters are OK, FALSE otherwise | |
6397 | ========================================================================== | |
6398 | */ | |
6399 | INT Set_Key3_Proc( | |
6400 | IN PRTMP_ADAPTER pAdapter, | |
6401 | IN PSTRING arg) | |
6402 | { | |
6403 | int KeyLen; | |
6404 | int i; | |
6405 | UCHAR CipherAlg=CIPHER_WEP64; | |
6406 | ||
6407 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6408 | return TRUE; // do nothing | |
6409 | ||
6410 | KeyLen = strlen(arg); | |
6411 | ||
6412 | switch (KeyLen) | |
6413 | { | |
6414 | case 5: //wep 40 Ascii type | |
6415 | pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen; | |
6416 | memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen); | |
6417 | CipherAlg = CIPHER_WEP64; | |
6418 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg)); | |
6419 | break; | |
6420 | case 10: //wep 40 Hex type | |
6421 | for(i=0; i < KeyLen; i++) | |
6422 | { | |
6423 | if( !isxdigit(*(arg+i)) ) | |
6424 | return FALSE; //Not Hex value; | |
6425 | } | |
6426 | pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ; | |
6427 | AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2); | |
6428 | CipherAlg = CIPHER_WEP64; | |
6429 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg)); | |
6430 | break; | |
6431 | case 13: //wep 104 Ascii type | |
6432 | pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen; | |
6433 | memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen); | |
6434 | CipherAlg = CIPHER_WEP128; | |
6435 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg)); | |
6436 | break; | |
6437 | case 26: //wep 104 Hex type | |
6438 | for(i=0; i < KeyLen; i++) | |
6439 | { | |
6440 | if( !isxdigit(*(arg+i)) ) | |
6441 | return FALSE; //Not Hex value; | |
6442 | } | |
6443 | pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ; | |
6444 | AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2); | |
6445 | CipherAlg = CIPHER_WEP128; | |
6446 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg)); | |
6447 | break; | |
6448 | default: //Invalid argument | |
6449 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg)); | |
6450 | return FALSE; | |
6451 | } | |
6452 | pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg; | |
6453 | ||
6454 | // Set keys (into ASIC) | |
6455 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6456 | ; // not support | |
6457 | else // Old WEP stuff | |
6458 | { | |
6459 | AsicAddSharedKeyEntry(pAdapter, | |
6460 | 0, | |
6461 | 2, | |
6462 | pAdapter->SharedKey[BSS0][2].CipherAlg, | |
6463 | pAdapter->SharedKey[BSS0][2].Key, | |
6464 | NULL, | |
6465 | NULL); | |
6466 | } | |
6467 | ||
6468 | return TRUE; | |
6469 | } | |
6470 | /* | |
6471 | ========================================================================== | |
6472 | Description: | |
6473 | Set WEP KEY4 | |
6474 | Return: | |
6475 | TRUE if all parameters are OK, FALSE otherwise | |
6476 | ========================================================================== | |
6477 | */ | |
6478 | INT Set_Key4_Proc( | |
6479 | IN PRTMP_ADAPTER pAdapter, | |
6480 | IN PSTRING arg) | |
6481 | { | |
6482 | int KeyLen; | |
6483 | int i; | |
6484 | UCHAR CipherAlg=CIPHER_WEP64; | |
6485 | ||
6486 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6487 | return TRUE; // do nothing | |
6488 | ||
6489 | KeyLen = strlen(arg); | |
6490 | ||
6491 | switch (KeyLen) | |
6492 | { | |
6493 | case 5: //wep 40 Ascii type | |
6494 | pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen; | |
6495 | memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen); | |
6496 | CipherAlg = CIPHER_WEP64; | |
6497 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii")); | |
6498 | break; | |
6499 | case 10: //wep 40 Hex type | |
6500 | for(i=0; i < KeyLen; i++) | |
6501 | { | |
6502 | if( !isxdigit(*(arg+i)) ) | |
6503 | return FALSE; //Not Hex value; | |
6504 | } | |
6505 | pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ; | |
6506 | AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2); | |
6507 | CipherAlg = CIPHER_WEP64; | |
6508 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex")); | |
6509 | break; | |
6510 | case 13: //wep 104 Ascii type | |
6511 | pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen; | |
6512 | memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen); | |
6513 | CipherAlg = CIPHER_WEP128; | |
6514 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii")); | |
6515 | break; | |
6516 | case 26: //wep 104 Hex type | |
6517 | for(i=0; i < KeyLen; i++) | |
6518 | { | |
6519 | if( !isxdigit(*(arg+i)) ) | |
6520 | return FALSE; //Not Hex value; | |
6521 | } | |
6522 | pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ; | |
6523 | AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2); | |
6524 | CipherAlg = CIPHER_WEP128; | |
6525 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex")); | |
6526 | break; | |
6527 | default: //Invalid argument | |
6528 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg)); | |
6529 | return FALSE; | |
6530 | } | |
6531 | pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg; | |
6532 | ||
6533 | // Set keys (into ASIC) | |
6534 | if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) | |
6535 | ; // not support | |
6536 | else // Old WEP stuff | |
6537 | { | |
6538 | AsicAddSharedKeyEntry(pAdapter, | |
6539 | 0, | |
6540 | 3, | |
6541 | pAdapter->SharedKey[BSS0][3].CipherAlg, | |
6542 | pAdapter->SharedKey[BSS0][3].Key, | |
6543 | NULL, | |
6544 | NULL); | |
6545 | } | |
6546 | ||
6547 | return TRUE; | |
6548 | } | |
6549 | ||
6550 | /* | |
6551 | ========================================================================== | |
6552 | Description: | |
6553 | Set WPA PSK key | |
6554 | Return: | |
6555 | TRUE if all parameters are OK, FALSE otherwise | |
6556 | ========================================================================== | |
6557 | */ | |
6558 | INT Set_WPAPSK_Proc( | |
6559 | IN PRTMP_ADAPTER pAd, | |
6560 | IN PSTRING arg) | |
6561 | { | |
6562 | int status; | |
6563 | ||
6564 | if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) && | |
6565 | (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) && | |
6566 | (pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) | |
6567 | ) | |
6568 | return TRUE; // do nothing | |
6569 | ||
6570 | DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg)); | |
6571 | ||
6572 | status = RT_CfgSetWPAPSKKey(pAd, arg, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, pAd->StaCfg.PMK); | |
6573 | if (status == FALSE) | |
6574 | { | |
6575 | DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc(): Set key failed!\n")); | |
6576 | return FALSE; | |
6577 | } | |
6578 | NdisZeroMemory(pAd->StaCfg.WpaPassPhrase, 64); | |
6579 | NdisMoveMemory(pAd->StaCfg.WpaPassPhrase, arg, strlen(arg)); | |
6580 | pAd->StaCfg.WpaPassPhraseLen = (UINT)strlen(arg); | |
6581 | ||
6582 | ||
6583 | ||
6584 | if(pAd->StaCfg.BssType == BSS_ADHOC && | |
6585 | pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) | |
6586 | { | |
6587 | pAd->StaCfg.WpaState = SS_NOTUSE; | |
6588 | } | |
6589 | else | |
6590 | { | |
6591 | // Start STA supplicant state machine | |
6592 | pAd->StaCfg.WpaState = SS_START; | |
6593 | } | |
6594 | ||
6595 | return TRUE; | |
6596 | } | |
6597 | ||
6598 | /* | |
6599 | ========================================================================== | |
6600 | Description: | |
6601 | Set Power Saving mode | |
6602 | Return: | |
6603 | TRUE if all parameters are OK, FALSE otherwise | |
6604 | ========================================================================== | |
6605 | */ | |
6606 | INT Set_PSMode_Proc( | |
6607 | IN PRTMP_ADAPTER pAdapter, | |
6608 | IN PSTRING arg) | |
6609 | { | |
6610 | if (pAdapter->StaCfg.BssType == BSS_INFRA) | |
6611 | { | |
6612 | if ((strcmp(arg, "Max_PSP") == 0) || | |
6613 | (strcmp(arg, "max_psp") == 0) || | |
6614 | (strcmp(arg, "MAX_PSP") == 0)) | |
6615 | { | |
6616 | // do NOT turn on PSM bit here, wait until MlmeCheckPsmChange() | |
6617 | // to exclude certain situations. | |
6618 | if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE) | |
6619 | pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP; | |
6620 | pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP; | |
6621 | OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM); | |
6622 | pAdapter->StaCfg.DefaultListenCount = 5; | |
6623 | ||
6624 | } | |
6625 | else if ((strcmp(arg, "Fast_PSP") == 0) || | |
6626 | (strcmp(arg, "fast_psp") == 0) || | |
6627 | (strcmp(arg, "FAST_PSP") == 0)) | |
6628 | { | |
6629 | // do NOT turn on PSM bit here, wait until MlmeCheckPsmChange() | |
6630 | // to exclude certain situations. | |
6631 | OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM); | |
6632 | if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE) | |
6633 | pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP; | |
6634 | pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP; | |
6635 | pAdapter->StaCfg.DefaultListenCount = 3; | |
6636 | } | |
6637 | else if ((strcmp(arg, "Legacy_PSP") == 0) || | |
6638 | (strcmp(arg, "legacy_psp") == 0) || | |
6639 | (strcmp(arg, "LEGACY_PSP") == 0)) | |
6640 | { | |
6641 | // do NOT turn on PSM bit here, wait until MlmeCheckPsmChange() | |
6642 | // to exclude certain situations. | |
6643 | OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM); | |
6644 | if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE) | |
6645 | pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP; | |
6646 | pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP; | |
6647 | pAdapter->StaCfg.DefaultListenCount = 3; | |
6648 | } | |
6649 | else | |
6650 | { | |
6651 | //Default Ndis802_11PowerModeCAM | |
6652 | // clear PSM bit immediately | |
6653 | RTMP_SET_PSM_BIT(pAdapter, PWR_ACTIVE); | |
6654 | OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM); | |
6655 | if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE) | |
6656 | pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM; | |
6657 | pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM; | |
6658 | } | |
6659 | ||
6660 | DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode)); | |
6661 | } | |
6662 | else | |
6663 | return FALSE; | |
6664 | ||
6665 | ||
6666 | return TRUE; | |
6667 | } | |
6668 | //Add to suport the function which clould dynamicallly enable/disable PCIe Power Saving | |
6669 | ||
6670 | #ifdef WPA_SUPPLICANT_SUPPORT | |
6671 | /* | |
6672 | ========================================================================== | |
6673 | Description: | |
6674 | Set WpaSupport flag. | |
6675 | Value: | |
6676 | 0: Driver ignore wpa_supplicant. | |
6677 | 1: wpa_supplicant initiates scanning and AP selection. | |
6678 | 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters. | |
6679 | Return: | |
6680 | TRUE if all parameters are OK, FALSE otherwise | |
6681 | ========================================================================== | |
6682 | */ | |
6683 | INT Set_Wpa_Support( | |
6684 | IN PRTMP_ADAPTER pAd, | |
6685 | IN PSTRING arg) | |
6686 | { | |
6687 | ||
6688 | if ( simple_strtol(arg, 0, 10) == 0) | |
6689 | pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE; | |
6690 | else if ( simple_strtol(arg, 0, 10) == 1) | |
6691 | pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE; | |
6692 | else if ( simple_strtol(arg, 0, 10) == 2) | |
6693 | pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI; | |
6694 | else | |
6695 | pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE; | |
6696 | ||
6697 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP)); | |
6698 | ||
6699 | return TRUE; | |
6700 | } | |
6701 | #endif // WPA_SUPPLICANT_SUPPORT // | |
6702 | ||
6703 | #ifdef DBG | |
6704 | /* | |
6705 | ========================================================================== | |
6706 | Description: | |
6707 | Read / Write MAC | |
6708 | Arguments: | |
6709 | pAdapter Pointer to our adapter | |
6710 | wrq Pointer to the ioctl argument | |
6711 | ||
6712 | Return Value: | |
6713 | None | |
6714 | ||
6715 | Note: | |
6716 | Usage: | |
6717 | 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0 | |
6718 | 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12 | |
6719 | ========================================================================== | |
6720 | */ | |
6721 | VOID RTMPIoctlMAC( | |
6722 | IN PRTMP_ADAPTER pAdapter, | |
6723 | IN struct iwreq *wrq) | |
6724 | { | |
6725 | PSTRING this_char; | |
6726 | PSTRING value; | |
6727 | INT j = 0, k = 0; | |
6728 | STRING msg[1024]; | |
6729 | STRING arg[255]; | |
6730 | ULONG macAddr = 0; | |
6731 | UCHAR temp[16]; | |
6732 | STRING temp2[16]; | |
6733 | UINT32 macValue = 0; | |
6734 | INT Status; | |
6735 | BOOLEAN bIsPrintAllMAC = FALSE; | |
6736 | ||
6737 | ||
6738 | memset(msg, 0x00, 1024); | |
6739 | if (wrq->u.data.length > 1) //No parameters. | |
6740 | { | |
6741 | Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length); | |
6742 | sprintf(msg, "\n"); | |
6743 | ||
6744 | //Parsing Read or Write | |
6745 | this_char = arg; | |
6746 | if (!*this_char) | |
6747 | goto next; | |
6748 | ||
6749 | if ((value = rtstrchr(this_char, '=')) != NULL) | |
6750 | *value++ = 0; | |
6751 | ||
6752 | if (!value || !*value) | |
6753 | { //Read | |
6754 | // Sanity check | |
6755 | if(strlen(this_char) > 4) | |
6756 | goto next; | |
6757 | ||
6758 | j = strlen(this_char); | |
6759 | while(j-- > 0) | |
6760 | { | |
6761 | if(this_char[j] > 'f' || this_char[j] < '0') | |
6762 | return; | |
6763 | } | |
6764 | ||
6765 | // Mac Addr | |
6766 | k = j = strlen(this_char); | |
6767 | while(j-- > 0) | |
6768 | { | |
6769 | this_char[4-k+j] = this_char[j]; | |
6770 | } | |
6771 | ||
6772 | while(k < 4) | |
6773 | this_char[3-k++]='0'; | |
6774 | this_char[4]='\0'; | |
6775 | ||
6776 | if(strlen(this_char) == 4) | |
6777 | { | |
6778 | AtoH(this_char, temp, 2); | |
6779 | macAddr = *temp*256 + temp[1]; | |
6780 | if (macAddr < 0xFFFF) | |
6781 | { | |
6782 | RTMP_IO_READ32(pAdapter, macAddr, &macValue); | |
6783 | DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue)); | |
6784 | sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue); | |
6785 | } | |
6786 | else | |
6787 | {//Invalid parametes, so default printk all mac | |
6788 | bIsPrintAllMAC = TRUE; | |
6789 | goto next; | |
6790 | } | |
6791 | } | |
6792 | } | |
6793 | else | |
6794 | { //Write | |
6795 | memcpy(&temp2, value, strlen(value)); | |
6796 | temp2[strlen(value)] = '\0'; | |
6797 | ||
6798 | // Sanity check | |
6799 | if((strlen(this_char) > 4) || strlen(temp2) > 8) | |
6800 | goto next; | |
6801 | ||
6802 | j = strlen(this_char); | |
6803 | while(j-- > 0) | |
6804 | { | |
6805 | if(this_char[j] > 'f' || this_char[j] < '0') | |
6806 | return; | |
6807 | } | |
6808 | ||
6809 | j = strlen(temp2); | |
6810 | while(j-- > 0) | |
6811 | { | |
6812 | if(temp2[j] > 'f' || temp2[j] < '0') | |
6813 | return; | |
6814 | } | |
6815 | ||
6816 | //MAC Addr | |
6817 | k = j = strlen(this_char); | |
6818 | while(j-- > 0) | |
6819 | { | |
6820 | this_char[4-k+j] = this_char[j]; | |
6821 | } | |
6822 | ||
6823 | while(k < 4) | |
6824 | this_char[3-k++]='0'; | |
6825 | this_char[4]='\0'; | |
6826 | ||
6827 | //MAC value | |
6828 | k = j = strlen(temp2); | |
6829 | while(j-- > 0) | |
6830 | { | |
6831 | temp2[8-k+j] = temp2[j]; | |
6832 | } | |
6833 | ||
6834 | while(k < 8) | |
6835 | temp2[7-k++]='0'; | |
6836 | temp2[8]='\0'; | |
6837 | ||
6838 | { | |
6839 | AtoH(this_char, temp, 2); | |
6840 | macAddr = *temp*256 + temp[1]; | |
6841 | ||
6842 | AtoH(temp2, temp, 4); | |
6843 | macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3]; | |
6844 | ||
6845 | // debug mode | |
6846 | if (macAddr == (HW_DEBUG_SETTING_BASE + 4)) | |
6847 | { | |
6848 | // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning | |
6849 | if (macValue & 0x000000ff) | |
6850 | { | |
6851 | pAdapter->BbpTuning.bEnable = TRUE; | |
6852 | DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n")); | |
6853 | } | |
6854 | else | |
6855 | { | |
6856 | UCHAR R66; | |
6857 | pAdapter->BbpTuning.bEnable = FALSE; | |
6858 | R66 = 0x26 + GET_LNA_GAIN(pAdapter); | |
6859 | #ifdef RALINK_ATE | |
6860 | if (ATE_ON(pAdapter)) | |
6861 | { | |
6862 | ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter))); | |
6863 | } | |
6864 | else | |
6865 | #endif // RALINK_ATE // | |
6866 | ||
6867 | RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter))); | |
6868 | DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66)); | |
6869 | } | |
6870 | return; | |
6871 | } | |
6872 | ||
6873 | DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue)); | |
6874 | ||
6875 | RTMP_IO_WRITE32(pAdapter, macAddr, macValue); | |
6876 | sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue); | |
6877 | } | |
6878 | } | |
6879 | } | |
6880 | else | |
6881 | bIsPrintAllMAC = TRUE; | |
6882 | next: | |
6883 | if (bIsPrintAllMAC) | |
6884 | { | |
6885 | struct file *file_w; | |
6886 | PSTRING fileName = "MacDump.txt"; | |
6887 | mm_segment_t orig_fs; | |
6888 | ||
6889 | orig_fs = get_fs(); | |
6890 | set_fs(KERNEL_DS); | |
6891 | ||
6892 | // open file | |
6893 | file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0); | |
6894 | if (IS_ERR(file_w)) | |
6895 | { | |
6896 | DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(file_w), fileName)); | |
6897 | } | |
6898 | else | |
6899 | { | |
6900 | if (file_w->f_op && file_w->f_op->write) | |
6901 | { | |
6902 | file_w->f_pos = 0; | |
6903 | macAddr = 0x1000; | |
6904 | ||
6905 | while (macAddr <= 0x1800) | |
6906 | { | |
6907 | RTMP_IO_READ32(pAdapter, macAddr, &macValue); | |
6908 | sprintf(msg, "%08lx = %08X\n", macAddr, macValue); | |
6909 | ||
6910 | // write data to file | |
6911 | file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos); | |
6912 | ||
6913 | printk("%s", msg); | |
6914 | macAddr += 4; | |
6915 | } | |
6916 | sprintf(msg, "\nDump all MAC values to %s\n", fileName); | |
6917 | } | |
6918 | filp_close(file_w, NULL); | |
6919 | } | |
6920 | set_fs(orig_fs); | |
6921 | } | |
6922 | if(strlen(msg) == 1) | |
6923 | sprintf(msg+strlen(msg), "===>Error command format!"); | |
6924 | ||
6925 | // Copy the information into the user buffer | |
6926 | wrq->u.data.length = strlen(msg); | |
6927 | Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length); | |
6928 | ||
6929 | DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n")); | |
6930 | } | |
6931 | ||
6932 | /* | |
6933 | ========================================================================== | |
6934 | Description: | |
6935 | Read / Write E2PROM | |
6936 | Arguments: | |
6937 | pAdapter Pointer to our adapter | |
6938 | wrq Pointer to the ioctl argument | |
6939 | ||
6940 | Return Value: | |
6941 | None | |
6942 | ||
6943 | Note: | |
6944 | Usage: | |
6945 | 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0 | |
6946 | 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234 | |
6947 | ========================================================================== | |
6948 | */ | |
6949 | VOID RTMPIoctlE2PROM( | |
6950 | IN PRTMP_ADAPTER pAdapter, | |
6951 | IN struct iwreq *wrq) | |
6952 | { | |
6953 | PSTRING this_char; | |
6954 | PSTRING value; | |
6955 | INT j = 0, k = 0; | |
6956 | STRING msg[1024]; | |
6957 | STRING arg[255]; | |
6958 | USHORT eepAddr = 0; | |
6959 | UCHAR temp[16]; | |
6960 | STRING temp2[16]; | |
6961 | USHORT eepValue; | |
6962 | int Status; | |
6963 | BOOLEAN bIsPrintAllE2P = FALSE; | |
6964 | ||
6965 | ||
6966 | memset(msg, 0x00, 1024); | |
6967 | if (wrq->u.data.length > 1) //No parameters. | |
6968 | { | |
6969 | Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length); | |
6970 | sprintf(msg, "\n"); | |
6971 | ||
6972 | //Parsing Read or Write | |
6973 | this_char = arg; | |
6974 | ||
6975 | ||
6976 | if (!*this_char) | |
6977 | goto next; | |
6978 | ||
6979 | if ((value = rtstrchr(this_char, '=')) != NULL) | |
6980 | *value++ = 0; | |
6981 | ||
6982 | if (!value || !*value) | |
6983 | { //Read | |
6984 | ||
6985 | // Sanity check | |
6986 | if(strlen(this_char) > 4) | |
6987 | goto next; | |
6988 | ||
6989 | j = strlen(this_char); | |
6990 | while(j-- > 0) | |
6991 | { | |
6992 | if(this_char[j] > 'f' || this_char[j] < '0') | |
6993 | return; | |
6994 | } | |
6995 | ||
6996 | // E2PROM addr | |
6997 | k = j = strlen(this_char); | |
6998 | while(j-- > 0) | |
6999 | { | |
7000 | this_char[4-k+j] = this_char[j]; | |
7001 | } | |
7002 | ||
7003 | while(k < 4) | |
7004 | this_char[3-k++]='0'; | |
7005 | this_char[4]='\0'; | |
7006 | ||
7007 | if(strlen(this_char) == 4) | |
7008 | { | |
7009 | AtoH(this_char, temp, 2); | |
7010 | eepAddr = *temp*256 + temp[1]; | |
7011 | if (eepAddr < 0xFFFF) | |
7012 | { | |
7013 | RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue); | |
7014 | sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue); | |
7015 | } | |
7016 | else | |
7017 | {//Invalid parametes, so default printk all bbp | |
7018 | bIsPrintAllE2P = TRUE; | |
7019 | goto next; | |
7020 | } | |
7021 | } | |
7022 | } | |
7023 | else | |
7024 | { //Write | |
7025 | memcpy(&temp2, value, strlen(value)); | |
7026 | temp2[strlen(value)] = '\0'; | |
7027 | ||
7028 | // Sanity check | |
7029 | if((strlen(this_char) > 4) || strlen(temp2) > 8) | |
7030 | goto next; | |
7031 | ||
7032 | j = strlen(this_char); | |
7033 | while(j-- > 0) | |
7034 | { | |
7035 | if(this_char[j] > 'f' || this_char[j] < '0') | |
7036 | return; | |
7037 | } | |
7038 | j = strlen(temp2); | |
7039 | while(j-- > 0) | |
7040 | { | |
7041 | if(temp2[j] > 'f' || temp2[j] < '0') | |
7042 | return; | |
7043 | } | |
7044 | ||
7045 | //MAC Addr | |
7046 | k = j = strlen(this_char); | |
7047 | while(j-- > 0) | |
7048 | { | |
7049 | this_char[4-k+j] = this_char[j]; | |
7050 | } | |
7051 | ||
7052 | while(k < 4) | |
7053 | this_char[3-k++]='0'; | |
7054 | this_char[4]='\0'; | |
7055 | ||
7056 | //MAC value | |
7057 | k = j = strlen(temp2); | |
7058 | while(j-- > 0) | |
7059 | { | |
7060 | temp2[4-k+j] = temp2[j]; | |
7061 | } | |
7062 | ||
7063 | while(k < 4) | |
7064 | temp2[3-k++]='0'; | |
7065 | temp2[4]='\0'; | |
7066 | ||
7067 | AtoH(this_char, temp, 2); | |
7068 | eepAddr = *temp*256 + temp[1]; | |
7069 | ||
7070 | AtoH(temp2, temp, 2); | |
7071 | eepValue = *temp*256 + temp[1]; | |
7072 | ||
7073 | RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue); | |
7074 | sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue); | |
7075 | } | |
7076 | } | |
7077 | else | |
7078 | bIsPrintAllE2P = TRUE; | |
7079 | next: | |
7080 | if (bIsPrintAllE2P) | |
7081 | { | |
7082 | struct file *file_w; | |
7083 | PSTRING fileName = "EEPROMDump.txt"; | |
7084 | mm_segment_t orig_fs; | |
7085 | ||
7086 | orig_fs = get_fs(); | |
7087 | set_fs(KERNEL_DS); | |
7088 | ||
7089 | // open file | |
7090 | file_w = filp_open(fileName, O_WRONLY|O_CREAT, 0); | |
7091 | if (IS_ERR(file_w)) | |
7092 | { | |
7093 | DBGPRINT(RT_DEBUG_TRACE, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(file_w), fileName)); | |
7094 | } | |
7095 | else | |
7096 | { | |
7097 | if (file_w->f_op && file_w->f_op->write) | |
7098 | { | |
7099 | file_w->f_pos = 0; | |
7100 | eepAddr = 0x00; | |
7101 | ||
7102 | while (eepAddr <= 0xFE) | |
7103 | { | |
7104 | RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue); | |
7105 | sprintf(msg, "%08x = %04x\n", eepAddr , eepValue); | |
7106 | ||
7107 | // write data to file | |
7108 | file_w->f_op->write(file_w, msg, strlen(msg), &file_w->f_pos); | |
7109 | ||
7110 | printk("%s", msg); | |
7111 | eepAddr += 2; | |
7112 | } | |
7113 | sprintf(msg, "\nDump all EEPROM values to %s\n", fileName); | |
7114 | } | |
7115 | filp_close(file_w, NULL); | |
7116 | } | |
7117 | set_fs(orig_fs); | |
7118 | } | |
7119 | if(strlen(msg) == 1) | |
7120 | sprintf(msg+strlen(msg), "===>Error command format!"); | |
7121 | ||
7122 | ||
7123 | // Copy the information into the user buffer | |
7124 | wrq->u.data.length = strlen(msg); | |
7125 | Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length); | |
7126 | ||
7127 | DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n")); | |
7128 | } | |
7129 | ||
7130 | ||
7131 | #ifdef RT30xx | |
7132 | /* | |
7133 | ========================================================================== | |
7134 | Description: | |
7135 | Read / Write RF register | |
7136 | Arguments: | |
7137 | pAdapter Pointer to our adapter | |
7138 | wrq Pointer to the ioctl argument | |
7139 | ||
7140 | Return Value: | |
7141 | None | |
7142 | ||
7143 | Note: | |
7144 | Usage: | |
7145 | 1.) iwpriv ra0 rf ==> read all RF registers | |
7146 | 2.) iwpriv ra0 rf 1 ==> read RF where RegID=1 | |
7147 | 3.) iwpriv ra0 rf 1=10 ==> write RF R1=0x10 | |
7148 | ========================================================================== | |
7149 | */ | |
7150 | VOID RTMPIoctlRF( | |
7151 | IN PRTMP_ADAPTER pAdapter, | |
7152 | IN struct iwreq *wrq) | |
7153 | { | |
7154 | CHAR *this_char; | |
7155 | CHAR *value; | |
7156 | UCHAR regRF = 0; | |
7157 | STRING msg[2048]; | |
7158 | CHAR arg[255]; | |
7159 | INT rfId; | |
7160 | LONG rfValue; | |
7161 | int Status; | |
7162 | BOOLEAN bIsPrintAllRF = FALSE; | |
7163 | ||
7164 | ||
7165 | memset(msg, 0x00, 2048); | |
7166 | if (wrq->u.data.length > 1) //No parameters. | |
7167 | { | |
7168 | Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length); | |
7169 | sprintf(msg, "\n"); | |
7170 | ||
7171 | //Parsing Read or Write | |
7172 | this_char = arg; | |
7173 | if (!*this_char) | |
7174 | goto next; | |
7175 | ||
7176 | if ((value = strchr(this_char, '=')) != NULL) | |
7177 | *value++ = 0; | |
7178 | ||
7179 | if (!value || !*value) | |
7180 | { //Read | |
7181 | if (sscanf((PSTRING) this_char, "%d", &(rfId)) == 1) | |
7182 | { | |
7183 | if (rfId <= 31) | |
7184 | { | |
7185 | #ifdef RALINK_ATE | |
7186 | /* | |
7187 | In RT2860 ATE mode, we do not load 8051 firmware. | |
7188 | We must access RF directly. | |
7189 | For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined. | |
7190 | */ | |
7191 | if (ATE_ON(pAdapter)) | |
7192 | { | |
7193 | ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF); | |
7194 | } | |
7195 | else | |
7196 | #endif // RALINK_ATE // | |
7197 | // according to Andy, Gary, David require. | |
7198 | // the command rf shall read rf register directly for dubug. | |
7199 | // BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); | |
7200 | RT30xxReadRFRegister(pAdapter, rfId, ®RF); | |
7201 | ||
7202 | sprintf(msg+strlen(msg), "R%02d[0x%02x]:%02X ", rfId, rfId, regRF); | |
7203 | } | |
7204 | else | |
7205 | {//Invalid parametes, so default printk all RF | |
7206 | bIsPrintAllRF = TRUE; | |
7207 | goto next; | |
7208 | } | |
7209 | } | |
7210 | else | |
7211 | { //Invalid parametes, so default printk all RF | |
7212 | bIsPrintAllRF = TRUE; | |
7213 | goto next; | |
7214 | } | |
7215 | } | |
7216 | else | |
7217 | { //Write | |
7218 | if ((sscanf((PSTRING) this_char, "%d", &(rfId)) == 1) && (sscanf((PSTRING) value, "%lx", &(rfValue)) == 1)) | |
7219 | { | |
7220 | if (rfId <= 31) | |
7221 | { | |
7222 | #ifdef RALINK_ATE | |
7223 | /* | |
7224 | In RT2860 ATE mode, we do not load 8051 firmware. | |
7225 | We must access RF directly. | |
7226 | For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined. | |
7227 | */ | |
7228 | if (ATE_ON(pAdapter)) | |
7229 | { | |
7230 | ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF); | |
7231 | ATE_RF_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)rfId,(UCHAR) rfValue); | |
7232 | //Read it back for showing | |
7233 | ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF); | |
7234 | sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId, regRF); | |
7235 | } | |
7236 | else | |
7237 | #endif // RALINK_ATE // | |
7238 | { | |
7239 | // according to Andy, Gary, David require. | |
7240 | // the command RF shall read/write RF register directly for dubug. | |
7241 | //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); | |
7242 | //BBP_IO_WRITE8_BY_REG_ID(pAdapter, (UCHAR)bbpId,(UCHAR) bbpValue); | |
7243 | RT30xxReadRFRegister(pAdapter, rfId, ®RF); | |
7244 | RT30xxWriteRFRegister(pAdapter, (UCHAR)rfId,(UCHAR) rfValue); | |
7245 | //Read it back for showing | |
7246 | //BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP); | |
7247 | RT30xxReadRFRegister(pAdapter, rfId, ®RF); | |
7248 | sprintf(msg+strlen(msg), "R%02d[0x%02X]:%02X\n", rfId, rfId, regRF); | |
7249 | } | |
7250 | } | |
7251 | else | |
7252 | {//Invalid parametes, so default printk all RF | |
7253 | bIsPrintAllRF = TRUE; | |
7254 | } | |
7255 | } | |
7256 | else | |
7257 | { //Invalid parametes, so default printk all RF | |
7258 | bIsPrintAllRF = TRUE; | |
7259 | } | |
7260 | } | |
7261 | } | |
7262 | else | |
7263 | bIsPrintAllRF = TRUE; | |
7264 | next: | |
7265 | if (bIsPrintAllRF) | |
7266 | { | |
7267 | memset(msg, 0x00, 2048); | |
7268 | sprintf(msg, "\n"); | |
7269 | for (rfId = 0; rfId <= 31; rfId++) | |
7270 | { | |
7271 | #ifdef RALINK_ATE | |
7272 | /* | |
7273 | In RT2860 ATE mode, we do not load 8051 firmware. | |
7274 | We must access RF directly. | |
7275 | For RT2870 ATE mode, ATE_RF_IO_WRITE8(/READ8)_BY_REG_ID are redefined. | |
7276 | */ | |
7277 | if (ATE_ON(pAdapter)) | |
7278 | { | |
7279 | ATE_RF_IO_READ8_BY_REG_ID(pAdapter, rfId, ®RF); | |
7280 | } | |
7281 | else | |
7282 | #endif // RALINK_ATE // | |
7283 | ||
7284 | // according to Andy, Gary, David require. | |
7285 | // the command RF shall read/write RF register directly for dubug. | |
7286 | RT30xxReadRFRegister(pAdapter, rfId, ®RF); | |
7287 | sprintf(msg+strlen(msg), "%03d = %02X\n", rfId, regRF); | |
7288 | } | |
7289 | // Copy the information into the user buffer | |
7290 | DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg)=%d\n", (UINT32)strlen(msg))); | |
7291 | wrq->u.data.length = strlen(msg); | |
7292 | if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length)) | |
7293 | { | |
7294 | DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__)); | |
7295 | } | |
7296 | } | |
7297 | else | |
7298 | { | |
7299 | if(strlen(msg) == 1) | |
7300 | sprintf(msg+strlen(msg), "===>Error command format!"); | |
7301 | ||
7302 | DBGPRINT(RT_DEBUG_TRACE, ("copy to user [msg=%s]\n", msg)); | |
7303 | // Copy the information into the user buffer | |
7304 | DBGPRINT(RT_DEBUG_TRACE, ("strlen(msg) =%d\n", (UINT32)strlen(msg))); | |
7305 | ||
7306 | // Copy the information into the user buffer | |
7307 | wrq->u.data.length = strlen(msg); | |
7308 | Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length); | |
7309 | } | |
7310 | ||
7311 | DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlRF\n\n")); | |
7312 | } | |
7313 | #endif // RT30xx // | |
7314 | #endif // DBG // | |
7315 | ||
7316 | ||
7317 | ||
7318 | ||
7319 | INT Set_TGnWifiTest_Proc( | |
7320 | IN PRTMP_ADAPTER pAd, | |
7321 | IN PSTRING arg) | |
7322 | { | |
7323 | if (simple_strtol(arg, 0, 10) == 0) | |
7324 | pAd->StaCfg.bTGnWifiTest = FALSE; | |
7325 | else | |
7326 | pAd->StaCfg.bTGnWifiTest = TRUE; | |
7327 | ||
7328 | DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest)); | |
7329 | return TRUE; | |
7330 | } | |
7331 | ||
7332 | #ifdef EXT_BUILD_CHANNEL_LIST | |
7333 | INT Set_Ieee80211dClientMode_Proc( | |
7334 | IN PRTMP_ADAPTER pAdapter, | |
7335 | IN PSTRING arg) | |
7336 | { | |
7337 | if (simple_strtol(arg, 0, 10) == 0) | |
7338 | pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None; | |
7339 | else if (simple_strtol(arg, 0, 10) == 1) | |
7340 | pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible; | |
7341 | else if (simple_strtol(arg, 0, 10) == 2) | |
7342 | pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict; | |
7343 | else | |
7344 | return FALSE; | |
7345 | ||
7346 | DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode)); | |
7347 | return TRUE; | |
7348 | } | |
7349 | #endif // EXT_BUILD_CHANNEL_LIST // | |
7350 | ||
7351 | #ifdef CARRIER_DETECTION_SUPPORT | |
7352 | INT Set_CarrierDetect_Proc( | |
7353 | IN PRTMP_ADAPTER pAd, | |
7354 | IN PSTRING arg) | |
7355 | { | |
7356 | if (simple_strtol(arg, 0, 10) == 0) | |
7357 | pAd->CommonCfg.CarrierDetect.Enable = FALSE; | |
7358 | else | |
7359 | pAd->CommonCfg.CarrierDetect.Enable = TRUE; | |
7360 | ||
7361 | DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable)); | |
7362 | return TRUE; | |
7363 | } | |
7364 | #endif // CARRIER_DETECTION_SUPPORT // | |
7365 | ||
7366 | ||
7367 | INT Show_Adhoc_MacTable_Proc( | |
7368 | IN PRTMP_ADAPTER pAd, | |
7369 | IN PSTRING extra) | |
7370 | { | |
7371 | INT i; | |
7372 | ||
7373 | sprintf(extra, "\n"); | |
7374 | ||
7375 | #ifdef DOT11_N_SUPPORT | |
7376 | sprintf(extra, "%sHT Operating Mode : %d\n", extra, pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode); | |
7377 | #endif // DOT11_N_SUPPORT // | |
7378 | ||
7379 | sprintf(extra, "%s\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n", extra, | |
7380 | "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC"); | |
7381 | ||
7382 | for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++) | |
7383 | { | |
7384 | PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i]; | |
7385 | ||
7386 | if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30)) | |
7387 | break; | |
7388 | if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC)) | |
7389 | { | |
7390 | sprintf(extra, "%s%02X:%02X:%02X:%02X:%02X:%02X ", extra, | |
7391 | pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2], | |
7392 | pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]); | |
7393 | sprintf(extra, "%s%-4d", extra, (int)pEntry->Aid); | |
7394 | sprintf(extra, "%s%-4d", extra, (int)pEntry->apidx); | |
7395 | sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi0); | |
7396 | sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi1); | |
7397 | sprintf(extra, "%s%-7d", extra, pEntry->RssiSample.AvgRssi2); | |
7398 | sprintf(extra, "%s%-10s", extra, GetPhyMode(pEntry->HTPhyMode.field.MODE)); | |
7399 | sprintf(extra, "%s%-6s", extra, GetBW(pEntry->HTPhyMode.field.BW)); | |
7400 | sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.MCS); | |
7401 | sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.ShortGI); | |
7402 | sprintf(extra, "%s%-6d", extra, pEntry->HTPhyMode.field.STBC); | |
7403 | sprintf(extra, "%s%-10d, %d, %d%%\n", extra, pEntry->DebugFIFOCount, pEntry->DebugTxCount, | |
7404 | (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0); | |
7405 | sprintf(extra, "%s\n", extra); | |
7406 | } | |
7407 | } | |
7408 | ||
7409 | return TRUE; | |
7410 | } | |
7411 | ||
7412 | ||
7413 | INT Set_BeaconLostTime_Proc( | |
7414 | IN PRTMP_ADAPTER pAd, | |
7415 | IN PSTRING arg) | |
7416 | { | |
7417 | ULONG ltmp = (ULONG)simple_strtol(arg, 0, 10); | |
7418 | ||
7419 | if ((ltmp != 0) && (ltmp <= 60)) | |
7420 | pAd->StaCfg.BeaconLostTime = (ltmp * OS_HZ); | |
7421 | ||
7422 | DBGPRINT(RT_DEBUG_TRACE, ("IF Set_BeaconLostTime_Proc::(BeaconLostTime=%ld)\n", pAd->StaCfg.BeaconLostTime)); | |
7423 | return TRUE; | |
7424 | } | |
7425 | ||
7426 | INT Set_AutoRoaming_Proc( | |
7427 | IN PRTMP_ADAPTER pAd, | |
7428 | IN PSTRING arg) | |
7429 | { | |
7430 | if (simple_strtol(arg, 0, 10) == 0) | |
7431 | pAd->StaCfg.bAutoRoaming = FALSE; | |
7432 | else | |
7433 | pAd->StaCfg.bAutoRoaming = TRUE; | |
7434 | ||
7435 | DBGPRINT(RT_DEBUG_TRACE, ("IF Set_AutoRoaming_Proc::(bAutoRoaming=%d)\n", pAd->StaCfg.bAutoRoaming)); | |
7436 | return TRUE; | |
7437 | } | |
7438 | ||
7439 | ||
7440 | /* | |
7441 | ========================================================================== | |
7442 | Description: | |
7443 | Issue a site survey command to driver | |
7444 | Arguments: | |
7445 | pAdapter Pointer to our adapter | |
7446 | wrq Pointer to the ioctl argument | |
7447 | ||
7448 | Return Value: | |
7449 | None | |
7450 | ||
7451 | Note: | |
7452 | Usage: | |
7453 | 1.) iwpriv ra0 set site_survey | |
7454 | ========================================================================== | |
7455 | */ | |
7456 | INT Set_SiteSurvey_Proc( | |
7457 | IN PRTMP_ADAPTER pAd, | |
7458 | IN PSTRING arg) | |
7459 | { | |
7460 | NDIS_802_11_SSID Ssid; | |
7461 | ||
7462 | //check if the interface is down | |
7463 | if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) | |
7464 | { | |
7465 | DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); | |
7466 | return -ENETDOWN; | |
7467 | } | |
7468 | ||
7469 | if (MONITOR_ON(pAd)) | |
7470 | { | |
7471 | DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n")); | |
7472 | return -EINVAL; | |
7473 | } | |
7474 | ||
7475 | RTMPZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID)); | |
7476 | Ssid.SsidLength = 0; | |
7477 | if ((arg != NULL) && | |
7478 | (strlen(arg) <= MAX_LEN_OF_SSID)) | |
7479 | { | |
7480 | RTMPMoveMemory(Ssid.Ssid, arg, strlen(arg)); | |
7481 | Ssid.SsidLength = strlen(arg); | |
7482 | } | |
7483 | ||
7484 | pAd->StaCfg.bScanReqIsFromWebUI = TRUE; | |
7485 | ||
7486 | if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) | |
7487 | { | |
7488 | RTMP_MLME_RESET_STATE_MACHINE(pAd); | |
7489 | DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n")); | |
7490 | } | |
7491 | ||
7492 | // tell CNTL state machine to call NdisMSetInformationComplete() after completing | |
7493 | // this request, because this request is initiated by NDIS. | |
7494 | pAd->MlmeAux.CurrReqIsFromNdis = FALSE; | |
7495 | // Reset allowed scan retries | |
7496 | pAd->StaCfg.ScanCnt = 0; | |
7497 | NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime); | |
7498 | ||
7499 | MlmeEnqueue(pAd, | |
7500 | MLME_CNTL_STATE_MACHINE, | |
7501 | OID_802_11_BSSID_LIST_SCAN, | |
7502 | Ssid.SsidLength, | |
7503 | Ssid.Ssid); | |
7504 | ||
7505 | RTMP_MLME_HANDLER(pAd); | |
7506 | ||
7507 | DBGPRINT(RT_DEBUG_TRACE, ("Set_SiteSurvey_Proc\n")); | |
7508 | ||
7509 | return TRUE; | |
7510 | } | |
7511 | ||
7512 | INT Set_ForceTxBurst_Proc( | |
7513 | IN PRTMP_ADAPTER pAd, | |
7514 | IN PSTRING arg) | |
7515 | { | |
7516 | if (simple_strtol(arg, 0, 10) == 0) | |
7517 | pAd->StaCfg.bForceTxBurst = FALSE; | |
7518 | else | |
7519 | pAd->StaCfg.bForceTxBurst = TRUE; | |
7520 | ||
7521 | DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ForceTxBurst_Proc::(bForceTxBurst=%d)\n", pAd->StaCfg.bForceTxBurst)); | |
7522 | return TRUE; | |
7523 | } | |
7524 | ||
7525 | #ifdef ANT_DIVERSITY_SUPPORT | |
7526 | INT Set_Antenna_Proc( | |
7527 | IN PRTMP_ADAPTER pAd, | |
7528 | IN PUCHAR arg) | |
7529 | { | |
7530 | UCHAR UsedAnt; | |
7531 | DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Antenna_Proc *******************\n")); | |
7532 | ||
7533 | if(simple_strtol(arg, 0, 10) <= 3) | |
7534 | UsedAnt = simple_strtol(arg, 0, 10); | |
7535 | ||
7536 | pAd->CommonCfg.bRxAntDiversity = UsedAnt; // Auto switch | |
7537 | if (UsedAnt == ANT_DIVERSITY_ENABLE) | |
7538 | { | |
7539 | pAd->RxAnt.EvaluateStableCnt = 0; | |
7540 | DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Antenna_Proc(Auto Switch Mode), (%d,%d)\n", pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt)); | |
7541 | } | |
7542 | /* 2: Fix in the PHY Antenna CON1*/ | |
7543 | if (UsedAnt == ANT_FIX_ANT1) | |
7544 | { | |
7545 | AsicSetRxAnt(pAd, 0); | |
7546 | DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Antenna_Proc(Fix in Ant CON1), (%d,%d)\n", pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt)); | |
7547 | } | |
7548 | /* 3: Fix in the PHY Antenna CON2*/ | |
7549 | if (UsedAnt == ANT_FIX_ANT2) | |
7550 | { | |
7551 | AsicSetRxAnt(pAd, 1); | |
7552 | DBGPRINT(RT_DEBUG_TRACE, ("<== Set_Antenna_Proc(Fix in Ant CON2), (%d,%d)\n", pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt)); | |
7553 | } | |
7554 | ||
7555 | return TRUE; | |
7556 | } | |
7557 | #endif // ANT_DIVERSITY_SUPPORT // |