About the SaunaFS Wireshark plugin
===================================

This directory contains a Python and Bash scripts which generate a plugin
(dissector) for Wireshark (http://www.wireshark.org/) which adds support for
the SaunaFS protocol. This plugin is compiled into a saunafs.so shared
library to make it easily redistributable.

To learn more about Wireshark dissectors see:
https://www.wireshark.org/docs/wsdg_html_chunked/ChapterDissection.html

----

Follow below steps to install SaunaFS Wireshark plugin:

1) Ensure you have the following packages installed (for Debian and Ubuntu):

        # apt install wireshark cmake libcap-dev libglib2.0-dev bison flex libcrypto++-dev libc-ares-dev libgcrypt20 libgcrypt20-dev libspeexdsp1 libspeexdsp-dev

2) If you want to be able to sniff interfaces without root privileges follow
   instructions from /usr/share/doc/wireshark-common/README.Debian (same steps
   for Ubuntu):

        # apt install wireshark
        # dpkg-reconfigure wireshark-common
        # usermod -a -G wireshark $USER
        # reboot
        # chmod +s /usr/bin/dumpcap

   If you haven't installed Wireshark yet, you can find instructions here:
   https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=debian/README.Debian;hb=HEAD

3) Set some variables:

        $ export SAUNAFS_SRCDIR=$(cd ../../; pwd)
        $ export WIRESHARK_SRCDIR=/tmp/wireshark/
        $ WIRESHARK_VERSION=$(wireshark --version | head -1 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')  # get version by invoking wireshark --version

4) Clone the Wireshark sources, e.g.:

        $ git clone https://gitlab.com/wireshark/wireshark.git "$WIRESHARK_SRCDIR"

5) Checkout your version of Wireshark:

        $ cd "$WIRESHARK_SRCDIR" && git checkout wireshark-$WIRESHARK_VERSION

6) Copy contents of this directory to the Wireshark source directory:

        $ tar -C "$SAUNAFS_SRCDIR"/utils/wireshark -c . | tar -C "$WIRESHARK_SRCDIR" -vx

7) Run the generate.sh script (provide path to the SFSCommunication file as an
   argument):

        $ "$WIRESHARK_SRCDIR"/plugins/epan/saunafs/generate.sh "$SAUNAFS_SRCDIR"/src/protocol/SFSCommunication.h

8) Edit the main CMakeLists.txt file in the Wireshark source tree to add the
   new plugin:

        $ vim "$WIRESHARK_SRCDIR"/CMakeLists.txt
```
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1804,6 +1804,7 @@ if(ENABLE_PLUGINS)
                plugins/epan/mate
                plugins/epan/opcua
                plugins/epan/profinet
+               plugins/epan/saunafs
                plugins/epan/stats_tree
                plugins/epan/transum
                plugins/epan/unistim
```


9) Build the Wireshark using cmake (you don't have to build the GUI):

        $ mkdir "$WIRESHARK_SRCDIR"/build
        $ cd "$WIRESHARK_SRCDIR"/build
        $ cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_wireshark=NO
        $ nice nice make -j$(nproc)

10) To install the plugin copy saunafs.so library to the personal plugin
    folder:

        $ mkdir -p ${PERSONAL_CONFIG_DIR}/epan
        $ cp "$WIRESHARK_SRCDIR"/build/run/saunafs.so ${PERSONAL_CONFIG_DIR}/epan

    or global plugin folder:

        # cp "$WIRESHARK_SRCDIR"/build/run/saunafs.so ${GLOBAL_CONFIG_DIR}/epan

    ${PERSONAL_CONFIG_DIR} and ${GLOBAL_CONFIG_DIR} are dependent on your
    system and Wireshark version. You can determine them by running Wireshark
    and navigating to:

        Help > About Wireshark > Folders

    E.g. for Wireshark 2.6.7:

        PERSONAL_CONFIG_DIR=~/.local/lib/wireshark/plugins/2.6
        GLOBAL_CONFIG_DIR=/usr/lib/x86_64-linux-gnu/wireshark/plugins/2.6/
            or for 4.4.3 =/usr/lib/x86_64-linux-gnu/wireshark/plugins/4.4/epan/

12) Enjoy!

    This plugin recognizes the SaunaFS protocol using TCP port numbers. If you
    use non-standard ports (9419-9422) you need to change them in:

        Edit -> Preferences -> Protocols -> SaunaFS

    E.g. to parse the communication in our test suite set SaunaFS TCP ports to:

        9419-9422,25000-25015
