ftfci_dissector.lua 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. function ftfci_dissector(buffer, pinfo, tree, FTFCI_protocol, offset)
  2. -- Define ProtoFields for each of the fields in the structure
  3. -- Control Field 1 (1 byte)
  4. local f_session_id = ProtoField.uint8("FileTransfer.session_id", "File Transfer Session ID", base.DEC)
  5. local f_data_segment_exchange_info = ProtoField.string("FileTransfer.data_segment_exchange_info", "Data Segment Exchange Info")
  6. local f_data_segment_exchange_info1 = ProtoField.string("FileTransfer.data_segment_exchange_info", "Data Segment Exchange Info")
  7. local f_reserved_byte = ProtoField.uint8("FileTransfer.reserved_byte", "Reserved Byte", base.HEX)
  8. -- Reserved (3 bytes)
  9. local f_reserved_3bytes = ProtoField.bytes("FileTransfer.reserved_3bytes", "Reserved (3 bytes)")
  10. -- Suspend Waiting Time or SCT Database (4 bytes)
  11. local f_suspend_waiting_time = ProtoField.uint32("FileTransfer.suspend_waiting_time", "Suspend Waiting Time", base.DEC)
  12. -- Add fields to protocol
  13. FTFCI_protocol.fields = {
  14. f_session_id,
  15. f_data_segment_exchange_info,
  16. -- f_reserved_bit7,
  17. f_reserved_byte,
  18. f_reserved_3bytes,
  19. f_suspend_waiting_time
  20. }
  21. -- Add the new structure data as a subtree
  22. local subtree = tree:add(FTFCI_protocol, buffer(), "FTFCI")
  23. -- dissect CONTROL FIELD 1 (1 byte)
  24. local control_field1 = buffer(offset, 1):le_uint()
  25. local session_id = control_field1 & 0x07 -- Bits 0-2
  26. local data_segment_exchange_info = (control_field1 >> 3) & 0x1F -- Bits 3-7
  27. --logic
  28. if data_segment_exchange_info == 0 then
  29. f_data_segment_exchange_info1 ="ftfci_na"
  30. elseif data_segment_exchange_info == 1 then
  31. f_data_segment_exchange_info1 ="ftfci_cancelled_by_app"
  32. elseif data_segment_exchange_info == 2 then
  33. f_data_segment_exchange_info1 ="ftfci_cancelled_by_seqloss"
  34. elseif data_segment_exchange_info == 3 then
  35. f_data_segment_exchange_info1 ="ftfci_suspend"
  36. elseif data_segment_exchange_info == 4 then
  37. f_data_segment_exchange_info1 ="ftfci_resume"
  38. --elseif data_segment_exchange_info == 5 then
  39. --f_data_segment_exchange_info1 ="ftsr_stop_transfer"
  40. elseif data_segment_exchange_info == 6 then
  41. f_data_segment_exchange_info1 ="ftfci_suspend_savecontext"
  42. elseif data_segment_exchange_info == 7 then
  43. f_data_segment_exchange_info1 ="ftfci_resume_savecontext"
  44. elseif data_segment_exchange_info == 8 then
  45. f_data_segment_exchange_info1 ="ftfci_cancelled_by_susp_timeoout"
  46. elseif data_segment_exchange_info == 9 then
  47. f_data_segment_exchange_info1 ="ftfci_cancelled_by_txnode"
  48. elseif data_segment_exchange_info == 10 then
  49. f_data_segment_exchange_info1 ="ftfci_ack"
  50. elseif data_segment_exchange_info == 11 then
  51. f_data_segment_exchange_info1 ="ftfci_nak"
  52. elseif data_segment_exchange_info == 12 then
  53. f_data_segment_exchange_info1 ="ftfci_ping"
  54. end
  55. -- Add Control Field 1 data to subtree
  56. subtree:add(f_session_id, session_id)
  57. subtree:add(f_data_segment_exchange_info, f_data_segment_exchange_info1)
  58. offset = offset + 1
  59. -- dissect Reserved Byte (1 byte)
  60. local reserved_byte = buffer(offset, 1):le_uint()
  61. subtree:add(f_reserved_byte, reserved_byte)
  62. offset = offset + 1
  63. -- dissect Reserved 3 bytes (2 bytes)
  64. local reserved_3bytes = buffer(offset, 2)
  65. subtree:add(f_reserved_3bytes, reserved_3bytes)
  66. offset = offset + 2
  67. -- dissect Suspend Waiting Time or SCT Database (4 bytes)
  68. local suspend_waiting_time = 0
  69. -- If Data Segment Exchange Info is "Request FT Suspend" or "Suspend with savecontext" or "Resume with savecontext"
  70. -- if data_segment_exchange_info == 0x03 or data_segment_exchange_info == 0x05 or data_segment_exchange_info == 0x06 then
  71. suspend_waiting_time = buffer(offset, 4):le_uint()
  72. subtree:add(f_suspend_waiting_time, suspend_waiting_time)
  73. offset = offset + 4
  74. --end
  75. end