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

📄 main_usb.c

📁 VIA VT6656 USB linux source code.
💻 C
📖 第 1 页 / 共 5 页
字号:
	    break;	// Get the current fragmentation threshold	case SIOCGIWFRAG:			rc = iwctl_giwfrag(dev, NULL, &(wrq->u.frag), NULL);		break;		// Set mode of operation	case SIOCSIWMODE:    	rc = iwctl_siwmode(dev, NULL, &(wrq->u.mode), NULL);	    		break;		// Get mode of operation	case SIOCGIWMODE:		rc = iwctl_giwmode(dev, NULL, &(wrq->u.mode), NULL);		break;			// Set WEP keys and mode	case SIOCSIWENCODE:		{            char abyKey[WLAN_WEP232_KEYLEN];		                			if (wrq->u.encoding.pointer) {			    			    				if (wrq->u.encoding.length > WLAN_WEP232_KEYLEN) {					rc = -E2BIG;					break;				}				memset(abyKey, 0, WLAN_WEP232_KEYLEN);				if (copy_from_user(abyKey, 				                  wrq->u.encoding.pointer,				                  wrq->u.encoding.length)) {					rc = -EFAULT;					break;				}			} else if (wrq->u.encoding.length != 0) {				rc = -EINVAL;				break;			}			rc = iwctl_siwencode(dev, NULL, &(wrq->u.encoding), abyKey);		}				break;				// Get the WEP keys and mode	case SIOCGIWENCODE:			if (!capable(CAP_NET_ADMIN)) {			rc = -EPERM;			break;		}		{		    char abyKey[WLAN_WEP232_KEYLEN];		    		    rc = iwctl_giwencode(dev, NULL, &(wrq->u.encoding), abyKey);		    if (rc != 0) break;			if (wrq->u.encoding.pointer) {				if (copy_to_user(wrq->u.encoding.pointer,						        abyKey,						        wrq->u.encoding.length))					rc = -EFAULT;			}		}		break;	#if WIRELESS_EXT > 9		// Get the current Tx-Power	case SIOCGIWTXPOW:        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");        rc = -EOPNOTSUPP;		break;				case SIOCSIWTXPOW:        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");	        rc = -EOPNOTSUPP;		break;				#endif // WIRELESS_EXT > 9 #if WIRELESS_EXT > 10	case SIOCSIWRETRY:			rc = iwctl_siwretry(dev, NULL, &(wrq->u.retry), NULL);			break;	case SIOCGIWRETRY:			rc = iwctl_giwretry(dev, NULL, &(wrq->u.retry), NULL);			break;#endif // WIRELESS_EXT > 10 		// Get range of parameters	case SIOCGIWRANGE:			{			struct iw_range range;						rc = iwctl_giwrange(dev, NULL, &(wrq->u.data), (char *) &range);			if (copy_to_user(wrq->u.data.pointer, &range, sizeof(struct iw_range)))				rc = -EFAULT;		}				break;		        	case SIOCGIWPOWER:			rc = iwctl_giwpower(dev, NULL, &(wrq->u.power), NULL);		break;		case SIOCSIWPOWER:		rc = iwctl_siwpower(dev, NULL, &(wrq->u.power), NULL);		break;		case SIOCGIWSENS:		    rc = iwctl_giwsens(dev, NULL, &(wrq->u.sens), NULL);		break;	case SIOCSIWSENS:        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSENS \n");			rc = -EOPNOTSUPP;		break;	case SIOCGIWAPLIST:	    {            char buffer[IW_MAX_AP * (sizeof(struct sockaddr) + sizeof(struct iw_quality))];            		    if (wrq->u.data.pointer) {		        rc = iwctl_giwaplist(dev, NULL, &(wrq->u.data), buffer);		        if (rc == 0) {                    if (copy_to_user(wrq->u.data.pointer,					                buffer,					               (wrq->u.data.length * (sizeof(struct sockaddr) +  sizeof(struct iw_quality)))				        ))				    rc = -EFAULT;		        }            }        }		break;		#ifdef WIRELESS_SPY		// Set the spy list	case SIOCSIWSPY:        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n");			rc = -EOPNOTSUPP;		break;			// Get the spy list	case SIOCGIWSPY:	        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n");			rc = -EOPNOTSUPP;		break;		#endif // WIRELESS_SPY 	case SIOCGIWPRIV:        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPRIV \n");				rc = -EOPNOTSUPP;/*		        		if(wrq->u.data.pointer) {			wrq->u.data.length = sizeof(iwctl_private_args) / sizeof( iwctl_private_args[0]);			if(copy_to_user(wrq->u.data.pointer,					(u_char *) iwctl_private_args,					sizeof(iwctl_private_args)))				rc = -EFAULT;		}*/				break;						//#endif // WIRELESS_EXT < 13	//2008-0409-07, <Add> by Einsn Liu#ifdef  WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT	case SIOCSIWAUTH:		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");		rc = iwctl_siwauth(dev, NULL, &(wrq->u.param), NULL);		break;	case SIOCGIWAUTH:		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAUTH \n");		rc = iwctl_giwauth(dev, NULL, &(wrq->u.param), NULL);				break;	case SIOCSIWGENIE:		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWGENIE \n");		rc = iwctl_siwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);		break;	case SIOCGIWGENIE:		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWGENIE \n");		rc = iwctl_giwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);		break;			case SIOCSIWENCODEEXT:		{  					char extra[sizeof(struct iw_encode_ext)+MAX_KEY_LEN+1];			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODEEXT \n");			if(wrq->u.encoding.pointer){				memset(extra, 0, sizeof(struct iw_encode_ext)+MAX_KEY_LEN+1);				if(wrq->u.encoding.length > (sizeof(struct iw_encode_ext)+ MAX_KEY_LEN)){					rc = -E2BIG;					break;					}				if(copy_from_user(extra, wrq->u.encoding.pointer,wrq->u.encoding.length)){					rc = -EFAULT;					break;				}					}else if(wrq->u.encoding.length != 0){				rc = -EINVAL;				break;			}			rc = iwctl_siwencodeext(dev, NULL, &(wrq->u.encoding), extra);		}		break;			case SIOCGIWENCODEEXT:		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODEEXT \n");		rc = iwctl_giwencodeext(dev, NULL, &(wrq->u.encoding), NULL);		break;	case SIOCSIWMLME:		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMLME \n");		rc = iwctl_siwmlme(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);		break;				#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT//End Add -- //2008-0409-07, <Add> by Einsn Liu#endif // WIRELESS_EXT            case IOCTL_CMD_TEST:    		if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {		    rc = -EFAULT;		    break;		} else {		    rc = 0;		}            pReq = (PSCmdRequest)rq;   //20080130-01,<Remark> by Mike Liu      // if(pDevice->bLinkPass==TRUE)          pReq->wResult = MAGIC_CODE;         //Linking status:0x3142   //20080130-02,<Remark> by Mike Liu      //  else      //	 pReq->wResult = MAGIC_CODE+1;    //disconnect status:0x3143        break;            case IOCTL_CMD_SET:               #ifdef SndEvt_ToAPI                  if((((PSCmdRequest)rq)->wCmdCode !=WLAN_CMD_SET_EVT) &&		       !(pDevice->flags & DEVICE_FLAGS_OPENED))	      #else		if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) 	      #endif		{		    rc = -EFAULT;		    break;		} else {		    rc = 0;		}		    		    	    if (test_and_set_bit( 0, (void*)&(pMgmt->uCmdBusy))) {		    return -EBUSY;	    }        rc = private_ioctl(pDevice, rq);        clear_bit( 0, (void*)&(pMgmt->uCmdBusy));        break;    case IOCTL_CMD_HOSTAPD:    		if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {		    rc = -EFAULT;		    break;		} else {		    rc = 0;		}		    		#if WIRELESS_EXT > 8		rc = hostap_ioctl(pDevice, &wrq->u.data);#else // WIRELESS_EXT > 8 		rc = hostap_ioctl(pDevice, (struct iw_point *) &wrq->u.data);#endif // WIRELESS_EXT > 8             break;            case IOCTL_CMD_WPA:    		if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {		    rc = -EFAULT;		    break;		} else {		    rc = 0;		}		#if WIRELESS_EXT > 8		rc = wpa_ioctl(pDevice, &wrq->u.data);#else // WIRELESS_EXT > 8 		rc = wpa_ioctl(pDevice, (struct iw_point *) &wrq->u.data);#endif // WIRELESS_EXT > 8             break;                	case SIOCETHTOOL:        return ethtool_ioctl(dev, (void *) rq->ifr_data);	// All other calls are currently unsupported	      	      		default:		rc = -EOPNOTSUPP;                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Ioctl command not support..%x\n", cmd);    }         if (pDevice->bCommit) {       if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {           netif_stop_queue(pDevice->dev);           spin_lock_irq(&pDevice->lock);             bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);           spin_unlock_irq(&pDevice->lock);                  }       else {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Commit the settings\n");                   spin_lock_irq(&pDevice->lock);       //2007-1121-01<Modify>by EinsnLiu	    if (pDevice->bLinkPass&&		  memcmp(pMgmt->abyCurrSSID,pMgmt->abyDesireSSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN)) {	      		  bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);	    	     } else {           pDevice->bLinkPass = FALSE; 	   pMgmt->eCurrState = WMAC_STATE_IDLE;	   memset(pMgmt->abyCurrBSSID, 0, 6); 		 }           ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);//End Modify           netif_stop_queue(pDevice->dev);           if(pDevice->bWPASuppWextEnabled !=TRUE)           bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);           bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);           spin_unlock_irq(&pDevice->lock);                 }       pDevice->bCommit = FALSE;    }                  return rc;}static int ethtool_ioctl(struct net_device *dev, void *useraddr){	u32 ethcmd;			if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))		return -EFAULT;	        switch (ethcmd) {	case ETHTOOL_GDRVINFO: {		struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};		strncpy(info.driver, DEVICE_NAME, sizeof(info.driver)-1);		strncpy(info.version, DEVICE_VERSION, sizeof(info.version)-1);		if (copy_to_user(useraddr, &info, sizeof(info)))			return -EFAULT;		return 0;	}	        }		return -EOPNOTSUPP;}/*------------------------------------------------------------------*/MODULE_DEVICE_TABLE(usb, vntwusb_table);#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)static struct usb_driver vntwusb_driver = {#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)	    .owner =	THIS_MODULE,#endif	    .name =		DEVICE_NAME,	    .probe =	vntwusb_found1,	    .disconnect =	vntwusb_disconnect,	    .id_table =	vntwusb_table,};#elsestatic struct usb_driver vntwusb_driver = {	    name:   DEVICE_NAME,	    probe:  vntwusb_found1,	    disconnect: vntwusb_disconnect,	    id_table:   vntwusb_table,    };#endifstatic int __init vntwusb_init_module(void){	info(DEVICE_FULL_DRV_NAM " " DEVICE_VERSION);    return usb_register(&vntwusb_driver);}static void __exit vntwusb_cleanup_module(void){	usb_deregister(&vntwusb_driver);	    } module_init(vntwusb_init_module);module_exit(vntwusb_cleanup_module);

⌨️ 快捷键说明

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