Chained Dissector in Lua

时间:2016-10-20 20:03:31

标签: lua wireshark wireshark-dissector ethercat

I'm writing a chained dissector in Lua for the Ethercat protocol. I named my chained dissector littlecat.

For what I have so far, littlecat correctly dissects the fields I want it to. However, instead of executing after the built in ecat dissector, littlecat takes it over completely.

This is what the registration at the end of my Lua code looks like.

-- Initialize Protocol
function littlecat.init()
end

-- Register Chained Dissector Ethercat Port
local ethercat_dissector_table = DissectorTable.get("ecatf.type")
dissector = ethercat_dissector_table:get_dissector(1)

 -- Dissector can be called from littlecat.dissector
 -- So the previous dissector gets called      
 ethercat_dissector_table:add(1, littlecat)

How can I have my dissector execute after ecat has been executed?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。

确保调用默认解剖器,然后调用自定义解剖器:

  1. 在解剖功能之前定义解剖器表和原始解剖器。
  2. 在解剖功能中调用原始解剖器。
  3. 实施例

    -- Initialize Protocol 
    -- Initialize Protocol Fields
    
    -- Define dissector table and default dissector here
    -- so they can be called within the dissection func.
    
    local dissector_table = DissectorTable.get("shortname")
    dissector = dissector_table:get_dissector(PORT)
    
     -- Dissection Function
     function dissectorname.dissector (tvbuf, pktinfo, root)
    
        -- Call default dissector.
        dissector(tvbuf, pktinfo, root)
    
        -- Continue dissection....
    
    end
    
    -- Initialize Protocol
    function dissectorname.init()
    end
    
    -- Dissector can be called from dissectorname.dissector
    -- So the previous dissector gets called      
    dissector_table:add(PORT, dissectorname)