Hi,
thanks for this help, Jeff, sharing variable is a good idea. I tried with a
range_t used for user-defined udp ports like that:
in packet-plugin1.h:
extern range_t *bite_udp_range;
in packet-plugin1.c:
#include "packet-plugin1.h"
...
range_t *bite_udp_range;
...
/*in proto_register_plugin1*/
range_convert_str(&global_bite_udp_range, BITE_UDP_DEFAULT_RANGE, 65535);
bite_udp_range = range_empty();
prefs_register_range_preference(afdx_module, "bite_udp_port",
"UDP Ports for BITE",
"Enter ports separated by commas",
&global_bite_udp_range, 65535);
...
/*in proto_reg_handoff*/
bite_udp_range = global_bite_udp_range;
in packet-plugin2.c:
#include "packet-plugin1.h"
...
range_t *bite_udp_range;
...
/* in proto_reg_handoff, the dissector_adding() calls dissector_add*/
range_foreach(bite_udp_range, dissector_adding);
The declaration in plugin1 seems good as WS works with this plugin only, but it
crashes ("WireShark has encountered a problem and must closed...") with the two
together. I copied the header file in the two folders to do that. I was
suprised because I needed to declare again bite_udp_range in *.c files to avoid
error during linking. Is something wrong? I suppose the range isn't defined
when plugin2 is called so it can't add the dissector properly, but I'm not
sure...
I also found in proto.h the following statement:
/** The header-field index for the special text pseudo-field. Exported by
libwireshark.dll */
WS_VAR_IMPORT int hf_text_only;
I don't know how to use it in plugin1, but could this WS_VAR_IMPORT be a
solution to share a variable between 2 dlls?
Thanks for your help
Yvan
________________________________
De : Jeff Morriss <[email protected]>
À : Developer support list for Wireshark <[email protected]>
Envoyé le : Jeudi, 23 Avril 2009, 17h50mn 36s
Objet : Re: [Wireshark-dev] Tr : Dissector preferences reuse
[email protected] 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.
___________________________________________________________________________
Sent via: Wireshark-dev mailing list <[email protected]>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
mailto:[email protected]?subject=unsubscribe
___________________________________________________________________________
Sent via: Wireshark-dev mailing list <[email protected]>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
mailto:[email protected]?subject=unsubscribe