string shell pattern match
Hi, according to the documentation for BIRD 1.6 it should be possible to use "shell patterns" with the ~ operator on strings: https://bird.network.cz/?get_doc&v=16&f=bird-5.html#ss5.2 I tried to apply this within a filter but the expression does not match: if ifname ~ "bond0.4[2345]" then { reject; } I can only match if I "unroll" the expression and create four different if statements. What does "shell pattern" from the documentation mean in this case? Are [ and ] not valid here? Regards -- Robert Sander Heinlein Support GmbH Schwedter Str. 8/9b, 10119 Berlin https://www.heinlein-support.de Tel: 030 / 405051-43 Fax: 030 / 405051-19 Amtsgericht Berlin-Charlottenburg - HRB 93818 B Geschäftsführer: Peer Heinlein - Sitz: Berlin
On 14/06/2019 12:58, Robert Sander wrote:
according to the documentation for BIRD 1.6 it should be possible to use "shell patterns" with the ~ operator on strings:
If you look here: [0] & note the description in the docs you referred to before. It should be clear enough the operators is meant to be used only with filter language in functions. """ The filter language supports common integer operators (+,-,*,/), parentheses (a*(b+c)), comparison (a=b, a!=b, a<b, a>=b). Logical operations include unary not (!), and (&&) and or (||). Special operators include (~, !~) for "is (not) element of a set" operation - it can be used on element and set of elements of the same type (returning true if element is contained in the given set), or on two strings (returning true if first string matches a shell-like pattern stored in second string) """ So if you create an function to check if the interface name matches a certain pattern. And in your if() statement matched against true/false return value of function. You should be able to do what you want. Alternatively look at the examples present on the page at [0]. Christoffer [0]: https://gitlab.labs.nic.cz/labs/bird/wikis/BGP_filtering
On 14.06.19 13:49, Hansen, Christoffer wrote:
So if you create an function to check if the interface name matches a certain pattern. And in your if() statement matched against true/false return value of function. You should be able to do what you want.
This does not work neither: function if_external(string ifnamestr) { if ifnamestr ~ "bond0.4[2345]" then return true; return false; } and later: export filter { if if_external(ifname) then reject; } Regards -- Robert Sander Heinlein Support GmbH Schwedter Str. 8/9b, 10119 Berlin https://www.heinlein-support.de Tel: 030 / 405051-43 Fax: 030 / 405051-19 Amtsgericht Berlin-Charlottenburg - HRB 93818 B Geschäftsführer: Peer Heinlein - Sitz: Berlin
participants (2)
-
Hansen, Christoffer -
Robert Sander