2
|
1 /*
|
|
2 aim_auth.c
|
|
3
|
|
4 Deals with the authorizer.
|
|
5
|
|
6 */
|
|
7
|
|
8 #include "aim.h"
|
|
9
|
|
10 /* this just pushes the passed cookie onto the passed connection -- NO SNAC! */
|
|
11 int aim_auth_sendcookie(struct aim_conn_t *conn, char *chipsahoy)
|
|
12 {
|
|
13 struct command_tx_struct newpacket;
|
|
14 int curbyte=0;
|
|
15
|
|
16 newpacket.lock = 1;
|
|
17
|
|
18 if (conn==NULL)
|
|
19 newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH);
|
|
20 else
|
|
21 newpacket.conn = conn;
|
|
22
|
|
23 newpacket.type = 0x0001; /* channel 1 (no SNACs, you know) */
|
|
24
|
|
25 newpacket.commandlen = 4 + 2 + 2 + 0x100;
|
|
26 newpacket.data = (char *) calloc(1, newpacket.commandlen);
|
|
27
|
|
28 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
|
|
29 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
|
|
30 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0006);
|
|
31 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0100);
|
|
32 memcpy(&(newpacket.data[curbyte]), chipsahoy, 0x100);
|
|
33
|
|
34 aim_tx_enqueue(&newpacket);
|
|
35
|
|
36 return 0;
|
|
37 }
|
|
38
|
|
39 u_long aim_auth_clientready(struct aim_conn_t *conn)
|
|
40 {
|
|
41 struct command_tx_struct newpacket;
|
|
42 int curbyte = 0;
|
|
43
|
|
44 newpacket.lock = 1;
|
|
45
|
|
46 if (conn==NULL)
|
|
47 newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH);
|
|
48 else
|
|
49 newpacket.conn = conn;
|
|
50
|
|
51 newpacket.type = 0x0002;
|
|
52
|
|
53 newpacket.commandlen = 26;
|
|
54 newpacket.data = (char *) malloc(newpacket.commandlen);
|
|
55
|
|
56 curbyte += aim_putsnac(newpacket.data+curbyte, 0x0001, 0x0002, 0x0000, aim_snac_nextid);
|
|
57 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
|
|
58 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002);
|
|
59 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
|
|
60 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0013);
|
|
61 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0007);
|
|
62 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
|
|
63 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
|
|
64 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
|
|
65
|
|
66 aim_tx_enqueue(&newpacket);
|
|
67
|
|
68 {
|
|
69 struct aim_snac_t snac;
|
|
70
|
|
71 snac.id = aim_snac_nextid;
|
|
72 snac.family = 0x0001;
|
|
73 snac.type = 0x0004;
|
|
74 snac.flags = 0x0000;
|
|
75
|
|
76 snac.data = NULL;
|
|
77
|
|
78 aim_newsnac(&snac);
|
|
79 }
|
|
80
|
|
81 return (aim_snac_nextid++);
|
|
82 }
|
|
83
|
|
84 u_long aim_auth_changepasswd(struct aim_conn_t *conn, char *new, char *current)
|
|
85 {
|
|
86 struct command_tx_struct newpacket;
|
|
87 int i;
|
|
88
|
|
89 newpacket.lock = 1;
|
|
90
|
|
91 if (conn==NULL)
|
|
92 newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH);
|
|
93 else
|
|
94 newpacket.conn = conn;
|
|
95
|
|
96 newpacket.type = 0x0002;
|
|
97
|
|
98 newpacket.commandlen = 10 + 4 + strlen(current) + 4 + strlen(new);
|
|
99 newpacket.data = (char *) malloc(newpacket.commandlen);
|
|
100
|
|
101 newpacket.data[0] = 0x00;
|
|
102 newpacket.data[1] = 0x07;
|
|
103
|
|
104 newpacket.data[2] = 0x00;
|
|
105 newpacket.data[3] = 0x04;
|
|
106
|
|
107 newpacket.data[4] = 0x00;
|
|
108 newpacket.data[5] = 0x00;
|
|
109
|
|
110 /* SNAC reqid */
|
|
111 newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF;
|
|
112 newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF;
|
|
113 newpacket.data[8] = (aim_snac_nextid >> 8) & 0xFF;
|
|
114 newpacket.data[9] = (aim_snac_nextid) & 0xFF;
|
|
115
|
|
116 /* current password TLV t(0002) */
|
|
117 i = 10;
|
|
118 newpacket.data[i++] = 0x00;
|
|
119 newpacket.data[i++] = 0x02;
|
|
120 newpacket.data[i++] = 0x00;
|
|
121 newpacket.data[i++] = strlen(current) & 0xff;
|
|
122 memcpy(&(newpacket.data[i]), current, strlen(current));
|
|
123 i += strlen(current);
|
|
124
|
|
125 /* new password TLV t(0012) */
|
|
126 newpacket.data[i++] = 0x00;
|
|
127 newpacket.data[i++] = 0x12;
|
|
128 newpacket.data[i++] = 0x00;
|
|
129 newpacket.data[i++] = strlen(new) & 0xff;
|
|
130 memcpy(&(newpacket.data[i]), new, strlen(new));
|
|
131 i+=strlen(new);
|
|
132
|
|
133 aim_tx_enqueue(&newpacket);
|
|
134
|
|
135 {
|
|
136 struct aim_snac_t snac;
|
|
137
|
|
138 snac.id = aim_snac_nextid;
|
|
139 snac.family = 0x0001;
|
|
140 snac.type = 0x0004;
|
|
141 snac.flags = 0x0000;
|
|
142
|
|
143 snac.data = NULL;
|
|
144
|
|
145 aim_newsnac(&snac);
|
|
146 }
|
|
147
|
|
148 return (aim_snac_nextid++);
|
|
149 }
|