Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] Dynamic value string

From: Sylvain Munaut <246tnt@xxxxxxxxx>
Date: Fri, 9 Sep 2011 18:49:22 +0200
Hi,

I'm trying to write a dissector for the GMR sattelite phone packets.
Among the fields, a lot of them are :
 - CSN encoded (thus I can use the packet-csn.c helpers a lot)
 - Not bit aligned at all (thus the CSN generic helpers use the
proto_add_bits(...) calls for the fields)
 - Have a 'meaning' that's not a direct mapping to the numeric encoded
value. (like longitude in tenth of degrees, or decibels values in 0.5
decibels units ...)

When only a few values are possible, I can use the value_string in the
field definition. But for 10 bits fields, it's not really an option.

My idea was to extend the value_string to include a 'DYNAMIC' version
where a call back of the dissector would be called with the value and
should return a string to display.

Obviously that string would have to be g_malloc'ed by the callback and
then g_free'ed by the caller. (or give a buffer to write into to the
call back, but then there is a size limit).

Is there any solution I missed ?
This seems like it would be very useful in many cases (at least in the
protocol I lookt at).

Cheers,

    Sylvain