From cef0cbd29a903e023ad5730b98beceb40baa6bf0 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 28 Aug 2024 16:06:20 +0200 Subject: more WIP --- wireshark/melon.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'wireshark/melon.lua') diff --git a/wireshark/melon.lua b/wireshark/melon.lua index a431781..265af01 100644 --- a/wireshark/melon.lua +++ b/wireshark/melon.lua @@ -1,5 +1,4 @@ -local p = Proto("melon", "MelonDS packet header") -local dt = DissectorTable.new("melon") +local p = Proto("melon", "MelonDS Ni-Fi header") p.fields.magic = ProtoField.uint32("melon.magic", "Magic", base.HEX) p.fields.src = ProtoField.int32("melon.src", "Instance ID", base.DEC) @@ -16,11 +15,15 @@ p.fields.timestamp = ProtoField.uint64("melon.timestamp", "Timestamp", base.DEC) local p_type_enum_field = Field.new("melon.type.enum") +local txhdr_dissector = Dissector.get("txhdr") +local rxhdr_dissector = Dissector.get("rxhdr") + function p.dissector(buffer, pinfo, tree) local header_size = 0x18 - + -- check buffer size + if buffer:len() < header_size then return 0 end -- check magic ("NIFI") - if buffer(0x00, 4):uint() ~= 0x4e494649 then return end + if buffer(0x00, 4):uint() ~= 0x4e494649 then return 0 end local subtree = tree:add(p, buffer(0, header_size), string.format("%s: %d bytes", p.description, header_size)) subtree:add(p.fields.magic, buffer(0x00, 4)) @@ -40,9 +43,12 @@ function p.dissector(buffer, pinfo, tree) pinfo.cols.src = string.format("instance %d", instance) pinfo.cols.info = p_type_enum_field().display - -- melonds packets always contain NIFI packets, I use 0 as the pattern - -- because this function doesn't seem to like nil - dt:try(0, buffer(header_size):tvb(), pinfo, tree) + -- melonds packets always contain NIFI packets + local next_dissector = txhdr_dissector + -- if instance ~= 0 then + -- next_dissector = rxhdr_dissector + -- end + next_dissector:call(buffer(header_size):tvb(), pinfo, tree) return header_size end -- cgit v1.2.3