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 extern UCHAR CipherWpa2Template[];
53 extern UCHAR CipherWpaPskTkip[];
54 extern UCHAR CipherWpaPskTkipLen;
56 typedef struct PACKED _RT_VERSION_INFO{
62 UINT DriverBuildMonth;
64 } RT_VERSION_INFO, *PRT_VERSION_INFO;
66 struct iw_priv_args privtab[] = {
68 IW_PRIV_TYPE_CHAR | 1024, 0,
71 { RTPRIV_IOCTL_SHOW, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
73 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
75 /* --- sub-ioctls definitions --- */
77 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
79 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "driverVer" },
81 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "bainfo" },
83 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "descinfo" },
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
88 #ifdef QOS_DLS_SUPPORT
89 { SHOW_DLS_ENTRY_INFO,
90 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
91 #endif // QOS_DLS_SUPPORT //
93 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
94 { SHOW_ADHOC_ENTRY_INFO,
95 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "adhocEntry" },
97 /* --- sub-ioctls relations --- */
101 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
104 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
107 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
111 { RTPRIV_IOCTL_STATISTICS,
112 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
114 { RTPRIV_IOCTL_GSITESURVEY,
115 0, IW_PRIV_TYPE_CHAR | 1024,
120 IN PRTMP_ADAPTER pAdapter,
124 INT Set_WmmCapable_Proc(
125 IN PRTMP_ADAPTER pAd,
129 INT Set_NetworkType_Proc(
130 IN PRTMP_ADAPTER pAdapter,
133 INT Set_AuthMode_Proc(
134 IN PRTMP_ADAPTER pAdapter,
137 INT Set_EncrypType_Proc(
138 IN PRTMP_ADAPTER pAdapter,
141 INT Set_DefaultKeyID_Proc(
142 IN PRTMP_ADAPTER pAdapter,
146 IN PRTMP_ADAPTER pAdapter,
150 IN PRTMP_ADAPTER pAdapter,
154 IN PRTMP_ADAPTER pAdapter,
158 IN PRTMP_ADAPTER pAdapter,
162 IN PRTMP_ADAPTER pAdapter,
167 IN PRTMP_ADAPTER pAdapter,
170 #ifdef WPA_SUPPLICANT_SUPPORT
172 IN PRTMP_ADAPTER pAd,
174 #endif // WPA_SUPPLICANT_SUPPORT //
178 IN PRTMP_ADAPTER pAdapter,
179 IN struct iwreq *wrq);
182 IN PRTMP_ADAPTER pAdapter,
183 IN struct iwreq *wrq);
185 VOID RTMPIoctlE2PROM(
186 IN PRTMP_ADAPTER pAdapter,
187 IN struct iwreq *wrq);
191 NDIS_STATUS RTMPWPANoneAddKeyProc(
192 IN PRTMP_ADAPTER pAd,
195 INT Set_FragTest_Proc(
196 IN PRTMP_ADAPTER pAdapter,
199 #ifdef DOT11_N_SUPPORT
200 INT Set_TGnWifiTest_Proc(
201 IN PRTMP_ADAPTER pAd,
203 #endif // DOT11_N_SUPPORT //
205 INT Set_LongRetryLimit_Proc(
206 IN PRTMP_ADAPTER pAdapter,
209 INT Set_ShortRetryLimit_Proc(
210 IN PRTMP_ADAPTER pAdapter,
213 #ifdef EXT_BUILD_CHANNEL_LIST
214 INT Set_Ieee80211dClientMode_Proc(
215 IN PRTMP_ADAPTER pAdapter,
217 #endif // EXT_BUILD_CHANNEL_LIST //
219 #ifdef CARRIER_DETECTION_SUPPORT
220 INT Set_CarrierDetect_Proc(
221 IN PRTMP_ADAPTER pAd,
223 #endif // CARRIER_DETECTION_SUPPORT //
225 INT Show_Adhoc_MacTable_Proc(
226 IN PRTMP_ADAPTER pAd,
231 INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
232 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
233 {"DriverVersion", Set_DriverVersion_Proc},
234 {"CountryRegion", Set_CountryRegion_Proc},
235 {"CountryRegionABand", Set_CountryRegionABand_Proc},
236 {"SSID", Set_SSID_Proc},
237 {"WirelessMode", Set_WirelessMode_Proc},
238 {"TxBurst", Set_TxBurst_Proc},
239 {"TxPreamble", Set_TxPreamble_Proc},
240 {"TxPower", Set_TxPower_Proc},
241 {"Channel", Set_Channel_Proc},
242 {"BGProtection", Set_BGProtection_Proc},
243 {"RTSThreshold", Set_RTSThreshold_Proc},
244 {"FragThreshold", Set_FragThreshold_Proc},
245 #ifdef DOT11_N_SUPPORT
246 {"HtBw", Set_HtBw_Proc},
247 {"HtMcs", Set_HtMcs_Proc},
248 {"HtGi", Set_HtGi_Proc},
249 {"HtOpMode", Set_HtOpMode_Proc},
250 {"HtExtcha", Set_HtExtcha_Proc},
251 {"HtMpduDensity", Set_HtMpduDensity_Proc},
252 {"HtBaWinSize", Set_HtBaWinSize_Proc},
253 {"HtRdg", Set_HtRdg_Proc},
254 {"HtAmsdu", Set_HtAmsdu_Proc},
255 {"HtAutoBa", Set_HtAutoBa_Proc},
256 {"HtBaDecline", Set_BADecline_Proc},
257 {"HtProtect", Set_HtProtect_Proc},
258 {"HtMimoPs", Set_HtMimoPs_Proc},
259 #endif // DOT11_N_SUPPORT //
261 #ifdef AGGREGATION_SUPPORT
262 {"PktAggregate", Set_PktAggregate_Proc},
266 {"WmmCapable", Set_WmmCapable_Proc},
268 {"IEEE80211H", Set_IEEE80211H_Proc},
269 {"NetworkType", Set_NetworkType_Proc},
270 {"AuthMode", Set_AuthMode_Proc},
271 {"EncrypType", Set_EncrypType_Proc},
272 {"DefaultKeyID", Set_DefaultKeyID_Proc},
273 {"Key1", Set_Key1_Proc},
274 {"Key2", Set_Key2_Proc},
275 {"Key3", Set_Key3_Proc},
276 {"Key4", Set_Key4_Proc},
277 {"WPAPSK", Set_WPAPSK_Proc},
278 {"ResetCounter", Set_ResetStatCounter_Proc},
279 {"PSMode", Set_PSMode_Proc},
281 {"Debug", Set_Debug_Proc},
284 #ifdef WPA_SUPPLICANT_SUPPORT
285 {"WpaSupport", Set_Wpa_Support},
286 #endif // WPA_SUPPLICANT_SUPPORT //
290 {"FixedTxMode", Set_FixedTxMode_Proc},
291 #ifdef DOT11_N_SUPPORT
292 {"TGnWifiTest", Set_TGnWifiTest_Proc},
293 {"ForceGF", Set_ForceGF_Proc},
294 #endif // DOT11_N_SUPPORT //
295 #ifdef QOS_DLS_SUPPORT
296 {"DlsAddEntry", Set_DlsAddEntry_Proc},
297 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
298 #endif // QOS_DLS_SUPPORT //
299 {"LongRetry", Set_LongRetryLimit_Proc},
300 {"ShortRetry", Set_ShortRetryLimit_Proc},
301 #ifdef EXT_BUILD_CHANNEL_LIST
302 {"11dClientMode", Set_Ieee80211dClientMode_Proc},
303 #endif // EXT_BUILD_CHANNEL_LIST //
304 #ifdef CARRIER_DETECTION_SUPPORT
305 {"CarrierDetect", Set_CarrierDetect_Proc},
306 #endif // CARRIER_DETECTION_SUPPORT //
313 IN PRTMP_ADAPTER pAd,
314 IN PNDIS_802_11_KEY pKey)
317 MAC_TABLE_ENTRY *pEntry;
319 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
321 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
323 if (pKey->KeyIndex & 0x80000000)
325 if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
327 NdisZeroMemory(pAd->StaCfg.PMK, 32);
328 NdisMoveMemory(pAd->StaCfg.PMK, pKey->KeyMaterial, pKey->KeyLength);
332 NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
333 pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
334 NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
335 #ifdef WPA_SUPPLICANT_SUPPORT
336 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
338 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
339 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
342 #endif // WPA_SUPPLICANT_SUPPORT //
344 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
345 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
348 // Decide its ChiperAlg
349 if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
350 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
351 else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
352 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
354 pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
356 // Update these related information to MAC_TABLE_ENTRY
357 pEntry = &pAd->MacTab.Content[BSSID_WCID];
358 NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
359 NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
360 NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
361 pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
363 // Update pairwise key information to ASIC Shared Key Table
364 AsicAddSharedKeyEntry(pAd,
367 pAd->SharedKey[BSS0][0].CipherAlg,
368 pAd->SharedKey[BSS0][0].Key,
369 pAd->SharedKey[BSS0][0].TxMic,
370 pAd->SharedKey[BSS0][0].RxMic);
372 // Update ASIC WCID attribute table and IVEIV table
373 RTMPAddWcidAttributeEntry(pAd,
376 pAd->SharedKey[BSS0][0].CipherAlg,
379 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
381 // set 802.1x port control
382 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
383 STA_PORT_SECURED(pAd);
385 // Indicate Connected for GUI
386 pAd->IndicateMediaState = NdisMediaStateConnected;
392 pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
393 NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
394 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
395 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
396 #ifdef WPA_SUPPLICANT_SUPPORT
397 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
399 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
400 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
403 #endif // WPA_SUPPLICANT_SUPPORT //
405 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
406 NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
409 // Update Shared Key CipherAlg
410 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;
411 if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
412 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;
413 else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
414 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
416 // Update group key information to ASIC Shared Key Table
417 AsicAddSharedKeyEntry(pAd,
419 pAd->StaCfg.DefaultKeyId,
420 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
421 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
422 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
423 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
425 // Update ASIC WCID attribute table and IVEIV table
426 RTMPAddWcidAttributeEntry(pAd,
428 pAd->StaCfg.DefaultKeyId,
429 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
432 // set 802.1x port control
433 //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
434 STA_PORT_SECURED(pAd);
436 // Indicate Connected for GUI
437 pAd->IndicateMediaState = NdisMediaStateConnected;
440 else // dynamic WEP from wpa_supplicant
445 if(pKey->KeyLength == 32)
448 KeyIdx = pKey->KeyIndex & 0x0fffffff;
452 // it is a default shared key, for Pairwise key setting
453 if (pKey->KeyIndex & 0x80000000)
455 pEntry = MacTableLookup(pAd, pKey->BSSID);
459 DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
461 // set key material and key length
462 pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
463 NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
466 if (pKey->KeyLength == 5)
467 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
469 pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
471 // Add Pair-wise key to Asic
472 AsicAddPairwiseKeyEntry(
476 &pEntry->PairwiseKey);
478 // update WCID attribute table and IVEIV table for this entry
479 RTMPAddWcidAttributeEntry(
482 KeyIdx, // The value may be not zero
483 pEntry->PairwiseKey.CipherAlg,
490 // Default key for tx (shared key)
491 pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
493 // set key material and key length
494 pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
495 NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
498 if (pKey->KeyLength == 5)
499 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
501 pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
503 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
504 Key = pAd->SharedKey[BSS0][KeyIdx].Key;
506 // Set Group key material to Asic
507 AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
509 // Update WCID attribute table and IVEIV table for this group key table
510 RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
519 char * rtstrchr(const char * s, int c)
521 for(; *s != (char) c; ++s)
528 This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
532 rt_ioctl_giwname(struct net_device *dev,
533 struct iw_request_info *info,
534 char *name, char *extra)
536 // PRTMP_ADAPTER pAdapter = dev->ml_priv;
539 strncpy(name, "RT2870 Wireless", IFNAMSIZ);
544 int rt_ioctl_siwfreq(struct net_device *dev,
545 struct iw_request_info *info,
546 struct iw_freq *freq, char *extra)
548 PRTMP_ADAPTER pAdapter = dev->ml_priv;
551 //check if the interface is down
552 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
554 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
562 if((freq->e == 0) && (freq->m <= 1000))
563 chan = freq->m; // Setting by channel number
565 MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
567 if (ChannelSanity(pAdapter, chan) == TRUE)
569 pAdapter->CommonCfg.Channel = chan;
570 DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
577 int rt_ioctl_giwfreq(struct net_device *dev,
578 struct iw_request_info *info,
579 struct iw_freq *freq, char *extra)
581 VIRTUAL_ADAPTER *pVirtualAd = NULL;
582 PRTMP_ADAPTER pAdapter = NULL;
586 if (dev->priv_flags == INT_MAIN)
588 pAdapter = dev->ml_priv;
592 pVirtualAd = dev->ml_priv;
593 if (pVirtualAd && pVirtualAd->RtmpDev)
594 pAdapter = pVirtualAd->RtmpDev->ml_priv;
597 if (pAdapter == NULL)
599 /* if 1st open fail, pAd will be free;
600 So the net_dev->ml_priv will be NULL in 2rd open */
604 ch = pAdapter->CommonCfg.Channel;
606 DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq %d\n", ch));
608 MAP_CHANNEL_ID_TO_KHZ(ch, m);
614 int rt_ioctl_siwmode(struct net_device *dev,
615 struct iw_request_info *info,
616 __u32 *mode, char *extra)
618 PRTMP_ADAPTER pAdapter = dev->ml_priv;
620 //check if the interface is down
621 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
623 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
630 Set_NetworkType_Proc(pAdapter, "Adhoc");
633 Set_NetworkType_Proc(pAdapter, "Infra");
635 case IW_MODE_MONITOR:
636 Set_NetworkType_Proc(pAdapter, "Monitor");
639 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
643 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
644 pAdapter->StaCfg.WpaState = SS_NOTUSE;
649 int rt_ioctl_giwmode(struct net_device *dev,
650 struct iw_request_info *info,
651 __u32 *mode, char *extra)
653 PRTMP_ADAPTER pAdapter = NULL;
654 VIRTUAL_ADAPTER *pVirtualAd = NULL;
656 if (dev->priv_flags == INT_MAIN)
658 pAdapter = dev->ml_priv;
662 pVirtualAd = dev->ml_priv;
663 if (pVirtualAd && pVirtualAd->RtmpDev)
664 pAdapter = pVirtualAd->RtmpDev->ml_priv;
667 if (pAdapter == NULL)
669 /* if 1st open fail, pAd will be free;
670 So the net_dev->ml_priv will be NULL in 2rd open */
674 if (ADHOC_ON(pAdapter))
675 *mode = IW_MODE_ADHOC;
676 else if (INFRA_ON(pAdapter))
677 *mode = IW_MODE_INFRA;
678 else if (MONITOR_ON(pAdapter))
680 *mode = IW_MODE_MONITOR;
683 *mode = IW_MODE_AUTO;
685 DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
689 int rt_ioctl_siwsens(struct net_device *dev,
690 struct iw_request_info *info,
691 char *name, char *extra)
693 PRTMP_ADAPTER pAdapter = dev->ml_priv;
695 //check if the interface is down
696 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
698 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
705 int rt_ioctl_giwsens(struct net_device *dev,
706 struct iw_request_info *info,
707 char *name, char *extra)
712 int rt_ioctl_giwrange(struct net_device *dev,
713 struct iw_request_info *info,
714 struct iw_point *data, char *extra)
716 PRTMP_ADAPTER pAdapter = NULL;
717 VIRTUAL_ADAPTER *pVirtualAd = NULL;
718 struct iw_range *range = (struct iw_range *) extra;
722 if (dev->priv_flags == INT_MAIN)
724 pAdapter = dev->ml_priv;
728 pVirtualAd = dev->ml_priv;
729 if (pVirtualAd && pVirtualAd->RtmpDev)
730 pAdapter = pVirtualAd->RtmpDev->ml_priv;
733 if (pAdapter == NULL)
735 /* if 1st open fail, pAd will be free;
736 So the net_dev->ml_priv will be NULL in 2rd open */
740 DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));
741 data->length = sizeof(struct iw_range);
742 memset(range, 0, sizeof(struct iw_range));
744 range->txpower_capa = IW_TXPOW_DBM;
746 if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))
748 range->min_pmp = 1 * 1024;
749 range->max_pmp = 65535 * 1024;
750 range->min_pmt = 1 * 1024;
751 range->max_pmt = 1000 * 1024;
752 range->pmp_flags = IW_POWER_PERIOD;
753 range->pmt_flags = IW_POWER_TIMEOUT;
754 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
755 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
758 range->we_version_compiled = WIRELESS_EXT;
759 range->we_version_source = 14;
761 range->retry_capa = IW_RETRY_LIMIT;
762 range->retry_flags = IW_RETRY_LIMIT;
763 range->min_retry = 0;
764 range->max_retry = 255;
766 range->num_channels = pAdapter->ChannelListNum;
769 for (i = 1; i <= range->num_channels; i++)
772 range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
773 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
774 range->freq[val].m = m * 100; /* HZ */
776 range->freq[val].e = 1;
778 if (val == IW_MAX_FREQUENCIES)
781 range->num_frequency = val;
783 range->max_qual.qual = 100; /* what is correct max? This was not
784 * documented exactly. At least
785 * 69 has been observed. */
786 range->max_qual.level = 0; /* dB */
787 range->max_qual.noise = 0; /* dB */
789 /* What would be suitable values for "average/typical" qual? */
790 range->avg_qual.qual = 20;
791 range->avg_qual.level = -60;
792 range->avg_qual.noise = -95;
793 range->sensitivity = 3;
795 range->max_encoding_tokens = NR_WEP_KEYS;
796 range->num_encoding_sizes = 2;
797 range->encoding_size[0] = 5;
798 range->encoding_size[1] = 13;
801 range->max_rts = 2347;
802 range->min_frag = 256;
803 range->max_frag = 2346;
805 #if WIRELESS_EXT > 17
806 /* IW_ENC_CAPA_* bit field */
807 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
808 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
814 int rt_ioctl_siwap(struct net_device *dev,
815 struct iw_request_info *info,
816 struct sockaddr *ap_addr, char *extra)
818 PRTMP_ADAPTER pAdapter = dev->ml_priv;
819 NDIS_802_11_MAC_ADDRESS Bssid;
821 //check if the interface is down
822 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
824 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
828 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
830 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
831 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
834 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
835 // this request, because this request is initiated by NDIS.
836 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
837 // Prevent to connect AP again in STAMlmePeriodicExec
838 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
840 memset(Bssid, 0, MAC_ADDR_LEN);
841 memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
842 MlmeEnqueue(pAdapter,
843 MLME_CNTL_STATE_MACHINE,
845 sizeof(NDIS_802_11_MAC_ADDRESS),
848 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
849 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
854 int rt_ioctl_giwap(struct net_device *dev,
855 struct iw_request_info *info,
856 struct sockaddr *ap_addr, char *extra)
858 PRTMP_ADAPTER pAdapter = NULL;
859 VIRTUAL_ADAPTER *pVirtualAd = NULL;
861 if (dev->priv_flags == INT_MAIN)
863 pAdapter = dev->ml_priv;
867 pVirtualAd = dev->ml_priv;
868 if (pVirtualAd && pVirtualAd->RtmpDev)
869 pAdapter = pVirtualAd->RtmpDev->ml_priv;
872 if (pAdapter == NULL)
874 /* if 1st open fail, pAd will be free;
875 So the net_dev->ml_priv will be NULL in 2rd open */
879 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
881 ap_addr->sa_family = ARPHRD_ETHER;
882 memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
884 #ifdef WPA_SUPPLICANT_SUPPORT
886 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
888 ap_addr->sa_family = ARPHRD_ETHER;
889 memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
891 #endif // WPA_SUPPLICANT_SUPPORT //
894 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
902 * Units are in db above the noise floor. That means the
903 * rssi values reported in the tx/rx descriptors in the
904 * driver are the SNR expressed in db.
906 * If you assume that the noise floor is -95, which is an
907 * excellent assumption 99.5 % of the time, then you can
908 * derive the absolute signal level (i.e. -95 + rssi).
909 * There are some other slight factors to take into account
910 * depending on whether the rssi measurement is from 11b,
911 * 11g, or 11a. These differences are at most 2db and
914 * NB: various calculations are based on the orinoco/wavelan
915 * drivers for compatibility
917 static void set_quality(PRTMP_ADAPTER pAdapter,
918 struct iw_quality *iq,
925 ChannelQuality = 100;
926 else if (rssi >= -80) // between -50 ~ -80dbm
927 ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
928 else if (rssi >= -90) // between -80 ~ -90dbm
929 ChannelQuality = (__u8)((rssi + 90) * 26)/10;
933 iq->qual = (__u8)ChannelQuality;
935 iq->level = (__u8)(rssi);
936 iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); // noise level (dBm)
937 iq->noise += 256 - 143;
938 iq->updated = pAdapter->iw_stats.qual.updated;
941 int rt_ioctl_iwaplist(struct net_device *dev,
942 struct iw_request_info *info,
943 struct iw_point *data, char *extra)
945 PRTMP_ADAPTER pAdapter = dev->ml_priv;
947 struct sockaddr addr[IW_MAX_AP];
948 struct iw_quality qual[IW_MAX_AP];
951 //check if the interface is down
952 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
954 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
960 for (i = 0; i <IW_MAX_AP ; i++)
962 if (i >= pAdapter->ScanTab.BssNr)
964 addr[i].sa_family = ARPHRD_ETHER;
965 memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
966 set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
969 memcpy(extra, &addr, i*sizeof(addr[0]));
970 data->flags = 1; /* signal quality present (sort of) */
971 memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
977 int rt_ioctl_siwscan(struct net_device *dev,
978 struct iw_request_info *info,
979 struct iw_point *data, char *extra)
981 PRTMP_ADAPTER pAdapter = dev->ml_priv;
984 int Status = NDIS_STATUS_SUCCESS;
986 //check if the interface is down
987 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
989 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
993 if (MONITOR_ON(pAdapter))
995 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
1000 #ifdef WPA_SUPPLICANT_SUPPORT
1001 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1003 pAdapter->StaCfg.WpaSupplicantScanCount++;
1005 #endif // WPA_SUPPLICANT_SUPPORT //
1007 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
1008 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1013 #ifdef WPA_SUPPLICANT_SUPPORT
1014 if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
1015 (pAdapter->StaCfg.WpaSupplicantScanCount > 3))
1017 DBGPRINT(RT_DEBUG_TRACE, ("!!! WpaSupplicantScanCount > 3\n"));
1018 Status = NDIS_STATUS_SUCCESS;
1021 #endif // WPA_SUPPLICANT_SUPPORT //
1023 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
1024 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
1025 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
1026 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
1028 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
1029 Status = NDIS_STATUS_SUCCESS;
1033 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
1035 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
1036 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
1039 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
1040 // this request, because this request is initiated by NDIS.
1041 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
1042 // Reset allowed scan retries
1043 pAdapter->StaCfg.ScanCnt = 0;
1044 pAdapter->StaCfg.LastScanTime = Now;
1046 MlmeEnqueue(pAdapter,
1047 MLME_CNTL_STATE_MACHINE,
1048 OID_802_11_BSSID_LIST_SCAN,
1052 Status = NDIS_STATUS_SUCCESS;
1053 RT28XX_MLME_HANDLER(pAdapter);
1058 int rt_ioctl_giwscan(struct net_device *dev,
1059 struct iw_request_info *info,
1060 struct iw_point *data, char *extra)
1063 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1065 char *current_ev = extra, *previous_ev = extra;
1067 char *current_val, custom[MAX_CUSTOM_LEN] = {0};
1070 #endif // IWEVGENIE //
1071 struct iw_event iwe;
1073 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
1076 * Still scanning, indicate the caller should try again.
1082 #ifdef WPA_SUPPLICANT_SUPPORT
1083 if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
1085 pAdapter->StaCfg.WpaSupplicantScanCount = 0;
1087 #endif // WPA_SUPPLICANT_SUPPORT //
1089 if (pAdapter->ScanTab.BssNr == 0)
1095 #if WIRELESS_EXT >= 17
1096 if (data->length > 0)
1097 end_buf = extra + data->length;
1099 end_buf = extra + IW_SCAN_MAX_DATA;
1101 end_buf = extra + IW_SCAN_MAX_DATA;
1104 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
1106 if (current_ev >= end_buf)
1108 #if WIRELESS_EXT >= 17
1116 //================================
1117 memset(&iwe, 0, sizeof(iwe));
1118 iwe.cmd = SIOCGIWAP;
1119 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1120 memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
1122 previous_ev = current_ev;
1123 current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
1124 if (current_ev == previous_ev)
1125 #if WIRELESS_EXT >= 17
1132 //================================
1133 memset(&iwe, 0, sizeof(iwe));
1134 iwe.cmd = SIOCGIWESSID;
1135 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
1136 iwe.u.data.flags = 1;
1138 previous_ev = current_ev;
1139 current_ev = iwe_stream_add_point(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
1140 if (current_ev == previous_ev)
1141 #if WIRELESS_EXT >= 17
1148 //================================
1149 memset(&iwe, 0, sizeof(iwe));
1150 iwe.cmd = SIOCGIWMODE;
1151 if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
1153 iwe.u.mode = IW_MODE_ADHOC;
1155 else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
1157 iwe.u.mode = IW_MODE_INFRA;
1161 iwe.u.mode = IW_MODE_AUTO;
1163 iwe.len = IW_EV_UINT_LEN;
1165 previous_ev = current_ev;
1166 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
1167 if (current_ev == previous_ev)
1168 #if WIRELESS_EXT >= 17
1174 //Channel and Frequency
1175 //================================
1176 memset(&iwe, 0, sizeof(iwe));
1177 iwe.cmd = SIOCGIWFREQ;
1178 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
1179 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1181 iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
1185 previous_ev = current_ev;
1186 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
1187 if (current_ev == previous_ev)
1188 #if WIRELESS_EXT >= 17
1194 //Add quality statistics
1195 //================================
1196 memset(&iwe, 0, sizeof(iwe));
1198 iwe.u.qual.level = 0;
1199 iwe.u.qual.noise = 0;
1200 set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi);
1201 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
1202 if (current_ev == previous_ev)
1203 #if WIRELESS_EXT >= 17
1210 //================================
1211 memset(&iwe, 0, sizeof(iwe));
1212 iwe.cmd = SIOCGIWENCODE;
1213 if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo ))
1214 iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1216 iwe.u.data.flags = IW_ENCODE_DISABLED;
1218 previous_ev = current_ev;
1219 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);
1220 if (current_ev == previous_ev)
1221 #if WIRELESS_EXT >= 17
1228 //================================
1229 if (pAdapter->ScanTab.BssEntry[i].SupRateLen)
1231 UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
1232 memset(&iwe, 0, sizeof(iwe));
1233 iwe.cmd = SIOCGIWRATE;
1234 current_val = current_ev + IW_EV_LCP_LEN;
1235 if (tmpRate == 0x82)
1236 iwe.u.bitrate.value = 1 * 1000000;
1237 else if (tmpRate == 0x84)
1238 iwe.u.bitrate.value = 2 * 1000000;
1239 else if (tmpRate == 0x8B)
1240 iwe.u.bitrate.value = 5.5 * 1000000;
1241 else if (tmpRate == 0x96)
1242 iwe.u.bitrate.value = 11 * 1000000;
1244 iwe.u.bitrate.value = (tmpRate/2) * 1000000;
1246 iwe.u.bitrate.disabled = 0;
1247 current_val = iwe_stream_add_value(info, current_ev,
1248 current_val, end_buf, &iwe,
1251 if((current_val-current_ev)>IW_EV_LCP_LEN)
1252 current_ev = current_val;
1254 #if WIRELESS_EXT >= 17
1263 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1265 memset(&iwe, 0, sizeof(iwe));
1266 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1267 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
1268 pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
1269 iwe.cmd = IWEVGENIE;
1270 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
1271 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1272 if (current_ev == previous_ev)
1273 #if WIRELESS_EXT >= 17
1281 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1283 memset(&iwe, 0, sizeof(iwe));
1284 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1285 memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
1286 pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
1287 iwe.cmd = IWEVGENIE;
1288 iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
1289 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, custom);
1290 if (current_ev == previous_ev)
1291 #if WIRELESS_EXT >= 17
1299 //================================
1300 if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
1302 NdisZeroMemory(&iwe, sizeof(iwe));
1303 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1304 iwe.cmd = IWEVCUSTOM;
1305 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
1306 NdisMoveMemory(custom, "wpa_ie=", 7);
1307 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
1308 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
1309 previous_ev = current_ev;
1310 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1311 if (current_ev == previous_ev)
1312 #if WIRELESS_EXT >= 17
1320 if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0)
1322 NdisZeroMemory(&iwe, sizeof(iwe));
1323 memset(&custom[0], 0, MAX_CUSTOM_LEN);
1324 iwe.cmd = IWEVCUSTOM;
1325 iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
1326 NdisMoveMemory(custom, "rsn_ie=", 7);
1327 for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
1328 sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
1329 previous_ev = current_ev;
1330 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom);
1331 if (current_ev == previous_ev)
1332 #if WIRELESS_EXT >= 17
1338 #endif // IWEVGENIE //
1341 data->length = current_ev - extra;
1342 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
1343 DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length));
1348 int rt_ioctl_siwessid(struct net_device *dev,
1349 struct iw_request_info *info,
1350 struct iw_point *data, char *essid)
1352 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1354 //check if the interface is down
1355 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1357 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1363 PCHAR pSsidString = NULL;
1365 // Includes null character.
1366 if (data->length > (IW_ESSID_MAX_SIZE + 1))
1369 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
1372 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
1373 NdisMoveMemory(pSsidString, essid, data->length);
1374 if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
1383 if (Set_SSID_Proc(pAdapter, "") == FALSE)
1389 int rt_ioctl_giwessid(struct net_device *dev,
1390 struct iw_request_info *info,
1391 struct iw_point *data, char *essid)
1393 PRTMP_ADAPTER pAdapter = NULL;
1394 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1396 if (dev->priv_flags == INT_MAIN)
1398 pAdapter = dev->ml_priv;
1402 pVirtualAd = dev->ml_priv;
1403 if (pVirtualAd && pVirtualAd->RtmpDev)
1404 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1407 if (pAdapter == NULL)
1409 /* if 1st open fail, pAd will be free;
1410 So the net_dev->ml_priv will be NULL in 2rd open */
1415 if (MONITOR_ON(pAdapter))
1421 if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
1423 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n"));
1424 data->length = pAdapter->CommonCfg.SsidLen;
1425 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1428 #ifdef WPA_SUPPLICANT_SUPPORT
1430 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
1432 data->length = pAdapter->CommonCfg.SsidLen;
1433 memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen);
1435 #endif // WPA_SUPPLICANT_SUPPORT //
1438 {//the ANY ssid was specified
1440 DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n"));
1447 int rt_ioctl_siwnickn(struct net_device *dev,
1448 struct iw_request_info *info,
1449 struct iw_point *data, char *nickname)
1451 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1453 //check if the interface is down
1454 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1456 DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
1460 if (data->length > IW_ESSID_MAX_SIZE)
1463 memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
1464 memcpy(pAdapter->nickname, nickname, data->length);
1470 int rt_ioctl_giwnickn(struct net_device *dev,
1471 struct iw_request_info *info,
1472 struct iw_point *data, char *nickname)
1474 PRTMP_ADAPTER pAdapter = NULL;
1475 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1477 if (dev->priv_flags == INT_MAIN)
1479 pAdapter = dev->ml_priv;
1483 pVirtualAd = dev->ml_priv;
1484 if (pVirtualAd && pVirtualAd->RtmpDev)
1485 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1488 if (pAdapter == NULL)
1490 /* if 1st open fail, pAd will be free;
1491 So the net_dev->ml_priv will be NULL in 2rd open */
1495 if (data->length > strlen(pAdapter->nickname) + 1)
1496 data->length = strlen(pAdapter->nickname) + 1;
1497 if (data->length > 0) {
1498 memcpy(nickname, pAdapter->nickname, data->length-1);
1499 nickname[data->length-1] = '\0';
1504 int rt_ioctl_siwrts(struct net_device *dev,
1505 struct iw_request_info *info,
1506 struct iw_param *rts, char *extra)
1508 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1511 //check if the interface is down
1512 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1514 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1519 val = MAX_RTS_THRESHOLD;
1520 else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
1522 else if (rts->value == 0)
1523 val = MAX_RTS_THRESHOLD;
1527 if (val != pAdapter->CommonCfg.RtsThreshold)
1528 pAdapter->CommonCfg.RtsThreshold = val;
1533 int rt_ioctl_giwrts(struct net_device *dev,
1534 struct iw_request_info *info,
1535 struct iw_param *rts, char *extra)
1537 PRTMP_ADAPTER pAdapter = NULL;
1538 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1540 if (dev->priv_flags == INT_MAIN)
1542 pAdapter = dev->ml_priv;
1546 pVirtualAd = dev->ml_priv;
1547 if (pVirtualAd && pVirtualAd->RtmpDev)
1548 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1551 if (pAdapter == NULL)
1553 /* if 1st open fail, pAd will be free;
1554 So the net_dev->ml_priv will be NULL in 2rd open */
1558 //check if the interface is down
1559 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1561 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1565 rts->value = pAdapter->CommonCfg.RtsThreshold;
1566 rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
1572 int rt_ioctl_siwfrag(struct net_device *dev,
1573 struct iw_request_info *info,
1574 struct iw_param *frag, char *extra)
1576 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1579 //check if the interface is down
1580 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1582 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1587 val = MAX_FRAG_THRESHOLD;
1588 else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD)
1589 val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */
1590 else if (frag->value == 0)
1591 val = MAX_FRAG_THRESHOLD;
1595 pAdapter->CommonCfg.FragmentThreshold = val;
1599 int rt_ioctl_giwfrag(struct net_device *dev,
1600 struct iw_request_info *info,
1601 struct iw_param *frag, char *extra)
1603 PRTMP_ADAPTER pAdapter = NULL;
1604 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1606 if (dev->priv_flags == INT_MAIN)
1608 pAdapter = dev->ml_priv;
1612 pVirtualAd = dev->ml_priv;
1613 if (pVirtualAd && pVirtualAd->RtmpDev)
1614 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1617 if (pAdapter == NULL)
1619 /* if 1st open fail, pAd will be free;
1620 So the net_dev->ml_priv will be NULL in 2rd open */
1624 //check if the interface is down
1625 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1627 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1631 frag->value = pAdapter->CommonCfg.FragmentThreshold;
1632 frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
1638 #define MAX_WEP_KEY_SIZE 13
1639 #define MIN_WEP_KEY_SIZE 5
1640 int rt_ioctl_siwencode(struct net_device *dev,
1641 struct iw_request_info *info,
1642 struct iw_point *erq, char *extra)
1644 PRTMP_ADAPTER pAdapter = dev->ml_priv;
1646 //check if the interface is down
1647 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1649 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1653 if ((erq->length == 0) &&
1654 (erq->flags & IW_ENCODE_DISABLED))
1656 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
1657 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
1658 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
1659 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1660 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1663 else if ((erq->length == 0) &&
1664 (erq->flags & IW_ENCODE_RESTRICTED || erq->flags & IW_ENCODE_OPEN))
1666 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
1667 STA_PORT_SECURED(pAdapter);
1668 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
1669 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
1670 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
1671 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
1672 if (erq->flags & IW_ENCODE_RESTRICTED)
1673 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
1675 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
1679 if (erq->length > 0)
1681 int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
1682 /* Check the size of the key */
1683 if (erq->length > MAX_WEP_KEY_SIZE) {
1686 /* Check key index */
1687 if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
1689 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
1690 keyIdx, pAdapter->StaCfg.DefaultKeyId));
1693 keyIdx = pAdapter->StaCfg.DefaultKeyId;
1696 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
1698 if (erq->length == MAX_WEP_KEY_SIZE)
1700 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
1701 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
1703 else if (erq->length == MIN_WEP_KEY_SIZE)
1705 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
1706 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
1709 /* Disable the key */
1710 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
1712 /* Check if the key is not marked as invalid */
1713 if(!(erq->flags & IW_ENCODE_NOKEY)) {
1714 /* Copy the key in the driver */
1715 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
1720 /* Do we want to just set the transmit key index ? */
1721 int index = (erq->flags & IW_ENCODE_INDEX) - 1;
1722 if ((index >= 0) && (index < 4))
1724 pAdapter->StaCfg.DefaultKeyId = index;
1727 /* Don't complain if only change the mode */
1728 if (!(erq->flags & IW_ENCODE_MODE)) {
1734 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
1735 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
1736 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",pAdapter->StaCfg.DefaultKeyId , pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen));
1737 DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::WepStatus=%x\n",pAdapter->StaCfg.WepStatus));
1742 rt_ioctl_giwencode(struct net_device *dev,
1743 struct iw_request_info *info,
1744 struct iw_point *erq, char *key)
1747 PRTMP_ADAPTER pAdapter = NULL;
1748 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1750 if (dev->priv_flags == INT_MAIN)
1752 pAdapter = dev->ml_priv;
1756 pVirtualAd = dev->ml_priv;
1757 if (pVirtualAd && pVirtualAd->RtmpDev)
1758 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1761 if (pAdapter == NULL)
1763 /* if 1st open fail, pAd will be free;
1764 So the net_dev->ml_priv will be NULL in 2rd open */
1768 //check if the interface is down
1769 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1771 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1775 kid = erq->flags & IW_ENCODE_INDEX;
1776 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
1778 if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled)
1781 erq->flags = IW_ENCODE_DISABLED;
1783 else if ((kid > 0) && (kid <=4))
1786 erq->flags = kid ; /* NB: base 1 */
1787 if (erq->length > pAdapter->SharedKey[BSS0][kid-1].KeyLen)
1788 erq->length = pAdapter->SharedKey[BSS0][kid-1].KeyLen;
1789 memcpy(key, pAdapter->SharedKey[BSS0][kid-1].Key, erq->length);
1790 //if ((kid == pAdapter->PortCfg.DefaultKeyId))
1791 //erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1792 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1793 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1795 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1800 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1801 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1803 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1804 erq->length = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
1805 memcpy(key, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, erq->length);
1806 // copy default key ID
1807 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
1808 erq->flags |= IW_ENCODE_RESTRICTED; /* XXX */
1810 erq->flags |= IW_ENCODE_OPEN; /* XXX */
1811 erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
1812 erq->flags |= IW_ENCODE_ENABLED; /* XXX */
1820 rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
1821 void *w, char *extra)
1823 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1824 PRTMP_ADAPTER pAdapter;
1826 char *this_char = extra;
1830 if (dev->priv_flags == INT_MAIN)
1832 pAdapter = dev->ml_priv;
1836 pVirtualAd = dev->ml_priv;
1837 pAdapter = pVirtualAd->RtmpDev->ml_priv;
1839 pObj = (POS_COOKIE) pAdapter->OS_Cookie;
1841 if (pAdapter == NULL)
1843 /* if 1st open fail, pAd will be free;
1844 So the net_dev->ml_priv will be NULL in 2rd open */
1849 pObj->ioctl_if_type = INT_MAIN;
1850 pObj->ioctl_if = MAIN_MBSSID;
1853 //check if the interface is down
1854 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
1856 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
1863 if ((value = rtstrchr(this_char, '=')) != NULL)
1869 // reject setting nothing besides ANY ssid(ssidLen=0)
1870 if (!*value && (strcmp(this_char, "SSID") != 0))
1873 for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
1875 if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
1877 if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
1878 { //FALSE:Set private failed then return Invalid argument
1881 break; //Exit for loop.
1885 if(PRTMP_PRIVATE_SET_PROC->name == NULL)
1886 { //Not found argument
1888 DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
1896 rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
1897 struct iw_point *wrq, char *extra)
1900 PRTMP_ADAPTER pAd = dev->ml_priv;
1908 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
1909 sprintf(extra, "\n\n");
1912 sprintf(extra+strlen(extra), "Tx success = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart);
1913 sprintf(extra+strlen(extra), "Tx success without retry = %ld\n", (ULONG)pAd->WlanCounters.TransmittedFragmentCount.QuadPart - (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1915 sprintf(extra+strlen(extra), "Tx success after retry = %ld\n", (ULONG)pAd->WlanCounters.RetryCount.QuadPart);
1916 sprintf(extra+strlen(extra), "Tx fail to Rcv ACK after retry = %ld\n", (ULONG)pAd->WlanCounters.FailedCount.QuadPart);
1917 sprintf(extra+strlen(extra), "RTS Success Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSSuccessCount.QuadPart);
1918 sprintf(extra+strlen(extra), "RTS Fail Rcv CTS = %ld\n", (ULONG)pAd->WlanCounters.RTSFailureCount.QuadPart);
1920 sprintf(extra+strlen(extra), "Rx success = %ld\n", (ULONG)pAd->WlanCounters.ReceivedFragmentCount.QuadPart);
1921 sprintf(extra+strlen(extra), "Rx with CRC = %ld\n", (ULONG)pAd->WlanCounters.FCSErrorCount.QuadPart);
1922 sprintf(extra+strlen(extra), "Rx drop due to out of resource = %ld\n", (ULONG)pAd->Counters8023.RxNoBuffer);
1923 sprintf(extra+strlen(extra), "Rx duplicate frame = %ld\n", (ULONG)pAd->WlanCounters.FrameDuplicateCount.QuadPart);
1925 sprintf(extra+strlen(extra), "False CCA (one second) = %ld\n", (ULONG)pAd->RalinkCounters.OneSecFalseCCACnt);
1927 sprintf(extra+strlen(extra), "RSSI-A = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
1928 sprintf(extra+strlen(extra), "RSSI-B (if available) = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
1929 sprintf(extra+strlen(extra), "RSSI-C (if available) = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
1931 #ifdef WPA_SUPPLICANT_SUPPORT
1932 sprintf(extra+strlen(extra), "WpaSupplicantUP = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
1933 #endif // WPA_SUPPLICANT_SUPPORT //
1936 wrq->length = strlen(extra) + 1; // 1: size of '\0'
1937 DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
1942 #ifdef DOT11_N_SUPPORT
1944 IN PRTMP_ADAPTER pAd,
1948 BA_ORI_ENTRY *pOriBAEntry;
1949 BA_REC_ENTRY *pRecBAEntry;
1951 for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
1953 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
1954 if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
1955 || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
1957 sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
1958 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
1959 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
1961 sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
1962 for (j=0; j < NUM_OF_TID; j++)
1964 if (pEntry->BARecWcidArray[j] != 0)
1966 pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
1967 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
1970 sprintf(pOutBuf, "%s\n", pOutBuf);
1972 sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
1973 for (j=0; j < NUM_OF_TID; j++)
1975 if (pEntry->BAOriWcidArray[j] != 0)
1977 pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
1978 sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
1981 sprintf(pOutBuf, "%s\n\n", pOutBuf);
1983 if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
1989 #endif // DOT11_N_SUPPORT //
1992 rt_private_show(struct net_device *dev, struct iw_request_info *info,
1993 struct iw_point *wrq, char *extra)
1996 VIRTUAL_ADAPTER *pVirtualAd = NULL;
1999 u32 subcmd = wrq->flags;
2001 if (dev->priv_flags == INT_MAIN)
2005 pVirtualAd = dev->ml_priv;
2006 pAd = pVirtualAd->RtmpDev->ml_priv;
2008 pObj = (POS_COOKIE) pAd->OS_Cookie;
2012 /* if 1st open fail, pAd will be free;
2013 So the net_dev->ml_priv will be NULL in 2rd open */
2022 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2025 pObj->ioctl_if_type = INT_MAIN;
2026 pObj->ioctl_if = MAIN_MBSSID;
2032 case SHOW_CONN_STATUS:
2033 if (MONITOR_ON(pAd))
2035 #ifdef DOT11_N_SUPPORT
2036 if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
2037 pAd->CommonCfg.RegTransmitSetting.field.BW)
2038 sprintf(extra, "Monitor Mode(CentralChannel %d)\n", pAd->CommonCfg.CentralChannel);
2040 #endif // DOT11_N_SUPPORT //
2041 sprintf(extra, "Monitor Mode(Channel %d)\n", pAd->CommonCfg.Channel);
2045 if (pAd->IndicateMediaState == NdisMediaStateConnected)
2049 sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
2050 pAd->CommonCfg.Ssid,
2051 pAd->CommonCfg.Bssid[0],
2052 pAd->CommonCfg.Bssid[1],
2053 pAd->CommonCfg.Bssid[2],
2054 pAd->CommonCfg.Bssid[3],
2055 pAd->CommonCfg.Bssid[4],
2056 pAd->CommonCfg.Bssid[5]);
2057 DBGPRINT(RT_DEBUG_TRACE ,("Ssid=%s ,Ssidlen = %d\n",pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen));
2059 else if (ADHOC_ON(pAd))
2060 sprintf(extra, "Connected\n");
2064 sprintf(extra, "Disconnected\n");
2065 DBGPRINT(RT_DEBUG_TRACE ,("ConnStatus is not connected\n"));
2068 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2070 case SHOW_DRVIER_VERION:
2071 sprintf(extra, "Driver version-%s, %s %s\n", STA_DRIVER_VERSION, __DATE__, __TIME__ );
2072 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2074 #ifdef DOT11_N_SUPPORT
2076 getBaInfo(pAd, extra);
2077 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2079 #endif // DOT11_N_SUPPORT //
2080 case SHOW_DESC_INFO:
2082 Show_DescInfo_Proc(pAd, NULL);
2083 wrq->length = 0; // 1: size of '\0'
2087 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2089 sprintf(extra, "Scanning\n");
2090 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2093 pAd->StaCfg.bSwRadio = FALSE;
2094 if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2096 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2097 if (pAd->StaCfg.bRadio == FALSE)
2100 // Update extra information
2101 pAd->ExtraInfo = SW_RADIO_OFF;
2104 sprintf(extra, "Radio Off\n");
2105 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2108 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
2110 sprintf(extra, "Scanning\n");
2111 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2114 pAd->StaCfg.bSwRadio = TRUE;
2115 //if (pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
2117 pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
2118 if (pAd->StaCfg.bRadio == TRUE)
2121 // Update extra information
2122 pAd->ExtraInfo = EXTRA_INFO_CLEAR;
2125 sprintf(extra, "Radio On\n");
2126 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2130 #ifdef QOS_DLS_SUPPORT
2131 case SHOW_DLS_ENTRY_INFO:
2133 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2134 wrq->length = 0; // 1: size of '\0'
2137 #endif // QOS_DLS_SUPPORT //
2139 case SHOW_CFG_VALUE:
2141 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
2143 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2146 case SHOW_ADHOC_ENTRY_INFO:
2147 Show_Adhoc_MacTable_Proc(pAd, extra);
2148 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2151 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2159 int rt_ioctl_siwmlme(struct net_device *dev,
2160 struct iw_request_info *info,
2161 union iwreq_data *wrqu,
2164 PRTMP_ADAPTER pAd = dev->ml_priv;
2165 struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
2166 MLME_QUEUE_ELEM MsgElem;
2167 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2168 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2170 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2177 #ifdef IW_MLME_DEAUTH
2178 case IW_MLME_DEAUTH:
2179 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2180 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2181 DeAuthReq.Reason = pMlme->reason_code;
2182 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
2183 NdisMoveMemory(MsgElem.Msg, &DeAuthReq, sizeof(MLME_DEAUTH_REQ_STRUCT));
2184 MlmeDeauthReqAction(pAd, &MsgElem);
2187 LinkDown(pAd, FALSE);
2188 pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
2191 #endif // IW_MLME_DEAUTH //
2192 #ifdef IW_MLME_DISASSOC
2193 case IW_MLME_DISASSOC:
2194 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2195 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2196 DisAssocReq.Reason = pMlme->reason_code;
2198 MsgElem.Machine = ASSOC_STATE_MACHINE;
2199 MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
2200 MsgElem.MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);
2201 NdisMoveMemory(MsgElem.Msg, &DisAssocReq, sizeof(MLME_DISASSOC_REQ_STRUCT));
2203 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
2204 MlmeDisassocReqAction(pAd, &MsgElem);
2206 #endif // IW_MLME_DISASSOC //
2208 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2214 #endif // SIOCSIWMLME //
2216 #if WIRELESS_EXT > 17
2217 int rt_ioctl_siwauth(struct net_device *dev,
2218 struct iw_request_info *info,
2219 union iwreq_data *wrqu, char *extra)
2221 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2222 struct iw_param *param = &wrqu->param;
2224 //check if the interface is down
2225 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2227 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2230 switch (param->flags & IW_AUTH_INDEX) {
2231 case IW_AUTH_WPA_VERSION:
2232 if (param->value == IW_AUTH_WPA_VERSION_WPA)
2234 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
2235 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
2236 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
2238 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2239 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2241 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2243 case IW_AUTH_CIPHER_PAIRWISE:
2244 if (param->value == IW_AUTH_CIPHER_NONE)
2246 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2247 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2248 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2250 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2251 param->value == IW_AUTH_CIPHER_WEP104)
2253 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
2254 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2255 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
2256 #ifdef WPA_SUPPLICANT_SUPPORT
2257 pAdapter->StaCfg.IEEE8021X = FALSE;
2258 #endif // WPA_SUPPLICANT_SUPPORT //
2260 else if (param->value == IW_AUTH_CIPHER_TKIP)
2262 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
2263 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2264 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
2266 else if (param->value == IW_AUTH_CIPHER_CCMP)
2268 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
2269 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2270 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2272 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2274 case IW_AUTH_CIPHER_GROUP:
2275 if (param->value == IW_AUTH_CIPHER_NONE)
2277 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2279 else if (param->value == IW_AUTH_CIPHER_WEP40 ||
2280 param->value == IW_AUTH_CIPHER_WEP104)
2282 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
2284 else if (param->value == IW_AUTH_CIPHER_TKIP)
2286 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
2288 else if (param->value == IW_AUTH_CIPHER_CCMP)
2290 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2292 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2294 case IW_AUTH_KEY_MGMT:
2295 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
2297 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
2299 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
2300 #ifdef WPA_SUPPLICANT_SUPPORT
2301 pAdapter->StaCfg.IEEE8021X = FALSE;
2302 #endif // WPA_SUPPLICANT_SUPPORT //
2304 else if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
2306 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
2307 #ifdef WPA_SUPPLICANT_SUPPORT
2308 pAdapter->StaCfg.IEEE8021X = FALSE;
2309 #endif // WPA_SUPPLICANT_SUPPORT //
2311 #ifdef WPA_SUPPLICANT_SUPPORT
2314 pAdapter->StaCfg.IEEE8021X = TRUE;
2315 #endif // WPA_SUPPLICANT_SUPPORT //
2317 else if (param->value == 0)
2319 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2320 STA_PORT_SECURED(pAdapter);
2322 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2324 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2326 case IW_AUTH_PRIVACY_INVOKED:
2327 /*if (param->value == 0)
2329 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2330 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
2331 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2332 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2333 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2335 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2337 case IW_AUTH_DROP_UNENCRYPTED:
2338 if (param->value != 0)
2339 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
2342 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2343 STA_PORT_SECURED(pAdapter);
2345 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2347 case IW_AUTH_80211_AUTH_ALG:
2348 if (param->value & IW_AUTH_ALG_SHARED_KEY)
2350 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
2352 else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
2354 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
2358 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2360 case IW_AUTH_WPA_ENABLED:
2361 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2370 int rt_ioctl_giwauth(struct net_device *dev,
2371 struct iw_request_info *info,
2372 union iwreq_data *wrqu, char *extra)
2374 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2375 struct iw_param *param = &wrqu->param;
2377 //check if the interface is down
2378 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2380 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2384 switch (param->flags & IW_AUTH_INDEX) {
2385 case IW_AUTH_DROP_UNENCRYPTED:
2386 param->value = (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) ? 0 : 1;
2389 case IW_AUTH_80211_AUTH_ALG:
2390 param->value = (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
2393 case IW_AUTH_WPA_ENABLED:
2394 param->value = (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) ? 1 : 0;
2400 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
2404 void fnSetCipherKey(
2405 IN PRTMP_ADAPTER pAdapter,
2409 IN struct iw_encode_ext *ext)
2411 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2412 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
2413 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, LEN_TKIP_EK);
2414 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic, ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
2415 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
2416 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
2418 // Update group key information to ASIC Shared Key Table
2419 AsicAddSharedKeyEntry(pAdapter,
2422 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2423 pAdapter->SharedKey[BSS0][keyIdx].Key,
2424 pAdapter->SharedKey[BSS0][keyIdx].TxMic,
2425 pAdapter->SharedKey[BSS0][keyIdx].RxMic);
2428 // Update ASIC WCID attribute table and IVEIV table
2429 RTMPAddWcidAttributeEntry(pAdapter,
2432 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2435 // Update ASIC WCID attribute table and IVEIV table
2436 RTMPAddWcidAttributeEntry(pAdapter,
2439 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
2440 &pAdapter->MacTab.Content[BSSID_WCID]);
2443 int rt_ioctl_siwencodeext(struct net_device *dev,
2444 struct iw_request_info *info,
2445 union iwreq_data *wrqu,
2448 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2449 struct iw_point *encoding = &wrqu->encoding;
2450 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2451 int keyIdx, alg = ext->alg;
2453 //check if the interface is down
2454 if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2456 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
2460 if (encoding->flags & IW_ENCODE_DISABLED)
2462 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2463 // set BSSID wcid entry of the Pair-wise Key table as no-security mode
2464 AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
2465 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
2466 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2467 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2468 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2469 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2473 // Get Key Index and convet to our own defined key index
2474 keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
2475 if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
2478 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2480 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2481 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2485 case IW_ENCODE_ALG_NONE:
2486 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2488 case IW_ENCODE_ALG_WEP:
2489 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2490 if (ext->key_len == MAX_WEP_KEY_SIZE)
2492 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
2493 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
2495 else if (ext->key_len == MIN_WEP_KEY_SIZE)
2497 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
2498 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
2503 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
2504 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2506 if (pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled ||
2507 pAdapter->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
2509 // Set Group key material to Asic
2510 AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, pAdapter->SharedKey[BSS0][keyIdx].Key, NULL, NULL);
2512 // Update WCID attribute table and IVEIV table for this group key table
2513 RTMPAddWcidAttributeEntry(pAdapter, BSS0, keyIdx, pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, NULL);
2515 STA_PORT_SECURED(pAdapter);
2517 // Indicate Connected for GUI
2518 pAdapter->IndicateMediaState = NdisMediaStateConnected;
2521 case IW_ENCODE_ALG_TKIP:
2522 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2523 if (ext->key_len == 32)
2525 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2527 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, FALSE, ext);
2528 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2530 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2531 STA_PORT_SECURED(pAdapter);
2534 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2536 fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
2538 // set 802.1x port control
2539 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2540 STA_PORT_SECURED(pAdapter);
2546 case IW_ENCODE_ALG_CCMP:
2547 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2549 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, FALSE, ext);
2550 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
2551 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2552 STA_PORT_SECURED(pAdapter);
2554 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2556 fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
2558 // set 802.1x port control
2559 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2560 STA_PORT_SECURED(pAdapter);
2572 rt_ioctl_giwencodeext(struct net_device *dev,
2573 struct iw_request_info *info,
2574 union iwreq_data *wrqu, char *extra)
2576 PRTMP_ADAPTER pAd = dev->ml_priv;
2578 struct iw_point *encoding = &wrqu->encoding;
2579 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2580 int idx, max_key_len;
2582 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_giwencodeext\n"));
2584 max_key_len = encoding->length - sizeof(*ext);
2585 if (max_key_len < 0)
2588 idx = encoding->flags & IW_ENCODE_INDEX;
2591 if (idx < 1 || idx > 4)
2595 if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
2596 (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled))
2598 if (idx != pAd->StaCfg.DefaultKeyId)
2606 idx = pAd->StaCfg.DefaultKeyId;
2608 encoding->flags = idx + 1;
2609 memset(ext, 0, sizeof(*ext));
2612 switch(pAd->StaCfg.WepStatus) {
2613 case Ndis802_11WEPDisabled:
2614 ext->alg = IW_ENCODE_ALG_NONE;
2615 encoding->flags |= IW_ENCODE_DISABLED;
2617 case Ndis802_11WEPEnabled:
2618 ext->alg = IW_ENCODE_ALG_WEP;
2619 if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
2623 ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
2624 pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
2627 case Ndis802_11Encryption2Enabled:
2628 case Ndis802_11Encryption3Enabled:
2629 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
2630 ext->alg = IW_ENCODE_ALG_TKIP;
2632 ext->alg = IW_ENCODE_ALG_CCMP;
2634 if (max_key_len < 32)
2639 pKey = &pAd->StaCfg.PMK[0];
2646 if (ext->key_len && pKey)
2648 encoding->flags |= IW_ENCODE_ENABLED;
2649 memcpy(ext->key, pKey, ext->key_len);
2656 int rt_ioctl_siwgenie(struct net_device *dev,
2657 struct iw_request_info *info,
2658 union iwreq_data *wrqu, char *extra)
2660 PRTMP_ADAPTER pAd = dev->ml_priv;
2662 if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
2663 (wrqu->data.length && extra == NULL))
2666 if (wrqu->data.length)
2668 pAd->StaCfg.RSNIE_Len = wrqu->data.length;
2669 NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
2673 pAd->StaCfg.RSNIE_Len = 0;
2674 NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
2679 #endif // SIOCSIWGENIE //
2681 int rt_ioctl_giwgenie(struct net_device *dev,
2682 struct iw_request_info *info,
2683 union iwreq_data *wrqu, char *extra)
2685 PRTMP_ADAPTER pAd = dev->ml_priv;
2687 if ((pAd->StaCfg.RSNIE_Len == 0) ||
2688 (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
2690 wrqu->data.length = 0;
2694 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
2696 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
2698 if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
2701 wrqu->data.length = pAd->StaCfg.RSNIE_Len;
2702 memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2705 #endif // SIOCSIWGENIE //
2706 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
2708 UCHAR RSNIe = IE_WPA;
2710 if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
2712 wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
2714 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
2715 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
2718 extra[0] = (char)RSNIe;
2719 extra[1] = pAd->StaCfg.RSNIE_Len;
2720 memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
2726 int rt_ioctl_siwpmksa(struct net_device *dev,
2727 struct iw_request_info *info,
2728 union iwreq_data *wrqu,
2731 PRTMP_ADAPTER pAd = dev->ml_priv;
2732 struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
2733 INT CachedIdx = 0, idx = 0;
2738 DBGPRINT(RT_DEBUG_TRACE ,("===> rt_ioctl_siwpmksa\n"));
2741 case IW_PMKSA_FLUSH:
2742 NdisZeroMemory(pAd->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
2743 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
2745 case IW_PMKSA_REMOVE:
2746 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2748 // compare the BSSID
2749 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2751 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN);
2752 NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].PMKID, 16);
2753 for (idx = CachedIdx; idx < (pAd->StaCfg.SavedPMKNum - 1); idx++)
2755 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].BSSID[0], &pAd->StaCfg.SavedPMK[idx+1].BSSID[0], MAC_ADDR_LEN);
2756 NdisMoveMemory(&pAd->StaCfg.SavedPMK[idx].PMKID[0], &pAd->StaCfg.SavedPMK[idx+1].PMKID[0], 16);
2758 pAd->StaCfg.SavedPMKNum--;
2763 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
2766 for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum; CachedIdx++)
2768 // compare the BSSID
2769 if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
2773 // Found, replace it
2774 if (CachedIdx < PMKID_NO)
2776 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2777 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2778 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2779 pAd->StaCfg.SavedPMKNum++;
2781 // Not found, replace the last one
2784 // Randomly replace one
2785 CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
2786 DBGPRINT(RT_DEBUG_OFF, ("Update PMKID, idx = %d\n", CachedIdx));
2787 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
2788 NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
2791 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
2794 DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - Unknow Command!!\n"));
2800 #endif // #if WIRELESS_EXT > 17
2804 rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
2805 struct iw_point *wrq, char *extra)
2810 // CHAR arg[255]={0};
2813 BOOLEAN bIsPrintAllBBP = FALSE;
2815 PRTMP_ADAPTER pAdapter = dev->ml_priv;
2818 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2820 if (wrq->length > 1) //No parameters.
2822 sprintf(extra, "\n");
2824 //Parsing Read or Write
2825 this_char = wrq->pointer;
2826 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
2830 if ((value = rtstrchr(this_char, '=')) != NULL)
2833 if (!value || !*value)
2835 DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
2836 if (sscanf(this_char, "%d", &(bbpId)) == 1)
2841 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2843 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2844 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2845 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2848 {//Invalid parametes, so default printk all bbp
2849 bIsPrintAllBBP = TRUE;
2854 { //Invalid parametes, so default printk all bbp
2855 bIsPrintAllBBP = TRUE;
2861 if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
2866 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
2867 //Read it back for showing
2868 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2870 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
2871 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2872 DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
2875 {//Invalid parametes, so default printk all bbp
2876 bIsPrintAllBBP = TRUE;
2881 { //Invalid parametes, so default printk all bbp
2882 bIsPrintAllBBP = TRUE;
2888 bIsPrintAllBBP = TRUE;
2893 memset(extra, 0x00, IW_PRIV_SIZE_MASK);
2894 sprintf(extra, "\n");
2895 for (bbpId = 0; bbpId <= 136; bbpId++)
2897 if (strlen(extra) >= (IW_PRIV_SIZE_MASK - 10))
2899 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, ®BBP);
2900 sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X ", bbpId, bbpId*2, regBBP);
2902 sprintf(extra+strlen(extra), "\n");
2905 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2906 DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
2909 DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
2915 int rt_ioctl_siwrate(struct net_device *dev,
2916 struct iw_request_info *info,
2917 union iwreq_data *wrqu, char *extra)
2919 PRTMP_ADAPTER pAd = dev->ml_priv;
2920 UINT32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
2922 //check if the interface is down
2923 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2925 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
2929 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
2930 /* rate = -1 => auto rate
2931 rate = X, fixed = 1 => (fixed rate X)
2936 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2937 pAd->StaCfg.bAutoTxRateSwitch = TRUE;
2938 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2939 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2940 RTMPSetDesiredRates(pAd, -1);
2942 #ifdef DOT11_N_SUPPORT
2944 #endif // DOT11_N_SUPPORT //
2950 pAd->StaCfg.bAutoTxRateSwitch = FALSE;
2951 if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
2952 (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
2953 RTMPSetDesiredRates(pAd, rate);
2956 pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
2957 #ifdef DOT11_N_SUPPORT
2959 #endif // DOT11_N_SUPPORT //
2961 DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(HtMcs=%d)\n",pAd->StaCfg.DesiredTransmitSetting.field.MCS));
2965 // TODO: rate = X, fixed = 0 => (rates <= X)
2973 int rt_ioctl_giwrate(struct net_device *dev,
2974 struct iw_request_info *info,
2975 union iwreq_data *wrqu, char *extra)
2977 PRTMP_ADAPTER pAd = dev->ml_priv;
2978 int rate_index = 0, rate_count = 0;
2979 HTTRANSMIT_SETTING ht_setting;
2980 __s32 ralinkrate[] =
2981 {2, 4, 11, 22, // CCK
2982 12, 18, 24, 36, 48, 72, 96, 108, // OFDM
2983 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
2984 39, 78, 117, 156, 234, 312, 351, 390, // 20MHz, 800ns GI, MCS: 16 ~ 23
2985 27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
2986 81, 162, 243, 324, 486, 648, 729, 810, // 40MHz, 800ns GI, MCS: 16 ~ 23
2987 14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
2988 43, 87, 130, 173, 260, 317, 390, 433, // 20MHz, 400ns GI, MCS: 16 ~ 23
2989 30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
2990 90, 180, 270, 360, 540, 720, 810, 900}; // 40MHz, 400ns GI, MCS: 16 ~ 23
2992 rate_count = sizeof(ralinkrate)/sizeof(__s32);
2993 //check if the interface is down
2994 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
2996 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
3000 if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
3002 ((pAd->CommonCfg.PhyMode <= PHY_11G) || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM)))
3003 ht_setting.word = pAd->StaCfg.HTPhyMode.word;
3005 ht_setting.word = pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
3007 #ifdef DOT11_N_SUPPORT
3008 if (ht_setting.field.MODE >= MODE_HTMIX)
3010 // rate_index = 12 + ((UCHAR)ht_setting.field.BW *16) + ((UCHAR)ht_setting.field.ShortGI *32) + ((UCHAR)ht_setting.field.MCS);
3011 rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
3014 #endif // DOT11_N_SUPPORT //
3015 if (ht_setting.field.MODE == MODE_OFDM)
3016 rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
3017 else if (ht_setting.field.MODE == MODE_CCK)
3018 rate_index = (UCHAR)(ht_setting.field.MCS);
3023 if (rate_index > rate_count)
3024 rate_index = rate_count;
3026 wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
3027 wrqu->bitrate.disabled = 0;
3032 static const iw_handler rt_handler[] =
3034 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3035 (iw_handler) rt_ioctl_giwname, /* SIOCGIWNAME */
3036 (iw_handler) NULL, /* SIOCSIWNWID */
3037 (iw_handler) NULL, /* SIOCGIWNWID */
3038 (iw_handler) rt_ioctl_siwfreq, /* SIOCSIWFREQ */
3039 (iw_handler) rt_ioctl_giwfreq, /* SIOCGIWFREQ */
3040 (iw_handler) rt_ioctl_siwmode, /* SIOCSIWMODE */
3041 (iw_handler) rt_ioctl_giwmode, /* SIOCGIWMODE */
3042 (iw_handler) NULL, /* SIOCSIWSENS */
3043 (iw_handler) NULL, /* SIOCGIWSENS */
3044 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3045 (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE */
3046 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3047 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3048 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3049 (iw_handler) rt28xx_get_wireless_stats /* kernel code */, /* SIOCGIWSTATS */
3050 (iw_handler) NULL, /* SIOCSIWSPY */
3051 (iw_handler) NULL, /* SIOCGIWSPY */
3052 (iw_handler) NULL, /* SIOCSIWTHRSPY */
3053 (iw_handler) NULL, /* SIOCGIWTHRSPY */
3054 (iw_handler) rt_ioctl_siwap, /* SIOCSIWAP */
3055 (iw_handler) rt_ioctl_giwap, /* SIOCGIWAP */
3057 (iw_handler) rt_ioctl_siwmlme, /* SIOCSIWMLME */
3059 (iw_handler) NULL, /* SIOCSIWMLME */
3060 #endif // SIOCSIWMLME //
3061 (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
3063 (iw_handler) rt_ioctl_siwscan, /* SIOCSIWSCAN */
3064 (iw_handler) rt_ioctl_giwscan, /* SIOCGIWSCAN */
3066 (iw_handler) NULL, /* SIOCSIWSCAN */
3067 (iw_handler) NULL, /* SIOCGIWSCAN */
3068 #endif /* SIOCGIWSCAN */
3069 (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID */
3070 (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID */
3071 (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN */
3072 (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN */
3073 (iw_handler) NULL, /* -- hole -- */
3074 (iw_handler) NULL, /* -- hole -- */
3075 (iw_handler) rt_ioctl_siwrate, /* SIOCSIWRATE */
3076 (iw_handler) rt_ioctl_giwrate, /* SIOCGIWRATE */
3077 (iw_handler) rt_ioctl_siwrts, /* SIOCSIWRTS */
3078 (iw_handler) rt_ioctl_giwrts, /* SIOCGIWRTS */
3079 (iw_handler) rt_ioctl_siwfrag, /* SIOCSIWFRAG */
3080 (iw_handler) rt_ioctl_giwfrag, /* SIOCGIWFRAG */
3081 (iw_handler) NULL, /* SIOCSIWTXPOW */
3082 (iw_handler) NULL, /* SIOCGIWTXPOW */
3083 (iw_handler) NULL, /* SIOCSIWRETRY */
3084 (iw_handler) NULL, /* SIOCGIWRETRY */
3085 (iw_handler) rt_ioctl_siwencode, /* SIOCSIWENCODE */
3086 (iw_handler) rt_ioctl_giwencode, /* SIOCGIWENCODE */
3087 (iw_handler) NULL, /* SIOCSIWPOWER */
3088 (iw_handler) NULL, /* SIOCGIWPOWER */
3089 (iw_handler) NULL, /* -- hole -- */
3090 (iw_handler) NULL, /* -- hole -- */
3091 #if WIRELESS_EXT > 17
3092 (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE */
3093 (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE */
3094 (iw_handler) rt_ioctl_siwauth, /* SIOCSIWAUTH */
3095 (iw_handler) rt_ioctl_giwauth, /* SIOCGIWAUTH */
3096 (iw_handler) rt_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3097 (iw_handler) rt_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3098 (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA */
3102 static const iw_handler rt_priv_handlers[] = {
3103 (iw_handler) NULL, /* + 0x00 */
3104 (iw_handler) NULL, /* + 0x01 */
3105 #ifndef CONFIG_AP_SUPPORT
3106 (iw_handler) rt_ioctl_setparam, /* + 0x02 */
3108 (iw_handler) NULL, /* + 0x02 */
3109 #endif // CONFIG_AP_SUPPORT //
3111 (iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
3113 (iw_handler) NULL, /* + 0x03 */
3115 (iw_handler) NULL, /* + 0x04 */
3116 (iw_handler) NULL, /* + 0x05 */
3117 (iw_handler) NULL, /* + 0x06 */
3118 (iw_handler) NULL, /* + 0x07 */
3119 (iw_handler) NULL, /* + 0x08 */
3120 (iw_handler) rt_private_get_statistics, /* + 0x09 */
3121 (iw_handler) NULL, /* + 0x0A */
3122 (iw_handler) NULL, /* + 0x0B */
3123 (iw_handler) NULL, /* + 0x0C */
3124 (iw_handler) NULL, /* + 0x0D */
3125 (iw_handler) NULL, /* + 0x0E */
3126 (iw_handler) NULL, /* + 0x0F */
3127 (iw_handler) NULL, /* + 0x10 */
3128 (iw_handler) rt_private_show, /* + 0x11 */
3129 (iw_handler) NULL, /* + 0x12 */
3130 (iw_handler) NULL, /* + 0x13 */
3131 (iw_handler) NULL, /* + 0x15 */
3132 (iw_handler) NULL, /* + 0x17 */
3133 (iw_handler) NULL, /* + 0x18 */
3136 const struct iw_handler_def rt28xx_iw_handler_def =
3138 #define N(a) (sizeof (a) / sizeof (a[0]))
3139 .standard = (iw_handler *) rt_handler,
3140 .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
3141 .private = (iw_handler *) rt_priv_handlers,
3142 .num_private = N(rt_priv_handlers),
3143 .private_args = (struct iw_priv_args *) privtab,
3144 .num_private_args = N(privtab),
3145 #if IW_HANDLER_VERSION >= 7
3146 .get_wireless_stats = rt28xx_get_wireless_stats,
3150 INT RTMPSetInformation(
3151 IN PRTMP_ADAPTER pAdapter,
3152 IN OUT struct ifreq *rq,
3155 struct iwreq *wrq = (struct iwreq *) rq;
3156 NDIS_802_11_SSID Ssid;
3157 NDIS_802_11_MAC_ADDRESS Bssid;
3158 RT_802_11_PHY_MODE PhyMode;
3159 RT_802_11_STA_CONFIG StaConfig;
3160 NDIS_802_11_RATES aryRates;
3161 RT_802_11_PREAMBLE Preamble;
3162 NDIS_802_11_WEP_STATUS WepStatus;
3163 NDIS_802_11_AUTHENTICATION_MODE AuthMode = Ndis802_11AuthModeMax;
3164 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
3165 NDIS_802_11_RTS_THRESHOLD RtsThresh;
3166 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
3167 NDIS_802_11_POWER_MODE PowerMode;
3168 PNDIS_802_11_KEY pKey = NULL;
3169 PNDIS_802_11_WEP pWepKey =NULL;
3170 PNDIS_802_11_REMOVE_KEY pRemoveKey = NULL;
3171 NDIS_802_11_CONFIGURATION Config, *pConfig = NULL;
3172 NDIS_802_11_NETWORK_TYPE NetType;
3175 INT Status = NDIS_STATUS_SUCCESS, MaxPhyMode = PHY_11G;
3178 BOOLEAN StateMachineTouched = FALSE;
3179 #ifdef DOT11_N_SUPPORT
3180 OID_SET_HT_PHYMODE HT_PhyMode; //11n ,kathy
3181 #endif // DOT11_N_SUPPORT //
3182 #ifdef WPA_SUPPLICANT_SUPPORT
3183 PNDIS_802_11_PMKID pPmkId = NULL;
3184 BOOLEAN IEEE8021xState = FALSE;
3185 BOOLEAN IEEE8021x_required_keys = FALSE;
3186 UCHAR wpa_supplicant_enable = 0;
3187 #endif // WPA_SUPPLICANT_SUPPORT //
3190 TX_RTY_CFG_STRUC tx_rty_cfg;
3191 ULONG ShortRetryLimit, LongRetryLimit;
3193 #endif // SNMP_SUPPORT //
3197 #ifdef DOT11_N_SUPPORT
3198 MaxPhyMode = PHY_11N_5G;
3199 #endif // DOT11_N_SUPPORT //
3202 DBGPRINT(RT_DEBUG_TRACE, ("-->RTMPSetInformation(), 0x%08x\n", cmd&0x7FFF));
3203 switch(cmd & 0x7FFF) {
3204 case RT_OID_802_11_COUNTRY_REGION:
3205 if (wrq->u.data.length < sizeof(UCHAR))
3207 // Only avaliable when EEPROM not programming
3208 else if (!(pAdapter->CommonCfg.CountryRegion & 0x80) && !(pAdapter->CommonCfg.CountryRegionForABand & 0x80))
3213 Status = copy_from_user(&Country, wrq->u.data.pointer, wrq->u.data.length);
3214 pAdapter->CommonCfg.CountryRegion = (UCHAR)(Country & 0x000000FF);
3215 pAdapter->CommonCfg.CountryRegionForABand = (UCHAR)((Country >> 8) & 0x000000FF);
3216 TmpPhy = pAdapter->CommonCfg.PhyMode;
3217 pAdapter->CommonCfg.PhyMode = 0xff;
3218 // Build all corresponding channel information
3219 RTMPSetPhyMode(pAdapter, TmpPhy);
3220 #ifdef DOT11_N_SUPPORT
3221 SetCommonHT(pAdapter);
3222 #endif // DOT11_N_SUPPORT //
3223 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_COUNTRY_REGION (A:%d B/G:%d)\n", pAdapter->CommonCfg.CountryRegionForABand,
3224 pAdapter->CommonCfg.CountryRegion));
3227 case OID_802_11_BSSID_LIST_SCAN:
3229 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID_LIST_SCAN, TxCnt = %d \n", pAdapter->RalinkCounters.LastOneSecTotalTxCount));
3231 if (MONITOR_ON(pAdapter))
3233 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is in Monitor Mode now !!!\n"));
3237 //Benson add 20080527, when radio off, sta don't need to scan
3238 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
3241 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
3243 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
3244 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3245 Status = NDIS_STATUS_SUCCESS;
3249 if (pAdapter->RalinkCounters.LastOneSecTotalTxCount > 100)
3251 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3252 Status = NDIS_STATUS_SUCCESS;
3253 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3257 if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
3258 ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
3259 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3260 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
3261 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
3262 (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
3264 DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
3265 Status = NDIS_STATUS_SUCCESS;
3266 pAdapter->StaCfg.ScanCnt = 99; // Prevent auto scan triggered by this OID
3271 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3273 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3274 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3277 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3278 // this request, because this request is initiated by NDIS.
3279 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3280 // Reset allowed scan retries
3281 pAdapter->StaCfg.ScanCnt = 0;
3282 pAdapter->StaCfg.LastScanTime = Now;
3284 pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
3285 RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
3286 MlmeEnqueue(pAdapter,
3287 MLME_CNTL_STATE_MACHINE,
3288 OID_802_11_BSSID_LIST_SCAN,
3292 Status = NDIS_STATUS_SUCCESS;
3293 StateMachineTouched = TRUE;
3295 case OID_802_11_SSID:
3296 if (wrq->u.data.length != sizeof(NDIS_802_11_SSID))
3300 PCHAR pSsidString = NULL;
3301 Status = copy_from_user(&Ssid, wrq->u.data.pointer, wrq->u.data.length);
3303 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SSID (Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
3304 if (Ssid.SsidLength > MAX_LEN_OF_SSID)
3308 if (Ssid.SsidLength == 0)
3310 Set_SSID_Proc(pAdapter, "");
3314 pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
3317 NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1);
3318 NdisMoveMemory(pSsidString, Ssid.Ssid, Ssid.SsidLength);
3319 Set_SSID_Proc(pAdapter, pSsidString);
3328 case OID_802_11_BSSID:
3329 if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
3333 Status = copy_from_user(&Bssid, wrq->u.data.pointer, wrq->u.data.length);
3335 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
3336 // this request, because this request is initiated by NDIS.
3337 pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
3339 // Prevent to connect AP again in STAMlmePeriodicExec
3340 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
3342 // Reset allowed scan retries
3343 pAdapter->StaCfg.ScanCnt = 0;
3345 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3347 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3348 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3350 MlmeEnqueue(pAdapter,
3351 MLME_CNTL_STATE_MACHINE,
3353 sizeof(NDIS_802_11_MAC_ADDRESS),
3355 Status = NDIS_STATUS_SUCCESS;
3356 StateMachineTouched = TRUE;
3358 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_BSSID %02x:%02x:%02x:%02x:%02x:%02x\n",
3359 Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
3362 case RT_OID_802_11_RADIO:
3363 if (wrq->u.data.length != sizeof(BOOLEAN))
3367 Status = copy_from_user(&RadioState, wrq->u.data.pointer, wrq->u.data.length);
3368 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RADIO (=%d)\n", RadioState));
3369 if (pAdapter->StaCfg.bSwRadio != RadioState)
3371 pAdapter->StaCfg.bSwRadio = RadioState;
3372 if (pAdapter->StaCfg.bRadio != (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio))
3374 pAdapter->StaCfg.bRadio = (pAdapter->StaCfg.bHwRadio && pAdapter->StaCfg.bSwRadio);
3375 if (pAdapter->StaCfg.bRadio == TRUE)
3377 MlmeRadioOn(pAdapter);
3378 // Update extra information
3379 pAdapter->ExtraInfo = EXTRA_INFO_CLEAR;
3383 MlmeRadioOff(pAdapter);
3384 // Update extra information
3385 pAdapter->ExtraInfo = SW_RADIO_OFF;
3391 case RT_OID_802_11_PHY_MODE:
3392 if (wrq->u.data.length != sizeof(RT_802_11_PHY_MODE))
3396 Status = copy_from_user(&PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3397 if (PhyMode <= MaxPhyMode)
3399 RTMPSetPhyMode(pAdapter, PhyMode);
3400 #ifdef DOT11_N_SUPPORT
3401 SetCommonHT(pAdapter);
3402 #endif // DOT11_N_SUPPORT //
3404 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PHY_MODE (=%d)\n", PhyMode));
3407 case RT_OID_802_11_STA_CONFIG:
3408 if (wrq->u.data.length != sizeof(RT_802_11_STA_CONFIG))
3412 Status = copy_from_user(&StaConfig, wrq->u.data.pointer, wrq->u.data.length);
3413 pAdapter->CommonCfg.bEnableTxBurst = StaConfig.EnableTxBurst;
3414 pAdapter->CommonCfg.UseBGProtection = StaConfig.UseBGProtection;
3415 pAdapter->CommonCfg.bUseShortSlotTime = 1; // 2003-10-30 always SHORT SLOT capable
3416 if ((pAdapter->CommonCfg.PhyMode != StaConfig.AdhocMode) &&
3417 (StaConfig.AdhocMode <= MaxPhyMode))
3419 // allow dynamic change of "USE OFDM rate or not" in ADHOC mode
3420 // if setting changed, need to reset current TX rate as well as BEACON frame format
3421 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
3423 pAdapter->CommonCfg.PhyMode = StaConfig.AdhocMode;
3424 RTMPSetPhyMode(pAdapter, PhyMode);
3425 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3426 MakeIbssBeacon(pAdapter); // re-build BEACON frame
3427 AsicEnableIbssSync(pAdapter); // copy to on-chip memory
3430 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_STA_CONFIG (Burst=%d, Protection=%ld,ShortSlot=%d\n",
3431 pAdapter->CommonCfg.bEnableTxBurst,
3432 pAdapter->CommonCfg.UseBGProtection,
3433 pAdapter->CommonCfg.bUseShortSlotTime));
3436 case OID_802_11_DESIRED_RATES:
3437 if (wrq->u.data.length != sizeof(NDIS_802_11_RATES))
3441 Status = copy_from_user(&aryRates, wrq->u.data.pointer, wrq->u.data.length);
3442 NdisZeroMemory(pAdapter->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
3443 NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates, sizeof(NDIS_802_11_RATES));
3444 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DESIRED_RATES (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
3445 pAdapter->CommonCfg.DesireRate[0],pAdapter->CommonCfg.DesireRate[1],
3446 pAdapter->CommonCfg.DesireRate[2],pAdapter->CommonCfg.DesireRate[3],
3447 pAdapter->CommonCfg.DesireRate[4],pAdapter->CommonCfg.DesireRate[5],
3448 pAdapter->CommonCfg.DesireRate[6],pAdapter->CommonCfg.DesireRate[7] ));
3449 // Changing DesiredRate may affect the MAX TX rate we used to TX frames out
3450 MlmeUpdateTxRates(pAdapter, FALSE, 0);
3453 case RT_OID_802_11_PREAMBLE:
3454 if (wrq->u.data.length != sizeof(RT_802_11_PREAMBLE))
3458 Status = copy_from_user(&Preamble, wrq->u.data.pointer, wrq->u.data.length);
3459 if (Preamble == Rt802_11PreambleShort)
3461 pAdapter->CommonCfg.TxPreamble = Preamble;
3462 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleShort);
3464 else if ((Preamble == Rt802_11PreambleLong) || (Preamble == Rt802_11PreambleAuto))
3466 // if user wants AUTO, initialize to LONG here, then change according to AP's
3467 // capability upon association.
3468 pAdapter->CommonCfg.TxPreamble = Preamble;
3469 MlmeSetTxPreamble(pAdapter, Rt802_11PreambleLong);
3476 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_PREAMBLE (=%d)\n", Preamble));
3479 case OID_802_11_WEP_STATUS:
3480 if (wrq->u.data.length != sizeof(NDIS_802_11_WEP_STATUS))
3484 Status = copy_from_user(&WepStatus, wrq->u.data.pointer, wrq->u.data.length);
3485 // Since TKIP, AES, WEP are all supported. It should not have any invalid setting
3486 if (WepStatus <= Ndis802_11Encryption3KeyAbsent)
3488 if (pAdapter->StaCfg.WepStatus != WepStatus)
3490 // Config has changed
3491 pAdapter->bConfigChanged = TRUE;
3493 pAdapter->StaCfg.WepStatus = WepStatus;
3494 pAdapter->StaCfg.OrigWepStatus = WepStatus;
3495 pAdapter->StaCfg.PairCipher = WepStatus;
3496 pAdapter->StaCfg.GroupCipher = WepStatus;
3503 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEP_STATUS (=%d)\n",WepStatus));
3506 case OID_802_11_AUTHENTICATION_MODE:
3507 if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
3511 Status = copy_from_user(&AuthMode, wrq->u.data.pointer, wrq->u.data.length);
3512 if (AuthMode > Ndis802_11AuthModeMax)
3519 if (pAdapter->StaCfg.AuthMode != AuthMode)
3521 // Config has changed
3522 pAdapter->bConfigChanged = TRUE;
3524 pAdapter->StaCfg.AuthMode = AuthMode;
3526 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
3527 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->StaCfg.AuthMode));
3530 case OID_802_11_INFRASTRUCTURE_MODE:
3531 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE))
3535 Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);
3537 if (BssType == Ndis802_11IBSS)
3538 Set_NetworkType_Proc(pAdapter, "Adhoc");
3539 else if (BssType == Ndis802_11Infrastructure)
3540 Set_NetworkType_Proc(pAdapter, "Infra");
3541 else if (BssType == Ndis802_11Monitor)
3542 Set_NetworkType_Proc(pAdapter, "Monitor");
3546 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n"));
3550 case OID_802_11_REMOVE_WEP:
3551 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_WEP\n"));
3552 if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX))
3558 KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
3560 if (KeyIdx & 0x80000000)
3562 // Should never set default bit when remove key
3567 KeyIdx = KeyIdx & 0x0fffffff;
3573 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3574 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3575 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3580 case RT_OID_802_11_RESET_COUNTERS:
3581 NdisZeroMemory(&pAdapter->WlanCounters, sizeof(COUNTER_802_11));
3582 NdisZeroMemory(&pAdapter->Counters8023, sizeof(COUNTER_802_3));
3583 NdisZeroMemory(&pAdapter->RalinkCounters, sizeof(COUNTER_RALINK));
3584 pAdapter->Counters8023.RxNoBuffer = 0;
3585 pAdapter->Counters8023.GoodReceives = 0;
3586 pAdapter->Counters8023.RxNoBuffer = 0;
3588 pAdapter->BulkOutComplete = 0;
3589 pAdapter->BulkOutCompleteOther= 0;
3590 pAdapter->BulkOutCompleteCancel = 0;
3591 pAdapter->BulkOutReq = 0;
3592 pAdapter->BulkInReq= 0;
3593 pAdapter->BulkInComplete = 0;
3594 pAdapter->BulkInCompleteFail = 0;
3596 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_RESET_COUNTERS \n"));
3598 case OID_802_11_RTS_THRESHOLD:
3599 if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD))
3603 Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);
3604 if (RtsThresh > MAX_RTS_THRESHOLD)
3607 pAdapter->CommonCfg.RtsThreshold = (USHORT)RtsThresh;
3609 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_RTS_THRESHOLD (=%ld)\n",RtsThresh));
3611 case OID_802_11_FRAGMENTATION_THRESHOLD:
3612 if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD))
3616 Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);
3617 pAdapter->CommonCfg.bUseZeroToDisableFragment = FALSE;
3618 if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
3620 if (FragThresh == 0)
3622 pAdapter->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
3623 pAdapter->CommonCfg.bUseZeroToDisableFragment = TRUE;
3629 pAdapter->CommonCfg.FragmentThreshold = (USHORT)FragThresh;
3631 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%ld) \n",FragThresh));
3633 case OID_802_11_POWER_MODE:
3634 if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE))
3638 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
3639 if (PowerMode == Ndis802_11PowerModeCAM)
3640 Set_PSMode_Proc(pAdapter, "CAM");
3641 else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
3642 Set_PSMode_Proc(pAdapter, "Max_PSP");
3643 else if (PowerMode == Ndis802_11PowerModeFast_PSP)
3644 Set_PSMode_Proc(pAdapter, "Fast_PSP");
3645 else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
3646 Set_PSMode_Proc(pAdapter, "Legacy_PSP");
3650 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode));
3652 case RT_OID_802_11_TX_POWER_LEVEL_1:
3653 if (wrq->u.data.length < sizeof(ULONG))
3657 Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);
3658 if (PowerTemp > 100)
3659 PowerTemp = 0xffffffff; // AUTO
3660 pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
3661 pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
3662 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
3665 case OID_802_11_NETWORK_TYPE_IN_USE:
3666 if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
3670 Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
3672 if (NetType == Ndis802_11DS)
3673 RTMPSetPhyMode(pAdapter, PHY_11B);
3674 else if (NetType == Ndis802_11OFDM24)
3675 RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
3676 else if (NetType == Ndis802_11OFDM5)
3677 RTMPSetPhyMode(pAdapter, PHY_11A);
3680 #ifdef DOT11_N_SUPPORT
3681 if (Status == NDIS_STATUS_SUCCESS)
3682 SetCommonHT(pAdapter);
3683 #endif // DOT11_N_SUPPORT //
3684 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
3687 // For WPA PSK PMK key
3688 case RT_OID_802_11_ADD_WPA:
3689 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3696 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3697 if (pKey->Length != wrq->u.data.length)
3700 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!!\n"));
3704 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
3705 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
3706 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) )
3708 Status = -EOPNOTSUPP;
3709 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n"));
3711 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
3712 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
3713 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) ) // Only for WPA PSK mode
3715 NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
3716 // Use RaConfig as PSK agent.
3717 // Start STA supplicant state machine
3718 if (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
3719 pAdapter->StaCfg.WpaState = SS_START;
3721 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3725 pAdapter->StaCfg.WpaState = SS_NOTUSE;
3726 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3731 case OID_802_11_REMOVE_KEY:
3732 pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3733 if(pRemoveKey == NULL)
3739 Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
3740 if (pRemoveKey->Length != wrq->u.data.length)
3743 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!\n"));
3747 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
3749 RTMPWPARemoveKeyProc(pAdapter, pRemoveKey);
3750 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Remove WPA Key!!\n"));
3754 KeyIdx = pRemoveKey->KeyIndex;
3756 if (KeyIdx & 0x80000000)
3758 // Should never set default bit when remove key
3760 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(Should never set default bit when remove key)\n"));
3764 KeyIdx = KeyIdx & 0x0fffffff;
3768 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY, Failed!!(KeyId[%d] out of range)\n", KeyIdx));
3772 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
3773 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
3774 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
3775 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
3783 case OID_802_11_ADD_KEY:
3784 pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
3790 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
3791 if (pKey->Length != wrq->u.data.length)
3794 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY, Failed!!\n"));
3798 RTMPAddKey(pAdapter, pKey);
3799 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_KEY (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
3803 case OID_802_11_CONFIGURATION:
3804 if (wrq->u.data.length != sizeof(NDIS_802_11_CONFIGURATION))
3808 Status = copy_from_user(&Config, wrq->u.data.pointer, wrq->u.data.length);
3811 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
3812 pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
3814 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
3815 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
3817 // Save the channel on MlmeAux for CntlOidRTBssidProc used.
3819 pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
3821 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
3822 pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
3823 // Config has changed
3824 pAdapter->bConfigChanged = TRUE;
3827 #ifdef DOT11_N_SUPPORT
3828 case RT_OID_802_11_SET_HT_PHYMODE:
3829 if (wrq->u.data.length != sizeof(OID_SET_HT_PHYMODE))
3833 POID_SET_HT_PHYMODE pHTPhyMode = &HT_PhyMode;
3835 Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
3836 DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode (PhyMode = %d,TransmitNo = %d, HtMode = %d, ExtOffset = %d , MCS = %d, BW = %d, STBC = %d, SHORTGI = %d) \n",
3837 pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
3838 pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
3839 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
3840 RTMPSetHT(pAdapter, pHTPhyMode);
3842 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
3843 pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
3844 pAdapter->StaCfg.HTPhyMode.field.STBC));
3846 #endif // DOT11_N_SUPPORT //
3847 case RT_OID_802_11_SET_APSD_SETTING:
3848 if (wrq->u.data.length != sizeof(ULONG))
3853 Status = copy_from_user(&apsd, wrq->u.data.pointer, wrq->u.data.length);
3855 /*-------------------------------------------------------------------
3856 |B31~B7 | B6~B5 | B4 | B3 | B2 | B1 | B0 |
3857 ---------------------------------------------------------------------
3858 | Rsvd | Max SP Len | AC_VO | AC_VI | AC_BK | AC_BE | APSD Capable |
3859 ---------------------------------------------------------------------*/
3860 pAdapter->CommonCfg.bAPSDCapable = (apsd & 0x00000001) ? TRUE : FALSE;
3861 pAdapter->CommonCfg.bAPSDAC_BE = ((apsd & 0x00000002) >> 1) ? TRUE : FALSE;
3862 pAdapter->CommonCfg.bAPSDAC_BK = ((apsd & 0x00000004) >> 2) ? TRUE : FALSE;
3863 pAdapter->CommonCfg.bAPSDAC_VI = ((apsd & 0x00000008) >> 3) ? TRUE : FALSE;
3864 pAdapter->CommonCfg.bAPSDAC_VO = ((apsd & 0x00000010) >> 4) ? TRUE : FALSE;
3865 pAdapter->CommonCfg.MaxSPLength = (UCHAR)((apsd & 0x00000060) >> 5);
3867 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, pAdapter->CommonCfg.bAPSDCapable,
3868 pAdapter->CommonCfg.bAPSDAC_BE, pAdapter->CommonCfg.bAPSDAC_BK, pAdapter->CommonCfg.bAPSDAC_VI, pAdapter->CommonCfg.bAPSDAC_VO, pAdapter->CommonCfg.MaxSPLength));
3872 case RT_OID_802_11_SET_APSD_PSM:
3873 if (wrq->u.data.length != sizeof(ULONG))
3877 // Driver needs to notify AP when PSM changes
3878 Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
3879 if (pAdapter->CommonCfg.bAPSDForcePowerSave != pAdapter->StaCfg.Psm)
3881 MlmeSetPsmBit(pAdapter, pAdapter->CommonCfg.bAPSDForcePowerSave);
3882 RTMPSendNullFrame(pAdapter, pAdapter->CommonCfg.TxRate, TRUE);
3884 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3887 #ifdef QOS_DLS_SUPPORT
3888 case RT_OID_802_11_SET_DLS:
3889 if (wrq->u.data.length != sizeof(ULONG))
3893 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3894 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3895 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3898 // tear down local dls table entry
3899 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3901 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3903 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3904 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3905 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3909 // tear down peer dls table entry
3910 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3912 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3914 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3915 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3916 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3921 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
3925 case RT_OID_802_11_SET_DLS_PARAM:
3926 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
3932 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
3933 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
3934 MlmeEnqueue(pAdapter,
3935 MLME_CNTL_STATE_MACHINE,
3936 RT_OID_802_11_SET_DLS_PARAM,
3937 sizeof(RT_802_11_DLS),
3939 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3942 #endif // QOS_DLS_SUPPORT //
3943 case RT_OID_802_11_SET_WMM:
3944 if (wrq->u.data.length != sizeof(BOOLEAN))
3948 Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
3949 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d) \n", pAdapter->CommonCfg.bWmmCapable));
3953 case OID_802_11_DISASSOCIATE:
3955 // Set NdisRadioStateOff to TRUE, instead of called MlmeRadioOff.
3956 // Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be 0
3957 // when query OID_802_11_BSSID_LIST.
3959 // TRUE: NumberOfItems will set to 0.
3960 // FALSE: NumberOfItems no change.
3962 pAdapter->CommonCfg.NdisRadioStateOff = TRUE;
3963 // Set to immediately send the media disconnect event
3964 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
3965 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE \n"));
3967 if (INFRA_ON(pAdapter))
3969 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
3971 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
3972 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
3975 MlmeEnqueue(pAdapter,
3976 MLME_CNTL_STATE_MACHINE,
3977 OID_802_11_DISASSOCIATE,
3981 StateMachineTouched = TRUE;
3985 #ifdef DOT11_N_SUPPORT
3986 case RT_OID_802_11_SET_IMME_BA_CAP:
3987 if (wrq->u.data.length != sizeof(OID_BACAP_STRUC))
3991 OID_BACAP_STRUC Orde ;
3992 Status = copy_from_user(&Orde, wrq->u.data.pointer, wrq->u.data.length);
3993 if (Orde.Policy > BA_NOTUSE)
3995 Status = NDIS_STATUS_INVALID_DATA;
3997 else if (Orde.Policy == BA_NOTUSE)
3999 pAdapter->CommonCfg.BACapability.field.Policy = BA_NOTUSE;
4000 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4001 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4002 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4003 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4004 pAdapter->CommonCfg.DesiredHtPhy.MimoPs= Orde.MMPSmode;
4005 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4007 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4008 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4009 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4013 pAdapter->CommonCfg.BACapability.field.AutoBA = Orde.AutoBA;
4014 pAdapter->CommonCfg.BACapability.field.Policy = IMMED_BA; // we only support immediate BA.
4015 pAdapter->CommonCfg.BACapability.field.MpduDensity = Orde.MpduDensity;
4016 pAdapter->CommonCfg.DesiredHtPhy.MpduDensity = Orde.MpduDensity;
4017 pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable = Orde.AmsduEnable;
4018 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
4019 pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
4020 pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
4023 pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
4024 pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
4025 pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
4027 if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
4028 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
4032 pAdapter->CommonCfg.REGBACapability.word = pAdapter->CommonCfg.BACapability.word;
4033 DBGPRINT(RT_DEBUG_TRACE, ("Set::(Orde.AutoBA = %d) (Policy=%d)(ReBAWinLimit=%d)(TxBAWinLimit=%d)(AutoMode=%d)\n",Orde.AutoBA, pAdapter->CommonCfg.BACapability.field.Policy,
4034 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit,pAdapter->CommonCfg.BACapability.field.TxBAWinLimit, pAdapter->CommonCfg.BACapability.field.AutoBA));
4035 DBGPRINT(RT_DEBUG_TRACE, ("Set::(MimoPs = %d)(AmsduEnable = %d) (AmsduSize=%d)(MpduDensity=%d)\n",pAdapter->CommonCfg.DesiredHtPhy.MimoPs, pAdapter->CommonCfg.DesiredHtPhy.AmsduEnable,
4036 pAdapter->CommonCfg.DesiredHtPhy.AmsduSize, pAdapter->CommonCfg.DesiredHtPhy.MpduDensity));
4040 case RT_OID_802_11_ADD_IMME_BA:
4041 DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
4042 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4047 OID_ADD_BA_ENTRY BA;
4048 MAC_TABLE_ENTRY *pEntry;
4050 Status = copy_from_user(&BA, wrq->u.data.pointer, wrq->u.data.length);
4053 Status = NDIS_STATUS_INVALID_DATA;
4058 //BATableInsertEntry
4059 //As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
4061 // in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
4062 pEntry = MacTableLookup(pAdapter, BA.MACAddr);
4065 DBGPRINT(RT_DEBUG_TRACE, ("RT_OID_802_11_ADD_IMME_BA. break on no connection.----:%x:%x\n", BA.MACAddr[4], BA.MACAddr[5]));
4068 if (BA.IsRecipient == FALSE)
4070 if (pEntry->bIAmBadAtheros == TRUE)
4071 pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = 0x10;
4073 BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
4077 //BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
4080 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_IMME_BA. Rec = %d. Mac = %x:%x:%x:%x:%x:%x . \n",
4081 BA.IsRecipient, BA.MACAddr[0], BA.MACAddr[1], BA.MACAddr[2], BA.MACAddr[2]
4082 , BA.MACAddr[4], BA.MACAddr[5]));
4087 case RT_OID_802_11_TEAR_IMME_BA:
4088 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
4089 if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
4093 POID_ADD_BA_ENTRY pBA;
4094 MAC_TABLE_ENTRY *pEntry;
4096 pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4100 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA kmalloc() can't allocate enough memory\n"));
4101 Status = NDIS_STATUS_FAILURE;
4105 Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
4106 DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
4108 if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
4110 Status = NDIS_STATUS_INVALID_DATA;
4114 if (pBA->IsRecipient == FALSE)
4116 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4117 DBGPRINT(RT_DEBUG_TRACE, (" pBA->IsRecipient == FALSE\n"));
4120 DBGPRINT(RT_DEBUG_TRACE, (" pBA->pEntry\n"));
4121 BAOriSessionTearDown(pAdapter, pEntry->Aid, pBA->TID, FALSE, TRUE);
4124 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4128 pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
4131 BARecSessionTearDown( pAdapter, (UCHAR)pEntry->Aid, pBA->TID, TRUE);
4134 DBGPRINT(RT_DEBUG_TRACE, ("Set :: Not found pEntry \n"));
4140 #endif // DOT11_N_SUPPORT //
4142 // For WPA_SUPPLICANT to set static wep key
4143 case OID_802_11_ADD_WEP:
4144 pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4149 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed!!\n"));
4152 Status = copy_from_user(pWepKey, wrq->u.data.pointer, wrq->u.data.length);
4156 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (length mismatch)!!\n"));
4160 KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
4161 // KeyIdx must be 0 ~ 3
4165 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, Failed (KeyIdx must be smaller than 4)!!\n"));
4169 UCHAR CipherAlg = 0;
4172 // set key material and key length
4173 NdisZeroMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, 16);
4174 pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4175 NdisMoveMemory(pAdapter->SharedKey[BSS0][KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4177 switch(pWepKey->KeyLength)
4180 CipherAlg = CIPHER_WEP64;
4183 CipherAlg = CIPHER_WEP128;
4186 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP, only support CIPHER_WEP64(len:5) & CIPHER_WEP128(len:13)!!\n"));
4190 pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CipherAlg;
4192 // Default key for tx (shared key)
4193 if (pWepKey->KeyIndex & 0x80000000)
4195 #ifdef WPA_SUPPLICANT_SUPPORT
4196 // set key material and key length
4197 NdisZeroMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, 16);
4198 pAdapter->StaCfg.DesireSharedKey[KeyIdx].KeyLen = (UCHAR) pWepKey->KeyLength;
4199 NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
4200 pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
4201 pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
4202 #endif // WPA_SUPPLICANT_SUPPORT //
4203 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4206 #ifdef WPA_SUPPLICANT_SUPPORT
4207 if ((pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) &&
4208 (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
4210 Key = pWepKey->KeyMaterial;
4212 // Set Group key material to Asic
4213 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4215 // Update WCID attribute table and IVEIV table for this group key table
4216 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4218 STA_PORT_SECURED(pAdapter);
4220 // Indicate Connected for GUI
4221 pAdapter->IndicateMediaState = NdisMediaStateConnected;
4223 else if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
4224 #endif // WPA_SUPPLICANT_SUPPORT
4226 Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
4228 // Set key material and cipherAlg to Asic
4229 AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
4231 if (pWepKey->KeyIndex & 0x80000000)
4233 PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
4234 // Assign group key info
4235 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
4236 // Assign pairwise key info
4237 RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
4240 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
4245 #ifdef WPA_SUPPLICANT_SUPPORT
4246 case OID_SET_COUNTERMEASURES:
4247 if (wrq->u.data.length != sizeof(int))
4252 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4254 pAdapter->StaCfg.bBlockAssoc = TRUE;
4256 // WPA MIC error should block association attempt for 60 seconds
4257 pAdapter->StaCfg.bBlockAssoc = FALSE;
4258 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_SET_COUNTERMEASURES bBlockAssoc=%s\n", pAdapter->StaCfg.bBlockAssoc ? "TRUE":"FALSE"));
4261 case RT_OID_WPA_SUPPLICANT_SUPPORT:
4262 if (wrq->u.data.length != sizeof(UCHAR))
4266 Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
4267 pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
4268 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
4271 case OID_802_11_DEAUTHENTICATION:
4272 if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
4276 MLME_DEAUTH_REQ_STRUCT *pInfo;
4277 MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
4279 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
4280 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
4281 MlmeDeauthReqAction(pAdapter, MsgElem);
4284 if (INFRA_ON(pAdapter))
4286 LinkDown(pAdapter, FALSE);
4287 pAdapter->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
4289 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DEAUTHENTICATION (Reason=%d)\n", pInfo->Reason));
4292 case OID_802_11_DROP_UNENCRYPTED:
4293 if (wrq->u.data.length != sizeof(int))
4298 Status = copy_from_user(&enabled, wrq->u.data.pointer, wrq->u.data.length);
4300 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
4302 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
4303 NdisAcquireSpinLock(&pAdapter->MacTabLock);
4304 pAdapter->MacTab.Content[BSSID_WCID].PortSecured = pAdapter->StaCfg.PortSecured;
4305 NdisReleaseSpinLock(&pAdapter->MacTabLock);
4306 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DROP_UNENCRYPTED (=%d)\n", enabled));
4309 case OID_802_11_SET_IEEE8021X:
4310 if (wrq->u.data.length != sizeof(BOOLEAN))
4314 Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
4315 pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
4316 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
4319 case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
4320 if (wrq->u.data.length != sizeof(BOOLEAN))
4324 Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
4325 pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
4326 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
4329 case OID_802_11_PMKID:
4330 pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
4332 if(pPmkId == NULL) {
4336 Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
4338 // check the PMKID information
4339 if (pPmkId->BSSIDInfoCount == 0)
4340 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
4343 PBSSID_INFO pBssIdInfo;
4347 for (BssIdx = 0; BssIdx < pPmkId->BSSIDInfoCount; BssIdx++)
4349 // point to the indexed BSSID_INFO structure
4350 pBssIdInfo = (PBSSID_INFO) ((PUCHAR) pPmkId + 2 * sizeof(UINT) + BssIdx * sizeof(BSSID_INFO));
4351 // Find the entry in the saved data base.
4352 for (CachedIdx = 0; CachedIdx < pAdapter->StaCfg.SavedPMKNum; CachedIdx++)
4354 // compare the BSSID
4355 if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
4359 // Found, replace it
4360 if (CachedIdx < PMKID_NO)
4362 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4363 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4364 pAdapter->StaCfg.SavedPMKNum++;
4366 // Not found, replace the last one
4369 // Randomly replace one
4370 CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
4371 DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
4372 NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
4379 #endif // WPA_SUPPLICANT_SUPPORT //
4384 case OID_802_11_SHORTRETRYLIMIT:
4385 if (wrq->u.data.length != sizeof(ULONG))
4389 Status = copy_from_user(&ShortRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4390 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4391 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
4392 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4393 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SHORTRETRYLIMIT (tx_rty_cfg.field.ShortRetryLimit=%d, ShortRetryLimit=%ld)\n", tx_rty_cfg.field.ShortRtyLimit, ShortRetryLimit));
4397 case OID_802_11_LONGRETRYLIMIT:
4398 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT \n"));
4399 if (wrq->u.data.length != sizeof(ULONG))
4403 Status = copy_from_user(&LongRetryLimit, wrq->u.data.pointer, wrq->u.data.length);
4404 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
4405 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
4406 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
4407 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_LONGRETRYLIMIT (tx_rty_cfg.field.LongRetryLimit= %d,LongRetryLimit=%ld)\n", tx_rty_cfg.field.LongRtyLimit, LongRetryLimit));
4411 case OID_802_11_WEPDEFAULTKEYVALUE:
4412 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE\n"));
4413 pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
4414 Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
4417 if ( pKey->Length != wrq->u.data.length)
4420 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYVALUE, Failed!!\n"));
4422 KeyIdx = pKey->KeyIndex & 0x0fffffff;
4423 DBGPRINT(RT_DEBUG_TRACE,("pKey->KeyIndex =%d, pKey->KeyLength=%d\n", pKey->KeyIndex, pKey->KeyLength));
4425 // it is a shared key
4430 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen = (UCHAR) pKey->KeyLength;
4431 NdisMoveMemory(&pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key, &pKey->KeyMaterial, pKey->KeyLength);
4432 if (pKey->KeyIndex & 0x80000000)
4434 // Default key for tx (shared key)
4435 pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
4437 //RestartAPIsRequired = TRUE;
4442 case OID_802_11_WEPDEFAULTKEYID:
4443 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_WEPDEFAULTKEYID \n"));
4445 if (wrq->u.data.length != sizeof(UCHAR))
4448 Status = copy_from_user(&pAdapter->StaCfg.DefaultKeyId, wrq->u.data.pointer, wrq->u.data.length);
4453 case OID_802_11_CURRENTCHANNEL:
4454 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CURRENTCHANNEL \n"));
4455 if (wrq->u.data.length != sizeof(UCHAR))
4459 Status = copy_from_user(&ctmp, wrq->u.data.pointer, wrq->u.data.length);
4460 sprintf(&ctmp,"%d", ctmp);
4461 Set_Channel_Proc(pAdapter, &ctmp);
4469 DBGPRINT(RT_DEBUG_TRACE, ("Set::unknown IOCTL's subcmd = 0x%08x\n", cmd));
4470 Status = -EOPNOTSUPP;
4478 INT RTMPQueryInformation(
4479 IN PRTMP_ADAPTER pAdapter,
4480 IN OUT struct ifreq *rq,
4483 struct iwreq *wrq = (struct iwreq *) rq;
4484 NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
4485 PNDIS_WLAN_BSSID_EX pBss;
4486 NDIS_802_11_SSID Ssid;
4487 NDIS_802_11_CONFIGURATION *pConfiguration = NULL;
4488 RT_802_11_LINK_STATUS *pLinkStatus = NULL;
4489 RT_802_11_STA_CONFIG *pStaConfig = NULL;
4490 NDIS_802_11_STATISTICS *pStatistics = NULL;
4491 NDIS_802_11_RTS_THRESHOLD RtsThresh;
4492 NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
4493 NDIS_802_11_POWER_MODE PowerMode;
4494 NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
4495 RT_802_11_PREAMBLE PreamType;
4496 NDIS_802_11_AUTHENTICATION_MODE AuthMode;
4497 NDIS_802_11_WEP_STATUS WepStatus;
4498 NDIS_MEDIA_STATE MediaState;
4499 ULONG BssBufSize, ulInfo=0, NetworkTypeList[4], apsd = 0;
4501 PUCHAR pBuf = NULL, pPtr;
4502 INT Status = NDIS_STATUS_SUCCESS;
4503 UINT we_version_compiled;
4504 UCHAR i, Padding = 0;
4506 UCHAR driverVersion[8];
4507 OID_SET_HT_PHYMODE *pHTPhyMode = NULL;
4512 DefaultKeyIdxValue *pKeyIdxValue;
4514 TX_RTY_CFG_STRUC tx_rty_cfg;
4515 ULONG ShortRetryLimit, LongRetryLimit;
4521 case RT_OID_DEVICE_NAME:
4522 wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
4523 Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
4525 case RT_OID_VERSION_INFO:
4526 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
4527 wrq->u.data.length = 8*sizeof(UCHAR);
4528 sprintf(&driverVersion[0], "%s", STA_DRIVER_VERSION);
4529 driverVersion[7] = '\0';
4530 if (copy_to_user(wrq->u.data.pointer, &driverVersion, wrq->u.data.length))
4535 case OID_802_11_BSSID_LIST:
4536 if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
4539 * Still scanning, indicate the caller should try again.
4541 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (Still scanning)\n"));
4544 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->ScanTab.BssNr));
4545 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
4546 // Claculate total buffer size required
4547 BssBufSize = sizeof(ULONG);
4549 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4551 // Align pointer to 4 bytes boundary.
4552 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
4555 BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4558 // For safety issue, we add 256 bytes just in case
4560 // Allocate the same size as passed from higher layer
4561 pBuf = kmalloc(BssBufSize, MEM_ALLOC_FLAG);
4567 // Init 802_11_BSSID_LIST_EX structure
4568 NdisZeroMemory(pBuf, BssBufSize);
4569 pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
4570 pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
4572 // Calculate total buffer length
4573 BssLen = 4; // Consist of NumberOfItems
4574 // Point to start of NDIS_WLAN_BSSID_EX
4575 // pPtr = pBuf + sizeof(ULONG);
4576 pPtr = (PUCHAR) &pBssidList->Bssid[0];
4577 for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
4579 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
4580 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
4581 if ((pAdapter->ScanTab.BssEntry[i].Hidden == 1) && (pAdapter->StaCfg.bShowHiddenSSID == FALSE))
4584 // We must return this SSID during 4way handshaking, otherwise Aegis will failed to parse WPA infomation
4585 // and then failed to send EAPOl farame.
4587 if ((pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAdapter->StaCfg.PortSecured != WPA_802_1X_PORT_SECURED))
4589 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4590 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4593 pBss->Ssid.SsidLength = 0;
4597 pBss->Ssid.SsidLength = pAdapter->ScanTab.BssEntry[i].SsidLen;
4598 NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
4600 pBss->Privacy = pAdapter->ScanTab.BssEntry[i].Privacy;
4601 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
4602 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
4603 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
4604 pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
4605 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
4607 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
4609 if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
4610 pBss->InfrastructureMode = Ndis802_11Infrastructure;
4612 pBss->InfrastructureMode = Ndis802_11IBSS;
4614 NdisMoveMemory(pBss->SupportedRates, pAdapter->ScanTab.BssEntry[i].SupRate, pAdapter->ScanTab.BssEntry[i].SupRateLen);
4615 NdisMoveMemory(pBss->SupportedRates + pAdapter->ScanTab.BssEntry[i].SupRateLen,
4616 pAdapter->ScanTab.BssEntry[i].ExtRate,
4617 pAdapter->ScanTab.BssEntry[i].ExtRateLen);
4619 if (pAdapter->ScanTab.BssEntry[i].VarIELen == 0)
4621 pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
4622 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4623 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4627 pBss->IELength = (ULONG)(sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen);
4628 pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs);
4629 NdisMoveMemory(pBss->IEs, &pAdapter->ScanTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
4630 NdisMoveMemory(pBss->IEs + sizeof(NDIS_802_11_FIXED_IEs), pAdapter->ScanTab.BssEntry[i].VarIEs, pAdapter->ScanTab.BssEntry[i].VarIELen);
4631 pPtr += pAdapter->ScanTab.BssEntry[i].VarIELen;
4633 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
4635 #if WIRELESS_EXT < 17
4636 if ((BssLen + pBss->Length) < wrq->u.data.length)
4637 BssLen += pBss->Length;
4640 pBssidList->NumberOfItems = i;
4644 BssLen += pBss->Length;
4648 #if WIRELESS_EXT < 17
4649 wrq->u.data.length = BssLen;
4651 if (BssLen > wrq->u.data.length)
4657 wrq->u.data.length = BssLen;
4659 Status = copy_to_user(wrq->u.data.pointer, pBssidList, BssLen);
4662 case OID_802_3_CURRENT_ADDRESS:
4663 wrq->u.data.length = MAC_ADDR_LEN;
4664 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
4666 case OID_GEN_MEDIA_CONNECT_STATUS:
4667 if (pAdapter->IndicateMediaState == NdisMediaStateConnected)
4668 MediaState = NdisMediaStateConnected;
4670 MediaState = NdisMediaStateDisconnected;
4672 wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
4673 Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
4675 case OID_802_11_BSSID:
4676 if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
4678 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Bssid, sizeof(NDIS_802_11_MAC_ADDRESS));
4683 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BSSID(=EMPTY)\n"));
4687 case OID_802_11_SSID:
4688 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
4689 NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
4690 Ssid.SsidLength = pAdapter->CommonCfg.SsidLen;
4691 memcpy(Ssid.Ssid, pAdapter->CommonCfg.Ssid, Ssid.SsidLength);
4692 wrq->u.data.length = sizeof(NDIS_802_11_SSID);
4693 Status = copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
4694 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid));
4696 case RT_OID_802_11_QUERY_LINK_STATUS:
4697 pLinkStatus = (RT_802_11_LINK_STATUS *) kmalloc(sizeof(RT_802_11_LINK_STATUS), MEM_ALLOC_FLAG);
4700 pLinkStatus->CurrTxRate = RateIdTo500Kbps[pAdapter->CommonCfg.TxRate]; // unit : 500 kbps
4701 pLinkStatus->ChannelQuality = pAdapter->Mlme.ChannelQuality;
4702 pLinkStatus->RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
4703 pLinkStatus->TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
4704 pLinkStatus->CentralChannel = pAdapter->CommonCfg.CentralChannel;
4705 wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
4706 Status = copy_to_user(wrq->u.data.pointer, pLinkStatus, wrq->u.data.length);
4708 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS\n"));
4712 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LINK_STATUS(kmalloc failed)\n"));
4716 case OID_802_11_CONFIGURATION:
4717 pConfiguration = (NDIS_802_11_CONFIGURATION *) kmalloc(sizeof(NDIS_802_11_CONFIGURATION), MEM_ALLOC_FLAG);
4720 pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
4721 pConfiguration->BeaconPeriod = pAdapter->CommonCfg.BeaconPeriod;
4722 pConfiguration->ATIMWindow = pAdapter->StaActive.AtimWin;
4723 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
4724 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
4725 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
4726 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
4727 pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
4728 kfree(pConfiguration);
4732 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(kmalloc failed)\n"));
4736 case RT_OID_802_11_SNR_0:
4737 if ((pAdapter->StaCfg.LastSNR0 > 0))
4739 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR0) * 3) / 16 ;
4740 wrq->u.data.length = sizeof(ulInfo);
4741 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4742 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_SNR_0(0x=%lx)\n", ulInfo));
4747 case RT_OID_802_11_SNR_1:
4748 if ((pAdapter->Antenna.field.RxPath > 1) &&
4749 (pAdapter->StaCfg.LastSNR1 > 0))
4751 ulInfo = ((0xeb - pAdapter->StaCfg.LastSNR1) * 3) / 16 ;
4752 wrq->u.data.length = sizeof(ulInfo);
4753 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4754 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(0x=%lx)\n",ulInfo));
4758 DBGPRINT(RT_DEBUG_TRACE,("Query::RT_OID_802_11_SNR_1(pAdapter->StaCfg.LastSNR1=%d)\n",pAdapter->StaCfg.LastSNR1));
4760 case OID_802_11_RSSI_TRIGGER:
4761 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0 - pAdapter->BbpRssiToDbmDelta;
4762 wrq->u.data.length = sizeof(ulInfo);
4763 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4764 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RSSI_TRIGGER(=%ld)\n", ulInfo));
4766 case OID_802_11_RSSI:
4767 case RT_OID_802_11_RSSI:
4768 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi0;
4769 wrq->u.data.length = sizeof(ulInfo);
4770 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4772 case RT_OID_802_11_RSSI_1:
4773 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi1;
4774 wrq->u.data.length = sizeof(ulInfo);
4775 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4777 case RT_OID_802_11_RSSI_2:
4778 ulInfo = pAdapter->StaCfg.RssiSample.LastRssi2;
4779 wrq->u.data.length = sizeof(ulInfo);
4780 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4782 case OID_802_11_STATISTICS:
4783 pStatistics = (NDIS_802_11_STATISTICS *) kmalloc(sizeof(NDIS_802_11_STATISTICS), MEM_ALLOC_FLAG);
4786 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
4787 // add the most up-to-date h/w raw counters into software counters
4788 NICUpdateRawCounters(pAdapter);
4790 // Sanity check for calculation of sucessful count
4791 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
4792 pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4794 pStatistics->TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart;
4795 pStatistics->MulticastTransmittedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastTransmittedFrameCount.QuadPart;
4796 pStatistics->FailedCount.QuadPart = pAdapter->WlanCounters.FailedCount.QuadPart;
4797 pStatistics->RetryCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
4798 pStatistics->MultipleRetryCount.QuadPart = pAdapter->WlanCounters.MultipleRetryCount.QuadPart;
4799 pStatistics->RTSSuccessCount.QuadPart = pAdapter->WlanCounters.RTSSuccessCount.QuadPart;
4800 pStatistics->RTSFailureCount.QuadPart = pAdapter->WlanCounters.RTSFailureCount.QuadPart;
4801 pStatistics->ACKFailureCount.QuadPart = pAdapter->WlanCounters.ACKFailureCount.QuadPart;
4802 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
4803 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
4804 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
4806 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
4808 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
4809 pStatistics->FrameDuplicateCount.u.LowPart = pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart / 100;
4811 wrq->u.data.length = sizeof(NDIS_802_11_STATISTICS);
4812 Status = copy_to_user(wrq->u.data.pointer, pStatistics, wrq->u.data.length);
4817 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS(kmalloc failed)\n"));
4821 case OID_GEN_RCV_OK:
4822 ulInfo = pAdapter->Counters8023.GoodReceives;
4823 wrq->u.data.length = sizeof(ulInfo);
4824 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4826 case OID_GEN_RCV_NO_BUFFER:
4827 ulInfo = pAdapter->Counters8023.RxNoBuffer;
4828 wrq->u.data.length = sizeof(ulInfo);
4829 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4831 case RT_OID_802_11_PHY_MODE:
4832 ulInfo = (ULONG)pAdapter->CommonCfg.PhyMode;
4833 wrq->u.data.length = sizeof(ulInfo);
4834 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4835 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PHY_MODE (=%ld)\n", ulInfo));
4837 case RT_OID_802_11_STA_CONFIG:
4838 pStaConfig = (RT_802_11_STA_CONFIG *) kmalloc(sizeof(RT_802_11_STA_CONFIG), MEM_ALLOC_FLAG);
4841 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG\n"));
4842 pStaConfig->EnableTxBurst = pAdapter->CommonCfg.bEnableTxBurst;
4843 pStaConfig->EnableTurboRate = 0;
4844 pStaConfig->UseBGProtection = pAdapter->CommonCfg.UseBGProtection;
4845 pStaConfig->UseShortSlotTime = pAdapter->CommonCfg.bUseShortSlotTime;
4846 //pStaConfig->AdhocMode = pAdapter->StaCfg.AdhocMode;
4847 pStaConfig->HwRadioStatus = (pAdapter->StaCfg.bHwRadio == TRUE) ? 1 : 0;
4848 pStaConfig->Rsv1 = 0;
4849 pStaConfig->SystemErrorBitmap = pAdapter->SystemErrorBitmap;
4850 wrq->u.data.length = sizeof(RT_802_11_STA_CONFIG);
4851 Status = copy_to_user(wrq->u.data.pointer, pStaConfig, wrq->u.data.length);
4856 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
4860 case OID_802_11_RTS_THRESHOLD:
4861 RtsThresh = pAdapter->CommonCfg.RtsThreshold;
4862 wrq->u.data.length = sizeof(RtsThresh);
4863 Status = copy_to_user(wrq->u.data.pointer, &RtsThresh, wrq->u.data.length);
4864 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_RTS_THRESHOLD(=%ld)\n", RtsThresh));
4866 case OID_802_11_FRAGMENTATION_THRESHOLD:
4867 FragThresh = pAdapter->CommonCfg.FragmentThreshold;
4868 if (pAdapter->CommonCfg.bUseZeroToDisableFragment == TRUE)
4870 wrq->u.data.length = sizeof(FragThresh);
4871 Status = copy_to_user(wrq->u.data.pointer, &FragThresh, wrq->u.data.length);
4872 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_FRAGMENTATION_THRESHOLD(=%ld)\n", FragThresh));
4874 case OID_802_11_POWER_MODE:
4875 PowerMode = pAdapter->StaCfg.WindowsPowerMode;
4876 wrq->u.data.length = sizeof(PowerMode);
4877 Status = copy_to_user(wrq->u.data.pointer, &PowerMode, wrq->u.data.length);
4878 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_POWER_MODE(=%d)\n", PowerMode));
4880 case RT_OID_802_11_RADIO:
4881 RadioState = (BOOLEAN) pAdapter->StaCfg.bSwRadio;
4882 wrq->u.data.length = sizeof(RadioState);
4883 Status = copy_to_user(wrq->u.data.pointer, &RadioState, wrq->u.data.length);
4884 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_RADIO (=%d)\n", RadioState));
4886 case OID_802_11_INFRASTRUCTURE_MODE:
4887 if (pAdapter->StaCfg.BssType == BSS_ADHOC)
4888 BssType = Ndis802_11IBSS;
4889 else if (pAdapter->StaCfg.BssType == BSS_INFRA)
4890 BssType = Ndis802_11Infrastructure;
4891 else if (pAdapter->StaCfg.BssType == BSS_MONITOR)
4892 BssType = Ndis802_11Monitor;
4894 BssType = Ndis802_11AutoUnknown;
4896 wrq->u.data.length = sizeof(BssType);
4897 Status = copy_to_user(wrq->u.data.pointer, &BssType, wrq->u.data.length);
4898 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_INFRASTRUCTURE_MODE(=%d)\n", BssType));
4900 case RT_OID_802_11_PREAMBLE:
4901 PreamType = pAdapter->CommonCfg.TxPreamble;
4902 wrq->u.data.length = sizeof(PreamType);
4903 Status = copy_to_user(wrq->u.data.pointer, &PreamType, wrq->u.data.length);
4904 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PREAMBLE(=%d)\n", PreamType));
4906 case OID_802_11_AUTHENTICATION_MODE:
4907 AuthMode = pAdapter->StaCfg.AuthMode;
4908 wrq->u.data.length = sizeof(AuthMode);
4909 Status = copy_to_user(wrq->u.data.pointer, &AuthMode, wrq->u.data.length);
4910 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_AUTHENTICATION_MODE(=%d)\n", AuthMode));
4912 case OID_802_11_WEP_STATUS:
4913 WepStatus = pAdapter->StaCfg.WepStatus;
4914 wrq->u.data.length = sizeof(WepStatus);
4915 Status = copy_to_user(wrq->u.data.pointer, &WepStatus, wrq->u.data.length);
4916 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEP_STATUS(=%d)\n", WepStatus));
4918 case OID_802_11_TX_POWER_LEVEL:
4919 wrq->u.data.length = sizeof(ULONG);
4920 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPower, wrq->u.data.length);
4921 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->CommonCfg.TxPower));
4923 case RT_OID_802_11_TX_POWER_LEVEL_1:
4924 wrq->u.data.length = sizeof(ULONG);
4925 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.TxPowerPercentage, wrq->u.data.length);
4926 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
4928 case OID_802_11_NETWORK_TYPES_SUPPORTED:
4929 if ((pAdapter->RfIcType == RFIC_2850) || (pAdapter->RfIcType == RFIC_2750))
4931 NetworkTypeList[0] = 3; // NumberOfItems = 3
4932 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4933 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4934 NetworkTypeList[3] = Ndis802_11OFDM5; // NetworkType[3] = 11a
4935 wrq->u.data.length = 16;
4936 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4940 NetworkTypeList[0] = 2; // NumberOfItems = 2
4941 NetworkTypeList[1] = Ndis802_11DS; // NetworkType[1] = 11b
4942 NetworkTypeList[2] = Ndis802_11OFDM24; // NetworkType[2] = 11g
4943 wrq->u.data.length = 12;
4944 Status = copy_to_user(wrq->u.data.pointer, &NetworkTypeList[0], wrq->u.data.length);
4946 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_NETWORK_TYPES_SUPPORTED\n"));
4948 case OID_802_11_NETWORK_TYPE_IN_USE:
4949 wrq->u.data.length = sizeof(ULONG);
4950 if (pAdapter->CommonCfg.PhyMode == PHY_11A)
4951 ulInfo = Ndis802_11OFDM5;
4952 else if ((pAdapter->CommonCfg.PhyMode == PHY_11BG_MIXED) || (pAdapter->CommonCfg.PhyMode == PHY_11G))
4953 ulInfo = Ndis802_11OFDM24;
4955 ulInfo = Ndis802_11DS;
4956 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4958 case RT_OID_802_11_QUERY_LAST_RX_RATE:
4959 ulInfo = (ULONG)pAdapter->LastRxRate;
4960 wrq->u.data.length = sizeof(ulInfo);
4961 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4962 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_RX_RATE (=%ld)\n", ulInfo));
4964 case RT_OID_802_11_QUERY_LAST_TX_RATE:
4965 //ulInfo = (ULONG)pAdapter->LastTxRate;
4966 ulInfo = (ULONG)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word;
4967 wrq->u.data.length = sizeof(ulInfo);
4968 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
4969 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_LAST_TX_RATE (=%lx)\n", ulInfo));
4971 case RT_OID_802_11_QUERY_EEPROM_VERSION:
4972 wrq->u.data.length = sizeof(ULONG);
4973 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->EepromVersion, wrq->u.data.length);
4975 case RT_OID_802_11_QUERY_FIRMWARE_VERSION:
4976 wrq->u.data.length = sizeof(ULONG);
4977 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->FirmwareVersion, wrq->u.data.length);
4979 case RT_OID_802_11_QUERY_NOISE_LEVEL:
4980 wrq->u.data.length = sizeof(UCHAR);
4981 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->BbpWriteLatch[66], wrq->u.data.length);
4982 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_NOISE_LEVEL (=%d)\n", pAdapter->BbpWriteLatch[66]));
4984 case RT_OID_802_11_EXTRA_INFO:
4985 wrq->u.data.length = sizeof(ULONG);
4986 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->ExtraInfo, wrq->u.data.length);
4987 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_EXTRA_INFO (=%ld)\n", pAdapter->ExtraInfo));
4989 case RT_OID_WE_VERSION_COMPILED:
4990 wrq->u.data.length = sizeof(UINT);
4991 we_version_compiled = WIRELESS_EXT;
4992 Status = copy_to_user(wrq->u.data.pointer, &we_version_compiled, wrq->u.data.length);
4994 case RT_OID_802_11_QUERY_APSD_SETTING:
4995 apsd = (pAdapter->CommonCfg.bAPSDCapable | (pAdapter->CommonCfg.bAPSDAC_BE << 1) | (pAdapter->CommonCfg.bAPSDAC_BK << 2)
4996 | (pAdapter->CommonCfg.bAPSDAC_VI << 3) | (pAdapter->CommonCfg.bAPSDAC_VO << 4) | (pAdapter->CommonCfg.MaxSPLength << 5));
4998 wrq->u.data.length = sizeof(ULONG);
4999 Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
5000 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",
5001 apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
5003 case RT_OID_802_11_QUERY_APSD_PSM:
5004 wrq->u.data.length = sizeof(ULONG);
5005 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
5006 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
5008 case RT_OID_802_11_QUERY_WMM:
5009 wrq->u.data.length = sizeof(BOOLEAN);
5010 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bWmmCapable, wrq->u.data.length);
5011 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_WMM (=%d)\n", pAdapter->CommonCfg.bWmmCapable));
5013 #ifdef WPA_SUPPLICANT_SUPPORT
5014 case RT_OID_NEW_DRIVER:
5017 wrq->u.data.length = sizeof(UCHAR);
5018 Status = copy_to_user(wrq->u.data.pointer, &enabled, wrq->u.data.length);
5019 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_NEW_DRIVER (=%d)\n", enabled));
5022 case RT_OID_WPA_SUPPLICANT_SUPPORT:
5023 wrq->u.data.length = sizeof(UCHAR);
5024 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.WpaSupplicantUP, wrq->u.data.length);
5025 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
5027 #endif // WPA_SUPPLICANT_SUPPORT //
5029 case RT_OID_DRIVER_DEVICE_NAME:
5030 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_DRIVER_DEVICE_NAME \n"));
5031 wrq->u.data.length = 16;
5032 if (copy_to_user(wrq->u.data.pointer, pAdapter->StaCfg.dev_name, wrq->u.data.length))
5037 case RT_OID_802_11_QUERY_HT_PHYMODE:
5038 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5041 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5042 pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
5043 pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
5044 pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
5045 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
5046 pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
5048 pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
5049 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5050 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5054 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5055 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5056 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5060 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5064 case RT_OID_802_11_COUNTRY_REGION:
5065 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_COUNTRY_REGION \n"));
5066 wrq->u.data.length = sizeof(ulInfo);
5067 ulInfo = pAdapter->CommonCfg.CountryRegionForABand;
5068 ulInfo = (ulInfo << 8)|(pAdapter->CommonCfg.CountryRegion);
5069 if (copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length))
5074 case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
5075 pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
5078 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
5079 pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
5080 pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
5081 pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
5082 pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
5083 pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
5085 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
5086 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
5090 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_HT_PHYMODE (PhyMode = %d, MCS =%d, BW = %d, STBC = %d, ExtOffset=%d)\n",
5091 pHTPhyMode->HtMode, pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->ExtOffset));
5092 DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (.word = %x )\n", pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.word));
5096 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_STA_CONFIG(kmalloc failed)\n"));
5100 case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
5101 wrq->u.data.length = sizeof(UCHAR);
5103 #ifdef MULTIPLE_CARD_SUPPORT
5105 #endif // MULTIPLE_CARD_SUPPORT //
5106 if (copy_to_user(wrq->u.data.pointer, &i, wrq->u.data.length))
5110 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_QUERY_MULTIPLE_CARD_SUPPORT(=%d) \n", i));
5113 case RT_OID_802_11_MAC_ADDRESS:
5114 wrq->u.data.length = MAC_ADDR_LEN;
5115 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5118 case RT_OID_802_11_MANUFACTUREROUI:
5119 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREROUI \n"));
5120 wrq->u.data.length = ManufacturerOUI_LEN;
5121 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
5124 case RT_OID_802_11_MANUFACTURERNAME:
5125 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTURERNAME \n"));
5126 wrq->u.data.length = strlen(ManufacturerNAME);
5127 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5130 case RT_OID_802_11_RESOURCETYPEIDNAME:
5131 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_RESOURCETYPEIDNAME \n"));
5132 wrq->u.data.length = strlen(ResourceTypeIdName);
5133 Status = copy_to_user(wrq->u.data.pointer, ResourceTypeIdName, wrq->u.data.length);
5136 case RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED:
5137 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRIVACYOPTIONIMPLEMENTED \n"));
5138 ulInfo = 1; // 1 is support wep else 2 is not support.
5139 wrq->u.data.length = sizeof(ulInfo);
5140 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5143 case RT_OID_802_11_POWERMANAGEMENTMODE:
5144 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_POWERMANAGEMENTMODE \n"));
5145 if (pAdapter->StaCfg.Psm == PSMP_ACTION)
5146 ulInfo = 1; // 1 is power active else 2 is power save.
5150 wrq->u.data.length = sizeof(ulInfo);
5151 Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
5154 case OID_802_11_WEPDEFAULTKEYVALUE:
5155 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_WEPDEFAULTKEYVALUE \n"));
5156 //KeyIdxValue.KeyIdx = pAd->PortCfg.MBSSID[pAd->IoctlIF].DefaultKeyId;
5157 pKeyIdxValue = wrq->u.data.pointer;
5158 DBGPRINT(RT_DEBUG_TRACE,("KeyIdxValue.KeyIdx = %d, \n",pKeyIdxValue->KeyIdx));
5159 valueLen = pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen;
5160 NdisMoveMemory(pKeyIdxValue->Value,
5161 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].Key,
5163 pKeyIdxValue->Value[valueLen]='\0';
5165 wrq->u.data.length = sizeof(DefaultKeyIdxValue);
5167 Status = copy_to_user(wrq->u.data.pointer, pKeyIdxValue, wrq->u.data.length);
5168 DBGPRINT(RT_DEBUG_TRACE,("DefaultKeyId = %d, total len = %d, str len=%d, KeyValue= %02x %02x %02x %02x \n", pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length, pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5169 pAdapter->SharedKey[BSS0][0].Key[0],
5170 pAdapter->SharedKey[BSS0][1].Key[0],
5171 pAdapter->SharedKey[BSS0][2].Key[0],
5172 pAdapter->SharedKey[BSS0][3].Key[0]));
5175 case OID_802_11_WEPDEFAULTKEYID:
5176 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPDEFAULTKEYID \n"));
5177 wrq->u.data.length = sizeof(UCHAR);
5178 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->StaCfg.DefaultKeyId, wrq->u.data.length);
5179 DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyId =%d \n", pAdapter->StaCfg.DefaultKeyId));
5182 case RT_OID_802_11_WEPKEYMAPPINGLENGTH:
5183 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_WEPKEYMAPPINGLENGTH \n"));
5184 wrq->u.data.length = sizeof(UCHAR);
5185 Status = copy_to_user(wrq->u.data.pointer,
5186 &pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].KeyLen,
5187 wrq->u.data.length);
5190 case OID_802_11_SHORTRETRYLIMIT:
5191 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_SHORTRETRYLIMIT \n"));
5192 wrq->u.data.length = sizeof(ULONG);
5193 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5194 ShortRetryLimit = tx_rty_cfg.field.ShortRtyLimit;
5195 DBGPRINT(RT_DEBUG_TRACE, ("ShortRetryLimit =%ld, tx_rty_cfg.field.ShortRetryLimit=%d\n", ShortRetryLimit, tx_rty_cfg.field.ShortRtyLimit));
5196 Status = copy_to_user(wrq->u.data.pointer, &ShortRetryLimit, wrq->u.data.length);
5199 case OID_802_11_LONGRETRYLIMIT:
5200 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_LONGRETRYLIMIT \n"));
5201 wrq->u.data.length = sizeof(ULONG);
5202 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
5203 LongRetryLimit = tx_rty_cfg.field.LongRtyLimit;
5204 DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld, tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
5205 Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
5208 case RT_OID_802_11_PRODUCTID:
5209 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
5212 sprintf(tmp, "%04x %04x\n", ((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idVendor ,((POS_COOKIE)pAdapter->OS_Cookie)->pUsb_Dev->descriptor.idProduct);
5215 wrq->u.data.length = strlen(tmp);
5216 Status = copy_to_user(wrq->u.data.pointer, tmp, wrq->u.data.length);
5219 case RT_OID_802_11_MANUFACTUREID:
5220 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_MANUFACTUREID \n"));
5221 wrq->u.data.length = strlen(ManufacturerNAME);
5222 Status = copy_to_user(wrq->u.data.pointer, ManufacturerNAME, wrq->u.data.length);
5225 case OID_802_11_CURRENTCHANNEL:
5226 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CURRENTCHANNEL \n"));
5227 wrq->u.data.length = sizeof(UCHAR);
5228 DBGPRINT(RT_DEBUG_TRACE, ("sizeof UCHAR=%d, channel=%d \n", sizeof(UCHAR), pAdapter->CommonCfg.Channel));
5229 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Channel, wrq->u.data.length);
5230 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5232 #endif //SNMP_SUPPORT
5234 case OID_802_11_BUILD_CHANNEL_EX:
5237 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_BUILD_CHANNEL_EX \n"));
5238 wrq->u.data.length = sizeof(UCHAR);
5239 #ifdef EXT_BUILD_CHANNEL_LIST
5240 DBGPRINT(RT_DEBUG_TRACE, ("Support EXT_BUILD_CHANNEL_LIST.\n"));
5243 DBGPRINT(RT_DEBUG_TRACE, ("Doesn't support EXT_BUILD_CHANNEL_LIST.\n"));
5245 #endif // EXT_BUILD_CHANNEL_LIST //
5246 Status = copy_to_user(wrq->u.data.pointer, &value, 1);
5247 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5251 case OID_802_11_GET_CH_LIST:
5253 PRT_CHANNEL_LIST_INFO pChListBuf;
5255 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CH_LIST \n"));
5256 if (pAdapter->ChannelListNum == 0)
5258 wrq->u.data.length = 0;
5262 pChListBuf = (RT_CHANNEL_LIST_INFO *) kmalloc(sizeof(RT_CHANNEL_LIST_INFO), MEM_ALLOC_FLAG);
5263 if (pChListBuf == NULL)
5265 wrq->u.data.length = 0;
5269 pChListBuf->ChannelListNum = pAdapter->ChannelListNum;
5270 for (i = 0; i < pChListBuf->ChannelListNum; i++)
5271 pChListBuf->ChannelList[i] = pAdapter->ChannelList[i].Channel;
5273 wrq->u.data.length = sizeof(RT_CHANNEL_LIST_INFO);
5274 Status = copy_to_user(wrq->u.data.pointer, pChListBuf, sizeof(RT_CHANNEL_LIST_INFO));
5275 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5282 case OID_802_11_GET_COUNTRY_CODE:
5283 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_COUNTRY_CODE \n"));
5284 wrq->u.data.length = 2;
5285 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.CountryCode, 2);
5286 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5289 case OID_802_11_GET_CHANNEL_GEOGRAPHY:
5290 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_GET_CHANNEL_GEOGRAPHY \n"));
5291 wrq->u.data.length = 1;
5292 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
5293 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5297 #ifdef QOS_DLS_SUPPORT
5298 case RT_OID_802_11_QUERY_DLS:
5299 wrq->u.data.length = sizeof(BOOLEAN);
5300 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5301 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5304 case RT_OID_802_11_QUERY_DLS_PARAM:
5306 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5307 if (pDlsInfo == NULL)
5310 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5312 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5315 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5316 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5317 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5318 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5324 #endif // QOS_DLS_SUPPORT //
5326 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5327 Status = -EOPNOTSUPP;
5333 INT rt28xx_sta_ioctl(
5334 IN struct net_device *net_dev,
5335 IN OUT struct ifreq *rq,
5339 VIRTUAL_ADAPTER *pVirtualAd = NULL;
5340 RTMP_ADAPTER *pAd = NULL;
5341 struct iwreq *wrq = (struct iwreq *) rq;
5342 BOOLEAN StateMachineTouched = FALSE;
5343 INT Status = NDIS_STATUS_SUCCESS;
5346 if (net_dev->priv_flags == INT_MAIN)
5348 pAd = net_dev->ml_priv;
5352 pVirtualAd = net_dev->ml_priv;
5353 pAd = pVirtualAd->RtmpDev->ml_priv;
5355 pObj = (POS_COOKIE) pAd->OS_Cookie;
5359 /* if 1st open fail, pAd will be free;
5360 So the net_dev->ml_priv will be NULL in 2rd open */
5364 //check if the interface is down
5365 if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
5368 DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
5373 { // determine this ioctl command is comming from which interface.
5374 pObj->ioctl_if_type = INT_MAIN;
5375 pObj->ioctl_if = MAIN_MBSSID;
5381 DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
5382 memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
5386 char *name=&wrq->u.name[0];
5387 rt_ioctl_giwname(net_dev, NULL, name, NULL);
5390 case SIOCGIWESSID: //Get ESSID
5392 struct iw_point *essid=&wrq->u.essid;
5393 rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
5396 case SIOCSIWESSID: //Set ESSID
5398 struct iw_point *essid=&wrq->u.essid;
5399 rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
5402 case SIOCSIWNWID: // set network id (the cell)
5403 case SIOCGIWNWID: // get network id
5404 Status = -EOPNOTSUPP;
5406 case SIOCSIWFREQ: //set channel/frequency (Hz)
5408 struct iw_freq *freq=&wrq->u.freq;
5409 rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
5412 case SIOCGIWFREQ: // get channel/frequency (Hz)
5414 struct iw_freq *freq=&wrq->u.freq;
5415 rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
5418 case SIOCSIWNICKN: //set node name/nickname
5420 struct iw_point *data=&wrq->u.data;
5421 rt_ioctl_siwnickn(net_dev, NULL, data, NULL);
5424 case SIOCGIWNICKN: //get node name/nickname
5426 struct iw_point *data=&wrq->u.data;
5427 rt_ioctl_giwnickn(net_dev, NULL, data, NULL);
5430 case SIOCGIWRATE: //get default bit rate (bps)
5431 rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
5433 case SIOCSIWRATE: //set default bit rate (bps)
5434 rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
5436 case SIOCGIWRTS: // get RTS/CTS threshold (bytes)
5438 struct iw_param *rts=&wrq->u.rts;
5439 rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
5442 case SIOCSIWRTS: //set RTS/CTS threshold (bytes)
5444 struct iw_param *rts=&wrq->u.rts;
5445 rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
5448 case SIOCGIWFRAG: //get fragmentation thr (bytes)
5450 struct iw_param *frag=&wrq->u.frag;
5451 rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
5454 case SIOCSIWFRAG: //set fragmentation thr (bytes)
5456 struct iw_param *frag=&wrq->u.frag;
5457 rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
5460 case SIOCGIWENCODE: //get encoding token & mode
5462 struct iw_point *erq=&wrq->u.encoding;
5464 rt_ioctl_giwencode(net_dev, NULL, erq, erq->pointer);
5467 case SIOCSIWENCODE: //set encoding token & mode
5469 struct iw_point *erq=&wrq->u.encoding;
5471 rt_ioctl_siwencode(net_dev, NULL, erq, erq->pointer);
5474 case SIOCGIWAP: //get access point MAC addresses
5476 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5477 rt_ioctl_giwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5480 case SIOCSIWAP: //set access point MAC addresses
5482 struct sockaddr *ap_addr=&wrq->u.ap_addr;
5483 rt_ioctl_siwap(net_dev, NULL, ap_addr, ap_addr->sa_data);
5486 case SIOCGIWMODE: //get operation mode
5488 __u32 *mode=&wrq->u.mode;
5489 rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
5492 case SIOCSIWMODE: //set operation mode
5494 __u32 *mode=&wrq->u.mode;
5495 rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
5498 case SIOCGIWSENS: //get sensitivity (dBm)
5499 case SIOCSIWSENS: //set sensitivity (dBm)
5500 case SIOCGIWPOWER: //get Power Management settings
5501 case SIOCSIWPOWER: //set Power Management settings
5502 case SIOCGIWTXPOW: //get transmit power (dBm)
5503 case SIOCSIWTXPOW: //set transmit power (dBm)
5504 case SIOCGIWRANGE: //Get range of parameters
5505 case SIOCGIWRETRY: //get retry limits and lifetime
5506 case SIOCSIWRETRY: //set retry limits and lifetime
5507 Status = -EOPNOTSUPP;
5510 subcmd = wrq->u.data.flags;
5511 if( subcmd & OID_GET_SET_TOGGLE)
5512 Status = RTMPSetInformation(pAd, rq, subcmd);
5514 Status = RTMPQueryInformation(pAd, rq, subcmd);
5517 if (wrq->u.data.pointer)
5519 if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
5521 wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
5522 if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
5526 case RTPRIV_IOCTL_SET:
5527 if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
5529 rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
5531 case RTPRIV_IOCTL_GSITESURVEY:
5532 RTMPIoctlGetSiteSurvey(pAd, wrq);
5535 case RTPRIV_IOCTL_MAC:
5536 RTMPIoctlMAC(pAd, wrq);
5538 case RTPRIV_IOCTL_E2P:
5539 RTMPIoctlE2PROM(pAd, wrq);
5545 DBGPRINT(RT_DEBUG_ERROR, ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
5546 Status = -EOPNOTSUPP;
5550 if(StateMachineTouched) // Upper layer sent a MLME-related operations
5551 RT28XX_MLME_HANDLER(pAd);
5557 ==========================================================================
5561 TRUE if all parameters are OK, FALSE otherwise
5562 ==========================================================================
5565 IN PRTMP_ADAPTER pAdapter,
5568 NDIS_802_11_SSID Ssid, *pSsid=NULL;
5569 BOOLEAN StateMachineTouched = FALSE;
5572 if( strlen(arg) <= MAX_LEN_OF_SSID)
5574 NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID));
5575 if (strlen(arg) != 0)
5577 NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
5578 Ssid.SsidLength = strlen(arg);
5582 Ssid.SsidLength = 0;
5583 memcpy(Ssid.Ssid, "", 0);
5584 pAdapter->StaCfg.BssType = BSS_INFRA;
5585 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5586 pAdapter->StaCfg.WepStatus = Ndis802_11EncryptionDisabled;
5590 if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
5592 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5593 DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
5596 pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
5597 pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
5598 pAdapter->bConfigChanged = TRUE;
5600 MlmeEnqueue(pAdapter,
5601 MLME_CNTL_STATE_MACHINE,
5603 sizeof(NDIS_802_11_SSID),
5606 StateMachineTouched = TRUE;
5607 DBGPRINT(RT_DEBUG_TRACE, ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength, Ssid.Ssid));
5612 if (StateMachineTouched) // Upper layer sent a MLME-related operations
5613 RT28XX_MLME_HANDLER(pAdapter);
5620 ==========================================================================
5622 Set WmmCapable Enable or Disable
5624 TRUE if all parameters are OK, FALSE otherwise
5625 ==========================================================================
5627 INT Set_WmmCapable_Proc(
5628 IN PRTMP_ADAPTER pAd,
5631 BOOLEAN bWmmCapable;
5633 bWmmCapable = simple_strtol(arg, 0, 10);
5635 if ((bWmmCapable == 1)
5637 && (pAd->NumberOfPipes >= 5)
5640 pAd->CommonCfg.bWmmCapable = TRUE;
5641 else if (bWmmCapable == 0)
5642 pAd->CommonCfg.bWmmCapable = FALSE;
5644 return FALSE; //Invalid argument
5646 DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
5647 pAd->CommonCfg.bWmmCapable));
5651 #endif // WMM_SUPPORT //
5654 ==========================================================================
5656 Set Network Type(Infrastructure/Adhoc mode)
5658 TRUE if all parameters are OK, FALSE otherwise
5659 ==========================================================================
5661 INT Set_NetworkType_Proc(
5662 IN PRTMP_ADAPTER pAdapter,
5667 if (strcmp(arg, "Adhoc") == 0)
5669 if (pAdapter->StaCfg.BssType != BSS_ADHOC)
5671 // Config has changed
5672 pAdapter->bConfigChanged = TRUE;
5673 if (MONITOR_ON(pAdapter))
5675 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5676 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5678 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5679 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5680 pAdapter->StaCfg.bAutoReconnect = TRUE;
5681 LinkDown(pAdapter, FALSE);
5683 if (INFRA_ON(pAdapter))
5685 //BOOLEAN Cancelled;
5686 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5687 // Since calling this indicate user don't want to connect to that SSID anymore.
5688 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5689 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5691 LinkDown(pAdapter, FALSE);
5693 DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
5696 pAdapter->StaCfg.BssType = BSS_ADHOC;
5697 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5698 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
5700 else if (strcmp(arg, "Infra") == 0)
5702 if (pAdapter->StaCfg.BssType != BSS_INFRA)
5704 // Config has changed
5705 pAdapter->bConfigChanged = TRUE;
5706 if (MONITOR_ON(pAdapter))
5708 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, STANORMAL);
5709 RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5711 RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5712 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5713 pAdapter->StaCfg.bAutoReconnect = TRUE;
5714 LinkDown(pAdapter, FALSE);
5716 if (ADHOC_ON(pAdapter))
5718 // Set the AutoReconnectSsid to prevent it reconnect to old SSID
5719 // Since calling this indicate user don't want to connect to that SSID anymore.
5720 pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
5721 NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
5723 LinkDown(pAdapter, FALSE);
5726 pAdapter->StaCfg.BssType = BSS_INFRA;
5727 pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
5728 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
5730 pAdapter->StaCfg.BssType = BSS_INFRA;
5732 else if (strcmp(arg, "Monitor") == 0)
5735 BCN_TIME_CFG_STRUC csr;
5736 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
5737 OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
5738 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
5739 // disable all periodic state machine
5740 pAdapter->StaCfg.bAutoReconnect = FALSE;
5741 // reset all mlme state machine
5742 RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
5743 DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
5744 if (pAdapter->CommonCfg.CentralChannel == 0)
5746 #ifdef DOT11_N_SUPPORT
5747 if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
5748 pAdapter->CommonCfg.CentralChannel = 36;
5750 #endif // DOT11_N_SUPPORT //
5751 pAdapter->CommonCfg.CentralChannel = 6;
5753 #ifdef DOT11_N_SUPPORT
5755 N_ChannelCheck(pAdapter);
5756 #endif // DOT11_N_SUPPORT //
5758 #ifdef DOT11_N_SUPPORT
5759 if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5760 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5761 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_ABOVE)
5763 // 40MHz ,control channel at lower
5764 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5765 bbpValue &= (~0x18);
5767 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5768 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5769 // RX : control channel at lower
5770 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5771 bbpValue &= (~0x20);
5772 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5774 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5775 Value &= 0xfffffffe;
5776 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5777 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
5778 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5779 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5780 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5781 pAdapter->CommonCfg.Channel,
5782 pAdapter->CommonCfg.CentralChannel));
5784 else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
5785 pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
5786 pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA == EXTCHA_BELOW)
5788 // 40MHz ,control channel at upper
5789 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5790 bbpValue &= (~0x18);
5792 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5793 pAdapter->CommonCfg.BBPCurrentBW = BW_40;
5794 RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
5796 RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
5798 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
5800 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
5801 pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
5802 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
5803 AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
5804 DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
5805 pAdapter->CommonCfg.Channel,
5806 pAdapter->CommonCfg.CentralChannel));
5809 #endif // DOT11_N_SUPPORT //
5812 RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4, &bbpValue);
5813 bbpValue &= (~0x18);
5814 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
5815 pAdapter->CommonCfg.BBPCurrentBW = BW_20;
5816 AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel, FALSE);
5817 AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
5818 DBGPRINT(RT_DEBUG_TRACE, ("BW_20, Channel(%d)\n", pAdapter->CommonCfg.Channel));
5820 // Enable Rx with promiscuous reception
5821 RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
5822 // ASIC supporsts sniffer function with replacing RSSI with timestamp.
5823 //RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
5825 //RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
5827 RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
5828 csr.field.bBeaconGen = 0;
5829 csr.field.bTBTTEnable = 0;
5830 csr.field.TsfSyncMode = 0;
5831 RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
5833 pAdapter->StaCfg.BssType = BSS_MONITOR;
5834 pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
5835 DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
5838 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
5839 pAdapter->StaCfg.WpaState = SS_NOTUSE;
5841 DBGPRINT(RT_DEBUG_TRACE, ("Set_NetworkType_Proc::(NetworkType=%d)\n", pAdapter->StaCfg.BssType));
5847 ==========================================================================
5849 Set Authentication mode
5851 TRUE if all parameters are OK, FALSE otherwise
5852 ==========================================================================
5854 INT Set_AuthMode_Proc(
5855 IN PRTMP_ADAPTER pAdapter,
5858 if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
5859 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
5860 else if ((strcmp(arg, "OPEN") == 0) || (strcmp(arg, "open") == 0))
5861 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
5862 else if ((strcmp(arg, "SHARED") == 0) || (strcmp(arg, "shared") == 0))
5863 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
5864 else if ((strcmp(arg, "WPAPSK") == 0) || (strcmp(arg, "wpapsk") == 0))
5865 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
5866 else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
5867 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
5868 else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
5869 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
5870 #ifdef WPA_SUPPLICANT_SUPPORT
5871 else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
5872 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
5873 else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
5874 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
5875 #endif // WPA_SUPPLICANT_SUPPORT //
5879 pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
5881 DBGPRINT(RT_DEBUG_TRACE, ("Set_AuthMode_Proc::(AuthMode=%d)\n", pAdapter->StaCfg.AuthMode));
5887 ==========================================================================
5891 TRUE if all parameters are OK, FALSE otherwise
5892 ==========================================================================
5894 INT Set_EncrypType_Proc(
5895 IN PRTMP_ADAPTER pAdapter,
5898 if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
5900 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5901 return TRUE; // do nothing
5903 pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
5904 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
5905 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
5907 else if ((strcmp(arg, "WEP") == 0) || (strcmp(arg, "wep") == 0))
5909 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5910 return TRUE; // do nothing
5912 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
5913 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
5914 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
5916 else if ((strcmp(arg, "TKIP") == 0) || (strcmp(arg, "tkip") == 0))
5918 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5919 return TRUE; // do nothing
5921 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption2Enabled;
5922 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
5923 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption2Enabled;
5925 else if ((strcmp(arg, "AES") == 0) || (strcmp(arg, "aes") == 0))
5927 if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
5928 return TRUE; // do nothing
5930 pAdapter->StaCfg.WepStatus = Ndis802_11Encryption3Enabled;
5931 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
5932 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
5937 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
5939 DBGPRINT(RT_DEBUG_TRACE, ("Set_EncrypType_Proc::(EncrypType=%d)\n", pAdapter->StaCfg.WepStatus));
5945 ==========================================================================
5949 TRUE if all parameters are OK, FALSE otherwise
5950 ==========================================================================
5952 INT Set_DefaultKeyID_Proc(
5953 IN PRTMP_ADAPTER pAdapter,
5958 KeyIdx = simple_strtol(arg, 0, 10);
5959 if((KeyIdx >= 1 ) && (KeyIdx <= 4))
5960 pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
5962 return FALSE; //Invalid argument
5964 DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
5970 ==========================================================================
5974 TRUE if all parameters are OK, FALSE otherwise
5975 ==========================================================================
5978 IN PRTMP_ADAPTER pAdapter,
5983 UCHAR CipherAlg=CIPHER_WEP64;
5985 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
5986 return TRUE; // do nothing
5988 KeyLen = strlen(arg);
5992 case 5: //wep 40 Ascii type
5993 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
5994 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
5995 CipherAlg = CIPHER_WEP64;
5996 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
5998 case 10: //wep 40 Hex type
5999 for(i=0; i < KeyLen; i++)
6001 if( !isxdigit(*(arg+i)) )
6002 return FALSE; //Not Hex value;
6004 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6005 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6006 CipherAlg = CIPHER_WEP64;
6007 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6009 case 13: //wep 104 Ascii type
6010 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
6011 memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
6012 CipherAlg = CIPHER_WEP128;
6013 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
6015 case 26: //wep 104 Hex type
6016 for(i=0; i < KeyLen; i++)
6018 if( !isxdigit(*(arg+i)) )
6019 return FALSE; //Not Hex value;
6021 pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
6022 AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
6023 CipherAlg = CIPHER_WEP128;
6024 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
6026 default: //Invalid argument
6027 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
6031 pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
6033 // Set keys (into ASIC)
6034 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6036 else // Old WEP stuff
6038 AsicAddSharedKeyEntry(pAdapter,
6041 pAdapter->SharedKey[BSS0][0].CipherAlg,
6042 pAdapter->SharedKey[BSS0][0].Key,
6050 ==========================================================================
6055 TRUE if all parameters are OK, FALSE otherwise
6056 ==========================================================================
6059 IN PRTMP_ADAPTER pAdapter,
6064 UCHAR CipherAlg=CIPHER_WEP64;
6066 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6067 return TRUE; // do nothing
6069 KeyLen = strlen(arg);
6073 case 5: //wep 40 Ascii type
6074 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6075 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6076 CipherAlg = CIPHER_WEP64;
6077 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6079 case 10: //wep 40 Hex type
6080 for(i=0; i < KeyLen; i++)
6082 if( !isxdigit(*(arg+i)) )
6083 return FALSE; //Not Hex value;
6085 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6086 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6087 CipherAlg = CIPHER_WEP64;
6088 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6090 case 13: //wep 104 Ascii type
6091 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen;
6092 memcpy(pAdapter->SharedKey[BSS0][1].Key, arg, KeyLen);
6093 CipherAlg = CIPHER_WEP128;
6094 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Ascii"));
6096 case 26: //wep 104 Hex type
6097 for(i=0; i < KeyLen; i++)
6099 if( !isxdigit(*(arg+i)) )
6100 return FALSE; //Not Hex value;
6102 pAdapter->SharedKey[BSS0][1].KeyLen = KeyLen / 2 ;
6103 AtoH(arg, pAdapter->SharedKey[BSS0][1].Key, KeyLen / 2);
6104 CipherAlg = CIPHER_WEP128;
6105 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
6107 default: //Invalid argument
6108 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
6111 pAdapter->SharedKey[BSS0][1].CipherAlg = CipherAlg;
6113 // Set keys (into ASIC)
6114 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6116 else // Old WEP stuff
6118 AsicAddSharedKeyEntry(pAdapter,
6121 pAdapter->SharedKey[BSS0][1].CipherAlg,
6122 pAdapter->SharedKey[BSS0][1].Key,
6130 ==========================================================================
6134 TRUE if all parameters are OK, FALSE otherwise
6135 ==========================================================================
6138 IN PRTMP_ADAPTER pAdapter,
6143 UCHAR CipherAlg=CIPHER_WEP64;
6145 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6146 return TRUE; // do nothing
6148 KeyLen = strlen(arg);
6152 case 5: //wep 40 Ascii type
6153 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6154 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6155 CipherAlg = CIPHER_WEP64;
6156 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6158 case 10: //wep 40 Hex type
6159 for(i=0; i < KeyLen; i++)
6161 if( !isxdigit(*(arg+i)) )
6162 return FALSE; //Not Hex value;
6164 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6165 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6166 CipherAlg = CIPHER_WEP64;
6167 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6169 case 13: //wep 104 Ascii type
6170 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen;
6171 memcpy(pAdapter->SharedKey[BSS0][2].Key, arg, KeyLen);
6172 CipherAlg = CIPHER_WEP128;
6173 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Ascii)\n", arg));
6175 case 26: //wep 104 Hex type
6176 for(i=0; i < KeyLen; i++)
6178 if( !isxdigit(*(arg+i)) )
6179 return FALSE; //Not Hex value;
6181 pAdapter->SharedKey[BSS0][2].KeyLen = KeyLen / 2 ;
6182 AtoH(arg, pAdapter->SharedKey[BSS0][2].Key, KeyLen / 2);
6183 CipherAlg = CIPHER_WEP128;
6184 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
6186 default: //Invalid argument
6187 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
6190 pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
6192 // Set keys (into ASIC)
6193 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6195 else // Old WEP stuff
6197 AsicAddSharedKeyEntry(pAdapter,
6200 pAdapter->SharedKey[BSS0][2].CipherAlg,
6201 pAdapter->SharedKey[BSS0][2].Key,
6209 ==========================================================================
6213 TRUE if all parameters are OK, FALSE otherwise
6214 ==========================================================================
6217 IN PRTMP_ADAPTER pAdapter,
6222 UCHAR CipherAlg=CIPHER_WEP64;
6224 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6225 return TRUE; // do nothing
6227 KeyLen = strlen(arg);
6231 case 5: //wep 40 Ascii type
6232 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6233 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6234 CipherAlg = CIPHER_WEP64;
6235 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6237 case 10: //wep 40 Hex type
6238 for(i=0; i < KeyLen; i++)
6240 if( !isxdigit(*(arg+i)) )
6241 return FALSE; //Not Hex value;
6243 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6244 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6245 CipherAlg = CIPHER_WEP64;
6246 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6248 case 13: //wep 104 Ascii type
6249 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen;
6250 memcpy(pAdapter->SharedKey[BSS0][3].Key, arg, KeyLen);
6251 CipherAlg = CIPHER_WEP128;
6252 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Ascii"));
6254 case 26: //wep 104 Hex type
6255 for(i=0; i < KeyLen; i++)
6257 if( !isxdigit(*(arg+i)) )
6258 return FALSE; //Not Hex value;
6260 pAdapter->SharedKey[BSS0][3].KeyLen = KeyLen / 2 ;
6261 AtoH(arg, pAdapter->SharedKey[BSS0][3].Key, KeyLen / 2);
6262 CipherAlg = CIPHER_WEP128;
6263 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
6265 default: //Invalid argument
6266 DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
6269 pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
6271 // Set keys (into ASIC)
6272 if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
6274 else // Old WEP stuff
6276 AsicAddSharedKeyEntry(pAdapter,
6279 pAdapter->SharedKey[BSS0][3].CipherAlg,
6280 pAdapter->SharedKey[BSS0][3].Key,
6289 ==========================================================================
6293 TRUE if all parameters are OK, FALSE otherwise
6294 ==========================================================================
6296 INT Set_WPAPSK_Proc(
6297 IN PRTMP_ADAPTER pAdapter,
6300 UCHAR keyMaterial[40];
6302 if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
6303 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
6304 (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
6306 return TRUE; // do nothing
6308 DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
6310 NdisZeroMemory(keyMaterial, 40);
6312 if ((strlen(arg) < 8) || (strlen(arg) > 64))
6314 DBGPRINT(RT_DEBUG_TRACE, ("Set failed!!(WPAPSK=%s), WPAPSK key-string required 8 ~ 64 characters \n", arg));
6318 if (strlen(arg) == 64)
6320 AtoH(arg, keyMaterial, 32);
6321 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6326 PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
6327 NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
6332 if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
6333 pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
6335 pAdapter->StaCfg.WpaState = SS_NOTUSE;
6339 // Start STA supplicant state machine
6340 pAdapter->StaCfg.WpaState = SS_START;
6347 ==========================================================================
6349 Set Power Saving mode
6351 TRUE if all parameters are OK, FALSE otherwise
6352 ==========================================================================
6354 INT Set_PSMode_Proc(
6355 IN PRTMP_ADAPTER pAdapter,
6358 if (pAdapter->StaCfg.BssType == BSS_INFRA)
6360 if ((strcmp(arg, "Max_PSP") == 0) ||
6361 (strcmp(arg, "max_psp") == 0) ||
6362 (strcmp(arg, "MAX_PSP") == 0))
6364 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6365 // to exclude certain situations.
6366 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6367 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
6368 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
6369 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6370 pAdapter->StaCfg.DefaultListenCount = 5;
6373 else if ((strcmp(arg, "Fast_PSP") == 0) ||
6374 (strcmp(arg, "fast_psp") == 0) ||
6375 (strcmp(arg, "FAST_PSP") == 0))
6377 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6378 // to exclude certain situations.
6379 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6380 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6381 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
6382 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
6383 pAdapter->StaCfg.DefaultListenCount = 3;
6385 else if ((strcmp(arg, "Legacy_PSP") == 0) ||
6386 (strcmp(arg, "legacy_psp") == 0) ||
6387 (strcmp(arg, "LEGACY_PSP") == 0))
6389 // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
6390 // to exclude certain situations.
6391 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6392 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6393 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeLegacy_PSP;
6394 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeLegacy_PSP;
6395 pAdapter->StaCfg.DefaultListenCount = 3;
6399 //Default Ndis802_11PowerModeCAM
6400 // clear PSM bit immediately
6401 MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
6402 OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
6403 if (pAdapter->StaCfg.bWindowsACCAMEnable == FALSE)
6404 pAdapter->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
6405 pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
6408 DBGPRINT(RT_DEBUG_TRACE, ("Set_PSMode_Proc::(PSMode=%ld)\n", pAdapter->StaCfg.WindowsPowerMode));
6417 #ifdef WPA_SUPPLICANT_SUPPORT
6419 ==========================================================================
6421 Set WpaSupport flag.
6423 0: Driver ignore wpa_supplicant.
6424 1: wpa_supplicant initiates scanning and AP selection.
6425 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters.
6427 TRUE if all parameters are OK, FALSE otherwise
6428 ==========================================================================
6430 INT Set_Wpa_Support(
6431 IN PRTMP_ADAPTER pAd,
6435 if ( simple_strtol(arg, 0, 10) == 0)
6436 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6437 else if ( simple_strtol(arg, 0, 10) == 1)
6438 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
6439 else if ( simple_strtol(arg, 0, 10) == 2)
6440 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE_WITH_WEB_UI;
6442 pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
6444 DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
6448 #endif // WPA_SUPPLICANT_SUPPORT //
6452 ==========================================================================
6456 pAdapter Pointer to our adapter
6457 wrq Pointer to the ioctl argument
6464 1.) iwpriv ra0 mac 0 ==> read MAC where Addr=0x0
6465 2.) iwpriv ra0 mac 0=12 ==> write MAC where Addr=0x0, value=12
6466 ==========================================================================
6469 IN PRTMP_ADAPTER pAdapter,
6470 IN struct iwreq *wrq)
6478 UCHAR temp[16], temp2[16];
6479 UINT32 macValue = 0;
6483 memset(msg, 0x00, 1024);
6484 if (wrq->u.data.length > 1) //No parameters.
6486 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6489 //Parsing Read or Write
6494 if ((value = rtstrchr(this_char, '=')) != NULL)
6497 if (!value || !*value)
6500 if(strlen(this_char) > 4)
6503 j = strlen(this_char);
6506 if(this_char[j] > 'f' || this_char[j] < '0')
6511 k = j = strlen(this_char);
6514 this_char[4-k+j] = this_char[j];
6518 this_char[3-k++]='0';
6521 if(strlen(this_char) == 4)
6523 AtoH(this_char, temp, 2);
6524 macAddr = *temp*256 + temp[1];
6525 if (macAddr < 0xFFFF)
6527 RTMP_IO_READ32(pAdapter, macAddr, &macValue);
6528 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%lx, MacValue=%x\n", macAddr, macValue));
6529 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr , macValue);
6532 {//Invalid parametes, so default printk all bbp
6539 memcpy(&temp2, value, strlen(value));
6540 temp2[strlen(value)] = '\0';
6543 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6546 j = strlen(this_char);
6549 if(this_char[j] > 'f' || this_char[j] < '0')
6556 if(temp2[j] > 'f' || temp2[j] < '0')
6561 k = j = strlen(this_char);
6564 this_char[4-k+j] = this_char[j];
6568 this_char[3-k++]='0';
6572 k = j = strlen(temp2);
6575 temp2[8-k+j] = temp2[j];
6583 AtoH(this_char, temp, 2);
6584 macAddr = *temp*256 + temp[1];
6586 AtoH(temp2, temp, 4);
6587 macValue = *temp*256*256*256 + temp[1]*256*256 + temp[2]*256 + temp[3];
6590 if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
6592 // 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
6593 if (macValue & 0x000000ff)
6595 pAdapter->BbpTuning.bEnable = TRUE;
6596 DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
6601 pAdapter->BbpTuning.bEnable = FALSE;
6602 R66 = 0x26 + GET_LNA_GAIN(pAdapter);
6603 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R66, (0x26 + GET_LNA_GAIN(pAdapter)));
6604 DBGPRINT(RT_DEBUG_TRACE,("turn off R17 tuning, restore to 0x%02x\n", R66));
6609 DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
6611 RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
6612 sprintf(msg+strlen(msg), "[0x%08lX]:%08X ", macAddr, macValue);
6617 if(strlen(msg) == 1)
6618 sprintf(msg+strlen(msg), "===>Error command format!");
6620 // Copy the information into the user buffer
6621 wrq->u.data.length = strlen(msg);
6622 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6624 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
6628 ==========================================================================
6632 pAdapter Pointer to our adapter
6633 wrq Pointer to the ioctl argument
6640 1.) iwpriv ra0 e2p 0 ==> read E2PROM where Addr=0x0
6641 2.) iwpriv ra0 e2p 0=1234 ==> write E2PROM where Addr=0x0, value=1234
6642 ==========================================================================
6644 VOID RTMPIoctlE2PROM(
6645 IN PRTMP_ADAPTER pAdapter,
6646 IN struct iwreq *wrq)
6654 UCHAR temp[16], temp2[16];
6659 memset(msg, 0x00, 1024);
6660 if (wrq->u.data.length > 1) //No parameters.
6662 Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
6665 //Parsing Read or Write
6672 if ((value = rtstrchr(this_char, '=')) != NULL)
6675 if (!value || !*value)
6679 if(strlen(this_char) > 4)
6682 j = strlen(this_char);
6685 if(this_char[j] > 'f' || this_char[j] < '0')
6690 k = j = strlen(this_char);
6693 this_char[4-k+j] = this_char[j];
6697 this_char[3-k++]='0';
6700 if(strlen(this_char) == 4)
6702 AtoH(this_char, temp, 2);
6703 eepAddr = *temp*256 + temp[1];
6704 if (eepAddr < 0xFFFF)
6706 RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
6707 sprintf(msg+strlen(msg), "[0x%04X]:0x%04X ", eepAddr , eepValue);
6710 {//Invalid parametes, so default printk all bbp
6717 memcpy(&temp2, value, strlen(value));
6718 temp2[strlen(value)] = '\0';
6721 if((strlen(this_char) > 4) || strlen(temp2) > 8)
6724 j = strlen(this_char);
6727 if(this_char[j] > 'f' || this_char[j] < '0')
6733 if(temp2[j] > 'f' || temp2[j] < '0')
6738 k = j = strlen(this_char);
6741 this_char[4-k+j] = this_char[j];
6745 this_char[3-k++]='0';
6749 k = j = strlen(temp2);
6752 temp2[4-k+j] = temp2[j];
6759 AtoH(this_char, temp, 2);
6760 eepAddr = *temp*256 + temp[1];
6762 AtoH(temp2, temp, 2);
6763 eepValue = *temp*256 + temp[1];
6765 RT28xx_EEPROM_WRITE16(pAdapter, eepAddr, eepValue);
6766 sprintf(msg+strlen(msg), "[0x%02X]:%02X ", eepAddr, eepValue);
6770 if(strlen(msg) == 1)
6771 sprintf(msg+strlen(msg), "===>Error command format!");
6774 // Copy the information into the user buffer
6775 wrq->u.data.length = strlen(msg);
6776 Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
6778 DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
6785 INT Set_TGnWifiTest_Proc(
6786 IN PRTMP_ADAPTER pAd,
6789 if (simple_strtol(arg, 0, 10) == 0)
6790 pAd->StaCfg.bTGnWifiTest = FALSE;
6792 pAd->StaCfg.bTGnWifiTest = TRUE;
6794 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_TGnWifiTest_Proc::(bTGnWifiTest=%d)\n", pAd->StaCfg.bTGnWifiTest));
6798 INT Set_LongRetryLimit_Proc(
6799 IN PRTMP_ADAPTER pAdapter,
6802 TX_RTY_CFG_STRUC tx_rty_cfg;
6803 UCHAR LongRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6805 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6806 tx_rty_cfg.field.LongRtyLimit = LongRetryLimit;
6807 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6808 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_LongRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6812 INT Set_ShortRetryLimit_Proc(
6813 IN PRTMP_ADAPTER pAdapter,
6816 TX_RTY_CFG_STRUC tx_rty_cfg;
6817 UCHAR ShortRetryLimit = (UCHAR)simple_strtol(arg, 0, 10);
6819 RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
6820 tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
6821 RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
6822 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
6826 #ifdef EXT_BUILD_CHANNEL_LIST
6827 INT Set_Ieee80211dClientMode_Proc(
6828 IN PRTMP_ADAPTER pAdapter,
6831 if (simple_strtol(arg, 0, 10) == 0)
6832 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_None;
6833 else if (simple_strtol(arg, 0, 10) == 1)
6834 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Flexible;
6835 else if (simple_strtol(arg, 0, 10) == 2)
6836 pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
6840 DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
6843 #endif // EXT_BUILD_CHANNEL_LIST //
6845 #ifdef CARRIER_DETECTION_SUPPORT
6846 INT Set_CarrierDetect_Proc(
6847 IN PRTMP_ADAPTER pAd,
6850 if (simple_strtol(arg, 0, 10) == 0)
6851 pAd->CommonCfg.CarrierDetect.Enable = FALSE;
6853 pAd->CommonCfg.CarrierDetect.Enable = TRUE;
6855 DBGPRINT(RT_DEBUG_TRACE, ("IF Set_CarrierDetect_Proc::(CarrierDetect.Enable=%d)\n", pAd->CommonCfg.CarrierDetect.Enable));
6858 #endif // CARRIER_DETECTION_SUPPORT //
6861 INT Show_Adhoc_MacTable_Proc(
6862 IN PRTMP_ADAPTER pAd,
6867 sprintf(extra, "\n");
6869 #ifdef DOT11_N_SUPPORT
6870 sprintf(extra + strlen(extra), "HT Operating Mode : %d\n", pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode);
6871 #endif // DOT11_N_SUPPORT //
6873 sprintf(extra + strlen(extra), "\n%-19s%-4s%-4s%-7s%-7s%-7s%-10s%-6s%-6s%-6s%-6s\n",
6874 "MAC", "AID", "BSS", "RSSI0", "RSSI1", "RSSI2", "PhMd", "BW", "MCS", "SGI", "STBC");
6876 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
6878 PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
6880 if (strlen(extra) > (IW_PRIV_SIZE_MASK - 30))
6882 if ((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
6884 sprintf(extra + strlen(extra), "%02X:%02X:%02X:%02X:%02X:%02X ",
6885 pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
6886 pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
6887 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->Aid);
6888 sprintf(extra + strlen(extra), "%-4d", (int)pEntry->apidx);
6889 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi0);
6890 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi1);
6891 sprintf(extra + strlen(extra), "%-7d", pEntry->RssiSample.AvgRssi2);
6892 sprintf(extra + strlen(extra), "%-10s", GetPhyMode(pEntry->HTPhyMode.field.MODE));
6893 sprintf(extra + strlen(extra), "%-6s", GetBW(pEntry->HTPhyMode.field.BW));
6894 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.MCS);
6895 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.ShortGI);
6896 sprintf(extra + strlen(extra), "%-6d", pEntry->HTPhyMode.field.STBC);
6897 sprintf(extra + strlen(extra), "%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
6898 (pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
6899 sprintf(extra, "%s\n", extra);