Wireshark-dev: Re: [Wireshark-dev] Handle the error cases
From: wsgd <[email protected]>
Date: Fri, 14 Aug 2009 21:03:17 +0200
Aurélien Decagny a écrit :
Hi,

I'm finishing to write a dissector for Wireshark, and I try to handle the error cases.
I found the expert info page: 
http://wiki.wireshark.org/Development/ExpertInfo
But I didn't really understand everything.
So I looked at the packet-tcp. source to see how it was done, and I have some questions for you:
To make the error cases, I have to use the expert_add_info_format 
function.
So if I use the following code:

    int i=0;
    proto_item *pi;
for(i=0; i<lengthStructArrTLV; i++)
    {
        /* We display the text */
pi = proto_tree_add_text(sle_tree, tvb, (structArrayTLV[i].octetPosition)+8, structArrayTLV[i].messageLength,"%s", structFinalDisplay[i].line); PROTO_ITEM_SET_GENERATED(pi); expert_add_info_format(pinfo, pi, PI_ERROR, PI_MALFORMED,"error!");
invert PI_ERROR, PI_MALFORMED -> PI_MALFORMED, PI_ERROR
    }


(Supposing that the structFinalDisplay[i].line are strings which contains all the data to be diplayed)
This should find a critical error on every line.

Firstly, I don't understand what is the purpose of the PROTO_ITEM_SET_GENERATED() function. I looked in the readme.developer, but I don't see the link.
There is no link.
The purpose is to say that pi is not read from the packet data, it is a field computed (ie generated) by the dissector.
Furthermore, I get error for each line, but not as I wanted. I would 
like that each line was red, but here the lines are white (the 
proto_tree_add_text lines, the normal ones), and I use the critical 
error, so that should be red! I don't really understand the whole 
thing in fact.

Regards

Aurelien

------------------------------------------------------------------------
Discutez sur Messenger où que vous soyez ! Mettez Messenger sur votre mobile ! <http://www.messengersurvotremobile.com/>
------------------------------------------------------------------------

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <[email protected]>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:[email protected]?subject=unsubscribe