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

📄 ioctl.c

📁 VIA VT6655 x86下的Linux Source Code
💻 C
📖 第 1 页 / 共 2 页
字号:
			break;
		};    
        break;
        
    case WLAN_CMD_GET_STAT:
        if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
			result = -EFAULT;
			break;
		};    
        break; 
    case WLAN_CMD_STOP_MAC:
    
        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
        netif_stop_queue(pDevice->dev);
                
        spin_lock_irq(&pDevice->lock);
        if (pDevice->bRadioOff == FALSE) { 
            CARDbRadioPowerOff(pDevice); 
        }
        pDevice->bLinkPass = FALSE;
        memset(pMgmt->abyCurrBSSID, 0, 6); 
        pMgmt->eCurrState = WMAC_STATE_IDLE;
        del_timer(&pDevice->sTimerCommand);
        del_timer(&pMgmt->sTimerSecondCallback);
        pDevice->bCmdRunning = FALSE;
        pDevice->bMACSuspend = TRUE;
        MACvIntDisable(pDevice->PortOffset);
        spin_unlock_irq(&pDevice->lock);
        
        break;
        
    case WLAN_CMD_START_MAC:
    
        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_START_MAC\n");
        
        if (pDevice->bMACSuspend == TRUE) {
            if (pDevice->bRadioOff == TRUE)
                CARDbRadioPowerOn(pDevice);
            vMgrTimerInit(pDevice);
            MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
            add_timer(&pMgmt->sTimerSecondCallback);
            pDevice->bMACSuspend = FALSE;            
        }    
        break;
        
    case WLAN_CMD_SET_HOSTAPD:
    
        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD\n");
        
        if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
			result = -EFAULT;
			break;
		};
		if (sValue.dwValue == 1) {
            if (hostap_set_hostapd(pDevice, 1, 1) == 0){
                DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
            }
            else {
			    result = -EFAULT;
			    break;
			}    
        }
        else {
            hostap_set_hostapd(pDevice, 0, 1);
            DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n");            
        }    
        
        break; 
        
    case WLAN_CMD_SET_HOSTAPD_STA:        
    
        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOSTAPD_STA\n");
                
        break;    
    case WLAN_CMD_SET_802_1X:
    
        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_802_1X\n");
        if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
			result = -EFAULT;
			break;
		};
		
		if (sValue.dwValue == 1) {
            pDevice->bEnable8021x = TRUE;
            DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable 802.1x\n");
        }
        else {
            pDevice->bEnable8021x = FALSE;
            DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable 802.1x\n");            
        }    		
		        
        break;                 
        
        
    case WLAN_CMD_SET_HOST_WEP:
    
        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_HOST_WEP\n");
        if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
			result = -EFAULT;
			break;
		};
		
		if (sValue.dwValue == 1) {
            pDevice->bEnableHostWEP = TRUE;
            DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HostWEP\n");
        }
        else {
            pDevice->bEnableHostWEP = FALSE;
            DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HostWEP\n");
        }    				
		
        break;                 

    case WLAN_CMD_SET_WPA:
         DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_SET_WPA\n");
         
        if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
			result = -EFAULT;
			break;
		};
		if (sValue.dwValue == 1) {
            if (wpa_set_wpadev(pDevice, 1) == 0){
                DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "init wpadev\n");
            }
            else {
			    result = -EFAULT;
			    break;
			}    
        }
        else {
            wpa_set_wpadev(pDevice, 0);
            DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "release wpadev\n");
        }    

        break;                          
        
    case WLAN_CMD_AP_START:

        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_AP_START\n");
        if (pDevice->bRadioOff == TRUE) {
            CARDbRadioPowerOn(pDevice);
            vMgrTimerInit(pDevice);
            MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
            add_timer(&pMgmt->sTimerSecondCallback);
        }
        if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
			result = -EFAULT;
			break;
		};
		
	    if (sStartAPCmd.wBSSType == AP) {
	        pMgmt->eConfigMode = WMAC_CONFIG_AP;
	        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct set to AP mode\n");
	    }    
	    else {
	        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ioct BSS type not set to AP mode\n");
			result = -EFAULT;
			break;	        
	    }        
	    

	    if (sStartAPCmd.wBBPType == PHY80211g) {
            pMgmt->byAPBBType = PHY_TYPE_11G;
        }
        else if (sStartAPCmd.wBBPType == PHY80211a) {
                 pMgmt->byAPBBType = PHY_TYPE_11A;
        }
        else {         
            pMgmt->byAPBBType = PHY_TYPE_11B;
        }                            
	        
        pItemSSID = (PWLAN_IE_SSID)sStartAPCmd.ssid;	    
        memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); 
		memcpy(pMgmt->abyDesireSSID, pItemSSID, pItemSSID->len + WLAN_IEHDR_LEN);
	    
	    if ((sStartAPCmd.uChannel > 0)&&(sStartAPCmd.uChannel <= 14))
	        pDevice->uChannel = sStartAPCmd.uChannel;
	    
	    if ((sStartAPCmd.uBeaconInt >= 20) && (sStartAPCmd.uBeaconInt <= 1000))
            pMgmt->wIBSSBeaconPeriod = sStartAPCmd.uBeaconInt;
        else     
            pMgmt->wIBSSBeaconPeriod = 100;

        if (sStartAPCmd.bShareKeyAuth == TRUE){
            pMgmt->bShareKeyAlgorithm = TRUE;
            DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Share Key \n");
        }
        else {
            pMgmt->bShareKeyAlgorithm = FALSE;
            DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Open System \n");
        }
        memcpy(pMgmt->abyIBSSSuppRates, abySuppRates, 6);

        if (sStartAPCmd.byBasicRate & BIT3) {
            pMgmt->abyIBSSSuppRates[2] |= BIT7;
            pMgmt->abyIBSSSuppRates[3] |= BIT7;
            pMgmt->abyIBSSSuppRates[4] |= BIT7;
            pMgmt->abyIBSSSuppRates[5] |= BIT7;            
        }else if (sStartAPCmd.byBasicRate & BIT2) {
             pMgmt->abyIBSSSuppRates[2] |= BIT7;
             pMgmt->abyIBSSSuppRates[3] |= BIT7;
             pMgmt->abyIBSSSuppRates[4] |= BIT7;                
        }else if (sStartAPCmd.byBasicRate & BIT1) {
             pMgmt->abyIBSSSuppRates[2] |= BIT7;
             pMgmt->abyIBSSSuppRates[3] |= BIT7;
        }else if (sStartAPCmd.byBasicRate & BIT1) {
             pMgmt->abyIBSSSuppRates[2] |= BIT7;
        }else {
            //default 1,2M
             pMgmt->abyIBSSSuppRates[2] |= BIT7;
             pMgmt->abyIBSSSuppRates[3] |= BIT7;            
        }
                     
        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Support Rate= %x %x %x %x\n", 
                pMgmt->abyIBSSSuppRates[2],
                pMgmt->abyIBSSSuppRates[3],
                pMgmt->abyIBSSSuppRates[4],
                pMgmt->abyIBSSSuppRates[5]                                                  
                );                     

        netif_stop_queue(pDevice->dev);        
        spin_lock_irq(&pDevice->lock);  
        bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);        
        spin_unlock_irq(&pDevice->lock);          
        break;
       
    case WLAN_CMD_GET_NODE_CNT:

		cbListCount = 0;		
		pNode = &(pMgmt->sNodeDBTable[0]);
        for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
            pNode = &(pMgmt->sNodeDBTable[ii]);
            if (!pNode->bActive)
                continue;
            cbListCount++;
        };
        
        sNodeList.uItem = cbListCount;
        if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
			result = -EFAULT;
			break;
		};
        pReq->wResult = 0;
        break;
            
    case WLAN_CMD_GET_NODE_LIST:
    
        if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
			result = -EFAULT;
			break;
		};    
        pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
        if (pNodeList == NULL) {    
            result = -ENOMEM;
            break;
        }        
		pNodeList->uItem = sNodeList.uItem;
		pNode = &(pMgmt->sNodeDBTable[0]);
        for (ii = 0, jj = 0; ii < (MAX_NODE_NUM + 1); ii++) {
            pNode = &(pMgmt->sNodeDBTable[ii]);
            if (pNode->bActive) {
    		    pNodeList->sNodeList[jj].wAID = pNode->wAID;
    		    memcpy(pNodeList->sNodeList[jj].abyMACAddr, pNode->abyMACAddr, WLAN_ADDR_LEN);
    		    pNodeList->sNodeList[jj].wTxDataRate = pNode->wTxDataRate;
    		    pNodeList->sNodeList[jj].wInActiveCount = (WORD)pNode->uInActiveCount;
    		    pNodeList->sNodeList[jj].wEnQueueCnt = (WORD)pNode->wEnQueueCnt;
    		    pNodeList->sNodeList[jj].wFlags = (WORD)pNode->dwFlags;
    		    pNodeList->sNodeList[jj].bPWBitOn = pNode->bPSEnable;
    		    pNodeList->sNodeList[jj].byKeyIndex = pNode->byKeyIndex;
    		    pNodeList->sNodeList[jj].wWepKeyLength = pNode->uWepKeyLength;
    		    memcpy(&(pNodeList->sNodeList[jj].abyWepKey[0]), &(pNode->abyWepKey[0]), WEP_KEYMAXLEN);
                DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "key= %2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
                            pNodeList->sNodeList[jj].abyWepKey[0],
                            pNodeList->sNodeList[jj].abyWepKey[1],
                            pNodeList->sNodeList[jj].abyWepKey[2],
                            pNodeList->sNodeList[jj].abyWepKey[3],
                            pNodeList->sNodeList[jj].abyWepKey[4]
                           );                                                                                     
    		    pNodeList->sNodeList[jj].bIsInFallback = pNode->bIsInFallback;
    		    pNodeList->sNodeList[jj].uTxFailures = pNode->uTxFailures;
    		    pNodeList->sNodeList[jj].uTxAttempts = pNode->uTxAttempts;
    		    pNodeList->sNodeList[jj].wFailureRatio = (WORD)pNode->uFailureRatio;
    		    jj ++;
    		    if (jj >= pNodeList->uItem) 
    		        break;
    		}    
		};
        if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
			result = -EFAULT;
			break;
		};
        kfree(pNodeList);
        pReq->wResult = 0;
        break;        

    default:
        DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Private command not support..\n");
    }

    return result;
}

/*
VOID
vConfigWEPKey (
    IN PSDevice pDevice,
    IN DWORD    dwKeyIndex,
    IN PBYTE    pbyKey,
    IN ULONG    uKeyLength
    )
{
    int ii;


    ZERO_MEMORY(&pDevice->abyWepKey[dwKeyIndex][0], WLAN_WEPMAX_KEYLEN);
    MEMvCopy(&pDevice->abyWepKey[dwKeyIndex][0], pbyKey, uKeyLength);

    pDevice->bWepKeyAvailable[dwKeyIndex] = TRUE;
    pDevice->auWepKeyLength[dwKeyIndex] = uKeyLength;

    MACvSetDefaultKeyEntry(pDevice->PortOffset, uKeyLength, dwKeyIndex, 
                           (PDWORD) &(pDevice->abyWepKey[dwKeyIndex][0]), pDevice->byLocalID);    

    if (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported) {
        for(ii=0; ii<MAX_GROUP_KEY; ii++) {
            if ((pDevice->bWepKeyAvailable[ii] == TRUE) &&
                (pDevice->auWepKeyLength[ii] == WLAN_WEP232_KEYLEN)) {
                pDevice->uCurrentWEPMode = TX_WEP_SW232;
                MACvDisableDefaultKey(pDevice->PortOffset);
                break;
            }
        }
        if ((ii == MAX_GROUP_KEY) &&
            (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported)) {
            MACvEnableDefaultKey(pDevice->PortOffset, pDevice->byLocalID);
        }
    }
}
*/

⌨️ 快捷键说明

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