2 * Definitions for routines common to multiple modules in the display
3 * filter code, but not used outside that code.
5 * $Id: dfilter-int.h,v 1.10 1999/10/19 05:31:13 gram Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@zing.org>
9 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #ifndef __DFILTER_INT_H__
28 #define __DFILTER_INT_H__
30 /* in dfilter-scanner.l */
31 GByteArray *byte_str_to_guint8_array(const char *s);
32 void dfilter_scanner_text(char*);
33 void dfilter_scanner_cleanup(void);
35 /* in dfilter-grammar.y */
36 extern dfilter *global_df;
38 /* Here we provide interfaces to make our scanner act and look like lex */
39 int dfilter_lex(void);
40 void dfilter_error(char *s);
42 /* Report an error during compilation of a filter; this is called by code
43 * other than parser code, so all it does is record that an error occurred,
44 * so that even if the filter is nominally syntactically valid, we still
48 void dfilter_fail(char *fmt, ...)
49 __attribute__((format (printf, 1, 2)));
51 void dfilter_fail(char *fmt, ...);
54 /* functions that dfilter-grammar.y needs during parsing*/
55 gboolean check_relation_numeric(gint operand, GArray *a, GArray *b);
56 gboolean check_relation_floating(gint operand, GArray *a, GArray *b);
57 gboolean check_relation_ether(gint operand, GArray *a, GArray *b);
58 gboolean check_relation_ipv6(gint operand, GArray *a, GArray *b);
59 gboolean check_relation_bytes(gint operand, GArray *a, GArray *b);
61 gboolean fill_array_numeric_value(GNode *gnode, gpointer data);
62 gboolean fill_array_numeric_variable(GNode *gnode, gpointer data);
63 gboolean fill_array_floating_value(GNode *gnode, gpointer data);
64 gboolean fill_array_floating_variable(GNode *gnode, gpointer data);
65 gboolean fill_array_ether_value(GNode *gnode, gpointer data);
66 gboolean fill_array_ether_variable(GNode *gnode, gpointer data);
67 gboolean fill_array_ipv6_value(GNode *gnode, gpointer data);
68 gboolean fill_array_ipv6_variable(GNode *gnode, gpointer data);
69 gboolean fill_array_bytes_value(GNode *gnode, gpointer data);
70 gboolean fill_array_bytes_variable(GNode *gnode, gpointer data);
73 #define boolean truth_value
77 relation, /* eq, ne, gt, ge, lt, le */
78 logical, /* and, or, not, xor */
79 variable, /* protocol or header field id */
80 existence, /* existence of a variable (protocol or hf) */
81 alternation, /* &, | */
82 boolean, /* true, false */
83 numeric, /* uint8, uint16, or uint32 value */
84 floating, /* double */
94 typedef gboolean(*CheckRelationFunc) (gint operand, GArray *a, GArray *b);
96 /* This struct is the parse tree node created by this grammary and used
97 * directly in the display filter routines to filter packets.
99 typedef struct dfilter_node {
100 enum node_type ntype; /* from dfilter-grammar.h */
101 int elem_size; /* computed at dfilter parse time rather than
102 when finding elements for each packet. Saves time
103 in get_values_from_ptree() */
104 CheckRelationFunc check_relation_func;
105 GNodeTraverseFunc fill_array_func;
107 /* copied from proto.h */
109 gint relation; /* if type == relation (eq, ne, gt, ge, lt, le) */
110 gint logical; /* if type == logical (and, or, not, xor) */
111 gint variable; /* if type == variable (protocol or header field abbrev) */
112 gint alternation; /* if type == alternation (& or |) */
116 struct timeval abs_time; /* the whole struct, not a pointer */
123 /* used for byte-ranges */
128 /* lookup an abbreviation in our token hash, returing the ID # */
129 int dfilter_lookup_token(char *abbrev);
131 #endif /* ! __DFILTER_INT_H__ */