ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] Tr : Dissector preferences reuse

From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Thu, 23 Apr 2009 11:50:36 -0400


yvanmmailbox-web@xxxxxxxx wrote:

I 'm working on 2 plugin dissectors, and I wish to know if it's possible (and if yes, how) to reuse preferences from one plugin to another. I need to reuse only a part of the preferences (which is an UAT table, so pretty long and boring to define) from plugin1 to plugin2, considering that protocol2 is included in plugin1 like this:
plugin1
    IP struct
        UDP struct
            plugin2
Can the copy_prefs() function be useful? How must I define the preferences in plugin1 to divide it in 2 parts? How to integrate a separated part into preferences of plugin2?

Well, the plugins could simply share the variable that stores the preference. Basically: make the variable not 'static' (so it is visible to other modules), put it in a header file (properly 'extern'd), and have both plugins include the header file and use the variable.

For an example, see the mtp3_standard preference in packet-mtp3.{h,c}.

Note: I know this works for regular dissectors but I don't know if the rules are different for plugins--especially on Windows.