annotate libfaim/login.c @ 1552:b669f48f0990

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