Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

First, I really don't understand why the child registers with the TCP dissector table at all. The child only needs to register with the parent.

Below are modified parent/child Lua pseudo-code that should work ... assuming the child is the only one (i.e., there are no other children that register with the parent):

Parent

MyParent = Proto.new("MyParent", "My Parent Protocol")

--Protofields and Fields defined here

local MyParentTable = DissectorTable.new("MyParentTable", "MyParentTable", ftypes.STRING, base.NONE)

function MyParent.dissector(buffer, pinfo, tree)

    pinfo.cols.protocol = MyParent.name

    local subtree = tree:add(MyParent, buffer(), "My Parent")

    -- Add parent fields here

    -- Subdissection:
    local nextBlock = -- get next bytes to process here
    MyParentTable:try("MyProtocolA", nextBlock, pinfo, subtree)
end

DissectorTable.get("tcp.port"):add(5001, MyParent)
DissectorTable.get("ethertype"):add(0x8800, MyParent)

Child

MyProtocolA = Proto.new("MyProtocolA", "My Protocol A")

--ProtoFields and Fields defined but not shown

function MyProtocolA.init()
    DissectorTable.get("MyParentTable"):add("MyProtocolA", MyProtocolA)
end

function MyProtocolA.dissector(buffer, pinfo, tree)
    pinfo.cols.protocol = MyProtocolA.name

    local subtree = tree:add(MyProtocolA, buffer(), "My Protocol A Data")

    --More here not shown
end

--[[
    -- This should also work instead of being done in MyProtocolA.init(),
    -- at least it did in my testing.
    DissectorTable.get("MyParentTable"):add("MyProtocolA", MyProtocolA)
--]]