Mercurial > pidgin
annotate libfaim/aim_login.c @ 1388:7dc0a8bb4dcb
[gaim-migrate @ 1398]
Pounce stuff is not sensitive if it doesnt need to be.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Fri, 05 Jan 2001 09:13:13 +0000 |
parents | 4c5c2fcb83cd |
children |
rev | line source |
---|---|
2 | 1 /* |
2 * aim_login.c | |
3 * | |
4 * This contains all the functions needed to actually login. | |
5 * | |
6 */ | |
7 | |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
8 #include <faim/aim.h> |
2 | 9 |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
10 #include "md5.h" |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
11 |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
12 static int aim_encode_password_md5(const char *password, const char *key, md5_byte_t *digest); |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
13 static int aim_encode_password(const char *password, unsigned char *encoded); |
2 | 14 |
15 /* | |
16 * FIXME: Reimplement the TIS stuff. | |
17 */ | |
18 #ifdef TIS_TELNET_PROXY | |
19 #include "tis_telnet_proxy.h" | |
20 #endif | |
21 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
22 faim_export int aim_sendconnack(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
23 struct aim_conn_t *conn) |
237 | 24 { |
25 int curbyte=0; | |
26 | |
27 struct command_tx_struct *newpacket; | |
28 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
412
diff
changeset
|
29 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0001, conn, 4))) |
237 | 30 return -1; |
31 | |
32 newpacket->lock = 1; | |
33 | |
34 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
35 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); | |
36 | |
37 newpacket->lock = 0; | |
38 return aim_tx_enqueue(sess, newpacket); | |
39 } | |
40 | |
2 | 41 /* |
237 | 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 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
49 faim_export int aim_request_login(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
50 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
51 char *sn) |
237 | 52 { |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
53 int curbyte; |
237 | 54 struct command_tx_struct *newpacket; |
55 | |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
56 if (!sess || !conn || !sn) |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
57 return -1; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
58 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
59 /* |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
60 * For ICQ, we enable the ancient horrible login and stuff |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
61 * a key packet into the queue to make it look like we got |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
62 * a reply back. This is so the client doesn't know we're |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
63 * really not doing MD5 login. |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
64 * |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
65 * This may sound stupid, but I'm not in the best of moods and |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
66 * I don't plan to keep support for this crap around much longer. |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
67 * Its all AOL's fault anyway, really. I hate AOL. Really. They |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
68 * always seem to be able to piss me off by doing the dumbest little |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
69 * things. Like disabling MD5 logins for ICQ UINs, or adding purposefully |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
70 * wrong TLV lengths, or adding superfluous information to host strings, |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
71 * or... I'll stop. |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
72 * |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
73 */ |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
74 if ((sn[0] >= '0') && (sn[0] <= '9')) { |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
75 struct command_rx_struct *newrx; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
76 int i; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
77 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
78 if (!(newrx = (struct command_rx_struct *)malloc(sizeof(struct command_rx_struct)))) |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
79 return -1; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
80 memset(newrx, 0x00, sizeof(struct command_rx_struct)); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
81 newrx->lock = 1; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
82 newrx->hdrtype = AIM_FRAMETYPE_OSCAR; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
83 newrx->hdr.oscar.type = 0x02; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
84 newrx->hdr.oscar.seqnum = 0; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
85 newrx->commandlen = 10+2+1; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
86 newrx->nofree = 0; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
87 if (!(newrx->data = malloc(newrx->commandlen))) { |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
88 free(newrx); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
89 return -1; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
90 } |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
91 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
92 i = aim_putsnac(newrx->data, 0x0017, 0x0007, 0x0000, 0x0000); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
93 i += aimutil_put16(newrx->data+i, 0x01); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
94 i += aimutil_putstr(newrx->data+i, "0", 1); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
95 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
96 newrx->conn = conn; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
97 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
98 newrx->next = sess->queue_incoming; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
99 sess->queue_incoming = newrx; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
100 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
101 newrx->lock = 0; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
102 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
103 sess->flags &= ~AIM_SESS_FLAGS_SNACLOGIN; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
104 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
105 return 0; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
106 } |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
107 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
108 sess->flags |= AIM_SESS_FLAGS_SNACLOGIN; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
109 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
110 aim_sendconnack(sess, conn); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
111 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
412
diff
changeset
|
112 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+2+2+strlen(sn)))) |
237 | 113 return -1; |
114 | |
115 newpacket->lock = 1; | |
116 | |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
117 curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0006, 0x0000, 0x00010000); |
237 | 118 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn); |
119 | |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
120 newpacket->commandlen = curbyte; |
237 | 121 newpacket->lock = 0; |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
122 |
237 | 123 return aim_tx_enqueue(sess, newpacket); |
124 } | |
125 | |
126 /* | |
127 * send_login(int socket, char *sn, char *password) | |
2 | 128 * |
129 * This is the initial login request packet. | |
130 * | |
131 * The password is encoded before transmition, as per | |
132 * encode_password(). See that function for their | |
133 * stupid method of doing it. | |
134 * | |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
135 * Latest WinAIM: |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
136 * clientstring = "AOL Instant Messenger (SM), version 4.3.2188/WIN32" |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
137 * major2 = 0x0109 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
138 * major = 0x0400 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
139 * minor = 0x0003 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
140 * minor2 = 0x0000 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
141 * build = 0x088c |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
142 * unknown = 0x00000086 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
143 * lang = "en" |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
144 * country = "us" |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
145 * unknown4a = 0x01 |
2 | 146 */ |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
147 faim_export int aim_send_login (struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
148 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
149 char *sn, char *password, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
150 struct client_info_s *clientinfo, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
151 char *key) |
2 | 152 { |
153 int curbyte=0; | |
237 | 154 struct command_tx_struct *newpacket; |
155 | |
156 if (!clientinfo || !sn || !password) | |
157 return -1; | |
158 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
412
diff
changeset
|
159 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152))) |
237 | 160 return -1; |
2 | 161 |
237 | 162 newpacket->lock = 1; |
2 | 163 |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
164 newpacket->hdr.oscar.type = (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)?0x02:0x01; |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
165 |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
166 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
167 curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0002, 0x0000, 0x00010000); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
168 else { |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
169 curbyte = aimutil_put16(newpacket->data, 0x0000); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
170 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
171 } |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
172 |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
173 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn); |
237 | 174 |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
175 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) { |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
176 md5_byte_t digest[16]; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
177 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
178 aim_encode_password_md5(password, key, digest); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
179 curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0025, 16, (char *)digest); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
180 } else { |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
181 char *password_encoded; |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
182 |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
183 password_encoded = (char *) malloc(strlen(password)); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
184 aim_encode_password(password, password_encoded); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
185 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0002, strlen(password), password_encoded); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
186 free(password_encoded); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
187 } |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
188 |
446
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
189 /* XXX is clientstring required by oscar? */ |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
190 if (strlen(clientinfo->clientstring)) |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
191 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring); |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
192 |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
193 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) { |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
194 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, (unsigned short)clientinfo->major2); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
195 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, (unsigned short)clientinfo->major); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
196 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, (unsigned short)clientinfo->minor); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
197 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, (unsigned short)clientinfo->minor2); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
198 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, (unsigned short)clientinfo->build); |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
199 |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
200 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
201 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015); |
1253
8342d3aab1f1
[gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1249
diff
changeset
|
202 curbyte += aim_puttlv_8(newpacket->data+curbyte, 0x004a, 0x00); |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
203 } else { |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
204 /* Use very specific version numbers, to further indicate the hack. */ |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
205 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, 0x010a); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
206 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, 0x0004); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
207 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, 0x003c); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
208 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
209 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, 0x0cce); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
210 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
211 } |
331
f3c8d79688db
[gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
212 |
446
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
213 if (strlen(clientinfo->country)) |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
214 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, strlen(clientinfo->country), clientinfo->country); |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
215 else |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
216 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, 2, "us"); |
331
f3c8d79688db
[gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
217 |
446
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
218 if (strlen(clientinfo->lang)) |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
219 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, strlen(clientinfo->lang), clientinfo->lang); |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
220 else |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
221 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, 2, "en"); |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
222 |
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
223 newpacket->commandlen = curbyte; |
2 | 224 |
237 | 225 newpacket->lock = 0; |
226 return aim_tx_enqueue(sess, newpacket); | |
2 | 227 } |
228 | |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
229 static int aim_encode_password_md5(const char *password, const char *key, md5_byte_t *digest) |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
230 { |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
231 md5_state_t state; |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
232 |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
233 md5_init(&state); |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
234 md5_append(&state, (const md5_byte_t *)key, strlen(key)); |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
235 md5_append(&state, (const md5_byte_t *)password, strlen(password)); |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
236 md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
237 md5_finish(&state, (md5_byte_t *)digest); |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
238 |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
239 return 0; |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
240 } |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
241 |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
242 /** |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
243 * aim_encode_password - Encode a password using old XOR method |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
244 * @password: incoming password |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
245 * @encoded: buffer to put encoded password |
2 | 246 * |
247 * This takes a const pointer to a (null terminated) string | |
248 * containing the unencoded password. It also gets passed | |
249 * an already allocated buffer to store the encoded password. | |
250 * This buffer should be the exact length of the password without | |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
251 * the null. The encoded password buffer /is not %NULL terminated/. |
2 | 252 * |
253 * The encoding_table seems to be a fixed set of values. We'll | |
254 * hope it doesn't change over time! | |
255 * | |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
256 * This is only used for the XOR method, not the better MD5 method. |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
257 * |
2 | 258 */ |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
259 static int aim_encode_password(const char *password, unsigned char *encoded) |
2 | 260 { |
237 | 261 u_char encoding_table[] = { |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
412
diff
changeset
|
262 #if 0 /* old v1 table */ |
2 | 263 0xf3, 0xb3, 0x6c, 0x99, |
264 0x95, 0x3f, 0xac, 0xb6, | |
265 0xc5, 0xfa, 0x6b, 0x63, | |
266 0x69, 0x6c, 0xc3, 0x9f | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
412
diff
changeset
|
267 #else /* v2.1 table, also works for ICQ */ |
412
ad08e67ec874
[gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
331
diff
changeset
|
268 0xf3, 0x26, 0x81, 0xc4, |
ad08e67ec874
[gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
331
diff
changeset
|
269 0x39, 0x86, 0xdb, 0x92, |
ad08e67ec874
[gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
331
diff
changeset
|
270 0x71, 0xa3, 0xb9, 0xe6, |
ad08e67ec874
[gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
331
diff
changeset
|
271 0x53, 0x7a, 0x95, 0x7c |
ad08e67ec874
[gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
331
diff
changeset
|
272 #endif |
2 | 273 }; |
274 | |
275 int i; | |
276 | |
277 for (i = 0; i < strlen(password); i++) | |
278 encoded[i] = (password[i] ^ encoding_table[i]); | |
279 | |
280 return 0; | |
281 } | |
282 | |
237 | 283 /* |
284 * This is sent back as a general response to the login command. | |
285 * It can be either an error or a success, depending on the | |
286 * precense of certain TLVs. | |
287 * | |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
288 * The client should check the value passed as errorcode. If |
237 | 289 * its nonzero, there was an error. |
290 * | |
291 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
292 faim_internal int aim_authparse(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
293 struct command_rx_struct *command) |
237 | 294 { |
295 struct aim_tlvlist_t *tlvlist; | |
296 int ret = 1; | |
297 rxcallback_t userfunc = NULL; | |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
298 char *sn = NULL, *bosip = NULL, *errurl = NULL, *email = NULL; |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
299 unsigned char *cookie = NULL; |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
300 int errorcode = 0, regstatus = 0; |
1247
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
301 int latestbuild = 0, latestbetabuild = 0; |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
302 char *latestrelease = NULL, *latestbeta = NULL; |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
303 char *latestreleaseurl = NULL, *latestbetaurl = NULL; |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
304 char *latestreleaseinfo = NULL, *latestbetainfo = NULL; |
237 | 305 |
306 /* | |
307 * Read block of TLVs. All further data is derived | |
308 * from what is parsed here. | |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
309 * |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
310 * For SNAC login, there's a 17/3 SNAC header in front. |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
311 * |
237 | 312 */ |
1081
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
313 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
314 tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10); |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
315 else |
efcacae6acdb
[gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
316 tlvlist = aim_readtlvchain(command->data, command->commandlen); |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
317 |
237 | 318 /* |
319 * No matter what, we should have a screen name. | |
320 */ | |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
321 memset(sess->sn, 0, sizeof(sess->sn)); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
322 if (aim_gettlv(tlvlist, 0x0001, 1)) { |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
323 sn = aim_gettlv_str(tlvlist, 0x0001, 1); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
324 strncpy(sess->sn, sn, sizeof(sess->sn)); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
325 } |
715
58106806ac2b
[gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
446
diff
changeset
|
326 |
237 | 327 /* |
328 * Check for an error code. If so, we should also | |
329 * have an error url. | |
330 */ | |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
331 if (aim_gettlv(tlvlist, 0x0008, 1)) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
332 errorcode = aim_gettlv16(tlvlist, 0x0008, 1); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
333 if (aim_gettlv(tlvlist, 0x0004, 1)) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
334 errurl = aim_gettlv_str(tlvlist, 0x0004, 1); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
335 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
336 /* |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
337 * BOS server address. |
237 | 338 */ |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
339 if (aim_gettlv(tlvlist, 0x0005, 1)) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
340 bosip = aim_gettlv_str(tlvlist, 0x0005, 1); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
341 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
342 /* |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
343 * Authorization cookie. |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
344 */ |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
345 if (aim_gettlv(tlvlist, 0x0006, 1)) { |
331
f3c8d79688db
[gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
346 struct aim_tlv_t *tmptlv; |
237 | 347 |
331
f3c8d79688db
[gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
348 tmptlv = aim_gettlv(tlvlist, 0x0006, 1); |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
349 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
350 if ((cookie = malloc(tmptlv->length))) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
351 memcpy(cookie, tmptlv->value, tmptlv->length); |
331
f3c8d79688db
[gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
352 } |
237 | 353 |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
354 /* |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
355 * The email address attached to this account |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
356 * Not available for ICQ logins. |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
357 */ |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
358 if (aim_gettlv(tlvlist, 0x0011, 1)) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
359 email = aim_gettlv_str(tlvlist, 0x0011, 1); |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
360 |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
361 /* |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
362 * The registration status. (Not real sure what it means.) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
363 * Not available for ICQ logins. |
1302
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1253
diff
changeset
|
364 * |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1253
diff
changeset
|
365 * 1 = No disclosure |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1253
diff
changeset
|
366 * 2 = Limited disclosure |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1253
diff
changeset
|
367 * 3 = Full disclosure |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1253
diff
changeset
|
368 * |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1253
diff
changeset
|
369 * This has to do with whether your email address is available |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1253
diff
changeset
|
370 * to other users or not. AFAIK, this feature is no longer used. |
4c5c2fcb83cd
[gaim-migrate @ 1312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1253
diff
changeset
|
371 * |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
372 */ |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
373 if (aim_gettlv(tlvlist, 0x0013, 1)) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
374 regstatus = aim_gettlv16(tlvlist, 0x0013, 1); |
237 | 375 |
1247
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
376 if (aim_gettlv(tlvlist, 0x0040, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
377 latestbetabuild = aim_gettlv32(tlvlist, 0x0040, 1); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
378 if (aim_gettlv(tlvlist, 0x0041, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
379 latestbetaurl = aim_gettlv_str(tlvlist, 0x0041, 1); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
380 if (aim_gettlv(tlvlist, 0x0042, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
381 latestbetainfo = aim_gettlv_str(tlvlist, 0x0042, 1); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
382 if (aim_gettlv(tlvlist, 0x0043, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
383 latestbeta = aim_gettlv_str(tlvlist, 0x0043, 1); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
384 if (aim_gettlv(tlvlist, 0x0048, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
385 ; /* no idea what this is */ |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
386 |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
387 if (aim_gettlv(tlvlist, 0x0044, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
388 latestbuild = aim_gettlv32(tlvlist, 0x0044, 1); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
389 if (aim_gettlv(tlvlist, 0x0045, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
390 latestreleaseurl = aim_gettlv_str(tlvlist, 0x0045, 1); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
391 if (aim_gettlv(tlvlist, 0x0046, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
392 latestreleaseinfo = aim_gettlv_str(tlvlist, 0x0046, 1); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
393 if (aim_gettlv(tlvlist, 0x0047, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
394 latestrelease = aim_gettlv_str(tlvlist, 0x0047, 1); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
395 if (aim_gettlv(tlvlist, 0x0049, 1)) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
396 ; /* no idea what this is */ |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
397 |
237 | 398 |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
399 if ((userfunc = aim_callhandler(command->conn, 0x0017, 0x0003))) |
1247
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
400 ret = userfunc(sess, command, sn, errorcode, errurl, regstatus, email, bosip, cookie, latestrelease, latestbuild, latestreleaseurl, latestreleaseinfo, latestbeta, latestbetabuild, latestbetaurl, latestbetainfo); |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
401 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
402 |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
403 if (sn) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
404 free(sn); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
405 if (bosip) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
406 free(bosip); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
407 if (errurl) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
408 free(errurl); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
409 if (email) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
410 free(email); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
411 if (cookie) |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
412 free(cookie); |
1247
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
413 if (latestrelease) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
414 free(latestrelease); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
415 if (latestreleaseurl) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
416 free(latestreleaseurl); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
417 if (latestbeta) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
418 free(latestbeta); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
419 if (latestbetaurl) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
420 free(latestbetaurl); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
421 if (latestreleaseinfo) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
422 free(latestreleaseinfo); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
423 if (latestbetainfo) |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
424 free(latestbetainfo); |
f50146ce818e
[gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1245
diff
changeset
|
425 |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
426 aim_freetlvchain(&tlvlist); |
237 | 427 |
428 return ret; | |
429 } | |
430 | |
431 /* | |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
432 * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
433 * by only its length in a two byte word. |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
434 * |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
435 * Calls the client, which should then use the value to call aim_send_login. |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
436 * |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
437 */ |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
438 faim_internal int aim_authkeyparse(struct aim_session_t *sess, struct command_rx_struct *command) |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
439 { |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
440 unsigned char *key; |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
441 int keylen; |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
442 int ret = 1; |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
443 rxcallback_t userfunc; |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
444 |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
445 keylen = aimutil_get16(command->data+10); |
771
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
741
diff
changeset
|
446 if (!(key = malloc(keylen+1))) |
72e556f6b99d
[gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
741
diff
changeset
|
447 return ret; |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
448 memcpy(key, command->data+12, keylen); |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
449 key[keylen] = '\0'; |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
450 |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
451 if ((userfunc = aim_callhandler(command->conn, 0x0017, 0x0007))) |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
452 ret = userfunc(sess, command, (char *)key); |
741
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
453 |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
454 free(key); |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
455 |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
456 return ret; |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
457 } |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
458 |
58a6e6e26695
[gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
715
diff
changeset
|
459 /* |
237 | 460 * Generate an authorization response. |
461 * | |
462 * You probably don't want this unless you're writing an AIM server. | |
463 * | |
464 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
465 faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
466 struct aim_conn_t *conn, |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
467 char *sn, int errorcode, |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
468 char *errorurl, char *bosip, |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
469 char *cookie, char *email, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
470 int regstatus) |
237 | 471 { |
472 struct command_tx_struct *tx; | |
473 struct aim_tlvlist_t *tlvlist = NULL; | |
474 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
412
diff
changeset
|
475 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0004, conn, 1152))) |
237 | 476 return -1; |
477 | |
478 tx->lock = 1; | |
479 | |
480 if (sn) | |
481 aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn)); | |
482 else | |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
483 aim_addtlvtochain_str(&tlvlist, 0x0001, sess->sn, strlen(sess->sn)); |
237 | 484 |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
485 if (errorcode) { |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
486 aim_addtlvtochain16(&tlvlist, 0x0008, errorcode); |
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
487 aim_addtlvtochain_str(&tlvlist, 0x0004, errorurl, strlen(errorurl)); |
237 | 488 } else { |
489 aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip)); | |
490 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN); | |
491 aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email)); | |
889
e1da6a6ec42b
[gaim-migrate @ 899]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
492 aim_addtlvtochain16(&tlvlist, 0x0013, (unsigned short)regstatus); |
237 | 493 } |
494 | |
495 tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist); | |
496 tx->lock = 0; | |
1245
2ac6ccb94229
[gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1081
diff
changeset
|
497 |
237 | 498 return aim_tx_enqueue(sess, tx); |
499 } | |
500 | |
501 /* | |
502 * Generate a random cookie. (Non-client use only) | |
503 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
504 faim_export int aim_gencookie(unsigned char *buf) |
237 | 505 { |
506 int i; | |
507 | |
508 srand(time(NULL)); | |
509 | |
510 for (i=0; i < AIM_COOKIELEN; i++) | |
511 buf[i] = 1+(int) (256.0*rand()/(RAND_MAX+0.0)); | |
512 | |
513 return i; | |
514 } | |
515 | |
516 /* | |
517 * Send Server Ready. (Non-client) | |
518 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
519 faim_export int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn) |
237 | 520 { |
521 struct command_tx_struct *tx; | |
522 int i = 0; | |
523 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
412
diff
changeset
|
524 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+0x22))) |
237 | 525 return -1; |
526 | |
527 tx->lock = 1; | |
528 | |
248
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
529 i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++); |
237 | 530 |
531 i += aimutil_put16(tx->data+i, 0x0001); | |
532 i += aimutil_put16(tx->data+i, 0x0002); | |
533 i += aimutil_put16(tx->data+i, 0x0003); | |
534 i += aimutil_put16(tx->data+i, 0x0004); | |
535 i += aimutil_put16(tx->data+i, 0x0006); | |
536 i += aimutil_put16(tx->data+i, 0x0008); | |
537 i += aimutil_put16(tx->data+i, 0x0009); | |
538 i += aimutil_put16(tx->data+i, 0x000a); | |
539 i += aimutil_put16(tx->data+i, 0x000b); | |
540 i += aimutil_put16(tx->data+i, 0x000c); | |
248
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
541 i += aimutil_put16(tx->data+i, 0x0013); |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
542 i += aimutil_put16(tx->data+i, 0x0015); |
237 | 543 |
248
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
544 tx->commandlen = i; |
237 | 545 tx->lock = 0; |
546 return aim_tx_enqueue(sess, tx); | |
547 } | |
2 | 548 |
549 | |
237 | 550 /* |
551 * Send service redirect. (Non-Client) | |
552 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
553 faim_export unsigned long aim_sendredirect(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
554 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
555 unsigned short servid, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
556 char *ip, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
557 char *cookie) |
237 | 558 { |
559 struct command_tx_struct *tx; | |
560 struct aim_tlvlist_t *tlvlist = NULL; | |
561 int i = 0; | |
2 | 562 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
412
diff
changeset
|
563 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152))) |
237 | 564 return -1; |
565 | |
566 tx->lock = 1; | |
567 | |
446
6d78b988b479
[gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
568 i += aim_putsnac(tx->data+i, 0x0001, 0x0005, 0x0000, 0x00000000); |
237 | 569 |
570 aim_addtlvtochain16(&tlvlist, 0x000d, servid); | |
571 aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip)); | |
572 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN); | |
573 | |
574 tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i; | |
575 aim_freetlvchain(&tlvlist); | |
576 | |
577 tx->lock = 0; | |
578 return aim_tx_enqueue(sess, tx); | |
579 } |