Ethereal-dev: [Ethereal-dev] Armagetronad dissector update

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

From: Guillaume Chazarain <guichaz@xxxxxxxx>
Date: Mon, 27 Mar 2006 14:09:03 +0200
Hi,

Here is a bugfix for the dissector (proto_tree_add_string() expects a null terminated string), and an update to handle the new message types. I don't intend to send an update for every new message added, just wanted to base on a released version, not a CVS snapshot.

Thanks.

--
Guillaume

Index: epan/dissectors/packet-armagetronad.c
===================================================================
--- epan/dissectors/packet-armagetronad.c	(révision 17730)
+++ epan/dissectors/packet-armagetronad.c	(copie de travail)
@@ -55,7 +55,7 @@
 #define ACK 1
 
 /*
- * CVS as of 05/05/2005
+ * armagetronad-0.2.8.1
  * The list in src/network/Makefile.in does not seem up to date,
  * so the numbers and names were retrieved at runtime using the
  * 'nDescriptor* descriptors[MAXDESCRIPTORS]' array
@@ -87,14 +87,19 @@
 	{51, "big_server"},
 	{52, "small_request"},
 	{53, "big_request"},
+	{54, "big_server_master"},
+	{55, "big_request_master"},
 	{60, "transfer config"},
 	{200, "Chat"},
 	{201, "ePlayerNetID"},
 	{202, "player_removed_from_game"},
+	{203, "Chat Client"},
 	{210, "eTimer"},
 	{220, "eTeam"},
 	{230, "vote cast"},
-	{231, "Chat"},
+	{231, "Kick vote"},
+	{232, "Server controlled vote"},
+	{233, "Server controlled vote expired"},
 	{300, "gNetPlayerWall"},
 	{310, "game"},
 	{311, "client_gamestate"},
@@ -102,7 +107,7 @@
 	{321, "destinaton"},
 	{330, "gAIPlayer"},
 	{331, "gAITeam"},
-	{340, "winzone"},
+	{340, "zone"},
 	{0, NULL}
 };
 
@@ -141,15 +146,16 @@
 add_message_data(tvbuff_t * tvb, gint offset, guint16 data_len,
 		 proto_tree * tree)
 {
-	guint16 *data = NULL;
+	guchar *data = NULL;
 
 	if (tree) {
-		data = (guint16*)tvb_memcpy(tvb, ep_alloc(data_len), offset, data_len);
+		data = tvb_memcpy(tvb, ep_alloc(data_len + 1), offset, data_len);
+		data[data_len] = '\0';
 	}
 
 	if (data) {
-		guint16 *ptr, *end = &data[data_len / 2];
-		for (ptr = data; ptr != end; ptr++) {
+		guint16 *ptr, *end = (guint16*) &data[data_len];
+		for (ptr = (guint16*) data; ptr != end; ptr++) {
 			/*
 			 * There must be a better way to tell
 			 * Ethereal not to stop on null bytes
@@ -168,8 +174,6 @@
 
 		proto_tree_add_string(tree, hf_armagetronad_data, tvb, offset,
 				      data_len, (gchar *) data);
-
-		data = NULL;
 	} else
 		proto_tree_add_item(tree, hf_armagetronad_data, tvb, offset,
 				    data_len, FALSE);