how to add Lua dissector to support bluetooth vendor specific command and event
Hi I try to add Lua-dissector to extend the original HCI_EVT dissector however, when I call dissector::call(but, pkt, root), the original HCI_EVT dissector seems not work it only show the raw data in tree items could you give a hint how to fix this thanks
p_multi = Proto("multi","MultiProto");
orig_d = nil
RSSI3 = ProtoField.uint8("multi.rssi", "RSSI", base.HEX)
p_multi.fields = {RSSI3}
orig_d = Dissector.get("bthci_evt")
data = Dissector.get("data")
orig_table = DissectorTable.get("hci_h4.type")
if nil == orig_d2 then
print("get orig_d2")
orig_d2 = orig_table.get_dissector(orig_table, 5)
if nil == orig_d2 then
orig_d2 = orig_table.get_dissector(orig_table, 4)
orig_table.set(5, orig_d2)
end
-- save orig_d2 as pattern 5 for testing
print("orig_d2" .. type(orig_d2) .. tostring(orig_d2))
end
function p_multi.dissector(buf,pkt,root)
length = buf:len()
length2 = buf(1, buf:len()-1):tvb():len()
print("length is " .. length .. " " .. length2)
subtree = root:add(p_multi, buf(), "Multi rssi")
if nil ~= orig_d2 then
orig_d2:call(buf, pkt, root, buf(0, buf:len()) )
--orig_d2:call(buf, pkt, root)
else
print("error ! no orig_d2")
end
info = tostring(pkt.cols.info)
pkt.cols.info:set(info .. " (length ".. length .. ")")
subtree:add(RSSI3, buf(1,1)) -- only for test
--end
end
if orig_d == nil then
print("failed orig_d is nil")
else
local inspect = require 'inspect'
print(inspect(getmetatable(orig_d)))
if orig_table == nil then
print("failed orig_table is nil")
else
print("register orig_table")
orig_table:add(4, p_multi)
end
end
local tap = Listener.new("bluetooth.hci_summary")
function tap.packet(pinfo,tvb,ip)
-- print("tap length:".. tvb:len() .. " " .. type(ip))
end