summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
Diffstat (limited to 'filter')
-rw-r--r--filter/filter.c29
-rw-r--r--filter/test.conf4
2 files changed, 32 insertions, 1 deletions
diff --git a/filter/filter.c b/filter/filter.c
index 98bae331..25587e0f 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -1165,7 +1165,34 @@ interpret(struct f_inst *what)
case P('C','a'): /* (Extended) Community list add or delete */
TWOARGS;
- if (v1.type == T_CLIST)
+ if (v1.type == T_PATH)
+ {
+ struct f_tree *set = NULL;
+ u32 key = 0;
+ int pos;
+
+ if (v2.type == T_INT)
+ key = v2.val.i;
+ else if ((v2.type == T_SET) && (v2.val.t->from.type == T_INT))
+ set = v2.val.t;
+ else
+ runtime("Can't delete non-integer (set)");
+
+ switch (what->aux)
+ {
+ case 'a': runtime("Can't add to path");
+ case 'd': pos = 0; break;
+ case 'f': pos = 1; break;
+ default: bug("unknown Ca operation");
+ }
+
+ if (pos && !set)
+ runtime("Can't filter integer");
+
+ res.type = T_PATH;
+ res.val.ad = as_path_filter(f_pool, v1.val.ad, set, key, pos);
+ }
+ else if (v1.type == T_CLIST)
{
/* Community (or cluster) list */
struct f_val dummy;
diff --git a/filter/test.conf b/filter/test.conf
index 4f40abff..048983b5 100644
--- a/filter/test.conf
+++ b/filter/test.conf
@@ -104,6 +104,8 @@ eclist el2;
print "Should be true: ", p2 ~ [= (3+2) (2*2) 3 2 1 =], " ", p2 ~ mkpath(5, 4);
print "Should be true: ", p2.len = 5, " ", p2.first = 5, " ", p2.last = 1;
print "5 = ", p2.len;
+ print "Delete 3: ", delete(p2, 3);
+ print "Filter 1-3: ", filter(p2, [1..3]);
pm1 = [= 1 2 * 3 4 5 =];
p2 = prepend( + empty +, 5 );
@@ -113,6 +115,8 @@ eclist el2;
p2 = prepend( p2, 2 );
p2 = prepend( p2, 1 );
print "Should be true: ", p2 ~ pm1, " ", p2, " ", pm1;
+ print "Delete 3: ", delete(p2, 3);
+ print "Delete 4-5: ", delete(p2, [4..5]);
l = - empty -;
print "Should be false in this special case: ", l ~ [(*,*)];