Ask Your Question
0

mixing c/c++ to write a plugin

asked 2018-04-17 13:05:56 +0000

tof gravatar image

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

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2024-04-16 15:36:00 +0000

Himanshu gravatar image

updated 2024-04-16 15:36:30 +0000

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
edit flag offensive delete link more

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 gravatar imageGuy 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 gravatar imageHimanshu ( 2024-06-04 20:44:03 +0000 )edit
0

answered 2018-04-17 13:20:41 +0000

grahamb gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-04-17 13:05:56 +0000

Seen: 1,149 times

Last updated: Apr 16