From 2be58f758402010f35d67279bec7125c9665e936 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Sat, 25 Apr 2020 22:03:29 +0200 Subject: [PATCH] MINOR: contrib: make the peers wireshark dissector a plugin The wireshark dissector could only be build within wireshark, which means maintaining a wireshark binary just for this dissector. It was not really convenient to update wireshark because of this. This patch converts the dissector into a .so plugin which is built with the .h found in distributions instead of the whole wireshark sources. --- contrib/wireshark-dissectors/peers/Makefile | 17 ++++++++ contrib/wireshark-dissectors/peers/README | 43 ++++++++++++++++++- .../wireshark-dissectors/peers/packet-happp.c | 25 +++++++++-- 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 contrib/wireshark-dissectors/peers/Makefile diff --git a/contrib/wireshark-dissectors/peers/Makefile b/contrib/wireshark-dissectors/peers/Makefile new file mode 100644 index 000000000..9e70802fb --- /dev/null +++ b/contrib/wireshark-dissectors/peers/Makefile @@ -0,0 +1,17 @@ +CFLAGS = `pkg-config --cflags wireshark` -g -fPIC +LDFLAGS = `pkg-config --libs wireshark` + +NAME = packet-happp.so +OBJS = packet-happp.o + +plugins=$(HOME)/.wireshark/plugins/ + +$(NAME): $(OBJS) + $(CC) -shared $(LDFLAGS) $(OBJS) -o $@ + +install: $(NAME) + install -d $(DESTDIR)$(plugins) + install -m 0755 $(NAME) $(DESTDIR)$(plugins) + +clean: + rm $(NAME) $(OBJS) diff --git a/contrib/wireshark-dissectors/peers/README b/contrib/wireshark-dissectors/peers/README index a81e98cfa..78cafcd5f 100644 --- a/contrib/wireshark-dissectors/peers/README +++ b/contrib/wireshark-dissectors/peers/README @@ -15,7 +15,7 @@ on Windows systems (could not be tested). packet-happp.c file DISSECTOR_SRC variable which list all wireshark - README: this file. -2) To build wireshark with HAPPP dissection support +2a) To build wireshark with HAPPP dissection support --------------------------------------------------- - Download wireshark sources: $ git clone https://code.wireshark.org/review/wireshark @@ -25,3 +25,44 @@ on Windows systems (could not be tested). $ ./autogen.sh $ ./configure $ make + +2b) Alternative: build the HAPPP dissector as a wireshark plugin +----------------------------------------------------------------- +If you don't want to build completely wireshark, you can build the dissector as +a plugin. + +You will need the development package of your distribution, which is +"libwireshark-dev" for debian based distribution and "wireshark-dev" for +redhat-based ones. + +$ make + +To install it in your home directory: + +$ make install + +The plugin will be installed in ~/.wireshark/plugins/ by default, but you can +change this path by setting the "plugins" variable. If it didn't work, check +the paths in "Help > About Wireshark > Folders > Personal Plugins" which should +give you the right path to use. + +In some distribution it will be in ~/.local/lib/wireshark/ so you will need to +install it this way: + +$ make install plugins=~/.local/lib/wireshark/plugins/3.2/epan/ + +If you want to install it in the system directory you can do it this way, the +righ path is also in the Folder window. Change the plugins variable this way: + +$ sudo make install plugins=/usr/lib64/wireshark/plugins/3.2/epan/ + +Be careful to use the right version number in the path. + +3) Check if you have the dissector in wireshark +----------------------------------------------- +To verify if the protocol was well loaded by your wireshark, open the Supported +Protocols window in "View > Internals > Supported Protocols" and look for +"HAPPP". + +In the case of a plugin, you should see your plugin loaded in "Help > About +Wireshark > Plugins". diff --git a/contrib/wireshark-dissectors/peers/packet-happp.c b/contrib/wireshark-dissectors/peers/packet-happp.c index 33263b418..3490d8b9e 100644 --- a/contrib/wireshark-dissectors/peers/packet-happp.c +++ b/contrib/wireshark-dissectors/peers/packet-happp.c @@ -27,12 +27,22 @@ #include #include + #include #include #include #include -#include "strutil.h" -#include "packet-tcp.h" +#include +#include +#include + +#include + +WS_DLL_PUBLIC_DEF const gchar plugin_version[] = "0.0.1"; +WS_DLL_PUBLIC_DEF const int plugin_want_major = WIRESHARK_VERSION_MAJOR; +WS_DLL_PUBLIC_DEF const int plugin_want_minor = WIRESHARK_VERSION_MINOR; +WS_DLL_PUBLIC void plugin_register(void); + #define HAPPP_PROTOCOL "HAProxyS" #define HAPPP_MSG_MIN_LEN 2 @@ -49,7 +59,6 @@ #include #include -#include "tvbuff.h" #ifdef DEBUG static unsigned char dbg_buf[16 << 10]; @@ -1630,3 +1639,13 @@ proto_reg_handoff_happp(void) proto_happp, HEURISTIC_ENABLE); } + +void +plugin_register(void) +{ + static proto_plugin plug; + + plug.register_protoinfo = proto_register_happp; + plug.register_handoff = proto_reg_handoff_happp; + proto_register_plugin(&plug); +}