Wireshark-dev: Re: [Wireshark-dev] Registering header fields later/in other functions?
From: Andreas <[email protected]>
Date: Tue, 15 Feb 2011 07:14:02 +0100
Am 13.02.2011 18:58, schrieb Thomas Wiens:
On 2/13/2011 9:36 AM, Andreas wrote:

I have dissectors classes that are spreaded over a lot of source files.
When Wireshark calls the function plugin_register() of my dissector, all
classes' Register() functions are called. So there is no problem with
making a dissector modular.
This seems to be a good soulution, thanks.
Most of the dissectors in the wireshark sources are only in one big
file, so there is not much where I can take a look at, which way is the
usually one.
Wireshark supports a lot of protocol. If a intrinsic dissectors would be spreader over several source files, this would require some naming scheme to identify what files belong to a protocol. Further with means of the C language you can define private variables like header fields and subtree arrays as static. That requires that the dissector is in one compilation unit.
Do you register the possible subtree arrays in the same way?
Yes, I do. Usually each class dissects one block that can be added as a tree. Since this block is a logical unit it makes sense to handle this in a class. Of course the class has it's own ett member that it initializes with proto_register_subtree_array().
The proto_register_subtree_array() call doesn't need the proto-id. Seems
as if I can register a new pointer-array in every file, or not?
Well you need the proto-id here and there. Therefore my dissector singleton that's called by Wireshark also provides the proto-id.