2 * Definitions for display filters
4 * $Id: dfilter.h,v 1.1 1999/07/07 22:51:37 gram Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 void dfilter_init(void);
30 void dfilter_cleanup(void);
31 int dfilter_compile(char* dfilter_text, GNode** p_dfcode);
32 gboolean dfilter_apply(GNode *dfcode, proto_tree *ptree, guint8* pd);
34 /* Here we provide interfaces to make our scanner act and look like lex */
36 void yyerror(char *s);
37 void dfilter_yyerror(char *fmt, ...);
39 /* functions that dfilter-grammar.y needs during parsing*/
40 gboolean check_relation_numeric(gint operand, GArray *a, GArray *b);
41 gboolean check_relation_ether(gint operand, GArray *a, GArray *b);
42 gboolean check_relation_bytes(gint operand, GArray *a, GArray *b);
43 gboolean check_relation_boolean(gint operand, GArray *a, GArray *b);
45 gboolean fill_array_numeric_value(GNode *gnode, gpointer data);
46 gboolean fill_array_numeric_variable(GNode *gnode, gpointer data);
47 gboolean fill_array_ether_value(GNode *gnode, gpointer data);
48 gboolean fill_array_ether_variable(GNode *gnode, gpointer data);
49 gboolean fill_array_bytes_value(GNode *gnode, gpointer data);
50 gboolean fill_array_bytes_variable(GNode *gnode, gpointer data);
51 gboolean fill_array_boolean_value(GNode *gnode, gpointer data);
52 gboolean fill_array_boolean_variable(GNode *gnode, gpointer data);
55 relation, /* eq, ne, gt, ge, lt, le */
56 logical, /* and, or, not, xor */
57 variable, /* protocol or header field id */
58 existence, /* existence of a variable (protocol or hf) */
59 alternation, /* &, | */
60 boolean, /* true, false */
61 numeric, /* uint8, uint16, or uint32 value */
70 typedef gboolean(*CheckRelationFunc) (gint operand, GArray *a, GArray *b);
72 /* This struct is the parse tree node created by this grammary and used
73 * directly in the display filter routines to filter packets.
75 typedef struct dfilter_node {
76 enum node_type ntype; /* from dfilter-grammar.h */
77 int elem_size; /* computed at dfilter parse time rather than
78 when finding elements for each packet. Saves time
79 in get_values_from_ptree() */
80 CheckRelationFunc check_relation_func;
81 GNodeTraverseFunc fill_array_func;
83 /* copied from proto.h */
85 gint relation; /* if type == relation (eq, ne, gt, ge, lt, le) */
86 gint logical; /* if type == logical (and, or, not, xor) */
87 gint variable; /* if type == variable (protocol or header field abbrev) */
88 gint alternation; /* if type == alternation (& or |) */
92 struct timeval abs_time; /* the whole struct, not a pointer */
98 /* used for byte-ranges */
105 #endif /* ! __DFILTER_H__ */