This is a static archive of our old Q&A Site. Please post any new questions and answers at

lua dissector from XML file


Is there some way to create a dissector from XML file?

I have few messages which are defined in XML files. I'd like to use some generic dissector so that one will have to use only the XML file in order to define the packet (all messages are based on UDP), the dissector will read all the XML files and will parse the data based on it.

asked 27 Jul '17, 22:24

BMWE's gravatar image

accept rate: 100%

One Answer:


You may want to have a look at this project. It is not fed by xml directly but you may use a script to convert your xml descriptions into the syntax required by this project.

Other approach would be to somewhat duplicate that project by using Lua to read your xml description of the protocol and create protocol fields at startup, but I am not really sure you can read from a file during the initialisation phase. In Lua, you can use constructs like

all_my_fields = {} local n=0

and then, for each protocol field description extracted from XML:

all_my_fields[n] = ProtoField.uint8(field_abbr_from_XML,field_name_from_XML,base.HEX, all_my_field_values_table_from_XML[n],field_bit_mask_from_XML) n=n+1

choosing the right ProtoField type (uint8 in this case) and base (base.HEX in this case) which I suspect must be literals, and then probably (I've never tested it so a different syntax may be necessary) you can use

my_proto.fields = all_my_fields

The tables for translation of numeric values to text strings must be complete before you use them to create a ProtoField as for some reason they are copied, not referred to.

answered 28 Jul '17, 03:07

sindy's gravatar image

accept rate: 24%

This project seems to be very useful. Thank you

(28 Jul '17, 22:29) BMWE