Цепной диссектор в Lua

Я пишу цепной диссектор на Lua для протокола Ethercat. Я назвал своего цепного диссектора котёнком.

Для того, что у меня есть до сих пор, littlecat правильно анализирует поля, которые я хочу. Однако вместо того, чтобы выполнять встроенный диссектор ecat, littlecat полностью берет его на себя.

Вот как выглядит регистрация в конце моего кода на Lua.

-- 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)

Как я могу запустить диссектор после выполнения ecat?


person Irfan Hossain    schedule 20.10.2016    source источник


Ответы (1)


Я нашел решение.

Чтобы убедиться, что вызывается диссектор по умолчанию, а затем пользовательский диссектор:

  1. Определите таблицу диссекторов и исходный диссектор перед функцией вскрытия.
  2. Вызов исходного диссектора в функции рассечения.

Пример

-- 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)
person Irfan Hossain    schedule 03.11.2016