/* 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>
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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))
fi = PITEM_FINFO(pi);
- if (fi->visible) {
+ if (!PROTO_ITEM_IS_HIDDEN(pi)) {
va_start(ap, format);
/*
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)) {
/* 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>
/* ... and similarly, */
#define TFS(x) (const struct true_false_string*)(x)
-struct _protocol;
+extern struct _protocol;
typedef struct _protocol protocol_t;
} \
}
+/* values for header_field_info.display */
enum {
BASE_NONE,
BASE_DEC,
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 {
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,
/* 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, ...)
* 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. */
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);
/* 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. */
extern int
hfinfo_bitwidth(header_field_info *hfinfo);
+
+
+
#include "epan.h"
/*
/* 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>
}
/* Don't match invisible entries. */
- if (!fi->visible)
+ if (PROTO_ITEM_IS_HIDDEN(node))
return;
/* was a free format label produced? */
/* 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>
GtkTreePath *path;
#endif
- if (!fi->visible)
+ if (PROTO_ITEM_IS_HIDDEN(node))
return;
/* was a free format label produced? */
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,
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;
/* 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>
}
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){
/* 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>
*
gchar *label_ptr;
/* Don't print invisible entries. */
- if (!fi->visible)
+ if (PROTO_ITEM_IS_HIDDEN(node))
return;
/* was a free format label produced? */
print_escaped_xml(pdata->fh, label_ptr);
}
- if(!fi->visible) {
+ if(PROTO_ITEM_IS_HIDDEN(node)) {
fprintf(pdata->fh, "\" hide=\"yes");
}