Mercurial > pidgin.yaz
annotate src/protocols/oscar/service.c @ 13047:473d3a454615
[gaim-migrate @ 15408]
15:52:32 <NSA_> In the system tray, the "Custom Status..." should be changed to
"New Status..." to be more consistent.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Thu, 26 Jan 2006 20:54:00 +0000 |
parents | e81adace5355 |
children |
rev | line source |
---|---|
2703 | 1 /* |
3952 | 2 * Family 0x0001 - This is a very special group. All connections support |
2703 | 3 * this group, as it does some particularly good things (like rate limiting). |
4 */ | |
5 | |
6 #define FAIM_INTERNAL | |
2734
9fc65bb80596
[gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
7 #define FAIM_NEED_CONN_INTERNAL |
11404 | 8 #include "aim.h" |
2703 | 9 |
11404 | 10 #include "cipher.h" |
2703 | 11 |
3952 | 12 /* Subtype 0x0002 - Client Online */ |
2703 | 13 faim_export int aim_clientready(aim_session_t *sess, aim_conn_t *conn) |
14 { | |
15 aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside; | |
16 struct snacgroup *sg; | |
17 aim_frame_t *fr; | |
18 aim_snacid_t snacid; | |
19 | |
20 if (!ins) | |
21 return -EINVAL; | |
22 | |
23 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) | |
24 return -ENOMEM; | |
25 | |
26 snacid = aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0); | |
27 aim_putsnac(&fr->data, 0x0001, 0x0002, 0x0000, snacid); | |
28 | |
29 /* | |
30 * Send only the tool versions that the server cares about (that it | |
11253 | 31 * marked as supporting in the server ready SNAC). |
2703 | 32 */ |
33 for (sg = ins->groups; sg; sg = sg->next) { | |
34 aim_module_t *mod; | |
35 | |
36 if ((mod = aim__findmodulebygroup(sess, sg->group))) { | |
37 aimbs_put16(&fr->data, mod->family); | |
38 aimbs_put16(&fr->data, mod->version); | |
39 aimbs_put16(&fr->data, mod->toolid); | |
40 aimbs_put16(&fr->data, mod->toolversion); | |
41 } else | |
11253 | 42 gaim_debug_misc("oscar", "aim_clientready: server supports group 0x%04x but we don't!\n", sg->group); |
2703 | 43 } |
44 | |
45 aim_tx_enqueue(sess, fr); | |
46 | |
47 return 0; | |
48 } | |
49 | |
50 /* | |
3952 | 51 * Subtype 0x0003 - Host Online |
11253 | 52 * |
2703 | 53 * See comments in conn.c about how the group associations are supposed |
54 * to work, and how they really work. | |
55 * | |
56 * This info probably doesn't even need to make it to the client. | |
57 * | |
58 * We don't actually call the client here. This starts off the connection | |
59 * initialization routine required by all AIM connections. The next time | |
11253 | 60 * the client is called is the CONNINITDONE callback, which should be |
2703 | 61 * shortly after the rate information is acknowledged. |
11253 | 62 * |
2703 | 63 */ |
64 static int hostonline(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
65 { | |
66 fu16_t *families; | |
67 int famcount; | |
68 | |
69 | |
70 if (!(families = malloc(aim_bstream_empty(bs)))) | |
71 return 0; | |
72 | |
73 for (famcount = 0; aim_bstream_empty(bs); famcount++) { | |
74 families[famcount] = aimbs_get16(bs); | |
75 aim_conn_addgroup(rx->conn, families[famcount]); | |
76 } | |
77 | |
78 free(families); | |
79 | |
80 | |
81 /* | |
82 * Next step is in the Host Versions handler. | |
83 * | |
84 * Note that we must send this before we request rates, since | |
85 * the format of the rate information depends on the versions we | |
86 * give it. | |
87 * | |
88 */ | |
89 aim_setversions(sess, rx->conn); | |
90 | |
10157 | 91 return 1; |
2703 | 92 } |
93 | |
3952 | 94 /* Subtype 0x0004 - Service request */ |
2703 | 95 faim_export int aim_reqservice(aim_session_t *sess, aim_conn_t *conn, fu16_t serviceid) |
96 { | |
97 return aim_genericreq_s(sess, conn, 0x0001, 0x0004, &serviceid); | |
98 } | |
99 | |
8225 | 100 /* |
101 * Join a room of name roomname. This is the first step to joining an | |
102 * already created room. It's basically a Service Request for | |
103 * family 0x000e, with a little added on to specify the exchange and room | |
104 * name. | |
105 */ | |
106 faim_export int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance) | |
107 { | |
108 aim_frame_t *fr; | |
109 aim_snacid_t snacid; | |
110 aim_tlvlist_t *tl = NULL; | |
111 struct chatsnacinfo csi; | |
10157 | 112 |
8225 | 113 if (!sess || !conn || !roomname || !strlen(roomname)) |
114 return -EINVAL; | |
115 | |
116 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512))) | |
117 return -ENOMEM; | |
118 | |
119 memset(&csi, 0, sizeof(csi)); | |
120 csi.exchange = exchange; | |
121 strncpy(csi.name, roomname, sizeof(csi.name)); | |
122 csi.instance = instance; | |
123 | |
124 snacid = aim_cachesnac(sess, 0x0001, 0x0004, 0x0000, &csi, sizeof(csi)); | |
125 aim_putsnac(&fr->data, 0x0001, 0x0004, 0x0000, snacid); | |
126 | |
127 /* | |
128 * Requesting service chat (0x000e) | |
129 */ | |
130 aimbs_put16(&fr->data, 0x000e); | |
131 | |
132 aim_tlvlist_add_chatroom(&tl, 0x0001, exchange, roomname, instance); | |
133 aim_tlvlist_write(&fr->data, &tl); | |
134 aim_tlvlist_free(&tl); | |
135 | |
136 aim_tx_enqueue(sess, fr); | |
137 | |
10157 | 138 return 0; |
8225 | 139 } |
140 | |
3952 | 141 /* Subtype 0x0005 - Redirect */ |
2703 | 142 static int redirect(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
143 { | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
144 struct aim_redirect_data redir; |
2703 | 145 aim_rxcallback_t userfunc; |
146 aim_tlvlist_t *tlvlist; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
147 aim_snac_t *origsnac = NULL; |
2703 | 148 int ret = 0; |
149 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
150 memset(&redir, 0, sizeof(redir)); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
151 |
7167 | 152 tlvlist = aim_tlvlist_read(bs); |
2703 | 153 |
7167 | 154 if (!aim_tlv_gettlv(tlvlist, 0x000d, 1) || |
155 !aim_tlv_gettlv(tlvlist, 0x0005, 1) || | |
156 !aim_tlv_gettlv(tlvlist, 0x0006, 1)) { | |
157 aim_tlvlist_free(&tlvlist); | |
2703 | 158 return 0; |
159 } | |
160 | |
7167 | 161 redir.group = aim_tlv_get16(tlvlist, 0x000d, 1); |
162 redir.ip = aim_tlv_getstr(tlvlist, 0x0005, 1); | |
163 redir.cookielen = aim_tlv_gettlv(tlvlist, 0x0006, 1)->length; | |
11159 | 164 redir.cookie = (guchar *)aim_tlv_getstr(tlvlist, 0x0006, 1); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
165 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
166 /* Fetch original SNAC so we can get csi if needed */ |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
167 origsnac = aim_remsnac(sess, snac->id); |
2703 | 168 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
169 if ((redir.group == AIM_CONN_TYPE_CHAT) && origsnac) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
170 struct chatsnacinfo *csi = (struct chatsnacinfo *)origsnac->data; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
171 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
172 redir.chat.exchange = csi->exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
173 redir.chat.room = csi->name; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
174 redir.chat.instance = csi->instance; |
2703 | 175 } |
176 | |
177 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
178 ret = userfunc(sess, rx, &redir); |
2703 | 179 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
180 free((void *)redir.ip); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
181 free((void *)redir.cookie); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
182 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
183 if (origsnac) |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
184 free(origsnac->data); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
185 free(origsnac); |
2703 | 186 |
7167 | 187 aim_tlvlist_free(&tlvlist); |
2703 | 188 |
189 return ret; | |
190 } | |
191 | |
3952 | 192 /* Subtype 0x0006 - Request Rate Information. */ |
2703 | 193 faim_internal int aim_reqrates(aim_session_t *sess, aim_conn_t *conn) |
194 { | |
7282 | 195 return aim_genericreq_n_snacid(sess, conn, 0x0001, 0x0006); |
2703 | 196 } |
197 | |
198 /* | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8225
diff
changeset
|
199 * OSCAR defines several 'rate classes'. Each class has separate |
2703 | 200 * rate limiting properties (limit level, alert level, disconnect |
201 * level, etc), and a set of SNAC family/type pairs associated with | |
202 * it. The rate classes, their limiting properties, and the definitions | |
203 * of which SNACs are belong to which class, are defined in the | |
204 * Rate Response packet at login to each host. | |
205 * | |
206 * Logically, all rate offenses within one class count against further | |
207 * offenses for other SNACs in the same class (ie, sending messages | |
208 * too fast will limit the number of user info requests you can send, | |
209 * since those two SNACs are in the same rate class). | |
210 * | |
211 * Since the rate classes are defined dynamically at login, the values | |
212 * below may change. But they seem to be fairly constant. | |
213 * | |
214 * Currently, BOS defines five rate classes, with the commonly used | |
215 * members as follows... | |
216 * | |
217 * Rate class 0x0001: | |
218 * - Everything thats not in any of the other classes | |
219 * | |
220 * Rate class 0x0002: | |
221 * - Buddy list add/remove | |
222 * - Permit list add/remove | |
223 * - Deny list add/remove | |
224 * | |
225 * Rate class 0x0003: | |
226 * - User information requests | |
227 * - Outgoing ICBMs | |
228 * | |
229 * Rate class 0x0004: | |
230 * - A few unknowns: 2/9, 2/b, and f/2 | |
231 * | |
232 * Rate class 0x0005: | |
233 * - Chat room create | |
234 * - Outgoing chat ICBMs | |
235 * | |
236 * The only other thing of note is that class 5 (chat) has slightly looser | |
237 * limiting properties than class 3 (normal messages). But thats just a | |
238 * small bit of trivia for you. | |
239 * | |
240 * The last thing that needs to be learned about the rate limiting | |
241 * system is how the actual numbers relate to the passing of time. This | |
242 * seems to be a big mystery. | |
243 * | |
244 */ | |
245 | |
246 static void rc_addclass(struct rateclass **head, struct rateclass *inrc) | |
247 { | |
248 struct rateclass *rc, *rc2; | |
249 | |
250 if (!(rc = malloc(sizeof(struct rateclass)))) | |
251 return; | |
252 | |
253 memcpy(rc, inrc, sizeof(struct rateclass)); | |
254 rc->next = NULL; | |
255 | |
256 for (rc2 = *head; rc2 && rc2->next; rc2 = rc2->next) | |
257 ; | |
258 | |
259 if (!rc2) | |
260 *head = rc; | |
261 else | |
262 rc2->next = rc; | |
263 | |
264 return; | |
265 } | |
266 | |
267 static struct rateclass *rc_findclass(struct rateclass **head, fu16_t id) | |
268 { | |
269 struct rateclass *rc; | |
270 | |
271 for (rc = *head; rc; rc = rc->next) { | |
272 if (rc->classid == id) | |
273 return rc; | |
274 } | |
275 | |
276 return NULL; | |
277 } | |
278 | |
279 static void rc_addpair(struct rateclass *rc, fu16_t group, fu16_t type) | |
280 { | |
281 struct snacpair *sp, *sp2; | |
282 | |
283 if (!(sp = malloc(sizeof(struct snacpair)))) | |
284 return; | |
285 memset(sp, 0, sizeof(struct snacpair)); | |
286 | |
287 sp->group = group; | |
288 sp->subtype = type; | |
289 sp->next = NULL; | |
290 | |
291 for (sp2 = rc->members; sp2 && sp2->next; sp2 = sp2->next) | |
292 ; | |
293 | |
294 if (!sp2) | |
295 rc->members = sp; | |
296 else | |
297 sp2->next = sp; | |
298 | |
299 return; | |
300 } | |
301 | |
3952 | 302 /* Subtype 0x0007 - Rate Parameters */ |
2703 | 303 static int rateresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
304 { | |
305 aim_conn_inside_t *ins = (aim_conn_inside_t *)rx->conn->inside; | |
306 fu16_t numclasses, i; | |
307 aim_rxcallback_t userfunc; | |
308 | |
309 | |
310 /* | |
311 * First are the parameters for each rate class. | |
312 */ | |
313 numclasses = aimbs_get16(bs); | |
314 for (i = 0; i < numclasses; i++) { | |
315 struct rateclass rc; | |
316 | |
317 memset(&rc, 0, sizeof(struct rateclass)); | |
318 | |
319 rc.classid = aimbs_get16(bs); | |
320 rc.windowsize = aimbs_get32(bs); | |
321 rc.clear = aimbs_get32(bs); | |
322 rc.alert = aimbs_get32(bs); | |
323 rc.limit = aimbs_get32(bs); | |
324 rc.disconnect = aimbs_get32(bs); | |
325 rc.current = aimbs_get32(bs); | |
326 rc.max = aimbs_get32(bs); | |
327 | |
328 /* | |
329 * The server will send an extra five bytes of parameters | |
330 * depending on the version we advertised in 1/17. If we | |
331 * didn't send 1/17 (evil!), then this will crash and you | |
332 * die, as it will default to the old version but we have | |
333 * the new version hardcoded here. | |
334 */ | |
335 if (mod->version >= 3) | |
336 aimbs_getrawbuf(bs, rc.unknown, sizeof(rc.unknown)); | |
337 | |
11253 | 338 gaim_debug_misc("oscar", "--- Adding rate class %d to connection type %d: window size = %ld, clear = %ld, alert = %ld, limit = %ld, disconnect = %ld, current = %ld, max = %ld\n", rx->conn->type, rc.classid, rc.windowsize, rc.clear, rc.alert, rc.limit, rc.disconnect, rc.current, rc.max); |
2734
9fc65bb80596
[gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
339 |
2703 | 340 rc_addclass(&ins->rates, &rc); |
341 } | |
342 | |
343 /* | |
344 * Then the members of each class. | |
345 */ | |
346 for (i = 0; i < numclasses; i++) { | |
347 fu16_t classid, count; | |
348 struct rateclass *rc; | |
349 int j; | |
350 | |
351 classid = aimbs_get16(bs); | |
352 count = aimbs_get16(bs); | |
353 | |
354 rc = rc_findclass(&ins->rates, classid); | |
355 | |
356 for (j = 0; j < count; j++) { | |
357 fu16_t group, subtype; | |
358 | |
359 group = aimbs_get16(bs); | |
360 subtype = aimbs_get16(bs); | |
361 | |
362 if (rc) | |
363 rc_addpair(rc, group, subtype); | |
364 } | |
365 } | |
366 | |
367 /* | |
368 * We don't pass the rate information up to the client, as it really | |
369 * doesn't care. The information is stored in the connection, however | |
370 * so that we can do more fun stuff later (not really). | |
371 */ | |
372 | |
373 /* | |
374 * Last step in the conn init procedure is to acknowledge that we | |
375 * agree to these draconian limitations. | |
376 */ | |
377 aim_rates_addparam(sess, rx->conn); | |
378 | |
379 /* | |
380 * Finally, tell the client it's ready to go... | |
381 */ | |
382 if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE))) | |
383 userfunc(sess, rx); | |
384 | |
385 | |
386 return 1; | |
387 } | |
388 | |
3952 | 389 /* Subtype 0x0008 - Add Rate Parameter */ |
2703 | 390 faim_internal int aim_rates_addparam(aim_session_t *sess, aim_conn_t *conn) |
391 { | |
392 aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside; | |
10157 | 393 aim_frame_t *fr; |
2703 | 394 aim_snacid_t snacid; |
395 struct rateclass *rc; | |
396 | |
397 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512))) | |
10157 | 398 return -ENOMEM; |
2703 | 399 |
400 snacid = aim_cachesnac(sess, 0x0001, 0x0008, 0x0000, NULL, 0); | |
401 aim_putsnac(&fr->data, 0x0001, 0x0008, 0x0000, snacid); | |
402 | |
403 for (rc = ins->rates; rc; rc = rc->next) | |
404 aimbs_put16(&fr->data, rc->classid); | |
405 | |
406 aim_tx_enqueue(sess, fr); | |
407 | |
408 return 0; | |
409 } | |
410 | |
3952 | 411 /* Subtype 0x0009 - Delete Rate Parameter */ |
2703 | 412 faim_internal int aim_rates_delparam(aim_session_t *sess, aim_conn_t *conn) |
413 { | |
414 aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside; | |
10157 | 415 aim_frame_t *fr; |
2703 | 416 aim_snacid_t snacid; |
417 struct rateclass *rc; | |
418 | |
419 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512))) | |
10157 | 420 return -ENOMEM; |
2703 | 421 |
422 snacid = aim_cachesnac(sess, 0x0001, 0x0009, 0x0000, NULL, 0); | |
423 aim_putsnac(&fr->data, 0x0001, 0x0009, 0x0000, snacid); | |
424 | |
425 for (rc = ins->rates; rc; rc = rc->next) | |
426 aimbs_put16(&fr->data, rc->classid); | |
427 | |
428 aim_tx_enqueue(sess, fr); | |
429 | |
430 return 0; | |
431 } | |
432 | |
3952 | 433 /* Subtype 0x000a - Rate Change */ |
2703 | 434 static int ratechange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
435 { | |
4871 | 436 int ret = 0; |
2703 | 437 aim_rxcallback_t userfunc; |
438 fu16_t code, rateclass; | |
439 fu32_t currentavg, maxavg, windowsize, clear, alert, limit, disconnect; | |
440 | |
441 code = aimbs_get16(bs); | |
442 rateclass = aimbs_get16(bs); | |
10157 | 443 |
2703 | 444 windowsize = aimbs_get32(bs); |
445 clear = aimbs_get32(bs); | |
446 alert = aimbs_get32(bs); | |
447 limit = aimbs_get32(bs); | |
448 disconnect = aimbs_get32(bs); | |
449 currentavg = aimbs_get32(bs); | |
450 maxavg = aimbs_get32(bs); | |
451 | |
452 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
4871 | 453 ret = userfunc(sess, rx, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg, maxavg); |
2703 | 454 |
4871 | 455 return ret; |
2703 | 456 } |
457 | |
458 /* | |
3952 | 459 * How Migrations work. |
2703 | 460 * |
461 * The server sends a Server Pause message, which the client should respond to | |
462 * with a Server Pause Ack, which contains the families it needs on this | |
463 * connection. The server will send a Migration Notice with an IP address, and | |
464 * then disconnect. Next the client should open the connection and send the | |
465 * cookie. Repeat the normal login process and pretend this never happened. | |
466 * | |
467 * The Server Pause contains no data. | |
468 * | |
469 */ | |
470 | |
3952 | 471 /* Subtype 0x000b - Service Pause */ |
2703 | 472 static int serverpause(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
473 { | |
4871 | 474 int ret = 0; |
2703 | 475 aim_rxcallback_t userfunc; |
476 | |
477 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
4871 | 478 ret = userfunc(sess, rx); |
2703 | 479 |
4871 | 480 return ret; |
2703 | 481 } |
482 | |
483 /* | |
3952 | 484 * Subtype 0x000c - Service Pause Acknowledgement |
2703 | 485 * |
486 * It is rather important that aim_sendpauseack() gets called for the exact | |
487 * same connection that the Server Pause callback was called for, since | |
488 * libfaim extracts the data for the SNAC from the connection structure. | |
489 * | |
490 * Of course, if you don't do that, more bad things happen than just what | |
491 * libfaim can cause. | |
492 * | |
493 */ | |
494 faim_export int aim_sendpauseack(aim_session_t *sess, aim_conn_t *conn) | |
495 { | |
496 aim_frame_t *fr; | |
497 aim_snacid_t snacid; | |
498 aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside; | |
499 struct snacgroup *sg; | |
500 | |
501 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1024))) | |
502 return -ENOMEM; | |
503 | |
504 snacid = aim_cachesnac(sess, 0x0001, 0x000c, 0x0000, NULL, 0); | |
505 aim_putsnac(&fr->data, 0x0001, 0x000c, 0x0000, snacid); | |
506 | |
507 /* | |
508 * This list should have all the groups that the original | |
509 * Host Online / Server Ready said this host supports. And | |
510 * we want them all back after the migration. | |
511 */ | |
512 for (sg = ins->groups; sg; sg = sg->next) | |
513 aimbs_put16(&fr->data, sg->group); | |
514 | |
515 aim_tx_enqueue(sess, fr); | |
516 | |
517 return 0; | |
518 } | |
519 | |
3952 | 520 /* Subtype 0x000d - Service Resume */ |
2703 | 521 static int serverresume(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
522 { | |
4871 | 523 int ret = 0; |
2703 | 524 aim_rxcallback_t userfunc; |
525 | |
526 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
4871 | 527 ret = userfunc(sess, rx); |
2703 | 528 |
4871 | 529 return ret; |
2703 | 530 } |
531 | |
3952 | 532 /* Subtype 0x000e - Request self-info */ |
2703 | 533 faim_export int aim_reqpersonalinfo(aim_session_t *sess, aim_conn_t *conn) |
534 { | |
7282 | 535 return aim_genericreq_n_snacid(sess, conn, 0x0001, 0x000e); |
2703 | 536 } |
537 | |
3952 | 538 /* Subtype 0x000f - Self User Info */ |
2703 | 539 static int selfinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
540 { | |
4871 | 541 int ret = 0; |
2703 | 542 aim_rxcallback_t userfunc; |
543 aim_userinfo_t userinfo; | |
544 | |
5836 | 545 aim_info_extract(sess, bs, &userinfo); |
2703 | 546 |
547 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
4871 | 548 ret = userfunc(sess, rx, &userinfo); |
2703 | 549 |
5836 | 550 aim_info_free(&userinfo); |
551 | |
4871 | 552 return ret; |
2703 | 553 } |
554 | |
3952 | 555 /* Subtype 0x0010 - Evil Notification */ |
2703 | 556 static int evilnotify(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
557 { | |
4871 | 558 int ret = 0; |
2703 | 559 aim_rxcallback_t userfunc; |
560 fu16_t newevil; | |
561 aim_userinfo_t userinfo; | |
562 | |
563 memset(&userinfo, 0, sizeof(aim_userinfo_t)); | |
10157 | 564 |
2703 | 565 newevil = aimbs_get16(bs); |
566 | |
567 if (aim_bstream_empty(bs)) | |
5836 | 568 aim_info_extract(sess, bs, &userinfo); |
2703 | 569 |
570 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
4871 | 571 ret = userfunc(sess, rx, newevil, &userinfo); |
2703 | 572 |
5836 | 573 aim_info_free(&userinfo); |
574 | |
4871 | 575 return ret; |
2703 | 576 } |
577 | |
578 /* | |
3952 | 579 * Subtype 0x0011 - Idle Notification |
2703 | 580 * |
581 * Should set your current idle time in seconds. Note that this should | |
582 * never be called consecutively with a non-zero idle time. That makes | |
583 * OSCAR do funny things. Instead, just set it once you go idle, and then | |
584 * call it again with zero when you're back. | |
585 * | |
586 */ | |
7474 | 587 faim_export int aim_srv_setidle(aim_session_t *sess, fu32_t idletime) |
2703 | 588 { |
7474 | 589 aim_conn_t *conn; |
590 | |
7484 | 591 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_BOS))) |
7474 | 592 return -EINVAL; |
593 | |
2703 | 594 return aim_genericreq_l(sess, conn, 0x0001, 0x0011, &idletime); |
595 } | |
596 | |
597 /* | |
3952 | 598 * Subtype 0x0012 - Service Migrate |
2703 | 599 * |
600 * This is the final SNAC sent on the original connection during a migration. | |
601 * It contains the IP and cookie used to connect to the new server, and | |
602 * optionally a list of the SNAC groups being migrated. | |
603 * | |
604 */ | |
605 static int migrate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
606 { | |
607 aim_rxcallback_t userfunc; | |
608 int ret = 0; | |
609 fu16_t groupcount, i; | |
610 aim_tlvlist_t *tl; | |
611 char *ip = NULL; | |
612 aim_tlv_t *cktlv; | |
613 | |
614 /* | |
615 * Apparently there's some fun stuff that can happen right here. The | |
616 * migration can actually be quite selective about what groups it | |
617 * moves to the new server. When not all the groups for a connection | |
618 * are migrated, or they are all migrated but some groups are moved | |
619 * to a different server than others, it is called a bifurcated | |
620 * migration. | |
621 * | |
622 * Let's play dumb and not support that. | |
623 * | |
624 */ | |
625 groupcount = aimbs_get16(bs); | |
626 for (i = 0; i < groupcount; i++) { | |
627 fu16_t group; | |
628 | |
629 group = aimbs_get16(bs); | |
630 | |
11253 | 631 gaim_debug_misc("oscar", "bifurcated migration unsupported -- group 0x%04x\n", group); |
2703 | 632 } |
633 | |
7167 | 634 tl = aim_tlvlist_read(bs); |
2703 | 635 |
7167 | 636 if (aim_tlv_gettlv(tl, 0x0005, 1)) |
637 ip = aim_tlv_getstr(tl, 0x0005, 1); | |
2703 | 638 |
7167 | 639 cktlv = aim_tlv_gettlv(tl, 0x0006, 1); |
2703 | 640 |
641 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
642 ret = userfunc(sess, rx, ip, cktlv ? cktlv->value : NULL); | |
643 | |
7167 | 644 aim_tlvlist_free(&tl); |
2703 | 645 free(ip); |
646 | |
647 return ret; | |
648 } | |
649 | |
3952 | 650 /* Subtype 0x0013 - Message of the Day */ |
2703 | 651 static int motd(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
652 { | |
653 aim_rxcallback_t userfunc; | |
654 char *msg = NULL; | |
655 int ret = 0; | |
656 aim_tlvlist_t *tlvlist; | |
657 fu16_t id; | |
658 | |
659 /* | |
660 * Code. | |
661 * | |
662 * Valid values: | |
663 * 1 Mandatory upgrade | |
664 * 2 Advisory upgrade | |
665 * 3 System bulletin | |
666 * 4 Nothing's wrong ("top o the world" -- normal) | |
667 * 5 Lets-break-something. | |
668 * | |
669 */ | |
670 id = aimbs_get16(bs); | |
671 | |
672 /* | |
673 * TLVs follow | |
674 */ | |
7167 | 675 tlvlist = aim_tlvlist_read(bs); |
2703 | 676 |
7167 | 677 msg = aim_tlv_getstr(tlvlist, 0x000b, 1); |
2703 | 678 |
679 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
680 ret = userfunc(sess, rx, id, msg); | |
681 | |
682 free(msg); | |
683 | |
7167 | 684 aim_tlvlist_free(&tlvlist); |
2703 | 685 |
686 return ret; | |
687 } | |
688 | |
689 /* | |
3952 | 690 * Subtype 0x0014 - Set privacy flags |
2703 | 691 * |
692 * Normally 0x03. | |
693 * | |
694 * Bit 1: Allows other AIM users to see how long you've been idle. | |
695 * Bit 2: Allows other AIM users to see how long you've been a member. | |
696 * | |
697 */ | |
698 faim_export int aim_bos_setprivacyflags(aim_session_t *sess, aim_conn_t *conn, fu32_t flags) | |
699 { | |
700 return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags); | |
701 } | |
702 | |
703 /* | |
3952 | 704 * Subtype 0x0016 - No-op |
2703 | 705 * |
706 * WinAIM sends these every 4min or so to keep the connection alive. Its not | |
3952 | 707 * really necessary. |
2703 | 708 * |
7282 | 709 * Wha? No? Since when? I think WinAIM sends an empty channel 3 |
710 * SNAC as a no-op... | |
2703 | 711 */ |
712 faim_export int aim_nop(aim_session_t *sess, aim_conn_t *conn) | |
713 { | |
714 return aim_genericreq_n(sess, conn, 0x0001, 0x0016); | |
715 } | |
716 | |
717 /* | |
3952 | 718 * Subtype 0x0017 - Set client versions |
2703 | 719 * |
720 * If you've seen the clientonline/clientready SNAC you're probably | |
721 * wondering what the point of this one is. And that point seems to be | |
722 * that the versions in the client online SNAC are sent too late for the | |
723 * server to be able to use them to change the protocol for the earlier | |
724 * login packets (client versions are sent right after Host Online is | |
725 * received, but client online versions aren't sent until quite a bit later). | |
726 * We can see them already making use of this by changing the format of | |
727 * the rate information based on what version of group 1 we advertise here. | |
728 * | |
729 */ | |
730 faim_internal int aim_setversions(aim_session_t *sess, aim_conn_t *conn) | |
731 { | |
732 aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside; | |
733 struct snacgroup *sg; | |
734 aim_frame_t *fr; | |
735 aim_snacid_t snacid; | |
736 | |
737 if (!ins) | |
738 return -EINVAL; | |
739 | |
740 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) | |
741 return -ENOMEM; | |
742 | |
743 snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0); | |
744 aim_putsnac(&fr->data, 0x0001, 0x0017, 0x0000, snacid); | |
745 | |
746 /* | |
747 * Send only the versions that the server cares about (that it | |
748 * marked as supporting in the server ready SNAC). | |
749 */ | |
750 for (sg = ins->groups; sg; sg = sg->next) { | |
751 aim_module_t *mod; | |
752 | |
753 if ((mod = aim__findmodulebygroup(sess, sg->group))) { | |
754 aimbs_put16(&fr->data, mod->family); | |
755 aimbs_put16(&fr->data, mod->version); | |
756 } else | |
11253 | 757 gaim_debug_misc("oscar", "aim_setversions: server supports group 0x%04x but we don't!\n", sg->group); |
2703 | 758 } |
759 | |
760 aim_tx_enqueue(sess, fr); | |
761 | |
762 return 0; | |
763 } | |
764 | |
3952 | 765 /* Subtype 0x0018 - Host versions */ |
2703 | 766 static int hostversions(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
767 { | |
768 int vercount; | |
769 fu8_t *versions; | |
770 | |
771 /* This is frivolous. (Thank you SmarterChild.) */ | |
772 vercount = aim_bstream_empty(bs)/4; | |
773 versions = aimbs_getraw(bs, aim_bstream_empty(bs)); | |
774 free(versions); | |
775 | |
776 /* | |
777 * Now request rates. | |
778 */ | |
779 aim_reqrates(sess, rx->conn); | |
780 | |
781 return 1; | |
782 } | |
783 | |
784 /* | |
10560 | 785 * Subtype 0x001e - Set various account settings (mostly ICQ related). |
2703 | 786 * |
10560 | 787 * These settings are transient, not server-stored (i.e. they only |
788 * apply to this session, and must be re-set the next time you sign | |
789 * on). | |
790 * | |
791 * You can set your ICQ status (available, away, do not disturb, | |
792 * etc.), or whether your IP address should be hidden or not, or | |
793 * if your status is visible on ICQ web sites, and you can set | |
794 * your IP address info and what not. | |
2703 | 795 * |
12349 | 796 * These are the same TLVs seen in user info. You can |
4342 | 797 * also set 0x0008 and 0x000c. |
2703 | 798 */ |
4901 | 799 faim_export int aim_setextstatus(aim_session_t *sess, fu32_t status) |
2703 | 800 { |
4901 | 801 aim_conn_t *conn; |
2703 | 802 aim_frame_t *fr; |
803 aim_snacid_t snacid; | |
804 aim_tlvlist_t *tl = NULL; | |
805 fu32_t data; | |
806 | |
9879 | 807 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_MSG))) |
4901 | 808 return -EINVAL; |
809 | |
12610 | 810 data = AIM_ICQ_STATE_HIDEIP | AIM_ICQ_STATE_DIRECTREQUIREAUTH | status; |
2703 | 811 |
812 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 8))) | |
813 return -ENOMEM; | |
814 | |
815 snacid = aim_cachesnac(sess, 0x0001, 0x001e, 0x0000, NULL, 0); | |
816 aim_putsnac(&fr->data, 0x0001, 0x001e, 0x0000, snacid); | |
10157 | 817 |
7167 | 818 aim_tlvlist_add_32(&tl, 0x0006, data); |
10560 | 819 #if 0 |
820 aim_tlvlist_add_raw(&tl, 0x000c, 0x0025, chunk_of_x25_bytes_with_ip_address_etc); | |
821 aim_tlvlist_add_raw(&tl, 0x0011, 0x0005, unknown 0x01 61 10 f6 41); | |
822 aim_tlvlist_add_16(&tl, 0x0012, unknown 0x00 00); | |
823 #endif | |
7167 | 824 aim_tlvlist_write(&fr->data, &tl); |
825 aim_tlvlist_free(&tl); | |
10157 | 826 |
2703 | 827 aim_tx_enqueue(sess, fr); |
828 | |
829 return 0; | |
830 } | |
831 | |
12349 | 832 /* |
5917 | 833 * Subtype 0x001e - Extended Status. |
834 * | |
12349 | 835 * Sets your "available" message. This is currently only supported by iChat |
5917 | 836 * and Gaim. |
837 * | |
12349 | 838 * These are the same TLVs seen in user info. You can |
5917 | 839 * also set 0x0008 and 0x000c. |
840 */ | |
12349 | 841 faim_export int aim_srv_setstatusmsg(aim_session_t *sess, const char *msg) |
5917 | 842 { |
843 aim_conn_t *conn; | |
844 aim_frame_t *fr; | |
845 aim_snacid_t snacid; | |
846 | |
9879 | 847 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
5917 | 848 return -EINVAL; |
849 | |
11808 | 850 if ((msg != NULL) && *msg != '\0') { |
5948 | 851 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + strlen(msg) + 8))) |
5917 | 852 return -ENOMEM; |
853 | |
854 snacid = aim_cachesnac(sess, 0x0001, 0x001e, 0x0000, NULL, 0); | |
855 aim_putsnac(&fr->data, 0x0001, 0x001e, 0x0000, snacid); | |
856 | |
7141 | 857 aimbs_put16(&fr->data, 0x001d); /* userinfo TLV type */ |
858 aimbs_put16(&fr->data, strlen(msg)+8); /* total length of userinfo TLV data */ | |
5948 | 859 aimbs_put16(&fr->data, 0x0002); |
860 aimbs_put8(&fr->data, 0x04); | |
861 aimbs_put8(&fr->data, strlen(msg)+4); | |
862 aimbs_put16(&fr->data, strlen(msg)); | |
10990 | 863 aimbs_putstr(&fr->data, msg); |
5917 | 864 aimbs_put16(&fr->data, 0x0000); |
865 } else { | |
866 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + 8))) | |
867 return -ENOMEM; | |
868 | |
869 snacid = aim_cachesnac(sess, 0x0001, 0x001e, 0x0000, NULL, 0); | |
870 aim_putsnac(&fr->data, 0x0001, 0x001e, 0x0000, snacid); | |
871 | |
872 aimbs_put16(&fr->data, 0x001d); | |
873 aimbs_put16(&fr->data, 0x0008); | |
874 aimbs_put16(&fr->data, 0x0002); | |
875 aimbs_put16(&fr->data, 0x0404); | |
876 aimbs_put16(&fr->data, 0x0000); | |
877 aimbs_put16(&fr->data, 0x0000); | |
878 } | |
879 | |
880 aim_tx_enqueue(sess, fr); | |
881 | |
882 return 0; | |
883 } | |
884 | |
2703 | 885 /* |
886 * Starting this past week (26 Mar 2001, say), AOL has started sending | |
887 * this nice little extra SNAC. AFAIK, it has never been used until now. | |
888 * | |
889 * The request contains eight bytes. The first four are an offset, the | |
890 * second four are a length. | |
891 * | |
892 * The offset is an offset into aim.exe when it is mapped during execution | |
893 * on Win32. So far, AOL has only been requesting bytes in static regions | |
894 * of memory. (I won't put it past them to start requesting data in | |
895 * less static regions -- regions that are initialized at run time, but still | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8225
diff
changeset
|
896 * before the client receives this request.) |
2703 | 897 * |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8225
diff
changeset
|
898 * When the client receives the request, it adds it to the current ds |
2703 | 899 * (0x00400000) and dereferences it, copying the data into a buffer which |
900 * it then runs directly through the MD5 hasher. The 16 byte output of | |
901 * the hash is then sent back to the server. | |
902 * | |
903 * If the client does not send any data back, or the data does not match | |
904 * the data that the specific client should have, the client will get the | |
905 * following message from "AOL Instant Messenger": | |
906 * "You have been disconnected from the AOL Instant Message Service (SM) | |
907 * for accessing the AOL network using unauthorized software. You can | |
908 * download a FREE, fully featured, and authorized client, here | |
909 * http://www.aol.com/aim/download2.html" | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8225
diff
changeset
|
910 * The connection is then closed, receiving disconnect code 1, URL |
2703 | 911 * http://www.aim.aol.com/errors/USER_LOGGED_OFF_NEW_LOGIN.html. |
912 * | |
913 * Note, however, that numerous inconsistencies can cause the above error, | |
914 * not just sending back a bad hash. Do not immediatly suspect this code | |
915 * if you get disconnected. AOL and the open/free software community have | |
916 * played this game for a couple years now, generating the above message | |
917 * on numerous ocassions. | |
918 * | |
919 * Anyway, neener. We win again. | |
920 * | |
921 */ | |
3952 | 922 /* Subtype 0x001f - Client verification */ |
2703 | 923 static int memrequest(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
924 { | |
4871 | 925 int ret = 0; |
2703 | 926 aim_rxcallback_t userfunc; |
927 fu32_t offset, len; | |
928 aim_tlvlist_t *list; | |
929 char *modname; | |
930 | |
931 offset = aimbs_get32(bs); | |
932 len = aimbs_get32(bs); | |
7167 | 933 list = aim_tlvlist_read(bs); |
2703 | 934 |
7167 | 935 modname = aim_tlv_getstr(list, 0x0001, 1); |
2703 | 936 |
11253 | 937 gaim_debug_info("oscar", "Got memory request for data at 0x%08lx (%d bytes) of requested %s\n", offset, len, modname ? modname : "aim.exe"); |
2703 | 938 |
939 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
4871 | 940 ret = userfunc(sess, rx, offset, len, modname); |
2703 | 941 |
942 free(modname); | |
7167 | 943 aim_tlvlist_free(&list); |
2703 | 944 |
4871 | 945 return ret; |
2703 | 946 } |
947 | |
3952 | 948 /* Subtype 0x0020 - Client verification reply */ |
2703 | 949 faim_export int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, fu32_t offset, fu32_t len, const fu8_t *buf, fu8_t flag) |
950 { | |
951 aim_frame_t *fr; | |
952 aim_snacid_t snacid; | |
953 | |
954 if (!sess || !conn) | |
955 return -EINVAL; | |
956 | |
957 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+16))) | |
958 return -ENOMEM; | |
959 | |
960 snacid = aim_cachesnac(sess, 0x0001, 0x0020, 0x0000, NULL, 0); | |
961 | |
962 aim_putsnac(&fr->data, 0x0001, 0x0020, 0x0000, snacid); | |
963 aimbs_put16(&fr->data, 0x0010); /* md5 is always 16 bytes */ | |
964 | |
965 if ((flag == AIM_SENDMEMBLOCK_FLAG_ISHASH) && buf && (len == 0x10)) { /* we're getting a hash */ | |
966 | |
10157 | 967 aimbs_putraw(&fr->data, buf, 0x10); |
2703 | 968 |
969 } else if (buf && (len > 0)) { /* use input buffer */ | |
11404 | 970 GaimCipher *cipher; |
971 GaimCipherContext *context; | |
972 guchar digest[16]; | |
973 | |
974 cipher = gaim_ciphers_find_cipher("md5"); | |
2703 | 975 |
11404 | 976 context = gaim_cipher_context_new(cipher, NULL); |
977 gaim_cipher_context_append(context, buf, len); | |
978 gaim_cipher_context_digest(context, 16, digest, NULL); | |
979 gaim_cipher_context_destroy(context); | |
2703 | 980 |
11404 | 981 aimbs_putraw(&fr->data, digest, 0x10); |
2703 | 982 |
983 } else if (len == 0) { /* no length, just hash NULL (buf is optional) */ | |
11404 | 984 GaimCipher *cipher; |
985 GaimCipherContext *context; | |
986 guchar digest[16]; | |
2703 | 987 fu8_t nil = '\0'; |
988 | |
989 /* | |
11404 | 990 * I'm not sure if we really need the empty append with the |
991 * new MD5 functions, so I'll leave it in, just in case. | |
2703 | 992 */ |
11404 | 993 cipher = gaim_ciphers_find_cipher("md5"); |
2703 | 994 |
11404 | 995 context = gaim_cipher_context_new(cipher, NULL); |
996 gaim_cipher_context_append(context, &nil, 0); | |
997 gaim_cipher_context_digest(context, 16, digest, NULL); | |
998 gaim_cipher_context_destroy(context); | |
999 | |
1000 aimbs_putraw(&fr->data, digest, 0x10); | |
2703 | 1001 |
1002 } else { | |
1003 | |
11404 | 1004 /* |
2703 | 1005 * This data is correct for AIM 3.5.1670. |
1006 * | |
1007 * Using these blocks is as close to "legal" as you can get | |
1008 * without using an AIM binary. | |
1009 * | |
1010 */ | |
1011 if ((offset == 0x03ffffff) && (len == 0x03ffffff)) { | |
1012 | |
1013 #if 1 /* with "AnrbnrAqhfzcd" */ | |
1014 aimbs_put32(&fr->data, 0x44a95d26); | |
1015 aimbs_put32(&fr->data, 0xd2490423); | |
1016 aimbs_put32(&fr->data, 0x93b8821f); | |
1017 aimbs_put32(&fr->data, 0x51c54b01); | |
1018 #else /* no filename */ | |
1019 aimbs_put32(&fr->data, 0x1df8cbae); | |
1020 aimbs_put32(&fr->data, 0x5523b839); | |
1021 aimbs_put32(&fr->data, 0xa0e10db3); | |
1022 aimbs_put32(&fr->data, 0xa46d3b39); | |
1023 #endif | |
1024 | |
1025 } else if ((offset == 0x00001000) && (len == 0x00000000)) { | |
1026 | |
1027 aimbs_put32(&fr->data, 0xd41d8cd9); | |
1028 aimbs_put32(&fr->data, 0x8f00b204); | |
1029 aimbs_put32(&fr->data, 0xe9800998); | |
1030 aimbs_put32(&fr->data, 0xecf8427e); | |
1031 | |
1032 } else | |
11253 | 1033 gaim_debug_warning("oscar", "sendmemblock: unknown hash request\n"); |
2703 | 1034 |
1035 } | |
1036 | |
1037 aim_tx_enqueue(sess, fr); | |
1038 | |
1039 return 0; | |
1040 } | |
1041 | |
5836 | 1042 /* |
1043 * Subtype 0x0021 - Receive our extended status | |
1044 * | |
11253 | 1045 * This is used for iChat's "available" messages, and maybe ICQ extended |
1046 * status messages? It's also used to tell the client whether or not it | |
5892 | 1047 * needs to upload an SSI buddy icon... who engineers this stuff, anyway? |
5836 | 1048 */ |
1049 static int aim_parse_extstatus(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
1050 { | |
5892 | 1051 int ret = 0; |
5836 | 1052 aim_rxcallback_t userfunc; |
5837 | 1053 fu16_t type; |
5892 | 1054 fu8_t flags, length; |
5836 | 1055 |
10157 | 1056 type = aimbs_get16(bs); |
5892 | 1057 flags = aimbs_get8(bs); |
1058 length = aimbs_get8(bs); | |
1059 | |
5842 | 1060 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { |
1061 switch (type) { | |
5892 | 1062 case 0x0000: |
6101 | 1063 case 0x0001: { /* buddy icon checksum */ |
1064 /* not sure what the difference between 1 and 0 is */ | |
5892 | 1065 fu8_t *md5 = aimbs_getraw(bs, length); |
1066 ret = userfunc(sess, rx, type, flags, length, md5); | |
5842 | 1067 free(md5); |
5892 | 1068 } break; |
6101 | 1069 case 0x0002: { /* available message */ |
5892 | 1070 /* there is a second length that is just for the message */ |
1071 char *msg = aimbs_getstr(bs, aimbs_get16(bs)); | |
5842 | 1072 ret = userfunc(sess, rx, msg); |
1073 free(msg); | |
5892 | 1074 } break; |
5842 | 1075 } |
5871 | 1076 } |
5917 | 1077 |
1078 return ret; | |
5836 | 1079 } |
1080 | |
2703 | 1081 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
1082 { | |
1083 | |
1084 if (snac->subtype == 0x0003) | |
1085 return hostonline(sess, mod, rx, snac, bs); | |
1086 else if (snac->subtype == 0x0005) | |
1087 return redirect(sess, mod, rx, snac, bs); | |
1088 else if (snac->subtype == 0x0007) | |
1089 return rateresp(sess, mod, rx, snac, bs); | |
1090 else if (snac->subtype == 0x000a) | |
1091 return ratechange(sess, mod, rx, snac, bs); | |
1092 else if (snac->subtype == 0x000b) | |
1093 return serverpause(sess, mod, rx, snac, bs); | |
1094 else if (snac->subtype == 0x000d) | |
1095 return serverresume(sess, mod, rx, snac, bs); | |
1096 else if (snac->subtype == 0x000f) | |
1097 return selfinfo(sess, mod, rx, snac, bs); | |
1098 else if (snac->subtype == 0x0010) | |
1099 return evilnotify(sess, mod, rx, snac, bs); | |
1100 else if (snac->subtype == 0x0012) | |
1101 return migrate(sess, mod, rx, snac, bs); | |
1102 else if (snac->subtype == 0x0013) | |
1103 return motd(sess, mod, rx, snac, bs); | |
1104 else if (snac->subtype == 0x0018) | |
1105 return hostversions(sess, mod, rx, snac, bs); | |
1106 else if (snac->subtype == 0x001f) | |
1107 return memrequest(sess, mod, rx, snac, bs); | |
5836 | 1108 else if (snac->subtype == 0x0021) |
1109 return aim_parse_extstatus(sess, mod, rx, snac, bs); | |
2703 | 1110 |
1111 return 0; | |
1112 } | |
1113 | |
7474 | 1114 faim_internal int service_modfirst(aim_session_t *sess, aim_module_t *mod) |
2703 | 1115 { |
1116 | |
1117 mod->family = 0x0001; | |
1118 mod->version = 0x0003; | |
1119 mod->toolid = 0x0110; | |
4071 | 1120 mod->toolversion = 0x0629; |
2703 | 1121 mod->flags = 0; |
7474 | 1122 strncpy(mod->name, "service", sizeof(mod->name)); |
2703 | 1123 mod->snachandler = snachandler; |
1124 | |
1125 return 0; | |
1126 } |