Wireshark Lua 解剖器:两者一起扩展

Wireshark Lua dissectors: both expand together

我为链式协议编写了​​两个简单的 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)

解剖器确实在工作并在树中一个接一个地显示协议。 现在,如果我展开其中一个协议(因此可以看到原型字段)并单击另一个数据包,那么树中的 proto1 和 proto2 都会因未知原因展开。 如果我现在折叠其中一个协议并单击另一个数据包,那么两者都会折叠。

有什么建议可以避免吗?我的协议比此处显示的更复杂,因此这种扩展使其难以分析。

这是一个错误。我可以发誓之前已经修复,然后正常工作。请在 bugs.wireshark.org.

上提交错误

在此期间,您可以伪造它:

local proto1 = Proto("proto1","First Layer")

local page    = ProtoField.uint16("proto1.page", "Page", base.HEX)
local proto2  = ProtoField.bytes("proto2","Second Layer")
local len     = ProtoField.uint8("proto2.len", "Payload Length")

proto1.fields = {page, proto2, len}


local function proto2_dissect(buffer, pinfo, tree)
    pinfo.cols.protocol = "proto2"
    local ptree = tree:add(proto2, buffer()):set_text("Second Layer")
    ptree:add(len, buffer(1,2))
end

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))
    proto2_dissect(buffer(6,4):tvb(), pinfo, tree)
end

DissectorTable.get("tcp.port"):add(3456, proto1)