2 * Routines for AIM Instant Messenger (OSCAR) dissection, SNAC Chat
3 * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
4 * Copyright 2000, Ralf Hoelzer <ralf@well.com>
6 * $Id: packet-aim-chat.c,v 1.3 2004/04/20 04:48:31 guy Exp $
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include <epan/packet.h>
39 #include <epan/strutil.h>
41 #include "packet-tcp.h"
42 #include "packet-aim.h"
46 #define FAMILY_CHAT 0x000E
49 #define FAMILY_CHAT_ERROR 0x0001
50 #define FAMILY_CHAT_ROOMINFOUPDATE 0x0002
51 #define FAMILY_CHAT_USERJOIN 0x0003
52 #define FAMILY_CHAT_USERLEAVE 0x0004
53 #define FAMILY_CHAT_OUTGOINGMSG 0x0005
54 #define FAMILY_CHAT_INCOMINGMSG 0x0006
55 #define FAMILY_CHAT_EVIL_REQ 0x0007
56 #define FAMILY_CHAT_EVIL_REPLY 0x0008
57 #define FAMILY_CHAT_DEFAULT 0xffff
59 static const value_string aim_fnac_family_chat[] = {
60 { FAMILY_CHAT_ERROR, "Error" },
61 { FAMILY_CHAT_ROOMINFOUPDATE, "Room Info Update" },
62 { FAMILY_CHAT_USERJOIN, "User Join" },
63 { FAMILY_CHAT_USERLEAVE, "User Leave" },
64 { FAMILY_CHAT_OUTGOINGMSG, "Outgoing Message" },
65 { FAMILY_CHAT_INCOMINGMSG, "Incoming Message" },
66 { FAMILY_CHAT_EVIL_REQ, "Evil Request" },
67 { FAMILY_CHAT_EVIL_REPLY, "Evil Reply" },
68 { FAMILY_CHAT_DEFAULT, "Chat Default" },
72 /* Initialize the protocol and registered fields */
73 static int proto_aim_chat = -1;
75 /* Initialize the subtree pointers */
76 static gint ett_aim_chat = -1;
78 static int dissect_aim_snac_chat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
80 guint8 buddyname_length = 0;
82 struct aiminfo *aiminfo = pinfo->private_data;
83 char buddyname[MAX_BUDDYNAME_LENGTH + 1];
86 proto_tree *chat_tree = NULL;
89 ti = proto_tree_add_text(tree, tvb, 0, -1, "Chat Service");
90 chat_tree = proto_item_add_subtree(ti, ett_aim_chat);
93 switch(aiminfo->subtype)
95 case FAMILY_CHAT_ERROR:
96 return dissect_aim_snac_error(tvb, pinfo, offset, chat_tree);
97 case FAMILY_CHAT_ROOMINFOUPDATE:
100 case FAMILY_CHAT_USERJOIN:
101 while(tvb_length_remaining(tvb, offset) > 0) {
102 offset = dissect_aim_buddyname(tvb, pinfo, offset, chat_tree);
106 case FAMILY_CHAT_USERLEAVE:
107 case FAMILY_CHAT_EVIL_REQ:
108 case FAMILY_CHAT_EVIL_REPLY:
111 case FAMILY_CHAT_OUTGOINGMSG:
112 /* channel message from client */
113 aim_get_message( msg, tvb, 40 + buddyname_length, tvb_length(tvb)
114 - 40 - buddyname_length );
116 if (check_col(pinfo->cinfo, COL_INFO))
117 col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", msg);
118 return tvb_length(tvb);
120 case FAMILY_CHAT_INCOMINGMSG:
121 /* channel message to client */
122 buddyname_length = aim_get_buddyname( buddyname, tvb, 30, 31 );
123 aim_get_message( msg, tvb, 36 + buddyname_length, tvb_length(tvb)
124 - 36 - buddyname_length );
126 if (check_col(pinfo->cinfo, COL_INFO)) {
127 col_append_fstr(pinfo->cinfo, COL_INFO, "from: %s", buddyname);
128 col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", msg);
132 proto_tree_add_text(chat_tree, tvb, 31, buddyname_length,
133 "Screen Name: %s", buddyname);
135 return tvb_length(tvb);
140 /* Register the protocol with Ethereal */
142 proto_register_aim_chat(void)
145 /* Setup list of header fields */
147 static hf_register_info hf[] = {
150 /* Setup protocol subtree array */
151 static gint *ett[] = {
155 /* Register the protocol name and description */
156 proto_aim_chat = proto_register_protocol("AIM Chat Service", "AIM Chat", "aim_chat");
158 /* Required function calls to register the header fields and subtrees used */
160 proto_register_field_array(proto_aim_chat, hf, array_length(hf));*/
161 proto_register_subtree_array(ett, array_length(ett));
165 proto_reg_handoff_aim_chat(void)
167 dissector_handle_t aim_handle;
168 aim_handle = new_create_dissector_handle(dissect_aim_snac_chat, proto_aim_chat);
169 dissector_add("aim.family", FAMILY_CHAT, aim_handle);
170 aim_init_family(FAMILY_CHAT, "Chat", aim_fnac_family_chat);