I am sure this line is wrong:
next_tvb=tvb_new_subset(next_tvb, length, -1, -1);
change it to
next_tvb=tvb_new_subset(next_tvb, 2, length, length);
instead.
On Fri, 13 Aug 2004 11:01:37 -0500, Michele B. wrote:
> Hello to all!
>
> I am trying the whole afternoon to add some subtrees.
> In fact I have some Items contained in the packet. The number of Items is contained in the header of the protocol. Therefore I wanted do display for each Item a subtree which contains the length and the value. But I get a problem when I try to add a subtree to another subtree. But if I want to add this Items to the "main" tree it works. Adding to subtree I get a memory error it says like the memomry couldn't be "read" memory. the code is like this
>
> for(i=1;i<=count;i++)
> {
> dissect_item(next_tvb, pinfo, item_tree);
> length=tvb_get_letohs(next_tvb,0);
> next_tvb=tvb_new_subset(next_tvb, length, -1, -1);
> }
>
> I created the item_tree with:
> ti = proto_tree_add_protocol_format (tree, proto_my_protocol, tvb, 0, -1, "My Protocol");
> item_tree = proto_item_add_subtree(ti, ett_item_tree);
>
> and added it do the ett[] array.
>
> The dissect_item function does just this:
> if (tree) {
> ti1 = proto_tree_add_text(tree, tvb, 0, 2, "TLV: %u", length);
>
> tlv_tree = proto_item_add_subtree(ti1, ett_profinet_cbart_item);
>
> proto_tree_add_text(tlv_tree, tvb, 0, 2,
> "Quality code: %u", length);
>
> proto_tree_add_text(tlv_tree, tvb, 3, 1,
> "Length: %d", length);
>
> ti1 = proto_tree_add_text(tlv_tree, tvb,4, length,
> "Value");
> }
> which I copied just from the packet-aim.c of ethereal just to test why there it works and with my function it doesn't. Does anybody have some hints for me?
>
> Thanks for all
>
> Michele Brocco
> --