Hi Zoran,
Le ven. 18 août 2023 à 17:36, Zoran Bošnjak a écrit :
> Dear wireshark developers,
> I am rewriting asterix dissector. There are some open problems on asterix,
> which are almost impossible to resolve in the current setting.
>
> The idea is to split the code between pure generated code (with all
> asterix items and other asterix related definitions), but which does not
> depend on wireshark internals at all, something like this:
>
> https://gitlab.com/zoranbosnjak/wireshark/-/blob/8db96a7226ed6c7efc60aca6313adbb6957ac35a/epan/dissectors/asterix-specs.h
>
> ... and the packet-asterix.c file which does what is necessary to dissect
> asterix. It includes the asterix-specs.h file. Something like this:
>
> https://gitlab.com/zoranbosnjak/wireshark/-/blob/8db96a7226ed6c7efc60aca6313adbb6957ac35a/epan/dissectors/packet-asterix.c
>
> The reason for a pure asterix-specs.h file is that it reduces the
> maintenance, since the same code could be used in any asterix related C
> project. It is also much shorter since the same definitions are defined
> only once. I could even check it alone with "gcc -Wall asterix-specs.h".
> And the packet-asterix.c becomes cleaner and shorter too.
>
> I have made some progress with this approach (see the 'asterix' branch in
> the repository above), but I am now facing the problem with 'hf' array in
>
> proto_register_field_array (proto_asterix, hf, array_length (hf));
>
> ...which is currently specified in the source code (statically known at
> compile time for each item).
>
> What would be the best way to populate this (hf) array at the
> initialization time or even during dissecting?
> The number of all distinct items is known at compile time, so the
> necessary memory could be prepared without any dynamic allocation, for
> example
>
> static int hf_generated_items[TOTAL_ITEM_COUNT];
> for (int i=0; i
> Are there any examples on other generated dissectors, where hf array is
> initialized at runtime?
>
See packet-diameter.c and its use of the proto_register_prefix() function
for example.
Best regards.
___
Sent via:Wireshark-dev mailing list
Archives:https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe