User guide

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
Work with the Wireshark sources
32