4 * This contains all the functions needed to actually login.
12 * FIXME: Reimplement the TIS stuff.
14 #ifdef TIS_TELNET_PROXY
15 #include "tis_telnet_proxy.h"
19 * send_login(int socket, char *sn, char *password)
21 * This is the initial login request packet.
23 * The password is encoded before transmition, as per
24 * encode_password(). See that function for their
25 * stupid method of doing it.
28 int aim_send_login (struct aim_session_t *sess,
29 struct aim_conn_t *conn,
30 char *sn, char *password, struct client_info_s *clientinfo)
32 u_char *password_encoded = NULL; /* to store encoded password */
35 struct command_tx_struct newpacket;
38 newpacket.conn = conn;
40 newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_AUTH);
42 newpacket.commandlen = 4 + 4+strlen(sn) + 4+strlen(password) + 6;
46 if (strlen(clientinfo->clientstring))
47 newpacket.commandlen += 4+strlen(clientinfo->clientstring);
48 newpacket.commandlen += 6+6+6;
49 if (strlen(clientinfo->country))
50 newpacket.commandlen += 4+strlen(clientinfo->country);
51 if (strlen(clientinfo->lang))
52 newpacket.commandlen += 4+strlen(clientinfo->lang);
54 newpacket.commandlen += 6;
56 newpacket.data = (char *) calloc (1, newpacket.commandlen );
58 newpacket.type = 0x01;
60 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
61 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
62 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
63 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(sn));
64 curbyte += aimutil_putstr(newpacket.data+curbyte, sn, strlen(sn));
66 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002);
67 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(password));
68 password_encoded = (char *) malloc(strlen(password));
69 aim_encode_password(password, password_encoded);
70 curbyte += aimutil_putstr(newpacket.data+curbyte, password_encoded, strlen(password));
71 free(password_encoded);
73 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0016, 0x0001);
77 if (strlen(clientinfo->clientstring))
79 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0003);
80 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->clientstring));
81 curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->clientstring, strlen(clientinfo->clientstring));
83 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0017, 0x0001);
84 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0018, 0x0001);
85 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x001a, 0x0013);
86 if (strlen(clientinfo->country))
88 curbyte += aimutil_put16(newpacket.data+curbyte, 0x000e);
89 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->country));
90 curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->country, strlen(clientinfo->country));
92 if (strlen(clientinfo->lang))
94 curbyte += aimutil_put16(newpacket.data+curbyte, 0x000f);
95 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->lang));
96 curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->lang, strlen(clientinfo->lang));
100 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0009, 0x0015);
103 aim_tx_enqueue(sess, &newpacket);
109 * int encode_password(
110 * const char *password,
114 * This takes a const pointer to a (null terminated) string
115 * containing the unencoded password. It also gets passed
116 * an already allocated buffer to store the encoded password.
117 * This buffer should be the exact length of the password without
118 * the null. The encoded password buffer IS NOT NULL TERMINATED.
120 * The encoding_table seems to be a fixed set of values. We'll
121 * hope it doesn't change over time!
124 int aim_encode_password(const char *password, u_char *encoded)
126 u_char encoding_table[] = {
127 0xf3, 0xb3, 0x6c, 0x99,
128 0x95, 0x3f, 0xac, 0xb6,
129 0xc5, 0xfa, 0x6b, 0x63,
130 0x69, 0x6c, 0xc3, 0x9f
135 for (i = 0; i < strlen(password); i++)
136 encoded[i] = (password[i] ^ encoding_table[i]);