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

#lua #wireshark #wireshark-dissector #ethercat

#lua #wireshark #разделитель с цепью wireshark #ethercat

Вопрос:

Я пишу разделитель с цепью в Lua для протокола Ethercat. Я назвал свой диссектор с цепью littlecat.

Для того, что у меня есть на данный момент, 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?

Ответ №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)