static int frrequest(req, data, set) int req, set; caddr_t data;
frrequest(req, data, set) int req, set; caddr_t data;
static int frrequest(req, data, set)int req, set;caddr_t data;{	register frentry_t *fp, *f, **fprev;	register frentry_t **ftail;	frentry_t fr;	frdest_t *fdp;	struct frentry frd;	int error = 0, in;	fp = &fr;	IRCOPY(data, (caddr_t)fp, sizeof(*fp));	bzero((char *)frcache, sizeof(frcache[0]) * 2);	in = (fp->fr_flags & FR_INQUE) ? 0 : 1;	if (fp->fr_flags & FR_ACCOUNT) {		ftail = fprev = &ipacct[in][set];	} else if (fp->fr_flags & (FR_OUTQUE|FR_INQUE))		ftail = fprev = &ipfilter[in][set];	else		return ESRCH;	IRCOPY((char *)fp, (char *)&frd, sizeof(frd));	fp = &frd;	if (*fp->fr_ifname) {		fp->fr_ifa = GETUNIT(fp->fr_ifname);		if (!fp->fr_ifa)			fp->fr_ifa = (struct ifnet *)-1;	}	fdp = &fp->fr_dif;	fp->fr_flags &= ~FR_DUP;	if (*fdp->fd_ifname) {		fdp->fd_ifp = GETUNIT(fdp->fd_ifname);		if (!fdp->fd_ifp)			fdp->fd_ifp = (struct ifnet *)-1;		else			fp->fr_flags |= FR_DUP;	}	fdp = &fp->fr_tif;	if (*fdp->fd_ifname) {		fdp->fd_ifp = GETUNIT(fdp->fd_ifname);		if (!fdp->fd_ifp)			fdp->fd_ifp = (struct ifnet *)-1;	}	/*	 * Look for a matching filter rule, but don't include the next or	 * interface pointer in the comparison (fr_next, fr_ifa).	 */	for (; (f = *ftail); ftail = &f->fr_next)		if (bcmp((char *)&f->fr_ip, (char *)&fp->fr_ip,			 FR_CMPSIZ) == 0)			break;	/*	 * If zero'ing statistics, copy current to caller and zero.	 */	if (req == SIOCZRLST) {		if (!f)			return ESRCH;		IWCOPY((caddr_t)f, data, sizeof(*f));		f->fr_hits = 0;		f->fr_bytes = 0;		return 0;	}	if (!f) {		ftail = fprev;		if (req != SIOCINAFR && req != SIOCINIFR)			while ((f = *ftail))				ftail = &f->fr_next;		else if (fp->fr_hits)			while (--fp->fr_hits && (f = *ftail))				ftail = &f->fr_next;		f = NULL;	}	if (req == SIOCDELFR || req == SIOCRMIFR) {		if (!f)			error = ESRCH;		else {			*ftail = f->fr_next;			(void) KFREE(f);		}	} else {		if (f)			error = EEXIST;		else {			if ((f = (struct frentry *)KMALLOC(sizeof(*f)))) {				bcopy((char *)fp, (char *)f, sizeof(*f));				f->fr_hits = 0;				f->fr_next = *ftail;				*ftail = f;			} else				error = ENOMEM;		}	}	return (error);}