4 * The routines for sending/receiving Instant Messages.
11 * Send an ICBM (instant message).
15 * AIM_IMFLAGS_AWAY -- Marks the message as an autoresponse
16 * AIM_IMFLAGS_ACK -- Requests that the server send an ack
17 * when the message is received (of type 0x0004/0x000c)
20 u_long aim_send_im(struct aim_session_t *sess,
21 struct aim_conn_t *conn,
22 char *destsn, u_int flags, char *msg)
26 struct command_tx_struct *newpacket;
28 if (strlen(msg) >= MAXMSGLEN)
31 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, strlen(msg)+256)))
34 newpacket->lock = 1; /* lock struct */
37 curbyte += aim_putsnac(newpacket->data+curbyte,
38 0x0004, 0x0006, 0x0000, sess->snac_nextid);
41 * Generate a random message cookie
43 * We could cache these like we do SNAC IDs. (In fact, it
44 * might be a good idea.) In the message error functions,
45 * the 8byte message cookie is returned as well as the
50 curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) random());
55 curbyte += aimutil_put16(newpacket->data+curbyte,0x0001);
58 * Destination SN (prepended with byte length)
60 curbyte += aimutil_put8(newpacket->data+curbyte,strlen(destsn));
61 curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn));
66 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
67 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x10);
70 * Flag data / ICBM Parameters?
72 curbyte += aimutil_put8(newpacket->data+curbyte, 0x05);
73 curbyte += aimutil_put8(newpacket->data+curbyte, 0x01);
75 /* number of bytes to follow */
76 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0004);
77 curbyte += aimutil_put8(newpacket->data+curbyte, 0x01);
78 curbyte += aimutil_put8(newpacket->data+curbyte, 0x01);
79 curbyte += aimutil_put8(newpacket->data+curbyte, 0x01);
80 curbyte += aimutil_put8(newpacket->data+curbyte, 0x02);
82 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0101);
85 * Message block length.
87 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x04);
92 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
93 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
96 * Message. Not terminated.
98 curbyte += aimutil_putstr(newpacket->data+curbyte,msg, strlen(msg));
101 * Set the Request Acknowledge flag.
103 if (flags & AIM_IMFLAGS_ACK) {
104 curbyte += aimutil_put16(newpacket->data+curbyte,0x0003);
105 curbyte += aimutil_put16(newpacket->data+curbyte,0x0000);
109 * Set the Autoresponse flag.
111 if (flags & AIM_IMFLAGS_AWAY) {
112 curbyte += aimutil_put16(newpacket->data+curbyte,0x0004);
113 curbyte += aimutil_put16(newpacket->data+curbyte,0x0000);
116 newpacket->commandlen = curbyte;
119 aim_tx_enqueue(sess, newpacket);
121 #ifdef USE_SNAC_FOR_IMS
123 struct aim_snac_t snac;
125 snac.id = sess->snac_nextid;
126 snac.family = 0x0004;
130 snac.data = malloc(strlen(destsn)+1);
131 memcpy(snac.data, destsn, strlen(destsn)+1);
133 aim_newsnac(sess, &snac);
136 aim_cleansnacs(sess, 60); /* clean out all SNACs over 60sec old */
139 return (sess->snac_nextid++);
142 struct aim_directim_priv {
143 unsigned char cookie[8];
147 int aim_send_im_direct(struct aim_session_t *sess,
148 struct aim_conn_t *conn,
151 struct command_tx_struct *newpacket;
152 struct aim_directim_priv *priv = NULL;
155 if (strlen(msg) >= MAXMSGLEN)
158 if (!sess || !conn || (conn->type != AIM_CONN_TYPE_RENDEZVOUS) || !conn->priv) {
159 printf("faim: directim: invalid arguments\n");
163 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OFT, 0x0001, conn, strlen(msg)))) {
164 printf("faim: directim: tx_new failed\n");
168 newpacket->lock = 1; /* lock struct */
170 priv = (struct aim_directim_priv *)conn->priv;
172 newpacket->hdr.oft.hdr2len = 0x44;
174 if (!(newpacket->hdr.oft.hdr2 = malloc(newpacket->hdr.oft.hdr2len))) {
180 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0006);
181 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
183 i += aimutil_putstr(newpacket->hdr.oft.hdr2+i, priv->cookie, 8);
185 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
186 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
187 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
188 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
190 i += aimutil_put32(newpacket->hdr.oft.hdr2+i, strlen(msg));
192 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
193 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
194 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
195 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
196 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
197 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
199 i += aimutil_putstr(newpacket->hdr.oft.hdr2+i, sess->logininfo.screen_name, strlen(sess->logininfo.screen_name));
202 i += aimutil_put8(newpacket->hdr.oft.hdr2+i, 0x00);
203 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
204 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
205 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
206 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
207 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
208 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
209 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
210 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
211 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
212 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
213 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
215 memcpy(newpacket->data, msg, strlen(msg));
219 aim_tx_enqueue(sess, newpacket);
224 int aim_parse_outgoing_im_middle(struct aim_session_t *sess,
225 struct command_rx_struct *command)
227 unsigned int i = 0, z;
228 rxcallback_t userfunc = NULL;
229 unsigned char cookie[8];
231 struct aim_tlvlist_t *tlvlist;
233 unsigned short icbmflags = 0;
234 unsigned char flag1 = 0, flag2 = 0;
235 unsigned char *msgblock = NULL, *msg = NULL;
240 for (z=0; z<8; z++,i++)
241 cookie[z] = command->data[i];
244 channel = aimutil_get16(command->data+i);
247 if (channel != 0x01) {
248 printf("faim: icbm: ICBM recieved on unsupported channel. Ignoring. (chan = %04x)\n", channel);
252 strncpy(sn, command->data+i+1, (int) *(command->data+i));
253 i += 1 + (int) *(command->data+i);
255 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
257 if (aim_gettlv(tlvlist, 0x0003, 1))
258 icbmflags |= AIM_IMFLAGS_ACK;
259 if (aim_gettlv(tlvlist, 0x0004, 1))
260 icbmflags |= AIM_IMFLAGS_AWAY;
262 if (aim_gettlv(tlvlist, 0x0002, 1)) {
265 msgblock = aim_gettlv_str(tlvlist, 0x0002, 1);
267 /* no, this really is correct. I'm not high or anything either. */
269 j += 2 + aimutil_get16(msgblock+j);
272 j += 2; /* final block length */
274 flag1 = aimutil_get16(msgblock);
276 flag2 = aimutil_get16(msgblock);
282 if ((userfunc = aim_callhandler(command->conn, 0x0004, 0x0006)) || (i = 0))
283 i = userfunc(sess, command, channel, sn, msg, icbmflags, flag1, flag2);
287 aim_freetlvchain(&tlvlist);
293 * It can easily be said that parsing ICBMs is THE single
294 * most difficult thing to do in the in AIM protocol. In
295 * fact, I think I just did say that.
297 * Below is the best damned solution I've come up with
298 * over the past sixteen months of battling with it. This
299 * can parse both away and normal messages from every client
300 * I have access to. Its not fast, its not clean. But it works.
302 * We should also support at least minimal parsing of
303 * Channel 2, so that we can at least know the name of the
304 * room we're invited to, but obviously can't attend...
307 int aim_parse_incoming_im_middle(struct aim_session_t *sess,
308 struct command_rx_struct *command)
311 rxcallback_t userfunc = NULL;
314 struct aim_tlvlist_t *tlvlist;
315 struct aim_userinfo_s userinfo;
318 memset(&userinfo, 0x00, sizeof(struct aim_userinfo_s));
320 i = 10; /* Skip SNAC header */
323 * Read ICBM Cookie. And throw away.
325 for (z=0; z<8; z++,i++)
326 cookie[z] = command->data[i];
331 * Channel 0x0001 is the message channel. There are
332 * other channels for things called "rendevous"
333 * which represent chat and some of the other new
334 * features of AIM2/3/3.5.
336 * Channel 0x0002 is the Rendevous channel, which
337 * is where Chat Invitiations and various client-client
338 * connection negotiations come from.
341 channel = aimutil_get16(command->data+i);
347 if ((channel != 0x01) && (channel != 0x02))
349 printf("faim: icbm: ICBM received on an unsupported channel. Ignoring.\n (chan = %04x)", channel);
354 * Extract the standard user info block.
356 * Note that although this contains TLVs that appear contiguous
357 * with the TLVs read below, they are two different pieces. The
358 * userinfo block contains the number of TLVs that contain user
359 * information, the rest are not even though there is no seperation.
360 * aim_extractuserinfo() returns the number of bytes used by the
361 * userinfo tlvs, so you can start reading the rest of them right
364 * That also means that TLV types can be duplicated between the
365 * userinfo block and the rest of the message, however there should
366 * never be two TLVs of the same type in one block.
369 i += aim_extractuserinfo(command->data+i, &userinfo);
372 * Read block of TLVs (not including the userinfo data). All
373 * further data is derived from what is parsed here.
375 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
378 * From here on, its depends on what channel we're on.
382 u_int j = 0, y = 0, z = 0;
385 struct aim_tlv_t *msgblocktlv, *tmptlv;
390 * Check Autoresponse status. If it is an autoresponse,
391 * it will contain a type 0x0004 TLV, with zero length.
393 if (aim_gettlv(tlvlist, 0x0004, 1))
394 icbmflags |= AIM_IMFLAGS_AWAY;
397 * Check Ack Request status.
399 if (aim_gettlv(tlvlist, 0x0003, 1))
400 icbmflags |= AIM_IMFLAGS_ACK;
405 msgblocktlv = aim_gettlv(tlvlist, 0x0002, 1);
406 if (!msgblocktlv || !msgblocktlv->value) {
407 printf("faim: icbm: major error! no message block TLV found!\n");
408 aim_freetlvchain(&tlvlist);
413 * Extracting the message from the unknown cruft.
415 * This is a bit messy, and I'm not really qualified,
416 * even as the author, to comment on it. At least
417 * its not as bad as a while loop shooting into infinity.
419 * "Do you believe in magic?"
422 msgblock = msgblocktlv->value;
425 wastebits = aimutil_get8(msgblock+j++);
426 wastebits = aimutil_get8(msgblock+j++);
428 y = aimutil_get16(msgblock+j);
430 for (z = 0; z < y; z++)
431 wastebits = aimutil_get8(msgblock+j++);
432 wastebits = aimutil_get8(msgblock+j++);
433 wastebits = aimutil_get8(msgblock+j++);
436 * Message string length, including flag words.
438 i = aimutil_get16(msgblock+j);
444 * Its rumored that these can kick in some funky
445 * 16bit-wide char stuff that used to really kill
446 * libfaim. Hopefully the latter is no longer true.
448 * Though someone should investiagte the former.
451 flag1 = aimutil_get16(msgblock+j);
453 flag2 = aimutil_get16(msgblock+j);
457 printf("faim: icbm: **warning: encoding flags are being used! {%04x, %04x}\n", flag1, flag2);
463 msg = (char *)malloc(i+1);
464 memcpy(msg, msgblock+j, i);
470 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
472 i = userfunc(sess, command, channel, &userinfo, msg, icbmflags, flag1, flag2);
478 else if (channel == 0x0002)
480 struct aim_tlv_t *block1;
481 struct aim_tlvlist_t *list2;
482 struct aim_tlv_t *tmptlv;
483 unsigned short reqclass = 0;
484 unsigned short status = 0;
487 * There's another block of TLVs embedded in the type 5 here.
489 block1 = aim_gettlv(tlvlist, 0x0005, 1);
491 printf("faim: no tlv 0x0005 in rendezvous transaction!\n");
492 aim_freetlvchain(&tlvlist);
493 return 1; /* major problem */
497 * First two bytes represent the status of the connection.
499 * 0 is a request, 2 is an accept
501 status = aimutil_get16(block1->value+0);
504 * Next comes the cookie. Should match the ICBM cookie.
506 if (memcmp(block1->value+2, cookie, 8) != 0)
507 printf("faim: rend: warning cookies don't match!\n");
510 * The next 16bytes are a capability block so we can
511 * identify what type of rendezvous this is.
513 * Thanks to Eric Warmenhoven <warmenhoven@linux.com> (of GAIM)
514 * for pointing some of this out to me. In fact, a lot of
515 * the client-to-client info comes from the work of the GAIM
516 * developers. Thanks!
518 * Read off one capability string and we should have it ID'd.
521 reqclass = aim_getcap(block1->value+2+8, 0x10);
522 if (reqclass == 0x0000) {
523 printf("faim: rend: no ID block\n");
524 aim_freetlvchain(&tlvlist);
529 * What follows may be TLVs or nothing, depending on the
530 * purpose of the message.
532 * Ack packets for instance have nothing more to them.
534 list2 = aim_readtlvchain(block1->value+2+8+16, block1->length-2-8-16);
536 if (!list2 || ((reqclass != AIM_CAPS_IMIMAGE) && !(aim_gettlv(list2, 0x2711, 1)))) {
537 struct aim_msgcookie_t *cook;
539 if ((cook = aim_uncachecookie(sess, cookie)) == NULL) {
540 printf("faim: non-data rendezvous thats not in cache!\n");
541 aim_freetlvchain(&list2);
542 aim_freetlvchain(&tlvlist);
546 if (cook->type == AIM_CAPS_SENDFILE) {
547 struct aim_filetransfer_t *ft;
550 struct aim_tlv_t *errortlv;
553 ft = (struct aim_filetransfer_t *)cook->data;
555 if ((errortlv = aim_gettlv(list2, 0x000b, 1))) {
556 errorcode = aimutil_get16(errortlv->value);
559 printf("faim: transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sender, ft->ip, ft->filename, errorcode);
560 } else if (status == 0x0002) { /* connection accepted */
561 printf("faim: transfer from %s (%s) for %s accepted\n", ft->sender, ft->ip, ft->filename);
565 printf("faim: not data attached to file transfer\n");
567 } else if (cook->type == AIM_CAPS_VOICE) {
568 printf("faim: voice request cancelled\n");
570 printf("faim: unknown cookie cache type %d\n", cook->type);
575 aim_freetlvchain(&list2);
576 aim_freetlvchain(&tlvlist);
581 * The rest of the handling depends on what type it is.
583 if (reqclass & AIM_CAPS_BUDDYICON) {
588 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
589 if (userfunc || (i = 0))
596 } else if (reqclass & AIM_CAPS_VOICE) {
597 struct aim_msgcookie_t cachedcook;
599 printf("faim: rend: voice!\n");
601 memcpy(cachedcook.cookie, cookie, 8);
602 cachedcook.type = AIM_CAPS_VOICE;
603 cachedcook.data = NULL;
604 if (aim_cachecookie(sess, &cachedcook) != 0)
605 printf("faim: ERROR caching message cookie\n");
607 /* XXX: implement all this */
612 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
613 if (userfunc || (i = 0)) {
620 } else if (reqclass & AIM_CAPS_IMIMAGE) {
622 struct aim_msgcookie_t cachedcook;
624 memset(ip, 0, sizeof(ip));
626 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) {
627 struct aim_tlv_t *iptlv, *porttlv;
629 iptlv = aim_gettlv(list2, 0x0003, 1);
630 porttlv = aim_gettlv(list2, 0x0005, 1);
632 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d",
633 aimutil_get8(iptlv->value+0),
634 aimutil_get8(iptlv->value+1),
635 aimutil_get8(iptlv->value+2),
636 aimutil_get8(iptlv->value+3),
637 4443 /*aimutil_get16(porttlv->value)*/);
640 printf("faim: rend: directIM request from %s (%s)\n",
646 struct aim_conn_t *newconn;
648 newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS, ip);
649 if (!newconn || (newconn->fd == -1)) {
650 printf("could not connect to %s\n", ip);
651 perror("aim_newconn");
652 aim_conn_kill(sess, &newconn);
654 struct aim_directim_priv *priv;
655 priv = (struct aim_directim_priv *)malloc(sizeof(struct aim_directim_priv));
656 memcpy(priv->cookie, cookie, 8);
657 strncpy(priv->sn, userinfo.sn, MAXSNLEN);
658 newconn->priv = priv;
659 printf("faim: connected to peer (fd = %d)\n", newconn->fd);
665 memcpy(cachedcook.cookie, cookie, 8);
667 ft = malloc(sizeof(struct aim_filetransfer_t));
668 strncpy(ft->sender, userinfo.sn, sizeof(ft->sender));
669 strncpy(ft->ip, ip, sizeof(ft->ip));
670 ft->filename = strdup(miscinfo->value+8);
671 cachedcook.type = AIM_CAPS_SENDFILE;
672 cachedcook.data = ft;
674 if (aim_cachecookie(sess, &cachedcook) != 0)
675 printf("faim: ERROR caching message cookie\n");
681 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
682 if (userfunc || (i = 0))
689 } else if (reqclass & AIM_CAPS_CHAT) {
690 struct aim_tlv_t *miscinfo;
691 struct aim_chat_roominfo roominfo;
692 char *msg=NULL,*encoding=NULL,*lang=NULL;
694 miscinfo = aim_gettlv(list2, 0x2711, 1);
695 aim_chat_readroominfo(miscinfo->value, &roominfo);
697 if (aim_gettlv(list2, 0x000c, 1))
698 msg = aim_gettlv_str(list2, 0x000c, 1);
700 if (aim_gettlv(list2, 0x000d, 1))
701 encoding = aim_gettlv_str(list2, 0x000d, 1);
703 if (aim_gettlv(list2, 0x000e, 1))
704 lang = aim_gettlv_str(list2, 0x000e, 1);
709 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
710 if (userfunc || (i = 0))
718 encoding?encoding+1:NULL,
724 } else if (reqclass & AIM_CAPS_GETFILE) {
729 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
730 if (userfunc || (i = 0))
737 } else if (reqclass & AIM_CAPS_SENDFILE) {
741 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
742 if (userfunc || (i = 0))
751 struct aim_msgcookie_t cachedcook;
752 struct aim_filetransfer_t *ft;
753 struct aim_tlv_t *miscinfo;
755 memset(ip, 0, sizeof(ip));
757 miscinfo = aim_gettlv(list2, 0x2711, 1);
759 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) {
760 struct aim_tlv_t *iptlv, *porttlv;
762 iptlv = aim_gettlv(list2, 0x0003, 1);
763 porttlv = aim_gettlv(list2, 0x0005, 1);
765 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d",
766 aimutil_get8(iptlv->value+0),
767 aimutil_get8(iptlv->value+1),
768 aimutil_get8(iptlv->value+2),
769 aimutil_get8(iptlv->value+3),
770 aimutil_get16(porttlv->value));
773 if (aim_gettlv(list2, 0x000c, 1)) {
774 desc = aim_gettlv_str(list2, 0x000c, 1);
777 printf("faim: rend: file transfer request from %s for %s: %s (%s)\n",
783 memcpy(cachedcook.cookie, cookie, 8);
785 ft = malloc(sizeof(struct aim_filetransfer_t));
786 strncpy(ft->sender, userinfo.sn, sizeof(ft->sender));
787 strncpy(ft->ip, ip, sizeof(ft->ip));
788 ft->filename = strdup(miscinfo->value+8);
789 cachedcook.type = AIM_CAPS_SENDFILE;
790 cachedcook.data = ft;
792 if (aim_cachecookie(sess, &cachedcook) != 0)
793 printf("faim: ERROR caching message cookie\n");
796 aim_accepttransfer(sess, command->conn, ft->sender, cookie, AIM_CAPS_SENDFILE);
802 printf("faim: rend: unknown rendezvous 0x%04x\n", reqclass);
805 aim_freetlvchain(&list2);
809 * Free up the TLV chain.
811 aim_freetlvchain(&tlvlist);
817 u_long aim_accepttransfer(struct aim_session_t *sess,
818 struct aim_conn_t *conn,
821 unsigned short rendid)
823 struct command_tx_struct *newpacket;
826 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+8+2+1+strlen(sender)+4+2+8+16)))
831 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0006, 0x0000, sess->snac_nextid);
832 for (i = 0; i < 8; i++)
833 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]);
834 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
835 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sender));
836 curbyte += aimutil_putstr(newpacket->data+curbyte, sender, strlen(sender));
837 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005);
838 curbyte += aimutil_put16(newpacket->data+curbyte, 0x001a);
839 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002 /* accept */);
840 for (i = 0; i < 8; i++)
841 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]);
842 curbyte += aim_putcap(newpacket->data+curbyte, 0x10, rendid);
845 aim_tx_enqueue(sess, newpacket);
847 return (sess->snac_nextid++);
852 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support"
853 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer"
854 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers"
857 u_long aim_denytransfer(struct aim_session_t *sess,
858 struct aim_conn_t *conn,
863 struct command_tx_struct *newpacket;
866 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+8+2+1+strlen(sender)+6)))
871 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x000b, 0x0000, sess->snac_nextid);
872 for (i = 0; i < 8; i++)
873 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]);
874 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
875 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sender));
876 curbyte += aimutil_putstr(newpacket->data+curbyte, sender, strlen(sender));
877 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0003, code);
880 aim_tx_enqueue(sess, newpacket);
882 return (sess->snac_nextid++);
886 * Not real sure what this does, nor does anyone I've talk to.
888 * Didn't use to send it. But now I think it might be a good
892 u_long aim_seticbmparam(struct aim_session_t *sess,
893 struct aim_conn_t *conn)
895 struct command_tx_struct *newpacket;
898 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+16)))
903 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid);
904 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
905 curbyte += aimutil_put32(newpacket->data+curbyte, 0x00000003);
906 curbyte += aimutil_put8(newpacket->data+curbyte, 0x1f);
907 curbyte += aimutil_put8(newpacket->data+curbyte, 0x40);
908 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03);
909 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7);
910 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03);
911 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7);
912 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
913 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
916 aim_tx_enqueue(sess, newpacket);
918 return (sess->snac_nextid++);
921 int aim_parse_msgerror_middle(struct aim_session_t *sess,
922 struct command_rx_struct *command)
924 u_long snacid = 0x000000000;
925 struct aim_snac_t *snac = NULL;
927 rxcallback_t userfunc = NULL;
930 * Get SNAC from packet and look it up
931 * the list of unrepliedto/outstanding
934 * After its looked up, the SN that the
935 * message should've gone to will be
936 * in the ->data element of the snac struct.
939 snacid = aimutil_get32(command->data+6);
940 snac = aim_remsnac(sess, snacid);
943 printf("faim: msgerr: got an ICBM-failed error on an unknown SNAC ID! (%08lx)\n", snacid);
949 userfunc = aim_callhandler(command->conn, 0x0004, 0x0001);
951 ret = userfunc(sess, command, (snac)?snac->data:"(UNKNOWN)");