summaryrefslogtreecommitdiff
path: root/usr.sbin/hoststated/parse.y
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2007-11-23 09:39:43 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2007-11-23 09:39:43 +0000
commit8a55c5d3ca663058a2ddc8dc5b0ac47e65d3b5b6 (patch)
treef95e92f40af0ac6bdddff0df6be66cc24d3c8f83 /usr.sbin/hoststated/parse.y
parent53d6b9213667eaffb95e49df42f51cc6006463eb (diff)
re-implement the "mark" action and document it in the manpage:
it is possible to attach a mark to a session based on matching an entity (header, url, cookie, ...) and add conditional action for this mark. it works a bit like the tag/tagged keywords in pf, but i decided to pick a different name to avoid confusion. ok pyr@ gilles@
Diffstat (limited to 'usr.sbin/hoststated/parse.y')
-rw-r--r--usr.sbin/hoststated/parse.y53
1 files changed, 39 insertions, 14 deletions
diff --git a/usr.sbin/hoststated/parse.y b/usr.sbin/hoststated/parse.y
index 86ebc48c691..55aeef325d2 100644
--- a/usr.sbin/hoststated/parse.y
+++ b/usr.sbin/hoststated/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.93 2007/11/22 10:09:53 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.94 2007/11/23 09:39:42 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -121,7 +121,7 @@ typedef struct {
%token SERVICE TABLE BACKUP HOST REAL INCLUDE
%token CHECK TCP ICMP EXTERNAL REQUEST RESPONSE
%token TIMEOUT CODE DIGEST PORT TAG INTERFACE STYLE RETURN
-%token VIRTUAL INTERVAL DISABLE STICKYADDR BACKLOG PATH SCRIPT
+%token VIRTUAL INTERVAL DISABLE STICKYADDR BACKLOG PATH SCRIPT WITH
%token SEND EXPECT NOTHING SSL LOADBALANCE ROUNDROBIN CIPHERS COOKIE
%token RELAY LISTEN ON FORWARD TO NAT LOOKUP PREFORK NO MARK MARKED URL
%token PROTO SESSION CACHE APPEND CHANGE REMOVE FROM FILTER HASH HEADER
@@ -130,7 +130,7 @@ typedef struct {
%token <v.string> STRING
%token <v.number> NUMBER
%type <v.string> interface hostname
-%type <v.number> port http_type loglevel sslcache optssl dstport
+%type <v.number> port http_type loglevel sslcache optssl dstport mark
%type <v.number> proto_type dstmode docheck retry log flag direction
%type <v.host> host
%type <v.tv> timeout
@@ -897,7 +897,7 @@ protonode : nodetype APPEND STRING TO STRING marked {
fatal("out of memory");
free($3);
}
- | nodetype EXPECT STRING FROM STRING mark {
+ | nodetype EXPECT STRING FROM STRING marked {
node.action = NODE_ACTION_EXPECT;
node.key = strdup($5);
node.value = strdup($3);
@@ -907,7 +907,7 @@ protonode : nodetype APPEND STRING TO STRING marked {
free($3);
proto->lateconnect++;
}
- | nodetype EXPECT STRING mark {
+ | nodetype EXPECT STRING marked {
node.action = NODE_ACTION_EXPECT;
node.key = strdup($3);
node.value = strdup("*");
@@ -916,7 +916,7 @@ protonode : nodetype APPEND STRING TO STRING marked {
free($3);
proto->lateconnect++;
}
- | nodetype EXPECT digest mark {
+ | nodetype EXPECT digest marked {
if (node.type != NODE_TYPE_URL) {
yyerror("digest not supported for this type");
free($3.digest);
@@ -931,7 +931,7 @@ protonode : nodetype APPEND STRING TO STRING marked {
free($3.digest);
proto->lateconnect++;
}
- | nodetype FILTER STRING FROM STRING mark {
+ | nodetype FILTER STRING FROM STRING marked {
node.action = NODE_ACTION_FILTER;
node.key = strdup($5);
node.value = strdup($3);
@@ -941,7 +941,7 @@ protonode : nodetype APPEND STRING TO STRING marked {
free($3);
proto->lateconnect++;
}
- | nodetype FILTER STRING mark {
+ | nodetype FILTER STRING marked {
node.action = NODE_ACTION_FILTER;
node.key = strdup($3);
node.value = strdup("*");
@@ -950,7 +950,7 @@ protonode : nodetype APPEND STRING TO STRING marked {
free($3);
proto->lateconnect++;
}
- | nodetype FILTER digest mark {
+ | nodetype FILTER digest marked {
if (node.type != NODE_TYPE_URL) {
yyerror("digest not supported for this type");
free($3.digest);
@@ -983,14 +983,38 @@ protonode : nodetype APPEND STRING TO STRING marked {
fatal("out of memory");
free($3);
}
+ | nodetype MARK STRING FROM STRING WITH mark {
+ node.action = NODE_ACTION_MARK;
+ node.key = strdup($5);
+ node.value = strdup($3);
+ node.mark = $7;
+ if (node.key == NULL || node.value == NULL)
+ fatal("out of memory");
+ free($3);
+ free($5);
+ }
+ | nodetype MARK STRING WITH mark {
+ node.action = NODE_ACTION_MARK;
+ node.key = strdup($3);
+ node.value = strdup("*");
+ node.mark = $5;
+ if (node.key == NULL || node.value == NULL)
+ fatal("out of memory");
+ free($3);
+ }
;
-mark : /* empty */
- | MARK { node.flags |= PNFLAG_MARK; }
+marked : /* empty */
+ | MARKED mark { node.mark = $2; }
;
-marked : /* empty */
- | MARKED { node.flags |= PNFLAG_MARK; }
+mark : NUMBER {
+ if ($1 <= 0 || $1 >= (int)USHRT_MAX) {
+ yyerror("invalid mark: %d", $1);
+ YYERROR;
+ }
+ $$ = $1;
+ }
;
nodetype : HEADER {
@@ -1392,7 +1416,8 @@ lookup(char *s)
{ "to", TO },
{ "updates", UPDATES },
{ "url", URL },
- { "virtual", VIRTUAL }
+ { "virtual", VIRTUAL },
+ { "with", WITH }
};
const struct keywords *p;