📄 rtusb_info.c
字号:
DBGPRINT_RAW(RT_DEBUG_TEMP,"WPAPSK Key : ");
for(i = 0; i < 32; i++)
DBGPRINT_RAW(RT_DEBUG_TEMP,"%x ", keyMaterial[i]);
DBGPRINT_RAW(RT_DEBUG_TEMP,"\n");
NdisMoveMemory(pAdapter->PortCfg.PskKey.Key, keyMaterial, 32);
NdisMoveMemory(Key.KeyMaterial, keyMaterial, 32);
}
else
return -EOPNOTSUPP;
RTUSBEnqueueCmdFromNdis(pAdapter, OID_802_11_ADD_KEY, TRUE, &Key, sizeof(Key));
pAdapter->PortCfg.WepStatus= Ndis802_11Encryption2Enabled;
pAdapter->PortCfg.PairCipher= Ndis802_11Encryption2Enabled;
pAdapter->PortCfg.GroupCipher= Ndis802_11Encryption2Enabled;
pAdapter->PortCfg.CipherAlg= CIPHER_TKIP;
// Start STA supplicant state machine
return 0;
}
static int rtusb_ioctl_setpsm(struct net_device *dev, struct iw_request_info *info,
void *w, char *extra)
{
PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv;
int *param = (int *) extra;
switch(param[0])
{
case 0:
// clear PSM bit immediately
MlmeSetPsmBit(pAdapter, PWR_ACTIVE);
pAdapter->PortCfg.RecvDtim = TRUE;
pAdapter->PortCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
break;
case 1:
// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
// to exclude certain situations.
pAdapter->PortCfg.RecvDtim = TRUE;
pAdapter->PortCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
pAdapter->PortCfg.DefaultListenCount = 3;
break;
default:
return -EOPNOTSUPP;
}
return 0;
}
static const iw_handler rtusb_handler[] =
{
(iw_handler) NULL, /* SIOCSIWCOMMIT */
(iw_handler) rtusb_ioctl_giwname, /* SIOCGIWNAME 1 */
(iw_handler) NULL, /* SIOCSIWNWID */
(iw_handler) NULL, /* SIOCGIWNWID */
(iw_handler) rtusb_ioctl_siwfreq, /* SIOCSIWFREQ */
(iw_handler) rtusb_ioctl_giwfreq, /* SIOCGIWFREQ 5*/
(iw_handler) rtusb_ioctl_siwmode, /* SIOCSIWMODE */
(iw_handler) rtusb_ioctl_giwmode, /* SIOCGIWMODE */
(iw_handler) NULL, /* SIOCSIWSENS */
(iw_handler) NULL, /* SIOCGIWSENS */
(iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
(iw_handler) rtusb_ioctl_giwrange, /* SIOCGIWRANGE 11 */
(iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
(iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
(iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
(iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS f*/
(iw_handler) NULL, /* SIOCSIWSPY */
(iw_handler) NULL, /* SIOCGIWSPY */
(iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* SIOCSIWAP */
(iw_handler) rtusb_ioctl_giwap, /* SIOCGIWAP 0x15*/
(iw_handler) NULL, /* -- hole -- 0x16 */
(iw_handler) rtusb_ioctl_iwaplist, /* SIOCGIWAPLIST */
#ifdef SIOCGIWSCAN
(iw_handler) rtusb_ioctl_siwscan, /* SIOCSIWSCAN 0x18*/
(iw_handler) rtusb_ioctl_giwscan, /* SIOCGIWSCAN */
#else
(iw_handler) NULL, /* SIOCSIWSCAN */
(iw_handler) NULL, /* SIOCGIWSCAN */
#endif /* SIOCGIWSCAN */
(iw_handler) rtusb_ioctl_siwessid, /* SIOCSIWESSID */
(iw_handler) rtusb_ioctl_giwessid, /* SIOCGIWESSID */
(iw_handler) rtusb_ioctl_siwnickn, /* SIOCSIWNICKN */
(iw_handler) rtusb_ioctl_giwnickn, /* SIOCGIWNICKN 1d*/
(iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* SIOCSIWRATE 20*/
(iw_handler) NULL, /* SIOCGIWRATE */
(iw_handler) rtusb_ioctl_siwrts, /* SIOCSIWRTS */
(iw_handler) rtusb_ioctl_giwrts, /* SIOCGIWRTS */
(iw_handler) rtusb_ioctl_siwfrag, /* SIOCSIWFRAG */
(iw_handler) rtusb_ioctl_giwfrag, /* SIOCGIWFRAG 25*/
(iw_handler) NULL, /* SIOCSIWTXPOW */
(iw_handler) NULL, /* SIOCGIWTXPOW */
(iw_handler) NULL, /* SIOCSIWRETRY */
(iw_handler) NULL, /* SIOCGIWRETRY 29*/
(iw_handler) rtusb_ioctl_siwencode, /* SIOCSIWENCODE 2a*/
(iw_handler) rtusb_ioctl_giwencode, /* SIOCGIWENCODE 2b*/
(iw_handler) NULL, /* SIOCSIWPOWER 2c*/
(iw_handler) NULL, /* SIOCGIWPOWER 2d*/
};
static const iw_handler rtusb_priv_handlers[] = {
(iw_handler) NULL, /* SIOCWFIRSTPRIV+0 */
(iw_handler) NULL, /* SIOCWFIRSTPRIV+3 */
(iw_handler) rtusb_ioctl_setauth, /* SIOCWFIRSTPRIV+2 */
(iw_handler) NULL, /* SIOCWFIRSTPRIV+3 */
(iw_handler) rtusb_ioctl_setencryp, /* SIOCWFIRSTPRIV+4 */
(iw_handler) rtusb_ioctl_setwpapsk, /* SIOCWFIRSTPRIV+5 */
(iw_handler) rtusb_ioctl_setpsm, /* SIOCWFIRSTPRIV+6 */
// (iw_handler) rtusb_ioctl_setkeyid, /* SIOCWFIRSTPRIV+1 */
};
struct iw_priv_args privtab[] = {
// { RTPRIV_IOCTL_SET,
// IW_PRIV_TYPE_INT |1, 0, ""}, // Variable arg count
{ 1,
IW_PRIV_TYPE_INT |1, 0, ""}, // Variable arg count
// { RTPRIV_IOCTL_KEYID,
// IW_PRIV_TYPE_INT |1, 0, "kid"}, // Variable arg count
{ RTPRIV_IOCTL_AUTH,
IW_PRIV_TYPE_INT |1, 0, "auth"}, // Variable arg count
{ RTPRIV_IOCTL_WEPSTATUS,
IW_PRIV_TYPE_INT |1, 0, "enc"}, // Variable arg count
{ RTPRIV_IOCTL_WPAPSK,
IW_PRIV_TYPE_CHAR |64, 0, "wpapsk"}, // Variable arg count
{ RTPRIV_IOCTL_PSM,
IW_PRIV_TYPE_INT |1, 0, "psm"}, // Variable arg count
#if 0
{ RTPRIV_IOCTL_BBP,
IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
"bbp"},
{ RTPRIV_IOCTL_MAC,
IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
"mac"}
#endif
};
const struct iw_handler_def rt2500usb_iw_handler_def =
{
#define N(a) (sizeof (a) / sizeof (a[0]))
.standard = (iw_handler *) rtusb_handler,
.num_standard = sizeof(rtusb_handler) / sizeof(iw_handler),
.private = (iw_handler *) rtusb_priv_handlers,
.num_private = N(rtusb_priv_handlers),
.private_args = (struct iw_priv_args *) privtab,
.num_private_args = N(privtab),
};
INT RTMPQueryInformation(
IN PRT2570ADAPTER pAdapter,
IN OUT struct ifreq *rq,
IN INT cmd)
{
struct iwreq *wrq = (struct iwreq *) rq;
NDIS_802_11_BSSID_LIST_EX *pBssidList = NULL;
PNDIS_WLAN_BSSID_EX pBss;
NDIS_802_11_SSID Ssid;
NDIS_802_11_CONFIGURATION Configuration;
RT_802_11_LINK_STATUS LinkStatus;
NDIS_802_11_STATISTICS Statistics;
NDIS_802_11_RTS_THRESHOLD RtsThresh;
NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh;
NDIS_802_11_POWER_MODE PowerMode;
NDIS_802_11_NETWORK_INFRASTRUCTURE BssType;
RT_802_11_PREAMBLE PreamType;
NDIS_802_11_AUTHENTICATION_MODE AuthMode;
NDIS_802_11_WEP_STATUS WepStatus;
RT_VERSION_INFO DriverVersionInfo;
ULONG BssBufSize;
ULONG BssLen;
ULONG ulInfo = 0;
PUCHAR pBuf = NULL;
PUCHAR pPtr;
INT Status = NDIS_STATUS_SUCCESS;
UCHAR Padding;
UINT i;
BOOLEAN RadioState;
UCHAR LastR17Value;
switch(cmd) {
case RT_OID_DEVICE_NAME:
DBGPRINT(RT_DEBUG_INFO, "Query::RT_OID_DEVICE_NAME\n");
wrq->u.data.length = sizeof(NIC_DEVICE_NAME);
copy_to_user(wrq->u.data.pointer, NIC_DEVICE_NAME, wrq->u.data.length);
break;
case RT_OID_VERSION_INFO:
DBGPRINT(RT_DEBUG_INFO, "Query::RT_OID_VERSION_INFO \n");
DriverVersionInfo.DriverMajorVersion = DRV_MAJORVERSION;
DriverVersionInfo.DriverMinorVersion = DRV_MINORVERSION;
DriverVersionInfo.DriverSubVersion = DRV_SUBVERSION;
DriverVersionInfo.DriverTestVersion = DRV_TESTVERSION;
DriverVersionInfo.DriverBuildYear = DRV_YEAR;
DriverVersionInfo.DriverBuildMonth = DRV_MONTH;
DriverVersionInfo.DriverBuildDay = DRV_DAY;
wrq->u.data.length = sizeof(RT_VERSION_INFO);
copy_to_user(wrq->u.data.pointer, &DriverVersionInfo, wrq->u.data.length);
break;
case OID_802_11_BSSID_LIST:
DBGPRINT(RT_DEBUG_ERROR, "Query::OID_802_11_BSSID_LIST (%d BSS returned)\n",pAdapter->PortCfg.BssTab.BssNr);
// Claculate total buffer size required
BssBufSize = sizeof(ULONG);
for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++)
{
// Align pointer to 4 bytes boundary.
Padding = 4 - (pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen & 0x0003);
if (Padding == 4)
Padding = 0;
BssBufSize += (sizeof(NDIS_WLAN_BSSID_EX) - 4 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen + Padding);
}
// For safety issue, we add 256 bytes just in case
BssBufSize += 256;
// Allocate the same size as passed from higher layer
pBuf = kmalloc(BssBufSize, GFP_KERNEL);
if(pBuf == NULL)
{
Status = -ENOMEM;
break;
}
// Init 802_11_BSSID_LIST_EX structure
NdisZeroMemory(pBuf, BssBufSize);
pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
pBssidList->NumberOfItems = pAdapter->PortCfg.BssTab.BssNr;
// Calculate total buffer length
BssLen = 4; // Consist of NumberOfItems
// Point to start of NDIS_WLAN_BSSID_EX
// pPtr = pBuf + sizeof(ULONG);
pPtr = (PUCHAR) &pBssidList->Bssid[0];
for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++)
{
pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
NdisMoveMemory(&pBss->MacAddress, &pAdapter->PortCfg.BssTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
if (pAdapter->PortCfg.BssTab.BssEntry[i].Hidden == 1)
{
pBss->Ssid.SsidLength = 0;
}
else
{
pBss->Ssid.SsidLength = pAdapter->PortCfg.BssTab.BssEntry[i].SsidLen;
NdisMoveMemory(pBss->Ssid.Ssid, pAdapter->PortCfg.BssTab.BssEntry[i].Ssid, pAdapter->PortCfg.BssTab.BssEntry[i].SsidLen);
}
pBss->Privacy = pAdapter->PortCfg.BssTab.BssEntry[i].Privacy;
//DBGPRINT(RT_DEBUG_ERROR,"pBss->Privacy=%x\n",(pBss->Privacy));
pBss->Rssi = pAdapter->PortCfg.BssTab.BssEntry[i].Rssi - RSSI_TO_DBM_OFFSET;
//DBGPRINT(RT_DEBUG_ERROR,"pBss->Rssi=%x\n",pBss->Rssi);
pBss->NetworkTypeInUse = Ndis802_11DS;
//DBGPRINT(RT_DEBUG_ERROR,"pBss->NetworkTypeInUse=%x\n",(pBss->NetworkTypeInUse));
pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
//DBGPRINT(RT_DEBUG_ERROR,"pBss->pBss->Configuration.Length=%d\n",pBss->Configuration.Length);
pBss->Configuration.BeaconPeriod = pAdapter->PortCfg.BssTab.BssEntry[i].BeaconPeriod;
//DBGPRINT(RT_DEBUG_ERROR,"pBss->pBss->Configuration.BeaconPeriod=%d\n",pBss->Configuration.BeaconPeriod);
pBss->Configuration.ATIMWindow = pAdapter->PortCfg.BssTab.BssEntry[i].AtimWin;
MAP_CHANNEL_ID_TO_KHZ(pAdapter->PortCfg.BssTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
if (pAdapter->PortCfg.BssTab.BssEntry[i].BssType == BSS_INFRA)
pBss->InfrastructureMode = Ndis802_11Infrastructure;
else
pBss->InfrastructureMode = Ndis802_11IBSS;
NdisMoveMemory(pBss->SupportedRates, pAdapter->PortCfg.BssTab.BssEntry[i].Rates, pAdapter->PortCfg.BssTab.BssEntry[i].RatesLen);
//DBGPRINT(RT_DEBUG_ERROR, "BSS#%d - %s, length of ssid=%d,Ch %d = %d Khz\n",
// i,pBss->Ssid.Ssid,pBss->Ssid.SsidLength,pAdapter->PortCfg.BssTab.BssEntry[i].Channel,pBss->Configuration.DSConfig);
if (pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen == 0)
{
pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs);
NdisMoveMemory(pBss->IEs, &pAdapter->PortCfg.BssTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 4 + sizeof(NDIS_802_11_FIXED_IEs);
}
else
{
pBss->IELength = sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen;
pPtr = pPtr + sizeof(NDIS_WLAN_BSSID_EX) - 4 + sizeof(NDIS_802_11_FIXED_IEs);
NdisMoveMemory(pBss->IEs, &pAdapter->PortCfg.BssTab.BssEntry[i].FixIEs, sizeof(NDIS_802_11_FIXED_IEs));
NdisMoveMemory(pPtr, pAdapter->PortCfg.BssTab.BssEntry[i].VarIEs, pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen);
pPtr += pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen;
}
// Align pointer to 4 bytes boundary.
Padding = 4 - (pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen & 0x0003);
if (Padding == 4)
Padding = 0;
pPtr += Padding;
pBss->Length = sizeof(NDIS_WLAN_BSSID_EX) - 4 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->PortCfg.BssTab.BssEntry[i].VarIELen + Padding;
BssLen += pBss->Length;
}
wrq->u.data.length = BssLen;
DBGPRINT(RT_DEBUG_INFO,"copy to user in OID_802_11_BSSID_LIST = %d\n",wrq->u.data.length);
copy_to_user(wrq->u.data.pointer, pBssidList, wrq->u.data.length);
kfree(pBssidList);
break;
case OID_802_11_TX_POWER_LEVEL:
wrq->u.data.length = sizeof(ULONG);
copy_to_user(wrq->u.data.pointer, &pAdapter->PortCfg.TxPower, wrq->u.data.length);
DBGPRINT(RT_DEBUG_INFO, "Query::OID_802_11_TX_POWER_LEVEL %x\n",pAdapter->PortCfg.TxPower);
break;
case OID_802_3_CURRENT_ADDRESS:
wrq->u.data.length = ETH_LENGTH_OF_ADDRESS;
copy_to_user(wrq->u.data.pointer, &pAdapter->CurrentAddress, wrq->u.data.length);
DBGPRINT(RT_DEBUG_INFO, "Query::OID_802_3_CURRENT_ADDRESS \n");
break;
case OID_GEN_MEDIA_CONNECT_STATUS:
DBGPRINT(RT_DEBUG_INFO, "Query::OID_GEN_MEDIA_CONNECT_STATUS \n");
wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
copy_to_user(wrq->u.data.pointer, &pAdapter->MediaState, wrq->u.data.length);
break;
case OID_802_11_BSSID:
if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
{
copy_to_user(wrq->u.data.pointer, &pAdapter->PortCfg.Bssid, sizeof(MACADDR));
DBGPRINT(RT_DEBUG_INFO, "IOCTL::SIOCGIWAP(=%02x:%02x:%02x:%02x:%02x:%02x)\n",
pAdapter->PortCfg.Bssid.Octet[0],pAdapter->PortCfg.Bssid.Octet[1],pAdapter->PortCfg.Bssid.Octet[2],
pAdapter->PortCfg.Bssid.Octet[3],pAdapter->PortCfg.Bssid.Octet[4],pAdapter->PortCfg.Bssid.Octet[5]);
}
else
{
DBGPRINT(RT_DEBUG_INFO, "Query::OID_802_11_BSSID(=EMPTY)\n");
Status = -ENOTCONN;
}
break;
case OID_802_11_SSID:
Ssid.SsidLength = pAdapter->PortCfg.SsidLen;
NdisZeroMemory(Ssid.Ssid, MAX_LEN_OF_SSID);
NdisMoveMemory(Ssid.Ssid, pAdapter->PortCfg.Ssid, Ssid.SsidLength);
wrq->u.data.length = sizeof(NDIS_802_11_SSID);
copy_to_user(wrq->u.data.pointer, &Ssid, wrq->u.data.length);
DBGPRINT(RT_DEBUG_INFO, "Query::OID_802_11_SSID (Len=%d, ssid=%s)\n", Ssid.SsidLength,Ssid.Ssid);
break;
case RT_OID_802_11_QUERY_LINK_STATUS:
LinkStatus.CurrTxRate = RateIdTo500Kbps[pAdapter->PortCfg.TxRate]; // unit : 500 kbps
LinkStatus.ChannelQuality = pAdapter->Mlme.ChannelQuality;
LinkStatus.RxByteCount = pAdapter->RalinkCounters.ReceivedByteCount;
LinkStatus.TxByteCount = pAdapter->RalinkCounters.TransmittedByteCount;
wrq->u.data.length = sizeof(RT_802_11_LINK_STATUS);
copy_to_user(wrq->u.data.pointer, &LinkStatus, wrq->u.data.length);
DBGPRINT(RT_DEBUG_INFO, "Query::RT_OID_802_11_LINK_STATUS\n");
break;
case OID_802_11_CONFIGURATION:
Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
Configuration.BeaconPeriod = pAdapter->PortCfg.BeaconPeriod;
Configuration.ATIMWindow = pAdapter->PortCfg.AtimWin;
if (ADHOC_ON(pAdapter))
{MAP_CHANNEL_ID_TO_KHZ(pAdapter->PortCfg.IbssConfig.Channel, Configuration.DSConfig);}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -