Changeset cf02dd6 for libfaim/im.c


Ignore:
Timestamp:
Dec 10, 2003, 3:20:45 PM (20 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
b1fe407
Parents:
8c46404
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfaim/im.c

    re374dee rcf02dd6  
    167167                return -EINVAL;
    168168
    169         return aim_genericreq_n(sess, conn, 0x0004, 0x0004);
     169        return aim_genericreq_n_snacid(sess, conn, 0x0004, 0x0004);
    170170}
    171171
     
    390390        aim_tx_enqueue(sess, fr);
    391391
    392         /* Move this to receive aim_flap_nop and send aim_flap_nop */
    393         if (!(sess->flags & AIM_SESS_FLAGS_DONTTIMEOUTONICBM))
    394                 aim_cleansnacs(sess, 60); /* clean out SNACs over 60sec old */
     392        /* clean out SNACs over 60sec old */
     393        aim_cleansnacs(sess, 60);
    395394
    396395        return 0;
     
    633632        aim_im_puticbm(&fr->data, ck, 0x0002, sn);
    634633
    635         aim_addtlvtochain_noval(&tl, 0x0003);
     634        aim_tlvlist_add_noval(&tl, 0x0003);
    636635
    637636        hdrlen = 2+8+16+6+8+6+4;
     
    643642        aim_putcap(&hdrbs, AIM_CAPS_DIRECTIM);
    644643
    645         aim_addtlvtochain16(&itl, 0x000a, 0x0001);
    646         aim_addtlvtochain_raw(&itl, 0x0003, 4, ip);
    647         aim_addtlvtochain16(&itl, 0x0005, port);
    648         aim_addtlvtochain_noval(&itl, 0x000f);
     644        aim_tlvlist_add_16(&itl, 0x000a, 0x0001);
     645        aim_tlvlist_add_raw(&itl, 0x0003, 4, ip);
     646        aim_tlvlist_add_16(&itl, 0x0005, port);
     647        aim_tlvlist_add_noval(&itl, 0x000f);
    649648       
    650         aim_writetlvchain(&hdrbs, &itl);
    651 
    652         aim_addtlvtochain_raw(&tl, 0x0005, aim_bstream_curpos(&hdrbs), hdr);
    653 
    654         aim_writetlvchain(&fr->data, &tl);
     649        aim_tlvlist_write(&hdrbs, &itl);
     650
     651        aim_tlvlist_add_raw(&tl, 0x0005, aim_bstream_curpos(&hdrbs), hdr);
     652
     653        aim_tlvlist_write(&fr->data, &tl);
    655654
    656655        free(hdr);
    657         aim_freetlvchain(&itl);
    658         aim_freetlvchain(&tl);
     656        aim_tlvlist_free(&itl);
     657        aim_tlvlist_free(&tl);
    659658
    660659        aim_tx_enqueue(sess, fr);
     
    688687                aim_bstream_t bs;
    689688
    690                 aim_addtlvtochain16(&subtl, 0x000a, 0x0001);
    691                 aim_addtlvtochain_noval(&subtl, 0x000f);
    692 /*              aim_addtlvtochain_raw(&subtl, 0x000e, 2, "en");
    693                 aim_addtlvtochain_raw(&subtl, 0x000d, 8, "us-ascii");
    694                 aim_addtlvtochain_raw(&subtl, 0x000c, 24, "Please accept this file."); */
     689                aim_tlvlist_add_16(&subtl, 0x000a, 0x0001);
     690                aim_tlvlist_add_noval(&subtl, 0x000f);
     691/*              aim_tlvlist_add_raw(&subtl, 0x000e, 2, "en");
     692                aim_tlvlist_add_raw(&subtl, 0x000d, 8, "us-ascii");
     693                aim_tlvlist_add_raw(&subtl, 0x000c, 24, "Please accept this file."); */
    695694                if (oft_info->clientip) {
    696695                        fu8_t ip[4];
     
    703702                                i++;
    704703                        }
    705                         aim_addtlvtochain_raw(&subtl, 0x0003, 4, ip);
     704                        aim_tlvlist_add_raw(&subtl, 0x0003, 4, ip);
    706705                }
    707                 aim_addtlvtochain16(&subtl, 0x0005, oft_info->port);
     706                aim_tlvlist_add_16(&subtl, 0x0005, oft_info->port);
    708707
    709708                /* TLV t(2711) */
     
    719718                aimbs_put8(&bs, 0x00);
    720719
    721                 aim_addtlvtochain_raw(&subtl, 0x2711, bs.len, bs.data);
     720                aim_tlvlist_add_raw(&subtl, 0x2711, bs.len, bs.data);
    722721                free(buf);
    723722        }
     
    729728
    730729                /* TLV t(0005) - Encompasses everything from above. Gee. */
    731                 buflen = 2+8+16+aim_sizetlvchain(&subtl);
     730                buflen = 2+8+16+aim_tlvlist_size(&subtl);
    732731                buf = malloc(buflen);
    733732                aim_bstream_init(&bs, buf, buflen);
     
    735734                aimbs_putraw(&bs, oft_info->cookie, 8);
    736735                aim_putcap(&bs, AIM_CAPS_SENDFILE);
    737                 aim_writetlvchain(&bs, &subtl);
    738                 aim_freetlvchain(&subtl);
    739                 aim_addtlvtochain_raw(&tl, 0x0005, bs.len, bs.data);
     736                aim_tlvlist_write(&bs, &subtl);
     737                aim_tlvlist_free(&subtl);
     738                aim_tlvlist_add_raw(&tl, 0x0005, bs.len, bs.data);
    740739                free(buf);
    741740
    742741                /* TLV t(0003) - Request an ack */
    743                 aim_addtlvtochain_noval(&tl, 0x0003);
    744         }
    745 
    746         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(oft_info->sn) + aim_sizetlvchain(&tl))))
     742                aim_tlvlist_add_noval(&tl, 0x0003);
     743        }
     744
     745        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(oft_info->sn) + aim_tlvlist_size(&tl))))
    747746                return -ENOMEM;
    748747
     
    754753
    755754        /* All that crap from above (the 0x0005 TLV and the 0x0003 TLV) */
    756         aim_writetlvchain(&fr->data, &tl);
    757         aim_freetlvchain(&tl);
     755        aim_tlvlist_write(&fr->data, &tl);
     756        aim_tlvlist_free(&tl);
    758757
    759758        aim_tx_enqueue(sess, fr);
     
    10331032        sn = aimbs_getstr(bs, snlen);
    10341033
    1035         tlvlist = aim_readtlvchain(bs);
    1036 
    1037         if (aim_gettlv(tlvlist, 0x0003, 1))
     1034        tlvlist = aim_tlvlist_read(bs);
     1035
     1036        if (aim_tlv_gettlv(tlvlist, 0x0003, 1))
    10381037                icbmflags |= AIM_IMFLAGS_ACK;
    1039         if (aim_gettlv(tlvlist, 0x0004, 1))
     1038        if (aim_tlv_gettlv(tlvlist, 0x0004, 1))
    10401039                icbmflags |= AIM_IMFLAGS_AWAY;
    10411040
    1042         if ((msgblock = aim_gettlv(tlvlist, 0x0002, 1))) {
     1041        if ((msgblock = aim_tlv_gettlv(tlvlist, 0x0002, 1))) {
    10431042                aim_bstream_t mbs;
    10441043                int featurelen, msglen;
     
    10651064
    10661065        free(sn);
    1067         aim_freetlvchain(&tlvlist);
     1066        aim_tlvlist_free(&tlvlist);
    10681067
    10691068        return ret;
     
    16551654         * There's another block of TLVs embedded in the type 5 here.
    16561655         */
    1657         block1 = aim_gettlv(tlvlist, 0x0005, 1);
     1656        block1 = aim_tlv_gettlv(tlvlist, 0x0005, 1);
    16581657        aim_bstream_init(&bbs, block1->value, block1->length);
    16591658
     
    16781677         * identify what type of rendezvous this is.
    16791678         */
    1680         args.reqclass = aim_getcap(sess, &bbs, 0x10);
     1679        args.reqclass = aim_locate_getcaps(sess, &bbs, 0x10);
    16811680
    16821681        /*
     
    16861685         * Ack packets for instance have nothing more to them.
    16871686         */
    1688         list2 = aim_readtlvchain(&bbs);
     1687        list2 = aim_tlvlist_read(&bbs);
    16891688
    16901689        /*
     
    16931692         * XXX - I don't like this.  Maybe just read in an int?  Or inet_ntoa...
    16941693         */
    1695         if (aim_gettlv(list2, 0x0002, 1)) {
     1694        if (aim_tlv_gettlv(list2, 0x0002, 1)) {
    16961695                aim_tlv_t *iptlv;
    16971696
    1698                 iptlv = aim_gettlv(list2, 0x0002, 1);
     1697                iptlv = aim_tlv_gettlv(list2, 0x0002, 1);
    16991698                if (iptlv->length == 4)
    1700                         snprintf(proxyip, sizeof(proxyip), "%hhd.%hhd.%hhd.%hhd",
     1699                        snprintf(proxyip, sizeof(proxyip), "%hhu.%hhu.%hhu.%hhu",
    17011700                                iptlv->value[0], iptlv->value[1],
    17021701                                iptlv->value[2], iptlv->value[3]);
     
    17061705         * IP address from the perspective of the client.
    17071706         */
    1708         if (aim_gettlv(list2, 0x0003, 1)) {
     1707        if (aim_tlv_gettlv(list2, 0x0003, 1)) {
    17091708                aim_tlv_t *iptlv;
    17101709
    1711                 iptlv = aim_gettlv(list2, 0x0003, 1);
     1710                iptlv = aim_tlv_gettlv(list2, 0x0003, 1);
    17121711                if (iptlv->length == 4)
    1713                         snprintf(clientip, sizeof(clientip), "%hhd.%hhd.%hhd.%hhd",
     1712                        snprintf(clientip, sizeof(clientip), "%hhu.%hhu.%hhu.%hhu",
    17141713                                iptlv->value[0], iptlv->value[1],
    17151714                                iptlv->value[2], iptlv->value[3]);
     
    17211720         * This is added by the server.
    17221721         */
    1723         if (aim_gettlv(list2, 0x0004, 1)) {
     1722        if (aim_tlv_gettlv(list2, 0x0004, 1)) {
    17241723                aim_tlv_t *iptlv;
    17251724
    1726                 iptlv = aim_gettlv(list2, 0x0004, 1);
     1725                iptlv = aim_tlv_gettlv(list2, 0x0004, 1);
    17271726                if (iptlv->length == 4)
    1728                         snprintf(verifiedip, sizeof(verifiedip), "%hhd.%hhd.%hhd.%hhd",
     1727                        snprintf(verifiedip, sizeof(verifiedip), "%hhu.%hhu.%hhu.%hhu",
    17291728                                iptlv->value[0], iptlv->value[1],
    17301729                                iptlv->value[2], iptlv->value[3]);
     
    17341733         * Port number for something.
    17351734         */
    1736         if (aim_gettlv(list2, 0x0005, 1))
    1737                 args.port = aim_gettlv16(list2, 0x0005, 1);
     1735        if (aim_tlv_gettlv(list2, 0x0005, 1))
     1736                args.port = aim_tlv_get16(list2, 0x0005, 1);
    17381737
    17391738        /*
     
    17421741         * 0x0002 - "I will accept this file from you"
    17431742         */
    1744         if (aim_gettlv(list2, 0x000a, 1))
     1743        if (aim_tlv_gettlv(list2, 0x000a, 1))
    17451744                ;
    17461745
     
    17481747         * Error code.
    17491748         */
    1750         if (aim_gettlv(list2, 0x000b, 1))
    1751                 args.errorcode = aim_gettlv16(list2, 0x000b, 1);
     1749        if (aim_tlv_gettlv(list2, 0x000b, 1))
     1750                args.errorcode = aim_tlv_get16(list2, 0x000b, 1);
    17521751
    17531752        /*
    17541753         * Invitation message / chat description.
    17551754         */
    1756         if (aim_gettlv(list2, 0x000c, 1))
    1757                 args.msg = aim_gettlv_str(list2, 0x000c, 1);
     1755        if (aim_tlv_gettlv(list2, 0x000c, 1))
     1756                args.msg = aim_tlv_getstr(list2, 0x000c, 1);
    17581757
    17591758        /*
    17601759         * Character set.
    17611760         */
    1762         if (aim_gettlv(list2, 0x000d, 1))
    1763                 args.encoding = aim_gettlv_str(list2, 0x000d, 1);
     1761        if (aim_tlv_gettlv(list2, 0x000d, 1))
     1762                args.encoding = aim_tlv_getstr(list2, 0x000d, 1);
    17641763       
    17651764        /*
    17661765         * Language.
    17671766         */
    1768         if (aim_gettlv(list2, 0x000e, 1))
    1769                 args.language = aim_gettlv_str(list2, 0x000e, 1);
     1767        if (aim_tlv_gettlv(list2, 0x000e, 1))
     1768                args.language = aim_tlv_getstr(list2, 0x000e, 1);
    17701769
    17711770        /*
     
    17741773         * Maybe means we should connect directly to transfer the file?
    17751774         */
    1776         if (aim_gettlv(list2, 0x000f, 1))
     1775        if (aim_tlv_gettlv(list2, 0x000f, 1))
    17771776                ;
    17781777
     
    17821781         * Maybe means we should proxy the file transfer through an AIM server?
    17831782         */
    1784         if (aim_gettlv(list2, 0x0010, 1))
     1783        if (aim_tlv_gettlv(list2, 0x0010, 1))
    17851784                ;
    17861785
     
    17981797         * Service Data blocks are module-specific in format.
    17991798         */
    1800         if ((servdatatlv = aim_gettlv(list2, 0x2711 /* 10001 */, 1))) {
     1799        if ((servdatatlv = aim_tlv_gettlv(list2, 0x2711 /* 10001 */, 1))) {
    18011800
    18021801                aim_bstream_init(&sdbs, servdatatlv->value, servdatatlv->length);
     
    18321831        free((char *)args.language);
    18331832
    1834         aim_freetlvchain(&list2);
     1833        aim_tlvlist_free(&list2);
    18351834
    18361835        return ret;
     
    18481847         * Make a bstream for the meaty part.  Yum.  Meat.
    18491848         */
    1850         if (!(block = aim_gettlv(tlvlist, 0x0005, 1)))
     1849        if (!(block = aim_tlv_gettlv(tlvlist, 0x0005, 1)))
    18511850                return -1;
    18521851        aim_bstream_init(&meat, block->value, block->length);
     
    19471946                 * further data is derived from what is parsed here.
    19481947                 */
    1949                 tlvlist = aim_readtlvchain(bs);
     1948                tlvlist = aim_tlvlist_read(bs);
    19501949
    19511950                ret = incomingim_ch2(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie);
    19521951
    1953                 aim_freetlvchain(&tlvlist);
     1952                aim_tlvlist_free(&tlvlist);
    19541953
    19551954        } else if (channel == 4) {
    19561955                aim_tlvlist_t *tlvlist;
    19571956
    1958                 tlvlist = aim_readtlvchain(bs);
     1957                tlvlist = aim_tlvlist_read(bs);
    19591958                ret = incomingim_ch4(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie);
    1960                 aim_freetlvchain(&tlvlist);
     1959                aim_tlvlist_free(&tlvlist);
    19611960
    19621961        } else {
     
    20562055        aimbs_putraw(&fr->data, sender, strlen(sender));
    20572056
    2058         aim_addtlvtochain16(&tl, 0x0003, code);
    2059         aim_writetlvchain(&fr->data, &tl);
    2060         aim_freetlvchain(&tl);
     2057        aim_tlvlist_add_16(&tl, 0x0003, code);
     2058        aim_tlvlist_write(&fr->data, &tl);
     2059        aim_tlvlist_free(&tl);
    20612060
    20622061        aim_tx_enqueue(sess, fr);
Note: See TracChangeset for help on using the changeset viewer.