annotate libfaim/aim_auth.c @ 94:9f6ce50ffb78

[gaim-migrate @ 104] Woohoo, the landing of the plugins. Nearly everything necessary is here. The only thing missing is that you can't load a plugin without signing on first (at least, not without some trickery). committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 09 Apr 2000 11:18:25 +0000
parents 68b230f8da5f
children 6ced2f1c8b24
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_auth.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 Deals with the authorizer.
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 #include "aim.h"
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 /* this just pushes the passed cookie onto the passed connection -- NO SNAC! */
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 int aim_auth_sendcookie(struct aim_conn_t *conn, char *chipsahoy)
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 {
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 struct command_tx_struct newpacket;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 int curbyte=0;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 newpacket.lock = 1;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 if (conn==NULL)
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 else
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 newpacket.conn = conn;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23 newpacket.type = 0x0001; /* channel 1 (no SNACs, you know) */
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 newpacket.commandlen = 4 + 2 + 2 + 0x100;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 newpacket.data = (char *) calloc(1, newpacket.commandlen);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0006);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0100);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 memcpy(&(newpacket.data[curbyte]), chipsahoy, 0x100);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 aim_tx_enqueue(&newpacket);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 return 0;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 }
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 u_long aim_auth_clientready(struct aim_conn_t *conn)
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 {
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 struct command_tx_struct newpacket;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 int curbyte = 0;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44 newpacket.lock = 1;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46 if (conn==NULL)
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48 else
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 newpacket.conn = conn;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51 newpacket.type = 0x0002;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
52
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53 newpacket.commandlen = 26;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54 newpacket.data = (char *) malloc(newpacket.commandlen);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
55
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
56 curbyte += aim_putsnac(newpacket.data+curbyte, 0x0001, 0x0002, 0x0000, aim_snac_nextid);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
57 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
58 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
59 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0013);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0007);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
62 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
63 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
64 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
65
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
66 aim_tx_enqueue(&newpacket);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
67
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
68 {
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
69 struct aim_snac_t snac;
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 snac.id = aim_snac_nextid;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72 snac.family = 0x0001;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73 snac.type = 0x0004;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
74 snac.flags = 0x0000;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
75
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
76 snac.data = NULL;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
78 aim_newsnac(&snac);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79 }
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81 return (aim_snac_nextid++);
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
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84 u_long aim_auth_changepasswd(struct aim_conn_t *conn, char *new, char *current)
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85 {
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 struct command_tx_struct newpacket;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87 int i;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
88
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
89 newpacket.lock = 1;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
90
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
91 if (conn==NULL)
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
92 newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
93 else
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
94 newpacket.conn = conn;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
95
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
96 newpacket.type = 0x0002;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
97
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
98 newpacket.commandlen = 10 + 4 + strlen(current) + 4 + strlen(new);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
99 newpacket.data = (char *) malloc(newpacket.commandlen);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
100
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
101 newpacket.data[0] = 0x00;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
102 newpacket.data[1] = 0x07;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
103
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104 newpacket.data[2] = 0x00;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
105 newpacket.data[3] = 0x04;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
106
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
107 newpacket.data[4] = 0x00;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
108 newpacket.data[5] = 0x00;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
109
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
110 /* SNAC reqid */
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
111 newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
112 newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
113 newpacket.data[8] = (aim_snac_nextid >> 8) & 0xFF;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
114 newpacket.data[9] = (aim_snac_nextid) & 0xFF;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
115
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
116 /* current password TLV t(0002) */
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
117 i = 10;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
118 newpacket.data[i++] = 0x00;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
119 newpacket.data[i++] = 0x02;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
120 newpacket.data[i++] = 0x00;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
121 newpacket.data[i++] = strlen(current) & 0xff;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
122 memcpy(&(newpacket.data[i]), current, strlen(current));
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
123 i += strlen(current);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
124
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
125 /* new password TLV t(0012) */
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
126 newpacket.data[i++] = 0x00;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
127 newpacket.data[i++] = 0x12;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
128 newpacket.data[i++] = 0x00;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
129 newpacket.data[i++] = strlen(new) & 0xff;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
130 memcpy(&(newpacket.data[i]), new, strlen(new));
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
131 i+=strlen(new);
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 aim_tx_enqueue(&newpacket);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
134
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
135 {
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
136 struct aim_snac_t snac;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
137
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
138 snac.id = aim_snac_nextid;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
139 snac.family = 0x0001;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
140 snac.type = 0x0004;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
141 snac.flags = 0x0000;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
142
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
143 snac.data = NULL;
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
144
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
145 aim_newsnac(&snac);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
146 }
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 return (aim_snac_nextid++);
68b230f8da5f [gaim-migrate @ 11]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
149 }