Hi all,
I'm pretty new about the LUA Dissector. I have a problem with my code. Every time that I expand the treelist all subtrees are expanded automatically. How can I avoid this? Also, I'd like to ask you why the subtrees are displayed in grey color instead of white.
Below you will find my code. Thank you in advance for the help
Peter.
-- New Protocol and fields
p_mynewproto = Proto ("MyProtocol", "Test")
– Define Header fields
local protoHeader = p_mynewproto.fields
protoHeader.rxId = ProtoField.uint16('protoHeader.rxId' , 'Rx ID ' , base.HEX, nil)
protoHeader.txId = ProtoField.uint16('protoHeader.txId' , 'Tx ID ' , base.HEX, nil)
protoHeader.timeHour = ProtoField.uint16('protoHeader.timeHour' , 'Hour ' , base.HEX, nil)
protoHeader.timeMinute = ProtoField.uint16('protoHeader.timeMinute', 'Minute' , base.HEX, nil)
protoHeader.timeSecond = ProtoField.uint16('protoHeader.timeSecond', 'Second' , base.HEX, nil)
– mynewproto dissector function
function p_mynewproto.dissector (buf, pkt, root)
– Check the packet length
if buf:len() == 0 then return end
pkt.cols.protocol = p_mynewproto.name
– start from offset 0
local offset = 0
– create subtree for mynewproto
subtreeA = root:add(p_mynewproto, buf(offset,buf:len())):append_text(" [My Protocol Header]")
– Rx ID
subtreeA:add(protoHeader.rxId , buf(offset,2))
– Tx ID
subtreeA:add(protoHeader.txId , buf(offset+2,2))
– Time
subtreeB = subtreeA:add(p_mynewproto, buf(offset+4,6),"[TIME]")
– Time Hour
subtreeB:add(protoHeader.timeHour , buf(offset+4,2))
– Time Minute
subtreeB:add(protoHeader.timeMinute , buf(offset+6,2))
– Time Second
subtreeB:add(protoHeader.timeSecond , buf(offset+8,2))
end
– Initialization function
function p_mynewproto.init()
end
– Register a chained dissector for port 11111
local udp_dissector_table = DissectorTable.get("udp.port")
dissector = udp_dissector_table:get_dissector(11111)
udp_dissector_table:add(11111, p_mynewproto)
asked 14 May ‘15, 15:26
Peter1969
11●1●1●5
accept rate: 0%
edited 27 Jun ‘15, 18:57
Hadriel
2.7k●2●9●39
Guys, I found this old wireshark question: https://ask.wireshark.org/questions/31356/how-to-get-all-tree-items-collapsed-as-default-in-gtk-version
But I don’t understand very well the response. How can I adapt it to my code. Thank you Peter.