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>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
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
49 static dissector_handle_t xml_handle=NULL;
52 dissect_jabber(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
55 proto_tree *jabber_tree;
63 if (check_col(pinfo->cinfo, COL_PROTOCOL))
64 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Jabber");
67 * Find the end of the first line.
69 * Note that "tvb_find_line_end()" will return a value that is
70 * not longer than what's in the buffer, so the "tvb_get_ptr()"
71 * call won't throw an exception.
73 linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
74 line = tvb_get_ptr(tvb, offset, linelen);
76 if (pinfo->match_port == pinfo->destport)
81 if (check_col(pinfo->cinfo, COL_INFO)) {
83 * Put the first line from the buffer into the summary
84 * (but leave out the line terminator).
86 col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",
87 is_request ? "Request" : "Response",
88 format_text(line, linelen));
92 ti = proto_tree_add_item(tree, proto_jabber, tvb, offset, -1,
94 jabber_tree = proto_item_add_subtree(ti, ett_jabber);
97 proto_tree_add_boolean_hidden(jabber_tree,
98 hf_jabber_request, tvb, 0, 0, TRUE);
100 proto_tree_add_boolean_hidden(jabber_tree,
101 hf_jabber_response, tvb, 0, 0, TRUE);
104 xmltvb = tvb_new_subset(tvb, offset, -1, -1);
105 call_dissector(xml_handle, xmltvb, pinfo, jabber_tree);
110 proto_register_jabber(void)
112 static hf_register_info hf[] = {
113 { &hf_jabber_response,
114 { "Response", "jabber.response",
115 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
116 "TRUE if Jabber response", HFILL }},
118 { &hf_jabber_request,
119 { "Request", "jabber.request",
120 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
121 "TRUE if Jabber request", HFILL }}
123 static gint *ett[] = {
128 proto_jabber = proto_register_protocol("Jabber XML Messaging",
130 proto_register_field_array(proto_jabber, hf, array_length(hf));
131 proto_register_subtree_array(ett, array_length(ett));
135 proto_reg_handoff_jabber(void)
137 dissector_handle_t jabber_handle;
139 xml_handle = find_dissector("xml");
141 jabber_handle = create_dissector_handle(dissect_jabber, proto_jabber);
142 dissector_add("tcp.port", TCP_PORT_JABBER, jabber_handle);