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

📄 rtmp_info.c

📁 r73模块的无线网卡在Linux下的驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
				if (AuthMode > Ndis802_11AuthModeMax)				{					DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",							__FUNCTION__);					Status	= -EINVAL;					break;				}				else				{					if (pAdapter->PortCfg.AuthMode != AuthMode)					{						// Config has changed						pAdapter->bConfigChanged = TRUE;					}					pAdapter->PortCfg.AuthMode = AuthMode;				}				pAdapter->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;				DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_AUTHENTICATION_MODE (=%d) \n",pAdapter->PortCfg.AuthMode);			}			break;		case OID_802_11_INFRASTRUCTURE_MODE:			if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status	= -EINVAL;			}			else			{				Status = copy_from_user(&BssType, wrq->u.data.pointer, wrq->u.data.length);				if (BssType == Ndis802_11IBSS)				{					if (pAdapter->PortCfg.BssType != BSS_ADHOC)					{						// Config has changed						if (INFRA_ON(pAdapter))						{							RTUSBEnqueueInternalCmd(pAdapter, RT_OID_LINK_DOWN);							// First cancel linkdown timer							DBGPRINT(RT_DEBUG_TRACE, "NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n");						}						//pAdapter->bConfigChanged = TRUE;					}					pAdapter->PortCfg.BssType = BSS_ADHOC;					DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_INFRASTRUCTURE_MODE (AD-HOC)\n");				}				else if (BssType == Ndis802_11Infrastructure)				{					if (pAdapter->PortCfg.BssType != BSS_INFRA)					{						// Config has changed						//pAdapter->bConfigChanged = TRUE;						if (ADHOC_ON(pAdapter))							RTUSBEnqueueInternalCmd(pAdapter, RT_OID_LINK_DOWN);					}					pAdapter->PortCfg.BssType = BSS_INFRA;					DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_INFRASTRUCTURE_MODE (INFRA)\n");				}				else				{					DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",							__FUNCTION__);					Status	= -EINVAL;					DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_INFRASTRUCTURE_MODE (unknown)\n");				}			}			// Reset Ralink supplicant to not use, it will be set to start when UI set PMK key			pAdapter->PortCfg.WpaState = SS_NOTUSE;			break;	    case OID_802_11_REMOVE_WEP:            DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_REMOVE_WEP\n");            if (wrq->u.data.length != sizeof(NDIS_802_11_KEY_INDEX)){				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);		        Status = -EINVAL;            }            else            {		        KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;		        if (KeyIdx & 0x80000000)		        {			        // Should never set default bit when remove key					DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",							__FUNCTION__);			        Status = -EINVAL;		        }		        else		        {			        KeyIdx = KeyIdx & 0x0fffffff;			        if (KeyIdx >= 4){						DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",								__FUNCTION__);				        Status = -EINVAL;			        }			        else			        {				        pAdapter->SharedKey[KeyIdx].KeyLen = 0;				        pAdapter->SharedKey[KeyIdx].CipherAlg = CIPHER_NONE;				        AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);			        }		        }            }            break;		case RT_OID_802_11_RESET_COUNTERS:			memset(&pAdapter->WlanCounters, 0, sizeof(COUNTER_802_11));			memset(&pAdapter->Counters8023, 0, sizeof(COUNTER_802_3));			memset(&pAdapter->RalinkCounters, 0, sizeof(COUNTER_RALINK));			pAdapter->Counters8023.RxNoBuffer	= 0;			pAdapter->Counters8023.GoodReceives = 0;			pAdapter->Counters8023.RxNoBuffer	= 0;			DBGPRINT(RT_DEBUG_TRACE, "Set::RT_OID_802_11_RESET_COUNTERS (=%d)\n", pAdapter->Counters8023.GoodReceives);			break;		case OID_802_11_RTS_THRESHOLD:			if (wrq->u.data.length != sizeof(NDIS_802_11_RTS_THRESHOLD)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status	= -EINVAL;			}			else			{				Status = copy_from_user(&RtsThresh, wrq->u.data.pointer, wrq->u.data.length);				if (RtsThresh > MAX_RTS_THRESHOLD) {					DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",							__FUNCTION__);					Status	= -EINVAL;				}				else					pAdapter->PortCfg.RtsThreshold = (USHORT)RtsThresh;			}			DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_RTS_THRESHOLD (=%d)\n",RtsThresh);			break;		case OID_802_11_FRAGMENTATION_THRESHOLD:			if (wrq->u.data.length != sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status	= -EINVAL;			}			else			{				Status = copy_from_user(&FragThresh, wrq->u.data.pointer, wrq->u.data.length);				pAdapter->PortCfg.bFragmentZeroDisable = FALSE;				if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)				{					if (FragThresh == 0)					{						pAdapter->PortCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;						pAdapter->PortCfg.bFragmentZeroDisable = TRUE;					}					else {						DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",								__FUNCTION__);						Status	= -EINVAL;					}				}				else					pAdapter->PortCfg.FragmentThreshold = (USHORT)FragThresh;			}			DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_FRAGMENTATION_THRESHOLD (=%d) \n",FragThresh);			break;		case OID_802_11_POWER_MODE:			if (wrq->u.data.length != sizeof(NDIS_802_11_POWER_MODE)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status = -EINVAL;			}			else			{				Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);				// save user's policy here, but not change PortCfg.Psm immediately				if (PowerMode == Ndis802_11PowerModeCAM)				{					// clear PSM bit immediately					MlmeSetPsmBit(pAdapter, PWR_ACTIVE);					OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);					if (pAdapter->PortCfg.bWindowsACCAMEnable == FALSE)						pAdapter->PortCfg.WindowsPowerMode = PowerMode;					pAdapter->PortCfg.WindowsBatteryPowerMode = PowerMode;				}				else if (PowerMode == Ndis802_11PowerModeMAX_PSP)				{					// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()					// to exclude certain situations.					//	   MlmeSetPsmBit(pAdapter, PWR_SAVE);					if (pAdapter->PortCfg.bWindowsACCAMEnable == FALSE)						pAdapter->PortCfg.WindowsPowerMode = PowerMode;					pAdapter->PortCfg.WindowsBatteryPowerMode = PowerMode;					OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);					pAdapter->PortCfg.DefaultListenCount = 5;				}				else if (PowerMode == Ndis802_11PowerModeFast_PSP)				{					// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()					// to exclude certain situations.					//	   MlmeSetPsmBit(pAdapter, PWR_SAVE);					OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);					if (pAdapter->PortCfg.bWindowsACCAMEnable == FALSE)						pAdapter->PortCfg.WindowsPowerMode = PowerMode;					pAdapter->PortCfg.WindowsBatteryPowerMode = PowerMode;					pAdapter->PortCfg.DefaultListenCount = 3;				}				else {					DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",							__FUNCTION__);					Status = -EINVAL;				}			}			DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_POWER_MODE (=%d)\n",PowerMode);			break;		case OID_802_11_TX_POWER_LEVEL:			if (wrq->u.data.length != sizeof(NDIS_802_11_TX_POWER_LEVEL)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status	= -EINVAL;			}			else			{				Status = copy_from_user(&TxPowerLevel, wrq->u.data.pointer, wrq->u.data.length);				if (TxPowerLevel > MAX_TX_POWER_LEVEL) {					DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",							__FUNCTION__);					Status	= -EINVAL;				}				else					pAdapter->PortCfg.TxPower = (UCHAR)TxPowerLevel;			}			DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_TX_POWER_LEVEL (=%d) \n",TxPowerLevel);			break;		case RT_OID_802_11_TX_POWER_LEVEL_1:			if (wrq->u.data.length	< sizeof(ULONG)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status = -EINVAL;			}			else			{				ULONG	PowerTemp;				Status = copy_from_user(&PowerTemp, wrq->u.data.pointer, wrq->u.data.length);				if (PowerTemp > 100)					PowerTemp = 0xffffffff;  // AUTO				pAdapter->PortCfg.TxPowerDefault = PowerTemp; //keep current setting.				// Only update TxPowerPercentage if the value is smaller than current AP setting// TODO: 2005-03-08 john removed the following line.//				if (pAdapter->PortCfg.TxPowerDefault < pAdapter->PortCfg.TxPowerPercentage)					pAdapter->PortCfg.TxPowerPercentage = pAdapter->PortCfg.TxPowerDefault;				DBGPRINT(RT_DEBUG_TRACE, "Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%d)\n", pAdapter->PortCfg.TxPowerPercentage);			}			break;		case OID_802_11_PRIVACY_FILTER:			if (wrq->u.data.length != sizeof(NDIS_802_11_PRIVACY_FILTER)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status = -EINVAL;			}			else			{				NDIS_802_11_PRIVACY_FILTER	Filter;				Status = copy_from_user(&Filter, wrq->u.data.pointer, wrq->u.data.length);				if ((Filter == Ndis802_11PrivFilterAcceptAll) || (Filter == Ndis802_11PrivFilter8021xWEP))					pAdapter->PortCfg.PrivacyFilter = Filter;				else {					DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",							__FUNCTION__);					Status = -EINVAL;				}			}			DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_PRIVACY_FILTER (=%d) \n",pAdapter->PortCfg.PrivacyFilter);			break;		case OID_802_11_NETWORK_TYPE_IN_USE:			if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status = -EINVAL;			}			else			{				Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);				RTUSBEnqueueCmdFromNdis(pAdapter, OID_802_11_NETWORK_TYPE_IN_USE, TRUE, &NetType, wrq->u.data.length);				DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType);			}			break;		case OID_802_11_RX_ANTENNA_SELECTED:			if (wrq->u.data.length != sizeof(NDIS_802_11_ANTENNA)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status = -EINVAL;			}			else			{				Status = copy_from_user(&AntDiv, wrq->u.data.pointer, wrq->u.data.length);				RTUSBEnqueueCmdFromNdis(pAdapter, OID_802_11_RX_ANTENNA_SELECTED, FALSE, &AntDiv, wrq->u.data.length);			}			break;		case OID_802_11_TX_ANTENNA_SELECTED:			if (wrq->u.data.length != sizeof(NDIS_802_11_ANTENNA)) {				DBGPRINT(RT_DEBUG_ERROR,"- %s: Invalid argument\n",						__FUNCTION__);				Status = -EINVAL;			}			else			{				Status = copy_from_user(&AntDiv, wrq->u.data.pointer, wrq->u.data.length);				RTUSBEnqueueCmdFromNdis(pAdapter, OID_802_11_TX_ANTENNA_SELECTED, FALSE, &AntDiv, wrq->u.data.length);			}			break;		// For WPA PSK PMK key		case RT_OID_802_11_ADD_WPA:			DBGPRINT(RT_DEBUG_ERROR, "!!!!!!!!!!!!!!!!!!!!!Set::RT_OID_802_11_ADD_WPA !!\n");			pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);			if(pKey == NULL)			{				Status = -ENOMEM;				break;			}			Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);			if (pKey->Length != wrq->u.data.length)			{				Status	= -EINVAL;				DBGPRINT(RT_DEBUG_TRACE, "Set::RT_OID_802_11_ADD_WPA, Failed!!\n");			}			else			{				if ((pAdapter->PortCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&\					(pAdapter->PortCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&\					(pAdapter->PortCfg.AuthMode != Ndis802_11AuthModeWPANone) )				{					Status = -EOPNOTSUPP;					DBGPRINT(RT_DEBUG_TRACE, "Set::RT_OID_802_11_ADD_WPA, Failed!! [AuthMode != WPAPSK/WPA2PSK/WPANONE]\n");				}				else if ((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||\						(pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ) 	// Only for WPA PSK mode				{					INT i;					pAdapter->PortCfg.PskKey.KeyLen = (UCHAR) pKey->KeyLength;					memcpy(pAdapter->PortCfg.PskKey.Key, &pKey->KeyMaterial, pKey->KeyLength);					// Use RaConfig as PSK agent.					// Start STA supplicant state machine					pAdapter->PortCfg.WpaState = SS_START;					DBGPRINT(RT_DEBUG_TRACE,"PskKey =  Len = %d \n",pKey->KeyLength);					for (i = 0; i < 32; i++)					{						DBGPRINT_RAW(RT_DEBUG_TRACE,"%02x:", pAdapter->PortCfg.PskKey.Key[i]);					}					DBGPRINT_RAW(RT_DEBUG_TRACE,"\n");					// Use RaConfig as PSK agent.					// Start STA supplicant state machine					pAdapter->PortCfg.WpaState = SS_START;					DBGPRINT(RT_DEBUG_TRACE, "Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength);				}				else				{					Status = RTUSBEnqueueCmdFromNdis(pAdapter, OID_802_11_ADD_KEY, TRUE, pKey, pKey->Length);				}			}			if(pKey != NULL){				kfree(pKey);			}			break;		case OID_802_11_REMOVE_KEY:			pRemoveKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);			if(pRemoveKey == NULL)			{				Status = -ENOMEM;				break;			}			Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);			if (pRemoveKey->Length != wrq->u.data.length)			{				Status = -EINVAL;				DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_REMOVE_KEY, Failed!!\n");			}			else			{				Status = RTMPRemoveKeySanity(pAdapter, pRemoveKey);				if (Status == NDIS_STATUS_SUCCESS)				{					RTUSBEnqueueCmdFromNdis(pAdapter, OID_802_11_REMOVE_KEY, TRUE, pRemoveKey, wrq->u.data.length);				}			}			DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length);			if(pRemoveKey != NULL){				kfree(pRemoveKey);			}			break;		// New for WPA		case OID_802_11_ADD_KEY:			DBGPRINT(RT_DEBUG_ERROR, "!!!!!!!!!!!!!!!!!!!!!Set::OID_802_11_ADD_KEY !!\n");			pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);			if(pKey == NULL)			{				Status = -ENOMEM;				break;			}			Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);			if (pKey->Length != wrq->u.data.length)			{				Status	= -EINVAL;				DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_ADD_KEY, Failed!!\n");			}			else			{				if (pAdapter->PortCfg.AuthMode >= Ndis802_11AuthModeWPA)				{					// Probably PortCfg.Bssid reset to zero as linkdown,				    // Set pKey.BSSID to Broadcast bssid in order to ensure AsicAddSharedKeyEntry done				    if(pAdapter->PortCfg.AuthMode == Ndis802_11AuthM

⌨️ 快捷键说明

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