From 355229fed58ec38debbb0acfd67c16663b26d2d7 Mon Sep 17 00:00:00 2001 From: mid Date: Sun, 26 Aug 2001 01:52:28 +0000 Subject: [PATCH] - Sat Aug 25 18:35:13 PDT 2001 - aim_sendconnack -> aim_sendflapver - Remove addicbmparam. This was identical to aim_seticbmparam - aim_seticbmparam now takes a struct with the parameters in it. See faimtest. !!! REQUIRES CLIENT CHANGES if you use aim_seticbmparam, which you really really should -- the defaults are insanely limited - Fix rendezvous IM parsing that I broke last time. - ICBM parameter info callback gives same struct as above. !!! REQUIRES CLIENT CHANGES - Reformat login.c and part of faimtest.c - !!! NOTE: don't do anything in your motd handler. If you do, it will get run twice, sine for some reason AOL is sending two MOTDs now. --- CHANGES | 13 + include/aim.h | 41 +- src/im.c | 54 +- src/login.c | 1038 +++++++++++++++++----------------- src/misc.c | 42 -- utils/faimtest/faimtest.c | 1109 +++++++++++++++++++------------------ 6 files changed, 1153 insertions(+), 1144 deletions(-) diff --git a/CHANGES b/CHANGES index 22f06e4..fd46f0d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,19 @@ No release numbers ------------------ + - Sat Aug 25 18:35:13 PDT 2001 + - aim_sendconnack -> aim_sendflapver + - Remove addicbmparam. This was identical to aim_seticbmparam + - aim_seticbmparam now takes a struct with the parameters in it. See + faimtest. !!! REQUIRES CLIENT CHANGES if you use aim_seticbmparam, which + you really really should -- the defaults are insanely limited + - Fix rendezvous IM parsing that I broke last time. + - ICBM parameter info callback gives same struct as above. !!! REQUIRES + CLIENT CHANGES + - Reformat login.c and part of faimtest.c + - !!! NOTE: don't do anything in your motd handler. If you do, it will + get run twice, sine for some reason AOL is sending two MOTDs now. + - Wed Aug 22 22:11:18 PDT 2001 - Reformat the rest of im.c - Fix a few returns, particularly in error cases diff --git a/include/aim.h b/include/aim.h index 6e5b013..30e15b6 100644 --- a/include/aim.h +++ b/include/aim.h @@ -484,8 +484,8 @@ faim_export void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **d typedef int (*aim_rxcallback_t)(struct aim_session_t *, struct command_rx_struct *, ...); /* aim_login.c */ -faim_export int aim_sendconnack(struct aim_session_t *sess, struct aim_conn_t *conn); -faim_export int aim_request_login (struct aim_session_t *sess, struct aim_conn_t *conn, char *sn); +faim_export int aim_sendflapver(struct aim_session_t *sess, struct aim_conn_t *conn); +faim_export int aim_request_login (struct aim_session_t *sess, struct aim_conn_t *conn, const char *sn); faim_export int aim_send_login (struct aim_session_t *, struct aim_conn_t *, char *, char *, struct client_info_s *, char *key); faim_export int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest); faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn, int errorcode, char *errorurl, char *bosip, char *cookie, char *email, int regstatus); @@ -563,8 +563,6 @@ faim_export unsigned long aim_bos_reqservice(struct aim_session_t *, struct aim_ faim_export unsigned long aim_bos_reqrights(struct aim_session_t *, struct aim_conn_t *); faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *, struct aim_conn_t *); faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *, struct aim_conn_t *); -faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *, struct aim_conn_t *); -faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess,struct aim_conn_t *conn); faim_export unsigned long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn); faim_export unsigned long aim_auth_setversions(struct aim_session_t *sess, struct aim_conn_t *conn); faim_export unsigned long aim_auth_reqconfirm(struct aim_session_t *sess, struct aim_conn_t *conn); @@ -714,7 +712,6 @@ faim_export unsigned short aim_iconsum(const unsigned char *buf, int buflen); faim_export int aim_send_im_direct(struct aim_session_t *, struct aim_conn_t *, char *); faim_export struct aim_conn_t * aim_directim_initiate(struct aim_session_t *, struct aim_conn_t *, struct aim_directim_priv *, char *destsn); faim_export struct aim_conn_t *aim_directim_connect(struct aim_session_t *, struct aim_conn_t *, struct aim_directim_priv *); -faim_export unsigned long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn); faim_export struct aim_conn_t *aim_getfile_initiate(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn); faim_export int aim_oft_getfile_request(struct aim_session_t *sess, struct aim_conn_t *conn, const unsigned char *name, const int size); @@ -788,6 +785,40 @@ faim_export int aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const c faim_export int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info); faim_export int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn); +#define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED 0x00000001 +#define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED 0x00000002 + +/* This is what the server will give you if you don't set them yourself. */ +#define AIM_IMPARAM_DEFAULTS { \ + 0, \ + AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \ + 512, /* !! Note how small this is. */ \ + (99.9)*10, (99.9)*10, \ + 1000 \ +} + +/* This is what most AIM versions use. */ +#define AIM_IMPARAM_REASONABLE { \ + 0, \ + AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \ + 8000, \ + (99.9)*10, (99.9)*10, \ + 0 \ +} + + +struct aim_icbmparameters { + unsigned short maxchan; + unsigned long flags; /* AIM_IMPARAM_FLAG_ */ + unsigned short maxmsglen; /* message size that you will accept */ + unsigned short maxsenderwarn; /* this and below are *10 (999=99.9%) */ + unsigned short maxrecverwarn; + unsigned long minmsginterval; /* in milliseconds? */ +}; + +faim_export unsigned long aim_reqicbmparams(struct aim_session_t *sess, struct aim_conn_t *conn); +faim_export unsigned long aim_seticbmparam(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_icbmparameters *params); + /* aim_auth.c */ faim_export int aim_auth_sendcookie(struct aim_session_t *, struct aim_conn_t *, u_char *); diff --git a/src/im.c b/src/im.c index e48fef2..af771fa 100644 --- a/src/im.c +++ b/src/im.c @@ -619,7 +619,7 @@ static int incomingim_ch2(struct aim_session_t *sess, aim_module_t *mod, struct /* * There's another block of TLVs embedded in the type 5 here. */ - if ((block1 = aim_gettlv(tlvlist, 0x0005, 1)) && block1->value) { + if (!(block1 = aim_gettlv(tlvlist, 0x0005, 1)) || !block1->value) { faimdprintf(sess, 0, "no tlv 0x0005 in rendezvous transaction!\n"); return 0; } @@ -1055,30 +1055,43 @@ faim_export int aim_denytransfer(struct aim_session_t *sess, } /* - * Not real sure what this does, nor does anyone I've talk to. + * aim_reqicbmparaminfo() * - * Didn't use to send it. But now I think it might be a good - * idea. + * Request ICBM parameter information. * */ -faim_export unsigned long aim_seticbmparam(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_reqicbmparams(struct aim_session_t *sess, struct aim_conn_t *conn) +{ + return aim_genericreq_n(sess, conn, 0x0004, 0x0004); +} + +/* + * + */ +faim_export unsigned long aim_seticbmparam(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_icbmparameters *params) { struct command_tx_struct *newpacket; int curbyte; + if (!sess || !conn || !params) + return -EINVAL; + if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+16))) return -ENOMEM; newpacket->lock = 1; curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid++); - curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); /* max channel?? */ - curbyte += aimutil_put32(newpacket->data+curbyte, 0x00000003); /* default flags?? */ - curbyte += aimutil_put16(newpacket->data+curbyte, 0x1f40); /* max msg size */ - curbyte += aimutil_put16(newpacket->data+curbyte, 0x03e7); /* maxsenderwarn */ - curbyte += aimutil_put16(newpacket->data+curbyte, 0x03e7); /* max recver warn */ - curbyte += aimutil_put32(newpacket->data+curbyte, 0x00000000); /* min msg interval */ + + /* This is read-only (in Parameter Reply). Must be set to zero here. */ + curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); + + /* These are all read-write */ + curbyte += aimutil_put32(newpacket->data+curbyte, params->flags); + curbyte += aimutil_put16(newpacket->data+curbyte, params->maxmsglen); + curbyte += aimutil_put16(newpacket->data+curbyte, params->maxsenderwarn); + curbyte += aimutil_put16(newpacket->data+curbyte, params->maxrecverwarn); + curbyte += aimutil_put32(newpacket->data+curbyte, params->minmsginterval); newpacket->lock = 0; aim_tx_enqueue(sess, newpacket); @@ -1088,31 +1101,30 @@ faim_export unsigned long aim_seticbmparam(struct aim_session_t *sess, static int paraminfo(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - unsigned long defflags, minmsginterval; - unsigned short maxicbmlen, maxsenderwarn, maxrecverwarn, maxchannel; + struct aim_icbmparameters params; aim_rxcallback_t userfunc; int i = 0; - maxchannel = aimutil_get16(data+i); + params.maxchan = aimutil_get16(data+i); i += 2; - defflags = aimutil_get32(data+i); + params.flags = aimutil_get32(data+i); i += 4; - maxicbmlen = aimutil_get16(data+i); + params.maxmsglen = aimutil_get16(data+i); i += 2; - maxsenderwarn = aimutil_get16(data+i); + params.maxsenderwarn = aimutil_get16(data+i); i += 2; - maxrecverwarn = aimutil_get16(data+i); + params.maxrecverwarn = aimutil_get16(data+i); i += 2; - minmsginterval = aimutil_get32(data+i); + params.minmsginterval = aimutil_get32(data+i); i += 4; if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - return userfunc(sess, rx, maxchannel, defflags, maxicbmlen, maxsenderwarn, maxrecverwarn, minmsginterval); + return userfunc(sess, rx, ¶ms); return 0; } diff --git a/src/login.c b/src/login.c index 4bd026e..041f823 100644 --- a/src/login.c +++ b/src/login.c @@ -12,23 +12,23 @@ static int aim_encode_password(const char *password, unsigned char *encoded); -faim_export int aim_sendconnack(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export int aim_sendflapver(struct aim_session_t *sess, struct aim_conn_t *conn) { - int curbyte=0; - - struct command_tx_struct *newpacket; + int curbyte=0; - if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0001, 4))) - return -1; + struct command_tx_struct *newpacket; - newpacket->lock = 1; - - curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); - curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); + if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0001, 4))) + return -ENOMEM; - newpacket->lock = 0; - return aim_tx_enqueue(sess, newpacket); + newpacket->lock = 1; + + curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); + curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); + + newpacket->lock = 0; + + return aim_tx_enqueue(sess, newpacket); } /* @@ -39,81 +39,82 @@ faim_export int aim_sendconnack(struct aim_session_t *sess, * a 0017/0007 comes back, which is the signal to send * it the main login command (0017/0002). */ -faim_export int aim_request_login(struct aim_session_t *sess, - struct aim_conn_t *conn, - char *sn) +faim_export int aim_request_login(struct aim_session_t *sess, struct aim_conn_t *conn, const char *sn) { - int curbyte; - struct command_tx_struct *newpacket; - - if (!sess || !conn || !sn) - return -1; - - /* - * For ICQ, we enable the ancient horrible login and stuff - * a key packet into the queue to make it look like we got - * a reply back. This is so the client doesn't know we're - * really not doing MD5 login. - * - * This may sound stupid, but I'm not in the best of moods and - * I don't plan to keep support for this crap around much longer. - * Its all AOL's fault anyway, really. I hate AOL. Really. They - * always seem to be able to piss me off by doing the dumbest little - * things. Like disabling MD5 logins for ICQ UINs, or adding purposefully - * wrong TLV lengths, or adding superfluous information to host strings, - * or... I'll stop. - * - */ - if ((sn[0] >= '0') && (sn[0] <= '9')) { - struct command_rx_struct *newrx; - int i; - - if (!(newrx = (struct command_rx_struct *)malloc(sizeof(struct command_rx_struct)))) - return -1; - memset(newrx, 0x00, sizeof(struct command_rx_struct)); - newrx->lock = 1; - newrx->hdrtype = AIM_FRAMETYPE_OSCAR; - newrx->hdr.oscar.type = 0x02; - newrx->hdr.oscar.seqnum = 0; - newrx->commandlen = 10+2+1; - newrx->nofree = 0; - if (!(newrx->data = malloc(newrx->commandlen))) { - free(newrx); - return -1; - } - - i = aim_putsnac(newrx->data, 0x0017, 0x0007, 0x0000, 0x0000); - i += aimutil_put16(newrx->data+i, 0x01); - i += aimutil_putstr(newrx->data+i, "0", 1); - - newrx->conn = conn; - - newrx->next = sess->queue_incoming; - sess->queue_incoming = newrx; - - newrx->lock = 0; - - sess->flags &= ~AIM_SESS_FLAGS_SNACLOGIN; - - return 0; - } - - sess->flags |= AIM_SESS_FLAGS_SNACLOGIN; - - aim_sendconnack(sess, conn); - - if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+2+2+strlen(sn)))) - return -1; - - newpacket->lock = 1; - - curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0006, 0x0000, 0x00010000); - curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn); - - newpacket->commandlen = curbyte; - newpacket->lock = 0; - - return aim_tx_enqueue(sess, newpacket); + int curbyte; + struct command_tx_struct *newpacket; + + if (!sess || !conn || !sn) + return -EINVAL; + + /* + * For ICQ, we enable the ancient horrible login and stuff + * a key packet into the queue to make it look like we got + * a reply back. This is so the client doesn't know we're + * really not doing MD5 login. + * + * This may sound stupid, but I'm not in the best of moods and + * I don't plan to keep support for this crap around much longer. + * Its all AOL's fault anyway, really. I hate AOL. Really. They + * always seem to be able to piss me off by doing the dumbest little + * things. Like disabling MD5 logins for ICQ UINs, or adding + * purposefully wrong TLV lengths, or adding superfluous information + * to host strings, or... I'll stop. + * + */ + if ((sn[0] >= '0') && (sn[0] <= '9')) { + struct command_rx_struct *newrx; + int i; + + /* XXX Uhm why doesn't this use aim_tx_new? */ + if (!(newrx = (struct command_rx_struct *)malloc(sizeof(struct command_rx_struct)))) + return -ENOMEM; + + memset(newrx, 0x00, sizeof(struct command_rx_struct)); + newrx->lock = 1; + newrx->hdrtype = AIM_FRAMETYPE_OSCAR; + newrx->hdr.oscar.type = 0x02; + newrx->hdr.oscar.seqnum = 0; + newrx->commandlen = 10+2+1; + newrx->nofree = 0; + + if (!(newrx->data = malloc(newrx->commandlen))) { + free(newrx); + return -ENOMEM; + } + + i = aim_putsnac(newrx->data, 0x0017, 0x0007, 0x0000, 0x0000); + i += aimutil_put16(newrx->data+i, 0x01); + i += aimutil_putstr(newrx->data+i, "0", 1); + + newrx->conn = conn; + + newrx->next = sess->queue_incoming; + sess->queue_incoming = newrx; + + newrx->lock = 0; + + sess->flags &= ~AIM_SESS_FLAGS_SNACLOGIN; + + return 0; + } + + sess->flags |= AIM_SESS_FLAGS_SNACLOGIN; + + aim_sendflapver(sess, conn); + + if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+2+2+strlen(sn)))) + return -ENOMEM; + + newpacket->lock = 1; + + curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0006, 0x0000, 0x00010000); + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn); + + newpacket->commandlen = curbyte; + newpacket->lock = 0; + + return aim_tx_enqueue(sess, newpacket); } /* @@ -175,93 +176,89 @@ faim_export int aim_request_login(struct aim_session_t *sess, * serverstore = 0x01 * */ -faim_export int aim_send_login (struct aim_session_t *sess, - struct aim_conn_t *conn, - char *sn, char *password, - struct client_info_s *clientinfo, - char *key) +faim_export int aim_send_login (struct aim_session_t *sess, struct aim_conn_t *conn, char *sn, char *password, struct client_info_s *clientinfo, char *key) { - int curbyte=0; - struct command_tx_struct *newpacket; - - if (!clientinfo || !sn || !password) - return -1; - - if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152))) - return -1; - - newpacket->lock = 1; - - newpacket->hdr.oscar.type = (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)?0x02:0x01; - - if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) - curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0002, 0x0000, 0x00010000); - else { - curbyte = aimutil_put16(newpacket->data, 0x0000); - curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); - } - - curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn); - - if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) { - unsigned char digest[16]; - - aim_encode_password_md5(password, key, digest); - curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0025, 16, (char *)digest); - } else { - char *password_encoded; - - password_encoded = (char *) malloc(strlen(password)); - aim_encode_password(password, password_encoded); - curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0002, strlen(password), password_encoded); - free(password_encoded); - } - - curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring); - - if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) { - - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, (unsigned short)clientinfo->major2); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, (unsigned short)clientinfo->major); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, (unsigned short)clientinfo->minor); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, (unsigned short)clientinfo->minor2); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, (unsigned short)clientinfo->build); - - } else { - /* Use very specific version numbers, to further indicate the hack. */ - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, 0x010a); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, 0x0004); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, 0x003c); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, 0x0cce); - curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055); - } - - curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, strlen(clientinfo->country), clientinfo->country); - curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, strlen(clientinfo->lang), clientinfo->lang); - - if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) { - curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015); - } - - newpacket->commandlen = curbyte; - - newpacket->lock = 0; - return aim_tx_enqueue(sess, newpacket); + int curbyte=0; + struct command_tx_struct *newpacket; + + if (!clientinfo || !sn || !password) + return -EINVAL; + + if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152))) + return -ENOMEM; + + newpacket->lock = 1; + + newpacket->hdr.oscar.type = (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)?0x02:0x01; + + if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) + curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0002, 0x0000, 0x00010000); + else { + curbyte = aimutil_put16(newpacket->data, 0x0000); + curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); + } + + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn); + + if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) { + unsigned char digest[16]; + + aim_encode_password_md5(password, key, digest); + curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0025, 16, (char *)digest); + } else { + char *password_encoded; + + password_encoded = (char *) malloc(strlen(password)); + aim_encode_password(password, password_encoded); + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0002, strlen(password), password_encoded); + free(password_encoded); + } + + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring); + + if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) { + + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, (unsigned short)clientinfo->major2); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, (unsigned short)clientinfo->major); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, (unsigned short)clientinfo->minor); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, (unsigned short)clientinfo->minor2); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, (unsigned short)clientinfo->build); + + } else { + /* Use very specific version numbers, to further indicate the hack. */ + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, 0x010a); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, 0x0004); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, 0x003c); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, 0x0cce); + curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055); + } + + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, strlen(clientinfo->country), clientinfo->country); + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, strlen(clientinfo->lang), clientinfo->lang); + + if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) { + curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015); + } + + newpacket->commandlen = curbyte; + newpacket->lock = 0; + + return aim_tx_enqueue(sess, newpacket); } faim_export int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest) { - md5_state_t state; + md5_state_t state; - md5_init(&state); - md5_append(&state, (const md5_byte_t *)key, strlen(key)); - md5_append(&state, (const md5_byte_t *)password, strlen(password)); - md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); - md5_finish(&state, (md5_byte_t *)digest); + md5_init(&state); + md5_append(&state, (const md5_byte_t *)key, strlen(key)); + md5_append(&state, (const md5_byte_t *)password, strlen(password)); + md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); + md5_finish(&state, (md5_byte_t *)digest); - return 0; + return 0; } /** @@ -283,26 +280,25 @@ faim_export int aim_encode_password_md5(const char *password, const char *key, u */ static int aim_encode_password(const char *password, unsigned char *encoded) { - u_char encoding_table[] = { + unsigned char encoding_table[] = { #if 0 /* old v1 table */ - 0xf3, 0xb3, 0x6c, 0x99, - 0x95, 0x3f, 0xac, 0xb6, - 0xc5, 0xfa, 0x6b, 0x63, - 0x69, 0x6c, 0xc3, 0x9f + 0xf3, 0xb3, 0x6c, 0x99, + 0x95, 0x3f, 0xac, 0xb6, + 0xc5, 0xfa, 0x6b, 0x63, + 0x69, 0x6c, 0xc3, 0x9f #else /* v2.1 table, also works for ICQ */ - 0xf3, 0x26, 0x81, 0xc4, - 0x39, 0x86, 0xdb, 0x92, - 0x71, 0xa3, 0xb9, 0xe6, - 0x53, 0x7a, 0x95, 0x7c + 0xf3, 0x26, 0x81, 0xc4, + 0x39, 0x86, 0xdb, 0x92, + 0x71, 0xa3, 0xb9, 0xe6, + 0x53, 0x7a, 0x95, 0x7c #endif - }; + }; + int i; - int i; - - for (i = 0; i < strlen(password); i++) - encoded[i] = (password[i] ^ encoding_table[i]); + for (i = 0; i < strlen(password); i++) + encoded[i] = (password[i] ^ encoding_table[i]); - return 0; + return 0; } /* @@ -318,33 +314,33 @@ faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess, char *cookie, char *email, int regstatus) { - struct command_tx_struct *tx; - struct aim_tlvlist_t *tlvlist = NULL; - - if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0004, 1152))) - return -1; - - tx->lock = 1; - - if (sn) - aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn)); - else - aim_addtlvtochain_str(&tlvlist, 0x0001, sess->sn, strlen(sess->sn)); - - if (errorcode) { - aim_addtlvtochain16(&tlvlist, 0x0008, errorcode); - aim_addtlvtochain_str(&tlvlist, 0x0004, errorurl, strlen(errorurl)); - } else { - aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip)); - aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN); - aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email)); - aim_addtlvtochain16(&tlvlist, 0x0013, (unsigned short)regstatus); - } - - tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist); - tx->lock = 0; - - return aim_tx_enqueue(sess, tx); + struct command_tx_struct *tx; + struct aim_tlvlist_t *tlvlist = NULL; + + if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0004, 1152))) + return -ENOMEM; + + tx->lock = 1; + + if (sn) + aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn)); + else + aim_addtlvtochain_str(&tlvlist, 0x0001, sess->sn, strlen(sess->sn)); + + if (errorcode) { + aim_addtlvtochain16(&tlvlist, 0x0008, errorcode); + aim_addtlvtochain_str(&tlvlist, 0x0004, errorurl, strlen(errorurl)); + } else { + aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip)); + aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN); + aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email)); + aim_addtlvtochain16(&tlvlist, 0x0013, (unsigned short)regstatus); + } + + tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist); + tx->lock = 0; + + return aim_tx_enqueue(sess, tx); } /* @@ -352,14 +348,14 @@ faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess, */ faim_export int aim_gencookie(unsigned char *buf) { - int i; + int i; - srand(time(NULL)); + srand(time(NULL)); - for (i=0; i < AIM_COOKIELEN; i++) - buf[i] = 1+(int) (256.0*rand()/(RAND_MAX+0.0)); + for (i=0; i < AIM_COOKIELEN; i++) + buf[i] = 1+(int) (256.0*rand()/(RAND_MAX+0.0)); - return i; + return i; } /* @@ -367,135 +363,132 @@ faim_export int aim_gencookie(unsigned char *buf) */ faim_export int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn) { - struct command_tx_struct *tx; - int i = 0; - - if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+0x22))) - return -1; - - tx->lock = 1; - - i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++); - - i += aimutil_put16(tx->data+i, 0x0001); - i += aimutil_put16(tx->data+i, 0x0002); - i += aimutil_put16(tx->data+i, 0x0003); - i += aimutil_put16(tx->data+i, 0x0004); - i += aimutil_put16(tx->data+i, 0x0006); - i += aimutil_put16(tx->data+i, 0x0008); - i += aimutil_put16(tx->data+i, 0x0009); - i += aimutil_put16(tx->data+i, 0x000a); - i += aimutil_put16(tx->data+i, 0x000b); - i += aimutil_put16(tx->data+i, 0x000c); - i += aimutil_put16(tx->data+i, 0x0013); - i += aimutil_put16(tx->data+i, 0x0015); - - tx->commandlen = i; - tx->lock = 0; - return aim_tx_enqueue(sess, tx); + struct command_tx_struct *tx; + int i; + + if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+0x22))) + return -ENOMEM; + + tx->lock = 1; + + i = aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++); + + i += aimutil_put16(tx->data+i, 0x0001); + i += aimutil_put16(tx->data+i, 0x0002); + i += aimutil_put16(tx->data+i, 0x0003); + i += aimutil_put16(tx->data+i, 0x0004); + i += aimutil_put16(tx->data+i, 0x0006); + i += aimutil_put16(tx->data+i, 0x0008); + i += aimutil_put16(tx->data+i, 0x0009); + i += aimutil_put16(tx->data+i, 0x000a); + i += aimutil_put16(tx->data+i, 0x000b); + i += aimutil_put16(tx->data+i, 0x000c); + i += aimutil_put16(tx->data+i, 0x0013); + i += aimutil_put16(tx->data+i, 0x0015); + + tx->commandlen = i; + tx->lock = 0; + + return aim_tx_enqueue(sess, tx); } /* * Send service redirect. (Non-Client) */ -faim_export unsigned long aim_sendredirect(struct aim_session_t *sess, - struct aim_conn_t *conn, - unsigned short servid, - char *ip, - char *cookie) +faim_export unsigned long aim_sendredirect(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned short servid, char *ip, char *cookie) { - struct command_tx_struct *tx; - struct aim_tlvlist_t *tlvlist = NULL; - int i = 0; + struct command_tx_struct *tx; + struct aim_tlvlist_t *tlvlist = NULL; + int i; + + if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152))) + return -ENOMEM; - if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152))) - return -1; + tx->lock = 1; - tx->lock = 1; + i = aim_putsnac(tx->data, 0x0001, 0x0005, 0x0000, 0x00000000); - i += aim_putsnac(tx->data+i, 0x0001, 0x0005, 0x0000, 0x00000000); - - aim_addtlvtochain16(&tlvlist, 0x000d, servid); - aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip)); - aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN); + aim_addtlvtochain16(&tlvlist, 0x000d, servid); + aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip)); + aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN); - tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i; - aim_freetlvchain(&tlvlist); + tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i; + aim_freetlvchain(&tlvlist); - tx->lock = 0; - return aim_tx_enqueue(sess, tx); + tx->lock = 0; + + return aim_tx_enqueue(sess, tx); } static int hostonline(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - aim_rxcallback_t userfunc; - int ret = 0; - unsigned short *families; - int famcount, i; + aim_rxcallback_t userfunc; + int ret = 0; + unsigned short *families; + int famcount, i; - famcount = datalen/2; + famcount = datalen/2; - if (!(families = malloc(datalen))) - return 0; + if (!(families = malloc(datalen))) + return 0; - for (i = 0; i < famcount; i++) - families[i] = aimutil_get16(data+(i*2)); + for (i = 0; i < famcount; i++) + families[i] = aimutil_get16(data+(i*2)); - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - ret = userfunc(sess, rx, famcount, families); + if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) + ret = userfunc(sess, rx, famcount, families); - free(families); + free(families); - return ret; + return ret; } static int redirect(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - int serviceid; - unsigned char *cookie; - char *ip; - aim_rxcallback_t userfunc; - struct aim_tlvlist_t *tlvlist; - char *chathack = NULL; - int chathackex = 0; - int ret = 0; - - tlvlist = aim_readtlvchain(data, datalen); - - if (!aim_gettlv(tlvlist, 0x000d, 1) || - !aim_gettlv(tlvlist, 0x0005, 1) || - !aim_gettlv(tlvlist, 0x0006, 1)) { - aim_freetlvchain(&tlvlist); - return 0; - } - - serviceid = aim_gettlv16(tlvlist, 0x000d, 1); - ip = aim_gettlv_str(tlvlist, 0x0005, 1); - cookie = aim_gettlv_str(tlvlist, 0x0006, 1); - - /* - * Chat hack. - * - */ - if ((serviceid == AIM_CONN_TYPE_CHAT) && sess->pendingjoin) { - chathack = sess->pendingjoin; - chathackex = sess->pendingjoinexchange; - sess->pendingjoin = NULL; - sess->pendingjoinexchange = 0; - } - - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - ret = userfunc(sess, rx, serviceid, ip, cookie, chathack, chathackex); - - free(ip); - free(cookie); - free(chathack); - - aim_freetlvchain(&tlvlist); - - return ret; + int serviceid; + unsigned char *cookie; + char *ip; + aim_rxcallback_t userfunc; + struct aim_tlvlist_t *tlvlist; + char *chathack = NULL; + int chathackex = 0; + int ret = 0; + + tlvlist = aim_readtlvchain(data, datalen); + + if (!aim_gettlv(tlvlist, 0x000d, 1) || + !aim_gettlv(tlvlist, 0x0005, 1) || + !aim_gettlv(tlvlist, 0x0006, 1)) { + aim_freetlvchain(&tlvlist); + return 0; + } + + serviceid = aim_gettlv16(tlvlist, 0x000d, 1); + ip = aim_gettlv_str(tlvlist, 0x0005, 1); + cookie = aim_gettlv_str(tlvlist, 0x0006, 1); + + /* + * Chat hack. + */ + if ((serviceid == AIM_CONN_TYPE_CHAT) && sess->pendingjoin) { + chathack = sess->pendingjoin; + chathackex = sess->pendingjoinexchange; + sess->pendingjoin = NULL; + sess->pendingjoinexchange = 0; + } + + if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) + ret = userfunc(sess, rx, serviceid, ip, cookie, chathack, chathackex); + + free(ip); + free(cookie); + free(chathack); + + aim_freetlvchain(&tlvlist); + + return ret; } /* @@ -551,127 +544,127 @@ static int redirect(struct aim_session_t *sess, aim_module_t *mod, struct comman /* XXX parse this */ static int rateresp(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - aim_rxcallback_t userfunc; + aim_rxcallback_t userfunc; - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - return userfunc(sess, rx); + if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) + return userfunc(sess, rx); - return 0; + return 0; } static int ratechange(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - aim_rxcallback_t userfunc; - int i = 0, code; - unsigned long currentavg, maxavg; - unsigned long rateclass, windowsize, clear, alert, limit, disconnect; - - code = aimutil_get16(data+i); - i += 2; - - rateclass = aimutil_get16(data+i); - i += 2; - - windowsize = aimutil_get32(data+i); - i += 4; - clear = aimutil_get32(data+i); - i += 4; - alert = aimutil_get32(data+i); - i += 4; - limit = aimutil_get32(data+i); - i += 4; - disconnect = aimutil_get32(data+i); - i += 4; - currentavg = aimutil_get32(data+i); - i += 4; - maxavg = aimutil_get32(data+i); - i += 4; - - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - return userfunc(sess, rx, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg, maxavg); - - return 0; + aim_rxcallback_t userfunc; + int i = 0, code; + unsigned long currentavg, maxavg; + unsigned long rateclass, windowsize, clear, alert, limit, disconnect; + + code = aimutil_get16(data+i); + i += 2; + + rateclass = aimutil_get16(data+i); + i += 2; + + windowsize = aimutil_get32(data+i); + i += 4; + clear = aimutil_get32(data+i); + i += 4; + alert = aimutil_get32(data+i); + i += 4; + limit = aimutil_get32(data+i); + i += 4; + disconnect = aimutil_get32(data+i); + i += 4; + currentavg = aimutil_get32(data+i); + i += 4; + maxavg = aimutil_get32(data+i); + i += 4; + + if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) + return userfunc(sess, rx, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg, maxavg); + + return 0; } /* XXX parse this */ static int selfinfo(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - aim_rxcallback_t userfunc; + aim_rxcallback_t userfunc; - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - return userfunc(sess, rx); + if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) + return userfunc(sess, rx); - return 0; + return 0; } static int evilnotify(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - aim_rxcallback_t userfunc = NULL; - int i = 0; - unsigned short newevil; - struct aim_userinfo_s userinfo; + aim_rxcallback_t userfunc = NULL; + int i = 0; + unsigned short newevil; + struct aim_userinfo_s userinfo; + + newevil = aimutil_get16(data); + i += 2; - newevil = aimutil_get16(data); - i += 2; + memset(&userinfo, 0, sizeof(struct aim_userinfo_s)); - memset(&userinfo, 0, sizeof(struct aim_userinfo_s)); + if (datalen-i) + i += aim_extractuserinfo(sess, data+i, &userinfo); - if (datalen-i) - i += aim_extractuserinfo(sess, data+i, &userinfo); + if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) + return userfunc(sess, rx, newevil, &userinfo); - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - return userfunc(sess, rx, newevil, &userinfo); - - return 0; + return 0; } static int motd(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - aim_rxcallback_t userfunc; - char *msg = NULL; - int ret = 0; - struct aim_tlvlist_t *tlvlist; - unsigned short id; - - /* - * Code. - * - * Valid values: - * 1 Mandatory upgrade - * 2 Advisory upgrade - * 3 System bulletin - * 4 Nothing's wrong ("top o the world" -- normal) - * - */ - id = aimutil_get16(data); - - /* - * TLVs follow - */ - if ((tlvlist = aim_readtlvchain(data+2, datalen-2))) - msg = aim_gettlv_str(tlvlist, 0x000b, 1); - - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - ret = userfunc(sess, rx, id, msg); - - free(msg); - - aim_freetlvchain(&tlvlist); - - return ret; + aim_rxcallback_t userfunc; + char *msg = NULL; + int ret = 0; + struct aim_tlvlist_t *tlvlist; + unsigned short id; + + /* + * Code. + * + * Valid values: + * 1 Mandatory upgrade + * 2 Advisory upgrade + * 3 System bulletin + * 4 Nothing's wrong ("top o the world" -- normal) + * + */ + id = aimutil_get16(data); + + /* + * TLVs follow + */ + if ((tlvlist = aim_readtlvchain(data+2, datalen-2))) + msg = aim_gettlv_str(tlvlist, 0x000b, 1); + + if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) + ret = userfunc(sess, rx, id, msg); + + free(msg); + + aim_freetlvchain(&tlvlist); + + return ret; } static int hostversions(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - aim_rxcallback_t userfunc; - int vercount; + aim_rxcallback_t userfunc; + int vercount; - vercount = datalen/4; - - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - return userfunc(sess, rx, vercount, data); + vercount = datalen/4; - return 0; + if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) + return userfunc(sess, rx, vercount, data); + + return 0; } /* @@ -713,175 +706,174 @@ static int hostversions(struct aim_session_t *sess, aim_module_t *mod, struct co */ static int memrequest(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - aim_rxcallback_t userfunc; - unsigned long offset, len; - int i = 0; - struct aim_tlvlist_t *list; - char *modname = NULL; + aim_rxcallback_t userfunc; + unsigned long offset, len; + int i = 0; + struct aim_tlvlist_t *list; + char *modname = NULL; - offset = aimutil_get32(data); - i += 4; + offset = aimutil_get32(data); + i += 4; - len = aimutil_get32(data+4); - i += 4; + len = aimutil_get32(data+4); + i += 4; - list = aim_readtlvchain(data+i, datalen-i); + list = aim_readtlvchain(data+i, datalen-i); - if (aim_gettlv(list, 0x0001, 1)) - modname = aim_gettlv_str(list, 0x0001, 1); + if (aim_gettlv(list, 0x0001, 1)) + modname = aim_gettlv_str(list, 0x0001, 1); - faimdprintf(sess, 1, "data at 0x%08lx (%d bytes) of requested\n", offset, len, modname?modname:"aim.exe"); + faimdprintf(sess, 1, "data at 0x%08lx (%d bytes) of requested\n", offset, len, modname ? modname : "aim.exe"); - if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) - return userfunc(sess, rx, offset, len, modname); + if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) + return userfunc(sess, rx, offset, len, modname); - free(modname); - aim_freetlvchain(&list); + free(modname); + aim_freetlvchain(&list); - return 0; + return 0; } static void dumpbox(struct aim_session_t *sess, unsigned char *buf, int len) { - int i = 0; + int i; + + if (!sess || !buf || !len) + return; - if (!sess || !buf || !len) - return; + faimdprintf(sess, 1, "\nDump of %d bytes at %p:", len, buf); - faimdprintf(sess, 1, "\nDump of %d bytes at %p:", len, buf); + for (i = 0; i < len; i++) { + if ((i % 8) == 0) + faimdprintf(sess, 1, "\n\t"); - for (i = 0; i < len; i++) - { - if ((i % 8) == 0) - faimdprintf(sess, 1, "\n\t"); + faimdprintf(sess, 1, "0x%2x ", buf[i]); + } - faimdprintf(sess, 1, "0x%2x ", buf[i]); - } - - faimdprintf(sess, 1, "\n\n"); + faimdprintf(sess, 1, "\n\n"); - return; + return; } faim_export int aim_sendmemblock(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned long offset, unsigned long len, const unsigned char *buf, unsigned char flag) { - struct command_tx_struct *tx; - int i = 0; + struct command_tx_struct *tx; + int i = 0; - if (!sess || !conn) - return 0; + if (!sess || !conn) + return -EINVAL; - if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+2+16))) - return -1; + if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+2+16))) + return -ENOMEM; - tx->lock = 1; + tx->lock = 1; - i = aim_putsnac(tx->data, 0x0001, 0x0020, 0x0000, sess->snac_nextid++); - i += aimutil_put16(tx->data+i, 0x0010); /* md5 is always 16 bytes */ + i = aim_putsnac(tx->data, 0x0001, 0x0020, 0x0000, sess->snac_nextid++); + i += aimutil_put16(tx->data+i, 0x0010); /* md5 is always 16 bytes */ - if ((flag == AIM_SENDMEMBLOCK_FLAG_ISHASH) && - buf && (len == 0x10)) { /* we're getting a hash */ + if ((flag == AIM_SENDMEMBLOCK_FLAG_ISHASH) && buf && (len == 0x10)) { /* we're getting a hash */ - memcpy(tx->data+i, buf, 0x10); - i += 0x10; + memcpy(tx->data+i, buf, 0x10); + i += 0x10; - } else if (buf && (len > 0)) { /* use input buffer */ - md5_state_t state; + } else if (buf && (len > 0)) { /* use input buffer */ + md5_state_t state; - md5_init(&state); - md5_append(&state, (const md5_byte_t *)buf, len); - md5_finish(&state, (md5_byte_t *)(tx->data+i)); - i += 0x10; + md5_init(&state); + md5_append(&state, (const md5_byte_t *)buf, len); + md5_finish(&state, (md5_byte_t *)(tx->data+i)); + i += 0x10; - } else if (len == 0) { /* no length, just hash NULL (buf is optional) */ - md5_state_t state; - unsigned char nil = '\0'; + } else if (len == 0) { /* no length, just hash NULL (buf is optional) */ + md5_state_t state; + unsigned char nil = '\0'; - /* - * These MD5 routines are stupid in that you have to have - * at least one append. So thats why this doesn't look - * real logical. - */ - md5_init(&state); - md5_append(&state, (const md5_byte_t *)&nil, 0); - md5_finish(&state, (md5_byte_t *)(tx->data+i)); - i += 0x10; + /* + * These MD5 routines are stupid in that you have to have + * at least one append. So thats why this doesn't look + * real logical. + */ + md5_init(&state); + md5_append(&state, (const md5_byte_t *)&nil, 0); + md5_finish(&state, (md5_byte_t *)(tx->data+i)); + i += 0x10; - } else { + } else { - /* - * This data is correct for AIM 3.5.1670. - * - * Using these blocks is as close to "legal" as you can get without - * using an AIM binary. - * - */ - if ((offset == 0x03ffffff) && (len == 0x03ffffff)) { + /* + * This data is correct for AIM 3.5.1670. + * + * Using these blocks is as close to "legal" as you can get + * without using an AIM binary. + * + */ + if ((offset == 0x03ffffff) && (len == 0x03ffffff)) { #if 1 /* with "AnrbnrAqhfzcd" */ - i += aimutil_put32(tx->data+i, 0x44a95d26); - i += aimutil_put32(tx->data+i, 0xd2490423); - i += aimutil_put32(tx->data+i, 0x93b8821f); - i += aimutil_put32(tx->data+i, 0x51c54b01); + i += aimutil_put32(tx->data+i, 0x44a95d26); + i += aimutil_put32(tx->data+i, 0xd2490423); + i += aimutil_put32(tx->data+i, 0x93b8821f); + i += aimutil_put32(tx->data+i, 0x51c54b01); #else /* no filename */ - i += aimutil_put32(tx->data+i, 0x1df8cbae); - i += aimutil_put32(tx->data+i, 0x5523b839); - i += aimutil_put32(tx->data+i, 0xa0e10db3); - i += aimutil_put32(tx->data+i, 0xa46d3b39); + i += aimutil_put32(tx->data+i, 0x1df8cbae); + i += aimutil_put32(tx->data+i, 0x5523b839); + i += aimutil_put32(tx->data+i, 0xa0e10db3); + i += aimutil_put32(tx->data+i, 0xa46d3b39); #endif - } else if ((offset == 0x00001000) && (len == 0x00000000)) { + } else if ((offset == 0x00001000) && (len == 0x00000000)) { - i += aimutil_put32(tx->data+i, 0xd41d8cd9); - i += aimutil_put32(tx->data+i, 0x8f00b204); - i += aimutil_put32(tx->data+i, 0xe9800998); - i += aimutil_put32(tx->data+i, 0xecf8427e); + i += aimutil_put32(tx->data+i, 0xd41d8cd9); + i += aimutil_put32(tx->data+i, 0x8f00b204); + i += aimutil_put32(tx->data+i, 0xe9800998); + i += aimutil_put32(tx->data+i, 0xecf8427e); - } else - faimdprintf(sess, 0, "sendmemblock: WARNING: unknown hash request\n"); + } else + faimdprintf(sess, 0, "sendmemblock: WARNING: unknown hash request\n"); - } + } - tx->commandlen = i; - tx->lock = 0; - aim_tx_enqueue(sess, tx); + tx->commandlen = i; + tx->lock = 0; + aim_tx_enqueue(sess, tx); - return 0; + return 0; } static int snachandler(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen) { - if (snac->subtype == 0x0003) - return hostonline(sess, mod, rx, snac, data, datalen); - else if (snac->subtype == 0x0005) - return redirect(sess, mod, rx, snac, data, datalen); - else if (snac->subtype == 0x0007) - return rateresp(sess, mod, rx, snac, data, datalen); - else if (snac->subtype == 0x000a) - return ratechange(sess, mod, rx, snac, data, datalen); - else if (snac->subtype == 0x000f) - return selfinfo(sess, mod, rx, snac, data, datalen); - else if (snac->subtype == 0x0010) - return evilnotify(sess, mod, rx, snac, data, datalen); - else if (snac->subtype == 0x0013) - return motd(sess, mod, rx, snac, data, datalen); - else if (snac->subtype == 0x0018) - return hostversions(sess, mod, rx, snac, data, datalen); - else if (snac->subtype == 0x001f) - return memrequest(sess, mod, rx, snac, data, datalen); - - return 0; + if (snac->subtype == 0x0003) + return hostonline(sess, mod, rx, snac, data, datalen); + else if (snac->subtype == 0x0005) + return redirect(sess, mod, rx, snac, data, datalen); + else if (snac->subtype == 0x0007) + return rateresp(sess, mod, rx, snac, data, datalen); + else if (snac->subtype == 0x000a) + return ratechange(sess, mod, rx, snac, data, datalen); + else if (snac->subtype == 0x000f) + return selfinfo(sess, mod, rx, snac, data, datalen); + else if (snac->subtype == 0x0010) + return evilnotify(sess, mod, rx, snac, data, datalen); + else if (snac->subtype == 0x0013) + return motd(sess, mod, rx, snac, data, datalen); + else if (snac->subtype == 0x0018) + return hostversions(sess, mod, rx, snac, data, datalen); + else if (snac->subtype == 0x001f) + return memrequest(sess, mod, rx, snac, data, datalen); + + return 0; } faim_internal int general_modfirst(struct aim_session_t *sess, aim_module_t *mod) { - mod->family = 0x0001; - mod->version = 0x0000; - mod->flags = 0; - strncpy(mod->name, "general", sizeof(mod->name)); - mod->snachandler = snachandler; + mod->family = 0x0001; + mod->version = 0x0000; + mod->flags = 0; + strncpy(mod->name, "general", sizeof(mod->name)); + mod->snachandler = snachandler; - return 0; + return 0; } + diff --git a/src/misc.c b/src/misc.c index dcb9780..4f1a229 100644 --- a/src/misc.c +++ b/src/misc.c @@ -669,48 +669,6 @@ faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *sess, return aim_genericreq_n(sess, conn, 0x0002, 0x0002); } -/* -* aim_bos_reqicbmparaminfo() - * - * Request ICBM parameter information. - * - */ -faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *sess, - struct aim_conn_t *conn) -{ - return aim_genericreq_n(sess, conn, 0x0004, 0x0004); -} - -/* - * Add ICBM parameter? Huh? - */ -faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess, - struct aim_conn_t *conn) -{ - struct command_tx_struct *newpacket; - int packlen = 10+16, i=0; - - if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen))) - return (sess->snac_nextid); - - newpacket->lock = 1; - - i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, 0x00000000); - - i += aimutil_put16(newpacket->data+i, 0x0000); - i += aimutil_put16(newpacket->data+i, 0x0000); - i += aimutil_put16(newpacket->data+i, 0x0003); - i += aimutil_put16(newpacket->data+i, 0x1f40); - i += aimutil_put16(newpacket->data+i, 0x03e7); - i += aimutil_put16(newpacket->data+i, 0x03e7); - i += aimutil_put16(newpacket->data+i, 0x0000); - i += aimutil_put16(newpacket->data+i, 0x0000); - - aim_tx_enqueue(sess, newpacket); - - return sess->snac_nextid; -} - /* * Set directory profile data (not the same as aim_bos_setprofile!) */ diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index c3b9dfc..610a5aa 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -169,43 +169,57 @@ static unsigned short buddyiconsum = 0; static void faimtest_debugcb(struct aim_session_t *sess, int level, const char *format, va_list va) { - vfprintf(stderr, format, va); + vfprintf(stderr, format, va); - return; + return; } int faimtest_reportinterval(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - unsigned short interval = 0; + va_list ap; + unsigned short interval = 0; - va_start(ap, command); - interval = va_arg(ap, int); - va_end(ap); + va_start(ap, command); + interval = va_arg(ap, int); + va_end(ap); - dvprintf("aim: minimum report interval: %d (seconds?)\n", interval); + dvprintf("aim: minimum report interval: %d (seconds?)\n", interval); - return 1; + if (!connected) + connected++; + +#if 0 + aim_bos_reqservice(sess, command->conn, 0x0005); /* adverts */ + aim_bos_reqservice(sess, command->conn, 0x000f); /* user directory */ + + /* Don't know what this does... */ + /* XXX sess->sn should be normalized by the 0001/000f handler */ + aim_0002_000b(sess, command->conn, sess->sn); +#endif + + aim_reqicbmparams(sess, command->conn); + + return 1; } int faimtest_flapversion(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - dvprintf("faimtest: using FLAP version %u\n", aimutil_get32(command->data)); + dvprintf("faimtest: using FLAP version %u\n", aimutil_get32(command->data)); #if 0 - /* - * This is an alternate location for starting the login process. - */ - /* XXX should do more checking to make sure its really the right AUTH conn */ - if (command->conn->type == AIM_CONN_TYPE_AUTH) { - /* do NOT send a connack/flapversion, request_login will send it if needed */ - aim_request_login(sess, command->conn, screenname); - dprintf("faimtest: login request sent\n"); - } + /* + * This is an alternate location for starting the login process. + */ + /* XXX should do more checking to make sure its really the right AUTH conn */ + if (command->conn->type == AIM_CONN_TYPE_AUTH) { + /* do NOT send a flapversion, request_login will send it if needed */ + aim_request_login(sess, command->conn, screenname); + dprintf("faimtest: login request sent\n"); + } #endif - return 1; + return 1; } /* @@ -218,17 +232,17 @@ int faimtest_flapversion(struct aim_session_t *sess, struct command_rx_struct *c */ int faimtest_conncomplete(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - struct aim_conn_t *conn; + va_list ap; + struct aim_conn_t *conn; - va_start(ap, command); - conn = va_arg(ap, struct aim_conn_t *); - va_end(ap); - - if (conn) - dvprintf("faimtest: connection on %d completed\n", conn->fd); + va_start(ap, command); + conn = va_arg(ap, struct aim_conn_t *); + va_end(ap); - return 1; + if (conn) + dvprintf("faimtest: connection on %d completed\n", conn->fd); + + return 1; } #ifdef _WIN32 @@ -240,364 +254,366 @@ int faimtest_conncomplete(struct aim_session_t *sess, struct command_rx_struct * */ int initwsa(void) { - WORD wVersionRequested; - WSADATA wsaData; + WORD wVersionRequested; + WSADATA wsaData; - wVersionRequested = MAKEWORD(2,2); - return WSAStartup(wVersionRequested, &wsaData); + wVersionRequested = MAKEWORD(2,2); + return WSAStartup(wVersionRequested, &wsaData); } #endif /* _WIN32 */ int faimtest_init(void) { - struct aim_conn_t *stdinconn = NULL; + struct aim_conn_t *stdinconn = NULL; - if (!(stdinconn = aim_newconn(&aimsess, 0, NULL))) { - dprintf("unable to create connection for stdin!\n"); - return -1; - } + if (!(stdinconn = aim_newconn(&aimsess, 0, NULL))) { + dprintf("unable to create connection for stdin!\n"); + return -1; + } - stdinconn->fd = STDIN_FILENO; + stdinconn->fd = STDIN_FILENO; - return 0; + return 0; } int logout(void) { - if (ohcaptainmycaptain) - aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), ohcaptainmycaptain, 0, "ta ta..."); + if (ohcaptainmycaptain) + aim_send_im(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS), ohcaptainmycaptain, 0, "ta ta..."); - aim_session_kill(&aimsess); + aim_session_kill(&aimsess); - if (faimtest_init() == -1) - dprintf("faimtest_init failed\n"); + if (faimtest_init() == -1) + dprintf("faimtest_init failed\n"); - return 0; + return 0; } int login(const char *sn, const char *passwd) { - struct aim_conn_t *authconn; + struct aim_conn_t *authconn; - if (sn) - screenname = strdup(sn); - if (passwd) - password = strdup(passwd); + if (sn) + screenname = strdup(sn); + if (passwd) + password = strdup(passwd); - if (proxy) - aim_setupproxy(&aimsess, proxy, proxyusername, proxypass); + if (proxy) + aim_setupproxy(&aimsess, proxy, proxyusername, proxypass); - if (!screenname || !password) { - dprintf("need SN and password\n"); - return -1; - } + if (!screenname || !password) { + dprintf("need SN and password\n"); + return -1; + } - if (!(authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, server?server:FAIM_LOGIN_SERVER))) { - dprintf("faimtest: internal connection error while in aim_login. bailing out.\n"); - return -1; - } else if (authconn->fd == -1) { - if (authconn->status & AIM_CONN_STATUS_RESOLVERR) { - dprintf("faimtest: could not resolve authorizer name\n"); - } else if (authconn->status & AIM_CONN_STATUS_CONNERR) { - dprintf("faimtest: could not connect to authorizer\n"); - } - aim_conn_kill(&aimsess, &authconn); - return -1; - } + if (!(authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, server?server:FAIM_LOGIN_SERVER))) { + dprintf("faimtest: internal connection error while in aim_login. bailing out.\n"); + return -1; + } else if (authconn->fd == -1) { + if (authconn->status & AIM_CONN_STATUS_RESOLVERR) { + dprintf("faimtest: could not resolve authorizer name\n"); + } else if (authconn->status & AIM_CONN_STATUS_CONNERR) { + dprintf("faimtest: could not connect to authorizer\n"); + } + aim_conn_kill(&aimsess, &authconn); + return -1; + } - aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0); - aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); - aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0); - aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0); + aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0); + aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); + aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0); + aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0); - aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT, faimtest_debugconn_connect, 0); + aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT, faimtest_debugconn_connect, 0); - /* If the connection is in progress, this will just be queued */ - aim_request_login(&aimsess, authconn, screenname); - dprintf("faimtest: login request sent\n"); + /* If the connection is in progress, this will just be queued */ + aim_request_login(&aimsess, authconn, screenname); + dprintf("faimtest: login request sent\n"); - return 0; + return 0; } int main(int argc, char **argv) { - struct aim_conn_t *waitingconn = NULL; - int i; - int selstat = 0; - static int faimtest_mode = 0; - struct timeval tv; - time_t lastnop = 0; - const char *buddyiconpath = NULL; - - screenname = getenv("SCREENNAME"); - password = getenv("PASSWORD"); - server = getenv("AUTHSERVER"); - proxy = getenv("SOCKSPROXY"); - proxyusername = getenv("SOCKSNAME"); - proxypass = getenv("SOCKSPASS"); - - listingpath = getenv("LISTINGPATH"); - - while ((i = getopt(argc, argv, "u:p:a:U:P:A:l:c:hoOb:i:")) != EOF) { - switch (i) { - case 'u': screenname = optarg; break; - case 'p': password = optarg; break; - case 'a': server = optarg; break; - case 'U': proxyusername = optarg; break; - case 'P': proxypass = optarg; break; - case 'A': proxy = optarg; break; - case 'l': listingpath = optarg; break; - case 'c': ohcaptainmycaptain = optarg; break; - case 'o': faimtest_mode = 1; break; /* half old interface */ - case 'O': faimtest_mode = 2; break; /* full old interface */ - case 'b': aimbinarypath = optarg; break; - case 'i': buddyiconpath = optarg; break; - case 'h': - default: - printf("faimtest\n"); - printf(" Options: \n"); - printf(" -u name Screen name ($SCREENNAME)\n"); - printf(" -p passwd Password ($PASSWORD)\n"); - printf(" -a host:port Authorizer ($AUTHSERVER)\n"); - printf(" -U name Proxy user name ($SOCKSPROXY)\n"); - printf(" -P passwd Proxy password ($SOCKSNAME)\n"); - printf(" -A host:port Proxy host ($SOCKSPASS)\n"); - printf(" -l path Path to listing file ($LISTINGPATH)\n"); - printf(" -c name Screen name of owner\n"); - printf(" -o Login at startup, then prompt\n"); - printf(" -O Login, never give prompt\n"); - printf(" -b path Path to AIM 3.5.1670 binaries\n"); - printf(" -i file Buddy Icon to send\n"); - exit(0); - } - } + struct aim_conn_t *waitingconn = NULL; + int i; + int selstat = 0; + static int faimtest_mode = 0; + struct timeval tv; + time_t lastnop = 0; + const char *buddyiconpath = NULL; + + screenname = getenv("SCREENNAME"); + password = getenv("PASSWORD"); + server = getenv("AUTHSERVER"); + proxy = getenv("SOCKSPROXY"); + proxyusername = getenv("SOCKSNAME"); + proxypass = getenv("SOCKSPASS"); + + listingpath = getenv("LISTINGPATH"); + + while ((i = getopt(argc, argv, "u:p:a:U:P:A:l:c:hoOb:i:")) != EOF) { + switch (i) { + case 'u': screenname = optarg; break; + case 'p': password = optarg; break; + case 'a': server = optarg; break; + case 'U': proxyusername = optarg; break; + case 'P': proxypass = optarg; break; + case 'A': proxy = optarg; break; + case 'l': listingpath = optarg; break; + case 'c': ohcaptainmycaptain = optarg; break; + case 'o': faimtest_mode = 1; break; /* half old interface */ + case 'O': faimtest_mode = 2; break; /* full old interface */ + case 'b': aimbinarypath = optarg; break; + case 'i': buddyiconpath = optarg; break; + case 'h': + default: + printf("faimtest\n"); + printf(" Options: \n"); + printf(" -u name Screen name ($SCREENNAME)\n"); + printf(" -p passwd Password ($PASSWORD)\n"); + printf(" -a host:port Authorizer ($AUTHSERVER)\n"); + printf(" -U name Proxy user name ($SOCKSPROXY)\n"); + printf(" -P passwd Proxy password ($SOCKSNAME)\n"); + printf(" -A host:port Proxy host ($SOCKSPASS)\n"); + printf(" -l path Path to listing file ($LISTINGPATH)\n"); + printf(" -c name Screen name of owner\n"); + printf(" -o Login at startup, then prompt\n"); + printf(" -O Login, never give prompt\n"); + printf(" -b path Path to AIM 3.5.1670 binaries\n"); + printf(" -i file Buddy Icon to send\n"); + exit(0); + } + } #ifdef _WIN32 - if (initwsa() != 0) { - dprintf("faimtest: could not initialize windows sockets\n"); - return -1; - } + if (initwsa() != 0) { + dprintf("faimtest: could not initialize windows sockets\n"); + return -1; + } #endif /* _WIN32 */ - /* Pass zero as flags if you want blocking connects */ - aim_session_init(&aimsess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 1); - aim_setdebuggingcb(&aimsess, faimtest_debugcb); /* still needed even if debuglevel = 0 ! */ - - if(listingpath) { - char *listingname; - if(!(listingname = (char *)calloc(1, strlen(listingpath)+strlen("/listing.txt")))) { - dperror("listingname calloc"); - exit(-1); - } - sprintf(listingname, "%s/listing.txt", listingpath); - if( (listingfile = fopen(listingname, "r")) == NULL) { - dvprintf("Couldn't open %s... disabling that shit.\n", listingname); - } - - free(listingname); - } - - if (buddyiconpath) { - struct stat st; - FILE *f; + /* Pass zero as flags if you want blocking connects */ + aim_session_init(&aimsess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 1); + aim_setdebuggingcb(&aimsess, faimtest_debugcb); /* still needed even if debuglevel = 0 ! */ - if ((stat(buddyiconpath, &st) != -1) && (st.st_size <= MAXICONLEN) && (f = fopen(buddyiconpath, "r"))) { + if (listingpath) { + char *listingname; + + if (!(listingname = (char *)calloc(1, strlen(listingpath)+strlen("/listing.txt")))) { + dperror("listingname calloc"); + exit(-1); + } - buddyiconlen = st.st_size; - buddyiconstamp = st.st_mtime; - buddyicon = malloc(buddyiconlen); - fread(buddyicon, 1, st.st_size, f); + sprintf(listingname, "%s/listing.txt", listingpath); + + if ((listingfile = fopen(listingname, "r")) == NULL) + dvprintf("Couldn't open %s... disabling that shit.\n", listingname); - buddyiconsum = aim_iconsum(buddyicon, buddyiconlen); + free(listingname); + } - dvprintf("read %d bytes of %s for buddy icon (sum 0x%08x)\n", buddyiconlen, buddyiconpath, buddyiconsum); + if (buddyiconpath) { + struct stat st; + FILE *f; - fclose(f); + if ((stat(buddyiconpath, &st) != -1) && (st.st_size <= MAXICONLEN) && (f = fopen(buddyiconpath, "r"))) { - } else - dvprintf("could not open buddy icon %s\n", buddyiconpath); + buddyiconlen = st.st_size; + buddyiconstamp = st.st_mtime; + buddyicon = malloc(buddyiconlen); + fread(buddyicon, 1, st.st_size, f); - } + buddyiconsum = aim_iconsum(buddyicon, buddyiconlen); - faimtest_init(); + dvprintf("read %d bytes of %s for buddy icon (sum 0x%08x)\n", buddyiconlen, buddyiconpath, buddyiconsum); - if (faimtest_mode < 2) - cmd_init(); + fclose(f); - if (faimtest_mode >= 1) { - if (login(screenname, password) == -1) { - if (faimtest_mode < 2) - cmd_uninit(); - exit(-1); - } - } + } else + dvprintf("could not open buddy icon %s\n", buddyiconpath); - while (keepgoing) { + } - tv.tv_sec = 5; - tv.tv_usec = 0; + faimtest_init(); - waitingconn = aim_select(&aimsess, &tv, &selstat); + if (faimtest_mode < 2) + cmd_init(); - if (connected && ((time(NULL) - lastnop) > 30)) { - lastnop = time(NULL); - aim_flap_nop(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)); - } + if (faimtest_mode >= 1) { + if (login(screenname, password) == -1) { + if (faimtest_mode < 2) + cmd_uninit(); + exit(-1); + } + } - if (selstat == -1) { /* error */ - keepgoing = 0; /* fall through */ - } else if (selstat == 0) { /* no events pending */ - ; - } else if (selstat == 1) { /* outgoing data pending */ - aim_tx_flushqueue(&aimsess); - } else if (selstat == 2) { /* incoming data pending */ - if ((faimtest_mode < 2) && (waitingconn->fd == STDIN_FILENO)) { - cmd_gotkey(); - } else { - if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { - if (aim_handlerendconnect(&aimsess, waitingconn) < 0) { - dprintf("connection error (rend out)\n"); - aim_conn_kill(&aimsess, &waitingconn); - } - } else { - if (aim_get_command(&aimsess, waitingconn) >= 0) { - aim_rxdispatch(&aimsess); - } else { - dvprintf("connection error (type 0x%04x:0x%04x)\n", waitingconn->type, waitingconn->subtype); - /* we should have callbacks for all these, else the library will do the conn_kill for us. */ - if(waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS) { - dprintf("connection error: rendezvous connection. you forgot register a disconnect callback, right?\n"); - aim_conn_kill(&aimsess, &waitingconn); - } else - aim_conn_kill(&aimsess, &waitingconn); - if (!aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)) { - dprintf("major connection error\n"); - if (faimtest_mode == 2) - break; - } - } + while (keepgoing) { + + tv.tv_sec = 5; + tv.tv_usec = 0; + + waitingconn = aim_select(&aimsess, &tv, &selstat); + + if (connected && ((time(NULL) - lastnop) > 30)) { + lastnop = time(NULL); + aim_flap_nop(&aimsess, aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)); + } + + if (selstat == -1) { /* error */ + keepgoing = 0; /* fall through */ + } else if (selstat == 0) { /* no events pending */ + ; + } else if (selstat == 1) { /* outgoing data pending */ + aim_tx_flushqueue(&aimsess); + } else if (selstat == 2) { /* incoming data pending */ + if ((faimtest_mode < 2) && (waitingconn->fd == STDIN_FILENO)) { + cmd_gotkey(); + } else { + if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { + if (aim_handlerendconnect(&aimsess, waitingconn) < 0) { + dprintf("connection error (rend out)\n"); + aim_conn_kill(&aimsess, &waitingconn); + } + } else { + if (aim_get_command(&aimsess, waitingconn) >= 0) { + aim_rxdispatch(&aimsess); + } else { + dvprintf("connection error (type 0x%04x:0x%04x)\n", waitingconn->type, waitingconn->subtype); + /* we should have callbacks for all these, else the library will do the conn_kill for us. */ + if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS) { + dprintf("connection error: rendezvous connection. you forgot register a disconnect callback, right?\n"); + aim_conn_kill(&aimsess, &waitingconn); + } else + aim_conn_kill(&aimsess, &waitingconn); + if (!aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)) { + dprintf("major connection error\n"); + if (faimtest_mode == 2) + break; + } + } + } + } + } } - } - } - } - /* close up all connections, dead or no */ - aim_session_kill(&aimsess); + /* close up all connections, dead or no */ + aim_session_kill(&aimsess); - if (faimtest_mode < 2) { - printf("\n"); - cmd_uninit(); - } + if (faimtest_mode < 2) { + printf("\n"); + cmd_uninit(); + } - free(buddyicon); + free(buddyicon); - /* Get out */ - exit(0); + /* Get out */ + exit(0); } int faimtest_rateresp(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - switch(command->conn->type) { - case AIM_CONN_TYPE_BOS: { - /* this is the new buddy list */ - char buddies[128]; - /* this is the new profile */ - char profile[256]; - char awaymsg[] = {"blah blah blah Ole! blah blah blah"}; - - /* Caution: Buddy1 and Buddy2 are real people! (who I don't know) */ - snprintf(buddies, sizeof(buddies), "Buddy1&Buddy2&%s&", ohcaptainmycaptain?ohcaptainmycaptain:"blah"); - snprintf(profile, sizeof(profile), "Hello.
My captain is %s. They were dumb enough to leave this message in their client, or they are using faimtest. Shame on them.", ohcaptainmycaptain); - - aim_bos_ackrateresp(sess, command->conn); /* ack rate info response */ - aim_bos_reqpersonalinfo(sess, command->conn); - aim_bos_reqlocaterights(sess, command->conn); - aim_bos_setprofile(sess, command->conn, profile, awaymsg, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE /*| AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS*/); - aim_bos_reqbuddyrights(sess, command->conn); - - /* send the buddy list and profile (required, even if empty) */ - aim_bos_setbuddylist(sess, command->conn, buddies); - - /* dont really know what this does */ - aim_addicbmparam(sess, command->conn); - aim_bos_reqicbmparaminfo(sess, command->conn); - - aim_bos_reqrights(sess, command->conn); - /* set group permissions -- all user classes */ - aim_bos_setgroupperm(sess, command->conn, AIM_FLAG_ALLUSERS); - aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE); + switch(command->conn->type) { + case AIM_CONN_TYPE_BOS: { + /* this is the new buddy list */ + char buddies[128]; + /* this is the new profile */ + char profile[256]; + char awaymsg[] = {"blah blah blah Ole! blah blah blah"}; - break; - } - case AIM_CONN_TYPE_AUTH: - aim_bos_ackrateresp(sess, command->conn); - aim_auth_clientready(sess, command->conn); - dprintf("faimtest: connected to authorization/admin service\n"); - break; + /* Caution: Buddy1 and Buddy2 are real people! (who I don't know) */ + snprintf(buddies, sizeof(buddies), "Buddy1&Buddy2&%s&", ohcaptainmycaptain?ohcaptainmycaptain:"blah"); + snprintf(profile, sizeof(profile), "Hello.
My captain is %s. They were dumb enough to leave this message in their client, or they are using faimtest. Shame on them.", ohcaptainmycaptain); - default: - dvprintf("faimtest: got rate response for unhandled connection type %04x\n", command->conn->type); - break; - } + aim_bos_ackrateresp(sess, command->conn); /* ack rate info response */ + aim_bos_reqpersonalinfo(sess, command->conn); + aim_bos_reqlocaterights(sess, command->conn); + aim_bos_setprofile(sess, command->conn, profile, awaymsg, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE /*| AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS*/); + aim_bos_reqbuddyrights(sess, command->conn); - return 1; + /* send the buddy list and profile (required, even if empty) */ + aim_bos_setbuddylist(sess, command->conn, buddies); + + aim_reqicbmparams(sess, command->conn); + + aim_bos_reqrights(sess, command->conn); + /* set group permissions -- all user classes */ + aim_bos_setgroupperm(sess, command->conn, AIM_FLAG_ALLUSERS); + aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE); + + break; + } + case AIM_CONN_TYPE_AUTH: + aim_bos_ackrateresp(sess, command->conn); + aim_auth_clientready(sess, command->conn); + dprintf("faimtest: connected to authorization/admin service\n"); + break; + + default: + dvprintf("faimtest: got rate response for unhandled connection type %04x\n", command->conn->type); + break; + } + + return 1; } static int faimtest_icbmparaminfo(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - unsigned long defflags, minmsginterval; - unsigned short maxicbmlen, maxsenderwarn, maxrecverwarn, maxchannel; - va_list ap; + struct aim_icbmparameters *params; + va_list ap; - va_start(ap, command); - maxchannel = va_arg(ap, unsigned int); - defflags = va_arg(ap, unsigned long); - maxicbmlen = va_arg(ap, unsigned int); - maxsenderwarn = va_arg(ap, unsigned int); - maxrecverwarn = va_arg(ap, unsigned int); - minmsginterval = va_arg(ap, unsigned long); - va_end(ap); + va_start(ap, command); + params = va_arg(ap, struct aim_icbmparameters *); + va_end(ap); - dvprintf("ICBM Parameters: maxchannel = %d, default flags = 0x%08lx, max msg len = %d, max sender evil = %f, max reciever evil = %f, min msg interval = %ld\n", maxchannel, defflags, maxicbmlen, ((float)maxsenderwarn)/10.0, ((float)maxrecverwarn)/10.0, minmsginterval); + dvprintf("ICBM Parameters: maxchannel = %d, default flags = 0x%08lx, max msg len = %d, max sender evil = %f, max reciever evil = %f, min msg interval = %ld\n", params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval); - return 1; + params->maxchan = 0; /* this has to be set to zero in the response */ + //params->flags = 0; + params->maxmsglen = 8000; + params->minmsginterval = 0; + + aim_seticbmparam(sess, command->conn, params); + + return 1; } int faimtest_hostversions(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - int vercount, i; - unsigned char *versions; - va_list ap; - - va_start(ap, command); - vercount = va_arg(ap, int); /* number of family/version pairs */ - versions = va_arg(ap, unsigned char *); - va_end(ap); - - dprintf("faimtest: SNAC versions supported by this host: "); - for (i = 0; i < vercount*4; i += 4) - dvinlineprintf("0x%04x:0x%04x ", - aimutil_get16(versions+i), /* SNAC family */ - aimutil_get16(versions+i+2) /* Version number */); - dinlineprintf("\n"); + int vercount, i; + unsigned char *versions; + va_list ap; + + va_start(ap, command); + vercount = va_arg(ap, int); /* number of family/version pairs */ + versions = va_arg(ap, unsigned char *); + va_end(ap); + + dprintf("faimtest: SNAC versions supported by this host: "); + for (i = 0; i < vercount*4; i += 4) { + dvinlineprintf("0x%04x:0x%04x ", + aimutil_get16(versions+i), /* SNAC family */ + aimutil_get16(versions+i+2) /* Version number */); + } + dinlineprintf("\n"); - return 1; + return 1; } int faimtest_accountconfirm(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - int status; - va_list ap; + int status; + va_list ap; - va_start(ap, command); - status = va_arg(ap, int); /* status code of confirmation request */ - va_end(ap); + va_start(ap, command); + status = va_arg(ap, int); /* status code of confirmation request */ + va_end(ap); - dvprintf("account confirmation returned status 0x%04x (%s)\n", status, (status==0x0000)?"email sent":"unknown"); + dvprintf("account confirmation returned status 0x%04x (%s)\n", status, (status==0x0000)?"email sent":"unknown"); - return 1; + return 1; } int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...) @@ -1798,85 +1814,72 @@ int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - static char *codes[] = { - "Unknown", - "Mandatory upgrade", - "Advisory upgrade", - "System bulletin", - "Top o' the world!"}; - static int codeslen = 5; - - char *msg; - unsigned short id; - va_list ap; - - va_start(ap, command); - id = va_arg(ap, int); - msg = va_arg(ap, char *); - va_end(ap); - - dvprintf("faimtest: motd: %s (%d / %s)\n", msg, id, - (id < codeslen)?codes[id]:"unknown"); + static char *codes[] = { + "Unknown", + "Mandatory upgrade", + "Advisory upgrade", + "System bulletin", + "Top o' the world!" + }; + static int codeslen = 5; + char *msg; + unsigned short id; + va_list ap; - if (!connected) - connected++; + va_start(ap, command); + id = va_arg(ap, int); + msg = va_arg(ap, char *); + va_end(ap); -#if 0 - aim_bos_reqservice(sess, command->conn, 0x0005); /* adverts */ - aim_bos_reqservice(sess, command->conn, 0x000f); /* user directory */ - - /* Don't know what this does... */ - /* XXX sess->sn should be normalized by the 0001/000f handler */ - aim_0002_000b(sess, command->conn, sess->sn); -#endif + dvprintf("faimtest: motd: %s (%d / %s)\n", msg, id, (id < codeslen)?codes[id]:"unknown"); - return 1; + return 1; } int faimtest_parse_genericerr(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - unsigned short reason; + va_list ap; + unsigned short reason; - va_start(ap, command); - reason = va_arg(ap, int); - va_end(ap); + va_start(ap, command); + reason = va_arg(ap, int); + va_end(ap); - dvprintf("faimtest: snac threw error (reason 0x%04x: %s)\n", reason, (reasonsn, reason, (reasonsn, reason, (reasonconn, screenname, password, &info, key); - - return 1; + va_start(ap, command); + key = va_arg(ap, char *); + va_end(ap); + + aim_send_login(sess, command->conn, screenname, password, &info, key); + + return 1; } int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - struct aim_userinfo_s *userinfo; - int count = 0, i = 0; - - va_start(ap, command); - count = va_arg(ap, int); - userinfo = va_arg(ap, struct aim_userinfo_s *); - va_end(ap); + va_list ap; + struct aim_userinfo_s *userinfo; + int count = 0, i = 0; - dvprintf("faimtest: chat: %s: New occupants have joined:\n", (char *)command->conn->priv); - while (i < count) - dvprintf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn); + va_start(ap, command); + count = va_arg(ap, int); + userinfo = va_arg(ap, struct aim_userinfo_s *); + va_end(ap); - return 1; + dvprintf("faimtest: chat: %s: New occupants have joined:\n", (char *)command->conn->priv); + while (i < count) + dvprintf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn); + + return 1; } int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - struct aim_userinfo_s *userinfo; - int count = 0, i = 0; - - va_start(ap, command); - count = va_arg(ap, int); - userinfo = va_arg(ap, struct aim_userinfo_s *); - va_end(ap); + va_list ap; + struct aim_userinfo_s *userinfo; + int count = 0, i = 0; - dvprintf("faimtest: chat: %s: Some occupants have left:\n", (char *)command->conn->priv); + va_start(ap, command); + count = va_arg(ap, int); + userinfo = va_arg(ap, struct aim_userinfo_s *); + va_end(ap); - for (i = 0; i < count; ) - dvprintf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn); + dvprintf("faimtest: chat: %s: Some occupants have left:\n", (char *)command->conn->priv); - return 1; + for (i = 0; i < count; ) + dvprintf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn); + + return 1; } int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - struct aim_userinfo_s *userinfo; - struct aim_chat_roominfo *roominfo; - char *roomname; - int usercount,i; - char *roomdesc; - unsigned short unknown_c9, unknown_d2, unknown_d5, maxmsglen; - unsigned long creationtime; - - va_start(ap, command); - roominfo = va_arg(ap, struct aim_chat_roominfo *); - roomname = va_arg(ap, char *); - usercount= va_arg(ap, int); - userinfo = va_arg(ap, struct aim_userinfo_s *); - roomdesc = va_arg(ap, char *); - unknown_c9 = va_arg(ap, int); - creationtime = va_arg(ap, unsigned long); - maxmsglen = va_arg(ap, int); - unknown_d2 = va_arg(ap, int); - unknown_d5 = va_arg(ap, int); - va_end(ap); - - dvprintf("faimtest: chat: %s: info update:\n", (char *)command->conn->priv); - dvprintf("faimtest: chat: %s: \tRoominfo: {%04x, %s, %04x}\n", - (char *)command->conn->priv, - roominfo->exchange, - roominfo->name, - roominfo->instance); - dvprintf("faimtest: chat: %s: \tRoomname: %s\n", (char *)command->conn->priv, roomname); - dvprintf("faimtest: chat: %s: \tRoomdesc: %s\n", (char *)command->conn->priv, roomdesc); - dvprintf("faimtest: chat: %s: \tOccupants: (%d)\n", (char *)command->conn->priv, usercount); - - for (i = 0; i < usercount; ) - dvprintf("faimtest: chat: %s: \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn); - - dvprintf("faimtest: chat: %s: \tUnknown_c9: 0x%04x\n", (char *)command->conn->priv, unknown_c9); - dvprintf("faimtest: chat: %s: \tCreation time: %lu (time_t)\n", (char *)command->conn->priv, creationtime); - dvprintf("faimtest: chat: %s: \tMax message length: %d bytes\n", (char *)command->conn->priv, maxmsglen); - dvprintf("faimtest: chat: %s: \tUnknown_d2: 0x%04x\n", (char *)command->conn->priv, unknown_d2); - dvprintf("faimtest: chat: %s: \tUnknown_d5: 0x%02x\n", (char *)command->conn->priv, unknown_d5); - - return 1; + va_list ap; + struct aim_userinfo_s *userinfo; + struct aim_chat_roominfo *roominfo; + char *roomname; + int usercount,i; + char *roomdesc; + unsigned short unknown_c9, unknown_d2, unknown_d5, maxmsglen; + unsigned long creationtime; + + va_start(ap, command); + roominfo = va_arg(ap, struct aim_chat_roominfo *); + roomname = va_arg(ap, char *); + usercount= va_arg(ap, int); + userinfo = va_arg(ap, struct aim_userinfo_s *); + roomdesc = va_arg(ap, char *); + unknown_c9 = va_arg(ap, int); + creationtime = va_arg(ap, unsigned long); + maxmsglen = va_arg(ap, int); + unknown_d2 = va_arg(ap, int); + unknown_d5 = va_arg(ap, int); + va_end(ap); + + dvprintf("faimtest: chat: %s: info update:\n", (char *)command->conn->priv); + dvprintf("faimtest: chat: %s: \tRoominfo: {%04x, %s, %04x}\n", (char *)command->conn->priv, roominfo->exchange, roominfo->name, roominfo->instance); + dvprintf("faimtest: chat: %s: \tRoomname: %s\n", (char *)command->conn->priv, roomname); + dvprintf("faimtest: chat: %s: \tRoomdesc: %s\n", (char *)command->conn->priv, roomdesc); + dvprintf("faimtest: chat: %s: \tOccupants: (%d)\n", (char *)command->conn->priv, usercount); + + for (i = 0; i < usercount; ) + dvprintf("faimtest: chat: %s: \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn); + + dvprintf("faimtest: chat: %s: \tUnknown_c9: 0x%04x\n", (char *)command->conn->priv, unknown_c9); + dvprintf("faimtest: chat: %s: \tCreation time: %lu (time_t)\n", (char *)command->conn->priv, creationtime); + dvprintf("faimtest: chat: %s: \tMax message length: %d bytes\n", (char *)command->conn->priv, maxmsglen); + dvprintf("faimtest: chat: %s: \tUnknown_d2: 0x%04x\n", (char *)command->conn->priv, unknown_d2); + dvprintf("faimtest: chat: %s: \tUnknown_d5: 0x%02x\n", (char *)command->conn->priv, unknown_d5); + + return 1; } int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - struct aim_userinfo_s *userinfo; - char *msg; - char tmpbuf[1152]; - - va_start(ap, command); - userinfo = va_arg(ap, struct aim_userinfo_s *); - msg = va_arg(ap, char *); - va_end(ap); - - dvprintf("faimtest: chat: %s: incoming msg from %s: %s\n", (char *)command->conn->priv, userinfo->sn, msg); - - /* - * Do an echo for testing purposes. But not for ourselves ("oops!") - */ - if (strcmp(userinfo->sn, sess->sn) != 0) - { - sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg); - aim_chat_send_im(sess, command->conn, 0, tmpbuf, strlen(tmpbuf)); - } + va_list ap; + struct aim_userinfo_s *userinfo; + char *msg; + char tmpbuf[1152]; + + va_start(ap, command); + userinfo = va_arg(ap, struct aim_userinfo_s *); + msg = va_arg(ap, char *); + va_end(ap); + + dvprintf("faimtest: chat: %s: incoming msg from %s: %s\n", (char *)command->conn->priv, userinfo->sn, msg); + + /* + * Do an echo for testing purposes. But not for ourselves ("oops!") + */ + if (strcmp(userinfo->sn, sess->sn) != 0) { + sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg); + aim_chat_send_im(sess, command->conn, 0, tmpbuf, strlen(tmpbuf)); + } - return 1; + return 1; } int faimtest_chatnav_info(struct aim_session_t *sess, struct command_rx_struct *command, ...) @@ -2093,37 +2095,37 @@ int faimtest_chatnav_info(struct aim_session_t *sess, struct command_rx_struct * int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - unsigned short code; - char *msg = NULL; + va_list ap; + unsigned short code; + char *msg = NULL; - va_start(ap, command); - code = va_arg(ap, int); - msg = va_arg(ap, char *); - va_end(ap); + va_start(ap, command); + code = va_arg(ap, int); + msg = va_arg(ap, char *); + va_end(ap); - dvprintf("faimtest: connerr: Code 0x%04x: %s\n", code, msg); - aim_conn_kill(sess, &command->conn); /* this will break the main loop */ + dvprintf("faimtest: connerr: Code 0x%04x: %s\n", code, msg); + aim_conn_kill(sess, &command->conn); /* this will break the main loop */ - connected = 0; + connected = 0; - return 1; + return 1; } int faimtest_debugconn_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - dprintf("faimtest: connecting to an aimdebugd!\n"); + dprintf("faimtest: connecting to an aimdebugd!\n"); - /* convert the authorizer connection to a BOS connection */ - command->conn->type = AIM_CONN_TYPE_BOS; + /* convert the authorizer connection to a BOS connection */ + command->conn->type = AIM_CONN_TYPE_BOS; - aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0); + aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0); - /* tell the aimddebugd we're ready */ - aim_debugconn_sendconnect(sess, command->conn); + /* tell the aimddebugd we're ready */ + aim_debugconn_sendconnect(sess, command->conn); - /* go right into main loop (don't open a BOS connection, etc) */ - return 1; + /* go right into main loop (don't open a BOS connection, etc) */ + return 1; } /* @@ -2131,36 +2133,36 @@ int faimtest_debugconn_connect(struct aim_session_t *sess, struct command_rx_str */ int faimtest_parse_msgack(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - unsigned short type; - char *sn = NULL; + va_list ap; + unsigned short type; + char *sn = NULL; - va_start(ap, command); - type = va_arg(ap, int); - sn = va_arg(ap, char *); - va_end(ap); + va_start(ap, command); + type = va_arg(ap, int); + sn = va_arg(ap, char *); + va_end(ap); - dvprintf("faimtest: msgack: 0x%04x / %s\n", type, sn); + dvprintf("faimtest: msgack: 0x%04x / %s\n", type, sn); - return 1; + return 1; } int faimtest_getfile_filereq(struct aim_session_t *ses, struct command_rx_struct *command, ...) { - va_list ap; - struct aim_conn_t *oftconn; - struct aim_fileheader_t *fh; - char *cookie; + va_list ap; + struct aim_conn_t *oftconn; + struct aim_fileheader_t *fh; + char *cookie; - va_start(ap, command); - oftconn = va_arg(ap, struct aim_conn_t *); - fh = va_arg(ap, struct aim_fileheader_t *); - cookie = va_arg(ap, char *); - va_end(ap); + va_start(ap, command); + oftconn = va_arg(ap, struct aim_conn_t *); + fh = va_arg(ap, struct aim_fileheader_t *); + cookie = va_arg(ap, char *); + va_end(ap); - dvprintf("faimtest: request for file %s.\n", fh->name); + dvprintf("faimtest: request for file %s.\n", fh->name); - return 1; + return 1; } @@ -2272,6 +2274,7 @@ int faimtest_getfile_disconnect(struct aim_session_t *sess, struct command_rx_st dvprintf("faimtest: getfile: disconnected from %s\n", sn); return 1; } + int faimtest_getfile_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...) { va_list ap; @@ -2519,59 +2522,59 @@ int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_stru int faimtest_parse_evilnotify(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - int newevil; - struct aim_userinfo_s *userinfo; + va_list ap; + int newevil; + struct aim_userinfo_s *userinfo; - va_start(ap, command); - newevil = va_arg(ap, int); - userinfo = va_arg(ap, struct aim_userinfo_s *); - va_end(ap); + va_start(ap, command); + newevil = va_arg(ap, int); + userinfo = va_arg(ap, struct aim_userinfo_s *); + va_end(ap); - /* - * Evil Notifications that are lacking userinfo->sn are anon-warns - * if they are an evil increases, but are not warnings at all if its - * a decrease (its the natural backoff happening). - * - * newevil is passed as an int representing the new evil value times - * ten. - */ - dvprintf("faimtest: evil level change: new value = %2.1f%% (caused by %s)\n", ((float)newevil)/10, (userinfo && strlen(userinfo->sn))?userinfo->sn:"anonymous"); + /* + * Evil Notifications that are lacking userinfo->sn are anon-warns + * if they are an evil increases, but are not warnings at all if its + * a decrease (its the natural backoff happening). + * + * newevil is passed as an int representing the new evil value times + * ten. + */ + dvprintf("faimtest: evil level change: new value = %2.1f%% (caused by %s)\n", ((float)newevil)/10, (userinfo && strlen(userinfo->sn))?userinfo->sn:"anonymous"); - return 1; + return 1; } int faimtest_parse_searchreply(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - char *address, *SNs; - int i, num; - - va_start(ap, command); - address = va_arg(ap, char *); - num = va_arg(ap, int); - SNs = va_arg(ap, char *); - va_end(ap); + va_list ap; + char *address, *SNs; + int i, num; - dvprintf("faimtest: E-Mail Search Results for %s: ", address); + va_start(ap, command); + address = va_arg(ap, char *); + num = va_arg(ap, int); + SNs = va_arg(ap, char *); + va_end(ap); - for(i = 0; i < num; i++) - dvinlineprintf("%s, ", &SNs[i*(MAXSNLEN+1)]); - dinlineprintf("\n"); + dvprintf("faimtest: E-Mail Search Results for %s: ", address); - return 1; + for(i = 0; i < num; i++) + dvinlineprintf("%s, ", &SNs[i*(MAXSNLEN+1)]); + dinlineprintf("\n"); + + return 1; } int faimtest_parse_searcherror(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - char *address; - - va_start(ap, command); - address = va_arg(ap, char *); - va_end(ap); + va_list ap; + char *address; - dvprintf("faimtest: E-Mail Search Results for %s: No Results or Invalid Email\n", address); + va_start(ap, command); + address = va_arg(ap, char *); + va_end(ap); - return 1; + dvprintf("faimtest: E-Mail Search Results for %s: No Results or Invalid Email\n", address); + + return 1; } -- 2.45.1