-- -- Postdissector to test field extractors in Lua -- do --------------------------------------------------------------------------------------- -- Dissector defns --------------------------------------------------------------------------------------- -- Define our new "protocol" local test_proto = Proto("testExtr", "Test field extraction") -- Add a proto field to display in tree local F_number = ProtoField.int32("testbool.fnum", "Extracted frame number") -- Declare the field extractors we need local extract_fnum = Field.new("frame.number") -- Declare global window for debug local tw = TextWindow.new("DEBUG test_fieldextra") -- Register our protocol as post-dissector register_postdissector(test_proto) --------------------------------------------------------------------------------------- -- Dissector function --------------------------------------------------------------------------------------- function test_proto.dissector(tvbuffer, pinfo, treeitem) local frameno = -2 -- Get the field value >>> Due to bug, extract_fnum() will always be nil if extract_fnum() then frameno = extract_fnum().value end -- Print value in debug window tw:append("Actual frame number = " .. pinfo.number .. " Lua got: " .. frameno .. "\n") -- Add our extra protocol subtree local subtreeitem = treeitem:add(test_proto, tvbuffer) -- Display our field value >>> Since extract_fnum() always nil, frameno always -2 local ti = subtreeitem:add(F_number, tvbuffer(), frameno) ti:set_text("Frame number is " .. frameno) end end