From: mid Date: Fri, 2 Mar 2001 02:23:56 +0000 (+0000) Subject: - Fri Mar 2 02:17:22 UTC 2001 X-Git-Tag: rel_0_99_2~69 X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/commitdiff_plain/9d83220cefa5bf6e22fbabae688b151c107780cd - Fri Mar 2 02:17:22 UTC 2001 - Add aim_fingerprintclient(). (AB will, but you shouldn't.) - Add some EXTRA_DIST to Makefile.am --- diff --git a/CHANGES b/CHANGES index 72835a9..023ee33 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ No release numbers ------------------ + - Fri Mar 2 02:17:22 UTC 2001 + - Add aim_fingerprintclient(). (AB will, but you shouldn't.) + - Add some EXTRA_DIST to Makefile.am + - Mon Feb 26 01:46:34 UTC 2001 - Fix swapped bytes in aim_caps[]. Thanks to Bruce Miller for pointing this out. diff --git a/Makefile.am b/Makefile.am index 891708d..53259cd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,5 @@ +EXTRA_DIST = AUTHORS BUGS CHANGES COPYING INSTALL README + SUBDIRS = include src utils diff --git a/include/aim.h b/include/aim.h index e31566d..11977bb 100644 --- a/include/aim.h +++ b/include/aim.h @@ -625,6 +625,13 @@ struct aim_tool_version { #endif /* FAIM_INTERNAL */ +#define AIM_CLIENTTYPE_UNKNOWN 0x0000 +#define AIM_CLIENTTYPE_MC 0x0001 +#define AIM_CLIENTTYPE_WINAIM 0x0002 +#define AIM_CLIENTTYPE_WINAIM41 0x0003 +#define AIM_CLIENTTYPE_AOL_TOC 0x0004 +faim_export unsigned short aim_fingerprintclient(unsigned char *msghdr, int len); + #define AIM_RATE_CODE_CHANGE 0x0001 #define AIM_RATE_CODE_WARNING 0x0002 #define AIM_RATE_CODE_LIMIT 0x0003 diff --git a/src/chat.c b/src/chat.c index 47f39d7..5c3f455 100644 --- a/src/chat.c +++ b/src/chat.c @@ -51,6 +51,7 @@ faim_export int aim_chat_attachname(struct aim_conn_t *conn, char *roomname) return 0; } +/* XXX convert this to use tlvchains */ faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, char *msg) @@ -84,8 +85,7 @@ faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, aim_cachecookie(sess, cookie); /* - * metaTLV start. -- i assume this is a metaTLV. it could be the - * channel ID though. + * Channel ID. */ curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003); @@ -402,6 +402,24 @@ faim_internal int aim_chat_parse_leave(struct aim_session_t *sess, * We could probably include this in the normal ICBM parsing * code as channel 0x0003, however, since only the start * would be the same, we might as well do it here. + * + * General outline of this SNAC: + * snac + * cookie + * channel id + * tlvlist + * unknown + * source user info + * name + * evility + * userinfo tlvs + * online time + * etc + * message metatlv + * message tlv + * message string + * possibly others + * */ faim_internal int aim_chat_parse_incoming(struct aim_session_t *sess, struct command_rx_struct *command) diff --git a/src/im.c b/src/im.c index 5f42b5b..ce4886a 100644 --- a/src/im.c +++ b/src/im.c @@ -8,6 +8,63 @@ #define FAIM_INTERNAL #include +/* + * Takes a msghdr (and a length) and returns a client type + * code. Note that this is *only a guess* and has a low likelihood + * of actually being accurate. + * + * Its based on experimental data, with the help of Eric Warmenhoven + * who seems to have collected a wide variety of different AIM clients. + * + * + * Heres the current collection: + * 0501 0003 0101 0101 01 AOL Mobile Communicator, WinAIM 1.0.414 + * 0501 0003 0101 0201 01 WinAIM 2.0.847, 2.1.1187, 3.0.1464, + * 4.3.2229, 4.4.2286 + * 0501 0004 0101 0102 0101 WinAIM 4.1.2010, libfaim (right here) + * 0501 0001 0101 01 AOL v6.0, CompuServe 2000 v6.0, any + * TOC client + */ +faim_export unsigned short aim_fingerprintclient(unsigned char *msghdr, int len) +{ + static const struct { + unsigned short clientid; + int len; + unsigned char data[10]; + } fingerprints[] = { + /* AOL Mobile Communicator, WinAIM 1.0.414 */ + { AIM_CLIENTTYPE_MC, + 9, {0x05, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01}}, + + /* WinAIM 2.0.847, 2.1.1187, 3.0.1464, 4.3.2229, 4.4.2286 */ + { AIM_CLIENTTYPE_WINAIM, + 9, {0x05, 0x01, 0x00, 0x03, 0x01, 0x01, 0x02, 0x01, 0x01}}, + + /* WinAIM 4.1.2010, libfaim */ + { AIM_CLIENTTYPE_WINAIM41, + 10, {0x05, 0x01, 0x00, 0x04, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01}}, + + /* AOL v6.0, CompuServe 2000 v6.0, any TOC client */ + { AIM_CLIENTTYPE_AOL_TOC, + 7, {0x05, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01}}, + + { 0, 0} + }; + int i; + + if (!msghdr || (len <= 0)) + return 0; + + for (i = 0; fingerprints[i].len; i++) { + if (fingerprints[i].len != len) + continue; + if (memcmp(fingerprints[i].data, msghdr, fingerprints[i].len) == 0) + return fingerprints[i].clientid; + } + + return AIM_CLIENTTYPE_UNKNOWN; +} + /* * Send an ICBM (instant message). * @@ -69,6 +126,9 @@ faim_export unsigned long aim_send_im(struct aim_session_t *sess, /* * Flag data / ICBM Parameters? + * + * I don't know what these are... + * */ curbyte += aimutil_put8(newpacket->data+curbyte, 0x05); curbyte += aimutil_put8(newpacket->data+curbyte, 0x01); @@ -217,7 +277,6 @@ faim_internal int aim_parse_incoming_im_middle(struct aim_session_t *sess, int channel; struct aim_tlvlist_t *tlvlist; struct aim_userinfo_s userinfo; - u_short wastebits; memset(&userinfo, 0x00, sizeof(struct aim_userinfo_s)); @@ -289,6 +348,9 @@ faim_internal int aim_parse_incoming_im_middle(struct aim_session_t *sess, struct aim_tlv_t *msgblocktlv; u_char *msgblock; u_short flag1,flag2; + int finlen = 0; + unsigned char fingerprint[10]; + u_short wastebits; /* * Check Autoresponse status. If it is an autoresponse, @@ -335,7 +397,12 @@ faim_internal int aim_parse_incoming_im_middle(struct aim_session_t *sess, wastebits = aimutil_get8(msgblock+j++); wastebits = aimutil_get8(msgblock+j++); wastebits = aimutil_get8(msgblock+j++); - + + finlen = j; + if (finlen > sizeof(fingerprint)) + finlen = sizeof(fingerprint); + memcpy(fingerprint, msgblocktlv->value, finlen); + /* * Message string length, including flag words. */ @@ -373,7 +440,7 @@ faim_internal int aim_parse_incoming_im_middle(struct aim_session_t *sess, */ userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); if (userfunc) - i = userfunc(sess, command, channel, &userinfo, msg, icbmflags, flag1, flag2); + i = userfunc(sess, command, channel, &userinfo, msg, icbmflags, flag1, flag2, finlen, fingerprint); else i = 0; diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index 491e619..57593b6 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -914,15 +914,23 @@ int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_str u_int icbmflags = 0; char *tmpstr = NULL; unsigned short flag1, flag2; + int finlen = 0; + unsigned char *fingerprint = NULL; + int clienttype = AIM_CLIENTTYPE_UNKNOWN; userinfo = va_arg(ap, struct aim_userinfo_s *); msg = va_arg(ap, char *); icbmflags = va_arg(ap, u_int); flag1 = va_arg(ap, int); flag2 = va_arg(ap, int); + finlen = va_arg(ap, int); + fingerprint = va_arg(ap, unsigned char *); va_end(ap); + clienttype = aim_fingerprintclient(fingerprint, finlen); + dvprintf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn); + dvprintf("faimtest: icbm: probable client type: %d\n", clienttype); dvprintf("faimtest: icbm: warnlevel = 0x%04x\n", userinfo->warnlevel); dvprintf("faimtest: icbm: flags = 0x%04x = ", userinfo->flags); printuserflags(userinfo->flags);