Lua dissector, loop vs table, what is supported?
I've got a dissector with a loop that looks something like
while i < payload_length do
local tag_type=payload(i,1):uint()
--Device Type
if tag_type == 1 then
tags_tree:add(hdhomerun_proto.fields.tag_device_type, payload(i+2,tag_length))
--Device ID
elseif tag_type == 2 then
tags_tree:add(hdhomerun_proto.fields.tag_device_id, payload(i+2,tag_length))
...
local hdhr_tag_types = {
[0x01] = ProtoField.new(...
[0x02] = ProtoField.new(...
[0x03] = ProtoField.new(...
}
and then have tags_tree:add(hdhr_tag_types[tag_type]) or something similar (where tags_tree is a subtree)
When I tried something like that it seemed like having a ProtoField in a table isn't supported.
For reference, the protocol I'm looking at is in https://github.com/Silicondust/libhdh...
What's supported? Is a loop with an if else statement for all 13 tags really the best way to make this work?