Mercurial > pidgin.yaz
annotate src/protocols/oscar/auth.c @ 7282:ad243bc63184
[gaim-migrate @ 7861]
Mostly this is my usual blah clean-up/changes.
I started merging that icq sms patch, but I'm not comfortable
with much of it...
I also made AIM have 6 login steps instead of 2. The first
few go pretty quickly though. I'll probably work on this
more later, but I'm going to sleep now.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 16 Oct 2003 06:12:43 +0000 |
parents | 0ed4d53c46f9 |
children | be7c1468c6a7 |
rev | line source |
---|---|
2086 | 1 /* |
3912 | 2 * Family 0x0017 - Authentication. |
3 * | |
4 * Deals with the authorizer for SNAC-based login, and also old-style | |
5 * non-SNAC login. | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6 * |
2086 | 7 */ |
8 | |
9 #define FAIM_INTERNAL | |
5345 | 10 #include <aim.h> |
2086 | 11 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
12 #include "md5.h" |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
13 |
7282 | 14 #include <ctype.h> |
15 | |
7253 | 16 /** |
17 * Encode a password using old XOR method | |
18 * | |
19 * This takes a const pointer to a (null terminated) string | |
20 * containing the unencoded password. It also gets passed | |
21 * an already allocated buffer to store the encoded password. | |
22 * This buffer should be the exact length of the password without | |
23 * the null. The encoded password buffer /is not %NULL terminated/. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
24 * |
7253 | 25 * The encoding_table seems to be a fixed set of values. We'll |
26 * hope it doesn't change over time! | |
27 * | |
28 * This is only used for the XOR method, not the better MD5 method. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
29 * |
7253 | 30 * @param password Incoming password. |
31 * @param encoded Buffer to put encoded password. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
32 */ |
7253 | 33 static int aim_encode_password(const char *password, fu8_t *encoded) |
2086 | 34 { |
7253 | 35 fu8_t encoding_table[] = { |
36 #if 0 /* old v1 table */ | |
37 0xf3, 0xb3, 0x6c, 0x99, | |
38 0x95, 0x3f, 0xac, 0xb6, | |
39 0xc5, 0xfa, 0x6b, 0x63, | |
40 0x69, 0x6c, 0xc3, 0x9f | |
41 #else /* v2.1 table, also works for ICQ */ | |
42 0xf3, 0x26, 0x81, 0xc4, | |
43 0x39, 0x86, 0xdb, 0x92, | |
44 0x71, 0xa3, 0xb9, 0xe6, | |
45 0x53, 0x7a, 0x95, 0x7c | |
46 #endif | |
47 }; | |
48 int i; | |
2086 | 49 |
7253 | 50 for (i = 0; i < strlen(password); i++) |
51 encoded[i] = (password[i] ^ encoding_table[i]); | |
2086 | 52 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
53 return 0; |
2086 | 54 } |
55 | |
7253 | 56 #ifdef USE_OLD_MD5 |
57 static int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest) | |
58 { | |
59 md5_state_t state; | |
60 | |
61 md5_init(&state); | |
62 md5_append(&state, (const md5_byte_t *)key, strlen(key)); | |
63 md5_append(&state, (const md5_byte_t *)password, strlen(password)); | |
64 md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
65 md5_finish(&state, (md5_byte_t *)digest); | |
66 | |
67 return 0; | |
68 } | |
69 #else | |
70 static int aim_encode_password_md5(const char *password, const char *key, fu8_t *digest) | |
71 { | |
72 md5_state_t state; | |
73 fu8_t passdigest[16]; | |
74 | |
75 md5_init(&state); | |
76 md5_append(&state, (const md5_byte_t *)password, strlen(password)); | |
77 md5_finish(&state, (md5_byte_t *)&passdigest); | |
78 | |
79 md5_init(&state); | |
80 md5_append(&state, (const md5_byte_t *)key, strlen(key)); | |
81 md5_append(&state, (const md5_byte_t *)&passdigest, 16); | |
82 md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
83 md5_finish(&state, (md5_byte_t *)digest); | |
84 | |
85 return 0; | |
86 } | |
87 #endif | |
88 | |
2086 | 89 /* |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
90 * Normally the FLAP version is sent as the first few bytes of the cookie, |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
91 * meaning you generally never call this. |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
92 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
93 * But there are times when something might want it seperate. Specifically, |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
94 * libfaim sends this internally when doing SNAC login. |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
95 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
96 */ |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
97 faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn) |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
98 { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
99 aim_frame_t *fr; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
100 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
101 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 4))) |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
102 return -ENOMEM; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
103 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
104 aimbs_put32(&fr->data, 0x00000001); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
105 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
106 aim_tx_enqueue(sess, fr); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
107 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
108 return 0; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
109 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
110 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
111 /* |
7253 | 112 * This just pushes the passed cookie onto the passed connection, without |
113 * the SNAC header or any of that. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
114 * |
7253 | 115 * Very commonly used, as every connection except auth will require this to |
116 * be the first thing you send. | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
117 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
118 */ |
7253 | 119 faim_export int aim_sendcookie(aim_session_t *sess, aim_conn_t *conn, const fu16_t length, const fu8_t *chipsahoy) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
120 { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
121 aim_frame_t *fr; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
122 aim_tlvlist_t *tl = NULL; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
123 |
7253 | 124 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0001, 4+2+2+length))) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
125 return -ENOMEM; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
126 |
7253 | 127 aimbs_put32(&fr->data, 0x00000001); |
128 aim_tlvlist_add_raw(&tl, 0x0006, length, chipsahoy); | |
7167 | 129 aim_tlvlist_write(&fr->data, &tl); |
130 aim_tlvlist_free(&tl); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
131 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
132 aim_tx_enqueue(sess, fr); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
133 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
134 return 0; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
135 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
136 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
137 /* |
3458 | 138 * Part two of the ICQ hack. Note the ignoring of the key. |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
139 */ |
3458 | 140 static int goddamnicq2(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password, struct client_info_s *ci) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
141 { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
142 aim_frame_t *fr; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
143 aim_tlvlist_t *tl = NULL; |
5345 | 144 int passwdlen; |
5927 | 145 fu8_t *password_encoded; |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
146 |
5345 | 147 passwdlen = strlen(password); |
148 if (!(password_encoded = (char *)malloc(passwdlen+1))) | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
149 return -ENOMEM; |
5345 | 150 if (passwdlen > MAXICQPASSLEN) |
151 passwdlen = MAXICQPASSLEN; | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
152 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
153 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 1152))) { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
154 free(password_encoded); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
155 return -ENOMEM; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
156 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
157 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
158 aim_encode_password(password, password_encoded); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
159 |
3458 | 160 aimbs_put32(&fr->data, 0x00000001); /* FLAP Version */ |
7167 | 161 aim_tlvlist_add_raw(&tl, 0x0001, strlen(sn), sn); |
162 aim_tlvlist_add_raw(&tl, 0x0002, passwdlen, password_encoded); | |
3458 | 163 |
164 if (ci->clientstring) | |
7167 | 165 aim_tlvlist_add_raw(&tl, 0x0003, strlen(ci->clientstring), ci->clientstring); |
166 aim_tlvlist_add_16(&tl, 0x0016, (fu16_t)ci->clientid); | |
167 aim_tlvlist_add_16(&tl, 0x0017, (fu16_t)ci->major); | |
168 aim_tlvlist_add_16(&tl, 0x0018, (fu16_t)ci->minor); | |
169 aim_tlvlist_add_16(&tl, 0x0019, (fu16_t)ci->point); | |
170 aim_tlvlist_add_16(&tl, 0x001a, (fu16_t)ci->build); | |
171 aim_tlvlist_add_32(&tl, 0x0014, (fu32_t)ci->distrib); /* distribution chan */ | |
172 aim_tlvlist_add_raw(&tl, 0x000f, strlen(ci->lang), ci->lang); | |
173 aim_tlvlist_add_raw(&tl, 0x000e, strlen(ci->country), ci->country); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
174 |
7167 | 175 aim_tlvlist_write(&fr->data, &tl); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
176 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
177 free(password_encoded); |
7167 | 178 aim_tlvlist_free(&tl); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
179 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
180 aim_tx_enqueue(sess, fr); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
181 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
182 return 0; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
183 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
184 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
185 /* |
7253 | 186 * Subtype 0x0002 |
187 * | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
188 * send_login(int socket, char *sn, char *password) |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
189 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
190 * This is the initial login request packet. |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
191 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
192 * NOTE!! If you want/need to make use of the aim_sendmemblock() function, |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
193 * then the client information you send here must exactly match the |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
194 * executable that you're pulling the data from. |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
195 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
196 * Java AIM 1.1.19: |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
197 * clientstring = "AOL Instant Messenger (TM) version 1.1.19 for Java built 03/24/98, freeMem 215871 totalMem 1048567, i686, Linus, #2 SMP Sun Feb 11 03:41:17 UTC 2001 2.4.1-ac9, IBM Corporation, 1.1.8, 45.3, Tue Mar 27 12:09:17 PST 2001" |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
198 * clientid = 0x0001 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
199 * major = 0x0001 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
200 * minor = 0x0001 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
201 * point = (not sent) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
202 * build = 0x0013 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
203 * unknown= (not sent) |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
204 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
205 * AIM for Linux 1.1.112: |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
206 * clientstring = "AOL Instant Messenger (SM)" |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
207 * clientid = 0x1d09 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
208 * major = 0x0001 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
209 * minor = 0x0001 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
210 * point = 0x0001 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
211 * build = 0x0070 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
212 * unknown= 0x0000008b |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
213 * serverstore = 0x01 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
214 * |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
215 */ |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
216 faim_export int aim_send_login(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password, struct client_info_s *ci, const char *key) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
217 { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
218 aim_frame_t *fr; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
219 aim_tlvlist_t *tl = NULL; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
220 fu8_t digest[16]; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
221 aim_snacid_t snacid; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
222 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
223 if (!ci || !sn || !password) |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
224 return -EINVAL; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
225 |
7282 | 226 /* If we're signing on an ICQ account then use the older, XOR login method */ |
227 if (isdigit(sn[0])) | |
3458 | 228 return goddamnicq2(sess, conn, sn, password, ci); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
229 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
230 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
231 return -ENOMEM; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
232 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
233 snacid = aim_cachesnac(sess, 0x0017, 0x0002, 0x0000, NULL, 0); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
234 aim_putsnac(&fr->data, 0x0017, 0x0002, 0x0000, snacid); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
235 |
7167 | 236 aim_tlvlist_add_raw(&tl, 0x0001, strlen(sn), sn); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
237 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
238 aim_encode_password_md5(password, key, digest); |
7167 | 239 aim_tlvlist_add_raw(&tl, 0x0025, 16, digest); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
240 |
7253 | 241 #ifndef USE_OLD_MD5 |
242 aim_tlvlist_add_noval(&tl, 0x004c); | |
243 #endif | |
3213 | 244 |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
245 if (ci->clientstring) |
7167 | 246 aim_tlvlist_add_raw(&tl, 0x0003, strlen(ci->clientstring), ci->clientstring); |
247 aim_tlvlist_add_16(&tl, 0x0016, (fu16_t)ci->clientid); | |
248 aim_tlvlist_add_16(&tl, 0x0017, (fu16_t)ci->major); | |
249 aim_tlvlist_add_16(&tl, 0x0018, (fu16_t)ci->minor); | |
250 aim_tlvlist_add_16(&tl, 0x0019, (fu16_t)ci->point); | |
251 aim_tlvlist_add_16(&tl, 0x001a, (fu16_t)ci->build); | |
252 aim_tlvlist_add_32(&tl, 0x0014, (fu32_t)ci->distrib); | |
7253 | 253 aim_tlvlist_add_raw(&tl, 0x000f, strlen(ci->lang), ci->lang); |
7167 | 254 aim_tlvlist_add_raw(&tl, 0x000e, strlen(ci->country), ci->country); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
255 |
4317 | 256 #ifndef NOSSI |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
257 /* |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
258 * If set, old-fashioned buddy lists will not work. You will need |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
259 * to use SSI. |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
260 */ |
7167 | 261 aim_tlvlist_add_8(&tl, 0x004a, 0x01); |
4317 | 262 #endif |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
263 |
7167 | 264 aim_tlvlist_write(&fr->data, &tl); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
265 |
7167 | 266 aim_tlvlist_free(&tl); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
267 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
268 aim_tx_enqueue(sess, fr); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
269 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
270 return 0; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
271 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
272 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
273 /* |
2086 | 274 * This is sent back as a general response to the login command. |
275 * It can be either an error or a success, depending on the | |
276 * precense of certain TLVs. | |
277 * | |
278 * The client should check the value passed as errorcode. If | |
279 * its nonzero, there was an error. | |
280 * | |
281 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
282 static int parse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 283 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
284 aim_tlvlist_t *tlvlist; |
2704 | 285 aim_rxcallback_t userfunc; |
4102 | 286 struct aim_authresp_info *info; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
287 int ret = 0; |
2704 | 288 |
4102 | 289 info = (struct aim_authresp_info *)malloc(sizeof(struct aim_authresp_info)); |
290 memset(info, 0, sizeof(struct aim_authresp_info)); | |
2086 | 291 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
292 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
293 * Read block of TLVs. All further data is derived |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
294 * from what is parsed here. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
295 */ |
7167 | 296 tlvlist = aim_tlvlist_read(bs); |
2086 | 297 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
298 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
299 * No matter what, we should have a screen name. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
300 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
301 memset(sess->sn, 0, sizeof(sess->sn)); |
7167 | 302 if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) { |
303 info->sn = aim_tlv_getstr(tlvlist, 0x0001, 1); | |
4102 | 304 strncpy(sess->sn, info->sn, sizeof(sess->sn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
305 } |
2086 | 306 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
307 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
308 * Check for an error code. If so, we should also |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
309 * have an error url. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
310 */ |
7167 | 311 if (aim_tlv_gettlv(tlvlist, 0x0008, 1)) |
312 info->errorcode = aim_tlv_get16(tlvlist, 0x0008, 1); | |
313 if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) | |
314 info->errorurl = aim_tlv_getstr(tlvlist, 0x0004, 1); | |
2086 | 315 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
316 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
317 * BOS server address. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
318 */ |
7167 | 319 if (aim_tlv_gettlv(tlvlist, 0x0005, 1)) |
320 info->bosip = aim_tlv_getstr(tlvlist, 0x0005, 1); | |
2086 | 321 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
322 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
323 * Authorization cookie. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
324 */ |
7167 | 325 if (aim_tlv_gettlv(tlvlist, 0x0006, 1)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
326 aim_tlv_t *tmptlv; |
2086 | 327 |
7167 | 328 tmptlv = aim_tlv_gettlv(tlvlist, 0x0006, 1); |
2086 | 329 |
4293 | 330 info->cookielen = tmptlv->length; |
4102 | 331 info->cookie = tmptlv->value; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
332 } |
2086 | 333 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
334 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
335 * The email address attached to this account |
4102 | 336 * Not available for ICQ or @mac.com logins. |
337 * If you receive this TLV, then you are allowed to use | |
338 * family 0x0018 to check the status of your email. | |
4317 | 339 * XXX - Not really true! |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
340 */ |
7167 | 341 if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) |
342 info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); | |
2086 | 343 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
344 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
345 * The registration status. (Not real sure what it means.) |
4102 | 346 * Not available for ICQ or @mac.com logins. |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
347 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
348 * 1 = No disclosure |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
349 * 2 = Limited disclosure |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
350 * 3 = Full disclosure |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
351 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
352 * This has to do with whether your email address is available |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
353 * to other users or not. AFAIK, this feature is no longer used. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
354 * |
4102 | 355 * Means you can use the admin family? (0x0007) |
356 * | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
357 */ |
7167 | 358 if (aim_tlv_gettlv(tlvlist, 0x0013, 1)) |
359 info->regstatus = aim_tlv_get16(tlvlist, 0x0013, 1); | |
2086 | 360 |
7167 | 361 if (aim_tlv_gettlv(tlvlist, 0x0040, 1)) |
362 info->latestbeta.build = aim_tlv_get32(tlvlist, 0x0040, 1); | |
363 if (aim_tlv_gettlv(tlvlist, 0x0041, 1)) | |
364 info->latestbeta.url = aim_tlv_getstr(tlvlist, 0x0041, 1); | |
365 if (aim_tlv_gettlv(tlvlist, 0x0042, 1)) | |
366 info->latestbeta.info = aim_tlv_getstr(tlvlist, 0x0042, 1); | |
367 if (aim_tlv_gettlv(tlvlist, 0x0043, 1)) | |
368 info->latestbeta.name = aim_tlv_getstr(tlvlist, 0x0043, 1); | |
369 if (aim_tlv_gettlv(tlvlist, 0x0048, 1)) | |
7253 | 370 ; /* beta serial */ |
2086 | 371 |
7167 | 372 if (aim_tlv_gettlv(tlvlist, 0x0044, 1)) |
373 info->latestrelease.build = aim_tlv_get32(tlvlist, 0x0044, 1); | |
374 if (aim_tlv_gettlv(tlvlist, 0x0045, 1)) | |
375 info->latestrelease.url = aim_tlv_getstr(tlvlist, 0x0045, 1); | |
376 if (aim_tlv_gettlv(tlvlist, 0x0046, 1)) | |
377 info->latestrelease.info = aim_tlv_getstr(tlvlist, 0x0046, 1); | |
378 if (aim_tlv_gettlv(tlvlist, 0x0047, 1)) | |
379 info->latestrelease.name = aim_tlv_getstr(tlvlist, 0x0047, 1); | |
380 if (aim_tlv_gettlv(tlvlist, 0x0049, 1)) | |
7253 | 381 ; /* lastest release serial */ |
2086 | 382 |
3912 | 383 /* |
384 * URL to change password. | |
385 */ | |
7167 | 386 if (aim_tlv_gettlv(tlvlist, 0x0054, 1)) |
387 info->chpassurl = aim_tlv_getstr(tlvlist, 0x0054, 1); | |
4102 | 388 |
389 /* | |
390 * Unknown. Seen on an @mac.com screen name with value of 0x003f | |
391 */ | |
7167 | 392 if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) |
4102 | 393 ; |
394 | |
395 sess->authinfo = info; | |
2086 | 396 |
2704 | 397 if ((userfunc = aim_callhandler(sess, rx->conn, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003))) |
4102 | 398 ret = userfunc(sess, rx, info); |
2086 | 399 |
7167 | 400 aim_tlvlist_free(&tlvlist); |
2086 | 401 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
402 return ret; |
2086 | 403 } |
404 | |
405 /* | |
7253 | 406 * Subtype 0x0007 (kind of) - Send a fake type 0x0007 SNAC to the client |
407 * | |
408 * This is a bit confusing. | |
409 * | |
410 * Normal SNAC login goes like this: | |
411 * - connect | |
412 * - server sends flap version | |
413 * - client sends flap version | |
414 * - client sends screen name (17/6) | |
415 * - server sends hash key (17/7) | |
416 * - client sends auth request (17/2 -- aim_send_login) | |
417 * - server yells | |
418 * | |
419 * XOR login (for ICQ) goes like this: | |
420 * - connect | |
421 * - server sends flap version | |
422 * - client sends auth request which contains flap version (aim_send_login) | |
423 * - server yells | |
424 * | |
425 * For the client API, we make them implement the most complicated version, | |
426 * and for the simpler version, we fake it and make it look like the more | |
427 * complicated process. | |
428 * | |
429 * This is done by giving the client a faked key, just so we can convince | |
430 * them to call aim_send_login right away, which will detect the session | |
431 * flag that says this is XOR login and ignore the key, sending an ICQ | |
432 * login request instead of the normal SNAC one. | |
433 * | |
434 * As soon as AOL makes ICQ log in the same way as AIM, this is /gone/. | |
435 * | |
436 * XXX This may cause problems if the client relies on callbacks only | |
437 * being called from the context of aim_rxdispatch()... | |
438 * | |
439 */ | |
440 static int goddamnicq(aim_session_t *sess, aim_conn_t *conn, const char *sn) | |
441 { | |
442 aim_frame_t fr; | |
443 aim_rxcallback_t userfunc; | |
444 | |
445 fr.conn = conn; | |
446 | |
447 if ((userfunc = aim_callhandler(sess, conn, 0x0017, 0x0007))) | |
448 userfunc(sess, &fr, ""); | |
449 | |
450 return 0; | |
451 } | |
452 | |
453 /* | |
454 * Subtype 0x0006 | |
455 * | |
456 * In AIM 3.5 protocol, the first stage of login is to request login from the | |
457 * Authorizer, passing it the screen name for verification. If the name is | |
458 * invalid, a 0017/0003 is spit back, with the standard error contents. If | |
459 * valid, a 0017/0007 comes back, which is the signal to send it the main | |
460 * login command (0017/0002). | |
461 * | |
462 */ | |
463 faim_export int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn) | |
464 { | |
465 aim_frame_t *fr; | |
466 aim_snacid_t snacid; | |
467 aim_tlvlist_t *tl = NULL; | |
468 | |
469 if (!sess || !conn || !sn) | |
470 return -EINVAL; | |
471 | |
472 if ((sn[0] >= '0') && (sn[0] <= '9')) | |
473 return goddamnicq(sess, conn, sn); | |
474 | |
475 aim_sendflapver(sess, conn); | |
476 | |
477 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(sn) /*+8*/ ))) | |
478 return -ENOMEM; | |
479 | |
480 snacid = aim_cachesnac(sess, 0x0017, 0x0006, 0x0000, NULL, 0); | |
481 aim_putsnac(&fr->data, 0x0017, 0x0006, 0x0000, snacid); | |
482 | |
483 aim_tlvlist_add_raw(&tl, 0x0001, strlen(sn), sn); | |
484 /* aim_tlvlist_add_noval(&tl, 0x004b); | |
485 aim_tlvlist_add_noval(&tl, 0x005a); */ | |
486 aim_tlvlist_write(&fr->data, &tl); | |
487 aim_tlvlist_free(&tl); | |
488 | |
489 aim_tx_enqueue(sess, fr); | |
490 | |
491 return 0; | |
492 } | |
493 | |
494 /* | |
495 * Subtype 0x0007 | |
496 * | |
2086 | 497 * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed |
498 * by only its length in a two byte word. | |
499 * | |
500 * Calls the client, which should then use the value to call aim_send_login. | |
501 * | |
502 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
503 static int keyparse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 504 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
505 int keylen, ret = 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
506 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
507 char *keystr; |
2086 | 508 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
509 keylen = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
510 keystr = aimbs_getstr(bs, keylen); |
2086 | 511 |
4230 | 512 /* XXX - When GiantGrayPanda signed on AIM I got a thing asking me to register |
513 * for the netscape network. This SNAC had a type 0x0058 TLV with length 10. | |
514 * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */ | |
515 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
516 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
517 ret = userfunc(sess, rx, keystr); |
2086 | 518 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
519 free(keystr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
520 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
521 return ret; |
2086 | 522 } |
523 | |
4102 | 524 static void auth_shutdown(aim_session_t *sess, aim_module_t *mod) |
525 { | |
526 if (sess->authinfo) { | |
527 free(sess->authinfo->sn); | |
528 free(sess->authinfo->bosip); | |
529 free(sess->authinfo->errorurl); | |
530 free(sess->authinfo->email); | |
531 free(sess->authinfo->chpassurl); | |
532 free(sess->authinfo->latestrelease.name); | |
533 free(sess->authinfo->latestrelease.url); | |
534 free(sess->authinfo->latestrelease.info); | |
535 free(sess->authinfo->latestbeta.name); | |
536 free(sess->authinfo->latestbeta.url); | |
537 free(sess->authinfo->latestbeta.info); | |
538 free(sess->authinfo); | |
539 } | |
540 } | |
541 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
542 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 543 { |
544 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
545 if (snac->subtype == 0x0003) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
546 return parse(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
547 else if (snac->subtype == 0x0007) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
548 return keyparse(sess, mod, rx, snac, bs); |
2086 | 549 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
550 return 0; |
2086 | 551 } |
552 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
553 faim_internal int auth_modfirst(aim_session_t *sess, aim_module_t *mod) |
2086 | 554 { |
555 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
556 mod->family = 0x0017; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
557 mod->version = 0x0000; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
558 mod->flags = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
559 strncpy(mod->name, "auth", sizeof(mod->name)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
560 mod->snachandler = snachandler; |
4102 | 561 mod->shutdown = auth_shutdown; |
2086 | 562 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
563 return 0; |
2086 | 564 } |