diff options
author | Rado Radoulov <rad0x6f@gmail.com> | 2017-04-27 13:06:24 -0400 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2017-05-05 08:38:40 +0000 |
commit | ae8b18d6183538a4ffd5d18588be1b5e1a058206 (patch) | |
tree | e9b30127d9dfa9ac55d87fc1eb0cf4edcba89ffc /test/lua | |
parent | ce8863c6efcee54655b7856002430bd1716a7776 (diff) |
New Lua function TreeItem:referenced(ProtoField | Dissector).
This function returns TRUE/FALSE depending whether the specified ProtoField/Dissector
needs to be dissected. By using this function in conjunction with the TreeItem.visible
attribute, Lua dissectors can be significantly sped up by making less C interop calls
which are relatively slow in terms of dissection especially when using sub-protocols
where the dissection of an entire protocol can be skipped.
Added tests for TreeItem:referenced to protofield.lua
Change-Id: I44feacb91a2a5b0e3c28c0ccd8d6b04cccd67261
Reviewed-on: https://code.wireshark.org/review/21387
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'test/lua')
-rw-r--r-- | test/lua/protofield.lua | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test/lua/protofield.lua b/test/lua/protofield.lua index c4026e5cf8..6b6110ddff 100644 --- a/test/lua/protofield.lua +++ b/test/lua/protofield.lua @@ -30,7 +30,7 @@ local function setFailed(name) end -- expected number of runs -local taptests = { [OTHER]=28 } +local taptests = { [OTHER]=32 } local function getResults() print("\n-----------------------------\n") for k,v in pairs(taptests) do @@ -70,6 +70,7 @@ end local test_proto = Proto.new("test", "Test Proto") test_proto.fields.time_field = ProtoField.uint16("test.time", "Time", base.UNIT_STRING, {" sec", " secs"}) test_proto.fields.dist_field = ProtoField.uint16("test.dist", "Distance", base.UNIT_STRING, {" km"}) +test_proto.fields.filtered_field = ProtoField.uint16("test.filtered", "Filtered Field", base.DEC) -- Field name: empty, illegal, incompatible success = pcall(ProtoField.int8, nil, "empty field name 1") @@ -155,6 +156,19 @@ function test_proto.dissector(tvb, pinfo, tree) test("Time: 65535 secs", ti.text == "Time: 65535 secs") ti = tree:add(test_proto.fields.dist_field, tvb3()) test("Distance: 65535 km", ti.text == "Distance: 65535 km") + + ti = tree:add(test_proto.fields.filtered_field, tvb2()) + -- Note that this file should be loaded in tshark twice. Once with a visible + -- tree (-V) and once without a visible tree. + if tree.visible then + -- Tree is visible so both fields should be referenced + test("Visible tree: Time is referenced", tree:referenced(test_proto.fields.time_field) == true) + test("Visible tree: Filtered field is referenced", tree:referenced(test_proto.fields.filtered_field) == true) + else + -- Tree is not visible so only the field that appears in a filter should be referenced + test("Invisible tree: Time is NOT referenced", tree:referenced(test_proto.fields.time_field) == false) + test("Invisible tree: Filtered field is referenced", tree:referenced(test_proto.fields.filtered_field) == true) + end end DissectorTable.get("udp.port"):add(65333, test_proto) |