annotate libfaim/aim_login.c @ 1274:32e819c194fd

[gaim-migrate @ 1284] lalalalal leee oyy committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Thu, 14 Dec 2000 17:26:54 +0000
parents 8342d3aab1f1
children 4c5c2fcb83cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * aim_login.c
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * This contains all the functions needed to actually login.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 */
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7
283
0f14e6d8a51b [gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 248
diff changeset
8 #include <faim/aim.h>
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 /*
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * FIXME: Reimplement the TIS stuff.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 */
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 #ifdef TIS_TELNET_PROXY
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 #include "tis_telnet_proxy.h"
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 #endif
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
24 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
25 int curbyte=0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
26
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
27 struct command_tx_struct *newpacket;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
30 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
31
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
32 newpacket->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
33
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
34 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
35 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
36
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
37 newpacket->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
38 return aim_tx_enqueue(sess, newpacket);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
39 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
40
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 /*
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
42 * In AIM 3.5 protocol, the first stage of login is to request
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
43 * login from the Authorizer, passing it the screen name
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
44 * for verification. If the name is invalid, a 0017/0003
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
45 * is spit back, with the standard error contents. If valid,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
46 * a 0017/0007 comes back, which is the signal to send
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
47 * it the main login command (0017/0002).
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
52 {
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 889
diff changeset
53 int curbyte;
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
54 struct command_tx_struct *newpacket;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
113 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
114
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
115 newpacket->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
118 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
119
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 889
diff changeset
120 newpacket->commandlen = curbyte;
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
121 newpacket->lock = 0;
1081
efcacae6acdb [gaim-migrate @ 1091]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 889
diff changeset
122
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
123 return aim_tx_enqueue(sess, newpacket);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
124 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
125
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
126 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
127 * send_login(int socket, char *sn, char *password)
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
128 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
129 * This is the initial login request packet.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
130 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
131 * The password is encoded before transmition, as per
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
132 * encode_password(). See that function for their
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
133 * stupid method of doing it.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
152 {
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
153 int curbyte=0;
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
154 struct command_tx_struct *newpacket;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
155
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
156 if (!clientinfo || !sn || !password)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
157 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
160 return -1;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
161
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
162 newpacket->lock = 1;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
224
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
225 newpacket->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
226 return aim_tx_enqueue(sess, newpacket);
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
227 }
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
246 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
247 * This takes a const pointer to a (null terminated) string
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
248 * containing the unencoded password. It also gets passed
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
249 * an already allocated buffer to store the encoded password.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
252 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
253 * The encoding_table seems to be a fixed set of values. We'll
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
254 * hope it doesn't change over time!
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
260 {
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
263 0xf3, 0xb3, 0x6c, 0x99,
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
264 0x95, 0x3f, 0xac, 0xb6,
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
265 0xc5, 0xfa, 0x6b, 0x63,
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
273 };
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
274
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
275 int i;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
276
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
277 for (i = 0; i < strlen(password); i++)
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
278 encoded[i] = (password[i] ^ encoding_table[i]);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
279
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
280 return 0;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
281 }
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
282
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
283 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
284 * This is sent back as a general response to the login command.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
285 * It can be either an error or a success, depending on the
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
286 * precense of certain TLVs.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
289 * its nonzero, there was an error.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
290 *
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
294 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
295 struct aim_tlvlist_t *tlvlist;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
296 int ret = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
305
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
306 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
307 * Read block of TLVs. All further data is derived
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
318 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
319 * No matter what, we should have a screen name.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
327 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
328 * Check for an error code. If so, we should also
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
329 * have an error url.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
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.
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
364 */
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
365 if (aim_gettlv(tlvlist, 0x0013, 1))
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
366 regstatus = aim_gettlv16(tlvlist, 0x0013, 1);
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
367
1247
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
368 if (aim_gettlv(tlvlist, 0x0040, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
369 latestbetabuild = aim_gettlv32(tlvlist, 0x0040, 1);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
370 if (aim_gettlv(tlvlist, 0x0041, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
371 latestbetaurl = aim_gettlv_str(tlvlist, 0x0041, 1);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
372 if (aim_gettlv(tlvlist, 0x0042, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
373 latestbetainfo = aim_gettlv_str(tlvlist, 0x0042, 1);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
374 if (aim_gettlv(tlvlist, 0x0043, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
375 latestbeta = aim_gettlv_str(tlvlist, 0x0043, 1);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
376 if (aim_gettlv(tlvlist, 0x0048, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
377 ; /* no idea what this is */
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
378
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
379 if (aim_gettlv(tlvlist, 0x0044, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
380 latestbuild = aim_gettlv32(tlvlist, 0x0044, 1);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
381 if (aim_gettlv(tlvlist, 0x0045, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
382 latestreleaseurl = aim_gettlv_str(tlvlist, 0x0045, 1);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
383 if (aim_gettlv(tlvlist, 0x0046, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
384 latestreleaseinfo = aim_gettlv_str(tlvlist, 0x0046, 1);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
385 if (aim_gettlv(tlvlist, 0x0047, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
386 latestrelease = aim_gettlv_str(tlvlist, 0x0047, 1);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
387 if (aim_gettlv(tlvlist, 0x0049, 1))
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
388 ; /* no idea what this is */
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
389
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
390
1245
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
391 if ((userfunc = aim_callhandler(command->conn, 0x0017, 0x0003)))
1247
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
392 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
393
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
394
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
395 if (sn)
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
396 free(sn);
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
397 if (bosip)
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
398 free(bosip);
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
399 if (errurl)
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
400 free(errurl);
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
401 if (email)
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
402 free(email);
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
403 if (cookie)
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
404 free(cookie);
1247
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
405 if (latestrelease)
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
406 free(latestrelease);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
407 if (latestreleaseurl)
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
408 free(latestreleaseurl);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
409 if (latestbeta)
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
410 free(latestbeta);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
411 if (latestbetaurl)
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
412 free(latestbetaurl);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
413 if (latestreleaseinfo)
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
414 free(latestreleaseinfo);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
415 if (latestbetainfo)
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
416 free(latestbetainfo);
f50146ce818e [gaim-migrate @ 1257]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1245
diff changeset
417
1245
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
418 aim_freetlvchain(&tlvlist);
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
419
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
420 return ret;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
421 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
422
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
423 /*
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
424 * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
425 * by only its length in a two byte word.
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
426 *
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
427 * 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
428 *
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
429 */
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
430 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
431 {
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
432 unsigned char *key;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
433 int keylen;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
434 int ret = 1;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
435 rxcallback_t userfunc;
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 keylen = aimutil_get16(command->data+10);
771
72e556f6b99d [gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 741
diff changeset
438 if (!(key = malloc(keylen+1)))
72e556f6b99d [gaim-migrate @ 781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 741
diff changeset
439 return ret;
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
440 memcpy(key, command->data+12, keylen);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
441 key[keylen] = '\0';
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
442
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
443 if ((userfunc = aim_callhandler(command->conn, 0x0017, 0x0007)))
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
444 ret = userfunc(sess, command, (char *)key);
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
445
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
446 free(key);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
447
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
448 return ret;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
449 }
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 /*
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
452 * Generate an authorization response.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
453 *
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
454 * You probably don't want this unless you're writing an AIM server.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
455 *
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
456 */
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
457 faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess,
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
458 struct aim_conn_t *conn,
1245
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
459 char *sn, int errorcode,
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
460 char *errorurl, char *bosip,
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
461 char *cookie, char *email,
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
462 int regstatus)
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
463 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
464 struct command_tx_struct *tx;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
465 struct aim_tlvlist_t *tlvlist = NULL;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
466
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
467 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0004, conn, 1152)))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
468 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
469
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
470 tx->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
471
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
472 if (sn)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
473 aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
474 else
1245
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
475 aim_addtlvtochain_str(&tlvlist, 0x0001, sess->sn, strlen(sess->sn));
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
476
1245
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
477 if (errorcode) {
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
478 aim_addtlvtochain16(&tlvlist, 0x0008, errorcode);
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
479 aim_addtlvtochain_str(&tlvlist, 0x0004, errorurl, strlen(errorurl));
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
480 } else {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
481 aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
482 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
483 aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email));
889
e1da6a6ec42b [gaim-migrate @ 899]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 840
diff changeset
484 aim_addtlvtochain16(&tlvlist, 0x0013, (unsigned short)regstatus);
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
485 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
486
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
487 tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
488 tx->lock = 0;
1245
2ac6ccb94229 [gaim-migrate @ 1255]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1081
diff changeset
489
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
490 return aim_tx_enqueue(sess, tx);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
491 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
492
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
493 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
494 * Generate a random cookie. (Non-client use only)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
495 */
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
496 faim_export int aim_gencookie(unsigned char *buf)
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
497 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
498 int i;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
499
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
500 srand(time(NULL));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
501
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
502 for (i=0; i < AIM_COOKIELEN; i++)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
503 buf[i] = 1+(int) (256.0*rand()/(RAND_MAX+0.0));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
504
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
505 return i;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
506 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
507
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
508 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
509 * Send Server Ready. (Non-client)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
510 */
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
511 faim_export int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn)
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
512 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
513 struct command_tx_struct *tx;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
514 int i = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
515
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
516 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+0x22)))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
517 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
518
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
519 tx->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
520
248
cfc73b8501a7 [gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 237
diff changeset
521 i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++);
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
522
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
523 i += aimutil_put16(tx->data+i, 0x0001);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
524 i += aimutil_put16(tx->data+i, 0x0002);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
525 i += aimutil_put16(tx->data+i, 0x0003);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
526 i += aimutil_put16(tx->data+i, 0x0004);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
527 i += aimutil_put16(tx->data+i, 0x0006);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
528 i += aimutil_put16(tx->data+i, 0x0008);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
529 i += aimutil_put16(tx->data+i, 0x0009);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
530 i += aimutil_put16(tx->data+i, 0x000a);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
531 i += aimutil_put16(tx->data+i, 0x000b);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
532 i += aimutil_put16(tx->data+i, 0x000c);
248
cfc73b8501a7 [gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 237
diff changeset
533 i += aimutil_put16(tx->data+i, 0x0013);
cfc73b8501a7 [gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 237
diff changeset
534 i += aimutil_put16(tx->data+i, 0x0015);
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
535
248
cfc73b8501a7 [gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 237
diff changeset
536 tx->commandlen = i;
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
537 tx->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
538 return aim_tx_enqueue(sess, tx);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
539 }
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
540
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
541
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
542 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
543 * Send service redirect. (Non-Client)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
544 */
840
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
545 faim_export unsigned long aim_sendredirect(struct aim_session_t *sess,
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
546 struct aim_conn_t *conn,
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
547 unsigned short servid,
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
548 char *ip,
595ac7759563 [gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 771
diff changeset
549 char *cookie)
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
550 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
551 struct command_tx_struct *tx;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
552 struct aim_tlvlist_t *tlvlist = NULL;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
553 int i = 0;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
554
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
555 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
556 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
557
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
558 tx->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
559
446
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
560 i += aim_putsnac(tx->data+i, 0x0001, 0x0005, 0x0000, 0x00000000);
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
561
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
562 aim_addtlvtochain16(&tlvlist, 0x000d, servid);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
563 aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
564 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
565
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
566 tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
567 aim_freetlvchain(&tlvlist);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
568
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
569 tx->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
570 return aim_tx_enqueue(sess, tx);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
571 }