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) + 0x0d);
72 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0501);
73 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
74 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0101);
75 curbyte += aimutil_put8 (newpacket->data+curbyte, 0x01);
78 * Message block length.
80 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x04);
85 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
86 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
89 * Message. Not terminated.
91 curbyte += aimutil_putstr(newpacket->data+curbyte,msg, strlen(msg));
94 * Set the Request Acknowledge flag.
96 if (flags & AIM_IMFLAGS_ACK) {
97 curbyte += aimutil_put16(newpacket->data+curbyte,0x0003);
98 curbyte += aimutil_put16(newpacket->data+curbyte,0x0000);
102 * Set the Autoresponse flag.
104 if (flags & AIM_IMFLAGS_AWAY) {
105 curbyte += aimutil_put16(newpacket->data+curbyte,0x0004);
106 curbyte += aimutil_put16(newpacket->data+curbyte,0x0000);
109 newpacket->commandlen = curbyte;
112 aim_tx_enqueue(sess, newpacket);
114 #ifdef USE_SNAC_FOR_IMS
116 struct aim_snac_t snac;
118 snac.id = sess->snac_nextid;
119 snac.family = 0x0004;
123 snac.data = malloc(strlen(destsn)+1);
124 memcpy(snac.data, destsn, strlen(destsn)+1);
126 aim_newsnac(sess, &snac);
129 aim_cleansnacs(sess, 60); /* clean out all SNACs over 60sec old */
132 return (sess->snac_nextid++);
135 struct aim_directim_priv {
136 unsigned char cookie[8];
140 int aim_send_im_direct(struct aim_session_t *sess,
141 struct aim_conn_t *conn,
144 struct command_tx_struct *newpacket;
145 struct aim_directim_priv *priv = NULL;
148 if (strlen(msg) >= MAXMSGLEN)
151 if (!sess || !conn || (conn->type != AIM_CONN_TYPE_RENDEZVOUS) || !conn->priv) {
152 printf("faim: directim: invalid arguments\n");
156 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OFT, 0x0001, conn, strlen(msg)))) {
157 printf("faim: directim: tx_new failed\n");
161 newpacket->lock = 1; /* lock struct */
163 priv = (struct aim_directim_priv *)conn->priv;
165 newpacket->hdr.oft.hdr2len = 0x44;
167 if (!(newpacket->hdr.oft.hdr2 = malloc(newpacket->hdr.oft.hdr2len))) {
173 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0006);
174 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
176 i += aimutil_putstr(newpacket->hdr.oft.hdr2+i, priv->cookie, 8);
178 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
179 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
180 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
181 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
183 i += aimutil_put32(newpacket->hdr.oft.hdr2+i, strlen(msg));
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);
189 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
190 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
192 i += aimutil_putstr(newpacket->hdr.oft.hdr2+i, sess->logininfo.screen_name, strlen(sess->logininfo.screen_name));
195 i += aimutil_put8(newpacket->hdr.oft.hdr2+i, 0x00);
196 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
197 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
198 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
199 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
200 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
201 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
202 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000);
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);
208 memcpy(newpacket->data, msg, strlen(msg));
212 aim_tx_enqueue(sess, newpacket);
218 * It can easily be said that parsing ICBMs is THE single
219 * most difficult thing to do in the in AIM protocol. In
220 * fact, I think I just did say that.
222 * Below is the best damned solution I've come up with
223 * over the past sixteen months of battling with it. This
224 * can parse both away and normal messages from every client
225 * I have access to. Its not fast, its not clean. But it works.
227 * We should also support at least minimal parsing of
228 * Channel 2, so that we can at least know the name of the
229 * room we're invited to, but obviously can't attend...
232 int aim_parse_incoming_im_middle(struct aim_session_t *sess,
233 struct command_rx_struct *command)
236 rxcallback_t userfunc = NULL;
239 struct aim_tlvlist_t *tlvlist;
240 struct aim_userinfo_s userinfo;
243 memset(&userinfo, 0x00, sizeof(struct aim_userinfo_s));
245 i = 10; /* Skip SNAC header */
248 * Read ICBM Cookie. And throw away.
250 for (z=0; z<8; z++,i++)
251 cookie[z] = command->data[i];
256 * Channel 0x0001 is the message channel. There are
257 * other channels for things called "rendevous"
258 * which represent chat and some of the other new
259 * features of AIM2/3/3.5.
261 * Channel 0x0002 is the Rendevous channel, which
262 * is where Chat Invitiations and various client-client
263 * connection negotiations come from.
266 channel = aimutil_get16(command->data+i);
272 if ((channel != 0x01) && (channel != 0x02))
274 printf("faim: icbm: ICBM received on an unsupported channel. Ignoring.\n (chan = %04x)", channel);
279 * Extract the standard user info block.
281 * Note that although this contains TLVs that appear contiguous
282 * with the TLVs read below, they are two different pieces. The
283 * userinfo block contains the number of TLVs that contain user
284 * information, the rest are not even though there is no seperation.
285 * aim_extractuserinfo() returns the number of bytes used by the
286 * userinfo tlvs, so you can start reading the rest of them right
289 * That also means that TLV types can be duplicated between the
290 * userinfo block and the rest of the message, however there should
291 * never be two TLVs of the same type in one block.
294 i += aim_extractuserinfo(command->data+i, &userinfo);
297 * Read block of TLVs (not including the userinfo data). All
298 * further data is derived from what is parsed here.
300 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
303 * From here on, its depends on what channel we're on.
307 u_int j = 0, y = 0, z = 0;
310 struct aim_tlv_t *msgblocktlv, *tmptlv;
315 * Check Autoresponse status. If it is an autoresponse,
316 * it will contain a type 0x0004 TLV, with zero length.
318 if (aim_gettlv(tlvlist, 0x0004, 1))
319 icbmflags |= AIM_IMFLAGS_AWAY;
322 * Check Ack Request status.
324 if (aim_gettlv(tlvlist, 0x0003, 1))
325 icbmflags |= AIM_IMFLAGS_ACK;
330 msgblocktlv = aim_gettlv(tlvlist, 0x0002, 1);
331 if (!msgblocktlv || !msgblocktlv->value) {
332 printf("faim: icbm: major error! no message block TLV found!\n");
333 aim_freetlvchain(&tlvlist);
338 * Extracting the message from the unknown cruft.
340 * This is a bit messy, and I'm not really qualified,
341 * even as the author, to comment on it. At least
342 * its not as bad as a while loop shooting into infinity.
344 * "Do you believe in magic?"
347 msgblock = msgblocktlv->value;
350 wastebits = aimutil_get8(msgblock+j++);
351 wastebits = aimutil_get8(msgblock+j++);
353 y = aimutil_get16(msgblock+j);
355 for (z = 0; z < y; z++)
356 wastebits = aimutil_get8(msgblock+j++);
357 wastebits = aimutil_get8(msgblock+j++);
358 wastebits = aimutil_get8(msgblock+j++);
361 * Message string length, including flag words.
363 i = aimutil_get16(msgblock+j);
369 * Its rumored that these can kick in some funky
370 * 16bit-wide char stuff that used to really kill
371 * libfaim. Hopefully the latter is no longer true.
373 * Though someone should investiagte the former.
376 flag1 = aimutil_get16(msgblock+j);
378 flag2 = aimutil_get16(msgblock+j);
382 printf("faim: icbm: **warning: encoding flags are being used! {%04x, %04x}\n", flag1, flag2);
388 msg = (char *)malloc(i+1);
389 memcpy(msg, msgblock+j, i);
395 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
397 i = userfunc(sess, command, channel, &userinfo, msg, icbmflags, flag1, flag2);
403 else if (channel == 0x0002)
405 struct aim_tlv_t *block1;
406 struct aim_tlvlist_t *list2;
407 struct aim_tlv_t *tmptlv;
408 unsigned short reqclass = 0;
409 unsigned short status = 0;
412 * There's another block of TLVs embedded in the type 5 here.
414 block1 = aim_gettlv(tlvlist, 0x0005, 1);
416 printf("faim: no tlv 0x0005 in rendezvous transaction!\n");
417 aim_freetlvchain(&tlvlist);
418 return 1; /* major problem */
422 * First two bytes represent the status of the connection.
424 * 0 is a request, 2 is an accept
426 status = aimutil_get16(block1->value+0);
429 * Next comes the cookie. Should match the ICBM cookie.
431 if (memcmp(block1->value+2, cookie, 8) != 0)
432 printf("faim: rend: warning cookies don't match!\n");
435 * The next 16bytes are a capability block so we can
436 * identify what type of rendezvous this is.
438 * Thanks to Eric Warmenhoven <warmenhoven@linux.com> (of GAIM)
439 * for pointing some of this out to me. In fact, a lot of
440 * the client-to-client info comes from the work of the GAIM
441 * developers. Thanks!
443 * Read off one capability string and we should have it ID'd.
446 reqclass = aim_getcap(block1->value+2+8, 0x10);
447 if (reqclass == 0x0000) {
448 printf("faim: rend: no ID block\n");
449 aim_freetlvchain(&tlvlist);
454 * What follows may be TLVs or nothing, depending on the
455 * purpose of the message.
457 * Ack packets for instance have nothing more to them.
459 list2 = aim_readtlvchain(block1->value+2+8+16, block1->length-2-8-16);
461 if (!list2 || ((reqclass != AIM_CAPS_IMIMAGE) && !(aim_gettlv(list2, 0x2711, 1)))) {
462 struct aim_msgcookie_t *cook;
464 if ((cook = aim_uncachecookie(sess, cookie)) == NULL) {
465 printf("faim: non-data rendezvous thats not in cache!\n");
466 aim_freetlvchain(&list2);
467 aim_freetlvchain(&tlvlist);
471 if (cook->type == AIM_CAPS_SENDFILE) {
472 struct aim_filetransfer_t *ft;
475 struct aim_tlv_t *errortlv;
478 ft = (struct aim_filetransfer_t *)cook->data;
480 if ((errortlv = aim_gettlv(list2, 0x000b, 1))) {
481 errorcode = aimutil_get16(errortlv->value);
484 printf("faim: transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sender, ft->ip, ft->filename, errorcode);
485 } else if (status == 0x0002) { /* connection accepted */
486 printf("faim: transfer from %s (%s) for %s accepted\n", ft->sender, ft->ip, ft->filename);
490 printf("faim: not data attached to file transfer\n");
492 } else if (cook->type == AIM_CAPS_VOICE) {
493 printf("faim: voice request cancelled\n");
495 printf("faim: unknown cookie cache type %d\n", cook->type);
500 aim_freetlvchain(&list2);
501 aim_freetlvchain(&tlvlist);
506 * The rest of the handling depends on what type it is.
508 if (reqclass & AIM_CAPS_BUDDYICON) {
513 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
514 if (userfunc || (i = 0))
521 } else if (reqclass & AIM_CAPS_VOICE) {
522 struct aim_msgcookie_t cachedcook;
524 printf("faim: rend: voice!\n");
526 memcpy(cachedcook.cookie, cookie, 8);
527 cachedcook.type = AIM_CAPS_VOICE;
528 cachedcook.data = NULL;
529 if (aim_cachecookie(sess, &cachedcook) != 0)
530 printf("faim: ERROR caching message cookie\n");
532 /* XXX: implement all this */
537 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
538 if (userfunc || (i = 0)) {
545 } else if (reqclass & AIM_CAPS_IMIMAGE) {
547 struct aim_msgcookie_t cachedcook;
549 memset(ip, 0, sizeof(ip));
551 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) {
552 struct aim_tlv_t *iptlv, *porttlv;
554 iptlv = aim_gettlv(list2, 0x0003, 1);
555 porttlv = aim_gettlv(list2, 0x0005, 1);
557 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d",
558 aimutil_get8(iptlv->value+0),
559 aimutil_get8(iptlv->value+1),
560 aimutil_get8(iptlv->value+2),
561 aimutil_get8(iptlv->value+3),
562 4443 /*aimutil_get16(porttlv->value)*/);
565 printf("faim: rend: directIM request from %s (%s)\n",
571 struct aim_conn_t *newconn;
573 newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS, ip);
574 if (!newconn || (newconn->fd == -1)) {
575 printf("could not connect to %s\n", ip);
576 perror("aim_newconn");
577 aim_conn_kill(sess, &newconn);
579 struct aim_directim_priv *priv;
580 priv = (struct aim_directim_priv *)malloc(sizeof(struct aim_directim_priv));
581 memcpy(priv->cookie, cookie, 8);
582 strncpy(priv->sn, userinfo.sn, MAXSNLEN);
583 newconn->priv = priv;
584 printf("faim: connected to peer (fd = %d)\n", newconn->fd);
590 memcpy(cachedcook.cookie, cookie, 8);
592 ft = malloc(sizeof(struct aim_filetransfer_t));
593 strncpy(ft->sender, userinfo.sn, sizeof(ft->sender));
594 strncpy(ft->ip, ip, sizeof(ft->ip));
595 ft->filename = strdup(miscinfo->value+8);
596 cachedcook.type = AIM_CAPS_SENDFILE;
597 cachedcook.data = ft;
599 if (aim_cachecookie(sess, &cachedcook) != 0)
600 printf("faim: ERROR caching message cookie\n");
606 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
607 if (userfunc || (i = 0))
614 } else if (reqclass & AIM_CAPS_CHAT) {
615 struct aim_tlv_t *miscinfo;
616 struct aim_chat_roominfo roominfo;
617 char *msg=NULL,*encoding=NULL,*lang=NULL;
619 miscinfo = aim_gettlv(list2, 0x2711, 1);
620 aim_chat_readroominfo(miscinfo->value, &roominfo);
622 if (aim_gettlv(list2, 0x000c, 1))
623 msg = aim_gettlv_str(list2, 0x000c, 1);
625 if (aim_gettlv(list2, 0x000d, 1))
626 encoding = aim_gettlv_str(list2, 0x000d, 1);
628 if (aim_gettlv(list2, 0x000e, 1))
629 lang = aim_gettlv_str(list2, 0x000e, 1);
634 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
635 if (userfunc || (i = 0))
643 encoding?encoding+1:NULL,
649 } else if (reqclass & AIM_CAPS_GETFILE) {
654 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
655 if (userfunc || (i = 0))
662 } else if (reqclass & AIM_CAPS_SENDFILE) {
666 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
667 if (userfunc || (i = 0))
676 struct aim_msgcookie_t cachedcook;
677 struct aim_filetransfer_t *ft;
678 struct aim_tlv_t *miscinfo;
680 memset(ip, 0, sizeof(ip));
682 miscinfo = aim_gettlv(list2, 0x2711, 1);
684 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) {
685 struct aim_tlv_t *iptlv, *porttlv;
687 iptlv = aim_gettlv(list2, 0x0003, 1);
688 porttlv = aim_gettlv(list2, 0x0005, 1);
690 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d",
691 aimutil_get8(iptlv->value+0),
692 aimutil_get8(iptlv->value+1),
693 aimutil_get8(iptlv->value+2),
694 aimutil_get8(iptlv->value+3),
695 aimutil_get16(porttlv->value));
698 if (aim_gettlv(list2, 0x000c, 1)) {
699 desc = aim_gettlv_str(list2, 0x000c, 1);
702 printf("faim: rend: file transfer request from %s for %s: %s (%s)\n",
708 memcpy(cachedcook.cookie, cookie, 8);
710 ft = malloc(sizeof(struct aim_filetransfer_t));
711 strncpy(ft->sender, userinfo.sn, sizeof(ft->sender));
712 strncpy(ft->ip, ip, sizeof(ft->ip));
713 ft->filename = strdup(miscinfo->value+8);
714 cachedcook.type = AIM_CAPS_SENDFILE;
715 cachedcook.data = ft;
717 if (aim_cachecookie(sess, &cachedcook) != 0)
718 printf("faim: ERROR caching message cookie\n");
721 aim_accepttransfer(sess, command->conn, ft->sender, cookie, AIM_CAPS_SENDFILE);
727 printf("faim: rend: unknown rendezvous 0x%04x\n", reqclass);
730 aim_freetlvchain(&list2);
734 * Free up the TLV chain.
736 aim_freetlvchain(&tlvlist);
742 u_long aim_accepttransfer(struct aim_session_t *sess,
743 struct aim_conn_t *conn,
746 unsigned short rendid)
748 struct command_tx_struct *newpacket;
751 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+8+2+1+strlen(sender)+4+2+8+16)))
756 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0006, 0x0000, sess->snac_nextid);
757 for (i = 0; i < 8; i++)
758 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]);
759 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
760 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sender));
761 curbyte += aimutil_putstr(newpacket->data+curbyte, sender, strlen(sender));
762 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005);
763 curbyte += aimutil_put16(newpacket->data+curbyte, 0x001a);
764 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002 /* accept */);
765 for (i = 0; i < 8; i++)
766 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]);
767 curbyte += aim_putcap(newpacket->data+curbyte, 0x10, rendid);
770 aim_tx_enqueue(sess, newpacket);
772 return (sess->snac_nextid++);
777 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support"
778 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer"
779 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers"
782 u_long aim_denytransfer(struct aim_session_t *sess,
783 struct aim_conn_t *conn,
788 struct command_tx_struct *newpacket;
791 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+8+2+1+strlen(sender)+6)))
796 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x000b, 0x0000, sess->snac_nextid);
797 for (i = 0; i < 8; i++)
798 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]);
799 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
800 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sender));
801 curbyte += aimutil_putstr(newpacket->data+curbyte, sender, strlen(sender));
802 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0003, code);
805 aim_tx_enqueue(sess, newpacket);
807 return (sess->snac_nextid++);
811 * Not real sure what this does, nor does anyone I've talk to.
813 * Didn't use to send it. But now I think it might be a good
817 u_long aim_seticbmparam(struct aim_session_t *sess,
818 struct aim_conn_t *conn)
820 struct command_tx_struct *newpacket;
823 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+16)))
828 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid);
829 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
830 curbyte += aimutil_put32(newpacket->data+curbyte, 0x00000003);
831 curbyte += aimutil_put8(newpacket->data+curbyte, 0x1f);
832 curbyte += aimutil_put8(newpacket->data+curbyte, 0x40);
833 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03);
834 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7);
835 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03);
836 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7);
837 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
838 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
841 aim_tx_enqueue(sess, newpacket);
843 return (sess->snac_nextid++);
846 int aim_parse_msgerror_middle(struct aim_session_t *sess,
847 struct command_rx_struct *command)
849 u_long snacid = 0x000000000;
850 struct aim_snac_t *snac = NULL;
852 rxcallback_t userfunc = NULL;
855 * Get SNAC from packet and look it up
856 * the list of unrepliedto/outstanding
859 * After its looked up, the SN that the
860 * message should've gone to will be
861 * in the ->data element of the snac struct.
864 snacid = aimutil_get32(command->data+6);
865 snac = aim_remsnac(sess, snacid);
868 printf("faim: msgerr: got an ICBM-failed error on an unknown SNAC ID! (%08lx)\n", snacid);
874 userfunc = aim_callhandler(command->conn, 0x0004, 0x0001);
876 ret = userfunc(sess, command, (snac)?snac->data:"(UNKNOWN)");