Change return value checking to the true meaning of the spec:
[obnox/wireshark/wip.git] / README.win32
1 $Id$
2
3 Installing Ethereal, Tethereal, and Editcap on Win32
4 ====================================================
5 These are the instructions for installing Ethereal
6 from the installation executable that is provided on
7 the Ethereal website at:
8
9 http://www.ethereal.com/distribution/win32
10
11 and any of its mirrors.
12
13 The installation package allows you to install:
14
15         o Ethereal - the GUI version
16         o Tethereal - the console, line-mode version
17         o Editcap - a console, line-mode utility to convert
18           capture files from one format to another.
19           (The same functions are available in Ethereal)
20         o Text2Pcap - a console, line-mode utility to generate 
21           a capture file from an ASCII hexdump of packets
22         o Mergecap - a console, line-mode utility to merge two 
23           capture files into one
24
25 Additionally, the installation package contains a "plugins"
26 option, which installs some additional dissector plugins
27 for use with Ethereal and Tethereal.
28
29 All binaries in Ethereal package are now built with debugging
30 information embedded. If you are experiencing a crash when running
31 Ethereal or other binaries, Dr. Watson or your debugger
32 can use the information embedded in the binary to provide useful 
33 information to the Ethereal developers that will help them pinpoint 
34 the problem. 
35
36 In the past, two versions of Ethereal binaries were published -- a
37 version that could capture packets and a version which could not.
38 The latter is useful if you're only reading files produced by
39 another product (e.g., a sniffer, firewall, or intrustion detection system)
40 and did not wish to install WinPcap, the library Ethereal uses
41 to capture packets on Win32 platforms.
42
43 As of WinPcap 2.1, all the WinPcap libraries have been released as DLLs. 
44 This means that Ethereal can detect the presence of WinPcap at run time,
45 which means that only one version of the Ethereal binaries needs to be
46 shipped.
47
48 If you don't want to capture packets, just install the Ethereal
49 package. If you do want to capture packets, install Ethereal *and*
50 install the latest non-beta version of WinPcap, available from:
51
52         http://winpcap.polito.it/
53
54 and mirrored at
55
56         http://winpcap.mirror.ethereal.com/
57
58 and
59
60         http://www.mirrors.wiretapped.net/security/packet-capture/winpcap/
61
62 If you already have an earlier version of WinPcap installed, you need to
63 un-install it and install the latest version.  If the older version is
64 WinPcap 2.0 or 2.02, and you have other applications that use the older
65 version , you will have to decide which applications to keep, since
66 WinPcap 2.0/2.02 and later versions cannot be installed on the same
67 system at the same time.
68
69 If Ethereal is not capturing packets and you have WinPcap installed, you
70 can test your WinPcap installation by installing WinDump (tcpdump for
71 Windows) ported by the same folks who make WinPcap.  It's at:
72
73         http://windump.polito.it/
74
75 and mirrored at
76
77         http://windump.mirror.ethereal.com/
78
79 and
80
81         http://www.mirrors.wiretapped.net/security/packet-capture/windump/
82
83 They also make Analyzer, a GUI sniffer for Win32:
84
85         http://analyzer.polito.it/
86
87 The rest of this documentation is only interesting if
88 you want to compile Ethereal yourself.
89
90
91 Compiling the Ethereal distribution from source
92 ===============================================
93
94 Developer's Guide
95 -----------------
96 You can find a comprehensive guide how to develop Ethereal in the 
97 Developer's Guide, which you can find (and much more info) at: 
98
99 http://wiki.ethereal.com/Development
100
101 The guide contains detailed information how to setup the development 
102 environment and it's usage.
103
104 Compilers
105 ---------
106 MS Visual C++ Version 6
107 This is the common compiler used for building Ethereal on win32.
108
109 If you've downloaded an Ethereal source tarball and unpacked it, then,
110 before you do any build, you must do
111
112         nmake -f makefile.nmake distclean
113
114 to get rid of files included in the source distribution that are built
115 for UN*X (so that the source distribution can be compiled on UN*X
116 without requiring tools such as Flex) and that won't compile on Windows
117 as generated.
118
119 You must also do that if you've built for UN*X in the same directory
120 tree, regardless of whether you are building from a source tarball or
121 from the Subversion tree.
122
123 You do not have to do this if you're directly building from the
124 Subversion tree, as long as you haven't done a UN*X build in the same
125 directory.
126
127 MS Visual C++ Version 7 / VC.NET
128 Currently unsupported for two reasons:
129 -the licence agreement does NOT allow you to compile GPL code.
130 -there are serious problems in using DLL's compiled with MS VC6.
131 See section "Problems with MS Visual C++ Version 7 / VC.NET" below.
132
133 Cygwin GCC
134 Ethereal can entirely be built with cygwin GCC. However the built binaries will
135 only run in a cygwin environment, so they are not standalone Win32 applications.
136 It is however not excluded that native Win32 code can be compiled on cygwin GCC
137 but you then have to use -mms-bitfields as a strict minimum and probably
138 -mno-cygwin or a similar compiler flag too.
139 See section below for instructions.
140
141
142 Automated library download
143 --------------------------
144 Before using the automated download, be sure to edit the config.nmake file 
145 to suit your needs. Especially have a look at the ETHEREAL_LIBS setting.
146 However, the defaults should be working well for a first start.
147
148 If you've installed Microsoft Visual C++ (MSVC), you can run:
149
150 nmake -f makefile.nmake setup 
151
152 This will first check the availability of all required tools and then uses 
153 the tool wget to download each package file (together around 30MB!) from the 
154 server location at:
155
156         http://anonsvn.ethereal.com/ethereal-win32-libs/trunk/packages/
157
158 and unpack it in the $ETHEREAL_LIBS directory. 
159
160 If you have problems downloading the files, you might be connected to the 
161 internet through a proxy/firewall. In this case see the wget documentation 
162 to configure wget accordingly.
163
164
165 Required libraries
166 ------------------
167 If the automated library download finished sucessfully, you should have all
168 libraries on your machine at the right places. So you don't have to read this,
169 unless you are interested which libraries are used.
170
171 You'll need the development packages for GLIB, GTK+, iconv, gettext,
172 WinPcap, Net-SNMP, and optionally ADNS, PCRE and zlib. The development 
173 packages contain header files and stub libraries to link against.  
174
175 PRECOMPILED VERSIONS OF ALL OF THESE PACKAGES ARE AVAILABLE AT:
176
177         http://anonsvn.ethereal.com/ethereal-win32-libs/trunk/packages/
178
179
180 The GLIB, GTK+, iconv, gettext packages for win32 can be found at the home 
181 page for the GTK+ for Win32 project:
182
183         http://www.gimp.org/~tml/gimp/win32 or the mirror
184         http://www.iki.fi/tml/gimp/win32/
185
186 The Net-SNMP package for win32 is available at its homepage:
187
188         http://
189
190 The WinPcap package is available at its homepage:
191
192         http://winpcap.polito.it/ or the mirror
193         http://www.wiretapped.net/security/packet-capture/winpcap/default.htm
194
195 The optional ADNS package for win32 is available at its homepage:
196
197         http://adns.jgaa.com/
198
199 The optional PCRE package (Perl Compatible Regular Expressions) for win32 is 
200 available at its homepage:
201
202         http://gnuwin32.sourceforge.net/packages/pcre.htm
203
204 The optional zlib package for win32 is available at its homepage:
205
206         http://www.gzip.org/zlib/
207
208
209 By default, the build process looks for these packages in
210 C:\ethereal-win32-libs.  You can place them in a different directory, but
211 you must update the ETHEREAL_LIBS variable in config.nmake accordingly.
212
213 The following lists the packages needed to compile Ethereal and the default
214 locations where to unpack them, when the above method isn't used.
215
216     Package                               Default Location
217     -------                               ----------------
218     glib-2.4.7.zip                        C:\ethereal-win32-libs\glib
219     glib-dev-2.4.7.zip                    C:\ethereal-win32-libs\glib
220     gtk+-1.3.0-20030717.zip               C:\ethereal-win32-libs\gtk+
221     gtk+-dev-1.3.0-20030115.zip           C:\ethereal-win32-libs\gtk+
222     libiconv-1.9.1.bin.woe32.zip          C:\ethereal-win32-libs\libiconv-1.9.1.bin.woe32
223     gettext-runtime-0.13.1.zip            C:\ethereal-win32-libs\gettext-runtime-0.13.1
224     net-snmp-5.2.1.2.zip                  C:\ethereal-win32-libs
225     wpdpack_3_0.zip                       C:\ethereal-win32-libs
226
227 and optional:
228
229     adns-1.0-win32-04.zip                 C:\ethereal-win32-libs
230     pcre-4.4.zip                          C:\ethereal-win32-libs
231     zlib123-dll.zip                       C:\ethereal-win32-libs\zlib123-dll
232
233 (to use the default locations, the directories in question should be
234 created, and each zip file should be unpacked into the corresponding
235 directory).  If you only want to change the C:\ethereal-win32-libs
236 part, you just change the setting of ETHEREAL_LIBS in config.nmake; if
237 you want to change subdirectories, you'll have to change the individual
238 item for a package.  (Note that some zip files create the subdirectory -
239 those zip files just have C:\ethereal-win32-libs in the list above - so
240 if you don't want the package to be in that subdirectory, you'd have to
241 rename the directory.)
242
243 The gettext runtime package provides intl.dll, which is needed by
244 GLib 2.4.7.
245
246
247 Compiling the Ethereal distribution using GTK+2
248 -----------------------------------------------
249
250 The more recent version 2 of the GTK+ can be used to compile 
251 Ethereal with, but is still considered beta.
252
253 GTK+2 will look better in various ways, especially for WIN32 users.
254
255 You can get the required libraries from:
256
257 http://www.ethereal.com/distribution/win32/development/gtk2
258
259 or (like the GTK+1 libraries from the GTK+ for Win32 project):
260
261 http://www.gimp.org/~tml/gimp/win32/downloads.html
262
263 If you want to try a build with GTK+2.x these Extra libraries are needed 
264
265     Package                               Default Location
266     -------                               ----------------
267     gtk+-2.4.14.zip                       C:\ethereal-win32-libs\gtk2
268     gtk+-dev-2.4.14.zip                   C:\ethereal-win32-libs\gtk2
269     pango-1.4.1.zip                       C:\ethereal-win32-libs\gtk2   
270     pango-dev-1.4.1.zip                   C:\ethereal-win32-libs\gtk2
271     atk-1.6.0.zip                         C:\ethereal-win32-libs\gtk2   
272     atk-dev-1.6.0.zip                     C:\ethereal-win32-libs\gtk2
273
274 and optional:
275
276     gtk-wimp-0.7.0-bin.zip                C:\ethereal-win32-libs\gtk-wimp
277
278 Be sure to set GTK2_DIR in config.nmake correct, to be able to compile.
279
280 Running your freshly compiled Ethereal
281 --------------------------------------
282
283 Make sure the glib and gtk DLL's are in your path or you use a directory 
284 where all required DLL's and the exe files reside.- i.e., that your
285 path includes the directory (folder) or directories (folders) in which
286 those DLLs are found - when you run Ethereal.
287
288 Note the wiretap*.dll must be in your path as well and if wiretap is changed
289 be sure to put the new one in your path.
290
291 Plugins (gryphon.dll and mgcp.dll) can go in:
292         <Ethereal installation directory>\plugins\<version>
293
294 Where <version> is the version number, without brackets.  For example,
295 if you have Ethereal 0.10.12 installed in the default location, plugins
296 will reside in C:\Program Files\Ethereal\plugins\0.10.12
297
298 Yes, the location of plugins needs to be more flexible.
299
300 Instructions for MS Visual C++
301 ----------------------------
302 Modify the config.nmake file in the top directory of the Ethereal source
303 tree to work for your local configuration; if you don't have Python,
304 comment out the line that defines PYTHON, otherwise set it to refer to
305 the pathname of your Python interpreter executable.  You should not have
306 to modify any other Makefile.
307
308 Note that perl is needed to build the documentation, the lines in config.nmake
309
310 POD2MAN=$(SH) pod2man
311 POD2HTML=$(SH) pod2html
312
313 requires Cygwin bash and perl to work.
314
315 Many of the file and directory names used in the build process go past
316 the old 8.3 naming limitations.  As a result, at least on Windows NT 4.0,
317 Windows 2000, Windows XP, and Windows .NET Server, you should use the
318 newer "cmd.exe" command interpreter instead of the old "command.com",
319 as the "command.com" on Windows 2000, at least, can't handle non-8.3
320 directory names.  (It may be that the "command.com" in Windows 95, Windows
321 98, and Windows Me, as it's the only command interpreter in those systems,
322 can handle those directories.  If not, it may not be possible to build
323 Ethereal from the command line on those versions of Windows.)
324
325 Be sure that your command-line environment is set up to compile
326 and link with MSVC++. When installing MSVC++, you can have your
327 system's environment set up to always allow compiling from the
328 command line, or you can invoke the vcvars32.bat script, which can
329 usually be found in the "VC98\Bin" subdirectory of the directory in
330 which Visual Studio was installed.
331
332 The first time you build Ethereal, run "nmake -f makefile.nmake distclean" 
333 in the top-level Ethereal source directory to make sure that the "config.h"
334 files will be reconstructed from the "config.h.win32" files.  (If, for
335 example, you have "config.h" files left over from a Unix build, a
336 Windows build will fail.)
337
338 In the ethereal directory, type "nmake -f makefile.nmake". It will
339 recurse into the subdirectories as appropriate.
340
341 Some generated source is created by traditionally "Unix-ish" tools.
342
343 If you are building from an official distribution, these files are
344 already generated, although they were generated on a Unix-compatible
345 system.  In most cases, the generated files can be used when building on
346 Windows, but the files listed below as being generated by Flex can be
347 used when building on Windows only when generated by a Windows version
348 of Flex, so you will need a Windows version of Flex to do a Windows
349 build.  Those generated files are removed by 
350 "nmake -f makefile.nmake distclean", to make sure that versions left over 
351 from a Unix build aren't used.
352
353 If you are building from a modified version of an official distribution,
354 and you modified any of the source files listed below, you will need the
355 tool(s) that generate output from those source files.
356
357 If building from a CVS image, you'll need all the tools to generate C
358 source.
359
360 The "special" files and their requisite tools are:
361
362 Source                          Output                  Tool
363 ------                          ------                  ----
364 config.h.win32                  config.h                sed
365 epan/config.h.win32             epan/config.h           sed
366 image/ethereal.rc.in            image/ethereal.rc       sed
367 image/tethereal.rc.in           image/tethereal.rc      sed
368 image/editcap.rc.in             image/editcap.rc        sed
369 image/mergecap.rc.in            image/mergecap.rc       sed
370 image/text2pcap.rc.in           image/text2pcap.rc      sed
371 wiretap/config.h.win32          wiretap/config.h        sed
372 epan/dfilter/dfilter-scanner.l  epan/dfilter/*.c        Flex
373 text2pcap-scanner.l             *.c                     Flex
374 wiretap/ascend-scanner.l        *.c                     Flex
375 wiretap/ascend-grammar.y        *.c,*.h                 Bison/Yacc
376 ncp2222.py                      packet-ncp2222.c        Python
377
378 make-reg-dotc, packet*.c        register.c              Bash + grep + sed
379 or
380 make-reg-dotc.py, packet*.c     register.c              Python
381
382 make-tapreg-dotc, tap-*.c       tethereal-tap-register.c
383                                                         Bash + grep + sed
384 make-tapreg-dotc, tap files     gtk/ethereal-tap-register.c
385     in the gtk subdirectory                             Bash + grep + sed
386
387 The Makefile.nmake supplied with the Ethereal distribution will, if
388 PYTHON is defined in config.nmake, attempt to make register.c with
389 Python, since it is much much much faster than the shell version.  The
390 reason it is faster is because the shell version launches multiple
391 processes (grep, sed) for each source file, multiple times.  The Python
392 script is one process.  This matters a lot on Win32.
393
394 If you have a Unix system handy, you can first build on Unix to create
395 most of the source files that these tools make, then run the build on
396 Windows.  That will avoid the need for these tools on your Windows
397 computer.  This won't work for the files in the "image" directory,
398 however, as those aren't built on Unix - they're only for Windows
399 builds.  It also won't work for the "config.h" files; whilst those are
400 built for Unix, they're specific to the platform on which you're
401 building, and the "config.h" files constructed for a Unix build will not
402 work with a Windows build.  In addition, it won't work for the files
403 generated by Flex, as, for a Windows build, those have to be generated
404 by a Windows version of Flex.
405
406 Most of those tools are available for Win32 systems as part of the
407 Cygwin package:
408
409         http://www.cygwin.com/
410
411 After installing them, you will probably have to modify the config.nmake
412 file to specify where the Cygwin binaries are installed.
413 Note that installing cygwin with the "Default Text File Type" set to DOS 
414 may break the compilation because all the required tools may not be found. 
415 Set this parameter to UNIX instead.
416
417 Python for Win32 is available from:
418
419         http://www.python.org/
420
421
422 Build an (NSIS based) installer
423 -------------------------------
424
425 If you want to build your own installer, you need to get NSIS from:
426
427 http://nsis.sourceforge.net/home/
428
429 After installing it, you will probably have to modify the config.nmake
430 file to specify where the NSIS binaries are installed and wether to use the modern UI or not.
431 You will need NSIS version 2 or higher, to build an installer with the modern user interface,
432 and for a much smaller installer (using the lzma compression).
433
434 In the ethereal directory, type "nmake -f makefile.nmake packaging" to build the installer. 
435 Please be patient while the compression is done, it will take some time even on fast machines.
436
437 You will hopefully now see something like ethereal-setup-0.10.12.exe in the dir packaging/nsis.
438
439
440 Installing GTK-Wimp
441 -------------------
442
443 GTK-Wimp can be used to get a native Look-and-Feel on WinXP machines, 
444 especially with the new "coloured" WinXP theme. It will only take effect
445 together with the GTK2 version of Ethereal. 
446
447 No changes to the Ethereal sources are needed, GTK-Wimp simply changes the 
448 way GTK2 displays the widgets (by changing the GTK2 default theme).
449
450 GTK-Wimp will be automatically installed if you use the official Ethereal Setup. 
451 In this case, the files mentioned below are already existing at the appropriate 
452 places.
453
454 If GTK-Wimp wasn't installed, you can install it yourself (however, this 
455 method is error prone and therefore no longer recommended): 
456
457 1. Go to http://gtk-wimp.sourceforge.net/
458 2. Download the ZIP archive containing the library and the theme
459 3. Locate the installation directory of Ethereal (C:\Program Files\Ethereal)
460 4. Create a subdirectory 'share\themes\Default\gtk-2.0'
461 5. Drop the file 'gtkrc' in 'share\themes\Default\gtk-2.0'
462 6. Create a subdirectory named 'lib\gtk-2.0\2.4.0\engines'
463 7. Drop the 'libwimp.dll' library in 'lib\gtk-2.0\2.4.0\engines'
464
465 When you're finished, you should have:
466
467 C:\Program Files\Ethereal\lib\gtk-2.0\2.4.0\engines\libwimp.dll
468 C:\Program Files\Ethereal\share\themes\Default\gtk-2.0\gtkrc
469
470 After (re-)starting Ethereal, you should now see it's widgets in the modern 
471 WinXP style on your screen.
472
473
474 Problems with MS Visual C++ Version 7 / VC.NET
475 ----------------------------------------------
476
477 Beside licensing problems with these compilers, there are known problems
478 with DLL's.  If Ethereal is compiled with MSVC Version 7, there are
479 conflicts in the MSVCRT DLL's, The MSVCRT.DLL includes the standard
480 ANSI-C functions like fopen, malloc, etc..  MSVCRT.DLL is shipped with
481 the MSVC 6 compiler versions, and dynamically linked to prebuild DLL's
482 like the one's for gtk, glib and such.  The MSVC 7 compiler now uses and
483 ships MSVCRT71.DLL with it, which is incompatible with MSVCRT.DLL.  So
484 when using the MSVC 7 compiler, some parts of the Ethereal code uses
485 MSVCRT71.DLL, and some others (indirectly from e.g. the gtk DLL) will
486 use MSVCRT.DLL.  This will result in incorrect file handles and such.
487
488 The same problem seems to apply on all MSVC compilers after version 6, like the
489 "Microsoft Visual C++ Toolkit 2003".
490
491
492 Instructions for Cygwin
493 -----------------------
494
495 It is possible to build Ethereal under Cygwin using their version
496 of XFree86. References:
497  - http://www.ethereal.com/lists/ethereal-dev/200205/msg00107.html
498  - http://www.ethereal.com/lists/ethereal-dev/200302/msg00026.html
499  
500 To get it running, execute the following steps:
501
502 1. Install the required cygwin packages (compiler, scripting, X, zlib)
503    with the CygWin setup.exe tool (http://www.cygwin.com/).
504    You need the base Xfree86 support plus the X headers package in order
505    to be able to compile the gtk+ package.
506
507 2. Download glib-1.2.10 and gtk+-1.2.10 from a mirror of www.gnome.org.
508
509 3. Retrieve the patches for glib-1.2.10 and gtk+-1.2.10 from
510    http://homepage.ntlworld.com/steven.obrien2/
511
512  + glib-1.2.10
513    http://homepage.ntlworld.com/steven.obrien2/ (URL cont'd on next line)
514           /libs/patches/glib-1.2.10-cygwin.patch
515
516  + gtk+-1.2.10
517    http://homepage.ntlworld.com/steven.obrien2/ (URL cont'd on next line)
518           /libs/patches/gtk+-1.2.10-cygwin.patch
519
520 4. Compile and install both packages after patching (see instructions
521    at the bottom of http://homepage.ntlworld.com/steven.obrien2/):
522
523    Set the path:
524
525      $ PATH=/opt/gnome/bin:/usr/X11R6/bin:$PATH
526
527    For glib-1.2.10:
528    
529      $ cd glib-1.2.10
530      $ patch -p1 < /path/to/glib-1.2.10-cygwin.patch
531      $ CFLAGS=-O2 ./configure --prefix=/opt/gnome --with-threads=posix
532      $ make
533      $ make check
534      $ make install
535
536    For gtk+-1.2.10:
537
538      $ cd gtk+-1.2.10
539      $ patch -p1 < /path/to/gtk+-1.2.10-cygwin.patch
540      $ CFLAGS=-O2 ./configure --prefix=/opt/gnome
541      $ make
542      $ make check
543      $ make install
544
545 5. Patch Makefile.am in <ethereal-src>/gtk/Makefile.am by
546    removing "ethclist.c" from the dependencies.
547
548    This patch is required since the private GTK+ clist widget
549    (was required for earlier versions of GTK+ but prevents Ethereal
550    from running with cygwin).
551
552 6. Configure and make Ethereal:
553
554    Set the path (if this has not yet been done earlier)
555
556      $ PATH=/opt/gnome/bin:$PATH
557
558      $ ./autogen.sh
559      $ ./configure --config-cache --without-pcap
560      $ make
561
562 7. Start X
563
564      $ sh /usr/X11R6/bin/startxwin.sh
565
566     Or you can start it from C:\cygwin\usr\X11R6\bin\startxwin.bat 
567
568 8. Run ethereal (add /opt/gnome/bin to $PATH if this is not yet done)
569
570      $ <ethereal-src>/ethereal
571
572     And voila! Behold the mighty sniffer in all its glory!
573
574     Note that the plugin dissectors must be installed (make install) if you
575     want to use them. Note also that running "make install" produces lots of
576     output to the console; this is normal.
577
578 Note: Compiling Ethereal under cygwin takes a lot of time, because the
579 generation of 'register.c' takes ages. If you only edit one dissector and
580 you know what you're doing, it is acceptable to uncomment the generation
581 of the file 'register.c' in Makefile. Look for the 'register.c' target:
582
583     register.c: $(DISSECTOR_SRC) $(srcdir)/make-reg-dotc
584         @echo Making register.c
585         # @$(srcdir)/make-reg-dotc register.c $(srcdir) $(DISSECTOR_SRC)
586         @echo Skipping generation of register.c
587
588 Of course, you need to generate the 'register.c' file at least once.
589
590 Note: You can also capture packets on a cygwin built Ethereal. You then have
591 to unpack the WinPCap development package, install the files in lib/ and
592 include/ in say /usr/lib and /usr/include (they must be in the search path of
593 the compiler and linker, otherwise you have to specify the configure option
594 --with-pcap=/location/to/pcap so the packet capture functionality can be used.
595 In order to run Ethereal, you have to add the .dll files in a directory in the
596 PATH (e.g., /bin).
597 Should you want packet capturing enabled in the cygwin build, then you have to
598 remove --without-pcap from step 6.