1 /* packet-msn-messenger.c
2 * Routines for MSN Messenger Service packet dissection
3 * Copyright 2003, Chris Waters <chris@waters.co.nz>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #include <epan/packet.h>
34 #include <epan/strutil.h>
37 * The now-expired Internet-Draft for the MSN Messenger 1.0 protocol
38 * can, as of the time of the writing of this comment, be found at:
40 * http://praya.sourceforge.net/draft-movva-msn-messenger-protocol-00.txt
42 * http://mono.es.gnome.org/imsharp/tutoriales/msn/appendixa.html
44 * http://www.hypothetic.org/docs/msn/ietf_draft.php
46 * http://babble.wundsam.net/docs/protocol-msn-im.txt
48 * Note that it's Yet Another FTP-Like Command/Response Protocol,
49 * so it arguably should be dissected as such, although you do have
50 * to worry about the MSG command, as only the first line of it
51 * should be parsed as a command, the rest should be parsed as the
52 * message body. We therefore leave "hf_msnms_command", "tokenlen",
53 * and "next_token", even though they're unused, as reminders that
54 * this should be done.
57 static int proto_msnms = -1;
58 /* static int hf_msnms_command = -1; */
60 static gint ett_msnms = -1;
62 #define TCP_PORT_MSNMS 1863
65 dissect_msnms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
67 proto_tree *msnms_tree;
74 /* const guchar *next_token; */
76 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSNMS");
79 * Find the end of the first line.
81 * Note that "tvb_find_line_end()" will return a value that is
82 * not longer than what's in the buffer, so the "tvb_get_ptr()"
83 * call won't throw an exception.
85 linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
86 line = tvb_get_ptr(tvb, offset, linelen);
89 if (check_col(pinfo->cinfo, COL_INFO)) {
91 * Put the first line from the buffer into the summary.
93 col_add_str(pinfo->cinfo, COL_INFO,
94 format_text(line, linelen));
98 ti = proto_tree_add_item(tree, proto_msnms, tvb, offset, -1,
100 msnms_tree = proto_item_add_subtree(ti, ett_msnms);
103 * Show the rest of the packet as text,
106 while (tvb_offset_exists(tvb, offset)) {
108 * Find the end of the line.
110 linelen = tvb_find_line_end(tvb, offset, -1,
111 &next_offset, FALSE);
116 proto_tree_add_text(msnms_tree, tvb, offset,
117 next_offset - offset, "%s",
118 tvb_format_text(tvb, offset, next_offset - offset));
119 offset = next_offset;
125 proto_register_msnms(void)
127 static gint *ett[] = {
131 proto_msnms = proto_register_protocol("MSN Messenger Service", "MSNMS", "msnms");
132 proto_register_subtree_array(ett, array_length(ett));
136 proto_reg_handoff_msnms(void)
138 dissector_handle_t msnms_handle;
140 msnms_handle = create_dissector_handle(dissect_msnms, proto_msnms);
141 dissector_add_uint("tcp.port", TCP_PORT_MSNMS, msnms_handle);
143 * For MSN Messenger Protocol over HTTP
145 dissector_add_string("media_type", "application/x-msn-messenger", msnms_handle);