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

📄 iwctl.c

📁 VIA VT6656 USB linux source code.
💻 C
📖 第 1 页 / 共 5 页
字号:
    if (dwKeyIndex > 0)		dwKeyIndex--;				// Send the key to the card 	if (wrq->length > 0) {		            if (wrq->length ==  WLAN_WEP232_KEYLEN) {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");        }        else if (wrq->length ==  WLAN_WEP104_KEYLEN) {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");        }        else if (wrq->length == WLAN_WEP40_KEYLEN) {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);        }        memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);        memcpy(pDevice->abyKey, extra, wrq->length);                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");        for (ii = 0; ii < wrq->length; ii++) {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);        }                  if (pDevice->flags & DEVICE_FLAGS_OPENED) {            spin_lock_irq(&pDevice->lock);                              KeybSetDefaultKey(  pDevice,                                &(pDevice->sKey),                                dwKeyIndex | (1 << 31),                                wrq->length,                                NULL,                                pDevice->abyKey,                                KEY_CTL_WEP                              );            spin_unlock_irq(&pDevice->lock);        }        pDevice->byKeyIndex = (BYTE)dwKeyIndex;        pDevice->uKeyLength = wrq->length;        pDevice->bTransmitKey = TRUE;        pDevice->bEncryptionEnable = TRUE;        pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;		// Do we want to just set the transmit key index ? 		if ( index < 4 ) {		    pDevice->byKeyIndex = index;		}		else if(!wrq->flags & IW_ENCODE_MODE) {				rc = -EINVAL;				return rc;	    }	}	// Read the flags 	if(wrq->flags & IW_ENCODE_DISABLED){				            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");		pMgmt->bShareKeyAlgorithm = FALSE;        pDevice->bEncryptionEnable = FALSE;        pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;        if (pDevice->flags & DEVICE_FLAGS_OPENED) {            spin_lock_irq(&pDevice->lock);            for(uu=0;uu<MAX_KEY_TABLE;uu++)                 MACvDisableKeyEntry(pDevice,uu);            spin_unlock_irq(&pDevice->lock);        }        	}		if(wrq->flags & IW_ENCODE_RESTRICTED) {        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");		    		pMgmt->bShareKeyAlgorithm = TRUE;	}		if(wrq->flags & IW_ENCODE_OPEN) {	    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");		pMgmt->bShareKeyAlgorithm = FALSE;	}			        #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT	   memset(pMgmt->abyDesireBSSID, 0xFF,6);#endif	return rc;}/* * Wireless Handler : get encode mode *///2008-0409-06, <Mark> by Einsn Liu /*int iwctl_giwencode(struct net_device *dev,             struct iw_request_info *info,             struct iw_point *wrq,             char *extra){    PSDevice	        pDevice = (PSDevice)dev->priv;    PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);        int rc = 0;    char abyKey[WLAN_WEP232_KEYLEN];	UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);    	PSKeyItem   pKey = NULL;        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");	memset(abyKey, 0, sizeof(abyKey));	// Check encryption mode 	wrq->flags = IW_ENCODE_NOKEY;	// Is WEP enabled ??? 	if (pDevice->bEncryptionEnable) 		wrq->flags |=  IW_ENCODE_ENABLED;    else		wrq->flags |=  IW_ENCODE_DISABLED;     		    if (pMgmt->bShareKeyAlgorithm)		wrq->flags |=  IW_ENCODE_RESTRICTED;	else		wrq->flags |=  IW_ENCODE_OPEN;			if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){         wrq->length = pKey->uKeyLength;        memcpy(abyKey, pKey->abyKey,  pKey->uKeyLength);    }    else {        rc = -EINVAL;        return rc;                           }        	wrq->flags |= index;	// Copy the key to the user buffer 	memcpy(extra,  abyKey, WLAN_WEP232_KEYLEN);	return 0;}*///2008-0409-06, <Add> by Einsn Liu int iwctl_giwencode(struct net_device *dev,			struct iw_request_info *info,			struct iw_point *wrq,			char *extra){	PSDevice			pDevice = (PSDevice)dev->priv;	PSMgmtObject		pMgmt = &(pDevice->sMgmtObj);	 	char abyKey[WLAN_WEP232_KEYLEN];		UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX);	   	PSKeyItem	pKey = NULL;			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");		if (index > WLAN_WEP_NKEYS) {		return	-EINVAL;	}		if(index<1){//get default key		if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){			index=pDevice->byKeyIndex;         	} else                       index=0;	}else              index--;				memset(abyKey, 0, WLAN_WEP232_KEYLEN);	// Check encryption mode 	wrq->flags = IW_ENCODE_NOKEY;	// Is WEP enabled ??? 	if (pDevice->bEncryptionEnable) 		wrq->flags |=  IW_ENCODE_ENABLED;	else		wrq->flags |=  IW_ENCODE_DISABLED;					if (pMgmt->bShareKeyAlgorithm)		wrq->flags |=  IW_ENCODE_RESTRICTED;	else		wrq->flags |=  IW_ENCODE_OPEN;		wrq->length=0;		if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||		pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise  key			if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){ 			   wrq->length = pKey->uKeyLength;				  memcpy(abyKey, pKey->abyKey,	pKey->uKeyLength);				  memcpy(extra,  abyKey, WLAN_WEP232_KEYLEN);			   }			}else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){ 			wrq->length = pKey->uKeyLength;			memcpy(abyKey, pKey->abyKey,  pKey->uKeyLength);		memcpy(extra,  abyKey, WLAN_WEP232_KEYLEN);	}		wrq->flags |= index+1;	return 0;}/* * Wireless Handler : set power mode */int iwctl_siwpower(struct net_device *dev,             struct iw_request_info *info,			 struct iw_param *wrq,             char *extra){    PSDevice            pDevice = (PSDevice)dev->priv;    PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);        int rc = 0;                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");	        if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {		 rc = -EINVAL;		 return rc;	}        	if (wrq->disabled) {		pDevice->ePSMode = WMAC_POWER_CAM;		PSvDisablePowerSaving(pDevice);		return rc;	}	if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {         pDevice->ePSMode = WMAC_POWER_FAST;         PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);         	} else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {	     pDevice->ePSMode = WMAC_POWER_FAST;         PSvEnablePowerSaving((HANDLE)pDevice, pMgmt->wListenInterval);	}	switch (wrq->flags & IW_POWER_MODE) {	case IW_POWER_UNICAST_R:        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");			rc = -EINVAL;		break;	case IW_POWER_ALL_R:        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");			rc = -EINVAL;	case IW_POWER_ON:        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");					break;	default:		rc = -EINVAL;	}                                   	return rc;}/* * Wireless Handler : get power mode */int iwctl_giwpower(struct net_device *dev,             struct iw_request_info *info,			 struct iw_param *wrq,                          char *extra){    PSDevice            pDevice = (PSDevice)dev->priv;    PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);        int mode = pDevice->ePSMode;        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");				if ((wrq->disabled = (mode == WMAC_POWER_CAM)))	    return 0;			if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {		wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);		wrq->flags = IW_POWER_TIMEOUT;	} else {		wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);    		    		wrq->flags = IW_POWER_PERIOD;	}	wrq->flags |= IW_POWER_ALL_R;	return 0;}/* * Wireless Handler : get Sensitivity */int iwctl_giwsens(struct net_device *dev,			 struct iw_request_info *info,			 struct iw_param *wrq,			 char *extra){    PSDevice	        pDevice = (PSDevice)dev->priv;    long ldBm;            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");	    if (pDevice->bLinkPass == TRUE) {                RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);	    wrq->value = ldBm;        	}	else {	    wrq->value = 0;      };			wrq->disabled = (wrq->value == 0);	wrq->fixed = 1;    	return 0;}//2008-0409-07, <Add> by Einsn Liu#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORTint iwctl_siwauth(struct net_device *dev,			  struct iw_request_info *info,			  struct iw_param *wrq,			  char *extra){	PSDevice			pDevice = (PSDevice)dev->priv;	PSMgmtObject	pMgmt = &(pDevice->sMgmtObj);	int ret=0;	static int wpa_version=0;  //must be static to save the last value,einsn liu	static int pairwise=0;    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");			switch (wrq->flags & IW_AUTH_INDEX) {	case IW_AUTH_WPA_VERSION:		wpa_version = wrq->value;		if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {		       printk("iwctl_siwauth:set WPADEV to disable at 1??????\n");				//pDevice->bWPADevEnable = FALSE;		}		else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {                          printk("iwctl_siwauth:set WPADEV to WPA1******\n");			}		else {                          printk("iwctl_siwauth:set WPADEV to WPA2******\n");		}		//pDevice->bWPASuppWextEnabled =TRUE;		break;	case IW_AUTH_CIPHER_PAIRWISE:		pairwise = wrq->value;                   printk("iwctl_siwauth:set pairwise=%d\n",pairwise);		if(pairwise == IW_AUTH_CIPHER_CCMP){			pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;		}else if(pairwise == IW_AUTH_CIPHER_TKIP){			pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;		}else if(pairwise == IW_AUTH_CIPHER_WEP40||pairwise == IW_AUTH_CIPHER_WEP104){			pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;		}else if(pairwise == IW_AUTH_CIPHER_NONE){			//do nothing,einsn liu		}else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;		break;	case IW_AUTH_CIPHER_GROUP:		 printk("iwctl_siwauth:set GROUP=%d\n",wrq->value);		if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED)			break;		if(pairwise == IW_AUTH_CIPHER_NONE){			if(wrq->value == IW_AUTH_CIPHER_CCMP){				pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;			}else {				pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;			}		}		break;	case IW_AUTH_KEY_MGMT:                    printk("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n",wpa_version,wrq->value);		if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){			if(wrq->value == IW_AUTH_KEY_MGMT_PSK)				pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;				else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;		}else if(wpa_version == IW_AUTH_WPA_VERSION_WPA){			if(wrq->value == 0){				pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;			}else if(wrq->value == IW_AUTH_KEY_MGMT_PSK)				pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;				else pMgmt->eAuthenMode = WMAC_AUTH_WPA;		}		break;	case IW_AUTH_TKIP_COUNTERMEASURES:		break;		/* FIXME */	case IW_AUTH_DROP_UNENCRYPTED:		break;	case IW_AUTH_80211_AUTH_ALG:		 printk("iwctl_siwauth:set AUTH_ALG=%d\n",wrq->value);		if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){			pMgmt->bShareKeyAlgorithm=FALSE;		}else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){			pMgmt->bShareKeyAlgorithm=TRUE;		}		break;			case IW_AUTH_WPA_ENABLED:		//pDevice->bWPADevEnable = !! wrq->value;		//if(pDevice->bWPADevEnable==TRUE)		  // printk("iwctl_siwauth:set WPADEV to enable sucessful*******\n");		//else		 //  printk("iwctl_siwauth:set WPADEV to enable fail?????\n");		break;	case IW_AUTH_RX_UNENCRYPTED_EAPOL:		break;	case IW_AUTH_ROAMING_CONTROL: 		ret = -EOPNOTSUPP;		break;	case IW_AUTH_PRIVACY_INVOKED:		pDevice->bEncryptionEnable = !!wrq->value;		if(pDevice->bEncryptionEnable == FALSE){			wpa_version = 0;			pairwise = 0;			pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;			pMgmt->bShareKeyAlgorithm = FALSE;			pMgmt->eAuthenMode = FALSE;			//pDevice->bWPADevEnable = FALSE;			 printk("iwctl_siwauth:set WPADEV to disaable at 2?????\n");		}				break;	default:		ret = -EOPNOTSUPP;		break;	}/*		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version);	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise);	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus);	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode  = %d\n",pMgmt->eAuthenMode);	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"TRUE":"FALSE");	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"TRUE":"FALSE");	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"TRUE":"FALSE");*/	   return ret;}int iwctl_giwauth(struct net_device *dev,			  struct iw_request_info *info,			  struct iw_param *wrq,			  char *extra){	return -EOPNOTSUPP;}int iwctl_siwgenie(struct net_device *dev,			  struct iw_request_info *info,			  struct iw_point *wrq,			  char *extra){	PSDevice			pDevice = (PSDevice)dev->priv;

⌨️ 快捷键说明

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