I've added a preference to a Lua dissector, but when the preference is changed, a restart of Wireshark is required before the change takes affect. Is it possible for the changed preference to be applied without a restart?
For example, below is a simple foo.lua Lua dissector with a simple Boolean preference. Changing the preference currently requires a Wireshark restart before the change takes affect. The foo.pcapng capture file hosted on cloudshark can be used to test it.
-- Protocol
local p_foo = Proto("foo", "FOO Protocol")
– Preferences
local foo_settings = {
info = true
}
p_foo.prefs.info = Pref.bool("Write to Info column", foo_settings.info,
"Whether to write information to the Info column or not")
function p_foo.prefs_changed()
if foo_settings.info ~= p_foo.prefs.info then
foo_settings.info = p_foo.prefs.info
reload() -- This doesn't seem to help.
end
end
– Fields
local f_foo_val8 = ProtoField.uint8("foo.val8", "Value 8", base.OCT)
local f_foo_val16 = ProtoField.uint16("foo.val16", "Value 16", base.DEC)
local f_foo_val32 = ProtoField.uint32("foo.val32", "Value 32", base.HEX)
local f_foo_ipv4 = ProtoField.ipv4("foo.ipv4", "IPv4 Address")
local f_foo_ipv6 = ProtoField.ipv6("foo.ipv6", "IPv6 Address")
p_foo.fields = { f_foo_val8, f_foo_val16, f_foo_val32, f_foo_ipv4, f_foo_ipv6 }
– Dissection
function p_foo.dissector(buf, pinfo, tree)
local foo_tree = tree:add(p_foo, buf(0,-1))
pinfo.cols.protocol:set("FOO")
if foo_settings.info then
pinfo.cols.info:set("Hello World!")
end
foo_tree:add(f_foo_val8, buf(0, 1))
foo_tree:add(f_foo_val16, buf(1, 2))
foo_tree:add(f_foo_val32, buf(3, 4))
foo_tree:add(f_foo_ipv4, buf(7, 4))
foo_tree:add(f_foo_ipv6, buf(11, 16))
end
– Registration
local udp_table = DissectorTable.get("udp.port")
udp_table:add(33333, p_foo)
asked 30 Mar ‘17, 11:26
cmaynard ♦♦
9.4k●10●38●142
accept rate: 20%