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] Adding numbers to the tree

From: Stephen Fisher <steve@xxxxxxxxxxxxxxxxxx>
Date: Sat, 14 Feb 2009 20:07:16 -0700
On Fri, Feb 13, 2009 at 08:27:54PM +0000, gogrady@xxxxxxxxx wrote:

> i have looked at those and it doesnt seem to be what i'm looking for. 
> I want to do something such as proto_tree_add_text(tree, "TEST", tvb, 
> 0, 0, function_call_that_returns_"TEST"() );
> 
> so that in the tree it will output something like TEST: TEST. however, 
> the first "TEST" is supposed to be an int, but i do not know how to 
> get around not using a static const value_string.

Try this:

  proto_tree_add_text(tree, "%d: TEST", tvb, 0, 0, function());

Since the value is coming from something other than the packet, put 
brackets around it:

  proto_item *pi;

  pi = proto_tree_add_text(tree, "%d: TEST", tvb, 0, 0, function));;
  PROTO_ITEM_SET_GENERATED(pi);

It will then show up as:

  [5: TEST]


Steve