Ethereal-dev: [Ethereal-dev] [patch] trivial jabber dissector
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Brad Hards <bhards@xxxxxxxxxxxxxx>
Date: Mon, 7 Jul 2003 20:56:00 +1000
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The attached patch (and file, "cvs diff" and I still don't agree) implements a trivial (naive?) dissector for the jabber client to server protocol, which is just XML streams. Apply, if you like. Brad -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/CVHIW6pHgIdAuOMRAofoAJ9gOz5jCKTvWbO8N55sY8bomv4pvQCfaLd1 tuOS8KQ45RW+eVE77YnMFr8= =wdys -----END PGP SIGNATURE-----
Index: Makefile.nmake =================================================================== RCS file: /cvsroot/ethereal/Makefile.nmake,v retrieving revision 1.315 diff -u -3 -p -r1.315 Makefile.nmake --- Makefile.nmake 25 Jun 2003 13:42:18 -0000 1.315 +++ Makefile.nmake 7 Jul 2003 10:57:28 -0000 @@ -195,6 +195,7 @@ DISSECTOR_SRC = \ packet-isns.c \ packet-isup.c \ packet-iua.c \ + packet-jabber.c \ packet-kadm5.c \ packet-kerberos.c \ packet-klm.c \ Index: Makefile.am =================================================================== RCS file: /cvsroot/ethereal/Makefile.am,v retrieving revision 1.595 diff -u -3 -p -r1.595 Makefile.am --- Makefile.am 26 Jun 2003 18:21:29 -0000 1.595 +++ Makefile.am 7 Jul 2003 10:57:29 -0000 @@ -254,6 +254,7 @@ DISSECTOR_SRC = \ packet-isns.c \ packet-isup.c \ packet-iua.c \ + packet-jabber.c \ packet-kadm5.c \ packet-kerberos.c \ packet-klm.c \
/* packet-jabber.c * Routines for Jabber packet dissection * Copyright 2003, Brad Hards <bradh@xxxxxxxxxxxxx> * Heavily based in packet-acap.c, which in turn is heavily based on * packet-imap.c, Copyright 1999, Richard Sharpe <rsharpe@xxxxxxxxxx> * * $Id: packet-jabber.c,v 1.2 2003/06/11 20:04:13 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@xxxxxxxxxxxx> * Copyright 1998 Gerald Combs * * Copied from packet-acap.c * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <stdio.h> #include <string.h> #include <glib.h> #include <epan/packet.h> #include <epan/strutil.h> static int proto_jabber = -1; static int hf_jabber_response = -1; static int hf_jabber_request = -1; static gint ett_jabber = -1; static gint ett_jabber_reqresp = -1; #define TCP_PORT_JABBER 5222 static void dissect_jabber(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { gboolean is_request; proto_tree *jabber_tree; proto_item *ti; gint offset = 0; const guchar *line; gint next_offset; int linelen; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "Jabber"); /* * Find the end of the first line. * * Note that "tvb_find_line_end()" will return a value that is * not longer than what's in the buffer, so the "tvb_get_ptr()" * call won't throw an exception. */ linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); line = tvb_get_ptr(tvb, offset, linelen); if (pinfo->match_port == pinfo->destport) is_request = TRUE; else is_request = FALSE; if (check_col(pinfo->cinfo, COL_INFO)) { /* * Put the first line from the buffer into the summary * (but leave out the line terminator). */ col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s", is_request ? "Request" : "Response", format_text(line, linelen)); } if (tree) { ti = proto_tree_add_item(tree, proto_jabber, tvb, offset, -1, FALSE); jabber_tree = proto_item_add_subtree(ti, ett_jabber); if (is_request) { proto_tree_add_boolean_hidden(jabber_tree, hf_jabber_request, tvb, 0, 0, TRUE); } else { proto_tree_add_boolean_hidden(jabber_tree, 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)); } } void proto_register_jabber(void) { static hf_register_info hf[] = { { &hf_jabber_response, { "Response", "jabber.response", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "TRUE if Jabber response", HFILL }}, { &hf_jabber_request, { "Request", "jabber.request", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "TRUE if Jabber request", HFILL }} }; static gint *ett[] = { &ett_jabber, &ett_jabber_reqresp, }; proto_jabber = proto_register_protocol("Jabber XML Messaging", "Jabber", "jabber"); proto_register_field_array(proto_jabber, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } void proto_reg_handoff_jabber(void) { dissector_handle_t jabber_handle; jabber_handle = create_dissector_handle(dissect_jabber, proto_jabber); dissector_add("tcp.port", TCP_PORT_JABBER, jabber_handle); }
- Follow-Ups:
- Re: [Ethereal-dev] [patch] trivial jabber dissector
- From: Guy Harris
- Re: [Ethereal-dev] [patch] trivial jabber dissector
- Prev by Date: [Ethereal-dev] fix "parse error" with Debian's flex
- Next by Date: [Ethereal-dev] doc/README.developer
- Previous by thread: Re: [Ethereal-dev] fix "parse error" with Debian's flex
- Next by thread: Re: [Ethereal-dev] [patch] trivial jabber dissector
- Index(es):