Ethereal-dev: [Ethereal-dev] New updates for wsp and wtls

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

From: "Alexandre P. Ferreira" <alexandref@xxxxxxxxxxxxxxx>
Date: Mon, 19 Feb 2001 09:23:03 -0300
Hi,

Some corrections for accept-charset and other improvements.

Thanks,

--
Alexandre P. Ferreira
Coordenador de Plataforma
Splice IP
+55 61 3137504

diff -cr ethereal-2001-02-19/packet-wap.c ethereal-2001-02-19.new/packet-wap.c
*** ethereal-2001-02-19/packet-wap.c	Mon Feb 12 22:17:54 2001
--- ethereal-2001-02-19.new/packet-wap.c	Mon Feb 19 08:53:27 2001
***************
*** 57,69 ****
  #ifdef DEBUG
  		fprintf (stderr, "dissect_wsp: Starting tvb_get_guintvar at offset %d, count=NULL\n", offset);
  #endif
  	}
  	else
  	{
  #ifdef DEBUG
  		fprintf (stderr, "dissect_wsp: Starting tvb_get_guintvar at offset %d, count=%d\n", offset, *octetCount);
  #endif
- 		counter = *octetCount;
  	}
  
  	while (cont != 0)
--- 57,69 ----
  #ifdef DEBUG
  		fprintf (stderr, "dissect_wsp: Starting tvb_get_guintvar at offset %d, count=NULL\n", offset);
  #endif
+ 		/* counter = *octetCount; */
  	}
  	else
  	{
  #ifdef DEBUG
  		fprintf (stderr, "dissect_wsp: Starting tvb_get_guintvar at offset %d, count=%d\n", offset, *octetCount);
  #endif
  	}
  
  	while (cont != 0)
diff -cr ethereal-2001-02-19/packet-wsp.c ethereal-2001-02-19.new/packet-wsp.c
*** ethereal-2001-02-19/packet-wsp.c	Mon Feb 12 22:17:54 2001
--- ethereal-2001-02-19.new/packet-wsp.c	Mon Feb 19 08:53:27 2001
***************
*** 818,824 ****
  	guint valueLen = tvb_reported_length (value_buff);
  	guint peek = 0;
  	struct timeval timeValue;
- 	guint count = 0;
  	guint value = 0;
  	guint valueLength = 0;
  	char valString[100];
--- 818,823 ----
***************
*** 883,890 ****
  						{
  							offset++;
  	
! 							/* TODO: Need to read peek octets */
! 							value = 0x00;
  							offset += peek;
  						}
  						valMatch = match_strval(value, vals_character_sets);
--- 882,907 ----
  						{
  							offset++;
  	
! 							switch (peek)
! 							{
! 								case 1:
! 									value = tvb_get_guint8 (value_buff, offset);
! 									break;
! 								case 2:
! 									value = tvb_get_ntohs (value_buff, offset);
! 									break;
! 								case 3:
! 									value = tvb_get_ntoh24 (value_buff, offset);
! 									break;
! 								case 4:
! 									value = tvb_get_ntohl (value_buff, offset);
! 									break;
! 								default:
! 									/* TODO: Need to read peek octets */
! 									value = 0;
! 									fprintf (stderr, "dissect_wsp: accept-charset size %d NYI\n", peek);
! 									break;
! 							}
  							offset += peek;
  						}
  						valMatch = match_strval(value, vals_character_sets);
***************
*** 897,918 ****
  					/* Any remaining data relates to Q-Value */
  					if (offset < valueLen)
  					{
! 						count = 0;
! 						q_value = tvb_get_guintvar (value_buff, offset, &count);
! 						if (count == 1)			/* Two decimal quality factors */
! 						{
! 							q_value -= 1;
! 							q_value /= 100;
  						}
! 						else if (count == 2) /* Three decimal quality factors */
! 						{
! 							q_value -= 100;
! 							q_value /= 1000;
! 						}
! 						else
! 						{
! 							fprintf (stderr, "dissect_wsp: Accept-Charset invalid Q-value %f\n", q_value);
  						}
  					}
  
  					/* Build string including Q values if present */
--- 914,927 ----
  					/* Any remaining data relates to Q-Value */
  					if (offset < valueLen)
  					{
! 						peek = tvb_get_guintvar (value_buff, offset, NULL);
! 						if (peek <= 100) {
! 							peek = (peek - 1) * 10;
  						}
! 						else {
! 							peek -= 100;
  						}
+ 						q_value = peek/1000.0;
  					}
  
  					/* Build string including Q values if present */
***************
*** 920,926 ****
  					{
  						if (valMatch == NULL)
  						{
! 							snprintf (valString, 100, "Unknown (%02X)", peek);
  						}
  						else
  						{
--- 929,935 ----
  					{
  						if (valMatch == NULL)
  						{
! 							snprintf (valString, 100, "Unknown (%X)", peek);
  						}
  						else
  						{
***************
*** 929,943 ****
  					}
  					else
  					{
- 						snprintf (valString, 100, "Unknown %d; Q=%5.3f", value,
- 							q_value/1000.0);
  						if (valMatch == NULL)
  						{
! 							snprintf (valString, 100, "Unknown (%02X)", peek);
  						}
  						else
  						{
! 							snprintf (valString, 100, "%s", valMatch);
  						}
  					}
  
--- 938,950 ----
  					}
  					else
  					{
  						if (valMatch == NULL)
  						{
! 							snprintf (valString, 100, "Unknown (%X); Q=%5.3f", peek,q_value);
  						}
  						else
  						{
! 							snprintf (valString, 100, "%s; Q=%5.3f", valMatch,q_value);
  						}
  					}
  
***************
*** 1192,1211 ****
  		 * by a 4-byte date value */
  		if (strncasecmp ("x-wap.tod", tvb_get_ptr (header_buff, 0, headerLen), 9) == 0)
  		{
! 			if (tvb_reported_length (value_buff) == 4)	/* Probably a date value */
  			{
! 				timeValue.tv_sec = tvb_get_ntohl (value_buff, 0);
  				ti = proto_tree_add_time (tree, hf_wsp_header_x_wap_tod, header_buff, offset, headerLen, &timeValue);
  			}
- 			else if (tvb_reported_length (value_buff) == 5) /* Probably a date */
- 			{
- 				add_date_value (value_buff, 0, tree,
- 					hf_wsp_header_x_wap_tod, header_buff, offset,
- 					headerLen, &timeValue, "X-Wap.Tod");
- 			}
  			else
! 			{
! 				ti = proto_tree_add_text (tree, header_buff, 0, headerLen, "%s: %s", tvb_get_ptr (header_buff, 0, headerLen), tvb_get_ptr (value_buff, 0, valueLen));
  			}
  		}
  		else
--- 1199,1232 ----
  		 * by a 4-byte date value */
  		if (strncasecmp ("x-wap.tod", tvb_get_ptr (header_buff, 0, headerLen), 9) == 0)
  		{
! 			peek = tvb_get_guint8 (value_buff,offset);
! 			if (peek < 31) 
  			{
! 				timeValue.tv_usec = 0;
! 				switch (peek)
! 				{
! 					case 1:
! 						timeValue.tv_sec = tvb_get_guint8 (value_buff, 1);
! 						break;
! 					case 2:
! 						timeValue.tv_sec = tvb_get_ntohs (value_buff, 1);
! 						break;
! 					case 3:
! 						timeValue.tv_sec = tvb_get_ntoh24 (value_buff, 1);
! 						break;
! 					case 4:
! 						timeValue.tv_sec = tvb_get_ntohl (value_buff, 1);
! 						break;
! 					default:
! 						timeValue.tv_sec = 0;
! 						fprintf (stderr, "dissect_wsp: X-WAP.TOD NYI\n");
! 						break;
! 				}
  				ti = proto_tree_add_time (tree, hf_wsp_header_x_wap_tod, header_buff, offset, headerLen, &timeValue);
  			}
  			else
! 		       	{
! 				fprintf (stderr, "dissect_wsp: X-WAP.TOD peek %X NYI\n",peek);
  			}
  		}
  		else
diff -cr ethereal-2001-02-19/packet-wtls.c ethereal-2001-02-19.new/packet-wtls.c
*** ethereal-2001-02-19/packet-wtls.c	Thu Feb 15 17:46:41 2001
--- ethereal-2001-02-19.new/packet-wtls.c	Mon Feb 19 09:02:01 2001
***************
*** 497,511 ****
  			wtls_msg_type_item_sub_tree = proto_item_add_subtree(ti, ett_wtls_msg_type_item_sub);
  			offset+=2;
  			for (;count > 0;count-=client_size) {
! 				cli_key_item = proto_tree_add_item(wtls_msg_type_item_sub_tree, 
  						hf_wtls_hands_cli_hello_key_exchange, tvb, offset,1,
! 						bo_little_endian);
  				client_size=1;
  				wtls_msg_type_item_sub_sub_tree = proto_item_add_subtree(cli_key_item, 
  								  ett_wtls_msg_type_item_sub_sub);
! 				ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
  						hf_wtls_hands_cli_hello_key_exchange_suite,
! 						tvb,offset,1,bo_big_endian);
  				offset++;
  				value = tvb_get_guint8 (tvb, offset);
  				ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
--- 497,512 ----
  			wtls_msg_type_item_sub_tree = proto_item_add_subtree(ti, ett_wtls_msg_type_item_sub);
  			offset+=2;
  			for (;count > 0;count-=client_size) {
! 				value = tvb_get_guint8 (tvb, offset);
! 				cli_key_item = proto_tree_add_uint(wtls_msg_type_item_sub_tree, 
  						hf_wtls_hands_cli_hello_key_exchange, tvb, offset,1,
! 						value);
  				client_size=1;
  				wtls_msg_type_item_sub_sub_tree = proto_item_add_subtree(cli_key_item, 
  								  ett_wtls_msg_type_item_sub_sub);
! 				ti = proto_tree_add_uint(wtls_msg_type_item_sub_sub_tree,
  						hf_wtls_hands_cli_hello_key_exchange_suite,
! 						tvb,offset,1,value);
  				offset++;
  				value = tvb_get_guint8 (tvb, offset);
  				ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
***************
*** 536,550 ****
  			wtls_msg_type_item_sub_tree = proto_item_add_subtree(ti, ett_wtls_msg_type_item_sub);
  			offset+=2;
  			for (;count > 0;count-=client_size) {
  				cli_key_item = proto_tree_add_item(wtls_msg_type_item_sub_tree, 
  						hf_wtls_hands_cli_hello_key_exchange, tvb, offset,1,
! 						bo_little_endian);
  				client_size=1;
  				wtls_msg_type_item_sub_sub_tree = proto_item_add_subtree(cli_key_item, 
  								  ett_wtls_msg_type_item_sub_sub);
! 				ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
  						hf_wtls_hands_cli_hello_key_exchange_suite,
! 						tvb,offset,1,bo_big_endian);
  				offset++;
  				value = tvb_get_guint8 (tvb, offset);
  				ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
--- 537,552 ----
  			wtls_msg_type_item_sub_tree = proto_item_add_subtree(ti, ett_wtls_msg_type_item_sub);
  			offset+=2;
  			for (;count > 0;count-=client_size) {
+ 				value = tvb_get_guint8 (tvb, offset);
  				cli_key_item = proto_tree_add_item(wtls_msg_type_item_sub_tree, 
  						hf_wtls_hands_cli_hello_key_exchange, tvb, offset,1,
! 						value);
  				client_size=1;
  				wtls_msg_type_item_sub_sub_tree = proto_item_add_subtree(cli_key_item, 
  								  ett_wtls_msg_type_item_sub_sub);
! 				ti = proto_tree_add_uint(wtls_msg_type_item_sub_sub_tree,
  						hf_wtls_hands_cli_hello_key_exchange_suite,
! 						tvb,offset,1,value);
  				offset++;
  				value = tvb_get_guint8 (tvb, offset);
  				ti = proto_tree_add_item(wtls_msg_type_item_sub_sub_tree,
***************
*** 974,980 ****
  		{ &hf_wtls_hands_cli_hello_key_exchange,
  			{ 	"Key Exchange",           
  				"wsp.wtls.handshake.client_hello.key.key_exchange",
! 				 FT_NONE, BASE_NONE, NULL, 0x00,
  				"Key Exchange" 
  			}
  		},
--- 976,982 ----
  		{ &hf_wtls_hands_cli_hello_key_exchange,
  			{ 	"Key Exchange",           
  				"wsp.wtls.handshake.client_hello.key.key_exchange",
! 				 FT_UINT8, BASE_HEX, VALS ( wtls_vals_key_exchange_suite ), 0x00,
  				"Key Exchange" 
  			}
  		},