int fr_scanlist(pass, ip, fin, m) int pass; ip_t *ip; register fr_info_t *fin; void *m;
fr_scanlist(pass, ip, fin #if (defined(_KERNEL) || defined(KERNEL)) && !SOLARIS , m) void *m; #else ) #endif int pass; ip_t *ip; register fr_info_t *fin;
int fr_scanlist(pass, ip, fin, m)int pass;ip_t *ip;register fr_info_t *fin;void *m;{	register struct frentry *fr;	register fr_ip_t *fi = &fin->fin_fi;	int rulen, portcmp = 0, off;	fin->fin_rule = 0;	off = ip->ip_off & 0x1fff;	pass |= (fi->fi_fl << 20);	if ((fi->fi_fl & FI_TCPUDP) && (fin->fin_dlen > 3) && !off)		portcmp = 1;	for (rulen = 0, fr = fin->fin_fr; fr; fr = fr->fr_next, rulen++) {		/*		 * In all checks below, a null (zero) value in the		 * filter struture is taken to mean a wildcard.		 *		 * check that we are working for the right interface		 */#ifdef	_KERNEL		if (fr->fr_ifa && fr->fr_ifa != fin->fin_ifp)			continue;#else		if (opts & (OPT_VERBOSE|OPT_DEBUG))			printf("\n");		FR_VERBOSE(("%c", (pass & FR_PASS) ? 'p' : 'b'));		if (fin->fin_ifp && *fr->fr_ifname &&		    strcasecmp((char *)fin->fin_ifp, fr->fr_ifname))			continue;		FR_VERBOSE((":i"));#endif		{			register u_long	*ld, *lm, *lip;			register int i;			lip = (u_long *)fi;			lm = (u_long *)&fr->fr_mip;			ld = (u_long *)&fr->fr_ip;			i = ((lip[0] & lm[0]) != ld[0]);			FR_IFDEBUG(i,continue,("0. %#08x & %#08x != %#08x\n",				   lip[0], lm[0], ld[0]));			i |= ((lip[1] & lm[1]) != ld[1]);			FR_IFDEBUG(i,continue,("1. %#08x & %#08x != %#08x\n",				   lip[1], lm[1], ld[1]));			i |= ((lip[2] & lm[2]) != ld[2]);			FR_IFDEBUG(i,continue,("2. %#08x & %#08x != %#08x\n",				   lip[2], lm[2], ld[2]));			i |= ((lip[3] & lm[3]) != ld[3]);			FR_IFDEBUG(i,continue,("3. %#08x & %#08x != %#08x\n",				   lip[3], lm[3], ld[3]));			i |= ((lip[4] & lm[4]) != ld[4]);			FR_IFDEBUG(i,continue,("4. %#08x & %#08x != %#08x\n",				   lip[4], lm[4], ld[4]));			if (i)				continue;		}		/*		 * If a fragment, then only the first has what we're looking		 * for here...		 */		if (fi->fi_fl & FI_TCPUDP) {			if (portcmp) {				if (!fr_tcpudpchk(fr, fin))					continue;			} else if (fr->fr_dcmp || fr->fr_scmp)				continue;		} else if (fi->fi_p == IPPROTO_ICMP) {			if (!off && (fin->fin_dlen > 1)) {				if ((fin->fin_data[0] & fr->fr_icmpm) !=				    fr->fr_icmp) {					FR_DEBUG(("i. %#x & %#x != %#x\n",						 fin->fin_data[0],						 fr->fr_icmpm, fr->fr_icmp));					continue;				}			} else if (fr->fr_icmpm || fr->fr_tcpfm)				continue;		}		FR_VERBOSE(("*"));                /*                 * Just log this packet...                 */		pass = fr->fr_flags;		if ((pass & FR_CALLNOW) && fr->fr_func)			pass = (*fr->fr_func)(ip, fin);#ifdef  IPFILTER_LOG		if ((pass & FR_LOGMASK) == FR_LOG) {			if (!IPLLOG(fr->fr_flags, ip, fin, m))				frstats[fin->fin_out].fr_skip++;			frstats[fin->fin_out].fr_pkl++;		}#endif /* IPFILTER_LOG */		FR_DEBUG(("pass %#x\n", pass));		fr->fr_hits++;		if (pass & FR_ACCOUNT)			fr->fr_bytes += ip->ip_len;		else			fin->fin_icode = fr->fr_icode;		if (pass & FR_QUICK)			break;	}	fin->fin_rule = rulen;	fin->fin_fr = fr;	return pass;}