From 24286d932574981faaace4ff3d41fc1231119122 Mon Sep 17 00:00:00 2001 From: mid Date: Fri, 24 Dec 1999 23:01:07 +0000 Subject: [PATCH] Last few changes left in my inbox. --- CHANGES | 6 ++ aim.h | 2 +- aim_im.c | 16 ++-- aim_login.c | 181 +++----------------------------------- aim_rxhandlers.c | 41 ++++----- aim_txqueue.c | 33 ++++--- utils/faimtest/faimtest.c | 15 +++- 7 files changed, 71 insertions(+), 223 deletions(-) diff --git a/CHANGES b/CHANGES index f5cad11..d1a0d7a 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,12 @@ No release numbers - Fri Dec 24 21:30:06 UTC 1999 - Added an error-counting Read() that has been sitting in my inbox - Cleaned up header files, created aim_cbtypes.h. + - Added void * to aim_conn_t for private client use if they want. (Orb) + - Removed all stderr output. All output is important, and goes to stdout. + - Renamed isautoresponse in IM parser to icbmflags. + - Added Orb's fix for the new login code, deleted old (see Orb, I do read + your mail....eventually). + - Added mailing lists to README. - Fri Dec 24 11:12:34 UTC 1999 - Cleaned up both outgoing and incoming ICBM handling. Anything diff --git a/aim.h b/aim.h index a2d41c9..52dbbc3 100644 --- a/aim.h +++ b/aim.h @@ -289,7 +289,7 @@ int aim_parse_generalerrs(struct command_rx_struct *command, ...); /* aim_im.c */ #define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */ #define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */ -u_long aim_send_im(struct aim_conn_t *, char *, int, char *); +u_long aim_send_im(struct aim_conn_t *, char *, u_int, char *); int aim_parse_incoming_im_middle(struct command_rx_struct *); u_long aim_seticbmparam(struct aim_conn_t *conn); diff --git a/aim_im.c b/aim_im.c index 54adc73..f98528d 100644 --- a/aim_im.c +++ b/aim_im.c @@ -5,7 +5,7 @@ * */ -#include "aim.h" +#include /* * Send an ICBM (instant message). @@ -17,7 +17,7 @@ * when the message is received (of type 0x0004/0x000c) * */ -u_long aim_send_im(struct aim_conn_t *conn, char *destsn, int flags, char *msg) +u_long aim_send_im(struct aim_conn_t *conn, char *destsn, u_int flags, char *msg) { int curbyte,i; @@ -152,7 +152,7 @@ int aim_parse_incoming_im_middle(struct command_rx_struct *command) struct aim_userinfo_s userinfo; u_int i = 0, j = 0, y = 0, z = 0; char *msg = NULL; - int isautoresponse = 0; + u_int icbmflags = 0; rxcallback_t userfunc = NULL; u_char cookie[8]; int channel; @@ -215,7 +215,13 @@ int aim_parse_incoming_im_middle(struct command_rx_struct *command) * it will contain a second type 0x0004 TLV, with zero length. */ if (aim_gettlv(tlvlist, 0x0004, 2)) - isautoresponse = 1; + icbmflags |= AIM_IMFLAGS_AWAY; + + /* + * Check Ack Request status. + */ + if (aim_gettlv(tlvlist, 0x0003, 2)) + icbmflags |= AIM_IMFLAGS_ACK; /* * Extract the various pieces of the userinfo struct. @@ -320,7 +326,7 @@ int aim_parse_incoming_im_middle(struct command_rx_struct *command) */ userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); if (userfunc) - i = userfunc(command, &userinfo, msg, isautoresponse, flag1, flag2); + i = userfunc(command, &userinfo, msg, icbmflags, flag1, flag2); else i = 0; diff --git a/aim_login.c b/aim_login.c index 313bffe..ba05e20 100644 --- a/aim_login.c +++ b/aim_login.c @@ -5,7 +5,7 @@ * */ -#include "aim.h" +#include /* @@ -16,7 +16,7 @@ #endif /* - * send_login(int socket, char *sn, char *password) + * send_login(int socket, char *sn, char *password) * * This is the initial login request packet. * @@ -24,11 +24,8 @@ * encode_password(). See that function for their * stupid method of doing it. * - * - * */ int aim_send_login (struct aim_conn_t *conn, char *sn, char *password, struct client_info_s *clientinfo) -#if 0 { char *password_encoded = NULL; /* to store encoded password */ int curbyte=0; @@ -40,18 +37,19 @@ int aim_send_login (struct aim_conn_t *conn, char *sn, char *password, struct cl else newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH); - newpacket.commandlen = 6+2+strlen(sn)+1+1+2+strlen(password)+6; - + newpacket.commandlen = 4 + 4+strlen(sn) + 4+strlen(password) + 6; + if (clientinfo) { if (strlen(clientinfo->clientstring)) - newpacket.commandlen += strlen(clientinfo->clientstring)+4; - newpacket.commandlen += 6+6+6; + newpacket.commandlen += 4+strlen(clientinfo->clientstring); + newpacket.commandlen += 6+6+6; if (strlen(clientinfo->country)) - newpacket.commandlen += strlen(clientinfo->country)+4; + newpacket.commandlen += 4+strlen(clientinfo->country); if (strlen(clientinfo->lang)) - newpacket.commandlen += strlen(clientinfo->lang)+4; + newpacket.commandlen += 4+strlen(clientinfo->lang); } + newpacket.commandlen += 6; newpacket.data = (char *) calloc (1, newpacket.commandlen ); newpacket.lock = 1; @@ -71,7 +69,7 @@ int aim_send_login (struct aim_conn_t *conn, char *sn, char *password, struct cl free(password_encoded); curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0016, 0x0001); - + if (clientinfo) { if (strlen(clientinfo->clientstring)) @@ -89,7 +87,7 @@ int aim_send_login (struct aim_conn_t *conn, char *sn, char *password, struct cl curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->country)); curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->country, strlen(clientinfo->country)); } - if (strlen(clientinfo->lang)) + if (strlen(clientinfo->lang)) { curbyte += aimutil_put16(newpacket.data+curbyte, 0x000f); curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->lang)); @@ -104,163 +102,6 @@ int aim_send_login (struct aim_conn_t *conn, char *sn, char *password, struct cl return 0; } -#else -{ - - /* this is for the client info field of this packet. for now, just - put a few zeros in there and hope they don't notice. */ - char info_field[] = { - 0x00, 0x00, 0x00, 0x00 - }; - int info_field_len = 4; - - char *password_encoded = NULL; /* to store encoded password */ - int n = 0; /* counter during packet construction */ - - struct command_tx_struct newpacket; - - if (conn) - newpacket.conn = conn; - else - newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH); - - /* breakdown of new_packet_login_len */ - newpacket.commandlen = 6; /* SNAC: fixed bytes */ - newpacket.commandlen += 2; /* SN len */ - newpacket.commandlen += strlen(sn); /* SN text */ - newpacket.commandlen += 1; /* SN null terminator */ - newpacket.commandlen += 1; /* fixed byte */ - newpacket.commandlen += 2; /* password len */ - newpacket.commandlen += strlen(password); /* password text */ - newpacket.commandlen += 1; /* password null term*/ - newpacket.commandlen += 1; /* fixed byte */ - newpacket.commandlen += 2; /* info field len */ - newpacket.commandlen += info_field_len; /* info field text */ - newpacket.commandlen += 1; /* info field null term */ - newpacket.commandlen += 41; /* fixed bytes */ - - /* allocate buffer to use for constructing packet_login */ - newpacket.data = (char *) malloc ( newpacket.commandlen ); - memset(newpacket.data, 0x00, newpacket.commandlen); - - newpacket.lock = 1; - newpacket.type = 0x01; - - newpacket.data[0] = 0x00; - newpacket.data[1] = 0x00; - newpacket.data[2] = 0x00; - newpacket.data[3] = 0x01; - newpacket.data[4] = 0x00; - newpacket.data[5] = 0x01; - - newpacket.data[6] = (char) ( (strlen(sn)) >> 8); - newpacket.data[7] = (char) ( (strlen(sn)) & 0xFF); - - n = 8; - memcpy(&(newpacket.data[n]), sn, strlen(sn)); - n += strlen(sn); - newpacket.data[n] = 0x00; - n++; - - newpacket.data[n] = 0x02; - n++; - - /* store password length as word */ - newpacket.data[n] = (char) ( (strlen(password)) >> 8); - newpacket.data[n+1] = (char) ( (strlen(password)) & 0xFF); - n += 2; - - /* allocate buffer for encoded password */ - password_encoded = (char *) malloc(strlen(password)); - /* encode password */ - aim_encode_password(password, password_encoded); - /* store encoded password */ - memcpy(&(newpacket.data[n]), password_encoded, strlen(password)); - - n += strlen(password); - /* free buffer */ - free(password_encoded); - /* place null terminator after encoded password */ - newpacket.data[n] = 0x00; - n++; - - newpacket.data[n] = 0x03; - n++; - - newpacket.data[n] = (char) ( (info_field_len) >> 8); - newpacket.data[n+1] = (char) ( (info_field_len) & 0xFF); - n += 2; - memcpy(&(newpacket.data[n]), info_field, info_field_len); - n += info_field_len; - newpacket.data[n] = 0x00; - n++; - - newpacket.data[n] = 0x16; - newpacket.data[n+1] = 0x00; - newpacket.data[n+2] = 0x02; - newpacket.data[n+3] = 0x00; - n += 4; - newpacket.data[n] = 0x01; - newpacket.data[n+1] = 0x00; - newpacket.data[n+2] = 0x17; - newpacket.data[n+3] = 0x00; - n += 4; - - newpacket.data[n] = 0x02; - newpacket.data[n+1] = 0x00; - newpacket.data[n+2] = 0x01; - newpacket.data[n+3] = 0x00; - n += 4; - - newpacket.data[n] = 0x18; - newpacket.data[n+1] = 0x00; - newpacket.data[n+2] = 0x02; - newpacket.data[n+3] = 0x00; - n += 4; - - newpacket.data[n] = 0x01; - newpacket.data[n+1] = 0x00; - newpacket.data[n+2] = 0x1a; - newpacket.data[n+3] = 0x00; - n += 4; - - newpacket.data[n] = 0x02; - newpacket.data[n+1] = 0x00; - newpacket.data[n+2] = 0x13; - newpacket.data[n+3] = 0x00; - n += 4; - - newpacket.data[n] = 0x0e; - newpacket.data[n+1] = 0x00; - newpacket.data[n+2] = 0x02; - newpacket.data[n+3] = 0x75; - n += 4; - - newpacket.data[n] = 0x73; - newpacket.data[n+1] = 0x00; - newpacket.data[n+2] = 0x0f; - newpacket.data[n+3] = 0x00; - n += 4; - - newpacket.data[n] = 0x02; - newpacket.data[n+1] = 0x65; - newpacket.data[n+2] = 0x6e; - newpacket.data[n+3] = 0x00; - n += 4; - newpacket.data[n] = 0x09; - newpacket.data[n+1] = 0x00; - newpacket.data[n+2] = 0x02; - newpacket.data[n+3] = 0x00; - n += 4; - - newpacket.data[n] = 0x15; - n += 1; - - aim_tx_enqueue(&newpacket); - - return 0; -} -#endif /* * int encode_password( diff --git a/aim_rxhandlers.c b/aim_rxhandlers.c index 196adde..4ae0175 100644 --- a/aim_rxhandlers.c +++ b/aim_rxhandlers.c @@ -1,36 +1,25 @@ - /* - aim_rxhandlers.c - - This file contains most all of the incoming packet handlers, along - with aim_rxdispatch(), the Rx dispatcher. Queue/list management is - actually done in aim_rxqueue.c. - + * aim_rxhandlers.c + * + * This file contains most all of the incoming packet handlers, along + * with aim_rxdispatch(), the Rx dispatcher. Queue/list management is + * actually done in aim_rxqueue.c. + * */ +#include -#include "aim.h" /* for most everything */ - - +/* + * Bleck functions get called when there's no non-bleck functions + * around to cleanup the mess... + */ int bleck(struct command_rx_struct *workingPtr, ...) { u_short family; u_short subtype; family = (workingPtr->data[0] << 8) + workingPtr->data[1]; subtype = (workingPtr->data[2] << 8) + workingPtr->data[3]; -#if debug > 0 - fprintf(stderr, "bleck: null handler for %04x/%04x\n", family, subtype); -#endif - return 1; -} - -int bleck2(struct command_rx_struct *workingPtr, ...) -{ - u_short family; - u_short subtype; - family = (workingPtr->data[0] << 8) + workingPtr->data[1]; - subtype = (workingPtr->data[2] << 8) + workingPtr->data[3]; - printf("OLDbleck: called for %04x/%04x -- OBSOLETE\n", family, subtype); + printf("bleck: null handler for %04x/%04x\n", family, subtype); return 1; } @@ -171,7 +160,7 @@ int aim_rxdispatch(void) (workingPtr->data[3] == 0x01) ) { #if debug > 0 - fprintf(stderr, "got connection ack on auth line\n"); + printf("got connection ack on auth line\n"); #endif workingPtr->handled = 1; } @@ -333,11 +322,11 @@ int aim_rxdispatch(void) } break; case AIM_CONN_TYPE_CHAT: - fprintf(stderr, "\nAHH! Dont know what to do with CHAT stuff yet!\n"); + printf("\nAHH! Dont know what to do with CHAT stuff yet!\n"); workingPtr->handled = aim_callhandler_noparam(workingPtr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_DEFAULT, workingPtr); break; default: - fprintf(stderr, "\nAHHHHH! UNKNOWN CONNECTION TYPE! (0x%02x)\n\n", workingPtr->conn->type); + printf("\nAHHHHH! UNKNOWN CONNECTION TYPE! (0x%02x)\n\n", workingPtr->conn->type); workingPtr->handled = aim_callhandler_noparam(workingPtr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_UNKNOWN, workingPtr); break; } diff --git a/aim_txqueue.c b/aim_txqueue.c index d3f7d9e..c6f507b 100644 --- a/aim_txqueue.c +++ b/aim_txqueue.c @@ -1,24 +1,24 @@ /* - aim_txqueue.c - - Herein lies all the mangement routines for the transmit (Tx) queue. - + * aim_txqueue.c + * + * Herein lies all the mangement routines for the transmit (Tx) queue. + * */ -#include "aim.h" +#include /* - aim_tx_enqeue() - - The overall purpose here is to enqueue the passed in command struct - into the outgoing (tx) queue. Basically... - 1) Make a scope-irrelevent copy of the struct - 2) Lock the struct - 3) Mark as not-sent-yet - 4) Enqueue the struct into the list - 5) Unlock the struct once it's linked in - 6) Return - + * aim_tx_enqeue() + * + * The overall purpose here is to enqueue the passed in command struct + * into the outgoing (tx) queue. Basically... + * 1) Make a scope-irrelevent copy of the struct + * 2) Lock the struct + * 3) Mark as not-sent-yet + * 4) Enqueue the struct into the list + * 5) Unlock the struct once it's linked in + * 6) Return + * */ int aim_tx_enqueue(struct command_tx_struct *newpacket) @@ -200,7 +200,6 @@ int aim_tx_flushqueue(void) if ( (u_int)write(workingPtr->conn->fd, curPacket, (workingPtr->commandlen + 6)) != (workingPtr->commandlen + 6)) { - perror("write"); printf("\nWARNING: Error in sending packet 0x%4x -- will try again next time\n\n", workingPtr->seqnum); workingPtr->sent = 0; /* mark it unsent */ return -1; /* bail out */ diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index 99116a5..3293dea 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -402,14 +402,14 @@ int faimtest_parse_userinfo(struct command_rx_struct *command, ...) * ulong membersince time_t of date of signup * ulong onsince time_t of date of singon * int idletime min (sec?) idle - * int isautoreply TRUE if its an auto-response + * u_int icbmflags sets AIM_IMFLAGS_{AWAY,ACK} * */ int faimtest_parse_incoming_im(struct command_rx_struct *command, ...) { struct aim_userinfo_s *userinfo; char *msg = NULL; - int isautoreply = 0; + u_int icbmflags = 0; va_list ap; char *tmpstr = NULL; u_short flag1, flag2; @@ -417,7 +417,7 @@ int faimtest_parse_incoming_im(struct command_rx_struct *command, ...) va_start(ap, command); userinfo = va_arg(ap, struct aim_userinfo_s *); msg = va_arg(ap, char *); - isautoreply = va_arg(ap, int); + icbmflags = va_arg(ap, u_int); flag1 = va_arg(ap, u_short); flag2 = va_arg(ap, u_short); va_end(ap); @@ -436,7 +436,14 @@ int faimtest_parse_incoming_im(struct command_rx_struct *command, ...) printf("faimtest: icbm: membersince = %lu\n", userinfo->membersince); printf("faimtest: icbm: onlinesince = %lu\n", userinfo->onlinesince); printf("faimtest: icbm: idletime = 0x%04x\n", userinfo->idletime); - printf("faimtest: icbm: isautoreply = %s\n", isautoreply ? "TRUE" : "FALSE"); + + printf("faimtest: icbm: icbmflags = "); + if (icbmflags & AIM_IMFLAGS_AWAY) + printf("away "); + if (icbmflags & AIM_IMFLAGS_ACK) + printf("ackrequest "); + printf("\n"); + printf("faimtest: icbm: encoding flags = {%04x, %04x}\n", flag1, flag2); printf("faimtest: icbm: message: %s\n", msg); -- 2.45.2