2086
|
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
|
3 /*
|
|
4 * $Id: udp.c 2096 2001-07-31 01:00:39Z warmenhoven $
|
|
5 *
|
|
6 * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
|
|
7 * Bill Soudan <soudan@kde.org>
|
|
8 *
|
|
9 * This program is free software; you can redistribute it and/or modify
|
|
10 * it under the terms of the GNU General Public License as published by
|
|
11 * the Free Software Foundation; either version 2 of the License, or
|
|
12 * (at your option) any later version.
|
|
13 *
|
|
14 * This program is distributed in the hope that it will be useful,
|
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 * GNU General Public License for more details.
|
|
18 *
|
|
19 * You should have received a copy of the GNU General Public License
|
|
20 * along with this program; if not, write to the Free Software
|
|
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 #ifdef _WIN32
|
|
26 #include <winsock.h>
|
|
27 #endif
|
|
28
|
|
29 #include <stdlib.h>
|
|
30
|
|
31 #include "icqlib.h"
|
|
32 #include "udp.h"
|
|
33 #include "queue.h"
|
|
34
|
|
35 #include "stdpackets.h"
|
|
36 #include "icqbyteorder.h"
|
|
37
|
|
38 #include "contacts.h"
|
|
39
|
|
40 static const BYTE icq_UDPTable[] = {
|
|
41 0x59, 0x60, 0x37, 0x6B, 0x65, 0x62, 0x46, 0x48, 0x53, 0x61, 0x4C, 0x59, 0x60, 0x57, 0x5B, 0x3D,
|
|
42 0x5E, 0x34, 0x6D, 0x36, 0x50, 0x3F, 0x6F, 0x67, 0x53, 0x61, 0x4C, 0x59, 0x40, 0x47, 0x63, 0x39,
|
|
43 0x50, 0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x43, 0x69, 0x48, 0x33, 0x31, 0x64, 0x35, 0x5A, 0x4A, 0x42,
|
|
44 0x56, 0x40, 0x67, 0x53, 0x41, 0x07, 0x6C, 0x49, 0x58, 0x3B, 0x4D, 0x46, 0x68, 0x43, 0x69, 0x48,
|
|
45 0x33, 0x31, 0x44, 0x65, 0x62, 0x46, 0x48, 0x53, 0x41, 0x07, 0x6C, 0x69, 0x48, 0x33, 0x51, 0x54,
|
|
46 0x5D, 0x4E, 0x6C, 0x49, 0x38, 0x4B, 0x55, 0x4A, 0x62, 0x46, 0x48, 0x33, 0x51, 0x34, 0x6D, 0x36,
|
|
47 0x50, 0x5F, 0x5F, 0x5F, 0x3F, 0x6F, 0x47, 0x63, 0x59, 0x40, 0x67, 0x33, 0x31, 0x64, 0x35, 0x5A,
|
|
48 0x6A, 0x52, 0x6E, 0x3C, 0x51, 0x34, 0x6D, 0x36, 0x50, 0x5F, 0x5F, 0x3F, 0x4F, 0x37, 0x4B, 0x35,
|
|
49 0x5A, 0x4A, 0x62, 0x66, 0x58, 0x3B, 0x4D, 0x66, 0x58, 0x5B, 0x5D, 0x4E, 0x6C, 0x49, 0x58, 0x3B,
|
|
50 0x4D, 0x66, 0x58, 0x3B, 0x4D, 0x46, 0x48, 0x53, 0x61, 0x4C, 0x59, 0x40, 0x67, 0x33, 0x31, 0x64,
|
|
51 0x55, 0x6A, 0x32, 0x3E, 0x44, 0x45, 0x52, 0x6E, 0x3C, 0x31, 0x64, 0x55, 0x6A, 0x52, 0x4E, 0x6C,
|
|
52 0x69, 0x48, 0x53, 0x61, 0x4C, 0x39, 0x30, 0x6F, 0x47, 0x63, 0x59, 0x60, 0x57, 0x5B, 0x3D, 0x3E,
|
|
53 0x64, 0x35, 0x3A, 0x3A, 0x5A, 0x6A, 0x52, 0x4E, 0x6C, 0x69, 0x48, 0x53, 0x61, 0x6C, 0x49, 0x58,
|
|
54 0x3B, 0x4D, 0x46, 0x68, 0x63, 0x39, 0x50, 0x5F, 0x5F, 0x3F, 0x6F, 0x67, 0x53, 0x41, 0x25, 0x41,
|
|
55 0x3C, 0x51, 0x54, 0x3D, 0x5E, 0x54, 0x5D, 0x4E, 0x4C, 0x39, 0x50, 0x5F, 0x5F, 0x5F, 0x3F, 0x6F,
|
|
56 0x47, 0x43, 0x69, 0x48, 0x33, 0x51, 0x54, 0x5D, 0x6E, 0x3C, 0x31, 0x64, 0x35, 0x5A, 0x00, 0x00,
|
|
57 };
|
|
58
|
|
59 DWORD icq_UDPCalculateCheckCode(icq_Packet *p)
|
|
60 {
|
|
61 DWORD num1, num2;
|
|
62 DWORD r1,r2;
|
|
63
|
|
64 num1 = p->data[8];
|
|
65 num1 <<= 8;
|
|
66 num1 += p->data[4];
|
|
67 num1 <<= 8;
|
|
68 num1 += p->data[2];
|
|
69 num1 <<= 8;
|
|
70 num1 += p->data[6];
|
|
71
|
|
72 r1 = 0x18 + (rand() % (p->length - 0x18));
|
|
73 r2 = rand() & 0xff;
|
|
74
|
|
75 num2 = r1;
|
|
76 num2 <<= 8;
|
|
77 num2 += p->data[r1];
|
|
78 num2 <<= 8;
|
|
79 num2 += r2;
|
|
80 num2 <<= 8;
|
|
81 num2 += icq_UDPTable[r2];
|
|
82 num2 ^= 0xFF00FF;
|
|
83
|
|
84 return num1 ^ num2;
|
|
85 }
|
|
86
|
|
87 DWORD icq_UDPScramble(DWORD cc)
|
|
88 {
|
|
89 DWORD a[5];
|
|
90
|
|
91 a[0] = cc & 0x0000001F;
|
|
92 a[1] = cc & 0x03E003E0;
|
|
93 a[2] = cc & 0xF8000400;
|
|
94 a[3] = cc & 0x0000F800;
|
|
95 a[4] = cc & 0x041F0000;
|
|
96
|
|
97 a[0] <<= 0x0C;
|
|
98 a[1] <<= 0x01;
|
|
99 a[2] >>= 0x0A;
|
|
100 a[3] <<= 0x10;
|
|
101 a[4] >>= 0x0F;
|
|
102
|
|
103 return a[0] + a[1] + a[2] + a[3] + a[4];
|
|
104 }
|
|
105
|
|
106 void icq_UDPEncode(icq_Packet *p, char *buffer)
|
|
107 {
|
|
108 DWORD checkcode = icq_UDPCalculateCheckCode(p);
|
|
109 DWORD code1, code2, code3;
|
|
110 DWORD pos;
|
|
111
|
|
112 memcpy(buffer, p->data, p->length);
|
|
113
|
|
114 *(DWORD *)(buffer+0x14)=htoicql(checkcode);
|
|
115 code1 = p->length * 0x68656c6cL;
|
|
116 code2 = code1 + checkcode;
|
|
117 pos = 0x0A;
|
|
118
|
|
119 for(; pos < p->length; pos+=4)
|
|
120 {
|
|
121 DWORD data = icqtohl(*(DWORD *)((p->data)+pos));
|
|
122 code3 = code2 + icq_UDPTable[pos & 0xFF];
|
|
123 data ^= code3;
|
|
124 *(DWORD*)(buffer+pos)=htoicql(data);
|
|
125 }
|
|
126 checkcode = icq_UDPScramble(checkcode);
|
|
127 *(DWORD *)(buffer+0x14)=htoicql(checkcode);
|
|
128 }
|
|
129
|
|
130 /*********************************************************
|
|
131 icq_UDPSockWrite and icq_UDPSockRead are for _UDP_ packets
|
|
132 proxy support for TCP sockets is different!
|
|
133 *********************************************************/
|
|
134 int icq_UDPSockWriteDirect(icq_Link *icqlink, icq_Packet *p)
|
|
135 {
|
|
136 char tmpbuf[ICQ_PACKET_DATA_SIZE+10];
|
|
137
|
|
138 if(icqlink->icq_UDPSok <= 3)
|
|
139 {
|
|
140 icq_FmtLog(icqlink, ICQ_LOG_ERROR, "Bad socket!\n");
|
|
141 return -1;
|
|
142 }
|
|
143
|
|
144 icq_UDPEncode(p, tmpbuf+10);
|
|
145
|
|
146 if(!icqlink->icq_UseProxy)
|
|
147 {
|
|
148 #ifdef _WIN32
|
|
149 return send(icqlink->icq_UDPSok, tmpbuf+10, p->length, 0);
|
|
150 #else
|
|
151 return write(icqlink->icq_UDPSok, tmpbuf+10, p->length);
|
|
152 #endif
|
|
153 }
|
|
154 else
|
|
155 {
|
|
156 tmpbuf[0] = 0; /* reserved */
|
|
157 tmpbuf[1] = 0; /* reserved */
|
|
158 tmpbuf[2] = 0; /* standalone packet */
|
|
159 tmpbuf[3] = 1; /* address type IP v4 */
|
|
160 *(unsigned long*)&tmpbuf[4] = htonl(icqlink->icq_ProxyDestIP);
|
|
161 *(unsigned short*)&tmpbuf[8] = htons(icqlink->icq_ProxyDestPort);
|
|
162 #ifdef _WIN32
|
|
163 return send(icqlink->icq_UDPSok, tmpbuf, p->length+10, 0)-10;
|
|
164 #else
|
|
165 return write(icqlink->icq_UDPSok, tmpbuf, p->length+10)-10;
|
|
166 #endif
|
|
167 }
|
|
168 }
|
|
169
|
|
170 int icq_UDPSockWrite(icq_Link *icqlink, icq_Packet *p)
|
|
171 {
|
|
172 icq_UDPQueuePut(icqlink, p);
|
|
173
|
|
174 return icq_UDPSockWriteDirect(icqlink, p);
|
|
175 }
|
|
176
|
|
177 int icq_UDPSockRead(icq_Link *icqlink, icq_Packet *p)
|
|
178 {
|
|
179 int res;
|
|
180 char tmpbuf[ICQ_PACKET_DATA_SIZE];
|
|
181
|
|
182 if(!icqlink->icq_UseProxy)
|
|
183 {
|
|
184 #ifdef _WIN32
|
|
185 res = recv(icqlink->icq_UDPSok, p->data, ICQ_PACKET_DATA_SIZE, 0);
|
|
186 #else
|
|
187 res = read(icqlink->icq_UDPSok, p->data, ICQ_PACKET_DATA_SIZE);
|
|
188 #endif
|
|
189 p->length = res;
|
|
190 return res;
|
|
191 }
|
|
192 else
|
|
193 {
|
|
194 #ifdef _WIN32
|
|
195 res = recv(icqlink->icq_UDPSok, tmpbuf, ICQ_PACKET_DATA_SIZE, 0);
|
|
196 #else
|
|
197 res = read(icqlink->icq_UDPSok, tmpbuf, ICQ_PACKET_DATA_SIZE);
|
|
198 #endif
|
|
199 if(res<0)
|
|
200 return res;
|
|
201 memcpy(p->data, &tmpbuf[10], res-10);
|
|
202 p->length = res-10;
|
|
203 return res-10;
|
|
204 }
|
|
205 }
|
|
206
|
|
207 /****************************************
|
|
208 This must be called every 2 min.
|
|
209 so the server knows we're still alive.
|
|
210 JAVA client sends two different commands
|
|
211 so we do also :)
|
|
212 *****************************************/
|
|
213 WORD icq_KeepAlive(icq_Link *icqlink) /* V5 */
|
|
214 {
|
|
215 icq_Packet *p = icq_UDPCreateStdSeqPacket(icqlink, UDP_CMD_KEEP_ALIVE, icqlink->d->icq_UDPSeqNum1++);
|
|
216 icq_PacketAppend32(p, rand());
|
|
217 icq_UDPSockWriteDirect(icqlink, p); /* don't queue keep alive packets! */
|
|
218 icq_PacketDelete(p);
|
|
219
|
|
220 icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Send Keep Alive packet to the server\n");
|
|
221
|
|
222 return icqlink->d->icq_UDPSeqNum1-1;
|
|
223 }
|
|
224
|
|
225 /**********************************
|
|
226 This must be called to remove
|
|
227 messages from the server
|
|
228 ***********************************/
|
|
229 void icq_SendGotMessages(icq_Link *icqlink) /* V5 */
|
|
230 {
|
|
231 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_ACK_MESSAGES);
|
|
232 icq_PacketAppend32(p, rand());
|
|
233 icq_UDPSockWrite(icqlink, p);
|
|
234 }
|
|
235
|
|
236 /*************************************
|
|
237 this sends over the contact list
|
|
238 *************************************/
|
|
239 void icq_SendContactList(icq_Link *icqlink) /* V5 */
|
|
240 {
|
|
241 char num_used;
|
|
242 icq_ContactItem *ptr = icq_ContactGetFirst(icqlink);
|
|
243
|
|
244 while(ptr)
|
|
245 {
|
|
246 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_CONT_LIST);
|
|
247
|
|
248 num_used = 0;
|
|
249 icq_PacketAdvance(p,1);
|
|
250 while(ptr && num_used<64)
|
|
251 {
|
|
252 icq_PacketAppend32(p, ptr->uin);
|
|
253 num_used++;
|
|
254 ptr = icq_ContactGetNext(ptr);
|
|
255 }
|
|
256 icq_PacketGotoUDPOutData(p, 0);
|
|
257 icq_PacketAppend8(p, num_used);
|
|
258 icq_UDPSockWrite(icqlink, p);
|
|
259 }
|
|
260 }
|
|
261
|
|
262 void icq_SendNewUser(icq_Link *icqlink, unsigned long uin) /* V5 */
|
|
263 {
|
|
264 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_ADD_TO_LIST);
|
|
265 icq_PacketAppend32(p, uin);
|
|
266 icq_UDPSockWrite(icqlink, p);
|
|
267 }
|
|
268
|
|
269 /*************************************
|
|
270 this sends over the visible list
|
|
271 that allows certain users to see you
|
|
272 if you're invisible.
|
|
273 *************************************/
|
|
274 void icq_SendVisibleList(icq_Link *icqlink) /* V5 */
|
|
275 {
|
|
276 char num_used;
|
|
277 icq_ContactItem *ptr = icq_ContactGetFirst(icqlink);
|
|
278 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_VIS_LIST);
|
|
279
|
|
280 num_used = 0;
|
|
281 icq_PacketAdvance(p,1);
|
|
282 while(ptr)
|
|
283 {
|
|
284 if(ptr->vis_list)
|
|
285 {
|
|
286 icq_PacketAppend32(p, ptr->uin);
|
|
287 num_used++;
|
|
288 }
|
|
289 ptr = icq_ContactGetNext(ptr);
|
|
290 }
|
|
291 if(num_used != 0)
|
|
292 {
|
|
293 icq_PacketGotoUDPOutData(p, 0);
|
|
294 icq_PacketAppend8(p, num_used);
|
|
295 icq_UDPSockWrite(icqlink, p);
|
|
296 }
|
|
297 else
|
|
298 icq_PacketDelete(p);
|
|
299 }
|
|
300
|
|
301 void icq_SendInvisibleList(icq_Link *icqlink) /* V5 */
|
|
302 {
|
|
303 char num_used;
|
|
304 icq_ContactItem *ptr = icq_ContactGetFirst(icqlink);
|
|
305 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_INVIS_LIST);
|
|
306
|
|
307 num_used = 0;
|
|
308 icq_PacketAdvance(p,1);
|
|
309 while(ptr)
|
|
310 {
|
|
311 if(ptr->invis_list)
|
|
312 {
|
|
313 icq_PacketAppend32(p, ptr->uin);
|
|
314 num_used++;
|
|
315 }
|
|
316 ptr = icq_ContactGetNext(ptr);
|
|
317 }
|
|
318 if(num_used != 0)
|
|
319 {
|
|
320 icq_PacketGotoUDPOutData(p, 0);
|
|
321 icq_PacketAppend8(p, num_used);
|
|
322 icq_UDPSockWrite(icqlink, p);
|
|
323 }
|
|
324 else
|
|
325 icq_PacketDelete(p);
|
|
326 }
|
|
327
|
|
328 /**************************************
|
|
329 This sends the second login command
|
|
330 this is necessary to finish logging in.
|
|
331 ***************************************/
|
|
332 void icq_SendLogin1(icq_Link *icqlink) /* V5 */
|
|
333 {
|
|
334 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_LOGIN_1);
|
|
335 icq_PacketAppend32(p, rand());
|
|
336 icq_UDPSockWrite(icqlink, p);
|
|
337 }
|
|
338
|
|
339 /************************************
|
|
340 This procedure logins into the server with icq_Uin and pass
|
|
341 on the socket icq_Sok and gives our ip and port.
|
|
342 It does NOT wait for any kind of a response.
|
|
343 *************************************/
|
|
344 void icq_Login(icq_Link *icqlink, DWORD status) /* V5 */
|
|
345 {
|
|
346 icq_Packet *p;
|
|
347
|
|
348 memset(icqlink->d->icq_UDPServMess, FALSE, sizeof(icqlink->d->icq_UDPServMess));
|
|
349 icqlink->d->icq_UDPSession = rand() & 0x3FFFFFFF;
|
|
350 icqlink->d->icq_UDPSeqNum1 = rand() & 0x7FFF;
|
|
351 icqlink->d->icq_UDPSeqNum2 = 1;
|
|
352
|
|
353 p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_LOGIN);
|
|
354 icq_PacketAppend32(p, time(0L));
|
|
355 icq_PacketAppend32n(p, icqlink->icq_TCPSrvPort);
|
|
356 /*icq_PacketAppend16(p, 0);
|
|
357 icq_PacketAppend16n(p, htons(icqlink->icq_OurPort));*/
|
|
358 icq_PacketAppendString(p, icqlink->icq_Password);
|
|
359 icq_PacketAppend32(p, LOGIN_X1_DEF);
|
|
360 if(icqlink->icq_UseTCP)
|
|
361 {
|
|
362 if(icqlink->icq_UseProxy)
|
|
363 {
|
|
364 icq_PacketAppend32n(p, htonl(icqlink->icq_ProxyIP));
|
|
365 icq_PacketAppend8(p, LOGIN_SNDONLY_TCP);
|
|
366 }
|
|
367 else
|
|
368 {
|
|
369 icq_PacketAppend32n(p, htonl(icqlink->icq_OurIP));
|
|
370 icq_PacketAppend8(p, LOGIN_SNDRCV_TCP);
|
|
371 }
|
|
372 }
|
|
373 else
|
|
374 {
|
|
375 icq_PacketAppend32n(p, htonl(icqlink->icq_ProxyIP));
|
|
376 icq_PacketAppend8(p, LOGIN_NO_TCP);
|
|
377 }
|
|
378 icq_PacketAppend32(p, status);
|
|
379 icq_PacketAppend32(p, LOGIN_X3_DEF);
|
|
380 icq_PacketAppend32(p, LOGIN_X4_DEF);
|
|
381 icq_PacketAppend32(p, LOGIN_X5_DEF);
|
|
382
|
|
383 icq_UDPSockWrite(icqlink, p);
|
|
384 }
|
|
385
|
|
386 /**********************
|
|
387 Logs off ICQ
|
|
388 ***********************/
|
|
389 void icq_Logout(icq_Link *icqlink) /* V5 */
|
|
390 {
|
|
391 icq_Packet *p = icq_UDPCreateStdSeqPacket(icqlink, UDP_CMD_SEND_TEXT_CODE, icqlink->d->icq_UDPSeqNum1++);
|
|
392 icq_PacketAppendString(p, "B_USER_DISCONNECTED");
|
|
393 icq_PacketAppend8(p, 5);
|
|
394 icq_PacketAppend8(p, 0);
|
|
395 icq_UDPSockWriteDirect(icqlink, p); /* don't queue */
|
|
396 icq_PacketDelete(p);
|
|
397 }
|
|
398
|
|
399 /*******************************
|
|
400 This routine sends the aknowlegement cmd to the
|
|
401 server it appears that this must be done after
|
|
402 everything the server sends us
|
|
403 *******************************/
|
|
404 void icq_UDPAck(icq_Link *icqlink, int seq) /* V5 */
|
|
405 {
|
|
406 icq_Packet *p = icq_UDPCreateStdSeqPacket(icqlink, UDP_CMD_ACK, seq);
|
|
407 icq_PacketAppend32(p, rand());
|
|
408
|
|
409 icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Acking\n");
|
|
410 icq_UDPSockWriteDirect(icqlink, p);
|
|
411 icq_PacketDelete(p);
|
|
412 }
|
|
413
|
|
414 /***************************************************
|
|
415 Sends a message thru the server to uin. Text is the
|
|
416 message to send.
|
|
417 ***************************************************/
|
|
418 WORD icq_UDPSendMessage(icq_Link *icqlink, DWORD uin, const char *text) /* V5 */
|
|
419 {
|
|
420 char buf[ICQ_MAX_UDP_MESSAGE_SIZE];
|
|
421 icq_Packet *p;
|
|
422
|
|
423 strncpy(buf, text, sizeof(buf));
|
|
424 buf[sizeof(buf)-1] = 0;
|
|
425 icq_RusConv("kw", buf);
|
|
426
|
|
427 p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEND_THRU_SRV);
|
|
428 icq_PacketAppend32(p, uin);
|
|
429 icq_PacketAppend16(p, TYPE_MSG);
|
|
430 icq_PacketAppendString(p, buf);
|
|
431
|
|
432 icq_UDPSockWrite(icqlink, p);
|
|
433 return icqlink->d->icq_UDPSeqNum1-1;
|
|
434 }
|
|
435
|
|
436 WORD icq_UDPSendURL(icq_Link *icqlink, DWORD uin, const char *url, const char *descr) /* V5 */
|
|
437 {
|
|
438 char buf1[ICQ_MAX_UDP_MESSAGE_SIZE], buf2[ICQ_MAX_UDP_MESSAGE_SIZE];
|
|
439 icq_Packet *p;
|
|
440
|
|
441 strncpy(buf1, descr, sizeof(buf1));
|
|
442 buf1[sizeof(buf1)-1] = 0;
|
|
443 icq_RusConv("kw", buf1);
|
|
444 strncpy(buf2, url, sizeof(buf2));
|
|
445 buf2[sizeof(buf2)-1] = 0;
|
|
446
|
|
447 p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEND_THRU_SRV);
|
|
448 icq_PacketAppend32(p, uin);
|
|
449 icq_PacketAppend16(p, TYPE_URL);
|
|
450 icq_PacketAppend16(p, strlen(buf1)+strlen(buf2)+2); /* length + the NULL + 0xFE delimiter */
|
|
451 icq_PacketAppendStringFE(p, buf1);
|
|
452 icq_PacketAppendString0(p, buf2);
|
|
453
|
|
454 icq_UDPSockWrite(icqlink, p);
|
|
455 return icqlink->d->icq_UDPSeqNum1-1;
|
|
456 }
|
|
457
|
|
458 /**************************************************
|
|
459 Sends a authorization to the server so the Mirabilis
|
|
460 client can add the user.
|
|
461 ***************************************************/
|
|
462 WORD icq_SendAuthMsg(icq_Link *icqlink, DWORD uin) /* V5 */
|
|
463 {
|
|
464 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEND_THRU_SRV);
|
|
465 icq_PacketAppend32(p, uin);
|
|
466 icq_PacketAppend32(p, TYPE_AUTH);
|
|
467 icq_PacketAppend16(p, 0);
|
|
468 icq_UDPSockWrite(icqlink, p);
|
|
469
|
|
470 return icqlink->d->icq_UDPSeqNum1-1;
|
|
471 }
|
|
472
|
|
473 /**************************************************
|
|
474 Changes the users status on the server
|
|
475 ***************************************************/
|
|
476 void icq_ChangeStatus(icq_Link *icqlink, DWORD status) /* V5 */
|
|
477 {
|
|
478 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_STATUS_CHANGE);
|
|
479 icq_PacketAppend32(p, status);
|
|
480 icqlink->icq_Status = status;
|
|
481 icq_UDPSockWrite(icqlink, p);
|
|
482 }
|
|
483
|
|
484 /********************************************************
|
|
485 Sends a request to the server for info on a specific user
|
|
486 *********************************************************/
|
|
487 WORD icq_SendInfoReq(icq_Link *icqlink, DWORD uin) /* V5 */
|
|
488 {
|
|
489 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_INFO_REQ);
|
|
490 icq_PacketAppend32(p, uin);
|
|
491 icq_UDPSockWrite(icqlink, p);
|
|
492 return icqlink->d->icq_UDPSeqNum1-1;
|
|
493 }
|
|
494
|
|
495 /********************************************************
|
|
496 Sends a request to the server for info on a specific user
|
|
497 *********************************************************/
|
|
498 WORD icq_SendExtInfoReq(icq_Link *icqlink, DWORD uin) /* V5 */
|
|
499 {
|
|
500 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_EXT_INFO_REQ);
|
|
501 icq_PacketAppend32(p, uin);
|
|
502 icq_UDPSockWrite(icqlink, p);
|
|
503 return icqlink->d->icq_UDPSeqNum1-1;
|
|
504 }
|
|
505
|
|
506 /**************************************************************
|
|
507 Initializes a server search for the information specified
|
|
508 ***************************************************************/
|
|
509 void icq_SendSearchReq(icq_Link *icqlink, const char *email, const char *nick, const char *first,
|
|
510 const char *last) /* V5 */
|
|
511 {
|
|
512 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEARCH_USER);
|
|
513 icq_PacketAppendString(p, nick);
|
|
514 icq_PacketAppendString(p, first);
|
|
515 icq_PacketAppendString(p, last);
|
|
516 icq_PacketAppendString(p, email);
|
|
517 icq_UDPSockWrite(icqlink, p);
|
|
518 }
|
|
519
|
|
520 /**************************************************************
|
|
521 Initializes a server search for the information specified
|
|
522 ***************************************************************/
|
|
523 void icq_SendSearchUINReq(icq_Link *icqlink, DWORD uin) /* V5 */
|
|
524 {
|
|
525 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_SEARCH_UIN);
|
|
526 icq_PacketAppend32(p, uin);
|
|
527 icq_UDPSockWrite(icqlink, p);
|
|
528 }
|
|
529
|
|
530 /**************************************************
|
|
531 Registers a new uin in the ICQ network
|
|
532 ***************************************************/
|
|
533 void icq_RegNewUser(icq_Link *icqlink, const char *pass) /* V5 */
|
|
534 {
|
|
535 char pass8[9];
|
|
536 icq_Packet *p = icq_UDPCreateStdSeqPacket(icqlink, UDP_CMD_REG_NEW_USER, icqlink->d->icq_UDPSeqNum1++);
|
|
537 strncpy(pass8, pass, 8);
|
|
538 icq_PacketAppendString(p, pass8);
|
|
539 icq_PacketAppend32(p, 0xA0);
|
|
540 icq_PacketAppend32(p, 0x2461);
|
|
541 icq_PacketAppend32(p, 0xA00000);
|
|
542 icq_PacketAppend32(p, 0x00);
|
|
543 icq_PacketGoto(p, 6);
|
|
544 icq_PacketAppend32(p, 0);
|
|
545 icq_PacketAppend32(p, rand());
|
|
546 icq_UDPSockWrite(icqlink, p);
|
|
547 icq_FmtLog(icqlink, ICQ_LOG_MESSAGE, "Send RegNewUser packet to the server\n");
|
|
548 }
|
|
549
|
|
550 WORD icq_UpdateUserInfo(icq_Link *icqlink, const char *nick, const char *first, const char *last,
|
|
551 const char *email) /* V5 */
|
|
552 {
|
|
553 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_UPDATE_INFO);
|
|
554 icq_PacketAppendString(p, nick);
|
|
555 icq_PacketAppendString(p, first);
|
|
556 icq_PacketAppendString(p, last);
|
|
557 icq_PacketAppendString(p, email);
|
|
558 /* auth (byte)? */
|
|
559 icq_UDPSockWrite(icqlink, p);
|
|
560 return icqlink->d->icq_UDPSeqNum1-1;
|
|
561 }
|
|
562
|
|
563 WORD icq_UpdateAuthInfo(icq_Link *icqlink, DWORD auth) /* V5 */
|
|
564 {
|
|
565 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_UPDATE_AUTH);
|
|
566 icq_PacketAppend32(p, auth); /* NOT auth? */
|
|
567 icq_UDPSockWrite(icqlink, p);
|
|
568 return icqlink->d->icq_UDPSeqNum1-1;
|
|
569 }
|
|
570
|
|
571 WORD icq_UpdateMetaInfoSet(icq_Link *icqlink, const char *nick, const char *first, const char *last,
|
|
572 const char *email, const char *email2, const char *email3,
|
|
573 const char *city, const char *state, const char *phone, const char *fax,
|
|
574 const char *street, const char *cellular, unsigned long zip,
|
|
575 unsigned short cnt_code, unsigned char cnt_stat, unsigned char emailhide)
|
|
576 {
|
|
577 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER);
|
|
578 icq_PacketAppend16(p, META_CMD_SET_INFO);
|
|
579 icq_PacketAppendString(p, nick);
|
|
580 icq_PacketAppendString(p, first);
|
|
581 icq_PacketAppendString(p, last);
|
|
582 icq_PacketAppendString(p, email);
|
|
583 icq_PacketAppendString(p, email2);
|
|
584 icq_PacketAppendString(p, email3);
|
|
585 icq_PacketAppendString(p, city);
|
|
586 icq_PacketAppendString(p, state);
|
|
587 icq_PacketAppendString(p, phone);
|
|
588 icq_PacketAppendString(p, fax);
|
|
589 icq_PacketAppendString(p, street);
|
|
590 icq_PacketAppendString(p, cellular);
|
|
591 icq_PacketAppend32(p, zip);
|
|
592 icq_PacketAppend16(p, cnt_code);
|
|
593 icq_PacketAppend8(p, cnt_stat);
|
|
594 icq_PacketAppend8(p, emailhide);
|
|
595 icq_UDPSockWrite(icqlink, p);
|
|
596 return icqlink->d->icq_UDPSeqNum2-1;
|
|
597 }
|
|
598
|
|
599 WORD icq_UpdateMetaInfoHomepage(icq_Link *icqlink, unsigned char age, const char *homepage,
|
|
600 unsigned char year, unsigned char month, unsigned char day,
|
|
601 unsigned char lang1, unsigned char lang2, unsigned char lang3)
|
|
602 {
|
|
603 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER);
|
|
604 (void)lang1;
|
|
605 (void)lang2;
|
|
606 (void)lang3;
|
|
607 icq_PacketAppend16(p, META_CMD_SET_HOMEPAGE);
|
|
608 icq_PacketAppend8(p, age);
|
|
609 icq_PacketAppend16(p, 0x0200);
|
|
610 icq_PacketAppendString(p, homepage);
|
|
611 icq_PacketAppend8(p, year);
|
|
612 icq_PacketAppend8(p, month);
|
|
613 icq_PacketAppend8(p, day);
|
|
614 icq_PacketAppend8(p, 0xFF /* lang1 */);
|
|
615 icq_PacketAppend8(p, 0xFF /* lang2 */);
|
|
616 icq_PacketAppend8(p, 0xFF /* lang3 */);
|
|
617 icq_UDPSockWrite(icqlink, p);
|
|
618 return icqlink->d->icq_UDPSeqNum2-1;
|
|
619 }
|
|
620
|
|
621 WORD icq_UpdateMetaInfoAbout(icq_Link *icqlink, const char *about)
|
|
622 {
|
|
623 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER);
|
|
624 icq_PacketAppend16(p, META_CMD_SET_ABOUT);
|
|
625 icq_PacketAppendString(p, about);
|
|
626 icq_UDPSockWrite(icqlink, p);
|
|
627 return icqlink->d->icq_UDPSeqNum2-1;
|
|
628 }
|
|
629
|
|
630 WORD icq_UpdateMetaInfoSecurity(icq_Link *icqlink, unsigned char reqauth, unsigned char webpresence,
|
|
631 unsigned char pubip)
|
|
632 {
|
|
633 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER);
|
|
634 icq_PacketAppend16(p, META_CMD_SET_SECURE);
|
|
635 icq_PacketAppend8(p, !reqauth);
|
|
636 icq_PacketAppend8(p, webpresence);
|
|
637 icq_PacketAppend8(p, pubip);
|
|
638 icq_UDPSockWrite(icqlink, p);
|
|
639 return icqlink->d->icq_UDPSeqNum2-1;
|
|
640 }
|
|
641
|
|
642 WORD icq_UpdateNewUserInfo(icq_Link *icqlink, const char *nick, const char *first, const char *last,
|
|
643 const char *email) /* V5 */
|
|
644 {
|
|
645 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_NEW_USER_INFO);
|
|
646 icq_PacketAppendString(p, nick);
|
|
647 icq_PacketAppendString(p, first);
|
|
648 icq_PacketAppendString(p, last);
|
|
649 icq_PacketAppendString(p, email);
|
|
650 icq_PacketAppend8(p, 1);
|
|
651 icq_PacketAppend8(p, 1);
|
|
652 icq_PacketAppend8(p, 1);
|
|
653 icq_UDPSockWrite(icqlink, p);
|
|
654 return icqlink->d->icq_UDPSeqNum1-1;
|
|
655 }
|
|
656
|
|
657 WORD icq_SendMetaInfoReq(icq_Link *icqlink, unsigned long uin)
|
|
658 {
|
|
659 icq_Packet *p = icq_UDPCreateStdPacket(icqlink, UDP_CMD_META_USER);
|
|
660 icq_PacketAppend16(p, META_CMD_REQ_INFO);
|
|
661 icq_PacketAppend32(p, uin);
|
|
662 icq_UDPSockWrite(icqlink, p);
|
|
663 return icqlink->d->icq_UDPSeqNum2-1;
|
|
664 }
|