Wireshark-dev: Re: [Wireshark-dev] Template for external dissector plugin

From: Reinhold Kainhofer <lists@xxxxxxxxxxxxx>
Date: Tue, 20 Dec 2011 17:12:13 +0100
On 20/12/2011 16:36, Jaap Keuter wrote:
Just for my information, is this the crux of your location independance?

find_package(Wireshark)
include_directories (${WIRESHARK_INCLUDE_DIRS})

Yes, the cmake/FindWireshark.cmake file (which is executed with the find_package) locates the libwireshark.so library and the wireshark headers (e.g. /usr/include/wireshark).

and does this the mean you need to have the Wireshark development tree available anyway?

No, you don't need the full wireshark development tree available. You just need the headers and the .so library. In Ubuntu these development files are provided by the libwireshark-dev package. Of course, if you compiled the development version of wireshark yourself, the plugin template will locate those development files (provided that the libwireshark.so and the headers are in a "sane" position, i.e. a standard location or a location given in the appropriate environment variables).

The only reason why all tutorials tell you to develop your plugin in the wireshark source tree is that it's easy to find the headers and link to the library (because everything is already set up in the make files). If you can locate the libwireshark.so library of your wireshark version and the installed wireshark headers by some other way (I use the cmake script, you might just as well write an autoconf snippet), there's nothing that stops you from developing out of the wireshark source tree.
However, if you have wireshark installed from packages and compiled your own version, then the wrong library might be found and linked to. In that case, your plugin will not work and might even crash wireshark at startup.

And my CMakeList.txt file makes sure the plugin is installed in ~/.wireshark/plugins/, which is a directory where wireshark will look for plugins. If you want to install it globally, you'll need to copy the .so file of your plugin to e.g. /usr/lib/wireshark/libwireshark1/plugins/ .

Cheers,
Reinhold
-- 
------------------------------------------------------------------
Reinhold Kainhofer, reinhold@xxxxxxxxxxxxx, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org