Ethereal-dev: [Ethereal-dev] [PATCH] EDG on reassembling UDP packets

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Thu, 13 Oct 2005 21:40:22 +0200 (CEST)
Hello list,

Working with the reassembly functionality Ethereal provides I've found
some additional changes had to be made to the EDG 8.4.1:
- a typo (made by myself)
- fragment_add_seq_check() doesn't take -1 as length remaining
- process_reassembled_data() can be called with or without tree, and
  is required in both dissection runs
- some whitespace stuff

That's it.
Jaap

Index: EDG_chapter_dissection.xml
===================================================================
--- EDG_chapter_dissection.xml	(revision 16218)
+++ EDG_chapter_dissection.xml	(working copy)
@@ -763,7 +763,7 @@
 	.....
 	}
 	msg_id	INTEGER(0..65535),
-	frag_id	INTEGER(0..65565),
+	frag_id	INTEGER(0..65535),
 	.....
 }
 ]]>
@@ -782,12 +782,12 @@
 	guint16 msg_num = tvb_get_ntohs(tvb, offset); offset += 2;
 
 	pinfo->fragmented = TRUE;
-	frag_msg = fragment_add_seq_check (tvb, offset, pinfo,
+	frag_msg = fragment_add_seq_check(tvb, offset, pinfo,
 		msg_seqid, /* ID for fragments belonging together */
 		msg_fragment_table, /* list of message fragments */
 		msg_reassembled_table, /* list of reassembled messages */
 		msg_num, /* fragment sequence number */
-		-1, /* fragment length - to the end */
+		tvb_length_remaining(tvb, offset), /* fragment length - to the end */
 		flags & FL_FRAG_LAST); /* More fragments? */
 ]]>
    </programlisting></example>
@@ -821,7 +821,7 @@
 	msg_num is the packet number within the sequence. 
 	</para></listitem>
 	<listitem><para>
-	The length here is specified as -1, as we want the rest of the packet data. 
+	The length here is specified as the rest of the tvb as we want the rest of the packet data. 
 	</para></listitem>
 	<listitem><para>
 	Finally a parameter that signals if this is the last fragment or not.
@@ -832,19 +832,17 @@
 	   <example><title>Reassembling fragments part 2</title>
 	   <programlisting>
 	   <![CDATA[
-	if (msg_tree)
-		new_tvb = process_reassembled_data(tvb, offset, pinfo,
+	new_tvb = process_reassembled_data(tvb, offset, pinfo,
 		"Reassembled Message", frag_msg, &msg_frag_items,
 		NULL, msg_tree);
 
 	if (frag_msg) { /* Reassembled */
-		if (check_col (pinfo->cinfo, COL_INFO))
-			col_append_str (pinfo->cinfo, COL_INFO, 
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_str(pinfo->cinfo, COL_INFO, 
 			" (Message Reassembled)");
-	} else {
-		/* Not last packet of reassembled Short Message */
-		if (check_col (pinfo->cinfo, COL_INFO))
-			col_append_fstr (pinfo->cinfo, COL_INFO,
+	} else { /* Not last packet of reassembled Short Message */
+		if (check_col(pinfo->cinfo, COL_INFO))
+			col_append_fstr(pinfo->cinfo, COL_INFO,
 			" (Message fragment %u)", msg_num);
 	}
 
@@ -858,16 +856,14 @@
 	next_tvb = tvb_new_subset(tvb, offset, -1, -1);
 }
 
-offset = 0;
+.....
 pinfo->fragmented = save_fragmented;
 	]]>
    </programlisting></example>
 	   <para>
 	   Having passed the fragment data to the reassembly handler, we can
-	   now check if we have the whole message. We can only do this if were
-	   in the display mode, as we need to pass the display tree parameter into this 
-	   routine. If there is enough information, this routine will return the 
-	   newly reassembled data buffer. 
+	   now check if we have the whole message. If there is enough information, 
+	   this routine will return the newly reassembled data buffer. 
 	   </para>
 	   <para>
 	   After that, we add a couple of informative messages to the display