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 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
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
46 #define FAMILY_SSI_TYPE_BUDDY 0x0000
47 #define FAMILY_SSI_TYPE_GROUP 0x0001
48 #define FAMILY_SSI_TYPE_PERMIT 0x0002
49 #define FAMILY_SSI_TYPE_DENY 0x0003
50 #define FAMILY_SSI_TYPE_PDINFO 0x0004
51 #define FAMILY_SSI_TYPE_PRESENCEPREFS 0x0005
52 #define FAMILY_SSI_TYPE_ICONINFO 0x0014
54 static const value_string aim_fnac_family_ssi_types[] = {
55 { FAMILY_SSI_TYPE_BUDDY, "Buddy" },
56 { FAMILY_SSI_TYPE_GROUP, "Group" },
57 { FAMILY_SSI_TYPE_PERMIT, "Permit" },
58 { FAMILY_SSI_TYPE_DENY, "Deny" },
59 { FAMILY_SSI_TYPE_PDINFO, "PDINFO" },
60 { FAMILY_SSI_TYPE_PRESENCEPREFS, "Presence Preferences" },
61 { FAMILY_SSI_TYPE_ICONINFO, "Icon Info" },
65 #define SSI_RIGHTSINFO_TLV_MAX_ITEMS 0x0004
67 static const aim_tlv ssi_rightsinfo_tlvs[] = {
68 { SSI_RIGHTSINFO_TLV_MAX_ITEMS, "Maximums For Items", dissect_aim_tlv_value_bytes },
72 /* Initialize the protocol and registered fields */
73 static int proto_aim_ssi = -1;
74 static int hf_aim_fnac_subtype_ssi_version = -1;
75 static int hf_aim_fnac_subtype_ssi_numitems = -1;
76 static int hf_aim_fnac_subtype_ssi_last_change_time = -1;
77 static int hf_aim_fnac_subtype_ssi_buddyname_len = -1;
78 static int hf_aim_fnac_subtype_ssi_buddyname = -1;
79 static int hf_aim_fnac_subtype_ssi_gid = -1;
80 static int hf_aim_fnac_subtype_ssi_bid = -1;
81 static int hf_aim_fnac_subtype_ssi_type = -1;
82 static int hf_aim_fnac_subtype_ssi_tlvlen = -1;
83 static int hf_aim_fnac_subtype_ssi_data = -1;
85 /* Initialize the subtree pointers */
86 static gint ett_aim_ssi = -1;
87 static gint ett_ssi = -1;
89 static int dissect_ssi_item(tvbuff_t *tvb, packet_info *pinfo _U_,
90 int offset, proto_tree *ssi_entry)
92 guint16 buddyname_length = 0;
96 /* Buddy Name Length */
97 buddyname_length = tvb_get_ntohs(tvb, offset);
98 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_buddyname_len,
99 tvb, offset, 2, FALSE);
103 if (buddyname_length > 0) {
104 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_buddyname, tvb,
105 offset, buddyname_length, FALSE);
106 offset += buddyname_length;
110 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_gid, tvb, offset,
115 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_bid, tvb, offset,
120 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_type, tvb, offset,
124 /* Size of the following TLV in bytes (as opposed to the number of
125 TLV objects in the chain) */
126 tlv_len = tvb_get_ntohs(tvb, offset);
127 proto_tree_add_item(ssi_entry, hf_aim_fnac_subtype_ssi_tlvlen, tvb,
132 /* For now, we just dump the TLV contents as-is, since there is not a
133 TLV dissection utility that works based on total chain length */
134 while(endoffset < offset+tlv_len) {
135 endoffset = dissect_aim_tlv(tvb, pinfo, endoffset, ssi_entry, client_tlvs);
140 static int dissect_ssi_ssi_item(tvbuff_t *tvb, packet_info *pinfo,
141 proto_tree *ssi_entry)
143 return dissect_ssi_item(tvb, pinfo, 0, ssi_entry);
147 static int dissect_aim_ssi_rightsinfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ssi_tree)
149 return dissect_aim_tlv_sequence(tvb, pinfo, 0, ssi_tree, ssi_rightsinfo_tlvs);
152 static int dissect_aim_ssi_was_added(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ssi_tree)
154 return dissect_aim_buddyname(tvb, pinfo, 0, ssi_tree);
157 static int dissect_aim_snac_ssi_list(tvbuff_t *tvb, packet_info *pinfo _U_,
163 proto_tree *ssi_entry = NULL;
164 guint16 num_items, i;
167 proto_tree_add_item(tree, hf_aim_fnac_subtype_ssi_version, tvb, offset, 1,
171 /* Number of items */
172 proto_tree_add_item(tree, hf_aim_fnac_subtype_ssi_numitems, tvb, offset, 2,
174 num_items = tvb_get_ntohs(tvb, offset);
177 for(i = 0; i < num_items; i++) {
178 ti = proto_tree_add_text(tree, tvb, offset, tvb_get_ntohs(tvb, offset+10)+10, "SSI Entry");
179 ssi_entry = proto_item_add_subtree(ti, ett_aim_ssi);
180 offset = dissect_ssi_item(tvb, pinfo, offset, ssi_entry);
182 proto_tree_add_item(tree, hf_aim_fnac_subtype_ssi_last_change_time, tvb, offset, 4, FALSE);
186 static const aim_subtype aim_fnac_family_ssi[] = {
187 { 0x0001, "Error", dissect_aim_snac_error },
188 { 0x0002, "Request Rights", NULL },
189 { 0x0003, "Rights Info", dissect_aim_ssi_rightsinfo },
190 { 0x0004, "Request List (first time)", NULL },
191 { 0x0005, "Request List", NULL },
192 { 0x0006, "List", dissect_aim_snac_ssi_list },
193 { 0x0007, "Activate", NULL },
194 { 0x0008, "Add Buddy", dissect_ssi_ssi_item },
195 { 0x0009, "Modify Buddy", dissect_ssi_ssi_item },
196 { 0x000a, "Delete Buddy", dissect_ssi_ssi_item },
197 { 0x000e, "Server Ack", NULL },
198 { 0x000f, "No List", NULL },
199 { 0x0011, "Edit Start", NULL },
200 { 0x0012, "Edit Stop", NULL },
201 { 0x0014, "Grant Future Authorization to Buddy", NULL },
202 { 0x0015, "Future Authorization Granted", NULL },
203 { 0x0018, "Send Authentication Request", NULL },
204 { 0x0019, "Authentication Request", NULL },
205 { 0x001a, "Send Authentication Reply", NULL },
206 { 0x001b, "Authentication Reply", NULL },
207 { 0x001c, "Remote User Added Client To List", dissect_aim_ssi_was_added },
212 /* Register the protocol with Wireshark */
214 proto_register_aim_ssi(void)
217 /* Setup list of header fields */
218 static hf_register_info hf[] = {
219 { &hf_aim_fnac_subtype_ssi_version,
220 { "SSI Version", "aim.fnac.ssi.version", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }
222 { &hf_aim_fnac_subtype_ssi_numitems,
223 { "SSI Object count", "aim.fnac.ssi.numitems", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
225 { &hf_aim_fnac_subtype_ssi_last_change_time,
226 { "SSI Last Change Time", "aim.fnac.ssi.last_change_time", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }
228 { &hf_aim_fnac_subtype_ssi_buddyname_len,
229 { "SSI Buddy Name length", "aim.fnac.ssi.buddyname_len", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
231 { &hf_aim_fnac_subtype_ssi_buddyname,
232 { "Buddy Name", "aim.fnac.ssi.buddyname", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }
234 { &hf_aim_fnac_subtype_ssi_gid,
235 { "SSI Buddy Group ID", "aim.fnac.ssi.gid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
237 { &hf_aim_fnac_subtype_ssi_bid,
238 { "SSI Buddy ID", "aim.fnac.ssi.bid", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
240 { &hf_aim_fnac_subtype_ssi_type,
241 { "SSI Buddy type", "aim.fnac.ssi.type", FT_UINT16, BASE_HEX, VALS(aim_fnac_family_ssi_types), 0x0, "", HFILL }
243 { &hf_aim_fnac_subtype_ssi_tlvlen,
244 { "SSI TLV Len", "aim.fnac.ssi.tlvlen", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
246 { &hf_aim_fnac_subtype_ssi_data,
247 { "SSI Buddy Data", "aim.fnac.ssi.data", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
251 /* Setup protocol subtree array */
252 static gint *ett[] = {
257 /* Register the protocol name and description */
258 proto_aim_ssi = proto_register_protocol("AIM Server Side Info", "AIM SSI", "aim_ssi");
260 /* Required function calls to register the header fields and subtrees used */
261 proto_register_field_array(proto_aim_ssi, hf, array_length(hf));
262 proto_register_subtree_array(ett, array_length(ett));
266 proto_reg_handoff_aim_ssi(void)
268 aim_init_family(proto_aim_ssi, ett_aim_ssi, FAMILY_SSI, aim_fnac_family_ssi);