首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Lua的链式分离器

Lua的链式分离器
EN

Stack Overflow用户
提问于 2016-10-20 20:03:30
回答 1查看 1.1K关注 0票数 0

我正在为Ethercat协议在Lua写一个链式分解器。我给我的带链子的拆尸器起了个名字。

到目前为止,我所拥有的一切都正确地剖析了我想要的领域。然而,没有在ecat分解后执行,littlecat完全接管了它。

这就是我的Lua代码末尾的注册内容。

代码语言:javascript
运行
复制
-- 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之后,我如何让我的部门执行?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-03 17:53:24

我找到了解决办法。

若要确保调用默认拆分,然后调用自定义拆分:

  1. 在解剖功能之前定义解剖表和原始解剖。
  2. 在解剖功能范围内调用原始解剖。

示例

代码语言:javascript
运行
复制
-- 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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40163541

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档