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

Ethereal-dev: [Ethereal-dev] [PATCH] EDG 8.4.1

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: Tue, 4 Oct 2005 08:06:23 +0200 (CEST)
Hi list,

Reading EDG 8.4.1 it struck me as a bit incomplete and inconsistent.
This patch hopes to work these kinks out.

Thanx,
Jaap

Index: EDG_chapter_dissection.xml
===================================================================
--- EDG_chapter_dissection.xml	(revision 16108)
+++ EDG_chapter_dissection.xml	(working copy)
@@ -743,17 +743,31 @@
 		</para>
 		<para>
 		To deal with such streams, we need several things to trigger
-		from. We need to know that this is packet is part of a multi-packet 
+		from. We need to know that this packet is part of a multi-packet 
 		sequence. We need to know how many packets are in the sequence.
-		We need to also know when we have all the packets.
+		We also need to know when we have all the packets.
 		</para>
 		<para>
 		For this example we'll assume there is a simple in-protocol
 		signaling mechanism to give details. A flag byte that signals
-		the presence of a multi-packet and also the last packet, 
-		followed by an ID of the sequence,
-		a packet sequence number.
+		the presence of a multi-packet sequence and also the last packet, 
+		followed by an ID of the sequence and a packet sequence number.
 		</para>
+                <programlisting>
+<![CDATA[
+msg_pkt ::= SEQUENCE {
+	.....
+	flags ::= SEQUENCE {
+		fragment	BOOLEAN,
+		last_fragment	BOOLEAN,
+	.....
+	}
+	msg_id	INTEGER(0..65535),
+	frag_id	INTEGER(0..65565),
+	.....
+}
+]]>
+                </programlisting>
 	   <example><title>Reassembling fragments - Part 1</title>
    <programlisting>
    <![CDATA[
@@ -761,7 +775,7 @@
    ...
 save_fragmented = pinfo->fragmented;
 flags = tvb_get_guint8(tvb, offset); offset++;
-if (flags & FL_FRAGMENT) { // fragmented
+if (flags & FL_FRAGMENT) { /* fragmented */
 	tvbuff_t* new_tvb = NULL;
 	fragment_data *frag_msg = NULL;
 	guint16 msg_seqid = tvb_get_ntohs(tvb, offset); offset += 2;
@@ -769,11 +783,11 @@
 
 	pinfo->fragmented = TRUE;
 	frag_msg = fragment_add_seq_check (tvb, offset, pinfo,
-		msg_seqid, /* guint32 ID for fragments belonging together */
+		msg_seqid, /* ID for fragments belonging together */
 		msg_fragment_table, /* list of message fragments */
 		msg_reassembled_table, /* list of reassembled messages */
-		msg_num, /* guint32 fragment sequence number */
-		-1, /* guint32 fragment length - to the end */
+		msg_num, /* fragment sequence number */
+		-1, /* fragment length - to the end */
 		flags & FL_FRAG_LAST); /* More fragments? */
 ]]>
    </programlisting></example>
@@ -827,20 +841,20 @@
 		if (check_col (pinfo->cinfo, COL_INFO))
 			col_append_str (pinfo->cinfo, COL_INFO, 
 			" (Message Reassembled)");
-	} else {
-		/* Not last packet of reassembled Short Message */
+	} 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);
 	}
-	if (new_tvb) { // take it all
+
+	if (new_tvb) { /* take it all */
 		next_tvb = new_tvb;
+	} else { /* make a new subset */
+	 	next_tvb = tvb_new_subset(tvb, offset, -1, -1);
 	}
-	else  // make a new subset
-		next_tvb = tvb_new_subset(next_tvb, offset, -1, -1);
 }
-else {
-	next_tvb = tvb_new_subset(next_tvb, offset, -1, -1);
+else { /* Not fragmented */
+	next_tvb = tvb_new_subset(tvb, offset, -1, -1);
 }
 
 offset = 0;
@@ -893,6 +907,19 @@
 	   <example><title>Reassembling fragments - Data</title>
 	   <programlisting>
 	   <![CDATA[
+...
+static int hf_msg_fragments = -1;
+static int hf_msg_fragment = -1;
+static int hf_msg_fragment_overlap = -1;
+static int hf_msg_fragment_overlap_conflicts = -1;
+static int hf_msg_fragment_multiple_tails = -1;
+static int hf_msg_fragment_too_long_fragment = -1;
+static int hf_msg_fragment_error = -1;
+static int hf_msg_reassembled_in = -1;
+...
+static gint ett_msg_fragment = -1;
+static gint ett_msg_fragments = -1;
+...
 static const fragment_items msg_frag_items = {
 	/* Fragment subtrees */
 	&ett_msg_fragment,
@@ -911,6 +938,9 @@
 	"Message fragments"
 };
 ...
+static hf_register_info hf[] = 
+{
+...
 {&hf_msg_fragments,
 	{"Message fragments", "msg.fragments",
 	FT_NONE, BASE_NONE, NULL, 0x00,	NULL, HFILL } },
@@ -937,6 +967,13 @@
 {&hf_msg_reassembled_in,
 	{"Reassembled in", "msg.reassembled.in",
 	FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } },
+...
+static gint *ett[] = 
+{
+...
+&ett_msg_fragment,
+&ett_msg_fragments
+...
 ]]>
    </programlisting></example>
    <para>