source: protocols/oscar/service.c @ e11216c

Last change on this file since e11216c was 5ebff60, checked in by dequis <dx@…>, at 2015-02-20T22:50:54Z

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

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