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 faim_export unsigned 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) rand());
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 faim_internal int aim_parse_outgoing_im_middle(struct aim_session_t *sess,
143 struct command_rx_struct *command)
145 unsigned int i = 0, z;
146 rxcallback_t userfunc = NULL;
147 unsigned char cookie[8];
149 struct aim_tlvlist_t *tlvlist;
151 unsigned short icbmflags = 0;
152 unsigned char flag1 = 0, flag2 = 0;
153 unsigned char *msgblock = NULL, *msg = NULL;
158 for (z=0; z<8; z++,i++)
159 cookie[z] = command->data[i];
162 channel = aimutil_get16(command->data+i);
165 if (channel != 0x01) {
166 printf("faim: icbm: ICBM recieved on unsupported channel. Ignoring. (chan = %04x)\n", channel);
170 strncpy(sn, (char *) command->data+i+1, (int) *(command->data+i));
171 i += 1 + (int) *(command->data+i);
173 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
175 if (aim_gettlv(tlvlist, 0x0003, 1))
176 icbmflags |= AIM_IMFLAGS_ACK;
177 if (aim_gettlv(tlvlist, 0x0004, 1))
178 icbmflags |= AIM_IMFLAGS_AWAY;
180 if (aim_gettlv(tlvlist, 0x0002, 1)) {
183 msgblock = (unsigned char *)aim_gettlv_str(tlvlist, 0x0002, 1);
185 /* no, this really is correct. I'm not high or anything either. */
187 j += 2 + aimutil_get16(msgblock+j);
190 j += 2; /* final block length */
192 flag1 = aimutil_get16(msgblock);
194 flag2 = aimutil_get16(msgblock);
200 if ((userfunc = aim_callhandler(command->conn, 0x0004, 0x0006)) || (i = 0))
201 i = userfunc(sess, command, channel, sn, msg, icbmflags, flag1, flag2);
205 aim_freetlvchain(&tlvlist);
211 * It can easily be said that parsing ICBMs is THE single
212 * most difficult thing to do in the in AIM protocol. In
213 * fact, I think I just did say that.
215 * Below is the best damned solution I've come up with
216 * over the past sixteen months of battling with it. This
217 * can parse both away and normal messages from every client
218 * I have access to. Its not fast, its not clean. But it works.
220 * We should also support at least minimal parsing of
221 * Channel 2, so that we can at least know the name of the
222 * room we're invited to, but obviously can't attend...
225 faim_internal int aim_parse_incoming_im_middle(struct aim_session_t *sess,
226 struct command_rx_struct *command)
229 rxcallback_t userfunc = NULL;
232 struct aim_tlvlist_t *tlvlist;
233 struct aim_userinfo_s userinfo;
236 memset(&userinfo, 0x00, sizeof(struct aim_userinfo_s));
238 i = 10; /* Skip SNAC header */
241 * Read ICBM Cookie. And throw away.
243 for (z=0; z<8; z++,i++)
244 cookie[z] = command->data[i];
249 * Channel 0x0001 is the message channel. There are
250 * other channels for things called "rendevous"
251 * which represent chat and some of the other new
252 * features of AIM2/3/3.5.
254 * Channel 0x0002 is the Rendevous channel, which
255 * is where Chat Invitiations and various client-client
256 * connection negotiations come from.
259 channel = aimutil_get16(command->data+i);
265 if ((channel != 0x01) && (channel != 0x02))
267 printf("faim: icbm: ICBM received on an unsupported channel. Ignoring.\n (chan = %04x)", channel);
272 * Extract the standard user info block.
274 * Note that although this contains TLVs that appear contiguous
275 * with the TLVs read below, they are two different pieces. The
276 * userinfo block contains the number of TLVs that contain user
277 * information, the rest are not even though there is no seperation.
278 * aim_extractuserinfo() returns the number of bytes used by the
279 * userinfo tlvs, so you can start reading the rest of them right
282 * That also means that TLV types can be duplicated between the
283 * userinfo block and the rest of the message, however there should
284 * never be two TLVs of the same type in one block.
287 i += aim_extractuserinfo(command->data+i, &userinfo);
290 * Read block of TLVs (not including the userinfo data). All
291 * further data is derived from what is parsed here.
293 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
296 * From here on, its depends on what channel we're on.
300 u_int j = 0, y = 0, z = 0;
303 struct aim_tlv_t *msgblocktlv;
308 * Check Autoresponse status. If it is an autoresponse,
309 * it will contain a type 0x0004 TLV, with zero length.
311 if (aim_gettlv(tlvlist, 0x0004, 1))
312 icbmflags |= AIM_IMFLAGS_AWAY;
315 * Check Ack Request status.
317 if (aim_gettlv(tlvlist, 0x0003, 1))
318 icbmflags |= AIM_IMFLAGS_ACK;
323 msgblocktlv = aim_gettlv(tlvlist, 0x0002, 1);
324 if (!msgblocktlv || !msgblocktlv->value) {
325 printf("faim: icbm: major error! no message block TLV found!\n");
326 aim_freetlvchain(&tlvlist);
331 * Extracting the message from the unknown cruft.
333 * This is a bit messy, and I'm not really qualified,
334 * even as the author, to comment on it. At least
335 * its not as bad as a while loop shooting into infinity.
337 * "Do you believe in magic?"
340 msgblock = msgblocktlv->value;
343 wastebits = aimutil_get8(msgblock+j++);
344 wastebits = aimutil_get8(msgblock+j++);
346 y = aimutil_get16(msgblock+j);
348 for (z = 0; z < y; z++)
349 wastebits = aimutil_get8(msgblock+j++);
350 wastebits = aimutil_get8(msgblock+j++);
351 wastebits = aimutil_get8(msgblock+j++);
354 * Message string length, including flag words.
356 i = aimutil_get16(msgblock+j);
362 * Its rumored that these can kick in some funky
363 * 16bit-wide char stuff that used to really kill
364 * libfaim. Hopefully the latter is no longer true.
366 * Though someone should investiagte the former.
369 flag1 = aimutil_get16(msgblock+j);
371 flag2 = aimutil_get16(msgblock+j);
375 printf("faim: icbm: **warning: encoding flags are being used! {%04x, %04x}\n", flag1, flag2);
381 msg = (char *)malloc(i+1);
382 memcpy(msg, msgblock+j, i);
388 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
390 i = userfunc(sess, command, channel, &userinfo, msg, icbmflags, flag1, flag2);
396 else if (channel == 0x0002)
398 struct aim_tlv_t *block1;
399 struct aim_tlvlist_t *list2;
400 struct aim_tlv_t *tmptlv;
401 unsigned short reqclass = 0;
402 unsigned short status = 0;
405 * There's another block of TLVs embedded in the type 5 here.
407 block1 = aim_gettlv(tlvlist, 0x0005, 1);
409 printf("faim: no tlv 0x0005 in rendezvous transaction!\n");
410 aim_freetlvchain(&tlvlist);
411 return 1; /* major problem */
415 * First two bytes represent the status of the connection.
417 * 0 is a request, 2 is an accept
419 status = aimutil_get16(block1->value+0);
422 * Next comes the cookie. Should match the ICBM cookie.
424 if (memcmp(block1->value+2, cookie, 8) != 0)
425 printf("faim: rend: warning cookies don't match!\n");
428 * The next 16bytes are a capability block so we can
429 * identify what type of rendezvous this is.
431 * Thanks to Eric Warmenhoven <warmenhoven@linux.com> (of GAIM)
432 * for pointing some of this out to me. In fact, a lot of
433 * the client-to-client info comes from the work of the GAIM
434 * developers. Thanks!
436 * Read off one capability string and we should have it ID'd.
439 reqclass = aim_getcap(block1->value+2+8, 0x10);
440 if (reqclass == 0x0000) {
441 printf("faim: rend: no ID block\n");
442 aim_freetlvchain(&tlvlist);
447 * What follows may be TLVs or nothing, depending on the
448 * purpose of the message.
450 * Ack packets for instance have nothing more to them.
452 list2 = aim_readtlvchain(block1->value+2+8+16, block1->length-2-8-16);
454 if (!list2 || ((reqclass != AIM_CAPS_IMIMAGE) && !(aim_gettlv(list2, 0x2711, 1)))) {
455 struct aim_msgcookie_t *cook;
458 type = aim_msgcookie_gettype(reqclass); /* XXX: fix this shitty code */
460 if ((cook = aim_uncachecookie(sess, cookie, type)) == NULL) {
461 printf("faim: non-data rendezvous thats not in cache!\n");
462 aim_freetlvchain(&list2);
463 aim_freetlvchain(&tlvlist);
467 if (cook->type == AIM_CAPS_SENDFILE) {
468 struct aim_filetransfer_priv *ft;
471 struct aim_tlv_t *errortlv;
474 ft = (struct aim_filetransfer_priv *)cook->data;
476 if ((errortlv = aim_gettlv(list2, 0x000b, 1))) {
477 errorcode = aimutil_get16(errortlv->value);
480 printf("faim: transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sn, ft->ip, ft->fh.name, errorcode);
481 } else if (status == 0x0002) { /* connection accepted */
482 printf("faim: transfer from %s (%s) for %s accepted\n", ft->sn, ft->ip, ft->fh.name);
486 printf("faim: not data attached to file transfer\n");
488 } else if (cook->type == AIM_CAPS_VOICE) {
489 printf("faim: voice request cancelled\n");
491 printf("faim: unknown cookie cache type %d\n", cook->type);
496 aim_freetlvchain(&list2);
497 aim_freetlvchain(&tlvlist);
502 * The rest of the handling depends on what type it is.
504 if (reqclass & AIM_CAPS_BUDDYICON) {
509 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
510 if (userfunc || (i = 0))
517 } else if (reqclass & AIM_CAPS_VOICE) {
518 struct aim_msgcookie_t *cachedcook;
520 printf("faim: rend: voice!\n");
522 if(!(cachedcook = (struct aim_msgcookie_t*)calloc(1, sizeof(struct aim_msgcookie_t))))
525 memcpy(cachedcook->cookie, cookie, 8);
526 cachedcook->type = AIM_COOKIETYPE_OFTVOICE;
527 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)) {
539 i = userfunc(sess, command, channel, reqclass, &userinfo);
541 } else if ((reqclass & AIM_CAPS_IMIMAGE) || (reqclass & AIM_CAPS_BUDDYICON)) {
543 struct aim_directim_priv *priv;
545 memset(ip, 0, sizeof(ip));
547 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0005, 1)) {
548 struct aim_tlv_t *iptlv, *porttlv;
550 iptlv = aim_gettlv(list2, 0x0003, 1);
551 porttlv = aim_gettlv(list2, 0x0005, 1);
553 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d",
554 aimutil_get8(iptlv->value+0),
555 aimutil_get8(iptlv->value+1),
556 aimutil_get8(iptlv->value+2),
557 aimutil_get8(iptlv->value+3),
558 4443 /*aimutil_get16(porttlv->value)*/);
561 printf("faim: rend: directIM request from %s (%s)\n",
565 /* XXX: there are a couple of different request packets for
566 * different things */
568 priv = (struct aim_directim_priv *)calloc(1, sizeof(struct aim_directim_priv));
569 memcpy(priv->ip, ip, sizeof(priv->ip));
570 memcpy(priv->sn, userinfo.sn, sizeof(priv->sn));
571 memcpy(priv->cookie, cookie, sizeof(priv->cookie));
576 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
577 if (userfunc || (i = 0))
584 } else if (reqclass & AIM_CAPS_CHAT) {
585 struct aim_tlv_t *miscinfo;
586 struct aim_chat_roominfo roominfo;
587 char *msg=NULL,*encoding=NULL,*lang=NULL;
589 miscinfo = aim_gettlv(list2, 0x2711, 1);
590 aim_chat_readroominfo(miscinfo->value, &roominfo);
592 if (aim_gettlv(list2, 0x000c, 1))
593 msg = aim_gettlv_str(list2, 0x000c, 1);
595 if (aim_gettlv(list2, 0x000d, 1))
596 encoding = aim_gettlv_str(list2, 0x000d, 1);
598 if (aim_gettlv(list2, 0x000e, 1))
599 lang = aim_gettlv_str(list2, 0x000e, 1);
604 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
605 if (userfunc || (i = 0))
613 encoding?encoding+1:NULL,
619 } else if (reqclass & AIM_CAPS_GETFILE) {
622 struct aim_msgcookie_t *cachedcook;
623 struct aim_filetransfer_priv *ft;
624 struct aim_tlv_t *miscinfo;
625 struct aim_conn_t *newconn;
627 if (!(cachedcook = calloc(1, sizeof(struct aim_msgcookie_t))))
630 memset(ip, 0, sizeof(ip));
632 if (!(miscinfo = aim_gettlv(list2, 0x2711, 1))) {
637 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0005, 1)) {
638 struct aim_tlv_t *iptlv, *porttlv;
640 if (!(iptlv = aim_gettlv(list2, 0x0003, 1)) || !(porttlv = aim_gettlv(list2, 0x0005, 1))) {
645 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d",
646 aimutil_get8(iptlv->value+0),
647 aimutil_get8(iptlv->value+1),
648 aimutil_get8(iptlv->value+2),
649 aimutil_get8(iptlv->value+3),
650 aimutil_get16(porttlv->value));
653 printf("faim: rend: file get request from %s (%s)\n", userinfo.sn, ip);
655 #if 0 /* XXX finish this */
656 newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS, ip);
657 if (!newconn || (newconn->fd == -1)) {
658 printf("could not connect to %s\n", ip);
659 perror("aim_newconn");
660 aim_conn_kill(sess, &newconn);
662 struct aim_filetransfer_priv *priv;
663 priv = (struct aim_filetransfer_priv *)calloc(1, sizeof(struct aim_filetransfer_priv));
664 memcpy(priv->cookie, cookie, 8);
665 strncpy(priv->sn, userinfo.sn, MAXSNLEN);
666 newconn->priv = priv;
667 printf("faim: connected to peer (fd = %d)\n", newconn->fd);
670 memcpy(cachedcook->cookie, cookie, 8);
672 ft = malloc(sizeof(struct aim_filetransfer_priv));
674 strncpy(ft->sn, userinfo.sn, sizeof(ft->sn));
675 strncpy(ft->ip, ip, sizeof(ft->ip));
677 strncpy(ft->fh.name, miscinfo->value+8, sizeof(ft->fh.name));
679 cachedcook->type = AIM_COOKIETYPE_OFTGET;
680 cachedcook->data = ft;
682 if (aim_cachecookie(sess, cachedcook) != 0)
683 printf("faim: ERROR caching message cookie\n");
685 aim_accepttransfer(sess, command->conn, newconn, ft->sn, cookie, AIM_CAPS_GETFILE);
692 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
693 if (userfunc || (i = 0))
700 } else if (reqclass & AIM_CAPS_SENDFILE) {
704 struct aim_msgcookie_t *cachedcook;
705 struct aim_filetransfer_priv *ft;
706 struct aim_tlv_t *miscinfo;
708 memset(ip, 0, sizeof(ip));
710 if (!(miscinfo = aim_gettlv(list2, 0x2711, 1)))
713 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) {
714 struct aim_tlv_t *iptlv, *porttlv;
716 iptlv = aim_gettlv(list2, 0x0003, 1);
717 porttlv = aim_gettlv(list2, 0x0005, 1);
719 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d",
720 aimutil_get8(iptlv->value+0),
721 aimutil_get8(iptlv->value+1),
722 aimutil_get8(iptlv->value+2),
723 aimutil_get8(iptlv->value+3),
724 aimutil_get16(porttlv->value));
727 if (aim_gettlv(list2, 0x000c, 1)) {
728 desc = aim_gettlv_str(list2, 0x000c, 1);
731 printf("faim: rend: file transfer request from %s for %s: %s (%s)\n",
737 memcpy(cachedcook->cookie, cookie, 8);
739 ft = malloc(sizeof(struct aim_filetransfer_priv));
740 strncpy(ft->sn, userinfo.sn, sizeof(ft->sn));
741 strncpy(ft->ip, ip, sizeof(ft->ip));
742 strncpy(ft->fh.name, miscinfo->value+8, sizeof(ft->fh.name));
743 cachedcook->type = AIM_COOKIETYPE_OFTSEND;
744 cachedcook->data = ft;
746 if (aim_cachecookie(sess, cachedcook) != 0)
747 printf("faim: ERROR caching message cookie\n");
750 aim_accepttransfer(sess, command->conn, ft->sn, cookie, AIM_CAPS_SENDFILE);
758 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
759 if (userfunc || (i = 0))
766 printf("faim: rend: unknown rendezvous 0x%04x\n", reqclass);
769 aim_freetlvchain(&list2);
773 * Free up the TLV chain.
775 aim_freetlvchain(&tlvlist);
783 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support"
784 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer"
785 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers"
788 faim_export unsigned long aim_denytransfer(struct aim_session_t *sess,
789 struct aim_conn_t *conn,
794 struct command_tx_struct *newpacket;
797 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+8+2+1+strlen(sender)+6)))
802 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x000b, 0x0000, sess->snac_nextid);
803 for (i = 0; i < 8; i++)
804 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]);
805 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
806 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sender));
807 curbyte += aimutil_putstr(newpacket->data+curbyte, sender, strlen(sender));
808 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0003, code);
811 aim_tx_enqueue(sess, newpacket);
813 return (sess->snac_nextid++);
817 * Not real sure what this does, nor does anyone I've talk to.
819 * Didn't use to send it. But now I think it might be a good
823 faim_export unsigned long aim_seticbmparam(struct aim_session_t *sess,
824 struct aim_conn_t *conn)
826 struct command_tx_struct *newpacket;
829 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+16)))
834 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid);
835 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
836 curbyte += aimutil_put32(newpacket->data+curbyte, 0x00000003);
837 curbyte += aimutil_put8(newpacket->data+curbyte, 0x1f);
838 curbyte += aimutil_put8(newpacket->data+curbyte, 0x40);
839 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03);
840 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7);
841 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03);
842 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7);
843 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
844 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
847 aim_tx_enqueue(sess, newpacket);
849 return (sess->snac_nextid++);
852 faim_internal int aim_parse_msgerror_middle(struct aim_session_t *sess,
853 struct command_rx_struct *command)
855 u_long snacid = 0x000000000;
856 struct aim_snac_t *snac = NULL;
858 rxcallback_t userfunc = NULL;
860 unsigned short reason = 0;
863 * Get SNAC from packet and look it up
864 * the list of unrepliedto/outstanding
867 * After its looked up, the SN that the
868 * message should've gone to will be
869 * in the ->data element of the snac struct.
872 snacid = aimutil_get32(command->data+6);
873 snac = aim_remsnac(sess, snacid);
876 printf("faim: msgerr: got an ICBM-failed error on an unknown SNAC ID! (%08lx)\n", snacid);
881 reason = aimutil_get16(command->data+10);
886 userfunc = aim_callhandler(command->conn, 0x0004, 0x0001);
888 ret = userfunc(sess, command, dest, reason);
901 faim_internal int aim_parse_missedcall(struct aim_session_t *sess,
902 struct command_rx_struct *command)
905 rxcallback_t userfunc = NULL;
906 unsigned short channel, nummissed, reason;
907 struct aim_userinfo_s userinfo;
909 i = 10; /* Skip SNAC header */
913 * XXX: supposedly, this entire packet can repeat as many times
914 * as necessary. Should implement that.
920 channel = aimutil_get16(command->data+i);
924 * Extract the standard user info block.
926 i += aim_extractuserinfo(command->data+i, &userinfo);
928 nummissed = aimutil_get16(command->data+i);
931 reason = aimutil_get16(command->data+i);
937 userfunc = aim_callhandler(command->conn, 0x0004, 0x000a);
939 ret = userfunc(sess, command, channel, &userinfo, nummissed, reason);