From 1a8c261b0ecb31698a38588cc7a1f27c91b0b079 Mon Sep 17 00:00:00 2001 From: mid Date: Mon, 17 Jul 2000 03:40:19 +0000 Subject: [PATCH] - Mon Jul 17 01:56:31 UTC 2000 - Added 0004/000c callback (for message acknowledgments) - This goes with the AIM_IMFLAGS_ACK option that has been there for ages now. When you send a message with that option, you'll get a message back containing the screenname, telling you it was sent. - Moved the aim_conn_kill's out of aim_get_command() and into the client. They're only closed in there now. This is so that you can detect what type of connection died. You'll want to handle BOS and chat connections in special ways most likely. You'll also need to call aim_conn_kill when you're done with it. - Added/fixed the Rate Change handlers. Now passes up a long that should contain a number. I'm currently in pattern-searching mode. --- CHANGES | 13 +++++++++++ aim_ft.c | 10 ++++---- aim_rxhandlers.c | 49 ++++++++++++++++++++++++++++++++++++++- aim_rxqueue.c | 5 ++-- utils/faimtest/faimtest.c | 43 +++++++++++++++++++++++++++++++--- 5 files changed, 109 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index b7ae661..e54c938 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,19 @@ No release numbers ------------------ + - Mon Jul 17 01:56:31 UTC 2000 + - Added 0004/000c callback (for message acknowledgments) + - This goes with the AIM_IMFLAGS_ACK option that has been there + for ages now. When you send a message with that option, you'll + get a message back containing the screenname, telling you it was sent. + - Moved the aim_conn_kill's out of aim_get_command() and into + the client. They're only closed in there now. This is so that you + can detect what type of connection died. You'll want to handle + BOS and chat connections in special ways most likely. You'll also + need to call aim_conn_kill when you're done with it. + - Added/fixed the Rate Change handlers. Now passes up a long that + should contain a number. I'm currently in pattern-searching mode. + - Sun Jul 16 22:59:39 GMT 2000 - Fixed the locking in the rendezvous code. Hopefully is safe now. diff --git a/aim_ft.c b/aim_ft.c index ae91999..f327940 100644 --- a/aim_ft.c +++ b/aim_ft.c @@ -695,7 +695,7 @@ int aim_get_command_rendezvous(struct aim_session_t *sess, struct aim_conn_t *co perror("read"); printf("faim: rend: read error (fd: %i) %02x%02x%02x%02x%02x%02x (%i)\n", conn->fd, hdrbuf1[0],hdrbuf1[1],hdrbuf1[0],hdrbuf1[0],hdrbuf1[0],hdrbuf1[0],hdrlen); faim_mutex_unlock(&conn->active); - aim_conn_kill(sess, &conn); + aim_conn_close(conn); return -1; } @@ -710,7 +710,7 @@ int aim_get_command_rendezvous(struct aim_session_t *sess, struct aim_conn_t *co printf("faim: rend: read2 error\n"); free(hdr); faim_mutex_unlock(&conn->active); - aim_conn_kill(sess, &conn); + aim_conn_close(conn); return 0; /* see comment on previous read check */ } @@ -752,8 +752,8 @@ int aim_get_command_rendezvous(struct aim_session_t *sess, struct aim_conn_t *co printf("faim: rend: read3 error\n"); free(msg); faim_mutex_unlock(&conn->active); - aim_conn_kill(sess, &conn); - return 0; + aim_conn_close(conn); + return -1; } faim_mutex_unlock(&conn->active); msg[payloadlength] = '\0'; @@ -996,7 +996,7 @@ int aim_get_command_rendezvous(struct aim_session_t *sess, struct aim_conn_t *co case 0x0204: { /* get file: finished. close it up */ printf("looks like we're done with a transfer (oft 0x0204)\n"); faim_mutex_unlock(&conn->active); - aim_conn_kill(sess, &conn); + aim_conn_close(conn); break; } default: { diff --git a/aim_rxhandlers.c b/aim_rxhandlers.c index e030402..b1f8f9b 100644 --- a/aim_rxhandlers.c +++ b/aim_rxhandlers.c @@ -420,7 +420,7 @@ int aim_rxdispatch(struct aim_session_t *sess) workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0001, 0x0007, workingPtr); break; case 0x000a: - workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0001, 0x000a, workingPtr); + workingPtr->handled = aim_parse_ratechange_middle(sess, workingPtr); break; case 0x000f: workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0001, 0x000f, workingPtr); @@ -482,6 +482,9 @@ int aim_rxdispatch(struct aim_session_t *sess) case 0x000a: workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0004, 0x000a, workingPtr); break; + case 0x000c: + workingPtr->handled = aim_parse_msgack_middle(sess, workingPtr); + break; default: workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_MSG, AIM_CB_MSG_DEFAULT, workingPtr); } @@ -609,6 +612,50 @@ int aim_rxdispatch(struct aim_session_t *sess) return 0; } +int aim_parse_msgack_middle(struct aim_session_t *sess, struct command_rx_struct *command) +{ + rxcallback_t userfunc = NULL; + char sn[MAXSNLEN]; + unsigned short type; + int i = 10+8; /* skip SNAC and cookie */ + int ret = 1; + unsigned char snlen; + + type = aimutil_get16(command->data+i); + i += 2; + + snlen = aimutil_get8(command->data+i); + i++; + + memset(sn, 0, sizeof(sn)); + strncpy(sn, command->data+i, snlen); + + if ((userfunc = aim_callhandler(command->conn, 0x0004, 0x000c))) + ret = userfunc(sess, command, type, sn); + + return ret; +} + +int aim_parse_ratechange_middle(struct aim_session_t *sess, struct command_rx_struct *command) +{ + rxcallback_t userfunc = NULL; + int i = 10; /* skip SNAC */ + int ret = 1; + unsigned long newrate; + + if (command->commandlen != 0x2f) { + printf("faim: unknown rate change length 0x%04x\n", command->commandlen); + return 1; + } + + newrate = aimutil_get32(command->data+34); + + if ((userfunc = aim_callhandler(command->conn, 0x0001, 0x000a))) + ret = userfunc(sess, command, newrate); + + return ret; +} + int aim_parsemotd_middle(struct aim_session_t *sess, struct command_rx_struct *command, ...) { diff --git a/aim_rxqueue.c b/aim_rxqueue.c index 75aa8bc..41e34c7 100644 --- a/aim_rxqueue.c +++ b/aim_rxqueue.c @@ -42,7 +42,7 @@ int aim_get_command(struct aim_session_t *sess, struct aim_conn_t *conn) */ faim_mutex_lock(&conn->active); if (read(conn->fd, generic, 6) < 6){ - aim_conn_kill(sess, &conn); + aim_conn_close(conn); faim_mutex_unlock(&conn->active); return -1; } @@ -53,6 +53,7 @@ int aim_get_command(struct aim_session_t *sess, struct aim_conn_t *conn) */ if (generic[0] != 0x2a) { faimdprintf(1, "Bad incoming data!"); + aim_conn_close(conn); faim_mutex_unlock(&conn->active); return -1; } @@ -91,7 +92,7 @@ int aim_get_command(struct aim_session_t *sess, struct aim_conn_t *conn) if (read(conn->fd, newrx->data, newrx->commandlen) < newrx->commandlen){ free(newrx->data); free(newrx); - aim_conn_kill(sess, &conn); + aim_conn_close(conn); faim_mutex_unlock(&conn->active); return -1; } diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index e650edf..58f449b 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -57,6 +57,7 @@ int faimtest_authsvrready(struct aim_session_t *, struct command_rx_struct *comm int faimtest_pwdchngdone(struct aim_session_t *, struct command_rx_struct *command, ...); int faimtest_serverready(struct aim_session_t *, struct command_rx_struct *command, ...); int faimtest_parse_misses(struct aim_session_t *, struct command_rx_struct *command, ...); +int faimtest_parse_msgack(struct aim_session_t *, struct command_rx_struct *command, ...); int faimtest_parse_motd(struct aim_session_t *, struct command_rx_struct *command, ...); int faimtest_parse_login(struct aim_session_t *, struct command_rx_struct *command, ...); int faimtest_chatnav_info(struct aim_session_t *, struct command_rx_struct *command, ...); @@ -73,6 +74,7 @@ int faimtest_directim_connect(struct aim_session_t *sess, struct command_rx_stru int faimtest_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...); int faimtest_directim_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...); int faimtest_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...); +int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...); int faimtest_reportinterval(struct aim_session_t *sess, struct command_rx_struct *command, ...) { @@ -159,6 +161,7 @@ int main(void) aim_rxdispatch(&aimsess); } else { printf("connection error\n"); + aim_conn_kill(&aimsess, &waitingconn); if (!aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)) { printf("major connetion error\n"); keepgoing = 0; @@ -401,10 +404,11 @@ int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_misses, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0); - aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_misses, 0); + aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_ratechange, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_misses, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0); - + aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, faimtest_parse_msgack, 0); + aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0); @@ -563,7 +567,7 @@ int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_str aim_logoff(sess); } else if (strstr(tmpstr, "goodday")) { printf("faimtest: icbm: sending response\n"); - aim_send_im(sess, command->conn, userinfo->sn, 0, "Good day to you too."); + aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too."); } else if (!strncmp(tmpstr, "open chatnav", 12)) { aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); //aim_chat_join(sess, command->conn, "thishereisaname2_chat85"); @@ -1138,3 +1142,36 @@ int faimtest_debugconn_connect(struct aim_session_t *sess, struct command_rx_str /* go right into main loop (don't open a BOS connection, etc) */ return 1; } + +/* + * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option. + */ +int faimtest_parse_msgack(struct aim_session_t *sess, struct command_rx_struct *command, ...) +{ + va_list ap; + unsigned short type; + char *sn = NULL; + + ap = va_start(ap, command); + type = va_arg(ap, unsigned short); + sn = va_arg(ap, char *); + va_end(ap); + + printf("faimtest: msgack: 0x%04x / %s\n", type, sn); + + return 1; +} + +int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...) +{ + va_list ap; + unsigned long newrate; + + va_start(ap, command); + newrate = va_arg(ap, unsigned long); + va_end(ap); + + printf("faimtest: ratechange: %lu\n", newrate); + + return (1); +}; -- 2.45.1