5 Writing a "plugin" dissector is not very different from writing a standard
6 one. In fact all of the functions described in README.developer can be
7 used in the plugins exactly as they are used in standard dissectors.
9 (Note, however, that not all OSes on which Wireshark runs can support
12 If you've chosen "foo" as the name of your plugin (typically, that would
13 be a short name for your protocol, in all lower case), the following
14 instructions tell you how to implement it as a plugin. All occurrences
15 of "foo" below should be replaced by the name of your plugin.
17 2. The directory for the plugin, and its files
19 The plugin should be placed in a new plugins/foo directory which should
20 contain at least the following files:
32 And of course the source and header files for your dissector.
34 Examples of these files can be found in plugins/gryphon.
36 2.1 AUTHORS, COPYING, and ChangeLog
38 The AUTHORS, COPYING, and ChangeLog are the standard sort of GPL project
43 For your plugins/foo/CMakeLists.txt file, see the corresponding file in
44 plugins/gryphon. Replace all occurrences of "gryphon" in those files
45 with "foo" and add your source files to the DISSECTOR_SRC variable.
49 For your plugins/foo/Makefile.am file, see the corresponding file in
50 plugins/gryphon. Replace all occurrences of "gryphon" in those files
55 Your plugins/foo/Makefile.common should only list the main source file(s),
56 which exports register_*() and handoff_*(), for your dissector in the
57 DISSECTOR_SRC variable. All other supporting source files should be
58 listed in the DISSECTOR_SUPPORT_SRC variable.
59 The header files for your dissector, if any, must be listed in the
60 DISSECTOR_INCLUDES variable. The DISSECTOR_INCLUDES variable should not
65 For your plugins/foo/Makefile.nmake file, see the corresponding file in
66 plugins/gryphon. No modifications are needed here.
70 Your plugins/foo/moduleinfo.h file is used to set the version information
75 Your plugins/foo/moduleinfo.nmake is used to set the version information
76 for building the plugin. Its contents should match that in moduleinfo.h
80 Your plugins/foo/plugin.rc.in is the Windows resource template file used
81 to add the plugin specific information as resources to the DLL.
82 No modifications are needed here.
84 3. Changes to existing Wireshark files
86 There are two ways to add your plugin dissector to the build, as a custom
87 extension or as a permanent addition. The custom extension is easy to
88 configure, but won't be used for inclusion in the distribution if that's
89 your goal. Setting up the permanent addition is somewhat more involved.
93 Go to the plugins directory and copy the three Custom.*.example files to
94 Custom.*. Now you have three files ready for building a plugin with the
95 name "foo". Replace the name if you so require.
97 If you want to add the plugin to your own Windows installer add a text
98 file named custom_plugins.txt to the packaging/nsis directory, with a
99 "File" statement for NSIS:
101 File "..\..\plugins\foo\foo.dll"
103 Then open packaging/nsis/Custom.nmake and add the relative path to your
104 DLL to CUSTOM_PLUGINS:
107 ../../plugins/foo/foo.dll
109 3.2 Permanent addition
111 In order to be able to permanently add a plugin take the following steps.
112 You will need to change the following files:
117 packaging/nsis/Makefile.nmake
118 packaging/nsis/wireshark.nsi
120 plugins/Makefile.nmake
122 You might also want to search your Wireshark development directory for
123 occurrences of an existing plugin name, in case this document is out of
124 date with the current directory structure. For example,
128 could be used from a shell prompt.
130 3.2.1 Changes to plugins/Makefile.am
132 The plugins directory contains a Makefile.am. You need to add to SUBDIRS
133 (in alphabetical order) the name of your plugin:
135 SUBDIRS = $(_CUSTOM_SUBDIRS_) \
143 3.2.2 Changes to plugins/Makefile.nmake
145 In plugins/Makefile.nmake you need to add to PLUGINS_LIST (in alphabetical
146 order) the name of your plugin:
155 3.2.3 Changes to the top level Makefile.am
157 Add your plugin (in alphabetical order) to plugin_ldadd:
161 plugin_ldadd = $(_CUSTOM_plugin_ldadd_) \
163 -dlopen plugins/ethercat/ethercat.la \
164 -dlopen plugins/foo/foo.la \
165 -dlopen plugins/gryphon/gryphon.la \
166 -dlopen plugins/irda/irda.la \
169 3.2.4 Changes to the top level configure.ac
171 You need to add your plugins Makefile (in alphbetical order) to the
172 AC_OUTPUT rule in the configure.ac
176 plugins/ethercat/Makefile
178 plugins/gryphon/Makefile
179 plugins/irda/Makefile
183 3.2.5 Changes to epan/Makefile.am
185 Add the relative path of all your plugin source files (in alphbetical
186 order) to plugin_src:
190 ../plugins/ethercat/packet-ioraw.c \
191 ../plugins/ethercat/packet-nv.c \
192 ../plugins/foo/packet-foo.c \
193 ../plugins/gryphon/packet-gryphon.c \
194 ../plugins/irda/packet-ircomm.c \
195 ../plugins/irda/packet-irda.c \
198 3.2.6 Changes to CMakeLists.txt
200 Add your plugin (in alphabetical order) to the PLUGIN_SRC_DIRS:
212 3.2.7 Changes to the installers
214 If you want to include your plugin in an installer you have to add lines
215 in the NSIS installer Makefile.nmake and wireshark.nsi files.
217 3.2.7.1 Changes to packaging/nsis/Makefile.nmake
219 Add the relative path of your plugin DLL (in alphbetical order) to PLUGINS:
223 ../../plugins/ethercat/ethercat.dll \
224 ../../plugins/foo/foo.dll \
225 ../../plugins/gryphon/gryphon.dll \
226 ../../plugins/irda/irda.dll \
228 3.2.7.2 Changes to packaging/nsis/wireshark.nsi
230 Add the relative path of your plugin DLL (in alphbetical order) to the
231 list of "File" statements in the "Dissector Plugins" section:
233 File "${STAGING_DIR}\plugins\${VERSION}\ethercat.dll"
234 File "${STAGING_DIR}\plugins\${VERSION}\foo.dll"
235 File "${STAGING_DIR}\plugins\${VERSION}\gryphon.dll"
236 File "${STAGING_DIR}\plugins\${VERSION}\irda.dll"
238 3.2.7.3 Other installers
240 The U3 and PortableApps installers build their manifests, including
241 plugins, from wireshark.nsi via the packaging/ws-manifest.pl script.
243 4. Development and plugins on Unix
245 Plugins make some aspects of development easier and some harder.
247 The first thing is that you'll have to run autogen.sh and configure once
248 more to setup your build environment.
250 The good news is that if you are working on a single plugin then you will
251 find recompiling the plugin MUCH faster than recompiling a dissector and
252 then linking it back into Wireshark. Use "make -C plugins" to compile just
255 The bad news is that Wireshark will not use the plugins unless the plugins
256 are installed in one of the places it expects them to find.
258 One way of dealing with this problem is to set an environment variable
259 when running Wireshark: WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1.
261 Another way to deal with this problem is to set up a working root for
262 wireshark, say in $HOME/build/root and build wireshark to install
265 ./configure --prefix=${HOME}/build/root && make install
267 then subsequent rebuilds/installs of your plugin can be accomplished
268 by going to the plugins/foo directory and running
272 5. Update "old style" plugins
274 5.1 How to update an "old style" plugin (using plugin_register and
275 plugin_reg_handoff functions).
277 The plugin registration has changed with the extension of the build
278 scripts. These now generate the additional code needed for plugin
279 encapsulation in plugin.c. When using the new style build scripts,
280 stips the parts outlined below:
282 o Remove the following include statements:
285 #include "moduleinfo.h"
287 o Removed the definition:
289 #ifndef ENABLE_STATIC
290 WS_DLL_PUBLIC_DEF gchar version[] = VERSION;
293 o Move relevant code from the blocks and delete these functions:
295 #ifndef ENABLE_STATIC
300 #ifndef ENABLE_STATIC
305 This will leave a clean dissector source file without plugin specifics.
307 5.2 How to update an "old style" plugin (using plugin_init function)
309 The plugin registering has changed between 0.10.9 and 0.10.10; everyone
310 is encouraged to update their plugins as outlined below:
312 o Remove following include statements from all plugin sources:
314 #include "plugins/plugin_api.h"
315 #include "plugins/plugin_api_defs.h"
317 o Remove the init function.
319 o Add a new Makefile.common file with the lists of source files and
322 o Change the Makefile.am and Makefile.nmake files to match those of
327 Ed Warnicke <hagbard@physics.rutgers.edu>
328 Guy Harris <guy@alum.mit.edu>
330 Derived and expanded from the plugin section of README.developers
331 which was originally written by
333 James Coe <jammer@cin.net>
334 Gilbert Ramirez <gram@alumni.rice.edu>
335 Jeff Foster <jfoste@woodward.com>
336 Olivier Abad <oabad@cybercable.fr>
337 Laurent Deniel <laurent.deniel@free.fr>
338 Jaap Keuter <jaap.keuter@xs4all.nl>