Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Adding numbers to the tree

Date: Fri, 13 Feb 2009 14:40:07 -0600
Hi,

Then i must be confused about what it is hfindex are doing and where they show up in the tree. Could you explain / how to use format?

Sorry for the trouble,
Greg 


-----Original Message-----
From: Jaap Keuter [mailto:jaap.keuter@xxxxxxxxx] 
Sent: Friday, February 13, 2009 3:35 PM
To: gogrady@xxxxxxxxx
Subject: Re: [Wireshark-dev] Adding numbers to the tree

Hi,

What's wrong with proto_tree_add_uint_format()? You'll have to format the 
presentation of your data completely.

proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint 
start, gint length, guint32 value, const char *format, ...)

tree: the tree you want to add to;
hfindex: headerfield index of the definition of the header field. Applicable for 
filtering;
tvb: the TVB you work from;
start: start offset in TVB, maybe 0 if N/A;
length: length of data in TVB, maybe 0 if N/A;
value: value you want to be able to filter with;
format: printf format string;
...: any format string parameters.

Thanx,
Jaap

gogrady@xxxxxxxxx wrote:
> Hi,
> 
> 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.
> 
> Unless i have missed a function that you would like to point out that makes that easy. 
> 
> Thanks, 
> Greg
> ______________________________
> Hi,
> 
> If you look at the other proto_tree_add.... functions you will probably find one which suits your needs.
> 
> Thanx,
> Jaap
> 
> gogrady@xxxxxxxxx wrote:
>> Ahh thank you, i think i get that. But also, for "id". It takes an int, but what if i want to put a different string there? I want to be able to include my own string for output that isn't in a static const value_string. I will be return data from a function from a loaded dll. And just something like:
>>
>> proto_tree_add_uint(tree, "Test: ", tvb, 0, 0, 7)
>>
>> or
>>
>> proto_tree_add_uint(tree, testfunction(), tvb, 0, 0, 7)
>>
>> where testfunction() would return a char * or something of the sort. Is there an easy way to do something like this?
>>
>> Greg