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] crash with Preference in Plugin

From: "khushbu thakkar" <thakkar.khushbu@xxxxxxxxx>
Date: Thu, 3 Jan 2008 11:48:52 +0530
Hi,
      
     I tried specifing new color filter for my dissector but it didnt override the UDP one and still takes colorization of UDP itself.
 
Thanx,
Khushbu

 
On 1/3/08, Jaap Keuter <jaap.keuter@xxxxxxxxx> wrote:
Hi,

Good for you :)

What happens when you enable colorfilters?

Thanx,
Jaap

khushbu thakkar wrote:
> Hi Jaap,
>
> After a long R&D i could fix the problem of crashing. And the reason was
> too silly. The protocol handle was not maintained i.e "static" was
> missing in "proto_reg_handoff_ipt_spy" for dissector handle.
>
> Anyways one new thing i could observed with Wireshark version 0.99.7 is
> that it does not show(was showing in Wireshark version 0.99.6) the
> name of the protocol (IPTWP in my case(UDP based)) in Protocol Column
> and Info column  but its shows UDP. It shows the dissection of IPTWP
> properly but not the Packet list pane.
>
> Could u please guide me what specifically needs to be changed
> implementationally or some configuration,if its missing. I have attached
> the screenshot for the same issue which shows the middle pane properly
> but packet list pane wrongly.
>
> Please look on to the issue.
>
> Thank You,
> Reply Soon.
> Khushbu
>
>
> On 12/22/07, *khushbu thakkar* < thakkar.khushbu@xxxxxxxxx
> <mailto:thakkar.khushbu@xxxxxxxxx>> wrote:
>
>     Hi Jaap,
>
>        I tried with your suggestion but still the tool crash with the
>     same sequence. But when i tried applying the same preference code to
>     packet-udp.c and tried to build wireshark, then it worked fine on
>     Applying the preference from udp. *So i doubt that the problem is
>     there while* *Registering the Preference with Plugin*, it works fine
>     with \epan\dissectors.
>
>     Would you please guide what else can be done. Actually my
>     requirement is to read external .xml file path/location to decode
>     some part within my plugin packet. So how can that file
>     path/location can be read. At present i m setting an enviornment
>     variable and reading it but i m searching if some setting could be
>      given in Wireshark itself to read the file path/location.
>
>     Reply soon,
>     Thank You,
>     Khushbu
>
>
>
>
>     On 12/17/07, *Jaap Keuter* < jaap.keuter@xxxxxxxxx
>     <mailto:jaap.keuter@xxxxxxxxx>> wrote:
>
>         Hi,
>
>         Loose the ipt_config_preferencefile variable, just go with
>         gbl_iptConfigDictionary. See packet-cigi.c where global_host_ip is
>         handled similarly.
>
>         Thanx,
>         Jaap
>
>         khushbu thakkar wrote:
>         >  Hi Jaap,
>         >
>         >            Thanx for the response. Attached is the part of
>         plugin code.
>         >
>         >  Reply Soon,
>         >  Thank You,
>         >  Khushbu
>         >
>         >  On 12/15/07, *Jaap Keuter* <jaap.keuter@xxxxxxxxx
>         <mailto: jaap.keuter@xxxxxxxxx>
>         >  <mailto:jaap.keuter@xxxxxxxxx <mailto:jaap.keuter@xxxxxxxxx>>>
>         wrote:
>         >
>         >     Hi,
>         >
>         >     If you could post at least your proto_register and
>         proto_handoff code we
>         >     might be able to get some insight.
>         >
>         >     Thanx,
>         >     Jaap
>         >
>         >     khushbu thakkar wrote:
>         >      > Hello,
>         >      >
>         >      >          I am not actually new to Wireshark, i have
>         build the
>         >     plugin in
>         >      > Wireshark which has to be decoded on the top of UDP. I m
>         using
>         >     this on
>         >      > Window XP SP1 . I have build Wireshark with GTK+ 2.10.12 and
>         >     Wireshark
>         >      > Version is 0.99.6.
>         >      >
>         >      >         The problem with me is *Wireshark Crash* when the
>         >     "*Preference*"
>         >      > of the my *plugin * is set. Whenever the preference
>         value changes
>         >     from
>         >      > the initialized value and if we try to capture or load the
>         >     recorded file
>         >      > having packets of my plugin protocol it crashes. And one
>         more
>         >     thing is
>         >      > if i disable the preference code n use the xxx.dll then
>         it works
>         >     fine
>         >      > i.e . problem is due to preference code.
>         >      >
>         >      >           I m using the Standard code format for
>         registering the
>         >      > Preference as in Readme.developer. So anybody could
>         please guide me
>         >      > where should the problem actually be. Thank You in
>         advance for
>         >     the help.
>         >      >
>         >      > Reply Soon,
>         >      > Best Regards,
>         >      > Khushbu
>         >      >
>         >
>         >     _______________________________________________
>         >     Wireshark-dev mailing list
>         >     Wireshark-dev@xxxxxxxxxxxxx
>         <mailto: Wireshark-dev@xxxxxxxxxxxxx> <mailto:
>         Wireshark-dev@xxxxxxxxxxxxx <mailto:Wireshark-dev@xxxxxxxxxxxxx >>
>         >     http://www.wireshark.org/mailman/listinfo/wireshark-dev
>         >
>         >
>         >
>         >
>         ------------------------------------------------------------------------
>
>         >
>         >
>         >  /* Global sample preference ("controls" display of numbers) */
>         >  static const char *gbl_iptConfigDictionary = NULL;
>         >  static char *ipt_config_preferencefile           = NULL;
>         >
>         >  /* Register the protocol with Wireshark */
>         >  /* this format is require because a script is used to build
>         the C function
>         >    that calls all the protocol registration.
>         >  */
>         >  void proto_register_ipt_spy(void)
>         >  {
>         >   module_t *ipt_spy_module;
>         >  /* Setup list of header fields  See Section 1.6.1 for details*/
>         >       static hf_register_info hf[] = {
>         >               { &hf_ipt_spy_timestamp,
>         >                       { "Time Stamp (microseconds)",
>         " iptwp.timestamp",
>         >                       FT_UINT32, BASE_DEC, NULL, 0x0,
>         >                       "", HFILL }
>         >               },
>         >               { &hf_ipt_spy_protocolversion,
>         >                       { "Protocol Version",
>         "iptwp.protocolversion ",
>         >                       FT_UINT32, BASE_HEX,
>         VALS(ipt_spy_protocol_ver_vals)  , 0x0,
>         >                       "", HFILL }
>         >               },
>         >                       .
>         >                       .
>         >                       .
>         >                       .
>         >       /* Setup protocol subtree array */
>         >       static gint *ett[] = {
>         >               &ett_ipt_spy,
>         >               &ett_ipt_spy_dscpfield,
>         >               &ett_ipt_spy_app_data,
>         >               &ett_ipt_spy_nestd_app_data,
>         >               &ett_ipt_spy_app_data_booleanfield,
>         >               &ett_ipt_spy_multiple_app_data,
>         >               &ett_ipt_spy_app_data_fcs,
>         >       };
>         >
>         >       ipt_config_preferencefile = g_strdup("");
>         >       gbl_iptConfigDictionary =
>         g_strdup(ipt_config_preferencefile);
>         >
>         >  /* Register the protocol name and description */
>         >       proto_ipt_spy = proto_register_protocol("IP Train Wire
>         Protocol", "IPTWP", "iptwp");
>         >
>         >       register_dissector("IPTWP", dissect_ipt_spy,
>         proto_ipt_spy); /*By Cisco*/
>         >
>         >  /* Required function calls to register the header fields and
>         subtrees used */
>         >       proto_register_field_array(proto_ipt_spy, hf,
>         array_length(hf));
>         >       proto_register_subtree_array(ett, array_length(ett));
>         >
>         >  /* Register preferences module (See Section 2.6 for more on
>         preferences) */
>         >     ipt_spy_module = prefs_register_protocol(proto_ipt_spy,
>         proto_reg_handoff_ipt_spy);
>         >
>         >  /* Register a sample preference */
>         >       prefs_register_string_preference(ipt_spy_module, "iptfile",
>         >                                   "IPT configuration file",
>         >                                   "IPT configuration file",
>         >                                   &gbl_iptConfigDictionary);
>         >
>         >  }
>         >
>         >
>         >  /* If this dissector uses sub-dissector registration add a
>         registration routine.
>         >    This exact format is required because a script is used to
>         find these routines
>         >    and create the code that calls these routines.
>         >
>         >    This function is also called by preferences whenever "Apply"
>         is pressed
>         >    (see prefs_register_protocol above) so it should accommodate
>         being called
>         >    more than once.
>         >  */
>         >  void proto_reg_handoff_ipt_spy(void)
>         >  {
>         >         static gboolean inited = FALSE;
>         >               dissector_handle_t ipt_spy_handle;
>         >
>         >               //g_free(ipt_config_pref);
>         >               // current_asn1 = g_strdup(asn1_filename);
>         >               //ipt_config_pref =
>         g_strdup(gbl_iptConfigDictionary);
>         >         if(!inited )
>         >               {
>         >                       ipt_spy_handle =
>         create_dissector_handle(dissect_ipt_spy, proto_ipt_spy);
>         >                       inited = TRUE;
>         >               }
>         >               else
>         >               {
>         >                       dissector_delete("udp.port",
>         ipt_spy_UDP_MD_PORT, ipt_spy_handle);
>         >                       dissector_delete("udp.port",
>         ipt_spy_UDP_PD_PORT, ipt_spy_handle);
>         >               }
>         >
>         >               ipt_config_preferencefile = gbl_iptConfigDictionary;
>         >
>         >               dissector_add("udp.port", ipt_spy_UDP_MD_PORT,
>         ipt_spy_handle);
>         >               dissector_add("udp.port", ipt_spy_UDP_PD_PORT,
>         ipt_spy_handle);
>         >     /*
>         >           If you perform registration functions which are
>         dependant upon
>         >           prefs the you should de-register everything which was
>         associated
>         >           with the previous settings and re-register using the
>         new prefs settings
>         >           here. In general this means you need to keep track of
>         what value the
>         >           preference had at the time you registered using a
>         local static in this
>         >           function. ie.
>         >           static int currentPort = -1;
>         >           if( -1 != currentPort ) {
>         >               dissector_delete( " tcp.port", currentPort,
>         ipt_spy_handle);
>         >           }
>         >           currentPort = gPortPref;
>         >           dissector_add("tcp.port", currentPort, ipt_spy_handle);
>         >       */
>         >
>         >
>         >  }
>         >
>         >
>

_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
http://www.wireshark.org/mailman/listinfo/wireshark-dev