]>
Commit | Line | Data |
---|---|---|
9de3ca7e | 1 | /* |
2 | aim_auth.c | |
3 | ||
4 | Deals with the authorizer. | |
5 | ||
6 | */ | |
7 | ||
a25832e6 | 8 | #include <faim/aim.h> |
9de3ca7e | 9 | |
10 | /* this just pushes the passed cookie onto the passed connection -- NO SNAC! */ | |
a25832e6 | 11 | int aim_auth_sendcookie(struct aim_session_t *sess, |
12 | struct aim_conn_t *conn, | |
13 | u_char *chipsahoy) | |
9de3ca7e | 14 | { |
15 | struct command_tx_struct newpacket; | |
16 | int curbyte=0; | |
17 | ||
18 | newpacket.lock = 1; | |
19 | ||
20 | if (conn==NULL) | |
a25832e6 | 21 | newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); |
9de3ca7e | 22 | else |
23 | newpacket.conn = conn; | |
24 | ||
25 | newpacket.type = 0x0001; /* channel 1 (no SNACs, you know) */ | |
26 | ||
a25832e6 | 27 | newpacket.commandlen = 4 + 2 + 2 + AIM_COOKIELEN; |
9de3ca7e | 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); | |
a25832e6 | 33 | curbyte += aimutil_put16(newpacket.data+curbyte, AIM_COOKIELEN); |
34 | memcpy(&(newpacket.data[curbyte]), chipsahoy, AIM_COOKIELEN); | |
9de3ca7e | 35 | |
a25832e6 | 36 | aim_tx_enqueue(sess, &newpacket); |
9de3ca7e | 37 | |
38 | return 0; | |
39 | } | |
40 | ||
a25832e6 | 41 | u_long aim_auth_clientready(struct aim_session_t *sess, |
42 | struct aim_conn_t *conn) | |
9de3ca7e | 43 | { |
44 | struct command_tx_struct newpacket; | |
45 | int curbyte = 0; | |
46 | ||
47 | newpacket.lock = 1; | |
48 | ||
49 | if (conn==NULL) | |
a25832e6 | 50 | newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); |
9de3ca7e | 51 | else |
52 | newpacket.conn = conn; | |
53 | ||
54 | newpacket.type = 0x0002; | |
55 | ||
56 | newpacket.commandlen = 26; | |
a25832e6 | 57 | newpacket.data = (u_char *) malloc(newpacket.commandlen); |
9de3ca7e | 58 | |
a25832e6 | 59 | curbyte += aim_putsnac(newpacket.data+curbyte, 0x0001, 0x0002, 0x0000, sess->snac_nextid); |
9de3ca7e | 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 | ||
a25832e6 | 69 | aim_tx_enqueue(sess, &newpacket); |
9de3ca7e | 70 | |
71 | { | |
72 | struct aim_snac_t snac; | |
73 | ||
a25832e6 | 74 | snac.id = sess->snac_nextid; |
9de3ca7e | 75 | snac.family = 0x0001; |
76 | snac.type = 0x0004; | |
77 | snac.flags = 0x0000; | |
78 | ||
79 | snac.data = NULL; | |
80 | ||
a25832e6 | 81 | aim_newsnac(sess, &snac); |
9de3ca7e | 82 | } |
83 | ||
a25832e6 | 84 | return (sess->snac_nextid++); |
9de3ca7e | 85 | } |
86 | ||
a25832e6 | 87 | u_long aim_auth_changepasswd(struct aim_session_t *sess, |
88 | struct aim_conn_t *conn, | |
89 | char *new, char *current) | |
9de3ca7e | 90 | { |
91 | struct command_tx_struct newpacket; | |
92 | int i; | |
93 | ||
94 | newpacket.lock = 1; | |
95 | ||
96 | if (conn==NULL) | |
a25832e6 | 97 | newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH); |
9de3ca7e | 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 | ||
a25832e6 | 106 | aim_putsnac(newpacket.data, 0x0007, 0x0004, 0x0000, sess->snac_nextid); |
9de3ca7e | 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 | ||
a25832e6 | 125 | aim_tx_enqueue(sess, &newpacket); |
9de3ca7e | 126 | |
127 | { | |
128 | struct aim_snac_t snac; | |
129 | ||
a25832e6 | 130 | snac.id = sess->snac_nextid; |
9de3ca7e | 131 | snac.family = 0x0001; |
132 | snac.type = 0x0004; | |
133 | snac.flags = 0x0000; | |
134 | ||
135 | snac.data = NULL; | |
136 | ||
a25832e6 | 137 | aim_newsnac(sess, &snac); |
9de3ca7e | 138 | } |
139 | ||
a25832e6 | 140 | return (sess->snac_nextid++); |
9de3ca7e | 141 | } |