aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dfilter/dfvm.h
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-10-25 04:20:18 +0100
committerJoão Valverde <j@v6e.pt>2022-10-31 21:02:39 +0000
commit0853ddd1cb9c94e83bba5ac2608c8de0dc94dae4 (patch)
tree9f571c07583e4a4527647471a5ca43411bd39fc5 /epan/dfilter/dfvm.h
parent31a0147daa278cfed749c0cbfc6db87bb5cfc3c9 (diff)
dfilter: Add support for raw (bytes) addressing mode
This adds new syntax to read a field from the tree as bytes, instead of the actual type. This is a useful extension for example to match matformed strings that contain unicode replacement characters. In this case it is not possible to match the raw value of the malformed string field. This extension fills this need and is generic enough that it should be useful in many other situations. The syntax used is to prefix the field name with "@". The following artificial example tests if the HTTP user agent contains a particular invalid UTF-8 sequence: @http.user_agent == "Mozill\xAA" Where simply using "http.user_agent" won't work because the invalid byte sequence will have been replaced with U+FFFD. Considering the following programs: $ dftest '_ws.ftypes.string == "ABC"' Filter: _ws.ftypes.string == "ABC" Syntax tree: 0 TEST_ANY_EQ: 1 FIELD(_ws.ftypes.string <FT_STRING>) 1 FVALUE("ABC" <FT_STRING>) Instructions: 00000 READ_TREE _ws.ftypes.string <FT_STRING> -> reg#0 00001 IF_FALSE_GOTO 3 00002 ANY_EQ reg#0 == "ABC" <FT_STRING> 00003 RETURN $ dftest '@_ws.ftypes.string == "ABC"' Filter: @_ws.ftypes.string == "ABC" Syntax tree: 0 TEST_ANY_EQ: 1 FIELD(_ws.ftypes.string <RAW>) 1 FVALUE(41:42:43 <FT_BYTES>) Instructions: 00000 READ_TREE @_ws.ftypes.string <FT_BYTES> -> reg#0 00001 IF_FALSE_GOTO 3 00002 ANY_EQ reg#0 == 41:42:43 <FT_BYTES> 00003 RETURN In the second case the field has a "raw" type, that equates directly to FT_BYTES, and the field value is read from the protocol raw data.
Diffstat (limited to 'epan/dfilter/dfvm.h')
-rw-r--r--epan/dfilter/dfvm.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/epan/dfilter/dfvm.h b/epan/dfilter/dfvm.h
index b042b5dd88..8d58f73a74 100644
--- a/epan/dfilter/dfvm.h
+++ b/epan/dfilter/dfvm.h
@@ -21,6 +21,7 @@ typedef enum {
EMPTY,
FVALUE,
HFINFO,
+ RAW_HFINFO,
INSN_NUMBER,
REGISTER,
INTEGER,
@@ -121,7 +122,7 @@ dfvm_value_t*
dfvm_value_new_fvalue(fvalue_t *fv);
dfvm_value_t*
-dfvm_value_new_hfinfo(header_field_info *hfinfo);
+dfvm_value_new_hfinfo(header_field_info *hfinfo, gboolean raw);
dfvm_value_t*
dfvm_value_new_register(int reg);