Accessing field from dissector from post dissector
Hi! Wireshark and Lua newbie here. I am trying to use a post dissector to dissect Bluetooth LE GATT data. The data has already been decode by the built in dissector as btatt.value and I figured I could further dissect btatt.value.
However, the code below doesn't work. I keep getting this error message:
calling 'add' on bad self (string expected, got userdata)
-- Source code below:
ble_gatt_value = Field.new("btatt.value")
trivial_proto = Proto("trivial","Trivial Postdissector")
gattval_field = ProtoField.bytes("trivial.gatt_value","GATT Value", base.DASH)
trivial_proto.fields = {gattval_field}
function trivial_proto.dissector(buffer,pinfo,tree)
local src_gatt_val = ble_gatt_value()
if src_gatt_val then
--print(src_gatt_val)
local subtree = tree:add(trivial_proto, src_gatt_val, "Trivial Protocol Data")
subtree:add(gattval_field,src_gatt_val)
end
end
register_postdissector(trivial_proto)
What am I doing wrong? I have seen several examples but they all used the function argument buffer(x,y)
with tree:add()
Thanks in advance.