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] WSP-patch

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

From: Georg von Zezschwitz <gvz@xxxxxxxxxx>
Date: Sun, 14 Oct 2001 15:43:26 +0200
Hi!

The attached patch:

  - solves the problem that Ethereal "hangs" when the header
	size in a WSP Connect request exceeds 256 bytes
	(declaration changed from uint8 to unit).
  - implements the attributes of WSP Suspend / Resume.

Cheers,


Georg
Index: packet-wsp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-wsp.c,v
retrieving revision 1.40
diff -u -r1.40 packet-wsp.c
--- packet-wsp.c	2001/10/07 08:49:46	1.40
+++ packet-wsp.c	2001/10/14 13:38:54
@@ -1049,69 +1049,49 @@
 	switch (pdut)
 	{
 		case CONNECT:
+		case CONNECTREPLY:
+		case RESUME:
 			if (tree) {
-				ti = proto_tree_add_item (wsp_tree, hf_wsp_version_major,tvb,offset,1,bo_little_endian);
-				ti = proto_tree_add_item (wsp_tree, hf_wsp_version_minor,tvb,offset,1,bo_little_endian);
-				offset++;
-				capabilityStart = offset;
-				count = 0;	/* Initialise count */
-				capabilityLength = tvb_get_guintvar (tvb, offset, &count);
-				offset += count;
-				ti = proto_tree_add_uint (wsp_tree, hf_wsp_capability_length,tvb,capabilityStart,count,capabilityLength);
-
-				headerStart = offset;
-				count = 0;	/* Initialise count */
-				headerLength = tvb_get_guintvar (tvb, offset, &count);
-				offset += count;
-				ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,headerStart,count,headerLength);
-				if (capabilityLength > 0)
+				if (pdut == CONNECT)
 				{
-					tmp_tvb = tvb_new_subset (tvb, offset, capabilityLength, capabilityLength);
-					add_capabilities (wsp_tree, tmp_tvb, CONNECT);
-					offset += capabilityLength;
-				}
-
-				if (headerLength > 0)
-				{
-					tmp_tvb = tvb_new_subset (tvb, offset, headerLength, headerLength);
-					add_headers (wsp_tree, tmp_tvb);
+					ti = proto_tree_add_item (wsp_tree, hf_wsp_version_major,tvb,offset,1,bo_little_endian);
+					ti = proto_tree_add_item (wsp_tree, hf_wsp_version_minor,tvb,offset,1,bo_little_endian);
+					offset++;
+				} else {
+					count = 0;	/* Initialise count */
+					value = tvb_get_guintvar (tvb, offset, &count);
+					ti = proto_tree_add_uint (wsp_tree, hf_wsp_server_session_id,tvb,offset,count,value);
+					offset += count;
 				}
-			}
-
-			break;
-
-		case CONNECTREPLY:
-			if (tree) {
-				count = 0;	/* Initialise count */
-				value = tvb_get_guintvar (tvb, offset, &count);
-				ti = proto_tree_add_uint (wsp_tree, hf_wsp_server_session_id,tvb,offset,count,value);
-				offset += count;
-
 				capabilityStart = offset;
 				count = 0;	/* Initialise count */
 				capabilityLength = tvb_get_guintvar (tvb, offset, &count);
 				offset += count;
 				ti = proto_tree_add_uint (wsp_tree, hf_wsp_capability_length,tvb,capabilityStart,count,capabilityLength);
 
-				headerStart = offset;
-				count = 0;	/* Initialise count */
-				headerLength = tvb_get_guintvar (tvb, offset, &count);
-				offset += count;
-				ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,headerStart,count,headerLength);
+				if (pdut != RESUME)
+				{
+					count = 0;	/* Initialise count */
+					headerLength = tvb_get_guintvar (tvb, offset, &count);
+					ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,tvb,offset,count,headerLength);
+					offset += count;
+					capabilityStart = offset;
+					headerStart = capabilityStart + capabilityLength;
+				} else {
+						/* Resume computes the headerlength by remaining bytes */
+					capabilityStart = offset;
+					headerStart = capabilityStart + capabilityLength;
+					headerLength = tvb_reported_length_remaining (tvb, headerStart);
+				}
 				if (capabilityLength > 0)
 				{
 					tmp_tvb = tvb_new_subset (tvb, offset, capabilityLength, capabilityLength);
-					add_capabilities (wsp_tree, tmp_tvb, CONNECTREPLY);
+					add_capabilities (wsp_tree, tmp_tvb, CONNECT);
 					offset += capabilityLength;
 				}
 
 				if (headerLength > 0)
 				{
-
-					/*
-					ti = proto_tree_add_item (wsp_tree, hf_wsp_headers_section,tvb,offset,headerLength,bo_little_endian);
-					wsp_headers = proto_item_add_subtree( ti, ett_headers );
-					*/
 					tmp_tvb = tvb_new_subset (tvb, offset, headerLength, headerLength);
 					add_headers (wsp_tree, tmp_tvb);
 				}
@@ -1125,6 +1105,7 @@
 			break;
 
 		case DISCONNECT:
+		case SUSPEND:
 			if (tree) {
 				count = 0;	/* Initialise count */
 				value = tvb_get_guintvar (tvb, offset, &count);
@@ -1354,7 +1335,7 @@
 	proto_tree *wsp_headers;
 	guint offset = 0;
 	guint headersLen = tvb_reported_length (tvb);
-	guint8 headerStart = 0;
+	guint headerStart = 0;
 	guint peek = 0;
 	guint pageCode = 1;