Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

lua dissector not a TreeItem!

Hi, I am using lua to write a dissector for my own message format, and I get "not a TreeItem" part way through my data

With the TCP payload data :

46 49 4e 53 00 00 00 1a 00 00 00 02 00 00 000080 00 07 00 1a 00 00 01 00 20 01 01 82 07 d0 00 00 b8

and my dissector

fins_proto = Proto("FINS", "FINS protocol")

fins_proto.fields.header     = ProtoField.string("fins.header", "Header")
fins_proto.fields.length     = ProtoField.uint32("fins.length", "Length")
fins_proto.fields.command    = ProtoField.uint32("fins.command", "Command", base.HEX)
fins_proto.fields.tcpErr     = ProtoField.uint32("fins.tcpErr", "TCP Err", base.HEX)
fins_proto.fields.icf        = ProtoField.uint8("fins.icf", "ICF", base.HEX)
fins_proto.fields.rsv        = ProtoField.uint8("fins.rsv", "RSV", base.HEX)

function fins_proto.dissector(buffer, pinfo, tree)

    local subtree = tree:add(fins_proto, buffer(), "FINS Protocol Data")
    subtree:add(fins_proto.fields.header, buffer(0,4))
    subtree:add(fins_proto.fields.length, buffer(4,4))
    subtree:add(fins_proto.fields.command, buffer(8,4))

    pinfo.cols.protocol = "FINS"
    subtree.add(fins_proto.fields.tcpErr, buffer(12,4))
    subtree:add(fins_proto.fields.icf, buffer(16,1))
    subtree:add(fins_proto.fields.rsv, buffer(17,1))

tcp_table = DissectorTable.get("tcp.port")
tcp_table:add(8085, fins_proto)

I get the output

FINS Protocol Data
       Header: FINS
       Length: 26
       Command: 0x00000002
Lua Error: [string "fins2.lua"]:18: not a TreeItem!

If I comment out line 18 -- subtree.add(fins_proto.fields.tcpErr, buffer(12,4)) then I can proceed through the dissection.

FINS Protocol Data
       Header: FINS
       Length: 26
       Command: 0x00000002
       ICF: 0x80
       RSV: 0x00

Please can someone tell me what a TreeItem is, and what I am doing wrong here?

many thanks dan