wireshark/test/suite_dfilter
João Valverde 0abe10e040 dfilter: Fix "!=" relation to be free of contradictions
Wireshark defines the relation of equality A == B as
A any_eq B <=> An == Bn for at least one An, Bn.
More accurately I think this is (formally) an equivalence
relation, not true equality.

Whichever definition for "==" we choose we must keep the
definition of "!=" as !(A == B), otherwise it will
lead to logical contradictions like (A == B) AND (A != B)
being true.

Fix the '!=' relation to match the definition of equality:
  A != B <=> !(A == B) <=> A all_ne B <=> An != Bn, for
every n.

This has been the recomended way to write "not equal" for a
long time in the documentation, even to the point where != was
deprecated, but it just wasn't implemented consistently in the
language, which has understandably been a persistent source
of confusion. Even a field that is normally well-behaved
with "!=" like "ip.src" or "ip.dst" will produce unexpected
results with encapsulations like IP-over-IP.

The opcode ALL_NE could have been implemented in the compiler
instead using NOT and ANY_EQ but I chose to implement it in
bytecode. It just seemed more elegant and efficient
but the difference was not very significant.

Keep around "~=" for any_ne relation, in case someone depends
on that, and because we don't have an operator for true equality:
  A strict_equal B <=> A all_eq B <=> !(A any_ne B).
If there is only one value then any_ne and all_ne are the same
comparison operation.

Implementing this change did not require fixing any tests so it
is unlikely the relation "~=" (any_ne) will be very useful.

Note that the behaviour of the '<' (less than) comparison relation
is a separate, more subtle issue. In the general case the definition
of '<' that is used is only a partial order.
2021-10-24 06:55:54 +00:00
..
__init__.py
dfiltertest.py tests: Accept a partial string in checkDFilterFail() 2021-10-15 15:10:57 +01:00
group_bytes_ether.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00
group_bytes_ipv6.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00
group_bytes_type.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00
group_deprecated.py dfilter: Fix "!=" relation to be free of contradictions 2021-10-24 06:55:54 +00:00
group_dfunction_string.py test/dfilter: be explicit with the expected error message 2019-01-24 18:24:00 +00:00
group_double.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00
group_integer.py test/dfilter: be explicit with the expected error message 2019-01-24 18:24:00 +00:00
group_integer_1byte.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00
group_ipv4.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00
group_membership.py dfilter: fix memory leaks on dfilter compile errors involving a set 2019-01-28 11:09:35 +00:00
group_range_method.py dfilter: Strengthen sanity check for range 2021-10-05 16:39:41 +01:00
group_scanner.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00
group_string_type.py tests: Fixup test names 2021-10-15 15:10:54 +01:00
group_stringz.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00
group_syntax.py dfilter: Fix "!=" relation to be free of contradictions 2021-10-24 06:55:54 +00:00
group_time_relative.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00
group_time_type.py test/dfilter: be explicit with the expected error message 2019-01-24 18:24:00 +00:00
group_tvb.py tests: Accept a partial string in checkDFilterFail() 2021-10-15 15:10:57 +01:00
group_uint64.py test: convert suite_dfilter to use fixtures 2018-11-15 22:57:40 +00:00