On Wed, Apr 05, 2000 at 01:18:44PM +0200, andreas.sikkema@xxxxxxxxxxx wrote:
> Hi
>
> I am a bit confused about creating subtrees.
> If you start a new subtree for a protocol one does this
> proto_PROT = proto_register_protocol()
>
> and later
> if (tree)
> PROTO_ti = proto_tree_add_item(...., proto_PROT,......tree)
> PROTO_tree = proto_item_add_subtree(..., PROTO_ti,.....)
>
> How does one build subtrees within subtrees?
Subtrees are attached to items, so after you add an item to
PROTO_tree, and save the proto_item pointer in a variable, you can
attach a subtree to it.
Look at packet-vtp.c to see how proto_tree_add_text() and
proto_tree_add_notext() are used to create proto_items that are just
labels have no filterable values. Of course, you can create a subtree
off of a proto_item that *does* have a value. That's how every dissector
starts, since proto_item representing the protocol itself is
a filterable value. Using a filterable proto_item as the branch-point
for a subtree is also useful for bitfields (see packet-tr.c).
--gilbert