aboutsummaryrefslogtreecommitdiffstats
path: root/epan/ftypes/ftype-string.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-02-27 14:47:31 +0000
committerJoão Valverde <j@v6e.pt>2022-03-31 11:27:34 +0100
commit2a9cb588aa6fe2322d37cbe39604dd54b8477292 (patch)
treed5ced7003cf14f84dff4704c57566c518a0abf2d /epan/ftypes/ftype-string.c
parentae537e24f03b3f06952276fce3c09b5f8a46bd79 (diff)
dfilter: Add binary arithmetic (add/subtract)
Add support for display filter binary addition and subtraction. The grammar is intentionally kept simple for now. The use case is to add a constant to a protocol field, or (maybe) add two fields in an expression. We use signed arithmetic with unsigned numbers, checking for overflow and casting where necessary to do the conversion. We could legitimately opt to use traditional modular arithmetic instead (like C) and if it turns out that that is more useful for some reason we may want to in the future. Fixes #15504.
Diffstat (limited to 'epan/ftypes/ftype-string.c')
-rw-r--r--epan/ftypes/ftype-string.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c
index 3267f07e82..f42ac968f9 100644
--- a/epan/ftypes/ftype-string.c
+++ b/epan/ftypes/ftype-string.c
@@ -194,6 +194,8 @@ ftype_register_string(void)
slice,
NULL, /* bitwise_and */
NULL, /* unary_minus */
+ NULL, /* add */
+ NULL, /* subtract */
};
static ftype_t stringz_type = {
FT_STRINGZ, /* ftype */
@@ -220,6 +222,8 @@ ftype_register_string(void)
slice,
NULL, /* bitwise_and */
NULL, /* unary_minus */
+ NULL, /* add */
+ NULL, /* subtract */
};
static ftype_t uint_string_type = {
FT_UINT_STRING, /* ftype */
@@ -246,6 +250,8 @@ ftype_register_string(void)
slice,
NULL, /* bitwise_and */
NULL, /* unary_minus */
+ NULL, /* add */
+ NULL, /* subtract */
};
static ftype_t stringzpad_type = {
FT_STRINGZPAD, /* ftype */
@@ -272,6 +278,8 @@ ftype_register_string(void)
slice,
NULL, /* bitwise_and */
NULL, /* unary_minus */
+ NULL, /* add */
+ NULL, /* subtract */
};
static ftype_t stringztrunc_type = {
FT_STRINGZTRUNC, /* ftype */
@@ -298,6 +306,8 @@ ftype_register_string(void)
slice,
NULL, /* bitwise_and */
NULL, /* unary_minus */
+ NULL, /* add */
+ NULL, /* subtract */
};
ftype_register(FT_STRING, &string_type);