If the LHS is a STRING or UNPARSED string, and the RHS is a FIELD,
then make sure that the FIELD can participate in the relation that is expressed in the display filter. Note that tvbuff's *should* be able to participate in == comparisons, etc., but those functions need to be added to ftype-tvbuff.c first. svn path=/trunk/; revision=10175
This commit is contained in:
parent
e6f75392c3
commit
5cfc41fd88
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: semcheck.c,v 1.23 2004/02/11 21:20:52 guy Exp $
|
||||
* $Id: semcheck.c,v 1.24 2004/02/22 03:04:40 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -423,7 +423,8 @@ check_relation_LHS_FIELD(const char *relation_string, FtypeCanFunc can_func,
|
|||
}
|
||||
|
||||
static void
|
||||
check_relation_LHS_STRING(FtypeCanFunc can_func _U_, gboolean allow_partial_value _U_,
|
||||
check_relation_LHS_STRING(const char* relation_string,
|
||||
FtypeCanFunc can_func _U_, gboolean allow_partial_value _U_,
|
||||
stnode_t *st_node,
|
||||
stnode_t *st_arg1, stnode_t *st_arg2)
|
||||
{
|
||||
|
@ -443,6 +444,13 @@ check_relation_LHS_STRING(FtypeCanFunc can_func _U_, gboolean allow_partial_valu
|
|||
hfinfo2 = stnode_data(st_arg2);
|
||||
ftype2 = hfinfo2->type;
|
||||
|
||||
if (!can_func(ftype2)) {
|
||||
dfilter_fail("%s (type=%s) cannot participate in '%s' comparison.",
|
||||
hfinfo2->abbrev, ftype_pretty_name(ftype2),
|
||||
relation_string);
|
||||
THROW(TypeError);
|
||||
}
|
||||
|
||||
s = stnode_data(st_arg1);
|
||||
fvalue = fvalue_from_string(ftype2, s, dfilter_fail);
|
||||
if (!fvalue) {
|
||||
|
@ -480,7 +488,8 @@ check_relation_LHS_STRING(FtypeCanFunc can_func _U_, gboolean allow_partial_valu
|
|||
}
|
||||
|
||||
static void
|
||||
check_relation_LHS_UNPARSED(FtypeCanFunc can_func _U_, gboolean allow_partial_value,
|
||||
check_relation_LHS_UNPARSED(const char* relation_string,
|
||||
FtypeCanFunc can_func, gboolean allow_partial_value,
|
||||
stnode_t *st_node,
|
||||
stnode_t *st_arg1, stnode_t *st_arg2)
|
||||
{
|
||||
|
@ -500,6 +509,13 @@ check_relation_LHS_UNPARSED(FtypeCanFunc can_func _U_, gboolean allow_partial_va
|
|||
hfinfo2 = stnode_data(st_arg2);
|
||||
ftype2 = hfinfo2->type;
|
||||
|
||||
if (!can_func(ftype2)) {
|
||||
dfilter_fail("%s (type=%s) cannot participate in '%s' comparison.",
|
||||
hfinfo2->abbrev, ftype_pretty_name(ftype2),
|
||||
relation_string);
|
||||
THROW(TypeError);
|
||||
}
|
||||
|
||||
s = stnode_data(st_arg1);
|
||||
fvalue = fvalue_from_unparsed(ftype2, s, allow_partial_value, dfilter_fail);
|
||||
if (!fvalue) {
|
||||
|
@ -716,7 +732,7 @@ check_relation(const char *relation_string, gboolean allow_partial_value,
|
|||
allow_partial_value, st_node, st_arg1, st_arg2);
|
||||
break;
|
||||
case STTYPE_STRING:
|
||||
check_relation_LHS_STRING(can_func,
|
||||
check_relation_LHS_STRING(relation_string, can_func,
|
||||
allow_partial_value, st_node, st_arg1, st_arg2);
|
||||
break;
|
||||
case STTYPE_RANGE:
|
||||
|
@ -724,7 +740,7 @@ check_relation(const char *relation_string, gboolean allow_partial_value,
|
|||
allow_partial_value, st_node, st_arg1, st_arg2);
|
||||
break;
|
||||
case STTYPE_UNPARSED:
|
||||
check_relation_LHS_UNPARSED(can_func,
|
||||
check_relation_LHS_UNPARSED(relation_string, can_func,
|
||||
allow_partial_value, st_node, st_arg1, st_arg2);
|
||||
break;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: ftype-tvbuff.c,v 1.16 2004/02/01 22:42:24 guy Exp $
|
||||
* $Id: ftype-tvbuff.c,v 1.17 2004/02/22 03:04:41 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -242,6 +242,9 @@ ftype_register_tvbuff(void)
|
|||
NULL,
|
||||
NULL,
|
||||
|
||||
|
||||
/* TODO - tvb's *can* do 'eq', etc. */
|
||||
|
||||
NULL, /* cmp_eq */
|
||||
NULL, /* cmp_ne */
|
||||
NULL, /* cmp_gt */
|
||||
|
|
|
@ -4,7 +4,7 @@ Test-suite to test ethereal's dfilter mechanism.
|
|||
"""
|
||||
|
||||
#
|
||||
# $Id: dfilter-test.py,v 1.3 2003/08/27 15:23:11 gram Exp $
|
||||
# $Id: dfilter-test.py,v 1.4 2004/02/22 03:04:41 gram Exp $
|
||||
#
|
||||
# Copyright (C) 2003 by Gilbert Ramirez <gram@alumni.rice.edu>
|
||||
#
|
||||
|
@ -207,6 +207,9 @@ class Test:
|
|||
|
||||
# print "GOT", len(output), "lines:", output, retval
|
||||
|
||||
if retval:
|
||||
tethereal_failed = 1
|
||||
|
||||
if tethereal_failed:
|
||||
if num_lines_expected == None:
|
||||
if VERBOSE:
|
||||
|
@ -215,6 +218,7 @@ class Test:
|
|||
else:
|
||||
print "\nGot:", output
|
||||
return FAILED
|
||||
|
||||
elif len(output) == num_lines_expected:
|
||||
if VERBOSE:
|
||||
print "\nGot:", output
|
||||
|
@ -1005,7 +1009,7 @@ class String(Test):
|
|||
|
||||
def ck_contains_5(self):
|
||||
return self.DFilterCount(pkt_http,
|
||||
'http.request.method contains 50:4f:53:54"', 0) # "POST"
|
||||
'http.request.method contains 50:4f:53:54"', None) # "POST"
|
||||
|
||||
def ck_contains_6(self):
|
||||
return self.DFilterCount(pkt_http,
|
||||
|
@ -1150,6 +1154,20 @@ class Time(Test):
|
|||
class TVB(Test):
|
||||
"""Tests routines in ftype-tvb.c"""
|
||||
|
||||
def ck_eq_1(self):
|
||||
# We expect 0 because even though this byte
|
||||
# string matches the 'eth' protocol, protocols cannot
|
||||
# work in an '==' comparison yet.
|
||||
return self.DFilterCount(pkt_http,
|
||||
"eth == 00:e0:81:00:b0:28:00:09:6b:88:f6:c9:08:00", None)
|
||||
|
||||
def ck_eq_2(self):
|
||||
# We expect 0 because even though this byte
|
||||
# string matches the 'eth' protocol, protocols cannot
|
||||
# work in an '==' comparison yet.
|
||||
return self.DFilterCount(pkt_http,
|
||||
"00:e0:81:00:b0:28:00:09:6b:88:f6:c9:08:00 == eth", None)
|
||||
|
||||
def ck_slice_1(self):
|
||||
return self.DFilterCount(pkt_http,
|
||||
"ip[0:2] == 45:00", 1)
|
||||
|
@ -1194,6 +1212,9 @@ class TVB(Test):
|
|||
|
||||
|
||||
tests = [
|
||||
ck_eq_1,
|
||||
ck_eq_2,
|
||||
|
||||
ck_slice_1,
|
||||
ck_slice_2,
|
||||
ck_slice_3,
|
||||
|
|
Loading…
Reference in New Issue