]> andersk Git - libfaim.git/commitdiff
- Sun Apr 2 07:29:11 UTC 2000
authormid <mid>
Sun, 2 Apr 2000 07:30:54 +0000 (07:30 +0000)
committermid <mid>
Sun, 2 Apr 2000 07:30:54 +0000 (07:30 +0000)
   - Redid much of the tx path to remove the superfluous copy.  But
       it touches every function that transmits.  Its been a long
       time in coming.
   - Added caps parameter to aim_bos_setprofile().  You can now
       control what capabilties you show up as others to
   - Added ->capabilities to userinfo.  It should be nonzero when
       its coming off buddy oncoming information, but NOT requested
       user info.

12 files changed:
aim_auth.c
aim_buddylist.c
aim_chat.c
aim_chatnav.c
aim_im.c
aim_info.c
aim_login.c
aim_misc.c
aim_search.c
aim_txqueue.c
faim/aim.h
utils/faimtest/faimtest.c

index eb98ac961493c4b9ad792fead58bbced10d495e1..491e2e08628302c76d503b7f3b9054b3b1b26ddc 100644 (file)
@@ -12,61 +12,45 @@ int aim_auth_sendcookie(struct aim_session_t *sess,
                        struct aim_conn_t *conn, 
                        u_char *chipsahoy)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int curbyte=0;
   
-  newpacket.lock = 1;
+  if (!(newpacket = aim_tx_new(0x0001, conn, 4+2+2+AIM_COOKIELEN)))
+    return -1;
 
-  if (conn==NULL)
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH);
-  else
-    newpacket.conn = conn;
+  newpacket->lock = 1;
 
-  newpacket.type = 0x0001;  /* channel 1 (no SNACs, you know) */
-  
-  newpacket.commandlen = 4 + 2 + 2 + AIM_COOKIELEN;
-  newpacket.data = (char *) calloc(1, newpacket.commandlen);
-  
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0006);
-  curbyte += aimutil_put16(newpacket.data+curbyte, AIM_COOKIELEN);
-  memcpy(&(newpacket.data[curbyte]), chipsahoy, AIM_COOKIELEN);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0006);
+  curbyte += aimutil_put16(newpacket->data+curbyte, AIM_COOKIELEN);
+  memcpy(newpacket->data+curbyte, chipsahoy, AIM_COOKIELEN);
 
-  aim_tx_enqueue(sess, &newpacket);
-  
-  return 0;
+  return aim_tx_enqueue(sess, newpacket);
 }
 
 u_long aim_auth_clientready(struct aim_session_t *sess,
                            struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int curbyte = 0;
 
-  newpacket.lock = 1;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 26)))
+    return -1;
 
-  if (conn==NULL)
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH);
-  else
-    newpacket.conn = conn;
+  newpacket->lock = 1;
 
-  newpacket.type = 0x0002;
-  
-  newpacket.commandlen = 26;
-  newpacket.data = (u_char *) malloc(newpacket.commandlen);
-  
-  curbyte += aim_putsnac(newpacket.data+curbyte, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0013);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0007);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-
-  aim_tx_enqueue(sess, &newpacket);
+  curbyte += aim_putsnac(newpacket->data+curbyte, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0013);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0007);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+
+  aim_tx_enqueue(sess, newpacket);
 
   {
     struct aim_snac_t snac;
@@ -88,41 +72,23 @@ u_long aim_auth_changepasswd(struct aim_session_t *sess,
                             struct aim_conn_t *conn, 
                             char *new, char *current)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int i;
 
-  newpacket.lock = 1;
-
-  if (conn==NULL)
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH);
-  else
-    newpacket.conn = conn;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10+4+strlen(current)+4+strlen(new))))
+    return -1;
 
-  newpacket.type = 0x0002;
-  
-  newpacket.commandlen = 10 + 4 + strlen(current) + 4 + strlen(new);
-  newpacket.data = (char *) malloc(newpacket.commandlen);
+  newpacket->lock = 1;
 
-  aim_putsnac(newpacket.data, 0x0007, 0x0004, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x0007, 0x0004, 0x0000, sess->snac_nextid);
 
   /* current password TLV t(0002) */
-  i = 10;
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = 0x02;
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = strlen(current) & 0xff;
-  memcpy(&(newpacket.data[i]), current, strlen(current));
-  i += strlen(current);
+  i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(current), current);
 
   /* new password TLV t(0012) */
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = 0x12;
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = strlen(new) & 0xff;
-  memcpy(&(newpacket.data[i]), new, strlen(new));
-  i+=strlen(new);
-
-  aim_tx_enqueue(sess, &newpacket);
+  i += aim_puttlv_str(newpacket->data+i, 0x0012, strlen(new), new);
+
+  aim_tx_enqueue(sess, newpacket);
 
   {
     struct aim_snac_t snac;
index 5fdd6464b8c81ce3fd01fde2dc378c0581a98276..04572b3356945c6ef8e9b858a03f7dad7e0741f2 100644 (file)
@@ -11,29 +11,22 @@ u_long aim_add_buddy(struct aim_session_t *sess,
                     struct aim_conn_t *conn, 
                     char *sn )
 {
-   struct command_tx_struct newpacket;
+   struct command_tx_struct *newpacket;
+   int i;
 
-   if( !sn )
-      return -1;
+   if(!sn)
+     return -1;
 
-   if (conn)
-     newpacket.conn = conn;
-   else
-     newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
+   if (!(newpacket = aim_tx_new(0x0002, conn, 10+1+strlen(sn))))
+     return -1;
 
-   newpacket.lock = 1;
-   newpacket.type = 0x0002;
-   newpacket.commandlen = 11 + strlen( sn );
-   newpacket.data = (char *)malloc( newpacket.commandlen );
+   newpacket->lock = 1;
 
-   aim_putsnac(newpacket.data, 0x0003, 0x0004, 0x0000, sess->snac_nextid);
+   i = aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, sess->snac_nextid);
+   i += aimutil_put8(newpacket->data+i, strlen(sn));
+   i += aimutil_putstr(newpacket->data+i, sn, strlen(sn));
 
-   /* length of screenname */ 
-   newpacket.data[10] = strlen( sn );
-
-   memcpy( &(newpacket.data[11]), sn, strlen( sn ) );
-
-   aim_tx_enqueue(sess, &newpacket );
+   aim_tx_enqueue(sess, newpacket );
 
    {
       struct aim_snac_t snac;
@@ -56,29 +49,23 @@ u_long aim_remove_buddy(struct aim_session_t *sess,
                        struct aim_conn_t *conn, 
                        char *sn )
 {
-   struct command_tx_struct newpacket;
-
-   if( !sn )
-      return -1;
+   struct command_tx_struct *newpacket;
+   int i;
 
-   if (conn)
-     newpacket.conn = conn;
-   else
-     newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
+   if(!sn)
+     return -1;
 
-   newpacket.lock = 1;
-   newpacket.type = 0x0002;
-   newpacket.commandlen = 11 + strlen(sn);
-   newpacket.data = (char *)malloc( newpacket.commandlen );
+   if (!(newpacket = aim_tx_new(0x0002, conn, 10+1+strlen(sn))))
+     return -1;
 
-   aim_putsnac(newpacket.data, 0x0003, 0x0005, 0x0000, sess->snac_nextid);
+   newpacket->lock = 1;
 
-   /* length of screenname */ 
-   newpacket.data[10] = strlen( sn );
+   i = aim_putsnac(newpacket->data, 0x0003, 0x0005, 0x0000, sess->snac_nextid);
 
-   memcpy( &(newpacket.data[11]), sn, strlen( sn ) );
+   i += aimutil_put8(newpacket->data+i, strlen(sn));
+   i += aimutil_putstr(newpacket->data+i, sn, strlen(sn));
 
-   aim_tx_enqueue(sess,  &newpacket );
+   aim_tx_enqueue(sess, newpacket);
 
    {
       struct aim_snac_t snac;
index 83256f024dfdd200b718826c3395327528468a4b..03650aca716cdd221ea5d93b1d6e193bcf1daebc 100644 (file)
@@ -52,58 +52,43 @@ u_long aim_chat_send_im(struct aim_session_t *sess,
 {   
 
   int curbyte,i;
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
 
   if (!sess || !conn || !msg)
     return 0;
   
-  newpacket.lock = 1; /* lock struct */
-  newpacket.type = 0x02; /* IMs are always family 0x02 */
-
-  /* 
-   * Since we must have a specific connection, then theres 
-   * no use in going on if we don't have one... 
-   */
-  if (!conn)
-    return sess->snac_nextid;
-  newpacket.conn = conn;
-
-  /*
-   * Its simplest to set this arbitrarily large and waste
-   * space.  Precalculating is costly here.
-   */
-  newpacket.commandlen = 1152;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 1152)))
+    return -1;
 
-  newpacket.data = (u_char *) calloc(1, newpacket.commandlen);
+  newpacket->lock = 1; /* lock struct */
 
   curbyte  = 0;
-  curbyte += aim_putsnac(newpacket.data+curbyte, 
+  curbyte += aim_putsnac(newpacket->data+curbyte, 
                         0x000e, 0x0005, 0x0000, sess->snac_nextid);
 
   /* 
    * Generate a random message cookie 
-   *
    */
   for (i=0;i<8;i++)
-    curbyte += aimutil_put8(newpacket.data+curbyte, (u_char) random());
+    curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) random());
 
   /*
    * metaTLV start.  -- i assume this is a metaTLV.  it could be the
    *                    channel ID though.
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0003);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003);
 
   /*
    * Type 1: Unknown.  Blank.
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
   
   /*
    * Type 6: Unknown.  Blank.
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0006);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0006);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
 
   /*
    * Type 5: Message block.  Contains more TLVs.
@@ -112,18 +97,18 @@ u_long aim_chat_send_im(struct aim_session_t *sess,
    * put in a message TLV however.  
    * 
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0005);
-  curbyte += aimutil_put16(newpacket.data+curbyte, strlen(msg)+4);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005);
+  curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg)+4);
 
   /*
    * SubTLV: Type 1: Message
    */
-  curbyte += aim_puttlv_str(newpacket.data+curbyte, 0x0001, strlen(msg), msg);
+  curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(msg), msg);
   
-  newpacket.commandlen = curbyte;
+  newpacket->commandlen = curbyte;
 
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -141,40 +126,33 @@ u_long aim_chat_join(struct aim_session_t *sess,
                     u_short exchange,
                     const char *roomname)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int i;
 
   if (!sess || !conn || !roomname)
     return 0;
   
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10+9+strlen(roomname)+2)))
+    return -1;
 
-  newpacket.type = 0x02;
+  newpacket->lock = 1;
   
-  newpacket.commandlen = 10 + 9 + strlen(roomname) + 2;
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  memset(newpacket.data, 0x00, newpacket.commandlen);
-  
-  i = aim_putsnac(newpacket.data, 0x0001, 0x0004, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0004, 0x0000, sess->snac_nextid);
 
-  i+= aimutil_put16(newpacket.data+i, 0x000e);
+  i+= aimutil_put16(newpacket->data+i, 0x000e);
 
   /* 
    * this is techinally a TLV, but we can't use normal functions
    * because we need the extraneous nulls and other weird things.
    */
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
-  i+= aimutil_put16(newpacket.data+i, 2+1+strlen(roomname)+2);
-  i+= aimutil_put16(newpacket.data+i, exchange);
-  i+= aimutil_put8(newpacket.data+i, strlen(roomname));
-  memcpy(newpacket.data+i, roomname, strlen(roomname));
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 2+1+strlen(roomname)+2);
+  i+= aimutil_put16(newpacket->data+i, exchange);
+  i+= aimutil_put8(newpacket->data+i, strlen(roomname));
+  memcpy(newpacket->data+i, roomname, strlen(roomname));
   i+= strlen(roomname);
-  //i+= aimutil_putstr(newpacket.data+i, roomname, strlen(roomname));
-  i+= aimutil_put16(newpacket.data+i, 0x0000);
+  //i+= aimutil_putstr(newpacket->data+i, roomname, strlen(roomname));
+  i+= aimutil_put16(newpacket->data+i, 0x0000);
 
   /*
    * Chat hack.
@@ -188,8 +166,8 @@ u_long aim_chat_join(struct aim_session_t *sess,
   sess->pendingjoin = (char *)malloc(strlen(roomname)+1);
   strcpy(sess->pendingjoin, roomname);
 
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
 
 #if 0
   {
@@ -524,34 +502,30 @@ int aim_chat_parse_incoming(struct aim_session_t *sess,
 u_long aim_chat_clientready(struct aim_session_t *sess,
                            struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int i;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_CHAT);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 0x20;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 0x20)))
+    return -1;
+
+  newpacket->lock = 1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  i = aim_putsnac(newpacket.data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
 
-  i+= aimutil_put16(newpacket.data+i, 0x000e);
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x000e);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
 
-  i+= aimutil_put16(newpacket.data+i, 0x0004);
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0004);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
 
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
-  i+= aimutil_put16(newpacket.data+i, 0x0003);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0003);
 
-  i+= aimutil_put16(newpacket.data+i, 0x0004);
-  i+= aimutil_put16(newpacket.data+i, 0x0686);
+  i+= aimutil_put16(newpacket->data+i, 0x0004);
+  i+= aimutil_put16(newpacket->data+i, 0x0686);
 
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -586,94 +560,90 @@ u_long aim_chat_invite(struct aim_session_t *sess,
                       char *roomname,
                       u_short instance)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int i,curbyte=0;
 
   if (!sess || !conn || !sn || !msg || !roomname)
     return 0;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 1152+strlen(sn)+strlen(roomname)+strlen(msg);
+  if (!(newpacket = aim_tx_new(0x0002, conn, 1152+strlen(sn)+strlen(roomname)+strlen(msg))))
+    return -1;
+
+  newpacket->lock = 1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  curbyte = aim_putsnac(newpacket.data, 0x0004, 0x0006, 0x0000, sess->snac_nextid);
+  curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0006, 0x0000, sess->snac_nextid);
 
   /*
    * Cookie
    */
   for (i=0;i<8;i++)
-    curbyte += aimutil_put8(newpacket.data+curbyte, (u_char)rand());
+    curbyte += aimutil_put8(newpacket->data+curbyte, (u_char)rand());
 
   /*
    * Channel (2)
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
 
   /*
    * Dest sn
    */
-  curbyte += aimutil_put8(newpacket.data+curbyte, strlen(sn));
-  curbyte += aimutil_putstr(newpacket.data+curbyte, sn, strlen(sn));
+  curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sn));
+  curbyte += aimutil_putstr(newpacket->data+curbyte, sn, strlen(sn));
 
   /*
    * TLV t(0005)
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0005);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x28+strlen(msg)+0x04+0x03+strlen(roomname)+0x02);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x28+strlen(msg)+0x04+0x03+strlen(roomname)+0x02);
   
   /* 
    * Unknown info
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x3131);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x3538);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x3446);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x4100);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x748f);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x2420);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x6287);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x11d1);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x8222);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x4445);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x5354);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x3131);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x3538);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x3446);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x4100);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x748f);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x2420);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x6287);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x11d1);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x8222);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x4445);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x5354);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
   
   /*
    * TLV t(000a) -- Unknown
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x000a);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x000a);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
   
   /*
    * TLV t(000f) -- Unknown
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x000f);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x000f);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
   
   /*
    * TLV t(000c) -- Invitation message
    */
-  curbyte += aim_puttlv_str(newpacket.data+curbyte, 0x000c, strlen(msg), msg);
+  curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000c, strlen(msg), msg);
 
   /*
    * TLV t(2711) -- Container for room information 
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x2711);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 3+strlen(roomname)+2);
-  curbyte += aimutil_put16(newpacket.data+curbyte, exchange);
-  curbyte += aimutil_put8(newpacket.data+curbyte, strlen(roomname));
-  curbyte += aimutil_putstr(newpacket.data+curbyte, roomname, strlen(roomname));
-  curbyte += aimutil_put16(newpacket.data+curbyte, instance);
-
-  newpacket.commandlen = curbyte;
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x2711);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 3+strlen(roomname)+2);
+  curbyte += aimutil_put16(newpacket->data+curbyte, exchange);
+  curbyte += aimutil_put8(newpacket->data+curbyte, strlen(roomname));
+  curbyte += aimutil_putstr(newpacket->data+curbyte, roomname, strlen(roomname));
+  curbyte += aimutil_put16(newpacket->data+curbyte, instance);
+
+  newpacket->commandlen = curbyte;
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
index b6764e1c152dfe827d787b428540ae716edb61f0..fd5be6d048b32bcbefb2311e03e62e5836456237 100644 (file)
@@ -31,33 +31,29 @@ u_long aim_chatnav_reqrights(struct aim_session_t *sess,
 u_long aim_chatnav_clientready(struct aim_session_t *sess,
                               struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket; 
+  struct command_tx_struct *newpacket; 
   int i;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 0x20;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 0x20)))
+    return -1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  i = aim_putsnac(newpacket.data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+  newpacket->lock = 1;
 
-  i+= aimutil_put16(newpacket.data+i, 0x000d);
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
 
-  i+= aimutil_put16(newpacket.data+i, 0x0004);
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x000d);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
 
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
-  i+= aimutil_put16(newpacket.data+i, 0x0003);
+  i+= aimutil_put16(newpacket->data+i, 0x0004);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
 
-  i+= aimutil_put16(newpacket.data+i, 0x0004);
-  i+= aimutil_put16(newpacket.data+i, 0x0686);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0003);
 
-  aim_tx_enqueue(sess, &newpacket);
+  i+= aimutil_put16(newpacket->data+i, 0x0004);
+  i+= aimutil_put16(newpacket->data+i, 0x0686);
+
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -283,40 +279,35 @@ u_long aim_chatnav_createroom(struct aim_session_t *sess,
                              char *name, 
                              u_short exchange)
 {
-  struct command_tx_struct newpacket; 
+  struct command_tx_struct *newpacket; 
   int i;
   struct aim_snac_t snac;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV);
-  newpacket.type = 0x02;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10+12+strlen("invite")+strlen(name))))
+    return -1;
 
-  newpacket.commandlen = 10 + 12 + strlen("invite") + strlen(name);
+  newpacket->lock = 1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  i = aim_putsnac(newpacket.data, 0x000d, 0x0008, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x000d, 0x0008, 0x0000, sess->snac_nextid);
 
   /* exchange */
-  i+= aimutil_put16(newpacket.data+i, exchange);
+  i+= aimutil_put16(newpacket->data+i, exchange);
 
   /* room cookie */
-  i+= aimutil_put8(newpacket.data+i, strlen("invite"));
-  i+= aimutil_putstr(newpacket.data+i, "invite", strlen("invite"));
+  i+= aimutil_put8(newpacket->data+i, strlen("invite"));
+  i+= aimutil_putstr(newpacket->data+i, "invite", strlen("invite"));
 
   /* instance */
-  i+= aimutil_put16(newpacket.data+i, 0xffff);
+  i+= aimutil_put16(newpacket->data+i, 0xffff);
   
   /* detail level */
-  i+= aimutil_put8(newpacket.data+i, 0x01);
+  i+= aimutil_put8(newpacket->data+i, 0x01);
   
   /* tlvcount */
-  i+= aimutil_put16(newpacket.data+i, 0x0001);
+  i+= aimutil_put16(newpacket->data+i, 0x0001);
 
   /* room name */
-  i+= aim_puttlv_str(newpacket.data+i, 0x00d3, strlen(name), name);
+  i+= aim_puttlv_str(newpacket->data+i, 0x00d3, strlen(name), name);
 
   snac.id = sess->snac_nextid;
   snac.family = 0x000d;
@@ -326,7 +317,7 @@ u_long aim_chatnav_createroom(struct aim_session_t *sess,
   
   aim_newsnac(sess, &snac);
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
index 838699212f0fd8d2890402010f79849ac7ddc50b..7f95181bc7855d5d84198866ba5b65d38967346b 100644 (file)
--- a/aim_im.c
+++ b/aim_im.c
@@ -23,25 +23,15 @@ u_long aim_send_im(struct aim_session_t *sess,
 {   
 
   int curbyte,i;
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   
-  newpacket.lock = 1; /* lock struct */
-  newpacket.type = 0x02; /* IMs are always family 0x02 */
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  /*
-   * Its simplest to set this arbitrarily large and waste
-   * space.  Precalculating is costly here.
-   */
-  newpacket.commandlen = 1152;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 1152)))
+    return -1;
 
-  newpacket.data = (u_char *) calloc(1, newpacket.commandlen);
+  newpacket->lock = 1; /* lock struct */
 
   curbyte  = 0;
-  curbyte += aim_putsnac(newpacket.data+curbyte, 
+  curbyte += aim_putsnac(newpacket->data+curbyte, 
                         0x0004, 0x0006, 0x0000, sess->snac_nextid);
 
   /* 
@@ -54,70 +44,69 @@ u_long aim_send_im(struct aim_session_t *sess,
    *
    */
   for (i=0;i<8;i++)
-    curbyte += aimutil_put8(newpacket.data+curbyte, (u_char) random());
+    curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) random());
 
   /*
    * Channel ID
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte,0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte,0x0001);
 
   /* 
    * Destination SN (prepended with byte length)
    */
-  curbyte += aimutil_put8(newpacket.data+curbyte,strlen(destsn));
-  curbyte += aimutil_putstr(newpacket.data+curbyte, destsn, strlen(destsn));
+  curbyte += aimutil_put8(newpacket->data+curbyte,strlen(destsn));
+  curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn));
 
   /*
    * metaTLV start.
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002);
-  curbyte += aimutil_put16(newpacket.data+curbyte, strlen(msg) + 0x0d);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
+  curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x0d);
 
   /*
    * Flag data?
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0501);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0101);
-  curbyte += aimutil_put8 (newpacket.data+curbyte, 0x01);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0501);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0101);
+  curbyte += aimutil_put8 (newpacket->data+curbyte, 0x01);
 
   /* 
    * Message block length.
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, strlen(msg) + 0x04);
+  curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x04);
 
   /*
    * Character set data? 
    */
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
 
   /*
    * Message.  Not terminated.
    */
-  curbyte += aimutil_putstr(newpacket.data+curbyte,msg, strlen(msg));
+  curbyte += aimutil_putstr(newpacket->data+curbyte,msg, strlen(msg));
 
   /*
    * Set the Request Acknowledge flag.  
    */
-  if (flags & AIM_IMFLAGS_ACK)
-    {
-      curbyte += aimutil_put16(newpacket.data+curbyte,0x0003);
-      curbyte += aimutil_put16(newpacket.data+curbyte,0x0000);
-    }
+  if (flags & AIM_IMFLAGS_ACK) {
+    curbyte += aimutil_put16(newpacket->data+curbyte,0x0003);
+    curbyte += aimutil_put16(newpacket->data+curbyte,0x0000);
+  }
   
   /*
    * Set the Autoresponse flag.
    */
-  if (flags & AIM_IMFLAGS_AWAY)
-    {
-      curbyte += aimutil_put16(newpacket.data+curbyte,0x0004);
-      curbyte += aimutil_put16(newpacket.data+curbyte,0x0000);
-    }
+  if (flags & AIM_IMFLAGS_AWAY) {
+    curbyte += aimutil_put16(newpacket->data+curbyte,0x0004);
+    curbyte += aimutil_put16(newpacket->data+curbyte,0x0000);
+  }
   
-  newpacket.commandlen = curbyte;
+  newpacket->commandlen = curbyte;
+  newpacket->lock = 0;
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
 #ifdef USE_SNAC_FOR_IMS
  {
@@ -488,32 +477,28 @@ int aim_parse_incoming_im_middle(struct aim_session_t *sess,
 u_long aim_seticbmparam(struct aim_session_t *sess,
                        struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int curbyte;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-
-  newpacket.commandlen = 10 + 16;
-  newpacket.data = (u_char *) malloc (newpacket.commandlen);
-
-  curbyte = aim_putsnac(newpacket.data, 0x0004, 0x0002, 0x0000, sess->snac_nextid);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
-  curbyte += aimutil_put32(newpacket.data+curbyte, 0x00000003);
-  curbyte += aimutil_put8(newpacket.data+curbyte,  0x1f);
-  curbyte += aimutil_put8(newpacket.data+curbyte,  0x40);
-  curbyte += aimutil_put8(newpacket.data+curbyte,  0x03);
-  curbyte += aimutil_put8(newpacket.data+curbyte,  0xe7);
-  curbyte += aimutil_put8(newpacket.data+curbyte,  0x03);
-  curbyte += aimutil_put8(newpacket.data+curbyte,  0xe7);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
-
-  aim_tx_enqueue(sess, &newpacket);
+  if(!(newpacket = aim_tx_new(0x0002, conn, 10+16)))
+    return -1;
+
+  newpacket->lock = 1;
+
+  curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
+  curbyte += aimutil_put32(newpacket->data+curbyte, 0x00000003);
+  curbyte += aimutil_put8(newpacket->data+curbyte,  0x1f);
+  curbyte += aimutil_put8(newpacket->data+curbyte,  0x40);
+  curbyte += aimutil_put8(newpacket->data+curbyte,  0x03);
+  curbyte += aimutil_put8(newpacket->data+curbyte,  0xe7);
+  curbyte += aimutil_put8(newpacket->data+curbyte,  0x03);
+  curbyte += aimutil_put8(newpacket->data+curbyte,  0xe7);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
+
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
index 8ba5878e3769104cbee701f274fab0f676d978ea..7a70321ce3b86d337b69b1bbc1af479d88852ddd 100644 (file)
@@ -13,31 +13,25 @@ u_long aim_getinfo(struct aim_session_t *sess,
                   struct aim_conn_t *conn, 
                   const char *sn)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int i = 0;
 
   if (!sess || !conn || !sn)
     return 0;
 
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  newpacket.lock = 1;
-  newpacket.type = 0x0002;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 12+1+strlen(sn))))
+    return -1;
 
-  newpacket.commandlen = 12 + 1 + strlen(sn);
-  newpacket.data = (char *) malloc(newpacket.commandlen);
+  newpacket->lock = 1;
 
-  i = aim_putsnac(newpacket.data, 0x0002, 0x0005, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x0002, 0x0005, 0x0000, sess->snac_nextid);
 
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put8(newpacket.data+i, strlen(sn));
-  i += aimutil_putstr(newpacket.data+i, sn, strlen(sn));
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+  i += aimutil_put8(newpacket->data+i, strlen(sn));
+  i += aimutil_putstr(newpacket->data+i, sn, strlen(sn));
 
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
 
   {
     struct aim_snac_t snac;
@@ -56,6 +50,37 @@ u_long aim_getinfo(struct aim_session_t *sess,
   return (sess->snac_nextid++);
 }
 
+
+/*
+ * Capability blocks.  
+ */
+u_char aim_caps[6][16] = {
+  
+  /* Buddy icon */
+  {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, 
+   0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00},
+  
+  /* Voice */
+  {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, 
+   0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00},
+  
+  /* IM image */
+  {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1, 
+   0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00},
+  
+  /* Chat */
+  {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, 
+   0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00},
+  
+  /* Get file */
+  {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1,
+   0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00},
+  
+  /* Send file */
+  {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1, 
+   0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}
+};
+
 /*
  * AIM is fairly regular about providing user info.  This
  * is a generic routine to extract it in its standard form.
@@ -170,6 +195,29 @@ int aim_extractuserinfo(u_char *buf, struct aim_userinfo_s *outinfo)
           *
           */
        case 0x000d:
+         {
+           int z,y; 
+           int len;
+           len = aimutil_get16(buf+i+2);
+           if (!len)
+             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;
 
          /*
@@ -398,64 +446,56 @@ int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info)
 
 int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info)
 {
-  struct command_tx_struct tx;
+  struct command_tx_struct *tx;
   int i = 0;
 
   if (!sess || !conn || !info)
     return 0;
 
-  tx.conn = conn;
+  if (!(tx = aim_tx_new(0x0002, conn, 1152)))
+    return -1;
 
-  tx.commandlen = 1152; /* too big */
-  tx.data = malloc(tx.commandlen);
-  memset(tx.data, 0x00, tx.commandlen);
-  
-  tx.lock = 1;
-  tx.type = 0x02;
+  tx->lock = 1;
 
-  i += aimutil_put16(tx.data+i, 0x0003);
-  i += aimutil_put16(tx.data+i, 0x000b);
-  i += aimutil_put16(tx.data+i, 0x0000);
-  i += aimutil_put16(tx.data+i, 0x0000);
-  i += aimutil_put16(tx.data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0003);
+  i += aimutil_put16(tx->data+i, 0x000b);
+  i += aimutil_put16(tx->data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0000);
 
-  i += aim_putuserinfo(tx.data+i, tx.commandlen-i, info);
+  i += aim_putuserinfo(tx->data+i, tx->commandlen-i, info);
 
-  tx.commandlen = i;
-  tx.lock = 0;
-  aim_tx_enqueue(sess, &tx);
+  tx->commandlen = i;
+  tx->lock = 0;
+  aim_tx_enqueue(sess, tx);
 
   return 0;
 }
 
 int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn)
 {
-  struct command_tx_struct tx;
+  struct command_tx_struct *tx;
   int i = 0;
 
   if (!sess || !conn || !sn)
     return 0;
 
-  tx.conn = conn;
+  if (!(tx = aim_tx_new(0x0002, conn, 10+1+strlen(sn))))
+    return -1;
 
-  tx.commandlen = 10 + 1 + strlen(sn);
-  tx.data = malloc(tx.commandlen);
-  memset(tx.data, 0x00, tx.commandlen);
-  
-  tx.lock = 1;
-  tx.type = 0x02;
+  tx->lock = 1;
 
-  i += aimutil_put16(tx.data+i, 0x0003);
-  i += aimutil_put16(tx.data+i, 0x000c);
-  i += aimutil_put16(tx.data+i, 0x0000);
-  i += aimutil_put16(tx.data+i, 0x0000);
-  i += aimutil_put16(tx.data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0003);
+  i += aimutil_put16(tx->data+i, 0x000c);
+  i += aimutil_put16(tx->data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0000);
 
-  i += aimutil_put8(tx.data+i, strlen(sn));
-  i += aimutil_putstr(tx.data+i, sn, strlen(sn));
+  i += aimutil_put8(tx->data+i, strlen(sn));
+  i += aimutil_putstr(tx->data+i, sn, strlen(sn));
   
-  tx.lock = 0;
-  aim_tx_enqueue(sess, &tx);
+  tx->lock = 0;
+  aim_tx_enqueue(sess, tx);
 
   return 0;
 }
index 2c75d64d7d0d740cef963af6b70fdc7faaa721ea..86ff00c8ce1ab8b3cf93c4b1a0115db616cf2daa 100644 (file)
@@ -20,25 +20,18 @@ int aim_sendconnack(struct aim_session_t *sess,
 {
   int curbyte=0;
   
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
 
-  if (conn)
-    newpacket.conn = conn;
-  else
+  if (!(newpacket = aim_tx_new(0x0001, conn, 4)))
     return -1;
 
-  newpacket.commandlen = 2+2;
-  newpacket.data = (u_char *) calloc (1,  newpacket.commandlen );
-  newpacket.lock = 1;
-  newpacket.type = 0x01;
+  newpacket->lock = 1;
   
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
 
-  return 0;
+  newpacket->lock = 0;
+  return aim_tx_enqueue(sess, newpacket);
 }
 
 #ifdef SNACLOGIN
@@ -56,25 +49,18 @@ int aim_request_login(struct aim_session_t *sess,
 {
   int curbyte=0;
   
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
 
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH);
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10+2+2+strlen(sn))))
+    return -1;
 
-  newpacket.commandlen = 10+2+2+strlen(sn);
-  newpacket.data = (u_char *) calloc (1,  newpacket.commandlen );
-  newpacket.lock = 1;
-  newpacket.type = 0x02;
+  newpacket->lock = 1;
   
-  curbyte += aim_putsnac(newpacket.data+curbyte, 0x0017, 0x0006, 0x0000, 0x00010000);
-  curbyte += aim_puttlv_str(newpacket.data+curbyte, 0x0001, strlen(sn), sn);
+  curbyte += aim_putsnac(newpacket->data+curbyte, 0x0017, 0x0006, 0x0000, 0x00010000);
+  curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
 
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
-
-  return 0;
+  newpacket->lock = 0;
+  return aim_tx_enqueue(sess, newpacket);
 }
 #endif /* SNACLOGIN */
 
@@ -95,113 +81,101 @@ int aim_send_login (struct aim_session_t *sess,
   u_char *password_encoded = NULL;  /* to store encoded password */
   int curbyte=0;
 
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
 
   if (!clientinfo || !sn || !password)
     return -1;
 
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH);
+  if (!(newpacket = aim_tx_new(0x0002, conn, 1152)))
+    return -1;
 
 #ifdef SNACLOGIN 
-  newpacket.commandlen = 10;
-  newpacket.commandlen += 2 + 2 + strlen(sn);
-  newpacket.commandlen += 2 + 2 + strlen(password);
-  newpacket.commandlen += 2 + 2 + strlen(clientinfo->clientstring);
-  newpacket.commandlen += 56;
+  newpacket->commandlen = 10;
+  newpacket->commandlen += 2 + 2 + strlen(sn);
+  newpacket->commandlen += 2 + 2 + strlen(password);
+  newpacket->commandlen += 2 + 2 + strlen(clientinfo->clientstring);
+  newpacket->commandlen += 56;
   
-  newpacket.data = (u_char *) calloc (1,  newpacket.commandlen );
-  newpacket.lock = 1;
-  newpacket.type = 0x02;
+  newpacket->lock = 1;
 
-  curbyte = aim_putsnac(newpacket.data+curbyte, 0x0017, 0x0002, 0x0000, 0x00010000);
-  curbyte+= aim_puttlv_str(newpacket.data+curbyte, 0x0001, strlen(sn), sn);
+  curbyte = aim_putsnac(newpacket->data+curbyte, 0x0017, 0x0002, 0x0000, 0x00010000);
+  curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
   password_encoded = (u_char *) malloc(strlen(password));
   aim_encode_password(password, password_encoded);
-  curbyte+= aim_puttlv_str(newpacket.data+curbyte, 0x0002, strlen(password), password_encoded);
-  curbyte+= aim_puttlv_str(newpacket.data+curbyte, 0x0003, 
+  curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0002, strlen(password), password_encoded);
+  curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0003, 
                           strlen(clientinfo->clientstring), 
                           clientinfo->clientstring);
   /* XXX: should use clientinfo provided version info */
-  curbyte+= aim_puttlv_16(newpacket.data+curbyte, 0x0016, 0x0004);
-  curbyte+= aim_puttlv_16(newpacket.data+curbyte, 0x0017, 0x0003);
-  curbyte+= aim_puttlv_16(newpacket.data+curbyte, 0x0018, 0x0005);
-  curbyte+= aim_puttlv_16(newpacket.data+curbyte, 0x0019, 0x0000);
-  curbyte+= aim_puttlv_16(newpacket.data+curbyte, 0x001a, 0x0686);
-  curbyte+= aim_puttlv_str(newpacket.data+curbyte, 0x0001, 0x0002, clientinfo->country);
-  curbyte+= aim_puttlv_str(newpacket.data+curbyte, 0x0001, 0x0002, clientinfo->lang);
-  curbyte+= aim_puttlv_32(newpacket.data+curbyte, 0x0014, 0x0000002a);
-  curbyte+= aim_puttlv_16(newpacket.data+curbyte, 0x0009, 0x0015);
+  curbyte+= aim_puttlv_16(newpacket->data+curbyte, 0x0016, 0x0004);
+  curbyte+= aim_puttlv_16(newpacket->data+curbyte, 0x0017, 0x0003);
+  curbyte+= aim_puttlv_16(newpacket->data+curbyte, 0x0018, 0x0005);
+  curbyte+= aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0000);
+  curbyte+= aim_puttlv_16(newpacket->data+curbyte, 0x001a, 0x0686);
+  curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0001, 0x0002, clientinfo->country);
+  curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0001, 0x0002, clientinfo->lang);
+  curbyte+= aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x0000002a);
+  curbyte+= aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015);
 #else
   
-  newpacket.commandlen = 4 + 4+strlen(sn) + 4+strlen(password) + 6;
+  newpacket->commandlen = 4 + 4+strlen(sn) + 4+strlen(password) + 6;
  
-  if (clientinfo)
-    {
-      if (strlen(clientinfo->clientstring))
-       newpacket.commandlen += 4+strlen(clientinfo->clientstring);
-      newpacket.commandlen += 6+6+6+6;
-      if (strlen(clientinfo->country))
-       newpacket.commandlen += 4+strlen(clientinfo->country);
-      if (strlen(clientinfo->lang))
-       newpacket.commandlen += 4+strlen(clientinfo->lang);
-    }
-  newpacket.commandlen += 6;
+  if (clientinfo) {
+    if (strlen(clientinfo->clientstring))
+      newpacket->commandlen += 4+strlen(clientinfo->clientstring);
+    newpacket->commandlen += 6+6+6+6;
+    if (strlen(clientinfo->country))
+      newpacket->commandlen += 4+strlen(clientinfo->country);
+    if (strlen(clientinfo->lang))
+      newpacket->commandlen += 4+strlen(clientinfo->lang);
+  }
+  newpacket->commandlen += 6;
 
-  newpacket.data = (char *) calloc (1,  newpacket.commandlen );
-  newpacket.lock = 1;
-  newpacket.type = 0x01;
+  newpacket->lock = 1;
+  newpacket->type = 0x01;
 
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, strlen(sn));
-  curbyte += aimutil_putstr(newpacket.data+curbyte, sn, strlen(sn));
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, strlen(sn));
+  curbyte += aimutil_putstr(newpacket->data+curbyte, sn, strlen(sn));
 
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002);
-  curbyte += aimutil_put16(newpacket.data+curbyte, strlen(password));
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
+  curbyte += aimutil_put16(newpacket->data+curbyte, strlen(password));
   password_encoded = (char *) malloc(strlen(password));
   aim_encode_password(password, password_encoded);
-  curbyte += aimutil_putstr(newpacket.data+curbyte, password_encoded, strlen(password));
+  curbyte += aimutil_putstr(newpacket->data+curbyte, password_encoded, strlen(password));
   free(password_encoded);
   
-  curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0016, 0x0004);
+  curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, 0x0004);
   
-  if (clientinfo)
-    {
-      if (strlen(clientinfo->clientstring))
-       {
-         curbyte += aimutil_put16(newpacket.data+curbyte, 0x0003);
-         curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->clientstring));
-         curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->clientstring, strlen(clientinfo->clientstring));
-       }
-      curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0017, clientinfo->major /*0x0001*/);
-      curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0018, clientinfo->minor /*0x0001*/);
-      curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0019, 0x0000);
-      curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x001a, clientinfo->build /*0x0013*/);
-      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 (clientinfo) {
+    if (strlen(clientinfo->clientstring)) {
+      curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003);
+      curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->clientstring));
+      curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->clientstring, strlen(clientinfo->clientstring));
     }
+    curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, clientinfo->major /*0x0001*/);
+    curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, clientinfo->minor /*0x0001*/);
+    curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0000);
+    curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, clientinfo->build /*0x0013*/);
+    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));
+    }
+  }
 
-  curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0009, 0x0015);
+  curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015);
 #endif
 
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
-
-  return 0;
+  newpacket->lock = 0;
+  return aim_tx_enqueue(sess, newpacket);
 }
 
 /*
@@ -345,17 +319,13 @@ unsigned long aim_sendauthresp(struct aim_session_t *sess,
                               char *cookie, char *email, 
                               int regstatus)
 {      
-  struct command_tx_struct tx;
+  struct command_tx_struct *tx;
   struct aim_tlvlist_t *tlvlist = NULL;
 
-  tx.conn = conn;
-
-  tx.commandlen = 1152; /* arbitrarily large */
-  tx.data = malloc(tx.commandlen);
-  memset(tx.data, 0x00, tx.commandlen);
+  if (!(tx = aim_tx_new(0x0001 /*right??*/, conn, 1152)))
+    return -1;
   
-  tx.lock = 1;
-  tx.type = 0x01; /* XXX: right? */
+  tx->lock = 1;
 
   if (sn)
     aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn));
@@ -372,11 +342,9 @@ unsigned long aim_sendauthresp(struct aim_session_t *sess,
     aim_addtlvtochain16(&tlvlist, 0x0013, regstatus);
   }
 
-  tx.commandlen = aim_writetlvchain(tx.data, tx.commandlen, &tlvlist);
-  tx.lock = 0;
-  aim_tx_enqueue(sess, &tx);
-
-  return 0;
+  tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist);
+  tx->lock = 0;
+  return aim_tx_enqueue(sess, tx);
 }
 
 /*
@@ -399,40 +367,34 @@ int aim_gencookie(unsigned char *buf)
  */
 int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn)
 {
-  struct command_tx_struct tx;
+  struct command_tx_struct *tx;
   int i = 0;
 
-  tx.conn = conn;
-
-  tx.commandlen = 10 + 0x20;
-  tx.data = malloc(tx.commandlen);
-  memset(tx.data, 0x00, tx.commandlen);
-  
-  tx.lock = 1;
-  tx.type = 0x02;
-
-  i += aimutil_put16(tx.data+i, 0x0001);
-  i += aimutil_put16(tx.data+i, 0x0003);
-  i += aimutil_put16(tx.data+i, 0x0000);
-  i += aimutil_put16(tx.data+i, 0x0000);
-  i += aimutil_put16(tx.data+i, 0x0000);
-  
-  i += aimutil_put16(tx.data+i, 0x0001);  
-  i += aimutil_put16(tx.data+i, 0x0002);
-  i += aimutil_put16(tx.data+i, 0x0003);
-  i += aimutil_put16(tx.data+i, 0x0004);
-  i += aimutil_put16(tx.data+i, 0x0006);
-  i += aimutil_put16(tx.data+i, 0x0008);
-  i += aimutil_put16(tx.data+i, 0x0009);
-  i += aimutil_put16(tx.data+i, 0x000a);
-  i += aimutil_put16(tx.data+i, 0x000b);
-  i += aimutil_put16(tx.data+i, 0x000c);
-
-  tx.lock = 0;
+  if (!(tx = aim_tx_new(0x0002, conn, 10+0x20)))
+    return -1;
 
-  aim_tx_enqueue(sess, &tx);
+  tx->lock = 1;
 
-  return 0;
+  i += aimutil_put16(tx->data+i, 0x0001);
+  i += aimutil_put16(tx->data+i, 0x0003);
+  i += aimutil_put16(tx->data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0000);
+  
+  i += aimutil_put16(tx->data+i, 0x0001);  
+  i += aimutil_put16(tx->data+i, 0x0002);
+  i += aimutil_put16(tx->data+i, 0x0003);
+  i += aimutil_put16(tx->data+i, 0x0004);
+  i += aimutil_put16(tx->data+i, 0x0006);
+  i += aimutil_put16(tx->data+i, 0x0008);
+  i += aimutil_put16(tx->data+i, 0x0009);
+  i += aimutil_put16(tx->data+i, 0x000a);
+  i += aimutil_put16(tx->data+i, 0x000b);
+  i += aimutil_put16(tx->data+i, 0x000c);
+
+  tx->lock = 0;
+
+  return aim_tx_enqueue(sess, tx);
 }
 
 
@@ -445,34 +407,28 @@ unsigned long aim_sendredirect(struct aim_session_t *sess,
                               char *ip,
                               char *cookie)
 {      
-  struct command_tx_struct tx;
+  struct command_tx_struct *tx;
   struct aim_tlvlist_t *tlvlist = NULL;
   int i = 0;
 
-  tx.conn = conn;
+  if (!(tx = aim_tx_new(0x0002, conn, 1152)))
+    return -1;
+
+  tx->lock = 1;
 
-  tx.commandlen = 1152; /* arbitrarily large */
-  tx.data = malloc(tx.commandlen);
-  memset(tx.data, 0x00, tx.commandlen);
-  
-  tx.lock = 1;
-  tx.type = 0x02;
-
-  i += aimutil_put16(tx.data+i, 0x0001);
-  i += aimutil_put16(tx.data+i, 0x0005);
-  i += aimutil_put16(tx.data+i, 0x0000);
-  i += aimutil_put16(tx.data+i, 0x0000);
-  i += aimutil_put16(tx.data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0001);
+  i += aimutil_put16(tx->data+i, 0x0005);
+  i += aimutil_put16(tx->data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0000);
+  i += aimutil_put16(tx->data+i, 0x0000);
   
   aim_addtlvtochain16(&tlvlist, 0x000d, servid);
   aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip));
   aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
 
-  tx.commandlen = aim_writetlvchain(tx.data+i, tx.commandlen-i, &tlvlist)+i;
+  tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i;
   aim_freetlvchain(&tlvlist);
 
-  tx.lock = 0;
-  aim_tx_enqueue(sess, &tx);
-
-  return 0;
+  tx->lock = 0;
+  return aim_tx_enqueue(sess, tx);
 }
index a451d7a99a45dd69ba71d5c91ed0864f92d8f2a4..242d28da161372efb51669a2d89d8be0d89fa284 100644 (file)
@@ -61,7 +61,8 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
                                struct aim_conn_t *conn, 
                                int changetype, char *denylist)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
+  int packlen = 0;
   u_short subtype;
 
   char *localcpy = NULL;
@@ -72,24 +73,16 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
   if (!denylist)
     return 0;
 
-  newpacket.lock = 1;
-
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  newpacket.type = 0x02;
-
   localcpy = (char *) malloc(strlen(denylist)+1);
   memcpy(localcpy, denylist, strlen(denylist)+1);
   
   listcount = aimutil_itemcnt(localcpy, '&');
-  newpacket.commandlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9;
+  packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9;
 
+  if (!(newpacket = aim_tx_new(0x0002, conn, packlen)))
+    return -1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  memset(newpacket.data, 0x00, newpacket.commandlen);
+  newpacket->lock = 1;
 
   switch(changetype)
     {
@@ -98,12 +91,13 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
     case AIM_VISIBILITYCHANGE_DENYADD:      subtype = 0x07; break;
     case AIM_VISIBILITYCHANGE_DENYREMOVE:   subtype = 0x08; break;
     default:
-      free(newpacket.data);
+      free(newpacket->data);
+      free(newpacket);
       return 0;
     }
 
   /* We actually DO NOT send a SNAC ID with this one! */
-  aim_putsnac(newpacket.data, 0x0009, subtype, 0x00, 0);
+  aim_putsnac(newpacket->data, 0x0009, subtype, 0x00, 0);
  
   j = 10;  /* the next byte */
   
@@ -111,16 +105,16 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
     {
       tmpptr = aimutil_itemidx(localcpy, i, '&');
 
-      newpacket.data[j] = strlen(tmpptr);
-      memcpy(&(newpacket.data[j+1]), tmpptr, strlen(tmpptr));
+      newpacket->data[j] = strlen(tmpptr);
+      memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
       j += strlen(tmpptr)+1;
       free(tmpptr);
     }
   free(localcpy);
 
-  newpacket.lock = 0;
+  newpacket->lock = 0;
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid); /* dont increment */
 
@@ -135,7 +129,9 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
  *
  * buddy_list = "Screen Name One&ScreenNameTwo&";
  *
- * TODO: Clean this up.
+ * TODO: Clean this up.  
+ *
+ * XXX: I can't stress the TODO enough.
  *
  */
 u_long aim_bos_setbuddylist(struct aim_session_t *sess,
@@ -144,7 +140,7 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess,
 {
   int i, j;
 
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
 
   int packet_login_phase3c_hi_b_len = 0;
 
@@ -154,15 +150,9 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess,
   packet_login_phase3c_hi_b_len = 16; /* 16b for FLAP and SNAC headers */
 
   /* bail out if we can't make the packet */
-  if (buddy_list == NULL)
-    {
-      printf("\nNO BUDDIES!  ARE YOU THAT LONELY???\n");
-      return 0;
-    }
-#if debug > 0
-  printf("****buddy list: %s\n", buddy_list);
-  printf("****buddy list len: %d (%x)\n", strlen(buddy_list), strlen(buddy_list));
-#endif
+  if (!buddy_list) {
+    return -1;
+  }
 
   localcpy = (char *) malloc(strlen(buddy_list)+1);
   memcpy(localcpy, buddy_list, strlen(buddy_list)+1);
@@ -183,17 +173,12 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess,
 #endif
   free(localcpy);
 
-  newpacket.type = 0x02;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.commandlen = packet_login_phase3c_hi_b_len - 6;
-  newpacket.lock = 1;
-  
-  newpacket.data = (char *) malloc(newpacket.commandlen);
+  if (!(newpacket = aim_tx_new(0x0002, conn, packet_login_phase3c_hi_b_len - 6)))
+    return -1;
 
-  aim_putsnac(newpacket.data, 0x0003, 0x0004, 0x0000, sess->snac_nextid);
+  newpacket->lock = 1;
+  
+  aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, sess->snac_nextid);
 
   j = 10;  /* the next byte */
 
@@ -204,16 +189,16 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess,
 #if debug > 0
       printf("---adding %s (%d)\n", tmpptr, strlen(tmpptr));
 #endif
-      newpacket.data[j] = strlen(tmpptr);
-      memcpy(&(newpacket.data[j+1]), tmpptr, strlen(tmpptr));
+      newpacket->data[j] = strlen(tmpptr);
+      memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
       j += strlen(tmpptr)+1;
       i++;
       tmpptr = strtok(NULL, "&");
     }
 
-  newpacket.lock = 0;
+  newpacket->lock = 0;
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -242,56 +227,49 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess,
 u_long aim_bos_setprofile(struct aim_session_t *sess,
                          struct aim_conn_t *conn, 
                          char *profile,
-                         char *awaymsg)
+                         char *awaymsg,
+                         unsigned int caps)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int i = 0;
-  u_char funkydata[] = {
-    0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, 
-    0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00,
-    0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, 
-    0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00,
-
-    0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1, 
-    0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00,
-    0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, 
-    0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00,
-
-    0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1,
-    0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00,
-    0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1, 
-    0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00
-  };
-
-  newpacket.type = 0x02;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  newpacket.commandlen = 1152+strlen(profile)+1; /*arbitrarily large */
-  if (awaymsg) 
-    newpacket.commandlen += strlen(awaymsg);
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
+  if (!(newpacket = aim_tx_new(0x0002, conn, 1152+strlen(profile)+1+(awaymsg?strlen(awaymsg):0))))
+    return -1;
 
-  i += aim_putsnac(newpacket.data, 0x0002, 0x004, 0x0000, sess->snac_nextid);
-  i += aim_puttlv_str(newpacket.data+i, 0x0001, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\"");
-  i += aim_puttlv_str(newpacket.data+i, 0x0002, strlen(profile), profile);
+  i += aim_putsnac(newpacket->data, 0x0002, 0x004, 0x0000, sess->snac_nextid);
+  i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\"");
+  i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(profile), profile);
   /* why do we send this twice?  */
-  i += aim_puttlv_str(newpacket.data+i, 0x0003, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\"");
+  i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\"");
   
   /* Away message -- we send this no matter what, even if its blank */
   if (awaymsg)
-    i += aim_puttlv_str(newpacket.data+i, 0x0004, strlen(awaymsg), awaymsg);
+    i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(awaymsg), awaymsg);
   else
-    i += aim_puttlv_str(newpacket.data+i, 0x0004, 0x0000, NULL);
+    i += aim_puttlv_str(newpacket->data+i, 0x0004, 0x0000, NULL);
 
   /* Capability information. */
-  i += aim_puttlv_str(newpacket.data+i, 0x0005, 0x0060, funkydata);
-
-  newpacket.commandlen = i;
-  aim_tx_enqueue(sess, &newpacket);
+  {
+    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);
+  }
+  newpacket->commandlen = i;
+  aim_tx_enqueue(sess, newpacket);
   
   return (sess->snac_nextid++);
 }
@@ -367,22 +345,19 @@ u_long aim_bos_clientready(struct aim_session_t *sess,
      0x00, 0x01
   };
   int command_2_len = 0x52;
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-  newpacket.commandlen = command_2_len;
-  newpacket.data = (char *) malloc (newpacket.commandlen);
-  memcpy(newpacket.data, command_2, newpacket.commandlen);
+  if (!(newpacket = aim_tx_new(0x0002, conn, command_2_len)))
+    return -1;
+
+  newpacket->lock = 1;
+
+  memcpy(newpacket->data, command_2, command_2_len);
   
   /* This write over the dynamic parts of the byte block */
-  aim_putsnac(newpacket.data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -410,36 +385,27 @@ u_long aim_bos_reqrate(struct aim_session_t *sess,
 u_long aim_bos_ackrateresp(struct aim_session_t *sess,
                           struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
+  int packlen = 18, i=0;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 18;
-  if (conn->type != AIM_CONN_TYPE_BOS)
-    newpacket.commandlen += 2;
-
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  aim_putsnac(newpacket.data, 0x0001, 0x0008, 0x0000, sess->snac_nextid);
-
-  newpacket.data[10] = 0x00;
-  newpacket.data[11] = 0x01;
-  newpacket.data[12] = 0x00;
-  newpacket.data[13] = 0x02;
-  newpacket.data[14] = 0x00;
-  newpacket.data[15] = 0x03;
-  newpacket.data[16] = 0x00;
-  newpacket.data[17] = 0x04;
   if (conn->type != AIM_CONN_TYPE_BOS)
-    {
-      newpacket.data[16] = 0x00;
-      newpacket.data[17] = 0x05;
-    }
+    packlen += 2;
+
+  if(!(newpacket = aim_tx_new(0x0002, conn, packlen)));
+  
+  newpacket->lock = 1;
 
-  aim_tx_enqueue(sess, &newpacket);
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, sess->snac_nextid);
+  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);
+  
+  if (conn->type != AIM_CONN_TYPE_BOS) {
+    i += aimutil_put16(newpacket->data+i, 0x0005);
+  }
+
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -470,24 +436,20 @@ 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;
+  struct command_tx_struct *newpacket;
   
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 12;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 12)))
+    return -1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  aim_putsnac(newpacket.data, 0x000a, 0x0001, 0x000e /* huh? */, sess->snac_nextid);
+  newpacket->lock = 1;
+
+  aim_putsnac(newpacket->data, 0x000a, 0x0001, 0x000e /* huh? */, sess->snac_nextid);
   
-  newpacket.data[10] = 0x0d;
-  newpacket.data[11] = 0xda;
+  newpacket->data[10] = 0x0d;
+  newpacket->data[11] = 0xda;
 
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -495,62 +457,57 @@ u_long aim_bos_reqpersonalinfo(struct aim_session_t *sess,
 u_long aim_setversions(struct aim_session_t *sess,
                                struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int i;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 10 + (4*11);
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10 + (4*11))))
+    return -1;
+
+  newpacket->lock = 1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  i = aim_putsnac(newpacket.data, 0x0001, 0x0017, 0x0000, sess->snac_nextid);
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid);
 
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x0003);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x0003);
 
-  i += aimutil_put16(newpacket.data+i, 0x0002);
-  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, 0x0003);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x0003);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
 
-  i += aimutil_put16(newpacket.data+i, 0x0004);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x0004);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
 
-  i += aimutil_put16(newpacket.data+i, 0x0006);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x0006);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
 
-  i += aimutil_put16(newpacket.data+i, 0x0008);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x0008);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
 
-  i += aimutil_put16(newpacket.data+i, 0x0009);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x0009);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
 
-  i += aimutil_put16(newpacket.data+i, 0x000a);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x000a);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
 
-  i += aimutil_put16(newpacket.data+i, 0x000b);
-  i += aimutil_put16(newpacket.data+i, 0x0002);
+  i += aimutil_put16(newpacket->data+i, 0x000b);
+  i += aimutil_put16(newpacket->data+i, 0x0002);
 
-  i += aimutil_put16(newpacket.data+i, 0x000c);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x000c);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
 
-  i += aimutil_put16(newpacket.data+i, 0x0015);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x0015);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
 
 #if 0
-  for (j = 0; j < 0x10; j++)
-    {
-      i += aimutil_put16(newpacket.data+i, j); /* family */
-      i += aimutil_put16(newpacket.data+i, 0x0003); /* version */
-    }
+  for (j = 0; j < 0x10; j++) {
+    i += aimutil_put16(newpacket->data+i, j); /* family */
+    i += aimutil_put16(newpacket->data+i, 0x0003); /* version */
+  }
 #endif
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -609,24 +566,16 @@ u_long aim_genericreq_n(struct aim_session_t *sess,
                        struct aim_conn_t *conn, 
                        u_short family, u_short subtype)
 {
-  struct command_tx_struct newpacket;
-
-  newpacket.lock = 1;
+  struct command_tx_struct *newpacket;
 
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-
-  newpacket.commandlen = 10;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10)))
+    return 0;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  memset(newpacket.data, 0x00, newpacket.commandlen);
+  newpacket->lock = 1;
 
-  aim_putsnac(newpacket.data, family, subtype, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
  
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
   return (sess->snac_nextid++);
 }
 
@@ -638,34 +587,25 @@ u_long aim_genericreq_l(struct aim_session_t *sess,
                        struct aim_conn_t *conn, 
                        u_short family, u_short subtype, u_long *longdata)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   u_long newlong;
 
   /* If we don't have data, there's no reason to use this function */
   if (!longdata)
     return aim_genericreq_n(sess, conn, family, subtype);
 
-  newpacket.lock = 1;
-
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  newpacket.type = 0x02;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10+sizeof(u_long))))
+    return -1;
 
-  newpacket.commandlen = 10+sizeof(u_long);
+  newpacket->lock = 1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  memset(newpacket.data, 0x00, newpacket.commandlen);
-
-  aim_putsnac(newpacket.data, family, subtype, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
 
   /* copy in data */
   newlong = htonl(*longdata);
-  memcpy(&(newpacket.data[10]), &newlong, sizeof(u_long));
+  memcpy(&(newpacket->data[10]), &newlong, sizeof(u_long));
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
   return (sess->snac_nextid++);
 }
 
@@ -673,34 +613,25 @@ u_long aim_genericreq_s(struct aim_session_t *sess,
                        struct aim_conn_t *conn, 
                        u_short family, u_short subtype, u_short *shortdata)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   u_short newshort;
 
   /* If we don't have data, there's no reason to use this function */
   if (!shortdata)
     return aim_genericreq_n(sess, conn, family, subtype);
 
-  newpacket.lock = 1;
-
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  newpacket.type = 0x02;
-
-  newpacket.commandlen = 10+sizeof(u_short);
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10+sizeof(u_short))))
+    return -1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  memset(newpacket.data, 0x00, newpacket.commandlen);
+  newpacket->lock = 1;
 
-  aim_putsnac(newpacket.data, family, subtype, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
 
   /* copy in data */
   newshort = htons(*shortdata);
-  memcpy(&(newpacket.data[10]), &newshort, sizeof(u_short));
+  memcpy(&(newpacket->data[10]), &newshort, sizeof(u_short));
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
   return (sess->snac_nextid++);
 }
 
index 78aef0fc7c55da9edebac0498e1564f32c0283d0..0f18faf73ec7c12eadb11e26f14c53e2f506f3e3 100644 (file)
@@ -12,28 +12,21 @@ u_long aim_usersearch_address(struct aim_session_t *sess,
                              struct aim_conn_t *conn, 
                              char *address)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   
   if (!address)
     return -1;
 
-  newpacket.lock = 1;
-
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10+strlen(address))))
+    return -1;
 
-  newpacket.type = 0x0002;
-  
-  newpacket.commandlen = 10 + strlen(address);
-  newpacket.data = (char *) malloc(newpacket.commandlen);
+  newpacket->lock = 1;
 
-  aim_putsnac(newpacket.data, 0x000a, 0x0002, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, 0x000a, 0x0002, 0x0000, sess->snac_nextid);
 
-  memcpy(&(newpacket.data[10]), address, strlen(address));
+  aimutil_putstr(newpacket->data+10, address, strlen(address));
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   {
     struct aim_snac_t snac;
index a21481fd2045dcadf9512d88d41cf7fb13e9f349..7967cbf609a380ea537a62e7af32e53f87e02c03 100644 (file)
  * Allocate a new tx frame.
  *
  * This is more for looks than anything else.
+ *
+ * Right now, that is.  If/when we implement a pool of transmit
+ * frames, this will become the request-an-unused-frame part.
  */
-struct command_tx_struct *aim_tx_new(void)
+struct command_tx_struct *aim_tx_new(int chan, struct aim_conn_t *conn, int datalen)
 {
   struct command_tx_struct *new;
 
+  if (!conn)
+    return NULL;
+
   new = (struct command_tx_struct *)malloc(sizeof(struct command_tx_struct));
   if (!new)
     return NULL;
   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;
+  }
+
   return new;
 }
 
@@ -41,35 +55,31 @@ int aim_tx_enqueue(struct aim_session_t *sess,
                   struct command_tx_struct *newpacket)
 {
   struct command_tx_struct *cur;
-  struct command_tx_struct *newpacket_copy = NULL;
 
   if (newpacket->conn == NULL) {
-      faimdprintf(1, "aim_tx_enqueue: WARNING: enqueueing packet with no connecetion,  defaulting to BOS\n");
+      faimdprintf(1, "aim_tx_enqueue: WARNING: enqueueing packet with no connecetion\n");
       newpacket->conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
   }
  
-  newpacket_copy = (struct command_tx_struct *) malloc (sizeof(struct command_tx_struct));
-  memcpy(newpacket_copy, newpacket, sizeof(struct command_tx_struct));
-
   /* assign seqnum */
-  newpacket_copy->seqnum = aim_get_next_txseqnum(newpacket_copy->conn);
+  newpacket->seqnum = aim_get_next_txseqnum(newpacket->conn);
   /* set some more fields */
-  newpacket_copy->lock = 1; /* lock */
-  newpacket_copy->sent = 0; /* not sent yet */
-  newpacket_copy->next = NULL; /* always last */
+  newpacket->lock = 1; /* lock */
+  newpacket->sent = 0; /* not sent yet */
+  newpacket->next = NULL; /* always last */
 
   /* see overhead note in aim_rxqueue counterpart */
   if (sess->queue_outgoing == NULL) {
-    sess->queue_outgoing = newpacket_copy;
+    sess->queue_outgoing = newpacket;
   } else {
     for (cur = sess->queue_outgoing;
         cur->next;
         cur = cur->next)
       ;
-    cur->next = newpacket_copy;
+    cur->next = newpacket;
   }
 
-  newpacket_copy->lock = 0; /* unlock so it can be sent */
+  newpacket->lock = 0; /* unlock so it can be sent */
 
 #if debug == 2
   faimdprintf(2, "calling aim_tx_printqueue()\n");
index e230c9a9186a0fa334d17c431e9ab236c055cd34..1d6a770218ace2961c11921e6ec4f79d4795acbe 100644 (file)
@@ -211,6 +211,7 @@ struct aim_userinfo_s {
   u_long membersince;
   u_long onlinesince;
   u_long sessionlen;  
+  u_short capabilities;
 };
 
 #define AIM_CLASS_TRIAL        0x0001
@@ -299,7 +300,7 @@ 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(void);
+struct command_tx_struct *aim_tx_new(int, struct aim_conn_t *, int);
 int aim_tx_enqueue(struct aim_session_t *, struct command_tx_struct *);
 u_int aim_get_next_txseqnum(struct aim_conn_t *);
 int aim_tx_flushqueue(struct aim_session_t *);
@@ -359,7 +360,7 @@ void aim_session_init(struct aim_session_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 *);
-u_long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *);
+u_long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *, unsigned int);
 u_long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long);
 u_long aim_bos_clientready(struct aim_session_t *, struct aim_conn_t *);
 u_long aim_bos_reqrate(struct aim_session_t *, struct aim_conn_t *);
@@ -392,6 +393,13 @@ 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 *);
 
 /* aim_info.c */
+#define AIM_CAPS_BUDDYICON 0x01
+#define AIM_CAPS_VOICE 0x02
+#define AIM_CAPS_IMIMAGE 0x04
+#define AIM_CAPS_CHAT 0x08
+#define AIM_CAPS_GETFILE 0x10
+#define AIM_CAPS_SENDFILE 0x20
+extern u_char aim_caps[6][16];
 u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *);
 int aim_extractuserinfo(u_char *, struct aim_userinfo_s *);
 int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *);
index 62b049b7e709802744c5e5886ea3c7b93e58df36..853922c1b3d969ac72e2fca5e4bcfce744d2ca0e 100644 (file)
@@ -263,7 +263,7 @@ int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct
 
       /* 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_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_CHAT);
 
       /* send final login command (required) */
       aim_bos_clientready(sess, command->conn); /* tell BOS we're ready to go live */
This page took 0.15823 seconds and 5 git commands to generate.