summaryrefslogtreecommitdiff
path: root/sbin/pfctl
diff options
context:
space:
mode:
authorCedric Berger <cedric@cvs.openbsd.org>2003-02-25 12:22:26 +0000
committerCedric Berger <cedric@cvs.openbsd.org>2003-02-25 12:22:26 +0000
commiteeb262f969301c3dd4cdfe3d3e61e99a5368c828 (patch)
treebbd08e72ea81521ca3b561d838fa3be5714d1163 /sbin/pfctl
parentf50dc4f119c0eeb6ea2ff5e405746491b021a36e (diff)
repair/simplify/flexify binat userland.
ok dhartmei@ henning@
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/parse.y55
-rw-r--r--sbin/pfctl/pfctl_parser.c19
2 files changed, 21 insertions, 53 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index bca5d984e99..c5abb3f8c61 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.329 2003/02/24 21:55:51 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.330 2003/02/25 12:22:25 cedric Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -2427,6 +2427,17 @@ binatrule : no BINAT interface af proto FROM host TO ipspec redirection
else
binat.action = PF_BINAT;
binat.af = $4;
+ if (!binat.af && $7 != NULL && $7->af)
+ binat.af = $7->af;
+ if (!binat.af && $9 != NULL && $9->af)
+ binat.af = $9->af;
+ if (!binat.af && $10 != NULL && $10->host)
+ binat.af = $10->host->af;
+ if (!binat.af) {
+ yyerror("address family (inet/inet6) "
+ "undefined");
+ YYERROR;
+ }
if ($3 != NULL) {
memcpy(binat.ifname, $3->ifname,
@@ -2446,34 +2457,19 @@ binatrule : no BINAT interface af proto FROM host TO ipspec redirection
"redirect address of a binat rule"))
YYERROR;
- if ($7 != NULL && $9 != NULL && $7->af != $9->af) {
- yyerror("binat ip versions must match");
- YYERROR;
- }
if ($7 != NULL) {
if ($7->next) {
yyerror("multiple binat ip addresses");
YYERROR;
}
- if ($7->addr.type == PF_ADDR_DYNIFTL) {
- if (!binat.af) {
- yyerror("address family (inet/"
- "inet6) undefined");
- YYERROR;
- }
+ if ($7->addr.type == PF_ADDR_DYNIFTL)
$7->af = binat.af;
- }
- if (binat.af && $7->af != binat.af) {
+ if ($7->af != binat.af) {
yyerror("binat ip versions must match");
YYERROR;
}
- binat.af = $7->af;
- memcpy(&binat.src.addr.v.a.addr,
- &$7->addr.v.a.addr,
- sizeof(binat.src.addr.v.a.addr));
- memcpy(&binat.src.addr.v.a.mask,
- &$7->addr.v.a.mask,
- sizeof(binat.src.addr.v.a.mask));
+ memcpy(&binat.src.addr, &$7->addr,
+ sizeof(binat.src.addr));
free($7);
}
if ($9 != NULL) {
@@ -2481,25 +2477,12 @@ binatrule : no BINAT interface af proto FROM host TO ipspec redirection
yyerror("multiple binat ip addresses");
YYERROR;
}
- if ($9->addr.type == PF_ADDR_DYNIFTL) {
- if (!binat.af) {
- yyerror("address family (inet/"
- "inet6) undefined");
- YYERROR;
- }
- $9->af = binat.af;
- }
- if (binat.af && $9->af != binat.af) {
+ if ($9->af != binat.af && $9->af) {
yyerror("binat ip versions must match");
YYERROR;
}
- binat.af = $9->af;
- memcpy(&binat.dst.addr.v.a.addr,
- &$9->addr.v.a.addr,
- sizeof(binat.dst.addr.v.a.addr));
- memcpy(&binat.dst.addr.v.a.mask,
- &$9->addr.v.a.mask,
- sizeof(binat.dst.addr.v.a.mask));
+ memcpy(&binat.dst.addr, &$9->addr,
+ sizeof(binat.dst.addr));
binat.dst.not = $9->not;
free($9);
}
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index 484b2987142..0c9bebd1286 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_parser.c,v 1.144 2003/02/19 19:08:19 cedric Exp $ */
+/* $OpenBSD: pfctl_parser.c,v 1.145 2003/02/25 12:22:25 cedric Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -580,22 +580,7 @@ print_binat(struct pf_rule *b, int verbose)
else
printf("proto %u ", b->proto);
}
- printf("from ");
- if (!PF_AZERO(&b->src.addr.v.a.addr, b->af) ||
- !PF_AZERO(&b->src.addr.v.a.mask, b->af)) {
- print_addr(&b->src.addr, b->af, verbose);
- printf(" ");
- } else
- printf("any ");
- printf("to ");
- if (!PF_AZERO(&b->dst.addr.v.a.addr, b->af) ||
- !PF_AZERO(&b->dst.addr.v.a.mask, b->af)) {
- if (b->dst.not)
- printf("! ");
- print_addr(&b->dst.addr, b->af, verbose);
- printf(" ");
- } else
- printf("any ");
+ print_fromto(&b->src, &b->dst, b->af, b->proto, verbose);
if (!b->anchorname[0] && (b->action == PF_BINAT)) {
printf("-> ");
print_pool(&b->rpool, 0, 0, b->af, PF_BINAT);