function ftsr_dissector(buffer, pinfo, tree, ftsr_protocol, offset) -- Define the fields for the protocol local f_session_id = ProtoField.uint8("ftsr_protocol.session_id", "Session ID", base.DEC) local f_status_code = ProtoField.uint8("ftsr_protocol.status_code", "Response Status Code", base.HEX) local f_missing_count = ProtoField.uint8("ftsr_protocol.missing_count", "Total Missing Data Segment Count", base.DEC) local f_reserved = ProtoField.uint16("ftsr_protocol.reserved1", "Reserved", base.HEX) local f_suspend_timeout_or_sct_db = ProtoField.uint32("ftsr_protocol.suspend_timeout_or_sct_db", "Suspend Waiting Timeout or SCT Database", base.HEX) local f_missing_segment_seq = ProtoField.bytes("ftsr_protocol.missing_segment_seq", "Missing Segment Sequence Numbers", base.SPACE) -- Add the fields to the protocol ftsr_protocol.fields = { f_session_id, f_status_code, f_reserved, f_missing_count, f_suspend_timeout_or_sct_db, f_missing_segment_seq } local subtree = tree:add(ftsr_protocol, buffer(), "FTSR") -- Parse the CONTROL FIELD (1 byte) local control_field = buffer(offset, 1):le_uint() local session_id = (control_field & 0x07) -- Bits 0-2 for Session ID (3 bits) local status_code = (control_field >> 3) & 0x1f -- Bits 3-7 for Status Code (5 bits) -- Add fields to the protocol tree subtree:add(f_session_id, session_id) if status_code == 0 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR RECEIVER READY (0x%02X)", status_code)) elseif status_code == 1 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR RX API NOT FOUND (0x%02X)", status_code)) elseif status_code == 2 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR SUSPEND (0x%02X)", status_code)) elseif status_code == 3 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR RESUME (0x%02X)", status_code)) elseif status_code == 4 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR STOP TRANSFER (0x%02X)", status_code)) elseif status_code == 5 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR MISSING PACKETS (0x%02X)", status_code)) elseif status_code == 6 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR CRC FAIL (0x%02X)", status_code)) elseif status_code == 7 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR FILE NOT FOUND (0x%02X)", status_code)) elseif status_code == 8 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR HEAD CHANGE (0x%02X)", status_code)) elseif status_code == 9 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR CANCELLED BY SUSPEND TIMEOUT (0x%02X)", status_code)) elseif status_code == 10 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR SUSPEND SAVE CONTEXT (0x%02X)", status_code)) elseif status_code == 11 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR RESUME SAVE CONTEXT (0x%02X)", status_code)) elseif status_code == 12 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR ACK (0x%02X)", status_code)) elseif status_code == 13 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR NAK (0x%02X)", status_code)) elseif status_code == 14 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR PING (0x%02X)", status_code)) elseif status_code == 15 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR DOWNLOAD COMPLETE (0x%02X)", status_code)) elseif status_code == 16 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR TERMINATE RX NODE (0x%02X)", status_code)) elseif status_code == 17 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR INVALID SESSION ID (0x%02X)", status_code)) elseif status_code == 18 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR DOWNLOAD PTR NULL (0x%02X)", status_code)) elseif status_code == 19 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR FTM BUSY (0x%02X)", status_code)) elseif status_code == 20 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR INVALID CFG INPUT (0x%02X)", status_code)) elseif status_code == 21 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR RX SYSTEM ERROR (0x%02X)", status_code)) elseif status_code == 22 then subtree:add(f_status_code, status_code):set_text(string.format("RESPONSE STATUS CODE: FTSR VERSION MISMATCH (0x%02X)", status_code)) end offset = offset + 1 -- Move to the next byte -- Parse the MISSING DATA SEGMENT COUNT (1 byte) if status_code == 0x05 then local missing_count = buffer(offset, 1):uint() subtree:add(f_missing_count, missing_count) offset = offset + 1 end -- Parse Reserved bytes (2 bytes) local reserved_bytes = buffer(offset, 2) subtree:add(f_reserved, reserved_bytes) offset = offset + 2 -- Parse SUSPEND WAITING TIMEOUT OR SCT DATABASE (4 bytes) -- This field is present based on the Response Status Code if status_code == 0x02 or status_code == 0x0A or status_code == 0x0B then local suspend_timeout_or_sct_db = buffer(offset, 4) subtree:add(f_suspend_timeout_or_sct_db, suspend_timeout_or_sct_db) offset = offset + 4 end -- Parse the MISSING SEGMENT SEQUENCE NUMBERS (variable length) if status_code == 0x05 then -- Missing segment sequence numbers are present when status code is 0x05 local missing_seq_start = offset local missing_seq_count = missing_count local missing_segments = buffer(missing_seq_start, missing_seq_count) subtree:add(f_missing_segment_seq, missing_segments) end end