]> andersk Git - libfaim.git/blame - aim_chat.c
- Fri Dec 1 22:25:56 UTC 2000
[libfaim.git] / aim_chat.c
CommitLineData
9de3ca7e 1/*
2 * aim_chat.c
3 *
aa6efcfd 4 * Routines for the Chat service.
9de3ca7e 5 *
6 */
7
a25832e6 8#include <faim/aim.h>
9de3ca7e 9
78b3fb13 10faim_export char *aim_chat_getname(struct aim_conn_t *conn)
0c20631f 11{
12 if (!conn)
13 return NULL;
14 if (conn->type != AIM_CONN_TYPE_CHAT)
15 return NULL;
16
17 return (char *)conn->priv; /* yuck ! */
18}
19
78b3fb13 20faim_export struct aim_conn_t *aim_chat_getconn(struct aim_session_t *sess, char *name)
0c20631f 21{
040457cc 22 struct aim_conn_t *cur;
23
24 faim_mutex_lock(&sess->connlistlock);
25 for (cur = sess->connlist; cur; cur = cur->next) {
26 if (cur->type != AIM_CONN_TYPE_CHAT)
27 continue;
9d2a3582 28 if (!cur->priv) {
29 printf("faim: chat: chat connection with no name! (fd = %d)\n", cur->fd);
30 continue;
31 }
040457cc 32 if (strcmp((char *)cur->priv, name) == 0)
33 break;
34 }
35 faim_mutex_unlock(&sess->connlistlock);
0c20631f 36
040457cc 37 return cur;
0c20631f 38}
39
78b3fb13 40faim_export int aim_chat_attachname(struct aim_conn_t *conn, char *roomname)
0c20631f 41{
42 if (!conn || !roomname)
43 return -1;
44
9d2a3582 45 if (conn->priv)
46 free(conn->priv);
47
48 conn->priv = strdup(roomname);
0c20631f 49
50 return 0;
51}
52
78b3fb13 53faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess,
54 struct aim_conn_t *conn,
55 char *msg)
0c20631f 56{
57
58 int curbyte,i;
5b79dc93 59 struct command_tx_struct *newpacket;
0c20631f 60
61 if (!sess || !conn || !msg)
62 return 0;
63
b69540e3 64 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
5b79dc93 65 return -1;
0c20631f 66
5b79dc93 67 newpacket->lock = 1; /* lock struct */
0c20631f 68
69 curbyte = 0;
5b79dc93 70 curbyte += aim_putsnac(newpacket->data+curbyte,
0c20631f 71 0x000e, 0x0005, 0x0000, sess->snac_nextid);
72
73 /*
74 * Generate a random message cookie
0c20631f 75 */
76 for (i=0;i<8;i++)
5ac21963 77 curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) rand());
0c20631f 78
7392c79f 79 aim_cachecookie(sess, aim_mkcookie(newpacket->data+curbyte-8, AIM_COOKIETYPE_CHAT, NULL));
80
0c20631f 81 /*
82 * metaTLV start. -- i assume this is a metaTLV. it could be the
83 * channel ID though.
84 */
5b79dc93 85 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003);
0c20631f 86
87 /*
88 * Type 1: Unknown. Blank.
89 */
5b79dc93 90 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
91 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
0c20631f 92
93 /*
94 * Type 6: Unknown. Blank.
95 */
5b79dc93 96 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0006);
97 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
0c20631f 98
99 /*
100 * Type 5: Message block. Contains more TLVs.
101 *
102 * This could include other information... We just
103 * put in a message TLV however.
104 *
105 */
5b79dc93 106 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005);
107 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg)+4);
0c20631f 108
109 /*
110 * SubTLV: Type 1: Message
111 */
5b79dc93 112 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(msg), msg);
0c20631f 113
5b79dc93 114 newpacket->commandlen = curbyte;
0c20631f 115
5b79dc93 116 newpacket->lock = 0;
117 aim_tx_enqueue(sess, newpacket);
0c20631f 118
119 return (sess->snac_nextid++);
120}
121
9de3ca7e 122/*
0c20631f 123 * Join a room of name roomname. This is the first
124 * step to joining an already created room. It's
125 * basically a Service Request for family 0x000e,
126 * with a little added on to specify the exchange
127 * and room name.
9de3ca7e 128 *
129 */
78b3fb13 130faim_export unsigned long aim_chat_join(struct aim_session_t *sess,
131 struct aim_conn_t *conn,
132 u_short exchange,
133 const char *roomname)
9de3ca7e 134{
5b79dc93 135 struct command_tx_struct *newpacket;
0c20631f 136 int i;
137
138 if (!sess || !conn || !roomname)
139 return 0;
9de3ca7e 140
b69540e3 141 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+9+strlen(roomname)+2)))
5b79dc93 142 return -1;
a25832e6 143
5b79dc93 144 newpacket->lock = 1;
9de3ca7e 145
5b79dc93 146 i = aim_putsnac(newpacket->data, 0x0001, 0x0004, 0x0000, sess->snac_nextid);
9de3ca7e 147
5b79dc93 148 i+= aimutil_put16(newpacket->data+i, 0x000e);
0c20631f 149
150 /*
151 * this is techinally a TLV, but we can't use normal functions
152 * because we need the extraneous nulls and other weird things.
153 */
5b79dc93 154 i+= aimutil_put16(newpacket->data+i, 0x0001);
155 i+= aimutil_put16(newpacket->data+i, 2+1+strlen(roomname)+2);
156 i+= aimutil_put16(newpacket->data+i, exchange);
157 i+= aimutil_put8(newpacket->data+i, strlen(roomname));
158 memcpy(newpacket->data+i, roomname, strlen(roomname));
0c20631f 159 i+= strlen(roomname);
5b79dc93 160 //i+= aimutil_putstr(newpacket->data+i, roomname, strlen(roomname));
161 i+= aimutil_put16(newpacket->data+i, 0x0000);
9de3ca7e 162
0c20631f 163 /*
164 * Chat hack.
165 *
166 * XXX: A problem occurs here if we request a channel
167 * join but it fails....pendingjoin will be nonnull
168 * even though the channel is never going to get a
169 * redirect!
170 *
171 */
172 sess->pendingjoin = (char *)malloc(strlen(roomname)+1);
173 strcpy(sess->pendingjoin, roomname);
174
5b79dc93 175 newpacket->lock = 0;
176 aim_tx_enqueue(sess, newpacket);
9de3ca7e 177
0c20631f 178#if 0
9de3ca7e 179 {
180 struct aim_snac_t snac;
181
a25832e6 182 snac.id = sess->snac_nextid;
9de3ca7e 183 snac.family = 0x0001;
184 snac.type = 0x0004;
185 snac.flags = 0x0000;
186
0c20631f 187 snac.data = malloc(strlen(roomname)+1);
188 strcpy(snac.data, roomname);
9de3ca7e 189
a25832e6 190 aim_newsnac(sess, &snac);
9de3ca7e 191 }
192
0c20631f 193#endif
194 return (sess->snac_nextid++);
195}
196
78b3fb13 197faim_internal int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo)
0c20631f 198{
199 int namelen = 0;
200 int i = 0;
201
202 if (!buf || !outinfo)
203 return 0;
204
205 outinfo->exchange = aimutil_get16(buf+i);
206 i += 2;
207
208 namelen = aimutil_get8(buf+i);
209 i += 1;
210
211 outinfo->name = (char *)malloc(namelen+1);
212 memcpy(outinfo->name, buf+i, namelen);
213 outinfo->name[namelen] = '\0';
214 i += namelen;
215
216 outinfo->instance = aimutil_get16(buf+i);
217 i += 2;
218
219 return i;
78b3fb13 220}
0c20631f 221
222
223/*
224 * General room information. Lots of stuff.
225 *
226 * Values I know are in here but I havent attached
227 * them to any of the 'Unknown's:
228 * - Language (English)
229 *
aa6efcfd 230 * SNAC 000e/0002
0c20631f 231 */
78b3fb13 232faim_internal int aim_chat_parse_infoupdate(struct aim_session_t *sess,
233 struct command_rx_struct *command)
0c20631f 234{
f1a5efe0 235 struct aim_userinfo_s *userinfo = NULL;
0c20631f 236 rxcallback_t userfunc=NULL;
237 int ret = 1, i = 0;
238 int usercount = 0;
239 u_char detaillevel = 0;
f1a5efe0 240 char *roomname = NULL;
0c20631f 241 struct aim_chat_roominfo roominfo;
242 u_short tlvcount = 0;
243 struct aim_tlvlist_t *tlvlist;
f1a5efe0 244 char *roomdesc = NULL;
aa6efcfd 245 struct aim_tlv_t *tmptlv;
246 unsigned short unknown_c9 = 0;
247 unsigned long creationtime = 0;
248 unsigned short maxmsglen = 0;
249 unsigned short unknown_d2 = 0, unknown_d5 = 0;
0c20631f 250
251 i = 10;
252 i += aim_chat_readroominfo(command->data+i, &roominfo);
253
254 detaillevel = aimutil_get8(command->data+i);
255 i++;
aa6efcfd 256
257 if (detaillevel != 0x02) {
258 if (detaillevel == 0x01)
313a06b7 259 printf("faim: chat_roomupdateinfo: detail level 1 not supported\n");
aa6efcfd 260 else
261 printf("faim: chat_roomupdateinfo: unknown detail level %d\n", detaillevel);
262 return 1;
263 }
0c20631f 264
265 tlvcount = aimutil_get16(command->data+i);
266 i += 2;
267
268 /*
269 * Everything else are TLVs.
270 */
271 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
272
273 /*
274 * TLV type 0x006a is the room name in Human Readable Form.
275 */
276 if (aim_gettlv(tlvlist, 0x006a, 1))
277 roomname = aim_gettlv_str(tlvlist, 0x006a, 1);
278
279 /*
280 * Type 0x006f: Number of occupants.
281 */
aa6efcfd 282 if (aim_gettlv(tlvlist, 0x006f, 1)) {
283 struct aim_tlv_t *tmptlv;
284 tmptlv = aim_gettlv(tlvlist, 0x006f, 1);
285
286 usercount = aimutil_get16(tmptlv->value);
287 }
0c20631f 288
289 /*
290 * Type 0x0073: Occupant list.
291 */
aa6efcfd 292 if (aim_gettlv(tlvlist, 0x0073, 1)) {
293 int curoccupant = 0;
294 struct aim_tlv_t *tmptlv;
295
296 tmptlv = aim_gettlv(tlvlist, 0x0073, 1);
0c20631f 297
aa6efcfd 298 /* Allocate enough userinfo structs for all occupants */
299 userinfo = calloc(usercount, sizeof(struct aim_userinfo_s));
300
301 i = 0;
302 while (curoccupant < usercount)
303 i += aim_extractuserinfo(tmptlv->value+i, &userinfo[curoccupant++]);
304 }
0c20631f 305
306 /*
aa6efcfd 307 * Type 0x00c9: Unknown. (2 bytes)
0c20631f 308 */
aa6efcfd 309 if ((tmptlv = aim_gettlv(tlvlist, 0x00c9, 1)))
310 unknown_c9 = aimutil_get16(tmptlv->value);
0c20631f 311
312 /*
aa6efcfd 313 * Type 0x00ca: Creation time (4 bytes)
0c20631f 314 */
aa6efcfd 315 if ((tmptlv = aim_gettlv(tlvlist, 0x00ca, 1)))
316 creationtime = aimutil_get32(tmptlv->value);
0c20631f 317
318 /*
319 * Type 0x00d1: Maximum Message Length
320 */
aa6efcfd 321 if ((tmptlv = aim_gettlv(tlvlist, 0x00d1, 1)))
322 maxmsglen = aimutil_get16(tmptlv->value);
0c20631f 323
324 /*
aa6efcfd 325 * Type 0x00d2: Unknown. (2 bytes)
0c20631f 326 */
aa6efcfd 327 if ((tmptlv = aim_gettlv(tlvlist, 0x00d2, 1)))
328 unknown_d2 = aimutil_get16(tmptlv->value);;
0c20631f 329
330 /*
331 * Type 0x00d3: Room Description
332 */
333 if (aim_gettlv(tlvlist, 0x00d3, 1))
334 roomdesc = aim_gettlv_str(tlvlist, 0x00d3, 1);
335
336 /*
aa6efcfd 337 * Type 0x00d5: Unknown. (1 byte)
0c20631f 338 */
aa6efcfd 339 if ((tmptlv = aim_gettlv(tlvlist, 0x00d5, 1)))
340 unknown_d5 = aimutil_get8(tmptlv->value);;
0c20631f 341
342
343 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE);
aa6efcfd 344 if (userfunc) {
345 ret = userfunc(sess,
346 command,
347 &roominfo,
348 roomname,
349 usercount,
350 userinfo,
351 roomdesc,
352 unknown_c9,
353 creationtime,
354 maxmsglen,
355 unknown_d2,
356 unknown_d5);
357 }
0c20631f 358 free(roominfo.name);
359 free(userinfo);
360 free(roomname);
361 free(roomdesc);
362 aim_freetlvchain(&tlvlist);
363
364 return ret;
365}
366
78b3fb13 367faim_internal int aim_chat_parse_joined(struct aim_session_t *sess,
368 struct command_rx_struct *command)
0c20631f 369{
370 struct aim_userinfo_s *userinfo = NULL;
371 rxcallback_t userfunc=NULL;
372 int i = 10, curcount = 0, ret = 1;
373
aa6efcfd 374 while (i < command->commandlen) {
375 curcount++;
376 userinfo = realloc(userinfo, curcount * sizeof(struct aim_userinfo_s));
377 i += aim_extractuserinfo(command->data+i, &userinfo[curcount-1]);
378 }
0c20631f 379
380 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN);
aa6efcfd 381 if (userfunc) {
382 ret = userfunc(sess,
383 command,
384 curcount,
385 userinfo);
386 }
0c20631f 387
388 free(userinfo);
389
390 return ret;
391}
392
78b3fb13 393faim_internal int aim_chat_parse_leave(struct aim_session_t *sess,
394 struct command_rx_struct *command)
0c20631f 395{
396
397 struct aim_userinfo_s *userinfo = NULL;
398 rxcallback_t userfunc=NULL;
399 int i = 10, curcount = 0, ret = 1;
400
aa6efcfd 401 while (i < command->commandlen) {
402 curcount++;
403 userinfo = realloc(userinfo, curcount * sizeof(struct aim_userinfo_s));
404 i += aim_extractuserinfo(command->data+i, &userinfo[curcount-1]);
405 }
0c20631f 406
407 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE);
aa6efcfd 408 if (userfunc) {
409 ret = userfunc(sess,
410 command,
411 curcount,
412 userinfo);
413 }
0c20631f 414
415 free(userinfo);
416
417 return ret;
418}
419
420/*
421 * We could probably include this in the normal ICBM parsing
422 * code as channel 0x0003, however, since only the start
423 * would be the same, we might as well do it here.
424 */
78b3fb13 425faim_internal int aim_chat_parse_incoming(struct aim_session_t *sess,
426 struct command_rx_struct *command)
0c20631f 427{
428 struct aim_userinfo_s userinfo;
429 rxcallback_t userfunc=NULL;
430 int ret = 1, i = 0, z = 0;
fd0b7da6 431 unsigned char cookie[8];
0c20631f 432 int channel;
433 struct aim_tlvlist_t *outerlist;
434 char *msg = NULL;
fd0b7da6 435 struct aim_msgcookie_t *ck;
0c20631f 436
437 memset(&userinfo, 0x00, sizeof(struct aim_userinfo_s));
438
439 i = 10; /* skip snac */
440
441 /*
7392c79f 442 * ICBM Cookie. Cache it.
0c20631f 443 */
444 for (z=0; z<8; z++,i++)
445 cookie[z] = command->data[i];
446
fd0b7da6 447 if ((ck = aim_uncachecookie(sess, cookie, AIM_COOKIETYPE_CHAT))) {
448 if (ck->data)
449 free(ck->data);
450 free(ck);
451 }
7392c79f 452
0c20631f 453 /*
454 * Channel ID
455 *
456 * Channels 1 and 2 are implemented in the normal ICBM
457 * parser.
458 *
459 * We only do channel 3 here.
460 *
461 */
462 channel = aimutil_get16(command->data+i);
463 i += 2;
464
aa6efcfd 465 if (channel != 0x0003) {
466 printf("faim: chat_incoming: unknown channel! (0x%04x)\n", channel);
467 return 1;
468 }
0c20631f 469
470 /*
471 * Start parsing TLVs right away.
472 */
473 outerlist = aim_readtlvchain(command->data+i, command->commandlen-i);
474
475 /*
476 * Type 0x0003: Source User Information
477 */
aa6efcfd 478 if (aim_gettlv(outerlist, 0x0003, 1)) {
479 struct aim_tlv_t *userinfotlv;
480
481 userinfotlv = aim_gettlv(outerlist, 0x0003, 1);
482 aim_extractuserinfo(userinfotlv->value, &userinfo);
483 }
0c20631f 484
485 /*
486 * Type 0x0001: Unknown.
487 */
488 if (aim_gettlv(outerlist, 0x0001, 1))
489 ;
490
491 /*
492 * Type 0x0005: Message Block. Conains more TLVs.
493 */
494 if (aim_gettlv(outerlist, 0x0005, 1))
495 {
496 struct aim_tlvlist_t *innerlist;
497 struct aim_tlv_t *msgblock;
498
499 msgblock = aim_gettlv(outerlist, 0x0005, 1);
500 innerlist = aim_readtlvchain(msgblock->value, msgblock->length);
501
502 /*
503 * Type 0x0001: Message.
504 */
505 if (aim_gettlv(innerlist, 0x0001, 1))
506 msg = aim_gettlv_str(innerlist, 0x0001, 1);
507
508 aim_freetlvchain(&innerlist);
509 }
510
511 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG);
512 if (userfunc)
513 {
514 ret = userfunc(sess,
515 command,
516 &userinfo,
517 msg);
518 }
519 free(msg);
520 aim_freetlvchain(&outerlist);
521
522 return ret;
523}
524
78b3fb13 525faim_export unsigned long aim_chat_clientready(struct aim_session_t *sess,
526 struct aim_conn_t *conn)
0c20631f 527{
5b79dc93 528 struct command_tx_struct *newpacket;
0c20631f 529 int i;
530
b69540e3 531 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 0x20)))
5b79dc93 532 return -1;
533
534 newpacket->lock = 1;
0c20631f 535
5b79dc93 536 i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
0c20631f 537
5b79dc93 538 i+= aimutil_put16(newpacket->data+i, 0x000e);
539 i+= aimutil_put16(newpacket->data+i, 0x0001);
0c20631f 540
5b79dc93 541 i+= aimutil_put16(newpacket->data+i, 0x0004);
542 i+= aimutil_put16(newpacket->data+i, 0x0001);
0c20631f 543
5b79dc93 544 i+= aimutil_put16(newpacket->data+i, 0x0001);
545 i+= aimutil_put16(newpacket->data+i, 0x0003);
0c20631f 546
5b79dc93 547 i+= aimutil_put16(newpacket->data+i, 0x0004);
548 i+= aimutil_put16(newpacket->data+i, 0x0686);
0c20631f 549
5b79dc93 550 newpacket->lock = 0;
551 aim_tx_enqueue(sess, newpacket);
0c20631f 552
553 return (sess->snac_nextid++);
554}
555
78b3fb13 556faim_export int aim_chat_leaveroom(struct aim_session_t *sess, char *name)
0c20631f 557{
040457cc 558 struct aim_conn_t *conn;
0c20631f 559
040457cc 560 if ((conn = aim_chat_getconn(sess, name)))
9d2a3582 561 aim_conn_close(conn);
040457cc 562
563 if (!conn)
564 return -1;
565 return 0;
0c20631f 566}
567
568/*
569 * conn must be a BOS connection!
570 */
78b3fb13 571faim_export unsigned long aim_chat_invite(struct aim_session_t *sess,
572 struct aim_conn_t *conn,
573 char *sn,
574 char *msg,
575 u_short exchange,
576 char *roomname,
577 u_short instance)
0c20631f 578{
5b79dc93 579 struct command_tx_struct *newpacket;
0c20631f 580 int i,curbyte=0;
581
582 if (!sess || !conn || !sn || !msg || !roomname)
9d2a3582 583 return -1;
584
585 if (conn->type != AIM_CONN_TYPE_BOS)
586 return -1;
0c20631f 587
b69540e3 588 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152+strlen(sn)+strlen(roomname)+strlen(msg))))
5b79dc93 589 return -1;
590
591 newpacket->lock = 1;
0c20631f 592
5b79dc93 593 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0006, 0x0000, sess->snac_nextid);
0c20631f 594
595 /*
596 * Cookie
597 */
598 for (i=0;i<8;i++)
5b79dc93 599 curbyte += aimutil_put8(newpacket->data+curbyte, (u_char)rand());
fd0b7da6 600
601 /* XXX this should get uncached by the unwritten 'invite accept' handler */
7392c79f 602 aim_cachecookie(sess, aim_mkcookie(newpacket->data+curbyte-8, AIM_COOKIETYPE_CHAT, NULL));
0c20631f 603
604 /*
605 * Channel (2)
606 */
5b79dc93 607 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
0c20631f 608
609 /*
610 * Dest sn
611 */
5b79dc93 612 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sn));
613 curbyte += aimutil_putstr(newpacket->data+curbyte, sn, strlen(sn));
0c20631f 614
615 /*
616 * TLV t(0005)
617 */
5b79dc93 618 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005);
619 curbyte += aimutil_put16(newpacket->data+curbyte, 0x28+strlen(msg)+0x04+0x03+strlen(roomname)+0x02);
0c20631f 620
621 /*
622 * Unknown info
623 */
5b79dc93 624 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
625 curbyte += aimutil_put16(newpacket->data+curbyte, 0x3131);
626 curbyte += aimutil_put16(newpacket->data+curbyte, 0x3538);
627 curbyte += aimutil_put16(newpacket->data+curbyte, 0x3446);
628 curbyte += aimutil_put16(newpacket->data+curbyte, 0x4100);
629 curbyte += aimutil_put16(newpacket->data+curbyte, 0x748f);
630 curbyte += aimutil_put16(newpacket->data+curbyte, 0x2420);
631 curbyte += aimutil_put16(newpacket->data+curbyte, 0x6287);
632 curbyte += aimutil_put16(newpacket->data+curbyte, 0x11d1);
633 curbyte += aimutil_put16(newpacket->data+curbyte, 0x8222);
634 curbyte += aimutil_put16(newpacket->data+curbyte, 0x4445);
635 curbyte += aimutil_put16(newpacket->data+curbyte, 0x5354);
636 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
0c20631f 637
638 /*
639 * TLV t(000a) -- Unknown
640 */
5b79dc93 641 curbyte += aimutil_put16(newpacket->data+curbyte, 0x000a);
642 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
643 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
0c20631f 644
645 /*
646 * TLV t(000f) -- Unknown
647 */
5b79dc93 648 curbyte += aimutil_put16(newpacket->data+curbyte, 0x000f);
649 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
0c20631f 650
651 /*
652 * TLV t(000c) -- Invitation message
653 */
5b79dc93 654 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000c, strlen(msg), msg);
0c20631f 655
656 /*
657 * TLV t(2711) -- Container for room information
658 */
5b79dc93 659 curbyte += aimutil_put16(newpacket->data+curbyte, 0x2711);
660 curbyte += aimutil_put16(newpacket->data+curbyte, 3+strlen(roomname)+2);
661 curbyte += aimutil_put16(newpacket->data+curbyte, exchange);
662 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(roomname));
663 curbyte += aimutil_putstr(newpacket->data+curbyte, roomname, strlen(roomname));
664 curbyte += aimutil_put16(newpacket->data+curbyte, instance);
665
666 newpacket->commandlen = curbyte;
667 newpacket->lock = 0;
668 aim_tx_enqueue(sess, newpacket);
0c20631f 669
a25832e6 670 return (sess->snac_nextid++);
9de3ca7e 671}
This page took 0.363198 seconds and 5 git commands to generate.