2 * Routines for AIM Instant Messenger (OSCAR) dissection, SNAC SSI
3 * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
4 * Copyright 2000, Ralf Hoelzer <ralf@well.com>
6 * $Id: packet-aim-ssi.c,v 1.3 2004/04/26 18:21:10 obiot 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-aim.h"
43 #define FAMILY_SSI 0x0013
45 /* Family Server-Stored Buddy Lists */
46 #define FAMILY_SSI_ERROR 0x0001
47 #define FAMILY_SSI_REQRIGHTS 0x0002
48 #define FAMILY_SSI_RIGHTSINFO 0x0003
49 #define FAMILY_SSI_REQLIST_FIRSTTIME 0x0004
50 #define FAMILY_SSI_REQLIST 0x0005
51 #define FAMILY_SSI_LIST 0x0006
52 #define FAMILY_SSI_ACTIVATE 0x0007
53 #define FAMILY_SSI_ADD 0x0008
54 #define FAMILY_SSI_MOD 0x0009
55 #define FAMILY_SSI_DEL 0x000a
56 #define FAMILY_SSI_SRVACK 0x000e
57 #define FAMILY_SSI_NOLIST 0x000f
58 #define FAMILY_SSI_EDITSTART 0x0011
59 #define FAMILY_SSI_EDITSTOP 0x0012
60 #define FAMILY_SSI_GRANT_FUTURE_AUTH 0x0014
61 #define FAMILY_SSI_FUTUR_AUTH_GRANTED 0x0015
62 #define FAMILY_SSI_SEND_AUTH_REQ 0x0018
63 #define FAMILY_SSI_AUTH_REQ 0x0019
64 #define FAMILY_SSI_SEND_AUTH_REPLY 0x001a
65 #define FAMILY_SSI_AUTH_REPLY 0x001b
66 #define FAMILY_SSI_WAS_ADDED 0x001c
68 static const value_string aim_fnac_family_ssi[] = {
69 { FAMILY_SSI_ERROR, "Error" },
70 { FAMILY_SSI_REQRIGHTS, "Request Rights" },
71 { FAMILY_SSI_RIGHTSINFO, "Rights Info" },
72 { FAMILY_SSI_REQLIST_FIRSTTIME, "Request List (first time)" },
73 { FAMILY_SSI_REQLIST, "Request List" },
74 { FAMILY_SSI_LIST, "List" },
75 { FAMILY_SSI_ACTIVATE, "Activate" },
76 { FAMILY_SSI_ADD, "Add Buddy" },
77 { FAMILY_SSI_MOD, "Modify Buddy" },
78 { FAMILY_SSI_DEL, "Delete Buddy" },
79 { FAMILY_SSI_SRVACK, "Server Ack" },
80 { FAMILY_SSI_NOLIST, "No List" },
81 { FAMILY_SSI_EDITSTART, "Edit Start" },
82 { FAMILY_SSI_EDITSTOP, "Edit Stop" },
83 { FAMILY_SSI_GRANT_FUTURE_AUTH, "Grant Future Authorization to Client" },
84 { FAMILY_SSI_FUTUR_AUTH_GRANTED, "Future Authorization Granted" },
85 { FAMILY_SSI_SEND_AUTH_REQ, "Send Authentication Request" },
86 { FAMILY_SSI_AUTH_REQ, "Authentication Request" },
87 { FAMILY_SSI_SEND_AUTH_REPLY, "Send Authentication Reply" },
88 { FAMILY_SSI_AUTH_REPLY, "Authentication Reply" },
89 { FAMILY_SSI_WAS_ADDED, "Remote User Added Client To List" },
93 #define FAMILY_SSI_TYPE_BUDDY 0x0000
94 #define FAMILY_SSI_TYPE_GROUP 0x0001
95 #define FAMILY_SSI_TYPE_PERMIT 0x0002
96 #define FAMILY_SSI_TYPE_DENY 0x0003
97 #define FAMILY_SSI_TYPE_PDINFO 0x0004
98 #define FAMILY_SSI_TYPE_PRESENCEPREFS 0x0005
99 #define FAMILY_SSI_TYPE_ICONINFO 0x0014
101 static const value_string aim_fnac_family_ssi_types[] = {
102 { FAMILY_SSI_TYPE_BUDDY, "Buddy" },
103 { FAMILY_SSI_TYPE_GROUP, "Group" },
104 { FAMILY_SSI_TYPE_PERMIT, "Permit" },
105 { FAMILY_SSI_TYPE_DENY, "Deny" },
106 { FAMILY_SSI_TYPE_PDINFO, "PDINFO" },
107 { FAMILY_SSI_TYPE_PRESENCEPREFS, "Presence Preferences" },
108 { FAMILY_SSI_TYPE_ICONINFO, "Icon Info" },
112 static const aim_tlv ssi_rights_tlvs[] = {
116 static int dissect_aim_snac_ssi_list(tvbuff_t *tvb, packet_info *pinfo _U_,
117 int offset, proto_tree *tree, guint16 subtype _U_);
119 /* Initialize the protocol and registered fields */
120 static int proto_aim_ssi = -1;
121 static int hf_aim_fnac_subtype_ssi_version = -1;
122 static int hf_aim_fnac_subtype_ssi_numitems = -1;
123 static int hf_aim_fnac_subtype_ssi_last_change_time = -1;
124 static int hf_aim_fnac_subtype_ssi_buddyname_len = -1;
125 static int hf_aim_fnac_subtype_ssi_buddyname = -1;
126 static int hf_aim_fnac_subtype_ssi_gid = -1;
127 static int hf_aim_fnac_subtype_ssi_bid = -1;
128 static int hf_aim_fnac_subtype_ssi_type = -1;
129 static int hf_aim_fnac_subtype_ssi_tlvlen = -1;
130 static int hf_aim_fnac_subtype_ssi_data = -1;
132 /* Initialize the subtree pointers */
133 static gint ett_aim_ssi = -1;
134 static gint ett_ssi = -1;
136 static int dissect_ssi_item(tvbuff_t *tvb, packet_info *pinfo _U_,
137 int offset, proto_tree *ssi_entry,
140 guint16 buddyname_length = 0;
143 /* Buddy Name Length */
144 buddyname_length = tvb_get_ntohs(tvb, offset);
145 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_buddyname_len,
146 tvb, offset, 2, FALSE);
150 if (buddyname_length > 0) {
151 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_buddyname, tvb,
152 offset, buddyname_length, FALSE);
153 offset += buddyname_length;
157 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_gid, tvb, offset,
162 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_bid, tvb, offset,
167 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_type, tvb, offset,
171 /* Size of the following TLV in bytes (as opposed to the number of
172 TLV objects in the chain) */
173 tlv_len = tvb_get_ntohs(tvb, offset);
174 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_tlvlen, tvb,
179 /* For now, we just dump the TLV contents as-is, since there is not a
180 TLV dissection utility that works based on total chain length */
181 while(endoffset < offset+tlv_len) {
182 endoffset = dissect_aim_tlv(tvb, pinfo, endoffset, ssi_entry, client_tlvs);
187 static int dissect_aim_snac_ssi(tvbuff_t *tvb, packet_info *pinfo _U_,
190 struct aiminfo *aiminfo = pinfo->private_data;
192 proto_item *ti = NULL;
193 proto_tree *ssi_tree = NULL;
196 ti = proto_tree_add_text(tree, tvb, 0, -1,"AIM Server Side Information Service");
197 ssi_tree = proto_item_add_subtree(ti, ett_ssi);
200 switch(aiminfo->subtype)
202 case FAMILY_SSI_ERROR:
203 return dissect_aim_snac_error(tvb, pinfo, offset, ssi_tree);
204 case FAMILY_SSI_LIST:
205 return dissect_aim_snac_ssi_list(tvb, pinfo, offset, ssi_tree, aiminfo->subtype);
206 case FAMILY_SSI_RIGHTSINFO:
207 while(tvb_length_remaining(tvb, offset) > 0) {
208 offset = dissect_aim_tlv(tvb, pinfo, offset, ssi_tree, ssi_rights_tlvs);
211 case FAMILY_SSI_REQRIGHTS:
212 case FAMILY_SSI_ACTIVATE:
213 case FAMILY_SSI_EDITSTART:
214 case FAMILY_SSI_EDITSTOP:
215 case FAMILY_SSI_REQLIST_FIRSTTIME:
221 return dissect_ssi_item(tvb, pinfo, offset, ssi_tree, aiminfo->subtype);
222 case FAMILY_SSI_WAS_ADDED:
223 return dissect_aim_buddyname(tvb, pinfo, offset, ssi_tree);
224 case FAMILY_SSI_REQLIST:
225 case FAMILY_SSI_SRVACK:
226 case FAMILY_SSI_NOLIST:
227 case FAMILY_SSI_GRANT_FUTURE_AUTH:
228 case FAMILY_SSI_FUTUR_AUTH_GRANTED:
229 case FAMILY_SSI_SEND_AUTH_REQ:
230 case FAMILY_SSI_AUTH_REQ:
231 case FAMILY_SSI_SEND_AUTH_REPLY:
232 case FAMILY_SSI_AUTH_REPLY:
242 static int dissect_aim_snac_ssi_list(tvbuff_t *tvb, packet_info *pinfo _U_,
243 int offset, proto_tree *tree,
247 proto_tree *ssi_entry = NULL;
248 guint16 num_items, i;
251 proto_tree_add_item(tree, hf_aim_fnac_subtype_ssi_version, tvb, offset, 1,
255 /* Number of items */
256 proto_tree_add_item(tree, hf_aim_fnac_subtype_ssi_numitems, tvb, offset, 2,
258 num_items = tvb_get_ntohs(tvb, offset);
261 for(i = 0; i < num_items; i++) {
262 ti = proto_tree_add_text(tree, tvb, offset, tvb_get_ntohs(tvb, offset+10)+10, "SSI Entry");
263 ssi_entry = proto_item_add_subtree(ti, ett_aim_ssi);
264 offset = dissect_ssi_item(tvb, pinfo, offset, ssi_entry, subtype);
266 proto_tree_add_item(tree, hf_aim_fnac_subtype_ssi_last_change_time, tvb, offset, 4, FALSE);
270 /* Register the protocol with Ethereal */
272 proto_register_aim_ssi(void)
275 /* Setup list of header fields */
276 static hf_register_info hf[] = {
277 { &hf_aim_fnac_subtype_ssi_version,
278 { "SSI Version", "aim.fnac.ssi.version", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }
280 { &hf_aim_fnac_subtype_ssi_numitems,
281 { "SSI Object count", "aim.fnac.ssi.numitems", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
283 { &hf_aim_fnac_subtype_ssi_last_change_time,
284 { "SSI Last Change Time", "aim.fnac.ssi.last_change_time", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }
286 { &hf_aim_fnac_subtype_ssi_buddyname_len,
287 { "SSI Buddy Name length", "aim.fnac.ssi.buddyname_len", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
289 { &hf_aim_fnac_subtype_ssi_buddyname,
290 { "Buddy Name", "aim.fnac.ssi.buddyname", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }
292 { &hf_aim_fnac_subtype_ssi_gid,
293 { "SSI Buddy Group ID", "aim.fnac.ssi.gid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
295 { &hf_aim_fnac_subtype_ssi_bid,
296 { "SSI Buddy ID", "aim.fnac.ssi.bid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
298 { &hf_aim_fnac_subtype_ssi_type,
299 { "SSI Buddy type", "aim.fnac.ssi.type", FT_UINT16, BASE_HEX, VALS(aim_fnac_family_ssi_types), 0x0, "", HFILL }
301 { &hf_aim_fnac_subtype_ssi_tlvlen,
302 { "SSI TLV Len", "aim.fnac.ssi.tlvlen", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
304 { &hf_aim_fnac_subtype_ssi_data,
305 { "SSI Buddy Data", "aim.fnac.ssi.data", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
309 /* Setup protocol subtree array */
310 static gint *ett[] = {
315 /* Register the protocol name and description */
316 proto_aim_ssi = proto_register_protocol("AIM Server Side Info", "AIM SSI", "aim_ssi");
318 /* Required function calls to register the header fields and subtrees used */
319 proto_register_field_array(proto_aim_ssi, hf, array_length(hf));
320 proto_register_subtree_array(ett, array_length(ett));
324 proto_reg_handoff_aim_ssi(void)
326 dissector_handle_t aim_handle;
328 aim_handle = new_create_dissector_handle(dissect_aim_snac_ssi, proto_aim_ssi);
329 dissector_add("aim.family", FAMILY_SSI, aim_handle);
330 aim_init_family(FAMILY_SSI, "SSI", aim_fnac_family_ssi);