Wireshark Lua解析器:同时扩展

我为链接协议编写了两个简单的Wireshark Lua Dissector:

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都会展开原因不明。如果我现在折叠一个协议并单击其他数据包,则两者都会折叠。

有什么建议如何避免这种情况吗?我的协议比这里显示的更复杂,因此这种扩展使分析变得困难。

点赞
用户3395060
用户3395060

那是个 Bug。我敢肯定以前已经被修复过并正常工作。请在 bugs.wireshark.org 上提交 Bug。

与此同时,你可以模拟:

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)
2015-07-12 14:22:48