2021-11-30 04:18:35 +00:00
|
|
|
/** @file
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-02-01 20:31:21 +00:00
|
|
|
* Copyright 2001 Gerald Combs
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2001-02-01 20:21:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DFILTER_INT_H
|
|
|
|
#define DFILTER_INT_H
|
|
|
|
|
|
|
|
#include "dfilter.h"
|
|
|
|
#include "syntax-tree.h"
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/proto.h>
|
2004-06-15 10:38:14 +00:00
|
|
|
#include <stdio.h>
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2022-06-23 23:07:42 +00:00
|
|
|
typedef struct {
|
|
|
|
const header_field_info *hfinfo;
|
|
|
|
fvalue_t *value;
|
|
|
|
int proto_layer_num;
|
|
|
|
} df_reference_t;
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
/* Passed back to user */
|
2013-12-03 20:59:25 +00:00
|
|
|
struct epan_dfilter {
|
2001-02-01 20:21:25 +00:00
|
|
|
GPtrArray *insns;
|
2009-10-18 23:25:33 +00:00
|
|
|
guint num_registers;
|
2022-03-21 11:43:28 +00:00
|
|
|
GSList **registers;
|
2001-02-01 20:21:25 +00:00
|
|
|
gboolean *attempted_load;
|
2022-03-18 12:47:29 +00:00
|
|
|
GDestroyNotify *free_registers;
|
2004-02-11 22:52:54 +00:00
|
|
|
int *interesting_fields;
|
|
|
|
int num_interesting_fields;
|
2008-01-31 19:50:38 +00:00
|
|
|
GPtrArray *deprecated;
|
2022-03-27 23:21:53 +00:00
|
|
|
char *expanded_text;
|
2022-03-27 14:26:46 +00:00
|
|
|
GHashTable *references;
|
2022-10-25 12:03:08 +00:00
|
|
|
GHashTable *raw_references;
|
2022-04-04 22:42:52 +00:00
|
|
|
char *syntax_tree_str;
|
2022-04-16 01:42:20 +00:00
|
|
|
/* Used to pass arguments to functions. List of Lists (list of registers). */
|
|
|
|
GSList *function_stack;
|
2001-02-01 20:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
/* Syntax Tree stuff */
|
|
|
|
stnode_t *st_root;
|
2022-11-19 19:21:19 +00:00
|
|
|
gboolean parse_failure;
|
|
|
|
df_error_t error;
|
2001-02-01 20:21:25 +00:00
|
|
|
GPtrArray *insns;
|
|
|
|
GHashTable *loaded_fields;
|
2022-10-25 03:20:18 +00:00
|
|
|
GHashTable *loaded_raw_fields;
|
2001-12-18 19:09:08 +00:00
|
|
|
GHashTable *interesting_fields;
|
2001-02-01 20:21:25 +00:00
|
|
|
int next_insn_id;
|
|
|
|
int next_register;
|
2021-09-27 22:22:59 +00:00
|
|
|
GPtrArray *deprecated;
|
2022-06-23 23:07:42 +00:00
|
|
|
GHashTable *references; /* hfinfo -> pointer to array of references */
|
2022-10-25 12:03:08 +00:00
|
|
|
GHashTable *raw_references; /* hfinfo -> pointer to array of references */
|
2022-04-07 12:57:39 +00:00
|
|
|
char *expanded_text;
|
2001-02-01 20:21:25 +00:00
|
|
|
} dfwork_t;
|
|
|
|
|
2015-01-18 10:22:19 +00:00
|
|
|
/*
|
2016-03-31 01:44:01 +00:00
|
|
|
* State kept by the scanner.
|
2015-01-18 10:22:19 +00:00
|
|
|
*/
|
2016-03-31 01:44:01 +00:00
|
|
|
typedef struct {
|
|
|
|
dfwork_t *dfw;
|
|
|
|
GString* quoted_string;
|
2021-05-30 02:38:12 +00:00
|
|
|
gboolean raw_string;
|
2022-04-07 12:57:39 +00:00
|
|
|
stloc_t string_loc;
|
|
|
|
stloc_t location;
|
2016-03-31 01:44:01 +00:00
|
|
|
} df_scanner_state_t;
|
2015-01-18 10:22:19 +00:00
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
/* Constructor/Destructor prototypes for Lemon Parser */
|
2008-03-21 16:10:47 +00:00
|
|
|
void *DfilterAlloc(void* (*)(gsize));
|
|
|
|
|
2001-02-15 06:22:46 +00:00
|
|
|
void DfilterFree(void*, void (*)(void *));
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2022-04-07 23:12:56 +00:00
|
|
|
void Dfilter(void*, int, stnode_t*, dfwork_t*);
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2004-02-11 22:52:54 +00:00
|
|
|
/* Return value for error in scanner. */
|
|
|
|
#define SCAN_FAILED -1 /* not 0, as that means end-of-input */
|
|
|
|
|
2021-11-08 12:20:40 +00:00
|
|
|
void
|
2022-11-19 19:21:19 +00:00
|
|
|
dfilter_vfail(dfwork_t *dfw, int code, stloc_t *err_loc,
|
2022-04-07 12:57:39 +00:00
|
|
|
const char *format, va_list args);
|
2021-11-08 12:20:40 +00:00
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
void
|
2022-11-19 19:21:19 +00:00
|
|
|
dfilter_fail(dfwork_t *dfw, int code, stloc_t *err_loc,
|
|
|
|
const char *format, ...) G_GNUC_PRINTF(4, 5);
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2022-02-25 19:37:53 +00:00
|
|
|
WS_NORETURN
|
2021-09-27 09:33:42 +00:00
|
|
|
void
|
2022-11-19 19:21:19 +00:00
|
|
|
dfilter_fail_throw(dfwork_t *dfw, int code, stloc_t *err_loc,
|
|
|
|
const char *format, ...) G_GNUC_PRINTF(4, 5);
|
2022-04-07 12:57:39 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
dfw_set_error_location(dfwork_t *dfw, stloc_t *err_loc);
|
2021-11-08 12:20:40 +00:00
|
|
|
|
2021-09-27 22:22:59 +00:00
|
|
|
void
|
2021-10-14 11:56:57 +00:00
|
|
|
add_deprecated_token(dfwork_t *dfw, const char *token);
|
2021-09-27 22:22:59 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
free_deprecated(GPtrArray *deprecated);
|
|
|
|
|
2004-06-15 10:38:14 +00:00
|
|
|
void
|
|
|
|
DfilterTrace(FILE *TraceFILE, char *zTracePrompt);
|
|
|
|
|
2022-02-22 21:55:05 +00:00
|
|
|
header_field_info *
|
|
|
|
dfilter_resolve_unparsed(dfwork_t *dfw, const char *name);
|
|
|
|
|
2022-04-12 15:13:08 +00:00
|
|
|
WS_RETNONNULL fvalue_t*
|
|
|
|
dfilter_fvalue_from_literal(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
|
|
|
|
gboolean allow_partial_value, header_field_info *hfinfo_value_string);
|
|
|
|
|
|
|
|
WS_RETNONNULL fvalue_t *
|
|
|
|
dfilter_fvalue_from_string(dfwork_t *dfw, ftenum_t ftype, stnode_t *st,
|
|
|
|
header_field_info *hfinfo_value_string);
|
|
|
|
|
|
|
|
WS_RETNONNULL fvalue_t *
|
|
|
|
dfilter_fvalue_from_charconst(dfwork_t *dfw, ftenum_t ftype, stnode_t *st);
|
|
|
|
|
2021-09-26 15:28:39 +00:00
|
|
|
const char *tokenstr(int token);
|
|
|
|
|
2022-06-23 23:07:42 +00:00
|
|
|
df_reference_t *
|
2022-10-25 12:03:08 +00:00
|
|
|
reference_new(const field_info *finfo, gboolean raw);
|
2022-06-23 23:07:42 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
reference_free(df_reference_t *ref);
|
|
|
|
|
2022-11-19 19:21:19 +00:00
|
|
|
void dfw_error_init(df_error_t *err);
|
|
|
|
|
|
|
|
void dfw_error_clear(df_error_t *err);
|
|
|
|
|
|
|
|
void dfw_error_set_msg(df_error_t **errp, const char *fmt, ...)
|
|
|
|
G_GNUC_PRINTF(2, 3);
|
|
|
|
|
|
|
|
void dfw_error_take(df_error_t **errp, df_error_t *src);
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
#endif
|