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* <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> 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
>     [email protected] <mailto:[email protected]>
>     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
[email protected]
http://www.wireshark.org/mailman/listinfo/wireshark-dev

Reply via email to