diff options
Diffstat (limited to 'wireshark/melon.lua')
-rw-r--r-- | wireshark/melon.lua | 20 |
1 files changed, 13 insertions, 7 deletions
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 |