I'm writing a simple dissector, and bump into a 'DRY/SPOT' violation: I can declare ProtoField
, but applying it to a vtbuff
I still need to tell how many bytes it should use:
proto = Proto("X", "x")
proto.fields.firstchunk = ProtoField.uint8("x.firstchunk", "The First Byte")
proto.fields.secondchunk = ProtoField.uint32("x.secondchunk", "The Second Chunk")
proto.dissector(buffer, pinfo, tree)
tree:add(proto.fields.firstchunk, buffer(0,1))
tree:add(proto.fields.secondchunk, buffer(1,4))
– I really wanted to write:
local offset = 0
tree:add(proto.fields.firstchunk(buffer, offset))
offset += proto.fields.firstchunk.size
tree:add(proto.fields.secondchunk(buffer, offset))
offset += proto.fields.secondchunk.size
…
end
Is something like that possible?
asked 28 May ‘14, 04:04
xtofl
16●2●2●5
accept rate: 0%