Wireshark 0.99.7 User Guide

Wireshark Developer's Guide
24295 for Wireshark 0.99.7
Ulf Lamping,
Wireshark Developer's Guide:
24295 for Wireshark 0.99.7
by Ulf Lamping Copyright © 2004-2007 Ulf Lamping
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation.
All logos and trademarks in this document are property of their respective owner.

Table of Contents

Preface ............................................................................................................. viii
1. Foreword .............................................................................................. viii
2. Who should read this document? ................................................................. ix
3. Acknowledgements .................................................................................... x
4. About this document ................................................................................. xi
5. Where to get the latest copy of this document? .............................................. xii
6. Providing feedback about this document ..................................................... xiii
I. Wireshark Build Environment ............................................................................... 1
1. Introduction .............................................................................................. 2
1.1. Introduction ................................................................................... 2
1.2. What is Wireshark? ......................................................................... 3
1.3. Platforms Wireshark runs on ............................................................. 4
1.3.1. Unix ................................................................................... 4
1.3.2. Linux ................................................................................. 4
1.3.3. Microsoft Windows ............................................................... 5
1.4. Development and maintenance of Wireshark ........................................ 6
1.4.1. Programming language(s) used ................................................ 6
1.4.2. Open Source Software ........................................................... 6
1.5. Releases and distributions ................................................................. 8
1.5.1. Binary distributions ............................................................... 8
1.5.2. Source code distributions ....................................................... 8
1.6. Automated Builds (Buildbot) ............................................................. 9
1.6.1. Advantages .......................................................................... 9
1.6.2. What does the Buildbot do? .................................................... 9
1.7. Reporting problems and getting help ..................................................10
1.7.1. Website .............................................................................10
1.7.2. Wiki ..................................................................................10
1.7.3. FAQ ..................................................................................10
1.7.4. Other sources ......................................................................10
1.7.5. Mailing Lists ......................................................................10
1.7.6. Bug database (Bugzilla) ........................................................11
1.7.7. Reporting Problems ..............................................................11
1.7.8. Reporting Crashes on UNIX/Linux platforms ............................12
1.7.9. Reporting Crashes on Windows platforms ................................12
2. Quick Setup .............................................................................................14
2.1. UNIX: Installation ..........................................................................14
2.2. Win32: Step-by-Step Guide ..............................................................15
2.2.1. Install Microsoft C compiler and Platform SDK .........................15
2.2.2. Install Cygwin .....................................................................15
2.2.3. Install Python ......................................................................16
2.2.4. Install Subversion Client .......................................................16
2.2.5. Install and Prepare Sources ....................................................16
2.2.6. Prepare cmd.exe ..................................................................17
2.2.7. Verify installed tools ............................................................17
2.2.8. Install Libraries ...................................................................18
2.2.9. Distclean Sources ................................................................18
2.2.10. Build Wireshark .................................................................18
2.2.11. Debug Environment Setup (XXX) .........................................19
2.2.12. Optional: Create User's and Developer's Guide ........................19
2.2.13. Optional: Create a Wireshark Installer ....................................19
3. Work with the Wireshark sources .................................................................21
3.1. Introduction ..................................................................................21
3.2. The Wireshark Subversion repository .................................................22
3.2.1. The web interface to the Subversion repository ..........................22
3.3. Obtain the Wireshark sources ...........................................................24
3.3.1. Anonymous Subversion access ...............................................24
3.3.2. Anonymous Subversion web interface .....................................24
iv
Wireshark Developer's Guide
3.3.3. Buildbot Snapshots ..............................................................24
3.3.4. Released sources .................................................................25
3.4. Update the Wireshark sources ...........................................................26
3.4.1. ... with Anonymous Subversion access .....................................26
3.4.2. ... from zip files ...................................................................26
3.5. Build Wireshark .............................................................................27
3.5.1. Unix ..................................................................................27
3.5.2. Win32 native ......................................................................27
3.6. Run generated Wireshark .................................................................29
3.7. Debug your generated Wireshark ......................................................30
3.7.1. Win32 native ......................................................................30
3.8. Make changes to the Wireshark sources ..............................................31
3.9. Contribute your changes ..................................................................32
3.9.1. What is a diff file (a patch)? ...................................................32
3.9.2. Generate a patch ..................................................................33
3.9.3. Some tips for a good patch .....................................................34
3.9.4. Code Requirements ..............................................................34
3.9.5. Sending your patch for inclusion .............................................35
3.10. Apply a patch from someone else ....................................................37
3.10.1. Using patch .......................................................................37
3.10.2. CVS diff (obsolete) ............................................................37
3.11. Add a new file to the Subversion repository .......................................39
3.12. Binary packaging ..........................................................................40
3.12.1. Debian: .deb packages .........................................................40
3.12.2. Red Hat: .rpm packages .......................................................40
3.12.3. Win32: NSIS .exe installer ...................................................40
4. Tool Reference .........................................................................................43
4.1. Introduction ..................................................................................43
4.2. Win32: Cygwin .............................................................................44
4.2.1. Add/Update/Remove Cygwin Packages ...................................44
4.3. GNU compiler toolchain (UNIX or Win32 Cygwin) .............................45
4.3.1. gcc (GNU compiler collection) ...............................................45
4.3.2. gdb (GNU project debugger) ..................................................45
4.3.3. ddd (GNU Data Display Debugger) .........................................45
4.3.4. make (GNU Make) ..............................................................46
4.4. Microsoft compiler toolchain (Win32 native) .......................................47
4.4.1. Toolchain Package Alternatives ..............................................47
4.4.2. Legal issues with MSVC > V6? ..............................................49
4.4.3. cl.exe (C Compiler) ..............................................................50
4.4.4. nmake.exe (Make) ...............................................................51
4.4.5. link.exe (Linker) ..................................................................51
4.4.6. C-Runtime "Redistributable" files ...........................................51
4.4.7. Windows (Platform) SDK .....................................................53
4.4.8. HTML Help ........................................................................53
4.4.9. Debugger ...........................................................................54
4.5. bash .............................................................................................55
4.5.1. UNIX or Win32 Cygwin: GNU bash .......................................55
4.5.2. Win32 native: - ...................................................................55
4.6. python ..........................................................................................56
4.6.1. UNIX or Win32 Cygwin: python ............................................56
4.6.2. Win32 native: python ...........................................................56
4.7. perl ..............................................................................................57
4.7.1. UNIX or Win32 Cygwin: perl ................................................57
4.7.2. Win32 native: perl ...............................................................57
4.8. sed ..............................................................................................58
4.8.1. UNIX or Win32 Cygwin: sed .................................................58
4.8.2. Win32 native: sed ................................................................58
4.9. yacc (bison) ..................................................................................59
4.9.1. UNIX or Win32 Cygwin: bison ..............................................59
4.9.2. Win32 native: bison .............................................................59
4.10. flex ............................................................................................60
4.10.1. UNIX or Win32 Cygwin: flex ..............................................60
4.10.2. Win32 native: flex ..............................................................60
v
Wireshark Developer's Guide
4.11. Subversion (SVN) client (optional) ..................................................61
4.11.1. UNIX or Win32 Cygwin: svn ...............................................61
4.11.2. Win32 native: svn ..............................................................61
4.12. Subversion (SVN) GUI client (optional) ...........................................62
4.12.1. UNIX or Win32 Cygwin: rapidSVN, subcommander ................62
4.12.2. Win32 native: TortoiseSVN .................................................62
4.13. diff (optional) ..............................................................................63
4.13.1. UNIX or Win32 Cygwin: GNU diff .......................................63
4.13.2. Win32 native: diff ..............................................................63
4.14. patch (optional) ............................................................................64
4.14.1. UNIX or Win32 Cygwin: patch ............................................64
4.14.2. Win32 native: patch ............................................................64
4.15. Win32: GNU wget (optional) ..........................................................65
4.16. Win32: GNU unzip (optional) .........................................................66
4.17. Win32: NSIS (optional) .................................................................67
5. Library Reference .....................................................................................69
5.1. Introduction ..................................................................................69
5.2. Binary library formats .....................................................................70
5.2.1. Unix ..................................................................................70
5.2.2. Win32: MSVC ....................................................................70
5.2.3. Win32: cygwin gcc ..............................................................70
5.3. Win32: Automated library download .................................................71
5.3.1. Initial download ..................................................................71
5.3.2. Update of a previous download ..............................................71
5.4. GTK+ / GLib / GDK / Pango / ATK / GNU gettext / GNU libiconv .........73
5.4.1. Unix ..................................................................................73
5.4.2. Win32 MSVC .....................................................................73
5.5. Net-SNMP (optional) ......................................................................74
5.5.1. Unix ..................................................................................74
5.5.2. Win32 MSVC .....................................................................74
5.6. GNU adns (optional) .......................................................................75
5.6.1. Unix ..................................................................................75
5.6.2. Win32 MSVC .....................................................................75
5.7. PCRE (optional) .............................................................................76
5.7.1. Unix ..................................................................................76
5.7.2. Win32 MSVC .....................................................................76
5.8. zlib (optional) ................................................................................77
5.8.1. Unix ..................................................................................77
5.8.2. Win32 MSVC .....................................................................77
5.9. libpcap/WinPcap (optional) ..............................................................78
5.9.1. Unix: libpcap ......................................................................78
5.9.2. Win32 MSVC: WinPcap .......................................................78
5.10. GnuTLS (optional) ........................................................................79
5.10.1. Unix ................................................................................79
5.10.2. Win32 MSVC ...................................................................79
5.11. Gcrypt (optional) ..........................................................................80
5.11.1. Unix ................................................................................80
5.11.2. Win32 MSVC ...................................................................80
5.12. Kerberos (optional) .......................................................................81
5.12.1. Unix ................................................................................81
5.12.2. Win32 MSVC ...................................................................81
5.13. LUA (optional) ............................................................................82
5.13.1. Unix ................................................................................82
5.13.2. Win32 MSVC ...................................................................82
5.14. PortAudio (optional) .....................................................................83
5.14.1. Unix ................................................................................83
5.14.2. Win32 MSVC ...................................................................83
5.15. Win32: GTK WIMP (optional) for GTK 2.x only ...............................84
II. Wireshark Development (incomplete) ..................................................................86
6. How Wireshark Works ..............................................................................87
6.1. Introduction ..................................................................................87
6.2. Overview ......................................................................................88
6.3. Capturing packets ...........................................................................90
vi
Wireshark Developer's Guide
6.4. Capture Files .................................................................................91
6.5. Dissect packets ..............................................................................92
7. Introduction .............................................................................................94
7.1. Source overview ............................................................................94
7.2. Coding styleguides .........................................................................95
7.3. The GLib library ............................................................................96
8. Packet capturing .......................................................................................98
8.1. How to add a new capture type to libpcap ...........................................98
9. Packet dissection ....................................................................................100
9.1. How it works ............................................................................... 100
9.2. Adding a basic dissector ................................................................101
9.2.1. Setting up the dissector ....................................................... 101
9.2.2. Dissecting the details of the protocol ..................................... 103
9.2.3. Improving the dissection information ..................................... 106
9.3. How to handle transformed data ...................................................... 109
9.4. How to reassemble split packets ...................................................... 110
9.4.1. How to reassemble split UDP packets .................................... 110
9.4.2. How to reassemble split TCP Packets .................................... 113
9.5. How to tap protocols ..................................................................... 115
9.6. How to produce protocol stats .........................................................116
9.7. How to use conversations .............................................................. 118
10. User Interface ....................................................................................... 120
10.1. Introduction ............................................................................... 120
10.2. The GTK library ......................................................................... 121
10.2.1. GTK Version 1.x ............................................................. 121
10.2.2. GTK Version 2.x ............................................................. 121
10.2.3. Compatibility between 1.x and 2.x ....................................... 122
10.2.4. GTK resources on the web .................................................122
10.3. GUI Reference documents ............................................................ 124
10.4. Adding/Extending Dialogs ........................................................... 125
10.5. Widget naming ........................................................................... 126
10.6. Common GTK programming pitfalls .............................................. 127
10.6.1. Usage of gtk_widget_show() / gtk_widget_show_all() ............ 127
A. This Document's License (GPL) ........................................................................ 129
vii

Preface

1. Foreword

This book tries to give you a guide to start your own experiments into the wonderful world of Wire­shark development.
Developers who are new to Wireshark often have a hard time getting their development environ­ment up and running. This is especially true for Win32 developers, as a lot of the tools and methods used when building Wireshark are much more common in the UNIX world than on Win32.
The first part of this book will describe how to set up the environment needed to develop Wireshark. The second part of this book will describe how to change the Wireshark source code. We hope that you find this book useful, and look forward to your comments.
viii
Preface

2. Who should read this document?

The intended audience of this book is anyone going into the development of Wireshark. This book is not intended to explain the usage of Wireshark in general. Please refer the Wireshark
User's Guide about Wireshark usage.
By reading this book, you will learn how to develop Wireshark. It will hopefully guide you around some common problems that frequently appear for new (and sometimes even advanced) developers of Wireshark.
ix

3. Acknowledgements

The authors would like to thank the whole Wireshark team for their assistance. In particular, the au­thors would like to thank:
Gerald Combs, for initiating the Wireshark project.
Guy Harris, for many helpful hints and his effort in maintaining the various contributions on the mailing lists.
The authors would also like to thank the following people for their helpful feedback on this docu­ment:
XXX - Please give feedback :-)
And of course a big thank you to the many, many contributors of the Wireshark development com­munity!
Preface
x
Preface

4. About this document

This book was developed by Ulf Lamping. It is written in DocBook/XML. You will find some specially marked parts in this book:
This is a warning!
You should pay attention to a warning, as otherwise data loss might occur.
This is a note!
A note will point you to common mistakes and things that might not be obvious.
This is a tip!
Tips will be helpful for your everyday work developing Wireshark.
xi
Preface

5. Where to get the latest copy of this document?

The latest copy of this documentation can always be found at: http://www.wireshark.org/docs/ in PDF (A4 and US letter), HTML (single and chunked) and CHM format.
xii
Preface

6. Providing feedback about this document

Should you have any feedback about this document, please send it to the authors through wireshark-
dev[AT]wireshark.org.
xiii
Preface
xiv
Part I. Wireshark Build
Environment
Part I. Wireshark Build Environment The first part describes how to set up the tools, libraries and source needed to generate Wire-
shark, and how to do some typical development tasks.
Part II. Wireshark Development The second part describes how the Wireshark sources are structured and how to change the sources
(e.g. adding a new dissector).

Chapter 1. Introduction

1.1. Introduction

This chapter will provide you with information about Wireshark development in general.
2
Introduction

1.2. What is Wireshark?

Well, if you want to start Wireshark development, you might already know what Wireshark is do­ing. If not, please have a look at the Wireshark User's Guide, which will provide a lot of general in­formation about it.
3
Introduction

1.3. Platforms Wireshark runs on

Wireshark currently runs on most UNIX platforms and various Windows platforms. It requires GTK+, GLib, libpcap and some other libraries in order to run.
As Wireshark is developed in a platform independent way and uses libraries (such as the GTK+ GUI library) which are available for a lot of different platforms, it's thus available on a wide variety of platforms.
If a binary package is not available for your platform, you should download the source and try to build it. Please report your experiences to wireshark-dev[AT]wireshark.org.
Binary packages are available for at least the following platforms:
1.3.1. Unix
Apple Mac OS X
BeOS
FreeBSD
HP-UX
IBM AIX
NetBSD
OpenBSD
SCO UnixWare/OpenUnix
SGI Irix
Sun Solaris/Intel
Sun Solaris/Sparc
Tru64 UNIX (formerly Digital UNIX)
1.3.2. Linux
Debian GNU/Linux
Gentoo Linux
IBM S/390 Linux (Red Hat)
Mandrake Linux
PLD Linux
Red Hat Linux
Rock Linux
Slackware Linux
4
Suse Linux
1.3.3. Microsoft Windows
Thanks to the Win32 API, development on all Windows platforms will be done in a very similar way. All Windows platforms referred to as Win32, Win or Windows may be used with the same meaning. Older Windows versions are no longer supported by Wireshark. As Windows CE differs a lot compared to the other Windows platforms mentioned, Wireshark will not run on Windows CE and there are no plans to support it.
Windows Server 2003 / XP / 2000
Introduction
5
Introduction

1.4. Development and maintenance of Wireshark

Wireshark was initially developed by Gerald Combs. Ongoing development and maintenance of Wireshark is handled by the Wireshark team, a loose group of individuals who fix bugs and provide new functionality.
There have also been a large number of people who have contributed protocol dissectors to Wire­shark, and it is expected that this will continue. You can find a list of the people who have contrib­uted code to Wireshark by checking the about dialog box of Wireshark, or have a look at the http://
anonsvn.wireshark.org/wireshark/trunk/AUTHORS page on the Wireshark web site.
The communication between the developers is usually done through the developer mailing list, which can be joined by anyone interested in the development process. At the time this document was written, more than 500 persons were subscribed to this mailing list!
It is strongly recommended to join the developer mailing list, if you are going to do any Wireshark development. See Section 1.7.5, “Mailing Lists” about the different Wireshark mailing lists avail­able.
1.4.1. Programming language(s) used
Almost any part of Wireshark is implemented in plain ANSI C. The typical task for a new Wireshark developer is to extend an existing, or write a new dissector for
a specific network protocol. As (almost) any dissector is written in plain old ANSI C, a good know­ledge about ANSI C will be sufficient for Wireshark development in almost any case.
So unless you are going to change the development process of Wireshark itself, you won't come in touch with any other programming language than ANSI C (such as perl or python, which are used only in the Wireshark build process).
Beside the usual tools for developing a program in C (compiler, make, ...), the build process uses some additional helper tools (Perl, Python, Sed, ...), which are needed for the build process when Wireshark is to be installed from the released source packages. If Wireshark is installed from a bin­ary package, none of these helper tools are needed on the target system.
1.4.2. Open Source Software
Wireshark is an open source software project, and is released under the GNU General Public Li-
cence (GPL). You can freely use Wireshark on any number of computers you like, without worrying
about license keys or fees or such. In addition, all source code is freely available under the GPL. Be­cause of that, it is very easy for people to add new protocols to Wireshark, either as plugins, or built into the source, and they often do!
You are welcome to modify Wireshark to suit your own needs, and it would be appreciated if you contribute your improvements back to the Wireshark team.
You gain three benefits by contributing your improvements back to the community:
Other people who find your contributions useful will appreciate them, and you will know that you have helped people in the same way that the developers of Wireshark have helped people.
The developers of Wireshark might improve your changes even more, as there's always room for improvements. Or they may implement some advanced things on top of your code, which can be useful for yourself too.
The maintainers and developers of Wireshark will maintain your code as well, fixing it when API changes or other changes are made, and generally keeping it in tune with what is happening
6
Introduction
with Wireshark. So if Wireshark is updated (which is done often), you can get a new Wireshark version from the website and your changes will already be included without any effort for you.
The Wireshark source code and binary kits for some platforms are all available on the download page of the Wireshark website: http://www.wireshark.org/download/.
7
Introduction

1.5. Releases and distributions

The officially released files can be found at: http://www.wireshark.org/download/. A new Wireshark version is released after significant changes compared to the last release are completed or a serious security issue is encountered. The typical release schedule is about every 4-8 weeks (although this may vary).
There are two kinds of distributions: binary and source; both have their advantages and disadvant­ages.
1.5.1. Binary distributions
Binary distributions are usually easy to install (as simply starting the appropriate file is usually the only thing to do). They are available for the following systems:
Win32 (.exe file). The typical Windows end user method is used to get a setup.exe file which will install all the required things for him.
Win32 U3 (.u3 file). Special distribution for U3 capable USB memory sticks.
Debian (.deb file). A user of a Debian Package Manager (DPKG) based system obtains a .deb file from which the package manager checks the dependencies and installs the software.
Red Hat (.rpm file). A user of a Red Hat Package Manager (RPM) based system obtains an .rpm file from which the package manager checks the dependencies and installs the software.
Solaris. A Solaris user obtains a file from which the package manager (PKG) checks the depend­encies and installs the software.
However, if you want to start developing with Wireshark, the binary distributions won't be too help­ful, as you need the source files, of course.
For details about how to build these binary distributions yourself, e.g. if you need a distribution for a special audience, see Section 3.12, “Binary packaging”.
1.5.2. Source code distributions
It's still common for UNIX developers to give the end user a source tarball and let the user compile it on their target machine (configure, make, make install). However, for different UNIX (Linux) dis­tributions it's becoming more common to release binary packages (e.g. .deb or .rpm files) these days.
You should use the released sources if you want to build Wireshark from source on your platform for productive use. However, if you going to develop changes to the Wireshark sources, it might be better to use the latest SVN sources. For details about the different ways to get the Wireshark source code see Section 3.3, “Obtain the Wireshark sources”.
Before building Wireshark from a source distribution, make sure you have all the tools and libraries required to build. The following chapters will describe the required tools and libraries in detail.
8
Introduction

1.6. Automated Builds (Buildbot)

The Wireshark Buildbot automatically rebuilds Wireshark on every change of the source code re­pository and indicates problematic changes. This frees the developers from repeating (and annoying) work, so time can be spent on more interesting tasks.
1.6.1. Advantages
Recognizing (cross platform) build problems - early. Compilation problems can be narrowed down to a few commits, making a fix much easier.
"Health status" overview of the sources. A quick look at: http://buildbot.wireshark.org/ trunk/ gives a good "feeling" if the sources are currently "well". On the other hand, if all is "red", an update of a personal source tree might better be done later ...
"Up to date" binary packages are available. After a change was committed to the repository, a binary package / installer is usually available within a few hours at: http://www.wireshark.org/
download/automated/. This can be quite helpful, e.g. a bug reporter can easily verify a bugfix by
installing a recent build.
Automated regression tests. In particular, the fuzz tests often indicate "real life" problems that are otherwise hard to find.
1.6.2. What does the Buildbot do?
The Buildbot will do the following (to a different degree on the different platforms):
checkout from the source repository
build
create binary package(s) / installer
create source package (and check completeness)
run regression tests
Each step is represented at the status page by a rectangle, green if it succeeded or red if it failed. Most steps provide a link to the corresponding console logfile, to get additional information.
The Buildbot runs on a platform collection that represents the different "platform specialties" quite well:
Windows XP x86 (Win32, little endian, MSVC)
Ubuntu x86 (Linux, little endian, gcc)
Solaris SPARC (Solaris, big endian, gcc)
Mac OS-X PPC (BSD, big endian, gcc)
Each platform is represented at the status page by a single column, the most recent entries are at the top.
9
Introduction

1.7. Reporting problems and getting help

If you have problems, or need help with Wireshark, there are several places that may be of interest to you (well, beside this guide of course).
1.7.1. Website
You will find lot's of useful information on the Wireshark homepage at http://www.wireshark.org.
1.7.2. Wiki
The Wireshark Wiki at http://wiki.wireshark.org provides a wide range of information related to Wireshark and packet capturing in general. You will find a lot of information not part of this de­veloper's guide. For example, there is an explanation how to capture on a switched network, an on­going effort to build a protocol reference and a lot more.
And best of all, if you would like to contribute your knowledge on a specific topic (maybe a net­work protocol you know well), you can edit the wiki pages by simply using your webbrowser.
1.7.3. FAQ
The "Frequently Asked Questions" will list often asked questions and the corresponding answers.
Read the FAQ!
Before sending any mail to the mailing lists below, be sure to read the FAQ, as it will often answer the question(s) you might have. This will save yourself and others a lot of time (keep in mind that a lot of people are subscribed to the mailing lists).
You will find the FAQ inside Wireshark by clicking the menu item Help/Contents and selecting the FAQ page in the upcoming dialog.
An online version is available at the Wireshark website: http://www.wireshark.org/faq.html. You might prefer this online version, as it's typically more up to date and the HTML format is easier to use.
1.7.4. Other sources
If you don't find the information you need inside this book, there are various other sources of in­formation:
the file doc/README.developer and all the other README.xxx files in the source code ­these are various documentation files on different topics
the Wireshark source code
tool documentation of the various tools used (e.g. manpages of sed, gcc, ...)
the different mailing lists: see Section 1.7.5, “Mailing Lists”
...
1.7.5. Mailing Lists
There are several mailing lists available on specific Wireshark topics:
10
Introduction
wireshark-announce This mailing list will inform you about new program releases, which
usually appear about every 4-8 weeks.
wireshark-users This list is for users of Wireshark. People post questions about build-
ing and using Wireshark, others (hopefully) provide answers.
wireshark-dev This list is for Wireshark developers. People post questions about the
development of Wireshark, others (hopefully) provide answers. If you want to start developing a protocol dissector, join this list.
wireshark-bugs This list is for Wireshark developers. Everytime a change to the bug
database occurs, a mail to this mailing list is generated. If you want to be notified about all the changes to the bug database, join this list. De­tails about the bug database can be found in Section 1.7.6, “Bug data-
base (Bugzilla)”.
wireshark-commits This list is for Wireshark developers. Everytime a change to the SVN
repository is checked in, a mail to this mailing list is generated. If you want to be notified about all the changes to the SVN repository, join this list. Details about the SVN repository can be found in Section 3.2,
“The Wireshark Subversion repository”.
You can subscribe to each of these lists from the Wireshark web site: http://www.wireshark.org. Simply select the mailing lists link on the left hand side of the site. The lists are archived at the Wireshark web site as well.
Tip!
You can search in the list archives to see if someone previously asked the same ques­tion and maybe already got an answer. That way you don't have to wait until someone answers your question.
1.7.6. Bug database (Bugzilla)
The Wireshark community collects bug reports in a Bugzilla database at http://bugs.wireshark.org. This database is filled with manually filed bug reports, usually after some discussion on wireshark­dev, and bug reports from the QA build tools.
1.7.7. Reporting Problems
Note!
Before reporting any problems, please make sure you have installed the latest version of Wireshark.
If you report problems, provide as much information as possible. In general, just think about what you would need to find that problem, if someone else sends you such a problem report. Also keep in mind that people compile/run Wireshark on a lot of different platforms.
When reporting problems with Wireshark, it is helpful if you supply the following information:
1. The version number of Wireshark and the dependent libraries linked with it, e.g. GTK+, etc.
You can obtain this with the command wireshark -v.
2. Information about the platform you run Wireshark on.
3. A detailed description of your problem.
4. If you get an error/warning message, copy the text of that message (and also a few lines before
11
Introduction
and after it, if there are some), so others may find the build step where things go wrong. Please don't give something like: "I get a warning when compiling x" as this won't give any direction to look at.
Don't send large files!
Do not send large files (>100KB) to the mailing lists, just place a note that further data is available on request. Large files will only annoy a lot of people on the list who are not interested in your specific problem. If required, you will be asked for further data by the persons who really can help you.
Don't send confidential information!
If you send captured data to the mailing lists, or add it to your bug report, be sure it doesn't contain any sensitive or confidential information, such as passwords.
1.7.8. Reporting Crashes on UNIX/Linux platforms
When reporting crashes with Wireshark, it is helpful if you supply the traceback information (besides the information mentioned in Section 1.7.7, “Reporting Problems”).
You can obtain this traceback information with the following commands:
$ gdb `whereis wireshark | cut -f2 -d: | cut -d' ' -f2` core >& bt.txt backtrace ^D $
Note
Type the characters in the first line verbatim! Those are back-tics there!
Note
backtrace is a gdb command. You should enter it verbatim after the first line shown above, but it will not be echoed. The ^D (Control-D, that is, press the Control key and the D key together) will cause gdb to exit. This will leave you with a file called bt.txt in the current directory. Include the file with your bug report.
Note
If you do not have gdb available, you will have to check out your operating system's debugger.
You should mail the traceback to the wireshark-dev[AT]wireshark.org mailing list, or append it to your bug report.
1.7.9. Reporting Crashes on Windows platforms
The Windows distributions don't contain the symbol files (.pdb), because they are very large. For this reason it's not possible to create a meaningful backtrace file from it. You should report your crash just like other problems, using the mechanism from Section 1.7.7, “Reporting Problems”.
12
Introduction
13

Chapter 2. Quick Setup

2.1. UNIX: Installation

All the tools required are usually installed on a UNIX developer machine. If a tool is not already installed on your system, you will typically use the installation package from
your distribution (by your favourite package manager: aptitude, yum, synaptics, ...). If an install package is not available, or you have a reason not to use it (maybe because it's simply
too old), you can install that tool from source code. The following sections will provide you with the webpage addresses where you can get these sources.
14
Quick Setup

2.2. Win32: Step-by-Step Guide

A quick setup guide for Win32 with recommended configuration.
Warning!
Unless you know exactly what you are doing, you should strictly follow the re­commendations!
2.2.1. Install Microsoft C compiler and Platform SDK
You need to install:
1. C compiler: Download(474MB) and install "Visual C++ 2005 Express Edition"
2. Platform SDK : Download(420MB) and install Platform SDK Server 2003 R2
Install MSVC the usual way. Don't forget to install vcvars32.bat or call it manually before building Wireshark. vcvars32.bat will set some required environment (e.g. the PATH) settings.
Other Microsoft C compiler variants possible!
It's possible to compile Wireshark with a wide range of Microsoft C compiler variants, for details see Section 4.4, “Microsoft compiler toolchain (Win32 native)”!
Don't use cygwin's gcc!
Using cygwin's gcc is not recommended and will certainly not work (at least without a lot of advanced tweaking). For further details on this topic, see Section 4.3, “GNU
compiler toolchain (UNIX or Win32 Cygwin)”.
XXX - mention the compiler and PSDK web installers - which significantly reduce download size ­and find out the required components
XXX - how to get the right PATH settings? Why this is recommended: While this is a huge download, the 2005 express edition is the only free
(as in beer) version that includes the Visual Studio integrated debugger.
2.2.2. Install Cygwin
Download the cygwin installer and start it.
At the "Select Packages" page, you'll need to select some additional packages, which are not in­stalled by default. Navigate to the required Category/Package row and click on the "Skip" item in the "New" column so it shows a version number for:
Archive/unzip
Devel/bison
Devel/flex
Interpreters/perl
15
Quick Setup
Utils/patch
Web/wget
After clicking the Next button several times, the setup will then download and install the selected packages (this may take a while).
Why this is recommended: Cygwin's bash version is required, as no native Win32 version is avail­able. As additional packages can easily be added, the perl and alike packages are also used.
2.2.3. Install Python
Get the python 2.4 installer from: http://python.org/download/and install python into the default loc­ation (currently: C:/Python24).
Beware: python 2.5 won't work without modifications. Why this is recommended: Cygwin's python package doesn't work on some machines, so the Win32
native package is recommended.
2.2.4. Install Subversion Client
Please note that the following is not required to build Wireshark, but can be quite helpful when working with the sources.
Why this is recommended: updating a personal source tree is significantly easier to do with Subver­sion than downloading a zip file and merging new sources into a personal source tree "by hand".
2.2.4.1. Subversion
If you want to work with the Wireshark Subversion source repositories (which is highly recommen­ded, see Section 3.3, “Obtain the Wireshark sources”), it's recommended to install Subversion. This makes the first time setup easy and enables the Wireshark build process to determine your current source code revision. You can download the setup from http://subversion.tigris.org/and simply in­stall it.
2.2.4.2. TortoiseSVN
If you want to work with the Wireshark Subversion source repositories (which is highly recommen­ded, see Section 3.3, “Obtain the Wireshark sources”), it's recommended to use TortoiseSVN for your everyday work. You can download the setup from http://tortoisesvn.tigris.org/and simply in­stall it.
2.2.5. Install and Prepare Sources
Tip
It's a good idea to successfully compile and run Wireshark at least once before you start hacking the Wireshark sources for your own project!
1. Download sources : Download Wireshark sources into: C:\wireshark using TortoiseSVN
a. right click on the C:\ drive in Windows Explorer b. in the upcoming context menu select "SVN checkout..." and then set:
16
Quick Setup
c.
i. URL of repository: " ht-
tp://anonsvn.wireshark.org/wireshark/trunk/"
ii. Checkout directory: "C:\wireshark" d. TortoiseSVN might ask you to create this directory - say yes e. TortoiseSVN starts downloading the sources f. if the download fails you may be behind a restrictive firewall, see Section 3.3, “Obtain the
Wireshark sources”for alternative download methods
2. Edit config.nmake: edit the settings in C:\wireshark\config.nmake, especially:
a. VERSION_EXTRA : give Wireshark your "private" version info, e.g.: -myprotocol123 -
to distinguish it from an official release! b. PROGRAM_FILES : where your programs reside, usually just keep the default:
C:/Program Files
2
c. MSVC_VARIANT : search for the line: #MSVC_VARIANT=MSVC2005EE and remove
the tailing # comment char from this line
1
Compiler dependent: This step depends on the compiler variant used, for other variants than the re­commended Visual C++ 2005 Express Edition see the table at Section 4.4, “Microsoft compiler
toolchain (Win32 native)”!
2
International Windows might use different values here, e.g. a german version uses C:/Programme ­take this also in account where C:\Program Files appears elsewhere
2.2.6. Prepare cmd.exe
Prepare cmd.exe - set environment and current dir.
1. start cmd.exe
2. call "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\SetEnv.Cmd" to
set environment variables of Platform SDK Server 2003 R2
3. call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat" to set environment
variables of Visual C++ 2005 Express Edition
4. cd C:\wireshark to jump into the source directory
1
Compiler dependent: This step depends on the compiler variant used, for other variants than the re­commended Visual C++ 2005 Express Edition see the table at Section 4.4, “Microsoft compiler
toolchain (Win32 native)”!
2
International Windows might use different values here, e.g. a german version uses C:/Programme ­take this also in account where C:\Program Files appears elsewhereNote: You need to repeat steps 1
- 4 each time you open a new cmd.exe!
1
1,2
1,2
2.2.7. Verify installed tools
After you've installed the Wireshark sources (see Section 3.3, “Obtain the Wireshark sources”), you can check the correct installation of all tools by using the verify_tools target of the Make- file.nmake from the source package.
17
Quick Setup
Warning!
You will need the Wireshark sources and some tools (nmake, bash) installed, before this verification is able to work.
Enter at the command line (cmd.exe, not Cygwin's bash!):
> nmake -f Makefile.nmake verify_tools
This will check for the various tools needed to build Wireshark:
Checking for required applications: cl: /cygdrive/c/Programme/Microsoft Visual Studio 8/VC/BIN/cl link: /cygdrive/c/Programme/Microsoft Visual Studio 8/VC/BIN/link nmake: /cygdrive/c/Programme/Microsoft Visual Studio 8/VC/BIN/nmake bash: /usr/bin/bash bison: /usr/bin/bison flex: /usr/bin/flex env: /usr/bin/env grep: /usr/bin/grep /usr/bin/find: /usr/bin/find perl: /usr/bin/perl env: /usr/bin/env C:/python24/python.exe: /cygdrive/c/python24/python.exe sed: /usr/bin/sed unzip: /usr/bin/unzip wget: /usr/bin/wget
If you have problems with all the first three items (cl, link, nmake), check if you called vcvars32/SetEnv as mentioned in Section 2.2.6, “Prepare cmd.exe” (which will "fix" your PATH settings). However, the exact text will be slightly different depending on the MSVC version used.
Unfortunately, the link command is defined both in cygwin and in MSVC each with completely dif­ferent functionality; you'll need the MSVC link. If your link command looks something like: / usr/bin/link, the link command of cygwin takes precedence over the MSVC one. To fix this, you can change your PATH environment setting or simply rename the link.exe in cygwin. If you rename it, make sure to remember that a cygwin update may provide a new version of it.
2.2.8. Install Libraries
1. If you've closed cmd.exe in the meantime, prepare cmd.exe again
2. nmake -f Makefile.nmake setup downloads libraries using wget and installs them - this may take a while ...
3. If the download fails you may be behind a restrictive firewall, see the wget manual for ways to use a proxy
2.2.9. Distclean Sources
The released Wireshark sources contain files that are prepared for a UNIX build (e.g. config.h). You must distclean your sources before building the first time!
1. If you've closed cmd.exe in the meantime, prepare cmd.exe again
2. nmake -f Makefile.nmake distclean to cleanup the Wireshark sources
2.2.10. Build Wireshark
18
Quick Setup
Now it's time to build Wireshark ...
1. If you've closed cmd.exe in the meantime, prepare cmd.exe again
2. nmake -f Makefile.nmake all to build Wireshark
3. wait for Wireshark to compile - this may take a while!
4. run C:\wireshark\wireshark-gtk2\wireshark.exe and check if it starts
5. check Help/About if it shows your "private" program version, e.g.: Version
0.99.4-myprotocol123 - you might run a release version previously installed!
Tip: If compilation fails for suspicious reasons after you changed some source files try to distclean the sources and make "all" again
2.2.11. Debug Environment Setup (XXX)
XXX - debug needs to be written, e.g. an idea is the create a simple MSVC 6 workspace/project(s) to ease Visual Studio debugging
2.2.12. Optional: Create User's and Developer's Guide
Detailed information to build these guides can be found in the file docbook/README.txt in the Wireshark sources.
2.2.13. Optional: Create a Wireshark Installer
Note: You should have successfully built Wireshark before doing the following! If you want to build your own wireshark-setup.exe, you'll need NSIS.
1. NSIS: Download and install NSIS You may check the MAKENSIS setting in the file config.nmake of the Wireshark sources.
2. vcredist_x86.exe : Download the C-Runtime redistributable for Visual C++ 2005 Express Edi­tion (vcredist_x86.exe) and copy it into C:\wireshark-win32-libs
Beware of Visual Studio Service Packs!
If you have installed the Visual Studio Service Pack 1, you need a different vcre­dist_x86.exe version! See Section 4.4, “Microsoft compiler toolchain (Win32 nat-
ive)”for details!
3. If you've closed cmd.exe in the meantime, prepare cmd.exe again
1
4. nmake -f Makefile.nmake packaging build Wireshark installer
5. run C:\wireshark\packaging\nsis\wireshark-setup-<version>.exe and test it - it's a good idea to test also on a different machine than the developer machine.
1
Compiler dependent: This step depends on the compiler variant used, for other variants than the re­commended Visual C++ 2005 Express Edition see the table at Section 4.4, “Microsoft compiler
toolchain (Win32 native)”!
19
Quick Setup
20

Chapter 3. Work with the Wireshark sources

3.1. Introduction

This chapter will explain how to work with the Wireshark source code. It will show you how to:
get the source
compile the source
submit changes
... However, this chapter will not explain the source file contents in detail, such as where to find a spe-
cific functionality. This is done in Section 7.1, “Source overview”.
21
Work with the Wireshark sources

3.2. The Wireshark Subversion repository

Subversion is used to keep track of the changes made to the Wireshark source code. The Wireshark source code is stored inside Wireshark project's Subversion repository located at a server at the wireshark.org domain.
To qoute the Subversion book about "What is Subversion?": “Subversion is a free/open-source version control system. That is, Subversion manages files and dir-
ectories over time. A tree of files is placed into a central repository. The repository is much like an ordinary file server, except that it remembers every change ever made to your files and directories. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of "time machine". ”
Tip: Subversion and SVN is the same!
Subversion is often abbreviated as SVN, as the command-line tools are abbreviated that way. You will find both terms with the same meaning in this book, in mailing list discussions and elsewhere.
Using Wireshark's Subversion repository you can:
keep your private sources up to date with very little effort
get a mail notification if someone changes the latest sources
get the source files from any previous release (or any other point in time)
have a quick look at the sources using a web interface
see which person changed a specific piece of code
... and a lot more things related to the history of the Wireshark source code development
Subversion is divided into a client and a server part. Thanks to Gerald Combs (the maintainer of the Subversion server), no user has to deal with the maintenance of the Subversion server. You will only need a Subversion client, which is available as both a command-line and a GUI tool for many differ­ent platforms.
For further reference about Subversion, have a look at the homepage of the Subversion project: ht-
tp:/ / subversion.tigris.org/ . There is a good and free book about it available at: http:/ / svn­book.red-bean.com/.
Please note that Wireshark's public (anonymous) Subversion repository is separate from the main re­pository. It may take several minutes for committed changes to appear in the public repository - so please be patient for a few minutes if you desperately need a code change that was commited to the repository very recently.
3.2.1. The web interface to the Subversion repository
If you need a quick look at the Wireshark source code, you will only need a Web browser. A simple view on the latest developer version can be found at:
http://anonsvn.wireshark.org/wireshark/trunk/.
A comprehensive view of all source versions (e.g. including the capability to show differences between versions) is available at:
22
Work with the Wireshark sources
http://anonsvn.wireshark.org/viewvc/viewvc.cgi/.
Of special interest might be the subdirectories:
trunk - the very latest source files
releases - the source files of all released versions
23
Work with the Wireshark sources

3.3. Obtain the Wireshark sources

There are several ways to obtain the sources from Wireshark's Subversion server.
Anonymous Subversion access is recommended!
It can make your life much easier, compared to updating your source tree by using any of the zip file methods mentioned below. Subversion handles merging of changes into your personal source tree in a very comfortable and quick way. So you can update your source tree several times a day without much effort.
Keep your sources "up to date"!
The following ways to retrieve the Wireshark sources are sorted in decreasing source timeliness. If you plan to commit changes you've made to the sources, it's a good idea to keep your private source tree as current as possible.
The age mentioned in the following sections indicates the age of the most recent change in that set of the sources.
3.3.1. Anonymous Subversion access
Recommended for development purposes. Age: a few minutes. You can use a Subversion client to download the source code from Wireshark's anonymous Subver-
sion repository. The URL for the repository trunk is: http://anonsvn.wireshark.org/wireshark/trunk/. See Section 4.11, “Subversion (SVN) client (optional)” on how to install a Subversion client. For example, to check out using the command-line Subversion client, you would type:
$ svn checkout http://anonsvn.wireshark.org/wireshark/trunk wire­shark
The checkout has to be only done once. This will copy all the sources of the latest version (including directories) from the server to your machine. This will take some time, depending on the speed of your internet connection.
3.3.2. Anonymous Subversion web interface
Recommended for informational purposes only, as only individual files can be downloaded. Age: a few minutes (same as anonymous Subversion access). The entire source tree of the Subversion repository is available via a web interface at: http://anons-
vn.wireshark.org/viewvc/ viewvc.cgi/. You can view each revision of a particular file, as well as
diffs between different revisions. You can also download individual files but not entire directories.
3.3.3. Buildbot Snapshots
Recommended for development purposes, if direct Subversion access isn't possible (e.g. because of a restrictive firewall).
Age: some number of minutes (a bit older than the anonymous Subversion access). The buildbot server will automatically start to generate a snapshot of Wireshark's source tree after a
24
Work with the Wireshark sources
source code change is committed. These snapshots can be found at: http:/ / www.wireshark.org/
download/automated/src/.
If anonymous Subversion access isn't possible, e.g. if the connection to the server isn't possible be­cause of a corporate firewall, the sources can be obtained by downloading the buildbot snapshots. However, if you are going to maintain your sources in parallel to the "official" sources for some time, it's recommended to use the anonymous Subversion access if possible (believe it, it will save you a lot of time).
3.3.4. Released sources
Recommended for productive purposes. Age: from days to weeks. The officially released source files can be found at: http:/ / www.wireshark.org/download/ . You
should use these sources if you want to build Wireshark on your platform for productive use. The differences between the released sources and the sources stored at the Subversion repository
will keep on growing until the next release is done (at the release time, the released and latest Sub­version repository versions are then identical again :-).
25
Work with the Wireshark sources

3.4. Update the Wireshark sources

After you've obtained the Wireshark sources for the first time, you might want to keep them in sync with the sources at the Subversion repository.
Take a look at the buildbot first!
As development evolves, the Wireshark sources are compilable most of the time - but not always. You may take a look at the Section 1.6, “Automated Builds (Buildbot)” first, to see if the sources are currently in a good shape.
3.4.1. ... with Anonymous Subversion access
After the first time checkout is done, updating your sources is simply done by typing (in the Wire­shark source dir):
$ svn update
This will only take a few seconds, even on a slow internet connection. It will replace old file ver­sions by new ones. If you and someone else have changed the same file since the last update, Sub­version will try to merge the changes into your private file (this works remarkably well).
3.4.2. ... from zip files
Independent of the way you retrieve the zip file of the Wireshark sources (as described in Sec-
tion 3.3, “Obtain the Wireshark sources” ), the way to bring the changes from the official sources in-
to your personal source tree is identical. First of all, you will download the new zip file of the official sources the way you did it the first
time. If you haven't changed anything in the sources, you could simply throw away your old sources and
reinstall everything just like the first time. But be sure, that you really haven't changed anything. It might be a good idea to simply rename the "old" dir to have it around, just in case you remember later that you really did change something before.
Well, if you did change something in your source tree, you have to merge the official changes since the last update into your source tree. You will install the content of the zip file into a new directory and use a good merge tool (e.g. http://winmerge.sourceforge.net/for Win32) to bring your personal source tree in sync with the official sources again.
26
Work with the Wireshark sources

3.5. Build Wireshark

The sources contain several documentation files, it's a good idea to look at these files first. So after obtaining the sources, tools and libraries, the first place to look at is doc/
README.developer, here you will get the latest infos for Wireshark development for all suppor­ted platforms.
Tip!
It is a very good idea, to first test your complete build environment (including running and debugging Wireshark) before doing any changes to the source code (unless other­wise noted).
The following steps for the first time generation differ on the two major platforms.
3.5.1. Unix
Run the autogen.sh script at the top-level wireshark directory to configure your build directory.
./autogen.sh ./configure make
If you need to build with a GTK 1.x version, you have to use:
./configure --disable-gtk2
instead of just ./configure.
3.5.2. Win32 native
The first thing to do will be to check the file config.nmake to determine if it reflects your con­figuration. The settings in this file are well documented, so please have a look at that file. However, if you've installed the libraries and tools as recommended there should be no need to edit things here.
Many of the file and directory names used in the build process go past the old 8.3 naming limita­tions. As a result, you should use the "cmd.exe" command interpreter instead of the old "com­mand.com".
Be sure that your command-line environment is set up to compile and link with MSVC++. When in­stalling MSVC++, you can have your system's environment set up to always allow compiling from the command line, or you can invoke the vcvars32.bat script, which can usually be found in the "VC98\Bin" subdirectory of the directory in which Visual Studio was installed.
You should then cleanup any intermediate files, which are shipped for convenience of Unix users, by typing at the command line prompt (cmd.exe):
> nmake -f Makefile.nmake distclean
After doing this, typing at the command line prompt (cmd.exe):
> nmake -f Makefile.nmake all
will start the whole Wireshark build process. After the build process has successfully finished, you should find a wireshark.exe and some
27
Work with the Wireshark sources
other files in the root directory.
28
Work with the Wireshark sources

3.6. Run generated Wireshark

Tip!
An already installed Wireshark may interfere with your newly generated version in various ways. If you have any problems getting your Wireshark running the first time, it might be a good idea to remove the previously installed version first.
XXX - add more info here.
29
Work with the Wireshark sources

3.7. Debug your generated Wireshark

See the above info on running Wireshark. XXX - add more info here.
3.7.1. Win32 native
XXX - add more info here.
30
Work with the Wireshark sources

3.8. Make changes to the Wireshark sources

As the Wireshark developers are working on many different platforms, a lot of editors are used to develop Wireshark (emacs, vi, Microsoft Visual Studio and many many others). There's no "stand­ard" or "default" development environment.
There are several reasons why you might want to change the Wireshark sources:
add your own new dissector
change/extend an existing dissector
fix a bug
implement a new glorious feature :-) The internal structure of the Wireshark sources will be described in Part II, “Wireshark Develop-
ment (incomplete)”.
Tip!
Ask the developer mailing list before you really start a new development task. If
you have an idea what you want to add/change, it's a good idea to contact the de­veloper mailing list (see Section 1.7.5, “Mailing Lists”) and explain your idea. Someone else might already be working on the same topic, so double effort can be re­duced, or someone can give you some tips that should be thought about (like side ef­fects that are sometimes very hard to see).
31
Work with the Wireshark sources

3.9. Contribute your changes

If you have finished changing the Wireshark sources to suit your needs, you might want to contrib­ute your changes back to the Wireshark community. You gain the following benefits by contributing your improvements:
It's the right thing to do. Other people who find your contributions useful will appreciate them,
and you will know that you have helped people in the same way that the developers of Wire­shark have helped you.
You get free enhancements. By making your code public, other developers have a chance to
make improvements, as there's always room for improvements. In addition someone may imple­ment advanced features on top of your code, which can be useful for yourself too.
You save time and effort. The maintainers and developers of Wireshark will maintain your code
as well, updating it when API changes or other changes are made, and generally keeping it in tune with what is happening with Wireshark. So if Wireshark is updated (which is done often), you can get a new Wireshark version from the website and your changes will already be in­cluded without any effort for you.
There's no direct way to commit changes to the SVN repository. Only a few people are authorised to actually make changes to the source code (check-in changed files). If you want to submit your changes, you should make a diff file (a patch) and upload it to the bug tracker.
3.9.1. What is a diff file (a patch)?
A diff file is a plain text file containing the differences between a pair of files (or a multiple of such file pairs).
Tip!
A diff file is often also called a patch, as it can be used to patch an existing source file or tree with changes from somewhere else.
The Wireshark community is using patches to transfer source code changes between the authors. A patch is both readable by humans and (as it is specially formatted) by some dedicated tools. Here is a small example of a patch for file.h that makes the second argument in
cf_continue_tail() volatile. It was created using svn diff, described below:
Index: file.h ===================================================================
--- file.h (revision 21134) +++ file.h (revision 22401) @@ -142,7 +142,7 @@
* @param err the error code, if an error had occured * @return one of cf_read_status_t */
-cf_read_status_t cf_continue_tail(capture_file *cf, int to_read, int *err); +cf_read_status_t cf_continue_tail(capture_file *cf, volatile int to_read, int *err);
/**
* Finish reading from "end" of a capture file.
The plus sign at the start of a line indicates an added line, a minus sign indicates a deleted line com­pared to the original sources.
We prefer to use so called "unified" diff files in Wireshark development, three unchanged lines be­fore and after the actual changed parts are included. This makes it much easier for a merge/patch
32
Work with the Wireshark sources
tool to find the right place(s) to change in the existing sources.
3.9.2. Generate a patch
There are several ways to generate patches. The preferred way is to generate them from an updated Subversion tree, since it avoids unnecessary integration work.
3.9.2.1. Using the svn command-line client
svn diff [changed_files] > svn.diff
Use the command line svn client to generate a patch in the required format from the changes you've made to your working copy. If you leave out the name of the changed file the svn client searches for all changes in the working copy and usually produces a patch containing more than just the change you want to send. Therefore you should always check the produced patch file.
If you've added a new file, e.g. packet-myprotocol.c, you can use svn add to add it to your local tree before generating the patch. Similarly, you can use svn rm for files that should be re­moved.
3.9.2.2. Using the diff feature of the GUI Subversion clients
Most (if not all) of the GUI Subversion clients (RapidSVN, TortoiseSVN, ...) have a built-in "diff" feature.
If you use TortoiseSVN: TortoiseSVN (to be precise Subversion) keeps track of the files you have changed in the directories
it controls, and will generate for you a unified diff file compiling the differences. To do so - after updating your sources from the SVN repository if needed - just right-click on the highest level dir­ectory and choose "TortoiseSVN" -> "Create patch...". You will be asked for a name and then the diff file will be created. The names of the files in the patch will be relative to the directory you have right-clicked on, so it will need to be applied on that level too.
When you create the diff file, it will include any difference TortoiseSVN finds in files in and under the directory you have right-clicked on, and nothing else. This means that changes you might have made for your specific configuration - like modifying "config.nmake" so that it uses your lib direct­ory - will also be included, and you will need to remove these lines from the diff file. It also means that only changes will be recorded, i.e. if you have created new files -say, a new packet-xxx for a new protocol dissector- it will not be included in the diff, you need to add it separately. And, of course, if you have been working separately in two different patches, the .diff file will include both topics, which is probably not a good idea.
3.9.2.3. Using the diff tool
A diff file is generated, by comparing two files or directories between your own working copy and the "official" source tree. So to be able to do a diff, you should have two source trees on your com­puter, one with your working copy (containing your changes), and one with the "official" source tree (hopefully the latest SVN files) from www.wireshark.org.
If you have only changed a single file, you could type something like this:
diff -r -u --strip-trailing-cr svn-file.c work-file.c > foo.diff
To get a diff file for your complete directory (including subdirectories), you could type something like this:
diff -N -r -u --strip-trailing-cr ./svn-dir ./working-dir > foo.diff
It's a good idea to do a make distclean before the actual diff call, as this will remove a lot of
33
Work with the Wireshark sources
temporary files which might be otherwise included in the diff. After doing the diff, you should edit the foo.diff file and remove unnecessary things, like your private changes to the con- fig.nmake file.
Table 3.1. Some useful diff options
Option Purpose
-N Add new files when used in conjuction with -r.
-r Recursively compare any subdirectories found.
-u Output unified context.
--strip-trailing-cr Strip trailing carriage return on input. This is useful for Win32
-x PAT Exclude files that match PAT. This could be something like -x *.obj to exclude all win32 ob­ject files.
The diff tool has a lot options; they can be listed with:
diff --help
3.9.3. Some tips for a good patch
Some tips that will make the merging of your changes into the SVN tree much more likely (and you want exactly that, don't you :-):
Use the latest SVN sources, or alike. It's a good idea to work with the same sources that are
used by the other developer's, this makes it usually much easier to apply your patch. For inform­ation about the different ways to get the sources, see Section 3.3, “Obtain the Wireshark
sources”.
Update your SVN sources just before making a patch. For the same reasons as the previous
point.
Do a "make clean" before generating the patch. This removes a lot of unneeded intermediate
files (like object files) which can confuse the diff tool generating a lot of unneeded stuff which you have to remove by hand from the patch again.
Find a good descriptive filename for your patch. Think a moment to find a proper name for
your patch file. Often a filename like wireshark.diff is used, which isn't really helpful if keeping several of these files and find the right one later. For example: If you want to commit changes to the datatypes of dissector foo, a good filename might be: packet- foo-datatypes.diff.
Don't put unrelated things into one large patch. A few smaller patches are usually easier to
apply (but also don't put every changed line into a separate patch :-).
Remove any parts of the patch not related to the changes you want to submit. You can use a
text editor for this. A common example for win32 developers are the differences in your private config.nmake file.
In general: making it easier to understand and apply your patch by one of the maintainers will make it much more likely (and faster) that it will actually be applied.
Please remember: you don't pay the person "on the other side of the mail" for his/her effort applying your patch!
3.9.4. Code Requirements
34
Work with the Wireshark sources
The core maintainers have done a lot of work fixing bugs and making code compile on the various platforms Wireshark supports.
To ensure Wireshark's source code quality, and to reduce the workload of the core maintainers, there are some things you should think about before submitting a patch.
Warn!
Ignoring the code requirements will make it very likely that your patch will be re­jected!
Follow the Wireshark source code style guide. Just because something compiles on your plat-
form, that doesn't mean it'll compile on all of the other platforms for which Wireshark is built. Wireshark runs on many platforms, and can be compiled with a number of different compilers. See Section 7.2, “Coding styleguides” for details.
Fuzz test your changes! Fuzz testing is a very effective way to automatically find a lot of dis-
sector related bugs. You'll take a capture file containing packets affecting your dissector and the fuzz test will randomly change bytes in this file, so that unusual code paths in your dissector are checked. There are tools available to automatically do this on any number of input files, see: ht-
tp://wiki.wireshark.org/FuzzTesting for details.
3.9.5. Sending your patch for inclusion
After generating a patch of your changes, you might want to have your changes included into the SVN repository.
To submit a patch, open a new ticket in the Wireshark bug database at http://bugs.wireshark.org/
bugzilla/enter_bug.cgi?product=Wireshark. You must first create a bug, then attach your patch or
patches.
Set the Product, Priority, and Severity as needed.
Add a Summary and Description, and create a bug using the Commit button. If your code has passed fuzz testing, please say so in the description.
Once the bug has been created, select Create a New Attachment and upload your patch or patches. Set the review_for_checkin flag to ?.
If possible and applicable, attach a capture file that demonstrates your new feature or protocol.
Tip!
Setting the review_for_checkin is important. Without it, your patch won't show up in the pending patch request queue.
You might get one of the following responses to your patch request:
Your patch is checked into the SVN repository. Congratulations!
You are asked to provide additional information, capture files, or other material. If you haven't fuzzed your code, you may be asked to do so.
Your patch is rejected. You should get a response with the reason for rejection. Common reas­ons include not following the style guide, buggy or insecure code, and code that won't compile on other platforms. In each case you'll have to fix each problem and upload another patch.
35
Work with the Wireshark sources
You don't get any reponse to your patch (even after a few days or so). Possible reason: your patch might simply get lost, as all core maintainers were busy at that time and forgot to look at your patch. Simply send a mail asking if the patch was forgotten or if someone is still looking at it.
36
Work with the Wireshark sources

3.10. Apply a patch from someone else

Sometimes you need to apply a patch to your private source tree. Maybe because you want to try a patch from someone on the developer mailing list, or you want to check your own patch before sub­mitting.
Warning!
If you have problems applying a patch, make sure the line endings (CR/NL) of the patch and your source files match.
3.10.1. Using patch
Given the file "new.diff" containing a unified diff, the right way to call the patch tool depends on what the pathnames in "new.diff" look like. If they're relative to the top-level source directory - for example, if a patch to "prefs.c" just has "prefs.c" as the file name - you'd run it as:
patch -p0 <new.diff
If they're relative to a higher-level directory, you'd replace 0 with the number of higher-level direct­ories in the path, e.g. if the names are "wireshark.orig/prefs.c" and "wireshark.mine/prefs.c", you'd run it with:
patch -p1 <new.diff
If they're relative to a subdirectory of the top-level directory, you'd run "patch" in that directory and run it with "-p0".
If you run it without "-p" at all, the patch tool flattens path names, so that if you have a patch file with patches to "Makefile.am" and "wiretap/Makefile.am", it'll try to apply the first patch to the top­level "Makefile.am" and then apply the "wiretap/Makefile.am" patch to the top-level "Makefile.am" as well.
At which position in the filesystem should the patch tool be called? If the pathnames are relative to the top-level source directory, or to a directory above that directory,
you'd run it in the top-level source directory. If they're relative to a subdirectory - for example, if somebody did a patch to "packet-ip.c" and ran
"diff" or "svn diff" in the "epan/dissectors" directory - you'd run it in that subdirectory. It is pre­ferred that people NOT submit patches like that - especially if they're only patching files that exist in multiple directories, such as "Makefile.am".
3.10.2. CVS diff (obsolete)
One other thing to note - "cvs diff" produces output that at least some versions of "patch" can't handle; you'd get something such as
Index: missing/dlnames.c =================================================================== RCS file: /tcpdump/master/tcpdump/missing/dlnames.c,v retrieving revision 1.5 diff -c -r1.5 dlnames.c *** missing/dlnames.c 18 Nov 2003 23:09:43 -0000 1.5
--- missing/dlnames.c 31 Aug 2004 21:45:16 -0000
***************
from "cvs diff -c", and something similar from "cvs diff -u", and "patch", unfortunately, would use the "diff -c" or "diff -u" line and try to patch "dlnames.c" in the directory you're in, rather than in the
37
Work with the Wireshark sources
"missing" subdirectory. For "cvs diff -c" or "cvs diff -u" diffs, there's a Python script "cvsdiff-fix.py" in the "tools" directory
in the Wireshark source tree; it will fix up those lines in "cvs diff" output. It reads its standard input by default, or can be given a file name on the command line, and writes to the standard output, so if you're typing at a command interpreter that does piping, you could do something such as
python tools/cvsdiff.py patchfile | patch -p0 -
to use "patchfile". (You might be able to leave the "python" out of the command line on many UN*Xes.)
"svn diff" doesn't produce a "diff -c" or "diff -u" line, so its output doesn't have that problem. Regu­lar "diff -c" or "diff -u" output also shouldn't have that problem.
38
Work with the Wireshark sources

3.11. Add a new file to the Subversion repository

The "usual" way to commit new files is described in Section 3.9, “Contribute your changes”. However, the following might be of interest for the "normal" developer as well.
Note!
This action is only possible/allowed by the Wireshark core developers who have write access to the Subversion repository. It is put in here, to have all information in one place.
If you (as a core developer) need to add a file to the SVN repository, then you need to perform the following steps:
1. Add the Wireshark boilerplate to the new file(s).
2. Add a line to each new file, containing the following text (case is important, so don't write ID
or id or iD):
$Id$
3. Add the new file(s) to the repository:
$ svn add new_file
4. Set the line ending property to "native" for the new file(s):
$ svn propset svn:eol-style native new_file
5. Set version keyword to "Id" for the new file(s):
$ svn propset svn:keywords Id new_file
6. Commit your changes, including the added file(s).
$ svn commit new_file other_files_you_modified
Don't forget a brief description of the reason for the commit, so other developers don't need to read the diff in order to know what has changed.
39
Work with the Wireshark sources

3.12. Binary packaging

Delivering binary packages, makes it much easier for the end-users to install Wireshark on their tar­get system. This section will explain how the binary packages are made.
3.12.1. Debian: .deb packages
The Debian Package is built using dpkg-buildpackage, based on information found in the source tree under debian. See http://www.debian-administration.org/articles/336 for a more in-depth discus­sion of the build process.
In the wireshark directory, type:
$ make debian-package
to build the Debian Package.
3.12.2. Red Hat: .rpm packages
The RPM is built using rpmbuild (http://www.rpm.org/), which comes as standard on many flavours of Linux, including Red Hat and Fedora. The process creates a clean build environment in pack-
aging/rpm/BUILD every time the RPM is built. The settings controlling the build are in pack­aging/rpm/SPECS/wireshark.spec.in. After editing the settings in this file, ./configure must be run again in the wireshark direcrory to generate the actual specification
script.
Warn!
The SPEC file contains settings for the configure used to set the RPM build envir­onment. These are completely independent of any settings passed to the usual Wire­shark ./configure.
In the wireshark directory, type:
$ make rpm-package
to build the RPM. Once it is done, there will be a message stating where the built RPM can be found.
Tip!
Because this does a clean build, as well as constructing the package, this can take quite a long time.
3.12.3. Win32: NSIS .exe installer
The "Nullsoft Install System" is a free installer generator for Win32 based systems; instructions how to install it can be found in Section 4.17, “Win32: NSIS (optional)”. NSIS is script based, you will find the Wireshark installer generation script at: packaging/nsis/wireshark.nsi.
You will probably have to modify the MAKENSIS setting in the config.nmake file to specify where the NSIS binaries are installed.
In the wireshark directory, type:
> nmake -f makefile.nmake packaging
to build the installer.
40
Work with the Wireshark sources
Tip!
Please be patient while the compression is done, it will take some time (a few minutes!) even on fast machines.
If everything went well, you will now find something like: wireshark-setup-0.99.7.exe in the packaging/nsis directory.
41
Work with the Wireshark sources
42

Chapter 4. Tool Reference

4.1. Introduction

This chapter will provide you with information about the various tools needed for Wireshark devel­opment.
None of the tools mentioned in this chapter is needed to run Wireshark, they are only needed to build it.
Most of these tools have their roots on UNIX like platforms, but Win32 ports are also available. Therefore the tools are available in different "flavours":
UNIX (or Win32 Cygwin): the tools should be commonly available on the supported UNIX platforms, and for Win32 platforms by using the Cygwin UNIX emulation
Win32 native: some tools are available as native Win32 tools, no special emulation is required
Warning!
Unless you know exactly what you are doing, you should strictly follow the re­commendations given in Chapter 2, Quick Setup!
The following sections give a very brief description of what a particular tool is doing, how it is used in the Wireshark project and how it can be installed and tested.
Don't expect a lot of documentation regarding these tools in this document. If you need further doc­umentation of a specific tool, you should find lot's of useful information on the web, as these tools are commonly used. You can also try to get help for the UNIX based tools with toolname -
-help or read the manpage man toolname.
You will find explanations of the tool usage for some of the specific development tasks in
Chapter 3, Work with the Wireshark sources.
43

4.2. Win32: Cygwin

Cygwin provides a lot of UNIX based tools on the Win32 platform. It uses a UNIX emulation layer which might be a bit slower compared to the native Win32 tools, but at an acceptable level. The in­stallation and update is pretty easy and done through a single (web based) setup.exe.
The native Win32 tools will typically be a bit faster, but more complicated to install, as you would have to download the tools from different webpages, and install them in different ways, tweaking the PATH and alike.
Note!
As there's no Win32 native bash version available, at least a basic installation of cyg­win is required in any case.
Although Cygwin consists of several separate packages, the installation and update is done through a single setup.exe, which acts similar to other web based installers. All tools will be installed into one base folder, the default is C:\cygwin.
You will find this network based setup.exe at: http://www.cygwin.com/. Click on one of the "Install Cygwin now" appearances to download the setup.exe. After the download completed, start this setup.exe on your machine.
Tool Reference
The setup will ask you for some settings, the defaults should usually work well for a first start. At the "Select Packages" page, you'll need to select some additional packages, which are not installed by default. Navigate to the required Category/Package row and click on the "Skip" item in the "New" column so it shows a version number for the required package
After clicking the Next button several times, the setup will then download and install the selected packages (this may take a while, depending on the package size).
Under: "Start -> Programs -> Cygwin -> Cygwin Bash Shell" you should now be able to start a new Cygwin bash shell, which is similar to the command line (command.com/cmd.exe) in Win32, but much more powerful.
4.2.1. Add/Update/Remove Cygwin Packages
If you want to add additional, update installed or remove packages later, you have to start the setup.exe again. At the "Select Packages" page, the entry in the "New" column will control what is done (or not) with the package. If a new version of a package is available, the new version number will be displayed, so it will be automatically updated. You can change the current setting by simply clicking at it, it will change between:
a specific version number - this different package version will be installed
Skip - not installed, no changes
Keep - already installed, no changes
Uninstall - uninstall this package
Reinstall - reinstall this package
44
Tool Reference

4.3. GNU compiler toolchain (UNIX or Win32 Cygwin)

4.3.1. gcc (GNU compiler collection)
Win32: Warn!
Using Cygwin gcc to compile Wireshark is "EXPERT ONLY" and therefore NOT re­commended. If you really want to try it anyway, see: http://wiki.wireshark.org/Devel-
opment/CygwinGCC for some details!
The GCC C compiler is available for most of the UNIX-like platforms and as the Devel/gcc package from the Cygwin setup.
If GCC isn't already installed or available as a package for your platform, you can get it at: http://
gcc.gnu.org/.
After correct installation, typing at the bash command line prompt:
$ gcc --version
should result in something like:
Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
However, the version string may vary.
gcc (GCC) 3.4.4 (cygwin special) (gdc 0.12, using dmd 0.125)
4.3.2. gdb (GNU project debugger)
GDB is the debugger for the GCC compiler. It is available for many (if not all) UNIX-like platforms and as the Devel/gdb package from the Cygwin setup
If you don't like debugging using the command line, there are some GUI frontends for it available, most notably GNU DDD.
If gdb isn't already installed or available as a package for your platform, you can get it at: http://
www.gnu.org/software/gdb/gdb.html.
After correct installation:
$ gdb --version
should result in something like:
Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-cygwin".
However, the version string may vary.
GNU gdb 6.5.50.20060706-cvs (cygwin-special)
4.3.3. ddd (GNU Data Display Debugger)
The GNU Data Display Debugger is a good GUI frontend for GDB (and a lot of other command line
45
debuggers), so you have to install GDB first. It is available for many UNIX-like platforms and as the ddd package from the Cygwin setup.
If GNU DDD isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.gnu.org/software/ddd/.
4.3.4. make (GNU Make)
Win32 Note!
Although some effort is made to use make from the Cygwin environment, the mainline is still using Microsoft Visual Studio's nmake.
GNU Make is available for most of the UNIX-like platforms and also as the Devel/make package from the Cygwin setup.
If GNU Make isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.gnu.org/software/make/.
After correct installation:
Tool Reference
$ make --version
should result in something like:
Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
However, the version string may vary.
GNU Make 3.81
46
Tool Reference

4.4. Microsoft compiler toolchain (Win32 native)

To compile Wireshark on Windows using the Microsoft C/C++ compiler, you'll need:
1. C compiler (cl.exe)
2. Linker (link.exe)
3. Make (nmake.exe)
4. C runtime headers and libraries (e.g. stdio.h, msvcrt.lib)
5. Windows platform headers and libraries (e.g. windows.h, WSock32.lib)
6. HTML help headers and libraries (htmlhelp.h, htmlhelp.lib)
4.4.1. Toolchain Package Alternatives
The Microsoft Visual C++ 2005 Express Edition is recommended to compile Wireshark - it's free (as in beer) and gives by far the best development comfort (compared to the other free packages).
However, you might already have a different Microsoft C compiler installed. With the following dif­ferences to the recommendations it's possible to use it as well:
Compiler Package
IDE / Debugger?
Publicly available?
Platform SDK
required?
con­fig.nmake:
MS­VC_VARIA NT
set compiler PATH and alike settings with:
Remarks
47
Tool Reference
Visual Stu­dio 6.0
Visual Stu­dio .NET (2002)
Visual Stu­dio .NET 2003
Visual Stu­dio 2005
Yes Commercial
1
MSVC6 Microsoft
Visual Stu­dio\VC98\Bi n\vcvars32.b at
Yes Commercial
1
MSVC2002 Microsoft
Visual Stu­dio .NET\Vc7\bi n\vcvars32.b at
2
No
Yes Commercial
1
MSVC2003 Microsoft
Visual Stu­dio .NET 2003\Vc7\bi n\vcvars32.b at
Yes Commercial MSVC2005 Microsoft
Visual Stu­dio 8\VC\bin\vc vars32.bat
-
-
-
-
Visual C++ 2005 Ex­press Edition
(recommend ed)
Visual Stu­dio 2008
(Code Name "Orcas")
Visual Stu­dio 2008 Ex­press Edition
(Code Name "Orcas")
Yes Free Down-
(474MB
load)
Yes Beta
Yes Beta
6
6
Free Down­load
(420MB)
2
No
2
No
MS­VC2005EE
­(not yet im-
plemented!)
­(not yet im-
plemented!)
Microsoft Visual Stu­dio 8\VC\bin\vc vars32.bat
Microsoft Visual Stu­dio
9.0\VC\bin\v cvars32.bat
Microsoft Visual Stu­dio
9.0\VC\bin\v cvars32.bat
vcre­dist_x86.exe
3
beta only
beta only
48
Tool Reference
.NET Frame­work SDK version 1.0a
.NET Frame­work SDK Version 1.1
.NET Frame­work 2.0
5
SDK
Windows SDK for Windows Vista and
.NET Frame­work 3.0 Runtime Components
No Free Down-
(104MB
load)
No Free Down-
5
(106MB
load)
No Free Down-
(363MB
load)
No Free Down-
(1188M
loadB)
Free Down-
load
(420MB)
2
No
DOTNET10 Mi-
crosoft.NET\ Frame­workS­DK\Bin\corv ars.bat
DOTNET11 Mi-
crosoft.NET\ SDK\v1.1\Bi n\sdkvars.bat
DOTNET20 Mi-
crosoft.NET\ SDK\v2.0\Bi n\sdkvars.bat
-
Microsoft SDKs\Wind
(not yet im­plemented!)
ows\v6.0\Bi n\SetEnv.C md
can't build
4
setup
can't build
4
setup
vcre­dist_x86.exe
3
vcre­dist_x86.exe
3
Color Legend: Good Not so good Might be a problem
1
no longer officially available, might still be available through the MSDN subscriptions
2
as the Platform SDK is already integrated in the package, you obviously don't need to install it and
don't even need to call a separate environment setting batch file for the Platform SDK!
3
vcredist_x86.exe (3MB free download) is required to build Wireshark-setup.exe
4
Wireshark-setup.exe cannot be created with this package, as msvcr*.dll is not available or not re-
distributable!
5
XXX - MSDN remarks that the corresponding .NET runtime is required. It's currently unclear if the runtime needs to be installed for the C compiler to work - or is this only needed to compile / run .NET programs?!?
6
beta version, not suitable for production use!
Note!
The "Visual C++ Toolkit 2003" should NOT be used to compile Wireshark!
4.4.2. Legal issues with MSVC > V6?
Please note: The following is not legal advice - ask your preferred lawyer instead! It's the authors view, but this view might be wrong!
The myriad of Win32 support lib port projects all seem to believe there are legal issues involved in
49
Tool Reference
using newer versions of Visual Studio. This FUD essentially stems from two misconceptions:
1. Unfortunately, it is believed by many that the Microsoft Visual Studio 2003 EULA explicitly
forbids linking with GPL'ed programs. This belief is probably due to an improper interpretation of the Visual Studio 2003 Toolkit EULA, which places redistribution restrictions only on SOURCE CODE SAMPLES which accompany the toolkit.
2. Other maintainers believe that the GPL itself forbids using Visual Studio 2003, since one of the
required support libraries (MSVCR71.DLL) does not ship with the Windows operating system.
This is also a wrongful interpretation, and the GPL FAQ explicitly addresses this issue. Similar applies to Visual Studio 2005 and alike. So in effect it should be perfectly legal to compile Wireshark and distribute / run it if it was com-
piled with any MSVC version > V6!
4.4.3. cl.exe (C Compiler)
The following table gives an overview of the possible Microsoft toolchain variants and their specific C compiler versions "ordered by release date":
Compiler Package cl.exe #define _MSC_VER required C-Runtime
DLL
Visual Studio 6.0 6.0 1200 msvcrt.dll
(Version 6)
Visual Studio .NET (2002)
7.0 1300 msvcr70.dll
.NET Framework SDK version 1.0a
Visual Studio .NET 2003
7.10 1310 msvcr71.dll
.NET Framework SDK Version 1.1
Visual Studio 2005
Visual C++ 2005 Ex­press Edition
.NET Framework 2.0 SDK
8.0 1400 msvcr80.dll
Windows SDK for Windows Vista and
.NET Framework 3.0 Runtime Components
Visual Studio 2008 (Code Name "Orcas")
9.0 1500 msvcr90.dll
50
Tool Reference
Visual Studio 2008 Ex­press Edition
(Code Name "Orcas")
After correct installation of the toolchain, typing at the command line prompt (cmd.exe):
> cl
should result in something like:
Copyright (C) Microsoft Corp 1984-1998. All rights reserved. usage: cl [ option... ] filename... [ /link linkoption...
However, the version string may vary.
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
4.4.4. nmake.exe (Make)
nmake is part of the toolchain packages described above. Instead of using the workspace (.dsw) and projects (.dsp) files, the traditional nmake makefiles are
used. This has one main reason: it makes it much easier to maintain changes simultaneously with the GCC toolchain makefile.am files as both file formats are similar. However, as no Visual Studio workspace/project files are available, this makes it hard to use the Visual Studio IDE e.g. for using the integrated debugging feature.
After correct installation, typing at the command line prompt (cmd.exe):
> nmake
should result in something like:
Copyright (C) Microsoft Corp 1988-1998. All rights reserved. NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
Microsoft (R) Program Maintenance Utility Version 6.00.9782.0
However, the version string may vary. Documentation on nmake can be found at Microsoft MSDN
4.4.5. link.exe (Linker)
XXX - add info here
4.4.6. C-Runtime "Redistributable" files
Please note: The following is not legal advice - ask your preferred lawyer instead! It's the authors view, but this view might be wrong!
Depending on the Microsoft compiler version you use, some binary files coming from Microsoft might be required to be installed on Windows machine to run Wireshark. On a developer machine, the compiler setup installs these files so they are available - but they might not be available on a user machine!
This is especially true for the C runtime DLL (msvcr*.dll), which contains the implementation of ANSI and alike functions, e.g.: fopen(), malloc(). The DLL is named like: msvcr<version>.dll, an abbreviation for "MicroSoft Visual C Runtime". For Wireshark to work, this DLL must be available
51
Tool Reference
on the users machine. MSVC6 was using msvcrt.dll, which is already available on all recent windows systems - no need to
redistribute anything. Starting with MSVC7, it is necessary to ship the C runtime DLL (msvcr<version>.dll) together with the application installer somehow, as that DLL is possibly not available on the target system.
Note!
The files to redistribute must be mentioned in the redist.txt file of the compiler pack­age - otherwise it can't be legally redistributed by third parties like us!
The following MSDN links are recommended for the interested reader:
"Redistributing Visual C++ Files"
"How to: Deploy using XCopy"
"Redistribution of the shared C runtime component in Visual C++ 2005 and in Visual C++
.NET"
4.4.6.1. msvcrt.dll - Version 6.0
Redistributables weren't an issue with MSVC 6, as any realistic installer target system (>= Win95) already contains the corresponding msvcrt.dll.
4.4.6.2. msvcr70.dll - Version 7.0 (2002)
"Visual Studio .NET (2002)" - comes with this dll and it's mentioned in redist.txt. ".NET Framework SDK 1.0" doesn't even come with this dll. XXX - Is this file available with
the .NET 1.0 runtime (dotnetfx.exe) - so it could be shipped instead?!? Do we want it that way?
4.4.6.3. msvcr71.dll - Version 7.1 (2003)
"Visual Studio .NET 2003" comes with this dll and it's mentioned in redist.txt. ".NET Framework SDK 1.1" comes with this dll, but it's NOT mentioned in redist.txt. XXX - Is this
file available with the .NET 1.1 runtime (dotnetfx.exe) - so it could be shipped instead ?!? Do we want it that way?
4.4.6.4. msvcr80.dll / vcredist_x86.exe - Version 8.0 (2005)
There are three redistribution methods that MSDN mentions for MSVC 8 (see: " Choosing a De-
ployment Method"):
1. "Redistributable Merge Modules" (kind of loadable modules for building msi installers - not
suitable for Wireshark's NSIS based installer)
2. copy the folder content of Microsoft.VC80.CRT to the target directory (e.g. "C:\program
files\Wireshark")
3. vcredist_x86.exe (needs to be executed on the target machine - MSDN recommends this for the
2005 Express Editions) To save installer size, MSVC2005 uses the content of Microsoft.VC80.CRT (method 2 - this is the
52
Tool Reference
smallest package). As MSVC2005EE and DOTNET20 doesn't provide the folder "Mi­crosoft.VC80.CRT" they use method 3. You'll have to download a vcredist_x86.exe from Microsoft that matches your compiler version. The best way to determine this version is to open one of the generated manifest files (e.g. wireshark.exe.manifest) and look for the version of the Mi­crosoft.VC80.CRT entry.
8.0.50608.0, from: "Microsoft Visual C++ 2005" (and probably the Express Edition as well): ht-
tp:/ / www.microsoft.com/ downloads/ de­tails.aspx?FamilyId=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en
8.0.50727.762, from: "Microsoft Visual C++ 2005 Express Edition - ENU Service Pack 1
(KB926748)": http:/ / www.microsoft.com/ downloads/ de-
tails.aspx?familyid=200B2FD9-AE1A-4A14-984D-389C36F85647&displaylang=en
Please report to the developer mailing list, if you find a different version number!
4.4.6.5. msvcr90.dll - Version 9.0 (2008)
As the corresponding C compiler is preliminary, it's too early to say!
4.4.7. Windows (Platform) SDK
The Windows Platform SDK (PSDK) is a free (as in beer) download and contains platform specific headers and libraries (e.g. windows.h, WSock32.lib, ...). As new Windows features evolve in time, updated PSDK's become available that include new and updated API's.
When you purchase a commercial Visual Studio, it will include a PSDK. The free (as in beer) down­loadable C compiler versions (VC++ 2005 Express, .NET Framework, ...) do not contain a PSDK ­you'll need to download a PSDK in order to have the required C header files and libraries.
Older Versions of the Platform SDK should also work. However, the command to set the environ­ment settings will be different, try search for SetEnv.* in the SDK directory.
BTW: "Windows SDK" seems to be the new name of the Platform SDK for Vista. The current SDK name is misleading: "Microsoft® Windows® Software Development Kit for Windows Vista™ and .NET Framework 3.0 Runtime Components" - translated this means: the Windows SDK for Win­dows Vista and Platforms (like WinXP) that have the .NET 3.0 runtime installed.
4.4.8. HTML Help
The HTML Help is used to create the User's and Developer's Guide in .chm format and to show the User's Guide as the Wireshark "Online Help".
Both features are currently optional, but might be mandatory in future versions.
4.4.8.1. HTML Help Compiler (hhc.exe)
This compiler is used to generate a .chm file from a bunch of HTML files - in our case to generate the User's and Developer's Guide in .chm format.
The compiler is only available as the free (as in beer) "HTML Help Workshop" download. If you want to compile the guides yourself, you need to download and install this. If you don't install it into the default directory, you may also have a look at the HHC_DIR setting in the file docbook/Make­file.
4.4.8.2. HTML Help Build Files (htmlhelp.c / htmlhelp.lib)
The files htmlhelp.c and htmlhelp.lib are required to be able to open .chm files from Wireshark - to show the "online help".
53
Tool Reference
Both files are part of the Platform SDK (standalone PSDK or MSVC since 2002). If you still use MSVC 6, you can get them from the "HTML Help Workshop" mentioned above.
The related settings in config.nmake depend on the MSVC variant you use:
MSVC 6: if the "HTML Help Workshop" is installed, set HHC_DIR to its directory
> MSVC 6: set HHC_DIR to use it (the actual value doesn't matter in this case)
4.4.9. Debugger
Well, using a good debugger can save you a lot of development time. The debugger you use must match the C compiler Wireshark was compiled with, otherwise the de-
bugger will simply fail or you will only see a lot of garbage.
4.4.9.1. Visual Studio integrated debugger
You can use the integrated debugger of Visual Studio - only available in some of the toolchain pack­ages.
However, setting up the environment is a bit tricky, as the Win32 build process is using makefiles instead of the .dsp/.dsw files usually used.
XXX - add instructions how to do it.
4.4.9.2. Debugging Tools for Windows
You could also use the Microsoft Debugging Tools for Windows toolkit, which is a standalone GUI debugger. Although it's not that comfortable compared to debugging with the Visual Studio integ­rated debugger, it can be helpful if you have to debug on a machine where an integrated debugger is not available.
You can get it free of charge at: http://www.microsoft.com/whdc/devtools/debugging/default.mspx (as links to microsoft pages change from time to time, search for "Debugging Tools" at their page if this link should be outdated).
54
Tool Reference

4.5. bash

The bash shell is needed to run several shell scripts.
4.5.1. UNIX or Win32 Cygwin: GNU bash
The bash shell is available for most of the UNIX-like platforms and as the bash package from the
Cygwin setup.
If bash isn't already installed or available as a package for your platform, you can get it at: http://
www.gnu.org/software/bash/bash.html.
After correct installation, typing at the bash command line prompt:
$ bash --version
should result in something like:
Copyright (C) 2005 Free Software Foundation, Inc.
However, the version string may vary.
GNU bash, version 3.1.17(6)-release (i686-pc-cygwin)
4.5.2. Win32 native: -
The authors don't know of any working Win32 native bash implementation.
55
Tool Reference

4.6. python

Python is an interpreter based programming language. The homepage of the python project is: http://
python.org/. Python is used to generate some source files. Python version 2.2 and above should be
working fine.
4.6.1. UNIX or Win32 Cygwin: python
Python is available for most of the UNIX-like platforms and as the python package from the Cyg-
win setup
If Python isn't already installed or available as a package for your platform, you can get it at: http://
www.python.org/.
After correct installation, typing at the bash command line prompt:
$ python -V
should result in something like:
Python 2.4.3
However, the version string may vary.
4.6.2. Win32 native: python
Have a look at http://python.org/download/to download the latest stable release. You can download a setup there, which will install the python system typically into C:\Python25 or similiar.
After correct installation, typing at the command line prompt (cmd.exe) - this must be entered in the Python directory, the installer won't set the PATH:
C:\Python25> python -V
should result in something like:
Python 2.5
However, the version string may vary.
56
Tool Reference

4.7. perl

Perl is an interpreter based programming language. The homepage of the perl project is: http:/ /
www.perl.com. Perl is used to convert various text files into usable source code. Perl version 5.6
and above should be working fine.
4.7.1. UNIX or Win32 Cygwin: perl
Perl is available for most of the UNIX-like platforms and as the perl package from the Cygwin
setup.
If perl isn't already installed or available as a package for your platform, you can get it at: http://
www.perl.com/.
After correct installation, typing at the bash command line prompt:
$ perl --version
should result in something like:
(with 1 registered patch, see perl -V for more detail) Copyright 1987-2005, Larry Wall Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page.
This is perl, v5.8.7 built for cygwin-thread-multi-64int
However, the version string may vary.
4.7.2. Win32 native: perl
A native Win32 perl package can be obtained from http://www.ActiveState.com. The installation should be straightforward.
After correct installation, typing at the command line prompt (cmd.exe):
> perl -v
should result in something like:
(with 1 registered patch, see perl -V for more detail) Copyright 1987-2002, Larry Wall Binary build 805 provided by ActiveState Corp. http://www.ActiveState.com
Built 18:08:02 Feb 4 2003 ...
This is perl, v5.8.0 built for MSWin32-x86-multi-thread
However, the version string may vary.
57
Tool Reference

4.8. sed

Sed it the streaming editor. It makes it easy for example to replace specially marked texts inside a source code file. The Wireshark build process uses this to stamp version strings into various places.
4.8.1. UNIX or Win32 Cygwin: sed
Sed is available for most of the UNIX-like platforms and as the sed package from the Cygwin setup. If sed isn't already installed or available as a package for your platform, you can get it at: http://dir-
ectory.fsf.org/GNU/sed.html
After correct installation, typing at the bash command line prompt:
$ sed --version
should result in something like:
Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, to the extent permitted by law.
However, the version string may vary.
GNU sed version 4.1.5
4.8.2. Win32 native: sed
A native Win32 sed package can be obtained from http://gnuwin32.sourceforge.net/. The installation should be straightforward.
58
Tool Reference

4.9. yacc (bison)

Bison is a free implementation of yacc.
4.9.1. UNIX or Win32 Cygwin: bison
Bison is available for most of the UNIX-like platforms and as the bison package from the Cygwin
setup.
If GNU Bison isn't already installed or available as a package for your platform, you can get it at:
http://www.gnu.org/software/bison/bison.html.
After correct installation, typing at the bash command line prompt:
$ bison --version
should result in something like:
Written by Robert Corbett and Richard Stallman. Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
However, the version string may vary.
bison (GNU Bison) 2.3
4.9.2. Win32 native: bison
A native Win32 yacc/bison package can be obtained from http://gnuwin32.sourceforge.net/. The in­stallation should be straightforward.
59
Tool Reference

4.10. flex

Flex is a free implementation of lexx.
4.10.1. UNIX or Win32 Cygwin: flex
Flex is available for most of the UNIX-like platforms and as the flex package from the Cygwin
setup.
If GNU flex isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.gnu.org/software/flex/.
After correct installation, typing at the bash command line prompt:
$ flex --version
should result in something like:
flex version 2.5.4
However, the version string may vary.
4.10.2. Win32 native: flex
A native Win32 lexx/flex package can be obtained from http://gnuwin32.sourceforge.net/. The in­stallation should be straightforward.
60
Tool Reference

4.11. Subversion (SVN) client (optional)

The Wireshark project uses its own Subversion (or short SVN) server to keep track of all the changes done to the source code. Details about the usage of Subversion in the Wireshark project can be found in Section 3.2, “The Wireshark Subversion repository”.
If you want to work with the source code and are planning to commit your changes back to the Wireshark community, it is recommended to use a SVN client to get the latest source files. For de­tailed information about the different ways to obtain the Wireshark sources, see Section 3.3, “Obtain
the Wireshark sources”.
You will find more instructions in Section 3.3.1, “Anonymous Subversion access” on how to use the Subversion client.
4.11.1. UNIX or Win32 Cygwin: svn
SVN is available for most of the UNIX-like platforms and as the Subversion package from the Cyg-
win setup
If Subversion isn't already installed or available as a package for your platform, you can get it at: ht-
tp://subversion.tigris.org/(together with the server software).
After correct installation, typing at the bash command line prompt:
$ svn --version
should result in something like:
svn, version 1.0.5 (r9954)
compiled Jun 20 2004, 23:28:30
Copyright (C) 2000-2004 CollabNet. Subversion is open source software, see http://subversion.tigris.org/ This product includes software developed by CollabNet (http://www.Collab.Net/).
...
However, the version string may vary.
4.11.2. Win32 native: svn
The Subversion command line tools for Win32 can be found at: http://subversion.tigris.org/. This will come with both client and server software - only the client software will be used.
After correct installation, typing at the command line prompt (cmd.exe):
> svn --version
should result in something like:
svn, Version 1.4.0 (r21228)
Copyright (C) 2000-2006 CollabNet. ...
However, the version string may vary.
61
Tool Reference

4.12. Subversion (SVN) GUI client (optional)

Along with the traditional command-line client, several GUI clients are available for a number of platforms, see http://subversion.tigris.org/project_links.html.
Keep Subversion program versions in sync!
If you are working with both command line and GUI clients, keep the Subversion pro­gram versions in sync, at least the major/minor versions (e.g. 1.4).
4.12.1. UNIX or Win32 Cygwin: rapidSVN, subcommander
RapidSVN is a cross platform Subversion frontend based on wxWidgets. It can be found at: http://
rapidsvn.tigris.org/. Subcommander is another cross platform Subversion frontend. It can be found
at: http://subcommander.tigris.org/. Cygwin doesn't provide any GUI client for Subversion.
4.12.2. Win32 native: TortoiseSVN
A good Subversion client for Win32 can be found at: http://tortoisesvn.tigris.org/. It will nicely in­tegrate into the Windows Explorer window.
62
Tool Reference

4.13. diff (optional)

Diff is used to get a file of all differences between two source files/trees (sometimes called a patch). The diff tool isn't needed for building Wireshark, but it's needed if you are going to commit your changes back to the Wireshark community.
Note!
The recommended way to build patches is using the Subversion client, see Sec-
tion 4.11, “Subversion (SVN) client (optional)” for details.
You will find more instructions in Section 3.9.2.3, “Using the diff tool” on how to use the diff tool.
4.13.1. UNIX or Win32 Cygwin: GNU diff
Diff is available for most of the UNIX-like platforms and as the diffutils package from the Cygwin
setup.
If GNU diff isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.gnu.org/software/diffutils/diffutils.html.
After correct installation, typing at the bash command line prompt:
$ diff --version
should result in something like:
Written by Paul Eggert, Mike Haertel, David Hayes, Richard Stallman, and Len Tower.
Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
However, the version string may vary.
diff (GNU diffutils) 2.8.7
4.13.2. Win32 native: diff
A native Win32 diff package can be obtained from http://gnuwin32.sourceforge.net/. The installa­tion should be straightforward.
The Subversion client TortoiseSVN has a built-in diff feature, see Section 4.12.2, “Win32 native:
TortoiseSVN”. It is currently unknown if this tool can be used to create diff files in the required
format, so other persons can use them.
63
Tool Reference

4.14. patch (optional)

The patch utility is used to merge a diff file into your own source tree. This tool is only needed, if you want to apply a patch (diff file) from someone else (probably from the developer mailing list) to try out in your own private source tree.
Tip!
Unless you are in the rare case needing to apply a patch to your private source tree, you won't need the patch tool installed.
You will find more instructions in Section 3.10, “Apply a patch from someone else” on how to use the patch tool.
4.14.1. UNIX or Win32 Cygwin: patch
Patch is available for most of the UNIX-like platforms and as the patch package from the Cygwin
setup.
If GNU patch isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.gnu.org/software/patch/patch.html.
After correct installation, typing at the bash command line prompt:
$ patch --version
should result in something like:
Copyright (C) 1988 Larry Wall Copyright (C) 2002 Free Software Foundation, Inc.
This program comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of this program under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING.
written by Larry Wall and Paul Eggert
However, the version string may vary.
patch 2.5.8
4.14.2. Win32 native: patch
A native Win32 patch package can be obtained from http://gnuwin32.sourceforge.net/. The installa­tion should be straightforward.
The Subversion client TortoiseSVN has a built-in patch feature, see Section 4.12.2, “Win32 native:
TortoiseSVN”. The last time tested (Version 1.1.0), this feature failed to apply patches known to be
ok.
64
Tool Reference

4.15. Win32: GNU wget (optional)

GNU wget is used to download files from the internet using the command line. GNU wget is available for most of the UNIX-like platforms and as the wget package from the Cyg-
win setup.
You will only need wget, if you want to use the Win32 automated library download, see Section 5.3,
“Win32: Automated library download” for details.
If GNU wget isn't already installed or available as a package for your platform (well, for Win32 it is available as a Cygwin package), you can get it at: http://www.gnu.org/software/wget/wget.html.
If wget is trying to download files but fails to do so, your Internet connection might use a HTTP proxy. Some Internet providers use such a proxy and it is common for company networks today. In this case, you must set the environment variable HTTP_PROXY before using wget. For example, if you are behind proxy.com which is listening on port 8080, you have to set it to something like:
set
HTTP_PROXY=http://proxy.com:8080/
If you are unsure about the settings, you might ask your system administrator.
65
Tool Reference

4.16. Win32: GNU unzip (optional)

GNU unzip is used to, well, unzip the zip files downloaded using the wget tool. GNU unzip is available for most of the UNIX-like platforms and as the unzip package from the
Cygwin setup.
You will only need unzip, if you want to use the Win32 automated library download, see Sec-
tion 5.3, “Win32: Automated library download” for details.
If GNU unzip isn't already installed or available as a package for your platform (well, for Win32 it is available as a Cygwin package), you can get it at: http://gnuwin32.sourceforge.net/packages/un-
zip.htm.
66
Tool Reference

4.17. Win32: NSIS (optional)

The NSIS (Nullsoft Scriptable Install System) is used to generate a wireshark-setup-<version>.exe from all the files needed to be installed, including all required DLL's and such.
To install it, simply download the latest released version (currently: 2.28) from http:/ /
nsis.sourceforge.net and start the downloaded installer. You will need NSIS version 2 final or high-
er. You will find more instructions in Section 3.12.3, “Win32: NSIS .exe installer” on how to use the
NSIS tool.
67
Tool Reference
68

Chapter 5. Library Reference

5.1. Introduction

Several libraries are needed to build / run Wireshark. Most of the libraries are split into three pack­ages:
1. Runtime package: binaries (e.g. win32 DLL's) and alike
2. Developer package: documentation, header files and alike
3. Source package: library sources, usually not required to build Wireshark
Tip!
Win32: All required libraries for the MSVC generation are available at: http://anons-
vn.wireshark.org/wireshark-win32-libs/trunk/packages/, but see Section 5.3, “Win32: Automated library download” for an easier way to install the libraries.
69
Library Reference

5.2. Binary library formats

Binary libraries are available in different formats, depending on the C compiler used to build it and of course the platform they were built for.
5.2.1. Unix
If you have installed unix binary libraries on your system, they will match the C compiler. If not already installed, the libraries should be available as a package from the platform installer, or you can download and compile the source and then install the binaries.
5.2.2. Win32: MSVC
Most of the Win32 binary libraries you will find on the web are in this format. You will recognize MSVC libraries by the .lib/.dll file extension.
5.2.3. Win32: cygwin gcc
Cygwin provides most of the required libraries (with file extension .a or .lib) for Wireshark suitable for cygwin's gcc compiler.
70
Library Reference

5.3. Win32: Automated library download

5.3.1. Initial download
You can download/install all required libraries by using the setup target of the Makefile.nmake from the source package.
Tip!
It's a really good idea to use the Win32 automated library download to install the re­quired libraries as it makes this download very easy.
Note!
Before you start the download, you must have installed both the required tools (see
Chapter 4, Tool Reference) and also the Wireshark sources (see Section 3.3, “Obtain the Wireshark sources”).
By default the libraries will be downloaded and installed into C:\wireshark-win32-libs. You can change this to any other location by editing the file config.nmake and changing the line containing the WIRESHARK_LIBS setting to your favourite place (use an absolute path here).
Then enter at the command line:
> nmake -f Makefile.nmake setup
This will first check for all the various tools needed to build Wireshark, as described already in Sec-
tion 2.2.7, “Verify installed tools”.
Then it will download the zipped libraries (together around 30MB!) from the server location at: ht-
tp:/ / anonsvn.wireshark.org/ wireshark-win32-libs/ trunk/ packages/ into the directory specified by
WIRESHARK_LIBS and install (unzip) all required library files there. If you have problems downloading the library files, you might be connected to the internet through a
proxy/firewall. In this case see the wget proxy comment in Section 4.15, “Win32: GNU wget
(optional)”.
5.3.2. Update of a previous download
As new versions of the libraries become available, maybe with bugfixes or some new functionality, your libraries get outdated.
You could simply remove everything in the WIRESHARK_LIBS dir and call the setup target again, but that would require a download of every file again, which isn't necessary.
The following will bring your libraries up to date:
Update your Wireshark sources to the latest SVN files (see Section 3.3, “Obtain the Wireshark
sources”), so the zip filenames in the setup target of Makefile.nmake are in sync with the library
zip files on the server.
Execute the library setup command as described above.
> nmake -f Makefile.nmake setup
Note that this command will automatically do a clean-setup which will remove all files pre­viously unzipped from the downloaded files in your WIRESHARK_LIBS library path (all the subdirs, e.g. c:\wireshark-win32-libs\gtk+), except for the zip files located at the
71
Library Reference
toplevel, which are the files downloaded the last time(s). Also note that as wget will download only the missing (updated) files, existing zip files in the
WIRESHARK_LIBS dir won't be downloaded again. Remaining (outdated) zip files shouldn't do any harm.
72
Library Reference

5.4. GTK+ / GLib / GDK / Pango / ATK / GNU gettext / GNU libiconv

The Glib library is used as a basic platform abstraction library, it's not related to graphical user inter­face (GUI) things. For a detailed description about GLib, see Section 7.3, “The GLib library”.
The GTK and its dependent libraries are used to build Wireshark's GUI. For a detailed description of the GTK libraries, see Section 10.2, “The GTK library”.
All other libraries are dependent on the two libraries mentioned above, you will typically not come in touch with these while doing Wireshark development.
As the requirements for the GLib/GTK libraries have increased in the past, the required additional libraries depend on the GLib/GTK versions you have. The 1.x versions only needed GLib/ GDK/GTK+, while the 2.x versions require all mentioned libs.
5.4.1. Unix
The GLib/GTK+ libraries are available for many unix-like platforms and cygwin. If these libraries aren't already installed and also aren't available as a package for your platform, you
can get them at: http://www.gtk.org.
5.4.2. Win32 MSVC
You can get the latest version at: http://www.gimp.org/%7Etml/gimp/win32/downloads.html.
73
Library Reference

5.5. Net-SNMP (optional)

"Various tools relating to the Simple Network Management Protocol"
5.5.1. Unix
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://sourceforge.net/projects/net-snmp/.
5.5.2. Win32 MSVC
Wireshark uses the source Net-SNMP distribution at http://sourceforge.net/projects/net-snmp/. lib­snmp is compiled with the "libsnmp - Win32 Release" project using MSVC++ 6.0. A file called "README.wireshark" has been placed in the net-snmp zip archive at http://anonsvn.wireshark.org/
wireshark-win32-libs/trunk/packages/describing the changes in more detail.
74
Library Reference

5.6. GNU adns (optional)

"Advanced, easy to use, asynchronous-capable DNS client library and utilities."
5.6.1. Unix
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.gnu.org/software/adns/.
5.6.2. Win32 MSVC
You can get the latest version at: http://adns.jgaa.com/
75
Library Reference

5.7. PCRE (optional)

"Perl compatible regular expressions"
5.7.1. Unix
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.pcre.org/.
5.7.2. Win32 MSVC
You can get the latest version at: http://gnuwin32.sourceforge.net/packages/pcre.htm
76

5.8. zlib (optional)

"zlib is designed to be a free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operat­ing system."
5.8.1. Unix
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.gzip.org/zlib/.
5.8.2. Win32 MSVC
You can get the latest version at: http://gnuwin32.sourceforge.net/packages/zlib.htm (A version for the MSVC2003 compiler can be found at: http://www.winimage.com/zLibDll/)
Library Reference
77
Library Reference

5.9. libpcap/WinPcap (optional)

"packet capture library"
5.9.1. Unix: libpcap
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.tcpdump.org/.
5.9.2. Win32 MSVC: WinPcap
You can get the "Windows packet capture library" at: http://www.winpcap.org/install/default.htm
78
Library Reference

5.10. GnuTLS (optional)

The "GNU Transport Layer Security Library" is used to dissect SSL and TLS protocols (aka: HT­TPS).
5.10.1. Unix
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.gnu.org/software/gnutls/download.html.
5.10.2. Win32 MSVC
We roll our own version using: http://josefsson.org/gnutls4win/
79
Library Reference

5.11. Gcrypt (optional)

The "Gcrypt Library" is Low-level encryption library and provides support for many ciphers, such as DES, 3DES, AES, Blowfish, and others..
5.11.1. Unix
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://directory.fsf.org/security/libgcrypt.html.
5.11.2. Win32 MSVC
Part of our homemade GnuTLS package.
80
Library Reference

5.12. Kerberos (optional)

The Kerberos library is used to dissect Kerberos, sealed DCERPC and secureLDAP protocols.
5.12.1. Unix
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://web.mit.edu/Kerberos/dist/.
XXX - Is it supported on *NIX at all?
5.12.2. Win32 MSVC
You can get the latest version of KfW "Kerberos for Windows" at: http://web.mit.edu/Kerberos/dist/
81

5.13. LUA (optional)

The LUA library is used to add scripting support to Wireshark.
5.13.1. Unix
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.lua.org/download.html.
5.13.2. Win32 MSVC
You can get the latest version at: http://luaforge.net/frs/?group_id=110
Library Reference
82
Library Reference

5.14. PortAudio (optional)

The PortAudio library enables audio output for RTP streams.
5.14.1. Unix
If this library isn't already installed or available as a package for your platform, you can get it at: ht-
tp://www.portaudio.com/download.html.
5.14.2. Win32 MSVC
You can get the latest version at: http://www.portaudio.com/download.html
83
Library Reference

5.15. Win32: GTK WIMP (optional) for GTK 2.x only

"GTK-Wimp ("Windows impersonator") is a GTK theme that blends well into the Windows desktop environment."
GTK-Wimp can be used to get a native Look-and-Feel on WinXP machines, especially with the "col­oured" WinXP theme. It will only take effect together with the GTK2 version of Wireshark.
No changes to the Wireshark sources are needed, GTK-Wimp simply changes the way GTK2 dis­plays the widgets (by changing the GTK2 default theme).
Wimp is available at: http://gtk-wimp.sourceforge.net/. Since GTK version 2.8 the GTK Wimp is included in the GTK releases where it's called "GTK MS
Windows Engine" now, so no need to download/install it separately if these versions used.
84
Library Reference
85
Part II. Wireshark Development
(incomplete)
Part I. Wireshark Build Environment The first part describes how to set up the tools, libraries and source needed to generate Wireshark,
and how to do some typical development tasks.
Part II. Wireshark Development The second part describes how the Wireshark sources are structured and how to change the
sources (e.g. adding a new dissector).
Loading...