summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2015-12-24 15:52:03 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2015-12-24 15:56:04 +0100
commit04632fd77f291f67753341d12d540f7dac341bd3 (patch)
tree94b319a0fe0e312539857e76e0b9d6982ce81555 /filter
parent70b90dde23a684c4d32aa53685f76a73ecba941d (diff)
Follow-up work on integration
Diffstat (limited to 'filter')
-rw-r--r--filter/config.Y19
-rw-r--r--filter/filter.h2
-rw-r--r--filter/test.conf16
3 files changed, 22 insertions, 15 deletions
diff --git a/filter/config.Y b/filter/config.Y
index 7e9f4104..6efc14f5 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -475,7 +475,8 @@ block:
* Complex types, their bison value is struct f_val
*/
fipa:
- ipa_raw %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.ip = $1; }
+ IP4 %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.ip = ipa_from_ip4($1); }
+ | IP6 %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.ip = ipa_from_ip6($1); }
;
@@ -571,19 +572,19 @@ switch_items:
;
fprefix:
- net_ip { $$.net = $1; $$.lo = $1.n.pxlen; $$.hi = $1.n.pxlen; }
- | net_ip '+' { $$.net = $1; $$.lo = $1.n.pxlen; $$.hi = net_max_prefix_length[$1.n.type]; }
- | net_ip '-' { $$.net = $1; $$.lo = 0; $$.hi = $1.n.pxlen; }
- | net_ip '{' NUM ',' NUM '}' {
+ net_ip_ { $$.net = $1; $$.lo = $1.pxlen; $$.hi = $1.pxlen; }
+ | net_ip_ '+' { $$.net = $1; $$.lo = $1.pxlen; $$.hi = net_max_prefix_length[$1.type]; }
+ | net_ip_ '-' { $$.net = $1; $$.lo = 0; $$.hi = $1.pxlen; }
+ | net_ip_ '{' NUM ',' NUM '}' {
$$.net = $1; $$.lo = $3; $$.hi = $5;
- if ((0 > $3) || ($3 > $5) || ($5 > net_max_prefix_length[$1.n.type]))
+ if ((0 > $3) || ($3 > $5) || ($5 > net_max_prefix_length[$1.type]))
cf_error("Invalid prefix pattern range: {%d, %d}", $3, $5);
}
;
fprefix_set:
- fprefix { $$ = f_new_trie(cfg_mem, sizeof(struct f_trie_node)); trie_add_prefix($$, &($1.net.n), $1.lo, $1.hi); }
- | fprefix_set ',' fprefix { $$ = $1; trie_add_prefix($$, &($3.net.n), $3.lo, $3.hi); }
+ fprefix { $$ = f_new_trie(cfg_mem, sizeof(struct f_trie_node)); trie_add_prefix($$, &($1.net), $1.lo, $1.hi); }
+ | fprefix_set ',' fprefix { $$ = $1; trie_add_prefix($$, &($3.net), $3.lo, $3.hi); }
;
switch_body: /* EMPTY */ { $$ = NULL; }
@@ -635,7 +636,7 @@ constant:
| FALSE { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_BOOL; $$->a2.i = 0; }
| TEXT { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_STRING; $$->a2.p = $1; }
| fipa { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
- | net_any { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; val->type = T_NET; val->val.net = $1; $$->a1.p = val; }
+ | net_ { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; val->type = T_NET; val->val.net = $1; $$->a1.p = val; }
| '[' set_items ']' { DBG( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_SET; $$->a2.p = build_tree($2); DBG( "ook\n" ); }
| '[' fprefix_set ']' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_PREFIX_SET; $$->a2.p = $2; }
| ENUM { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
diff --git a/filter/filter.h b/filter/filter.h
index 1052f8c8..c100a79a 100644
--- a/filter/filter.h
+++ b/filter/filter.h
@@ -39,7 +39,7 @@ struct f_inst_roa_check {
};
struct f_prefix {
- net_addr_union net;
+ net_addr net;
u8 lo, hi;
};
diff --git a/filter/test.conf b/filter/test.conf
index a99d0a51..c3f74d94 100644
--- a/filter/test.conf
+++ b/filter/test.conf
@@ -16,6 +16,10 @@ define ten = 10;
define p23 = (2, 3);
define ip1222 = 1.2.2.2;
+define net10 = 10.0.0.0/8;
+define netdoc = 2001:db8::/32;
+
+
function onef(int a)
{
return 1;
@@ -55,6 +59,7 @@ function fifteen()
return 15;
}
+/*
roa table rl
{
roa 10.110.0.0/16 max 16 as 1000;
@@ -80,6 +85,7 @@ function test_roa()
" ", roa_check(rl, 10.130.30.0/24, 3000) = ROA_INVALID,
" ", roa_check(rl, 10.130.130.0/24, 3000) = ROA_VALID;
}
+*/
function path_test()
bgpmask pm1;
@@ -232,7 +238,7 @@ function __test2()
function test_pxset(prefix set pxs)
{
print pxs;
- print " must be true: ", 10.0.0.0/8 ~ pxs, ",", 10.0.0.0/10 ~ pxs, ",", 10.0.0.0/12 ~ pxs, ",",
+ print " must be true: ", net10 ~ pxs, ",", 10.0.0.0/10 ~ pxs, ",", 10.0.0.0/12 ~ pxs, ",",
20.0.0.0/24 ~ pxs, ",", 20.0.40.0/24 ~ pxs, ",", 20.0.0.0/26 ~ pxs, ",",
20.0.100.0/26 ~ pxs, ",", 20.0.0.0/28 ~ pxs, ",", 20.0.255.0/28 ~ pxs;
print " must be false: ", 10.0.0.0/7 ~ pxs, ",", 10.0.0.0/13 ~ pxs, ",", 10.0.0.0/16 ~ pxs, ",",
@@ -312,12 +318,12 @@ string st;
px = 1.2.0.0/18;
print "Testing prefixes: 1.2.0.0/18 = ", px;
- print " must be true: ", 192.168.0.0/16 ~ 192.168.0.0/16, " ", 192.168.0.0/17 ~ 192.168.0.0/16, " ", 192.168.254.0/24 ~ 192.168.0.0/16;
- print " must be false: ", 192.168.0.0/15 ~ 192.168.0.0/16, " ", 192.160.0.0/17 ~ 192.168.0.0/16;
+ print " must be true: ", 192.168.0.0/16 ~ 192.168.0.0/16, " ", 192.168.0.0/17 ~ 192.168.0.0/16, " ", 192.168.254.0/24 ~ 192.168.0.0/16, " ", netdoc ~ 2001::/16;
+ print " must be false: ", 192.168.0.0/15 ~ 192.168.0.0/16, " ", 192.160.0.0/17 ~ 192.168.0.0/16, " ", px ~ netdoc;
p = 127.1.2.3;
print "Testing mask : 127.0.0.0 = ", p.mask(8);
-
+
pp = (1, 2);
print "Testing pairs: (1,2) = ", (1,2), " = ", pp, " = ", (1,1+1), " = ", 'mkpair-a'(2);
print " must be true: ", (1,2) = (1,1+1);
@@ -397,7 +403,7 @@ string st;
print "1.2.3.4 = ", onetwo;
i = 4200000000;
- print "4200000000 = ", i, " false: ", i = 4200000000, " ", i > 4100000000, " false: ", i > 4250000000;
+ print "4200000000 = ", i, " true: ", i = 4200000000, " ", i > 4100000000, " false: ", i > 4250000000;
test_undef(2);
test_undef(3);