dfilter: Handle a bitwise expr on the RHS
This commit is contained in:
parent
0335ebdc3a
commit
2fc8c0e36b
|
@ -721,6 +721,19 @@ again:
|
|||
else if (type2 == STTYPE_PCRE) {
|
||||
ws_assert(st_op == TEST_OP_MATCHES);
|
||||
}
|
||||
else if (type2 == STTYPE_BITWISE) {
|
||||
ftype2 = check_bitwise_operation(dfw, st_arg2);
|
||||
|
||||
if (!compatible_ftypes(ftype1, ftype2)) {
|
||||
FAIL(dfw, "%s and %s are not of compatible types.",
|
||||
stnode_todisplay(st_arg1), stnode_todisplay(st_arg2));
|
||||
}
|
||||
|
||||
if (!can_func(ftype2)) {
|
||||
FAIL(dfw, "%s (type=%s) cannot participate in specified comparison.",
|
||||
stnode_todisplay(st_arg2), ftype_pretty_name(ftype2));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
|
@ -801,6 +814,19 @@ again:
|
|||
else if (type2 == STTYPE_PCRE) {
|
||||
ws_assert(st_op == TEST_OP_MATCHES);
|
||||
}
|
||||
else if (type2 == STTYPE_BITWISE) {
|
||||
ftype2 = check_bitwise_operation(dfw, st_arg2);
|
||||
|
||||
if (!compatible_ftypes(FT_BYTES, ftype2)) {
|
||||
FAIL(dfw, "%s and %s are not of compatible types.",
|
||||
stnode_todisplay(st_arg1), stnode_todisplay(st_arg2));
|
||||
}
|
||||
|
||||
if (!can_func(ftype2)) {
|
||||
FAIL(dfw, "%s (type=%s) cannot participate in specified comparison.",
|
||||
stnode_todisplay(st_arg2), ftype_pretty_name(ftype2));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
|
@ -904,6 +930,19 @@ again:
|
|||
else if (type2 == STTYPE_PCRE) {
|
||||
ws_assert(st_op == TEST_OP_MATCHES);
|
||||
}
|
||||
else if (type2 == STTYPE_BITWISE) {
|
||||
ftype2 = check_bitwise_operation(dfw, st_arg2);
|
||||
|
||||
if (!compatible_ftypes(ftype1, ftype2)) {
|
||||
FAIL(dfw, "%s and %s are not of compatible types.",
|
||||
stnode_todisplay(st_arg1), stnode_todisplay(st_arg2));
|
||||
}
|
||||
|
||||
if (!can_func(ftype2)) {
|
||||
FAIL(dfw, "%s (type=%s) cannot participate in specified comparison.",
|
||||
stnode_todisplay(st_arg2), ftype_pretty_name(ftype2));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ws_assert_not_reached();
|
||||
}
|
||||
|
|
|
@ -149,10 +149,14 @@ class case_bitwise(unittest.TestCase):
|
|||
dfilter = "tcp.flags & 0x8"
|
||||
checkDFilterCount(dfilter, 1)
|
||||
|
||||
def test_exists_1(self, checkDFilterCount):
|
||||
def test_exists_2(self, checkDFilterCount):
|
||||
dfilter = "eth[0] & 1"
|
||||
checkDFilterCount(dfilter, 0)
|
||||
|
||||
def test_equal_1(self, checkDFilterCount):
|
||||
dfilter = "tcp.flags & 0x0F == 8"
|
||||
checkDFilterCount(dfilter, 1)
|
||||
|
||||
def test_exists_1(self, checkDFilterCount):
|
||||
dfilter = "eth[0] & 1"
|
||||
checkDFilterCount(dfilter, 0)
|
||||
def test_equal_2(self, checkDFilterCount):
|
||||
dfilter = "tcp.srcport != tcp.dstport & 0x0F"
|
||||
checkDFilterCount(dfilter, 1)
|
||||
|
|
Loading…
Reference in New Issue