]> andersk Git - libfaim.git/blame - src/login.c
- Fri Mar 23 01:45:28 UTC 2001
[libfaim.git] / src / login.c
CommitLineData
9de3ca7e 1/*
2 * aim_login.c
3 *
4 * This contains all the functions needed to actually login.
5 *
6 */
7
37ee990e 8#define FAIM_INTERNAL
dd60ff8b 9#include <aim.h>
9de3ca7e 10
b5bc2a8c 11#include "md5.h"
12
13static int aim_encode_password_md5(const char *password, const char *key, md5_byte_t *digest);
5daacaa3 14static int aim_encode_password(const char *password, unsigned char *encoded);
9de3ca7e 15
78b3fb13 16faim_export int aim_sendconnack(struct aim_session_t *sess,
17 struct aim_conn_t *conn)
01b59e1e 18{
19 int curbyte=0;
20
5b79dc93 21 struct command_tx_struct *newpacket;
01b59e1e 22
646c6b52 23 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0001, 4)))
01b59e1e 24 return -1;
25
5b79dc93 26 newpacket->lock = 1;
01b59e1e 27
5b79dc93 28 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
29 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
01b59e1e 30
5b79dc93 31 newpacket->lock = 0;
32 return aim_tx_enqueue(sess, newpacket);
01b59e1e 33}
34
01b59e1e 35/*
36 * In AIM 3.5 protocol, the first stage of login is to request
37 * login from the Authorizer, passing it the screen name
38 * for verification. If the name is invalid, a 0017/0003
39 * is spit back, with the standard error contents. If valid,
40 * a 0017/0007 comes back, which is the signal to send
41 * it the main login command (0017/0002).
42 */
78b3fb13 43faim_export int aim_request_login(struct aim_session_t *sess,
44 struct aim_conn_t *conn,
45 char *sn)
01b59e1e 46{
5daacaa3 47 int curbyte;
5b79dc93 48 struct command_tx_struct *newpacket;
01b59e1e 49
5daacaa3 50 if (!sess || !conn || !sn)
51 return -1;
52
53 /*
54 * For ICQ, we enable the ancient horrible login and stuff
55 * a key packet into the queue to make it look like we got
56 * a reply back. This is so the client doesn't know we're
57 * really not doing MD5 login.
58 *
59 * This may sound stupid, but I'm not in the best of moods and
60 * I don't plan to keep support for this crap around much longer.
61 * Its all AOL's fault anyway, really. I hate AOL. Really. They
62 * always seem to be able to piss me off by doing the dumbest little
63 * things. Like disabling MD5 logins for ICQ UINs, or adding purposefully
64 * wrong TLV lengths, or adding superfluous information to host strings,
65 * or... I'll stop.
66 *
67 */
68 if ((sn[0] >= '0') && (sn[0] <= '9')) {
69 struct command_rx_struct *newrx;
70 int i;
71
72 if (!(newrx = (struct command_rx_struct *)malloc(sizeof(struct command_rx_struct))))
73 return -1;
74 memset(newrx, 0x00, sizeof(struct command_rx_struct));
75 newrx->lock = 1;
76 newrx->hdrtype = AIM_FRAMETYPE_OSCAR;
77 newrx->hdr.oscar.type = 0x02;
78 newrx->hdr.oscar.seqnum = 0;
79 newrx->commandlen = 10+2+1;
80 newrx->nofree = 0;
81 if (!(newrx->data = malloc(newrx->commandlen))) {
82 free(newrx);
83 return -1;
84 }
85
86 i = aim_putsnac(newrx->data, 0x0017, 0x0007, 0x0000, 0x0000);
87 i += aimutil_put16(newrx->data+i, 0x01);
88 i += aimutil_putstr(newrx->data+i, "0", 1);
89
90 newrx->conn = conn;
91
92 newrx->next = sess->queue_incoming;
93 sess->queue_incoming = newrx;
94
95 newrx->lock = 0;
96
22517493 97 sess->flags &= ~AIM_SESS_FLAGS_SNACLOGIN;
98
5daacaa3 99 return 0;
100 }
101
22517493 102 sess->flags |= AIM_SESS_FLAGS_SNACLOGIN;
5daacaa3 103
104 aim_sendconnack(sess, conn);
105
646c6b52 106 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+2+2+strlen(sn))))
5b79dc93 107 return -1;
01b59e1e 108
5b79dc93 109 newpacket->lock = 1;
01b59e1e 110
5daacaa3 111 curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0006, 0x0000, 0x00010000);
5b79dc93 112 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
01b59e1e 113
5daacaa3 114 newpacket->commandlen = curbyte;
5b79dc93 115 newpacket->lock = 0;
5daacaa3 116
5b79dc93 117 return aim_tx_enqueue(sess, newpacket);
01b59e1e 118}
01b59e1e 119
9de3ca7e 120/*
24286d93 121 * send_login(int socket, char *sn, char *password)
9de3ca7e 122 *
123 * This is the initial login request packet.
124 *
125 * The password is encoded before transmition, as per
126 * encode_password(). See that function for their
127 * stupid method of doing it.
128 *
355982c5 129 * Latest WinAIM:
130 * clientstring = "AOL Instant Messenger (SM), version 4.3.2188/WIN32"
131 * major2 = 0x0109
132 * major = 0x0400
133 * minor = 0x0003
134 * minor2 = 0x0000
135 * build = 0x088c
136 * unknown = 0x00000086
137 * lang = "en"
138 * country = "us"
139 * unknown4a = 0x01
154b4093 140 *
141 * Latest WinAIM that libfaim can emulate without server-side buddylists:
142 * clientstring = "AOL Instant Messenger (SM), version 3.5.1670/WIN32"
143 * major2 = 0x0004
144 * major = 0x0003
145 * minor = 0x0005
146 * minor2 = 0x0000
147 * build = 0x0686
148 * unknown =0x0000002a
149 *
9de3ca7e 150 */
78b3fb13 151faim_export int aim_send_login (struct aim_session_t *sess,
152 struct aim_conn_t *conn,
153 char *sn, char *password,
154 struct client_info_s *clientinfo,
155 char *key)
9de3ca7e 156{
9de3ca7e 157 int curbyte=0;
5b79dc93 158 struct command_tx_struct *newpacket;
9de3ca7e 159
01b59e1e 160 if (!clientinfo || !sn || !password)
161 return -1;
162
646c6b52 163 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152)))
5b79dc93 164 return -1;
9de3ca7e 165
5b79dc93 166 newpacket->lock = 1;
01b59e1e 167
22517493 168 newpacket->hdr.oscar.type = (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)?0x02:0x01;
b5bc2a8c 169
22517493 170 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)
5daacaa3 171 curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0002, 0x0000, 0x00010000);
172 else {
173 curbyte = aimutil_put16(newpacket->data, 0x0000);
174 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
175 }
b5bc2a8c 176
5daacaa3 177 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
9de3ca7e 178
22517493 179 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) {
5daacaa3 180 md5_byte_t digest[16];
181
182 aim_encode_password_md5(password, key, digest);
183 curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0025, 16, (char *)digest);
184 } else {
185 char *password_encoded;
186
187 password_encoded = (char *) malloc(strlen(password));
188 aim_encode_password(password, password_encoded);
189 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0002, strlen(password), password_encoded);
190 free(password_encoded);
191 }
192
13ebc4c4 193 /* XXX is clientstring required by oscar? */
194 if (strlen(clientinfo->clientstring))
195 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring);
196
22517493 197 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) {
154b4093 198
5daacaa3 199 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, (unsigned short)clientinfo->major2);
200 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, (unsigned short)clientinfo->major);
201 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, (unsigned short)clientinfo->minor);
202 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, (unsigned short)clientinfo->minor2);
203 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, (unsigned short)clientinfo->build);
b5bc2a8c 204
5daacaa3 205 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown);
206 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015);
154b4093 207
5daacaa3 208 } else {
355982c5 209 /* Use very specific version numbers, to further indicate the hack. */
5daacaa3 210 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, 0x010a);
211 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, 0x0004);
212 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, 0x003c);
213 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001);
214 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, 0x0cce);
215 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055);
216 }
9de3ca7e 217
13ebc4c4 218 if (strlen(clientinfo->country))
154b4093 219 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, strlen(clientinfo->country), clientinfo->country);
13ebc4c4 220 else
154b4093 221 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, 2, "us");
13ebc4c4 222
223 if (strlen(clientinfo->lang))
154b4093 224 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, strlen(clientinfo->lang), clientinfo->lang);
13ebc4c4 225 else
154b4093 226 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, 2, "en");
13ebc4c4 227
228 newpacket->commandlen = curbyte;
9de3ca7e 229
5b79dc93 230 newpacket->lock = 0;
231 return aim_tx_enqueue(sess, newpacket);
9de3ca7e 232}
9de3ca7e 233
b5bc2a8c 234static int aim_encode_password_md5(const char *password, const char *key, md5_byte_t *digest)
235{
236 md5_state_t state;
237
238 md5_init(&state);
239 md5_append(&state, (const md5_byte_t *)key, strlen(key));
240 md5_append(&state, (const md5_byte_t *)password, strlen(password));
241 md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING));
242 md5_finish(&state, (md5_byte_t *)digest);
243
244 return 0;
245}
246
5daacaa3 247/**
248 * aim_encode_password - Encode a password using old XOR method
249 * @password: incoming password
250 * @encoded: buffer to put encoded password
9de3ca7e 251 *
252 * This takes a const pointer to a (null terminated) string
253 * containing the unencoded password. It also gets passed
254 * an already allocated buffer to store the encoded password.
255 * This buffer should be the exact length of the password without
5daacaa3 256 * the null. The encoded password buffer /is not %NULL terminated/.
9de3ca7e 257 *
258 * The encoding_table seems to be a fixed set of values. We'll
259 * hope it doesn't change over time!
260 *
5daacaa3 261 * This is only used for the XOR method, not the better MD5 method.
b5bc2a8c 262 *
9de3ca7e 263 */
b5bc2a8c 264static int aim_encode_password(const char *password, unsigned char *encoded)
9de3ca7e 265{
266 u_char encoding_table[] = {
b69540e3 267#if 0 /* old v1 table */
9de3ca7e 268 0xf3, 0xb3, 0x6c, 0x99,
269 0x95, 0x3f, 0xac, 0xb6,
270 0xc5, 0xfa, 0x6b, 0x63,
271 0x69, 0x6c, 0xc3, 0x9f
b69540e3 272#else /* v2.1 table, also works for ICQ */
5e02cf44 273 0xf3, 0x26, 0x81, 0xc4,
b69540e3 274 0x39, 0x86, 0xdb, 0x92,
275 0x71, 0xa3, 0xb9, 0xe6,
276 0x53, 0x7a, 0x95, 0x7c
277#endif
5e02cf44 278 };
279
280 int i;
b69540e3 281
5e02cf44 282 for (i = 0; i < strlen(password); i++)
283 encoded[i] = (password[i] ^ encoding_table[i]);
284
285 return 0;
286}
287
01b59e1e 288/*
289 * This is sent back as a general response to the login command.
290 * It can be either an error or a success, depending on the
291 * precense of certain TLVs.
292 *
355982c5 293 * The client should check the value passed as errorcode. If
01b59e1e 294 * its nonzero, there was an error.
295 *
296 */
78b3fb13 297faim_internal int aim_authparse(struct aim_session_t *sess,
298 struct command_rx_struct *command)
01b59e1e 299{
300 struct aim_tlvlist_t *tlvlist;
301 int ret = 1;
01b59e1e 302 rxcallback_t userfunc = NULL;
355982c5 303 char *sn = NULL, *bosip = NULL, *errurl = NULL, *email = NULL;
304 unsigned char *cookie = NULL;
305 int errorcode = 0, regstatus = 0;
89bce177 306 int latestbuild = 0, latestbetabuild = 0;
307 char *latestrelease = NULL, *latestbeta = NULL;
308 char *latestreleaseurl = NULL, *latestbetaurl = NULL;
309 char *latestreleaseinfo = NULL, *latestbetainfo = NULL;
01b59e1e 310
311 /*
312 * Read block of TLVs. All further data is derived
313 * from what is parsed here.
b5bc2a8c 314 *
315 * For SNAC login, there's a 17/3 SNAC header in front.
316 *
01b59e1e 317 */
22517493 318 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)
5daacaa3 319 tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10);
320 else
321 tlvlist = aim_readtlvchain(command->data, command->commandlen);
b5bc2a8c 322
01b59e1e 323 /*
324 * No matter what, we should have a screen name.
325 */
355982c5 326 memset(sess->sn, 0, sizeof(sess->sn));
327 if (aim_gettlv(tlvlist, 0x0001, 1)) {
328 sn = aim_gettlv_str(tlvlist, 0x0001, 1);
329 strncpy(sess->sn, sn, sizeof(sess->sn));
330 }
b13c9e13 331
01b59e1e 332 /*
333 * Check for an error code. If so, we should also
334 * have an error url.
335 */
355982c5 336 if (aim_gettlv(tlvlist, 0x0008, 1))
337 errorcode = aim_gettlv16(tlvlist, 0x0008, 1);
338 if (aim_gettlv(tlvlist, 0x0004, 1))
339 errurl = aim_gettlv_str(tlvlist, 0x0004, 1);
340
341 /*
342 * BOS server address.
01b59e1e 343 */
355982c5 344 if (aim_gettlv(tlvlist, 0x0005, 1))
345 bosip = aim_gettlv_str(tlvlist, 0x0005, 1);
346
347 /*
348 * Authorization cookie.
349 */
350 if (aim_gettlv(tlvlist, 0x0006, 1)) {
5e02cf44 351 struct aim_tlv_t *tmptlv;
352
5e02cf44 353 tmptlv = aim_gettlv(tlvlist, 0x0006, 1);
355982c5 354
355 if ((cookie = malloc(tmptlv->length)))
356 memcpy(cookie, tmptlv->value, tmptlv->length);
5e02cf44 357 }
01b59e1e 358
355982c5 359 /*
360 * The email address attached to this account
361 * Not available for ICQ logins.
362 */
363 if (aim_gettlv(tlvlist, 0x0011, 1))
364 email = aim_gettlv_str(tlvlist, 0x0011, 1);
365
366 /*
367 * The registration status. (Not real sure what it means.)
368 * Not available for ICQ logins.
d6c9fcf0 369 *
370 * 1 = No disclosure
371 * 2 = Limited disclosure
372 * 3 = Full disclosure
373 *
374 * This has to do with whether your email address is available
375 * to other users or not. AFAIK, this feature is no longer used.
376 *
355982c5 377 */
378 if (aim_gettlv(tlvlist, 0x0013, 1))
379 regstatus = aim_gettlv16(tlvlist, 0x0013, 1);
b5bc2a8c 380
89bce177 381 if (aim_gettlv(tlvlist, 0x0040, 1))
382 latestbetabuild = aim_gettlv32(tlvlist, 0x0040, 1);
383 if (aim_gettlv(tlvlist, 0x0041, 1))
384 latestbetaurl = aim_gettlv_str(tlvlist, 0x0041, 1);
385 if (aim_gettlv(tlvlist, 0x0042, 1))
386 latestbetainfo = aim_gettlv_str(tlvlist, 0x0042, 1);
387 if (aim_gettlv(tlvlist, 0x0043, 1))
388 latestbeta = aim_gettlv_str(tlvlist, 0x0043, 1);
389 if (aim_gettlv(tlvlist, 0x0048, 1))
390 ; /* no idea what this is */
391
392 if (aim_gettlv(tlvlist, 0x0044, 1))
393 latestbuild = aim_gettlv32(tlvlist, 0x0044, 1);
394 if (aim_gettlv(tlvlist, 0x0045, 1))
395 latestreleaseurl = aim_gettlv_str(tlvlist, 0x0045, 1);
396 if (aim_gettlv(tlvlist, 0x0046, 1))
397 latestreleaseinfo = aim_gettlv_str(tlvlist, 0x0046, 1);
398 if (aim_gettlv(tlvlist, 0x0047, 1))
399 latestrelease = aim_gettlv_str(tlvlist, 0x0047, 1);
400 if (aim_gettlv(tlvlist, 0x0049, 1))
401 ; /* no idea what this is */
402
01b59e1e 403
646c6b52 404 if ((userfunc = aim_callhandler(sess, command->conn, 0x0017, 0x0003)))
89bce177 405 ret = userfunc(sess, command, sn, errorcode, errurl, regstatus, email, bosip, cookie, latestrelease, latestbuild, latestreleaseurl, latestreleaseinfo, latestbeta, latestbetabuild, latestbetaurl, latestbetainfo);
01b59e1e 406
355982c5 407
408 if (sn)
409 free(sn);
410 if (bosip)
411 free(bosip);
412 if (errurl)
413 free(errurl);
414 if (email)
415 free(email);
416 if (cookie)
417 free(cookie);
89bce177 418 if (latestrelease)
419 free(latestrelease);
420 if (latestreleaseurl)
421 free(latestreleaseurl);
422 if (latestbeta)
423 free(latestbeta);
424 if (latestbetaurl)
425 free(latestbetaurl);
426 if (latestreleaseinfo)
427 free(latestreleaseinfo);
428 if (latestbetainfo)
429 free(latestbetainfo);
430
355982c5 431 aim_freetlvchain(&tlvlist);
01b59e1e 432
433 return ret;
434}
e6b05d80 435
b5bc2a8c 436/*
437 * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed
438 * by only its length in a two byte word.
439 *
440 * Calls the client, which should then use the value to call aim_send_login.
441 *
442 */
78b3fb13 443faim_internal int aim_authkeyparse(struct aim_session_t *sess, struct command_rx_struct *command)
b5bc2a8c 444{
445 unsigned char *key;
446 int keylen;
447 int ret = 1;
448 rxcallback_t userfunc;
449
450 keylen = aimutil_get16(command->data+10);
98c88242 451 if (!(key = malloc(keylen+1)))
452 return ret;
b5bc2a8c 453 memcpy(key, command->data+12, keylen);
454 key[keylen] = '\0';
455
646c6b52 456 if ((userfunc = aim_callhandler(sess, command->conn, 0x0017, 0x0007)))
78b3fb13 457 ret = userfunc(sess, command, (char *)key);
b5bc2a8c 458
459 free(key);
460
461 return ret;
462}
463
e6b05d80 464/*
465 * Generate an authorization response.
466 *
467 * You probably don't want this unless you're writing an AIM server.
468 *
469 */
78b3fb13 470faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess,
471 struct aim_conn_t *conn,
355982c5 472 char *sn, int errorcode,
473 char *errorurl, char *bosip,
78b3fb13 474 char *cookie, char *email,
475 int regstatus)
e6b05d80 476{
5b79dc93 477 struct command_tx_struct *tx;
e6b05d80 478 struct aim_tlvlist_t *tlvlist = NULL;
479
646c6b52 480 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0004, 1152)))
5b79dc93 481 return -1;
e6b05d80 482
5b79dc93 483 tx->lock = 1;
e6b05d80 484
485 if (sn)
486 aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn));
487 else
355982c5 488 aim_addtlvtochain_str(&tlvlist, 0x0001, sess->sn, strlen(sess->sn));
e6b05d80 489
355982c5 490 if (errorcode) {
491 aim_addtlvtochain16(&tlvlist, 0x0008, errorcode);
492 aim_addtlvtochain_str(&tlvlist, 0x0004, errorurl, strlen(errorurl));
e6b05d80 493 } else {
494 aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip));
495 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
496 aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email));
5ac21963 497 aim_addtlvtochain16(&tlvlist, 0x0013, (unsigned short)regstatus);
e6b05d80 498 }
499
5b79dc93 500 tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist);
501 tx->lock = 0;
355982c5 502
5b79dc93 503 return aim_tx_enqueue(sess, tx);
e6b05d80 504}
505
506/*
507 * Generate a random cookie. (Non-client use only)
508 */
78b3fb13 509faim_export int aim_gencookie(unsigned char *buf)
e6b05d80 510{
511 int i;
512
513 srand(time(NULL));
514
515 for (i=0; i < AIM_COOKIELEN; i++)
516 buf[i] = 1+(int) (256.0*rand()/(RAND_MAX+0.0));
517
518 return i;
519}
520
521/*
522 * Send Server Ready. (Non-client)
523 */
78b3fb13 524faim_export int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn)
e6b05d80 525{
5b79dc93 526 struct command_tx_struct *tx;
e6b05d80 527 int i = 0;
528
646c6b52 529 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+0x22)))
5b79dc93 530 return -1;
e6b05d80 531
5b79dc93 532 tx->lock = 1;
e6b05d80 533
67c0bb2f 534 i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++);
5b79dc93 535
536 i += aimutil_put16(tx->data+i, 0x0001);
537 i += aimutil_put16(tx->data+i, 0x0002);
538 i += aimutil_put16(tx->data+i, 0x0003);
539 i += aimutil_put16(tx->data+i, 0x0004);
540 i += aimutil_put16(tx->data+i, 0x0006);
541 i += aimutil_put16(tx->data+i, 0x0008);
542 i += aimutil_put16(tx->data+i, 0x0009);
543 i += aimutil_put16(tx->data+i, 0x000a);
544 i += aimutil_put16(tx->data+i, 0x000b);
545 i += aimutil_put16(tx->data+i, 0x000c);
67c0bb2f 546 i += aimutil_put16(tx->data+i, 0x0013);
547 i += aimutil_put16(tx->data+i, 0x0015);
5b79dc93 548
67c0bb2f 549 tx->commandlen = i;
5b79dc93 550 tx->lock = 0;
5b79dc93 551 return aim_tx_enqueue(sess, tx);
e6b05d80 552}
553
554
555/*
556 * Send service redirect. (Non-Client)
557 */
78b3fb13 558faim_export unsigned long aim_sendredirect(struct aim_session_t *sess,
559 struct aim_conn_t *conn,
560 unsigned short servid,
561 char *ip,
562 char *cookie)
e6b05d80 563{
5b79dc93 564 struct command_tx_struct *tx;
e6b05d80 565 struct aim_tlvlist_t *tlvlist = NULL;
566 int i = 0;
567
646c6b52 568 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152)))
5b79dc93 569 return -1;
570
571 tx->lock = 1;
e6b05d80 572
13ebc4c4 573 i += aim_putsnac(tx->data+i, 0x0001, 0x0005, 0x0000, 0x00000000);
e6b05d80 574
575 aim_addtlvtochain16(&tlvlist, 0x000d, servid);
576 aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip));
577 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
578
5b79dc93 579 tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i;
e6b05d80 580 aim_freetlvchain(&tlvlist);
581
5b79dc93 582 tx->lock = 0;
583 return aim_tx_enqueue(sess, tx);
e6b05d80 584}
This page took 0.416178 seconds and 5 git commands to generate.