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