int error = 0, s, unit, used;
int error = 0, s, unit;
int iplioctl(dev, cmd, data, mode#if _BSDI_VERSION >= 199510, p)struct proc *p;#else)#endifdev_t dev;int cmd;caddr_t data;int mode;{	int error = 0, s, unit, used;	unit = minor(dev);	if (unit != 0)		return ENXIO;	SPLNET(s);	switch (cmd) {	case FIONREAD :#ifdef IPFILTER_LOG		*(int *)data = iplused;#endif		break;#ifndef	IPFILTER_LKM	case SIOCFRENB :	{		u_int	enable;		if (!(mode & FWRITE))			error = EPERM;		else {			IRCOPY(data, (caddr_t)&enable, sizeof(enable));			if (enable)				error = iplattach();			else				error = ipldetach();		}		break;	}#endif	case SIOCSETFF :		if (!(mode & FWRITE))			error = EPERM;		else			IRCOPY(data, (caddr_t)&fr_flags, sizeof(fr_flags));		break;	case SIOCGETFF :		IWCOPY((caddr_t)&fr_flags, data, sizeof(fr_flags));		break;	case SIOCINAFR :	case SIOCRMAFR :	case SIOCADAFR :	case SIOCZRLST :		if (!(mode & FWRITE))			error = EPERM;		else			error = frrequest(cmd, data, fr_active);		break;	case SIOCINIFR :	case SIOCRMIFR :	case SIOCADIFR :		if (!(mode & FWRITE))			error = EPERM;		else			error = frrequest(cmd, data, 1 - fr_active);		break;	case SIOCSWAPA :		if (!(mode & FWRITE))			error = EPERM;		else {			bzero((char *)frcache, sizeof(frcache[0]) * 2);			*(u_int *)data = fr_active;			fr_active = 1 - fr_active;		}		break;	case SIOCGETFS :	{		struct	friostat	fio;		bcopy((char *)frstats, (char *)fio.f_st,			sizeof(struct filterstats) * 2);		fio.f_fin[0] = ipfilter[0][0];		fio.f_fin[1] = ipfilter[0][1];		fio.f_fout[0] = ipfilter[1][0];		fio.f_fout[1] = ipfilter[1][1];		fio.f_acctin[0] = ipacct[0][0];		fio.f_acctin[1] = ipacct[0][1];		fio.f_acctout[0] = ipacct[1][0];		fio.f_acctout[1] = ipacct[1][1];		fio.f_active = fr_active;		IWCOPY((caddr_t)&fio, data, sizeof(fio));		break;	}	case	SIOCFRZST :		if (!(mode & FWRITE))			error = EPERM;		else			frzerostats(data);		break;	case	SIOCIPFFL :		if (!(mode & FWRITE))			error = EPERM;		else			frflush(data);		break;#ifdef	IPFILTER_LOG	case	SIOCIPFFB :		if (!(mode & FWRITE))			error = EPERM;		else {			*(int *)data = iplused;			iplh = iplt = iplbuf;			iplused = 0;		}		break;#endif /* IPFILTER_LOG */	case SIOCADNAT :	case SIOCRMNAT :	case SIOCGNATS :	case SIOCGNATL :	case SIOCFLNAT :	case SIOCCNATL :		error = nat_ioctl(data, cmd, mode);		break;	case SIOCGFRST :		IWCOPY((caddr_t)ipfr_fragstats(), data, sizeof(ipfrstat_t));		break;	case SIOCGIPST :		IWCOPY((caddr_t)fr_statetstats(), data, sizeof(ips_stat_t));		break;	default :		error = EINVAL;		break;	}	SPLX(s);	return error;}