summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filter/config.Y7
-rw-r--r--filter/filter.c4
2 files changed, 10 insertions, 1 deletions
diff --git a/filter/config.Y b/filter/config.Y
index 64109bc..9d0cc74 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -5,7 +5,7 @@
*
* Can be freely distributed and used under the terms of the GNU GPL.
*
- FIXME: constant prefixes, make prefix.ip and prefix.length work
+ FIXME: prefix variables, make prefix.ip and prefix.length work
FIXME: define keyword
FIXME: case without { }'s
FIXME: allow px+, px- px^pair in prefix sets
@@ -13,6 +13,8 @@
FIXME: whole system of paths, path ~ string, path.prepend(), path.originate
FIXME: create community lists
FIXME: access to dynamic attributes
+ FIXME: do not allow function call by callme(1,2,)
+ FIXME: pairs of integers: define compare
*/
CF_HDR
@@ -147,6 +149,7 @@ block:
set_atom:
NUM { $$.type = T_INT; $$.val.i = $1; }
| IPA { $$.type = T_IP; $$.val.ip = $1; }
+
;
set_item:
@@ -165,7 +168,9 @@ constant:
| TRUE { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_BOOL; $$->a2.i = 1; }
| FALSE { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_BOOL; $$->a2.i = 0; }
| TEXT { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_STRING; $$->a2.p = $1; }
+ | '(' NUM ',' NUM ')' { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_PAIR; $$->a2.i = $2 << 16 | $4; }
| IPA { struct f_val * val; val = cfg_alloc(sizeof(struct f_val)); $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; val->type = T_IP; val->val.ip = $1; }
+ | IPA '/' NUM { struct f_val * val; val = cfg_alloc(sizeof(struct f_val)); $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; val->type = T_PREFIX; val->val.px.ip = $1; val->val.px.len = $3; printf( "ook, we have prefix here\n" ); }
| '[' set_items ']' { printf( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_SET; $$->a2.p = build_tree($2); printf( "ook\n" ); }
;
diff --git a/filter/filter.c b/filter/filter.c
index aa0b9e9..d317fcc 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -6,6 +6,8 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*
* FIXME: local namespace for functions
+ *
+ * Notice that pair is stored as integer: first << 16 | second
*/
#include <stdio.h>
@@ -99,6 +101,8 @@ val_print(struct f_val v)
case T_INT: PRINTF( "%d ", v.val.i ); break;
case T_STRING: PRINTF( "%s", v.val.s ); break;
case T_IP: PRINTF( "%I", v.val.ip ); break;
+ case T_PREFIX: PRINTF( "%I/%d", v.val.px.ip, v.val.px.len ); break;
+ case T_PAIR: PRINTF( "(%d,%d)", v.val.i >> 16, v.val.i & 0xffff ); break;
case T_SET: tree_print( v.val.t ); PRINTF( "\n" ); break;
default: PRINTF( "[unknown type %x]", v.type );
}