diff options
-rw-r--r-- | filter/config.Y | 9 | ||||
-rw-r--r-- | filter/test.conf | 53 |
2 files changed, 59 insertions, 3 deletions
diff --git a/filter/config.Y b/filter/config.Y index bbb8a640..93ad8d8b 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -35,6 +35,7 @@ f_valid_set_type(int type) case T_IP: case T_EC: case T_LC: + case T_RD: return 1; default: @@ -492,6 +493,7 @@ type: case T_QUAD: case T_EC: case T_LC: + case T_RD: case T_IP: $$ = T_SET; break; @@ -641,9 +643,10 @@ fipa: */ set_atom: - NUM { $$.type = T_INT; $$.val.i = $1; } - | fipa { $$ = $1; } - | ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); } + NUM { $$.type = T_INT; $$.val.i = $1; } + | fipa { $$ = $1; } + | VPN_RD { $$.type = T_RD; $$.val.ec = $1; } + | ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); } | '(' term ')' { $$ = f_eval($2, cfg_mem); if (!f_valid_set_type($$.type)) cf_error("Set-incompatible type"); diff --git a/filter/test.conf b/filter/test.conf index 989dab14..39b349cc 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -1006,6 +1006,59 @@ bt_test_suite(t_lclist_set, "Testing sets of large communities"); /* + * Testing Route Distinguishers + * ---------------------------- + */ + +function t_rd() +rd x; +{ + x = 12345:20000; + bt_assert(format(x) = "12345:20000"); + + bt_assert(x = 12345:20000); + bt_assert(x < 12345:20010); + bt_assert(x != 12346:20000); + bt_assert(x != 2:12345:20000); + bt_assert(!(x > 12345:200010)); + + bt_assert(format(10.0.0.1:1000) = "10.0.0.1:1000"); + bt_assert(format(100000:20000) = "100000:20000"); + bt_assert(format(2:100000:20000) = "100000:20000"); + bt_assert(format(2:1000:1000) = "2:1000:1000"); +} + +bt_test_suite(t_rd, "Testing route distinguishers"); + + + + +/* + * Testing sets of Route Distinguishers + * ------------------------------------ + */ + +function t_rd_set() +rd set rds; +{ + rds = [10:20, 100000:100..100000:200]; + bt_assert(format(rds) = "[10:20, 100000:100..100000:200]"); + + bt_assert(10:20 ~ rds); + bt_assert(10:21 !~ rds); + bt_assert(100000:90 !~ rds); + bt_assert(100000:100 ~ rds); + bt_assert(100000:128 ~ rds); + bt_assert(100000:200 ~ rds); + bt_assert(100010:150 !~ rds); +} + +bt_test_suite(t_rd_set, "Testing sets of route distinguishers"); + + + + +/* * Testing defined() function * -------------------------- */ |