aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/proto.c65
-rw-r--r--epan/proto.h88
-rw-r--r--file.c4
-rw-r--r--gtk/proto_draw.c12
-rw-r--r--packet-tcp.c9
-rw-r--r--print.c6
6 files changed, 104 insertions, 80 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"
/*
diff --git a/file.c b/file.c
index ea58cf4453..127fac0df7 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.379 2004/04/25 12:04:07 ulfl Exp $
+ * $Id: file.c,v 1.380 2004/05/01 15:15:07 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1959,7 +1959,7 @@ match_subtree_text(proto_node *node, gpointer data)
}
/* Don't match invisible entries. */
- if (!fi->visible)
+ if (PROTO_ITEM_IS_HIDDEN(node))
return;
/* was a free format label produced? */
diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c
index 71131f2662..e145a58975 100644
--- a/gtk/proto_draw.c
+++ b/gtk/proto_draw.c
@@ -1,7 +1,7 @@
/* proto_draw.c
* Routines for GTK+ packet display
*
- * $Id: proto_draw.c,v 1.92 2004/04/28 20:56:43 guy Exp $
+ * $Id: proto_draw.c,v 1.93 2004/05/01 15:15:08 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1796,7 +1796,7 @@ proto_tree_draw_node(proto_node *node, gpointer data)
GtkTreePath *path;
#endif
- if (!fi->visible)
+ if (PROTO_ITEM_IS_HIDDEN(node))
return;
/* was a free format label produced? */
@@ -1823,6 +1823,10 @@ proto_tree_draw_node(proto_node *node, gpointer data)
is_expanded = FALSE;
}
+ if(PROTO_ITEM_IS_GENERATED(node)) {
+ label_ptr = g_strdup_printf("[%s]", label_ptr);
+ }
+
#if GTK_MAJOR_VERSION < 2
info.ctree = parent_info->ctree;
parent = gtk_ctree_insert_node ( info.ctree, parent_info->ctree_node, NULL,
@@ -1837,6 +1841,10 @@ proto_tree_draw_node(proto_node *node, gpointer data)
gtk_tree_store_set(store, &iter, 0, label_ptr, 1, fi, -1);
#endif
+ if(PROTO_ITEM_IS_GENERATED(node)) {
+ g_free(label_ptr);
+ }
+
if (!is_leaf) {
#if GTK_MAJOR_VERSION < 2
info.ctree_node = parent;
diff --git a/packet-tcp.c b/packet-tcp.c
index 9ac4896b0a..5a94ce6b4a 100644
--- a/packet-tcp.c
+++ b/packet-tcp.c
@@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
- * $Id: packet-tcp.c,v 1.230 2004/04/30 06:24:35 ulfl Exp $
+ * $Id: packet-tcp.c,v 1.231 2004/05/01 15:15:08 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1150,17 +1150,20 @@ tcp_print_sequence_number_analysis(packet_info *pinfo, tvbuff_t *tvb, proto_tree
}
item=proto_tree_add_text(parent_tree, tvb, 0, 0, "SEQ/ACK analysis");
+ PROTO_ITEM_SET_GENERATED(item);
tree=proto_item_add_subtree(item, ett_tcp_analysis);
/* encapsulate all proto_tree_add_xxx in ifs so we only print what
data we actually have */
if(ta->frame_acked){
- proto_tree_add_uint(tree, hf_tcp_analysis_acks_frame,
+ item = proto_tree_add_uint(tree, hf_tcp_analysis_acks_frame,
tvb, 0, 0, ta->frame_acked);
+ PROTO_ITEM_SET_GENERATED(item);
}
if( ta->ts.secs || ta->ts.nsecs ){
- proto_tree_add_time(tree, hf_tcp_analysis_ack_rtt,
+ item = proto_tree_add_time(tree, hf_tcp_analysis_ack_rtt,
tvb, 0, 0, &ta->ts);
+ PROTO_ITEM_SET_GENERATED(item);
}
if(ta->flags){
diff --git a/print.c b/print.c
index 02b723824e..b203040c91 100644
--- a/print.c
+++ b/print.c
@@ -1,7 +1,7 @@
/* print.c
* Routines for printing packet analysis trees.
*
- * $Id: print.c,v 1.80 2004/04/26 15:58:33 gram Exp $
+ * $Id: print.c,v 1.81 2004/05/01 15:15:08 ulfl Exp $
*
* Gilbert Ramirez <gram@alumni.rice.edu>
*
@@ -209,7 +209,7 @@ void proto_tree_print_node(proto_node *node, gpointer data)
gchar *label_ptr;
/* Don't print invisible entries. */
- if (!fi->visible)
+ if (PROTO_ITEM_IS_HIDDEN(node))
return;
/* was a free format label produced? */
@@ -389,7 +389,7 @@ proto_tree_print_node_pdml(proto_node *node, gpointer data)
print_escaped_xml(pdata->fh, label_ptr);
}
- if(!fi->visible) {
+ if(PROTO_ITEM_IS_HIDDEN(node)) {
fprintf(pdata->fh, "\" hide=\"yes");
}