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