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

How to apply a change to a Lua preference without requiring a restart of Wireshark?

0

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's gravatar image

cmaynard ♦♦
9.4k1038142
accept rate: 20%


One Answer:

0

OK, this is apparently a Lua bug with the latest version, Version 2.3.0 (v2.1.0rc0-3313-geb37819), because it works as expected with Wireshark 1.12.13. I'll file a bug report.

EDIT: It also works with the latest version of Wireshark Gtk, but just not with Qt. This is reflected in the bug report, which is Bug 13536.

answered 30 Mar '17, 11:49

cmaynard's gravatar image

cmaynard ♦♦
9.4k1038142
accept rate: 20%

edited 30 Mar '17, 13:08