diff options
author | João Valverde <j@v6e.pt> | 2022-04-04 16:52:11 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2022-04-08 23:12:04 +0100 |
commit | fb9a176587454e8168c2ba068d5701332638109c (patch) | |
tree | a33c89aacf2b52cb122308d4ff718e76b5eefc6d /test | |
parent | 73770c61b42577e0c8ad8c8bea5623fec746d0d5 (diff) |
dfilter: Allow grouping arithmetical expressions with { }
This removes the limitation of having only two terms in an
arithmetic expression and allows setting the precedence using
curly braces (like any basic calculator).
Our grammar currently does not allow grouping arithmetic expressions
using parenthesis, because boolean expressions and arithmetic
expressions are different and parenthesis are used with the former.
Diffstat (limited to 'test')
-rw-r--r-- | test/suite_dfilter/group_syntax.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/suite_dfilter/group_syntax.py b/test/suite_dfilter/group_syntax.py index 5ca2aff038..91f9509a6f 100644 --- a/test/suite_dfilter/group_syntax.py +++ b/test/suite_dfilter/group_syntax.py @@ -262,3 +262,11 @@ class case_arithmetic(unittest.TestCase): def test_sub_4(self, checkDFilterCount): dfilter = "udp.length == ip.len - 20" checkDFilterCount(dfilter, 4) + + def test_expr_1(self, checkDFilterCount): + dfilter = 'udp.port * { 10 / {5 - 4} } == udp.port * { {50 + 50} / 2 - 40 }' + checkDFilterCount(dfilter, 4) + + def test_expr_2(self, checkDFilterCount): + dfilter = 'udp.dstport * { udp.srcport / {5 - 4} } == udp.srcport * { 2 * udp.dstport - 68 }' + checkDFilterCount(dfilter, 2) |