epan_dissect_t*
epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible);
+/* Indicate whether we should fake protocols or not */
+void
+epan_dissect_fake_protocols(epan_dissect_t *edt, gboolean fake_protocols);
+
/* run a single packet dissection */
void
epan_dissect_run(epan_dissect_t *edt, void* pseudo_header,
DONT try to fake a node where PTREE_FINFO(tree) is NULL \
since dissectors that want to do proto_item_set_len() or \
other operations that dereference this would crash. \
- We dont fake FT_PROTOCOL either since these are cheap and \
- some stuff (proto hier stat) assumes they always exist. \
+ We fake FT_PROTOCOL unless some clients have requested us \
+ not to do so. \
*/ \
if(!(PTREE_DATA(tree)->visible)){ \
if(PTREE_FINFO(tree)){ \
register header_field_info *hfinfo; \
PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo); \
if((hfinfo->ref_count == HF_REF_TYPE_NONE) \
- && (hfinfo->type!=FT_PROTOCOL)){ \
+ && (hfinfo->type!=FT_PROTOCOL || \
+ PTREE_DATA(tree)->fake_protocols)){ \
/* just return tree back to the caller */\
return tree; \
} \
PTREE_DATA(tree)->visible = visible;
}
+void
+proto_tree_set_fake_protocols(proto_tree *tree, gboolean fake_protocols)
+{
+ PTREE_DATA(tree)->fake_protocols = fake_protocols;
+}
+
/* Assume dissector set only its protocol fields.
This function is called by dissectors and allowes to speed up filtering
in wireshark, if this function returns FALSE it is safe to reset tree to NULL
{
proto_item *pi;
+ if (!tree)
+ return(NULL);
+
+ TRY_TO_FAKE_THIS_ITEM(tree, hf_text_only);
+
pi = proto_tree_add_pi(tree, hf_text_only, tvb, start, &length, NULL);
if (pi == NULL)
return(NULL);
if (!tree)
return (NULL);
+ TRY_TO_FAKE_THIS_ITEM(tree, hfindex);
+
PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo);
DISSECTOR_ASSERT(hfinfo->type == FT_NONE);
if (!tree)
return (NULL);
+ TRY_TO_FAKE_THIS_ITEM(tree, hfindex);
+
PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo);
DISSECTOR_ASSERT(hfinfo->type == FT_PROTOCOL);
* changed, then we'll find out very quickly. */
pnode->tree_data->visible = FALSE;
+ /* Make sure that we fake protocols (if possible) */
+ pnode->tree_data->fake_protocols = TRUE;
+
/* Keep track of the number of children */
pnode->tree_data->count = 0;
typedef struct {
GHashTable *interesting_hfids;
gboolean visible;
+ gboolean fake_protocols;
gint count;
} tree_data_t;
extern void
proto_tree_set_visible(proto_tree *tree, gboolean visible);
+/** Indicate whether we should fake protocols during dissection (default = TRUE)
+ @param tree the tree to be set
+ @param fake_protocols TRUE if we should fake protocols */
+extern void
+proto_tree_set_fake_protocols(proto_tree *tree, gboolean fake_protocols);
+
/** Mark a field/protocol ID as "interesting".
@param tree the tree to be set
@param hfid the interesting field id
/* Dissect the frame tree not visible */
edt = epan_dissect_new(TRUE, FALSE);
+ /* Don't fake protocols. We need them for the protocol hierarchy */
+ epan_dissect_fake_protocols(edt, FALSE);
epan_dissect_run(edt, &phdr, pd, frame, cinfo);
/* Get stats from this protocol tree */