break;  case TUNSETLINK: /* Only allow setting the type when the interface is down */ if (tun->dev->flags & IFF_UP) { DBG(KERN_INFO "%s: Linktype set failed because interface is up\n", tun->dev->name); return -EBUSY; } else { tun->dev->type = (int) arg; DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type); } 
static int tun_chr_ioctl(struct inode *inode, struct file *file, 			 unsigned int cmd, unsigned long arg){	struct tun_struct *tun = file->private_data;	void __user* argp = (void __user*)arg;	struct ifreq ifr;	if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89)		if (copy_from_user(&ifr, argp, sizeof ifr))			return -EFAULT;	if (cmd == TUNSETIFF && !tun) {		int err;		ifr.ifr_name[IFNAMSIZ-1] = '\0';		rtnl_lock();		err = tun_set_iff(file, &ifr);		rtnl_unlock();		if (err)			return err;		if (copy_to_user(argp, &ifr, sizeof(ifr)))			return -EFAULT;		return 0;	}	if (!tun)		return -EBADFD;	DBG(KERN_INFO "%s: tun_chr_ioctl cmd %d\n", tun->dev->name, cmd);	switch (cmd) {	case TUNSETNOCSUM:		/* Disable/Enable checksum */		if (arg)			tun->flags |= TUN_NOCHECKSUM;		else			tun->flags &= ~TUN_NOCHECKSUM;		DBG(KERN_INFO "%s: checksum %s\n",		    tun->dev->name, arg ? "disabled" : "enabled");		break;	case TUNSETPERSIST:		/* Disable/Enable persist mode */		if (arg)			tun->flags |= TUN_PERSIST;		else			tun->flags &= ~TUN_PERSIST;		DBG(KERN_INFO "%s: persist %s\n",		    tun->dev->name, arg ? "disabled" : "enabled");		break;	case TUNSETOWNER:		/* Set owner of the device */		tun->owner = (uid_t) arg;		DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner);		break;#ifdef TUN_DEBUG	case TUNSETDEBUG:		tun->debug = arg;		break;#endif	case SIOCGIFFLAGS:		ifr.ifr_flags = tun->if_flags;		if (copy_to_user( argp, &ifr, sizeof ifr))			return -EFAULT;		return 0;	case SIOCSIFFLAGS:		/** Set the character device's interface flags. Currently only		 * IFF_PROMISC and IFF_ALLMULTI are used. */		tun->if_flags = ifr.ifr_flags;		DBG(KERN_INFO "%s: interface flags 0x%lx\n",				tun->dev->name, tun->if_flags);		return 0;	case SIOCGIFHWADDR:		memcpy(ifr.ifr_hwaddr.sa_data, tun->dev_addr,				min(sizeof ifr.ifr_hwaddr.sa_data, sizeof tun->dev_addr));		if (copy_to_user( argp, &ifr, sizeof ifr))			return -EFAULT;		return 0;	case SIOCSIFHWADDR:		/** Set the character device's hardware address. This is used when		 * filtering packets being sent from the network device to the character		 * device. */		memcpy(tun->dev_addr, ifr.ifr_hwaddr.sa_data,				min(sizeof ifr.ifr_hwaddr.sa_data, sizeof tun->dev_addr));		DBG(KERN_DEBUG "%s: set hardware address: %x:%x:%x:%x:%x:%x\n",				tun->dev->name,				tun->dev_addr[0], tun->dev_addr[1], tun->dev_addr[2],				tun->dev_addr[3], tun->dev_addr[4], tun->dev_addr[5]);		return 0;	case SIOCADDMULTI:		/** Add the specified group to the character device's multicast filter		 * list. */		add_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);		DBG(KERN_DEBUG "%s: add multi: %x:%x:%x:%x:%x:%x\n",				tun->dev->name,				(u8)ifr.ifr_hwaddr.sa_data[0], (u8)ifr.ifr_hwaddr.sa_data[1],				(u8)ifr.ifr_hwaddr.sa_data[2], (u8)ifr.ifr_hwaddr.sa_data[3],				(u8)ifr.ifr_hwaddr.sa_data[4], (u8)ifr.ifr_hwaddr.sa_data[5]);		return 0;	case SIOCDELMULTI:		/** Remove the specified group from the character device's multicast		 * filter list. */		del_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);		DBG(KERN_DEBUG "%s: del multi: %x:%x:%x:%x:%x:%x\n",				tun->dev->name,				(u8)ifr.ifr_hwaddr.sa_data[0], (u8)ifr.ifr_hwaddr.sa_data[1],				(u8)ifr.ifr_hwaddr.sa_data[2], (u8)ifr.ifr_hwaddr.sa_data[3],				(u8)ifr.ifr_hwaddr.sa_data[4], (u8)ifr.ifr_hwaddr.sa_data[5]);		return 0;	default:		return -EINVAL;	};	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/ff4cc3ac93e1d0369928fd60ec1fe82417afc576/tun.c/clean/drivers/net/tun.c