annotate libfaim/login.c @ 1649:3fe5799b7823

[gaim-migrate @ 1659] Update libfaim. committer: Tailor Script <tailor@pidgin.im>
author Adam Fritzler <mid@auk.cx>
date Tue, 27 Mar 2001 00:51:09 +0000
parents 1e2cc8c8bf3c
children bacb77b0eb06
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(const char *password, unsigned char *encoded);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 faim_export int aim_sendconnack(struct aim_session_t *sess,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 struct aim_conn_t *conn)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 int curbyte=0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 struct command_tx_struct *newpacket;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0001, 4)))
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 return -1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 newpacket->lock = 1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 newpacket->lock = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 return aim_tx_enqueue(sess, newpacket);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 }
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 * 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
36 * login from the Authorizer, passing it the screen name
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 * for verification. If the name is invalid, a 0017/0003
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 * is spit back, with the standard error contents. If valid,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 * a 0017/0007 comes back, which is the signal to send
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 * it the main login command (0017/0002).
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 */
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 faim_export int aim_request_login(struct aim_session_t *sess,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 struct aim_conn_t *conn,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 char *sn)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 int curbyte;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 struct command_tx_struct *newpacket;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 if (!sess || !conn || !sn)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 return -1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51
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 * For ICQ, we enable the ancient horrible login and stuff
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 * 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
55 * 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
56 * really not doing MD5 login.
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 *
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 * 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
59 * 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
60 * Its all AOL's fault anyway, really. I hate AOL. Really. They
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 * 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
62 * things. Like disabling MD5 logins for ICQ UINs, or adding purposefully
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 * wrong TLV lengths, or adding superfluous information to host strings,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 * or... I'll stop.
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 *
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 if ((sn[0] >= '0') && (sn[0] <= '9')) {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 struct command_rx_struct *newrx;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 int i;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 if (!(newrx = (struct command_rx_struct *)malloc(sizeof(struct command_rx_struct))))
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 return -1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 memset(newrx, 0x00, sizeof(struct command_rx_struct));
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 newrx->lock = 1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 newrx->hdrtype = AIM_FRAMETYPE_OSCAR;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 newrx->hdr.oscar.type = 0x02;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 newrx->hdr.oscar.seqnum = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 newrx->commandlen = 10+2+1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 newrx->nofree = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 if (!(newrx->data = malloc(newrx->commandlen))) {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 free(newrx);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 return -1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 }
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 i = aim_putsnac(newrx->data, 0x0017, 0x0007, 0x0000, 0x0000);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 i += aimutil_put16(newrx->data+i, 0x01);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 i += aimutil_putstr(newrx->data+i, "0", 1);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 newrx->conn = conn;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 newrx->next = sess->queue_incoming;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 sess->queue_incoming = newrx;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 newrx->lock = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 sess->flags &= ~AIM_SESS_FLAGS_SNACLOGIN;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 return 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 }
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 sess->flags |= AIM_SESS_FLAGS_SNACLOGIN;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 aim_sendconnack(sess, conn);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 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
106 return -1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 newpacket->lock = 1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0006, 0x0000, 0x00010000);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 newpacket->commandlen = curbyte;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 newpacket->lock = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 return aim_tx_enqueue(sess, newpacket);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 }
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 * send_login(int socket, char *sn, char *password)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 *
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 * This is the initial login request packet.
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 *
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 * The password is encoded before transmition, as per
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 * encode_password(). See that function for their
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 * stupid method of doing it.
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 *
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 * Latest WinAIM:
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 * clientstring = "AOL Instant Messenger (SM), version 4.3.2188/WIN32"
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 * major2 = 0x0109
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 * major = 0x0400
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 * minor = 0x0003
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 * minor2 = 0x0000
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 * build = 0x088c
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 * unknown = 0x00000086
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 * lang = "en"
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 * country = "us"
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 * unknown4a = 0x01
1649
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
139 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
140 * Latest WinAIM that libfaim can emulate without server-side buddylists:
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
141 * clientstring = "AOL Instant Messenger (SM), version 3.5.1670/WIN32"
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
142 * major2 = 0x0004
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
143 * major = 0x0003
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
144 * minor = 0x0005
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
145 * minor2 = 0x0000
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
146 * build = 0x0686
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
147 * unknown =0x0000002a
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
148 *
1535
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 faim_export int aim_send_login (struct aim_session_t *sess,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 struct aim_conn_t *conn,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 char *sn, char *password,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 struct client_info_s *clientinfo,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 char *key)
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 int curbyte=0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 struct command_tx_struct *newpacket;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 if (!clientinfo || !sn || !password)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 return -1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152)))
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 return -1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 newpacket->lock = 1;
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 newpacket->hdr.oscar.type = (sess->flags & AIM_SESS_FLAGS_SNACLOGIN)?0x02:0x01;
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 curbyte = aim_putsnac(newpacket->data, 0x0017, 0x0002, 0x0000, 0x00010000);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 else {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 curbyte = aimutil_put16(newpacket->data, 0x0000);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 }
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) {
1649
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
179 unsigned char digest[16];
1535
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 aim_encode_password_md5(password, key, digest);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0025, 16, (char *)digest);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 } else {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 char *password_encoded;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 password_encoded = (char *) malloc(strlen(password));
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 aim_encode_password(password, password_encoded);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0002, strlen(password), password_encoded);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 free(password_encoded);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 }
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191
1649
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
192 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring);
1535
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 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) {
1649
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
195
1535
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, (unsigned short)clientinfo->major2);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, (unsigned short)clientinfo->major);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, (unsigned short)clientinfo->minor);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, (unsigned short)clientinfo->minor2);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, (unsigned short)clientinfo->build);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 } else {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 /* Use very specific version numbers, to further indicate the hack. */
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, 0x010a);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, 0x0004);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, 0x003c);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, 0x0cce);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 }
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211
1649
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
212 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, strlen(clientinfo->country), clientinfo->country);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
213 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, strlen(clientinfo->lang), clientinfo->lang);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
214
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
215 if (sess->flags & AIM_SESS_FLAGS_SNACLOGIN) {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
216 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
217 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
218 }
1535
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 newpacket->commandlen = curbyte;
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 newpacket->lock = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 return aim_tx_enqueue(sess, newpacket);
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
1649
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
226 faim_export int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest)
1535
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 md5_state_t state;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230 md5_init(&state);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 md5_append(&state, (const md5_byte_t *)key, strlen(key));
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 md5_append(&state, (const md5_byte_t *)password, strlen(password));
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 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
234 md5_finish(&state, (md5_byte_t *)digest);
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 return 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 }
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 /**
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 * aim_encode_password - Encode a password using old XOR method
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 * @password: incoming password
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 * @encoded: buffer to put encoded password
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 *
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 * This takes a const pointer to a (null terminated) string
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 * containing the unencoded password. It also gets passed
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 * an already allocated buffer to store the encoded password.
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 * This buffer should be the exact length of the password without
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 * the null. The encoded password buffer /is not %NULL terminated/.
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 * 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
251 * hope it doesn't change over time!
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 * 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
254 *
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 */
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 static int aim_encode_password(const char *password, unsigned char *encoded)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 u_char encoding_table[] = {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 #if 0 /* old v1 table */
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 0xf3, 0xb3, 0x6c, 0x99,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 0x95, 0x3f, 0xac, 0xb6,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 0xc5, 0xfa, 0x6b, 0x63,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 0x69, 0x6c, 0xc3, 0x9f
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 #else /* v2.1 table, also works for ICQ */
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 0xf3, 0x26, 0x81, 0xc4,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 0x39, 0x86, 0xdb, 0x92,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 0x71, 0xa3, 0xb9, 0xe6,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 0x53, 0x7a, 0x95, 0x7c
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 #endif
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
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 int 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 for (i = 0; i < strlen(password); i++)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 encoded[i] = (password[i] ^ encoding_table[i]);
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 return 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 }
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 /*
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 * Generate an authorization response.
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 *
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 * 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
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_export unsigned long aim_sendauthresp(struct aim_session_t *sess,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 struct aim_conn_t *conn,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 char *sn, int errorcode,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 char *errorurl, char *bosip,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 char *cookie, char *email,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 int regstatus)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 struct command_tx_struct *tx;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 struct aim_tlvlist_t *tlvlist = NULL;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0004, 1152)))
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 return -1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 tx->lock = 1;
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 if (sn)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn));
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 else
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 aim_addtlvtochain_str(&tlvlist, 0x0001, sess->sn, strlen(sess->sn));
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 if (errorcode) {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 aim_addtlvtochain16(&tlvlist, 0x0008, errorcode);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 aim_addtlvtochain_str(&tlvlist, 0x0004, errorurl, strlen(errorurl));
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 aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip));
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email));
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 aim_addtlvtochain16(&tlvlist, 0x0013, (unsigned short)regstatus);
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
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 tx->lock = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 return aim_tx_enqueue(sess, tx);
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 /*
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 * Generate a random cookie. (Non-client use only)
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 faim_export int aim_gencookie(unsigned char *buf)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 int i;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 srand(time(NULL));
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 for (i=0; i < AIM_COOKIELEN; i++)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 buf[i] = 1+(int) (256.0*rand()/(RAND_MAX+0.0));
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 return i;
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 /*
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 * Send Server Ready. (Non-client)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 */
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 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
341 {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 struct command_tx_struct *tx;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 int i = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 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
346 return -1;
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 tx->lock = 1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++);
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 i += aimutil_put16(tx->data+i, 0x0001);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 i += aimutil_put16(tx->data+i, 0x0002);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 i += aimutil_put16(tx->data+i, 0x0003);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 i += aimutil_put16(tx->data+i, 0x0004);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 i += aimutil_put16(tx->data+i, 0x0006);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 i += aimutil_put16(tx->data+i, 0x0008);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 i += aimutil_put16(tx->data+i, 0x0009);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 i += aimutil_put16(tx->data+i, 0x000a);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 i += aimutil_put16(tx->data+i, 0x000b);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 i += aimutil_put16(tx->data+i, 0x000c);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 i += aimutil_put16(tx->data+i, 0x0013);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 i += aimutil_put16(tx->data+i, 0x0015);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 tx->commandlen = i;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 tx->lock = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 return aim_tx_enqueue(sess, tx);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 }
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
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 /*
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 * Send service redirect. (Non-Client)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 */
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 faim_export unsigned long aim_sendredirect(struct aim_session_t *sess,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 struct aim_conn_t *conn,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 unsigned short servid,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 char *ip,
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 char *cookie)
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 {
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 struct command_tx_struct *tx;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 struct aim_tlvlist_t *tlvlist = NULL;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 int i = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152)))
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 return -1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 tx->lock = 1;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 i += aim_putsnac(tx->data+i, 0x0001, 0x0005, 0x0000, 0x00000000);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 aim_addtlvtochain16(&tlvlist, 0x000d, servid);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip));
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 aim_freetlvchain(&tlvlist);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 tx->lock = 0;
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 return aim_tx_enqueue(sess, tx);
1e2cc8c8bf3c [gaim-migrate @ 1545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 }
1649
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
401
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
402
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
403 static int hostonline(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
404 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
405 rxcallback_t userfunc;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
406 int ret = 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
407 unsigned short *families;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
408 int famcount, i;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
409
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
410 famcount = datalen/2;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
411
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
412 if (!(families = malloc(datalen)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
413 return 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
414
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
415 for (i = 0; i < famcount; i++)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
416 families[i] = aimutil_get16(data+(i*2));
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
417
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
418 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
419 ret = userfunc(sess, rx, famcount, families);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
420
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
421 free(families);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
422
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
423 return ret;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
424 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
425
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
426 static int redirect(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
427 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
428 int serviceid;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
429 unsigned char *cookie;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
430 char *ip;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
431 rxcallback_t userfunc;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
432 struct aim_tlvlist_t *tlvlist;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
433 char *chathack = NULL;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
434 int chathackex = 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
435 int ret = 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
436
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
437 tlvlist = aim_readtlvchain(data, datalen);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
438
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
439 if (!aim_gettlv(tlvlist, 0x000d, 1) ||
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
440 !aim_gettlv(tlvlist, 0x0005, 1) ||
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
441 !aim_gettlv(tlvlist, 0x0006, 1)) {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
442 aim_freetlvchain(&tlvlist);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
443 return 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
444 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
445
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
446 serviceid = aim_gettlv16(tlvlist, 0x000d, 1);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
447 ip = aim_gettlv_str(tlvlist, 0x0005, 1);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
448 cookie = aim_gettlv_str(tlvlist, 0x0006, 1);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
449
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
450 /*
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
451 * Chat hack.
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
452 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
453 */
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
454 if ((serviceid == AIM_CONN_TYPE_CHAT) && sess->pendingjoin) {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
455 chathack = sess->pendingjoin;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
456 chathackex = sess->pendingjoinexchange;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
457 sess->pendingjoin = NULL;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
458 sess->pendingjoinexchange = 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
459 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
460
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
461 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
462 ret = userfunc(sess, rx, serviceid, ip, cookie, chathack, chathackex);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
463
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
464 free(ip);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
465 free(cookie);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
466 free(chathack);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
467
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
468 aim_freetlvchain(&tlvlist);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
469
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
470 return ret;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
471 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
472
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
473 /*
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
474 * The Rate Limiting System, An Abridged Guide to Nonsense.
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
475 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
476 * OSCAR defines several 'rate classes'. Each class has seperate
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
477 * rate limiting properties (limit level, alert level, disconnect
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
478 * level, etc), and a set of SNAC family/type pairs associated with
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
479 * it. The rate classes, their limiting properties, and the definitions
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
480 * of which SNACs are belong to which class, are defined in the
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
481 * Rate Response packet at login to each host.
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
482 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
483 * Logically, all rate offenses within one class count against further
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
484 * offenses for other SNACs in the same class (ie, sending messages
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
485 * too fast will limit the number of user info requests you can send,
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
486 * since those two SNACs are in the same rate class).
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
487 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
488 * Since the rate classes are defined dynamically at login, the values
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
489 * below may change. But they seem to be fairly constant.
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
490 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
491 * Currently, BOS defines five rate classes, with the commonly used
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
492 * members as follows...
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
493 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
494 * Rate class 0x0001:
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
495 * - Everything thats not in any of the other classes
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
496 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
497 * Rate class 0x0002:
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
498 * - Buddy list add/remove
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
499 * - Permit list add/remove
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
500 * - Deny list add/remove
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
501 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
502 * Rate class 0x0003:
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
503 * - User information requests
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
504 * - Outgoing ICBMs
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
505 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
506 * Rate class 0x0004:
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
507 * - A few unknowns: 2/9, 2/b, and f/2
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
508 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
509 * Rate class 0x0005:
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
510 * - Chat room create
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
511 * - Outgoing chat ICBMs
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
512 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
513 * The only other thing of note is that class 5 (chat) has slightly looser
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
514 * limiting properties than class 3 (normal messages). But thats just a
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
515 * small bit of trivia for you.
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
516 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
517 * The last thing that needs to be learned about the rate limiting
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
518 * system is how the actual numbers relate to the passing of time. This
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
519 * seems to be a big mystery.
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
520 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
521 */
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
522
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
523 /* XXX parse this */
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
524 static int rateresp(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
525 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
526 rxcallback_t userfunc;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
527
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
528 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
529 return userfunc(sess, rx);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
530
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
531 return 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
532 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
533
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
534 static int ratechange(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
535 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
536 rxcallback_t userfunc;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
537 int i = 0, code;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
538 unsigned long currentavg, maxavg;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
539 unsigned long rateclass, windowsize, clear, alert, limit, disconnect;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
540
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
541 code = aimutil_get16(data+i);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
542 i += 2;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
543
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
544 rateclass = aimutil_get16(data+i);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
545 i += 2;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
546
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
547 windowsize = aimutil_get32(data+i);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
548 i += 4;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
549 clear = aimutil_get32(data+i);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
550 i += 4;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
551 alert = aimutil_get32(data+i);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
552 i += 4;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
553 limit = aimutil_get32(data+i);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
554 i += 4;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
555 disconnect = aimutil_get32(data+i);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
556 i += 4;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
557 currentavg = aimutil_get32(data+i);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
558 i += 4;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
559 maxavg = aimutil_get32(data+i);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
560 i += 4;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
561
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
562 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
563 return userfunc(sess, rx, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg, maxavg);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
564
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
565 return 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
566 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
567
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
568 /* XXX parse this */
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
569 static int selfinfo(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
570 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
571 rxcallback_t userfunc;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
572
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
573 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
574 return userfunc(sess, rx);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
575
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
576 return 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
577 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
578
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
579 static int evilnotify(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
580 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
581 rxcallback_t userfunc = NULL;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
582 int i = 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
583 unsigned short newevil;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
584 struct aim_userinfo_s userinfo;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
585
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
586 newevil = aimutil_get16(data);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
587 i += 2;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
588
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
589 memset(&userinfo, 0, sizeof(struct aim_userinfo_s));
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
590
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
591 if (datalen-i)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
592 i += aim_extractuserinfo(sess, data+i, &userinfo);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
593
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
594 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
595 return userfunc(sess, rx, newevil, &userinfo);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
596
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
597 return 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
598 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
599
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
600 static int motd(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
601 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
602 rxcallback_t userfunc;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
603 char *msg = NULL;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
604 int ret = 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
605 struct aim_tlvlist_t *tlvlist;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
606 unsigned short id;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
607
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
608 /*
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
609 * Code.
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
610 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
611 * Valid values:
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
612 * 1 Mandatory upgrade
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
613 * 2 Advisory upgrade
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
614 * 3 System bulletin
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
615 * 4 Nothing's wrong ("top o the world" -- normal)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
616 *
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
617 */
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
618 id = aimutil_get16(data);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
619
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
620 /*
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
621 * TLVs follow
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
622 */
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
623 if ((tlvlist = aim_readtlvchain(data+2, datalen-2)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
624 msg = aim_gettlv_str(tlvlist, 0x000b, 1);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
625
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
626 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
627 ret = userfunc(sess, rx, id, msg);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
628
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
629 free(msg);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
630
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
631 aim_freetlvchain(&tlvlist);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
632
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
633 return ret;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
634 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
635
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
636 static int hostversions(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
637 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
638 rxcallback_t userfunc;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
639 int vercount;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
640
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
641 vercount = datalen/4;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
642
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
643 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
644 return userfunc(sess, rx, vercount, data);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
645
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
646 return 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
647 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
648
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
649 static int snachandler(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
650 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
651
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
652 if (snac->subtype == 0x0003)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
653 return hostonline(sess, mod, rx, snac, data, datalen);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
654 else if (snac->subtype == 0x0005)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
655 return redirect(sess, mod, rx, snac, data, datalen);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
656 else if (snac->subtype == 0x0007)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
657 return rateresp(sess, mod, rx, snac, data, datalen);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
658 else if (snac->subtype == 0x000a)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
659 return ratechange(sess, mod, rx, snac, data, datalen);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
660 else if (snac->subtype == 0x000f)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
661 return selfinfo(sess, mod, rx, snac, data, datalen);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
662 else if (snac->subtype == 0x0010)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
663 return evilnotify(sess, mod, rx, snac, data, datalen);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
664 else if (snac->subtype == 0x0013)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
665 return motd(sess, mod, rx, snac, data, datalen);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
666 else if (snac->subtype == 0x0018)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
667 return hostversions(sess, mod, rx, snac, data, datalen);
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
668
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
669 return 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
670 }
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
671
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
672 faim_internal int general_modfirst(struct aim_session_t *sess, aim_module_t *mod)
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
673 {
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
674
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
675 mod->family = 0x0001;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
676 mod->version = 0x0000;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
677 mod->flags = 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
678 strncpy(mod->name, "general", sizeof(mod->name));
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
679 mod->snachandler = snachandler;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
680
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
681 return 0;
3fe5799b7823 [gaim-migrate @ 1659]
Adam Fritzler <mid@auk.cx>
parents: 1535
diff changeset
682 }