summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcedric <cedric@openbsd.org>2004-02-17 08:48:29 +0000
committercedric <cedric@openbsd.org>2004-02-17 08:48:29 +0000
commit9ee451e7c2a417d025ca845d7500bab5d595c5f0 (patch)
tree97636e5a0232f832e24e3ec03b18881e97a4d26e
parentTighten pfi_skip_if() up, and a bit of KNF. ok mcbride@ (diff)
downloadwireguard-openbsd-9ee451e7c2a417d025ca845d7500bab5d595c5f0.tar.xz
wireguard-openbsd-9ee451e7c2a417d025ca845d7500bab5d595c5f0.zip
add -i flag, use it for -sI as a start. ok henning@, ok+test mcbride@
-rw-r--r--sbin/pfctl/pfctl.88
-rw-r--r--sbin/pfctl/pfctl.c20
-rw-r--r--sbin/pfctl/pfctl.h4
-rw-r--r--sbin/pfctl/pfctl_table.c6
4 files changed, 24 insertions, 14 deletions
diff --git a/sbin/pfctl/pfctl.8 b/sbin/pfctl/pfctl.8
index 8218171b8a5..40d21298e71 100644
--- a/sbin/pfctl/pfctl.8
+++ b/sbin/pfctl/pfctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pfctl.8,v 1.107 2004/02/12 11:03:45 jmc Exp $
+.\" $OpenBSD: pfctl.8,v 1.108 2004/02/17 08:48:29 cedric Exp $
.\"
.\" Copyright (c) 2001 Kjell Wooding. All rights reserved.
.\"
@@ -38,6 +38,7 @@
.Op Fl D Ar macro=value
.Op Fl F Ar modifier
.Op Fl f Ar file
+.Op Fl i Ar interface
.Op Fl k Ar host
.Op Fl p Ar device
.Op Fl s Ar modifier
@@ -189,6 +190,9 @@ order.
Include output helpful for debugging.
.It Fl h
Help.
+.It Fl i Ar interface
+Restrict the operation to the given
+.Ar interface .
.It Fl k Ar host
Kill all of the state entries originating from the specified
.Ar host .
@@ -297,6 +301,8 @@ Show the list of interfaces and interface drivers available to PF.
When used together with a double
.Fl v ,
interface statistics are also shown.
+.Fl i
+can be used to select an interface or a group of interfaces.
.It Fl s Ar all
Show all of the above.
.El
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index 6282934cca9..e7048e9100f 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl.c,v 1.204 2004/02/12 11:03:45 jmc Exp $ */
+/* $OpenBSD: pfctl.c,v 1.205 2004/02/17 08:48:29 cedric Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -86,6 +86,7 @@ const char *showopt;
const char *debugopt;
char *anchoropt;
char *pf_device = "/dev/pf";
+char *ifaceopt;
char *tableopt;
const char *tblcmdopt;
int state_killers;
@@ -191,10 +192,10 @@ usage(void)
fprintf(stderr, "usage: %s [-AdeghNnOqRrvz] ", __progname);
fprintf(stderr, "[-a anchor[:ruleset]] [-D macro=value]\n");
fprintf(stderr, " ");
- fprintf(stderr, "[-F modifier] [-f file] [-k host] [-p device] \n");
- fprintf(stderr, " ");
- fprintf(stderr, "[-s modifier] [-T command [address ...]]\n");
+ fprintf(stderr, "[-F modifier] [-f file] [-i interface] ");
+ fprintf(stderr, "[-k host] [-p device]\n");
fprintf(stderr, " ");
+ fprintf(stderr, "[-s modifier] [-T command [address ...]] ");
fprintf(stderr, "[-t table] [-x level]\n");
exit(1);
}
@@ -1450,8 +1451,8 @@ main(int argc, char *argv[])
if (argc < 2)
usage();
- while ((ch = getopt(argc, argv, "a:AdD:eqf:F:ghk:nNOp:rRs:t:T:vx:z")) !=
- -1) {
+ while ((ch = getopt(argc, argv,
+ "a:AdD:eqf:F:ghi:k:nNOp:rRs:t:T:vx:z")) != -1) {
switch (ch) {
case 'a':
anchoropt = optarg;
@@ -1480,6 +1481,9 @@ main(int argc, char *argv[])
}
mode = O_RDWR;
break;
+ case 'i':
+ ifaceopt = optarg;
+ break;
case 'k':
if (state_killers >= 2) {
warnx("can only specify -k twice");
@@ -1677,7 +1681,7 @@ main(int argc, char *argv[])
pfctl_show_limits(dev, opts);
pfctl_show_tables(anchorname, rulesetname, opts);
pfctl_show_fingerprints(opts);
- pfctl_show_ifaces(opts);
+ pfctl_show_ifaces(ifaceopt, opts);
break;
case 'T':
pfctl_show_tables(anchorname, rulesetname, opts);
@@ -1687,7 +1691,7 @@ main(int argc, char *argv[])
pfctl_show_fingerprints(opts);
break;
case 'I':
- pfctl_show_ifaces(opts);
+ pfctl_show_ifaces(ifaceopt, opts);
break;
}
}
diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h
index 25eb3d8a77c..a577e1d324e 100644
--- a/sbin/pfctl/pfctl.h
+++ b/sbin/pfctl/pfctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl.h,v 1.31 2004/02/10 22:26:56 dhartmei Exp $ */
+/* $OpenBSD: pfctl.h,v 1.32 2004/02/17 08:48:29 cedric Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -85,7 +85,7 @@ int pfctl_command_tables(int, char *[], char *, const char *, char *,
const char *, const char *, int);
int pfctl_show_altq(int, int, int);
void warn_namespace_collision(const char *);
-int pfctl_show_ifaces(int);
+int pfctl_show_ifaces(const char *, int);
#ifndef DEFAULT_PRIORITY
#define DEFAULT_PRIORITY 1
diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c
index 35abc5653be..8a790283f61 100644
--- a/sbin/pfctl/pfctl_table.c
+++ b/sbin/pfctl/pfctl_table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_table.c,v 1.55 2004/02/10 22:26:56 dhartmei Exp $ */
+/* $OpenBSD: pfctl_table.c,v 1.56 2004/02/17 08:48:29 cedric Exp $ */
/*
* Copyright (c) 2002 Cedric Berger
@@ -537,7 +537,7 @@ xprintf(int opts, const char *fmt, ...)
/* interface stuff */
int
-pfctl_show_ifaces(int opts)
+pfctl_show_ifaces(const char *filter, int opts)
{
struct pfr_buffer b;
struct pfi_if *p;
@@ -548,7 +548,7 @@ pfctl_show_ifaces(int opts)
for (;;) {
pfr_buf_grow(&b, b.pfrb_size);
b.pfrb_size = b.pfrb_msize;
- if (pfi_get_ifaces(NULL, b.pfrb_caddr, &b.pfrb_size,
+ if (pfi_get_ifaces(filter, b.pfrb_caddr, &b.pfrb_size,
PFI_FLAG_GROUP|PFI_FLAG_INSTANCE)) {
radix_perror();
return (1);