ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] How to retrieve/modify a tree string

From: Ulf Lamping <ulf.lamping@xxxxxx>
Date: Wed, 15 Nov 2006 22:25:45 +0100
Guy Harris wrote:

Unfortunately, there's currently no way to do that - and there's no proto_tree_add_item_format() for that; you could use the other proto_tree_add_XXX_format() routines.

This sort of thing is - "arrays" or sequences of entries of the same type - is, I suspect, common enough that we might want to have a mechanism to add an item and have a "subscript" added to it.
Sound like a good idea.
That might be a variant of the proto_tree_add_XXX routines that takes a subscript value, and adds the subscript value after the field name - for example, proto_tree_add_XXX_array_element() or proto_tree_add_XXX_sequence_element().
I've implemented something similar (a subroutine in the DCOM/CBA dissector) and I've named it "xxx_indexed", but array_element would be ok too IMHO (the term sequence might be leading to a wrong direction).
If we did that, would we want the format of the subscript to be wired in (e.g., "Field[n]" or "Field n"), would we want it to be a property of the field (in the hf[] entry), or would we want it to be an additional argument to the proto_tree_add_XXX_... routine?
Without thinking too much about it, I would guess that there are a lot of variants (leading zeroes, hex or dec, ...), so we might need a format string - but I'm not sure about that.

Regards, ULFL