Changeset cf02dd6 for libfaim/im.c
- Timestamp:
- Dec 10, 2003, 3:20:45 PM (20 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfaim/im.c
re374dee rcf02dd6 167 167 return -EINVAL; 168 168 169 return aim_genericreq_n (sess, conn, 0x0004, 0x0004);169 return aim_genericreq_n_snacid(sess, conn, 0x0004, 0x0004); 170 170 } 171 171 … … 390 390 aim_tx_enqueue(sess, fr); 391 391 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); 395 394 396 395 return 0; … … 633 632 aim_im_puticbm(&fr->data, ck, 0x0002, sn); 634 633 635 aim_ addtlvtochain_noval(&tl, 0x0003);634 aim_tlvlist_add_noval(&tl, 0x0003); 636 635 637 636 hdrlen = 2+8+16+6+8+6+4; … … 643 642 aim_putcap(&hdrbs, AIM_CAPS_DIRECTIM); 644 643 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); 649 648 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); 655 654 656 655 free(hdr); 657 aim_ freetlvchain(&itl);658 aim_ freetlvchain(&tl);656 aim_tlvlist_free(&itl); 657 aim_tlvlist_free(&tl); 659 658 660 659 aim_tx_enqueue(sess, fr); … … 688 687 aim_bstream_t bs; 689 688 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."); */ 695 694 if (oft_info->clientip) { 696 695 fu8_t ip[4]; … … 703 702 i++; 704 703 } 705 aim_ addtlvtochain_raw(&subtl, 0x0003, 4, ip);704 aim_tlvlist_add_raw(&subtl, 0x0003, 4, ip); 706 705 } 707 aim_ addtlvtochain16(&subtl, 0x0005, oft_info->port);706 aim_tlvlist_add_16(&subtl, 0x0005, oft_info->port); 708 707 709 708 /* TLV t(2711) */ … … 719 718 aimbs_put8(&bs, 0x00); 720 719 721 aim_ addtlvtochain_raw(&subtl, 0x2711, bs.len, bs.data);720 aim_tlvlist_add_raw(&subtl, 0x2711, bs.len, bs.data); 722 721 free(buf); 723 722 } … … 729 728 730 729 /* 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); 732 731 buf = malloc(buflen); 733 732 aim_bstream_init(&bs, buf, buflen); … … 735 734 aimbs_putraw(&bs, oft_info->cookie, 8); 736 735 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); 740 739 free(buf); 741 740 742 741 /* 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)))) 747 746 return -ENOMEM; 748 747 … … 754 753 755 754 /* 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); 758 757 759 758 aim_tx_enqueue(sess, fr); … … 1033 1032 sn = aimbs_getstr(bs, snlen); 1034 1033 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)) 1038 1037 icbmflags |= AIM_IMFLAGS_ACK; 1039 if (aim_ gettlv(tlvlist, 0x0004, 1))1038 if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) 1040 1039 icbmflags |= AIM_IMFLAGS_AWAY; 1041 1040 1042 if ((msgblock = aim_ gettlv(tlvlist, 0x0002, 1))) {1041 if ((msgblock = aim_tlv_gettlv(tlvlist, 0x0002, 1))) { 1043 1042 aim_bstream_t mbs; 1044 1043 int featurelen, msglen; … … 1065 1064 1066 1065 free(sn); 1067 aim_ freetlvchain(&tlvlist);1066 aim_tlvlist_free(&tlvlist); 1068 1067 1069 1068 return ret; … … 1655 1654 * There's another block of TLVs embedded in the type 5 here. 1656 1655 */ 1657 block1 = aim_ gettlv(tlvlist, 0x0005, 1);1656 block1 = aim_tlv_gettlv(tlvlist, 0x0005, 1); 1658 1657 aim_bstream_init(&bbs, block1->value, block1->length); 1659 1658 … … 1678 1677 * identify what type of rendezvous this is. 1679 1678 */ 1680 args.reqclass = aim_ getcap(sess, &bbs, 0x10);1679 args.reqclass = aim_locate_getcaps(sess, &bbs, 0x10); 1681 1680 1682 1681 /* … … 1686 1685 * Ack packets for instance have nothing more to them. 1687 1686 */ 1688 list2 = aim_ readtlvchain(&bbs);1687 list2 = aim_tlvlist_read(&bbs); 1689 1688 1690 1689 /* … … 1693 1692 * XXX - I don't like this. Maybe just read in an int? Or inet_ntoa... 1694 1693 */ 1695 if (aim_ gettlv(list2, 0x0002, 1)) {1694 if (aim_tlv_gettlv(list2, 0x0002, 1)) { 1696 1695 aim_tlv_t *iptlv; 1697 1696 1698 iptlv = aim_ gettlv(list2, 0x0002, 1);1697 iptlv = aim_tlv_gettlv(list2, 0x0002, 1); 1699 1698 if (iptlv->length == 4) 1700 snprintf(proxyip, sizeof(proxyip), "%hh d.%hhd.%hhd.%hhd",1699 snprintf(proxyip, sizeof(proxyip), "%hhu.%hhu.%hhu.%hhu", 1701 1700 iptlv->value[0], iptlv->value[1], 1702 1701 iptlv->value[2], iptlv->value[3]); … … 1706 1705 * IP address from the perspective of the client. 1707 1706 */ 1708 if (aim_ gettlv(list2, 0x0003, 1)) {1707 if (aim_tlv_gettlv(list2, 0x0003, 1)) { 1709 1708 aim_tlv_t *iptlv; 1710 1709 1711 iptlv = aim_ gettlv(list2, 0x0003, 1);1710 iptlv = aim_tlv_gettlv(list2, 0x0003, 1); 1712 1711 if (iptlv->length == 4) 1713 snprintf(clientip, sizeof(clientip), "%hh d.%hhd.%hhd.%hhd",1712 snprintf(clientip, sizeof(clientip), "%hhu.%hhu.%hhu.%hhu", 1714 1713 iptlv->value[0], iptlv->value[1], 1715 1714 iptlv->value[2], iptlv->value[3]); … … 1721 1720 * This is added by the server. 1722 1721 */ 1723 if (aim_ gettlv(list2, 0x0004, 1)) {1722 if (aim_tlv_gettlv(list2, 0x0004, 1)) { 1724 1723 aim_tlv_t *iptlv; 1725 1724 1726 iptlv = aim_ gettlv(list2, 0x0004, 1);1725 iptlv = aim_tlv_gettlv(list2, 0x0004, 1); 1727 1726 if (iptlv->length == 4) 1728 snprintf(verifiedip, sizeof(verifiedip), "%hh d.%hhd.%hhd.%hhd",1727 snprintf(verifiedip, sizeof(verifiedip), "%hhu.%hhu.%hhu.%hhu", 1729 1728 iptlv->value[0], iptlv->value[1], 1730 1729 iptlv->value[2], iptlv->value[3]); … … 1734 1733 * Port number for something. 1735 1734 */ 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); 1738 1737 1739 1738 /* … … 1742 1741 * 0x0002 - "I will accept this file from you" 1743 1742 */ 1744 if (aim_ gettlv(list2, 0x000a, 1))1743 if (aim_tlv_gettlv(list2, 0x000a, 1)) 1745 1744 ; 1746 1745 … … 1748 1747 * Error code. 1749 1748 */ 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); 1752 1751 1753 1752 /* 1754 1753 * Invitation message / chat description. 1755 1754 */ 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); 1758 1757 1759 1758 /* 1760 1759 * Character set. 1761 1760 */ 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); 1764 1763 1765 1764 /* 1766 1765 * Language. 1767 1766 */ 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); 1770 1769 1771 1770 /* … … 1774 1773 * Maybe means we should connect directly to transfer the file? 1775 1774 */ 1776 if (aim_ gettlv(list2, 0x000f, 1))1775 if (aim_tlv_gettlv(list2, 0x000f, 1)) 1777 1776 ; 1778 1777 … … 1782 1781 * Maybe means we should proxy the file transfer through an AIM server? 1783 1782 */ 1784 if (aim_ gettlv(list2, 0x0010, 1))1783 if (aim_tlv_gettlv(list2, 0x0010, 1)) 1785 1784 ; 1786 1785 … … 1798 1797 * Service Data blocks are module-specific in format. 1799 1798 */ 1800 if ((servdatatlv = aim_ gettlv(list2, 0x2711 /* 10001 */, 1))) {1799 if ((servdatatlv = aim_tlv_gettlv(list2, 0x2711 /* 10001 */, 1))) { 1801 1800 1802 1801 aim_bstream_init(&sdbs, servdatatlv->value, servdatatlv->length); … … 1832 1831 free((char *)args.language); 1833 1832 1834 aim_ freetlvchain(&list2);1833 aim_tlvlist_free(&list2); 1835 1834 1836 1835 return ret; … … 1848 1847 * Make a bstream for the meaty part. Yum. Meat. 1849 1848 */ 1850 if (!(block = aim_ gettlv(tlvlist, 0x0005, 1)))1849 if (!(block = aim_tlv_gettlv(tlvlist, 0x0005, 1))) 1851 1850 return -1; 1852 1851 aim_bstream_init(&meat, block->value, block->length); … … 1947 1946 * further data is derived from what is parsed here. 1948 1947 */ 1949 tlvlist = aim_ readtlvchain(bs);1948 tlvlist = aim_tlvlist_read(bs); 1950 1949 1951 1950 ret = incomingim_ch2(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie); 1952 1951 1953 aim_ freetlvchain(&tlvlist);1952 aim_tlvlist_free(&tlvlist); 1954 1953 1955 1954 } else if (channel == 4) { 1956 1955 aim_tlvlist_t *tlvlist; 1957 1956 1958 tlvlist = aim_ readtlvchain(bs);1957 tlvlist = aim_tlvlist_read(bs); 1959 1958 ret = incomingim_ch4(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie); 1960 aim_ freetlvchain(&tlvlist);1959 aim_tlvlist_free(&tlvlist); 1961 1960 1962 1961 } else { … … 2056 2055 aimbs_putraw(&fr->data, sender, strlen(sender)); 2057 2056 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); 2061 2060 2062 2061 aim_tx_enqueue(sess, fr);
Note: See TracChangeset
for help on using the changeset viewer.