Прикованный диссектор в Луа

Я пишу цепочечный диссектор на 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?

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)
Другие вопросы по тегам