richard.coe@xxxxxxxxxx wrote:
Telling me that it can't be done when it already works doesn't help much.
Telling me that it already works when I know that a packet where it
won't work could be constructed - a packet where the first fragment is
long enough to run past the end of the TCP segment, so that
dcm_get_pdu_len() *cannot* determine the length of the defragmented
packet) doesn't help much, either.
And I only look at the data the remains in the tvbuff
--> tvb_ensure_length_remaining
That doesn't guarantee that you'll be able to look at all of the
fragment headers.
Can you please explain why I must write code in the dcm dissector that
already does what the tcp fragmenter does ?
Because the TCP reassembly code is designed to handle that subset of
protocols where the length of a packet can be determined purely by
looking at the first N bytes of the packet, where N is no larger than
the minimum size of any packet. (This is done so that it can reassemble
the first N bytes of the packet, if necessary.) If you define a packet,
at that layer of reassembly, as a DICOM fragment, that appears to be
true, as the length appears to be a 4-byte value starting 2 bytes into
the fragment, so you can determine the length of a fragment from the
first 6 bytes.
A large number of protocols work that way. Protocols that don't would
need a different mechanism to do reassembly, and wouldn't be able to use
a loop of the sort that tcp_dissect_pdus() uses.
Do you have any examples in another dissector which does it another way ?
I'm not sure there are currently any dissectors that use
tcp_dissect_pdus() at one level and have separate reassembly code for a
layer above that, although it looks as if the Netlib layer in
packet-tds.c could use tcp_dissect_pdus() - I'll look into that.
That is, however, an example of a dissector that handles two levels of
defragmentation, one where packets are reassembled using the TCP
reassembly mechanism based on a length field near the beginning of the
packet, and one where those reassembled packets are further reassembled
based on a "last fragment" flag.