annotate libfaim/aim_login.c @ 741:58a6e6e26695

[gaim-migrate @ 751] oscar logins work better (?), aliases in convo windows. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 22 Aug 2000 23:38:47 +0000
parents 58106806ac2b
children 72e556f6b99d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * aim_login.c
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * This contains all the functions needed to actually login.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 */
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7
283
0f14e6d8a51b [gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 248
diff changeset
8 #include <faim/aim.h>
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
10 #include "md5.h"
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
11
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
12 static int aim_encode_password_md5(const char *password, const char *key, md5_byte_t *digest);
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 /*
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * FIXME: Reimplement the TIS stuff.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 */
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 #ifdef TIS_TELNET_PROXY
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 #include "tis_telnet_proxy.h"
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 #endif
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
21 int aim_sendconnack(struct aim_session_t *sess,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
22 struct aim_conn_t *conn)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
23 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
24 int curbyte=0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
25
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
26 struct command_tx_struct *newpacket;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
27
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
28 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0001, conn, 4)))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
29 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
30
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
31 newpacket->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
32
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
33 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
34 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
35
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
36 newpacket->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
37 return aim_tx_enqueue(sess, newpacket);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
38 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
39
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 /*
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
41 * In AIM 3.5 protocol, the first stage of login is to request
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
42 * login from the Authorizer, passing it the screen name
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
43 * for verification. If the name is invalid, a 0017/0003
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
44 * is spit back, with the standard error contents. If valid,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
45 * a 0017/0007 comes back, which is the signal to send
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
46 * it the main login command (0017/0002).
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
47 */
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
48 int aim_request_login(struct aim_session_t *sess,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
49 struct aim_conn_t *conn,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
50 char *sn)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
51 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
52 int curbyte=0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
53
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
54 struct command_tx_struct *newpacket;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
55
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
56 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+2+2+strlen(sn))))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
57 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
58
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
59 newpacket->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
60
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
61 curbyte += aim_putsnac(newpacket->data+curbyte, 0x0017, 0x0006, 0x0000, 0x00010000);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
62 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
63
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
64 newpacket->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
65 return aim_tx_enqueue(sess, newpacket);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
66 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
67
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
68 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
69 * send_login(int socket, char *sn, char *password)
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
70 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
71 * This is the initial login request packet.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73 * The password is encoded before transmition, as per
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
74 * encode_password(). See that function for their
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
75 * stupid method of doing it.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
76 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77 */
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
78 int aim_send_login (struct aim_session_t *sess,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
79 struct aim_conn_t *conn,
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
80 char *sn, char *password, struct client_info_s *clientinfo,
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
81 char *key)
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 {
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83 int curbyte=0;
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
84 md5_byte_t digest[16];
331
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
85
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
86 struct command_tx_struct *newpacket;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
87
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
88 if (!clientinfo || !sn || !password)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
89 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
90
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
91 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
92 return -1;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
93
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
94 newpacket->lock = 1;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
95
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
96 newpacket->hdr.oscar.type = 0x02;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
97
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
98 curbyte = aim_putsnac(newpacket->data+curbyte, 0x0017, 0x0002, 0x0000, 0x00010000);
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
99
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
100 curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
101
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
102 aim_encode_password_md5(password, key, digest);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
103 curbyte+= aim_puttlv_str(newpacket->data+curbyte, 0x0025, 16, digest);
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104
446
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
105 /* XXX is clientstring required by oscar? */
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
106 if (strlen(clientinfo->clientstring))
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
107 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring);
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
108
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
109 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, clientinfo->major2);
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
110 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, clientinfo->major);
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
111 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, clientinfo->minor);
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
112 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, clientinfo->minor2);
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
113 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, clientinfo->build);
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
114
446
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
115 curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown);
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
116 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015);
331
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
117
446
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
118 if (strlen(clientinfo->country))
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
119 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, strlen(clientinfo->country), clientinfo->country);
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
120 else
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
121 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, 2, "us");
331
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
122
446
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
123 if (strlen(clientinfo->lang))
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
124 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, strlen(clientinfo->lang), clientinfo->lang);
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
125 else
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
126 curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, 2, "en");
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
127
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
128 newpacket->commandlen = curbyte;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
129
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
130 newpacket->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
131 return aim_tx_enqueue(sess, newpacket);
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
132 }
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
133
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
134 static int aim_encode_password_md5(const char *password, const char *key, md5_byte_t *digest)
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
135 {
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
136 md5_state_t state;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
137
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
138 md5_init(&state);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
139 md5_append(&state, (const md5_byte_t *)key, strlen(key));
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
140 md5_append(&state, (const md5_byte_t *)password, strlen(password));
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
141 md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING));
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
142 md5_finish(&state, (md5_byte_t *)digest);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
143
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
144 return 0;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
145 }
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
146
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
147 /*
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
148 * int encode_password(
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
149 * const char *password,
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
150 * char *encoded
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
151 * );
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
152 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
153 * This takes a const pointer to a (null terminated) string
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
154 * containing the unencoded password. It also gets passed
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
155 * an already allocated buffer to store the encoded password.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
156 * This buffer should be the exact length of the password without
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
157 * the null. The encoded password buffer IS NOT NULL TERMINATED.
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
158 *
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
159 * The encoding_table seems to be a fixed set of values. We'll
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
160 * hope it doesn't change over time!
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
161 *
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
162 * NOTE: This is no longer used. Its here for historical reference.
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
163 *
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
164 */
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
165 #if 0
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
166 static int aim_encode_password(const char *password, unsigned char *encoded)
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
167 {
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
168 u_char encoding_table[] = {
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
169 #if 0 /* old v1 table */
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
170 0xf3, 0xb3, 0x6c, 0x99,
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
171 0x95, 0x3f, 0xac, 0xb6,
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
172 0xc5, 0xfa, 0x6b, 0x63,
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
173 0x69, 0x6c, 0xc3, 0x9f
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
174 #else /* v2.1 table, also works for ICQ */
412
ad08e67ec874 [gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 331
diff changeset
175 0xf3, 0x26, 0x81, 0xc4,
ad08e67ec874 [gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 331
diff changeset
176 0x39, 0x86, 0xdb, 0x92,
ad08e67ec874 [gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 331
diff changeset
177 0x71, 0xa3, 0xb9, 0xe6,
ad08e67ec874 [gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 331
diff changeset
178 0x53, 0x7a, 0x95, 0x7c
ad08e67ec874 [gaim-migrate @ 422]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 331
diff changeset
179 #endif
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
180 };
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
181
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
182 int i;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
183
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
184 for (i = 0; i < strlen(password); i++)
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
185 encoded[i] = (password[i] ^ encoding_table[i]);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
186
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
187 return 0;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
188 }
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
189 #endif
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
191 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
192 * This is sent back as a general response to the login command.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
193 * It can be either an error or a success, depending on the
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
194 * precense of certain TLVs.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
195 *
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
196 * The client should check the value of logininfo->errorcode. If
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
197 * its nonzero, there was an error.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
198 *
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
199 */
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
200 int aim_authparse(struct aim_session_t *sess,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
201 struct command_rx_struct *command)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
202 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
203 struct aim_tlvlist_t *tlvlist;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
204 int ret = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
205 char *sn;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
206 rxcallback_t userfunc = NULL;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
207
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
208 memset(&sess->logininfo, 0x00, sizeof(sess->logininfo));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
209
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
210 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
211 * Read block of TLVs. All further data is derived
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
212 * from what is parsed here.
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
213 *
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
214 * For SNAC login, there's a 17/3 SNAC header in front.
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
215 *
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
216 */
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
217 tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10);
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
218
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
219 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
220 * No matter what, we should have a screen name.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
221 */
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
222 sn = aim_gettlv_str(tlvlist, 0x0001, 1);
715
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
223 strncpy(sess->logininfo.screen_name, sn, strlen(sn));
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
224 free(sn);
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
225
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
226 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
227 * Check for an error code. If so, we should also
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
228 * have an error url.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
229 */
331
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
230 if (aim_gettlv(tlvlist, 0x0008, 1)) {
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
231 struct aim_tlv_t *errtlv;
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
232 errtlv = aim_gettlv(tlvlist, 0x0008, 1);
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
233 sess->logininfo.errorcode = aimutil_get16(errtlv->value);
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
234 sess->logininfo.errorurl = aim_gettlv_str(tlvlist, 0x0004, 1);
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
235 }
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
236 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
237 * If we have both an IP number (0x0005) and a cookie (0x0006),
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
238 * then the login was successful.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
239 */
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
240 else if (aim_gettlv(tlvlist, 0x0005, 1) && aim_gettlv(tlvlist, 0x0006, 1)
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
241 /*aim_gettlv(tlvlist, 0x0006, 1)->length*/) {
331
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
242 struct aim_tlv_t *tmptlv;
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
243
331
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
244 /*
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
245 * IP address of BOS server.
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
246 */
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
247 sess->logininfo.BOSIP = aim_gettlv_str(tlvlist, 0x0005, 1);
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
248
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
249 /*
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
250 * Authorization Cookie
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
251 */
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
252 tmptlv = aim_gettlv(tlvlist, 0x0006, 1);
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
253 memcpy(sess->logininfo.cookie, tmptlv->value, AIM_COOKIELEN);
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
254
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
255 /*
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
256 * The email address attached to this account
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
257 * Not available for ICQ logins.
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
258 */
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
259 if (aim_gettlv(tlvlist, 0x0011, 1))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
260 sess->logininfo.email = aim_gettlv_str(tlvlist, 0x0011, 1);
331
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
261
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
262 /*
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
263 * The registration status. (Not real sure what it means.)
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
264 * Not available for ICQ logins.
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
265 */
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
266 if ((tmptlv = aim_gettlv(tlvlist, 0x0013, 1)))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
267 sess->logininfo.regstatus = aimutil_get16(tmptlv->value);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
268
331
f3c8d79688db [gaim-migrate @ 341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 283
diff changeset
269 }
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
270
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
271 userfunc = aim_callhandler(command->conn, 0x0017, 0x0003);
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
272
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
273 if (userfunc)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
274 ret = userfunc(sess, command);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
275
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
276 aim_freetlvchain(&tlvlist);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
277
715
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
278 if (sess->logininfo.BOSIP) {
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
279 free(sess->logininfo.BOSIP);
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
280 sess->logininfo.BOSIP = NULL;
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
281 }
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
282 if (sess->logininfo.email) {
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
283 free(sess->logininfo.email);
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
284 sess->logininfo.email = NULL;
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
285 }
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
286 if (sess->logininfo.errorurl) {
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
287 free(sess->logininfo.errorurl);
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
288 sess->logininfo.errorurl = NULL;
58106806ac2b [gaim-migrate @ 725]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 446
diff changeset
289 }
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
290
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
291 return ret;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
292 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
293
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
294 /*
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
295 * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
296 * by only its length in a two byte word.
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
297 *
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
298 * Calls the client, which should then use the value to call aim_send_login.
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
299 *
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
300 */
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
301 int aim_authkeyparse(struct aim_session_t *sess, struct command_rx_struct *command)
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
302 {
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
303 unsigned char *key;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
304 int keylen;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
305 int ret = 1;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
306 rxcallback_t userfunc;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
307
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
308 keylen = aimutil_get16(command->data+10);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
309 key = malloc(keylen+1);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
310 memcpy(key, command->data+12, keylen);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
311 key[keylen] = '\0';
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
312
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
313 if ((userfunc = aim_callhandler(command->conn, 0x0017, 0x0007)))
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
314 ret = userfunc(sess, command, key);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
315
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
316 free(key);
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
317
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
318 return ret;
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
319 }
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
320
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 715
diff changeset
321 /*
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
322 * Generate an authorization response.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
323 *
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
324 * You probably don't want this unless you're writing an AIM server.
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
325 *
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
326 */
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
327 unsigned long aim_sendauthresp(struct aim_session_t *sess,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
328 struct aim_conn_t *conn,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
329 char *sn, char *bosip,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
330 char *cookie, char *email,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
331 int regstatus)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
332 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
333 struct command_tx_struct *tx;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
334 struct aim_tlvlist_t *tlvlist = NULL;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
335
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
336 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0004, conn, 1152)))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
337 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
338
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
339 tx->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
340
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
341 if (sn)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
342 aim_addtlvtochain_str(&tlvlist, 0x0001, sn, strlen(sn));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
343 else
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
344 aim_addtlvtochain_str(&tlvlist, 0x0001, sess->logininfo.screen_name, strlen(sess->logininfo.screen_name));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
345
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
346 if (sess->logininfo.errorcode) {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
347 aim_addtlvtochain16(&tlvlist, 0x0008, sess->logininfo.errorcode);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
348 aim_addtlvtochain_str(&tlvlist, 0x0004, sess->logininfo.errorurl, strlen(sess->logininfo.errorurl));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
349 } else {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
350 aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
351 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
352 aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
353 aim_addtlvtochain16(&tlvlist, 0x0013, regstatus);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
354 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
355
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
356 tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
357 tx->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
358 return aim_tx_enqueue(sess, tx);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
359 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
360
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
361 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
362 * Generate a random cookie. (Non-client use only)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
363 */
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
364 int aim_gencookie(unsigned char *buf)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
365 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
366 int i;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
367
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
368 srand(time(NULL));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
369
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
370 for (i=0; i < AIM_COOKIELEN; i++)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
371 buf[i] = 1+(int) (256.0*rand()/(RAND_MAX+0.0));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
372
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
373 return i;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
374 }
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
375
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
376 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
377 * Send Server Ready. (Non-client)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
378 */
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
379 int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
380 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
381 struct command_tx_struct *tx;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
382 int i = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
383
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
384 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+0x22)))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
385 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
386
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
387 tx->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
388
248
cfc73b8501a7 [gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 237
diff changeset
389 i += aim_putsnac(tx->data, 0x0001, 0x0003, 0x0000, sess->snac_nextid++);
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
390
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
391 i += aimutil_put16(tx->data+i, 0x0001);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
392 i += aimutil_put16(tx->data+i, 0x0002);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
393 i += aimutil_put16(tx->data+i, 0x0003);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
394 i += aimutil_put16(tx->data+i, 0x0004);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
395 i += aimutil_put16(tx->data+i, 0x0006);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
396 i += aimutil_put16(tx->data+i, 0x0008);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
397 i += aimutil_put16(tx->data+i, 0x0009);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
398 i += aimutil_put16(tx->data+i, 0x000a);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
399 i += aimutil_put16(tx->data+i, 0x000b);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
400 i += aimutil_put16(tx->data+i, 0x000c);
248
cfc73b8501a7 [gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 237
diff changeset
401 i += aimutil_put16(tx->data+i, 0x0013);
cfc73b8501a7 [gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 237
diff changeset
402 i += aimutil_put16(tx->data+i, 0x0015);
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
403
248
cfc73b8501a7 [gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 237
diff changeset
404 tx->commandlen = i;
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
405 tx->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
406 return aim_tx_enqueue(sess, tx);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
407 }
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
408
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
409
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
410 /*
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
411 * Send service redirect. (Non-Client)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
412 */
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
413 unsigned long aim_sendredirect(struct aim_session_t *sess,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
414 struct aim_conn_t *conn,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
415 unsigned short servid,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
416 char *ip,
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
417 char *cookie)
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
418 {
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
419 struct command_tx_struct *tx;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
420 struct aim_tlvlist_t *tlvlist = NULL;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
421 int i = 0;
2
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
422
445
e4c34ca88d9b [gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 412
diff changeset
423 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
424 return -1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
425
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
426 tx->lock = 1;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
427
446
6d78b988b479 [gaim-migrate @ 456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 445
diff changeset
428 i += aim_putsnac(tx->data+i, 0x0001, 0x0005, 0x0000, 0x00000000);
237
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
429
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
430 aim_addtlvtochain16(&tlvlist, 0x000d, servid);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
431 aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip));
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
432 aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
433
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
434 tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist)+i;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
435 aim_freetlvchain(&tlvlist);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
436
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
437 tx->lock = 0;
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
438 return aim_tx_enqueue(sess, tx);
6ced2f1c8b24 [gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2
diff changeset
439 }