Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] DESEGMENT_ONE_MORE_SEGMENT over iax

From: Richard van der Hoff <richardv@xxxxxxxxxxxxx>
Date: Fri, 16 Feb 2007 18:12:29 +0000
Hi,

This patch makes the defragmentation code in the iax2 dissector handle pinfo->desegment_len=DESEGMENT_ONE_MORE_SEGMENT, in line with
Ronnie's changes to the tcp dissector of 11 November.

Incidentally, Ronnie: I think there's a problem with the tcp dissector. Basically if the subdissector sets pinfo->desegment_len=DESEGMENT_ONE_MORE_SEGMENT, this causes the tcp dissector to set MSP_FLAGS_REASSEMBLE_ENTIRE_SEGMENT for the datagram being reassembled. However, if the same packet is revisited (as it appears it can be sometimes), no more data is added, and MSP_FLAGS_REASSEMBLE_ENTIRE_SEGMENT is cleared. The next fragment is then deemed to start a new datagram.

Cheers

Richard
Index: epan/dissectors/packet-iax2.c
===================================================================
@@ -1789,12 +1801,17 @@
          within that section, the higher-level dissector was unable to find any
          pdus; if it's after that, it found one or more complete PDUs.
       */
-      old_len = (gint32)(tvb_reported_length(next_tvb) - tvb_reported_length(tvb));
+      old_len = (gint32)(tvb_reported_length(next_tvb) - frag_len);
       if( pinfo->desegment_len &&
 	  pinfo->desegment_offset < old_len ) {
 	/* oops, it wasn't actually complete */
 	fragment_set_partial_reassembly(pinfo, fid, iax_call->fragment_table);
-	dirdata->current_frag_minlen = fd_head->datalen + pinfo->desegment_len;
+        if(pinfo->desegment_len == DESEGMENT_ONE_MORE_SEGMENT) {
+          /* only one more byte should be enough for a retry */
+          dirdata->current_frag_minlen = fd_head->datalen + 1;
+        } else {
+          dirdata->current_frag_minlen = fd_head->datalen + pinfo->desegment_len;
+        }
       } else {
 	/* we successfully dissected some data; create the proto tree items for
 	 * the fragments, and flag any remaining data for desegmentation */
@@ -1847,7 +1864,14 @@
       guint32 frag_len = tvb_reported_length_remaining(tvb,deseg_offset);
       dirdata->current_frag_id = fid;
       dirdata->current_frag_bytes = frag_len;
-      dirdata->current_frag_minlen = frag_len + pinfo->desegment_len;
+
+      if(pinfo->desegment_len == DESEGMENT_ONE_MORE_SEGMENT) {
+        /* only one more byte should be enough for a retry */
+          dirdata->current_frag_minlen = frag_len + 1;
+        } else {
+          dirdata->current_frag_minlen = frag_len + pinfo->desegment_len;
+        }
+
       fd_head = fragment_add(tvb, deseg_offset, pinfo, fid,
 			     iax_call->fragment_table,
                              0, frag_len, TRUE );