2 * Routines for yahoo messenger packet dissection
3 * Copyright 1999, Nathan Neulinger <nneul@umr.edu>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * Copied from packet-tftp.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.
34 #include <epan/packet.h>
36 static int proto_yhoo = -1;
37 static int hf_yhoo_version = -1;
38 static int hf_yhoo_len = -1;
39 static int hf_yhoo_service = -1;
40 static int hf_yhoo_connection_id = -1;
41 static int hf_yhoo_magic_id = -1;
42 static int hf_yhoo_unknown1 = -1;
43 static int hf_yhoo_msgtype = -1;
44 static int hf_yhoo_nick1 = -1;
45 static int hf_yhoo_nick2 = -1;
46 static int hf_yhoo_content = -1;
48 static gint ett_yhoo = -1;
50 #define TCP_PORT_YHOO 5050
52 /* This is from yahoolib.h from gtkyahoo */
54 /* Service constants */
55 #define YAHOO_SERVICE_LOGON 1
56 #define YAHOO_SERVICE_LOGOFF 2
57 #define YAHOO_SERVICE_ISAWAY 3
58 #define YAHOO_SERVICE_ISBACK 4
59 #define YAHOO_SERVICE_IDLE 5
60 #define YAHOO_SERVICE_MESSAGE 6
61 #define YAHOO_SERVICE_IDACT 7
62 #define YAHOO_SERVICE_IDDEACT 8
63 #define YAHOO_SERVICE_MAILSTAT 9
64 #define YAHOO_SERVICE_USERSTAT 10
65 #define YAHOO_SERVICE_NEWMAIL 11
66 #define YAHOO_SERVICE_CHATINVITE 12
67 #define YAHOO_SERVICE_CALENDAR 13
68 #define YAHOO_SERVICE_NEWPERSONALMAIL 14
69 #define YAHOO_SERVICE_NEWCONTACT 15
70 #define YAHOO_SERVICE_ADDIDENT 16
71 #define YAHOO_SERVICE_ADDIGNORE 17
72 #define YAHOO_SERVICE_PING 18
73 #define YAHOO_SERVICE_GROUPRENAME 19
74 #define YAHOO_SERVICE_SYSMESSAGE 20
75 #define YAHOO_SERVICE_PASSTHROUGH2 22
76 #define YAHOO_SERVICE_CONFINVITE 24
77 #define YAHOO_SERVICE_CONFLOGON 25
78 #define YAHOO_SERVICE_CONFDECLINE 26
79 #define YAHOO_SERVICE_CONFLOGOFF 27
80 #define YAHOO_SERVICE_CONFADDINVITE 28
81 #define YAHOO_SERVICE_CONFMSG 29
82 #define YAHOO_SERVICE_CHATLOGON 30
83 #define YAHOO_SERVICE_CHATLOGOFF 31
84 #define YAHOO_SERVICE_CHATMSG 32
85 #define YAHOO_SERVICE_FILETRANSFER 70
86 #define YAHOO_SERVICE_CHATADDINVITE 157
87 #define YAHOO_SERVICE_AVATAR 188
88 #define YAHOO_SERVICE_PICTURE_CHECKSUM 189
89 #define YAHOO_SERVICE_PICTURE 190
90 #define YAHOO_SERVICE_PICTURE_UPDATE 193
91 #define YAHOO_SERVICE_PICTURE_UPLOAD 194
92 #define YAHOO_SERVICE_YAHOO6_STATUS_UPDATE 198
93 #define YAHOO_SERVICE_AVATAR_UPDATE 199
94 #define YAHOO_SERVICE_AUDIBLE 208
95 #define YAHOO_SERVICE_WEBLOGIN 550
96 #define YAHOO_SERVICE_SMS_MSG 746
100 #define YAHOO_MSGTYPE_NONE 0
101 #define YAHOO_MSGTYPE_NORMAL 1
102 #define YAHOO_MSGTYPE_BOUNCE 2
103 #define YAHOO_MSGTYPE_STATUS 4
104 #define YAHOO_MSGTYPE_OFFLINE 1515563606 /* yuck! */
106 struct yahoo_rawpacket
108 char version[8]; /* 7 chars and trailing null */
109 unsigned char len[4]; /* length - little endian */
110 unsigned char service[4]; /* service - little endian */
111 unsigned char connection_id[4]; /* connection number - little endian */
112 unsigned char magic_id[4]; /* magic number used for http session */
113 unsigned char unknown1[4];
114 unsigned char msgtype[4];
117 char content[1]; /* was zero, had problems with aix xlc */
120 static const value_string yhoo_service_vals[] = {
121 {YAHOO_SERVICE_LOGON, "Pager Logon"},
122 {YAHOO_SERVICE_LOGOFF, "Pager Logoff"},
123 {YAHOO_SERVICE_ISAWAY, "Is Away"},
124 {YAHOO_SERVICE_ISBACK, "Is Back"},
125 {YAHOO_SERVICE_IDLE, "Idle"},
126 {YAHOO_SERVICE_MESSAGE, "Message"},
127 {YAHOO_SERVICE_IDACT, "Activate Identity"},
128 {YAHOO_SERVICE_IDDEACT, "Deactivate Identity"},
129 {YAHOO_SERVICE_MAILSTAT, "Mail Status"},
130 {YAHOO_SERVICE_USERSTAT, "User Status"},
131 {YAHOO_SERVICE_NEWMAIL, "New Mail"},
132 {YAHOO_SERVICE_CHATINVITE, "Chat Invitation"},
133 {YAHOO_SERVICE_CALENDAR, "Calendar Reminder"},
134 {YAHOO_SERVICE_NEWPERSONALMAIL, "New Personals Mail"},
135 {YAHOO_SERVICE_NEWCONTACT, "New Friend"},
136 {YAHOO_SERVICE_GROUPRENAME, "Group Renamed"},
137 {YAHOO_SERVICE_ADDIDENT, "Add Identity"},
138 {YAHOO_SERVICE_ADDIGNORE, "Add Ignore"},
139 {YAHOO_SERVICE_PING, "Ping"},
140 {YAHOO_SERVICE_SYSMESSAGE, "System Message"},
141 {YAHOO_SERVICE_CONFINVITE, "Conference Invitation"},
142 {YAHOO_SERVICE_CONFLOGON, "Conference Logon"},
143 {YAHOO_SERVICE_CONFDECLINE, "Conference Decline"},
144 {YAHOO_SERVICE_CONFLOGOFF, "Conference Logoff"},
145 {YAHOO_SERVICE_CONFMSG, "Conference Message"},
146 {YAHOO_SERVICE_CONFADDINVITE, "Conference Additional Invitation"},
147 {YAHOO_SERVICE_CHATLOGON, "Chat Logon"},
148 {YAHOO_SERVICE_CHATLOGOFF, "Chat Logoff"},
149 {YAHOO_SERVICE_CHATMSG, "Chat Message"},
150 {YAHOO_SERVICE_FILETRANSFER, "File Transfer"},
151 {YAHOO_SERVICE_PASSTHROUGH2, "Passthrough 2"},
152 {YAHOO_SERVICE_CHATADDINVITE, "Chat add Invite"},
153 {YAHOO_SERVICE_AVATAR, "Avatar"},
154 {YAHOO_SERVICE_PICTURE_CHECKSUM, "Picture Checksum"},
155 {YAHOO_SERVICE_PICTURE, "Picture"},
156 {YAHOO_SERVICE_PICTURE_UPDATE, "Picture Update"},
157 {YAHOO_SERVICE_PICTURE_UPLOAD, "Picture Upload"},
158 {YAHOO_SERVICE_YAHOO6_STATUS_UPDATE, "Status update"},
159 {YAHOO_SERVICE_AUDIBLE, "Audible"},
160 {YAHOO_SERVICE_WEBLOGIN, "Weblogin"},
161 {YAHOO_SERVICE_SMS_MSG, "SMS Message"},
165 static const value_string yhoo_msgtype_vals[] = {
166 {YAHOO_MSGTYPE_NONE, "None"},
167 {YAHOO_MSGTYPE_NORMAL, "Normal"},
168 {YAHOO_MSGTYPE_BOUNCE, "Bounce"},
169 {YAHOO_MSGTYPE_STATUS, "Status Update"},
170 {YAHOO_MSGTYPE_OFFLINE, "Request Offline"},
175 dissect_yhoo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
177 proto_tree *yhoo_tree, *ti;
180 if (pinfo->srcport != TCP_PORT_YHOO && pinfo->destport != TCP_PORT_YHOO) {
181 /* Not the Yahoo port - not a Yahoo Messenger packet. */
185 /* get at least a full packet structure */
186 if ( tvb_length(tvb) < sizeof(struct yahoo_rawpacket) ) {
187 /* Not enough data captured; maybe it is a Yahoo
188 Messenger packet, but it contains too little data to
193 if (tvb_memeql(tvb, offset, "YPNS", 4) != 0 &&
194 tvb_memeql(tvb, offset, "YHOO", 4) != 0) {
195 /* Not a Yahoo Messenger packet. */
199 col_set_str(pinfo->cinfo, COL_PROTOCOL, "YHOO");
202 if (check_col(pinfo->cinfo, COL_INFO)) {
203 col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",
204 ( tvb_memeql(tvb, offset + 0, "YPNS", 4) == 0 ) ? "Request" : "Response",
205 val_to_str(tvb_get_letohl(tvb, offset + 12),
206 yhoo_service_vals, "Unknown Service: %u"));
210 ti = proto_tree_add_item(tree, proto_yhoo, tvb, offset, -1,
212 yhoo_tree = proto_item_add_subtree(ti, ett_yhoo);
214 proto_tree_add_item(yhoo_tree, hf_yhoo_version, tvb,
215 offset, 8, ENC_ASCII|ENC_NA);
218 proto_tree_add_item(yhoo_tree, hf_yhoo_len, tvb,
219 offset, 4, ENC_LITTLE_ENDIAN);
222 proto_tree_add_item(yhoo_tree, hf_yhoo_service, tvb,
223 offset, 4, ENC_LITTLE_ENDIAN);
226 proto_tree_add_item(yhoo_tree, hf_yhoo_connection_id, tvb,
227 offset, 4, ENC_LITTLE_ENDIAN);
230 proto_tree_add_item(yhoo_tree, hf_yhoo_magic_id, tvb,
231 offset, 4, ENC_LITTLE_ENDIAN);
234 proto_tree_add_item(yhoo_tree, hf_yhoo_unknown1, tvb,
235 offset, 4, ENC_LITTLE_ENDIAN);
238 proto_tree_add_item(yhoo_tree, hf_yhoo_msgtype, tvb,
239 offset, 4, ENC_LITTLE_ENDIAN);
242 proto_tree_add_item(yhoo_tree, hf_yhoo_nick1, tvb,
243 offset, 36, ENC_ASCII|ENC_NA);
246 proto_tree_add_item(yhoo_tree, hf_yhoo_nick2, tvb,
247 offset, 36, ENC_ASCII|ENC_NA);
250 proto_tree_add_item(yhoo_tree, hf_yhoo_content, tvb, -1,
251 offset, ENC_ASCII|ENC_NA);
258 proto_register_yhoo(void)
260 static hf_register_info hf[] = {
261 { &hf_yhoo_service, {
262 "Service Type", "yhoo.service", FT_UINT32, BASE_DEC,
263 VALS(yhoo_service_vals), 0, NULL, HFILL }},
264 { &hf_yhoo_msgtype, {
265 "Message Type", "yhoo.msgtype", FT_UINT32, BASE_DEC,
266 VALS(yhoo_msgtype_vals), 0, "Message Type Flags", HFILL }},
267 { &hf_yhoo_connection_id, {
268 "Connection ID", "yhoo.connection_id", FT_UINT32, BASE_HEX,
269 NULL, 0, NULL, HFILL }},
270 { &hf_yhoo_magic_id, {
271 "Magic ID", "yhoo.magic_id", FT_UINT32, BASE_HEX,
272 NULL, 0, NULL, HFILL }},
273 { &hf_yhoo_unknown1, {
274 "Unknown 1", "yhoo.unknown1", FT_UINT32, BASE_HEX,
275 NULL, 0, NULL, HFILL }},
277 "Packet Length", "yhoo.len", FT_UINT32, BASE_DEC,
278 NULL, 0, NULL, HFILL }},
280 "Real Nick (nick1)", "yhoo.nick1", FT_STRING, BASE_NONE,
281 NULL, 0, NULL, HFILL }},
283 "Active Nick (nick2)", "yhoo.nick2", FT_STRING, BASE_NONE,
284 NULL, 0, NULL, HFILL }},
285 { &hf_yhoo_content, {
286 "Content", "yhoo.content", FT_STRING, BASE_NONE,
287 NULL, 0, "Data portion of the packet", HFILL }},
288 { &hf_yhoo_version, {
289 "Version", "yhoo.version", FT_STRING, BASE_NONE,
290 NULL, 0, "Packet version identifier", HFILL }},
292 static gint *ett[] = {
296 proto_yhoo = proto_register_protocol("Yahoo Messenger Protocol",
299 proto_register_field_array(proto_yhoo, hf, array_length(hf));
301 proto_register_subtree_array(ett, array_length(ett));
305 proto_reg_handoff_yhoo(void)
308 * DO NOT register for port 5050, as that's used by the
309 * old and new Yahoo messenger protocols.
311 * Just register as a heuristic TCP dissector, and reject stuff
312 * not to or from that port.
314 heur_dissector_add("tcp", dissect_yhoo, proto_yhoo);