Skip to content

Commit

Permalink
Mark packet with expert_info to indicate incorrect data in the message
Browse files Browse the repository at this point in the history
  • Loading branch information
petrvanekrobe committed Jan 16, 2024
1 parent a63715b commit bc2a65f
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions mvrxchange_dissector/mvrxchange.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ mvrxchange.fields.message_ver_major = ProtoField.string('mvrxchange.message_ver_
mvrxchange.fields.message_ver_minor = ProtoField.string('mvrxchange.message_ver_minor', "MESSAGE_VER_MINOR")
mvrxchange.fields.message_comment = ProtoField.string('mvrxchange.message_comment', "MESSAGE_COMMENT")
mvrxchange.fields.message_commits = ProtoField.string('mvrxchange.message_commits', "MESSAGE_COMMITS")
mvrxchange.fields.message_files = ProtoField.string('mvrxchange.message_files', "MESSAGE_FILES")
mvrxchange.fields.message_station_uuid = ProtoField.string('mvrxchange.message_station_uuid', "MESSAGE_STATION_UUID")
mvrxchange.fields.message_from_station_uuid = ProtoField.string('mvrxchange.message_from_station_uuid', "MESSAGE_FROM_STATION_UUID")
mvrxchange.fields.message_file_uuid = ProtoField.string('mvrxchange.message_file_uuid', "MESSAGE_FILE_UUID")

mvrxchange.fields.message_errors = ProtoField.string('mvrxchange.message_errors', "MESSAGE_ERRORS")


function process_message(data, subtree)
Expand All @@ -54,20 +55,34 @@ function process_message(data, subtree)
subtree:add(mvrxchange.fields.message_comment):append_text(data["Comment"])
end
if data["Commits"] ~= nil then
subtree:add(mvrxchange.fields.message_commits):append_text("Number:" .. tostring(#data["Commits"]) .. "")
subtree:add(mvrxchange.fields.message_commits):append_text("" .. tostring(#data["Commits"]) .. "")
end

if data["Files"] ~= nil then
errsubtree = subtree:add(mvrxchange.fields.message_files):append_text("Number:" .. tostring(#data["Files"]) .. "")
errsubtree:add_expert_info(PI_MALFORMED, PI_WARN, "Wrong field, should be Commits")
end
if data["StationName"] ~= nil then
subtree:add(mvrxchange.fields.message_station_name):append_text(data["StationName"])
end
if data["StationUUID"] ~= nil then
subtree:add(mvrxchange.fields.message_station_uuid):append_text(data["StationUUID"])
errsubtree = subtree:add(mvrxchange.fields.message_station_uuid):append_text(data["StationUUID"])
if (data["StationUUID"] == "00000000-0000-0000-0000-000000000000") or (data["StationUUID"] == "") then
errsubtree:add_expert_info(PI_MALFORMED, PI_WARN, "UUID should not be empty or 0")
end
end
if data["FileUUID"] ~= nil then
subtree:add(mvrxchange.fields.message_file_uuid):append_text(data["FileUUID"])
errsubtree = subtree:add(mvrxchange.fields.message_file_uuid):append_text(data["FileUUID"])
if data["FileUUID"] == "00000000-0000-0000-0000-000000000000" then
errsubtree:add_expert_info(PI_MALFORMED, PI_WARN, "UUID can be empty or UUID but should not be 0")
end
end
if data["FromStationUUID"] ~= nil then
if is_not_table(data["FromStationUUID"]) then
subtree:add(mvrxchange.fields.message_from_station_uuid):append_text(data["FromStationUUID"])
errsubtree = subtree:add(mvrxchange.fields.message_from_station_uuid):append_text(data["FromStationUUID"])
if data["FromStationUUID"] == "" then
errsubtree:add_expert_info(PI_MALFORMED, PI_WARN, "Should not be empty")
end
end
end
end
Expand Down

0 comments on commit bc2a65f

Please sign in to comment.