Wireshark-dev: [Wireshark-dev] Reassemble serial protocols payloads

From: Tomasz Moń <desowin@xxxxxxxxx>
Date: Sun, 5 Jul 2020 17:05:57 +0200
Hello,

I am trying to implement reassembly for FTDI MPSSE protocol. The
desegment API sounds like an excellent choice, because there can be
more serial protocols implemented in the future that share similar
characteristics to MPSSE (i.e. are designed around asynchronous
character transmission).

Each time FTDI FT passes the payload to MPSSE dissector, MPSSE can:
  * dissect the data just fine if it received (one or more) complete
function code with parameters,
  * dissect as much as it can (complete function code with parameters)
and request X additional bytes

The value X in some cases is known from the beginning, but in some
cases it is only an estimate. It is only an estimate if the missing
data includes the variable data length parameter (i.e. MPSSE dissector
knows that it is a data shifting command, but does not know how many
bytes the command will send out, because the length is in the next
frame).

I am not sure if the approach I am pursuing is good or bad. The work
in progress I have produced so far is at [1]. I am stuck at the point
where, I need to either:
  * pass the "partially reassembled" tvb to MPSSE to check if it is complete, or
  * mark the data as reassembled as soon as I receive X additional
bytes, but then after passing such reassembled data to MPSSE, it
should be possible to "unmark" in case it needs even more bytes (in
case the original estimate changes based on the new information).

Is either of the above viable? Are there any better approaches to the problem?

[1] https://code.wireshark.org/review/37709

Best Regards,
Tomasz Moń