Make the protocol dissector heuristic (#14335)

This commit is contained in:
someone-aka-sum1 2024-02-04 21:21:23 +01:00 committed by GitHub
parent 1d9c9710d7
commit 16aaef097a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1280,13 +1280,14 @@ do
function p_minetest.dissector(buffer, pinfo, tree)
-- Add Minetest tree item and verify the ID
-- Defer if payload doesn't have Minetest's magic number
if buffer(0,4):uint() ~= minetest_id then
return false
end
-- Add Minetest tree item
local t = tree:add(p_minetest, buffer(0,8))
t:add(f_id, buffer(0,4))
if buffer(0,4):uint() ~= minetest_id then
t:add_expert_info(PI_UNDECODED, PI_WARN, "Invalid ID, this is not a Minetest packet")
return
end
-- ID is valid, so replace packet's shown protocol
pinfo.cols.protocol = "Minetest"
@ -1339,12 +1340,11 @@ do
end
pinfo.cols.info:append(" (" .. reliability_info .. ")")
return true
end
-- FIXME Is there a way to let the dissector table check if the first payload bytes are 0x4f457403?
DissectorTable.get("udp.port"):add(30000, p_minetest)
DissectorTable.get("udp.port"):add(30001, p_minetest)
p_minetest:register_heuristic("udp", p_minetest.dissector)
end