aboutsummaryrefslogtreecommitdiffstats
path: root/doc/README.plugins
blob: 6b015a34dd5c4d50c0a12d1f93219f842c13afc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
$Id$

1. Plugins

Writing a "plugin" dissector is not very different from writing a
standard one.  In fact all of the functions described in
README.developer can be used in the plugins exactly as the are used in
standard dissectors.

(Note, however, that not all OSes on which Wireshark runs can support
plugins.)

If you've chosen "xxx" as the name of your plugin (typically, that would
be a short name for your protocol, in all lower case), the following
instructions tell you how to implement it as a plugin.  All occurrences
of "xxx" below should be replaced by the name of your plugin.

2. The directory for the plugin, and its files

The plugin should be placed in a new plugins/xxx directory which should
contain minimally the following files:

AUTHORS
COPYING
ChangeLog
Makefile.am
Makefile.common
Makefile.nmake
moduleinfo.h
moduleinfo.nmake
plugin.rc.in
The source files and header files for your dissector

Examples of these files can be found in plugins/agentx.

2.1 AUTHORS, COPYING, and ChangeLog

The AUTHORS, COPYING, and ChangeLog are the standard sort of GPL project
files.

2.2 Makefile.am

For your plugins/xxx/Makefile.am file, see the corresponding file in
plugins/agentx. Replace all occurrences of "agentx" in those files with "xxx".

2.3 Makefile.common

Your plugins/xxx/Makefile.common should list the source files for your
dissector in the DISSECTOR_SRC variable, and all supporting source files
in the DISSECTOR_SUPPORT_SRC variable.
The header files for your dissector, if any, must be listed in the
DISSECTOR_INCLUDES variable. The DISSECTOR_INCLUDES variable should not
include moduleinfo.h.

2.4 Makefile.nmake

For your plugins/xxx/Makefile.nmake file, see the corresponding file in
plugins/agentx. No modifications are needed here.

2.5 moduleinfo.h

Your plugins/xxx/moduleinfo.h file is used to set the version information
for the plugin.

2.6 moduleinfo.nmake

Your plugins/xxx/moduleinfo.nmake is used to set the version information
for building the plugin. Its contents should match that in moduleinfo.h

2.7 plugin.rc.in

Your plugins/xxx/plugin.rc.in is the Windows resource template file
used to add the plugin specific information as resources to the DLL.
No modifications are needed here.

3. Changes to existing Wireshark files

You will also need to change the plugins/Makefile.am, the
plugins/Makefile.nmake, the toplevel Makefile.am file, and the
toplevel configure.in file.

3.1  Changes to plugins/Makefile.am

The plugins directory contains a Makefile.am.  You need to change the
SUBDIRS directive to reflect the addition of your plugin:

SUBDIRS = \
	gryphon \
	mgcp \
	xxx


3.2 Changes to plugins/Makefile.nmake

To the Makefile.nmake you need to add your plugin to the all: rule

all: \
	gryphon \
	mgcp \
	xxx

then add a rule for your plugin:

xxx:
	cd xxx
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
	cd ..

and add to the clean rules support for cleaning up after your
plugin:

clean:
	cd gryphon
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
	cd ../mgcp
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
	cd ..
	cd xxx
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
	cd ..


distclean: clean
	cd gryphon
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
	cd ../mgcp
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
	cd ..
	cd xxx
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
	cd ..


maintainer-clean: clean
	cd gryphon
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
	cd ../mgcp
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
	cd ..
	cd xxx
	$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
	cd ..

Finally add a copy command to install-plugins rule:

        xcopy mgcp\*.dll $(VERSION) /d
        xcopy xxx\*.dll $(VERSION) /d

3.3 Changes to the top level Makefile.am

Unfortunately there are quite some several places in the top level
Makefile.am that need to be altered for adding a plugin.

Add your plugin to the plugin_libs and plugin_ldadd:

plugin_libs = \
        plugins/gryphon/gryphon.la \
        plugins/mgcp/mgcp.la    \
        plugins/xxx/xxx.la

if ENABLE_STATIC
plugin_ldadd = (plugin_libs)

else          # ENABLE_STATIC
plugin_ldadd = \
        "-dlopen" self  \
        "-dlopen" plugins/gryphon/gryphon.la \
        "-dlopen" plugins/mgcp/mgcp.la \
        "-dlopen" plugins/xxx/xxx.la

3.4  Changes to top level configure.in

You need to add your plugins Makefile to the AC_OUTPUT rule in the
configure.in

AC_OUTPUT(
  Makefile
  doc/Makefile
  gtk/Makefile
  packaging/Makefile
  packaging/nsis/Makefile
  packaging/rpm/Makefile
  packaging/rpm/wireshark.spec
  packaging/svr4/Makefile
  packaging/svr4/checkinstall
  packaging/svr4/pkginfo
  plugins/Makefile
  plugins/gryphon/Makefile
  plugins/mgcp/Makefile
  plugins/xxx/Makefile
  tools/Makefile
  tools/lemon/Makefile
  ,)

3.5  Changes to the installers

If you want to include your plugin in an installer you have to add lines
in the NSIS installer Makefile.nmake and wireshark.nsi files, and the U3
installer makefile.nmake file.

For the NSIS installer:

	Add ../../plugins/xxx/xxx.dll to the list of plugins for the
	PLUGINS variable in packaging/nsis/Makefile.nmake.

	Add

		File "..\..\plugins\xxx\xxx.dll"

	to the list of "File" statements in the "Dissector Plugins"
	section in packaging/nsis/wireshark.nsi.

For the U3 installer:

	Add

		$(COPY) $(TOPDIR)\plugins\xxx\xxx.dll $(DEVICE)\plugins\$(VERSION) $(COPY_FLAGS)

	to the list of commands for the "distribution" target in
	packaging/u3/win32/makefile.nmake.

4. Development and plugins on Unix

Plugins make some aspects of development easier and some harder.

The first thing is that you'll have to run autogen.sh and configure
once more to setup your build environment.

The good news is that if you are working on a single plugin
then you will find recompiling the plugin MUCH faster than
recompiling a dissector and then linking it back into Wireshark.

The bad news is that Wireshark will not use the plugins unless the
plugins are installed in one of the places it expects them to find.

One way of dealing with this problem is to set an environment variable
when running Wireshark: WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1.

Another way to deal with this problem is to set up a working root for
wireshark, say in $HOME/build/root and build wireshark to install
there

./configure --prefix=${HOME}/build/root;make install

then subsequent rebuilds/installs of your plugin can be accomplished
by going to the plugins/xxx directory and running

make install

5. Update "old style" plugins

5.1 How to update an "old style" plugin (using plugin_register and
    plugin_reg_handoff functions).

The plugin registration has changed with the extension of the build
scripts. These now generate the additional code needed for plugin
encapsulation in plugin.c. When using the new style build scripts,
stips the parts outlined below:

    o Remove the following include statments:

        #include <gmodule.h>
        #include "moduleinfo.h"

    o Removed the definition:

        #ifndef ENABLE_STATIC
        G_MODULE_EXPORT gchar version[] = VERSION;
        #endif

    o Move relevant code from the blocks and delete these functions:

        #ifndef ENABLE_STATIC
        plugin_reg_handoff()
        ....
        #endif

        #ifndef ENABLE_STATIC
        plugin_register()
        ....
        #endif

This will leave a clean dissector source file without plugin specifics.

5.2 How to update an "old style" plugin (using plugin_init function)

The plugin registering has changed between 0.10.9 and 0.10.10; everyone
is encouraged to update their plugins as outlined below:

    o Remove following include statements from all plugin sources:

	#include "plugins/plugin_api.h"
	#include "plugins/plugin_api_defs.h"

    o Remove the init function.

    o Add a new Makefile.common file with the lists of source files and
      headers.

    o Change the Makefile.am and Makefile.nmake files to match those of
      the DOCSIS plugin.

----------------

Ed Warnicke <hagbard@physics.rutgers.edu>
Guy Harris <guy@alum.mit.edu>

Derived and expanded from the plugin section of README.developers
which was originally written by

James Coe <jammer@cin.net>
Gilbert Ramirez <gram@alumni.rice.edu>
Jeff Foster <jfoste@woodward.com>
Olivier Abad <oabad@cybercable.fr>
Laurent Deniel <laurent.deniel@free.fr>
Jaap Keuter <jaap.keuter@xs4all.nl>