Add "-L" flags to LDFLAGS, not LIBS, and get rid of all the exotic
[obnox/wireshark/wip.git] / dfilter-int.h
1 /* dfilter-int.h
2  * Definitions for routines common to multiple modules in the display
3  * filter code, but not used outside that code.
4  *
5  * $Id: dfilter-int.h,v 1.11 1999/11/15 06:32:12 gram Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@zing.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * 
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.
16  * 
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.
21  * 
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.
25  */
26
27 #ifndef __DFILTER_INT_H__
28 #define __DFILTER_INT_H__
29
30 #ifndef __IPV4_H__
31 #include "ipv4.h"
32 #endif
33
34 /* in dfilter-scanner.l */
35 GByteArray *byte_str_to_guint8_array(const char *s);
36 void dfilter_scanner_text(char*);
37 void dfilter_scanner_cleanup(void);
38
39 /* in dfilter-grammar.y */
40 extern dfilter *global_df;
41
42 /* Here we provide interfaces to make our scanner act and look like lex */
43 int dfilter_lex(void);
44 void dfilter_error(char *s);
45
46 /* Report an error during compilation of a filter; this is called by code
47  * other than parser code, so all it does is record that an error occurred,
48  * so that even if the filter is nominally syntactically valid, we still
49  * fail.
50  */
51 #if __GNUC__ == 2
52 void dfilter_fail(char *fmt, ...)
53     __attribute__((format (printf, 1, 2)));
54 #else
55 void dfilter_fail(char *fmt, ...);
56 #endif
57
58 /* functions that dfilter-grammar.y needs during parsing*/
59 gboolean check_relation_numeric(gint operand, GArray *a, GArray *b);
60 gboolean check_relation_floating(gint operand, GArray *a, GArray *b);
61 gboolean check_relation_ether(gint operand, GArray *a, GArray *b);
62 gboolean check_relation_ipv4(gint operand, GArray *a, GArray *b);
63 gboolean check_relation_ipv6(gint operand, GArray *a, GArray *b);
64 gboolean check_relation_bytes(gint operand, GArray *a, GArray *b);
65
66 gboolean fill_array_numeric_value(GNode *gnode, gpointer data);
67 gboolean fill_array_numeric_variable(GNode *gnode, gpointer data);
68 gboolean fill_array_floating_value(GNode *gnode, gpointer data);
69 gboolean fill_array_floating_variable(GNode *gnode, gpointer data);
70 gboolean fill_array_ether_value(GNode *gnode, gpointer data);
71 gboolean fill_array_ether_variable(GNode *gnode, gpointer data);
72 gboolean fill_array_ipv4_value(GNode *gnode, gpointer data);
73 gboolean fill_array_ipv4_variable(GNode *gnode, gpointer data);
74 gboolean fill_array_ipv6_value(GNode *gnode, gpointer data);
75 gboolean fill_array_ipv6_variable(GNode *gnode, gpointer data);
76 gboolean fill_array_bytes_value(GNode *gnode, gpointer data);
77 gboolean fill_array_bytes_variable(GNode *gnode, gpointer data);
78
79 #ifdef WIN32
80 #define boolean truth_value
81 #endif
82
83 enum node_type {
84         relation,       /* eq, ne, gt, ge, lt, le */
85         logical,        /* and, or, not, xor */
86         variable,       /* protocol or header field id */
87         existence,      /* existence of a variable (protocol or hf) */
88         alternation,    /* &, | */
89         boolean,        /* true, false */
90         numeric,        /* uint8, uint16, or uint32 value */
91         floating,       /* double */
92         abs_time,
93         string,
94         ether,
95         bytes,
96         ipv4,
97         ipv6,
98         ipxnet
99 };
100
101 typedef gboolean(*CheckRelationFunc) (gint operand, GArray *a, GArray *b);
102
103 /* This struct is the parse tree node created by this grammary and used
104  * directly in the display filter routines to filter packets.
105  */
106 typedef struct dfilter_node {
107         enum node_type                  ntype; /* from dfilter-grammar.h */
108         int                             elem_size; /* computed at dfilter parse time rather than
109                                                 when finding elements for each packet. Saves time
110                                                 in get_values_from_ptree() */
111         CheckRelationFunc               check_relation_func;
112         GNodeTraverseFunc               fill_array_func;
113
114         /* copied from proto.h */
115         union {
116                 gint            relation; /* if type == relation (eq, ne, gt, ge, lt, le) */
117                 gint            logical;  /* if type == logical (and, or, not, xor) */
118                 gint            variable; /* if type == variable (protocol or header field abbrev) */
119                 gint            alternation; /* if type == alternation (& or |) */
120
121                 guint32         numeric;
122                 double          floating;
123                 struct timeval  abs_time;       /* the whole struct, not a pointer */
124                 gchar           *string;
125                 guint8          ether[6];
126                 ipv4_addr       ipv4;           /* the whole struct, not a pointer */
127                 guint8          ipv6[16];
128                 GByteArray      *bytes;
129         }                               value;
130
131         /* used for byte-ranges */
132         gint                            offset;
133         guint                           length;
134 } dfilter_node;
135
136 /* lookup an abbreviation in our token hash, returing the ID # */
137 int dfilter_lookup_token(char *abbrev);
138
139 #endif /* ! __DFILTER_INT_H__ */