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