Add some info as to the determination of the length of a FT_STRINGZ item.
[obnox/wireshark/wip.git] / doc / README.plugins
1 $Id$
2
3 1. Plugins
4
5 Writing a "plugin" dissector is not very different from writing a
6 standard one.  In fact all of the functions described in
7 README.developer can be used in the plugins exactly as they are used in
8 standard dissectors.
9
10 (Note, however, that not all OSes on which Wireshark runs can support
11 plugins.)
12
13 If you've chosen "xxx" as the name of your plugin (typically, that would
14 be a short name for your protocol, in all lower case), the following
15 instructions tell you how to implement it as a plugin.  All occurrences
16 of "xxx" below should be replaced by the name of your plugin.
17
18 2. The directory for the plugin, and its files
19
20 The plugin should be placed in a new plugins/xxx directory which should
21 contain minimally the following files:
22
23 AUTHORS
24 COPYING
25 ChangeLog
26 CMakeLists.txt
27 Makefile.am
28 Makefile.common
29 Makefile.nmake
30 moduleinfo.h
31 moduleinfo.nmake
32 plugin.rc.in
33 The source files and header files for your dissector
34
35 Examples of these files can be found in plugins/gryphon.
36
37 2.1 AUTHORS, COPYING, and ChangeLog
38
39 The AUTHORS, COPYING, and ChangeLog are the standard sort of GPL project
40 files.
41
42 2.2 CMakeLists.txt
43
44 For your plugins/xxx/CMakeLists.txt file, see the corresponding file in
45 plugins/gryphon. Replace all occurrences of "gryphon" in those files
46 with "xxx" and add your source files to the DISSECTOR_SRC variable.
47
48 2.3 Makefile.am
49
50 For your plugins/xxx/Makefile.am file, see the corresponding file in
51 plugins/gryphon. Replace all occurrences of "gryphon" in those files
52 with "xxx".
53
54 2.4 Makefile.common
55
56 Your plugins/xxx/Makefile.common should only list the main source file(s),
57 which exports register_*() and handoff_*(), for your dissector in the
58 DISSECTOR_SRC variable. All other supporting source files should be listed
59 in the DISSECTOR_SUPPORT_SRC variable, and this variable added to the
60 xxx_la_SOURCES variable in Makefile.am.
61 The header files for your dissector, if any, must be listed in the
62 DISSECTOR_INCLUDES variable. The DISSECTOR_INCLUDES variable should not
63 include moduleinfo.h.
64
65 2.5 Makefile.nmake
66
67 For your plugins/xxx/Makefile.nmake file, see the corresponding file in
68 plugins/gryphon. No modifications are needed here.
69
70 2.6 moduleinfo.h
71
72 Your plugins/xxx/moduleinfo.h file is used to set the version information
73 for the plugin.
74
75 2.7 moduleinfo.nmake
76
77 Your plugins/xxx/moduleinfo.nmake is used to set the version information
78 for building the plugin. Its contents should match that in moduleinfo.h
79
80 2.8 plugin.rc.in
81
82 Your plugins/xxx/plugin.rc.in is the Windows resource template file
83 used to add the plugin specific information as resources to the DLL.
84 No modifications are needed here.
85
86 3. Changes to existing Wireshark files
87
88 You will also need to change the following files:
89         configure.in
90         CMakeLists.txt
91         epan/Makefile.am
92         Makefile.am
93         packaging/nsis/Makefile.nmake
94         packaging/nsis/wireshark.nsi
95         plugins/Makefile.am
96         plugins/Makefile.nmake
97
98 You might also want to search your Wireshark development directory for
99 occurrences of an existing plugin name, in case this document is out of
100 date with the current directory structure. For example,
101
102         grep -rl gryphon .
103
104 could be used from a shell prompt.
105
106 3.1  Changes to plugins/Makefile.am
107
108 The plugins directory contains a Makefile.am.  You need to change the
109 SUBDIRS directive to reflect the addition of your plugin:
110
111 SUBDIRS = $(_CUSTOM_SUBDIRS_) \
112         ...
113         gryphon \
114         irda \
115         xxx \
116
117 3.2 Changes to plugins/Makefile.nmake
118
119 In plugins/Makefile.nmake you need to add to the PLUGINS_LIST  
120 (in alphabetical order) the name of your dissector (actually:
121 the name of the plugins sub-directory which contains your dissector).
122
123 3.3 Changes to the top level Makefile.am
124
125 Add your plugin (in alphabetical order) to the plugin_ldadd:
126
127 if HAVE_PLUGINS
128
129 plugin_ldadd = \
130         ...
131         -dlopen plugins/gryphon/gryphon.la      \
132         -dlopen plugins/irda/irda.la    \
133         -dlopen plugins/xxx/xxx.la      \
134         ...
135
136 3.4  Changes to the top level configure.in
137
138 You need to add your plugins Makefile (in alphbetical order) to the AC_OUTPUT
139 rule in the configure.in
140
141 AC_OUTPUT(
142   ...
143   plugins/gryphon/Makefile
144   plugins/irda/Makefile
145   plugins/xxx/Makefile
146   ...
147   ,)
148
149 3.5  Changes to epan/Makefile.am
150
151 Add the relative path of your plugin (in alphbetical order) to plugin_src:
152
153 plugin_src = \
154         ...
155         ../plugins/gryphon/packet-gryphon.c \
156         ../plugins/irda/packet-irda.c \
157         ../plugins/xxx/packet-xxx.c \
158         ...
159
160 3.6  Changes to CMakeLists.txt
161
162 Add your plugin (in alphabetical order) to the PLUGIN_SRC_DIRS:
163
164 if(ENABLE_PLUGINS)
165         ...
166         set(PLUGIN_SRC_DIRS
167                 ...
168                 plugins/gryphon
169                 plugins/irda
170                 plugins/xxx
171                 ...
172
173 3.7  Changes to the installers
174
175 If you want to include your plugin in an installer you have to add lines
176 in the NSIS installer Makefile.nmake and wireshark.nsi files.
177
178 For the NSIS installer:
179
180         Add ../../plugins/xxx/xxx.dll to the list of plugins for the
181         PLUGINS variable in packaging/nsis/Makefile.nmake.
182
183         Add
184
185                 File "..\..\plugins\xxx\xxx.dll"
186
187         to the list of "File" statements in the "Dissector Plugins"
188         section in packaging/nsis/wireshark.nsi.
189
190 The U3 and PortableApps installers build their manifests, including plugins,
191 from packaging/nsis/wireshark.nsi via the packaging/ws-manifest.pl script.
192
193 4. Development and plugins on Unix
194
195 Plugins make some aspects of development easier and some harder.
196
197 The first thing is that you'll have to run autogen.sh and configure
198 once more to setup your build environment.
199
200 The good news is that if you are working on a single plugin
201 then you will find recompiling the plugin MUCH faster than
202 recompiling a dissector and then linking it back into Wireshark.
203
204 The bad news is that Wireshark will not use the plugins unless the
205 plugins are installed in one of the places it expects them to find.
206
207 One way of dealing with this problem is to set an environment variable
208 when running Wireshark: WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1.
209
210 Another way to deal with this problem is to set up a working root for
211 wireshark, say in $HOME/build/root and build wireshark to install
212 there
213
214 ./configure --prefix=${HOME}/build/root;make install
215
216 then subsequent rebuilds/installs of your plugin can be accomplished
217 by going to the plugins/xxx directory and running
218
219 make install
220
221 5. Update "old style" plugins
222
223 5.1 How to update an "old style" plugin (using plugin_register and
224     plugin_reg_handoff functions).
225
226 The plugin registration has changed with the extension of the build
227 scripts. These now generate the additional code needed for plugin
228 encapsulation in plugin.c. When using the new style build scripts,
229 stips the parts outlined below:
230
231     o Remove the following include statements:
232
233         #include <gmodule.h>
234         #include "moduleinfo.h"
235
236     o Removed the definition:
237
238         #ifndef ENABLE_STATIC
239         G_MODULE_EXPORT gchar version[] = VERSION;
240         #endif
241
242     o Move relevant code from the blocks and delete these functions:
243
244         #ifndef ENABLE_STATIC
245         plugin_reg_handoff()
246         ....
247         #endif
248
249         #ifndef ENABLE_STATIC
250         plugin_register()
251         ....
252         #endif
253
254 This will leave a clean dissector source file without plugin specifics.
255
256 5.2 How to update an "old style" plugin (using plugin_init function)
257
258 The plugin registering has changed between 0.10.9 and 0.10.10; everyone
259 is encouraged to update their plugins as outlined below:
260
261     o Remove following include statements from all plugin sources:
262
263         #include "plugins/plugin_api.h"
264         #include "plugins/plugin_api_defs.h"
265
266     o Remove the init function.
267
268     o Add a new Makefile.common file with the lists of source files and
269       headers.
270
271     o Change the Makefile.am and Makefile.nmake files to match those of
272       the DOCSIS plugin.
273
274 ----------------
275
276 Ed Warnicke <hagbard@physics.rutgers.edu>
277 Guy Harris <guy@alum.mit.edu>
278
279 Derived and expanded from the plugin section of README.developers
280 which was originally written by
281
282 James Coe <jammer@cin.net>
283 Gilbert Ramirez <gram@alumni.rice.edu>
284 Jeff Foster <jfoste@woodward.com>
285 Olivier Abad <oabad@cybercable.fr>
286 Laurent Deniel <laurent.deniel@free.fr>
287 Jaap Keuter <jaap.keuter@xs4all.nl>