Initialize ProtoField table inside protocol init function.
I would like to initialize the fields protocol table inside the protocol init function, is it possible ?
I've tried the following but it doesn't seem to be working:
(The Wireshark UI search filter does not see the added ProtoField)
function my_protocol_addProtoFieds()
local field_table = {}
local attr_id = "test"
local field_name = "proto." .. attr_id
local field_abbr = attr_id
local ltype = ftypes.BOOLEAN
if ltype ~= nil then
local field = ProtoField.new(field_name, field_abbr, ltype)
table.insert(field_table, field)
end
my_protocol.fields = field_table
end
function my_protocol.init()
-- read some initialization files
my_protocol_addProtoFieds()
end
It would help a bit if you could say exactly what it is that "doesn't seem to be working."
The fields table is left unmodified.
Are you actually creating the protocol somewhere? You don't in the sample code. Do you have lines like
How do you know that the fields table is left unmodified? Note that if you're trying to test it by printing in the Lua Console (as opposed to adding it to the tree), then if you define the protocol as a local, as above, then it will be
nilin the Lua Console.Using your basic code as above but creating a protocol and dissector, and registering it to a port:
I can definitely add fields from the protocol: Note that the Lua tables are 1-indexed.
The point was based on fields initialization in prototocol init function. What I mean by "left unmodified" is that all changes to fieds table inside protocol init function is not seen by the WireShark UI search filter.
Discussion of
.initfunctions: 15907: Lua needs to support running some dissector code at "dissector registration" time and other dissector code at "dissector handoff registration" time