]> andersk Git - libfaim.git/commitdiff
- Fri Sep 1 23:34:28 UTC 2000
authormid <mid>
Fri, 1 Sep 2000 23:44:46 +0000 (23:44 +0000)
committermid <mid>
Fri, 1 Sep 2000 23:44:46 +0000 (23:44 +0000)
   - Switched the read()s in rxqueue to use recv()
     - Should fix the big message problem and the big buddy list problem
   - Changed some values around in aim_misc to match winaim4.1
   - Added aim_addicbmparm. dunno what it does
   - Cleanup the login process in faimtest (can now login in less than 2sec)

CHANGES
aim_misc.c
aim_rxqueue.c
faim/aim.h
utils/faimtest/faimtest.c

diff --git a/CHANGES b/CHANGES
index 9f26b142477118abd61dc916ef74ec80937aaf4a..87eecb037aa5ce94ac84cae4befc35a8df9ba77e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,16 @@
 
 No release numbers
 ------------------
+ - Fri Sep  1 23:34:28 UTC 2000
+   - Switched the read()s in rxqueue to use recv()
+     - Should fix the big message problem and the big buddy list problem
+   - Changed some values around in aim_misc to match winaim4.1
+   - Added aim_addicbmparm. dunno what it does
+   - Cleanup the login process in faimtest (can now login in less than 2sec)
+
+ - Fri Sep  1 00:13:04 UTC 2000
+   - Avoid zero-length mallocs in aim_tlv
+
  - Thu Aug 31 23:40:23 UTC 2000
    - Threw in aim_select modification from nicolas
    - Remove stray debugging printf in aim_tlv
index b863b6c19ff0395dd7f6a1b855538ad43ba6e16f..4b38852197bb0cbf8ccb00ebaa6c0c331a722439 100644 (file)
@@ -142,65 +142,61 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess,
 
   struct command_tx_struct *newpacket;
 
-  int packet_login_phase3c_hi_b_len = 0;
+  int len = 0;
 
   char *localcpy = NULL;
   char *tmpptr = NULL;
 
-  packet_login_phase3c_hi_b_len = 16; /* 16b for FLAP and SNAC headers */
+  len = 10; /* 10B SNAC headers */
 
-  /* bail out if we can't make the packet */
-  if (!buddy_list) {
+  if (!buddy_list || !(localcpy = (char *) malloc(strlen(buddy_list)+1))) 
     return -1;
-  }
-
-  localcpy = (char *) malloc(strlen(buddy_list)+1);
-  memcpy(localcpy, buddy_list, strlen(buddy_list)+1);
+  strncpy(localcpy, buddy_list, strlen(buddy_list)+1);
 
   i = 0;
   tmpptr = strtok(localcpy, "&");
-  while ((tmpptr != NULL) && (i < 100))
-    {
+  while ((tmpptr != NULL) && (i < 150)) {
 #if debug > 0
-      printf("---adding %s (%d)\n", tmpptr, strlen(tmpptr));
+    printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr));
 #endif
-      packet_login_phase3c_hi_b_len += strlen(tmpptr)+1;
-      i++;
-      tmpptr = strtok(NULL, "&");
-    }
+    len += 1+strlen(tmpptr);
+    i++;
+    tmpptr = strtok(NULL, "&");
+  }
 #if debug > 0
-  printf("*** send buddy list len: %d (%x)\n", packet_login_phase3c_hi_b_len, packet_login_phase3c_hi_b_len);
+  printf("*** send buddy list len: %d (%x)\n", len, len);
 #endif
-  free(localcpy);
 
-  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packet_login_phase3c_hi_b_len - 6)))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, len)))
     return -1;
 
   newpacket->lock = 1;
   
-  aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, 0);
 
   j = 10;  /* the next byte */
 
+  strncpy(localcpy, buddy_list, strlen(buddy_list)+1);
   i = 0;
-  tmpptr = strtok(buddy_list, "&");
-  while ((tmpptr != NULL) & (i < 100))
-    {
+  tmpptr = strtok(localcpy, "&");
+  while ((tmpptr != NULL) & (i < 150)) {
 #if debug > 0
-      printf("---adding %s (%d)\n", tmpptr, strlen(tmpptr));
+    printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr));
 #endif
-      newpacket->data[j] = strlen(tmpptr);
-      memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
-      j += strlen(tmpptr)+1;
-      i++;
-      tmpptr = strtok(NULL, "&");
-    }
+    newpacket->data[j] = strlen(tmpptr);
+    memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
+    j += 1+strlen(tmpptr);
+    i++;
+    tmpptr = strtok(NULL, "&");
+  }
 
   newpacket->lock = 0;
 
   aim_tx_enqueue(sess, newpacket);
 
-  return (sess->snac_nextid++);
+  free(localcpy);
+
+  return (sess->snac_nextid);
 }
 
 /* 
@@ -283,7 +279,8 @@ u_long aim_bos_clientready(struct aim_session_t *sess,
      0x00, 0x01,   
      0x00, 0x03, 
      0x00, 0x04, 
-     0x06, 0x86,  
+     0x07, 0xda,  
+
      0x00, 0x02, 
      0x00, 0x01,  
      0x00, 0x04, 
@@ -292,7 +289,8 @@ u_long aim_bos_clientready(struct aim_session_t *sess,
      0x00, 0x03, 
      0x00, 0x01,  
      0x00, 0x04, 
-     0x00, 0x01, 
+     0x00, 0x01,
      0x00, 0x04, 
      0x00, 0x01, 
      0x00, 0x04,
@@ -357,28 +355,23 @@ u_long aim_bos_ackrateresp(struct aim_session_t *sess,
                           struct aim_conn_t *conn)
 {
   struct command_tx_struct *newpacket;
-  int packlen = 18, i=0;
+  int packlen = 20, i=0;
 
-  if (conn->type != AIM_CONN_TYPE_BOS)
-    packlen += 2;
-
-  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)));
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
+    return (sess->snac_nextid);
   
   newpacket->lock = 1;
 
-  i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, 0);
   i += aimutil_put16(newpacket->data+i, 0x0001); 
   i += aimutil_put16(newpacket->data+i, 0x0002);
   i += aimutil_put16(newpacket->data+i, 0x0003);
   i += aimutil_put16(newpacket->data+i, 0x0004);
+  i += aimutil_put16(newpacket->data+i, 0x0005);
   
-  if (conn->type != AIM_CONN_TYPE_BOS) {
-    i += aimutil_put16(newpacket->data+i, 0x0005);
-  }
-
   aim_tx_enqueue(sess, newpacket);
 
-  return (sess->snac_nextid++);
+  return (sess->snac_nextid);
 }
 
 /* 
@@ -407,22 +400,7 @@ u_long aim_bos_setprivacyflags(struct aim_session_t *sess,
 u_long aim_bos_reqpersonalinfo(struct aim_session_t *sess,
                               struct aim_conn_t *conn)
 {
-  struct command_tx_struct *newpacket;
-  
-  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 12)))
-    return -1;
-
-  newpacket->lock = 1;
-
-  aim_putsnac(newpacket->data, 0x000a, 0x0001, 0x000e /* huh? */, sess->snac_nextid);
-  
-  newpacket->data[10] = 0x0d;
-  newpacket->data[11] = 0xda;
-
-  newpacket->lock = 0;
-  aim_tx_enqueue(sess, newpacket);
-
-  return (sess->snac_nextid++);
+  return aim_genericreq_n(sess, conn, 0x0001, 0x000e);
 }
 
 u_long aim_setversions(struct aim_session_t *sess,
@@ -431,7 +409,7 @@ u_long aim_setversions(struct aim_session_t *sess,
   struct command_tx_struct *newpacket;
   int i;
 
-  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + (4*11))))
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + (4*12))))
     return -1;
 
   newpacket->lock = 1;
@@ -468,6 +446,9 @@ u_long aim_setversions(struct aim_session_t *sess,
   i += aimutil_put16(newpacket->data+i, 0x000c);
   i += aimutil_put16(newpacket->data+i, 0x0001);
 
+  i += aimutil_put16(newpacket->data+i, 0x0013);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
   i += aimutil_put16(newpacket->data+i, 0x0015);
   i += aimutil_put16(newpacket->data+i, 0x0001);
 
@@ -694,3 +675,31 @@ u_long aim_bos_reqicbmparaminfo(struct aim_session_t *sess,
   return aim_genericreq_n(sess, conn, 0x0004, 0x0004);
 }
 
+/*
+ * Add ICBM parameter? Huh?
+ */
+unsigned long aim_addicbmparam(struct aim_session_t *sess,
+                              struct aim_conn_t *conn)
+{
+  struct command_tx_struct *newpacket;
+  int packlen = 10+16, i=0;
+
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
+    return (sess->snac_nextid);
+  
+  newpacket->lock = 1;
+
+  i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid);
+  i += aimutil_put16(newpacket->data+i, 0x0000); 
+  i += aimutil_put16(newpacket->data+i, 0x0000);
+  i += aimutil_put16(newpacket->data+i, 0x0003);
+  i += aimutil_put16(newpacket->data+i, 0x1f40);
+  i += aimutil_put16(newpacket->data+i, 0x03e7);
+  i += aimutil_put16(newpacket->data+i, 0x03e7);
+  i += aimutil_put16(newpacket->data+i, 0x0000); 
+  i += aimutil_put16(newpacket->data+i, 0x0000); 
+  
+  aim_tx_enqueue(sess, newpacket);
+
+  return (sess->snac_nextid);
+}
index 41e34c71707d0b3eb3a970615808404e68119664..9d8dd7f228a5f5314308116e6ef6385d1d2224cc 100644 (file)
@@ -41,7 +41,8 @@ int aim_get_command(struct aim_session_t *sess, struct aim_conn_t *conn)
    *   4 short -- Number of data bytes that follow.
    */
   faim_mutex_lock(&conn->active);
-  if (read(conn->fd, generic, 6) < 6){
+  if (recv(conn->fd, generic, 6, MSG_WAITALL) < 6){
+    printf("faim: flap: read underflow (header)\n");
     aim_conn_close(conn);
     faim_mutex_unlock(&conn->active);
     return -1;
@@ -89,7 +90,8 @@ int aim_get_command(struct aim_session_t *sess, struct aim_conn_t *conn)
   }
 
   /* read the data portion of the packet */
-  if (read(conn->fd, newrx->data, newrx->commandlen) < newrx->commandlen){
+  if (recv(conn->fd, newrx->data, newrx->commandlen, MSG_WAITALL) < newrx->commandlen){
+    printf("faim: flap: read underflow (payload)\n");
     free(newrx->data);
     free(newrx);
     aim_conn_close(conn);
index 6f5165e46ab9af60f5fbe77ad0357ca7530ca18d..f5f5603dabbdcf418b7c0abcb1679f1880cf4805 100644 (file)
@@ -510,6 +510,7 @@ u_long aim_bos_reqrights(struct aim_session_t *, struct aim_conn_t *);
 u_long aim_bos_reqbuddyrights(struct aim_session_t *, struct aim_conn_t *);
 u_long aim_bos_reqlocaterights(struct aim_session_t *, struct aim_conn_t *);
 u_long aim_bos_reqicbmparaminfo(struct aim_session_t *, struct aim_conn_t *);
+unsigned long aim_addicbmparam(struct aim_session_t *sess,struct aim_conn_t *conn);
 u_long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn);
 
 struct aim_fileheader_t *aim_getlisting(struct aim_session_t*);
index f5f60f98f5d67b3f380e3631029c4b3e9625ae30..7ebb441db994db8a76b9d36fa6eac5b7705af465 100644 (file)
@@ -180,33 +180,54 @@ int main(void)
   exit(0);
 }
 
+int faimtest_rateresp(struct aim_session_t *sess, struct command_rx_struct *command, ...)
+{
+
+  switch(command->conn->type) {
+  case AIM_CONN_TYPE_BOS: {
+    /* this is the new buddy list */
+    char buddies[] = "Buddy1&Buddy2&ThisHereIsAName2&";
+    /* this is the new profile */
+    char profile[] = "Hello";  
+
+    aim_bos_ackrateresp(sess, command->conn);  /* ack rate info response */
+    aim_bos_reqpersonalinfo(sess, command->conn);
+    aim_bos_reqlocaterights(sess, command->conn);
+    aim_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_VOICE | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE);
+    aim_bos_reqbuddyrights(sess, command->conn);
+
+    /* send the buddy list and profile (required, even if empty) */
+    aim_bos_setbuddylist(sess, command->conn, buddies);
+
+    /* dont really know what this does */
+    aim_addicbmparam(sess, command->conn);
+    aim_bos_reqicbmparaminfo(sess, command->conn);  
+  
+    aim_bos_reqrights(sess, command->conn);  
+    /* set group permissions -- all user classes */
+    aim_bos_setgroupperm(sess, command->conn, AIM_CLASS_ALLUSERS);
+    aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE|AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
+
+    break;  
+  }
+
+  default: 
+    printf("faimtest: got rate response for unhandled connection type %04x\n", command->conn->type);
+    break;
+  }
+
+  return 1;
+}
+
 int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
 {
   switch (command->conn->type)
     {
     case AIM_CONN_TYPE_BOS:
 
-      aim_bos_reqrate(sess, command->conn); /* request rate info */
-      aim_bos_ackrateresp(sess, command->conn);  /* ack rate info response -- can we say timing? */
-      aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE|AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
-      
-#if 0
-      aim_bos_reqpersonalinfo(sess, command->conn);
-#endif
-      
-      /* Request advertisement service -- see comment in handleredirect */
-      aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS);
       aim_setversions(sess, command->conn);
+      aim_bos_reqrate(sess, command->conn); /* request rate info */
 
-#if 0
-      aim_bos_reqrights(sess, command->conn);
-      aim_bos_reqbuddyrights(sess, command->conn);
-      aim_bos_reqlocaterights(sess, command->conn);
-      aim_bos_reqicbmparaminfo(sess, command->conn);
-#endif
-      
-      /* set group permissions -- all user classes */
-      aim_bos_setgroupperm(sess, command->conn, AIM_CLASS_ALLUSERS);
       fprintf(stderr, "faimtest: done with BOS ServerReady\n");
       break;
 
@@ -240,6 +261,15 @@ int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *c
   return 1;
 }
 
+int faimtest_bosrights(struct aim_session_t *sess, struct command_rx_struct *command, ...)
+{
+  aim_bos_clientready(sess, command->conn);
+
+  printf("faimtest: officially connected to BOS.\n");
+
+  return 1;
+}
+
 /*
   handleredirect()...
 
@@ -262,11 +292,6 @@ int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct
   char *ip;
   char *cookie;
 
-  /* this is the new buddy list */
-  char buddies[] = "Buddy1&Buddy2&ThisHereIsAName2&";
-  /* this is the new profile */
-  char profile[] = "Hello";  
-
   va_start(ap, command);
   serviceid = va_arg(ap, int);
   ip = va_arg(ap, char *);
@@ -274,24 +299,6 @@ int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct
  
   switch(serviceid)
     {
-    case 0x0005: /* Advertisements */
-      /*
-       * The craziest explanation yet as to why we finish logging in when
-       * we get the advertisements redirect, of which we don't use anyway....
-       *                    IT WAS EASY!
-       */
-
-      /* send the buddy list and profile (required, even if empty) */
-      aim_bos_setbuddylist(sess, command->conn, buddies);
-      aim_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_VOICE | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE);
-
-      /* send final login command (required) */
-      aim_bos_clientready(sess, command->conn); /* tell BOS we're ready to go live */
-
-      /* you should now be ready to go */
-      printf("\nYou are now officially online.\n");      
-
-      break;
     case 0x0007: /* Authorizer */
       {
        struct aim_conn_t *tstconn;
@@ -389,6 +396,8 @@ int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct
     fprintf(stderr, "faimtest: could not connect to BOS\n");
     aim_conn_kill(sess, &bosconn);
   } else {
+    aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, faimtest_bosrights, 0);
+    aim_conn_addhandler(sess, bosconn, 0x0001, 0x0007, faimtest_rateresp, 0); /* rate info */
     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0);
     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_serverready, 0);
     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0);
This page took 0.075845 seconds and 5 git commands to generate.