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] Use of Expert Info failed

From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Tue, 03 Nov 2009 15:51:37 +0100
Hi,

Your first line is suspect:
> if (tree) { 

Thanx,
Jaap

On Tue, 03 Nov 2009 15:44:01 +0100, Christian Gurk
<christian.gurk@xxxxxxx>
wrote:
> Hi together,
> 
> I tried to use the Expert Info feature to get a fast "statistic" about 
> checksum errors in my protocol. So, when a message has a wrong CRC, I 
> rise a Expert warn. It shows nicely in the message list (as a yellow 
> marking), but it doesn't show up in the Expert Info Analyse Window.
> 
> Here my code snipplet:
> 
>>     if (tree) { // we are being asked for details
>>     -------------------------------------------
>>         guint32 offset = 0;
>>         guint32 length = 0;
>>     
>>         // add subtree for MPIC com7 protocol    
>>         mpic_com7_item = proto_tree_add_protocol_format(tree,
>>         proto_mpic_com7, tvb, 0, -1,
>> 		      "MPIC COM7 frame (raw bytes: %3d, decrypted bytes: %3d,
>> 		      framestatus: %s)",
>> 		      datalen, j, match_strval(framestatus,framestatusnames));
>>         
>>         mpic_com7_tree = proto_item_add_subtree(mpic_com7_item,
>>         ett_mpic_com7_length);
>> 
>>         // Add subitems 
>>         proto_tree_add_uint(mpic_com7_tree, hf_mpic_com7_length, tvb,
0,
>>         i, datalen);
>>         proto_tree_add_uint(mpic_com7_tree, hf_mpic_com7_checksum, tvb,
>>         0, 0, inbyte);
>> 		if (framecheck != 0)
>> 		{
>> 			pi = proto_tree_add_text(mpic_com7_tree, tvb, 0, 0, "Calculated CRC:
>> 			0x%02x -> CRC ERROR	!", framecheck);
>> 			expert_add_info_format(pinfo, pi, PI_CHECKSUM, PI_WARN, "CRC8
ERROR");
>> 		}
>>         proto_tree_add_uint(mpic_com7_tree, hf_mpic_com7_framestatus,
>>         tvb, 0, 0, framestatus);
>>     }
> 
> Did I something wrong? As I said, it works nicely for the message list, 
> but not for the Expert Info Analysis. Attached a screenshot, you can see

> my "warn" Info and the following "error" warning looking quite the same.

>   I know, that the error might mask out my warning, if they're in the 
> same message, but I also have messages only with a warning, the problem 
> is the same...
> Could anyone help me?
> Thanks
> Christian