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] Proper way to handle changes in the preferences

From: Pascal Quantin <pascal@xxxxxxxxxxxxx>
Date: Mon, 17 Jun 2019 07:51:16 +0200
Hi Sake,

Le lun. 17 juin 2019 à 07:10, Sake Blok | SYN-bit <sake.blok@xxxxxxxxxx> a écrit :
Hi,

I'm working on a patch to add the possibility to show times in milli- or microsecond units. While working this out, I see a need to change the name of certain preferences and/or change the values of other preferences. This will however break compatibility with older versions of Wireshark in reading/writing the preferences (in my case, settings in the "recent" file).

Is there a way to add backwards compatibility in preference items by converting old preference settings into new ones?
And is there a way to add code to the current versions to do the reverse for forward compatibility, so at least future minor versions of old major versions will be able to handle this correctly?

Things that I might want to change are:

# Timestamp display precision.
# One of: AUTO, SEC, DSEC, CSEC, MSEC, USEC, NSEC
gui.time_precision: MSEC

to:

# Timestamp display precision.
# One of: AUTO, 0DECIMALS, 1DECIMAL, 2DECIMALS, 3DECIMALS, 6DECIMALS, 9DECIMALS
gui.time_precision: AUTO

and

# Seconds display format.
# One of: SECONDS, HOUR_MIN_SEC
gui.seconds_format: SECONDS

to

# Seconds display format.
# One of: SECONDS, MILLISECONDS, MICROSECONDS, HOUR_MIN_SEC
gui.time_units: SECONDS

Are there some guidelines available in handling preferences between wireshark versions?

You can find some code handling preferences rename in epan/prefs.c file, set_pref() function. This is probably the right place to put some conversion code between the old and new format.

Cheers,
Pascal.