Closed SuperBigYB closed 6 months ago
I don't know Wireshark code/API so well, however:
I don't know Wireshark code/API so well, however:
- could you share how to compile and run your code?
- I don't know what you are trying to achieve, but you can use ndpiReader as extcap with un-modified Wireshark and view flow classification directly from the GUI....
thank you for reply, you can use cmake like:
cmake_minimum_required(VERSION 3.13)
project(untitled)
add_executable(${PROJECT_NAME} main.cpp)
# include
target_include_directories(${PROJECT_NAME} PRIVATE
/usr/include/glib-2.0
/usr/lib/x86_64-linux-gnu/glib-2.0/include/
/usr/local/include/wireshark/
)
target_link_libraries(${PROJECT_NAME} pcap glib-2.0 wireshark wiretap wsutil ndpi)
after apt install libwireshark-dev
to run it.
No crashes on my machine so far. If you're using a debian based distro, you may also try /usr/include/wireshark/
instead of /usr/local/include/wireshark/
. That should be the directory where the package libwireshark-dev
places it's header files.
It crashes from time to time, but only with -O0
(tried also: -Og
, -Os
, -O1
, -O2
, -O3
):
AddressSanitizer:DEADLYSIGNAL
=================================================================
==36830==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000013 (pc 0x7f775670ba87 bp 0x614000000240 sp 0x7ffdd555f1e0 T0)
==36830==The signal is caused by a READ memory access.
==36830==Hint: address points to the zero page.
#0 0x7f775670ba87 in write_psml_columns (/lib/x86_64-linux-gnu/libwireshark.so.16+0x230ba87)
#1 0x564e69bc7ae4 in handle_pkt(unsigned char*, pcap_pkthdr const*, unsigned char const*) /home/toni/git/ndpi-wireshark/main.cpp:190
#2 0x7f775c64a909 (/lib/x86_64-linux-gnu/libpcap.so.0.8+0x24909)
#3 0x7f775c635cee in pcap_loop (/lib/x86_64-linux-gnu/libpcap.so.0.8+0xfcee)
#4 0x564e69bc7d67 in main /home/toni/git/ndpi-wireshark/main.cpp:221
#5 0x7f7753c46249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#6 0x7f7753c46304 in __libc_start_main_impl ../csu/libc-start.c:360
#7 0x564e69bc74a0 in _start (/home/toni/git/ndpi-wireshark/main+0x34a0)
This is most likely not related to nDPI.
But to be sure: please try adding -fsanitize=address
to your CFLAGS
and upload any crash traces here.
This is most likely not related to nDPI. But to be sure: please try adding to your and upload any crash traces here.
-fsanitize=address``CFLAGS
Thank you for your reply.
I modified and simplified the code according to your suggestions: ws.c:
#include <epan/epan.h>
#include <epan/timestamp.h>
#include <ndpi/ndpi_api.h>
#include <stdio.h>
#include <wsutil/privileges.h>
#include <wsutil/report_message.h>
#include <wsutil/wslog.h>
static void ws_perror(const char *format, va_list ap) {
vfprintf(stderr, format, ap);
}
int main() {
printf("start\n");
ws_log_init("ws_test", ws_perror);
ws_log_set_level(LOG_LEVEL_NOISY);
struct report_message_routines rmr;
rmr.vreport_failure = ws_perror;
init_report_message("ws_test", &rmr);
timestamp_set_type(TS_RELATIVE);
timestamp_set_precision(TS_PREC_AUTO);
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
init_process_policies();
wtap_init(false);
int ret = epan_init(NULL, NULL, false);
if (ret) {
printf("\nsuccess\n");
exit(EXIT_SUCCESS);
}else {
printf("\nfail\n");
exit(EXIT_FAILURE);
}
}
CMakeLists.txt:
cmake_minimum_required(VERSION 3.13)
project(untitled C)
add_executable(${PROJECT_NAME} ws.c)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
# include
target_include_directories(${PROJECT_NAME} PRIVATE
/usr/include/glib-2.0
/usr/lib/x86_64-linux-gnu/glib-2.0/include/
/usr/include/wireshark/
)
target_link_libraries(${PROJECT_NAME}
glib-2.0 wireshark wiretap wsutil
# ndpi # if add ndpi, epan_init() will fail
)
When I link nDPI in CMakeLists.txt, Wireshark's epan_init() will fail.
@SuperBigYB
I am able to reproduce the issue with your latest snapshot.
My 2 cents: wireshark code is linking to nDPI internal implementation of gcry_md_open()
instead of the standard one in in libgcrypt.
Try to:
--local-libgcrypt
flag@SuperBigYB
I am able to reproduce the issue with your latest snapshot.
My 2 cents: wireshark code is linking to nDPI internal implementation of
gcry_md_open()
instead of the standard one in in libgcrypt. Try to:
- compile nDPI with
--local-libgcrypt
flag- link your code to that version of nDPI and to libgcrypt
@IvanNardi
thanks,
According to your answer, I used --with-local-libgcrypt
to test successfully.
Could you please tell me what impact adding this flag will have on nDPI?
@IvanNardi thanks, According to your answer, I used
--with-local-libgcrypt
to test successfully. Could you please tell me what impact adding this flag will have on nDPI?
Short answer: non real differences: nDPI has the same capabilities in both cases, and, AFAIK, the same performance.
nDPI needs some low-level cryptographic algorithms: it can get them or from an internal, simplified, implementation (default) or via the external libgcrypt library (--with-local-libgcrypt
).
For some users, in some constraint environments, it is important to not have (another) external dependency.
BTW, libgcrypt is the same library used by Wireshark...
谢谢,根据你的回答,我曾经测试成功。您能告诉我添加此标志将对 nDPI 产生什么影响吗?
--with-local-libgcrypt
简短的回答:非实际差异:nDPI 在两种情况下具有相同的功能,并且 AFAIK 具有相同的性能。
nDPI 需要一些低级加密算法:它可以从内部简化的实现(默认)或通过外部 libgcrypt 库 () 获取它们。对于某些用户来说,在某些约束环境中,没有(另一个)外部依赖关系是很重要的。
--with-local-libgcrypt
顺便说一句,libgcrypt 与 Wireshark 使用的库相同......
@IvanNardi Thank you very much. Your answer perfectly solved my problem.
Describe the bug
The epan_init() function of wireshark reports an error after linking nDPI:
Dissector bug: epan/dissectors/packet-wireguard.c:416: failed assertion "DISSECTOR_ASSERT_NOT_REACHED"
nDPI Environment (please complete the following information):
How to reproduce the reported bug
Before linking nDPI, my simple example of using libwireshark-dev works properly But after the nDPI is linked, the epan_init() function of wireshark reports an error:
Distributor bug: epan/transmitters/packet wireguard. c: 416: failed assertion "DISSECTOR_ASSERT_NOT_RECHED"
Additional context