aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>1999-08-03 15:04:33 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>1999-08-03 15:04:33 +0000
commitaebcf2eb32cc8693056172c2ed7718880f2db85d (patch)
tree7e276869eedbacd669164d445e93812ee2402c62
parentfeaab633b56e6207a3d374a7a94defcd8bf42729 (diff)
Removed the "exists" keyword from the grammar. The name of a protocol or a
field by itself assumes you are checking for the existence of that protocol or field. Changed the format of the list of filterable fields in the man page. Developers: run "./configure" so that your configure script will re-create dfilter2pod from the new dfilter2pod.in svn path=/trunk/; revision=426
-rw-r--r--dfilter-grammar.y51
-rw-r--r--dfilter-scanner.l52
-rw-r--r--dfilter.c39
-rw-r--r--dfilter.h3
-rwxr-xr-xdoc/dfilter2pod.in8
5 files changed, 50 insertions, 103 deletions
diff --git a/dfilter-grammar.y b/dfilter-grammar.y
index 52f83e0c3f..cb9444ee8f 100644
--- a/dfilter-grammar.y
+++ b/dfilter-grammar.y
@@ -3,7 +3,7 @@
/* dfilter-grammar.y
* Parser for display filters
*
- * $Id: dfilter-grammar.y,v 1.4 1999/08/02 06:34:23 gram Exp $
+ * $Id: dfilter-grammar.y,v 1.5 1999/08/03 15:04:25 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -112,7 +112,7 @@ GSList *dfilter_list_byte_arrays = NULL;
%type <node> ether_value ether_variable
%type <node> ipxnet_value ipxnet_variable
%type <node> ipv4_value ipv4_variable
-%type <node> protocol_name
+%type <node> variable_name
%type <node> bytes_value bytes_variable
%type <node> boolean_value boolean_variable
@@ -121,7 +121,6 @@ GSList *dfilter_list_byte_arrays = NULL;
%type <operand> bytes_relation
%type <variable> any_variable_type
-%type <operand> exists_operand
%token <variable> T_FT_UINT8
%token <variable> T_FT_UINT16
@@ -134,14 +133,13 @@ GSList *dfilter_list_byte_arrays = NULL;
%token <variable> T_FT_STRING
%token <variable> T_FT_IPXNET
-%token <id> T_VAL_ID
+%token <id> T_VAL_UNQUOTED_STRING
%token <ether> T_VAL_ETHER
%token <bytes> T_VAL_BYTES
%token <byte_range> T_VAL_BYTE_RANGE
%token <operand> TOK_AND TOK_OR TOK_NOT TOK_XOR
%token <operand> TOK_EQ TOK_NE TOK_GT TOK_GE TOK_LT TOK_LE
-%token <operand> TOK_EXIST
%token <operand> TOK_TRUE TOK_FALSE
%left TOK_AND
@@ -161,9 +159,10 @@ statement: expression
expression: '(' expression ')' { $$ = $2; }
| expression TOK_AND expression { $$ = dfilter_mknode_join($1, logical, $2, $3); }
| expression TOK_OR expression { $$ = dfilter_mknode_join($1, logical, $2, $3); }
+ | expression TOK_XOR expression { $$ = dfilter_mknode_join($1, logical, $2, $3); }
| TOK_NOT expression { $$ = dfilter_mknode_unary(TOK_NOT, $2); }
| relation { $$ = $1; }
- | protocol_name { $$ = $1; }
+ | variable_name { $$ = $1; }
;
relation: numeric_variable numeric_relation numeric_value
@@ -221,12 +220,10 @@ relation: numeric_variable numeric_relation numeric_value
$$ = dfilter_mknode_join($1, relation, $2, $3);
}
- | exists_operand any_variable_type { $$ = dfilter_mknode_existence($2); }
-
;
-numeric_value: T_VAL_ID
+numeric_value: T_VAL_UNQUOTED_STRING
{
$$ = dfilter_mknode_numeric_value(string_to_value($1));
g_free($1);
@@ -239,13 +236,13 @@ ether_value: T_VAL_ETHER
}
;
-ipxnet_value: T_VAL_ID
+ipxnet_value: T_VAL_UNQUOTED_STRING
{
$$ = dfilter_mknode_ipxnet_value(string_to_value($1));
}
;
-ipv4_value: T_VAL_ID
+ipv4_value: T_VAL_UNQUOTED_STRING
{
$$ = dfilter_mknode_ipv4_value($1);
g_free($1);
@@ -257,7 +254,7 @@ bytes_value: T_VAL_BYTES
$$ = dfilter_mknode_bytes_value($1);
}
- | T_VAL_ID
+ | T_VAL_UNQUOTED_STRING
{ /* one byte */
GByteArray *barray = g_byte_array_new();
guint8 val;
@@ -300,7 +297,7 @@ ipxnet_variable: T_FT_IPXNET { $$ = dfilter_mknode_ipxnet_variable($1); }
ipv4_variable: T_FT_IPv4 { $$ = dfilter_mknode_ipv4_variable($1); }
;
-protocol_name: T_FT_NONE { $$ = dfilter_mknode_existence($1); }
+variable_name: any_variable_type { $$ = dfilter_mknode_existence($1); }
;
bytes_variable: any_variable_type T_VAL_BYTE_RANGE
@@ -323,26 +320,22 @@ any_variable_type: T_FT_UINT8 { $$ = $1; }
| T_FT_STRING { $$ = $1; }
;
-numeric_relation: TOK_EQ { $$ = $1; }
- | TOK_NE { $$ = $1; }
- | TOK_GT { $$ = $1; }
- | TOK_GE { $$ = $1; }
- | TOK_LT { $$ = $1; }
- | TOK_LE { $$ = $1; }
- ;
-
-equality_relation: TOK_EQ { $$ = $1; }
- | TOK_NE { $$ = $1; }
+numeric_relation: TOK_EQ { $$ = TOK_EQ; }
+ | TOK_NE { $$ = TOK_NE; }
+ | TOK_GT { $$ = TOK_GT; }
+ | TOK_GE { $$ = TOK_GE; }
+ | TOK_LT { $$ = TOK_LT; }
+ | TOK_LE { $$ = TOK_LE; }
;
-bytes_relation: TOK_EQ { $$ = $1; }
- | TOK_NE { $$ = $1; }
- | TOK_GT { $$ = $1; }
- | TOK_LT { $$ = $1; }
+equality_relation: TOK_EQ { $$ = TOK_EQ; }
+ | TOK_NE { $$ = TOK_NE; }
;
-exists_operand: TOK_EXIST { $$ = $1; }
- | '?' { $$ = TOK_EXIST; }
+bytes_relation: TOK_EQ { $$ = TOK_EQ; }
+ | TOK_NE { $$ = TOK_NE; }
+ | TOK_GT { $$ = TOK_GT; }
+ | TOK_LT { $$ = TOK_LT; }
;
%%
diff --git a/dfilter-scanner.l b/dfilter-scanner.l
index dc6412be9e..d5ffc56252 100644
--- a/dfilter-scanner.l
+++ b/dfilter-scanner.l
@@ -3,7 +3,7 @@
/* dfilter-scanner.l
* Scanner for display filters
*
- * $Id: dfilter-scanner.l,v 1.1 1999/08/01 04:28:07 gram Exp $
+ * $Id: dfilter-scanner.l,v 1.2 1999/08/03 15:04:25 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -98,38 +98,17 @@ hexsep [-:.]
[\t\n ]+ /* ignore whitespace */
-\&\& { yylval.operand = TOK_AND; return TOK_AND; }
-and { yylval.operand = TOK_AND; return TOK_AND; }
+and|\&\& { return TOK_AND; }
+or|\|\| { return TOK_OR; }
+not|\! { return TOK_NOT; }
+xor|\^\^ { return TOK_XOR; }
+eq|\=\= { return TOK_EQ; }
+ne|\!\= { return TOK_NE; }
+gt|\> { return TOK_GT; }
+ge|\>\= { return TOK_GE; }
+lt|\< { return TOK_LT; }
+le|\<\= { return TOK_LE; }
-\|\| { yylval.operand = TOK_OR; return TOK_OR; }
-or { yylval.operand = TOK_OR; return TOK_OR; }
-
-\! { yylval.operand = TOK_NOT; return TOK_NOT; }
-not { yylval.operand = TOK_NOT; return TOK_NOT; }
-
-\^\^ { yylval.operand = TOK_XOR; return TOK_XOR; }
-xor { yylval.operand = TOK_XOR; return TOK_XOR; }
-
-\=\= { yylval.operand = TOK_EQ; return TOK_EQ; }
-eq { yylval.operand = TOK_EQ; return TOK_EQ; }
-
-\!\= { yylval.operand = TOK_NE; return TOK_NE; }
-ne { yylval.operand = TOK_NE; return TOK_NE; }
-
-\> { yylval.operand = TOK_GT; return TOK_GT; }
-gt { yylval.operand = TOK_GT; return TOK_GT; }
-
-\>\= { yylval.operand = TOK_GE; return TOK_GE; }
-ge { yylval.operand = TOK_GE; return TOK_GE; }
-
-\< { yylval.operand = TOK_LT; return TOK_LT; }
-lt { yylval.operand = TOK_LT; return TOK_LT; }
-
-\<\= { yylval.operand = TOK_LE; return TOK_LE; }
-le { yylval.operand = TOK_LE; return TOK_LE; }
-
-exist { yylval.operand = TOK_EXIST; return TOK_EXIST; }
-exists { yylval.operand = TOK_EXIST; return TOK_EXIST; }
true { yylval.operand = TOK_TRUE; return TOK_TRUE; }
false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
@@ -192,7 +171,8 @@ false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
enum ftenum ftype;
yylval.variable = dfilter_lookup_token(yytext);
if (yylval.variable == 0) {
- return 0;
+ yylval.id = g_strdup(yytext);
+ return T_VAL_UNQUOTED_STRING;
}
ftype = proto_registrar_get_ftype(yylval.variable);
@@ -238,18 +218,18 @@ false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
[0-9]+ { /* decimal or octal values */
yylval.id = g_strdup(yytext);
- return T_VAL_ID;
+ return T_VAL_UNQUOTED_STRING;
}
0[xX][A-Fa-f0-9]+ { /* hex values */
yylval.id = g_strdup(yytext);
- return T_VAL_ID;
+ return T_VAL_UNQUOTED_STRING;
}
[0-9\:\.]+ {
yylval.id = g_strdup(yytext);
- return T_VAL_ID;
+ return T_VAL_UNQUOTED_STRING;
}
%%
diff --git a/dfilter.c b/dfilter.c
index b5a79e5099..41587df426 100644
--- a/dfilter.c
+++ b/dfilter.c
@@ -1,7 +1,7 @@
/* dfilter.c
* Routines for display filters
*
- * $Id: dfilter.c,v 1.5 1999/08/01 04:28:07 gram Exp $
+ * $Id: dfilter.c,v 1.6 1999/08/03 15:04:25 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -158,7 +158,8 @@ clear_byte_array(gpointer data, gpointer user_data)
void
yyerror(char *s)
{
- fprintf(stderr, "%s\n", s);
+/* fprintf(stderr, "%s\n", s);
+ Do not report the error, just let yyparse() return 1 */
}
void
@@ -210,13 +211,10 @@ dfilter_apply_node(GNode *gnode, proto_tree *ptree, const guint8* pd)
switch(dnode->ntype) {
case variable:
- /* the only time we'll see a 'variable' at this point is if the display filter
- * checks the value of a single field: "tr.sr", for example. Inside a relation,
- * the relation code will retrieve the value of the variable
- */
- g_assert(!gnode_a && !gnode_b);
+ /* We'll never see this case because if the parser finds the name of
+ * a variable, it will cause it to be an 'existence' operation.
+ */
g_assert_not_reached();
- /*return check_single_variable(gnode, ptree, pd);*/
case logical:
return check_logical(dnode->value.logical, gnode_a, gnode_b, ptree, pd);
@@ -233,13 +231,13 @@ dfilter_apply_node(GNode *gnode, proto_tree *ptree, const guint8* pd)
case ipv4:
case boolean:
case ether:
- case ether_vendor:
case string:
case abs_time:
case bytes:
case ipxnet:
/* the only time we'll see these at this point is if the display filter
- * is really wacky. Just return TRUE */
+ * is really wacky. (like simply "192.168.1.1"). The parser as it stands
+ * now let these by. Just return TRUE */
g_assert(!gnode_a && !gnode_b);
return TRUE;
@@ -310,27 +308,6 @@ check_relation(gint operand, GNode *a, GNode *b, proto_tree *ptree, const guint8
return retval;
}
-#if 0
-static gboolean
-check_single_variable(GNode *gnode, proto_tree *ptree, guint8* pd)
-{
- dfilter_node *node = (dfilter_node*) (gnode->data);
- GArray *vals;
- gboolean retval;
-
-
- bytes_length = node->length;
- bytes_offset = node->offset;
- vals = get_values_from_ptree(node, ptree, pd);
-
- retval = node_a->check_relation_func(operand, vals_a, vals_b);
-
- g_array_free(vals, FALSE);
-
- return retval;
-}
-#endif
-
static gboolean
check_existence_in_ptree(dfilter_node *dnode, proto_tree *ptree)
{
diff --git a/dfilter.h b/dfilter.h
index 8fcf65bee7..a46fd1a421 100644
--- a/dfilter.h
+++ b/dfilter.h
@@ -1,7 +1,7 @@
/* dfilter.h
* Definitions for display filters
*
- * $Id: dfilter.h,v 1.4 1999/08/01 04:28:08 gram Exp $
+ * $Id: dfilter.h,v 1.5 1999/08/03 15:04:26 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -66,7 +66,6 @@ enum node_type {
abs_time,
string,
ether,
- ether_vendor,
bytes,
ipv4,
ipxnet
diff --git a/doc/dfilter2pod.in b/doc/dfilter2pod.in
index 1afde713bd..7403144ed8 100755
--- a/doc/dfilter2pod.in
+++ b/doc/dfilter2pod.in
@@ -9,7 +9,7 @@
# will be replaced by the pod-formatted glossary
# STDOUT is the output
#
-# $Id: dfilter2pod.in,v 1.2 1999/08/01 04:28:20 gram Exp $
+# $Id: dfilter2pod.in,v 1.3 1999/08/03 15:04:33 gram Exp $
%ftenum_names = (
'FT_NONE', 'No value',
@@ -86,13 +86,11 @@ sub create_dfilter_table {
# If this proto has children fields, print those
if ($field_abbrev{$proto_abbrev{$proto_name}}) {
- print "=over 4\n\n";
for $field_abbrev (sort @{$field_abbrev{$proto_abbrev{$proto_name}}}) {
- print "=item ", $field_info{$field_abbrev}[0]," ($field_abbrev)\n\n";
- print $ftenum_names{$field_info{$field_abbrev}[1]}, "\n\n";
+ print " $field_abbrev ", $field_info{$field_abbrev}[0],"\n";
+ print " ", $ftenum_names{$field_info{$field_abbrev}[1]}, "\n\n";
}
- print "=back\n\n";
}
}
}