Wireshark-dev: [Wireshark-dev] Handle the error cases

From: Aurélien Decagny <funtim78@xxxxxxxxxxx>
Date: Fri, 14 Aug 2009 18:51:32 +0200
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!");

    }


(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.

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 !