summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-05 12:48:52 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-05 12:48:52 +0100
commitfe9f1a6dedda6bab23cbb605d1cd5db6cd3e2468 (patch)
treed6ea417b7ed16c90b29634fe075e51508dec87d9 /filter
parent8eb8e546dc8cc647fcfa4a3a17dfa8ab36b00958 (diff)
Initial commit on integrated BIRD
New data types net_addr and variants (in lib/net.h) describing network addresses (prefix/pxlen). Modifications of FIB structures to handle these data types and changing everything to use these data types instead of prefix/pxlen pairs where possible. The commit is WiP, some protocols are not yet updated (BGP, Kernel), and the code contains some temporary scaffolding. Comments are welcome.
Diffstat (limited to 'filter')
-rw-r--r--filter/config.Y7
-rw-r--r--filter/filter.c8
2 files changed, 6 insertions, 9 deletions
diff --git a/filter/config.Y b/filter/config.Y
index 7eb2c0a3..312506c4 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -477,7 +477,7 @@ block:
* Complex types, their bison value is struct f_val
*/
fipa:
- IPA %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.px.ip = $1; }
+ ipa_raw %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.px.ip = $1; }
;
@@ -491,7 +491,6 @@ fipa:
set_atom:
NUM { $$.type = T_INT; $$.val.i = $1; }
- | RTRID { $$.type = T_QUAD; $$.val.i = $1; }
| fipa { $$ = $1; }
| ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); }
| '(' term ')' {
@@ -508,7 +507,6 @@ set_atom:
switch_atom:
NUM { $$.type = T_INT; $$.val.i = $1; }
| '(' term ')' { $$.type = T_INT; $$.val.i = f_eval_int($2); }
- | RTRID { $$.type = T_QUAD; $$.val.i = $1; }
| fipa { $$ = $1; }
| ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); }
;
@@ -575,7 +573,7 @@ switch_items:
;
fprefix_s:
- IPA '/' NUM %prec '/' {
+ ipa_raw '/' NUM %prec '/' {
if (($3 < 0) || ($3 > MAX_PREFIX_LENGTH) || !ip_is_prefix($1, $3)) cf_error("Invalid network prefix: %I/%d.", $1, $3);
$$.type = T_PREFIX; $$.val.px.ip = $1; $$.val.px.len = $3;
}
@@ -646,7 +644,6 @@ constant:
| 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; }
| fprefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
- | RTRID { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_QUAD; $$->a2.i = $1; }
| '[' 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.c b/filter/filter.c
index 55062aca..1383961c 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -792,8 +792,8 @@ interpret(struct f_inst *what)
{
case SA_FROM: res.val.px.ip = rta->from; break;
case SA_GW: res.val.px.ip = rta->gw; break;
- case SA_NET: res.val.px.ip = (*f_rte)->net->n.prefix;
- res.val.px.len = (*f_rte)->net->n.pxlen; break;
+ case SA_NET: res.val.px.ip = net_prefix((*f_rte)->net->n.addr);
+ res.val.px.len = net_pxlen((*f_rte)->net->n.addr); break;
case SA_PROTO: res.val.s = rta->src->proto->name; break;
case SA_SOURCE: res.val.i = rta->source; break;
case SA_SCOPE: res.val.i = rta->scope; break;
@@ -1292,8 +1292,8 @@ interpret(struct f_inst *what)
else
{
ACCESS_RTE;
- v1.val.px.ip = (*f_rte)->net->n.prefix;
- v1.val.px.len = (*f_rte)->net->n.pxlen;
+ v1.val.px.ip = net_prefix((*f_rte)->net->n.addr);
+ v1.val.px.len = net_pxlen((*f_rte)->net->n.addr);
/* We ignore temporary attributes, probably not a problem here */
/* 0x02 is a value of BA_AS_PATH, we don't want to include BGP headers */