Wireshark-dev: Re: [Wireshark-dev] Exposing KRB5 value_strings to other dissectors ...
From: Richard Sharpe <[email protected]>
Date: Tue, 3 Jul 2012 09:22:19 -0700
On Tue, Jul 3, 2012 at 8:36 AM, Bill Meier <[email protected]> wrote:
> On 7/3/2012 11:22 AM, Stephen Fisher wrote:
>>
>>
>> ---- On Tue, 03 Jul 2012 08:45:46 -0600 Richard Sharpe  wrote ----
>>
>>> There are protocols that specify the use of KRB5 specified values.
>>> Eg, NegoEx specifies RFC3961 strings.
>>>
>>> Rather than simply re-entering these values it would be useful to
>>> reuse the existing value_string variables, but they are static ...
>>
>>
>> Move them to a separate header file (without the static identifier)
>> and include that in each dissector source file.  Take a look at
>> packet-x11-keysym.h for an example of sharing a value string, which
>> is used by packet-x11.c and packet-vnc.c.
>>
>
>
> Uh, I'm not a fan of this approach (putting value strings in .h files) since
> that ends up with multiple instances of the same array in the executable.
> :)
>
> In fact, I've been fixing such instances as I encounter them.
>
> Am I missing something ?
>
> My tendency would be to change the change the usage of the value-string
> array defined in packet-x11-keysym.

Right. I agree.

One should have the definition only in the .h file. Eg:

extern value_string some_value_string_array[];

And then, in the primary place it is used:

#include "the_include_file_with_the_val_strings.h"
...
value_string some_value_string_array[] = {
   {SOME_VAL, "The string for SOME_VAL"},
   {0, NULL}
}

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)