2 * Routines for Jabber packet dissection
3 * Copyright 2003, Brad Hards <bradh@frogmouth.net>
4 * Heavily based in packet-acap.c, which in turn is heavily based on
5 * packet-imap.c, Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
7 * $Id: packet-jabber.c,v 1.1 2003/07/07 22:48:55 guy Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
11 * Copyright 1998 Gerald Combs
13 * Copied from packet-acap.c
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include <epan/packet.h>
39 #include <epan/strutil.h>
41 static int proto_jabber = -1;
42 static int hf_jabber_response = -1;
43 static int hf_jabber_request = -1;
45 static gint ett_jabber = -1;
46 static gint ett_jabber_reqresp = -1;
48 #define TCP_PORT_JABBER 5222
51 dissect_jabber(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
54 proto_tree *jabber_tree;
61 if (check_col(pinfo->cinfo, COL_PROTOCOL))
62 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Jabber");
65 * Find the end of the first line.
67 * Note that "tvb_find_line_end()" will return a value that is
68 * not longer than what's in the buffer, so the "tvb_get_ptr()"
69 * call won't throw an exception.
71 linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
72 line = tvb_get_ptr(tvb, offset, linelen);
74 if (pinfo->match_port == pinfo->destport)
79 if (check_col(pinfo->cinfo, COL_INFO)) {
81 * Put the first line from the buffer into the summary
82 * (but leave out the line terminator).
84 col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",
85 is_request ? "Request" : "Response",
86 format_text(line, linelen));
90 ti = proto_tree_add_item(tree, proto_jabber, tvb, offset, -1,
92 jabber_tree = proto_item_add_subtree(ti, ett_jabber);
95 proto_tree_add_boolean_hidden(jabber_tree,
96 hf_jabber_request, tvb, 0, 0, TRUE);
98 proto_tree_add_boolean_hidden(jabber_tree,
99 hf_jabber_response, tvb, 0, 0, TRUE);
103 * Put the line into the protocol tree.
105 ti = proto_tree_add_text(jabber_tree, tvb, offset,
106 next_offset - offset, "%s",
107 tvb_format_text(tvb, offset, next_offset - offset));
112 proto_register_jabber(void)
114 static hf_register_info hf[] = {
115 { &hf_jabber_response,
116 { "Response", "jabber.response",
117 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
118 "TRUE if Jabber response", HFILL }},
120 { &hf_jabber_request,
121 { "Request", "jabber.request",
122 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
123 "TRUE if Jabber request", HFILL }}
125 static gint *ett[] = {
130 proto_jabber = proto_register_protocol("Jabber XML Messaging",
132 proto_register_field_array(proto_jabber, hf, array_length(hf));
133 proto_register_subtree_array(ett, array_length(ett));
137 proto_reg_handoff_jabber(void)
139 dissector_handle_t jabber_handle;
141 jabber_handle = create_dissector_handle(dissect_jabber, proto_jabber);
142 dissector_add("tcp.port", TCP_PORT_JABBER, jabber_handle);