Ask Your Question
0

Can multiple taps listeners use the same "void *tapdata" parameter?

asked 2024-11-12 15:45:14 +0000

David000 gravatar image

updated 2024-11-12 15:45:42 +0000

All tap listeners would be registered in the same file. Each tap listener would listen to different protocol. The purpose is that they all have access to the same variable (struct), which is made possible by using the same variable tapdata, which is the 2nd parameter of function register_tap_listener().

I tried to register another tap listener in the file "ui/mcast_stream.c". For each tap I created its own ..._packet() function and it worked perfectly, but when I close the window of the table of this multicast statistics, the wireshark crashes due to "segmentation fault".

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2024-11-13 08:50:48 +0000

johnthacker gravatar image

From README.tapping:

The tap system uses the value of this pointer to distinguish between different instances of a tap. Just make sure that it is unique by letting it be the pointer to a struct holding all state variables. If you want to allow multiple concurrent instances, just put ALL state variables inside a struct allocated by g_new() and use that pointer.

The same paragraph is in epan/tap.h in the comments above register_tap_listener. Sharing the parameter will probably lead to either memory leaks or invalid memory accesses, especially upon destruction. Note that remove_tap_listener uses the tapdata.

It might be possible to rewrite mcaststream_reset and other functions to make it possible to share an object, but it's not supported.

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: 2024-11-12 15:45:14 +0000

Seen: 68 times

Last updated: Nov 13