comparison plugins/icq/stdpackets.c @ 1912:8ed70631ed15

[gaim-migrate @ 1922] new icqlib committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 29 May 2001 10:32:53 +0000
parents 4c510ca3563f
children 7b3f1eb1ef7d
comparison
equal deleted inserted replaced
1911:db3104dda736 1912:8ed70631ed15
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
2 /* 3 /*
3 $Id: stdpackets.c 1442 2001-01-28 01:52:27Z warmenhoven $ 4 * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
4 $Log$ 5 * Bill Soudan <soudan@kde.org>
5 Revision 1.3 2001/01/28 01:52:27 warmenhoven 6 *
6 icqlib 1.1.5 7 * This program is free software; you can redistribute it and/or modify
7 8 * it under the terms of the GNU General Public License as published by
8 Revision 1.12 2001/01/24 05:11:14 bills 9 * the Free Software Foundation; either version 2 of the License, or
9 applied patch from Robin Ericsson <lobbin@localhost.nu> which implements 10 * (at your option) any later version.
10 receiving contact lists. See new icq_RecvContactList callback. 11 *
11 12 * This program is distributed in the hope that it will be useful,
12 Revision 1.11 2000/12/19 06:00:07 bills 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 moved members from ICQLINK to ICQLINK_private struct 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 15 * GNU General Public License for more details.
15 Revision 1.10 2000/06/15 01:51:23 bills 16 *
16 added creation functions for cancel and refuse operations 17 * You should have received a copy of the GNU General Public License
17 18 * along with this program; if not, write to the Free Software
18 Revision 1.9 2000/05/04 15:50:38 bills 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 warning cleanups 20 *
20 21 */
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 22
63 #include <stdlib.h> 23 #include <stdlib.h>
64 24
65 #include "icqtypes.h"
66 #include "icq.h"
67 #include "icqlib.h" 25 #include "icqlib.h"
68 #include "tcp.h" 26 #include "tcp.h"
69 #include "stdpackets.h" 27 #include "stdpackets.h"
70 28
71 icq_Packet *icq_TCPCreateInitPacket(icq_TCPLink *plink) 29 icq_Packet *icq_TCPCreateInitPacket(icq_TCPLink *plink)
95 53
96 return p; 54 return p;
97 } 55 }
98 56
99 icq_Packet *icq_TCPCreateStdPacket(icq_TCPLink *plink, WORD icq_TCPCommand, 57 icq_Packet *icq_TCPCreateStdPacket(icq_TCPLink *plink, WORD icq_TCPCommand,
100 WORD type, const unsigned char *msg, WORD status, 58 WORD type, const char *msg, WORD status,
101 WORD msg_command) 59 WORD msg_command)
102 { 60 {
103 icq_Packet *p=icq_PacketNew(); 61 icq_Packet *p=icq_PacketNew();
104 62
105 if(p) 63 if(p)
124 } 82 }
125 83
126 return p; 84 return p;
127 } 85 }
128 86
129 icq_Packet *icq_TCPCreateMessagePacket(icq_TCPLink *plink, const unsigned char *message) 87 icq_Packet *icq_TCPCreateMessagePacket(icq_TCPLink *plink, const char *message)
130 { 88 {
131 icq_Packet *p=icq_TCPCreateStdPacket( 89 icq_Packet *p=icq_TCPCreateStdPacket(
132 plink, 90 plink,
133 ICQ_TCP_MESSAGE, 91 ICQ_TCP_MESSAGE,
134 ICQ_TCP_MSG_MSG, 92 ICQ_TCP_MSG_MSG,
151 109
152 p=icq_TCPCreateStdPacket( 110 p=icq_TCPCreateStdPacket(
153 plink, 111 plink,
154 ICQ_TCP_MESSAGE, 112 ICQ_TCP_MESSAGE,
155 ICQ_TCP_MSG_URL, 113 ICQ_TCP_MSG_URL,
156 str, 114 (const char *)str,
157 0, /* status */ 115 0, /* status */
158 ICQ_TCP_MSG_REAL); 116 ICQ_TCP_MSG_REAL);
159 117
160 free(str); 118 free(str);
161 119
162 return p; 120 return p;
163 } 121 }
164 122
165 icq_Packet *icq_TCPCreateChatReqPacket(icq_TCPLink *plink, const unsigned char *message) 123 icq_Packet *icq_TCPCreateChatReqPacket(icq_TCPLink *plink, const char *message)
166 { 124 {
167 icq_Packet *p=icq_TCPCreateStdPacket( 125 icq_Packet *p=icq_TCPCreateStdPacket(
168 plink, 126 plink,
169 ICQ_TCP_MESSAGE, 127 ICQ_TCP_MESSAGE,
170 ICQ_TCP_MSG_CHAT, 128 ICQ_TCP_MSG_CHAT,
368 { 326 {
369 icq_Packet *p=icq_TCPCreateStdPacket( 327 icq_Packet *p=icq_TCPCreateStdPacket(
370 plink, 328 plink,
371 ICQ_TCP_MESSAGE, 329 ICQ_TCP_MESSAGE,
372 ICQ_TCP_MSG_FILE, 330 ICQ_TCP_MSG_FILE,
373 (const unsigned char*)message, 331 (const char*)message,
374 0, /* status */ 332 0, /* status */
375 ICQ_TCP_MSG_REAL); 333 ICQ_TCP_MSG_REAL);
376 334
377 icq_PacketAppend16(p, 0x0000); 335 icq_PacketAppend16(p, 0x0000);
378 icq_PacketAppend16(p, 0x0000); 336 icq_PacketAppend16(p, 0x0000);
383 icq_PacketAppend32(p, 0x00000000); 341 icq_PacketAppend32(p, 0x00000000);
384 342
385 return p; 343 return p;
386 } 344 }
387 345
388 void icq_TCPAppendSequence(ICQLINK *link, icq_Packet *p) 346 void icq_TCPAppendSequence(icq_Link *icqlink, icq_Packet *p)
389 { 347 {
390 p->id=link->d->icq_TCPSequence--; 348 p->id=icqlink->d->icq_TCPSequence--;
391 icq_PacketEnd(p); 349 icq_PacketEnd(p);
392 icq_PacketAppend32(p, p->id); 350 icq_PacketAppend32(p, p->id);
393 } 351 }
394 352
395 void icq_TCPAppendSequenceN(ICQLINK *link, icq_Packet *p, DWORD seq) 353 void icq_TCPAppendSequenceN(icq_Link *icqlink, icq_Packet *p, DWORD seq)
396 { 354 {
397 (void)link; 355 (void)icqlink;
398 p->id=seq; 356 p->id=seq;
399 icq_PacketEnd(p); 357 icq_PacketEnd(p);
400 icq_PacketAppend32(p, p->id); 358 icq_PacketAppend32(p, p->id);
401 } 359 }
402 360
403 icq_Packet *icq_TCPCreateMessageAck(icq_TCPLink *plink, const unsigned char *message) 361 icq_Packet *icq_TCPCreateMessageAck(icq_TCPLink *plink, const char *message)
404 { 362 {
405 icq_Packet *p=icq_TCPCreateStdPacket( 363 icq_Packet *p=icq_TCPCreateStdPacket(
406 plink, 364 plink,
407 ICQ_TCP_ACK, 365 ICQ_TCP_ACK,
408 ICQ_TCP_MSG_MSG, 366 ICQ_TCP_MSG_MSG,
411 ICQ_TCP_MSG_ACK); 369 ICQ_TCP_MSG_ACK);
412 370
413 return p; 371 return p;
414 } 372 }
415 373
416 icq_Packet *icq_TCPCreateURLAck(icq_TCPLink *plink, const unsigned char *message) 374 icq_Packet *icq_TCPCreateURLAck(icq_TCPLink *plink, const char *message)
417 { 375 {
418 icq_Packet *p=icq_TCPCreateStdPacket( 376 icq_Packet *p=icq_TCPCreateStdPacket(
419 plink, 377 plink,
420 ICQ_TCP_ACK, 378 ICQ_TCP_ACK,
421 ICQ_TCP_MSG_URL, 379 ICQ_TCP_MSG_URL,
424 ICQ_TCP_MSG_ACK); 382 ICQ_TCP_MSG_ACK);
425 383
426 return p; 384 return p;
427 } 385 }
428 386
429 icq_Packet *icq_TCPCreateContactListAck(icq_TCPLink *plink, const unsigned char *message) 387 icq_Packet *icq_TCPCreateContactListAck(icq_TCPLink *plink, const char *message)
430 { 388 {
431 icq_Packet *p=icq_TCPCreateStdPacket( 389 icq_Packet *p=icq_TCPCreateStdPacket(
432 plink, 390 plink,
433 ICQ_TCP_ACK, 391 ICQ_TCP_ACK,
434 ICQ_TCP_MSG_CONTACTLIST, 392 ICQ_TCP_MSG_CONTACTLIST,
542 } 500 }
543 501
544 return p; 502 return p;
545 } 503 }
546 504
547 icq_Packet *icq_UDPCreateStdPacket(ICQLINK *link, WORD cmd) 505 icq_Packet *icq_UDPCreateStdPacket(icq_Link *icqlink, WORD cmd)
548 { 506 {
549 icq_Packet *p = icq_PacketNew(); 507 icq_Packet *p = icq_PacketNew();
550 508
551 /* if(!link->d->icq_UDPSession) 509 /* if(!link->d->icq_UDPSession)
552 link->d->icq_UDPSession = rand() & 0x3FFFFFFF; 510 link->d->icq_UDPSession = rand() & 0x3FFFFFFF;
553 if(!link->d->icq_UDPSeqNum2) 511 if(!link->d->icq_UDPSeqNum2)
554 link->d->icq_UDPSeqNum2 = rand() & 0x7FFF;*/ 512 link->d->icq_UDPSeqNum2 = rand() & 0x7FFF;*/
555 513
556 icq_PacketAppend16(p, ICQ_UDP_VER); /* ver */ 514 icq_PacketAppend16(p, ICQ_UDP_VER); /* ver */
557 icq_PacketAppend32(p, 0); /* zero */ 515 icq_PacketAppend32(p, 0); /* zero */
558 icq_PacketAppend32(p, link->icq_Uin); /* uin */ 516 icq_PacketAppend32(p, icqlink->icq_Uin); /* uin */
559 icq_PacketAppend32(p, link->d->icq_UDPSession); /* session */ 517 icq_PacketAppend32(p, icqlink->d->icq_UDPSession); /* session */
560 icq_PacketAppend16(p, cmd); /* cmd */ 518 icq_PacketAppend16(p, cmd); /* cmd */
561 icq_PacketAppend16(p, link->d->icq_UDPSeqNum1++); /* seq1 */ 519 icq_PacketAppend16(p, icqlink->d->icq_UDPSeqNum1++); /* seq1 */
562 icq_PacketAppend16(p, link->d->icq_UDPSeqNum2++); /* seq2 */ 520 icq_PacketAppend16(p, icqlink->d->icq_UDPSeqNum2++); /* seq2 */
563 icq_PacketAppend32(p, 0); /* checkcode */ 521 icq_PacketAppend32(p, 0); /* checkcode */
564 522
565 return p; 523 return p;
566 } 524 }
567 525
568 icq_Packet *icq_UDPCreateStdSeqPacket(ICQLINK *link, WORD cmd, WORD seq) 526 icq_Packet *icq_UDPCreateStdSeqPacket(icq_Link *icqlink, WORD cmd, WORD seq)
569 { 527 {
570 icq_Packet *p = icq_PacketNew(); 528 icq_Packet *p = icq_PacketNew();
571 529
572 icq_PacketAppend16(p, ICQ_UDP_VER); /* ver */ 530 icq_PacketAppend16(p, ICQ_UDP_VER); /* ver */
573 icq_PacketAppend32(p, 0); /* zero */ 531 icq_PacketAppend32(p, 0); /* zero */
574 icq_PacketAppend32(p, link->icq_Uin); /* uin */ 532 icq_PacketAppend32(p, icqlink->icq_Uin); /* uin */
575 icq_PacketAppend32(p, link->d->icq_UDPSession); /* session */ 533 icq_PacketAppend32(p, icqlink->d->icq_UDPSession); /* session */
576 icq_PacketAppend16(p, cmd); /* cmd */ 534 icq_PacketAppend16(p, cmd); /* cmd */
577 icq_PacketAppend16(p, seq); /* seq1 */ 535 icq_PacketAppend16(p, seq); /* seq1 */
578 icq_PacketAppend16(p, 0); /* seq2 */ 536 icq_PacketAppend16(p, 0); /* seq2 */
579 icq_PacketAppend32(p, 0); /* checkcode */ 537 icq_PacketAppend32(p, 0); /* checkcode */
580 538
581 return p; 539 return p;
582 } 540 }