MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-aim-icq.c
blob9b5c9c26b1c5e643d2147827d1b1eac8c5b0d272
1 /* packet-aim-icq.c
2 * Routines for AIM Instant Messenger (OSCAR) dissection, SNAC ICQ
3 * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
5 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "config.h"
28 #include <glib.h>
30 #include <epan/packet.h>
31 #include <epan/strutil.h>
33 #include "packet-aim.h"
35 void proto_register_aim_icq(void);
36 void proto_reg_handoff_aim_icq(void);
38 #define FAMILY_ICQ 0x0015
41 #define ICQ_CLI_OFFLINE_MESSAGE_REQ 0x003c
42 #define ICQ_CLI_DELETE_OFFLINE_MSGS 0x003e
43 #define ICQ_SRV_OFFLINE_MSGS 0x0041
44 #define ICQ_SRV_END_OF_OFFLINE_MSGS 0x0042
45 #define ICQ_CLI_META_INFO_REQ 0x07d0
46 #define ICQ_SRV_META_INFO_REPL 0x07da
48 static const value_string aim_icq_data_types[] = {
49 { ICQ_CLI_OFFLINE_MESSAGE_REQ, "Offline Message Request" },
50 { ICQ_SRV_OFFLINE_MSGS, "Offline Messages Reply" },
51 { ICQ_SRV_END_OF_OFFLINE_MSGS, "End Of Offline Messages Reply" },
52 { ICQ_CLI_DELETE_OFFLINE_MSGS, "Delete Offline Messages Request" },
53 { ICQ_CLI_META_INFO_REQ, "Metainfo Request" },
54 { ICQ_SRV_META_INFO_REPL, "Metainfo Reply" },
55 { 0, NULL }
59 static int dissect_aim_tlv_value_icq(proto_item *ti, guint16 subtype, tvbuff_t *tvb, packet_info *pinfo _U_);
61 #define TLV_ICQ_META_DATA 0x0001
63 static const aim_tlv icq_tlv[] = {
64 { TLV_ICQ_META_DATA, "Encapsulated ICQ Meta Data", dissect_aim_tlv_value_icq },
65 { 0, NULL, NULL },
68 /* Initialize the protocol and registered fields */
69 static int proto_aim_icq = -1;
71 /* Initialize the subtree pointers */
72 static gint ett_aim_icq = -1;
73 static gint ett_aim_icq_tlv = -1;
75 static gint hf_icq_tlv_data_chunk_size = -1;
76 static gint hf_icq_tlv_request_owner_uid = -1;
77 static gint hf_icq_tlv_request_type = -1;
78 static gint hf_icq_meta_subtype = -1;
79 static gint hf_icq_tlv_request_seq_num = -1;
80 static gint hf_icq_dropped_msg_flag = -1;
83 static struct
85 guint16 subtype;
86 const char *name;
87 int (*dissector) (tvbuff_t *, packet_info *, proto_tree *);
88 } icq_calls [] = {
89 { 0x0001, "Server Error Reply", NULL },
90 { 0x0064, "Set User Home Info Reply", NULL },
91 { 0x006e, "Set User Work Info Reply", NULL },
92 { 0x0078, "Set User More Info Reply", NULL },
93 { 0x0082, "Set User Notes Info Reply", NULL },
94 { 0x0087, "Set User Email Info Reply", NULL },
95 { 0x008c, "Set User Interests Info Reply", NULL },
96 { 0x0096, "Set User Affiliations Info Reply", NULL },
97 { 0x00a0, "Set User Permissions Reply", NULL },
98 { 0x00aa, "Set User Password Reply", NULL },
99 { 0x00b4, "Unregister Account Reply", NULL },
100 { 0x00be, "Set User Homepage Category Reply", NULL },
101 { 0x00c8, "User Basic Info Reply", NULL },
102 { 0x00d2, "User Work Info Reply", NULL },
103 { 0x00dc, "User More Info Reply", NULL },
104 { 0x00e6, "User Notes Info Reply", NULL },
105 { 0x00eb, "User Extended Email Reply", NULL },
106 { 0x00f0, "User Interests Info Reply", NULL },
107 { 0x00fa, "User Affiliations Info Reply", NULL },
108 { 0x0104, "Short User Info Reply", NULL },
109 { 0x010e, "User Homepage Category Reply", NULL },
110 { 0x01a4, "Search: User found", NULL },
111 { 0x0302, "Registration Stats Reply", NULL },
112 { 0x0366, "Random Search Server Reply", NULL },
113 { 0x03ea, "Set User Home Info Request", NULL },
114 { 0x03f3, "Set User Work Info Request", NULL },
115 { 0x03fd, "Set User More Info Request", NULL },
116 { 0x0406, "Set User Notes Request", NULL },
117 { 0x040b, "Set User Extended Email Info Request", NULL },
118 { 0x0410, "Set User Interests Info Request", NULL },
119 { 0x041a, "Set User Affiliations Info Request", NULL },
120 { 0x0424, "Set User Permissions Info Request", NULL },
121 { 0x042e, "Change User Password Request", NULL },
122 { 0x0442, "Set User Homepage Category Request", NULL },
123 { 0x04b2, "Fullinfo Request", NULL },
124 { 0x04ba, "Short User Info Request", NULL },
125 { 0x04c4, "Unregister User Request", NULL },
126 { 0x0515, "Search By Details Request", NULL },
127 { 0x0569, "Search By UIN Request", NULL },
128 { 0x055f, "Whitepages Search Request", NULL },
129 { 0x0573, "Search By Email Request", NULL },
130 { 0x074e, "Random Chat User Search Request", NULL },
131 { 0x0898, "Server Variable Request (XML)", NULL },
132 { 0x0aa5, "Registration Report Request", NULL },
133 { 0x0aaf, "Shortcut Bar Stats Report Request", NULL },
134 { 0x0c3a, "Save Info Request", NULL },
135 { 0x1482, "Send SMS Request", NULL },
136 { 0x2008, "Spam Report Request", NULL },
137 { 0x08a2, "Server Variable Reply (XML)", NULL },
138 { 0x0c3f, "Set Fullinfo Reply", NULL },
139 { 0x2012, "User Spam Report Reply", NULL },
140 { 0, NULL, NULL },
144 static int dissect_aim_tlv_value_icq(proto_item *ti _U_, guint16 subtype _U_, tvbuff_t *tvb _U_, packet_info *pinfo)
146 int offset = 0;
147 int i;
148 proto_item *subtype_item;
149 guint16 req_type, req_subtype;
150 proto_tree *t = proto_item_add_subtree(ti, ett_aim_icq_tlv);
152 proto_tree_add_item(t, hf_icq_tlv_data_chunk_size, tvb, offset, 2, ENC_LITTLE_ENDIAN);
153 offset += 2;
155 proto_tree_add_item(t, hf_icq_tlv_request_owner_uid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
156 offset += 4;
158 proto_tree_add_item(t, hf_icq_tlv_request_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
159 req_type = tvb_get_letohs(tvb, offset);
160 offset += 2;
162 proto_tree_add_item(t, hf_icq_tlv_request_seq_num, tvb, offset, 2, ENC_LITTLE_ENDIAN);
163 offset += 2;
165 switch (req_type) {
166 case ICQ_CLI_OFFLINE_MESSAGE_REQ: return offset;
167 case ICQ_CLI_DELETE_OFFLINE_MSGS: return offset;
168 case ICQ_SRV_OFFLINE_MSGS:
169 /* FIXME */
170 break;
171 case ICQ_SRV_END_OF_OFFLINE_MSGS:
172 proto_tree_add_item(t, hf_icq_dropped_msg_flag, tvb, offset, 1, ENC_LITTLE_ENDIAN);
173 return offset+1;
174 case ICQ_CLI_META_INFO_REQ:
175 case ICQ_SRV_META_INFO_REPL:
176 req_subtype = tvb_get_letohs(tvb, offset);
177 subtype_item = proto_tree_add_item(t, hf_icq_meta_subtype, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset+=2;
179 for (i = 0; icq_calls[i].name; i++) {
180 if (icq_calls[i].subtype == req_subtype) break;
183 col_set_str(pinfo->cinfo, COL_INFO, icq_calls[i].name?icq_calls[i].name:"Unknown ICQ Meta Call");
185 proto_item_append_text(subtype_item, " (%s)", icq_calls[i].name?icq_calls[i].name:"Unknown");
187 if (icq_calls[i].dissector)
188 return icq_calls[i].dissector(tvb_new_subset_remaining(tvb, offset), pinfo, t);
190 default:
191 break;
194 return offset;
197 static int dissect_aim_icq_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
199 return dissect_aim_tlv(tvb, pinfo, 0, tree, icq_tlv);
202 static const aim_subtype aim_fnac_family_icq[] = {
203 { 0x0001, "Error", dissect_aim_snac_error },
204 { 0x0002, "ICQ Request", dissect_aim_icq_tlv },
205 { 0x0003, "ICQ Response", dissect_aim_icq_tlv },
206 { 0x0006, "Auth Request", NULL },
207 { 0x0007, "Auth Response", NULL },
208 { 0, NULL, NULL }
212 /* Register the protocol with Wireshark */
213 void
214 proto_register_aim_icq(void)
217 /* Setup list of header fields */
218 static hf_register_info hf[] = {
219 { &hf_icq_tlv_data_chunk_size,
220 { "Data chunk size", "aim_icq.chunk_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL },
222 { &hf_icq_tlv_request_owner_uid,
223 { "Owner UID", "aim_icq.owner_uid", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL},
225 { &hf_icq_tlv_request_type,
226 {"Request Type", "aim_icq.request_type", FT_UINT16, BASE_DEC, VALS(aim_icq_data_types), 0x0, NULL, HFILL},
228 { &hf_icq_tlv_request_seq_num,
229 {"Request Sequence Number", "aim_icq.request_seq_number", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL},
231 { &hf_icq_dropped_msg_flag,
232 {"Dropped messages flag", "aim_icq.offline_msgs.dropped_flag", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL },
234 { &hf_icq_meta_subtype,
235 {"Meta Request Subtype", "aim_icq.subtype", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL },
239 /* Setup protocol subtree array */
240 static gint *ett[] = {
241 &ett_aim_icq,
242 &ett_aim_icq_tlv
245 /* Register the protocol name and description */
246 proto_aim_icq = proto_register_protocol("AIM ICQ", "AIM ICQ", "aim_icq");
248 /* Required function calls to register the header fields and subtrees used */
249 proto_register_field_array(proto_aim_icq, hf, array_length(hf));
250 proto_register_subtree_array(ett, array_length(ett));
253 void
254 proto_reg_handoff_aim_icq(void)
256 aim_init_family(proto_aim_icq, ett_aim_icq, FAMILY_ICQ, aim_fnac_family_icq);