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] Moving codecs to libwireshark or libwsutil?

From: Pascal Quantin <pascal.quantin@xxxxxxxxx>
Date: Mon, 30 Nov 2015 16:08:39 +0100


2015-11-30 15:40 GMT+01:00 Pascal Quantin <pascal.quantin@xxxxxxxxx>:
Hi all,

I tried to create a codecs plugin for Windows, but the plugin registration fails.

As reported previously on this list (https://www.wireshark.org/lists/wireshark-dev/201409/msg00043.html), this because the plugin itself ends with its own copy of register_codec function instead of using one exported by the main program. So the codecs of the plugin gets registered in a hash table local to the plugin.
I tried declaring register_codec as WS_DLL_PUBLIC but as expected it does not work and it triggers the following error:

       "D:\dev\wireshark\x64\Wireshark.sln" (default target) (1) ->
       "D:\dev\wireshark\x64\ALL_BUILD.vcxproj.metaproj" (default target) (2) -
       >
       "D:\dev\wireshark\x64\codecs\codecs.vcxproj.metaproj" (default target) (
       11) ->
       "D:\dev\wireshark\x64\codecs\codecs.vcxproj" (default target) (85) ->
       (ClCompile target) ->
         D:\dev\wireshark\git\codecs\codecs.c(160): warning C4273: 'register_co
       dec' : inconsistent dll linkage [D:\dev\wireshark\x64\codecs\codecs.vcxp
       roj]


       "D:\dev\wireshark\x64\Wireshark.sln" (default target) (1) ->
       "D:\dev\wireshark\x64\ALL_BUILD.vcxproj.metaproj" (default target) (2) -
       >
       "D:\dev\wireshark\x64\wireshark.vcxproj.metaproj" (default target) (50)
       ->
       "D:\dev\wireshark\x64\wireshark.vcxproj" (default target) (142) ->
       (Link target) ->
         LINK : fatal error LNK1149: output filename matches input filename 'D:
       \dev\wireshark\x64\run\Debug\Wireshark.lib' [D:\dev\wireshark\x64\wiresh
       ark.vcxproj]

    1 Warning(s)
    1 Error(s)

I'm not sure it makes sense anyway to have a library depending on a function (and global variable) from the main program. This sounds like bad design (and maybe not even doable on some platforms but I'm not very familiar of this kind of issues).

Should we move codecs functions to one of the existing libraries? Or add it to its own? Because so far this officially supported plugin type does not work at all (at least on Windows).

A much less intrusive solution could be to modify register_codec_module() prototype so as to givve as an argument a pointer to the hash table, and introduce a new register_codec_from_plugin() function that would be identical to register_codec() but with the hash table pointer as argument.
Unless someone objects, I'm gonna propose this instead.

Best regards,
Pascal.