comparison libfaim/aim_login.c @ 445:e4c34ca88d9b

[gaim-migrate @ 455] Hehehehehe Libfaim got updated, gaim got updated. btw, gaim/faim can't sign in yet, don't ask me why. it's not my fault. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 29 Jun 2000 20:40:28 +0000
parents ad08e67ec874
children 6d78b988b479
comparison
equal deleted inserted replaced
444:e7885c54ed2f 445:e4c34ca88d9b
20 { 20 {
21 int curbyte=0; 21 int curbyte=0;
22 22
23 struct command_tx_struct *newpacket; 23 struct command_tx_struct *newpacket;
24 24
25 if (!(newpacket = aim_tx_new(0x0001, conn, 4))) 25 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0001, conn, 4)))
26 return -1; 26 return -1;
27 27
28 newpacket->lock = 1; 28 newpacket->lock = 1;
29 29
30 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); 30 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
49 { 49 {
50 int curbyte=0; 50 int curbyte=0;
51 51
52 struct command_tx_struct *newpacket; 52 struct command_tx_struct *newpacket;
53 53
54 if (!(newpacket = aim_tx_new(0x0002, conn, 10+2+2+strlen(sn)))) 54 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+2+2+strlen(sn))))
55 return -1; 55 return -1;
56 56
57 newpacket->lock = 1; 57 newpacket->lock = 1;
58 58
59 curbyte += aim_putsnac(newpacket->data+curbyte, 0x0017, 0x0006, 0x0000, 0x00010000); 59 curbyte += aim_putsnac(newpacket->data+curbyte, 0x0017, 0x0006, 0x0000, 0x00010000);
85 struct command_tx_struct *newpacket; 85 struct command_tx_struct *newpacket;
86 86
87 if (!clientinfo || !sn || !password) 87 if (!clientinfo || !sn || !password)
88 return -1; 88 return -1;
89 89
90 if (!(newpacket = aim_tx_new(0x0002, conn, 1152))) 90 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
91 return -1; 91 return -1;
92 92
93 /* 93 /*
94 * For ICQ logins, the client version must be at 94 * For ICQ logins, the client version must be at
95 * least as high as ICQ2000a. 95 * least as high as ICQ2000a.
148 if (strlen(clientinfo->lang)) 148 if (strlen(clientinfo->lang))
149 newpacket->commandlen += 4+strlen(clientinfo->lang); 149 newpacket->commandlen += 4+strlen(clientinfo->lang);
150 } 150 }
151 151
152 newpacket->lock = 1; 152 newpacket->lock = 1;
153 newpacket->type = 0x01; 153 newpacket->hdr.oscar.type = 0x01;
154 154
155 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); 155 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
156 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); 156 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
157 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); 157 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
158 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(sn)); 158 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(sn));
159 curbyte += aimutil_putstr(newpacket->data+curbyte, sn, strlen(sn)); 159 curbyte += aimutil_putstr(newpacket->data+curbyte, sn, strlen(sn));
160 160
161 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); 161 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
162 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(password)); 162 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(password));
163 password_encoded = (char *) malloc(strlen(password)); 163 password_encoded = (char *) malloc(strlen(password));
164 if (icqmode) 164 aim_encode_password(password, password_encoded);
165 aimicq_encode_password(password, password_encoded);
166 else
167 aim_encode_password(password, password_encoded);
168 curbyte += aimutil_putstr(newpacket->data+curbyte, password_encoded, strlen(password)); 165 curbyte += aimutil_putstr(newpacket->data+curbyte, password_encoded, strlen(password));
169 free(password_encoded); 166 free(password_encoded);
170 167
171 if (strlen(clientinfo->clientstring)) { 168 if (strlen(clientinfo->clientstring)) {
172 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003); 169 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003);
179 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001); 176 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001);
180 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, clientinfo->build /*0x0013*/); 177 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, clientinfo->build /*0x0013*/);
181 178
182 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055); 179 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055);
183 180
181 if (strlen(clientinfo->country)) {
182 curbyte += aimutil_put16(newpacket->data+curbyte, 0x000e);
183 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->country));
184 curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->country, strlen(clientinfo->country));
185 }
184 if (strlen(clientinfo->lang)) { 186 if (strlen(clientinfo->lang)) {
185 curbyte += aimutil_put16(newpacket->data+curbyte, 0x000f); 187 curbyte += aimutil_put16(newpacket->data+curbyte, 0x000f);
186 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->lang)); 188 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->lang));
187 curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->lang, strlen(clientinfo->lang)); 189 curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->lang, strlen(clientinfo->lang));
188 }
189
190 if (strlen(clientinfo->country)) {
191 curbyte += aimutil_put16(newpacket->data+curbyte, 0x000e);
192 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->country));
193 curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->country, strlen(clientinfo->country));
194 } 190 }
195 191
196 #endif 192 #endif
197 193
198 newpacket->lock = 0; 194 newpacket->lock = 0;
216 * 212 *
217 */ 213 */
218 int aim_encode_password(const char *password, u_char *encoded) 214 int aim_encode_password(const char *password, u_char *encoded)
219 { 215 {
220 u_char encoding_table[] = { 216 u_char encoding_table[] = {
221 #if 0 217 #if 0 /* old v1 table */
222 0xf3, 0xb3, 0x6c, 0x99, 218 0xf3, 0xb3, 0x6c, 0x99,
223 0x95, 0x3f, 0xac, 0xb6, 219 0x95, 0x3f, 0xac, 0xb6,
224 0xc5, 0xfa, 0x6b, 0x63, 220 0xc5, 0xfa, 0x6b, 0x63,
225 0x69, 0x6c, 0xc3, 0x9f 221 0x69, 0x6c, 0xc3, 0x9f
226 #else 222 #else /* v2.1 table, also works for ICQ */
227 0xf3, 0x26, 0x81, 0xc4, 223 0xf3, 0x26, 0x81, 0xc4,
228 0x39, 0x86, 0xdb, 0x92, 224 0x39, 0x86, 0xdb, 0x92,
229 0x71, 0xa3, 0xb9, 0xe6, 225 0x71, 0xa3, 0xb9, 0xe6,
230 0x53, 0x7a, 0x95, 0x7c 226 0x53, 0x7a, 0x95, 0x7c
231 #endif 227 #endif
232 }; 228 };
233 229
234 int i; 230 int i;
235 231
236 for (i = 0; i < strlen(password); i++)
237 encoded[i] = (password[i] ^ encoding_table[i]);
238
239 return 0;
240 }
241
242 /*
243 * They changed the hash slightly for ICQ.
244 * This new hash may work for AIM too (though
245 * the max password length for ICQ is only
246 * eight characters, where its 16 with AIM).
247 *
248 */
249 int aimicq_encode_password(const char *password, u_char *encoded)
250 {
251 u_char encoding_table[] = {
252 0xf3, 0x26, 0x81, 0xc4,
253 0x39, 0x86, 0xdb, 0x92
254 };
255
256 int i;
257
258 if (strlen(password) > 8)
259 return -1;
260
261 for (i = 0; i < strlen(password); i++) 232 for (i = 0; i < strlen(password); i++)
262 encoded[i] = (password[i] ^ encoding_table[i]); 233 encoded[i] = (password[i] ^ encoding_table[i]);
263 234
264 return 0; 235 return 0;
265 } 236 }
311 } 282 }
312 /* 283 /*
313 * If we have both an IP number (0x0005) and a cookie (0x0006), 284 * If we have both an IP number (0x0005) and a cookie (0x0006),
314 * then the login was successful. 285 * then the login was successful.
315 */ 286 */
316 else if (aim_gettlv(tlvlist, 0x0005, 1) && aim_gettlv(tlvlist, 0x0006, 1)) { 287 else if (aim_gettlv(tlvlist, 0x0005, 1) && aim_gettlv(tlvlist, 0x0006, 1)
288 /*aim_gettlv(tlvlist, 0x0006, 1)->length*/) {
317 struct aim_tlv_t *tmptlv; 289 struct aim_tlv_t *tmptlv;
318 290
319 /* 291 /*
320 * IP address of BOS server. 292 * IP address of BOS server.
321 */ 293 */
374 int regstatus) 346 int regstatus)
375 { 347 {
376 struct command_tx_struct *tx; 348 struct command_tx_struct *tx;
377 struct aim_tlvlist_t *tlvlist = NULL; 349 struct aim_tlvlist_t *tlvlist = NULL;
378 350
379 if (!(tx = aim_tx_new(0x0004, conn, 1152))) 351 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0004, conn, 1152)))
380 return -1; 352 return -1;
381 353
382 tx->lock = 1; 354 tx->lock = 1;
383 355
384 if (sn) 356 if (sn)
422 int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn) 394 int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn)
423 { 395 {
424 struct command_tx_struct *tx; 396 struct command_tx_struct *tx;
425 int i = 0; 397 int i = 0;
426 398
427 if (!(tx = aim_tx_new(0x0002, conn, 10+0x22))) 399 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+0x22)))
428 return -1; 400 return -1;
429 401
430 tx->lock = 1; 402 tx->lock = 1;
431 403
432 i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++); 404 i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++);
461 { 433 {
462 struct command_tx_struct *tx; 434 struct command_tx_struct *tx;
463 struct aim_tlvlist_t *tlvlist = NULL; 435 struct aim_tlvlist_t *tlvlist = NULL;
464 int i = 0; 436 int i = 0;
465 437
466 if (!(tx = aim_tx_new(0x0002, conn, 1152))) 438 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
467 return -1; 439 return -1;
468 440
469 tx->lock = 1; 441 tx->lock = 1;
470 442
471 i += aimutil_put16(tx->data+i, 0x0001); 443 i += aimutil_put16(tx->data+i, 0x0001);