smb2-dissector: learn the "REPLAY_OPERATION" flag
[obnox/wireshark/wip.git] / epan / dissectors / packet-aim-generic.c
1 /* packet-aim-generic.c
2  * Routines for AIM Instant Messenger (OSCAR) dissection, SNAC Family Generic
3  * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
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.
15  *
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.
20  *
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.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <glib.h>
31
32 #include <epan/packet.h>
33
34 #include "packet-aim.h"
35
36 #define STRIP_TAGS 1
37
38 /* SNAC families */
39 #define FAMILY_GENERIC    0x0001
40
41
42 #define FAMILY_GENERIC_MOTD_MOTDTYPE_MDT_UPGRADE       0x0001
43 #define FAMILY_GENERIC_MOTD_MOTDTYPE_ADV_UPGRADE       0x0002
44 #define FAMILY_GENERIC_MOTD_MOTDTYPE_SYS_BULLETIN      0x0003
45 #define FAMILY_GENERIC_MOTD_MOTDTYPE_NORMAL            0x0004
46 #define FAMILY_GENERIC_MOTD_MOTDTYPE_NEWS              0x0006
47
48 static const value_string aim_snac_generic_motd_motdtypes[] = {
49         { FAMILY_GENERIC_MOTD_MOTDTYPE_MDT_UPGRADE, "Mandatory Upgrade Needed Notice" },
50         { FAMILY_GENERIC_MOTD_MOTDTYPE_ADV_UPGRADE, "Advisable Upgrade Notice" },
51         { FAMILY_GENERIC_MOTD_MOTDTYPE_SYS_BULLETIN, "AIM/ICQ Service System Announcements" },
52         { FAMILY_GENERIC_MOTD_MOTDTYPE_NORMAL, "Standard Notice" },
53         { FAMILY_GENERIC_MOTD_MOTDTYPE_NEWS, "News from AOL service" },
54         { 0, NULL }
55 };
56
57 #define RATEINFO_STATE_LIMITED                  0x01
58 #define RATEINFO_STATE_ALERT                    0x02
59 #define RATEINFO_STATE_CLEAR                    0x03
60
61 static const value_string rateinfo_states[] = {
62         { RATEINFO_STATE_LIMITED, "Limited" },
63         { RATEINFO_STATE_ALERT, "Alert" },
64         { RATEINFO_STATE_CLEAR, "Clear" },
65         { 0, NULL }
66 };
67
68 #define RATECHANGE_MSG_LIMIT_PARAMS_CHANGED      0x0001
69 #define RATECHANGE_MSG_LIMIT_WARN                0x0002
70 #define RATECHANGE_MSG_LIMIT_HIT                 0x0003
71 #define RATECHANGE_MSG_LIMIT_CLEAR               0x0004
72
73 static const value_string ratechange_msgs[] = {
74         { RATECHANGE_MSG_LIMIT_PARAMS_CHANGED, "Rate limits parameters changed" },
75         { RATECHANGE_MSG_LIMIT_WARN, "Rate limits warning (current level < alert level)" },
76         { RATECHANGE_MSG_LIMIT_HIT, "Rate limit hit (current level < limit level)" },
77         { RATECHANGE_MSG_LIMIT_CLEAR, "Rate limit clear (current level now > clear level)" },
78         { 0, NULL },
79 };
80
81 #define EXT_STATUS_TYPE_BUDDY_ICON_0 0
82 #define EXT_STATUS_TYPE_BUDDY_ICON_1 1
83 #define EXT_STATUS_TYPE_AVAIL_MSG    2
84 #define EXT_STATUS_TYPE_UNKNOWN          6
85
86 static const value_string ext_status_types[] = {
87         { EXT_STATUS_TYPE_BUDDY_ICON_0, "Request to send buddy icon" },
88         { EXT_STATUS_TYPE_BUDDY_ICON_1, "Request to send buddy icon" },
89         { EXT_STATUS_TYPE_AVAIL_MSG, "Extended Status Update" },
90         { 0, NULL },
91 };
92
93 #define EXT_STATUS_FLAG_INITIAL_SEND    0x41
94 #define EXT_STATUS_FLAG_RESEND                  0x81
95
96 static const value_string ext_status_flags[] = {
97         { EXT_STATUS_FLAG_INITIAL_SEND, "First Send Request" },
98         { EXT_STATUS_FLAG_RESEND,               "Request To Re-Send" },
99         { 0, NULL },
100 };
101
102 /* Initialize the protocol and registered fields */
103 static int proto_aim_generic = -1;
104 static int hf_generic_motd_motdtype = -1;
105 static int hf_generic_servicereq_service = -1;
106 static int hf_generic_rateinfo_numclasses = -1;
107 static int hf_generic_rateinfo_windowsize = -1;
108 static int hf_generic_rateinfo_clearlevel = -1;
109 static int hf_generic_rateinfo_alertlevel = -1;
110 static int hf_generic_rateinfo_limitlevel = -1;
111 static int hf_generic_rateinfo_disconnectlevel = -1;
112 static int hf_generic_rateinfo_currentlevel = -1;
113 static int hf_generic_rateinfo_maxlevel = -1;
114 static int hf_generic_rateinfo_lasttime = -1;
115 static int hf_generic_rateinfo_curstate = -1;
116 static int hf_generic_rateinfo_classid = -1;
117 static int hf_generic_rateinfo_numpairs = -1;
118 static int hf_generic_rateinfoack_group = -1;
119 static int hf_generic_ratechange_msg    = -1;
120 static int hf_generic_migration_numfams  = -1;
121 static int hf_generic_priv_flags = -1;
122 static int hf_generic_allow_idle_see = -1;
123 static int hf_generic_allow_member_see = -1;
124 static int hf_generic_selfinfo_warninglevel = -1;
125 static int hf_generic_evil_new_warn_level = -1;
126 static int hf_generic_idle_time = -1;
127 static int hf_generic_client_ver_req_offset = -1;
128 static int hf_generic_client_ver_req_length = -1;
129 static int hf_generic_client_ver_req_hash = -1;
130 static int hf_generic_ext_status_type = -1;
131 static int hf_generic_ext_status_length = -1;
132 static int hf_generic_ext_status_flags = -1;
133 static int hf_generic_ext_status_data = -1;
134
135 /* Initialize the subtree pointers */
136 static gint ett_generic_clientready = -1;
137 static gint ett_generic_migratefamilies = -1;
138 static gint ett_generic_clientready_item = -1;
139 static gint ett_generic_serverready = -1;
140 static gint ett_generic = -1;
141 static gint ett_generic_priv_flags = -1;
142 static gint ett_generic_rateinfo_class = -1;
143 static gint ett_generic_rateinfo_classes = -1;
144 static gint ett_generic_rateinfo_groups = -1;
145 static gint ett_generic_rateinfo_group = -1;
146
147 static int dissect_rate_class(tvbuff_t *tvb, packet_info *pinfo _U_, int offset, proto_tree *class_tree)
148 {
149         proto_tree_add_uint(class_tree, hf_generic_rateinfo_classid, tvb, offset, 2, tvb_get_ntohs(tvb, offset));offset+=2;
150         proto_tree_add_uint(class_tree, hf_generic_rateinfo_windowsize, tvb, offset, 4, tvb_get_ntohl(tvb, offset));offset+=4;
151         proto_tree_add_uint(class_tree, hf_generic_rateinfo_clearlevel, tvb, offset, 4, tvb_get_ntohl(tvb, offset));offset+=4;
152         proto_tree_add_uint(class_tree, hf_generic_rateinfo_alertlevel, tvb, offset, 4, tvb_get_ntohl(tvb, offset));offset+=4;
153         proto_tree_add_uint(class_tree, hf_generic_rateinfo_limitlevel, tvb, offset, 4, tvb_get_ntohl(tvb, offset));offset+=4;
154         proto_tree_add_uint(class_tree, hf_generic_rateinfo_disconnectlevel, tvb, offset, 4, tvb_get_ntohl(tvb, offset));offset+=4;
155         proto_tree_add_uint(class_tree, hf_generic_rateinfo_currentlevel, tvb, offset, 4, tvb_get_ntohl(tvb, offset));offset+=4;
156         proto_tree_add_uint(class_tree, hf_generic_rateinfo_maxlevel, tvb, offset, 4, tvb_get_ntohl(tvb, offset));offset+=4;
157         proto_tree_add_uint(class_tree, hf_generic_rateinfo_lasttime, tvb, offset, 4, tvb_get_ntohl(tvb, offset));offset+=4;
158         proto_tree_add_uint(class_tree, hf_generic_rateinfo_curstate, tvb, offset, 1, tvb_get_guint8(tvb, offset));offset+=1;
159         return offset;
160 }
161
162 static int dissect_generic_rateinfo(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
163 {
164         int offset = 0;
165         guint16 i;
166         proto_item *ti;
167         guint16 numclasses = tvb_get_ntohs(tvb, 0);
168         proto_tree *classes_tree = NULL, *groups_tree, *group_tree;
169         proto_tree_add_uint(tree, hf_generic_rateinfo_numclasses, tvb, 0, 2, numclasses );
170         offset+=2;
171
172         if(tree) {
173                 /* sizeof(rate_class_struct) = 35 ! */
174                 ti = proto_tree_add_text(tree, tvb, offset, 35 * numclasses, "Available Rate Classes");
175                 classes_tree = proto_item_add_subtree(ti, ett_generic_rateinfo_classes);
176         }
177
178         for(i = 0; i < numclasses; i++) {
179                 guint16 myid = tvb_get_ntohs(tvb, offset);
180                 proto_item *ti_local = proto_tree_add_text(classes_tree, tvb, offset, 35, "Rate Class 0x%02x", myid);
181                 proto_tree *class_tree = proto_item_add_subtree(ti_local, ett_generic_rateinfo_class);
182                 offset = dissect_rate_class(tvb, pinfo, offset, class_tree);
183         }
184
185         ti = proto_tree_add_text(tree, tvb, offset, -1, "Rate Groups");
186         groups_tree = proto_item_add_subtree(ti, ett_generic_rateinfo_groups);
187
188         for(i = 0; i < numclasses; i++) {
189                 guint16 j;
190                 guint16 myid = tvb_get_ntohs(tvb, offset);
191                 guint16 numpairs = tvb_get_ntohs(tvb, offset + 2);
192                 /*
193                  * sizeof(rate_group) = sizeof(class_id) + sizeof(numpairs) + numpairs * 2 * sizeof(uint16_t)
194                  *                    = 2 + 2 + numpairs * 4
195                  */
196                 proto_item *ti_local = proto_tree_add_text(groups_tree, tvb, offset, 4 + 4 * numpairs, "Rate Group 0x%02x", myid);
197                 group_tree = proto_item_add_subtree(ti_local, ett_generic_rateinfo_group);
198                 proto_tree_add_uint(group_tree, hf_generic_rateinfo_classid, tvb, offset, 2, myid);offset+=2;
199                 proto_tree_add_uint(group_tree, hf_generic_rateinfo_numpairs, tvb, offset, 2, numpairs); offset+=2;
200                 for(j = 0; j < numpairs; j++) {
201                         guint16 family_id;
202                         guint16 subtype_id;
203                         const aim_family *family;
204                         const aim_subtype *subtype;
205                         family_id = tvb_get_ntohs(tvb, offset); offset+=2;
206                         subtype_id = tvb_get_ntohs(tvb, offset); offset+=2;
207
208                         family = aim_get_family(family_id);
209                         subtype = aim_get_subtype(family_id, subtype_id);
210
211                         proto_tree_add_text(group_tree, tvb, offset-4, 4, "Family: %s (0x%04x), Subtype: %s (0x%04x)", family?family->name:"Unknown", family_id, subtype?subtype->name:"Unknown", subtype_id);
212                 }
213         }
214
215         return offset;
216 }
217
218 static int dissect_aim_generic_clientready(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
219 {
220         int offset = 0;
221         proto_item *ti = proto_tree_add_text(gen_tree, tvb, 0, tvb_length(tvb), "Supported services");
222         proto_tree *entry = proto_item_add_subtree(ti, ett_generic_clientready);
223
224         while(tvb_length_remaining(tvb, offset) > 0) {
225                 guint16 famnum = tvb_get_ntohs(tvb, offset);
226                 const aim_family *family = aim_get_family(famnum);
227
228                 proto_tree *subentry;
229                 ti = proto_tree_add_text(entry, tvb, offset, 2, "%s (0x%x)", family?family->name:"Unknown Family", famnum);
230                 offset+=2;
231
232                 subentry = proto_item_add_subtree(ti, ett_generic_clientready_item);
233
234                 proto_tree_add_text(subentry, tvb, offset, 2, "Version: %d", tvb_get_ntohs(tvb, offset) ); offset += 2;
235                 proto_tree_add_text(subentry, tvb, offset, 4, "DLL Version: %u", tvb_get_ntoh24(tvb, offset) ); offset += 4;
236         }
237         return offset;
238 }
239
240
241 static int dissect_aim_generic_serverready(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
242 {
243         int offset = 0;
244         proto_item *ti = proto_tree_add_text(gen_tree, tvb, offset, tvb_length(tvb), "Supported services");
245         proto_tree *entry = proto_item_add_subtree(ti, ett_generic_clientready);
246
247         while(tvb_length_remaining(tvb, offset) > 0) {
248                 guint16 famnum = tvb_get_ntohs(tvb, offset);
249                 const aim_family *family = aim_get_family(famnum);
250                 proto_tree_add_text(entry, tvb, offset, 2, "%s (0x%x)", family?family->name:"Unknown Family", famnum);
251                 offset+=2;
252         }
253         return offset;
254 }
255
256
257 static int dissect_aim_generic_service_req(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
258 {
259         int offset = 0;
260         const aim_family *family = aim_get_family( tvb_get_ntohs(tvb, offset) );
261
262         proto_tree_add_uint_format(gen_tree, hf_generic_servicereq_service, tvb, offset, 2, tvb_get_ntohs(tvb, offset), "%s (0x%04x)", family?family->name:"Unknown", tvb_get_ntohs(tvb, offset) );
263         offset+=2;
264         return offset;
265 }
266
267 static int dissect_aim_generic_redirect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *gen_tree)
268 {
269         return dissect_aim_tlv_sequence(tvb, pinfo, 0, gen_tree, aim_client_tlvs);
270 }
271
272 static int dissect_aim_generic_capabilities(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
273 {
274         int offset = 0;
275         proto_item *ti = proto_tree_add_text(gen_tree, tvb, offset, tvb_length(tvb), "Requested services");
276         proto_tree *entry = proto_item_add_subtree(ti, ett_generic_clientready);
277
278         while(tvb_length_remaining(tvb, offset) > 0) {
279                 guint16 famnum = tvb_get_ntohs(tvb, offset);
280                 const aim_family *family = aim_get_family(famnum);
281                 proto_tree_add_text(entry, tvb, offset, 4, "%s (0x%x), Version: %d", family?family->name:"Unknown Family", famnum, tvb_get_ntohs(tvb, offset+2));
282                 offset += 4;
283         }
284         return offset;
285 }
286
287 static int dissect_aim_generic_capack(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
288 {
289         int offset = 0;
290         proto_item *ti = proto_tree_add_text(gen_tree, tvb, offset, tvb_length(tvb), "Accepted requested services");
291         proto_tree *entry = proto_item_add_subtree(ti, ett_generic_clientready);
292
293         while(tvb_length_remaining(tvb, offset) > 0) {
294                 guint16 famnum = tvb_get_ntohs(tvb, offset);
295                 const aim_family *family = aim_get_family(famnum);
296                 proto_tree_add_text(entry, tvb, offset, 4, "%s (0x%x), Version: %d", family?family->name:"Unknown Family", famnum, tvb_get_ntohs(tvb, offset+2));
297                 offset += 4;
298         }
299         return offset;
300 }
301
302 static int dissect_aim_generic_motd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *gen_tree)
303 {
304         int offset = 0;
305         proto_tree_add_item(gen_tree, hf_generic_motd_motdtype, tvb, offset,
306                                                 2, tvb_get_ntohs(tvb, offset));
307         offset+=2;
308         return dissect_aim_tlv_sequence(tvb, pinfo, offset, gen_tree, aim_motd_tlvs);
309 }
310
311 static int dissect_aim_generic_rateinfoack(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
312 {
313         int offset = 0;
314         while(tvb_length_remaining(tvb, offset) > 0) {
315                 proto_tree_add_uint(gen_tree, hf_generic_rateinfoack_group, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
316                 offset+=2;
317         }
318         return offset;
319 }
320
321 static int dissect_aim_generic_ratechange(tvbuff_t *tvb, packet_info *pinfo, proto_tree *gen_tree)
322 {
323         int offset = 0;
324         proto_tree_add_uint(gen_tree, hf_generic_ratechange_msg, tvb, offset, 2, tvb_get_ntohs(tvb, offset));
325         offset+=2;
326         offset = dissect_rate_class(tvb, pinfo, offset, gen_tree);
327         return offset;
328 }
329
330
331 static int dissect_aim_generic_clientpauseack(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
332 {
333         int offset = 0;
334         while(tvb_length_remaining(tvb, offset) > 0) {
335                 guint16 famnum = tvb_get_ntohs(tvb, offset);
336                 const aim_family *family = aim_get_family(famnum);
337                 proto_tree_add_text(gen_tree, tvb, offset, 4, "Family: %s (0x%x)", family?family->name:"Unknown Family", famnum);
338                 offset += 2;
339         }
340         return offset;
341 }
342
343 static int dissect_aim_generic_migration_req(tvbuff_t *tvb, packet_info *pinfo, proto_tree *gen_tree)
344 {
345         int offset = 0;
346         guint32 n, i;
347         proto_item *ti;
348         proto_tree *entry;
349
350         n = tvb_get_ntohs(tvb, offset);offset+=2;
351         proto_tree_add_uint(gen_tree, hf_generic_migration_numfams, tvb, offset, 2, n);
352         ti = proto_tree_add_text(gen_tree, tvb, offset, 2 * n, "Families to migrate");
353         entry = proto_item_add_subtree(ti, ett_generic_migratefamilies);
354         for(i = 0; i < n; i++) {
355                 guint16 famnum = tvb_get_ntohs(tvb, offset);
356                 const aim_family *family = aim_get_family(famnum);
357                 proto_tree_add_text(entry, tvb, offset, 4, "Family: %s (0x%x)", family?family->name:"Unknown Family", famnum);
358                 offset += 2;
359         }
360
361         return dissect_aim_tlv_sequence(tvb, pinfo, offset, gen_tree, aim_client_tlvs);
362 }
363
364 static int dissect_aim_generic_setprivflags(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
365 {
366         int offset = 0;
367         guint32 flags = tvb_get_ntoh24(tvb, offset);
368         proto_item *ti = proto_tree_add_uint(gen_tree, hf_generic_priv_flags, tvb, offset, 4, flags);
369         proto_tree *entry = proto_item_add_subtree(ti, ett_generic_priv_flags);
370         proto_tree_add_boolean(entry, hf_generic_allow_idle_see, tvb, offset, 4, flags);
371         proto_tree_add_boolean(entry, hf_generic_allow_member_see, tvb, offset, 4, flags);
372         offset+=4;
373         return offset;
374 }
375
376 static int dissect_aim_generic_selfinfo_repl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *gen_tree)
377 {
378         int offset = dissect_aim_buddyname(tvb, pinfo, 0, gen_tree);
379         proto_tree_add_item(gen_tree, hf_generic_selfinfo_warninglevel, tvb, offset, 2, ENC_BIG_ENDIAN);
380         offset += 2;
381         return dissect_aim_tlv_list(tvb, pinfo, offset, gen_tree, aim_onlinebuddy_tlvs);
382 }
383
384 static int dissect_aim_generic_evil(tvbuff_t *tvb, packet_info *pinfo, proto_tree *gen_tree)
385 {
386         int offset = 0;
387         proto_tree_add_item(gen_tree, hf_generic_evil_new_warn_level, tvb, offset, 2, ENC_BIG_ENDIAN);
388         while(tvb_length_remaining(tvb, offset) > 0) {
389                 offset = dissect_aim_userinfo(tvb, pinfo, offset, gen_tree);
390         }
391         return offset;
392 }
393
394 static int dissect_aim_generic_setidle(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
395 {
396         proto_tree_add_item(gen_tree, hf_generic_idle_time, tvb, 0, 2, ENC_BIG_ENDIAN);
397         return 2;
398 }
399
400 static int dissect_aim_generic_ext_status_req(tvbuff_t *tvb, packet_info *pinfo, proto_tree *gen_tree)
401 {
402         return dissect_aim_tlv_sequence(tvb, pinfo, 0, gen_tree, aim_onlinebuddy_tlvs);
403 }
404
405 static int dissect_aim_generic_clientver_req(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
406 {
407         int offset = 0;
408         proto_tree_add_item(gen_tree, hf_generic_client_ver_req_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
409         offset+=4;
410         proto_tree_add_item(gen_tree, hf_generic_client_ver_req_length, tvb, offset, 4, ENC_BIG_ENDIAN);
411         return offset+4;
412 }
413
414 static int dissect_aim_generic_clientver_repl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
415 {
416         proto_tree_add_item(gen_tree, hf_generic_client_ver_req_hash, tvb, 0, 16, ENC_NA);
417         return 16;
418 }
419
420 static int dissect_aim_generic_ext_status_repl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *gen_tree)
421 {
422         guint8 length;
423         int offset = 0;
424         proto_tree_add_item(gen_tree, hf_generic_ext_status_type, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
425         proto_tree_add_item(gen_tree, hf_generic_ext_status_flags, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1;
426         proto_tree_add_item(gen_tree, hf_generic_ext_status_length, tvb, offset, 1, ENC_BIG_ENDIAN); length = tvb_get_guint8(tvb, offset); offset += 1;
427         proto_tree_add_item(gen_tree, hf_generic_ext_status_data, tvb, offset, length, ENC_NA); offset += 1;
428         return offset;
429 }
430
431 static const aim_subtype aim_fnac_family_generic[] = {
432         { 0x0001, "Error", dissect_aim_snac_error },
433         { 0x0002, "Client Ready", dissect_aim_generic_clientready },
434         { 0x0003, "Server Ready", dissect_aim_generic_serverready  },
435         { 0x0004, "Service Request", dissect_aim_generic_service_req },
436         { 0x0005, "Redirect", dissect_aim_generic_redirect },
437         { 0x0006, "Rate Info Request", NULL},
438         { 0x0007, "Rate Info", dissect_generic_rateinfo },
439         { 0x0008, "Rate Info Ack", dissect_aim_generic_rateinfoack },
440         { 0x000a, "Rate Change", dissect_aim_generic_ratechange },
441         { 0x000b, "Server Pause", NULL },
442         { 0x000c, "Client Pause Ack", dissect_aim_generic_clientpauseack },
443         { 0x000d, "Server Resume", NULL },
444         { 0x000e, "Self Info Request", NULL },
445         { 0x000f, "Self Info Reply", dissect_aim_generic_selfinfo_repl },
446         { 0x0010, "Evil", dissect_aim_generic_evil },
447         { 0x0011, "Set Idle", dissect_aim_generic_setidle },
448         { 0x0012, "Migration Request", dissect_aim_generic_migration_req },
449         { 0x0013, "Message Of The Day", dissect_aim_generic_motd },
450         { 0x0014, "Set Privilege Flags", dissect_aim_generic_setprivflags },
451         { 0x0015, "Well Known URL", NULL }, /* FIXME */
452         { 0x0016, "noop", NULL },
453         { 0x0017, "Capabilities",  dissect_aim_generic_capabilities },
454         { 0x0018, "Capabilities Ack", dissect_aim_generic_capack },
455         { 0x001e, "Set Extended Status Request", dissect_aim_generic_ext_status_req },
456         { 0x001f, "Client Verification Request",  dissect_aim_generic_clientver_req },
457         { 0x0020, "Client Verification Reply", dissect_aim_generic_clientver_repl },
458         { 0x0021, "Set Extended Status Reply", dissect_aim_generic_ext_status_repl },
459         { 0, NULL, NULL }
460 };
461
462
463 /* Register the protocol with Wireshark */
464 void
465 proto_register_aim_generic(void)
466 {
467
468         /* Setup list of header fields */
469         static hf_register_info hf[] = {
470                 { &hf_generic_servicereq_service,
471                         { "Requested Service", "aim_generic.servicereq.service", FT_UINT16,
472                                 BASE_HEX, NULL, 0x0, NULL, HFILL },
473         },
474         { &hf_generic_motd_motdtype,
475           { "MOTD Type", "aim_generic.motd.motdtype", FT_UINT16,
476                   BASE_HEX, VALS(aim_snac_generic_motd_motdtypes), 0x0, NULL, HFILL },
477         },
478         { &hf_generic_rateinfo_numclasses,
479           { "Number of Rateinfo Classes", "aim_generic.rateinfo.numclasses", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL },
480         },
481         { &hf_generic_rateinfo_windowsize,
482           { "Window Size", "aim_generic.rateinfo.class.window_size", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL },
483         },
484         { &hf_generic_rateinfo_clearlevel,
485           { "Clear Level", "aim_generic.rateinfo.class.clearlevel", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL },
486         },
487         { &hf_generic_rateinfo_alertlevel,
488           { "Alert Level", "aim_generic.rateinfo.class.alertlevel", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL },
489         },
490         { &hf_generic_rateinfo_limitlevel,
491           { "Limit Level", "aim_generic.rateinfo.class.limitlevel", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL },
492         },
493         { &hf_generic_rateinfo_disconnectlevel,
494           { "Disconnect Level", "aim_generic.rateinfo.class.disconnectlevel", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL },
495         },
496         { &hf_generic_rateinfo_currentlevel,
497           { "Current Level", "aim_generic.rateinfo.class.currentlevel", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL },
498         },
499         { &hf_generic_rateinfo_maxlevel,
500           { "Max Level", "aim_generic.rateinfo.class.maxlevel", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL },
501         },
502         { &hf_generic_rateinfo_lasttime,
503           { "Last Time", "aim_generic.rateinfo.class.lasttime", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL },
504         },
505         { &hf_generic_rateinfo_curstate,
506           { "Current State", "aim_generic.rateinfo.class.curstate", FT_UINT8, BASE_HEX, VALS(rateinfo_states), 0x0, NULL, HFILL },
507         },
508         { &hf_generic_rateinfo_classid,
509           { "Class ID", "aim_generic.rateinfo.class.id", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL },
510         },
511         { &hf_generic_rateinfo_numpairs,
512           { "Number of Family/Subtype pairs", "aim_generic.rateinfo.class.numpairs", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL },
513         },
514         { &hf_generic_rateinfoack_group,
515           { "Acknowledged Rate Class", "aim_generic.rateinfoack.class", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL },
516         },
517         { &hf_generic_ratechange_msg,
518           { "Rate Change Message", "aim_generic.ratechange.msg", FT_UINT16, BASE_HEX, VALS(ratechange_msgs), 0x0, NULL, HFILL },
519         },
520         { &hf_generic_migration_numfams,
521           { "Number of families to migrate", "aim_generic.migrate.numfams", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL },
522         },
523         { &hf_generic_priv_flags,
524           { "Privilege flags", "aim_generic.privilege_flags", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL },
525         },
526         { &hf_generic_allow_idle_see,
527           { "Allow other users to see idle time", "aim_generic.privilege_flags.allow_idle", FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x0001, NULL, HFILL },
528         },
529         { &hf_generic_allow_member_see,
530           { "Allow other users to see how long account has been a member", "aim_generic.privilege_flags.allow_member", FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x0002, NULL, HFILL },
531         },
532         { &hf_generic_selfinfo_warninglevel,
533                 { "Warning level", "aim_generic.selfinfo.warn_level", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL },
534         },
535         { &hf_generic_evil_new_warn_level,
536                 { "New warning level", "aim_generic.evil.new_warn_level", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL },
537         },
538         { &hf_generic_idle_time,
539                 { "Idle time (seconds)", "aim_generic.idle_time", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL },
540         },
541         { &hf_generic_client_ver_req_offset,
542                 { "Client Verification Request Offset", "aim_generic.client_verification.offset", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL },
543         },
544         { &hf_generic_client_ver_req_length,
545                 { "Client Verification Request Length", "aim_generic.client_verification.length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL },
546         },
547         { &hf_generic_client_ver_req_hash,
548                 { "Client Verification MD5 Hash", "aim_generic.client_verification.hash", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL },
549         },
550         { &hf_generic_ext_status_type,
551                 { "Extended Status Type", "aim_generic.ext_status.type", FT_UINT16, BASE_DEC, VALS(ext_status_types), 0x0, NULL, HFILL },
552         },
553         { &hf_generic_ext_status_flags,
554                 { "Extended Status Flags", "aim_generic.ext_status.flags", FT_UINT8, BASE_HEX, VALS(ext_status_flags), 0x0, NULL, HFILL },
555         },
556         { &hf_generic_ext_status_length,
557                 { "Extended Status Length", "aim_generic.ext_status.length", FT_UINT8, BASE_HEX, NULL, 0x0, NULL , HFILL },
558         },
559         { &hf_generic_ext_status_data,
560                 { "Extended Status Data", "aim_generic.ext_status.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL , HFILL },
561         },
562
563   };
564
565 /* Setup protocol subtree array */
566         static gint *ett[] = {
567                 &ett_generic,
568                 &ett_generic_migratefamilies,
569                 &ett_generic_rateinfo_class,
570                 &ett_generic_rateinfo_group,
571                 &ett_generic_rateinfo_groups,
572                 &ett_generic_rateinfo_classes,
573                 &ett_generic_clientready,
574                 &ett_generic_clientready_item,
575                 &ett_generic_serverready,
576                 &ett_generic_priv_flags,
577         };
578
579 /* Register the protocol name and description */
580         proto_aim_generic = proto_register_protocol("AIM Generic Service", "AIM Generic", "aim_generic");
581
582 /* Required function calls to register the header fields and subtrees used */
583         proto_register_field_array(proto_aim_generic, hf, array_length(hf));
584         proto_register_subtree_array(ett, array_length(ett));
585 }
586
587 void
588 proto_reg_handoff_aim_generic(void)
589 {
590         aim_init_family(proto_aim_generic, ett_generic, FAMILY_GENERIC, aim_fnac_family_generic);
591 }