Mercurial > pidgin.yaz
annotate plugins/icq/stdpackets.c @ 1727:02653161cbce
[gaim-migrate @ 1737]
bleh. this should be handled by write_to_conv.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 19 Apr 2001 03:53:23 +0000 |
parents | 4c510ca3563f |
children | 8ed70631ed15 |
rev | line source |
---|---|
1152 | 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* | |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
3 $Id: stdpackets.c 1442 2001-01-28 01:52:27Z warmenhoven $ |
1152 | 4 $Log$ |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
5 Revision 1.3 2001/01/28 01:52:27 warmenhoven |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
6 icqlib 1.1.5 |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
7 |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
8 Revision 1.12 2001/01/24 05:11:14 bills |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
9 applied patch from Robin Ericsson <lobbin@localhost.nu> which implements |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
10 receiving contact lists. See new icq_RecvContactList callback. |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
11 |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
12 Revision 1.11 2000/12/19 06:00:07 bills |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
13 moved members from ICQLINK to ICQLINK_private struct |
1152 | 14 |
15 Revision 1.10 2000/06/15 01:51:23 bills | |
16 added creation functions for cancel and refuse operations | |
17 | |
18 Revision 1.9 2000/05/04 15:50:38 bills | |
19 warning cleanups | |
20 | |
21 Revision 1.8 2000/04/10 18:11:45 denis | |
22 ANSI cleanups. | |
23 | |
24 Revision 1.7 2000/04/06 16:38:04 denis | |
25 icq_*Send*Seq() functions with specified sequence number were added. | |
26 | |
27 Revision 1.6 2000/02/07 02:35:13 bills | |
28 slightly modified chat packets | |
29 | |
30 Revision 1.5 2000/01/20 19:59:15 bills | |
31 first implementation of sending file requests | |
32 | |
33 Revision 1.4 1999/09/29 20:12:32 bills | |
34 tcp_link*->icq_TCPLink* | |
35 | |
36 Revision 1.3 1999/09/29 17:07:48 denis | |
37 Host/network byteorder cleanups. | |
38 | |
39 Revision 1.2 1999/07/16 15:45:20 denis | |
40 Cleaned up. | |
41 | |
42 Revision 1.1 1999/07/16 12:13:11 denis | |
43 UDP packets support added. | |
44 tcppackets.[ch] files renamed to stdpackets.[ch] | |
45 | |
46 Revision 1.9 1999/07/12 15:13:39 cproch | |
47 - added definition of ICQLINK to hold session-specific global variabled | |
48 applications which have more than one connection are now possible | |
49 - changed nearly every function defintion to support ICQLINK parameter | |
50 | |
51 Revision 1.8 1999/05/03 21:41:28 bills | |
52 initial file xfer support added- untested | |
53 | |
54 Revision 1.7 1999/04/17 19:39:09 bills | |
55 added new functions to create chat packets. removed unnecessary code. | |
56 added new function to create URL ack packet. | |
57 | |
58 Revision 1.6 1999/04/14 15:08:39 denis | |
59 Cleanups for "strict" compiling (-ansi -pedantic) | |
60 | |
61 */ | |
62 | |
63 #include <stdlib.h> | |
64 | |
65 #include "icqtypes.h" | |
66 #include "icq.h" | |
67 #include "icqlib.h" | |
68 #include "tcp.h" | |
69 #include "stdpackets.h" | |
70 | |
71 icq_Packet *icq_TCPCreateInitPacket(icq_TCPLink *plink) | |
72 { | |
73 icq_Packet *p=icq_PacketNew(); | |
74 | |
75 if(p) | |
76 { | |
77 int type=plink->type; | |
78 | |
79 icq_PacketAppend8(p, 0xFF); | |
80 icq_PacketAppend32(p, ICQ_TCP_VER); | |
81 if(type==TCP_LINK_MESSAGE) | |
82 icq_PacketAppend32n(p, htons(plink->icqlink->icq_TCPSrvPort)); | |
83 else | |
84 icq_PacketAppend32(p, 0x00000000); | |
85 icq_PacketAppend32(p, plink->icqlink->icq_Uin); | |
86 icq_PacketAppend32n(p, htonl(plink->icqlink->icq_OurIP)); | |
87 icq_PacketAppend32n(p, htonl(plink->icqlink->icq_OurIP)); | |
88 icq_PacketAppend8(p, 0x04); | |
89 if(type==TCP_LINK_FILE || type==TCP_LINK_CHAT) | |
90 icq_PacketAppend32(p, ntohs(plink->socket_address.sin_port)); | |
91 else | |
92 icq_PacketAppend32(p, 0x00000000); | |
93 | |
94 } | |
95 | |
96 return p; | |
97 } | |
98 | |
99 icq_Packet *icq_TCPCreateStdPacket(icq_TCPLink *plink, WORD icq_TCPCommand, | |
100 WORD type, const unsigned char *msg, WORD status, | |
101 WORD msg_command) | |
102 { | |
103 icq_Packet *p=icq_PacketNew(); | |
104 | |
105 if(p) | |
106 { | |
107 icq_PacketAppend32(p, plink->icqlink->icq_Uin); | |
108 icq_PacketAppend16(p, ICQ_TCP_VER); | |
109 icq_PacketAppend16(p, icq_TCPCommand); | |
110 icq_PacketAppend16(p, 0x0000); | |
111 icq_PacketAppend32(p, plink->icqlink->icq_Uin); | |
112 | |
113 icq_PacketAppend16(p, type); | |
114 icq_PacketAppendString(p, (char*)msg); | |
115 | |
116 /* FIXME: this should be the address the server returns to us, | |
117 * link->icq_OurIp */ | |
118 icq_PacketAppend32(p, plink->socket_address.sin_addr.s_addr); | |
119 icq_PacketAppend32(p, plink->socket_address.sin_addr.s_addr); | |
120 icq_PacketAppend32(p, ntohs(plink->socket_address.sin_port)); | |
121 icq_PacketAppend8(p, 0x04); | |
122 icq_PacketAppend16(p, status); | |
123 icq_PacketAppend16(p, msg_command); | |
124 } | |
125 | |
126 return p; | |
127 } | |
128 | |
129 icq_Packet *icq_TCPCreateMessagePacket(icq_TCPLink *plink, const unsigned char *message) | |
130 { | |
131 icq_Packet *p=icq_TCPCreateStdPacket( | |
132 plink, | |
133 ICQ_TCP_MESSAGE, | |
134 ICQ_TCP_MSG_MSG, | |
135 message, | |
136 0, /* status */ | |
137 ICQ_TCP_MSG_REAL); | |
138 | |
139 return p; | |
140 } | |
141 | |
142 icq_Packet *icq_TCPCreateURLPacket(icq_TCPLink *plink, const char *message, | |
143 const char *url) | |
144 { | |
145 icq_Packet *p; | |
146 unsigned char *str=(unsigned char*)malloc(strlen(message)+strlen(url)+2); | |
147 | |
148 strcpy((char*)str, message); | |
149 *(str+strlen(message))=0xFE; | |
150 strcpy((char*)(str+strlen(message)+1), url); | |
151 | |
152 p=icq_TCPCreateStdPacket( | |
153 plink, | |
154 ICQ_TCP_MESSAGE, | |
155 ICQ_TCP_MSG_URL, | |
156 str, | |
157 0, /* status */ | |
158 ICQ_TCP_MSG_REAL); | |
159 | |
160 free(str); | |
161 | |
162 return p; | |
163 } | |
164 | |
165 icq_Packet *icq_TCPCreateChatReqPacket(icq_TCPLink *plink, const unsigned char *message) | |
166 { | |
167 icq_Packet *p=icq_TCPCreateStdPacket( | |
168 plink, | |
169 ICQ_TCP_MESSAGE, | |
170 ICQ_TCP_MSG_CHAT, | |
171 message, | |
172 0, /* status */ | |
173 ICQ_TCP_MSG_REAL); | |
174 | |
175 icq_PacketAppendString(p, 0); | |
176 | |
177 icq_PacketAppend16(p, 0x0000); | |
178 icq_PacketAppend16(p, 0x0000); | |
179 icq_PacketAppend32(p, 0x00000000); | |
180 | |
181 return p; | |
182 } | |
183 | |
184 icq_Packet *icq_TCPCreateChatReqAck(icq_TCPLink *plink, WORD port) | |
185 { | |
186 icq_Packet *p=icq_TCPCreateStdPacket( | |
187 plink, | |
188 ICQ_TCP_ACK, | |
189 ICQ_TCP_MSG_CHAT, | |
190 0, | |
191 0, /* status */ | |
192 ICQ_TCP_MSG_ACK); | |
193 | |
194 icq_PacketAppendString(p, 0); | |
195 | |
196 icq_PacketAppend16(p, htons(port)); | |
197 icq_PacketAppend16(p, 0x0000); | |
198 icq_PacketAppend32(p, port); | |
199 | |
200 return p; | |
201 } | |
202 | |
203 icq_Packet *icq_TCPCreateChatReqRefuse(icq_TCPLink *plink, WORD port, | |
204 const char *reason) | |
205 { | |
206 icq_Packet *p=icq_TCPCreateStdPacket( | |
207 plink, | |
208 ICQ_TCP_ACK, | |
209 ICQ_TCP_MSG_CHAT, | |
210 reason, | |
211 ICQ_TCP_STATUS_REFUSE, | |
212 ICQ_TCP_MSG_ACK); | |
213 | |
214 icq_PacketAppendString(p, 0); | |
215 | |
216 icq_PacketAppend16(p, htons(port)); | |
217 icq_PacketAppend16(p, 0x0000); | |
218 icq_PacketAppend32(p, port); | |
219 | |
220 return p; | |
221 } | |
222 | |
223 icq_Packet *icq_TCPCreateChatReqCancel(icq_TCPLink *plink, WORD port) | |
224 { | |
225 icq_Packet *p=icq_TCPCreateStdPacket( | |
226 plink, | |
227 ICQ_TCP_CANCEL, | |
228 ICQ_TCP_MSG_CHAT, | |
229 0, | |
230 0, /* status */ | |
231 ICQ_TCP_MSG_ACK); | |
232 | |
233 icq_PacketAppendString(p, 0); | |
234 | |
235 icq_PacketAppend16(p, htons(port)); | |
236 icq_PacketAppend16(p, 0x0000); | |
237 icq_PacketAppend32(p, port); | |
238 | |
239 return p; | |
240 } | |
241 | |
242 icq_Packet *icq_TCPCreateFileReqAck(icq_TCPLink *plink, WORD port) | |
243 { | |
244 icq_Packet *p=icq_TCPCreateStdPacket( | |
245 plink, | |
246 ICQ_TCP_ACK, | |
247 ICQ_TCP_MSG_FILE, | |
248 0, | |
249 0, /* status */ | |
250 ICQ_TCP_MSG_ACK); | |
251 | |
252 icq_PacketAppend16(p, htons(port)); | |
253 icq_PacketAppend16(p, 0x0000); | |
254 icq_PacketAppendString(p, 0); | |
255 icq_PacketAppend32(p, 0x00000000); | |
256 icq_PacketAppend32(p, port); | |
257 | |
258 return p; | |
259 } | |
260 | |
261 icq_Packet *icq_TCPCreateFileReqRefuse(icq_TCPLink *plink, WORD port, | |
262 const char *reason) | |
263 { | |
264 icq_Packet *p=icq_TCPCreateStdPacket( | |
265 plink, | |
266 ICQ_TCP_ACK, | |
267 ICQ_TCP_MSG_FILE, | |
268 reason, | |
269 ICQ_TCP_STATUS_REFUSE, | |
270 ICQ_TCP_MSG_ACK); | |
271 | |
272 icq_PacketAppend16(p, htons(port)); | |
273 icq_PacketAppend16(p, 0x0000); | |
274 icq_PacketAppendString(p, 0); | |
275 icq_PacketAppend32(p, 0x00000000); | |
276 icq_PacketAppend32(p, port); | |
277 | |
278 return p; | |
279 } | |
280 | |
281 icq_Packet *icq_TCPCreateFileReqCancel(icq_TCPLink *plink, WORD port) | |
282 { | |
283 icq_Packet *p=icq_TCPCreateStdPacket( | |
284 plink, | |
285 ICQ_TCP_CANCEL, | |
286 ICQ_TCP_MSG_FILE, | |
287 0, | |
288 0, /* status */ | |
289 ICQ_TCP_MSG_ACK); | |
290 | |
291 icq_PacketAppend16(p, htons(port)); | |
292 icq_PacketAppend16(p, 0x0000); | |
293 icq_PacketAppendString(p, 0); | |
294 icq_PacketAppend32(p, 0x00000000); | |
295 icq_PacketAppend32(p, port); | |
296 | |
297 return p; | |
298 } | |
299 | |
300 icq_Packet *icq_TCPCreateChatInfoPacket(icq_TCPLink *plink, const char *name, | |
301 DWORD foreground, DWORD background) | |
302 { | |
303 icq_Packet *p=icq_PacketNew(); | |
304 | |
305 icq_PacketAppend32(p, 0x00000065); | |
306 icq_PacketAppend32(p, 0xfffffffa); | |
307 icq_PacketAppend32(p, plink->icqlink->icq_Uin); | |
308 icq_PacketAppendString(p, name); | |
309 icq_PacketAppend16(p, plink->socket_address.sin_port); | |
310 icq_PacketAppend32(p, foreground); | |
311 icq_PacketAppend32(p, background); | |
312 icq_PacketAppend8(p, 0x00); | |
313 | |
314 return p; | |
315 | |
316 } | |
317 | |
318 icq_Packet *icq_TCPCreateChatInfo2Packet(icq_TCPLink *plink, const char *name, | |
319 DWORD foreground, DWORD background) | |
320 { | |
321 icq_Packet *p=icq_PacketNew(); | |
322 | |
323 icq_PacketAppend32(p, 0x00000064); | |
324 icq_PacketAppend32(p, plink->icqlink->icq_Uin); | |
325 icq_PacketAppendString(p, name); | |
326 icq_PacketAppend32(p, foreground); | |
327 icq_PacketAppend32(p, background); | |
328 | |
329 icq_PacketAppend32(p, 0x00070004); | |
330 icq_PacketAppend32(p, 0x00000000); | |
331 icq_PacketAppend32n(p, htonl(plink->icqlink->icq_OurIP)); | |
332 icq_PacketAppend32n(p, htonl(plink->icqlink->icq_OurIP)); | |
333 icq_PacketAppend8(p, 0x04); | |
334 icq_PacketAppend16(p, 0x0000); | |
335 icq_PacketAppend32(p, 0x000a); | |
336 icq_PacketAppend32(p, 0x0000); | |
337 icq_PacketAppendString(p, "Courier New"); | |
338 icq_PacketAppend8(p, 204); | |
339 icq_PacketAppend8(p, 49); | |
340 icq_PacketAppend8(p, 0x00); | |
341 | |
342 return p; | |
343 } | |
344 | |
345 icq_Packet *icq_TCPCreateChatFontInfoPacket(icq_TCPLink *plink) | |
346 { | |
347 icq_Packet *p=icq_PacketNew(); | |
348 | |
349 icq_PacketAppend32(p, 0x00070004); | |
350 icq_PacketAppend32(p, 0x00000000); | |
351 icq_PacketAppend32n(p, htonl(plink->icqlink->icq_OurIP)); | |
352 icq_PacketAppend32n(p, htonl(plink->icqlink->icq_OurIP)); | |
353 icq_PacketAppend8(p, 0x04); | |
354 icq_PacketAppend16(p, ntohs(plink->socket_address.sin_port)); /* Zero ? */ | |
355 icq_PacketAppend32(p, 0x000a); | |
356 icq_PacketAppend32(p, 0x0000); | |
357 icq_PacketAppendString(p, "Courier New"); | |
358 icq_PacketAppend8(p, 204); | |
359 icq_PacketAppend8(p, 49); | |
360 icq_PacketAppend8(p, 0x00); | |
361 | |
362 return p; | |
363 } | |
364 | |
365 | |
366 icq_Packet *icq_TCPCreateFileReqPacket(icq_TCPLink *plink, | |
367 const char *message, const char *filename, unsigned long size) | |
368 { | |
369 icq_Packet *p=icq_TCPCreateStdPacket( | |
370 plink, | |
371 ICQ_TCP_MESSAGE, | |
372 ICQ_TCP_MSG_FILE, | |
373 (const unsigned char*)message, | |
374 0, /* status */ | |
375 ICQ_TCP_MSG_REAL); | |
376 | |
377 icq_PacketAppend16(p, 0x0000); | |
378 icq_PacketAppend16(p, 0x0000); | |
379 | |
380 icq_PacketAppendString(p, filename); | |
381 | |
382 icq_PacketAppend32(p, size); | |
383 icq_PacketAppend32(p, 0x00000000); | |
384 | |
385 return p; | |
386 } | |
387 | |
388 void icq_TCPAppendSequence(ICQLINK *link, icq_Packet *p) | |
389 { | |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
390 p->id=link->d->icq_TCPSequence--; |
1152 | 391 icq_PacketEnd(p); |
392 icq_PacketAppend32(p, p->id); | |
393 } | |
394 | |
395 void icq_TCPAppendSequenceN(ICQLINK *link, icq_Packet *p, DWORD seq) | |
396 { | |
397 (void)link; | |
398 p->id=seq; | |
399 icq_PacketEnd(p); | |
400 icq_PacketAppend32(p, p->id); | |
401 } | |
402 | |
403 icq_Packet *icq_TCPCreateMessageAck(icq_TCPLink *plink, const unsigned char *message) | |
404 { | |
405 icq_Packet *p=icq_TCPCreateStdPacket( | |
406 plink, | |
407 ICQ_TCP_ACK, | |
408 ICQ_TCP_MSG_MSG, | |
409 message, | |
410 0, /* status */ | |
411 ICQ_TCP_MSG_ACK); | |
412 | |
413 return p; | |
414 } | |
415 | |
416 icq_Packet *icq_TCPCreateURLAck(icq_TCPLink *plink, const unsigned char *message) | |
417 { | |
418 icq_Packet *p=icq_TCPCreateStdPacket( | |
419 plink, | |
420 ICQ_TCP_ACK, | |
421 ICQ_TCP_MSG_URL, | |
422 message, | |
423 0, /* status */ | |
424 ICQ_TCP_MSG_ACK); | |
425 | |
426 return p; | |
427 } | |
428 | |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
429 icq_Packet *icq_TCPCreateContactListAck(icq_TCPLink *plink, const unsigned char *message) |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
430 { |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
431 icq_Packet *p=icq_TCPCreateStdPacket( |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
432 plink, |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
433 ICQ_TCP_ACK, |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
434 ICQ_TCP_MSG_CONTACTLIST, |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
435 message, |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
436 0, /* status */ |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
437 ICQ_TCP_MSG_ACK); |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
438 |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
439 return p; |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1309
diff
changeset
|
440 } |
1152 | 441 |
442 icq_Packet *icq_TCPCreateFile00Packet(DWORD num_files, DWORD total_bytes, | |
443 DWORD speed, const char *name) | |
444 { | |
445 icq_Packet *p=icq_PacketNew(); | |
446 | |
447 if(p) | |
448 { | |
449 icq_PacketAppend8(p, 0x00); | |
450 icq_PacketAppend32(p, 0x00000000); | |
451 icq_PacketAppend32(p, num_files); | |
452 icq_PacketAppend32(p, total_bytes); | |
453 icq_PacketAppend32(p, speed); | |
454 icq_PacketAppendString(p, name); | |
455 } | |
456 | |
457 return p; | |
458 } | |
459 | |
460 icq_Packet *icq_TCPCreateFile01Packet(DWORD speed, const char *name) | |
461 { | |
462 icq_Packet *p=icq_PacketNew(); | |
463 | |
464 if(p) | |
465 { | |
466 icq_PacketAppend8(p, 0x01); | |
467 icq_PacketAppend32(p, speed); | |
468 icq_PacketAppendString(p, name); | |
469 } | |
470 | |
471 return p; | |
472 } | |
473 | |
474 icq_Packet *icq_TCPCreateFile02Packet(const char *filename, DWORD filesize, | |
475 DWORD speed) | |
476 { | |
477 icq_Packet *p=icq_PacketNew(); | |
478 | |
479 if(p) | |
480 { | |
481 icq_PacketAppend8(p, 0x02); | |
482 icq_PacketAppend8(p, 0x00); | |
483 icq_PacketAppendString(p, filename); | |
484 icq_PacketAppendString(p, 0); | |
485 icq_PacketAppend32(p, filesize); | |
486 icq_PacketAppend32(p, 0x00000000); | |
487 icq_PacketAppend32(p, speed); | |
488 } | |
489 | |
490 return p; | |
491 } | |
492 | |
493 icq_Packet *icq_TCPCreateFile03Packet(DWORD filesize, DWORD speed) | |
494 { | |
495 icq_Packet *p=icq_PacketNew(); | |
496 | |
497 if(p) | |
498 { | |
499 icq_PacketAppend8(p, 0x03); | |
500 icq_PacketAppend32(p, filesize); | |
501 icq_PacketAppend32(p, 0x00000000); | |
502 icq_PacketAppend32(p, speed); | |
503 } | |
504 | |
505 return p; | |
506 } | |
507 | |
508 icq_Packet *icq_TCPCreateFile04Packet(DWORD filenum) | |
509 { | |
510 icq_Packet *p=icq_PacketNew(); | |
511 | |
512 if(p) | |
513 { | |
514 icq_PacketAppend8(p, 0x04); | |
515 icq_PacketAppend32(p, filenum); | |
516 } | |
517 | |
518 return p; | |
519 } | |
520 | |
521 icq_Packet *icq_TCPCreateFile05Packet(DWORD speed) | |
522 { | |
523 icq_Packet *p=icq_PacketNew(); | |
524 | |
525 if(p) | |
526 { | |
527 icq_PacketAppend8(p, 0x05); | |
528 icq_PacketAppend32(p, speed); | |
529 } | |
530 | |
531 return p; | |
532 } | |
533 | |
534 icq_Packet *icq_TCPCreateFile06Packet(int length, void *data) | |
535 { | |
536 icq_Packet *p=icq_PacketNew(); | |
537 | |
538 if(p) | |
539 { | |
540 icq_PacketAppend8(p, 0x06); | |
541 icq_PacketAppend(p, data, length); | |
542 } | |
543 | |
544 return p; | |
545 } | |
546 | |
547 icq_Packet *icq_UDPCreateStdPacket(ICQLINK *link, WORD cmd) | |
548 { | |
549 icq_Packet *p = icq_PacketNew(); | |
550 | |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
551 /* if(!link->d->icq_UDPSession) |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
552 link->d->icq_UDPSession = rand() & 0x3FFFFFFF; |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
553 if(!link->d->icq_UDPSeqNum2) |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
554 link->d->icq_UDPSeqNum2 = rand() & 0x7FFF;*/ |
1152 | 555 |
556 icq_PacketAppend16(p, ICQ_UDP_VER); /* ver */ | |
557 icq_PacketAppend32(p, 0); /* zero */ | |
558 icq_PacketAppend32(p, link->icq_Uin); /* uin */ | |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
559 icq_PacketAppend32(p, link->d->icq_UDPSession); /* session */ |
1152 | 560 icq_PacketAppend16(p, cmd); /* cmd */ |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
561 icq_PacketAppend16(p, link->d->icq_UDPSeqNum1++); /* seq1 */ |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
562 icq_PacketAppend16(p, link->d->icq_UDPSeqNum2++); /* seq2 */ |
1152 | 563 icq_PacketAppend32(p, 0); /* checkcode */ |
564 | |
565 return p; | |
566 } | |
567 | |
568 icq_Packet *icq_UDPCreateStdSeqPacket(ICQLINK *link, WORD cmd, WORD seq) | |
569 { | |
570 icq_Packet *p = icq_PacketNew(); | |
571 | |
572 icq_PacketAppend16(p, ICQ_UDP_VER); /* ver */ | |
573 icq_PacketAppend32(p, 0); /* zero */ | |
574 icq_PacketAppend32(p, link->icq_Uin); /* uin */ | |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
575 icq_PacketAppend32(p, link->d->icq_UDPSession); /* session */ |
1152 | 576 icq_PacketAppend16(p, cmd); /* cmd */ |
577 icq_PacketAppend16(p, seq); /* seq1 */ | |
578 icq_PacketAppend16(p, 0); /* seq2 */ | |
579 icq_PacketAppend32(p, 0); /* checkcode */ | |
580 | |
581 return p; | |
582 } |