1 /* packet-msn-messenger.c
2 * Routines for MSN Messenger Service packet dissection
3 * Copyright 2003, Chris Waters <chris@waters.co.nz>
5 * $Id: packet-msn-messenger.c,v 1.3 2003/02/13 23:49:19 jmayer Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * Copied from packet-pop.c
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <epan/packet.h>
37 #include <epan/strutil.h>
40 * The now-expired Internet-Draft for the MSN Messenger 1.0 protocol
41 * can, as of the time of the writing of this comment, be found at:
43 * http://praya.sourceforge.net/draft-movva-msn-messenger-protocol-00.txt
45 * http://mono.es.gnome.org/imsharp/tutoriales/msn/appendixa.html
47 * http://www.hypothetic.org/docs/msn/ietf_draft.php
49 * http://babble.wundsam.net/docs/protocol-msn-im.txt
51 * Note that it's Yet Another FTP-Like Command/Response Protocol,
52 * so it arguably should be dissected as such, although you do have
53 * to worry about the MSG command, as only the first line of it
54 * should be parsed as a command, the rest should be parsed as the
55 * message body. We therefore leave "hf_msnms_command", "tokenlen",
56 * and "next_token", even though they're unused, as reminders that
57 * this should be done.
60 static int proto_msnms = -1;
61 /* static int hf_msnms_command = -1; */
63 static gint ett_msnms = -1;
65 static dissector_handle_t data_handle;
67 #define TCP_PORT_MSNMS 1863
70 dissect_msnms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
72 proto_tree *msnms_tree;
79 /* const guchar *next_token; */
81 if (check_col(pinfo->cinfo, COL_PROTOCOL))
82 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSNMS");
85 * Find the end of the first line.
87 * Note that "tvb_find_line_end()" will return a value that is
88 * not longer than what's in the buffer, so the "tvb_get_ptr()"
89 * call won't throw an exception.
91 linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
92 line = tvb_get_ptr(tvb, offset, linelen);
95 if (check_col(pinfo->cinfo, COL_INFO)) {
97 * Put the first line from the buffer into the summary.
99 col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
100 format_text(line, linelen));
104 ti = proto_tree_add_item(tree, proto_msnms, tvb, offset, -1,
106 msnms_tree = proto_item_add_subtree(ti, ett_msnms);
109 * Show the rest of the packet as text,
112 while (tvb_offset_exists(tvb, offset)) {
114 * Find the end of the line.
116 linelen = tvb_find_line_end(tvb, offset, -1,
117 &next_offset, FALSE);
122 proto_tree_add_text(msnms_tree, tvb, offset,
123 next_offset - offset, "%s",
124 tvb_format_text(tvb, offset, next_offset - offset));
125 offset = next_offset;
131 proto_register_msnms(void)
133 static gint *ett[] = {
137 proto_msnms = proto_register_protocol("MSN Messenger Service", "MSNMS", "msnms");
138 proto_register_subtree_array(ett, array_length(ett));
142 proto_reg_handoff_msnms(void)
144 dissector_handle_t msnms_handle;
146 msnms_handle = create_dissector_handle(dissect_msnms, proto_msnms);
147 dissector_add("tcp.port", TCP_PORT_MSNMS, msnms_handle);
148 data_handle = find_dissector("data");