Skip to content

Commit

Permalink
Make the protocol dissector heuristic (#14335)
Browse files Browse the repository at this point in the history
  • Loading branch information
someone-aka-sum1 committed Feb 4, 2024
1 parent 1d9c971 commit 16aaef0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions util/wireshark/minetest.lua
Expand Up @@ -1280,14 +1280,15 @@ do

function p_minetest.dissector(buffer, pinfo, tree)

-- Add Minetest tree item and verify the ID
local t = tree:add(p_minetest, buffer(0,8))
t:add(f_id, buffer(0,4))
-- Defer if payload doesn't have Minetest's magic number
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
return false
end

-- Add Minetest tree item
local t = tree:add(p_minetest, buffer(0,8))
t:add(f_id, buffer(0,4))

-- ID is valid, so replace packet's shown protocol
pinfo.cols.protocol = "Minetest"
pinfo.cols.info = "Minetest"
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 16aaef0

Please sign in to comment.