aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2004-05-01 15:15:08 +0000
committerUlf Lamping <ulf.lamping@web.de>2004-05-01 15:15:08 +0000
commitd9118dc089e7d842bc5c288238e1b100c799fb63 (patch)
tree9a1acdf9d2c216571cbfd181a679af12cab5d99d /epan
parent4cf12f590ec0c5ffca4f6af9ffb99c59ec52a005 (diff)
add PROTO_ITEM_SET_HIDDEN() and PROTO_ITEM_SET_GENERATED(),
this sets flags for later rendering of the field data svn path=/trunk/; revision=10752
Diffstat (limited to 'epan')
-rw-r--r--epan/proto.c65
-rw-r--r--epan/proto.h88
2 files changed, 83 insertions, 70 deletions
diff --git a/epan/proto.c b/epan/proto.c
index 676b082359..9283502d25 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.131 2004/03/25 23:55:21 guy Exp $
+ * $Id: proto.c,v 1.132 2004/05/01 15:15:08 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -858,14 +858,12 @@ proto_tree_add_item_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb,
gint start, gint length, gboolean little_endian)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_item(tree, hfindex, tvb, start, length, little_endian);
if (pi == NULL)
return(NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -961,14 +959,12 @@ proto_tree_add_bytes_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint s
gint length, const guint8 *start_ptr)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_bytes(tree, hfindex, tvb, start, length, start_ptr);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1037,14 +1033,12 @@ proto_tree_add_time_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st
nstime_t *value_ptr)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_time(tree, hfindex, tvb, start, length, value_ptr);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1100,14 +1094,12 @@ proto_tree_add_ipxnet_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint
guint32 value)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_ipxnet(tree, hfindex, tvb, start, length, value);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1163,14 +1155,12 @@ proto_tree_add_ipv4_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st
guint32 value)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_ipv4(tree, hfindex, tvb, start, length, value);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1226,14 +1216,12 @@ proto_tree_add_ipv6_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st
const guint8* value_ptr)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_ipv6(tree, hfindex, tvb, start, length, value_ptr);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1318,14 +1306,12 @@ proto_tree_add_string_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint
gint length, const char* value)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_string(tree, hfindex, tvb, start, length, value);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1421,14 +1407,12 @@ proto_tree_add_ether_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint s
const guint8* value)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_ether(tree, hfindex, tvb, start, length, value);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1490,14 +1474,12 @@ proto_tree_add_boolean_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint
guint32 value)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_boolean(tree, hfindex, tvb, start, length, value);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1553,14 +1535,12 @@ proto_tree_add_float_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint s
float value)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_float(tree, hfindex, tvb, start, length, value);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1616,14 +1596,12 @@ proto_tree_add_double_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint
double value)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_double(tree, hfindex, tvb, start, length, value);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1689,14 +1667,12 @@ proto_tree_add_uint_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint st
guint32 value)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_uint(tree, hfindex, tvb, start, length, value);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -1776,14 +1752,12 @@ proto_tree_add_int_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint sta
gint32 value)
{
proto_item *pi;
- field_info *fi;
pi = proto_tree_add_int(tree, hfindex, tvb, start, length, value);
if (pi == NULL)
return (NULL);
- fi = PITEM_FINFO(pi);
- fi->visible = FALSE;
+ PROTO_ITEM_SET_HIDDEN(pi);
return pi;
}
@@ -2003,7 +1977,10 @@ alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
fi->start+=(tvb)?TVB_RAW_OFFSET(tvb):0;
fi->length = *length;
fi->tree_type = -1;
- fi->visible = PTREE_DATA(tree)->visible;
+ fi->flags = 0;
+ if(!PTREE_DATA(tree)->visible) {
+ FI_SET_FLAG(fi, FI_HIDDEN);
+ }
fvalue_init(&fi->value, fi->hfinfo->type);
fi->rep = NULL;
@@ -2021,7 +1998,7 @@ proto_tree_set_representation(proto_item *pi, const char *format, va_list ap)
int ret; /*tmp return value */
field_info *fi = PITEM_FINFO(pi);
- if (fi->visible) {
+ if (!PROTO_ITEM_IS_HIDDEN(pi)) {
ITEM_LABEL_NEW(fi->rep);
ret = vsnprintf(fi->rep->representation, ITEM_LABEL_LENGTH, format, ap);
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
@@ -2066,7 +2043,7 @@ proto_item_append_text(proto_item *pi, const char *format, ...)
fi = PITEM_FINFO(pi);
- if (fi->visible) {
+ if (!PROTO_ITEM_IS_HIDDEN(pi)) {
va_start(ap, format);
/*
@@ -3426,7 +3403,7 @@ check_for_offset(proto_node *node, gpointer data)
offset_search_t *offsearch = data;
/* !fi == the top most container node which holds nothing */
- if (fi && fi->visible && fi->ds_tvb && offsearch->tvb == fi->ds_tvb) {
+ if (fi && !PROTO_ITEM_IS_HIDDEN(node) && fi->ds_tvb && offsearch->tvb == fi->ds_tvb) {
if (offsearch->offset >= (guint) fi->start &&
offsearch->offset < (guint) (fi->start + fi->length)) {
diff --git a/epan/proto.h b/epan/proto.h
index 10e12005ad..ccb8c4176c 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
- * $Id: proto.h,v 1.58 2004/04/30 06:56:15 ulfl Exp $
+ * $Id: proto.h,v 1.59 2004/05/01 15:15:08 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -52,7 +52,7 @@ struct _value_string;
/* ... and similarly, */
#define TFS(x) (const struct true_false_string*)(x)
-struct _protocol;
+extern struct _protocol;
typedef struct _protocol protocol_t;
@@ -64,6 +64,7 @@ typedef struct _protocol protocol_t;
} \
}
+/* values for header_field_info.display */
enum {
BASE_NONE,
BASE_DEC,
@@ -110,18 +111,29 @@ typedef struct _item_label_t {
char representation[ITEM_LABEL_LENGTH];
} item_label_t;
+
+
/* Contains the field information for the proto_item. */
typedef struct field_info {
- header_field_info *hfinfo;
+ header_field_info *hfinfo;
gint start;
gint length;
gint tree_type; /* ETT_* */
- item_label_t *rep; /* string for GUI tree */
- int visible;
+ item_label_t *rep; /* string for GUI tree */
+ int flags;
tvbuff_t *ds_tvb; /* data source tvbuff */
fvalue_t value;
} field_info;
+
+#define FI_HIDDEN 0x0001
+#define FI_GENERATED 0x0002
+
+#define FI_GET_FLAG(fi, flag) (fi->flags & flag)
+#define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag)
+
+
+
/* One of these exists for the entire protocol tree. Each proto_node
* in the protocol tree points to the same copy. */
typedef struct {
@@ -142,6 +154,15 @@ typedef struct _proto_node {
typedef proto_node proto_tree;
typedef proto_node proto_item;
+
+/* indicate that this field should not be shown by Ethereal (used for filtering only) */
+#define PROTO_ITEM_IS_HIDDEN(proto_item) FI_GET_FLAG(proto_item->finfo, FI_HIDDEN)
+#define PROTO_ITEM_SET_HIDDEN(proto_item) FI_SET_FLAG(proto_item->finfo, FI_HIDDEN)
+/* indicate that this field is generated by Ethereal (and not inside the packet data) */
+#define PROTO_ITEM_IS_GENERATED(proto_item) FI_GET_FLAG(proto_item->finfo, FI_GENERATED)
+#define PROTO_ITEM_SET_GENERATED(proto_item) FI_SET_FLAG(proto_item->finfo, FI_GENERATED)
+
+
typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
extern void proto_tree_children_foreach(proto_tree *tree,
@@ -160,6 +181,20 @@ extern void proto_init(const char *plugin_dir,
/* Frees memory used by proto routines. Called at program shutdown */
extern void proto_cleanup(void);
+
+
+/* Create a subtree under an existing item; returns tree pointer */
+extern proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
+
+/* Get a subtree under an item; returns tree pointer */
+extern proto_tree* proto_item_get_subtree(proto_item *ti);
+
+/* Get a parent item; returns item pointer */
+extern proto_item* proto_item_get_parent(proto_item *ti);
+
+/* Get Nth generation parent item; returns item pointer */
+extern proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
+
/* Set text of proto_item after having already been created. */
#if __GNUC__ >= 2
extern void proto_item_set_text(proto_item *ti, const char *format, ...)
@@ -192,39 +227,26 @@ extern void proto_item_set_end(proto_item *pi, tvbuff_t *tvb, gint end);
* to add a variable-length field (e.g., FT_NSTRING_UINT8) */
extern int proto_item_get_len(proto_item *ti);
+
+
/* Creates new proto_tree root */
extern proto_tree* proto_tree_create_root(void);
-/* Mark a field/protocol ID as "interesting". */
-extern void
-proto_tree_prime_hfid(proto_tree *tree, int hfid);
-
/* Clear memory for entry proto_tree. Clears proto_tree struct also. */
extern void proto_tree_free(proto_tree *tree);
-/* Create a subtree under an existing item; returns tree pointer */
-extern proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
-
-/* Get a subtree under an item; returns tree pointer */
-extern proto_tree* proto_item_get_subtree(proto_item *ti);
-
-/* Get a parent item; returns item pointer */
-extern proto_item* proto_item_get_parent(proto_item *ti);
+extern void
+proto_tree_set_visible(proto_tree *tree, gboolean visible);
-/* Get Nth generation parent item; returns item pointer */
-extern proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
+/* Mark a field/protocol ID as "interesting". */
+extern void
+proto_tree_prime_hfid(proto_tree *tree, int hfid);
/* Get a parent item of subtree; returns item pointer */
extern proto_item* proto_tree_get_parent(proto_tree *tree);
-extern int
-proto_register_protocol(char *name, char *short_name, char *filter_name);
-extern void
-proto_register_field_array(int parent, hf_register_info *hf, int num_records);
-extern void
-proto_register_subtree_array(gint **indices, int num_indices);
/* Add an item to a proto_tree, using the text label registered to that item;
the item is extracted from the tvbuff handed to it. */
@@ -531,11 +553,20 @@ extern proto_item *
proto_tree_add_debug_text(proto_tree *tree, const char *format, ...);
#endif
+
extern void
proto_item_fill_label(field_info *fi, gchar *label_str);
+
+
+extern int
+proto_register_protocol(char *name, char *short_name, char *filter_name);
+
extern void
-proto_tree_set_visible(proto_tree *tree, gboolean visible);
+proto_register_field_array(int parent, hf_register_info *hf, int num_records);
+
+extern void
+proto_register_subtree_array(gint **indices, int num_indices);
/* Returns number of items (protocols or header fields) registered. */
extern int proto_registrar_n(void);
@@ -625,6 +656,8 @@ extern void proto_registrar_dump_protocols(void);
/* Dumps a glossary of the protocol and field registrations to STDOUT */
extern void proto_registrar_dump_fields(void);
+
+
/* Points to the first element of an array of Booleans, indexed by
a subtree item type; that array element is TRUE if subtrees of
an item of that type are to be expanded. */
@@ -641,6 +674,9 @@ extern int num_tree_types;
extern int
hfinfo_bitwidth(header_field_info *hfinfo);
+
+
+
#include "epan.h"
/*