aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dfilter/dfilter-int.h
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-06-24 00:07:42 +0100
committerJoão Valverde <j@v6e.pt>2022-06-25 14:57:40 +0100
commitaaff0d21aef1f4702b87c068900a8af48d9884b6 (patch)
treea9411eabe79b90470ba3b537f739c0196ea4108f /epan/dfilter/dfilter-int.h
parente9e6431d7b68e5ceacc41f3b3e1c8d290e55666b (diff)
dfilter: Add layer support for references
This adds support for using the layers filter with field references. Before: $ dftest 'ip.src != ${ip.src#2}' dftest: invalid character in macro name After: $ dftest 'ip.src != ${ip.src#2}' Filter: ip.src != ${ip.src#2} Syntax tree: 0 TEST_ALL_NE: 1 FIELD(ip.src <FT_IPv4>) 1 REFERENCE(ip.src#[2:1] <FT_IPv4>) Instructions: 00000 READ_TREE ip.src <FT_IPv4> -> reg#0 00001 IF_FALSE_GOTO 5 00002 READ_REFERENCE_R ${ip.src <FT_IPv4>} #[2:1] -> reg#1 00003 IF_FALSE_GOTO 5 00004 ALL_NE reg#0 != reg#1 00005 RETURN This requires adding another level of complexity to references. When loading references we need to copy the 'proto_layer_num' and add the logic to filter on that. The "layer" sttype is removed and replace by a new field sttype with support for a range. This is a nice cleanup for the semantic check and general simplification. The grammar is better too with this design. Range sttype is renamed to slice for clarity.
Diffstat (limited to 'epan/dfilter/dfilter-int.h')
-rw-r--r--epan/dfilter/dfilter-int.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/epan/dfilter/dfilter-int.h b/epan/dfilter/dfilter-int.h
index 5bdd6056fc..2082a6d992 100644
--- a/epan/dfilter/dfilter-int.h
+++ b/epan/dfilter/dfilter-int.h
@@ -16,6 +16,12 @@
#include <epan/proto.h>
#include <stdio.h>
+typedef struct {
+ const header_field_info *hfinfo;
+ fvalue_t *value;
+ int proto_layer_num;
+} df_reference_t;
+
/* Passed back to user */
struct epan_dfilter {
GPtrArray *insns;
@@ -44,7 +50,7 @@ typedef struct {
int next_insn_id;
int next_register;
GPtrArray *deprecated;
- GHashTable *references; /* hfinfo -> pointer to GSList of fvalues */
+ GHashTable *references; /* hfinfo -> pointer to array of references */
GHashTable *loaded_references;
char *expanded_text;
stloc_t err_loc;
@@ -119,4 +125,10 @@ dfilter_fvalue_from_charconst(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
const char *tokenstr(int token);
+df_reference_t *
+reference_new(const field_info *finfo);
+
+void
+reference_free(df_reference_t *ref);
+
#endif