|
I'm having a problem with getting the value of a protofield to the Info column. I've defined the following ProtoField:
I want add this field value (On or Off) to |
|
You can't extract the value from a ProtoField (see similar question). Instead, you have to parse the buffer, and add the value manually to the Info column, which is fairly easy to do. Try this: local VALS_ON_OFF = { [0] = "Off", [1] = "On" }
local proto_foo = Proto("foo", "Foo Protocol")
local f = proto_foo.fields
f.payload = ProtoField.uint8("observation.payload", "payload", base.HEX, VALS_ON_OFF, 0x10)
function proto_foo.dissector(buf, pinfo, tree)
local t = tree:add(proto_foo, buf())
-- assume observation.payload is at byte 0
t:add(f.payload, buf(0,1))
-- 0x10 has one bit set, that's bit 3 from the left
local bitval = buf(0,1):bitfield(3)
-- set the Info column based on the bit value
pinfo.cols.info = "payload: "..VALS_ON_OFF[bitval]
end
|
