source: protocols/oscar/service.c @ 11e7828

Last change on this file since 11e7828 was 6042a54, checked in by Wilmer van der Gaast <wilmer@…>, at 2012-10-19T23:38:33Z

Massive cleanup in OSCAR.

  • Property mode set to 100644
File size: 20.8 KB
Line 
1/*
2 * Group 1.  This is a very special group.  All connections support
3 * this group, as it does some particularly good things (like rate limiting).
4 */
5
6#include <aim.h>
7
8#include "md5.h"
9
10/* Client Online (group 1, subtype 2) */
11int aim_clientready(aim_session_t *sess, aim_conn_t *conn)
12{
13        aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
14        struct snacgroup *sg;
15        aim_frame_t *fr;
16        aim_snacid_t snacid;
17
18        if (!ins)
19                return -EINVAL;
20
21        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
22                return -ENOMEM;
23
24        snacid = aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
25        aim_putsnac(&fr->data, 0x0001, 0x0002, 0x0000, snacid);
26
27        /*
28         * Send only the tool versions that the server cares about (that it
29         * marked as supporting in the server ready SNAC). 
30         */
31        for (sg = ins->groups; sg; sg = sg->next) {
32                aim_module_t *mod;
33
34                if ((mod = aim__findmodulebygroup(sess, sg->group))) {
35                        aimbs_put16(&fr->data, mod->family);
36                        aimbs_put16(&fr->data, mod->version);
37                        aimbs_put16(&fr->data, mod->toolid);
38                        aimbs_put16(&fr->data, mod->toolversion);
39                } 
40        }
41
42        aim_tx_enqueue(sess, fr);
43
44        return 0;
45}
46
47/*
48 * Host Online (group 1, type 3)
49 *
50 * See comments in conn.c about how the group associations are supposed
51 * to work, and how they really work.
52 *
53 * This info probably doesn't even need to make it to the client.
54 *
55 * We don't actually call the client here.  This starts off the connection
56 * initialization routine required by all AIM connections.  The next time
57 * the client is called is the CONNINITDONE callback, which should be
58 * shortly after the rate information is acknowledged.
59 *
60 */
61static int hostonline(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
62{
63        guint16 *families;
64        int famcount;
65
66
67        if (!(families = g_malloc(aim_bstream_empty(bs))))
68                return 0;
69
70        for (famcount = 0; aim_bstream_empty(bs); famcount++) {
71                families[famcount] = aimbs_get16(bs);
72                aim_conn_addgroup(rx->conn, families[famcount]);
73        }
74
75        g_free(families);
76
77
78        /*
79         * Next step is in the Host Versions handler.
80         *
81         * Note that we must send this before we request rates, since
82         * the format of the rate information depends on the versions we
83         * give it.
84         *
85         */
86        aim_setversions(sess, rx->conn);
87
88        return 1; 
89}
90
91/* Service request (group 1, type 4) */
92int aim_reqservice(aim_session_t *sess, aim_conn_t *conn, guint16 serviceid)
93{
94        return aim_genericreq_s(sess, conn, 0x0001, 0x0004, &serviceid);
95}
96
97/* Redirect (group 1, type 5) */
98static int redirect(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
99{
100        struct aim_redirect_data redir;
101        aim_rxcallback_t userfunc;
102        aim_tlvlist_t *tlvlist;
103        aim_snac_t *origsnac = NULL;
104        int ret = 0;
105
106        memset(&redir, 0, sizeof(redir));
107
108        tlvlist = aim_readtlvchain(bs);
109
110        if (!aim_gettlv(tlvlist, 0x000d, 1) ||
111                        !aim_gettlv(tlvlist, 0x0005, 1) ||
112                        !aim_gettlv(tlvlist, 0x0006, 1)) {
113                aim_freetlvchain(&tlvlist);
114                return 0;
115        }
116
117        redir.group = aim_gettlv16(tlvlist, 0x000d, 1);
118        redir.ip = aim_gettlv_str(tlvlist, 0x0005, 1);
119        redir.cookie = (guint8 *)aim_gettlv_str(tlvlist, 0x0006, 1);
120
121        /* Fetch original SNAC so we can get csi if needed */
122        origsnac = aim_remsnac(sess, snac->id);
123
124        if ((redir.group == AIM_CONN_TYPE_CHAT) && origsnac) {
125                struct chatsnacinfo *csi = (struct chatsnacinfo *)origsnac->data;
126
127                redir.chat.exchange = csi->exchange;
128                redir.chat.room = csi->name;
129                redir.chat.instance = csi->instance;
130        }
131
132        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
133                ret = userfunc(sess, rx, &redir);
134
135        g_free((void *)redir.ip);
136        g_free((void *)redir.cookie);
137
138        if (origsnac)
139                g_free(origsnac->data);
140        g_free(origsnac);
141
142        aim_freetlvchain(&tlvlist);
143
144        return ret;
145}
146
147/* Request Rate Information. (group 1, type 6) */
148int aim_reqrates(aim_session_t *sess, aim_conn_t *conn)
149{
150        return aim_genericreq_n(sess, conn, 0x0001, 0x0006);
151}
152
153/*
154 * OSCAR defines several 'rate classes'.  Each class has seperate
155 * rate limiting properties (limit level, alert level, disconnect
156 * level, etc), and a set of SNAC family/type pairs associated with
157 * it.  The rate classes, their limiting properties, and the definitions
158 * of which SNACs are belong to which class, are defined in the
159 * Rate Response packet at login to each host. 
160 *
161 * Logically, all rate offenses within one class count against further
162 * offenses for other SNACs in the same class (ie, sending messages
163 * too fast will limit the number of user info requests you can send,
164 * since those two SNACs are in the same rate class).
165 *
166 * Since the rate classes are defined dynamically at login, the values
167 * below may change. But they seem to be fairly constant.
168 *
169 * Currently, BOS defines five rate classes, with the commonly used
170 * members as follows...
171 *
172 *  Rate class 0x0001:
173 *      - Everything thats not in any of the other classes
174 *
175 *  Rate class 0x0002:
176 *      - Buddy list add/remove
177 *      - Permit list add/remove
178 *      - Deny list add/remove
179 *
180 *  Rate class 0x0003:
181 *      - User information requests
182 *      - Outgoing ICBMs
183 *
184 *  Rate class 0x0004:
185 *      - A few unknowns: 2/9, 2/b, and f/2
186 *
187 *  Rate class 0x0005:
188 *      - Chat room create
189 *      - Outgoing chat ICBMs
190 *
191 * The only other thing of note is that class 5 (chat) has slightly looser
192 * limiting properties than class 3 (normal messages).  But thats just a
193 * small bit of trivia for you.
194 *
195 * The last thing that needs to be learned about the rate limiting
196 * system is how the actual numbers relate to the passing of time.  This
197 * seems to be a big mystery.
198 *
199 */
200
201static void rc_addclass(struct rateclass **head, struct rateclass *inrc)
202{
203        struct rateclass *rc, *rc2;
204
205        if (!(rc = g_malloc(sizeof(struct rateclass))))
206                return;
207
208        memcpy(rc, inrc, sizeof(struct rateclass));
209        rc->next = NULL;
210
211        for (rc2 = *head; rc2 && rc2->next; rc2 = rc2->next)
212                ;
213
214        if (!rc2)
215                *head = rc;
216        else
217                rc2->next = rc;
218
219        return;
220}
221
222static struct rateclass *rc_findclass(struct rateclass **head, guint16 id)
223{
224        struct rateclass *rc;
225
226        for (rc = *head; rc; rc = rc->next) {
227                if (rc->classid == id)
228                        return rc;
229        }
230
231        return NULL;
232}
233
234static void rc_addpair(struct rateclass *rc, guint16 group, guint16 type)
235{
236        struct snacpair *sp, *sp2;
237
238        if (!(sp = g_new0(struct snacpair, 1)))
239                return;
240
241        sp->group = group;
242        sp->subtype = type;
243        sp->next = NULL;
244
245        for (sp2 = rc->members; sp2 && sp2->next; sp2 = sp2->next)
246                ;
247
248        if (!sp2)
249                rc->members = sp;
250        else
251                sp2->next = sp;
252
253        return;
254}
255
256/* Rate Parameters (group 1, type 7) */
257static int rateresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
258{
259        aim_conn_inside_t *ins = (aim_conn_inside_t *)rx->conn->inside;
260        guint16 numclasses, i;
261        aim_rxcallback_t userfunc;
262
263
264        /*
265         * First are the parameters for each rate class.
266         */
267        numclasses = aimbs_get16(bs);
268        for (i = 0; i < numclasses; i++) {
269                struct rateclass rc;
270
271                memset(&rc, 0, sizeof(struct rateclass));
272
273                rc.classid = aimbs_get16(bs);
274                rc.windowsize = aimbs_get32(bs);
275                rc.clear = aimbs_get32(bs);
276                rc.alert = aimbs_get32(bs);
277                rc.limit = aimbs_get32(bs);
278                rc.disconnect = aimbs_get32(bs);
279                rc.current = aimbs_get32(bs);
280                rc.max = aimbs_get32(bs);
281
282                /*
283                 * The server will send an extra five bytes of parameters
284                 * depending on the version we advertised in 1/17.  If we
285                 * didn't send 1/17 (evil!), then this will crash and you
286                 * die, as it will default to the old version but we have
287                 * the new version hardcoded here.
288                 */
289                if (mod->version >= 3)
290                        aimbs_getrawbuf(bs, rc.unknown, sizeof(rc.unknown));
291
292                rc_addclass(&ins->rates, &rc);
293        }
294
295        /*
296         * Then the members of each class.
297         */
298        for (i = 0; i < numclasses; i++) {
299                guint16 classid, count;
300                struct rateclass *rc;
301                int j;
302
303                classid = aimbs_get16(bs);
304                count = aimbs_get16(bs);
305
306                rc = rc_findclass(&ins->rates, classid);
307
308                for (j = 0; j < count; j++) {
309                        guint16 group, subtype;
310
311                        group = aimbs_get16(bs);
312                        subtype = aimbs_get16(bs);
313
314                        if (rc)
315                                rc_addpair(rc, group, subtype);
316                }
317        }
318
319        /*
320         * We don't pass the rate information up to the client, as it really
321         * doesn't care.  The information is stored in the connection, however
322         * so that we can do more fun stuff later (not really).
323         */
324
325        /*
326         * Last step in the conn init procedure is to acknowledge that we
327         * agree to these draconian limitations.
328         */
329        aim_rates_addparam(sess, rx->conn);
330
331        /*
332         * Finally, tell the client it's ready to go...
333         */
334        if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE)))
335                userfunc(sess, rx);
336
337
338        return 1;
339}
340
341/* Add Rate Parameter (group 1, type 8) */
342int aim_rates_addparam(aim_session_t *sess, aim_conn_t *conn)
343{
344        aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
345        aim_frame_t *fr;       
346        aim_snacid_t snacid;
347        struct rateclass *rc;
348
349        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512)))
350                return -ENOMEM; 
351
352        snacid = aim_cachesnac(sess, 0x0001, 0x0008, 0x0000, NULL, 0);
353        aim_putsnac(&fr->data, 0x0001, 0x0008, 0x0000, snacid);
354
355        for (rc = ins->rates; rc; rc = rc->next)
356                aimbs_put16(&fr->data, rc->classid);
357
358        aim_tx_enqueue(sess, fr);
359
360        return 0;
361}
362
363/* Rate Change (group 1, type 0x0a) */
364static int ratechange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
365{
366        aim_rxcallback_t userfunc;
367        guint16 code, rateclass;
368        guint32 currentavg, maxavg, windowsize, clear, alert, limit, disconnect;
369
370        code = aimbs_get16(bs);
371        rateclass = aimbs_get16(bs);
372       
373        windowsize = aimbs_get32(bs);
374        clear = aimbs_get32(bs);
375        alert = aimbs_get32(bs);
376        limit = aimbs_get32(bs);
377        disconnect = aimbs_get32(bs);
378        currentavg = aimbs_get32(bs);
379        maxavg = aimbs_get32(bs);
380
381        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
382                return userfunc(sess, rx, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg, maxavg);
383
384        return 0;
385}
386
387/*
388 * How Migrations work. 
389 *
390 * The server sends a Server Pause message, which the client should respond to
391 * with a Server Pause Ack, which contains the families it needs on this
392 * connection. The server will send a Migration Notice with an IP address, and
393 * then disconnect. Next the client should open the connection and send the
394 * cookie.  Repeat the normal login process and pretend this never happened.
395 *
396 * The Server Pause contains no data.
397 *
398 */
399
400/* Service Pause (group 1, type 0x0b) */
401static int serverpause(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
402{
403        aim_rxcallback_t userfunc;
404
405        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
406                return userfunc(sess, rx);
407
408        return 0;
409}
410
411/* Service Resume (group 1, type 0x0d) */
412static int serverresume(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
413{
414        aim_rxcallback_t userfunc;
415
416        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
417                return userfunc(sess, rx);
418
419        return 0;
420}
421
422/* Request self-info (group 1, type 0x0e) */
423int aim_reqpersonalinfo(aim_session_t *sess, aim_conn_t *conn)
424{
425        return aim_genericreq_n(sess, conn, 0x0001, 0x000e);
426}
427
428/* Self User Info (group 1, type 0x0f) */
429static int selfinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
430{
431        aim_rxcallback_t userfunc;
432        aim_userinfo_t userinfo;
433
434        aim_extractuserinfo(sess, bs, &userinfo);
435
436        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
437                return userfunc(sess, rx, &userinfo);
438
439        return 0;
440}
441
442/* Evil Notification (group 1, type 0x10) */
443static int evilnotify(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
444{
445        aim_rxcallback_t userfunc;
446        guint16 newevil;
447        aim_userinfo_t userinfo;
448
449        memset(&userinfo, 0, sizeof(aim_userinfo_t));
450       
451        newevil = aimbs_get16(bs);
452
453        if (aim_bstream_empty(bs))
454                aim_extractuserinfo(sess, bs, &userinfo);
455
456        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
457                return userfunc(sess, rx, newevil, &userinfo);
458
459        return 0;
460}
461
462/*
463 * Service Migrate (group 1, type 0x12)
464 *
465 * This is the final SNAC sent on the original connection during a migration.
466 * It contains the IP and cookie used to connect to the new server, and
467 * optionally a list of the SNAC groups being migrated.
468 *
469 */
470static int migrate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
471{
472        aim_rxcallback_t userfunc;
473        int ret = 0;
474        guint16 groupcount, i;
475        aim_tlvlist_t *tl;
476        char *ip = NULL;
477        aim_tlv_t *cktlv;
478
479        /*
480         * Apparently there's some fun stuff that can happen right here. The
481         * migration can actually be quite selective about what groups it
482         * moves to the new server.  When not all the groups for a connection
483         * are migrated, or they are all migrated but some groups are moved
484         * to a different server than others, it is called a bifurcated
485         * migration.
486         *
487         * Let's play dumb and not support that.
488         *
489         */
490        groupcount = aimbs_get16(bs);
491        for (i = 0; i < groupcount; i++) {
492                aimbs_get16(bs);
493
494                imcb_error(sess->aux_data, "bifurcated migration unsupported");
495        }
496
497        tl = aim_readtlvchain(bs);
498
499        if (aim_gettlv(tl, 0x0005, 1))
500                ip = aim_gettlv_str(tl, 0x0005, 1);
501
502        cktlv = aim_gettlv(tl, 0x0006, 1);
503
504        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
505                ret = userfunc(sess, rx, ip, cktlv ? cktlv->value : NULL);
506
507        aim_freetlvchain(&tl);
508        g_free(ip);
509
510        return ret;
511}
512
513/* Message of the Day (group 1, type 0x13) */
514static int motd(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
515{
516        aim_rxcallback_t userfunc;
517        char *msg = NULL;
518        int ret = 0;
519        aim_tlvlist_t *tlvlist;
520        guint16 id;
521
522        /*
523         * Code.
524         *
525         * Valid values:
526         *   1 Mandatory upgrade
527         *   2 Advisory upgrade
528         *   3 System bulletin
529         *   4 Nothing's wrong ("top o the world" -- normal)
530         *   5 Lets-break-something.
531         *
532         */
533        id = aimbs_get16(bs);
534
535        /*
536         * TLVs follow
537         */
538        tlvlist = aim_readtlvchain(bs);
539
540        msg = aim_gettlv_str(tlvlist, 0x000b, 1);
541
542        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
543                ret = userfunc(sess, rx, id, msg);
544
545        g_free(msg);
546
547        aim_freetlvchain(&tlvlist);
548
549        return ret;
550}
551
552/*
553 * Set privacy flags (group 1, type 0x14)
554 *
555 * Normally 0x03.
556 *
557 *  Bit 1:  Allows other AIM users to see how long you've been idle.
558 *  Bit 2:  Allows other AIM users to see how long you've been a member.
559 *
560 */
561int aim_bos_setprivacyflags(aim_session_t *sess, aim_conn_t *conn, guint32 flags)
562{
563        return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags);
564}
565
566
567/*
568 * Set client versions (group 1, subtype 0x17)
569 *
570 * If you've seen the clientonline/clientready SNAC you're probably
571 * wondering what the point of this one is.  And that point seems to be
572 * that the versions in the client online SNAC are sent too late for the
573 * server to be able to use them to change the protocol for the earlier
574 * login packets (client versions are sent right after Host Online is
575 * received, but client online versions aren't sent until quite a bit later).
576 * We can see them already making use of this by changing the format of
577 * the rate information based on what version of group 1 we advertise here.
578 *
579 */
580int aim_setversions(aim_session_t *sess, aim_conn_t *conn)
581{
582        aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
583        struct snacgroup *sg;
584        aim_frame_t *fr;
585        aim_snacid_t snacid;
586
587        if (!ins)
588                return -EINVAL;
589
590        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
591                return -ENOMEM;
592
593        snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
594        aim_putsnac(&fr->data, 0x0001, 0x0017, 0x0000, snacid);
595
596        /*
597         * Send only the versions that the server cares about (that it
598         * marked as supporting in the server ready SNAC). 
599         */
600        for (sg = ins->groups; sg; sg = sg->next) {
601                aim_module_t *mod;
602
603                if ((mod = aim__findmodulebygroup(sess, sg->group))) {
604                        aimbs_put16(&fr->data, mod->family);
605                        aimbs_put16(&fr->data, mod->version);
606                }
607        }
608
609        aim_tx_enqueue(sess, fr);
610
611        return 0;
612}
613
614/* Host versions (group 1, subtype 0x18) */
615static int hostversions(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
616{
617        guint8 *versions;
618
619        /* This is frivolous. (Thank you SmarterChild.) */
620        aim_bstream_empty(bs); /* == vercount * 4 */
621        versions = aimbs_getraw(bs, aim_bstream_empty(bs));
622        g_free(versions);
623
624        /*
625         * Now request rates.
626         */
627        aim_reqrates(sess, rx->conn);
628
629        return 1;
630}
631
632/*
633 * Subtype 0x001e - Extended Status
634 *
635 * Sets your ICQ status (available, away, do not disturb, etc.)
636 *
637 * These are the same TLVs seen in user info.  You can
638 * also set 0x0008 and 0x000c.
639 */
640int aim_setextstatus(aim_session_t *sess, aim_conn_t *conn, guint32 status)
641{
642        aim_frame_t *fr;
643        aim_snacid_t snacid;
644        aim_tlvlist_t *tl = NULL;
645        guint32 data;
646        struct im_connection *ic = sess ? sess->aux_data : NULL;
647
648        data = AIM_ICQ_STATE_HIDEIP | status; /* yay for error checking ;^) */
649       
650        if (ic && set_getbool(&ic->acc->set, "web_aware"))
651                data |= AIM_ICQ_STATE_WEBAWARE;
652
653        aim_addtlvtochain32(&tl, 0x0006, data); /* tlvlen */
654
655        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 8)))
656                return -ENOMEM;
657
658        snacid = aim_cachesnac(sess, 0x0001, 0x001e, 0x0000, NULL, 0);
659        aim_putsnac(&fr->data, 0x0001, 0x001e, 0x0000, snacid);
660       
661        aim_writetlvchain(&fr->data, &tl);
662        aim_freetlvchain(&tl);
663       
664        aim_tx_enqueue(sess, fr);
665
666        return 0;
667}
668
669/*
670 * Starting this past week (26 Mar 2001, say), AOL has started sending
671 * this nice little extra SNAC.  AFAIK, it has never been used until now.
672 *
673 * The request contains eight bytes.  The first four are an offset, the
674 * second four are a length.
675 *
676 * The offset is an offset into aim.exe when it is mapped during execution
677 * on Win32.  So far, AOL has only been requesting bytes in static regions
678 * of memory.  (I won't put it past them to start requesting data in
679 * less static regions -- regions that are initialized at run time, but still
680 * before the client recieves this request.)
681 *
682 * When the client recieves the request, it adds it to the current ds
683 * (0x00400000) and dereferences it, copying the data into a buffer which
684 * it then runs directly through the MD5 hasher.  The 16 byte output of
685 * the hash is then sent back to the server.
686 *
687 * If the client does not send any data back, or the data does not match
688 * the data that the specific client should have, the client will get the
689 * following message from "AOL Instant Messenger":
690 *    "You have been disconnected from the AOL Instant Message Service (SM)
691 *     for accessing the AOL network using unauthorized software.  You can
692 *     download a FREE, fully featured, and authorized client, here
693 *     http://www.aol.com/aim/download2.html"
694 * The connection is then closed, recieving disconnect code 1, URL
695 * http://www.aim.aol.com/errors/USER_LOGGED_OFF_NEW_LOGIN.html. 
696 *
697 * Note, however, that numerous inconsistencies can cause the above error,
698 * not just sending back a bad hash.  Do not immediatly suspect this code
699 * if you get disconnected.  AOL and the open/free software community have
700 * played this game for a couple years now, generating the above message
701 * on numerous ocassions.
702 *
703 * Anyway, neener.  We win again.
704 *
705 */
706/* Client verification (group 1, subtype 0x1f) */
707static int memrequest(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
708{
709        aim_rxcallback_t userfunc;
710        guint32 offset, len;
711        aim_tlvlist_t *list;
712        char *modname;
713
714        offset = aimbs_get32(bs);
715        len = aimbs_get32(bs);
716        list = aim_readtlvchain(bs);
717
718        modname = aim_gettlv_str(list, 0x0001, 1);
719
720        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
721                return userfunc(sess, rx, offset, len, modname);
722
723        g_free(modname);
724        aim_freetlvchain(&list);
725
726        return 0;
727}
728
729static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
730{
731
732        if (snac->subtype == 0x0003)
733                return hostonline(sess, mod, rx, snac, bs);
734        else if (snac->subtype == 0x0005)
735                return redirect(sess, mod, rx, snac, bs);
736        else if (snac->subtype == 0x0007)
737                return rateresp(sess, mod, rx, snac, bs);
738        else if (snac->subtype == 0x000a)
739                return ratechange(sess, mod, rx, snac, bs);
740        else if (snac->subtype == 0x000b)
741                return serverpause(sess, mod, rx, snac, bs);
742        else if (snac->subtype == 0x000d)
743                return serverresume(sess, mod, rx, snac, bs);
744        else if (snac->subtype == 0x000f)
745                return selfinfo(sess, mod, rx, snac, bs);
746        else if (snac->subtype == 0x0010)
747                return evilnotify(sess, mod, rx, snac, bs);
748        else if (snac->subtype == 0x0012)
749                return migrate(sess, mod, rx, snac, bs);
750        else if (snac->subtype == 0x0013)
751                return motd(sess, mod, rx, snac, bs);
752        else if (snac->subtype == 0x0018)
753                return hostversions(sess, mod, rx, snac, bs);
754        else if (snac->subtype == 0x001f)
755                return memrequest(sess, mod, rx, snac, bs);
756
757        return 0;
758}
759
760int general_modfirst(aim_session_t *sess, aim_module_t *mod)
761{
762
763        mod->family = 0x0001;
764        mod->version = 0x0003;
765        mod->toolid = 0x0110;
766        mod->toolversion = 0x0629;
767        mod->flags = 0;
768        strncpy(mod->name, "general", sizeof(mod->name));
769        mod->snachandler = snachandler;
770
771        return 0;
772}
773
Note: See TracBrowser for help on using the repository browser.