First time here? Check out the FAQ!
THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

mixing c/c++ to write a plugin

Hello

After having spent a few hours in prototyping my custom protocol dissector with LUA, I decided to switch to C (Win10 x64 / VS2015 / 2.9.0rc of WS)

We already have a code base in some othre projects consuming that same protocol, but it is written in C++. Is it possible to use C++ to write a dissector plugin or am I stuck to C?

Thanks

Christophe

tof's avatar
3
tof
asked 2018-04-17 13:05:56 +0000
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

0

Yes. None of the core Wireshark plugins use C++, but WSGD does.

Note that Wireshark 2.9.x (and the up-coming 3.0) are built with VS2017. VS2015 should be OK, but it isn't tested.

grahamb's avatar
23.8k
grahamb
answered 2018-04-17 13:20:41 +0000
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

It can be done by dividing the protocol in C and C++ like below (creating DLMS plugin for wireshark. May want to refer my GitHub repository for the same:

#!/bin/sh
g++ -Wall -Wno-sign-compare -Wno-unused-variable -Wno-unused-function \
    `pkg-config --cflags-only-I wireshark` \
    -Iinclude \
    -shared \
    -fPIC \
    -o dlms.o \
    -c dlms.cpp \
&& \
ar rs libdlms.a dlms.o \
&& echo "libdlms.a created" \
&& rm dlms.o \
&& \
gcc -Wall -Wno-sign-compare \
    `pkg-config --cflags-only-I wireshark` \
    -Iinclude \
    -shared \
    -o dlms.so \
    proto.c libdlms.a \
&& echo "dlms.so created" \
&& rm libdlms.a \
&& sudo cp dlms.so /usr/lib/x86_64-linux-gnu/wireshark/plugins/3.2/epan \
&& echo "dlms.so copied to wireshark plugins" \
&& rm dlms.so
Himanshu's avatar
1
Himanshu
answered 2024-04-16 15:36:00 +0000, updated 2024-04-16 15:36:30 +0000
edit flag offensive 0 remove flag delete link

Comments

With proper use of extern "C" it may be possible to write it completely in C++ (if C++ compilers turn extern "C" functions into code that follows the platform's C ABI/procedure call interface).

Guy Harris's avatar Guy Harris (2024-04-17 04:25:57 +0000) edit

Actually your argument is rightly directed and I did try that earlier but I faced some issues.

Himanshu's avatar Himanshu (2024-06-04 20:44:03 +0000) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer