X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/blobdiff_plain/01b59e1e19a0f8bbde04b559038984cfb438d4f8..0c20631fc9dd6411357abe57e146196087631010:/aim_misc.c diff --git a/aim_misc.c b/aim_misc.c index dae9e9e..a451d7a 100644 --- a/aim_misc.c +++ b/aim_misc.c @@ -223,25 +223,45 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess, * * Gives BOS your profile. * + * + * The large data chunk given here is of unknown decoding. + * What I do know is that each 0x20 byte repetition + * represents a capability. People with only the + * first two reptitions can support normal messaging + * and chat (client version 2.0 or 3.0). People with + * the third as well can also support voice chat (client + * version 3.5 or higher). IOW, if we don't send this, + * we won't get chat invitations (get "software doesn't + * support chat" error). + * + * This data is broadcast along with your oncoming + * buddy command to everyone who has you on their + * buddy list, as a type 0x0002 TLV. + * */ u_long aim_bos_setprofile(struct aim_session_t *sess, struct aim_conn_t *conn, - char *profile) + char *profile, + char *awaymsg) { - int packet_profile_len = 0; struct command_tx_struct newpacket; int i = 0; - - /* len: SNAC */ - packet_profile_len = 10; - /* len: T+L (where t(0001)) */ - packet_profile_len += 2 + 2; - /* len: V (where t(0001)) */ - packet_profile_len += strlen("text/x-aolrtf"); - /* len: T+L (where t(0002)) */ - packet_profile_len += 2 + 2; - /* len: V (where t(0002)) */ - packet_profile_len += strlen(profile); + u_char funkydata[] = { + 0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, + 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00, + 0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, + 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00, + + 0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1, + 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00, + 0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, + 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00, + + 0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1, + 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00, + 0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1, + 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 + }; newpacket.type = 0x02; if (conn) @@ -249,32 +269,28 @@ u_long aim_bos_setprofile(struct aim_session_t *sess, else newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS); - newpacket.commandlen = packet_profile_len; - newpacket.data = (char *) malloc(packet_profile_len); + newpacket.commandlen = 1152+strlen(profile)+1; /*arbitrarily large */ + if (awaymsg) + newpacket.commandlen += strlen(awaymsg); - i = 0; + newpacket.data = (char *) malloc(newpacket.commandlen); i += aim_putsnac(newpacket.data, 0x0002, 0x004, 0x0000, sess->snac_nextid); - - /* TLV t(0001) */ - newpacket.data[i++] = 0x00; - newpacket.data[i++] = 0x01; - /* TLV l(000d) */ - newpacket.data[i++] = 0x00; - newpacket.data[i++] = 0x0d; - /* TLV v(text/x-aolrtf) */ - memcpy(&(newpacket.data[i]), "text/x-aolrtf", 0x000d); - i += 0x000d; + i += aim_puttlv_str(newpacket.data+i, 0x0001, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); + i += aim_puttlv_str(newpacket.data+i, 0x0002, strlen(profile), profile); + /* why do we send this twice? */ + i += aim_puttlv_str(newpacket.data+i, 0x0003, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); - /* TLV t(0002) */ - newpacket.data[i++] = 0x00; - newpacket.data[i++] = 0x02; - /* TLV l() */ - newpacket.data[i++] = (strlen(profile) >> 8) & 0xFF; - newpacket.data[i++] = (strlen(profile) & 0xFF); - /* TLV v(profile) */ - memcpy(&(newpacket.data[i]), profile, strlen(profile)); + /* Away message -- we send this no matter what, even if its blank */ + if (awaymsg) + i += aim_puttlv_str(newpacket.data+i, 0x0004, strlen(awaymsg), awaymsg); + else + i += aim_puttlv_str(newpacket.data+i, 0x0004, 0x0000, NULL); + + /* Capability information. */ + i += aim_puttlv_str(newpacket.data+i, 0x0005, 0x0060, funkydata); + newpacket.commandlen = i; aim_tx_enqueue(sess, &newpacket); return (sess->snac_nextid++); @@ -403,6 +419,8 @@ u_long aim_bos_ackrateresp(struct aim_session_t *sess, newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS); newpacket.type = 0x02; newpacket.commandlen = 18; + if (conn->type != AIM_CONN_TYPE_BOS) + newpacket.commandlen += 2; newpacket.data = (char *) malloc(newpacket.commandlen); aim_putsnac(newpacket.data, 0x0001, 0x0008, 0x0000, sess->snac_nextid); @@ -415,6 +433,11 @@ u_long aim_bos_ackrateresp(struct aim_session_t *sess, newpacket.data[15] = 0x03; newpacket.data[16] = 0x00; newpacket.data[17] = 0x04; + if (conn->type != AIM_CONN_TYPE_BOS) + { + newpacket.data[16] = 0x00; + newpacket.data[17] = 0x05; + } aim_tx_enqueue(sess, &newpacket); @@ -473,7 +496,7 @@ u_long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn) { struct command_tx_struct newpacket; - int i,j; + int i; newpacket.lock = 1; if (conn) @@ -481,41 +504,46 @@ u_long aim_setversions(struct aim_session_t *sess, else newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS); newpacket.type = 0x02; - newpacket.commandlen = 10 + (4*13); + newpacket.commandlen = 10 + (4*11); newpacket.data = (char *) malloc(newpacket.commandlen); i = aim_putsnac(newpacket.data, 0x0001, 0x0017, 0x0000, sess->snac_nextid); i += aimutil_put16(newpacket.data+i, 0x0001); i += aimutil_put16(newpacket.data+i, 0x0003); + i += aimutil_put16(newpacket.data+i, 0x0002); i += aimutil_put16(newpacket.data+i, 0x0001); + i += aimutil_put16(newpacket.data+i, 0x0003); i += aimutil_put16(newpacket.data+i, 0x0001); + i += aimutil_put16(newpacket.data+i, 0x0004); i += aimutil_put16(newpacket.data+i, 0x0001); + i += aimutil_put16(newpacket.data+i, 0x0006); i += aimutil_put16(newpacket.data+i, 0x0001); + i += aimutil_put16(newpacket.data+i, 0x0008); i += aimutil_put16(newpacket.data+i, 0x0001); + i += aimutil_put16(newpacket.data+i, 0x0009); i += aimutil_put16(newpacket.data+i, 0x0001); + i += aimutil_put16(newpacket.data+i, 0x000a); i += aimutil_put16(newpacket.data+i, 0x0001); + i += aimutil_put16(newpacket.data+i, 0x000b); i += aimutil_put16(newpacket.data+i, 0x0002); + i += aimutil_put16(newpacket.data+i, 0x000c); i += aimutil_put16(newpacket.data+i, 0x0001); + i += aimutil_put16(newpacket.data+i, 0x0015); - i += aimutil_put16(newpacket.data+i, 0x0003); - i += aimutil_put16(newpacket.data+i, 0x000f); - i += aimutil_put16(newpacket.data+i, 0x0001); - i += aimutil_put16(newpacket.data+i, 0x0005); i += aimutil_put16(newpacket.data+i, 0x0001); #if 0 for (j = 0; j < 0x10; j++) -A { i += aimutil_put16(newpacket.data+i, j); /* family */ i += aimutil_put16(newpacket.data+i, 0x0003); /* version */