]> andersk Git - libfaim.git/blame - src/login.c
- Mon Mar 5 01:19:48 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
9de3ca7e 140 */
78b3fb13 141faim_export int aim_send_login (struct aim_session_t *sess,
142 struct aim_conn_t *conn,
143 char *sn, char *password,
144 struct client_info_s *clientinfo,
145 char *key)
9de3ca7e 146{
9de3ca7e 147 int curbyte=0;
5b79dc93 148 struct command_tx_struct *newpacket;
9de3ca7e 149
01b59e1e 150 if (!clientinfo || !sn || !password)
151 return -1;
152
646c6b52 153 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152)))
5b79dc93 154 return -1;
9de3ca7e 155
5b79dc93 156 newpacket->lock = 1;
01b59e1e 157
22517493 158 newpacket->hdr.oscar.type = (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)?0x02:0x01;
b5bc2a8c 159
22517493 160 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)
5daacaa3 161 curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0002, 0x0000, 0x00010000);
162 else {
163 curbyte = aimutil_put16(newpacket->data, 0x0000);
164 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
165 }
b5bc2a8c 166
5daacaa3 167 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
9de3ca7e 168
22517493 169 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) {
5daacaa3 170 md5_byte_t digest[16];
171
172 aim_encode_password_md5(password, key, digest);
173 curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0025, 16, (char *)digest);
174 } else {
175 char *password_encoded;
176
177 password_encoded = (char *) malloc(strlen(password));
178 aim_encode_password(password, password_encoded);
179 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0002, strlen(password), password_encoded);
180 free(password_encoded);
181 }
182
13ebc4c4 183 /* XXX is clientstring required by oscar? */
184 if (strlen(clientinfo->clientstring))
185 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring);
186
22517493 187 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) {
5daacaa3 188 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, (unsigned short)clientinfo->major2);
189 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, (unsigned short)clientinfo->major);
190 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, (unsigned short)clientinfo->minor);
191 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, (unsigned short)clientinfo->minor2);
192 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, (unsigned short)clientinfo->build);
b5bc2a8c 193
5daacaa3 194 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown);
195 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015);
ee49b735 196 curbyte += aim_puttlv_8(newpacket->data+curbyte, 0x004a, 0x00);
5daacaa3 197 } else {
355982c5 198 /* Use very specific version numbers, to further indicate the hack. */
5daacaa3 199 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, 0x010a);
200 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, 0x0004);
201 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, 0x003c);
202 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001);
203 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, 0x0cce);
204 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055);
205 }
9de3ca7e 206
13ebc4c4 207 if (strlen(clientinfo->country))
208 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, strlen(clientinfo->country), clientinfo->country);
209 else
210 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, 2, "us");
211
212 if (strlen(clientinfo->lang))
213 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, strlen(clientinfo->lang), clientinfo->lang);
214 else
215 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, 2, "en");
216
217 newpacket->commandlen = curbyte;
9de3ca7e 218
5b79dc93 219 newpacket->lock = 0;
220 return aim_tx_enqueue(sess, newpacket);
9de3ca7e 221}
9de3ca7e 222
b5bc2a8c 223static int aim_encode_password_md5(const char *password, const char *key, md5_byte_t *digest)
224{
225 md5_state_t state;
226
227 md5_init(&state);
228 md5_append(&state, (const md5_byte_t *)key, strlen(key));
229 md5_append(&state, (const md5_byte_t *)password, strlen(password));
230 md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING));
231 md5_finish(&state, (md5_byte_t *)digest);
232
233 return 0;
234}
235
5daacaa3 236/**
237 * aim_encode_password - Encode a password using old XOR method
238 * @password: incoming password
239 * @encoded: buffer to put encoded password
9de3ca7e 240 *
241 * This takes a const pointer to a (null terminated) string
242 * containing the unencoded password. It also gets passed
243 * an already allocated buffer to store the encoded password.
244 * This buffer should be the exact length of the password without
5daacaa3 245 * the null. The encoded password buffer /is not %NULL terminated/.
9de3ca7e 246 *
247 * The encoding_table seems to be a fixed set of values. We'll
248 * hope it doesn't change over time!
249 *
5daacaa3 250 * This is only used for the XOR method, not the better MD5 method.
b5bc2a8c 251 *
9de3ca7e 252 */
b5bc2a8c 253static int aim_encode_password(const char *password, unsigned char *encoded)
9de3ca7e 254{
255 u_char encoding_table[] = {
b69540e3 256#if 0 /* old v1 table */
9de3ca7e 257 0xf3, 0xb3, 0x6c, 0x99,
258 0x95, 0x3f, 0xac, 0xb6,
259 0xc5, 0xfa, 0x6b, 0x63,
260 0x69, 0x6c, 0xc3, 0x9f
b69540e3 261#else /* v2.1 table, also works for ICQ */
5e02cf44 262 0xf3, 0x26, 0x81, 0xc4,
b69540e3 263 0x39, 0x86, 0xdb, 0x92,
264 0x71, 0xa3, 0xb9, 0xe6,
265 0x53, 0x7a, 0x95, 0x7c
266#endif
5e02cf44 267 };
268
269 int i;
b69540e3 270
5e02cf44 271 for (i = 0; i < strlen(password); i++)
272 encoded[i] = (password[i] ^ encoding_table[i]);
273
274 return 0;
275}
276
01b59e1e 277/*
278 * This is sent back as a general response to the login command.
279 * It can be either an error or a success, depending on the
280 * precense of certain TLVs.
281 *
355982c5 282 * The client should check the value passed as errorcode. If
01b59e1e 283 * its nonzero, there was an error.
284 *
285 */
78b3fb13 286faim_internal int aim_authparse(struct aim_session_t *sess,
287 struct command_rx_struct *command)
01b59e1e 288{
289 struct aim_tlvlist_t *tlvlist;
290 int ret = 1;
01b59e1e 291 rxcallback_t userfunc = NULL;
355982c5 292 char *sn = NULL, *bosip = NULL, *errurl = NULL, *email = NULL;
293 unsigned char *cookie = NULL;
294 int errorcode = 0, regstatus = 0;
89bce177 295 int latestbuild = 0, latestbetabuild = 0;
296 char *latestrelease = NULL, *latestbeta = NULL;
297 char *latestreleaseurl = NULL, *latestbetaurl = NULL;
298 char *latestreleaseinfo = NULL, *latestbetainfo = NULL;
01b59e1e 299
300 /*
301 * Read block of TLVs. All further data is derived
302 * from what is parsed here.
b5bc2a8c 303 *
304 * For SNAC login, there's a 17/3 SNAC header in front.
305 *
01b59e1e 306 */
22517493 307 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)
5daacaa3 308 tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10);
309 else
310 tlvlist = aim_readtlvchain(command->data, command->commandlen);
b5bc2a8c 311
01b59e1e 312 /*
313 * No matter what, we should have a screen name.
314 */
355982c5 315 memset(sess->sn, 0, sizeof(sess->sn));
316 if (aim_gettlv(tlvlist, 0x0001, 1)) {
317 sn = aim_gettlv_str(tlvlist, 0x0001, 1);
318 strncpy(sess->sn, sn, sizeof(sess->sn));
319 }
b13c9e13 320
01b59e1e 321 /*
322 * Check for an error code. If so, we should also
323 * have an error url.
324 */
355982c5 325 if (aim_gettlv(tlvlist, 0x0008, 1))
326 errorcode = aim_gettlv16(tlvlist, 0x0008, 1);
327 if (aim_gettlv(tlvlist, 0x0004, 1))
328 errurl = aim_gettlv_str(tlvlist, 0x0004, 1);
329
330 /*
331 * BOS server address.
01b59e1e 332 */
355982c5 333 if (aim_gettlv(tlvlist, 0x0005, 1))
334 bosip = aim_gettlv_str(tlvlist, 0x0005, 1);
335
336 /*
337 * Authorization cookie.
338 */
339 if (aim_gettlv(tlvlist, 0x0006, 1)) {
5e02cf44 340 struct aim_tlv_t *tmptlv;
341
5e02cf44 342 tmptlv = aim_gettlv(tlvlist, 0x0006, 1);
355982c5 343
344 if ((cookie = malloc(tmptlv->length)))
345 memcpy(cookie, tmptlv->value, tmptlv->length);
5e02cf44 346 }
01b59e1e 347
355982c5 348 /*
349 * The email address attached to this account
350 * Not available for ICQ logins.
351 */
352 if (aim_gettlv(tlvlist, 0x0011, 1))
353 email = aim_gettlv_str(tlvlist, 0x0011, 1);
354
355 /*
356 * The registration status. (Not real sure what it means.)
357 * Not available for ICQ logins.
d6c9fcf0 358 *
359 * 1 = No disclosure
360 * 2 = Limited disclosure
361 * 3 = Full disclosure
362 *
363 * This has to do with whether your email address is available
364 * to other users or not. AFAIK, this feature is no longer used.
365 *
355982c5 366 */
367 if (aim_gettlv(tlvlist, 0x0013, 1))
368 regstatus = aim_gettlv16(tlvlist, 0x0013, 1);
b5bc2a8c 369
89bce177 370 if (aim_gettlv(tlvlist, 0x0040, 1))
371 latestbetabuild = aim_gettlv32(tlvlist, 0x0040, 1);
372 if (aim_gettlv(tlvlist, 0x0041, 1))
373 latestbetaurl = aim_gettlv_str(tlvlist, 0x0041, 1);
374 if (aim_gettlv(tlvlist, 0x0042, 1))
375 latestbetainfo = aim_gettlv_str(tlvlist, 0x0042, 1);
376 if (aim_gettlv(tlvlist, 0x0043, 1))
377 latestbeta = aim_gettlv_str(tlvlist, 0x0043, 1);
378 if (aim_gettlv(tlvlist, 0x0048, 1))
379 ; /* no idea what this is */
380
381 if (aim_gettlv(tlvlist, 0x0044, 1))
382 latestbuild = aim_gettlv32(tlvlist, 0x0044, 1);
383 if (aim_gettlv(tlvlist, 0x0045, 1))
384 latestreleaseurl = aim_gettlv_str(tlvlist, 0x0045, 1);
385 if (aim_gettlv(tlvlist, 0x0046, 1))
386 latestreleaseinfo = aim_gettlv_str(tlvlist, 0x0046, 1);
387 if (aim_gettlv(tlvlist, 0x0047, 1))
388 latestrelease = aim_gettlv_str(tlvlist, 0x0047, 1);
389 if (aim_gettlv(tlvlist, 0x0049, 1))
390 ; /* no idea what this is */
391
01b59e1e 392
646c6b52 393 if ((userfunc = aim_callhandler(sess, command->conn, 0x0017, 0x0003)))
89bce177 394 ret = userfunc(sess, command, sn, errorcode, errurl, regstatus, email, bosip, cookie, latestrelease, latestbuild, latestreleaseurl, latestreleaseinfo, latestbeta, latestbetabuild, latestbetaurl, latestbetainfo);
01b59e1e 395
355982c5 396
397 if (sn)
398 free(sn);
399 if (bosip)
400 free(bosip);
401 if (errurl)
402 free(errurl);
403 if (email)
404 free(email);
405 if (cookie)
406 free(cookie);
89bce177 407 if (latestrelease)
408 free(latestrelease);
409 if (latestreleaseurl)
410 free(latestreleaseurl);
411 if (latestbeta)
412 free(latestbeta);
413 if (latestbetaurl)
414 free(latestbetaurl);
415 if (latestreleaseinfo)
416 free(latestreleaseinfo);
417 if (latestbetainfo)
418 free(latestbetainfo);
419
355982c5 420 aim_freetlvchain(&tlvlist);
01b59e1e 421
422 return ret;
423}
e6b05d80 424
b5bc2a8c 425/*
426 * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed
427 * by only its length in a two byte word.
428 *
429 * Calls the client, which should then use the value to call aim_send_login.
430 *
431 */
78b3fb13 432faim_internal int aim_authkeyparse(struct aim_session_t *sess, struct command_rx_struct *command)
b5bc2a8c 433{
434 unsigned char *key;
435 int keylen;
436 int ret = 1;
437 rxcallback_t userfunc;
438
439 keylen = aimutil_get16(command->data+10);
98c88242 440 if (!(key = malloc(keylen+1)))
441 return ret;
b5bc2a8c 442 memcpy(key, command->data+12, keylen);
443 key[keylen] = '\0';
444
646c6b52 445 if ((userfunc = aim_callhandler(sess, command->conn, 0x0017, 0x0007)))
78b3fb13 446 ret = userfunc(sess, command, (char *)key);
b5bc2a8c 447
448 free(key);
449
450 return ret;
451}
452
e6b05d80 453/*
454 * Generate an authorization response.
455 *
456 * You probably don't want this unless you're writing an AIM server.
457 *
458 */
78b3fb13 459faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess,
460 struct aim_conn_t *conn,
355982c5 461 char *sn, int errorcode,
462 char *errorurl, char *bosip,
78b3fb13 463 char *cookie, char *email,
464 int regstatus)
e6b05d80 465{
5b79dc93 466 struct command_tx_struct *tx;
e6b05d80 467 struct aim_tlvlist_t *tlvlist = NULL;
468
646c6b52 469 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0004, 1152)))
5b79dc93 470 return -1;
e6b05d80 471
5b79dc93 472 tx->lock = 1;
e6b05d80 473
474 if (sn)
475 aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn));
476 else
355982c5 477 aim_addtlvtochain_str(&tlvlist, 0x0001, sess->sn, strlen(sess->sn));
e6b05d80 478
355982c5 479 if (errorcode) {
480 aim_addtlvtochain16(&tlvlist, 0x0008, errorcode);
481 aim_addtlvtochain_str(&tlvlist, 0x0004, errorurl, strlen(errorurl));
e6b05d80 482 } else {
483 aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip));
484 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
485 aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email));
5ac21963 486 aim_addtlvtochain16(&tlvlist, 0x0013, (unsigned short)regstatus);
e6b05d80 487 }
488
5b79dc93 489 tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist);
490 tx->lock = 0;
355982c5 491
5b79dc93 492 return aim_tx_enqueue(sess, tx);
e6b05d80 493}
494
495/*
496 * Generate a random cookie. (Non-client use only)
497 */
78b3fb13 498faim_export int aim_gencookie(unsigned char *buf)
e6b05d80 499{
500 int i;
501
502 srand(time(NULL));
503
504 for (i=0; i < AIM_COOKIELEN; i++)
505 buf[i] = 1+(int) (256.0*rand()/(RAND_MAX+0.0));
506
507 return i;
508}
509
510/*
511 * Send Server Ready. (Non-client)
512 */
78b3fb13 513faim_export int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn)
e6b05d80 514{
5b79dc93 515 struct command_tx_struct *tx;
e6b05d80 516 int i = 0;
517
646c6b52 518 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+0x22)))
5b79dc93 519 return -1;
e6b05d80 520
5b79dc93 521 tx->lock = 1;
e6b05d80 522
67c0bb2f 523 i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++);
5b79dc93 524
525 i += aimutil_put16(tx->data+i, 0x0001);
526 i += aimutil_put16(tx->data+i, 0x0002);
527 i += aimutil_put16(tx->data+i, 0x0003);
528 i += aimutil_put16(tx->data+i, 0x0004);
529 i += aimutil_put16(tx->data+i, 0x0006);
530 i += aimutil_put16(tx->data+i, 0x0008);
531 i += aimutil_put16(tx->data+i, 0x0009);
532 i += aimutil_put16(tx->data+i, 0x000a);
533 i += aimutil_put16(tx->data+i, 0x000b);
534 i += aimutil_put16(tx->data+i, 0x000c);
67c0bb2f 535 i += aimutil_put16(tx->data+i, 0x0013);
536 i += aimutil_put16(tx->data+i, 0x0015);
5b79dc93 537
67c0bb2f 538 tx->commandlen = i;
5b79dc93 539 tx->lock = 0;
5b79dc93 540 return aim_tx_enqueue(sess, tx);
e6b05d80 541}
542
543
544/*
545 * Send service redirect. (Non-Client)
546 */
78b3fb13 547faim_export unsigned long aim_sendredirect(struct aim_session_t *sess,
548 struct aim_conn_t *conn,
549 unsigned short servid,
550 char *ip,
551 char *cookie)
e6b05d80 552{
5b79dc93 553 struct command_tx_struct *tx;
e6b05d80 554 struct aim_tlvlist_t *tlvlist = NULL;
555 int i = 0;
556
646c6b52 557 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152)))
5b79dc93 558 return -1;
559
560 tx->lock = 1;
e6b05d80 561
13ebc4c4 562 i += aim_putsnac(tx->data+i, 0x0001, 0x0005, 0x0000, 0x00000000);
e6b05d80 563
564 aim_addtlvtochain16(&tlvlist, 0x000d, servid);
565 aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip));
566 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
567
5b79dc93 568 tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i;
e6b05d80 569 aim_freetlvchain(&tlvlist);
570
5b79dc93 571 tx->lock = 0;
572 return aim_tx_enqueue(sess, tx);
e6b05d80 573}
This page took 0.162409 seconds and 5 git commands to generate.