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