I have a custom dissector written in Lua. One of the fields in my protocol is a payload which may be possible to analyze with a secondary dissector. I would like the user to be able to choose the secondary dissector in the Decode As dialog.
local proto = Proto("myproto", "My Protocol")
proto.fields.payload = ProtoField.bytes("myproto.payload", "Payload")
My understanding is that I need to create and use a DissectorTable:
local dissector_table = DissectorTable.new(
"myproto.payload",
nil, -- use default description
ftypes.NONE
)
function proto.dissector(tvb, pinfo, tree)
-- Dispatch payload to sub-dissector
local dissector = dissector_table:get_dissector()
if dissector then
dissector:call(tvb:range(0), pinfo, tree)
end
end
Then, in the second dissector, I write:
local proto2 = Proto("my2ndproto", "My 2nd Protocol")
...
pcall(require, "myproto") -- make sure we load second
local dt = DissectorTable.get("myproto.payload")
if dt then
dt:add_for_decode_as(proto2)
end
This gets me to the point where my DissectorTable appears in the Decode As dialog, and I do get MY2NDPROTO as the dissector choice.
However, when I select it, I don't see the payload getting dissected by the secondary dissector in the tree. And sometimes my selections in the Decode As window just get lost as soon as I close it.