Ethereal-dev: [Ethereal-dev] Patch to packet-jabber.c - dissect as XML

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

From: Kaul <mykaul@xxxxxxxxx>
Date: Tue, 20 Sep 2005 09:49:57 +0300
Jabber traffic is XML, attached patch dissects it as such.

Regards,
Y.

Index: packet-jabber.c
===================================================================
--- packet-jabber.c	(revision 15875)
+++ packet-jabber.c	(working copy)
@@ -46,6 +46,7 @@
 static gint ett_jabber_reqresp = -1;
 
 #define TCP_PORT_JABBER			5222
+static dissector_handle_t xml_handle=NULL;
 
 static void
 dissect_jabber(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -57,6 +58,7 @@
 	const guchar	*line;
 	gint		next_offset;
 	int		linelen;
+	tvbuff_t *xmltvb;
 
 	if (check_col(pinfo->cinfo, COL_PROTOCOL))
 		col_set_str(pinfo->cinfo, COL_PROTOCOL, "Jabber");
@@ -99,12 +101,8 @@
 			    hf_jabber_response, tvb, 0, 0, TRUE);
 		}
 
-		/*
-		 * Put the line into the protocol tree.
-		 */
-		ti = proto_tree_add_text(jabber_tree, tvb, offset,
-		    next_offset - offset, "%s",
-		    tvb_format_text(tvb, offset, next_offset - offset));
+		xmltvb = tvb_new_subset(tvb, offset, -1, -1);
+		call_dissector(xml_handle, xmltvb, pinfo, jabber_tree);
 	}
 }
 
@@ -138,6 +136,8 @@
 {
   dissector_handle_t jabber_handle;
 
+  xml_handle = find_dissector("xml");
+
   jabber_handle = create_dissector_handle(dissect_jabber, proto_jabber);
   dissector_add("tcp.port", TCP_PORT_JABBER, jabber_handle);
 }