This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Get parent node of a proto_tree

0

Is there a way to grab a child proto_tree's parent proto_tree?

Thank you for your time,

Brandon

asked 27 Jul '11, 07:51

officialhopsof's gravatar image

officialhopsof
318812
accept rate: 100%

edited 27 Jul '11, 07:52


One Answer:

1

See proto_item_get_parent() in proto.h

Update: Upon doing some research: I think that the code to get the parent_proto_tree is as follows:

subtree_item = proto_tree_get_parent(subtree);  // returns (proto_item *)subtree
parent_item  = proto_item_get_parent(subtree_item);
parent_tree  = proto_item_get_subtree(parent_item);

AFAIKT there are no instances of this usage in the current Wireshark source.

What I do see in a number of dissectors is code like the following:

proto_item_append_text(proto_item_get_parent(proto_tree_get_parent(tree)), "...");

which appends text to the item "1 level up" from the item for the current tree.

answered 27 Jul '11, 08:03

Bill%20Meier's gravatar image

Bill Meier ♦♦
3.2k1850
accept rate: 17%

edited 27 Jul '11, 14:02