【发布时间】:2015-09-30 13:19:05
【问题描述】:
我为链式协议编写了两个简单的 Wireshark Lua 解析器:
local proto1 = Proto("proto1","First Layer")
local page = ProtoField.uint16("proto1.page", "Page", base.HEX)
proto1.fields = {page}
function proto1.dissector(buffer, pinfo, tree)
pinfo.cols.protocol = proto1.name;
local ptree = tree:add(proto1,buffer(1,5))
ptree:add(page, buffer(1,2))
Dissector.get("proto2"):call(buffer(6, 4):tvb(), pinfo, tree)
end
local proto2 = Proto("proto2","Second Layer")
local len = ProtoField.uint8("proto2.len", "Payload Length")
proto2.fields = {len}
function proto2.dissector(buffer, pinfo, tree)
pinfo.cols.protocol = proto2.name;
local ptree = tree:add(proto2,buffer())
ptree:add(len, buffer(1,2))
end
DissectorTable.get("tcp.port"):add(3456, proto1)
解析器会一个接一个地在树中工作并显示协议。 现在,如果我展开其中一个协议(因此 protofield 可见)并单击另一个数据包,那么树中的 proto1 和 proto2 都会因未知原因而展开。 如果我现在折叠其中一个协议并单击另一个数据包,那么两者都会折叠。
任何建议如何避免它?我的协议比这里显示的要复杂,所以这种扩展很难分析。
【问题讨论】:
标签: lua wireshark wireshark-dissector