]>
Commit | Line | Data |
---|---|---|
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 | ||
12 | static int aim_encode_password_md5(const char *password, const char *key, md5_byte_t *digest); | |
5daacaa3 | 13 | static 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 | 22 | faim_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 | 49 | faim_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 | ||
103 | sess->snaclogin = 0; | |
104 | return 0; | |
105 | } | |
106 | ||
107 | sess->snaclogin = 1; | |
108 | ||
109 | aim_sendconnack(sess, conn); | |
110 | ||
b69540e3 | 111 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+2+2+strlen(sn)))) |
5b79dc93 | 112 | return -1; |
01b59e1e | 113 | |
5b79dc93 | 114 | newpacket->lock = 1; |
01b59e1e | 115 | |
5daacaa3 | 116 | curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0006, 0x0000, 0x00010000); |
5b79dc93 | 117 | curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn); |
01b59e1e | 118 | |
5daacaa3 | 119 | newpacket->commandlen = curbyte; |
5b79dc93 | 120 | newpacket->lock = 0; |
5daacaa3 | 121 | |
5b79dc93 | 122 | return aim_tx_enqueue(sess, newpacket); |
01b59e1e | 123 | } |
01b59e1e | 124 | |
9de3ca7e | 125 | /* |
24286d93 | 126 | * send_login(int socket, char *sn, char *password) |
9de3ca7e | 127 | * |
128 | * This is the initial login request packet. | |
129 | * | |
130 | * The password is encoded before transmition, as per | |
131 | * encode_password(). See that function for their | |
132 | * stupid method of doing it. | |
133 | * | |
9de3ca7e | 134 | */ |
78b3fb13 | 135 | faim_export int aim_send_login (struct aim_session_t *sess, |
136 | struct aim_conn_t *conn, | |
137 | char *sn, char *password, | |
138 | struct client_info_s *clientinfo, | |
139 | char *key) | |
9de3ca7e | 140 | { |
9de3ca7e | 141 | int curbyte=0; |
5b79dc93 | 142 | struct command_tx_struct *newpacket; |
9de3ca7e | 143 | |
01b59e1e | 144 | if (!clientinfo || !sn || !password) |
145 | return -1; | |
146 | ||
b69540e3 | 147 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152))) |
5b79dc93 | 148 | return -1; |
9de3ca7e | 149 | |
5b79dc93 | 150 | newpacket->lock = 1; |
01b59e1e | 151 | |
5daacaa3 | 152 | newpacket->hdr.oscar.type = sess->snaclogin?0x02:0x01; |
b5bc2a8c | 153 | |
5daacaa3 | 154 | if (sess->snaclogin) |
155 | curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0002, 0x0000, 0x00010000); | |
156 | else { | |
157 | curbyte = aimutil_put16(newpacket->data, 0x0000); | |
158 | curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); | |
159 | } | |
b5bc2a8c | 160 | |
5daacaa3 | 161 | curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn); |
9de3ca7e | 162 | |
5daacaa3 | 163 | if (sess->snaclogin) { |
164 | md5_byte_t digest[16]; | |
165 | ||
166 | aim_encode_password_md5(password, key, digest); | |
167 | curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0025, 16, (char *)digest); | |
168 | } else { | |
169 | char *password_encoded; | |
170 | ||
171 | password_encoded = (char *) malloc(strlen(password)); | |
172 | aim_encode_password(password, password_encoded); | |
173 | curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0002, strlen(password), password_encoded); | |
174 | free(password_encoded); | |
175 | } | |
176 | ||
13ebc4c4 | 177 | /* XXX is clientstring required by oscar? */ |
178 | if (strlen(clientinfo->clientstring)) | |
179 | curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring); | |
180 | ||
5daacaa3 | 181 | if (sess->snaclogin) { |
182 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, (unsigned short)clientinfo->major2); | |
183 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, (unsigned short)clientinfo->major); | |
184 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, (unsigned short)clientinfo->minor); | |
185 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, (unsigned short)clientinfo->minor2); | |
186 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, (unsigned short)clientinfo->build); | |
b5bc2a8c | 187 | |
5daacaa3 | 188 | curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown); |
189 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015); | |
190 | } else { | |
191 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, 0x010a); | |
192 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, 0x0004); | |
193 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, 0x003c); | |
194 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001); | |
195 | curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, 0x0cce); | |
196 | curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055); | |
197 | } | |
9de3ca7e | 198 | |
13ebc4c4 | 199 | if (strlen(clientinfo->country)) |
200 | curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, strlen(clientinfo->country), clientinfo->country); | |
201 | else | |
202 | curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, 2, "us"); | |
203 | ||
204 | if (strlen(clientinfo->lang)) | |
205 | curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, strlen(clientinfo->lang), clientinfo->lang); | |
206 | else | |
207 | curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, 2, "en"); | |
208 | ||
209 | newpacket->commandlen = curbyte; | |
9de3ca7e | 210 | |
5b79dc93 | 211 | newpacket->lock = 0; |
212 | return aim_tx_enqueue(sess, newpacket); | |
9de3ca7e | 213 | } |
9de3ca7e | 214 | |
b5bc2a8c | 215 | static int aim_encode_password_md5(const char *password, const char *key, md5_byte_t *digest) |
216 | { | |
217 | md5_state_t state; | |
218 | ||
219 | md5_init(&state); | |
220 | md5_append(&state, (const md5_byte_t *)key, strlen(key)); | |
221 | md5_append(&state, (const md5_byte_t *)password, strlen(password)); | |
222 | md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
223 | md5_finish(&state, (md5_byte_t *)digest); | |
224 | ||
225 | return 0; | |
226 | } | |
227 | ||
5daacaa3 | 228 | /** |
229 | * aim_encode_password - Encode a password using old XOR method | |
230 | * @password: incoming password | |
231 | * @encoded: buffer to put encoded password | |
9de3ca7e | 232 | * |
233 | * This takes a const pointer to a (null terminated) string | |
234 | * containing the unencoded password. It also gets passed | |
235 | * an already allocated buffer to store the encoded password. | |
236 | * This buffer should be the exact length of the password without | |
5daacaa3 | 237 | * the null. The encoded password buffer /is not %NULL terminated/. |
9de3ca7e | 238 | * |
239 | * The encoding_table seems to be a fixed set of values. We'll | |
240 | * hope it doesn't change over time! | |
241 | * | |
5daacaa3 | 242 | * This is only used for the XOR method, not the better MD5 method. |
b5bc2a8c | 243 | * |
9de3ca7e | 244 | */ |
b5bc2a8c | 245 | static int aim_encode_password(const char *password, unsigned char *encoded) |
9de3ca7e | 246 | { |
247 | u_char encoding_table[] = { | |
b69540e3 | 248 | #if 0 /* old v1 table */ |
9de3ca7e | 249 | 0xf3, 0xb3, 0x6c, 0x99, |
250 | 0x95, 0x3f, 0xac, 0xb6, | |
251 | 0xc5, 0xfa, 0x6b, 0x63, | |
252 | 0x69, 0x6c, 0xc3, 0x9f | |
b69540e3 | 253 | #else /* v2.1 table, also works for ICQ */ |
5e02cf44 | 254 | 0xf3, 0x26, 0x81, 0xc4, |
b69540e3 | 255 | 0x39, 0x86, 0xdb, 0x92, |
256 | 0x71, 0xa3, 0xb9, 0xe6, | |
257 | 0x53, 0x7a, 0x95, 0x7c | |
258 | #endif | |
5e02cf44 | 259 | }; |
260 | ||
261 | int i; | |
b69540e3 | 262 | |
5e02cf44 | 263 | for (i = 0; i < strlen(password); i++) |
264 | encoded[i] = (password[i] ^ encoding_table[i]); | |
265 | ||
266 | return 0; | |
267 | } | |
268 | ||
01b59e1e | 269 | /* |
270 | * This is sent back as a general response to the login command. | |
271 | * It can be either an error or a success, depending on the | |
272 | * precense of certain TLVs. | |
273 | * | |
274 | * The client should check the value of logininfo->errorcode. If | |
275 | * its nonzero, there was an error. | |
276 | * | |
277 | */ | |
78b3fb13 | 278 | faim_internal int aim_authparse(struct aim_session_t *sess, |
279 | struct command_rx_struct *command) | |
01b59e1e | 280 | { |
281 | struct aim_tlvlist_t *tlvlist; | |
282 | int ret = 1; | |
283 | char *sn; | |
284 | rxcallback_t userfunc = NULL; | |
285 | ||
286 | memset(&sess->logininfo, 0x00, sizeof(sess->logininfo)); | |
287 | ||
288 | /* | |
289 | * Read block of TLVs. All further data is derived | |
290 | * from what is parsed here. | |
b5bc2a8c | 291 | * |
292 | * For SNAC login, there's a 17/3 SNAC header in front. | |
293 | * | |
01b59e1e | 294 | */ |
5daacaa3 | 295 | if (sess->snaclogin) |
296 | tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10); | |
297 | else | |
298 | tlvlist = aim_readtlvchain(command->data, command->commandlen); | |
b5bc2a8c | 299 | |
01b59e1e | 300 | /* |
301 | * No matter what, we should have a screen name. | |
302 | */ | |
303 | sn = aim_gettlv_str(tlvlist, 0x0001, 1); | |
b13c9e13 | 304 | strncpy(sess->logininfo.screen_name, sn, strlen(sn)); |
305 | free(sn); | |
306 | ||
01b59e1e | 307 | /* |
308 | * Check for an error code. If so, we should also | |
309 | * have an error url. | |
310 | */ | |
5e02cf44 | 311 | if (aim_gettlv(tlvlist, 0x0008, 1)) { |
312 | struct aim_tlv_t *errtlv; | |
313 | errtlv = aim_gettlv(tlvlist, 0x0008, 1); | |
314 | sess->logininfo.errorcode = aimutil_get16(errtlv->value); | |
315 | sess->logininfo.errorurl = aim_gettlv_str(tlvlist, 0x0004, 1); | |
316 | } | |
01b59e1e | 317 | /* |
318 | * If we have both an IP number (0x0005) and a cookie (0x0006), | |
319 | * then the login was successful. | |
320 | */ | |
b69540e3 | 321 | else if (aim_gettlv(tlvlist, 0x0005, 1) && aim_gettlv(tlvlist, 0x0006, 1) |
322 | /*aim_gettlv(tlvlist, 0x0006, 1)->length*/) { | |
5e02cf44 | 323 | struct aim_tlv_t *tmptlv; |
324 | ||
325 | /* | |
326 | * IP address of BOS server. | |
327 | */ | |
328 | sess->logininfo.BOSIP = aim_gettlv_str(tlvlist, 0x0005, 1); | |
329 | ||
330 | /* | |
331 | * Authorization Cookie | |
332 | */ | |
333 | tmptlv = aim_gettlv(tlvlist, 0x0006, 1); | |
334 | memcpy(sess->logininfo.cookie, tmptlv->value, AIM_COOKIELEN); | |
335 | ||
336 | /* | |
337 | * The email address attached to this account | |
338 | * Not available for ICQ logins. | |
339 | */ | |
340 | if (aim_gettlv(tlvlist, 0x0011, 1)) | |
01b59e1e | 341 | sess->logininfo.email = aim_gettlv_str(tlvlist, 0x0011, 1); |
5e02cf44 | 342 | |
343 | /* | |
344 | * The registration status. (Not real sure what it means.) | |
345 | * Not available for ICQ logins. | |
346 | */ | |
347 | if ((tmptlv = aim_gettlv(tlvlist, 0x0013, 1))) | |
01b59e1e | 348 | sess->logininfo.regstatus = aimutil_get16(tmptlv->value); |
349 | ||
5e02cf44 | 350 | } |
01b59e1e | 351 | |
01b59e1e | 352 | userfunc = aim_callhandler(command->conn, 0x0017, 0x0003); |
b5bc2a8c | 353 | |
01b59e1e | 354 | if (userfunc) |
355 | ret = userfunc(sess, command); | |
356 | ||
357 | aim_freetlvchain(&tlvlist); | |
358 | ||
dad2e696 | 359 | if (sess->logininfo.BOSIP) { |
91c55d47 | 360 | free(sess->logininfo.BOSIP); |
dad2e696 | 361 | sess->logininfo.BOSIP = NULL; |
362 | } | |
363 | if (sess->logininfo.email) { | |
91c55d47 | 364 | free(sess->logininfo.email); |
dad2e696 | 365 | sess->logininfo.email = NULL; |
366 | } | |
367 | if (sess->logininfo.errorurl) { | |
91c55d47 | 368 | free(sess->logininfo.errorurl); |
dad2e696 | 369 | sess->logininfo.errorurl = NULL; |
370 | } | |
01b59e1e | 371 | |
372 | return ret; | |
373 | } | |
e6b05d80 | 374 | |
b5bc2a8c | 375 | /* |
376 | * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed | |
377 | * by only its length in a two byte word. | |
378 | * | |
379 | * Calls the client, which should then use the value to call aim_send_login. | |
380 | * | |
381 | */ | |
78b3fb13 | 382 | faim_internal int aim_authkeyparse(struct aim_session_t *sess, struct command_rx_struct *command) |
b5bc2a8c | 383 | { |
384 | unsigned char *key; | |
385 | int keylen; | |
386 | int ret = 1; | |
387 | rxcallback_t userfunc; | |
388 | ||
389 | keylen = aimutil_get16(command->data+10); | |
98c88242 | 390 | if (!(key = malloc(keylen+1))) |
391 | return ret; | |
b5bc2a8c | 392 | memcpy(key, command->data+12, keylen); |
393 | key[keylen] = '\0'; | |
394 | ||
395 | if ((userfunc = aim_callhandler(command->conn, 0x0017, 0x0007))) | |
78b3fb13 | 396 | ret = userfunc(sess, command, (char *)key); |
b5bc2a8c | 397 | |
398 | free(key); | |
399 | ||
400 | return ret; | |
401 | } | |
402 | ||
e6b05d80 | 403 | /* |
404 | * Generate an authorization response. | |
405 | * | |
406 | * You probably don't want this unless you're writing an AIM server. | |
407 | * | |
408 | */ | |
78b3fb13 | 409 | faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess, |
410 | struct aim_conn_t *conn, | |
411 | char *sn, char *bosip, | |
412 | char *cookie, char *email, | |
413 | int regstatus) | |
e6b05d80 | 414 | { |
5b79dc93 | 415 | struct command_tx_struct *tx; |
e6b05d80 | 416 | struct aim_tlvlist_t *tlvlist = NULL; |
417 | ||
b69540e3 | 418 | if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0004, conn, 1152))) |
5b79dc93 | 419 | return -1; |
e6b05d80 | 420 | |
5b79dc93 | 421 | tx->lock = 1; |
e6b05d80 | 422 | |
423 | if (sn) | |
424 | aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn)); | |
425 | else | |
426 | aim_addtlvtochain_str(&tlvlist, 0x0001, sess->logininfo.screen_name, strlen(sess->logininfo.screen_name)); | |
427 | ||
428 | if (sess->logininfo.errorcode) { | |
429 | aim_addtlvtochain16(&tlvlist, 0x0008, sess->logininfo.errorcode); | |
430 | aim_addtlvtochain_str(&tlvlist, 0x0004, sess->logininfo.errorurl, strlen(sess->logininfo.errorurl)); | |
431 | } else { | |
432 | aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip)); | |
433 | aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN); | |
434 | aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email)); | |
5ac21963 | 435 | aim_addtlvtochain16(&tlvlist, 0x0013, (unsigned short)regstatus); |
e6b05d80 | 436 | } |
437 | ||
5b79dc93 | 438 | tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist); |
439 | tx->lock = 0; | |
440 | return aim_tx_enqueue(sess, tx); | |
e6b05d80 | 441 | } |
442 | ||
443 | /* | |
444 | * Generate a random cookie. (Non-client use only) | |
445 | */ | |
78b3fb13 | 446 | faim_export int aim_gencookie(unsigned char *buf) |
e6b05d80 | 447 | { |
448 | int i; | |
449 | ||
450 | srand(time(NULL)); | |
451 | ||
452 | for (i=0; i < AIM_COOKIELEN; i++) | |
453 | buf[i] = 1+(int) (256.0*rand()/(RAND_MAX+0.0)); | |
454 | ||
455 | return i; | |
456 | } | |
457 | ||
458 | /* | |
459 | * Send Server Ready. (Non-client) | |
460 | */ | |
78b3fb13 | 461 | faim_export int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn) |
e6b05d80 | 462 | { |
5b79dc93 | 463 | struct command_tx_struct *tx; |
e6b05d80 | 464 | int i = 0; |
465 | ||
b69540e3 | 466 | if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+0x22))) |
5b79dc93 | 467 | return -1; |
e6b05d80 | 468 | |
5b79dc93 | 469 | tx->lock = 1; |
e6b05d80 | 470 | |
67c0bb2f | 471 | i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++); |
5b79dc93 | 472 | |
473 | i += aimutil_put16(tx->data+i, 0x0001); | |
474 | i += aimutil_put16(tx->data+i, 0x0002); | |
475 | i += aimutil_put16(tx->data+i, 0x0003); | |
476 | i += aimutil_put16(tx->data+i, 0x0004); | |
477 | i += aimutil_put16(tx->data+i, 0x0006); | |
478 | i += aimutil_put16(tx->data+i, 0x0008); | |
479 | i += aimutil_put16(tx->data+i, 0x0009); | |
480 | i += aimutil_put16(tx->data+i, 0x000a); | |
481 | i += aimutil_put16(tx->data+i, 0x000b); | |
482 | i += aimutil_put16(tx->data+i, 0x000c); | |
67c0bb2f | 483 | i += aimutil_put16(tx->data+i, 0x0013); |
484 | i += aimutil_put16(tx->data+i, 0x0015); | |
5b79dc93 | 485 | |
67c0bb2f | 486 | tx->commandlen = i; |
5b79dc93 | 487 | tx->lock = 0; |
5b79dc93 | 488 | return aim_tx_enqueue(sess, tx); |
e6b05d80 | 489 | } |
490 | ||
491 | ||
492 | /* | |
493 | * Send service redirect. (Non-Client) | |
494 | */ | |
78b3fb13 | 495 | faim_export unsigned long aim_sendredirect(struct aim_session_t *sess, |
496 | struct aim_conn_t *conn, | |
497 | unsigned short servid, | |
498 | char *ip, | |
499 | char *cookie) | |
e6b05d80 | 500 | { |
5b79dc93 | 501 | struct command_tx_struct *tx; |
e6b05d80 | 502 | struct aim_tlvlist_t *tlvlist = NULL; |
503 | int i = 0; | |
504 | ||
b69540e3 | 505 | if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152))) |
5b79dc93 | 506 | return -1; |
507 | ||
508 | tx->lock = 1; | |
e6b05d80 | 509 | |
13ebc4c4 | 510 | i += aim_putsnac(tx->data+i, 0x0001, 0x0005, 0x0000, 0x00000000); |
e6b05d80 | 511 | |
512 | aim_addtlvtochain16(&tlvlist, 0x000d, servid); | |
513 | aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip)); | |
514 | aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN); | |
515 | ||
5b79dc93 | 516 | tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i; |
e6b05d80 | 517 | aim_freetlvchain(&tlvlist); |
518 | ||
5b79dc93 | 519 | tx->lock = 0; |
520 | return aim_tx_enqueue(sess, tx); | |
e6b05d80 | 521 | } |