summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKjell Wooding <kjell@cvs.openbsd.org>2001-06-27 10:31:52 +0000
committerKjell Wooding <kjell@cvs.openbsd.org>2001-06-27 10:31:52 +0000
commit1af4743896368d72b37729fb509c340856465816 (patch)
tree135ce5b80dfc7230b98001235cbc2e4c11bded46 /sbin
parent448bece5da7e46a44180845c85ee979221134c31 (diff)
add -z flag for zeroing statistics. -s status no longer resets anything
Diffstat (limited to 'sbin')
-rw-r--r--sbin/pfctl/pfctl.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index 2b7d72a0633..9db439e019f 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl.c,v 1.18 2001/06/26 23:24:06 kjell Exp $ */
+/* $OpenBSD: pfctl.c,v 1.19 2001/06/27 10:31:49 kjell Exp $ */
/*
* Copyright (c) 2001, Daniel Hartmeier
@@ -51,6 +51,7 @@ void usage(void);
char *load_file(char *, size_t *);
int pfctl_enable(int);
int pfctl_disable(int);
+int pfctl_clear_stats(int);
int pfctl_clear_rules(int);
int pfctl_clear_nat(int);
int pfctl_clear_states(int);
@@ -66,6 +67,7 @@ int dflag = 0;
int eflag = 0;
int vflag = 0;
int Nflag = 0;
+int zflag = 0;
char *clearopt;
char *logopt;
char *natopt;
@@ -78,7 +80,7 @@ usage()
extern char *__progname;
fprintf(stderr, "usage: %s [-de] [-c set] [-l interface]", __progname);
- fprintf(stderr, " [-n file] [-r file] [-s set]\n");
+ fprintf(stderr, " [-N] [-n file] [-r file] [-s set] [-v] [-z]\n");
exit(1);
}
@@ -136,6 +138,17 @@ pfctl_disable(int dev)
}
int
+pfctl_clear_stats(int dev)
+{
+ if (ioctl(dev, DIOCCLRSTATUS)) {
+ errx(1, "DIOCCLRSTATUS");
+ return (1);
+ }
+ printf("pf: statistics cleared\n");
+ return (0);
+}
+
+int
pfctl_clear_rules(int dev)
{
struct pfioc_rule pr;
@@ -428,7 +441,7 @@ main(int argc, char *argv[])
if (argc < 2)
usage();
- while ((ch = getopt(argc, argv, "c:del:Nn:r:s:v")) != -1) {
+ while ((ch = getopt(argc, argv, "c:del:Nn:r:s:vz")) != -1) {
switch (ch) {
case 'c':
clearopt = optarg;
@@ -457,6 +470,9 @@ main(int argc, char *argv[])
case 'v':
vflag++;
break;
+ case 'z':
+ zflag++;
+ break;
default:
usage();
/* NOTREACHED */
@@ -473,6 +489,10 @@ main(int argc, char *argv[])
if (pfctl_disable(dev))
error = 1;
+ if (zflag)
+ if (pfctl_clear_stats(dev))
+ error = 1;
+
if (clearopt != NULL) {
if (!strcmp(clearopt, "rules")) {
if (pfctl_clear_rules(dev))