forked from osmocom/wireshark
Use the ftype routines to determine what tests can be done on a field,
and whether you can slice a field. svn path=/trunk/; revision=2974
This commit is contained in:
parent
baee1df878
commit
e7d46da0dd
|
@ -7,7 +7,7 @@
|
||||||
* Copyright 2000, Jeffrey C. Foster<jfoste@woodward.com> and
|
* Copyright 2000, Jeffrey C. Foster<jfoste@woodward.com> and
|
||||||
* Guy Harris <guy@alum.mit.edu>
|
* Guy Harris <guy@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* $Id: dfilter_expr_dlg.c,v 1.7 2001/02/01 22:01:42 guy Exp $
|
* $Id: dfilter_expr_dlg.c,v 1.8 2001/02/01 22:21:30 guy Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -89,7 +89,7 @@ typedef struct protocol_data {
|
||||||
} protocol_data_t;
|
} protocol_data_t;
|
||||||
|
|
||||||
static void show_relations(GtkWidget *relation_label, GtkWidget *relation_list,
|
static void show_relations(GtkWidget *relation_label, GtkWidget *relation_list,
|
||||||
GtkWidget *range_label, GtkWidget *range_entry, guint32 relations);
|
GtkWidget *range_label, GtkWidget *range_entry, ftenum_t ftype);
|
||||||
static void add_relation_list(GtkWidget *relation_list, char *relation);
|
static void add_relation_list(GtkWidget *relation_list, char *relation);
|
||||||
static void build_boolean_values(GtkWidget *value_list_scrolled_win,
|
static void build_boolean_values(GtkWidget *value_list_scrolled_win,
|
||||||
GtkWidget *value_list, const true_false_string *values);
|
GtkWidget *value_list, const true_false_string *values);
|
||||||
|
@ -101,15 +101,6 @@ static void display_value_fields(header_field_info *hfinfo,
|
||||||
gboolean is_comparison, GtkWidget *value_label, GtkWidget *value_entry,
|
gboolean is_comparison, GtkWidget *value_label, GtkWidget *value_entry,
|
||||||
GtkWidget *value_list, GtkWidget *value_list_scrolled_win);
|
GtkWidget *value_list, GtkWidget *value_list_scrolled_win);
|
||||||
|
|
||||||
/*
|
|
||||||
* What relations are supported?
|
|
||||||
*/
|
|
||||||
#define EXISTENCE_OK 0x00000001
|
|
||||||
#define EQUALITY_OK 0x00000002
|
|
||||||
#define ORDER_OK 0x00000004
|
|
||||||
#define ORDER_EQUALITY_OK 0x00000008
|
|
||||||
#define RANGES_OK 0x00000010
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that this is called every time the user clicks on an item,
|
* Note that this is called every time the user clicks on an item,
|
||||||
* whether it is already selected or not.
|
* whether it is already selected or not.
|
||||||
|
@ -138,7 +129,6 @@ field_select_row_cb(GtkWidget *tree, GList *node, gint column,
|
||||||
GtkWidget *accept_bt = gtk_object_get_data(GTK_OBJECT(window),
|
GtkWidget *accept_bt = gtk_object_get_data(GTK_OBJECT(window),
|
||||||
E_DFILTER_EXPR_ACCEPT_BT_KEY);
|
E_DFILTER_EXPR_ACCEPT_BT_KEY);
|
||||||
header_field_info *hfinfo, *cur_hfinfo;
|
header_field_info *hfinfo, *cur_hfinfo;
|
||||||
guint32 relations;
|
|
||||||
const char *value_type;
|
const char *value_type;
|
||||||
char value_label_string[1024+1]; /* XXX - should be large enough */
|
char value_label_string[1024+1]; /* XXX - should be large enough */
|
||||||
|
|
||||||
|
@ -163,85 +153,8 @@ field_select_row_cb(GtkWidget *tree, GList *node, gint column,
|
||||||
gtk_object_set_data(GTK_OBJECT(window), E_DFILTER_EXPR_CURRENT_VAR_KEY,
|
gtk_object_set_data(GTK_OBJECT(window), E_DFILTER_EXPR_CURRENT_VAR_KEY,
|
||||||
hfinfo);
|
hfinfo);
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the relation list column to show all the comparison
|
|
||||||
* operators supported on it, if any.
|
|
||||||
*/
|
|
||||||
switch (hfinfo->type) {
|
|
||||||
|
|
||||||
case FT_NONE:
|
|
||||||
case FT_PROTOCOL:
|
|
||||||
/*
|
|
||||||
* You can only test for the field's presence;
|
|
||||||
* hide the relation stuff.
|
|
||||||
* XXX - what about "tcp[xx:yy]"?
|
|
||||||
*/
|
|
||||||
relations = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FT_BOOLEAN:
|
|
||||||
/*
|
|
||||||
* You can only test whether the field is true or false;
|
|
||||||
* hide the relation stuff.
|
|
||||||
*/
|
|
||||||
relations = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FT_UINT8:
|
|
||||||
case FT_UINT16:
|
|
||||||
case FT_UINT24:
|
|
||||||
case FT_UINT32:
|
|
||||||
case FT_INT8:
|
|
||||||
case FT_INT16:
|
|
||||||
case FT_INT24:
|
|
||||||
case FT_INT32:
|
|
||||||
case FT_IPv4:
|
|
||||||
/*
|
|
||||||
* All comparison operators are allowed, but you can't
|
|
||||||
* select a subrange of bytes in it.
|
|
||||||
*/
|
|
||||||
relations = EXISTENCE_OK|EQUALITY_OK|ORDER_OK|ORDER_EQUALITY_OK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FT_STRING:
|
|
||||||
case FT_STRINGZ:
|
|
||||||
case FT_UINT_STRING:
|
|
||||||
case FT_ETHER:
|
|
||||||
case FT_IPv6:
|
|
||||||
case FT_IPXNET:
|
|
||||||
/*
|
|
||||||
* Only equality comparisons are allowed, and you can't
|
|
||||||
* select a subrange of bytes.
|
|
||||||
*/
|
|
||||||
relations = EXISTENCE_OK|EQUALITY_OK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FT_DOUBLE:
|
|
||||||
case FT_ABSOLUTE_TIME:
|
|
||||||
case FT_RELATIVE_TIME:
|
|
||||||
/*
|
|
||||||
* We don't support filtering on these.
|
|
||||||
*/
|
|
||||||
relations = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FT_BYTES:
|
|
||||||
/*
|
|
||||||
* Equality and "greater than" and "less than", but *not*
|
|
||||||
* "greater than or equal to" or "less than or equal to",
|
|
||||||
* are supported. XXX - is that an error?
|
|
||||||
* Ranges are supported.
|
|
||||||
*/
|
|
||||||
relations = EXISTENCE_OK|EQUALITY_OK|ORDER_OK|RANGES_OK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
g_assert_not_reached();
|
|
||||||
relations = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
show_relations(relation_label, relation_list, range_label,
|
show_relations(relation_label, relation_list, range_label,
|
||||||
range_entry, relations);
|
range_entry, hfinfo->type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the label for the value to indicate what type of value
|
* Set the label for the value to indicate what type of value
|
||||||
|
@ -318,58 +231,60 @@ field_select_row_cb(GtkWidget *tree, GList *node, gint column,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_relations(GtkWidget *relation_label, GtkWidget *relation_list,
|
show_relations(GtkWidget *relation_label, GtkWidget *relation_list,
|
||||||
GtkWidget *range_label, GtkWidget *range_entry, guint32 relations)
|
GtkWidget *range_label, GtkWidget *range_entry, ftenum_t ftype)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Clear out the currently displayed list of relations.
|
* Clear out the currently displayed list of relations.
|
||||||
*/
|
*/
|
||||||
gtk_list_clear_items(GTK_LIST(relation_list), 0, -1);
|
gtk_list_clear_items(GTK_LIST(relation_list), 0, -1);
|
||||||
if (relations == 0) {
|
switch (ftype) {
|
||||||
|
|
||||||
|
case FT_BOOLEAN:
|
||||||
/*
|
/*
|
||||||
* No relational operators are supported; hide the relation
|
* No relational operators are supported; hide the relation
|
||||||
* and range stuff.
|
* stuff.
|
||||||
*/
|
*/
|
||||||
gtk_widget_hide(relation_label);
|
gtk_widget_hide(relation_label);
|
||||||
gtk_widget_hide(relation_list);
|
gtk_widget_hide(relation_list);
|
||||||
gtk_widget_hide(range_label);
|
break;
|
||||||
gtk_widget_hide(range_entry);
|
|
||||||
} else {
|
default:
|
||||||
/*
|
/*
|
||||||
* Add the supported relations.
|
* Add the supported relations.
|
||||||
|
* XXX - pick something better than "is present"
|
||||||
|
* for protocols.
|
||||||
*/
|
*/
|
||||||
if (relations & EXISTENCE_OK)
|
add_relation_list(relation_list, "is present");
|
||||||
add_relation_list(relation_list, "is present");
|
if (ftype_can_eq(ftype))
|
||||||
if (relations & EQUALITY_OK) {
|
|
||||||
add_relation_list(relation_list, "==");
|
add_relation_list(relation_list, "==");
|
||||||
|
if (ftype_can_ne(ftype))
|
||||||
add_relation_list(relation_list, "!=");
|
add_relation_list(relation_list, "!=");
|
||||||
}
|
if (ftype_can_gt(ftype))
|
||||||
if (relations & ORDER_OK) {
|
|
||||||
add_relation_list(relation_list, ">");
|
add_relation_list(relation_list, ">");
|
||||||
|
if (ftype_can_lt(ftype))
|
||||||
add_relation_list(relation_list, "<");
|
add_relation_list(relation_list, "<");
|
||||||
}
|
if (ftype_can_ge(ftype))
|
||||||
if (relations & ORDER_EQUALITY_OK) {
|
|
||||||
add_relation_list(relation_list, ">=");
|
add_relation_list(relation_list, ">=");
|
||||||
|
if (ftype_can_le(ftype))
|
||||||
add_relation_list(relation_list, "<=");
|
add_relation_list(relation_list, "<=");
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* And show the list.
|
* And show the list.
|
||||||
*/
|
*/
|
||||||
gtk_widget_show(relation_label);
|
gtk_widget_show(relation_label);
|
||||||
gtk_widget_show(relation_list);
|
gtk_widget_show(relation_list);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Are range supported? If so, show the range stuff,
|
* Are range supported? If so, show the range stuff,
|
||||||
* otherwise hide it.
|
* otherwise hide it.
|
||||||
*/
|
*/
|
||||||
if (relations & RANGES_OK) {
|
if (ftype_can_slice(ftype)) {
|
||||||
gtk_widget_show(range_label);
|
gtk_widget_show(range_label);
|
||||||
gtk_widget_show(range_entry);
|
gtk_widget_show(range_entry);
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_hide(range_label);
|
gtk_widget_hide(range_label);
|
||||||
gtk_widget_hide(range_entry);
|
gtk_widget_hide(range_entry);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,10 +900,14 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
|
||||||
* as it'll ever need, so the dialog box and widgets start out
|
* as it'll ever need, so the dialog box and widgets start out
|
||||||
* with the right sizes.
|
* with the right sizes.
|
||||||
*
|
*
|
||||||
* XXX - this doesn't work.
|
* XXX - this doesn't work. It *doesn't* request as much space
|
||||||
|
* as it'll ever need.
|
||||||
|
*
|
||||||
|
* XXX - FT_UINT8 doesn't support ranges, so even if it did work,
|
||||||
|
* it wouldn't work right.
|
||||||
*/
|
*/
|
||||||
show_relations(relation_label, relation_list, range_label, range_entry,
|
show_relations(relation_label, relation_list, range_label, range_entry,
|
||||||
EXISTENCE_OK|EQUALITY_OK|ORDER_OK|ORDER_EQUALITY_OK|RANGES_OK);
|
FT_UINT8);
|
||||||
|
|
||||||
value_vb = gtk_vbox_new(FALSE, 5);
|
value_vb = gtk_vbox_new(FALSE, 5);
|
||||||
gtk_container_border_width(GTK_CONTAINER(value_vb), 5);
|
gtk_container_border_width(GTK_CONTAINER(value_vb), 5);
|
||||||
|
|
Loading…
Reference in New Issue