Wireshark mailing list archives

Re: When is the preference variable updated?


From: Paul Offord <Paul.Offord () advance7 com>
Date: Thu, 12 Nov 2015 15:13:13 +0000

Hi Pascal,

You are right – it got called twice without the preference value being set and then the third time it was.  Thanks to 
you both for your help, it’s saved me a lot of time.

Best regards…Paul

From: wireshark-dev-bounces () wireshark org [mailto:wireshark-dev-bounces () wireshark org] On Behalf Of Pascal Quantin
Sent: 12 November 2015 14:53
To: Developer support list for Wireshark <wireshark-dev () wireshark org>
Subject: Re: [Wireshark-dev] When is the preference variable updated?



2015-11-12 15:48 GMT+01:00 Paul Offord <Paul.Offord () advance7 com<mailto:Paul.Offord () advance7 com>>:
Hi Pascal,

I wondered if that would be the case but it doesn’t seem to be set when I enter the handoff code.  My handoff looks 
like this:

proto_reg_handoff_tmsvc(void)
{
               dissector_handle_t dissect_tmsvc_handle;
               HANDLE h_thread;

               if (tmsvc_port > 0) {
                              dissect_tmsvc_handle = create_dissector_handle(dissect_tmsvc, proto_tmsvc);

                              register_postdissector(dissect_tmsvc_handle);

                              h_thread = create_service_thread();
               }

               return;
}

I’ve checked the value of tmsvc_port with a breakpoint set on the if statement and it’s still 0 at this point.  It is 
set to the saved preference 8989 by the time of the first call to my dissector.

I notice that Anders has given me a slightly different solution and so I’ll take a look at that next.

Anders' solution should be the same as mine (or maybe I was not clear): proto_reg_handoff_tmsvc should be given as 
parameter to perfs_register_protocol and you will see that this function starts being called several times (so you 
should probably ensure that your code is called only once).


Thanks and regards…Paul



From: wireshark-dev-bounces () wireshark org<mailto:wireshark-dev-bounces () wireshark org> 
[mailto:wireshark-dev-bounces () wireshark org<mailto:wireshark-dev-bounces () wireshark org>] On Behalf Of Pascal 
Quantin
Sent: 12 November 2015 14:15
To: Developer support list for Wireshark <wireshark-dev () wireshark org<mailto:wireshark-dev () wireshark org>>
Subject: Re: [Wireshark-dev] When is the preference variable updated?



2015-11-12 15:07 GMT+01:00 Paul Offord <Paul.Offord () advance7 com<mailto:Paul.Offord () advance7 com>>:
Hi,

Frankly I feel a bit stupid asking this but I've been trying to figure it out for about 6 hours and I think I need 
help.  I have a dissector which I register like this:

static int tmsvc_port = 0;

void
proto_register_tmsvc(void)
{
    module_t *tmsvc_module;

    proto_tmsvc = proto_register_protocol("TM Syncro Service",
                                          "TmSyncro",
                                          "tmsvc");

    tmsvc_module = prefs_register_protocol(proto_tmsvc, NULL);

    prefs_register_uint_preference(tmsvc_module, "port",
                                   "TmSyncro service port",
                                   "When set to a value greater than 0 the TmSyncro service is started and accessible 
via the port number"
                                   10,
                                   &tmsvc_port);

}

Immediately after the prefs_register_uint_preference call I check the tmsvc_port value and its still 0 (and I've tried 
other initialisation values and they remain unchanged).  I was expecting tmsvc_port to be set to the value I last set 
by editing the preferences through the Wireshark menu system.

If I check with Menu -> Edit -> Preferences -> Protocols -> TmSyncro sure enough the value I last set is there.

When does my variable get updated?  Or alternatively, how can I retrieve the saved preference value?

Thanks and regards...Paul

Hi Paul,
the variable should be set according to the preference content when the  proto_reg_handoff_tmsvc function (that you 
register thanks to the prefs_register_protocol function) is called. Alternatively (if you do not need the reg_handoff 
function at all) the variable should be set when your dissector code is called.
Best regards,
Pascal.

______________________________________________________________________

This message contains confidential information and is intended only for the individual named. If you are not the named 
addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if 
you have received this e-mail by mistake and delete this e-mail from your system.

Any views or opinions expressed are solely those of the author and do not necessarily represent those of Advance Seven 
Ltd. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, 
corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept 
liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission.

Advance Seven Ltd. Registered in England & Wales numbered 2373877 at Endeavour House, Coopers End Lane, Stansted, Essex 
CM24 1SJ

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org<mailto:wireshark-dev () wireshark org>>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org<mailto:wireshark-dev-request () wireshark 
org>?subject=unsubscribe


______________________________________________________________________

This message contains confidential information and is intended only for the individual named. If you are not the named 
addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if 
you have received this e-mail by mistake and delete this e-mail from your system.

Any views or opinions expressed are solely those of the author and do not necessarily represent those of Advance Seven 
Ltd. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, 
corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept 
liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission.

Advance Seven Ltd. Registered in England & Wales numbered 2373877 at Endeavour House, Coopers End Lane, Stansted, Essex 
CM24 1SJ

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: