Mercurial > pidgin.yaz
comparison libfaim/aim_login.c @ 2:68b230f8da5f
[gaim-migrate @ 11]
A few more commits :)
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Thu, 23 Mar 2000 03:16:06 +0000 |
parents | |
children | 6ced2f1c8b24 |
comparison
equal
deleted
inserted
replaced
1:2846a03bda67 | 2:68b230f8da5f |
---|---|
1 /* | |
2 * aim_login.c | |
3 * | |
4 * This contains all the functions needed to actually login. | |
5 * | |
6 */ | |
7 | |
8 #include "aim.h" | |
9 | |
10 | |
11 /* | |
12 * FIXME: Reimplement the TIS stuff. | |
13 */ | |
14 #ifdef TIS_TELNET_PROXY | |
15 #include "tis_telnet_proxy.h" | |
16 #endif | |
17 | |
18 /* | |
19 * send_login(int socket, char *sn, char *password) | |
20 * | |
21 * This is the initial login request packet. | |
22 * | |
23 * The password is encoded before transmition, as per | |
24 * encode_password(). See that function for their | |
25 * stupid method of doing it. | |
26 * | |
27 * | |
28 * | |
29 */ | |
30 int aim_send_login (struct aim_conn_t *conn, char *sn, char *password, struct client_info_s *clientinfo) | |
31 { | |
32 char *password_encoded = NULL; /* to store encoded password */ | |
33 int curbyte=0; | |
34 | |
35 struct command_tx_struct newpacket; | |
36 | |
37 if (conn) | |
38 newpacket.conn = conn; | |
39 else | |
40 newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH); | |
41 | |
42 newpacket.commandlen = 6+2+strlen(sn)+1+1+2+strlen(password)+6; | |
43 | |
44 if (clientinfo) | |
45 { | |
46 if (strlen(clientinfo->clientstring)) | |
47 newpacket.commandlen += strlen(clientinfo->clientstring)+4; | |
48 newpacket.commandlen += 6+6+6; | |
49 if (strlen(clientinfo->country)) | |
50 newpacket.commandlen += strlen(clientinfo->country)+4; | |
51 if (strlen(clientinfo->lang)) | |
52 newpacket.commandlen += strlen(clientinfo->lang)+4; | |
53 } | |
54 | |
55 newpacket.data = (char *) calloc (1, newpacket.commandlen ); | |
56 newpacket.lock = 1; | |
57 newpacket.type = 0x01; | |
58 | |
59 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000); | |
60 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001); | |
61 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001); | |
62 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(sn)); | |
63 curbyte += aimutil_putstr(newpacket.data+curbyte, sn, strlen(sn)); | |
64 | |
65 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002); | |
66 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(password)); | |
67 password_encoded = (char *) malloc(strlen(password)); | |
68 aim_encode_password(password, password_encoded); | |
69 curbyte += aimutil_putstr(newpacket.data+curbyte, password_encoded, strlen(password)); | |
70 free(password_encoded); | |
71 | |
72 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0016, 0x0001); | |
73 | |
74 if (clientinfo) | |
75 { | |
76 if (strlen(clientinfo->clientstring)) | |
77 { | |
78 curbyte += aimutil_put16(newpacket.data+curbyte, 0x0003); | |
79 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->clientstring)); | |
80 curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->clientstring, strlen(clientinfo->clientstring)); | |
81 } | |
82 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0017, 0x0001); | |
83 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0018, 0x0001); | |
84 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x001a, 0x0013); | |
85 if (strlen(clientinfo->country)) | |
86 { | |
87 curbyte += aimutil_put16(newpacket.data+curbyte, 0x000e); | |
88 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->country)); | |
89 curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->country, strlen(clientinfo->country)); | |
90 } | |
91 if (strlen(clientinfo->lang)) | |
92 { | |
93 curbyte += aimutil_put16(newpacket.data+curbyte, 0x000f); | |
94 curbyte += aimutil_put16(newpacket.data+curbyte, strlen(clientinfo->lang)); | |
95 curbyte += aimutil_putstr(newpacket.data+curbyte, clientinfo->lang, strlen(clientinfo->lang)); | |
96 } | |
97 } | |
98 | |
99 curbyte += aim_puttlv_16(newpacket.data+curbyte, 0x0009, 0x0015); | |
100 | |
101 newpacket.lock = 0; | |
102 aim_tx_enqueue(&newpacket); | |
103 | |
104 return 0; | |
105 } | |
106 | |
107 /* | |
108 * int encode_password( | |
109 * const char *password, | |
110 * char *encoded | |
111 * ); | |
112 * | |
113 * This takes a const pointer to a (null terminated) string | |
114 * containing the unencoded password. It also gets passed | |
115 * an already allocated buffer to store the encoded password. | |
116 * This buffer should be the exact length of the password without | |
117 * the null. The encoded password buffer IS NOT NULL TERMINATED. | |
118 * | |
119 * The encoding_table seems to be a fixed set of values. We'll | |
120 * hope it doesn't change over time! | |
121 * | |
122 */ | |
123 int aim_encode_password(const char *password, char *encoded) | |
124 { | |
125 char encoding_table[] = { | |
126 0xf3, 0xb3, 0x6c, 0x99, | |
127 0x95, 0x3f, 0xac, 0xb6, | |
128 0xc5, 0xfa, 0x6b, 0x63, | |
129 0x69, 0x6c, 0xc3, 0x9f | |
130 }; | |
131 | |
132 int i; | |
133 | |
134 for (i = 0; i < strlen(password); i++) | |
135 encoded[i] = (password[i] ^ encoding_table[i]); | |
136 | |
137 return 0; | |
138 } | |
139 | |
140 | |
141 | |
142 |