diff options
Diffstat (limited to 'contrib/ipfilter/fils.c')
-rw-r--r-- | contrib/ipfilter/fils.c | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/contrib/ipfilter/fils.c b/contrib/ipfilter/fils.c index e6bf11f..4092ac4 100644 --- a/contrib/ipfilter/fils.c +++ b/contrib/ipfilter/fils.c @@ -12,7 +12,7 @@ # endif # endif #endif -#ifdef __sgi +#if defined(__sgi) && (IRIX > 602) # include <sys/ptimers.h> #endif #include <stdio.h> @@ -32,8 +32,13 @@ (!defined(__FreeBSD_version) || (__FreeBSD_version < 430000)) # undef STATETOP # endif -# if defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105000000) -# undef STATETOP +# if defined(__NetBSD_Version__) +# if (__NetBSD_Version__ < 105000000) +# undef STATETOP +# else +# include <poll.h> +# define USE_POLL +# endif # endif # if defined(sun) # if defined(__svr4__) || defined(__SVR4) @@ -94,7 +99,7 @@ #if !defined(lint) static const char sccsid[] = "@(#)fils.c 1.21 4/20/96 (C) 1993-2000 Darren Reed"; -static const char rcsid[] = "@(#)$Id: fils.c,v 2.21.2.36 2002/06/27 14:29:16 darrenr Exp $"; +static const char rcsid[] = "@(#)$Id: fils.c,v 2.21.2.40 2002/12/06 11:40:20 darrenr Exp $"; #endif extern char *optarg; @@ -104,7 +109,8 @@ extern int optind; #define FPRINTF (void)fprintf #define F_IN 0 #define F_OUT 1 -#define F_AC 2 +#define F_ACIN 2 +#define F_ACOUT 3 static char *filters[4] = { "ipfilter(in)", "ipfilter(out)", "ipacct(in)", "ipacct(out)" }; @@ -773,13 +779,22 @@ struct friostat *fiop; if (opts & OPT_INACTIVE) set = 1 - set; if (opts & OPT_ACCNT) { - i = F_AC; +#ifdef USE_INET6 + if ((use_inet6) && (opts & OPT_OUTQUE)) { + i = F_ACOUT; + fp = (struct frentry *)fiop->f_acctout6[set]; + } else if ((use_inet6) && (opts & OPT_INQUE)) { + i = F_ACIN; + fp = (struct frentry *)fiop->f_acctin6[set]; + } else +#endif if (opts & OPT_OUTQUE) { + i = F_ACOUT; fp = (struct frentry *)fiop->f_acctout[set]; - i++; - } else if (opts & OPT_INQUE) + } else if (opts & OPT_INQUE) { + i = F_ACIN; fp = (struct frentry *)fiop->f_acctin[set]; - else { + } else { FPRINTF(stderr, "No -i or -o given with -a\n"); return; } @@ -807,7 +822,7 @@ struct friostat *fiop; if (opts & OPT_VERBOSE) PRINTF("fp %p set %d\n", fp, set); - if (!fp) { + if (fp == NULL) { FPRINTF(stderr, "empty list for %s%s\n", (opts & OPT_INACTIVE) ? "inactive " : "", filters[i]); return; @@ -915,12 +930,16 @@ int topclosed; ipstate_t *istab[IPSTATE_SIZE], ips; ips_stat_t ipsst, *ipsstp = &ipsst; statetop_t *tstable = NULL, *tp; - struct timeval selecttimeout; char hostnm[HOSTNMLEN]; struct protoent *proto; - fd_set readfd; int c = 0; time_t t; +#ifdef USE_POLL + struct pollfd set[1]; +#else + struct timeval selecttimeout; + fd_set readfd; +#endif /* open state device */ if ((sfd = open(IPL_STATE, O_RDONLY)) == -1) { @@ -1188,6 +1207,14 @@ int topclosed; } /* wait for key press or a 1 second time out period */ +#ifdef USE_POLL + set[0].fd = 0; + set[0].events = POLLIN; + poll(set, 1, refreshtime * 1000); + + /* if key pressed, read all waiting keys */ + if (set[0].revents & POLLIN) +#else selecttimeout.tv_sec = refreshtime; selecttimeout.tv_usec = 0; FD_ZERO(&readfd); @@ -1195,7 +1222,10 @@ int topclosed; select(1, &readfd, NULL, NULL, &selecttimeout); /* if key pressed, read all waiting keys */ - if (FD_ISSET(0, &readfd)) { + if (FD_ISSET(0, &readfd)) +#endif + + { c = wgetch(stdscr); if (c == ERR) continue; |