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>
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 #define SSI_RIGHTSINFO_TLV_MAX_ITEMS 0x0004
114 static const aim_tlv ssi_rightsinfo_tlvs[] = {
115 { SSI_RIGHTSINFO_TLV_MAX_ITEMS, "Maximums For Items", dissect_aim_tlv_value_bytes },
119 static int dissect_aim_snac_ssi_list(tvbuff_t *tvb, packet_info *pinfo _U_,
120 int offset, proto_tree *tree, guint16 subtype _U_);
122 /* Initialize the protocol and registered fields */
123 static int proto_aim_ssi = -1;
124 static int hf_aim_fnac_subtype_ssi_version = -1;
125 static int hf_aim_fnac_subtype_ssi_numitems = -1;
126 static int hf_aim_fnac_subtype_ssi_last_change_time = -1;
127 static int hf_aim_fnac_subtype_ssi_buddyname_len = -1;
128 static int hf_aim_fnac_subtype_ssi_buddyname = -1;
129 static int hf_aim_fnac_subtype_ssi_gid = -1;
130 static int hf_aim_fnac_subtype_ssi_bid = -1;
131 static int hf_aim_fnac_subtype_ssi_type = -1;
132 static int hf_aim_fnac_subtype_ssi_tlvlen = -1;
133 static int hf_aim_fnac_subtype_ssi_data = -1;
135 /* Initialize the subtree pointers */
136 static gint ett_aim_ssi = -1;
137 static gint ett_ssi = -1;
139 static int dissect_ssi_item(tvbuff_t *tvb, packet_info *pinfo _U_,
140 int offset, proto_tree *ssi_entry,
143 guint16 buddyname_length = 0;
146 /* Buddy Name Length */
147 buddyname_length = tvb_get_ntohs(tvb, offset);
148 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_buddyname_len,
149 tvb, offset, 2, FALSE);
153 if (buddyname_length > 0) {
154 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_buddyname, tvb,
155 offset, buddyname_length, FALSE);
156 offset += buddyname_length;
160 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_gid, tvb, offset,
165 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_bid, tvb, offset,
170 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_type, tvb, offset,
174 /* Size of the following TLV in bytes (as opposed to the number of
175 TLV objects in the chain) */
176 tlv_len = tvb_get_ntohs(tvb, offset);
177 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_tlvlen, tvb,
182 /* For now, we just dump the TLV contents as-is, since there is not a
183 TLV dissection utility that works based on total chain length */
184 while(endoffset < offset+tlv_len) {
185 endoffset = dissect_aim_tlv(tvb, pinfo, endoffset, ssi_entry, client_tlvs);
190 static int dissect_aim_snac_ssi(tvbuff_t *tvb, packet_info *pinfo _U_,
193 struct aiminfo *aiminfo = pinfo->private_data;
195 proto_item *ti = NULL;
196 proto_tree *ssi_tree = NULL;
199 ti = proto_tree_add_text(tree, tvb, 0, -1,"AIM Server Side Information Service");
200 ssi_tree = proto_item_add_subtree(ti, ett_ssi);
203 switch(aiminfo->subtype)
205 case FAMILY_SSI_ERROR:
206 return dissect_aim_snac_error(tvb, pinfo, offset, ssi_tree);
207 case FAMILY_SSI_LIST:
208 return dissect_aim_snac_ssi_list(tvb, pinfo, offset, ssi_tree, aiminfo->subtype);
209 case FAMILY_SSI_RIGHTSINFO:
210 while(tvb_length_remaining(tvb, offset) > 0) {
211 offset = dissect_aim_tlv(tvb, pinfo, offset, ssi_tree, ssi_rightsinfo_tlvs);
214 case FAMILY_SSI_REQRIGHTS:
215 case FAMILY_SSI_ACTIVATE:
216 case FAMILY_SSI_EDITSTART:
217 case FAMILY_SSI_EDITSTOP:
218 case FAMILY_SSI_REQLIST_FIRSTTIME:
224 return dissect_ssi_item(tvb, pinfo, offset, ssi_tree, aiminfo->subtype);
225 case FAMILY_SSI_WAS_ADDED:
226 return dissect_aim_buddyname(tvb, pinfo, offset, ssi_tree);
227 case FAMILY_SSI_REQLIST:
228 case FAMILY_SSI_SRVACK:
229 case FAMILY_SSI_NOLIST:
230 case FAMILY_SSI_GRANT_FUTURE_AUTH:
231 case FAMILY_SSI_FUTUR_AUTH_GRANTED:
232 case FAMILY_SSI_SEND_AUTH_REQ:
233 case FAMILY_SSI_AUTH_REQ:
234 case FAMILY_SSI_SEND_AUTH_REPLY:
235 case FAMILY_SSI_AUTH_REPLY:
245 static int dissect_aim_snac_ssi_list(tvbuff_t *tvb, packet_info *pinfo _U_,
246 int offset, proto_tree *tree,
250 proto_tree *ssi_entry = NULL;
251 guint16 num_items, i;
254 proto_tree_add_item(tree, hf_aim_fnac_subtype_ssi_version, tvb, offset, 1,
258 /* Number of items */
259 proto_tree_add_item(tree, hf_aim_fnac_subtype_ssi_numitems, tvb, offset, 2,
261 num_items = tvb_get_ntohs(tvb, offset);
264 for(i = 0; i < num_items; i++) {
265 ti = proto_tree_add_text(tree, tvb, offset, tvb_get_ntohs(tvb, offset+10)+10, "SSI Entry");
266 ssi_entry = proto_item_add_subtree(ti, ett_aim_ssi);
267 offset = dissect_ssi_item(tvb, pinfo, offset, ssi_entry, subtype);
269 proto_tree_add_item(tree, hf_aim_fnac_subtype_ssi_last_change_time, tvb, offset, 4, FALSE);
273 /* Register the protocol with Ethereal */
275 proto_register_aim_ssi(void)
278 /* Setup list of header fields */
279 static hf_register_info hf[] = {
280 { &hf_aim_fnac_subtype_ssi_version,
281 { "SSI Version", "aim.fnac.ssi.version", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }
283 { &hf_aim_fnac_subtype_ssi_numitems,
284 { "SSI Object count", "aim.fnac.ssi.numitems", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
286 { &hf_aim_fnac_subtype_ssi_last_change_time,
287 { "SSI Last Change Time", "aim.fnac.ssi.last_change_time", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }
289 { &hf_aim_fnac_subtype_ssi_buddyname_len,
290 { "SSI Buddy Name length", "aim.fnac.ssi.buddyname_len", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
292 { &hf_aim_fnac_subtype_ssi_buddyname,
293 { "Buddy Name", "aim.fnac.ssi.buddyname", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }
295 { &hf_aim_fnac_subtype_ssi_gid,
296 { "SSI Buddy Group ID", "aim.fnac.ssi.gid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
298 { &hf_aim_fnac_subtype_ssi_bid,
299 { "SSI Buddy ID", "aim.fnac.ssi.bid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
301 { &hf_aim_fnac_subtype_ssi_type,
302 { "SSI Buddy type", "aim.fnac.ssi.type", FT_UINT16, BASE_HEX, VALS(aim_fnac_family_ssi_types), 0x0, "", HFILL }
304 { &hf_aim_fnac_subtype_ssi_tlvlen,
305 { "SSI TLV Len", "aim.fnac.ssi.tlvlen", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
307 { &hf_aim_fnac_subtype_ssi_data,
308 { "SSI Buddy Data", "aim.fnac.ssi.data", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
312 /* Setup protocol subtree array */
313 static gint *ett[] = {
318 /* Register the protocol name and description */
319 proto_aim_ssi = proto_register_protocol("AIM Server Side Info", "AIM SSI", "aim_ssi");
321 /* Required function calls to register the header fields and subtrees used */
322 proto_register_field_array(proto_aim_ssi, hf, array_length(hf));
323 proto_register_subtree_array(ett, array_length(ett));
327 proto_reg_handoff_aim_ssi(void)
329 dissector_handle_t aim_handle;
331 aim_handle = new_create_dissector_handle(dissect_aim_snac_ssi, proto_aim_ssi);
332 dissector_add("aim.family", FAMILY_SSI, aim_handle);
333 aim_init_family(FAMILY_SSI, "SSI", aim_fnac_family_ssi);