2 * Routines for AIM (OSCAR) dissection, SNAC Server Stored Themes
3 * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 #include <epan/packet.h>
38 #include <epan/strutil.h>
40 #include "packet-aim.h"
42 #define FAMILY_SST 0x0010
45 /* Initialize the protocol and registered fields */
46 static int proto_aim_sst = -1;
47 static int hf_aim_sst_unknown = -1;
48 static int hf_aim_sst_md5_hash = -1;
49 static int hf_aim_sst_md5_hash_size = -1;
50 static int hf_aim_sst_ref_num = -1;
51 static int hf_aim_sst_icon_size = -1;
52 static int hf_aim_sst_icon = -1;
54 /* Initialize the subtree pointers */
55 static gint ett_aim_sst = -1;
57 static int dissect_aim_sst_buddy_down_req (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
59 int offset = dissect_aim_buddyname(tvb, pinfo, 0, tree);
62 proto_tree_add_item(tree, hf_aim_sst_unknown, tvb, offset, 4, FALSE);
65 proto_tree_add_item(tree, hf_aim_sst_md5_hash_size, tvb, offset, 1, FALSE);
66 md5_size = tvb_get_guint8(tvb, offset);
69 proto_tree_add_item(tree, hf_aim_sst_md5_hash, tvb, offset, md5_size, FALSE);
75 static int dissect_aim_sst_buddy_down_repl (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
77 int offset = dissect_aim_buddyname(tvb, pinfo, 0, tree);
81 proto_tree_add_item(tree, hf_aim_sst_unknown, tvb, offset, 3, FALSE);
84 proto_tree_add_item(tree, hf_aim_sst_md5_hash_size, tvb, offset, 1, FALSE);
85 md5_size = tvb_get_guint8(tvb, offset);
88 proto_tree_add_item(tree, hf_aim_sst_md5_hash, tvb, offset, md5_size, FALSE);
92 proto_tree_add_item(tree, hf_aim_sst_icon_size, tvb, offset, 2, FALSE);
93 icon_size = tvb_get_ntohs(tvb, offset);
96 if (icon_size && (tvb_ensure_length_remaining(tvb, offset) >= icon_size))
98 proto_tree_add_item(tree, hf_aim_sst_icon, tvb, offset, icon_size, FALSE);
106 static int dissect_aim_sst_buddy_up_repl (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
111 proto_tree_add_item(tree, hf_aim_sst_unknown, tvb, offset, 4, FALSE);
114 proto_tree_add_item(tree, hf_aim_sst_md5_hash_size, tvb, offset, 1, FALSE);
115 md5_size = tvb_get_guint8(tvb, offset);
118 proto_tree_add_item(tree, hf_aim_sst_md5_hash, tvb, offset, md5_size, FALSE);
124 static int dissect_aim_sst_buddy_up_req (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
129 proto_tree_add_item(tree, hf_aim_sst_ref_num, tvb, offset, 2, FALSE);
132 proto_tree_add_item(tree, hf_aim_sst_icon_size, tvb, offset, 2, FALSE);
133 icon_size = tvb_get_ntohs(tvb, offset);
136 if (icon_size && (tvb_ensure_length_remaining(tvb, offset) >= icon_size))
138 proto_tree_add_item(tree, hf_aim_sst_icon, tvb, offset, icon_size, FALSE);
145 static const aim_subtype aim_fnac_family_sst[] = {
146 { 0x0001, "Error", dissect_aim_snac_error },
147 { 0x0002, "Upload Buddy Icon Request", dissect_aim_sst_buddy_up_req },
148 { 0x0003, "Upload Buddy Icon Reply", dissect_aim_sst_buddy_up_repl },
149 { 0x0004, "Download Buddy Icon Request", dissect_aim_sst_buddy_down_req },
150 { 0x0005, "Download Buddy Icon Reply", dissect_aim_sst_buddy_down_repl },
155 /* Register the protocol with Wireshark */
157 proto_register_aim_sst(void)
160 /* Setup list of header fields */
161 static hf_register_info hf[] = {
162 { &hf_aim_sst_md5_hash,
163 { "MD5 Hash", "aim.sst.md5", FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL },
165 { &hf_aim_sst_md5_hash_size,
166 { "MD5 Hash Size", "aim.sst.md5.size", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL },
168 { &hf_aim_sst_unknown,
169 { "Unknown Data", "aim.sst.unknown", FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL },
171 { &hf_aim_sst_ref_num,
172 { "Reference Number", "aim.sst.ref_num", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
174 { &hf_aim_sst_icon_size,
175 { "Icon Size", "aim.sst.icon_size", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
178 { "Icon", "aim.sst.icon", FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL },
182 /* Setup protocol subtree array */
183 static gint *ett[] = {
187 /* Register the protocol name and description */
188 proto_aim_sst = proto_register_protocol("AIM Server Side Themes", "AIM SST", "aim_sst");
190 /* Required function calls to register the header fields and subtrees used */
191 proto_register_field_array(proto_aim_sst, hf, array_length(hf));
192 proto_register_subtree_array(ett, array_length(ett));
196 proto_reg_handoff_aim_sst(void)
198 aim_init_family(proto_aim_sst, ett_aim_sst, FAMILY_SST, aim_fnac_family_sst);