⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sta_ioctl.c

📁 ralink 2870 usb无线网卡 最新驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
        		pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;             // Update these related information to MAC_TABLE_ENTRY        	pEntry = &pAd->MacTab.Content[BSSID_WCID];            NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);                    	NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);        	NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);        	pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;        	// Update pairwise key information to ASIC Shared Key Table	           	AsicAddSharedKeyEntry(pAd,         						  BSS0,         						  0,         						  pAd->SharedKey[BSS0][0].CipherAlg,        						  pAd->SharedKey[BSS0][0].Key,        						  pAd->SharedKey[BSS0][0].TxMic,         						  pAd->SharedKey[BSS0][0].RxMic);        	// Update ASIC WCID attribute table and IVEIV table        	RTMPAddWcidAttributeEntry(pAd,         							  BSS0,         							  0,         							  pAd->SharedKey[BSS0][0].CipherAlg,         							  pEntry);            if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)            {                // set 802.1x port control	            //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;				STA_PORT_SECURED(pAd);                                // Indicate Connected for GUI                pAd->IndicateMediaState = NdisMediaStateConnected;            }		}        else        {            // Update GTK                        pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);            NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));              pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;            NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);#ifdef WPA_SUPPLICANT_SUPPORT                        if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)            {                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);                            NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);        	            }            else#endif // WPA_SUPPLICANT_SUPPORT //                            {            	NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);                            NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);        	            }            // Update Shared Key CipherAlg    		pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_NONE;    		if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)    			pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_TKIP;    		else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)    			pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;            // Update group key information to ASIC Shared Key Table	           	AsicAddSharedKeyEntry(pAd,         						  BSS0,         						  pAd->StaCfg.DefaultKeyId,         						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,        						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,        						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,         						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);        	// Update ASIC WCID attribute table and IVEIV table        	RTMPAddWcidAttributeEntry(pAd,         							  BSS0,         							  pAd->StaCfg.DefaultKeyId,         							  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,         							  NULL);            // set 802.1x port control	        //pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;			STA_PORT_SECURED(pAd);            // Indicate Connected for GUI            pAd->IndicateMediaState = NdisMediaStateConnected;        }	}	else	// dynamic WEP from wpa_supplicant	{		UCHAR	CipherAlg;    	PUCHAR	Key;		if(pKey->KeyLength == 32)			goto end;				KeyIdx = pKey->KeyIndex & 0x0fffffff;		if (KeyIdx < 4)		{			// it is a default shared key, for Pairwise key setting			if (pKey->KeyIndex & 0x80000000)			{				pEntry = MacTableLookup(pAd, pKey->BSSID);				if (pEntry)				{					DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));							// set key material and key length 					pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;					NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);										// set Cipher type					if (pKey->KeyLength == 5)						pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;					else						pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;											// Add Pair-wise key to Asic					AsicAddPairwiseKeyEntry(						pAd, 						pEntry->Addr, 						(UCHAR)pEntry->Aid,                		&pEntry->PairwiseKey);					// update WCID attribute table and IVEIV table for this entry					RTMPAddWcidAttributeEntry(						pAd, 						BSS0, 						KeyIdx, // The value may be not zero						pEntry->PairwiseKey.CipherAlg, 						pEntry);				}				}			else	            {				// Default key for tx (shared key)				pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;                     				// set key material and key length				pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;				NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);								// Set Ciper type				if (pKey->KeyLength == 5)					pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;				else					pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;			    			CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;    			Key = pAd->SharedKey[BSS0][KeyIdx].Key;				// Set Group key material to Asic    			AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);						// Update WCID attribute table and IVEIV table for this group key table  				RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);															}		}	}end:	return;}char * rtstrchr(const char * s, int c){    for(; *s != (char) c; ++s)        if (*s == '\0')            return NULL;    return (char *) s;}/*This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function*/intrt_ioctl_giwname(struct net_device *dev,		   struct iw_request_info *info,		   char *name, char *extra){#ifdef RTMP_MAC_USB		strncpy(name, "RT2870 Wireless", IFNAMSIZ);#endif // RTMP_MAC_USB //	return 0;}int rt_ioctl_siwfreq(struct net_device *dev,			struct iw_request_info *info,			struct iw_freq *freq, char *extra){	PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;	int 	chan = -1;    //check if the interface is down    if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))    {        DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));        return -ENETDOWN;       }	if (freq->e > 1)		return -EINVAL;	if((freq->e == 0) && (freq->m <= 1000))		chan = freq->m;	// Setting by channel number 	else		MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,     if (ChannelSanity(pAdapter, chan) == TRUE)    {	pAdapter->CommonCfg.Channel = chan;	DBGPRINT(RT_DEBUG_ERROR, ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->CommonCfg.Channel));    }    else        return -EINVAL;    	return 0;}int rt_ioctl_giwfreq(struct net_device *dev,		   struct iw_request_info *info,		   struct iw_freq *freq, char *extra){	PRTMP_ADAPTER pAdapter = NULL;	UCHAR ch;	ULONG	m = 2412000;	pAdapter = dev->priv;	if (pAdapter == NULL)	{		/* if 1st open fail, pAd will be free;		   So the net_dev->priv will be NULL in 2rd open */		return -ENETDOWN;	}		ch = pAdapter->CommonCfg.Channel;	DBGPRINT(RT_DEBUG_TRACE,("==>rt_ioctl_giwfreq  %d\n", ch));	MAP_CHANNEL_ID_TO_KHZ(ch, m);	freq->m = m * 100;	freq->e = 1;	return 0;}int rt_ioctl_siwmode(struct net_device *dev,		   struct iw_request_info *info,		   __u32 *mode, char *extra){	PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;	//check if the interface is down    if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))    {    	DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));       	return -ENETDOWN;       }	switch (*mode)	{		case IW_MODE_ADHOC:			Set_NetworkType_Proc(pAdapter, "Adhoc");			break;		case IW_MODE_INFRA:			Set_NetworkType_Proc(pAdapter, "Infra");			break;#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))        case IW_MODE_MONITOR:			Set_NetworkType_Proc(pAdapter, "Monitor");			break;#endif            		default:			DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));			return -EINVAL;	}		// Reset Ralink supplicant to not use, it will be set to start when UI set PMK key	pAdapter->StaCfg.WpaState = SS_NOTUSE;	return 0;}int rt_ioctl_giwmode(struct net_device *dev,		   struct iw_request_info *info,		   __u32 *mode, char *extra){	PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;	if (pAdapter == NULL)	{		/* if 1st open fail, pAd will be free;		   So the net_dev->priv will be NULL in 2rd open */		return -ENETDOWN;	}	if (ADHOC_ON(pAdapter))		*mode = IW_MODE_ADHOC;    else if (INFRA_ON(pAdapter))		*mode = IW_MODE_INFRA;#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20))    else if (MONITOR_ON(pAdapter))    {        *mode = IW_MODE_MONITOR;    }#endif             else        *mode = IW_MODE_AUTO;	DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));	return 0;}int rt_ioctl_siwsens(struct net_device *dev,		   struct iw_request_info *info,		   char *name, char *extra){	PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;	//check if the interface is down    	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))    	{        	DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));        	return -ENETDOWN;       	}	return 0;}int rt_ioctl_giwsens(struct net_device *dev,		   struct iw_request_info *info,		   char *name, char *extra){	return 0;}int rt_ioctl_giwrange(struct net_device *dev,		   struct iw_request_info *info,		   struct iw_point *data, char *extra){	PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;	struct iw_range *range = (struct iw_range *) extra;	u16 val;	int i;	if (pAdapter == NULL)	{		/* if 1st open fail, pAd will be free;		   So the net_dev->priv will be NULL in 2rd open */		return -ENETDOWN;	}	DBGPRINT(RT_DEBUG_TRACE ,("===>rt_ioctl_giwrange\n"));	data->length = sizeof(struct iw_range);	memset(range, 0, sizeof(struct iw_range));	range->txpower_capa = IW_TXPOW_DBM;	if (INFRA_ON(pAdapter)||ADHOC_ON(pAdapter))	{		range->min_pmp = 1 * 1024;		range->max_pmp = 65535 * 1024;		range->min_pmt = 1 * 1024;		range->max_pmt = 1000 * 1024;		range->pmp_flags = IW_POWER_PERIOD;		range->pmt_flags = IW_POWER_TIMEOUT;		range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |			IW_POWER_UNICAST_R | IW_POWER_ALL_R;	}	range->we_version_compiled = WIRELESS_EXT;	range->we_version_source = 14;	range->retry_capa = IW_RETRY_LIMIT;	range->retry_flags = IW_RETRY_LIMIT;	range->min_retry = 0;	range->max_retry = 255;	range->num_channels =  pAdapter->ChannelListNum;	val = 0;	for (i = 1; i <= range->num_channels; i++) 	{		u32 m = 2412000;		range->freq[val].i = pAdapter->ChannelList[i-1].Channel;		MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);		range->freq[val].m = m * 100; /* OS_HZ */				range->freq[val].e = 1;		val++;		if (val == IW_MAX_FREQUENCIES)			break;	}	range->num_frequency = val;	range->max_qual.qual = 100; /* what is correct max? This was not					* documented exactly. At least					* 69 has been observed. */	range->max_qual.level = 0; /* dB */	range->max_qual.noise = 0; /* dB */	/* What would be suitable values for "average/typical" qual? */	range->avg_qual.qual = 20;	range->avg_qual.level = -60;	range->avg_qual.noise = -95;	range->sensitivity = 3;	range->max_encoding_tokens = NR_WEP_KEYS;	range->num_encoding_sizes = 2;	range->encoding_size[0] = 5;	range->encoding_size[1] = 13;	range->min_rts = 0;	range->max_rts = 2347;	range->min_frag = 256;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -