Mercurial > pidgin
comparison src/protocols/oscar/family_auth.c @ 13592:6519aeb66b31
[gaim-migrate @ 15978]
Holy cow this is crazy.
34 files changed, 5760 insertions(+), 8517 deletions(-)
* Non-blocking I/O for all of oscar. That includes normal FLAP
connections as well as file transfers and direct IM.
* Kick-ass file transfer and direct IM. Either party can request
the connection. Gaim will try both the "public" IP and the
"client" IP. It'll fall back to transferring through a proxy
if that fails. Should be relatively few memleaks (I didn't
have a lot of confidence in the non-memleakiness of the old
code). And the code is reasonably generic, so it shouldn't
be too much work to add voice chat. This might still be a
LITTLE buggy, but it shouldn't be too bad. If anything, file
transfer will be more buggy than direct IM. And sending a
file will be more buggy than receiving a file. Bug reports
with a series of steps to reproduce are welcome.
* I merged OscarData and aim_session_t
* Somewhere between 50 and 100 hours of work.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 07 Apr 2006 05:10:56 +0000 |
parents | 87a7c3077c19 |
children | a07dcc2c01bd |
comparison
equal
deleted
inserted
replaced
13591:dcfda39ad547 | 13592:6519aeb66b31 |
---|---|
50 * This is only used for the XOR method, not the better MD5 method. | 50 * This is only used for the XOR method, not the better MD5 method. |
51 * | 51 * |
52 * @param password Incoming password. | 52 * @param password Incoming password. |
53 * @param encoded Buffer to put encoded password. | 53 * @param encoded Buffer to put encoded password. |
54 */ | 54 */ |
55 static int aim_encode_password(const char *password, guint8 *encoded) | 55 static int |
56 aim_encode_password(const char *password, guint8 *encoded) | |
56 { | 57 { |
57 guint8 encoding_table[] = { | 58 guint8 encoding_table[] = { |
58 #if 0 /* old v1 table */ | 59 #if 0 /* old v1 table */ |
59 0xf3, 0xb3, 0x6c, 0x99, | 60 0xf3, 0xb3, 0x6c, 0x99, |
60 0x95, 0x3f, 0xac, 0xb6, | 61 0x95, 0x3f, 0xac, 0xb6, |
75 return 0; | 76 return 0; |
76 } | 77 } |
77 #endif | 78 #endif |
78 | 79 |
79 #ifdef USE_OLD_MD5 | 80 #ifdef USE_OLD_MD5 |
80 static int aim_encode_password_md5(const char *password, const char *key, guint8 *digest) | 81 static int |
82 aim_encode_password_md5(const char *password, const char *key, guint8 *digest) | |
81 { | 83 { |
82 GaimCipher *cipher; | 84 GaimCipher *cipher; |
83 GaimCipherContext *context; | 85 GaimCipherContext *context; |
84 | 86 |
85 cipher = gaim_ciphers_find_cipher("md5"); | 87 cipher = gaim_ciphers_find_cipher("md5"); |
92 gaim_cipher_context_destroy(context); | 94 gaim_cipher_context_destroy(context); |
93 | 95 |
94 return 0; | 96 return 0; |
95 } | 97 } |
96 #else | 98 #else |
97 static int aim_encode_password_md5(const char *password, const char *key, guint8 *digest) | 99 static int |
100 aim_encode_password_md5(const char *password, const char *key, guint8 *digest) | |
98 { | 101 { |
99 GaimCipher *cipher; | 102 GaimCipher *cipher; |
100 GaimCipherContext *context; | 103 GaimCipherContext *context; |
101 guchar passdigest[16]; | 104 guchar passdigest[16]; |
102 | 105 |
116 | 119 |
117 return 0; | 120 return 0; |
118 } | 121 } |
119 #endif | 122 #endif |
120 | 123 |
121 /* | |
122 * The FLAP version is sent by itself at the beginning of authorization | |
123 * connections. The FLAP version is also sent before the cookie when connecting | |
124 * for other services (BOS, chatnav, chat, etc.). | |
125 */ | |
126 faim_export int aim_sendflapver(OscarSession *sess, OscarConnection *conn) | |
127 { | |
128 FlapFrame *fr; | |
129 | |
130 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 4))) | |
131 return -ENOMEM; | |
132 | |
133 aimbs_put32(&fr->data, 0x00000001); | |
134 | |
135 aim_tx_enqueue(sess, fr); | |
136 | |
137 return 0; | |
138 } | |
139 | |
140 /* | |
141 * This just pushes the passed cookie onto the passed connection, without | |
142 * the SNAC header or any of that. | |
143 * | |
144 * Very commonly used, as every connection except auth will require this to | |
145 * be the first thing you send. | |
146 * | |
147 */ | |
148 faim_export int aim_sendcookie(OscarSession *sess, OscarConnection *conn, const guint16 length, const guint8 *chipsahoy) | |
149 { | |
150 FlapFrame *fr; | |
151 aim_tlvlist_t *tl = NULL; | |
152 | |
153 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 4+2+2+length))) | |
154 return -ENOMEM; | |
155 | |
156 aimbs_put32(&fr->data, 0x00000001); | |
157 aim_tlvlist_add_raw(&tl, 0x0006, length, chipsahoy); | |
158 aim_tlvlist_write(&fr->data, &tl); | |
159 aim_tlvlist_free(&tl); | |
160 | |
161 aim_tx_enqueue(sess, fr); | |
162 | |
163 return 0; | |
164 } | |
165 | |
166 #ifdef USE_XOR_FOR_ICQ | 124 #ifdef USE_XOR_FOR_ICQ |
167 /* | 125 /* |
168 * Part two of the ICQ hack. Note the ignoring of the key. | 126 * Part two of the ICQ hack. Note the ignoring of the key. |
169 */ | 127 */ |
170 static int goddamnicq2(OscarSession *sess, OscarConnection *conn, const char *sn, const char *password, ClientInfo *ci) | 128 static int |
171 { | 129 goddamnicq2(OscarData *od, FlapConnection *conn, const char *sn, const char *password, ClientInfo *ci) |
172 FlapFrame *fr; | 130 { |
131 FlapFrame *frame; | |
173 aim_tlvlist_t *tl = NULL; | 132 aim_tlvlist_t *tl = NULL; |
174 int passwdlen; | 133 int passwdlen; |
175 guint8 *password_encoded; | 134 guint8 *password_encoded; |
176 | 135 |
177 passwdlen = strlen(password); | 136 passwdlen = strlen(password); |
178 if (!(password_encoded = (guint8 *)malloc(passwdlen+1))) | 137 password_encoded = (guint8 *)malloc(passwdlen+1); |
179 return -ENOMEM; | |
180 if (passwdlen > MAXICQPASSLEN) | 138 if (passwdlen > MAXICQPASSLEN) |
181 passwdlen = MAXICQPASSLEN; | 139 passwdlen = MAXICQPASSLEN; |
182 | 140 |
183 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 1152))) { | 141 frame = flap_frame_new(od, 0x01, 1152); |
184 free(password_encoded); | |
185 return -ENOMEM; | |
186 } | |
187 | 142 |
188 aim_encode_password(password, password_encoded); | 143 aim_encode_password(password, password_encoded); |
189 | 144 |
190 aimbs_put32(&fr->data, 0x00000001); /* FLAP Version */ | 145 byte_stream_put32(&frame->data, 0x00000001); /* FLAP Version */ |
191 aim_tlvlist_add_str(&tl, 0x0001, sn); | 146 aim_tlvlist_add_str(&tl, 0x0001, sn); |
192 aim_tlvlist_add_raw(&tl, 0x0002, passwdlen, password_encoded); | 147 aim_tlvlist_add_raw(&tl, 0x0002, passwdlen, password_encoded); |
193 | 148 |
194 if (ci->clientstring) | 149 if (ci->clientstring) |
195 aim_tlvlist_add_str(&tl, 0x0003, ci->clientstring); | 150 aim_tlvlist_add_str(&tl, 0x0003, ci->clientstring); |
200 aim_tlvlist_add_16(&tl, 0x001a, (guint16)ci->build); | 155 aim_tlvlist_add_16(&tl, 0x001a, (guint16)ci->build); |
201 aim_tlvlist_add_32(&tl, 0x0014, (guint32)ci->distrib); /* distribution chan */ | 156 aim_tlvlist_add_32(&tl, 0x0014, (guint32)ci->distrib); /* distribution chan */ |
202 aim_tlvlist_add_str(&tl, 0x000f, ci->lang); | 157 aim_tlvlist_add_str(&tl, 0x000f, ci->lang); |
203 aim_tlvlist_add_str(&tl, 0x000e, ci->country); | 158 aim_tlvlist_add_str(&tl, 0x000e, ci->country); |
204 | 159 |
205 aim_tlvlist_write(&fr->data, &tl); | 160 aim_tlvlist_write(&frame->data, &tl); |
206 | 161 |
207 free(password_encoded); | 162 free(password_encoded); |
208 aim_tlvlist_free(&tl); | 163 aim_tlvlist_free(&tl); |
209 | 164 |
210 aim_tx_enqueue(sess, fr); | 165 flap_connection_send(conn, frame); |
211 | 166 |
212 return 0; | 167 return 0; |
213 } | 168 } |
214 #endif | 169 #endif |
215 | 170 |
240 * build = 0x0070 | 195 * build = 0x0070 |
241 * unknown= 0x0000008b | 196 * unknown= 0x0000008b |
242 * serverstore = 0x01 | 197 * serverstore = 0x01 |
243 * | 198 * |
244 */ | 199 */ |
245 faim_export int aim_send_login(OscarSession *sess, OscarConnection *conn, const char *sn, const char *password, ClientInfo *ci, const char *key) | 200 int |
246 { | 201 aim_send_login(OscarData *od, FlapConnection *conn, const char *sn, const char *password, ClientInfo *ci, const char *key) |
247 FlapFrame *fr; | 202 { |
203 FlapFrame *frame; | |
248 aim_tlvlist_t *tl = NULL; | 204 aim_tlvlist_t *tl = NULL; |
249 guint8 digest[16]; | 205 guint8 digest[16]; |
250 aim_snacid_t snacid; | 206 aim_snacid_t snacid; |
251 | 207 |
252 if (!ci || !sn || !password) | 208 if (!ci || !sn || !password) |
253 return -EINVAL; | 209 return -EINVAL; |
254 | 210 |
255 #ifdef USE_XOR_FOR_ICQ | 211 #ifdef USE_XOR_FOR_ICQ |
256 /* If we're signing on an ICQ account then use the older, XOR login method */ | 212 /* If we're signing on an ICQ account then use the older, XOR login method */ |
257 if (isdigit(sn[0])) | 213 if (isdigit(sn[0])) |
258 return goddamnicq2(sess, conn, sn, password, ci); | 214 return goddamnicq2(od, conn, sn, password, ci); |
259 #endif | 215 #endif |
260 | 216 |
261 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) | 217 frame = flap_frame_new(od, 0x02, 1152); |
262 return -ENOMEM; | 218 |
263 | 219 snacid = aim_cachesnac(od, 0x0017, 0x0002, 0x0000, NULL, 0); |
264 snacid = aim_cachesnac(sess, 0x0017, 0x0002, 0x0000, NULL, 0); | 220 aim_putsnac(&frame->data, 0x0017, 0x0002, 0x0000, snacid); |
265 aim_putsnac(&fr->data, 0x0017, 0x0002, 0x0000, snacid); | |
266 | 221 |
267 aim_tlvlist_add_str(&tl, 0x0001, sn); | 222 aim_tlvlist_add_str(&tl, 0x0001, sn); |
268 | 223 |
269 /* Truncate ICQ passwords, if necessary */ | 224 /* Truncate ICQ passwords, if necessary */ |
270 if (isdigit(sn[0]) && (strlen(password) > MAXICQPASSLEN)) | 225 if (isdigit(sn[0]) && (strlen(password) > MAXICQPASSLEN)) |
300 * If set, old-fashioned buddy lists will not work. You will need | 255 * If set, old-fashioned buddy lists will not work. You will need |
301 * to use SSI. | 256 * to use SSI. |
302 */ | 257 */ |
303 aim_tlvlist_add_8(&tl, 0x004a, 0x01); | 258 aim_tlvlist_add_8(&tl, 0x004a, 0x01); |
304 | 259 |
305 aim_tlvlist_write(&fr->data, &tl); | 260 aim_tlvlist_write(&frame->data, &tl); |
306 | 261 |
307 aim_tlvlist_free(&tl); | 262 aim_tlvlist_free(&tl); |
308 | 263 |
309 aim_tx_enqueue(sess, fr); | 264 flap_connection_send(conn, frame); |
310 | 265 |
311 return 0; | 266 return 0; |
312 } | 267 } |
313 | 268 |
314 /* | 269 /* |
315 * This is sent back as a general response to the login command. | 270 * This is sent back as a general response to the login command. |
316 * It can be either an error or a success, depending on the | 271 * It can be either an error or a success, depending on the |
317 * presence of certain TLVs. | 272 * presence of certain TLVs. |
318 * | 273 * |
319 * The client should check the value passed as errorcode. If | 274 * The client should check the value passed as errorcode. If |
320 * its nonzero, there was an error. | 275 * its nonzero, there was an error. |
321 */ | 276 */ |
322 static int parse(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 277 static int |
278 parse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
323 { | 279 { |
324 aim_tlvlist_t *tlvlist; | 280 aim_tlvlist_t *tlvlist; |
325 aim_rxcallback_t userfunc; | 281 aim_rxcallback_t userfunc; |
326 struct aim_authresp_info *info; | 282 struct aim_authresp_info *info; |
327 int ret = 0; | 283 int ret = 0; |
328 | 284 |
329 info = (struct aim_authresp_info *)malloc(sizeof(struct aim_authresp_info)); | 285 info = g_new0(struct aim_authresp_info, 1); |
330 memset(info, 0, sizeof(struct aim_authresp_info)); | |
331 | 286 |
332 /* | 287 /* |
333 * Read block of TLVs. All further data is derived | 288 * Read block of TLVs. All further data is derived |
334 * from what is parsed here. | 289 * from what is parsed here. |
335 */ | 290 */ |
336 tlvlist = aim_tlvlist_read(bs); | 291 tlvlist = aim_tlvlist_read(bs); |
337 | 292 |
338 /* | 293 /* |
339 * No matter what, we should have a screen name. | 294 * No matter what, we should have a screen name. |
340 */ | 295 */ |
341 memset(sess->sn, 0, sizeof(sess->sn)); | 296 memset(od->sn, 0, sizeof(od->sn)); |
342 if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) { | 297 if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) { |
343 info->sn = aim_tlv_getstr(tlvlist, 0x0001, 1); | 298 info->sn = aim_tlv_getstr(tlvlist, 0x0001, 1); |
344 strncpy(sess->sn, info->sn, sizeof(sess->sn)); | 299 strncpy(od->sn, info->sn, sizeof(od->sn)); |
345 } | 300 } |
346 | 301 |
347 /* | 302 /* |
348 * Check for an error code. If so, we should also | 303 * Check for an error code. If so, we should also |
349 * have an error url. | 304 * have an error url. |
372 } | 327 } |
373 | 328 |
374 /* | 329 /* |
375 * The email address attached to this account | 330 * The email address attached to this account |
376 * Not available for ICQ or @mac.com logins. | 331 * Not available for ICQ or @mac.com logins. |
377 * If you receive this TLV, then you are allowed to use | 332 * If you receive this TLV, then you are allowed to use |
378 * family 0x0018 to check the status of your email. | 333 * family 0x0018 to check the status of your email. |
379 * XXX - Not really true! | 334 * XXX - Not really true! |
380 */ | 335 */ |
381 if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) | 336 if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) |
382 info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); | 337 info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); |
441 if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) { | 396 if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) { |
442 /* Unhandled */ | 397 /* Unhandled */ |
443 } | 398 } |
444 #endif | 399 #endif |
445 | 400 |
446 sess->authinfo = info; | 401 od->authinfo = info; |
447 | 402 |
448 if ((userfunc = aim_callhandler(sess, rx->conn, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003))) | 403 if ((userfunc = aim_callhandler(od, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003))) |
449 ret = userfunc(sess, rx, info); | 404 ret = userfunc(od, conn, frame, info); |
450 | 405 |
451 aim_tlvlist_free(&tlvlist); | 406 aim_tlvlist_free(&tlvlist); |
452 | 407 |
453 return ret; | 408 return ret; |
454 } | 409 } |
487 * | 442 * |
488 * XXX This may cause problems if the client relies on callbacks only | 443 * XXX This may cause problems if the client relies on callbacks only |
489 * being called from the context of aim_rxdispatch()... | 444 * being called from the context of aim_rxdispatch()... |
490 * | 445 * |
491 */ | 446 */ |
492 static int goddamnicq(OscarSession *sess, OscarConnection *conn, const char *sn) | 447 static int |
493 { | 448 goddamnicq(OscarData *od, FlapConnection *conn, const char *sn) |
494 FlapFrame fr; | 449 { |
450 FlapFrame frame; | |
495 aim_rxcallback_t userfunc; | 451 aim_rxcallback_t userfunc; |
496 | 452 |
497 fr.conn = conn; | 453 if ((userfunc = aim_callhandler(od, 0x0017, 0x0007))) |
498 | 454 userfunc(od, conn, &frame, ""); |
499 if ((userfunc = aim_callhandler(sess, conn, 0x0017, 0x0007))) | |
500 userfunc(sess, &fr, ""); | |
501 | 455 |
502 return 0; | 456 return 0; |
503 } | 457 } |
504 #endif | 458 #endif |
505 | 459 |
506 /* | 460 /* |
507 * Subtype 0x0006 | 461 * Subtype 0x0006 |
508 * | 462 * |
509 * In AIM 3.5 protocol, the first stage of login is to request login from the | 463 * In AIM 3.5 protocol, the first stage of login is to request login from the |
510 * Authorizer, passing it the screen name for verification. If the name is | 464 * Authorizer, passing it the screen name for verification. If the name is |
511 * invalid, a 0017/0003 is spit back, with the standard error contents. If | 465 * invalid, a 0017/0003 is spit back, with the standard error contents. If |
512 * valid, a 0017/0007 comes back, which is the signal to send it the main | 466 * valid, a 0017/0007 comes back, which is the signal to send it the main |
513 * login command (0017/0002). | 467 * login command (0017/0002). |
514 * | 468 * |
515 */ | 469 */ |
516 faim_export int aim_request_login(OscarSession *sess, OscarConnection *conn, const char *sn) | 470 int |
517 { | 471 aim_request_login(OscarData *od, FlapConnection *conn, const char *sn) |
518 FlapFrame *fr; | 472 { |
473 FlapFrame *frame; | |
519 aim_snacid_t snacid; | 474 aim_snacid_t snacid; |
520 aim_tlvlist_t *tl = NULL; | 475 aim_tlvlist_t *tl = NULL; |
521 | 476 |
522 if (!sess || !conn || !sn) | 477 if (!od || !conn || !sn) |
523 return -EINVAL; | 478 return -EINVAL; |
524 | 479 |
525 #ifdef USE_XOR_FOR_ICQ | 480 #ifdef USE_XOR_FOR_ICQ |
526 if (isdigit(sn[0])) | 481 if (isdigit(sn[0])) |
527 return goddamnicq(sess, conn, sn); | 482 return goddamnicq(od, conn, sn); |
528 #endif | 483 #endif |
529 | 484 |
530 aim_sendflapver(sess, conn); | 485 frame = flap_frame_new(od, 0x02, 10+2+2+strlen(sn)+8); |
531 | 486 |
532 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(sn)+8 ))) | 487 snacid = aim_cachesnac(od, 0x0017, 0x0006, 0x0000, NULL, 0); |
533 return -ENOMEM; | 488 aim_putsnac(&frame->data, 0x0017, 0x0006, 0x0000, snacid); |
534 | |
535 snacid = aim_cachesnac(sess, 0x0017, 0x0006, 0x0000, NULL, 0); | |
536 aim_putsnac(&fr->data, 0x0017, 0x0006, 0x0000, snacid); | |
537 | 489 |
538 aim_tlvlist_add_str(&tl, 0x0001, sn); | 490 aim_tlvlist_add_str(&tl, 0x0001, sn); |
539 | 491 |
540 /* Tell the server we support SecurID logins. */ | 492 /* Tell the server we support SecurID logins. */ |
541 aim_tlvlist_add_noval(&tl, 0x004b); | 493 aim_tlvlist_add_noval(&tl, 0x004b); |
542 | 494 |
543 /* Unknown. Sent in recent WinAIM clients.*/ | 495 /* Unknown. Sent in recent WinAIM clients.*/ |
544 aim_tlvlist_add_noval(&tl, 0x005a); | 496 aim_tlvlist_add_noval(&tl, 0x005a); |
545 | 497 |
546 aim_tlvlist_write(&fr->data, &tl); | 498 aim_tlvlist_write(&frame->data, &tl); |
547 aim_tlvlist_free(&tl); | 499 aim_tlvlist_free(&tl); |
548 | 500 |
549 aim_tx_enqueue(sess, fr); | 501 flap_connection_send(conn, frame); |
550 | 502 |
551 return 0; | 503 return 0; |
552 } | 504 } |
553 | 505 |
554 /* | 506 /* |
558 * by only its length in a two byte word. | 510 * by only its length in a two byte word. |
559 * | 511 * |
560 * Calls the client, which should then use the value to call aim_send_login. | 512 * Calls the client, which should then use the value to call aim_send_login. |
561 * | 513 * |
562 */ | 514 */ |
563 static int keyparse(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 515 static int |
516 keyparse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
564 { | 517 { |
565 int keylen, ret = 1; | 518 int keylen, ret = 1; |
566 aim_rxcallback_t userfunc; | 519 aim_rxcallback_t userfunc; |
567 char *keystr; | 520 char *keystr; |
568 | 521 |
569 keylen = aimbs_get16(bs); | 522 keylen = byte_stream_get16(bs); |
570 keystr = aimbs_getstr(bs, keylen); | 523 keystr = byte_stream_getstr(bs, keylen); |
571 | 524 |
572 /* XXX - When GiantGrayPanda signed on AIM I got a thing asking me to register | 525 /* XXX - When GiantGrayPanda signed on AIM I got a thing asking me to register |
573 * for the netscape network. This SNAC had a type 0x0058 TLV with length 10. | 526 * for the netscape network. This SNAC had a type 0x0058 TLV with length 10. |
574 * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */ | 527 * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */ |
575 | 528 |
576 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 529 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
577 ret = userfunc(sess, rx, keystr); | 530 ret = userfunc(od, conn, frame, keystr); |
578 | 531 |
579 free(keystr); | 532 free(keystr); |
580 | 533 |
581 return ret; | 534 return ret; |
582 } | 535 } |
584 /** | 537 /** |
585 * Subtype 0x000a | 538 * Subtype 0x000a |
586 * | 539 * |
587 * Receive SecurID request. | 540 * Receive SecurID request. |
588 */ | 541 */ |
589 static int got_securid_request(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 542 static int |
543 got_securid_request(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
590 { | 544 { |
591 int ret = 0; | 545 int ret = 0; |
592 aim_rxcallback_t userfunc; | 546 aim_rxcallback_t userfunc; |
593 | 547 |
594 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 548 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
595 ret = userfunc(sess, rx); | 549 ret = userfunc(od, conn, frame); |
596 | 550 |
597 return ret; | 551 return ret; |
598 } | 552 } |
599 | 553 |
600 /** | 554 /** |
601 * Subtype 0x000b | 555 * Subtype 0x000b |
602 * | 556 * |
603 * Send SecurID response. | 557 * Send SecurID response. |
604 */ | 558 */ |
605 faim_export int aim_auth_securid_send(OscarSession *sess, const char *securid) | 559 int |
606 { | 560 aim_auth_securid_send(OscarData *od, const char *securid) |
607 OscarConnection *conn; | 561 { |
608 FlapFrame *fr; | 562 FlapConnection *conn; |
563 FlapFrame *frame; | |
609 aim_snacid_t snacid; | 564 aim_snacid_t snacid; |
610 int len; | 565 int len; |
611 | 566 |
612 if (!sess || !(conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH)) || !securid) | 567 if (!od || !(conn = flap_connection_getbytype_all(od, SNAC_FAMILY_AUTH)) || !securid) |
613 return -EINVAL; | 568 return -EINVAL; |
614 | 569 |
615 len = strlen(securid); | 570 len = strlen(securid); |
616 | 571 |
617 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+len))) | 572 frame = flap_frame_new(od, 0x02, 10+2+len); |
618 return -ENOMEM; | 573 |
619 | 574 snacid = aim_cachesnac(od, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, NULL, 0); |
620 snacid = aim_cachesnac(sess, OSCAR_FAMILY_AUTH, OSCAR_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, NULL, 0); | 575 aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, 0); |
621 aim_putsnac(&fr->data, OSCAR_FAMILY_AUTH, OSCAR_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, 0); | 576 |
622 | 577 byte_stream_put16(&frame->data, len); |
623 aimbs_put16(&fr->data, len); | 578 byte_stream_putstr(&frame->data, securid); |
624 aimbs_putstr(&fr->data, securid); | 579 |
625 | 580 flap_connection_send(conn, frame); |
626 aim_tx_enqueue(sess, fr); | 581 |
627 | 582 return 0; |
628 return 0; | 583 } |
629 } | 584 |
630 | 585 static void |
631 static void auth_shutdown(OscarSession *sess, aim_module_t *mod) | 586 auth_shutdown(OscarData *od, aim_module_t *mod) |
632 { | 587 { |
633 if (sess->authinfo) { | 588 if (od->authinfo != NULL) |
634 free(sess->authinfo->sn); | 589 { |
635 free(sess->authinfo->bosip); | 590 free(od->authinfo->sn); |
636 free(sess->authinfo->errorurl); | 591 free(od->authinfo->bosip); |
637 free(sess->authinfo->email); | 592 free(od->authinfo->errorurl); |
638 free(sess->authinfo->chpassurl); | 593 free(od->authinfo->email); |
639 free(sess->authinfo->latestrelease.name); | 594 free(od->authinfo->chpassurl); |
640 free(sess->authinfo->latestrelease.url); | 595 free(od->authinfo->latestrelease.name); |
641 free(sess->authinfo->latestrelease.info); | 596 free(od->authinfo->latestrelease.url); |
642 free(sess->authinfo->latestbeta.name); | 597 free(od->authinfo->latestrelease.info); |
643 free(sess->authinfo->latestbeta.url); | 598 free(od->authinfo->latestbeta.name); |
644 free(sess->authinfo->latestbeta.info); | 599 free(od->authinfo->latestbeta.url); |
645 free(sess->authinfo); | 600 free(od->authinfo->latestbeta.info); |
646 } | 601 free(od->authinfo); |
647 } | 602 } |
648 | 603 } |
649 static int snachandler(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 604 |
650 { | 605 static int |
651 | 606 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
607 { | |
652 if (snac->subtype == 0x0003) | 608 if (snac->subtype == 0x0003) |
653 return parse(sess, mod, rx, snac, bs); | 609 return parse(od, conn, mod, frame, snac, bs); |
654 else if (snac->subtype == 0x0007) | 610 else if (snac->subtype == 0x0007) |
655 return keyparse(sess, mod, rx, snac, bs); | 611 return keyparse(od, conn, mod, frame, snac, bs); |
656 else if (snac->subtype == 0x000a) | 612 else if (snac->subtype == 0x000a) |
657 return got_securid_request(sess, mod, rx, snac, bs); | 613 return got_securid_request(od, conn, mod, frame, snac, bs); |
658 | 614 |
659 return 0; | 615 return 0; |
660 } | 616 } |
661 | 617 |
662 faim_internal int auth_modfirst(OscarSession *sess, aim_module_t *mod) | 618 int |
663 { | 619 auth_modfirst(OscarData *od, aim_module_t *mod) |
664 | 620 { |
665 mod->family = 0x0017; | 621 mod->family = 0x0017; |
666 mod->version = 0x0000; | 622 mod->version = 0x0000; |
667 mod->flags = 0; | 623 mod->flags = 0; |
668 strncpy(mod->name, "auth", sizeof(mod->name)); | 624 strncpy(mod->name, "auth", sizeof(mod->name)); |
669 mod->snachandler = snachandler; | 625 mod->snachandler = snachandler; |