changeset 445:e4c34ca88d9b

[gaim-migrate @ 455] Hehehehehe Libfaim got updated, gaim got updated. btw, gaim/faim can't sign in yet, don't ask me why. it's not my fault. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 29 Jun 2000 20:40:28 +0000
parents e7885c54ed2f
children 6d78b988b479
files libfaim/Makefile.am libfaim/aim_ads.c libfaim/aim_auth.c libfaim/aim_buddylist.c libfaim/aim_chat.c libfaim/aim_chatnav.c libfaim/aim_conn.c libfaim/aim_im.c libfaim/aim_info.c libfaim/aim_login.c libfaim/aim_misc.c libfaim/aim_rxhandlers.c libfaim/aim_rxqueue.c libfaim/aim_search.c libfaim/aim_txqueue.c libfaim/faim/aim.h libfaim/faim/aim_cbtypes.h libfaim/faim/faimconfig.h plugins/ChangeLog plugins/HOWTO plugins/Makefile.am src/away.c src/oscar.c
diffstat 23 files changed, 1163 insertions(+), 548 deletions(-) [+]
line wrap: on
line diff
--- a/libfaim/Makefile.am	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/Makefile.am	Thu Jun 29 20:40:28 2000 +0000
@@ -3,7 +3,8 @@
 EXTRA_DIST = faim/aim.h faim/aim_cbtypes.h faim/faimconfig.h README \
 		README.gaim CHANGES CHANGES.gaim COPYING BUGS
 
-libfaim_a_SOURCES = 	aim_auth.c 		\
+libfaim_a_SOURCES = 	aim_ads.c		\
+			aim_auth.c 		\
 			aim_buddylist.c		\
 			aim_chat.c		\
 			aim_chatnav.c		\
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libfaim/aim_ads.c	Thu Jun 29 20:40:28 2000 +0000
@@ -0,0 +1,42 @@
+/*
+ *
+ *
+ */
+
+#include <faim/aim.h>
+
+u_long aim_ads_clientready(struct aim_session_t *sess,
+			   struct aim_conn_t *conn)
+{
+  struct command_tx_struct *newpacket;
+  int i;
+
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 0x1a)))
+    return -1;
+
+  newpacket->lock = 1;
+
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0002);
+
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0013);
+
+  i+= aimutil_put16(newpacket->data+i, 0x0005);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
+
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
+
+  return (sess->snac_nextid++);
+}
+
+u_long aim_ads_requestads(struct aim_session_t *sess,
+			  struct aim_conn_t *conn)
+{
+  return aim_genericreq_n(sess, conn, 0x0005, 0x0002);
+}
--- a/libfaim/aim_auth.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_auth.c	Thu Jun 29 20:40:28 2000 +0000
@@ -15,7 +15,7 @@
   struct command_tx_struct *newpacket;
   int curbyte=0;
   
-  if (!(newpacket = aim_tx_new(0x0001, conn, 4+2+2+AIM_COOKIELEN)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0001, conn, 4+2+2+AIM_COOKIELEN)))
     return -1;
 
   newpacket->lock = 1;
@@ -35,7 +35,7 @@
   struct command_tx_struct *newpacket;
   int curbyte = 0;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 26)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 26)))
     return -1;
 
   newpacket->lock = 1;
@@ -75,7 +75,7 @@
   struct command_tx_struct *newpacket;
   int i;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 10+4+strlen(current)+4+strlen(new))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+4+strlen(current)+4+strlen(new))))
     return -1;
 
   newpacket->lock = 1;
--- a/libfaim/aim_buddylist.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_buddylist.c	Thu Jun 29 20:40:28 2000 +0000
@@ -17,7 +17,7 @@
    if(!sn)
      return -1;
 
-   if (!(newpacket = aim_tx_new(0x0002, conn, 10+1+strlen(sn))))
+   if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn))))
      return -1;
 
    newpacket->lock = 1;
@@ -55,7 +55,7 @@
    if(!sn)
      return -1;
 
-   if (!(newpacket = aim_tx_new(0x0002, conn, 10+1+strlen(sn))))
+   if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn))))
      return -1;
 
    newpacket->lock = 1;
--- a/libfaim/aim_chat.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_chat.c	Thu Jun 29 20:40:28 2000 +0000
@@ -55,7 +55,7 @@
   if (!sess || !conn || !msg)
     return 0;
   
-  if (!(newpacket = aim_tx_new(0x0002, conn, 1152)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
     return -1;
 
   newpacket->lock = 1; /* lock struct */
@@ -130,7 +130,7 @@
   if (!sess || !conn || !roomname)
     return 0;
   
-  if (!(newpacket = aim_tx_new(0x0002, conn, 10+9+strlen(roomname)+2)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+9+strlen(roomname)+2)))
     return -1;
 
   newpacket->lock = 1;
@@ -513,7 +513,7 @@
   struct command_tx_struct *newpacket;
   int i;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 0x20)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 0x20)))
     return -1;
 
   newpacket->lock = 1;
@@ -567,7 +567,7 @@
   if (!sess || !conn || !sn || !msg || !roomname)
     return 0;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 1152+strlen(sn)+strlen(roomname)+strlen(msg))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152+strlen(sn)+strlen(roomname)+strlen(msg))))
     return -1;
 
   newpacket->lock = 1;
--- a/libfaim/aim_chatnav.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_chatnav.c	Thu Jun 29 20:40:28 2000 +0000
@@ -34,7 +34,7 @@
   struct command_tx_struct *newpacket; 
   int i;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 0x20)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 0x20)))
     return -1;
 
   newpacket->lock = 1;
@@ -283,7 +283,7 @@
   int i;
   struct aim_snac_t snac;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 10+12+strlen("invite")+strlen(name))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+12+strlen("invite")+strlen(name))))
     return -1;
 
   newpacket->lock = 1;
--- a/libfaim/aim_conn.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_conn.c	Thu Jun 29 20:40:28 2000 +0000
@@ -80,6 +80,9 @@
   }
   faim_mutex_unlock(&sess->connlistlock);
 
+  /* XXX: do we need this for txqueue too? */
+  aim_rxqueue_cleanbyconn(sess, *deadconn);
+
   aim_conn_close(*deadconn);
   free(*deadconn);
   deadconn = NULL;
@@ -255,7 +258,8 @@
   faim_mutex_lock(&sess->connlistlock);
   if (sess->connlist == NULL) {
     faim_mutex_unlock(&sess->connlistlock);
-    return 0;
+    *status = -1;
+    return NULL;
   }
   faim_mutex_unlock(&sess->connlistlock);
 
--- a/libfaim/aim_im.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_im.c	Thu Jun 29 20:40:28 2000 +0000
@@ -28,7 +28,7 @@
   if (strlen(msg) >= MAXMSGLEN)
     return -1;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, strlen(msg)+256)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, strlen(msg)+256)))
     return -1;
 
   newpacket->lock = 1; /* lock struct */
@@ -64,15 +64,22 @@
    * metaTLV start.
    */
   curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
-  curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x0d);
+  curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x10);
 
   /*
-   * Flag data?
+   * Flag data / ICBM Parameters?
    */
-  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0501);
-  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put8(newpacket->data+curbyte, 0x05);
+  curbyte += aimutil_put8(newpacket->data+curbyte, 0x01);
+
+  /* number of bytes to follow */
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0004);
+  curbyte += aimutil_put8(newpacket->data+curbyte, 0x01);
+  curbyte += aimutil_put8(newpacket->data+curbyte, 0x01);
+  curbyte += aimutil_put8(newpacket->data+curbyte, 0x01);
+  curbyte += aimutil_put8(newpacket->data+curbyte, 0x02);
+
   curbyte += aimutil_put16(newpacket->data+curbyte, 0x0101);
-  curbyte += aimutil_put8 (newpacket->data+curbyte, 0x01);
 
   /* 
    * Message block length.
@@ -132,6 +139,156 @@
   return (sess->snac_nextid++);
 }
 
+struct aim_directim_priv {
+  unsigned char cookie[8];
+  char sn[MAXSNLEN+1];
+};
+
+int aim_send_im_direct(struct aim_session_t *sess, 
+		       struct aim_conn_t *conn,
+		       char *msg)
+{
+  struct command_tx_struct *newpacket;
+  struct aim_directim_priv *priv = NULL;
+  int i;
+
+  if (strlen(msg) >= MAXMSGLEN)
+    return -1;
+
+  if (!sess || !conn || (conn->type != AIM_CONN_TYPE_RENDEZVOUS) || !conn->priv) {
+    printf("faim: directim: invalid arguments\n");
+    return -1;
+  }
+
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OFT, 0x0001, conn, strlen(msg)))) {
+    printf("faim: directim: tx_new failed\n");
+    return -1;
+  }
+
+  newpacket->lock = 1; /* lock struct */
+
+  priv = (struct aim_directim_priv *)conn->priv;
+
+  newpacket->hdr.oft.hdr2len = 0x44;
+
+  if (!(newpacket->hdr.oft.hdr2 = malloc(newpacket->hdr.oft.hdr2len))) {
+    free(newpacket);
+    return -1;
+  }
+
+  i = 0;
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0006);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+
+  i += aimutil_putstr(newpacket->hdr.oft.hdr2+i, priv->cookie, 8);
+
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+
+  i += aimutil_put32(newpacket->hdr.oft.hdr2+i, strlen(msg));
+
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+
+  i += aimutil_putstr(newpacket->hdr.oft.hdr2+i, sess->logininfo.screen_name, strlen(sess->logininfo.screen_name));
+  
+  i = 52;
+  i += aimutil_put8(newpacket->hdr.oft.hdr2+i, 0x00);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+  i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
+
+  memcpy(newpacket->data, msg, strlen(msg));
+
+  newpacket->lock = 0;
+
+  aim_tx_enqueue(sess, newpacket);
+
+  return 0;
+}
+
+int aim_parse_outgoing_im_middle(struct aim_session_t *sess,
+				 struct command_rx_struct *command)
+{
+  unsigned int i = 0, z;
+  rxcallback_t userfunc = NULL;
+  unsigned char cookie[8];
+  int channel;
+  struct aim_tlvlist_t *tlvlist;
+  char sn[MAXSNLEN];
+  unsigned short icbmflags = 0;
+  unsigned char flag1 = 0, flag2 = 0;
+  unsigned char *msgblock = NULL, *msg = NULL;
+
+  i = 10;
+  
+  /* ICBM Cookie. */
+  for (z=0; z<8; z++,i++)
+    cookie[z] = command->data[i];
+
+  /* Channel ID */
+  channel = aimutil_get16(command->data+i);
+  i += 2;
+
+  if (channel != 0x01) {
+    printf("faim: icbm: ICBM recieved on unsupported channel.  Ignoring. (chan = %04x)\n", channel);
+    return 1;
+  }
+
+  strncpy(sn, command->data+i+1, (int) *(command->data+i));
+  i += 1 + (int) *(command->data+i);
+
+  tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
+
+  if (aim_gettlv(tlvlist, 0x0003, 1))
+    icbmflags |= AIM_IMFLAGS_ACK;
+  if (aim_gettlv(tlvlist, 0x0004, 1))
+    icbmflags |= AIM_IMFLAGS_AWAY;
+
+  if (aim_gettlv(tlvlist, 0x0002, 1)) {
+    int j = 0;
+
+    msgblock = aim_gettlv_str(tlvlist, 0x0002, 1);
+
+    /* no, this really is correct.  I'm not high or anything either. */
+    j += 2;
+    j += 2 + aimutil_get16(msgblock+j);
+    j += 2;
+    
+    j += 2; /* final block length */
+
+    flag1 = aimutil_get16(msgblock);
+    j += 2;
+    flag2 = aimutil_get16(msgblock);
+    j += 2;
+    
+    msg = msgblock+j;
+  }
+
+  if ((userfunc = aim_callhandler(command->conn, 0x0004, 0x0006)) || (i = 0))
+    i = userfunc(sess, command, channel, sn, msg, icbmflags, flag1, flag2);
+  
+  if (msgblock)
+    free(msgblock);
+  aim_freetlvchain(&tlvlist);
+
+  return 0;
+}
+
 /*
  * It can easily be said that parsing ICBMs is THE single
  * most difficult thing to do in the in AIM protocol.  In
@@ -194,27 +351,26 @@
     }
 
   /*
-   * Source screen name.
-   */
-  memcpy(userinfo.sn, command->data+i+1, (int)command->data[i]);
-  userinfo.sn[(int)command->data[i]] = '\0';
-  i += 1 + (int)command->data[i];
-
-  /*
-   * Warning Level
+   * Extract the standard user info block.
+   *
+   * Note that although this contains TLVs that appear contiguous
+   * with the TLVs read below, they are two different pieces.  The
+   * userinfo block contains the number of TLVs that contain user
+   * information, the rest are not even though there is no seperation.
+   * aim_extractuserinfo() returns the number of bytes used by the
+   * userinfo tlvs, so you can start reading the rest of them right
+   * afterward.  
+   *
+   * That also means that TLV types can be duplicated between the
+   * userinfo block and the rest of the message, however there should
+   * never be two TLVs of the same type in one block.
+   * 
    */
-  userinfo.warnlevel = aimutil_get16(command->data+i); /* guess */
-  i += 2;
-
-  /*
-   * Number of TLVs that follow.  Not needed.
-   */
-  wastebits = aimutil_get16(command->data+i);
-  i += 2;
+  i += aim_extractuserinfo(command->data+i, &userinfo);
   
   /*
-   * Read block of TLVs.  All further data is derived
-   * from what is parsed here.
+   * Read block of TLVs (not including the userinfo data).  All 
+   * further data is derived from what is parsed here.
    */
   tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
 
@@ -232,55 +388,26 @@
            
       /*
        * Check Autoresponse status.  If it is an autoresponse,
-       * it will contain a second type 0x0004 TLV, with zero length.
+       * it will contain a type 0x0004 TLV, with zero length.
        */
-      if (aim_gettlv(tlvlist, 0x0004, 2))
+      if (aim_gettlv(tlvlist, 0x0004, 1))
 	icbmflags |= AIM_IMFLAGS_AWAY;
       
       /*
        * Check Ack Request status.
        */
-      if (aim_gettlv(tlvlist, 0x0003, 2))
+      if (aim_gettlv(tlvlist, 0x0003, 1))
 	icbmflags |= AIM_IMFLAGS_ACK;
       
       /*
-       * Extract the various pieces of the userinfo struct.
-       */
-      /* Class. */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x0001, 1)))
-	userinfo.class = aimutil_get16(tmptlv->value);
-      /* Member-since date. */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x0002, 1)))
-	{
-	  /* If this is larger than 4, its probably the message block, skip */
-	  if (tmptlv->length <= 4)
-	    userinfo.membersince = aimutil_get32(tmptlv->value);
-	}
-      /* On-since date */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x0003, 1)))
-	userinfo.onlinesince = aimutil_get32(tmptlv->value);
-      /* Idle-time */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x0004, 1)))
-	userinfo.idletime = aimutil_get16(tmptlv->value);
-      /* Session Length (AIM) */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x000f, 1)))
-	userinfo.sessionlen = aimutil_get16(tmptlv->value);
-      /* Session Length (AOL) */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x0010, 1)))
-	userinfo.sessionlen = aimutil_get16(tmptlv->value);
-      
-      /*
        * Message block.
-       *
-       * XXX: Will the msgblock always be the second 0x0002? 
        */
       msgblocktlv = aim_gettlv(tlvlist, 0x0002, 1);
-      if (!msgblocktlv)
-	{
-	  printf("faim: icbm: major error! no message block TLV found!\n");
-	  aim_freetlvchain(&tlvlist);
-	  return 1;
-	}
+      if (!msgblocktlv || !msgblocktlv->value) {
+	printf("faim: icbm: major error! no message block TLV found!\n");
+	aim_freetlvchain(&tlvlist);
+	return 1;
+      }
       
       /*
        * Extracting the message from the unknown cruft.
@@ -353,26 +480,9 @@
       struct aim_tlv_t *block1;
       struct aim_tlvlist_t *list2;
       struct aim_tlv_t *tmptlv;
-      struct aim_tlv_t *miscinfo;
       unsigned short reqclass = 0;
-      int a;
+      unsigned short status = 0;
       
-      /* Class. */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x0001, 1)))
-	userinfo.class = aimutil_get16(tmptlv->value);
-      /* On-since date */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x0003, 1)))
-	userinfo.onlinesince = aimutil_get32(tmptlv->value);
-      /* Idle-time */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x0004, 1)))
-	userinfo.idletime = aimutil_get16(tmptlv->value);
-      /* Session Length (AIM) */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x000f, 1)))
-	userinfo.sessionlen = aimutil_get16(tmptlv->value);
-      /* Session Length (AOL) */
-      if ((tmptlv = aim_gettlv(tlvlist, 0x0010, 1)))
-	userinfo.sessionlen = aimutil_get16(tmptlv->value);
-
       /*
        * There's another block of TLVs embedded in the type 5 here. 
        */
@@ -383,32 +493,57 @@
 	return 1; /* major problem */
       }
 
-      a = 0x1a; /* skip -- not sure what this information is! */
+      /*
+       * First two bytes represent the status of the connection.
+       *
+       * 0 is a request, 2 is an accept
+       */ 
+      status = aimutil_get16(block1->value+0);
+      
+      /*
+       * Next comes the cookie.  Should match the ICBM cookie.
+       */
+      if (memcmp(block1->value+2, cookie, 8) != 0) 
+	printf("faim: rend: warning cookies don't match!\n");
 
       /*
-       * XXX: Ignore if there's no data, only cookie information.
+       * The next 16bytes are a capability block so we can
+       * identify what type of rendezvous this is.
        *
-       * Its probably just an accepted invitation or something.
-       *  
+       * Thanks to Eric Warmenhoven <warmenhoven@linux.com> (of GAIM)
+       * for pointing some of this out to me.  In fact, a lot of 
+       * the client-to-client info comes from the work of the GAIM 
+       * developers. Thanks!
+       *
+       * Read off one capability string and we should have it ID'd.
+       * 
        */
-      if (block1->length <= 0x1a) {
+      reqclass = aim_getcap(block1->value+2+8, 0x10);
+      if (reqclass == 0x0000) {
+	printf("faim: rend: no ID block\n");
 	aim_freetlvchain(&tlvlist);
 	return 1;
       }
 
-      list2 = aim_readtlvchain(block1->value+a, block1->length-a);
-
-      if (!(miscinfo = aim_gettlv(list2, 0x2711, 1))) {
+      /* 
+       * What follows may be TLVs or nothing, depending on the
+       * purpose of the message.
+       *
+       * Ack packets for instance have nothing more to them.
+       */
+      list2 = aim_readtlvchain(block1->value+2+8+16, block1->length-2-8-16);
+      
+      if (!list2 || ((reqclass != AIM_CAPS_IMIMAGE) && !(aim_gettlv(list2, 0x2711, 1)))) {
 	struct aim_msgcookie_t *cook;
 
 	if ((cook = aim_uncachecookie(sess, cookie)) == NULL) {
-	  printf("faim: no 0x2711 info TLV in rendezvous and its not in cache!\n");
+	  printf("faim: non-data rendezvous thats not in cache!\n");
 	  aim_freetlvchain(&list2);
 	  aim_freetlvchain(&tlvlist);
 	  return 1;
 	}
 
-	if (cook->type == 1) {
+	if (cook->type == AIM_CAPS_SENDFILE) {
 	  struct aim_filetransfer_t *ft;
 
 	  if (cook->data) {
@@ -420,40 +555,54 @@
 	    if ((errortlv = aim_gettlv(list2, 0x000b, 1))) {
 	      errorcode = aimutil_get16(errortlv->value);
 	    }
-	    printf("faim: transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sender, ft->ip, ft->filename, errorcode);
+	    if (errorcode) {
+	      printf("faim: transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sender, ft->ip, ft->filename, errorcode);
+	    } else if (status == 0x0002) { /* connection accepted */
+	      printf("faim: transfer from %s (%s) for %s accepted\n", ft->sender, ft->ip, ft->filename);
+	    }
 	    free(cook->data);
 	  } else {
 	    printf("faim: not data attached to file transfer\n");
 	  }
-
+	} else if (cook->type == AIM_CAPS_VOICE) {
+	  printf("faim: voice request cancelled\n");
 	} else {
 	  printf("faim: unknown cookie cache type %d\n", cook->type);
 	}
 
 	free(cook);
+	if (list2)
+	  aim_freetlvchain(&list2);
+	aim_freetlvchain(&tlvlist);
 	return 1;
       }
 
+      /*
+       * The rest of the handling depends on what type it is.
+       */
+      if (reqclass & AIM_CAPS_BUDDYICON) {
 
-      /*
-       * Parse the first two bytes of the 0x2711 TLV.  
-       *
-       * This can be interpretted in a couple ways.  
-       *
-       * It could be said that its a service type or some such and
-       * that voice is 0, file transfer is 1, and chat is 4 (and 5).
-       *
-       * Or it could be said that its an exchange value.  Exchanges
-       * four and five are for chat, voice is on exchange zero and
-       * file transfer is done on exchange 1.  
-       *
-       * It should work out the same no how its thought of.
-       *
-       */
-      reqclass = aimutil_get16(miscinfo->value+0);
-   
-      switch (reqclass) {	
-      case AIM_RENDEZVOUS_VOICE: {
+	/*
+	 * Call client.
+	 */
+	userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+	if (userfunc || (i = 0))
+	  i = userfunc(sess, 
+		       command, 
+		       channel, 
+		       reqclass,
+		       &userinfo);
+
+      } else if (reqclass & AIM_CAPS_VOICE) {
+	struct aim_msgcookie_t cachedcook;
+
+	printf("faim: rend: voice!\n");
+
+	memcpy(cachedcook.cookie, cookie, 8);
+	cachedcook.type = AIM_CAPS_VOICE;
+	cachedcook.data = NULL;
+	if (aim_cachecookie(sess, &cachedcook) != 0)
+	  printf("faim: ERROR caching message cookie\n");
 
 	/* XXX: implement all this */
 
@@ -468,16 +617,145 @@
 		       reqclass,
 		       &userinfo);
 	}
-	break;
-      }
-      case AIM_RENDEZVOUS_FILETRANSFER: {
+      } else if (reqclass & AIM_CAPS_IMIMAGE) {
+	char ip[30];
+	struct aim_msgcookie_t cachedcook;
+
+	memset(ip, 0, sizeof(ip));
+	
+	if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) {
+	  struct aim_tlv_t *iptlv, *porttlv;
+	  
+	  iptlv = aim_gettlv(list2, 0x0003, 1);
+	  porttlv = aim_gettlv(list2, 0x0005, 1);
+
+	  snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d", 
+		  aimutil_get8(iptlv->value+0),
+		  aimutil_get8(iptlv->value+1),
+		  aimutil_get8(iptlv->value+2),
+		  aimutil_get8(iptlv->value+3),
+		  4443 /*aimutil_get16(porttlv->value)*/);
+	}
+
+	printf("faim: rend: directIM request from %s (%s)\n",
+	       userinfo.sn,
+	       ip);
+
+#if 0
+	{
+	  struct aim_conn_t *newconn;
+	  
+	  newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS, ip);
+	  if (!newconn || (newconn->fd == -1)) { 
+	    printf("could not connect to %s\n", ip);
+	    perror("aim_newconn");
+	    aim_conn_kill(sess, &newconn);
+	  } else {
+	    struct aim_directim_priv *priv;
+	    priv = (struct aim_directim_priv *)malloc(sizeof(struct aim_directim_priv));
+	    memcpy(priv->cookie, cookie, 8);
+	    strncpy(priv->sn, userinfo.sn, MAXSNLEN);
+	    newconn->priv = priv;
+	    printf("faim: connected to peer (fd = %d)\n", newconn->fd);
+	  }
+	}
+#endif
+	
+#if 0
+	memcpy(cachedcook.cookie, cookie, 8);
+	
+	ft = malloc(sizeof(struct aim_filetransfer_t));
+	strncpy(ft->sender, userinfo.sn, sizeof(ft->sender));
+	strncpy(ft->ip, ip, sizeof(ft->ip));
+	ft->filename = strdup(miscinfo->value+8);
+	cachedcook.type = AIM_CAPS_SENDFILE; 
+	cachedcook.data = ft;
+
+	if (aim_cachecookie(sess, &cachedcook) != 0)
+	  printf("faim: ERROR caching message cookie\n");
+#endif	
+
+	/*
+	 * Call client.
+	 */
+	userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+	if (userfunc || (i = 0))
+	  i = userfunc(sess, 
+		       command, 
+		       channel, 
+		       reqclass,
+		       &userinfo);
+
+      } else if (reqclass & AIM_CAPS_CHAT) {
+	struct aim_tlv_t *miscinfo;
+	struct aim_chat_roominfo roominfo;
+	char *msg=NULL,*encoding=NULL,*lang=NULL;
+
+	miscinfo = aim_gettlv(list2, 0x2711, 1);
+	aim_chat_readroominfo(miscinfo->value, &roominfo);
+		  
+	if (aim_gettlv(list2, 0x000c, 1))
+	  msg = aim_gettlv_str(list2, 0x000c, 1);
+	  
+	if (aim_gettlv(list2, 0x000d, 1))
+	  encoding = aim_gettlv_str(list2, 0x000d, 1);
+	  
+	if (aim_gettlv(list2, 0x000e, 1))
+	  lang = aim_gettlv_str(list2, 0x000e, 1);
+      
+	/*
+	 * Call client.
+	 */
+	userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+	if (userfunc || (i = 0))
+	  i = userfunc(sess, 
+		       command, 
+		       channel, 
+		       reqclass,
+		       &userinfo, 
+		       &roominfo, 
+		       msg, 
+		       encoding?encoding+1:NULL, 
+		       lang?lang+1:NULL);
+	  free(roominfo.name);
+	  free(msg);
+	  free(encoding);
+	  free(lang);
+      } else if (reqclass & AIM_CAPS_GETFILE) {
+
+	/*
+	 * Call client.
+	 */
+	userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+	if (userfunc || (i = 0))
+	  i = userfunc(sess, 
+		       command, 
+		       channel, 
+		       reqclass,
+		       &userinfo);
+
+      } else if (reqclass & AIM_CAPS_SENDFILE) {
+	/*
+	 * Call client.
+	 */
+	userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+	if (userfunc || (i = 0))
+	  i = userfunc(sess, 
+		       command, 
+		       channel, 
+		       reqclass,
+		       &userinfo);
+#if 0
 	char ip[30];
 	char *desc = NULL;
 	struct aim_msgcookie_t cachedcook;
 	struct aim_filetransfer_t *ft;
+	struct aim_tlv_t *miscinfo;
 
 	memset(ip, 0, sizeof(ip));
 	
+	miscinfo = aim_gettlv(list2, 0x2711, 1);
+
 	if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) {
 	  struct aim_tlv_t *iptlv, *porttlv;
 	  
@@ -503,74 +781,26 @@
 	       ip);
 	
 	memcpy(cachedcook.cookie, cookie, 8);
-	memcpy(cachedcook.extended, block1->value+10, 16);
 	
 	ft = malloc(sizeof(struct aim_filetransfer_t));
 	strncpy(ft->sender, userinfo.sn, sizeof(ft->sender));
 	strncpy(ft->ip, ip, sizeof(ft->ip));
 	ft->filename = strdup(miscinfo->value+8);
-	cachedcook.type = 1; 
+	cachedcook.type = AIM_CAPS_SENDFILE; 
 	cachedcook.data = ft;
 
 	if (aim_cachecookie(sess, &cachedcook) != 0)
 	  printf("faim: ERROR caching message cookie\n");
 	
 	
-	aim_denytransfer(sess, command->conn, ft->sender, cookie, 0);
+	aim_accepttransfer(sess, command->conn, ft->sender, cookie, AIM_CAPS_SENDFILE);
 
 	free(desc);
-	
+#endif	
 	i = 1;
-	break;
-      }
-      case AIM_RENDEZVOUS_FILETRANSFER_GET: {
-	printf("faim: file get request (unsupported)\n");
-	i = 1;
-	break;
+      } else {
+	printf("faim: rend: unknown rendezvous 0x%04x\n", reqclass);
       }
-      case AIM_RENDEZVOUS_CHAT_EX3:
-      case AIM_RENDEZVOUS_CHAT_EX4:
-      case AIM_RENDEZVOUS_CHAT_EX5: {
-	struct aim_chat_roominfo roominfo;
-	char *msg=NULL,*encoding=NULL,*lang=NULL;
-
-	aim_chat_readroominfo(miscinfo->value, &roominfo);
-		  
-	if (aim_gettlv(list2, 0x000c, 1))
-	  msg = aim_gettlv_str(list2, 0x000c, 1);
-	  
-	if (aim_gettlv(list2, 0x000d, 1))
-	  encoding = aim_gettlv_str(list2, 0x000d, 1);
-	  
-	if (aim_gettlv(list2, 0x000e, 1))
-	  lang = aim_gettlv_str(list2, 0x000e, 1);
-      
-	/*
-	 * Call client.
-	 */
-	userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
-	if (userfunc || (i = 0))
-	  i = userfunc(sess, 
-		       command, 
-		       channel, 
-		       reqclass, /* == roominfo->exchange */
-		       &userinfo, 
-		       &roominfo, 
-		       msg, 
-		       encoding?encoding+1:NULL, 
-		       lang?lang+1:NULL);
-	  free(roominfo.name);
-	  free(msg);
-	  free(encoding);
-	  free(lang);
-	  break;
-      }
-      default: {
-	printf("faim: rendezvous: unknown rend class 0x%04x\n", reqclass);
-	i = 1;
-	break;
-      }
-      } /* switch */
 
       aim_freetlvchain(&list2);
     }
@@ -584,6 +814,39 @@
   return i;
 }
 
+u_long aim_accepttransfer(struct aim_session_t *sess,
+			  struct aim_conn_t *conn, 
+			  char *sender,
+			  char *cookie,
+			  unsigned short rendid)
+{
+  struct command_tx_struct *newpacket;
+  int curbyte, i;
+
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+8+2+1+strlen(sender)+4+2+8+16)))
+    return -1;
+
+  newpacket->lock = 1;
+
+  curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0006, 0x0000, sess->snac_nextid);
+  for (i = 0; i < 8; i++)
+    curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
+  curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sender));
+  curbyte += aimutil_putstr(newpacket->data+curbyte, sender, strlen(sender));
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x001a);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002 /* accept */);
+  for (i = 0; i < 8; i++)
+    curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]);
+  curbyte += aim_putcap(newpacket->data+curbyte, 0x10, rendid);
+
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
+
+  return (sess->snac_nextid++);
+}
+
 /*
  * Possible codes:
  *    AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support"
@@ -600,7 +863,7 @@
   struct command_tx_struct *newpacket;
   int curbyte, i;
 
-  if(!(newpacket = aim_tx_new(0x0002, conn, 10+8+2+1+strlen(sender)+6)))
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+8+2+1+strlen(sender)+6)))
     return -1;
 
   newpacket->lock = 1;
@@ -632,7 +895,7 @@
   struct command_tx_struct *newpacket;
   int curbyte;
 
-  if(!(newpacket = aim_tx_new(0x0002, conn, 10+16)))
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+16)))
     return -1;
 
   newpacket->lock = 1;
--- a/libfaim/aim_info.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_info.c	Thu Jun 29 20:40:28 2000 +0000
@@ -25,7 +25,7 @@
   if (!sess || !conn || !sn)
     return 0;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 12+1+strlen(sn))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 12+1+strlen(sn))))
     return -1;
 
   newpacket->lock = 1;
@@ -88,6 +88,66 @@
    0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}
 };
 
+u_short aim_getcap(unsigned char *capblock, int buflen)
+{
+  u_short ret = 0;
+  int y;
+  int offset = 0;
+
+  while (offset < buflen) {
+    for(y=0; y < (sizeof(aim_caps)/0x10); y++) {
+      if (memcmp(&aim_caps[y], capblock+offset, 0x10) == 0) {
+	switch(y) {
+	case 0: ret |= AIM_CAPS_BUDDYICON; break;
+	case 1: ret |= AIM_CAPS_VOICE; break;
+	case 2: ret |= AIM_CAPS_IMIMAGE; break;
+	case 3: ret |= AIM_CAPS_CHAT; break;
+	case 4: ret |= AIM_CAPS_GETFILE; break;
+	case 5: ret |= AIM_CAPS_SENDFILE; break;
+	default: ret |= 0xff00; break;
+	}
+      }
+    }
+    offset += 0x10;
+  } 
+  return ret;
+}
+
+int aim_putcap(unsigned char *capblock, int buflen, u_short caps)
+{
+  int offset = 0;
+
+  if (!capblock)
+    return -1;
+
+  if ((caps & AIM_CAPS_BUDDYICON) && (offset < buflen)) {
+    memcpy(capblock+offset, aim_caps[0], sizeof(aim_caps[0]));
+    offset += sizeof(aim_caps[1]);
+  }
+  if ((caps & AIM_CAPS_VOICE) && (offset < buflen)) {
+    memcpy(capblock+offset, aim_caps[1], sizeof(aim_caps[1]));
+    offset += sizeof(aim_caps[1]);
+  }
+  if ((caps & AIM_CAPS_IMIMAGE) && (offset < buflen)) {
+    memcpy(capblock+offset, aim_caps[2], sizeof(aim_caps[2]));
+    offset += sizeof(aim_caps[2]);
+  }
+  if ((caps & AIM_CAPS_CHAT) && (offset < buflen)) {
+    memcpy(capblock+offset, aim_caps[3], sizeof(aim_caps[3]));
+    offset += sizeof(aim_caps[3]);
+  }
+  if ((caps & AIM_CAPS_GETFILE) && (offset < buflen)) {
+    memcpy(capblock+offset, aim_caps[4], sizeof(aim_caps[4]));
+    offset += sizeof(aim_caps[4]);
+  }
+  if ((caps & AIM_CAPS_SENDFILE) && (offset < buflen)) {
+    memcpy(capblock+offset, aim_caps[5], sizeof(aim_caps[5]));
+    offset += sizeof(aim_caps[5]);
+  }
+
+  return offset;
+}
+
 /*
  * AIM is fairly regular about providing user info.  This
  * is a generic routine to extract it in its standard form.
@@ -99,6 +159,7 @@
   int curtlv = 0;
   int tlv1 = 0;
   u_short curtype;
+  int lastvalid;
 
 
   if (!buf || !outinfo)
@@ -111,8 +172,13 @@
    * Screen name.    Stored as an unterminated string prepended
    *                 with an unsigned byte containing its length.
    */
-  memcpy(outinfo->sn, &(buf[i+1]), buf[i]);
-  outinfo->sn[(int)buf[i]] = '\0';
+  if (buf[i] < MAXSNLEN) {
+    memcpy(outinfo->sn, &(buf[i+1]), buf[i]);
+    outinfo->sn[(int)buf[i]] = '\0';
+  } else {
+    memcpy(outinfo->sn, &(buf[i+1]), MAXSNLEN-1);
+    outinfo->sn[MAXSNLEN] = '\0';
+  }
   i = 1 + (int)buf[i];
 
   /*
@@ -131,180 +197,177 @@
   /* 
    * Parse out the Type-Length-Value triples as they're found.
    */
-  while (curtlv < tlvcnt)
-    {
-      curtype = aimutil_get16(&buf[i]);
-      switch (curtype)
-	{
-	  /*
-	   * Type = 0x0001: Member Class.   
-	   * 
-	   * Specified as any of the following bitwise ORed together:
-	   *      0x0001  Trial (user less than 60days)
-	   *      0x0002  Unknown bit 2
-	   *      0x0004  AOL Main Service user
-	   *      0x0008  Unknown bit 4
-	   *      0x0010  Free (AIM) user 
-	   *      0x0020  Away
-	   *
-	   * In some odd cases, we can end up with more
-	   * than one of these.  We only want the first,
-	   * as the others may not be something we want.
-	   *
-	   */
-	case 0x0001:
-	  if (tlv1) /* use only the first */
-	    break;
-	  outinfo->class = aimutil_get16(&buf[i+4]);
-	  tlv1++;
-	  break;
-	  
-	  /*
-	   * Type = 0x0002: Member-Since date. 
-	   *
-	   * The time/date that the user originally
-	   * registered for the service, stored in 
-	   * time_t format
-	   */
-	case 0x0002: 
-	  outinfo->membersince = aimutil_get32(&buf[i+4]);
-	  break;
-	  
-	  /*
-	   * Type = 0x0003: On-Since date.
-	   *
-	   * The time/date that the user started 
-	   * their current session, stored in time_t
-	   * format.
-	   */
-	case 0x0003:
-	  outinfo->onlinesince = aimutil_get32(&buf[i+4]);
-	  break;
-
-	  /*
-	   * Type = 0x0004: Idle time.
-	   *
-	   * Number of seconds since the user
-	   * actively used the service.
-	   */
-	case 0x0004:
-	  outinfo->idletime = aimutil_get16(&buf[i+4]);
-	  break;
-
-	  /*
-	   * Type = 0x000d
-	   *
-	   * Capability information.  Not real sure of
-	   * actual decoding.  See comment on aim_bos_setprofile()
-	   * in aim_misc.c about the capability block, its the same.
-	   *
-	   * Ignore.
-	   *
-	   */
-	case 0x000d:
-	  {
-	    int z,y; 
-	    int len;
-	    len = aimutil_get16(buf+i+2);
-	    if (!len)
-	      break;
+  while (curtlv < tlvcnt) {
+    lastvalid = 1;
+    curtype = aimutil_get16(&buf[i]);
+    switch (curtype) {
+      /*
+       * Type = 0x0000: Invalid
+       *
+       * AOL has been trying to throw these in just to break us.
+       * They're real nice guys over there at AOL.  
+       *
+       * Just skip the two zero bytes and continue on. (This doesn't
+       * count towards tlvcnt!)
+       */
+    case 0x0000:
+      lastvalid = 0;
+      i += 2;
+      break;
 
-	    for (z = 0; z < len; z+=0x10) {
-	      for(y=0; y < 6; y++) {
-		if (memcmp(&aim_caps[y], buf+i+4+z, 0x10) == 0) {
-		  switch(y) {
-		  case 0: outinfo->capabilities |= AIM_CAPS_BUDDYICON; break;
-		  case 1: outinfo->capabilities |= AIM_CAPS_VOICE; break;
-		  case 2: outinfo->capabilities |= AIM_CAPS_IMIMAGE; break;
-		  case 3: outinfo->capabilities |= AIM_CAPS_CHAT; break;
-		  case 4: outinfo->capabilities |= AIM_CAPS_GETFILE; break;
-		  case 5: outinfo->capabilities |= AIM_CAPS_SENDFILE; break;
-		  default: outinfo->capabilities |= 0xff00; break;
-		  }
-		}
-	      }
-	    }
-	  }
-	  break;
-
-	  /*
-	   * Type = 0x000e
-	   *
-	   * Unknown.  Always of zero length, and always only
-	   * on AOL users.
-	   *
-	   * Ignore.
-	   *
-	   */
-	case 0x000e:
-	  break;
-	  
-	  /*
-	   * Type = 0x000f: Session Length. (AIM)
-	   * Type = 0x0010: Session Length. (AOL)
-	   *
-	   * The duration, in seconds, of the user's
-	   * current session.
-	   *
-	   * Which TLV type this comes in depends
-	   * on the service the user is using (AIM or AOL).
-	   *
-	   */
-	case 0x000f:
-	case 0x0010:
-	  outinfo->sessionlen = aimutil_get32(&buf[i+4]);
-	  break;
-
-	  /*
-	   * Reaching here indicates that either AOL has
-	   * added yet another TLV for us to deal with, 
-	   * or the parsing has gone Terribly Wrong.
-	   *
-	   * Either way, inform the owner and attempt
-	   * recovery.
-	   *
-	   */
-	default:
-	  {
-	    int len,z = 0, y = 0, x = 0;
-	    char tmpstr[80];
-	    printf("faim: userinfo: **warning: unexpected TLV:\n");
-	    printf("faim: userinfo:   sn    =%s\n", outinfo->sn);
-	    printf("faim: userinfo:   curtlv=0x%04x\n", curtlv);
-	    printf("faim: userinfo:   type  =0x%04x\n",aimutil_get16(&buf[i]));
-	    printf("faim: userinfo:   length=0x%04x\n", len = aimutil_get16(&buf[i+2]));
-	    printf("faim: userinfo:   data: \n");
-	    while (z<len)
-	      {
-		x = sprintf(tmpstr, "faim: userinfo:      ");
-		for (y = 0; y < 8; y++)
-		  {
-		    if (z<len)
-		      {
-			sprintf(tmpstr+x, "%02x ", buf[i+4+z]);
-			z++;
-			x += 3;
-		      }
-		    else
-		      break;
-		  }
-		printf("%s\n", tmpstr);
-	      }
-	  }
-	  break;
-	}  
+      /*
+       * Type = 0x0001: Member Class.   
+       * 
+       * Specified as any of the following bitwise ORed together:
+       *      0x0001  Trial (user less than 60days)
+       *      0x0002  Unknown bit 2
+       *      0x0004  AOL Main Service user
+       *      0x0008  Unknown bit 4
+       *      0x0010  Free (AIM) user 
+       *      0x0020  Away
+       *
+       * In some odd cases, we can end up with more
+       * than one of these.  We only want the first,
+       * as the others may not be something we want.
+       *
+       */
+    case 0x0001:
+      if (tlv1) /* use only the first */
+	break;
+      outinfo->class = aimutil_get16(&buf[i+4]);
+      tlv1++;
+      break;
+      
       /*
-       * No matter what, TLV triplets should always look like this:
+       * Type = 0x0002: Member-Since date. 
+       *
+       * The time/date that the user originally
+       * registered for the service, stored in 
+       * time_t format
+       */
+    case 0x0002: 
+      outinfo->membersince = aimutil_get32(&buf[i+4]);
+      break;
+      
+      /*
+       * Type = 0x0003: On-Since date.
        *
-       *   u_short type;
-       *   u_short length;
-       *   u_char  data[length];
+       * The time/date that the user started 
+       * their current session, stored in time_t
+       * format.
+       */
+    case 0x0003:
+      outinfo->onlinesince = aimutil_get32(&buf[i+4]);
+      break;
+      
+      /*
+       * Type = 0x0004: Idle time.
+       *
+       * Number of seconds since the user
+       * actively used the service.
+       */
+    case 0x0004:
+      outinfo->idletime = aimutil_get16(&buf[i+4]);
+      break;
+      
+      /*
+       * Type = 0x000d
+       *
+       * Capability information.  Not real sure of
+       * actual decoding.  See comment on aim_bos_setprofile()
+       * in aim_misc.c about the capability block, its the same.
        *
        */
-      i += (2 + 2 + aimutil_get16(&buf[i+2]));
+    case 0x000d:
+      {
+	int len;
+	len = aimutil_get16(buf+i+2);
+	if (!len)
+	  break;
+	
+	outinfo->capabilities = aim_getcap(buf+i+4, len);
+      }
+      break;
+      
+      /*
+       * Type = 0x000e
+       *
+       * Unknown.  Always of zero length, and always only
+       * on AOL users.
+       *
+       * Ignore.
+       *
+       */
+    case 0x000e:
+      break;
+      
+      /*
+       * Type = 0x000f: Session Length. (AIM)
+       * Type = 0x0010: Session Length. (AOL)
+       *
+       * The duration, in seconds, of the user's
+       * current session.
+       *
+       * Which TLV type this comes in depends
+       * on the service the user is using (AIM or AOL).
+       *
+       */
+    case 0x000f:
+    case 0x0010:
+      outinfo->sessionlen = aimutil_get32(&buf[i+4]);
+      break;
       
+      /*
+       * Reaching here indicates that either AOL has
+       * added yet another TLV for us to deal with, 
+       * or the parsing has gone Terribly Wrong.
+       *
+       * Either way, inform the owner and attempt
+       * recovery.
+       *
+       */
+    default:
+      {
+	int len,z = 0, y = 0, x = 0;
+	char tmpstr[80];
+	printf("faim: userinfo: **warning: unexpected TLV:\n");
+	printf("faim: userinfo:   sn    =%s\n", outinfo->sn);
+	printf("faim: userinfo:   curtlv=0x%04x\n", curtlv);
+	printf("faim: userinfo:   type  =0x%04x\n",aimutil_get16(&buf[i]));
+	printf("faim: userinfo:   length=0x%04x\n", len = aimutil_get16(&buf[i+2]));
+	printf("faim: userinfo:   data: \n");
+	while (z<len)
+	  {
+	    x = sprintf(tmpstr, "faim: userinfo:      ");
+	    for (y = 0; y < 8; y++)
+	      {
+		if (z<len)
+		  {
+		    sprintf(tmpstr+x, "%02x ", buf[i+4+z]);
+		    z++;
+		    x += 3;
+		  }
+		else
+		  break;
+	      }
+	    printf("%s\n", tmpstr);
+	  }
+      }
+      break;
+    }  
+    /*
+     * No matter what, TLV triplets should always look like this:
+     *
+     *   u_short type;
+     *   u_short length;
+     *   u_char  data[length];
+     *
+     */
+    if (lastvalid) {
+      i += (2 + 2 + aimutil_get16(&buf[i+2])); 	   
       curtlv++;
     }
+  }
   
   return i;
 }
@@ -478,7 +541,7 @@
   if (!sess || !conn || !info)
     return 0;
 
-  if (!(tx = aim_tx_new(0x0002, conn, 1152)))
+  if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
     return -1;
 
   tx->lock = 1;
@@ -506,7 +569,7 @@
   if (!sess || !conn || !sn)
     return 0;
 
-  if (!(tx = aim_tx_new(0x0002, conn, 10+1+strlen(sn))))
+  if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn))))
     return -1;
 
   tx->lock = 1;
--- a/libfaim/aim_login.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_login.c	Thu Jun 29 20:40:28 2000 +0000
@@ -22,7 +22,7 @@
   
   struct command_tx_struct *newpacket;
 
-  if (!(newpacket = aim_tx_new(0x0001, conn, 4)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0001, conn, 4)))
     return -1;
 
   newpacket->lock = 1;
@@ -51,7 +51,7 @@
   
   struct command_tx_struct *newpacket;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 10+2+2+strlen(sn))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+2+2+strlen(sn))))
     return -1;
 
   newpacket->lock = 1;
@@ -87,7 +87,7 @@
   if (!clientinfo || !sn || !password)
     return -1;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 1152)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
     return -1;
 
   /*
@@ -150,7 +150,7 @@
   }
 
   newpacket->lock = 1;
-  newpacket->type = 0x01;
+  newpacket->hdr.oscar.type = 0x01;
 
   curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
   curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
@@ -161,10 +161,7 @@
   curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
   curbyte += aimutil_put16(newpacket->data+curbyte, strlen(password));
   password_encoded = (char *) malloc(strlen(password));
-  if (icqmode)
-    aimicq_encode_password(password, password_encoded);
-  else
-    aim_encode_password(password, password_encoded);
+  aim_encode_password(password, password_encoded);
   curbyte += aimutil_putstr(newpacket->data+curbyte, password_encoded, strlen(password));
   free(password_encoded);
   
@@ -181,18 +178,17 @@
 
   curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055);
 
+  if (strlen(clientinfo->country)) {
+    curbyte += aimutil_put16(newpacket->data+curbyte, 0x000e);
+    curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->country));
+    curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->country, strlen(clientinfo->country));
+  }
   if (strlen(clientinfo->lang)) {
     curbyte += aimutil_put16(newpacket->data+curbyte, 0x000f);
     curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->lang));
     curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->lang, strlen(clientinfo->lang));
   }
 
-  if (strlen(clientinfo->country)) {
-    curbyte += aimutil_put16(newpacket->data+curbyte, 0x000e);
-    curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->country));
-    curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->country, strlen(clientinfo->country));
-  }
-
 #endif
 
   newpacket->lock = 0;
@@ -218,12 +214,12 @@
 int aim_encode_password(const char *password, u_char *encoded)
 {
   u_char encoding_table[] = {
-#if 0
+#if 0 /* old v1 table */
     0xf3, 0xb3, 0x6c, 0x99,
     0x95, 0x3f, 0xac, 0xb6,
     0xc5, 0xfa, 0x6b, 0x63,
     0x69, 0x6c, 0xc3, 0x9f
-#else
+#else /* v2.1 table, also works for ICQ */
     0xf3, 0x26, 0x81, 0xc4,
     0x39, 0x86, 0xdb, 0x92,
     0x71, 0xa3, 0xb9, 0xe6,
@@ -240,31 +236,6 @@
 }
 
 /*
- * They changed the hash slightly for ICQ. 
- *   This new hash may work for AIM too (though
- *   the max password length for ICQ is only 
- *   eight characters, where its 16 with AIM).
- *
- */
-int aimicq_encode_password(const char *password, u_char *encoded)
-{
-  u_char encoding_table[] = {
-    0xf3, 0x26, 0x81, 0xc4,
-    0x39, 0x86, 0xdb, 0x92
-  };
-
-  int i;
-
-  if (strlen(password) > 8)
-    return -1;
-
-  for (i = 0; i < strlen(password); i++)
-      encoded[i] = (password[i] ^ encoding_table[i]);
-
-  return 0;
-}
-
-/*
  * This is sent back as a general response to the login command.
  * It can be either an error or a success, depending on the
  * precense of certain TLVs.  
@@ -313,7 +284,8 @@
    * If we have both an IP number (0x0005) and a cookie (0x0006),
    * then the login was successful.
    */
-  else if (aim_gettlv(tlvlist, 0x0005, 1) && aim_gettlv(tlvlist, 0x0006, 1)) {
+  else if (aim_gettlv(tlvlist, 0x0005, 1) && aim_gettlv(tlvlist, 0x0006, 1) 
+	   /*aim_gettlv(tlvlist, 0x0006, 1)->length*/) {
     struct aim_tlv_t *tmptlv;
 
     /*
@@ -376,7 +348,7 @@
   struct command_tx_struct *tx;
   struct aim_tlvlist_t *tlvlist = NULL;
 
-  if (!(tx = aim_tx_new(0x0004, conn, 1152)))
+  if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0004, conn, 1152)))
     return -1;
   
   tx->lock = 1;
@@ -424,7 +396,7 @@
   struct command_tx_struct *tx;
   int i = 0;
 
-  if (!(tx = aim_tx_new(0x0002, conn, 10+0x22)))
+  if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+0x22)))
     return -1;
 
   tx->lock = 1;
@@ -463,7 +435,7 @@
   struct aim_tlvlist_t *tlvlist = NULL;
   int i = 0;
 
-  if (!(tx = aim_tx_new(0x0002, conn, 1152)))
+  if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
     return -1;
 
   tx->lock = 1;
--- a/libfaim/aim_misc.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_misc.c	Thu Jun 29 20:40:28 2000 +0000
@@ -79,7 +79,7 @@
   listcount = aimutil_itemcnt(localcpy, '&');
   packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, packlen)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
     return -1;
 
   newpacket->lock = 1;
@@ -173,7 +173,7 @@
 #endif
   free(localcpy);
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, packet_login_phase3c_hi_b_len - 6)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packet_login_phase3c_hi_b_len - 6)))
     return -1;
 
   newpacket->lock = 1;
@@ -209,20 +209,6 @@
  * Gives BOS your profile.
  *
  * 
- * The large data chunk given here is of unknown decoding.
- * What I do know is that each 0x20 byte repetition 
- * represents a capability.  People with only the 
- * first two reptitions can support normal messaging
- * and chat (client version 2.0 or 3.0).  People with 
- * the third as well can also support voice chat (client
- * version 3.5 or higher).  IOW, if we don't send this,
- * we won't get chat invitations (get "software doesn't
- * support chat" error).
- *
- * This data is broadcast along with your oncoming
- * buddy command to everyone who has you on their
- * buddy list, as a type 0x0002 TLV.
- * 
  */
 u_long aim_bos_setprofile(struct aim_session_t *sess,
 			  struct aim_conn_t *conn, 
@@ -231,9 +217,9 @@
 			  unsigned int caps)
 {
   struct command_tx_struct *newpacket;
-  int i = 0;
+  int i = 0, tmp, caplen;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 1152+strlen(profile)+1+(awaymsg?strlen(awaymsg):0))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152+strlen(profile)+1+(awaymsg?strlen(awaymsg):0))))
     return -1;
 
   i += aim_putsnac(newpacket->data, 0x0002, 0x004, 0x0000, sess->snac_nextid);
@@ -249,25 +235,12 @@
     i += aim_puttlv_str(newpacket->data+i, 0x0004, 0x0000, NULL);
 
   /* Capability information. */
-  {
-    int isave;
-    i += aimutil_put16(newpacket->data+i, 0x0005);
-    isave = i;
-    i += aimutil_put16(newpacket->data+i, 0);
-    if (caps & AIM_CAPS_BUDDYICON)
-      i += aimutil_putstr(newpacket->data+i, aim_caps[0], 0x10);
-    if (caps & AIM_CAPS_VOICE)
-      i += aimutil_putstr(newpacket->data+i, aim_caps[1], 0x10);
-    if (caps & AIM_CAPS_IMIMAGE)
-      i += aimutil_putstr(newpacket->data+i, aim_caps[2], 0x10);
-    if (caps & AIM_CAPS_CHAT)
-      i += aimutil_putstr(newpacket->data+i, aim_caps[3], 0x10);
-    if (caps & AIM_CAPS_GETFILE)
-      i += aimutil_putstr(newpacket->data+i, aim_caps[4], 0x10);
-    if (caps & AIM_CAPS_SENDFILE)
-      i += aimutil_putstr(newpacket->data+i, aim_caps[5], 0x10);
-    aimutil_put16(newpacket->data+isave, i-isave-2);
-  }
+ 
+  tmp = (i += aimutil_put16(newpacket->data+i, 0x0005));
+  i += aimutil_put16(newpacket->data+i, 0x0000); /* rewritten later */
+  i += (caplen = aim_putcap(newpacket->data+i, 512, caps));
+  aimutil_put16(newpacket->data+tmp, caplen); /* rewrite TLV size */
+
   newpacket->commandlen = i;
   aim_tx_enqueue(sess, newpacket);
   
@@ -347,7 +320,7 @@
   int command_2_len = 0x52;
   struct command_tx_struct *newpacket;
   
-  if (!(newpacket = aim_tx_new(0x0002, conn, command_2_len)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, command_2_len)))
     return -1;
 
   newpacket->lock = 1;
@@ -391,7 +364,7 @@
   if (conn->type != AIM_CONN_TYPE_BOS)
     packlen += 2;
 
-  if(!(newpacket = aim_tx_new(0x0002, conn, packlen)));
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)));
   
   newpacket->lock = 1;
 
@@ -438,7 +411,7 @@
 {
   struct command_tx_struct *newpacket;
   
-  if (!(newpacket = aim_tx_new(0x0002, conn, 12)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 12)))
     return -1;
 
   newpacket->lock = 1;
@@ -460,7 +433,7 @@
   struct command_tx_struct *newpacket;
   int i;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 10 + (4*11))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + (4*11))))
     return -1;
 
   newpacket->lock = 1;
@@ -527,6 +500,22 @@
 }
 
 /*
+ * aim_bos_nop()
+ *
+ * No-op.  WinAIM sends these every 4min or so to keep
+ * the connection alive.  With the recent changes
+ * in the OSCAR servers, it looks like we must do the
+ * same or be disconnected with a mysterious 'you logged
+ * on from another client' message.
+ *
+ */
+u_long aim_bos_nop(struct aim_session_t *sess,
+		   struct aim_conn_t *conn)
+{
+  return aim_genericreq_n(sess, conn, 0x0001, 0x0016);
+}
+
+/*
  * aim_bos_reqrights()
  *
  * Request BOS rights.
@@ -551,6 +540,17 @@
 }
 
 /*
+ * aim_debugconn_sendconnect()
+ *
+ * For aimdebugd.  If you don't know what it is, you don't want to.
+ */
+u_long aim_debugconn_sendconnect(struct aim_session_t *sess,
+				 struct aim_conn_t *conn)
+{
+  return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT);
+}
+
+/*
  * Generic routine for sending commands.
  *
  *
@@ -568,7 +568,7 @@
 {
   struct command_tx_struct *newpacket;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 10)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10)))
     return 0;
 
   newpacket->lock = 1;
@@ -594,7 +594,7 @@
   if (!longdata)
     return aim_genericreq_n(sess, conn, family, subtype);
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 10+sizeof(u_long))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_long))))
     return -1;
 
   newpacket->lock = 1;
@@ -620,7 +620,7 @@
   if (!shortdata)
     return aim_genericreq_n(sess, conn, family, subtype);
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 10+sizeof(u_short))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_short))))
     return -1;
 
   newpacket->lock = 1;
--- a/libfaim/aim_rxhandlers.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_rxhandlers.c	Thu Jun 29 20:40:28 2000 +0000
@@ -177,9 +177,9 @@
   subtype= aimutil_get16(workingPtr->data+2);
 
   if((family < maxf) && (subtype+1 < maxs) && (literals[family][subtype] != NULL))
-    faimdprintf(1, "bleck: null handler for %04x/%04x (%s)\n", family, subtype, literals[family][subtype+1]);
+    faimdprintf("bleck: null handler for %04x/%04x (%s)\n", family, subtype, literals[family][subtype+1]);
   else
-    faimdprintf(1, "bleck: null handler for %04x/%04x (no literal)\n",family,subtype);
+    faimdprintf("bleck: null handler for %04x/%04x (no literal)\n",family,subtype);
 
   return 1;
 }
@@ -314,6 +314,19 @@
       if (workingPtr->handled)
 	continue;
 
+      /*
+       * This is a debugging/sanity check only and probably could/should be removed
+       * for stable code.
+       */
+      if (((workingPtr->hdrtype == AIM_FRAMETYPE_OFT) && 
+	   (workingPtr->conn->type != AIM_CONN_TYPE_RENDEZVOUS)) || 
+	  ((workingPtr->hdrtype == AIM_FRAMETYPE_OSCAR) && 
+	   (workingPtr->conn->type == AIM_CONN_TYPE_RENDEZVOUS))) {
+	printf("faim: rxhandlers: incompatible frame type %d on connection type 0x%04x\n", workingPtr->hdrtype, workingPtr->conn->type);
+	workingPtr->handled = 1;
+	continue;
+      }
+
       switch(workingPtr->conn->type) {
       case -1:
 	/*
@@ -332,7 +345,9 @@
 	if (head == 0x00000001) {
 	  faimdprintf(1, "got connection ack on auth line\n");
 	  workingPtr->handled = 1;
-	} else {
+	} else if (workingPtr->hdr.oscar.type == 0x0004) {
+	  workingPtr->handled = aim_authparse(sess, workingPtr);
+        } else {
 	  u_short family,subtype;
 	  
 	  family = aimutil_get16(workingPtr->data);
@@ -354,15 +369,17 @@
 #else	
 	    /* XXX: this isnt foolproof */
 	  case 0x0001:
-	    if (subtype == 0x0003)
-	      workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, workingPtr);
-	    else
-	      workingPtr->handled = aim_authparse(sess, workingPtr);
+	    workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, workingPtr);
 	    break;
 	  case 0x0007:
 	    if (subtype == 0x0005)
 	      workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_ADM, AIM_CB_ADM_INFOCHANGE_REPLY, workingPtr);
 	    break;
+	  case AIM_CB_FAM_SPECIAL:
+	    if (subtype == AIM_CB_SPECIAL_DEBUGCONN_CONNECT) {
+	      workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, family, subtype, workingPtr);
+	      break;
+	    } /* others fall through */
 	  default:
 	    /* Old login protocol */
 	    /* any user callbacks will be called from here */
@@ -376,7 +393,7 @@
 	u_short family;
 	u_short subtype;
 
-	if (workingPtr->type == 0x04) {
+	if (workingPtr->hdr.oscar.type == 0x04) {
 	  workingPtr->handled = aim_negchan_middle(sess, workingPtr);
 	  break;
 	}
@@ -459,6 +476,9 @@
 	  case 0x0005:
 	    workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0004, 0x0005, workingPtr);
 	    break;
+	  case 0x0006:
+	    workingPtr->handled = aim_parse_outgoing_im_middle(sess, workingPtr);
+	    break;
 	  case 0x0007:
 	    workingPtr->handled = aim_parse_incoming_im_middle(sess, workingPtr);
 	    break;
@@ -497,6 +517,9 @@
 	  else
 	    workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_STS, AIM_CB_STS_DEFAULT, workingPtr);
 	  break;
+      case AIM_CB_FAM_SPECIAL: 
+	workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, family, subtype, workingPtr);
+	break;
 	default:
 	  workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_UNKNOWN, workingPtr);
 	  break;
@@ -553,8 +576,21 @@
 	}
 	break;
       }
+      case AIM_CONN_TYPE_RENDEZVOUS: {
+	/* make sure that we only get OFT frames on these connections */
+	if (workingPtr->hdrtype != AIM_FRAMETYPE_OFT) {
+	  printf("faim: internal error: non-OFT frames on OFT connection\n");
+	  workingPtr->handled = 1; /* get rid of it */
+	  break;
+	}
+	
+	/* XXX: implement this */
+	printf("faim: OFT frame!\n");
+	
+	break;
+      }
       default:
-	printf("\ninternal error: unknown connection type (very bad.) (type = %d, fd = %d, channel = %02x, commandlen = %02x)\n\n", workingPtr->conn->type, workingPtr->conn->fd, workingPtr->type, workingPtr->commandlen);
+	printf("\ninternal error: unknown connection type (very bad.) (type = %d, fd = %d, commandlen = %02x)\n\n", workingPtr->conn->type, workingPtr->conn->fd, workingPtr->commandlen);
 	workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_UNKNOWN, workingPtr);
 	break;
       }	
@@ -680,12 +716,12 @@
   for (i = 0; i < command->commandlen; i++)
     {
       if ((i % 8) == 0)
-	printf("\n\t");
+	faimdprintf(1, "\n\t");
 
-      printf("0x%2x ", command->data[i]);
+      faimdprintf(1, "0x%2x ", command->data[i]);
     }
   
-  printf("\n\n");
+  faimdprintf(1, "\n\n");
 
   return 1;
 }
--- a/libfaim/aim_rxqueue.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_rxqueue.c	Thu Jun 29 20:40:28 2000 +0000
@@ -14,7 +14,7 @@
  */
 int aim_get_command(struct aim_session_t *sess, struct aim_conn_t *conn)
 {
-  u_char generic[6]; 
+  unsigned char generic[6]; 
   struct command_rx_struct *newrx = NULL;
 
   if (!sess || !conn)
@@ -27,8 +27,8 @@
    * Rendezvous (client-client) connections do not speak
    * FLAP, so this function will break on them.
    */
-  if (conn->type > 0x01000)
-    return 0;
+  if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) 
+    return aim_get_command_rendezvous(sess, conn);
 
   /*
    * Read FLAP header.  Six bytes:
@@ -40,11 +40,10 @@
    */
   faim_mutex_lock(&conn->active);
   if (read(conn->fd, generic, 6) < 6){
-    aim_conn_close(conn);
+    aim_conn_kill(sess, &conn);
     faim_mutex_unlock(&conn->active);
     return -1;
   }
-  faim_mutex_unlock(&conn->active);
 
   /*
    * This shouldn't happen unless the socket breaks, the server breaks,
@@ -52,22 +51,27 @@
    */
   if (generic[0] != 0x2a) {
     faimdprintf(1, "Bad incoming data!");
+    faim_mutex_unlock(&conn->active);
     return -1;
   }	
 
   /* allocate a new struct */
-  newrx = (struct command_rx_struct *)malloc(sizeof(struct command_rx_struct));
-  if (!newrx)
+  if (!(newrx = (struct command_rx_struct *)malloc(sizeof(struct command_rx_struct)))) {
+    faim_mutex_unlock(&conn->active);
     return -1;
+  }
   memset(newrx, 0x00, sizeof(struct command_rx_struct));
 
   newrx->lock = 1;  /* lock the struct */
 
+  /* we're doing OSCAR if we're here */
+  newrx->hdrtype = AIM_FRAMETYPE_OSCAR;
+
   /* store channel -- byte 2 */
-  newrx->type = (char) generic[1];
+  newrx->hdr.oscar.type = (char) generic[1];
 
   /* store seqnum -- bytes 3 and 4 */
-  newrx->seqnum = aimutil_get16(generic+2);
+  newrx->hdr.oscar.seqnum = aimutil_get16(generic+2);
 
   /* store commandlen -- bytes 5 and 6 */
   newrx->commandlen = aimutil_get16(generic+4);
@@ -75,18 +79,17 @@
   newrx->nofree = 0; /* free by default */
 
   /* malloc for data portion */
-  newrx->data = (u_char *) malloc(newrx->commandlen);
-  if (!newrx->data) {
+  if (!(newrx->data = (u_char *) malloc(newrx->commandlen))) {
     free(newrx);
+    faim_mutex_unlock(&conn->active);
     return -1;
   }
 
   /* read the data portion of the packet */
-  faim_mutex_lock(&conn->active);
   if (read(conn->fd, newrx->data, newrx->commandlen) < newrx->commandlen){
     free(newrx->data);
     free(newrx);
-    aim_conn_close(conn);
+    aim_conn_kill(sess, &conn);
     faim_mutex_unlock(&conn->active);
     return -1;
   }
@@ -119,6 +122,82 @@
   return 0;  
 }
 
+int aim_get_command_rendezvous(struct aim_session_t *sess, struct aim_conn_t *conn)
+{
+  unsigned char hdrbuf1[6];
+  unsigned char *hdr = NULL;
+  int hdrlen, hdrtype;
+  int payloadlength = 0;
+  int flags = 0;
+  char *snptr = NULL;
+
+  if (read(conn->fd, hdrbuf1, 6) < 6) {
+    perror("read");
+    printf("faim: rend: read error\n");
+    aim_conn_kill(sess, &conn);
+    return -1;
+  }
+
+  hdrlen = aimutil_get16(hdrbuf1+4);
+
+  hdrlen -= 6;
+  hdr = malloc(hdrlen);
+
+  faim_mutex_lock(&conn->active);
+  if (read(conn->fd, hdr, hdrlen) < hdrlen) {
+    perror("read");
+    printf("faim: rend: read2 error\n");
+    free(hdr);
+    faim_mutex_unlock(&conn->active);
+    aim_conn_kill(sess, &conn);
+    return -1;
+  }
+  
+  hdrtype = aimutil_get16(hdr);  
+
+  switch (hdrtype) {
+  case 0x0001: {
+    payloadlength = aimutil_get32(hdr+22);
+    flags = aimutil_get16(hdr+32);
+    snptr = hdr+38;
+
+    printf("OFT frame: %04x / %04x / %04x / %s\n", hdrtype, payloadlength, flags, snptr);
+
+    if (flags == 0x000e) {
+      printf("directim: %s has started typing\n", snptr);
+    } else if ((flags == 0x0000) && payloadlength) {
+      unsigned char *buf;
+      buf = malloc(payloadlength+1);
+
+      /* XXX theres got to be a better way */
+      faim_mutex_lock(&conn->active);
+      if (recv(conn->fd, buf, payloadlength, MSG_WAITALL) < payloadlength) {
+	perror("read");
+	printf("faim: rend: read3 error\n");
+	free(buf);
+	faim_mutex_unlock(&conn->active);
+	aim_conn_kill(sess, &conn);
+	return -1;
+      }
+      faim_mutex_unlock(&conn->active);
+      buf[payloadlength] = '\0';
+      printf("directim: %s/%04x/%04x/%s\n", snptr, payloadlength, flags, buf);
+      aim_send_im_direct(sess, conn, buf);
+      free(buf);
+    }
+    break;
+  }
+  default:
+    printf("OFT frame: type %04x\n", hdrtype);  
+    /* data connection may be unreliable here */
+    break;
+  } /* switch */
+
+  free(hdr);
+  
+  return 0;
+}
+
 /*
  * Purge recieve queue of all handled commands (->handled==1).  Also
  * allows for selective freeing using ->nofree so that the client can
@@ -144,6 +223,8 @@
       sess->queue_incoming = NULL;
 
       if (!tmp->nofree) {
+	if (tmp->hdrtype == AIM_FRAMETYPE_OFT)
+	  free(tmp->hdr.oft.hdr2);
 	free(tmp->data);
 	free(tmp);
       } else
@@ -157,6 +238,8 @@
       tmp = cur->next;
       cur->next = tmp->next;
       if (!tmp->nofree) {
+	if (tmp->hdrtype == AIM_FRAMETYPE_OFT)
+	  free(tmp->hdr.oft.hdr2);
 	free(tmp->data);
 	free(tmp);
       } else
@@ -176,3 +259,21 @@
 
   return;
 }
+
+/*
+ * Since aim_get_command will aim_conn_kill dead connections, we need
+ * to clean up the rxqueue of unprocessed connections on that socket.
+ *
+ * XXX: this is something that was handled better in the old connection
+ * handling method, but eh.
+ */
+void aim_rxqueue_cleanbyconn(struct aim_session_t *sess, struct aim_conn_t *conn)
+{
+  struct command_rx_struct *currx;
+
+  for (currx = sess->queue_incoming; currx; currx = currx->next) {
+    if ((!currx->handled) && (currx->conn == conn))
+      currx->handled = 1;
+  }	
+  return;
+}
--- a/libfaim/aim_search.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_search.c	Thu Jun 29 20:40:28 2000 +0000
@@ -17,7 +17,7 @@
   if (!address)
     return -1;
 
-  if (!(newpacket = aim_tx_new(0x0002, conn, 10+strlen(address))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+strlen(address))))
     return -1;
 
   newpacket->lock = 1;
--- a/libfaim/aim_txqueue.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/aim_txqueue.c	Thu Jun 29 20:40:28 2000 +0000
@@ -14,8 +14,12 @@
  *
  * Right now, that is.  If/when we implement a pool of transmit
  * frames, this will become the request-an-unused-frame part.
+ *
+ * framing = AIM_FRAMETYPE_OFT/OSCAR
+ * chan = channel for OSCAR, hdrtype for OFT
+ *
  */
-struct command_tx_struct *aim_tx_new(int chan, struct aim_conn_t *conn, int datalen)
+struct command_tx_struct *aim_tx_new(unsigned short framing, int chan, struct aim_conn_t *conn, int datalen)
 {
   struct command_tx_struct *new;
 
@@ -30,11 +34,21 @@
   memset(new, 0, sizeof(struct command_tx_struct));
 
   new->conn = conn; 
-  new->type = chan;
 
   if(datalen) {
     new->data = (u_char *)malloc(datalen);
     new->commandlen = datalen;
+  } else
+    new->data = NULL;
+
+  new->hdrtype = framing;
+  if (new->hdrtype == AIM_FRAMETYPE_OSCAR) {
+    new->hdr.oscar.type = chan;
+  } else if (new->hdrtype == AIM_FRAMETYPE_OFT) {
+    new->hdr.oft.type = chan;
+    new->hdr.oft.hdr2len = 0; /* this will get setup by caller */
+  } else { 
+    printf("tx_new: unknown framing\n");
   }
 
   return new;
@@ -66,8 +80,10 @@
       newpacket->conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
   }
  
-  /* assign seqnum */
-  newpacket->seqnum = aim_get_next_txseqnum(newpacket->conn);
+  if (newpacket->hdrtype == AIM_FRAMETYPE_OSCAR) {
+    /* assign seqnum */
+    newpacket->hdr.oscar.seqnum = aim_get_next_txseqnum(newpacket->conn);
+  }
   /* set some more fields */
   newpacket->lock = 1; /* lock */
   newpacket->sent = 0; /* not sent yet */
@@ -116,12 +132,13 @@
     return -1;
   }
 
-  newpacket->seqnum = aim_get_next_txseqnum(newpacket->conn);
+  if (newpacket->hdrtype == AIM_FRAMETYPE_OSCAR)
+    newpacket->hdr.oscar.seqnum = aim_get_next_txseqnum(newpacket->conn);
 
   newpacket->lock = 1; /* lock */
   newpacket->sent = 0; /* not sent yet */
 
-  aim_tx_sendframe(newpacket);
+  aim_tx_sendframe(sess, newpacket);
 
   if (newpacket->data)
     free(newpacket->data);
@@ -169,8 +186,10 @@
     faimdprintf(2, "aim_tx_flushqueue(): queue empty");
   else {
       for (cur = sess->queue_outgoing; cur; cur = cur->next) {
-	  faimdprintf(2, "\t  %2x   %4x %4x   %1d    %1d\n", 
-		      cur->type, cur->seqnum, 
+	  faimdprintf(2, "\t  %2x  %2x   %4x %4x   %1d    %1d\n", 
+		      cur->hdrtype,
+		      (cur->hdrtype==AIM_FRAMETYPE_OFT)?cur->hdr.oft.type:cur->hdr.oscar.type, 
+		      (cur->hdrtype==AIM_FRAMETYPE_OSCAR)?cur->seqnum:0, 
 		      cur->commandlen, cur->lock, 
 		      cur->sent);
       }
@@ -206,46 +225,86 @@
  *    9) Step to next struct in list and go back to 1.
  *
  */
-int aim_tx_sendframe(struct command_tx_struct *cur)
+int aim_tx_sendframe(struct aim_session_t *sess, struct command_tx_struct *cur)
 {
-  u_char *curPacket;
+  int buflen = 0;
+  unsigned char *curPacket;
 
   if (!cur)
     return -1; /* fatal */
 
   cur->lock = 1; /* lock the struct */
 
+  if (cur->hdrtype == AIM_FRAMETYPE_OSCAR)
+    buflen = cur->commandlen + 6;
+  else if (cur->hdrtype == AIM_FRAMETYPE_OFT)
+    buflen = cur->hdr.oft.hdr2len + 8;
+  else {
+    cur->lock = 0;
+    return -1;
+  }
+
   /* allocate full-packet buffer */
-  curPacket = (char *) malloc(cur->commandlen + 6);
-      
-  /* command byte */
-  curPacket[0] = 0x2a;
+  if (!(curPacket = (unsigned char *) malloc(buflen))) {
+    cur->lock = 0;
+    return -1;
+  }
       
-  /* type/family byte */
-  curPacket[1] = cur->type;
+  if (cur->hdrtype == AIM_FRAMETYPE_OSCAR) {
+    /* command byte */
+    curPacket[0] = 0x2a;
       
-  /* bytes 3+4: word: FLAP sequence number */
-  aimutil_put16(curPacket+2, cur->seqnum);
+    /* type/family byte */
+    curPacket[1] = cur->hdr.oscar.type;
+      
+    /* bytes 3+4: word: FLAP sequence number */
+    aimutil_put16(curPacket+2, cur->hdr.oscar.seqnum);
 
-  /* bytes 5+6: word: SNAC len */
-  aimutil_put16(curPacket+4, cur->commandlen);
+    /* bytes 5+6: word: SNAC len */
+    aimutil_put16(curPacket+4, cur->commandlen);
       
-  /* bytes 7 and on: raw: SNAC data */  /* XXX: ye gods! get rid of this! */
-  memcpy(&(curPacket[6]), cur->data, cur->commandlen);
-      
-  /* full image of raw packet data now in curPacket */
+    /* bytes 7 and on: raw: SNAC data */  /* XXX: ye gods! get rid of this! */
+    memcpy(&(curPacket[6]), cur->data, cur->commandlen);
+
+  } else if (cur->hdrtype == AIM_FRAMETYPE_OFT) {
+    int z = 0;
+
+    z += aimutil_put8(curPacket+z, 0x4f);
+    z += aimutil_put8(curPacket+z, 0x44);
+    z += aimutil_put8(curPacket+z, 0x43);
+    z += aimutil_put8(curPacket+z, 0x32);
+
+    z += aimutil_put16(curPacket+z, cur->hdr.oft.hdr2len + 8);
+    z += aimutil_put16(curPacket+z, cur->hdr.oft.type);
+
+    memcpy(curPacket+z, cur->hdr.oft.hdr2, cur->hdr.oft.hdr2len);
+  }
+
+  /* 
+   * For OSCAR, a full image of the raw packet data now in curPacket.
+   * For OFT, an image of just the bloated header is in curPacket, 
+   * since OFT allows us to do the data in a different write (yay!).
+   */
   faim_mutex_lock(&cur->conn->active);
-  if ( (u_int)write(cur->conn->fd, curPacket, (cur->commandlen + 6)) != (cur->commandlen + 6)) {
+  if ( (u_int)write(cur->conn->fd, curPacket, buflen) != buflen) {
     faim_mutex_unlock(&cur->conn->active);
-    printf("\nWARNING: Error in sending packet 0x%4x -- will try again next time\n\n", cur->seqnum);
-    cur->sent = 0; /* mark it unsent */
-    return 0; /* bail out -- continuable error */
-  } else {
-    faimdprintf(2, "\nSENT 0x%4x\n\n", cur->seqnum);
-    
-    cur->sent = 1; /* mark the struct as sent */
-    cur->conn->lastactivity = time(NULL);
+    cur->sent = 1;
+    aim_conn_kill(sess, &cur->conn);
+    return 0; /* bail out */
   }
+
+  if ((cur->hdrtype == AIM_FRAMETYPE_OFT) && cur->commandlen) {
+    if (write(cur->conn->fd, cur->data, cur->commandlen) != cur->commandlen) {
+      /* 
+       * Theres nothing we can do about this since we've already sent the 
+       * header!  The connection is unstable.
+       */
+    }
+  }
+
+  cur->sent = 1; /* mark the struct as sent */
+  cur->conn->lastactivity = time(NULL);
+
   faim_mutex_unlock(&cur->conn->active);
 
 #if debug > 2
@@ -293,7 +352,7 @@
 	sleep((cur->conn->lastactivity + cur->conn->forcedlatency) - time(NULL));
       }
 
-      if (aim_tx_sendframe(cur) == -1)
+      if (aim_tx_sendframe(sess, cur) == -1)
 	break;
     }
   }
@@ -324,6 +383,8 @@
     if (!sess->queue_outgoing->lock && sess->queue_outgoing->sent) {
       tmp = sess->queue_outgoing;
       sess->queue_outgoing = NULL;
+      if (tmp->hdrtype == AIM_FRAMETYPE_OFT)
+	free(tmp->hdr.oft.hdr2);
       free(tmp->data);
       free(tmp);
     }
@@ -334,6 +395,8 @@
     if (!cur->next->lock && cur->next->sent) {
       tmp = cur->next;
       cur->next = tmp->next;
+      if (tmp->hdrtype == AIM_FRAMETYPE_OFT)
+	free(tmp->hdr.oft.hdr2);
       free(tmp->data);
       free(tmp);
     }	
--- a/libfaim/faim/aim.h	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/faim/aim.h	Thu Jun 29 20:40:28 2000 +0000
@@ -10,11 +10,11 @@
 #define FAIM_VERSION_MINOR 99
 #define FAIM_VERSION_MINORMINOR 0
 
-#include <faimconfig.h>
-#include <aim_cbtypes.h>
+#include <faim/faimconfig.h>
+#include <faim/aim_cbtypes.h>
 
-#ifndef FAIM_USEPTHREADS
-#error pthreads are currently required.
+#if !defined(FAIM_USEPTHREADS) && !defined(FAIM_USEFAKELOCKS)
+#error pthreads or fakelocks are currently required.
 #endif
 
 #include <stdio.h>
@@ -31,6 +31,18 @@
 #define faim_mutex_init pthread_mutex_init
 #define faim_mutex_lock pthread_mutex_lock
 #define faim_mutex_unlock pthread_mutex_unlock
+#elif defined(FAIM_USEFAKELOCKS)
+/*
+ * For platforms without pthreads, we also assume
+ * we're not linking against a threaded app.  Which
+ * means we don't have to do real locking.  The 
+ * macros below do nothing really.  They're a joke.
+ * But they get it to compile.
+ */
+#define faim_mutex_t char
+#define faim_mutex_init(x, y) *x = 0
+#define faim_mutex_lock(x) *x = 1;
+#define faim_mutex_unlock(x) *x = 0;
 #endif
 
 #ifdef _WIN32
@@ -56,10 +68,18 @@
 #define gethostbyname(x) gethostbyname2(x, AF_INET) 
 #endif
 
+#if !defined(MSG_WAITALL)
+#warning FIX YOUR LIBC! MSG_WAITALL is required!
+#define MSG_WAITALL 0x100
+#endif
+
 /* 
  * Current Maximum Length for Screen Names (not including NULL) 
+ *
+ * Currently only names up to 16 characters can be registered
+ * however it is aparently legal for them to be larger.
  */
-#define MAXSNLEN 16
+#define MAXSNLEN 32
 
 /*
  * Current Maximum Length for Instant Messages
@@ -74,7 +94,7 @@
  * with utterly oversized instant messages!
  * 
  */
-#define MAXMSGLEN 7988
+#define MAXMSGLEN 7987
 
 /*
  * Current Maximum Length for Chat Room Messages
@@ -154,6 +174,9 @@
 #define AIM_CONN_STATUS_RESOLVERR   0x0080
 #define AIM_CONN_STATUS_CONNERR     0x0040
 
+#define AIM_FRAMETYPE_OSCAR 0x0000
+#define AIM_FRAMETYPE_OFT 0x0001
+
 struct aim_conn_t {
   int fd;
   int type;
@@ -170,25 +193,43 @@
 
 /* struct for incoming commands */
 struct command_rx_struct {
-                            /* byte 1 assumed to always be 0x2a */
-  char type;                /* type code (byte 2) */
-  u_int seqnum;             /* sequence number (bytes 3 and 4) */
-  u_int commandlen;         /* total packet len - 6 (bytes 5 and 6) */
-  u_char *data;             /* packet data (from 7 byte on) */
-  u_int lock;               /* 0 = open, !0 = locked */
-  u_int handled;            /* 0 = new, !0 = been handled */
-  u_int nofree;		    /* 0 = free data on purge, 1 = only unlink */
+  unsigned char hdrtype; /* defines which piece of the union to use */
+  union {
+    struct { 
+      char type;        
+      unsigned short seqnum;     
+    } oscar;
+    struct {
+      unsigned short type;
+      unsigned short hdr2len;
+      unsigned char *hdr2; /* rest of bloated header */
+    } oft;
+  } hdr;
+  unsigned short commandlen;         /* total payload length */
+  unsigned char *data;             /* packet data (from 7 byte on) */
+  unsigned char lock;               /* 0 = open, !0 = locked */
+  unsigned char handled;            /* 0 = new, !0 = been handled */
+  unsigned char nofree;		    /* 0 = free data on purge, 1 = only unlink */
   struct aim_conn_t *conn;  /* the connection it came in on... */
   struct command_rx_struct *next; /* ptr to next struct in list */
 };
 
 /* struct for outgoing commands */
 struct command_tx_struct {
-                            /* byte 1 assumed to be 0x2a */
-  char type;                /* type/family code */
-  u_int seqnum;             /* seqnum dynamically assigned on tx */
-  u_int commandlen;         /* SNAC length */
-  u_char *data;             /* packet data */
+  unsigned char hdrtype; /* defines which piece of the union to use */
+  union {
+    struct {
+      unsigned char type;
+      unsigned short seqnum;
+    } oscar;
+    struct {
+      unsigned short type;
+      unsigned short hdr2len;
+      unsigned char *hdr2;
+    } oft;
+  } hdr;
+  u_int commandlen;         
+  u_char *data;      
   u_int lock;               /* 0 = open, !0 = locked */
   u_int sent;               /* 0 = pending, !0 = has been sent */
   struct aim_conn_t *conn; 
@@ -318,7 +359,8 @@
  */
 int aim_get_command(struct aim_session_t *, struct aim_conn_t *);
 int aim_rxdispatch(struct aim_session_t *);
-
+u_long aim_debugconn_sendconnect(struct aim_session_t *sess,
+				 struct aim_conn_t *conn);
 int aim_logoff(struct aim_session_t *);
 
 void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **deadconn);
@@ -349,17 +391,18 @@
 			       char *ip,
 			       char *cookie);
 void aim_purge_rxqueue(struct aim_session_t *);
-
+void aim_rxqueue_cleanbyconn(struct aim_session_t *sess, struct aim_conn_t *conn);
 
 int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *command, ...);
 int aim_parse_missed_im(struct aim_session_t *, struct command_rx_struct *, ...);
 int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...);
 
-struct command_tx_struct *aim_tx_new(int, struct aim_conn_t *, int);
+
+struct command_tx_struct *aim_tx_new(unsigned short framing, int chan, struct aim_conn_t *conn, int datalen);
 int aim_tx_enqueue__queuebased(struct aim_session_t *, struct command_tx_struct *);
 int aim_tx_enqueue__immediate(struct aim_session_t *, struct command_tx_struct *);
 #define aim_tx_enqueue(x, y) ((*(x->tx_enqueue))(x, y))
-int aim_tx_sendframe(struct command_tx_struct *cur);
+int aim_tx_sendframe(struct aim_session_t *sess, struct command_tx_struct *cur);
 u_int aim_get_next_txseqnum(struct aim_conn_t *);
 int aim_tx_flushqueue(struct aim_session_t *);
 int aim_tx_printqueue(struct aim_session_t *);
@@ -415,6 +458,7 @@
 #define AIM_VISIBILITYCHANGE_DENYADD      0x07
 #define AIM_VISIBILITYCHANGE_DENYREMOVE   0x08
 
+u_long aim_bos_nop(struct aim_session_t *, struct aim_conn_t *);
 u_long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long);
 u_long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *);
 u_long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *);
@@ -447,6 +491,7 @@
 
 u_long aim_send_im(struct aim_session_t *, struct aim_conn_t *, char *, u_int, char *);
 int aim_parse_incoming_im_middle(struct aim_session_t *, struct command_rx_struct *);
+int aim_parse_outgoing_im_middle(struct aim_session_t *, struct command_rx_struct *);
 u_long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn);
 int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *);
 int aim_negchan_middle(struct aim_session_t *sess, struct command_rx_struct *command);
@@ -458,21 +503,16 @@
 #define AIM_CAPS_CHAT 0x08
 #define AIM_CAPS_GETFILE 0x10
 #define AIM_CAPS_SENDFILE 0x20
+
 extern u_char aim_caps[6][16];
+u_short aim_getcap(unsigned char *capblock, int buflen);
+int aim_putcap(unsigned char *capblock, int buflen, u_short caps);
 
 #define AIM_GETINFO_GENERALINFO 0x00001
 #define AIM_GETINFO_AWAYMESSAGE 0x00003
 
-#define AIM_RENDEZVOUS_VOICE 0x0000
-#define AIM_RENDEZVOUS_FILETRANSFER 0x0001
-#define AIM_RENDEZVOUS_CHAT_EX3 0x0003
-#define AIM_RENDEZVOUS_CHAT_EX4 0x0004
-#define AIM_RENDEZVOUS_CHAT_EX5 0x0005
-#define AIM_RENDEZVOUS_FILETRANSFER_GET 0x0012
-
 struct aim_msgcookie_t {
   unsigned char cookie[8];
-  unsigned char extended[16];
   int type;
   void *data;
   time_t addtime;
@@ -492,6 +532,7 @@
 #define AIM_TRANSFER_DENY_DECLINE 0x0001
 #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002
 u_long aim_denytransfer(struct aim_session_t *sess, struct aim_conn_t *conn, char *sender, char *cookie, unsigned short code);
+u_long aim_accepttransfer(struct aim_session_t *sess, struct aim_conn_t *conn, char *sender, char *cookie, unsigned short rendid);
 
 u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *, unsigned short);
 int aim_extractuserinfo(u_char *, struct aim_userinfo_s *);
--- a/libfaim/faim/aim_cbtypes.h	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/faim/aim_cbtypes.h	Thu Jun 29 20:40:28 2000 +0000
@@ -191,6 +191,7 @@
 #define AIM_CB_SPECIAL_AUTHSUCCESS 0x0001
 #define AIM_CB_SPECIAL_AUTHOTHER 0x0002
 #define AIM_CB_SPECIAL_CONNERR 0x0003
+#define AIM_CB_SPECIAL_DEBUGCONN_CONNECT 0xe001
 #define AIM_CB_SPECIAL_UNKNOWN 0xffff
 #define AIM_CB_SPECIAL_DEFAULT AIM_CB_SPECIAL_UNKNOWN
 
--- a/libfaim/faim/faimconfig.h	Thu Jun 29 19:38:18 2000 +0000
+++ b/libfaim/faim/faimconfig.h	Thu Jun 29 20:40:28 2000 +0000
@@ -106,14 +106,17 @@
 /*
  * Select whether or not to use POSIX thread functionality.
  * 
- * Default: defined on Linux, otherwise undefined
+ * We don't actually use threads, but we do use the POSIX mutex
+ * in order to maintain thread safety.  You can use the fake locking
+ * if you really don't like pthreads or you don't have it.
+ *
+ * Default: defined on Linux, otherwise use fake locks.
  */
-/*
 #ifdef __linux__
 #define FAIM_USEPTHREADS
+#else
+#define FAIM_USEFAKELOCKS
 #endif
-*/
-#define FAIM_USEPTHREADS
 
 #endif /* __FAIMCONFIG_H__ */
 
--- a/plugins/ChangeLog	Thu Jun 29 19:38:18 2000 +0000
+++ b/plugins/ChangeLog	Thu Jun 29 20:40:28 2000 +0000
@@ -8,6 +8,7 @@
 	- int gaim_plugin_init(void *) (no longer returns void, see error.c)
 	- void gaim_plugin_unload(void *) (to allow plugin to remove itself)
 	- can only load 1 instance of the same plugin
+	- PLUGIN_LIBS for extra libraries for plugin
 
 	The first thing to note is that there are about 9 new events plugins
 	can attach to, most of them dealing with chat, since I know that was a
@@ -54,6 +55,16 @@
 	for both instances would be removed. Rather than deal with two copies
 	of the same plugin, it is easier and cleaner to only handle one.
 
+	Sometimes it's necessary to link a plugin with libraries other than the
+	ones needed for GTK. Before, it was necessary to modify the Makefile to
+	do so (which was usually messy since it's generated by GNU automake).
+	Now, you can simply set the environment variable PLUGIN_LIBS to be the
+	extra libraries you want to link in. For example, to link plugin.c with
+	the math library, you can run the command
+	PLUGIN_LIBS=-lm make plugin.so
+	To link with multiple plugins, make sure to indicate spaces, e.g.
+	PLUGIN_LIBS='-lm -lcrypt' make encrypt.so
+
 	There is a new event, event_quit, which signifies that gaim has exited
 	correctly (i.e. didn't segfault). Also, after this event is called, all
 	plugins are removed, and their gaim_plugin_remove function is called.
--- a/plugins/HOWTO	Thu Jun 29 19:38:18 2000 +0000
+++ b/plugins/HOWTO	Thu Jun 29 20:40:28 2000 +0000
@@ -57,10 +57,18 @@
 the plugin gets unloaded, it removes the window. Also, all the callbacks you
 have attached to gaim signals will be removed.
 
+Plugins can also unload themselves. To do this, call gaim_plugin_unload(void *)
+(the void* is the handle passed to gaim_plugin_init). When your plugin gets
+unloaded, gaim will remove all of your callbacks. It will not call your
+gaim_plugin_remove function, however, since it will assume you have already
+done the necessary cleanup.
+
 Compilation of the plugins is fairly straight-forward; there is a Makefile in
 this directory that has a rule for making the .so file from a .c file. No
 modification of the Makefile should be necessary, unless if you simply want
 to type 'make' to have it made; otherwise, 'make filename.so' will take
-filename.c and make the .so plugin from it.
+filename.c and make the .so plugin from it. If you need to link in with extra
+libraries, you can set the environment variable PLUGIN_LIBS to be the libraries
+you want to link with.
 
 There are a few examples in this directory. Enjoy.
--- a/plugins/Makefile.am	Thu Jun 29 19:38:18 2000 +0000
+++ b/plugins/Makefile.am	Thu Jun 29 20:40:28 2000 +0000
@@ -9,7 +9,7 @@
 LDFLAGS += -ggdb $(GTK_LIBS) -shared
 SUFFIXES = .c .so
 .c.so:
-	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -fPIC -DPIC -o $@ $< $(LDFLAGS)
+	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -fPIC -DPIC -o $@ $< $(LDFLAGS) $(PLUGIN_LIBS)
 
 
 
--- a/src/away.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/src/away.c	Thu Jun 29 20:40:28 2000 +0000
@@ -153,7 +153,10 @@
 		gtk_container_add(GTK_CONTAINER(imaway), vbox);
 		awaymessage = a;
 
-        }
+        } else {
+		destroy_im_away();
+		do_away_message(w, a);
+	}
 
         /* New away message... Clear out the old sent_aways */
         while(cnv) {
--- a/src/oscar.c	Thu Jun 29 19:38:18 2000 +0000
+++ b/src/oscar.c	Thu Jun 29 20:40:28 2000 +0000
@@ -542,10 +542,7 @@
 	} else if (channel == 2) {
 		struct aim_userinfo_s *userinfo;
 		int rendtype = va_arg(ap, int);
-		if (rendtype == 0 ||
-		    rendtype == AIM_RENDEZVOUS_CHAT_EX3 ||
-		    rendtype == AIM_RENDEZVOUS_CHAT_EX4 ||
-		    rendtype == AIM_RENDEZVOUS_CHAT_EX5) {
+		if (rendtype & AIM_CAPS_CHAT) {
 			char *msg, *encoding, *lang;
 			struct aim_chat_roominfo *roominfo;
 
@@ -560,12 +557,15 @@
 					     roominfo->instance,
 					     userinfo->sn,
 					     msg);
-		} else if (rendtype == AIM_RENDEZVOUS_FILETRANSFER) {
+		} else if (rendtype & AIM_CAPS_SENDFILE) {
 			/* libfaim won't tell us that we got this just yet */
-		} else if (rendtype == AIM_RENDEZVOUS_FILETRANSFER_GET) {
+		} else if (rendtype & AIM_CAPS_GETFILE) {
 			/* nor will it tell us this. but it's still there */
-		} else if (rendtype == AIM_RENDEZVOUS_VOICE) {
+		} else if (rendtype & AIM_CAPS_VOICE) {
 			/* this one libfaim tells us unuseful info about  */
+		} else if (rendtype & AIM_CAPS_BUDDYICON) {
+			/* bah */
+		} else if (rendtype & AIM_CAPS_IMIMAGE) {
 		} else {
 			sprintf(debug_buff, "Unknown rendtype %d\n", rendtype);
 			debug_print(debug_buff);
@@ -670,8 +670,11 @@
 
 int gaim_chatnav_info(struct aim_session_t *sess,
 		      struct command_rx_struct *command, ...) {
-	va_list ap = va_start(ap, command);
-	u_short type = va_arg(ap, u_short);
+	va_list ap;
+	u_short type;
+
+	va_start(ap, command);
+	type = va_arg(ap, u_short);
 
 	switch(type) {
 		case 0x0002: {