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.
31 #include <epan/packet.h>
32 #include <epan/strutil.h>
35 * The now-expired Internet-Draft for the MSN Messenger 1.0 protocol
36 * can, as of the time of the writing of this comment, be found at:
38 * http://praya.sourceforge.net/draft-movva-msn-messenger-protocol-00.txt
40 * http://mono.es.gnome.org/imsharp/tutoriales/msn/appendixa.html
42 * http://www.hypothetic.org/docs/msn/ietf_draft.php
44 * http://babble.wundsam.net/docs/protocol-msn-im.txt
46 * Note that it's Yet Another FTP-Like Command/Response Protocol,
47 * so it arguably should be dissected as such, although you do have
48 * to worry about the MSG command, as only the first line of it
49 * should be parsed as a command, the rest should be parsed as the
50 * message body. We therefore leave "hf_msnms_command", "tokenlen",
51 * and "next_token", even though they're unused, as reminders that
52 * this should be done.
55 static int proto_msnms
= -1;
56 /* static int hf_msnms_command = -1; */
58 static gint ett_msnms
= -1;
60 #define TCP_PORT_MSNMS 1863
63 dissect_msnms(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
65 proto_tree
*msnms_tree
;
72 /* const guchar *next_token; */
74 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MSNMS");
77 * Find the end of the first line.
79 * Note that "tvb_find_line_end()" will return a value that is
80 * not longer than what's in the buffer, so the "tvb_get_ptr()"
81 * call won't throw an exception.
83 linelen
= tvb_find_line_end(tvb
, offset
, -1, &next_offset
, FALSE
);
84 line
= tvb_get_ptr(tvb
, offset
, linelen
);
88 * Put the first line from the buffer into the summary.
90 col_add_str(pinfo
->cinfo
, COL_INFO
,
91 format_text(line
, linelen
));
94 ti
= proto_tree_add_item(tree
, proto_msnms
, tvb
, offset
, -1,
96 msnms_tree
= proto_item_add_subtree(ti
, ett_msnms
);
99 * Show the rest of the packet as text,
102 while (tvb_offset_exists(tvb
, offset
)) {
104 * Find the end of the line.
106 tvb_find_line_end(tvb
, offset
, -1,
107 &next_offset
, FALSE
);
112 proto_tree_add_text(msnms_tree
, tvb
, offset
,
113 next_offset
- offset
, "%s",
114 tvb_format_text(tvb
, offset
, next_offset
- offset
));
115 offset
= next_offset
;
121 proto_register_msnms(void)
123 static gint
*ett
[] = {
127 proto_msnms
= proto_register_protocol("MSN Messenger Service", "MSNMS", "msnms");
128 proto_register_subtree_array(ett
, array_length(ett
));
132 proto_reg_handoff_msnms(void)
134 dissector_handle_t msnms_handle
;
136 msnms_handle
= create_dissector_handle(dissect_msnms
, proto_msnms
);
137 dissector_add_uint("tcp.port", TCP_PORT_MSNMS
, msnms_handle
);
139 * For MSN Messenger Protocol over HTTP
141 dissector_add_string("media_type", "application/x-msn-messenger", msnms_handle
);