Wireshark-dev: Re: [Wireshark-dev] TCP Packet Re-Assembly regression?

From: Robert Hogan <robert@xxxxxxxxxxxxxxx>
Date: Wed, 23 Sep 2009 21:16:05 +0100
On Wednesday 23 September 2009 20:09:32 Stephen Fisher wrote:
> On Sep 23, 2009, at 12:35 PM, Robert Hogan wrote:
> > Has there been a change to the packet re-assembly logic since
> > 20/08/09?
>
> Are you using dissect_tcp_pdus()?  The file containing that function,
> packet-tcp.c, has had a few changes since then:
>
> http://anonsvn.wireshark.org/viewvc/trunk/epan/dissectors/packet-tcp.c?v
>iew=log
>
> Can you explain what the problem is that you're having?
>

This is what I have against svn trunk:

http://roberthogan.net/images/ws-svn-trunk-127.jpg

This is what i have with svn up -r {2009-08-20}:

http://roberthogan.net/images/ws-svn-20090820-127.jpg

Note that the latter shows a reassembled tcp packet but svn trunk does not.

I'm using the standard

      pinfo->desegment_offset = offset;
      pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;

to desegment/reassemble. My code is as follows:

while ((len = tvb_length_remaining(tvb, offset)) > 0) {
  iac_offset = find_unescaped_iac(tvb, offset, len);
  if (iac_offset != -1) {
    /*
      * We found an IAC byte.
      * If there's any data before it, add that data to the
      * tree, a line at a time.
      */
    data_len = iac_offset - offset;
    if (data_len > 0) {
  if (is_tn3270) {
      next_tvb = tvb_new_subset(tvb, offset, data_len, data_len);
      call_dissector(tn3270_handle, next_tvb, pinfo,telnet_tree);
  }else if (is_tn5250) {
      next_tvb = tvb_new_subset(tvb, offset, data_len, data_len);
      call_dissector(tn5250_handle, next_tvb, pinfo,telnet_tree);
  } else
      telnet_add_text(telnet_tree, tvb, offset, data_len);
    }
    /*
      * Now interpret the command.
      */
    offset = telnet_command(pinfo, telnet_tree, tvb, iac_offset);
  } else {
    /* get more data if tn3270 */
if (is_tn3270 || is_tn5250) {
      pinfo->desegment_offset = offset;
      pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
      return;
    }
    /*
      * We found no IAC byte, so what remains in the buffer
      * is the last of the data in the packet.
      * Add it to the tree, a line at a time, and then quit.
      */
    telnet_add_text(telnet_tree, tvb, offset, len);
    break;
  }
}
}