2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
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. *
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. *
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. *
25 *************************************************************************
31 IOCTL related subroutines
35 -------- ---------- ----------------------------------------------
36 Rory Chen 01-03-2003 created
37 Rory Chen 02-14-2005 modify to support RT61
40 #include "rt_config.h"
43 extern ULONG RTDebugLevel
;
47 #define WEP_SMALL_KEY_LEN (40/8)
48 #define WEP_LARGE_KEY_LEN (104/8)
50 #define GROUP_KEY_NO 4
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)
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)
62 extern UCHAR CipherWpa2Template
[];
64 typedef struct PACKED _RT_VERSION_INFO
{
70 UINT DriverBuildMonth
;
72 } RT_VERSION_INFO
, *PRT_VERSION_INFO
;
74 struct iw_priv_args privtab
[] = {
76 IW_PRIV_TYPE_CHAR
| 1024, 0,
79 { RTPRIV_IOCTL_SHOW
, IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
,
81 /* --- sub-ioctls definitions --- */
83 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "connStatus" },
85 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "driverVer" },
87 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "bainfo" },
89 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "descinfo" },
91 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, "radio_off" },
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 //
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 --- */
106 IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
,
109 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| 1024,
111 #ifdef RTMP_RF_RW_SUPPORT
113 IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
,
115 #endif // RTMP_RF_RW_SUPPORT //
117 IW_PRIV_TYPE_CHAR
| 1024, IW_PRIV_TYPE_CHAR
| 1024,
121 { RTPRIV_IOCTL_STATISTICS
,
122 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_MASK
,
124 { RTPRIV_IOCTL_GSITESURVEY
,
125 0, IW_PRIV_TYPE_CHAR
| 1024,
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};
146 IN PRTMP_ADAPTER pAdapter
,
150 INT
Set_WmmCapable_Proc(
151 IN PRTMP_ADAPTER pAd
,
155 INT
Set_NetworkType_Proc(
156 IN PRTMP_ADAPTER pAdapter
,
159 INT
Set_AuthMode_Proc(
160 IN PRTMP_ADAPTER pAdapter
,
163 INT
Set_EncrypType_Proc(
164 IN PRTMP_ADAPTER pAdapter
,
167 INT
Set_DefaultKeyID_Proc(
168 IN PRTMP_ADAPTER pAdapter
,
172 IN PRTMP_ADAPTER pAdapter
,
176 IN PRTMP_ADAPTER pAdapter
,
180 IN PRTMP_ADAPTER pAdapter
,
184 IN PRTMP_ADAPTER pAdapter
,
188 IN PRTMP_ADAPTER pAdapter
,
193 IN PRTMP_ADAPTER pAdapter
,
197 INT
Set_PCIePSLevel_Proc(
198 IN PRTMP_ADAPTER pAdapter
,
201 #ifdef WPA_SUPPLICANT_SUPPORT
203 IN PRTMP_ADAPTER pAd
,
205 #endif // WPA_SUPPLICANT_SUPPORT //
210 IN PRTMP_ADAPTER pAdapter
,
211 IN
struct iwreq
*wrq
);
213 VOID
RTMPIoctlE2PROM(
214 IN PRTMP_ADAPTER pAdapter
,
215 IN
struct iwreq
*wrq
);
219 NDIS_STATUS
RTMPWPANoneAddKeyProc(
220 IN PRTMP_ADAPTER pAd
,
223 INT
Set_FragTest_Proc(
224 IN PRTMP_ADAPTER pAdapter
,
227 #ifdef DOT11_N_SUPPORT
228 INT
Set_TGnWifiTest_Proc(
229 IN PRTMP_ADAPTER pAd
,
231 #endif // DOT11_N_SUPPORT //
233 INT
Set_LongRetryLimit_Proc(
234 IN PRTMP_ADAPTER pAdapter
,
237 INT
Set_ShortRetryLimit_Proc(
238 IN PRTMP_ADAPTER pAdapter
,
241 #ifdef EXT_BUILD_CHANNEL_LIST
242 INT
Set_Ieee80211dClientMode_Proc(
243 IN PRTMP_ADAPTER pAdapter
,
245 #endif // EXT_BUILD_CHANNEL_LIST //
247 #ifdef CARRIER_DETECTION_SUPPORT
248 INT
Set_CarrierDetect_Proc(
249 IN PRTMP_ADAPTER pAd
,
251 #endif // CARRIER_DETECTION_SUPPORT //
253 INT
Show_Adhoc_MacTable_Proc(
254 IN PRTMP_ADAPTER pAd
,
257 #ifdef RTMP_RF_RW_SUPPORT
259 IN PRTMP_ADAPTER pAdapter
,
260 IN
struct iwreq
*wrq
);
261 #endif // RTMP_RF_RW_SUPPORT //
264 INT
Set_BeaconLostTime_Proc(
265 IN PRTMP_ADAPTER pAd
,
268 INT
Set_AutoRoaming_Proc(
269 IN PRTMP_ADAPTER pAd
,
272 INT
Set_SiteSurvey_Proc(
273 IN PRTMP_ADAPTER pAd
,
276 INT
Set_ForceTxBurst_Proc(
277 IN PRTMP_ADAPTER pAd
,
280 #ifdef ANT_DIVERSITY_SUPPORT
281 INT
Set_Antenna_Proc(
282 IN PRTMP_ADAPTER pAd
,
284 #endif // ANT_DIVERSITY_SUPPORT //
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 //
319 #ifdef AGGREGATION_SUPPORT
320 {"PktAggregate", Set_PktAggregate_Proc
},
321 #endif // AGGREGATION_SUPPORT //
324 {"WmmCapable", Set_WmmCapable_Proc
},
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
},
339 {"Debug", Set_Debug_Proc
},
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
},
370 #ifdef RALINK_28xx_QA
371 {"TxStop", Set_TxStop_Proc
},
372 {"RxStop", Set_RxStop_Proc
},
373 #endif // RALINK_28xx_QA //
374 #endif // RALINK_ATE //
376 #ifdef WPA_SUPPLICANT_SUPPORT
377 {"WpaSupport", Set_Wpa_Support
},
378 #endif // WPA_SUPPLICANT_SUPPORT //
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 //
406 //2008/09/11:KH add to support efuse<--
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 //
418 //2008/09/11:KH add to support efuse-->
420 {"BeaconLostTime", Set_BeaconLostTime_Proc
},
421 {"AutoRoaming", Set_AutoRoaming_Proc
},
422 {"SiteSurvey", Set_SiteSurvey_Proc
},
423 {"ForceTxBurst", Set_ForceTxBurst_Proc
},
430 IN PRTMP_ADAPTER pAd
,
431 IN PNDIS_802_11_KEY pKey
)
434 MAC_TABLE_ENTRY
*pEntry
;
436 DBGPRINT(RT_DEBUG_TRACE
, ("RTMPAddKey ------>\n"));
438 if (pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
440 if (pKey
->KeyIndex
& 0x80000000)
442 if (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
444 NdisZeroMemory(pAd
->StaCfg
.PMK
, 32);
445 NdisMoveMemory(pAd
->StaCfg
.PMK
, pKey
->KeyMaterial
, pKey
->KeyLength
);
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
)
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
);
459 #endif // WPA_SUPPLICANT_SUPPORT //
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
);
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
;
471 pAd
->SharedKey
[BSS0
][0].CipherAlg
= CIPHER_NONE
;
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
;
480 // Update pairwise key information to ASIC Shared Key Table
481 AsicAddSharedKeyEntry(pAd
,
484 pAd
->SharedKey
[BSS0
][0].CipherAlg
,
485 pAd
->SharedKey
[BSS0
][0].Key
,
486 pAd
->SharedKey
[BSS0
][0].TxMic
,
487 pAd
->SharedKey
[BSS0
][0].RxMic
);
489 // Update ASIC WCID attribute table and IVEIV table
490 RTMPAddWcidAttributeEntry(pAd
,
493 pAd
->SharedKey
[BSS0
][0].CipherAlg
,
496 if (pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA2
)
498 // set 802.1x port control
499 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
500 STA_PORT_SECURED(pAd
);
502 // Indicate Connected for GUI
503 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
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
)
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
);
520 #endif // WPA_SUPPLICANT_SUPPORT //
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
);
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
;
533 // Update group key information to ASIC Shared Key Table
534 AsicAddSharedKeyEntry(pAd
,
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
);
542 // Update ASIC WCID attribute table and IVEIV table
543 RTMPAddWcidAttributeEntry(pAd
,
545 pAd
->StaCfg
.DefaultKeyId
,
546 pAd
->SharedKey
[BSS0
][pAd
->StaCfg
.DefaultKeyId
].CipherAlg
,
549 // set 802.1x port control
550 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
551 STA_PORT_SECURED(pAd
);
553 // Indicate Connected for GUI
554 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
557 else // dynamic WEP from wpa_supplicant
562 if(pKey
->KeyLength
== 32)
565 KeyIdx
= pKey
->KeyIndex
& 0x0fffffff;
569 // it is a default shared key, for Pairwise key setting
570 if (pKey
->KeyIndex
& 0x80000000)
572 pEntry
= MacTableLookup(pAd
, pKey
->BSSID
);
576 DBGPRINT(RT_DEBUG_TRACE
, ("RTMPAddKey: Set Pair-wise Key\n"));
578 // set key material and key length
579 pEntry
->PairwiseKey
.KeyLen
= (UCHAR
)pKey
->KeyLength
;
580 NdisMoveMemory(pEntry
->PairwiseKey
.Key
, &pKey
->KeyMaterial
, pKey
->KeyLength
);
583 if (pKey
->KeyLength
== 5)
584 pEntry
->PairwiseKey
.CipherAlg
= CIPHER_WEP64
;
586 pEntry
->PairwiseKey
.CipherAlg
= CIPHER_WEP128
;
588 // Add Pair-wise key to Asic
589 AsicAddPairwiseKeyEntry(
593 &pEntry
->PairwiseKey
);
595 // update WCID attribute table and IVEIV table for this entry
596 RTMPAddWcidAttributeEntry(
599 KeyIdx
, // The value may be not zero
600 pEntry
->PairwiseKey
.CipherAlg
,
607 // Default key for tx (shared key)
608 pAd
->StaCfg
.DefaultKeyId
= (UCHAR
) KeyIdx
;
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
);
615 if (pKey
->KeyLength
== 5)
616 pAd
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
= CIPHER_WEP64
;
618 pAd
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
= CIPHER_WEP128
;
620 CipherAlg
= pAd
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
;
621 Key
= pAd
->SharedKey
[BSS0
][KeyIdx
].Key
;
623 // Set Group key material to Asic
624 AsicAddSharedKeyEntry(pAd
, BSS0
, KeyIdx
, CipherAlg
, Key
, NULL
, NULL
);
626 // Update WCID attribute table and IVEIV table for this group key table
627 RTMPAddWcidAttributeEntry(pAd
, BSS0
, KeyIdx
, CipherAlg
, NULL
);
636 char * rtstrchr(const char * s
, int c
)
638 for(; *s
!= (char) c
; ++s
)
645 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
649 rt_ioctl_giwname(struct net_device
*dev
,
650 struct iw_request_info
*info
,
651 char *name
, char *extra
)
655 strncpy(name
, "RT2860 Wireless", IFNAMSIZ
);
656 #endif // RTMP_MAC_PCI //
660 int rt_ioctl_siwfreq(struct net_device
*dev
,
661 struct iw_request_info
*info
,
662 struct iw_freq
*freq
, char *extra
)
664 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
667 //check if the interface is down
668 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
670 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
678 if((freq
->e
== 0) && (freq
->m
<= 1000))
679 chan
= freq
->m
; // Setting by channel number
681 MAP_KHZ_TO_CHANNEL_ID( (freq
->m
/100) , chan
); // Setting by frequency - search the table , like 2.412G, 2.422G,
683 if (ChannelSanity(pAdapter
, chan
) == TRUE
)
685 pAdapter
->CommonCfg
.Channel
= chan
;
686 DBGPRINT(RT_DEBUG_ERROR
, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ
, pAdapter
->CommonCfg
.Channel
));
695 int rt_ioctl_giwfreq(struct net_device
*dev
,
696 struct iw_request_info
*info
,
697 struct iw_freq
*freq
, char *extra
)
699 PRTMP_ADAPTER pAdapter
= NULL
;
703 pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
704 if (pAdapter
== NULL
)
706 /* if 1st open fail, pAd will be free;
707 So the net_dev->priv will be NULL in 2rd open */
711 ch
= pAdapter
->CommonCfg
.Channel
;
713 DBGPRINT(RT_DEBUG_TRACE
,("==>rt_ioctl_giwfreq %d\n", ch
));
715 MAP_CHANNEL_ID_TO_KHZ(ch
, m
);
722 int rt_ioctl_siwmode(struct net_device
*dev
,
723 struct iw_request_info
*info
,
724 __u32
*mode
, char *extra
)
726 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
728 //check if the interface is down
729 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
731 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
738 Set_NetworkType_Proc(pAdapter
, "Adhoc");
741 Set_NetworkType_Proc(pAdapter
, "Infra");
743 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))
744 case IW_MODE_MONITOR
:
745 Set_NetworkType_Proc(pAdapter
, "Monitor");
749 DBGPRINT(RT_DEBUG_TRACE
, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode
));
753 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
754 pAdapter
->StaCfg
.WpaState
= SS_NOTUSE
;
760 int rt_ioctl_giwmode(struct net_device
*dev
,
761 struct iw_request_info
*info
,
762 __u32
*mode
, char *extra
)
764 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
766 if (pAdapter
== NULL
)
768 /* if 1st open fail, pAd will be free;
769 So the net_dev->priv will be NULL in 2rd open */
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
))
780 *mode
= IW_MODE_MONITOR
;
784 *mode
= IW_MODE_AUTO
;
786 DBGPRINT(RT_DEBUG_TRACE
, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode
));
790 int rt_ioctl_siwsens(struct net_device
*dev
,
791 struct iw_request_info
*info
,
792 char *name
, char *extra
)
794 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
796 //check if the interface is down
797 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
799 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
806 int rt_ioctl_giwsens(struct net_device
*dev
,
807 struct iw_request_info
*info
,
808 char *name
, char *extra
)
813 int rt_ioctl_giwrange(struct net_device
*dev
,
814 struct iw_request_info
*info
,
815 struct iw_point
*data
, char *extra
)
817 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
818 struct iw_range
*range
= (struct iw_range
*) extra
;
822 if (pAdapter
== NULL
)
824 /* if 1st open fail, pAd will be free;
825 So the net_dev->priv will be NULL in 2rd open */
829 DBGPRINT(RT_DEBUG_TRACE
,("===>rt_ioctl_giwrange\n"));
830 data
->length
= sizeof(struct iw_range
);
831 memset(range
, 0, sizeof(struct iw_range
));
833 range
->txpower_capa
= IW_TXPOW_DBM
;
835 if (INFRA_ON(pAdapter
)||ADHOC_ON(pAdapter
))
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
;
847 range
->we_version_compiled
= WIRELESS_EXT
;
848 range
->we_version_source
= 14;
850 range
->retry_capa
= IW_RETRY_LIMIT
;
851 range
->retry_flags
= IW_RETRY_LIMIT
;
852 range
->min_retry
= 0;
853 range
->max_retry
= 255;
855 range
->num_channels
= pAdapter
->ChannelListNum
;
858 for (i
= 1; i
<= range
->num_channels
; i
++)
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 */
865 range
->freq
[val
].e
= 1;
867 if (val
== IW_MAX_FREQUENCIES
)
870 range
->num_frequency
= val
;
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 */
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;
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;
890 range
->max_rts
= 2347;
891 range
->min_frag
= 256;
892 range
->max_frag
= 2346;
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
;
903 int rt_ioctl_siwap(struct net_device
*dev
,
904 struct iw_request_info
*info
,
905 struct sockaddr
*ap_addr
, char *extra
)
907 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
908 NDIS_802_11_MAC_ADDRESS Bssid
;
910 //check if the interface is down
911 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
913 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
917 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
919 RTMP_MLME_RESET_STATE_MACHINE(pAdapter
);
920 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
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;
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
,
934 sizeof(NDIS_802_11_MAC_ADDRESS
),
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]));
943 int rt_ioctl_giwap(struct net_device
*dev
,
944 struct iw_request_info
*info
,
945 struct sockaddr
*ap_addr
, char *extra
)
947 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
949 if (pAdapter
== NULL
)
951 /* if 1st open fail, pAd will be free;
952 So the net_dev->priv will be NULL in 2rd open */
956 if (INFRA_ON(pAdapter
) || ADHOC_ON(pAdapter
))
958 ap_addr
->sa_family
= ARPHRD_ETHER
;
959 memcpy(ap_addr
->sa_data
, &pAdapter
->CommonCfg
.Bssid
, ETH_ALEN
);
961 #ifdef WPA_SUPPLICANT_SUPPORT
963 else if (pAdapter
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_DISABLE
)
965 ap_addr
->sa_family
= ARPHRD_ETHER
;
966 memcpy(ap_addr
->sa_data
, &pAdapter
->MlmeAux
.Bssid
, ETH_ALEN
);
968 #endif // WPA_SUPPLICANT_SUPPORT //
971 DBGPRINT(RT_DEBUG_TRACE
, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
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.
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
991 * NB: various calculations are based on the orinoco/wavelan
992 * drivers for compatibility
994 static void set_quality(PRTMP_ADAPTER pAdapter
,
995 struct iw_quality
*iq
,
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;
1010 iq
->qual
= (__u8
)ChannelQuality
;
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
;
1018 int rt_ioctl_iwaplist(struct net_device
*dev
,
1019 struct iw_request_info
*info
,
1020 struct iw_point
*data
, char *extra
)
1022 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1024 struct sockaddr addr
[IW_MAX_AP
];
1025 struct iw_quality qual
[IW_MAX_AP
];
1028 //check if the interface is down
1029 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1031 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1037 for (i
= 0; i
<IW_MAX_AP
; i
++)
1039 if (i
>= pAdapter
->ScanTab
.BssNr
)
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
);
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
]));
1054 int rt_ioctl_siwscan(struct net_device
*dev
,
1055 struct iw_request_info
*info
,
1056 struct iw_point
*data
, char *extra
)
1058 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1061 int Status
= NDIS_STATUS_SUCCESS
;
1063 //check if the interface is down
1064 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1066 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1070 if (MONITOR_ON(pAdapter
))
1072 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Driver is in Monitor Mode now !!!\n"));
1077 #ifdef WPA_SUPPLICANT_SUPPORT
1078 if (pAdapter
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_ENABLE
)
1080 pAdapter
->StaCfg
.WpaSupplicantScanCount
++;
1082 #endif // WPA_SUPPLICANT_SUPPORT //
1084 pAdapter
->StaCfg
.bScanReqIsFromWebUI
= TRUE
;
1085 if (RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
1086 return NDIS_STATUS_SUCCESS
;
1090 #ifdef WPA_SUPPLICANT_SUPPORT
1091 if ((pAdapter
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_ENABLE
) &&
1092 (pAdapter
->StaCfg
.WpaSupplicantScanCount
> 3))
1094 DBGPRINT(RT_DEBUG_TRACE
, ("!!! WpaSupplicantScanCount > 3\n"));
1095 Status
= NDIS_STATUS_SUCCESS
;
1098 #endif // WPA_SUPPLICANT_SUPPORT //
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
))
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
;
1110 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
1112 RTMP_MLME_RESET_STATE_MACHINE(pAdapter
);
1113 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
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
;
1123 MlmeEnqueue(pAdapter
,
1124 MLME_CNTL_STATE_MACHINE
,
1125 OID_802_11_BSSID_LIST_SCAN
,
1129 Status
= NDIS_STATUS_SUCCESS
;
1130 RTMP_MLME_HANDLER(pAdapter
);
1132 return NDIS_STATUS_SUCCESS
;
1135 int rt_ioctl_giwscan(struct net_device
*dev
,
1136 struct iw_request_info
*info
,
1137 struct iw_point
*data
, char *extra
)
1140 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1142 PSTRING current_ev
= extra
, previous_ev
= extra
;
1144 PSTRING current_val
;
1145 STRING custom
[MAX_CUSTOM_LEN
] = {0};
1148 #endif // IWEVGENIE //
1149 struct iw_event iwe
;
1151 if (RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
1154 * Still scanning, indicate the caller should try again.
1160 #ifdef WPA_SUPPLICANT_SUPPORT
1161 if (pAdapter
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_ENABLE
)
1163 pAdapter
->StaCfg
.WpaSupplicantScanCount
= 0;
1165 #endif // WPA_SUPPLICANT_SUPPORT //
1167 if (pAdapter
->ScanTab
.BssNr
== 0)
1173 #if WIRELESS_EXT >= 17
1174 if (data
->length
> 0)
1175 end_buf
= extra
+ data
->length
;
1177 end_buf
= extra
+ IW_SCAN_MAX_DATA
;
1179 end_buf
= extra
+ IW_SCAN_MAX_DATA
;
1182 for (i
= 0; i
< pAdapter
->ScanTab
.BssNr
; i
++)
1184 if (current_ev
>= end_buf
)
1186 #if WIRELESS_EXT >= 17
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
);
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
1211 it will show scanned AP's WirelessMode .
1220 memset(&iwe
, 0, sizeof(iwe
));
1221 iwe
.cmd
= SIOCGIWNAME
;
1225 PBSS_ENTRY pBssEntry
=&pAdapter
->ScanTab
.BssEntry
[i
];
1226 BOOLEAN isGonly
=FALSE
;
1229 if (pBssEntry
->Channel
>14)
1231 if (pBssEntry
->HtCapabilityLen
!=0)
1232 strcpy(iwe
.u
.name
,"802.11a/n");
1234 strcpy(iwe
.u
.name
,"802.11a");
1239 if one of non B mode rate is set supported rate . it mean G only.
1241 for (rateCnt
=0;rateCnt
<pBssEntry
->SupRateLen
;rateCnt
++)
1244 6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate , it mean G only.
1246 if (pBssEntry
->SupRate
[rateCnt
]==140 || pBssEntry
->SupRate
[rateCnt
]==146 || pBssEntry
->SupRate
[rateCnt
]>=152)
1250 for (rateCnt
=0;rateCnt
<pBssEntry
->ExtRateLen
;rateCnt
++)
1252 if (pBssEntry
->ExtRate
[rateCnt
]==140 || pBssEntry
->ExtRate
[rateCnt
]==146 || pBssEntry
->ExtRate
[rateCnt
]>=152)
1257 if (pBssEntry
->HtCapabilityLen
!=0)
1260 strcpy(iwe
.u
.name
,"802.11g/n");
1262 strcpy(iwe
.u
.name
,"802.11b/g/n");
1267 strcpy(iwe
.u
.name
,"802.11g");
1270 if (pBssEntry
->SupRateLen
==4 && pBssEntry
->ExtRateLen
==0)
1271 strcpy(iwe
.u
.name
,"802.11b");
1273 strcpy(iwe
.u
.name
,"802.11b/g");
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
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;
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
1305 //================================
1306 memset(&iwe
, 0, sizeof(iwe
));
1307 iwe
.cmd
= SIOCGIWMODE
;
1308 if (pAdapter
->ScanTab
.BssEntry
[i
].BssType
== Ndis802_11IBSS
)
1310 iwe
.u
.mode
= IW_MODE_ADHOC
;
1312 else if (pAdapter
->ScanTab
.BssEntry
[i
].BssType
== Ndis802_11Infrastructure
)
1314 iwe
.u
.mode
= IW_MODE_INFRA
;
1318 iwe
.u
.mode
= IW_MODE_AUTO
;
1320 iwe
.len
= IW_EV_UINT_LEN
;
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
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
;
1338 iwe
.u
.freq
.m
= pAdapter
->ScanTab
.BssEntry
[i
].Channel
;
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
1351 //Add quality statistics
1352 //================================
1353 memset(&iwe
, 0, sizeof(iwe
));
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
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
;
1373 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
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
1385 //================================
1386 if (pAdapter
->ScanTab
.BssEntry
[i
].SupRateLen
)
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;
1401 iwe
.u
.bitrate
.value
= (tmpRate
/2) * 1000000;
1403 if (tmpRate
== 0x6c && pAdapter
->ScanTab
.BssEntry
[i
].HtCapabilityLen
> 0)
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
);
1412 if (rate_index
> rate_count
)
1413 rate_index
= rate_count
;
1414 iwe
.u
.bitrate
.value
= ralinkrate
[rate_index
] * 500000;
1417 iwe
.u
.bitrate
.disabled
= 0;
1418 current_val
= IWE_STREAM_ADD_VALUE(info
, current_ev
,
1419 current_val
, end_buf
, &iwe
,
1422 if((current_val
-current_ev
)>IW_EV_LCP_LEN
)
1423 current_ev
= current_val
;
1425 #if WIRELESS_EXT >= 17
1434 if (pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IELen
> 0)
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
1452 if (pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IELen
> 0)
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
1470 //================================
1471 if (pAdapter
->ScanTab
.BssEntry
[i
].WpaIE
.IELen
> 0)
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
1491 if (pAdapter
->ScanTab
.BssEntry
[i
].RsnIE
.IELen
> 0)
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
1509 #endif // IWEVGENIE //
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
));
1519 int rt_ioctl_siwessid(struct net_device
*dev
,
1520 struct iw_request_info
*info
,
1521 struct iw_point
*data
, char *essid
)
1523 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1525 //check if the interface is down
1526 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1528 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1534 PSTRING pSsidString
= NULL
;
1536 // Includes null character.
1537 if (data
->length
> (IW_ESSID_MAX_SIZE
+ 1))
1540 pSsidString
= kmalloc(MAX_LEN_OF_SSID
+1, MEM_ALLOC_FLAG
);
1543 NdisZeroMemory(pSsidString
, MAX_LEN_OF_SSID
+1);
1544 NdisMoveMemory(pSsidString
, essid
, data
->length
);
1545 if (Set_SSID_Proc(pAdapter
, pSsidString
) == FALSE
)
1554 if (Set_SSID_Proc(pAdapter
, "") == FALSE
)
1560 int rt_ioctl_giwessid(struct net_device
*dev
,
1561 struct iw_request_info
*info
,
1562 struct iw_point
*data
, char *essid
)
1564 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1566 if (pAdapter
== NULL
)
1568 /* if 1st open fail, pAd will be free;
1569 So the net_dev->priv will be NULL in 2rd open */
1574 if (MONITOR_ON(pAdapter
))
1580 if (OPSTATUS_TEST_FLAG(pAdapter
, fOP_STATUS_MEDIA_STATE_CONNECTED
))
1582 DBGPRINT(RT_DEBUG_TRACE
,("MediaState is connected\n"));
1583 data
->length
= pAdapter
->CommonCfg
.SsidLen
;
1584 memcpy(essid
, pAdapter
->CommonCfg
.Ssid
, pAdapter
->CommonCfg
.SsidLen
);
1587 {//the ANY ssid was specified
1589 DBGPRINT(RT_DEBUG_TRACE
,("MediaState is not connected, ess\n"));
1596 int rt_ioctl_siwnickn(struct net_device
*dev
,
1597 struct iw_request_info
*info
,
1598 struct iw_point
*data
, char *nickname
)
1600 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1602 //check if the interface is down
1603 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1605 DBGPRINT(RT_DEBUG_TRACE
,("INFO::Network is down!\n"));
1609 if (data
->length
> IW_ESSID_MAX_SIZE
)
1612 memset(pAdapter
->nickname
, 0, IW_ESSID_MAX_SIZE
+ 1);
1613 memcpy(pAdapter
->nickname
, nickname
, data
->length
);
1619 int rt_ioctl_giwnickn(struct net_device
*dev
,
1620 struct iw_request_info
*info
,
1621 struct iw_point
*data
, char *nickname
)
1623 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1625 if (pAdapter
== NULL
)
1627 /* if 1st open fail, pAd will be free;
1628 So the net_dev->priv will be NULL in 2rd open */
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';
1641 int rt_ioctl_siwrts(struct net_device
*dev
,
1642 struct iw_request_info
*info
,
1643 struct iw_param
*rts
, char *extra
)
1645 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1648 //check if the interface is down
1649 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1651 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1656 val
= MAX_RTS_THRESHOLD
;
1657 else if (rts
->value
< 0 || rts
->value
> MAX_RTS_THRESHOLD
)
1659 else if (rts
->value
== 0)
1660 val
= MAX_RTS_THRESHOLD
;
1664 if (val
!= pAdapter
->CommonCfg
.RtsThreshold
)
1665 pAdapter
->CommonCfg
.RtsThreshold
= val
;
1670 int rt_ioctl_giwrts(struct net_device
*dev
,
1671 struct iw_request_info
*info
,
1672 struct iw_param
*rts
, char *extra
)
1674 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1676 if (pAdapter
== NULL
)
1678 /* if 1st open fail, pAd will be free;
1679 So the net_dev->priv will be NULL in 2rd open */
1683 //check if the interface is down
1684 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1686 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1690 rts
->value
= pAdapter
->CommonCfg
.RtsThreshold
;
1691 rts
->disabled
= (rts
->value
== MAX_RTS_THRESHOLD
);
1697 int rt_ioctl_siwfrag(struct net_device
*dev
,
1698 struct iw_request_info
*info
,
1699 struct iw_param
*frag
, char *extra
)
1701 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1704 //check if the interface is down
1705 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1707 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
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
;
1720 pAdapter
->CommonCfg
.FragmentThreshold
= val
;
1724 int rt_ioctl_giwfrag(struct net_device
*dev
,
1725 struct iw_request_info
*info
,
1726 struct iw_param
*frag
, char *extra
)
1728 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1730 if (pAdapter
== NULL
)
1732 /* if 1st open fail, pAd will be free;
1733 So the net_dev->priv will be NULL in 2rd open */
1737 //check if the interface is down
1738 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1740 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1744 frag
->value
= pAdapter
->CommonCfg
.FragmentThreshold
;
1745 frag
->disabled
= (frag
->value
== MAX_FRAG_THRESHOLD
);
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
)
1757 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1759 //check if the interface is down
1760 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1762 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1766 if ((erq
->length
== 0) &&
1767 (erq
->flags
& IW_ENCODE_DISABLED
))
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
;
1776 else if (erq
->flags
& IW_ENCODE_RESTRICTED
|| erq
->flags
& IW_ENCODE_OPEN
)
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
;
1787 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
1790 if (erq
->length
> 0)
1792 int keyIdx
= (erq
->flags
& IW_ENCODE_INDEX
) - 1;
1793 /* Check the size of the key */
1794 if (erq
->length
> MAX_WEP_KEY_SIZE
)
1798 /* Check key index */
1799 if ((keyIdx
< 0) || (keyIdx
>= NR_WEP_KEYS
))
1801 DBGPRINT(RT_DEBUG_TRACE
,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1802 keyIdx
, pAdapter
->StaCfg
.DefaultKeyId
));
1805 keyIdx
= pAdapter
->StaCfg
.DefaultKeyId
;
1808 pAdapter
->StaCfg
.DefaultKeyId
= keyIdx
;
1810 NdisZeroMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
, 16);
1812 if (erq
->length
== MAX_WEP_KEY_SIZE
)
1814 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= MAX_WEP_KEY_SIZE
;
1815 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CIPHER_WEP128
;
1817 else if (erq
->length
== MIN_WEP_KEY_SIZE
)
1819 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= MIN_WEP_KEY_SIZE
;
1820 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CIPHER_WEP64
;
1823 /* Disable the key */
1824 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= 0;
1826 /* Check if the key is not marked as invalid */
1827 if(!(erq
->flags
& IW_ENCODE_NOKEY
))
1829 /* Copy the key in the driver */
1830 NdisMoveMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
, extra
, erq
->length
);
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))
1839 pAdapter
->StaCfg
.DefaultKeyId
= index
;
1842 /* Don't complain if only change the mode */
1843 if (!(erq
->flags
& IW_ENCODE_MODE
))
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
));
1856 rt_ioctl_giwencode(struct net_device
*dev
,
1857 struct iw_request_info
*info
,
1858 struct iw_point
*erq
, char *key
)
1861 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1863 if (pAdapter
== NULL
)
1865 /* if 1st open fail, pAd will be free;
1866 So the net_dev->priv will be NULL in 2rd open */
1870 //check if the interface is down
1871 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1873 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1877 kid
= erq
->flags
& IW_ENCODE_INDEX
;
1878 DBGPRINT(RT_DEBUG_TRACE
, ("===>rt_ioctl_giwencode %d\n", erq
->flags
& IW_ENCODE_INDEX
));
1880 if (pAdapter
->StaCfg
.WepStatus
== Ndis802_11WEPDisabled
)
1883 erq
->flags
= IW_ENCODE_DISABLED
;
1885 else if ((kid
> 0) && (kid
<=4))
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 */
1897 erq
->flags
|= IW_ENCODE_OPEN
; /* XXX */
1902 if (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeShared
)
1903 erq
->flags
|= IW_ENCODE_RESTRICTED
; /* XXX */
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 */
1912 erq
->flags
|= IW_ENCODE_OPEN
; /* XXX */
1913 erq
->flags
= pAdapter
->StaCfg
.DefaultKeyId
+ 1; /* NB: base 1 */
1914 erq
->flags
|= IW_ENCODE_ENABLED
; /* XXX */
1922 rt_ioctl_setparam(struct net_device
*dev
, struct iw_request_info
*info
,
1923 void *w
, char *extra
)
1925 PRTMP_ADAPTER pAdapter
;
1927 PSTRING this_char
= extra
;
1931 pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
1932 if (pAdapter
== NULL
)
1934 /* if 1st open fail, pAd will be free;
1935 So the net_dev->priv will be NULL in 2rd open */
1939 pObj
= (POS_COOKIE
) pAdapter
->OS_Cookie
;
1941 pObj
->ioctl_if_type
= INT_MAIN
;
1942 pObj
->ioctl_if
= MAIN_MBSSID
;
1945 //check if the interface is down
1946 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
1948 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
1955 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
1958 if (!value
&& (strcmp(this_char
, "SiteSurvey") != 0))
1963 // reject setting nothing besides ANY ssid(ssidLen=0)
1964 if (!*value
&& (strcmp(this_char
, "SSID") != 0))
1968 for (PRTMP_PRIVATE_SET_PROC
= RTMP_PRIVATE_SUPPORT_PROC
; PRTMP_PRIVATE_SET_PROC
->name
; PRTMP_PRIVATE_SET_PROC
++)
1970 if (strcmp(this_char
, PRTMP_PRIVATE_SET_PROC
->name
) == 0)
1972 if(!PRTMP_PRIVATE_SET_PROC
->set_proc(pAdapter
, value
))
1973 { //FALSE:Set private failed then return Invalid argument
1976 break; //Exit for loop.
1980 if(PRTMP_PRIVATE_SET_PROC
->name
== NULL
)
1981 { //Not found argument
1983 DBGPRINT(RT_DEBUG_TRACE
, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char
, value
));
1991 rt_private_get_statistics(struct net_device
*dev
, struct iw_request_info
*info
,
1992 struct iw_point
*wrq
, char *extra
)
1995 PRTMP_ADAPTER pAd
= RTMP_OS_NETDEV_GET_PRIV(dev
);
2003 memset(extra
, 0x00, IW_PRIV_SIZE_MASK
);
2004 sprintf(extra
, "\n\n");
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);
2013 #endif // RALINK_ATE //
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
);
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
);
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
);
2028 sprintf(extra
+strlen(extra
), "False CCA (one second) = %ld\n", (ULONG
)pAd
->RalinkCounters
.OneSecFalseCCACnt
);
2033 if (pAd
->ate
.RxAntennaSel
== 0)
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
));
2041 sprintf(extra
+strlen(extra
), "RSSI = %ld\n", (LONG
)(pAd
->ate
.LastRssi0
- pAd
->BbpRssiToDbmDelta
));
2045 #endif // RALINK_ATE //
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
));
2051 #ifdef WPA_SUPPLICANT_SUPPORT
2052 sprintf(extra
+strlen(extra
), "WpaSupplicantUP = %d\n\n", pAd
->StaCfg
.WpaSupplicantUP
);
2053 #endif // WPA_SUPPLICANT_SUPPORT //
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
));
2063 #ifdef DOT11_N_SUPPORT
2065 IN PRTMP_ADAPTER pAd
,
2069 BA_ORI_ENTRY
*pOriBAEntry
;
2070 BA_REC_ENTRY
*pRecBAEntry
;
2072 for (i
=0; i
<MAX_LEN_OF_MAC_TABLE
; i
++)
2074 PMAC_TABLE_ENTRY pEntry
= &pAd
->MacTab
.Content
[i
];
2075 if (((pEntry
->ValidAsCLI
|| pEntry
->ValidAsApCli
) && (pEntry
->Sst
== SST_ASSOC
))
2076 || (pEntry
->ValidAsWDS
) || (pEntry
->ValidAsMesh
))
2078 sprintf(pOutBuf
, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
2080 pEntry
->Addr
[0], pEntry
->Addr
[1], pEntry
->Addr
[2],
2081 pEntry
->Addr
[3], pEntry
->Addr
[4], pEntry
->Addr
[5], pEntry
->Aid
);
2083 sprintf(pOutBuf
, "%s[Recipient]\n", pOutBuf
);
2084 for (j
=0; j
< NUM_OF_TID
; j
++)
2086 if (pEntry
->BARecWcidArray
[j
] != 0)
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
);
2092 sprintf(pOutBuf
, "%s\n", pOutBuf
);
2094 sprintf(pOutBuf
, "%s[Originator]\n", pOutBuf
);
2095 for (j
=0; j
< NUM_OF_TID
; j
++)
2097 if (pEntry
->BAOriWcidArray
[j
] != 0)
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
]);
2103 sprintf(pOutBuf
, "%s\n\n", pOutBuf
);
2105 if (strlen(pOutBuf
) > (IW_PRIV_SIZE_MASK
- 30))
2111 #endif // DOT11_N_SUPPORT //
2114 rt_private_show(struct net_device
*dev
, struct iw_request_info
*info
,
2115 struct iw_point
*wrq
, PSTRING extra
)
2120 u32 subcmd
= wrq
->flags
;
2122 pAd
= RTMP_OS_NETDEV_GET_PRIV(dev
);
2125 /* if 1st open fail, pAd will be free;
2126 So the net_dev->priv will be NULL in 2rd open */
2130 pObj
= (POS_COOKIE
) pAd
->OS_Cookie
;
2136 memset(extra
, 0x00, IW_PRIV_SIZE_MASK
);
2139 pObj
->ioctl_if_type
= INT_MAIN
;
2140 pObj
->ioctl_if
= MAIN_MBSSID
;
2146 case SHOW_CONN_STATUS
:
2147 if (MONITOR_ON(pAd
))
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
);
2154 #endif // DOT11_N_SUPPORT //
2155 sprintf(extra
, "Monitor Mode(Channel %d)\n", pAd
->CommonCfg
.Channel
);
2159 if (pAd
->IndicateMediaState
== NdisMediaStateConnected
)
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
));
2173 else if (ADHOC_ON(pAd
))
2174 sprintf(extra
, "Connected\n");
2178 sprintf(extra
, "Disconnected\n");
2179 DBGPRINT(RT_DEBUG_TRACE
,("ConnStatus is not connected\n"));
2182 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
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'
2188 #ifdef DOT11_N_SUPPORT
2190 getBaInfo(pAd
, extra
);
2191 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2193 #endif // DOT11_N_SUPPORT //
2194 case SHOW_DESC_INFO
:
2196 Show_DescInfo_Proc(pAd
, NULL
);
2197 wrq
->length
= 0; // 1: size of '\0'
2201 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
2203 if (pAd
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
2205 RTMP_MLME_RESET_STATE_MACHINE(pAd
);
2206 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
2209 pAd
->StaCfg
.bSwRadio
= FALSE
;
2210 if (pAd
->StaCfg
.bRadio
!= (pAd
->StaCfg
.bHwRadio
&& pAd
->StaCfg
.bSwRadio
))
2212 pAd
->StaCfg
.bRadio
= (pAd
->StaCfg
.bHwRadio
&& pAd
->StaCfg
.bSwRadio
);
2213 if (pAd
->StaCfg
.bRadio
== FALSE
)
2216 // Update extra information
2217 pAd
->ExtraInfo
= SW_RADIO_OFF
;
2220 sprintf(extra
, "Radio Off\n");
2221 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2224 pAd
->StaCfg
.bSwRadio
= TRUE
;
2225 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2227 pAd
->StaCfg
.bRadio
= (pAd
->StaCfg
.bHwRadio
&& pAd
->StaCfg
.bSwRadio
);
2228 if (pAd
->StaCfg
.bRadio
== TRUE
)
2231 // Update extra information
2232 pAd
->ExtraInfo
= EXTRA_INFO_CLEAR
;
2235 sprintf(extra
, "Radio On\n");
2236 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2240 #ifdef QOS_DLS_SUPPORT
2241 case SHOW_DLS_ENTRY_INFO
:
2243 Set_DlsEntryInfo_Display_Proc(pAd
, NULL
);
2244 wrq
->length
= 0; // 1: size of '\0'
2247 #endif // QOS_DLS_SUPPORT //
2249 case SHOW_CFG_VALUE
:
2251 Status
= RTMPShowCfgValue(pAd
, (PSTRING
) wrq
->pointer
, extra
);
2253 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2256 case SHOW_ADHOC_ENTRY_INFO
:
2257 Show_Adhoc_MacTable_Proc(pAd
, extra
);
2258 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
2261 DBGPRINT(RT_DEBUG_TRACE
, ("%s - unknow subcmd = %d\n", __FUNCTION__
, subcmd
));
2269 int rt_ioctl_siwmlme(struct net_device
*dev
,
2270 struct iw_request_info
*info
,
2271 union iwreq_data
*wrqu
,
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
;
2280 DBGPRINT(RT_DEBUG_TRACE
, ("====> %s\n", __FUNCTION__
));
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
);
2297 LinkDown(pAd
, FALSE
);
2298 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
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
;
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
));
2313 pAd
->Mlme
.CntlMachine
.CurrState
= CNTL_WAIT_OID_DISASSOC
;
2314 MlmeDisassocReqAction(pAd
, &MsgElem
);
2316 #endif // IW_MLME_DISASSOC //
2318 DBGPRINT(RT_DEBUG_TRACE
, ("====> %s - Unknow Command\n", __FUNCTION__
));
2324 #endif // SIOCSIWMLME //
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
)
2331 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
2332 struct iw_param
*param
= &wrqu
->param
;
2334 //check if the interface is down
2335 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
2337 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
2340 switch (param
->flags
& IW_AUTH_INDEX
) {
2341 case IW_AUTH_WPA_VERSION
:
2342 if (param
->value
== IW_AUTH_WPA_VERSION_WPA
)
2344 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPAPSK
;
2345 if (pAdapter
->StaCfg
.BssType
== BSS_ADHOC
)
2346 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPANone
;
2348 else if (param
->value
== IW_AUTH_WPA_VERSION_WPA2
)
2349 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPA2PSK
;
2351 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__
, param
->value
));
2353 case IW_AUTH_CIPHER_PAIRWISE
:
2354 if (param
->value
== IW_AUTH_CIPHER_NONE
)
2356 pAdapter
->StaCfg
.WepStatus
= Ndis802_11WEPDisabled
;
2357 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
2358 pAdapter
->StaCfg
.PairCipher
= Ndis802_11WEPDisabled
;
2360 else if (param
->value
== IW_AUTH_CIPHER_WEP40
||
2361 param
->value
== IW_AUTH_CIPHER_WEP104
)
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 //
2370 else if (param
->value
== IW_AUTH_CIPHER_TKIP
)
2372 pAdapter
->StaCfg
.WepStatus
= Ndis802_11Encryption2Enabled
;
2373 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
2374 pAdapter
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
2376 else if (param
->value
== IW_AUTH_CIPHER_CCMP
)
2378 pAdapter
->StaCfg
.WepStatus
= Ndis802_11Encryption3Enabled
;
2379 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
2380 pAdapter
->StaCfg
.PairCipher
= Ndis802_11Encryption3Enabled
;
2382 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__
, param
->value
));
2384 case IW_AUTH_CIPHER_GROUP
:
2385 if (param
->value
== IW_AUTH_CIPHER_NONE
)
2387 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPDisabled
;
2389 else if (param
->value
== IW_AUTH_CIPHER_WEP40
||
2390 param
->value
== IW_AUTH_CIPHER_WEP104
)
2392 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPEnabled
;
2394 else if (param
->value
== IW_AUTH_CIPHER_TKIP
)
2396 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11Encryption2Enabled
;
2398 else if (param
->value
== IW_AUTH_CIPHER_CCMP
)
2400 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11Encryption3Enabled
;
2402 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__
, param
->value
));
2404 case IW_AUTH_KEY_MGMT
:
2405 if (param
->value
== IW_AUTH_KEY_MGMT_802_1X
)
2407 if (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPAPSK
)
2409 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPA
;
2410 #ifdef WPA_SUPPLICANT_SUPPORT
2411 pAdapter
->StaCfg
.IEEE8021X
= FALSE
;
2412 #endif // WPA_SUPPLICANT_SUPPORT //
2414 else if (pAdapter
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
)
2416 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeWPA2
;
2417 #ifdef WPA_SUPPLICANT_SUPPORT
2418 pAdapter
->StaCfg
.IEEE8021X
= FALSE
;
2419 #endif // WPA_SUPPLICANT_SUPPORT //
2421 #ifdef WPA_SUPPLICANT_SUPPORT
2424 pAdapter
->StaCfg
.IEEE8021X
= TRUE
;
2425 #endif // WPA_SUPPLICANT_SUPPORT //
2427 else if (param
->value
== 0)
2429 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2430 STA_PORT_SECURED(pAdapter
);
2432 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__
, param
->value
));
2434 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
2436 case IW_AUTH_PRIVACY_INVOKED
:
2437 /*if (param->value == 0)
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;
2445 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__
, param
->value
));
2447 case IW_AUTH_DROP_UNENCRYPTED
:
2448 if (param
->value
!= 0)
2449 pAdapter
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
2452 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2453 STA_PORT_SECURED(pAdapter
);
2455 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__
, param
->value
));
2457 case IW_AUTH_80211_AUTH_ALG
:
2458 if (param
->value
& IW_AUTH_ALG_SHARED_KEY
)
2460 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeShared
;
2462 else if (param
->value
& IW_AUTH_ALG_OPEN_SYSTEM
)
2464 pAdapter
->StaCfg
.AuthMode
= Ndis802_11AuthModeOpen
;
2468 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__
, param
->value
));
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
));
2480 int rt_ioctl_giwauth(struct net_device
*dev
,
2481 struct iw_request_info
*info
,
2482 union iwreq_data
*wrqu
, char *extra
)
2484 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
2485 struct iw_param
*param
= &wrqu
->param
;
2487 //check if the interface is down
2488 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
2490 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
2494 switch (param
->flags
& IW_AUTH_INDEX
) {
2495 case IW_AUTH_DROP_UNENCRYPTED
:
2496 param
->value
= (pAdapter
->StaCfg
.WepStatus
== Ndis802_11WEPDisabled
) ? 0 : 1;
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
;
2503 case IW_AUTH_WPA_ENABLED
:
2504 param
->value
= (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
) ? 1 : 0;
2510 DBGPRINT(RT_DEBUG_TRACE
, ("rt_ioctl_giwauth::param->value = %d!\n", param
->value
));
2514 void fnSetCipherKey(
2515 IN PRTMP_ADAPTER pAdapter
,
2519 IN
struct iw_encode_ext
*ext
)
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
;
2528 // Update group key information to ASIC Shared Key Table
2529 AsicAddSharedKeyEntry(pAdapter
,
2532 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
,
2533 pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
,
2534 pAdapter
->SharedKey
[BSS0
][keyIdx
].TxMic
,
2535 pAdapter
->SharedKey
[BSS0
][keyIdx
].RxMic
);
2538 // Update ASIC WCID attribute table and IVEIV table
2539 RTMPAddWcidAttributeEntry(pAdapter
,
2542 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
,
2545 // Update ASIC WCID attribute table and IVEIV table
2546 RTMPAddWcidAttributeEntry(pAdapter
,
2549 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
,
2550 &pAdapter
->MacTab
.Content
[BSSID_WCID
]);
2553 int rt_ioctl_siwencodeext(struct net_device
*dev
,
2554 struct iw_request_info
*info
,
2555 union iwreq_data
*wrqu
,
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
;
2563 //check if the interface is down
2564 if(!RTMP_TEST_FLAG(pAdapter
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
2566 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
2570 if (encoding
->flags
& IW_ENCODE_DISABLED
)
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
));
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
))
2588 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
2590 pAdapter
->StaCfg
.DefaultKeyId
= keyIdx
;
2591 DBGPRINT(RT_DEBUG_TRACE
, ("%s::DefaultKeyId = %d\n", __FUNCTION__
, pAdapter
->StaCfg
.DefaultKeyId
));
2595 case IW_ENCODE_ALG_NONE
:
2596 DBGPRINT(RT_DEBUG_TRACE
, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__
));
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
)
2602 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= MAX_WEP_KEY_SIZE
;
2603 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CIPHER_WEP128
;
2605 else if (ext
->key_len
== MIN_WEP_KEY_SIZE
)
2607 pAdapter
->SharedKey
[BSS0
][keyIdx
].KeyLen
= MIN_WEP_KEY_SIZE
;
2608 pAdapter
->SharedKey
[BSS0
][keyIdx
].CipherAlg
= CIPHER_WEP64
;
2613 NdisZeroMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
, 16);
2614 NdisMoveMemory(pAdapter
->SharedKey
[BSS0
][keyIdx
].Key
, ext
->key
, ext
->key_len
);
2616 if (pAdapter
->StaCfg
.GroupCipher
== Ndis802_11GroupWEP40Enabled
||
2617 pAdapter
->StaCfg
.GroupCipher
== Ndis802_11GroupWEP104Enabled
)
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
;
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)
2632 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
2634 fnSetCipherKey(pAdapter
, keyIdx
, CIPHER_TKIP
, FALSE
, ext
);
2635 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA2
)
2637 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2638 STA_PORT_SECURED(pAdapter
);
2639 pAdapter
->IndicateMediaState
= NdisMediaStateConnected
;
2642 else if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
)
2644 fnSetCipherKey(pAdapter
, keyIdx
, CIPHER_TKIP
, TRUE
, ext
);
2646 // set 802.1x port control
2647 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2648 STA_PORT_SECURED(pAdapter
);
2649 pAdapter
->IndicateMediaState
= NdisMediaStateConnected
;
2655 case IW_ENCODE_ALG_CCMP
:
2656 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
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
;
2664 else if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
)
2666 fnSetCipherKey(pAdapter
, keyIdx
, CIPHER_AES
, TRUE
, ext
);
2668 // set 802.1x port control
2669 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2670 STA_PORT_SECURED(pAdapter
);
2671 pAdapter
->IndicateMediaState
= NdisMediaStateConnected
;
2683 rt_ioctl_giwencodeext(struct net_device
*dev
,
2684 struct iw_request_info
*info
,
2685 union iwreq_data
*wrqu
, char *extra
)
2687 PRTMP_ADAPTER pAd
= RTMP_OS_NETDEV_GET_PRIV(dev
);
2689 struct iw_point
*encoding
= &wrqu
->encoding
;
2690 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
2691 int idx
, max_key_len
;
2693 DBGPRINT(RT_DEBUG_TRACE
,("===> rt_ioctl_giwencodeext\n"));
2695 max_key_len
= encoding
->length
- sizeof(*ext
);
2696 if (max_key_len
< 0)
2699 idx
= encoding
->flags
& IW_ENCODE_INDEX
;
2702 if (idx
< 1 || idx
> 4)
2706 if ((pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption2Enabled
) ||
2707 (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption3Enabled
))
2709 if (idx
!= pAd
->StaCfg
.DefaultKeyId
)
2717 idx
= pAd
->StaCfg
.DefaultKeyId
;
2719 encoding
->flags
= idx
+ 1;
2720 memset(ext
, 0, sizeof(*ext
));
2723 switch(pAd
->StaCfg
.WepStatus
) {
2724 case Ndis802_11WEPDisabled
:
2725 ext
->alg
= IW_ENCODE_ALG_NONE
;
2726 encoding
->flags
|= IW_ENCODE_DISABLED
;
2728 case Ndis802_11WEPEnabled
:
2729 ext
->alg
= IW_ENCODE_ALG_WEP
;
2730 if (pAd
->SharedKey
[BSS0
][idx
].KeyLen
> max_key_len
)
2734 ext
->key_len
= pAd
->SharedKey
[BSS0
][idx
].KeyLen
;
2735 pKey
= (PCHAR
)&(pAd
->SharedKey
[BSS0
][idx
].Key
[0]);
2738 case Ndis802_11Encryption2Enabled
:
2739 case Ndis802_11Encryption3Enabled
:
2740 if (pAd
->StaCfg
.WepStatus
== Ndis802_11Encryption2Enabled
)
2741 ext
->alg
= IW_ENCODE_ALG_TKIP
;
2743 ext
->alg
= IW_ENCODE_ALG_CCMP
;
2745 if (max_key_len
< 32)
2750 pKey
= (PCHAR
)&pAd
->StaCfg
.PMK
[0];
2757 if (ext
->key_len
&& pKey
)
2759 encoding
->flags
|= IW_ENCODE_ENABLED
;
2760 memcpy(ext
->key
, pKey
, ext
->key_len
);
2767 int rt_ioctl_siwgenie(struct net_device
*dev
,
2768 struct iw_request_info
*info
,
2769 union iwreq_data
*wrqu
, char *extra
)
2771 PRTMP_ADAPTER pAd
= RTMP_OS_NETDEV_GET_PRIV(dev
);
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
))
2781 if (wrqu
->data
.length
)
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 //
2791 pAd
->StaCfg
.RSNIE_Len
= 0;
2792 NdisZeroMemory(&pAd
->StaCfg
.RSN_IE
[0], MAX_LEN_OF_RSNIE
);
2797 #endif // SIOCSIWGENIE //
2799 int rt_ioctl_giwgenie(struct net_device
*dev
,
2800 struct iw_request_info
*info
,
2801 union iwreq_data
*wrqu
, char *extra
)
2803 PRTMP_ADAPTER pAd
= RTMP_OS_NETDEV_GET_PRIV(dev
);
2805 if ((pAd
->StaCfg
.RSNIE_Len
== 0) ||
2806 (pAd
->StaCfg
.AuthMode
< Ndis802_11AuthModeWPA
))
2808 wrqu
->data
.length
= 0;
2812 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2814 if (pAd
->StaCfg
.WpaSupplicantUP
== WPA_SUPPLICANT_ENABLE
)
2816 if (wrqu
->data
.length
< pAd
->StaCfg
.RSNIE_Len
)
2819 wrqu
->data
.length
= pAd
->StaCfg
.RSNIE_Len
;
2820 memcpy(extra
, &pAd
->StaCfg
.RSN_IE
[0], pAd
->StaCfg
.RSNIE_Len
);
2823 #endif // SIOCSIWGENIE //
2824 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2826 UCHAR RSNIe
= IE_WPA
;
2828 if (wrqu
->data
.length
< (pAd
->StaCfg
.RSNIE_Len
+ 2)) // ID, Len
2830 wrqu
->data
.length
= pAd
->StaCfg
.RSNIE_Len
+ 2;
2832 if ((pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2PSK
) ||
2833 (pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPA2
))
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
);
2844 int rt_ioctl_siwpmksa(struct net_device
*dev
,
2845 struct iw_request_info
*info
,
2846 union iwreq_data
*wrqu
,
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;
2856 DBGPRINT(RT_DEBUG_TRACE
,("===> rt_ioctl_siwpmksa\n"));
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"));
2863 case IW_PMKSA_REMOVE
:
2864 for (CachedIdx
= 0; CachedIdx
< pAd
->StaCfg
.SavedPMKNum
; CachedIdx
++)
2866 // compare the BSSID
2867 if (NdisEqualMemory(pPmksa
->bssid
.sa_data
, pAd
->StaCfg
.SavedPMK
[CachedIdx
].BSSID
, MAC_ADDR_LEN
))
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
++)
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);
2876 pAd
->StaCfg
.SavedPMKNum
--;
2881 DBGPRINT(RT_DEBUG_TRACE
,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2884 for (CachedIdx
= 0; CachedIdx
< pAd
->StaCfg
.SavedPMKNum
; CachedIdx
++)
2886 // compare the BSSID
2887 if (NdisEqualMemory(pPmksa
->bssid
.sa_data
, pAd
->StaCfg
.SavedPMK
[CachedIdx
].BSSID
, MAC_ADDR_LEN
))
2891 // Found, replace it
2892 if (CachedIdx
< PMKID_NO
)
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
++;
2899 // Not found, replace the last one
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);
2909 DBGPRINT(RT_DEBUG_TRACE
,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2912 DBGPRINT(RT_DEBUG_TRACE
,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2918 #endif // #if WIRELESS_EXT > 17
2922 rt_private_ioctl_bbp(struct net_device
*dev
, struct iw_request_info
*info
,
2923 struct iw_point
*wrq
, char *extra
)
2926 PSTRING value
= NULL
;
2928 // CHAR arg[255]={0};
2931 BOOLEAN bIsPrintAllBBP
= FALSE
;
2933 PRTMP_ADAPTER pAdapter
= RTMP_OS_NETDEV_GET_PRIV(dev
);
2936 memset(extra
, 0x00, IW_PRIV_SIZE_MASK
);
2938 if (wrq
->length
> 1) //No parameters.
2940 sprintf(extra
, "\n");
2942 //Parsing Read or Write
2943 this_char
= wrq
->pointer
;
2944 DBGPRINT(RT_DEBUG_TRACE
, ("this_char=%s\n", this_char
));
2948 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
2951 if (!value
|| !*value
)
2953 DBGPRINT(RT_DEBUG_TRACE
, ("this_char=%s, value=%s\n", this_char
, value
));
2954 if (sscanf(this_char
, "%d", &(bbpId
)) == 1)
2956 if (bbpId
<= MAX_BBP_ID
)
2959 if (ATE_ON(pAdapter
))
2961 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
2964 #endif // RALINK_ATE //
2966 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
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
));
2973 {//Invalid parametes, so default printk all bbp
2974 bIsPrintAllBBP
= TRUE
;
2979 { //Invalid parametes, so default printk all bbp
2980 bIsPrintAllBBP
= TRUE
;
2986 if ((sscanf(this_char
, "%d", &(bbpId
)) == 1) && (sscanf(value
, "%x", &(bbpValue
)) == 1))
2988 if (bbpId
<= MAX_BBP_ID
)
2991 if (ATE_ON(pAdapter
))
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
);
2998 #endif // RALINK_ATE //
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
);
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
));
3009 {//Invalid parametes, so default printk all bbp
3010 bIsPrintAllBBP
= TRUE
;
3015 { //Invalid parametes, so default printk all bbp
3016 bIsPrintAllBBP
= TRUE
;
3022 bIsPrintAllBBP
= TRUE
;
3027 memset(extra
, 0x00, IW_PRIV_SIZE_MASK
);
3028 sprintf(extra
, "\n");
3029 for (bbpId
= 0; bbpId
<= MAX_BBP_ID
; bbpId
++)
3031 if (strlen(extra
) >= (IW_PRIV_SIZE_MASK
- 20))
3034 if (ATE_ON(pAdapter
))
3036 ATE_BBP_IO_READ8_BY_REG_ID(pAdapter
, bbpId
, ®BBP
);
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
);
3043 sprintf(extra
+strlen(extra
), "%03d = %02X\n", bbpId
, regBBP
); // edit by johnli, change display format
3046 wrq
->length
= strlen(extra
) + 1; // 1: size of '\0'
3047 DBGPRINT(RT_DEBUG_TRACE
, ("wrq->length = %d\n", wrq
->length
));
3050 DBGPRINT(RT_DEBUG_TRACE
, ("<==rt_private_ioctl_bbp\n\n"));
3056 int rt_ioctl_siwrate(struct net_device
*dev
,
3057 struct iw_request_info
*info
,
3058 union iwreq_data
*wrqu
, char *extra
)
3060 PRTMP_ADAPTER pAd
= RTMP_OS_NETDEV_GET_PRIV(dev
);
3061 UINT32 rate
= wrqu
->bitrate
.value
, fixed
= wrqu
->bitrate
.fixed
;
3063 //check if the interface is down
3064 if(!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
3066 DBGPRINT(RT_DEBUG_TRACE
, ("rt_ioctl_siwrate::Network is down!\n"));
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)
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);
3083 #ifdef DOT11_N_SUPPORT
3085 #endif // DOT11_N_SUPPORT //
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
);
3097 pAd
->StaCfg
.DesiredTransmitSetting
.field
.MCS
= MCS_AUTO
;
3098 #ifdef DOT11_N_SUPPORT
3100 #endif // DOT11_N_SUPPORT //
3102 DBGPRINT(RT_DEBUG_TRACE
, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd
->StaCfg
.DesiredTransmitSetting
.field
.MCS
));
3106 // TODO: rate = X, fixed = 0 => (rates <= X)
3114 int rt_ioctl_giwrate(struct net_device
*dev
,
3115 struct iw_request_info
*info
,
3116 union iwreq_data
*wrqu
, char *extra
)
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
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
))
3139 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
3143 if ((pAd
->StaCfg
.bAutoTxRateSwitch
== FALSE
) &&
3145 ((pAd
->CommonCfg
.PhyMode
<= PHY_11G
) || (pAd
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.field
.MODE
<= MODE_OFDM
)))
3146 ht_setting
.word
= pAd
->StaCfg
.HTPhyMode
.word
;
3148 ht_setting
.word
= pAd
->MacTab
.Content
[BSSID_WCID
].HTPhyMode
.word
;
3150 #ifdef DOT11_N_SUPPORT
3151 if (ht_setting
.field
.MODE
>= MODE_HTMIX
)
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
);
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
);
3166 if (rate_index
> rate_count
)
3167 rate_index
= rate_count
;
3169 wrqu
->bitrate
.value
= ralinkrate
[rate_index
] * 500000;
3170 wrqu
->bitrate
.disabled
= 0;
3175 static const iw_handler rt_handler
[] =
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 */
3200 (iw_handler
) rt_ioctl_siwmlme
, /* SIOCSIWMLME */
3202 (iw_handler
) NULL
, /* SIOCSIWMLME */
3203 #endif // SIOCSIWMLME //
3204 (iw_handler
) rt_ioctl_iwaplist
, /* SIOCGIWAPLIST */
3206 (iw_handler
) rt_ioctl_siwscan
, /* SIOCSIWSCAN */
3207 (iw_handler
) rt_ioctl_giwscan
, /* SIOCGIWSCAN */
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 */
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 */
3250 (iw_handler
) rt_private_ioctl_bbp
, /* + 0x03 */
3252 (iw_handler
) NULL
, /* + 0x03 */
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 */
3277 const struct iw_handler_def rt28xx_iw_handler_def
=
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
,
3291 INT
RTMPSetInformation(
3292 IN PRTMP_ADAPTER pAd
,
3293 IN OUT
struct ifreq
*rq
,
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
;
3316 INT Status
= NDIS_STATUS_SUCCESS
, MaxPhyMode
= PHY_11G
;
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 //
3332 TX_RTY_CFG_STRUC tx_rty_cfg
;
3333 ULONG ShortRetryLimit
, LongRetryLimit
;
3335 #endif // SNMP_SUPPORT //
3340 #ifdef DOT11_N_SUPPORT
3341 MaxPhyMode
= PHY_11N_5G
;
3342 #endif // DOT11_N_SUPPORT //
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
))
3349 // Only avaliable when EEPROM not programming
3350 else if (!(pAd
->CommonCfg
.CountryRegion
& 0x80) && !(pAd
->CommonCfg
.CountryRegionForABand
& 0x80))
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
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
));
3369 case OID_802_11_BSSID_LIST_SCAN
:
3371 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAd
->RalinkCounters
.LastOneSecTotalTxCount
));
3373 if (MONITOR_ON(pAd
))
3375 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Driver is in Monitor Mode now !!!\n"));
3379 //Benson add 20080527, when radio off, sta don't need to scan
3380 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_RADIO_OFF
))
3383 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
3385 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Driver is scanning now !!!\n"));
3386 pAd
->StaCfg
.bScanReqIsFromWebUI
= TRUE
;
3387 Status
= NDIS_STATUS_SUCCESS
;
3391 if (pAd
->RalinkCounters
.LastOneSecTotalTxCount
> 100)
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
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
))
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
3413 if (pAd
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
3415 RTMP_MLME_RESET_STATE_MACHINE(pAd
);
3416 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
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
;
3426 pAd
->StaCfg
.bScanReqIsFromWebUI
= TRUE
;
3427 RTMP_SET_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
);
3429 MLME_CNTL_STATE_MACHINE
,
3430 OID_802_11_BSSID_LIST_SCAN
,
3434 Status
= NDIS_STATUS_SUCCESS
;
3435 StateMachineTouched
= TRUE
;
3437 case OID_802_11_SSID
:
3438 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_SSID
))
3442 PSTRING pSsidString
= NULL
;
3443 Status
= copy_from_user(&Ssid
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
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
)
3450 if (Ssid
.SsidLength
== 0)
3452 Set_SSID_Proc(pAd
, "");
3456 pSsidString
= (PSTRING
)kmalloc(MAX_LEN_OF_SSID
+1, MEM_ALLOC_FLAG
);
3459 NdisZeroMemory(pSsidString
, MAX_LEN_OF_SSID
+1);
3460 NdisMoveMemory(pSsidString
, Ssid
.Ssid
, Ssid
.SsidLength
);
3461 Set_SSID_Proc(pAd
, pSsidString
);
3470 case OID_802_11_SET_PASSPHRASE
:
3471 ppassphrase
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
3473 if(ppassphrase
== NULL
)
3476 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_SET_PASSPHRASE, Failed!!\n"));
3481 Status
= copy_from_user(ppassphrase
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3486 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_SET_PASSPHRASE, Failed (length mismatch)!!\n"));
3490 if(ppassphrase
->KeyLength
< 8 || ppassphrase
->KeyLength
> 64)
3493 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_SET_PASSPHRASE, Failed (len less than 8 or greater than 64)!!\n"));
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
);
3509 case OID_802_11_BSSID
:
3510 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_MAC_ADDRESS
))
3514 Status
= copy_from_user(&Bssid
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
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
;
3520 // Prevent to connect AP again in STAMlmePeriodicExec
3521 pAd
->MlmeAux
.AutoReconnectSsidLen
= 32;
3523 // Reset allowed scan retries
3524 pAd
->StaCfg
.ScanCnt
= 0;
3526 if (pAd
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
3528 RTMP_MLME_RESET_STATE_MACHINE(pAd
);
3529 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
3532 MLME_CNTL_STATE_MACHINE
,
3534 sizeof(NDIS_802_11_MAC_ADDRESS
),
3536 Status
= NDIS_STATUS_SUCCESS
;
3537 StateMachineTouched
= TRUE
;
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]));
3543 case RT_OID_802_11_RADIO
:
3544 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
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
)
3552 pAd
->StaCfg
.bSwRadio
= RadioState
;
3553 if (pAd
->StaCfg
.bRadio
!= (pAd
->StaCfg
.bHwRadio
&& pAd
->StaCfg
.bSwRadio
))
3555 pAd
->StaCfg
.bRadio
= (pAd
->StaCfg
.bHwRadio
&& pAd
->StaCfg
.bSwRadio
);
3556 if (pAd
->StaCfg
.bRadio
== TRUE
)
3559 // Update extra information
3560 pAd
->ExtraInfo
= EXTRA_INFO_CLEAR
;
3564 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
3566 if (pAd
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
3568 RTMP_MLME_RESET_STATE_MACHINE(pAd
);
3569 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
3574 // Update extra information
3575 pAd
->ExtraInfo
= SW_RADIO_OFF
;
3581 case RT_OID_802_11_PHY_MODE
:
3582 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_PHY_MODE
))
3586 Status
= copy_from_user(&PhyMode
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3587 if (PhyMode
<= MaxPhyMode
)
3589 RTMPSetPhyMode(pAd
, PhyMode
);
3590 #ifdef DOT11_N_SUPPORT
3592 #endif // DOT11_N_SUPPORT //
3594 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode
));
3597 case RT_OID_802_11_STA_CONFIG
:
3598 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_STA_CONFIG
))
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
))
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
)
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
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
));
3627 if (pAd
->CommonCfg
.PSPXlink
)
3631 RTMP_IO_WRITE32(pAd
, RX_FILTR_CFG
, Value
);
3633 RTMP_IO_READ32(pAd
, MAC_SYS_CTRL
, &Value
);
3635 RTMP_IO_WRITE32(pAd
, MAC_SYS_CTRL
, Value
);
3638 case OID_802_11_DESIRED_RATES
:
3639 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_RATES
))
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);
3655 case RT_OID_802_11_PREAMBLE
:
3656 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_PREAMBLE
))
3660 Status
= copy_from_user(&Preamble
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3661 if (Preamble
== Rt802_11PreambleShort
)
3663 pAd
->CommonCfg
.TxPreamble
= Preamble
;
3664 MlmeSetTxPreamble(pAd
, Rt802_11PreambleShort
);
3666 else if ((Preamble
== Rt802_11PreambleLong
) || (Preamble
== Rt802_11PreambleAuto
))
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
);
3678 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble
));
3681 case OID_802_11_WEP_STATUS
:
3682 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_WEP_STATUS
))
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
)
3690 if (pAd
->StaCfg
.WepStatus
!= WepStatus
)
3692 // Config has changed
3693 pAd
->bConfigChanged
= TRUE
;
3695 pAd
->StaCfg
.WepStatus
= WepStatus
;
3696 pAd
->StaCfg
.OrigWepStatus
= WepStatus
;
3697 pAd
->StaCfg
.PairCipher
= WepStatus
;
3698 pAd
->StaCfg
.GroupCipher
= WepStatus
;
3705 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus
));
3708 case OID_802_11_AUTHENTICATION_MODE
:
3709 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_AUTHENTICATION_MODE
))
3713 Status
= copy_from_user(&AuthMode
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3714 if (AuthMode
> Ndis802_11AuthModeMax
)
3721 if (pAd
->StaCfg
.AuthMode
!= AuthMode
)
3723 // Config has changed
3724 pAd
->bConfigChanged
= TRUE
;
3726 pAd
->StaCfg
.AuthMode
= AuthMode
;
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
));
3732 case OID_802_11_INFRASTRUCTURE_MODE
:
3733 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE
))
3737 Status
= copy_from_user(&BssType
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
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");
3748 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
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
))
3760 KeyIdx
= *(NDIS_802_11_KEY_INDEX
*) wrq
->u
.data
.pointer
;
3762 if (KeyIdx
& 0x80000000)
3764 // Should never set default bit when remove key
3769 KeyIdx
= KeyIdx
& 0x0fffffff;
3775 pAd
->SharedKey
[BSS0
][KeyIdx
].KeyLen
= 0;
3776 pAd
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
= CIPHER_NONE
;
3777 AsicRemoveSharedKeyEntry(pAd
, 0, (UCHAR
)KeyIdx
);
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"));
3791 case OID_802_11_RTS_THRESHOLD
:
3792 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_RTS_THRESHOLD
))
3796 Status
= copy_from_user(&RtsThresh
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3797 if (RtsThresh
> MAX_RTS_THRESHOLD
)
3800 pAd
->CommonCfg
.RtsThreshold
= (USHORT
)RtsThresh
;
3802 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh
));
3804 case OID_802_11_FRAGMENTATION_THRESHOLD
:
3805 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD
))
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
)
3813 if (FragThresh
== 0)
3815 pAd
->CommonCfg
.FragmentThreshold
= MAX_FRAG_THRESHOLD
;
3816 pAd
->CommonCfg
.bUseZeroToDisableFragment
= TRUE
;
3822 pAd
->CommonCfg
.FragmentThreshold
= (USHORT
)FragThresh
;
3824 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh
));
3826 case OID_802_11_POWER_MODE
:
3827 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_POWER_MODE
))
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");
3843 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode
));
3845 case RT_OID_802_11_TX_POWER_LEVEL_1
:
3846 if (wrq
->u
.data
.length
< sizeof(ULONG
))
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
));
3858 case OID_802_11_NETWORK_TYPE_IN_USE
:
3859 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_NETWORK_TYPE
))
3863 Status
= copy_from_user(&NetType
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
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
);
3873 #ifdef DOT11_N_SUPPORT
3874 if (Status
== NDIS_STATUS_SUCCESS
)
3876 #endif // DOT11_N_SUPPORT //
3877 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType
));
3880 // For WPA PSK PMK key
3881 case RT_OID_802_11_ADD_WPA
:
3882 pKey
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
3889 Status
= copy_from_user(pKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3890 if (pKey
->Length
!= wrq
->u
.data
.length
)
3893 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3897 if ((pAd
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPAPSK
) &&
3898 (pAd
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPA2PSK
) &&
3899 (pAd
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPANone
) )
3901 Status
= -EOPNOTSUPP
;
3902 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
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
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
;
3914 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey
->KeyIndex
, pKey
->KeyLength
));
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
));
3924 case OID_802_11_REMOVE_KEY
:
3925 pRemoveKey
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
3926 if(pRemoveKey
== NULL
)
3932 Status
= copy_from_user(pRemoveKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3933 if (pRemoveKey
->Length
!= wrq
->u
.data
.length
)
3936 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3940 if (pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
3942 RTMPWPARemoveKeyProc(pAd
, pRemoveKey
);
3943 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3947 KeyIdx
= pRemoveKey
->KeyIndex
;
3949 if (KeyIdx
& 0x80000000)
3951 // Should never set default bit when remove key
3953 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3957 KeyIdx
= KeyIdx
& 0x0fffffff;
3961 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx
));
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
));
3976 case OID_802_11_ADD_KEY
:
3977 pKey
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
3983 Status
= copy_from_user(pKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
3984 if (pKey
->Length
!= wrq
->u
.data
.length
)
3987 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
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
));
3996 case OID_802_11_CONFIGURATION
:
3997 if (wrq
->u
.data
.length
!= sizeof(NDIS_802_11_CONFIGURATION
))
4001 Status
= copy_from_user(&Config
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4004 if ((pConfig
->BeaconPeriod
>= 20) && (pConfig
->BeaconPeriod
<=400))
4005 pAd
->CommonCfg
.BeaconPeriod
= (USHORT
) pConfig
->BeaconPeriod
;
4007 pAd
->StaActive
.AtimWin
= (USHORT
) pConfig
->ATIMWindow
;
4008 MAP_KHZ_TO_CHANNEL_ID(pConfig
->DSConfig
, pAd
->CommonCfg
.Channel
);
4010 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
4012 pAd
->MlmeAux
.Channel
= pAd
->CommonCfg
.Channel
;
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
;
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
))
4026 POID_SET_HT_PHYMODE pHTPhyMode
= &HT_PhyMode
;
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
);
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
));
4039 #endif // DOT11_N_SUPPORT //
4040 case RT_OID_802_11_SET_APSD_SETTING
:
4041 if (wrq
->u
.data
.length
!= sizeof(ULONG
))
4046 Status
= copy_from_user(&apsd
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
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);
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
));
4065 case RT_OID_802_11_SET_APSD_PSM
:
4066 if (wrq
->u
.data
.length
!= sizeof(ULONG
))
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
)
4074 RTMP_SET_PSM_BIT(pAd
, pAd
->CommonCfg
.bAPSDForcePowerSave
);
4075 RTMPSendNullFrame(pAd
, pAd
->CommonCfg
.TxRate
, TRUE
);
4077 DBGPRINT(RT_DEBUG_TRACE
, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAd
->CommonCfg
.bAPSDForcePowerSave
));
4080 #ifdef QOS_DLS_SUPPORT
4081 case RT_OID_802_11_SET_DLS
:
4082 if (wrq
->u
.data
.length
!= sizeof(ULONG
))
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
)
4091 // tear down local dls table entry
4092 for (i
=0; i
<MAX_NUM_OF_INIT_DLS_ENTRY
; i
++)
4094 if (pAd
->StaCfg
.DLSEntry
[i
].Valid
&& (pAd
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
))
4096 pAd
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
4097 pAd
->StaCfg
.DLSEntry
[i
].Valid
= FALSE
;
4098 RTMPSendDLSTearDownFrame(pAd
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
);
4102 // tear down peer dls table entry
4103 for (i
=MAX_NUM_OF_INIT_DLS_ENTRY
; i
<MAX_NUM_OF_DLS_ENTRY
; i
++)
4105 if (pAd
->StaCfg
.DLSEntry
[i
].Valid
&& (pAd
->StaCfg
.DLSEntry
[i
].Status
== DLS_FINISH
))
4107 pAd
->StaCfg
.DLSEntry
[i
].Status
= DLS_NONE
;
4108 pAd
->StaCfg
.DLSEntry
[i
].Valid
= FALSE
;
4109 RTMPSendDLSTearDownFrame(pAd
, pAd
->StaCfg
.DLSEntry
[i
].MacAddr
);
4114 DBGPRINT(RT_DEBUG_TRACE
,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAd
->CommonCfg
.bDLSCapable
));
4118 case RT_OID_802_11_SET_DLS_PARAM
:
4119 if (wrq
->u
.data
.length
!= sizeof(RT_802_11_DLS_UI
))
4125 NdisZeroMemory(&Dls
, sizeof(RT_802_11_DLS
));
4126 RTMPMoveMemory(&Dls
, wrq
->u
.data
.pointer
, sizeof(RT_802_11_DLS_UI
));
4128 MLME_CNTL_STATE_MACHINE
,
4129 RT_OID_802_11_SET_DLS_PARAM
,
4130 sizeof(RT_802_11_DLS
),
4132 DBGPRINT(RT_DEBUG_TRACE
,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
4135 #endif // QOS_DLS_SUPPORT //
4136 case RT_OID_802_11_SET_WMM
:
4137 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
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
));
4146 case OID_802_11_DISASSOCIATE
:
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.
4152 // TRUE: NumberOfItems will set to 0.
4153 // FALSE: NumberOfItems no change.
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"));
4163 if (pAd
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
4165 RTMP_MLME_RESET_STATE_MACHINE(pAd
);
4166 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
4170 MLME_CNTL_STATE_MACHINE
,
4171 OID_802_11_DISASSOCIATE
,
4175 StateMachineTouched
= TRUE
;
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
))
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
)
4189 Status
= NDIS_STATUS_INVALID_DATA
;
4191 else if (Orde
.Policy
== BA_NOTUSE
)
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
;
4201 pAd
->CommonCfg
.HtCapability
.HtCapInfo
.MimoPs
= Orde
.MMPSmode
;
4202 pAd
->CommonCfg
.HtCapability
.HtCapInfo
.AMsduSize
= Orde
.AmsduSize
;
4203 pAd
->CommonCfg
.HtCapability
.HtCapParm
.MpduDensity
= Orde
.MpduDensity
;
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
;
4217 pAd
->CommonCfg
.HtCapability
.HtCapInfo
.MimoPs
= Orde
.MMPSmode
;
4218 pAd
->CommonCfg
.HtCapability
.HtCapInfo
.AMsduSize
= Orde
.AmsduSize
;
4219 pAd
->CommonCfg
.HtCapability
.HtCapParm
.MpduDensity
= Orde
.MpduDensity
;
4221 if (pAd
->CommonCfg
.BACapability
.field
.RxBAWinLimit
> MAX_RX_REORDERBUF
)
4222 pAd
->CommonCfg
.BACapability
.field
.RxBAWinLimit
= MAX_RX_REORDERBUF
;
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
));
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
))
4241 OID_ADD_BA_ENTRY BA
;
4242 MAC_TABLE_ENTRY
*pEntry
;
4244 Status
= copy_from_user(&BA
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4247 Status
= NDIS_STATUS_INVALID_DATA
;
4252 //BATableInsertEntry
4253 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4255 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4256 pEntry
= MacTableLookup(pAd
, BA
.MACAddr
);
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]));
4262 if (BA
.IsRecipient
== FALSE
)
4264 if (pEntry
->bIAmBadAtheros
== TRUE
)
4265 pAd
->CommonCfg
.BACapability
.field
.RxBAWinLimit
= 0x10;
4267 BAOriSessionSetUp(pAd
, pEntry
, index
, 0, 100, TRUE
);
4271 //BATableInsertEntry(pAd, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
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]));
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
))
4287 POID_ADD_BA_ENTRY pBA
;
4288 MAC_TABLE_ENTRY
*pEntry
;
4290 pBA
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
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
;
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
));
4302 if (!pBA
->bAllTid
&& (pBA
->TID
> NUM_OF_TID
))
4304 Status
= NDIS_STATUS_INVALID_DATA
;
4308 if (pBA
->IsRecipient
== FALSE
)
4310 pEntry
= MacTableLookup(pAd
, pBA
->MACAddr
);
4311 DBGPRINT(RT_DEBUG_TRACE
, (" pBA->IsRecipient == FALSE\n"));
4314 DBGPRINT(RT_DEBUG_TRACE
, (" pBA->pEntry\n"));
4315 BAOriSessionTearDown(pAd
, pEntry
->Aid
, pBA
->TID
, FALSE
, TRUE
);
4318 DBGPRINT(RT_DEBUG_TRACE
, ("Set :: Not found pEntry \n"));
4322 pEntry
= MacTableLookup(pAd
, pBA
->MACAddr
);
4325 BARecSessionTearDown( pAd
, (UCHAR
)pEntry
->Aid
, pBA
->TID
, TRUE
);
4328 DBGPRINT(RT_DEBUG_TRACE
, ("Set :: Not found pEntry \n"));
4334 #endif // DOT11_N_SUPPORT //
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
);
4343 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4346 Status
= copy_from_user(pWepKey
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4350 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4354 KeyIdx
= pWepKey
->KeyIndex
& 0x0fffffff;
4355 // KeyIdx must be 0 ~ 3
4359 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4363 UCHAR CipherAlg
= 0;
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
);
4371 switch(pWepKey
->KeyLength
)
4374 CipherAlg
= CIPHER_WEP64
;
4377 CipherAlg
= CIPHER_WEP128
;
4380 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4384 pAd
->SharedKey
[BSS0
][KeyIdx
].CipherAlg
= CipherAlg
;
4386 // Default key for tx (shared key)
4387 if (pWepKey
->KeyIndex
& 0x80000000)
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
;
4400 #ifdef WPA_SUPPLICANT_SUPPORT
4401 if ((pAd
->StaCfg
.WpaSupplicantUP
!= WPA_SUPPLICANT_DISABLE
) &&
4402 (pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
))
4404 Key
= pWepKey
->KeyMaterial
;
4406 // Set Group key material to Asic
4407 AsicAddSharedKeyEntry(pAd
, BSS0
, KeyIdx
, CipherAlg
, Key
, NULL
, NULL
);
4409 // Update WCID attribute table and IVEIV table for this group key table
4410 RTMPAddWcidAttributeEntry(pAd
, BSS0
, KeyIdx
, CipherAlg
, NULL
);
4412 STA_PORT_SECURED(pAd
);
4414 // Indicate Connected for GUI
4415 pAd
->IndicateMediaState
= NdisMediaStateConnected
;
4417 else if (pAd
->StaCfg
.PortSecured
== WPA_802_1X_PORT_SECURED
)
4418 #endif // WPA_SUPPLICANT_SUPPORT
4420 Key
= pAd
->SharedKey
[BSS0
][KeyIdx
].Key
;
4422 // Set key material and cipherAlg to Asic
4423 AsicAddSharedKeyEntry(pAd
, BSS0
, KeyIdx
, CipherAlg
, Key
, NULL
, NULL
);
4425 if (pWepKey
->KeyIndex
& 0x80000000)
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
);
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"));
4439 #ifdef WPA_SUPPLICANT_SUPPORT
4440 case OID_SET_COUNTERMEASURES
:
4441 if (wrq
->u
.data
.length
!= sizeof(int))
4446 Status
= copy_from_user(&enabled
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4448 pAd
->StaCfg
.bBlockAssoc
= TRUE
;
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"));
4455 case RT_OID_WPA_SUPPLICANT_SUPPORT
:
4456 if (wrq
->u
.data
.length
!= sizeof(UCHAR
))
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
));
4465 case OID_802_11_DEAUTHENTICATION
:
4466 if (wrq
->u
.data
.length
!= sizeof(MLME_DEAUTH_REQ_STRUCT
))
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
)
4474 DBGPRINT(RT_DEBUG_ERROR
, ("%s():alloc memory failed!\n", __FUNCTION__
));
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
);
4485 LinkDown(pAd
, FALSE
);
4486 pAd
->Mlme
.AssocMachine
.CurrState
= ASSOC_IDLE
;
4488 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo
->Reason
));
4491 case OID_802_11_DROP_UNENCRYPTED
:
4492 if (wrq
->u
.data
.length
!= sizeof(int))
4497 Status
= copy_from_user(&enabled
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4499 pAd
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
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
));
4508 case OID_802_11_SET_IEEE8021X
:
4509 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
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
));
4518 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY
:
4519 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
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
));
4528 case OID_802_11_PMKID
:
4529 pPmkId
= kmalloc(wrq
->u
.data
.length
, MEM_ALLOC_FLAG
);
4531 if(pPmkId
== NULL
) {
4535 Status
= copy_from_user(pPmkId
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
4537 // check the PMKID information
4538 if (pPmkId
->BSSIDInfoCount
== 0)
4539 NdisZeroMemory(pAd
->StaCfg
.SavedPMK
, sizeof(BSSID_INFO
)*PMKID_NO
);
4542 PBSSID_INFO pBssIdInfo
;
4546 for (BssIdx
= 0; BssIdx
< pPmkId
->BSSIDInfoCount
; BssIdx
++)
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
++)
4553 // compare the BSSID
4554 if (NdisEqualMemory(pBssIdInfo
->BSSID
, pAd
->StaCfg
.SavedPMK
[CachedIdx
].BSSID
, sizeof(NDIS_802_11_MAC_ADDRESS
)))
4558 // Found, replace it
4559 if (CachedIdx
< PMKID_NO
)
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
++;
4565 // Not found, replace the last one
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
));
4578 #endif // WPA_SUPPLICANT_SUPPORT //
4583 case OID_802_11_SHORTRETRYLIMIT
:
4584 if (wrq
->u
.data
.length
!= sizeof(ULONG
))
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
));
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
))
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
));
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
);
4616 if ( pKey
->Length
!= wrq
->u
.data
.length
)
4619 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4621 KeyIdx
= pKey
->KeyIndex
& 0x0fffffff;
4622 DBGPRINT(RT_DEBUG_TRACE
,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey
->KeyIndex
, pKey
->KeyLength
));
4624 // it is a shared key
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)
4633 // Default key for tx (shared key)
4634 pAd
->StaCfg
.DefaultKeyId
= (UCHAR
) KeyIdx
;
4636 //RestartAPIsRequired = TRUE;
4641 case OID_802_11_WEPDEFAULTKEYID
:
4642 DBGPRINT(RT_DEBUG_TRACE
, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4644 if (wrq
->u
.data
.length
!= sizeof(UCHAR
))
4647 Status
= copy_from_user(&pAd
->StaCfg
.DefaultKeyId
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
);
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
))
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
);
4667 case RT_OID_802_11_SET_PSPXLINK_MODE
:
4668 if (wrq
->u
.data
.length
!= sizeof(BOOLEAN
))
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
));
4681 DBGPRINT(RT_DEBUG_TRACE
, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd
));
4682 Status
= -EOPNOTSUPP
;
4690 INT
RTMPQueryInformation(
4691 IN PRTMP_ADAPTER pAd
,
4692 IN OUT
struct ifreq
*rq
,
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;
4713 PUCHAR pBuf
= NULL
, pPtr
;
4714 INT Status
= NDIS_STATUS_SUCCESS
;
4715 UINT we_version_compiled
;
4716 UCHAR i
, Padding
= 0;
4718 STRING driverVersion
[8];
4719 OID_SET_HT_PHYMODE
*pHTPhyMode
= NULL
;
4724 DefaultKeyIdxValue
*pKeyIdxValue
;
4726 TX_RTY_CFG_STRUC tx_rty_cfg
;
4727 ULONG ShortRetryLimit
, LongRetryLimit
;
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
);
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
))
4748 case OID_802_11_BSSID_LIST
:
4749 if (RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS
))
4752 * Still scanning, indicate the caller should try again.
4754 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
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
);
4762 for (i
= 0; i
< pAd
->ScanTab
.BssNr
; i
++)
4764 // Align pointer to 4 bytes boundary.
4765 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4768 BssBufSize
+= (sizeof(NDIS_WLAN_BSSID_EX
) - 1 + sizeof(NDIS_802_11_FIXED_IEs
) + pAd
->ScanTab
.BssEntry
[i
].VarIELen
+ Padding
);
4771 // For safety issue, we add 256 bytes just in case
4773 // Allocate the same size as passed from higher layer
4774 pBuf
= kmalloc(BssBufSize
, MEM_ALLOC_FLAG
);
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
;
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
++)
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
))
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.
4800 if ((pAd
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
) && (pAd
->StaCfg
.PortSecured
!= WPA_802_1X_PORT_SECURED
))
4802 pBss
->Ssid
.SsidLength
= pAd
->ScanTab
.BssEntry
[i
].SsidLen
;
4803 NdisMoveMemory(pBss
->Ssid
.Ssid
, pAd
->ScanTab
.BssEntry
[i
].Ssid
, pAd
->ScanTab
.BssEntry
[i
].SsidLen
);
4806 pBss
->Ssid
.SsidLength
= 0;
4810 pBss
->Ssid
.SsidLength
= pAd
->ScanTab
.BssEntry
[i
].SsidLen
;
4811 NdisMoveMemory(pBss
->Ssid
.Ssid
, pAd
->ScanTab
.BssEntry
[i
].Ssid
, pAd
->ScanTab
.BssEntry
[i
].SsidLen
);
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
;
4820 MAP_CHANNEL_ID_TO_KHZ(pAd
->ScanTab
.BssEntry
[i
].Channel
, pBss
->Configuration
.DSConfig
);
4822 if (pAd
->ScanTab
.BssEntry
[i
].BssType
== BSS_INFRA
)
4823 pBss
->InfrastructureMode
= Ndis802_11Infrastructure
;
4825 pBss
->InfrastructureMode
= Ndis802_11IBSS
;
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
);
4832 if (pAd
->ScanTab
.BssEntry
[i
].VarIELen
== 0)
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
);
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
;
4846 pBss
->Length
= (ULONG
)(sizeof(NDIS_WLAN_BSSID_EX
) - 1 + sizeof(NDIS_802_11_FIXED_IEs
) + pAd
->ScanTab
.BssEntry
[i
].VarIELen
+ Padding
);
4848 #if WIRELESS_EXT < 17
4849 if ((BssLen
+ pBss
->Length
) < wrq
->u
.data
.length
)
4850 BssLen
+= pBss
->Length
;
4853 pBssidList
->NumberOfItems
= i
;
4857 BssLen
+= pBss
->Length
;
4861 #if WIRELESS_EXT < 17
4862 wrq
->u
.data
.length
= BssLen
;
4864 if (BssLen
> wrq
->u
.data
.length
)
4870 wrq
->u
.data
.length
= BssLen
;
4872 Status
= copy_to_user(wrq
->u
.data
.pointer
, pBssidList
, BssLen
);
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
);
4879 case OID_GEN_MEDIA_CONNECT_STATUS
:
4880 if (pAd
->IndicateMediaState
== NdisMediaStateConnected
)
4881 MediaState
= NdisMediaStateConnected
;
4883 MediaState
= NdisMediaStateDisconnected
;
4885 wrq
->u
.data
.length
= sizeof(NDIS_MEDIA_STATE
);
4886 Status
= copy_to_user(wrq
->u
.data
.pointer
, &MediaState
, wrq
->u
.data
.length
);
4888 case OID_802_11_BSSID
:
4889 if (INFRA_ON(pAd
) || ADHOC_ON(pAd
))
4891 Status
= copy_to_user(wrq
->u
.data
.pointer
, &pAd
->CommonCfg
.Bssid
, sizeof(NDIS_802_11_MAC_ADDRESS
));
4896 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
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
));
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
);
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
);
4921 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4925 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4929 case OID_802_11_CONFIGURATION
:
4930 pConfiguration
= (NDIS_802_11_CONFIGURATION
*) kmalloc(sizeof(NDIS_802_11_CONFIGURATION
), MEM_ALLOC_FLAG
);
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
);
4945 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4949 case RT_OID_802_11_SNR_0
:
4950 if ((pAd
->StaCfg
.LastSNR0
> 0))
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
));
4960 case RT_OID_802_11_SNR_1
:
4961 if ((pAd
->Antenna
.field
.RxPath
> 1) &&
4962 (pAd
->StaCfg
.LastSNR1
> 0))
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
));
4971 DBGPRINT(RT_DEBUG_TRACE
,("Query::RT_OID_802_11_SNR_1(pAd->StaCfg.LastSNR1=%d)\n",pAd
->StaCfg
.LastSNR1
));
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
));
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
);
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
);
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
);
4995 case OID_802_11_STATISTICS
:
4996 pStatistics
= (NDIS_802_11_STATISTICS
*) kmalloc(sizeof(NDIS_802_11_STATISTICS
), MEM_ALLOC_FLAG
);
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
);
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
;
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
;
5019 pStatistics
->FCSErrorCount
= pAd
->RalinkCounters
.RealFcsErrCount
;
5021 pStatistics
->FCSErrorCount
.QuadPart
= pAd
->WlanCounters
.FCSErrorCount
.QuadPart
;
5022 pStatistics
->FrameDuplicateCount
.u
.LowPart
= pAd
->WlanCounters
.FrameDuplicateCount
.u
.LowPart
/ 100;
5024 wrq
->u
.data
.length
= sizeof(NDIS_802_11_STATISTICS
);
5025 Status
= copy_to_user(wrq
->u
.data
.pointer
, pStatistics
, wrq
->u
.data
.length
);
5030 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
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
);
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
);
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
));
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
);
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
);
5069 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
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
));
5079 case OID_802_11_FRAGMENTATION_THRESHOLD
:
5080 FragThresh
= pAd
->CommonCfg
.FragmentThreshold
;
5081 if (pAd
->CommonCfg
.bUseZeroToDisableFragment
== TRUE
)
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
));
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
));
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
));
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
;
5107 BssType
= Ndis802_11AutoUnknown
;
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
));
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
));
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
));
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
));
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
));
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
));
5141 case OID_802_11_NETWORK_TYPES_SUPPORTED
:
5142 if ((pAd
->RfIcType
== RFIC_2850
) || (pAd
->RfIcType
== RFIC_2750
) || (pAd
->RfIcType
== RFIC_3052
))
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
);
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
);
5159 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
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
;
5168 ulInfo
= Ndis802_11DS
;
5169 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
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
));
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
));
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
);
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
);
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]));
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
));
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
);
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));
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
));
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
));
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
));
5226 #ifdef WPA_SUPPLICANT_SUPPORT
5227 case RT_OID_NEW_DRIVER
:
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
));
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
));
5240 #endif // WPA_SUPPLICANT_SUPPORT //
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
))
5250 case RT_OID_802_11_QUERY_HT_PHYMODE
:
5251 pHTPhyMode
= (OID_SET_HT_PHYMODE
*) kmalloc(sizeof(OID_SET_HT_PHYMODE
), MEM_ALLOC_FLAG
);
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
;
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
))
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
));
5273 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
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
))
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
);
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
;
5298 wrq
->u
.data
.length
= sizeof(OID_SET_HT_PHYMODE
);
5299 if (copy_to_user(wrq
->u
.data
.pointer
, pHTPhyMode
, wrq
->u
.data
.length
))
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
));
5309 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5313 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT
:
5314 wrq
->u
.data
.length
= sizeof(UCHAR
);
5316 #ifdef MULTIPLE_CARD_SUPPORT
5318 #endif // MULTIPLE_CARD_SUPPORT //
5319 if (copy_to_user(wrq
->u
.data
.pointer
, &i
, wrq
->u
.data
.length
))
5323 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i
));
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
);
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
);
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
);
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
);
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
);
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.
5363 wrq
->u
.data
.length
= sizeof(ulInfo
);
5364 Status
= copy_to_user(wrq
->u
.data
.pointer
, &ulInfo
, wrq
->u
.data
.length
);
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
,
5376 pKeyIdxValue
->Value
[valueLen
]='\0';
5378 wrq
->u
.data
.length
= sizeof(DefaultKeyIdxValue
);
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
,
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]));
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
));
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
);
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
);
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
);
5424 case RT_OID_802_11_PRODUCTID
:
5425 DBGPRINT(RT_DEBUG_TRACE
, ("Query::RT_OID_802_11_PRODUCTID \n"));
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
);
5434 DBGPRINT(RT_DEBUG_TRACE
, (" pci_dev = NULL\n"));
5435 sprintf((PSTRING
)tmp
, "%04x %04x\n", NIC_PCI_VENDOR_ID
, device_id
);
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
);
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
);
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
));
5455 #endif //SNMP_SUPPORT
5457 case OID_802_11_BUILD_CHANNEL_EX
:
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"));
5466 DBGPRINT(RT_DEBUG_TRACE
, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
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
));
5474 case OID_802_11_GET_CH_LIST
:
5476 PRT_CHANNEL_LIST_INFO pChListBuf
;
5478 DBGPRINT(RT_DEBUG_TRACE
, ("Query::OID_802_11_GET_CH_LIST \n"));
5479 if (pAd
->ChannelListNum
== 0)
5481 wrq
->u
.data
.length
= 0;
5485 pChListBuf
= (RT_CHANNEL_LIST_INFO
*) kmalloc(sizeof(RT_CHANNEL_LIST_INFO
), MEM_ALLOC_FLAG
);
5486 if (pChListBuf
== NULL
)
5488 wrq
->u
.data
.length
= 0;
5492 pChListBuf
->ChannelListNum
= pAd
->ChannelListNum
;
5493 for (i
= 0; i
< pChListBuf
->ChannelListNum
; i
++)
5494 pChListBuf
->ChannelList
[i
] = pAd
->ChannelList
[i
].Channel
;
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
));
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
));
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
));
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
));
5527 case RT_OID_802_11_QUERY_DLS_PARAM
:
5529 PRT_802_11_DLS_INFO pDlsInfo
= kmalloc(sizeof(RT_802_11_DLS_INFO
), GFP_ATOMIC
);
5530 if (pDlsInfo
== NULL
)
5533 for (i
=0; i
<MAX_NUM_OF_DLS_ENTRY
; i
++)
5535 RTMPMoveMemory(&pDlsInfo
->Entry
[i
], &pAd
->StaCfg
.DLSEntry
[i
], sizeof(RT_802_11_DLS_UI
));
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"));
5547 #endif // QOS_DLS_SUPPORT //
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
));
5557 DBGPRINT(RT_DEBUG_TRACE
, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd
));
5558 Status
= -EOPNOTSUPP
;
5564 INT
rt28xx_sta_ioctl(
5565 IN
struct net_device
*net_dev
,
5566 IN OUT
struct ifreq
*rq
,
5570 RTMP_ADAPTER
*pAd
= NULL
;
5571 struct iwreq
*wrq
= (struct iwreq
*) rq
;
5572 BOOLEAN StateMachineTouched
= FALSE
;
5573 INT Status
= NDIS_STATUS_SUCCESS
;
5577 pAd
= RTMP_OS_NETDEV_GET_PRIV(net_dev
);
5580 /* if 1st open fail, pAd will be free;
5581 So the net_dev->priv will be NULL in 2rd open */
5584 pObj
= (POS_COOKIE
) pAd
->OS_Cookie
;
5586 //check if the interface is down
5587 if(!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
5589 #ifdef CONFIG_APSTA_MIXED_SUPPORT
5590 if (wrq
->u
.data
.pointer
== NULL
)
5595 if (strstr(wrq
->u
.data
.pointer
, "OpMode") == NULL
)
5596 #endif // CONFIG_APSTA_MIXED_SUPPORT //
5598 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
5603 { // determine this ioctl command is comming from which interface.
5604 pObj
->ioctl_if_type
= INT_MAIN
;
5605 pObj
->ioctl_if
= MAIN_MBSSID
;
5611 #ifdef RALINK_28xx_QA
5612 case RTPRIV_IOCTL_ATE
:
5614 RtmpDoAte(pAd
, wrq
);
5617 #endif // RALINK_28xx_QA //
5618 #endif // RALINK_ATE //
5620 DBGPRINT(RT_DEBUG_TRACE
, ("IOCTL::SIOCGIFHWADDR\n"));
5621 memcpy(wrq
->u
.name
, pAd
->CurrentAddress
, ETH_ALEN
);
5625 char *name
=&wrq
->u
.name
[0];
5626 rt_ioctl_giwname(net_dev
, NULL
, name
, NULL
);
5629 case SIOCGIWESSID
: //Get ESSID
5631 struct iw_point
*essid
=&wrq
->u
.essid
;
5632 rt_ioctl_giwessid(net_dev
, NULL
, essid
, essid
->pointer
);
5635 case SIOCSIWESSID
: //Set ESSID
5637 struct iw_point
*essid
=&wrq
->u
.essid
;
5638 rt_ioctl_siwessid(net_dev
, NULL
, essid
, essid
->pointer
);
5641 case SIOCSIWNWID
: // set network id (the cell)
5642 case SIOCGIWNWID
: // get network id
5643 Status
= -EOPNOTSUPP
;
5645 case SIOCSIWFREQ
: //set channel/frequency (Hz)
5647 struct iw_freq
*freq
=&wrq
->u
.freq
;
5648 rt_ioctl_siwfreq(net_dev
, NULL
, freq
, NULL
);
5651 case SIOCGIWFREQ
: // get channel/frequency (Hz)
5653 struct iw_freq
*freq
=&wrq
->u
.freq
;
5654 rt_ioctl_giwfreq(net_dev
, NULL
, freq
, NULL
);
5657 case SIOCSIWNICKN
: //set node name/nickname
5659 //struct iw_point *data=&wrq->u.data;
5660 //rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5663 case SIOCGIWNICKN
: //get node name/nickname
5665 struct iw_point
*erq
= NULL
;
5667 erq
->length
= strlen((PSTRING
) pAd
->nickname
);
5668 Status
= copy_to_user(erq
->pointer
, pAd
->nickname
, erq
->length
);
5671 case SIOCGIWRATE
: //get default bit rate (bps)
5672 rt_ioctl_giwrate(net_dev
, NULL
, &wrq
->u
, NULL
);
5674 case SIOCSIWRATE
: //set default bit rate (bps)
5675 rt_ioctl_siwrate(net_dev
, NULL
, &wrq
->u
, NULL
);
5677 case SIOCGIWRTS
: // get RTS/CTS threshold (bytes)
5679 struct iw_param
*rts
=&wrq
->u
.rts
;
5680 rt_ioctl_giwrts(net_dev
, NULL
, rts
, NULL
);
5683 case SIOCSIWRTS
: //set RTS/CTS threshold (bytes)
5685 struct iw_param
*rts
=&wrq
->u
.rts
;
5686 rt_ioctl_siwrts(net_dev
, NULL
, rts
, NULL
);
5689 case SIOCGIWFRAG
: //get fragmentation thr (bytes)
5691 struct iw_param
*frag
=&wrq
->u
.frag
;
5692 rt_ioctl_giwfrag(net_dev
, NULL
, frag
, NULL
);
5695 case SIOCSIWFRAG
: //set fragmentation thr (bytes)
5697 struct iw_param
*frag
=&wrq
->u
.frag
;
5698 rt_ioctl_siwfrag(net_dev
, NULL
, frag
, NULL
);
5701 case SIOCGIWENCODE
: //get encoding token & mode
5703 struct iw_point
*erq
=&wrq
->u
.encoding
;
5705 rt_ioctl_giwencode(net_dev
, NULL
, erq
, erq
->pointer
);
5708 case SIOCSIWENCODE
: //set encoding token & mode
5710 struct iw_point
*erq
=&wrq
->u
.encoding
;
5712 rt_ioctl_siwencode(net_dev
, NULL
, erq
, erq
->pointer
);
5715 case SIOCGIWAP
: //get access point MAC addresses
5717 struct sockaddr
*ap_addr
=&wrq
->u
.ap_addr
;
5718 rt_ioctl_giwap(net_dev
, NULL
, ap_addr
, ap_addr
->sa_data
);
5721 case SIOCSIWAP
: //set access point MAC addresses
5723 struct sockaddr
*ap_addr
=&wrq
->u
.ap_addr
;
5724 rt_ioctl_siwap(net_dev
, NULL
, ap_addr
, ap_addr
->sa_data
);
5727 case SIOCGIWMODE
: //get operation mode
5729 __u32
*mode
=&wrq
->u
.mode
;
5730 rt_ioctl_giwmode(net_dev
, NULL
, mode
, NULL
);
5733 case SIOCSIWMODE
: //set operation mode
5735 __u32
*mode
=&wrq
->u
.mode
;
5736 rt_ioctl_siwmode(net_dev
, NULL
, mode
, NULL
);
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
;
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
);
5756 Status
= RTMPQueryInformation(pAd
, rq
, subcmd
);
5759 if (wrq
->u
.data
.pointer
)
5761 if ( access_ok(VERIFY_WRITE
, wrq
->u
.data
.pointer
, sizeof(privtab
)) != TRUE
)
5763 wrq
->u
.data
.length
= sizeof(privtab
) / sizeof(privtab
[0]);
5764 if (copy_to_user(wrq
->u
.data
.pointer
, privtab
, sizeof(privtab
)))
5768 case RTPRIV_IOCTL_SET
:
5769 if(access_ok(VERIFY_READ
, wrq
->u
.data
.pointer
, wrq
->u
.data
.length
) != TRUE
)
5771 rt_ioctl_setparam(net_dev
, NULL
, NULL
, wrq
->u
.data
.pointer
);
5773 case RTPRIV_IOCTL_GSITESURVEY
:
5774 RTMPIoctlGetSiteSurvey(pAd
, wrq
);
5777 case RTPRIV_IOCTL_MAC
:
5778 RTMPIoctlMAC(pAd
, wrq
);
5780 case RTPRIV_IOCTL_E2P
:
5781 RTMPIoctlE2PROM(pAd
, wrq
);
5783 #ifdef RTMP_RF_RW_SUPPORT
5784 case RTPRIV_IOCTL_RF
:
5785 RTMPIoctlRF(pAd
, wrq
);
5787 #endif // RTMP_RF_RW_SUPPORT //
5793 DBGPRINT(RT_DEBUG_ERROR
, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd
));
5794 Status
= -EOPNOTSUPP
;
5798 if(StateMachineTouched
) // Upper layer sent a MLME-related operations
5799 RTMP_MLME_HANDLER(pAd
);
5805 ==========================================================================
5809 TRUE if all parameters are OK, FALSE otherwise
5810 ==========================================================================
5813 IN PRTMP_ADAPTER pAdapter
,
5816 NDIS_802_11_SSID Ssid
, *pSsid
=NULL
;
5817 BOOLEAN StateMachineTouched
= FALSE
;
5820 if( strlen(arg
) <= MAX_LEN_OF_SSID
)
5822 NdisZeroMemory(&Ssid
, sizeof(NDIS_802_11_SSID
));
5823 if (strlen(arg
) != 0)
5825 NdisMoveMemory(Ssid
.Ssid
, arg
, strlen(arg
));
5826 Ssid
.SsidLength
= strlen(arg
);
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
;
5838 if (pAdapter
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
5840 RTMP_MLME_RESET_STATE_MACHINE(pAdapter
);
5841 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
5844 if ((pAdapter
->StaCfg
.WpaPassPhraseLen
>= 8) &&
5845 (pAdapter
->StaCfg
.WpaPassPhraseLen
<= 64))
5847 STRING passphrase_str
[65] = {0};
5848 UCHAR keyMaterial
[40];
5850 RTMPMoveMemory(passphrase_str
, pAdapter
->StaCfg
.WpaPassPhrase
, pAdapter
->StaCfg
.WpaPassPhraseLen
);
5851 RTMPZeroMemory(pAdapter
->StaCfg
.PMK
, 32);
5852 if (pAdapter
->StaCfg
.WpaPassPhraseLen
== 64)
5854 AtoH((PSTRING
) pAdapter
->StaCfg
.WpaPassPhrase
, pAdapter
->StaCfg
.PMK
, 32);
5858 PasswordHash((PSTRING
) pAdapter
->StaCfg
.WpaPassPhrase
, Ssid
.Ssid
, Ssid
.SsidLength
, keyMaterial
);
5859 NdisMoveMemory(pAdapter
->StaCfg
.PMK
, keyMaterial
, 32);
5863 pAdapter
->MlmeAux
.CurrReqIsFromNdis
= TRUE
;
5864 pAdapter
->StaCfg
.bScanReqIsFromWebUI
= FALSE
;
5865 pAdapter
->bConfigChanged
= TRUE
;
5867 MlmeEnqueue(pAdapter
,
5868 MLME_CNTL_STATE_MACHINE
,
5870 sizeof(NDIS_802_11_SSID
),
5873 StateMachineTouched
= TRUE
;
5874 DBGPRINT(RT_DEBUG_TRACE
, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid
.SsidLength
, Ssid
.Ssid
));
5879 if (StateMachineTouched
) // Upper layer sent a MLME-related operations
5880 RTMP_MLME_HANDLER(pAdapter
);
5887 ==========================================================================
5889 Set WmmCapable Enable or Disable
5891 TRUE if all parameters are OK, FALSE otherwise
5892 ==========================================================================
5894 INT
Set_WmmCapable_Proc(
5895 IN PRTMP_ADAPTER pAd
,
5898 BOOLEAN bWmmCapable
;
5900 bWmmCapable
= simple_strtol(arg
, 0, 10);
5902 if ((bWmmCapable
== 1)
5904 pAd
->CommonCfg
.bWmmCapable
= TRUE
;
5905 else if (bWmmCapable
== 0)
5906 pAd
->CommonCfg
.bWmmCapable
= FALSE
;
5908 return FALSE
; //Invalid argument
5910 DBGPRINT(RT_DEBUG_TRACE
, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5911 pAd
->CommonCfg
.bWmmCapable
));
5915 #endif // WMM_SUPPORT //
5918 ==========================================================================
5920 Set Network Type(Infrastructure/Adhoc mode)
5922 TRUE if all parameters are OK, FALSE otherwise
5923 ==========================================================================
5925 INT
Set_NetworkType_Proc(
5926 IN PRTMP_ADAPTER pAdapter
,
5931 if (strcmp(arg
, "Adhoc") == 0)
5933 if (pAdapter
->StaCfg
.BssType
!= BSS_ADHOC
)
5935 // Config has changed
5936 pAdapter
->bConfigChanged
= TRUE
;
5937 if (MONITOR_ON(pAdapter
))
5939 RTMP_IO_WRITE32(pAdapter
, RX_FILTR_CFG
, STANORMAL
);
5940 RTMP_IO_READ32(pAdapter
, MAC_SYS_CTRL
, &Value
);
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
);
5947 if (INFRA_ON(pAdapter
))
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
);
5955 LinkDown(pAdapter
, FALSE
);
5957 DBGPRINT(RT_DEBUG_TRACE
, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
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"));
5964 else if (strcmp(arg
, "Infra") == 0)
5966 if (pAdapter
->StaCfg
.BssType
!= BSS_INFRA
)
5968 // Config has changed
5969 pAdapter
->bConfigChanged
= TRUE
;
5970 if (MONITOR_ON(pAdapter
))
5972 RTMP_IO_WRITE32(pAdapter
, RX_FILTR_CFG
, STANORMAL
);
5973 RTMP_IO_READ32(pAdapter
, MAC_SYS_CTRL
, &Value
);
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
);
5980 if (ADHOC_ON(pAdapter
))
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
);
5987 LinkDown(pAdapter
, FALSE
);
5990 pAdapter
->StaCfg
.BssType
= BSS_INFRA
;
5991 pAdapter
->net_dev
->type
= pAdapter
->StaCfg
.OriDevType
;
5992 DBGPRINT(RT_DEBUG_TRACE
, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5994 else if (strcmp(arg
, "Monitor") == 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)
6008 #ifdef DOT11_N_SUPPORT
6009 if (pAdapter
->CommonCfg
.PhyMode
== PHY_11AN_MIXED
)
6010 pAdapter
->CommonCfg
.CentralChannel
= 36;
6012 #endif // DOT11_N_SUPPORT //
6013 pAdapter
->CommonCfg
.CentralChannel
= 6;
6015 #ifdef DOT11_N_SUPPORT
6017 N_ChannelCheck(pAdapter
);
6018 #endif // DOT11_N_SUPPORT //
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
)
6025 // 40MHz ,control channel at lower
6026 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R4
, &bbpValue
);
6027 bbpValue
&= (~0x18);
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
);
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
));
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
)
6050 // 40MHz ,control channel at upper
6051 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R4
, &bbpValue
);
6052 bbpValue
&= (~0x18);
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
);
6058 RTMP_IO_WRITE32(pAdapter
, TX_BAND_CFG
, Value
);
6060 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter
, BBP_R3
, &bbpValue
);
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
));
6071 #endif // DOT11_N_SUPPORT //
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
));
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);
6087 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
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
);
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"));
6100 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
6101 pAdapter
->StaCfg
.WpaState
= SS_NOTUSE
;
6103 DBGPRINT(RT_DEBUG_TRACE
, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter
->StaCfg
.BssType
));
6109 ==========================================================================
6111 Set Authentication mode
6113 TRUE if all parameters are OK, FALSE otherwise
6114 ==========================================================================
6116 INT
Set_AuthMode_Proc(
6117 IN PRTMP_ADAPTER pAdapter
,
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 //
6141 pAdapter
->StaCfg
.PortSecured
= WPA_802_1X_PORT_NOT_SECURED
;
6143 DBGPRINT(RT_DEBUG_TRACE
, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter
->StaCfg
.AuthMode
));
6149 ==========================================================================
6153 TRUE if all parameters are OK, FALSE otherwise
6154 ==========================================================================
6156 INT
Set_EncrypType_Proc(
6157 IN PRTMP_ADAPTER pAdapter
,
6160 if ((strcmp(arg
, "NONE") == 0) || (strcmp(arg
, "none") == 0))
6162 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6163 return TRUE
; // do nothing
6165 pAdapter
->StaCfg
.WepStatus
= Ndis802_11WEPDisabled
;
6166 pAdapter
->StaCfg
.PairCipher
= Ndis802_11WEPDisabled
;
6167 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPDisabled
;
6169 else if ((strcmp(arg
, "WEP") == 0) || (strcmp(arg
, "wep") == 0))
6171 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6172 return TRUE
; // do nothing
6174 pAdapter
->StaCfg
.WepStatus
= Ndis802_11WEPEnabled
;
6175 pAdapter
->StaCfg
.PairCipher
= Ndis802_11WEPEnabled
;
6176 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11WEPEnabled
;
6178 else if ((strcmp(arg
, "TKIP") == 0) || (strcmp(arg
, "tkip") == 0))
6180 if (pAdapter
->StaCfg
.AuthMode
< Ndis802_11AuthModeWPA
)
6181 return TRUE
; // do nothing
6183 pAdapter
->StaCfg
.WepStatus
= Ndis802_11Encryption2Enabled
;
6184 pAdapter
->StaCfg
.PairCipher
= Ndis802_11Encryption2Enabled
;
6185 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11Encryption2Enabled
;
6187 else if ((strcmp(arg
, "AES") == 0) || (strcmp(arg
, "aes") == 0))
6189 if (pAdapter
->StaCfg
.AuthMode
< Ndis802_11AuthModeWPA
)
6190 return TRUE
; // do nothing
6192 pAdapter
->StaCfg
.WepStatus
= Ndis802_11Encryption3Enabled
;
6193 pAdapter
->StaCfg
.PairCipher
= Ndis802_11Encryption3Enabled
;
6194 pAdapter
->StaCfg
.GroupCipher
= Ndis802_11Encryption3Enabled
;
6199 pAdapter
->StaCfg
.OrigWepStatus
= pAdapter
->StaCfg
.WepStatus
;
6201 DBGPRINT(RT_DEBUG_TRACE
, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter
->StaCfg
.WepStatus
));
6207 ==========================================================================
6211 TRUE if all parameters are OK, FALSE otherwise
6212 ==========================================================================
6214 INT
Set_DefaultKeyID_Proc(
6215 IN PRTMP_ADAPTER pAdapter
,
6220 KeyIdx
= simple_strtol(arg
, 0, 10);
6221 if((KeyIdx
>= 1 ) && (KeyIdx
<= 4))
6222 pAdapter
->StaCfg
.DefaultKeyId
= (UCHAR
) (KeyIdx
- 1 );
6224 return FALSE
; //Invalid argument
6226 DBGPRINT(RT_DEBUG_TRACE
, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter
->StaCfg
.DefaultKeyId
));
6232 ==========================================================================
6236 TRUE if all parameters are OK, FALSE otherwise
6237 ==========================================================================
6240 IN PRTMP_ADAPTER pAdapter
,
6245 UCHAR CipherAlg
=CIPHER_WEP64
;
6247 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6248 return TRUE
; // do nothing
6250 KeyLen
= strlen(arg
);
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"));
6260 case 10: //wep 40 Hex type
6261 for(i
=0; i
< KeyLen
; i
++)
6263 if( !isxdigit(*(arg
+i
)) )
6264 return FALSE
; //Not Hex value;
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"));
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"));
6277 case 26: //wep 104 Hex type
6278 for(i
=0; i
< KeyLen
; i
++)
6280 if( !isxdigit(*(arg
+i
)) )
6281 return FALSE
; //Not Hex value;
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"));
6288 default: //Invalid argument
6289 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg
));
6293 pAdapter
->SharedKey
[BSS0
][0].CipherAlg
= CipherAlg
;
6295 // Set keys (into ASIC)
6296 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6298 else // Old WEP stuff
6300 AsicAddSharedKeyEntry(pAdapter
,
6303 pAdapter
->SharedKey
[BSS0
][0].CipherAlg
,
6304 pAdapter
->SharedKey
[BSS0
][0].Key
,
6312 ==========================================================================
6317 TRUE if all parameters are OK, FALSE otherwise
6318 ==========================================================================
6321 IN PRTMP_ADAPTER pAdapter
,
6326 UCHAR CipherAlg
=CIPHER_WEP64
;
6328 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6329 return TRUE
; // do nothing
6331 KeyLen
= strlen(arg
);
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"));
6341 case 10: //wep 40 Hex type
6342 for(i
=0; i
< KeyLen
; i
++)
6344 if( !isxdigit(*(arg
+i
)) )
6345 return FALSE
; //Not Hex value;
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"));
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"));
6358 case 26: //wep 104 Hex type
6359 for(i
=0; i
< KeyLen
; i
++)
6361 if( !isxdigit(*(arg
+i
)) )
6362 return FALSE
; //Not Hex value;
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"));
6369 default: //Invalid argument
6370 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg
));
6373 pAdapter
->SharedKey
[BSS0
][1].CipherAlg
= CipherAlg
;
6375 // Set keys (into ASIC)
6376 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6378 else // Old WEP stuff
6380 AsicAddSharedKeyEntry(pAdapter
,
6383 pAdapter
->SharedKey
[BSS0
][1].CipherAlg
,
6384 pAdapter
->SharedKey
[BSS0
][1].Key
,
6392 ==========================================================================
6396 TRUE if all parameters are OK, FALSE otherwise
6397 ==========================================================================
6400 IN PRTMP_ADAPTER pAdapter
,
6405 UCHAR CipherAlg
=CIPHER_WEP64
;
6407 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6408 return TRUE
; // do nothing
6410 KeyLen
= strlen(arg
);
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
));
6420 case 10: //wep 40 Hex type
6421 for(i
=0; i
< KeyLen
; i
++)
6423 if( !isxdigit(*(arg
+i
)) )
6424 return FALSE
; //Not Hex value;
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
));
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
));
6437 case 26: //wep 104 Hex type
6438 for(i
=0; i
< KeyLen
; i
++)
6440 if( !isxdigit(*(arg
+i
)) )
6441 return FALSE
; //Not Hex value;
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
));
6448 default: //Invalid argument
6449 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg
));
6452 pAdapter
->SharedKey
[BSS0
][2].CipherAlg
= CipherAlg
;
6454 // Set keys (into ASIC)
6455 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6457 else // Old WEP stuff
6459 AsicAddSharedKeyEntry(pAdapter
,
6462 pAdapter
->SharedKey
[BSS0
][2].CipherAlg
,
6463 pAdapter
->SharedKey
[BSS0
][2].Key
,
6471 ==========================================================================
6475 TRUE if all parameters are OK, FALSE otherwise
6476 ==========================================================================
6479 IN PRTMP_ADAPTER pAdapter
,
6484 UCHAR CipherAlg
=CIPHER_WEP64
;
6486 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6487 return TRUE
; // do nothing
6489 KeyLen
= strlen(arg
);
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"));
6499 case 10: //wep 40 Hex type
6500 for(i
=0; i
< KeyLen
; i
++)
6502 if( !isxdigit(*(arg
+i
)) )
6503 return FALSE
; //Not Hex value;
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"));
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"));
6516 case 26: //wep 104 Hex type
6517 for(i
=0; i
< KeyLen
; i
++)
6519 if( !isxdigit(*(arg
+i
)) )
6520 return FALSE
; //Not Hex value;
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"));
6527 default: //Invalid argument
6528 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg
));
6531 pAdapter
->SharedKey
[BSS0
][3].CipherAlg
= CipherAlg
;
6533 // Set keys (into ASIC)
6534 if (pAdapter
->StaCfg
.AuthMode
>= Ndis802_11AuthModeWPA
)
6536 else // Old WEP stuff
6538 AsicAddSharedKeyEntry(pAdapter
,
6541 pAdapter
->SharedKey
[BSS0
][3].CipherAlg
,
6542 pAdapter
->SharedKey
[BSS0
][3].Key
,
6551 ==========================================================================
6555 TRUE if all parameters are OK, FALSE otherwise
6556 ==========================================================================
6558 INT
Set_WPAPSK_Proc(
6559 IN PRTMP_ADAPTER pAd
,
6564 if ((pAd
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPAPSK
) &&
6565 (pAd
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPA2PSK
) &&
6566 (pAd
->StaCfg
.AuthMode
!= Ndis802_11AuthModeWPANone
)
6568 return TRUE
; // do nothing
6570 DBGPRINT(RT_DEBUG_TRACE
, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg
));
6572 status
= RT_CfgSetWPAPSKKey(pAd
, arg
, pAd
->MlmeAux
.Ssid
, pAd
->MlmeAux
.SsidLen
, pAd
->StaCfg
.PMK
);
6573 if (status
== FALSE
)
6575 DBGPRINT(RT_DEBUG_TRACE
, ("Set_WPAPSK_Proc(): Set key failed!\n"));
6578 NdisZeroMemory(pAd
->StaCfg
.WpaPassPhrase
, 64);
6579 NdisMoveMemory(pAd
->StaCfg
.WpaPassPhrase
, arg
, strlen(arg
));
6580 pAd
->StaCfg
.WpaPassPhraseLen
= (UINT
)strlen(arg
);
6584 if(pAd
->StaCfg
.BssType
== BSS_ADHOC
&&
6585 pAd
->StaCfg
.AuthMode
== Ndis802_11AuthModeWPANone
)
6587 pAd
->StaCfg
.WpaState
= SS_NOTUSE
;
6591 // Start STA supplicant state machine
6592 pAd
->StaCfg
.WpaState
= SS_START
;
6599 ==========================================================================
6601 Set Power Saving mode
6603 TRUE if all parameters are OK, FALSE otherwise
6604 ==========================================================================
6606 INT
Set_PSMode_Proc(
6607 IN PRTMP_ADAPTER pAdapter
,
6610 if (pAdapter
->StaCfg
.BssType
== BSS_INFRA
)
6612 if ((strcmp(arg
, "Max_PSP") == 0) ||
6613 (strcmp(arg
, "max_psp") == 0) ||
6614 (strcmp(arg
, "MAX_PSP") == 0))
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;
6625 else if ((strcmp(arg
, "Fast_PSP") == 0) ||
6626 (strcmp(arg
, "fast_psp") == 0) ||
6627 (strcmp(arg
, "FAST_PSP") == 0))
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;
6637 else if ((strcmp(arg
, "Legacy_PSP") == 0) ||
6638 (strcmp(arg
, "legacy_psp") == 0) ||
6639 (strcmp(arg
, "LEGACY_PSP") == 0))
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;
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
;
6660 DBGPRINT(RT_DEBUG_TRACE
, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter
->StaCfg
.WindowsPowerMode
));
6668 //Add to suport the function which clould dynamicallly enable/disable PCIe Power Saving
6670 #ifdef WPA_SUPPLICANT_SUPPORT
6672 ==========================================================================
6674 Set WpaSupport flag.
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.
6680 TRUE if all parameters are OK, FALSE otherwise
6681 ==========================================================================
6683 INT
Set_Wpa_Support(
6684 IN PRTMP_ADAPTER pAd
,
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
;
6695 pAd
->StaCfg
.WpaSupplicantUP
= WPA_SUPPLICANT_DISABLE
;
6697 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd
->StaCfg
.WpaSupplicantUP
));
6701 #endif // WPA_SUPPLICANT_SUPPORT //
6705 ==========================================================================
6709 pAdapter Pointer to our adapter
6710 wrq Pointer to the ioctl argument
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 ==========================================================================
6722 IN PRTMP_ADAPTER pAdapter
,
6723 IN
struct iwreq
*wrq
)
6733 UINT32 macValue
= 0;
6735 BOOLEAN bIsPrintAllMAC
= FALSE
;
6738 memset(msg
, 0x00, 1024);
6739 if (wrq
->u
.data
.length
> 1) //No parameters.
6741 Status
= copy_from_user(arg
, wrq
->u
.data
.pointer
, (wrq
->u
.data
.length
> 255) ? 255 : wrq
->u
.data
.length
);
6744 //Parsing Read or Write
6749 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
6752 if (!value
|| !*value
)
6755 if(strlen(this_char
) > 4)
6758 j
= strlen(this_char
);
6761 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
6766 k
= j
= strlen(this_char
);
6769 this_char
[4-k
+j
] = this_char
[j
];
6773 this_char
[3-k
++]='0';
6776 if(strlen(this_char
) == 4)
6778 AtoH(this_char
, temp
, 2);
6779 macAddr
= *temp
*256 + temp
[1];
6780 if (macAddr
< 0xFFFF)
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
);
6787 {//Invalid parametes, so default printk all mac
6788 bIsPrintAllMAC
= TRUE
;
6795 memcpy(&temp2
, value
, strlen(value
));
6796 temp2
[strlen(value
)] = '\0';
6799 if((strlen(this_char
) > 4) || strlen(temp2
) > 8)
6802 j
= strlen(this_char
);
6805 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
6812 if(temp2
[j
] > 'f' || temp2
[j
] < '0')
6817 k
= j
= strlen(this_char
);
6820 this_char
[4-k
+j
] = this_char
[j
];
6824 this_char
[3-k
++]='0';
6828 k
= j
= strlen(temp2
);
6831 temp2
[8-k
+j
] = temp2
[j
];
6839 AtoH(this_char
, temp
, 2);
6840 macAddr
= *temp
*256 + temp
[1];
6842 AtoH(temp2
, temp
, 4);
6843 macValue
= *temp
*256*256*256 + temp
[1]*256*256 + temp
[2]*256 + temp
[3];
6846 if (macAddr
== (HW_DEBUG_SETTING_BASE
+ 4))
6848 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6849 if (macValue
& 0x000000ff)
6851 pAdapter
->BbpTuning
.bEnable
= TRUE
;
6852 DBGPRINT(RT_DEBUG_TRACE
,("turn on R17 tuning\n"));
6857 pAdapter
->BbpTuning
.bEnable
= FALSE
;
6858 R66
= 0x26 + GET_LNA_GAIN(pAdapter
);
6860 if (ATE_ON(pAdapter
))
6862 ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter
, BBP_R66
, (0x26 + GET_LNA_GAIN(pAdapter
)));
6865 #endif // RALINK_ATE //
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
));
6873 DBGPRINT(RT_DEBUG_TRACE
, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr
, macValue
));
6875 RTMP_IO_WRITE32(pAdapter
, macAddr
, macValue
);
6876 sprintf(msg
+strlen(msg
), "[0x%08lX]:%08X ", macAddr
, macValue
);
6881 bIsPrintAllMAC
= TRUE
;
6885 struct file
*file_w
;
6886 PSTRING fileName
= "MacDump.txt";
6887 mm_segment_t orig_fs
;
6893 file_w
= filp_open(fileName
, O_WRONLY
|O_CREAT
, 0);
6896 DBGPRINT(RT_DEBUG_TRACE
, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__
, -PTR_ERR(file_w
), fileName
));
6900 if (file_w
->f_op
&& file_w
->f_op
->write
)
6905 while (macAddr
<= 0x1800)
6907 RTMP_IO_READ32(pAdapter
, macAddr
, &macValue
);
6908 sprintf(msg
, "%08lx = %08X\n", macAddr
, macValue
);
6910 // write data to file
6911 file_w
->f_op
->write(file_w
, msg
, strlen(msg
), &file_w
->f_pos
);
6916 sprintf(msg
, "\nDump all MAC values to %s\n", fileName
);
6918 filp_close(file_w
, NULL
);
6922 if(strlen(msg
) == 1)
6923 sprintf(msg
+strlen(msg
), "===>Error command format!");
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
);
6929 DBGPRINT(RT_DEBUG_TRACE
, ("<==RTMPIoctlMAC\n\n"));
6933 ==========================================================================
6937 pAdapter Pointer to our adapter
6938 wrq Pointer to the ioctl argument
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 ==========================================================================
6949 VOID
RTMPIoctlE2PROM(
6950 IN PRTMP_ADAPTER pAdapter
,
6951 IN
struct iwreq
*wrq
)
6963 BOOLEAN bIsPrintAllE2P
= FALSE
;
6966 memset(msg
, 0x00, 1024);
6967 if (wrq
->u
.data
.length
> 1) //No parameters.
6969 Status
= copy_from_user(arg
, wrq
->u
.data
.pointer
, (wrq
->u
.data
.length
> 255) ? 255 : wrq
->u
.data
.length
);
6972 //Parsing Read or Write
6979 if ((value
= rtstrchr(this_char
, '=')) != NULL
)
6982 if (!value
|| !*value
)
6986 if(strlen(this_char
) > 4)
6989 j
= strlen(this_char
);
6992 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
6997 k
= j
= strlen(this_char
);
7000 this_char
[4-k
+j
] = this_char
[j
];
7004 this_char
[3-k
++]='0';
7007 if(strlen(this_char
) == 4)
7009 AtoH(this_char
, temp
, 2);
7010 eepAddr
= *temp
*256 + temp
[1];
7011 if (eepAddr
< 0xFFFF)
7013 RT28xx_EEPROM_READ16(pAdapter
, eepAddr
, eepValue
);
7014 sprintf(msg
+strlen(msg
), "[0x%04X]:0x%04X ", eepAddr
, eepValue
);
7017 {//Invalid parametes, so default printk all bbp
7018 bIsPrintAllE2P
= TRUE
;
7025 memcpy(&temp2
, value
, strlen(value
));
7026 temp2
[strlen(value
)] = '\0';
7029 if((strlen(this_char
) > 4) || strlen(temp2
) > 8)
7032 j
= strlen(this_char
);
7035 if(this_char
[j
] > 'f' || this_char
[j
] < '0')
7041 if(temp2
[j
] > 'f' || temp2
[j
] < '0')
7046 k
= j
= strlen(this_char
);
7049 this_char
[4-k
+j
] = this_char
[j
];
7053 this_char
[3-k
++]='0';
7057 k
= j
= strlen(temp2
);
7060 temp2
[4-k
+j
] = temp2
[j
];
7067 AtoH(this_char
, temp
, 2);
7068 eepAddr
= *temp
*256 + temp
[1];
7070 AtoH(temp2
, temp
, 2);
7071 eepValue
= *temp
*256 + temp
[1];
7073 RT28xx_EEPROM_WRITE16(pAdapter
, eepAddr
, eepValue
);
7074 sprintf(msg
+strlen(msg
), "[0x%02X]:%02X ", eepAddr
, eepValue
);
7078 bIsPrintAllE2P
= TRUE
;
7082 struct file
*file_w
;
7083 PSTRING fileName
= "EEPROMDump.txt";
7084 mm_segment_t orig_fs
;
7090 file_w
= filp_open(fileName
, O_WRONLY
|O_CREAT
, 0);
7093 DBGPRINT(RT_DEBUG_TRACE
, ("-->2) %s: Error %ld opening %s\n", __FUNCTION__
, -PTR_ERR(file_w
), fileName
));
7097 if (file_w
->f_op
&& file_w
->f_op
->write
)
7102 while (eepAddr
<= 0xFE)
7104 RT28xx_EEPROM_READ16(pAdapter
, eepAddr
, eepValue
);
7105 sprintf(msg
, "%08x = %04x\n", eepAddr
, eepValue
);
7107 // write data to file
7108 file_w
->f_op
->write(file_w
, msg
, strlen(msg
), &file_w
->f_pos
);
7113 sprintf(msg
, "\nDump all EEPROM values to %s\n", fileName
);
7115 filp_close(file_w
, NULL
);
7119 if(strlen(msg
) == 1)
7120 sprintf(msg
+strlen(msg
), "===>Error command format!");
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
);
7127 DBGPRINT(RT_DEBUG_TRACE
, ("<==RTMPIoctlE2PROM\n"));
7133 ==========================================================================
7135 Read / Write RF register
7137 pAdapter Pointer to our adapter
7138 wrq Pointer to the ioctl argument
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 ==========================================================================
7151 IN PRTMP_ADAPTER pAdapter
,
7152 IN
struct iwreq
*wrq
)
7162 BOOLEAN bIsPrintAllRF
= FALSE
;
7165 memset(msg
, 0x00, 2048);
7166 if (wrq
->u
.data
.length
> 1) //No parameters.
7168 Status
= copy_from_user(arg
, wrq
->u
.data
.pointer
, (wrq
->u
.data
.length
> 255) ? 255 : wrq
->u
.data
.length
);
7171 //Parsing Read or Write
7176 if ((value
= strchr(this_char
, '=')) != NULL
)
7179 if (!value
|| !*value
)
7181 if (sscanf((PSTRING
) this_char
, "%d", &(rfId
)) == 1)
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.
7191 if (ATE_ON(pAdapter
))
7193 ATE_RF_IO_READ8_BY_REG_ID(pAdapter
, rfId
, ®RF
);
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
);
7202 sprintf(msg
+strlen(msg
), "R%02d[0x%02x]:%02X ", rfId
, rfId
, regRF
);
7205 {//Invalid parametes, so default printk all RF
7206 bIsPrintAllRF
= TRUE
;
7211 { //Invalid parametes, so default printk all RF
7212 bIsPrintAllRF
= TRUE
;
7218 if ((sscanf((PSTRING
) this_char
, "%d", &(rfId
)) == 1) && (sscanf((PSTRING
) value
, "%lx", &(rfValue
)) == 1))
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.
7228 if (ATE_ON(pAdapter
))
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
);
7237 #endif // RALINK_ATE //
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
);
7252 {//Invalid parametes, so default printk all RF
7253 bIsPrintAllRF
= TRUE
;
7257 { //Invalid parametes, so default printk all RF
7258 bIsPrintAllRF
= TRUE
;
7263 bIsPrintAllRF
= TRUE
;
7267 memset(msg
, 0x00, 2048);
7269 for (rfId
= 0; rfId
<= 31; rfId
++)
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.
7277 if (ATE_ON(pAdapter
))
7279 ATE_RF_IO_READ8_BY_REG_ID(pAdapter
, rfId
, ®RF
);
7282 #endif // RALINK_ATE //
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
);
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
))
7294 DBGPRINT(RT_DEBUG_TRACE
, ("%s: copy_to_user() fail\n", __FUNCTION__
));
7299 if(strlen(msg
) == 1)
7300 sprintf(msg
+strlen(msg
), "===>Error command format!");
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
)));
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
);
7311 DBGPRINT(RT_DEBUG_TRACE
, ("<==RTMPIoctlRF\n\n"));
7319 INT
Set_TGnWifiTest_Proc(
7320 IN PRTMP_ADAPTER pAd
,
7323 if (simple_strtol(arg
, 0, 10) == 0)
7324 pAd
->StaCfg
.bTGnWifiTest
= FALSE
;
7326 pAd
->StaCfg
.bTGnWifiTest
= TRUE
;
7328 DBGPRINT(RT_DEBUG_TRACE
, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd
->StaCfg
.bTGnWifiTest
));
7332 #ifdef EXT_BUILD_CHANNEL_LIST
7333 INT
Set_Ieee80211dClientMode_Proc(
7334 IN PRTMP_ADAPTER pAdapter
,
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
;
7346 DBGPRINT(RT_DEBUG_TRACE
, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter
->StaCfg
.IEEE80211dClientMode
));
7349 #endif // EXT_BUILD_CHANNEL_LIST //
7351 #ifdef CARRIER_DETECTION_SUPPORT
7352 INT
Set_CarrierDetect_Proc(
7353 IN PRTMP_ADAPTER pAd
,
7356 if (simple_strtol(arg
, 0, 10) == 0)
7357 pAd
->CommonCfg
.CarrierDetect
.Enable
= FALSE
;
7359 pAd
->CommonCfg
.CarrierDetect
.Enable
= TRUE
;
7361 DBGPRINT(RT_DEBUG_TRACE
, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd
->CommonCfg
.CarrierDetect
.Enable
));
7364 #endif // CARRIER_DETECTION_SUPPORT //
7367 INT
Show_Adhoc_MacTable_Proc(
7368 IN PRTMP_ADAPTER pAd
,
7373 sprintf(extra
, "\n");
7375 #ifdef DOT11_N_SUPPORT
7376 sprintf(extra
, "%sHT Operating Mode : %d\n", extra
, pAd
->CommonCfg
.AddHTInfo
.AddHtInfo2
.OperaionMode
);
7377 #endif // DOT11_N_SUPPORT //
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");
7382 for (i
=1; i
<MAX_LEN_OF_MAC_TABLE
; i
++)
7384 PMAC_TABLE_ENTRY pEntry
= &pAd
->MacTab
.Content
[i
];
7386 if (strlen(extra
) > (IW_PRIV_SIZE_MASK
- 30))
7388 if ((pEntry
->ValidAsCLI
|| pEntry
->ValidAsApCli
) && (pEntry
->Sst
== SST_ASSOC
))
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
);
7413 INT
Set_BeaconLostTime_Proc(
7414 IN PRTMP_ADAPTER pAd
,
7417 ULONG ltmp
= (ULONG
)simple_strtol(arg
, 0, 10);
7419 if ((ltmp
!= 0) && (ltmp
<= 60))
7420 pAd
->StaCfg
.BeaconLostTime
= (ltmp
* OS_HZ
);
7422 DBGPRINT(RT_DEBUG_TRACE
, ("IF Set_BeaconLostTime_Proc::(BeaconLostTime=%ld)\n", pAd
->StaCfg
.BeaconLostTime
));
7426 INT
Set_AutoRoaming_Proc(
7427 IN PRTMP_ADAPTER pAd
,
7430 if (simple_strtol(arg
, 0, 10) == 0)
7431 pAd
->StaCfg
.bAutoRoaming
= FALSE
;
7433 pAd
->StaCfg
.bAutoRoaming
= TRUE
;
7435 DBGPRINT(RT_DEBUG_TRACE
, ("IF Set_AutoRoaming_Proc::(bAutoRoaming=%d)\n", pAd
->StaCfg
.bAutoRoaming
));
7441 ==========================================================================
7443 Issue a site survey command to driver
7445 pAdapter Pointer to our adapter
7446 wrq Pointer to the ioctl argument
7453 1.) iwpriv ra0 set site_survey
7454 ==========================================================================
7456 INT
Set_SiteSurvey_Proc(
7457 IN PRTMP_ADAPTER pAd
,
7460 NDIS_802_11_SSID Ssid
;
7462 //check if the interface is down
7463 if (!RTMP_TEST_FLAG(pAd
, fRTMP_ADAPTER_INTERRUPT_IN_USE
))
7465 DBGPRINT(RT_DEBUG_TRACE
, ("INFO::Network is down!\n"));
7469 if (MONITOR_ON(pAd
))
7471 DBGPRINT(RT_DEBUG_TRACE
, ("!!! Driver is in Monitor Mode now !!!\n"));
7475 RTMPZeroMemory(&Ssid
, sizeof(NDIS_802_11_SSID
));
7476 Ssid
.SsidLength
= 0;
7477 if ((arg
!= NULL
) &&
7478 (strlen(arg
) <= MAX_LEN_OF_SSID
))
7480 RTMPMoveMemory(Ssid
.Ssid
, arg
, strlen(arg
));
7481 Ssid
.SsidLength
= strlen(arg
);
7484 pAd
->StaCfg
.bScanReqIsFromWebUI
= TRUE
;
7486 if (pAd
->Mlme
.CntlMachine
.CurrState
!= CNTL_IDLE
)
7488 RTMP_MLME_RESET_STATE_MACHINE(pAd
);
7489 DBGPRINT(RT_DEBUG_TRACE
, ("!!! MLME busy, reset MLME state machine !!!\n"));
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
);
7500 MLME_CNTL_STATE_MACHINE
,
7501 OID_802_11_BSSID_LIST_SCAN
,
7505 RTMP_MLME_HANDLER(pAd
);
7507 DBGPRINT(RT_DEBUG_TRACE
, ("Set_SiteSurvey_Proc\n"));
7512 INT
Set_ForceTxBurst_Proc(
7513 IN PRTMP_ADAPTER pAd
,
7516 if (simple_strtol(arg
, 0, 10) == 0)
7517 pAd
->StaCfg
.bForceTxBurst
= FALSE
;
7519 pAd
->StaCfg
.bForceTxBurst
= TRUE
;
7521 DBGPRINT(RT_DEBUG_TRACE
, ("IF Set_ForceTxBurst_Proc::(bForceTxBurst=%d)\n", pAd
->StaCfg
.bForceTxBurst
));
7525 #ifdef ANT_DIVERSITY_SUPPORT
7526 INT
Set_Antenna_Proc(
7527 IN PRTMP_ADAPTER pAd
,
7531 DBGPRINT(RT_DEBUG_TRACE
, ("==> Set_Antenna_Proc *******************\n"));
7533 if(simple_strtol(arg
, 0, 10) <= 3)
7534 UsedAnt
= simple_strtol(arg
, 0, 10);
7536 pAd
->CommonCfg
.bRxAntDiversity
= UsedAnt
; // Auto switch
7537 if (UsedAnt
== ANT_DIVERSITY_ENABLE
)
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
));
7542 /* 2: Fix in the PHY Antenna CON1*/
7543 if (UsedAnt
== ANT_FIX_ANT1
)
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
));
7548 /* 3: Fix in the PHY Antenna CON2*/
7549 if (UsedAnt
== ANT_FIX_ANT2
)
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
));
7557 #endif // ANT_DIVERSITY_SUPPORT //