summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/pfctl/parse.y43
1 files changed, 40 insertions, 3 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index e6f88352269..c2de13b1d23 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.81 2002/06/08 07:58:07 dhartmei Exp $ */
+/* $OpenBSD: parse.y,v 1.82 2002/06/08 08:04:02 henning Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -143,6 +143,7 @@ struct sym {
struct sym *symhead = NULL;
int symset(char *name, char *val);
+int symextend(char *name, char *val);
char * symget(char *name);
struct ifaddrs *ifa0_lookup(char *ifa_name);
@@ -198,9 +199,9 @@ typedef struct {
%token PASS BLOCK SCRUB RETURN IN OUT LOG LOGALL QUICK ON FROM TO FLAGS
%token RETURNRST RETURNICMP RETURNICMP6 PROTO INET INET6 ALL ANY ICMPTYPE
-%token ICMP6TYPE CODE KEEP MODULATE STATE PORT RDR NAT BINAT ARROW NODF
+%token ICMP6TYPE CODE KEEP MODULATE STATE PORT RDR NAT BINAT ARROW NODF
%token MINTTL IPV6ADDR ERROR ALLOWOPTS FASTROUTE ROUTETO DUPTO NO LABEL
-%token NOROUTE FRAGMENT USER GROUP MAXMSS MAXIMUM TTL
+%token NOROUTE FRAGMENT USER GROUP MAXMSS MAXIMUM TTL PLUSEQUAL
%token <v.string> STRING
%token <v.number> NUMBER
%token <v.i> PORTUNARY PORTBINARY
@@ -231,6 +232,7 @@ ruleset : /* empty */
| ruleset binatrule '\n'
| ruleset rdrrule '\n'
| ruleset varset '\n'
+ | ruleset varextend '\n'
| ruleset error '\n' { errors++; }
;
@@ -245,6 +247,17 @@ varset : STRING PORTUNARY STRING
}
;
+varextend : STRING PLUSEQUAL STRING
+ {
+ if (pf->opts & PF_OPT_VERBOSE)
+ printf("%s += %s\n", $1, $3);
+ if (symextend($1, $3) == -1) {
+ yyerror("cannot extend variable %s", $1);
+ YYERROR;
+ }
+ }
+ ;
+
pfrule : action dir log quick interface route af proto fromto
uids gids flags icmpspec keep fragment nodf minttl
maxmss allowopts label
@@ -2209,6 +2222,12 @@ top:
return (ARROW);
lungetc(next, fin);
break;
+ case '+':
+ next = lgetc(fin);
+ if (next == '=')
+ return (PLUSEQUAL);
+ lungetc(next, fin);
+ break;
}
/* Need to parse v6 addresses before tokenizing numbers. ick */
@@ -2399,6 +2418,24 @@ symset(char *nam, char *val)
return (0);
}
+int
+symextend(char *nam, char *val)
+{
+ struct sym *sym;
+ char *p;
+
+ for (sym = symhead; sym && strcmp(nam, sym->nam); sym = sym->next)
+ ; /* nothing */
+ if (sym == NULL)
+ return -1;
+ p = realloc(sym->val, strlen(sym->val) + strlen(val) + 1);
+ if (p == NULL)
+ return -1;
+ sym->val = p;
+ strlcat(sym->val, val, strlen(sym->val) + strlen(val) + 1);
+ return 0;
+}
+
char *
symget(char *nam)
{