Wireshark-dev: Re: [Wireshark-dev] Documentation : 9.6. How to produce protocol stats plugin_re

From: wsgd <wsgd@xxxxxxx>
Date: Thu, 24 Dec 2020 12:11:02 +0100
Hello,

About plugin_register_tap_listener is never called


5) WS_DLL_PUBLIC_DEF void plugin_register_tap_listener(void) does not compile :
Solution :
Add :
/* plugins are DLLs */
#define WS_BUILD_DLL
#include "ws_symbol_export.h"
This must be done BEFORE include epan/...


6) WS_DLL_PUBLIC_DEF void plugin_register_tap_listener(void) is never called
NB: looking at ws_symbol_export.h and looking at intellisense, WS_DLL_PUBLIC_DEF = __declspec(dllexport)
Also tried WS_DLL_PUBLIC (as used for plugin_register in plugin.c) = WS_DLL_PUBLIC_DEF extern = __declspec(dllexport) extern

plugin_register is referenced in plugins.c :  if (!g_module_symbol(handle, "plugin_register", &symbol)) {
plugin_register_tap_listener is NOT referenced/used anywhere (master or 3.4)


Thanks,
Olivier

Le 23/12/2020 à 14:35, Jaap Keuter a écrit :
Hi,

Thanks for having a look and reporting back. This could have been done as a merge request, this works as well. I’ve created one on your behalf, see WSDG: update protocol stats section to match current API

Further comments are inline.

Thanks,
Jaap

On 20 Dec 2020, at 10:32, wsgd <wsgd@xxxxxxx> wrote:

Hello all,


Questions/remarks about https://www.wireshark.org/docs/wsdg_html_chunked/ChDissectStats.html


1) An include is missing :
Solution :
Add #include <epan/stats_tree.h>


Done


2) msgtypevalues does not exist
Solution :
Replace "msgtypevalues" by "packettypenames"
 to be conform with previous § 9.2.3. Improving the dissection information (https://www.wireshark.org/docs/wsdg_html_chunked/ChDissectAdd.html)


Done


3) st_node_packets = stats_tree_create_node(st, st_str_packets, 0, TRUE); does not compile
Solution :
Replace it by :
    st_node_packets = stats_tree_create_node(st, st_str_packets, 0, STAT_DT_INT, TRUE);


Done


4) foo_stats_tree_packet has bad prototype
Solution :
foo_stats_tree_packet should return tap_packet_status / TAP_PACKET_REDRAW (instead of int / 1)



Done


About register_foo_stat_trees

5) WS_DLL_PUBLIC_DEF void plugin_register_tap_listener(void) does not compile :
1>T:\wireshark\dev\build_sources_3.4--win64\wireshark\plugins\epan\foo\packet-foo.c(192,1): error C2491: 'plugin_register_tap_listener' : définition de fonction dllimport non autorisée
1>Génération du projet "foo.vcxproj" terminée -- ÉCHEC.
"Solution" :
Use __declspec(dllexport) instead of WS_DLL_PUBLIC_DEF


Nope, this is what ws_symbol_export.h is in place for, to have a cross platform abstraction of dynamically linked identifiers. The build system has to take care of this, the Windows one is especially finicky about the details.


6) __declspec(dllexport) void plugin_register_tap_listener(void) is never called
Solution ? :
- remove it
- call directly register_foo_stat_trees(); from proto_reg_handoff_foo

It is the good way to do ?


Again, this is what the build system is taking care of, to create cross platform abstractions of the dynamic link linking.


Thanks,
Olivier



___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe