aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2024-02-21 09:21:55 -0500
committerJohn Thacker <johnthacker@gmail.com>2024-02-21 09:25:14 -0500
commit722816c68e2f54b9b05e9d0d665d5a4504abe995 (patch)
tree46e6db48c449719671dd9744e997815706fb219c /epan
parent2f6833b5f70aaca769d29d24dd057db0e91dcf1e (diff)
dfilter: Handle 64-bit extended value strings
Allow matching against 64-bit extended value strings the same way as other value strings. The IAX2 sample capture on the Wiki is a good test of this. Previously the matches operator would never match, and comparison operators we not allowed. Before: $ ./run/dftest -s 'iax2.voice.codec == "GSM compression"' Filter: iax2.voice.codec == "GSM compression" Error: "GSM compression" cannot be found among the possible values for iax2.voice.codec. iax2.voice.codec == "GSM compression" ^~~~~~~~~~~~~~~~~ After: $ ./run/dftest -s 'iax2.voice.codec == "GSM compression"' Filter: iax2.voice.codec == "GSM compression" Syntax tree: 0 TEST_ANY_EQ: 1 FIELD(iax2.voice.codec <FT_UINT64>) 1 FVALUE(2 <FT_UINT64>) Instructions: 0000 READ_TREE iax2.voice.codec -> R0 0001 IF_FALSE_GOTO 3 0002 ANY_EQ R0 == 2 0003 RETURN
Diffstat (limited to 'epan')
-rw-r--r--epan/dfilter/dfvm.c18
-rw-r--r--epan/dfilter/semcheck.c2
2 files changed, 16 insertions, 4 deletions
diff --git a/epan/dfilter/dfvm.c b/epan/dfilter/dfvm.c
index 8fe6745fec..f7b88a6564 100644
--- a/epan/dfilter/dfvm.c
+++ b/epan/dfilter/dfvm.c
@@ -1303,15 +1303,28 @@ try_value_string(const header_field_info *hfinfo, fvalue_t *fv_num, char *buf)
{
uint64_t val;
+ /* XXX - What about BASE_UNIT_STRING? Should we guarantee that we
+ * don't get here for unit strings in semcheck.c (currently we
+ * do for OP_MATCHES instead of disallowing it, which will result
+ * in a legal filter that always compares false as this returns NULL.)
+ */
if (fvalue_to_uinteger64(fv_num, &val) != FT_OK)
return NULL;
/* XXX We should find or create instead a suitable function in proto.h
- * to perform this mapping. */
+ * to perform this mapping. hf_try_val[64]_to_str are similar, though
+ * don't handle BASE_CUSTOM but do handle BASE_UNIT_STRING */
if (hfinfo->display & BASE_RANGE_STRING) {
return try_rval_to_str((uint32_t)val, hfinfo->strings);
}
+ else if (hfinfo->display & BASE_EXT_STRING) {
+ if (hfinfo->display & BASE_VAL64_STRING) {
+ return try_val64_to_str_ext(val, (val64_string_ext *)hfinfo->strings);
+ } else {
+ return try_val_to_str_ext((uint32_t)val, (value_string_ext *)hfinfo->strings);
+ }
+ }
else if (hfinfo->display & BASE_VAL64_STRING) {
return try_val64_to_str(val, hfinfo->strings);
}
@@ -1323,9 +1336,6 @@ try_value_string(const header_field_info *hfinfo, fvalue_t *fv_num, char *buf)
else
ws_assert_not_reached();
}
- else if (hfinfo->display & BASE_EXT_STRING) {
- return try_val_to_str_ext((uint32_t)val, (value_string_ext *)hfinfo->strings);
- }
else {
return try_val_to_str((uint32_t)val, hfinfo->strings);
}
diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c
index 9aaff5c365..b7dd8a1994 100644
--- a/epan/dfilter/semcheck.c
+++ b/epan/dfilter/semcheck.c
@@ -538,6 +538,8 @@ mk_fvalue_from_val_string(dfwork_t *dfw, header_field_info *hfinfo, const char *
}
else if (hfinfo->display & BASE_VAL64_STRING) {
const val64_string *vals = (const val64_string *)hfinfo->strings;
+ if (hfinfo->display & BASE_EXT_STRING)
+ vals = VAL64_STRING_EXT_VS_P((const val64_string_ext *) vals);
while (vals->strptr != NULL && count <= 1) {
if (g_ascii_strcasecmp(s, vals->strptr) == 0) {