EQPacket.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "debug.h"
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <iostream>
  20. #include <iomanip>
  21. #include "EQPacket.h"
  22. #include "misc.h"
  23. #include "op_codes.h"
  24. #include "CRC16.h"
  25. #include "opcodemgr.h"
  26. #include "packet_dump.h"
  27. #include <map>
  28. #include "Log.h"
  29. #include <time.h>
  30. using namespace std;
  31. extern map<int16,OpcodeManager*>EQOpcodeManager;
  32. uint8 EQApplicationPacket::default_opcode_size=2;
  33. EQPacket::EQPacket(const uint16 op, const unsigned char *buf, uint32 len)
  34. {
  35. this->opcode=op;
  36. this->pBuffer=NULL;
  37. this->size=0;
  38. version = 0;
  39. setTimeInfo(0,0);
  40. if (len>0) {
  41. this->size=len;
  42. pBuffer= new unsigned char[this->size];
  43. if (buf) {
  44. memcpy(this->pBuffer,buf,this->size);
  45. } else {
  46. memset(this->pBuffer,0,this->size);
  47. }
  48. }
  49. }
  50. const char* EQ2Packet::GetOpcodeName() {
  51. int16 OpcodeVersion = GetOpcodeVersion(version);
  52. if (EQOpcodeManager.count(OpcodeVersion) > 0)
  53. return EQOpcodeManager[OpcodeVersion]->EmuToName(login_op);
  54. else
  55. return NULL;
  56. }
  57. int8 EQ2Packet::PreparePacket(int16 MaxLen) {
  58. int16 OpcodeVersion = GetOpcodeVersion(version);
  59. // stops a crash for incorrect version
  60. if (EQOpcodeManager.count(OpcodeVersion) == 0)
  61. {
  62. LogWrite(PACKET__ERROR, 0, "Packet", "Version %i is not listed in the opcodes table.", version);
  63. return -1;
  64. }
  65. packet_prepared = true;
  66. int16 login_opcode = EQOpcodeManager[OpcodeVersion]->EmuToEQ(login_op);
  67. if (login_opcode == 0xcdcd)
  68. {
  69. LogWrite(PACKET__ERROR, 0, "Packet", "Version %i is not listed in the opcodes table for opcode %s", version, EQOpcodeManager[OpcodeVersion]->EmuToName(login_op));
  70. return -1;
  71. }
  72. int16 orig_opcode = login_opcode;
  73. int8 offset = 0;
  74. //one of the int16s is for the seq, other is for the EQ2 opcode and compressed flag (OP_Packet is the header, not the opcode)
  75. int32 new_size = size + sizeof(int16) + sizeof(int8);
  76. bool oversized = false;
  77. if (login_opcode != 2) {
  78. new_size += sizeof(int8); //for opcode
  79. if (login_opcode >= 255) {
  80. new_size += sizeof(int16);
  81. oversized = true;
  82. }
  83. else
  84. login_opcode = ntohs(login_opcode);
  85. }
  86. uchar* new_buffer = new uchar[new_size];
  87. memset(new_buffer, 0, new_size);
  88. uchar* ptr = new_buffer + sizeof(int16); // sequence is first
  89. if (login_opcode != 2) {
  90. if (oversized) {
  91. ptr += sizeof(int8); //compressed flag
  92. int8 addon = 0xff;
  93. memcpy(ptr, &addon, sizeof(int8));
  94. ptr += sizeof(int8);
  95. }
  96. memcpy(ptr, &login_opcode, sizeof(int16));
  97. ptr += sizeof(int16);
  98. }
  99. else {
  100. memcpy(ptr, &login_opcode, sizeof(int8));
  101. ptr += sizeof(int8);
  102. }
  103. memcpy(ptr, pBuffer, size);
  104. safe_delete_array(pBuffer);
  105. pBuffer = new_buffer;
  106. offset = new_size - size - 1;
  107. size = new_size;
  108. return offset;
  109. }
  110. uint32 EQProtocolPacket::serialize(unsigned char *dest, int8 offset) const
  111. {
  112. if (opcode>0xff) {
  113. *(uint16 *)dest=opcode;
  114. } else {
  115. *(dest)=0;
  116. *(dest+1)=opcode;
  117. }
  118. memcpy(dest+2,pBuffer+offset,size-offset);
  119. return size+2;
  120. }
  121. uint32 EQApplicationPacket::serialize(unsigned char *dest) const
  122. {
  123. uint8 OpCodeBytes = app_opcode_size;
  124. if (app_opcode_size==1)
  125. *(unsigned char *)dest=opcode;
  126. else
  127. {
  128. // Application opcodes with a low order byte of 0x00 require an extra 0x00 byte inserting prior to the opcode.
  129. if ((opcode & 0x00ff) == 0)
  130. {
  131. *(uint8*)dest = 0;
  132. *(uint16*)(dest + 1) = opcode;
  133. ++OpCodeBytes;
  134. }
  135. else
  136. *(uint16*)dest = opcode;
  137. }
  138. memcpy(dest+app_opcode_size,pBuffer,size);
  139. return size+ OpCodeBytes;
  140. }
  141. EQPacket::~EQPacket()
  142. {
  143. safe_delete_array(pBuffer);
  144. pBuffer=NULL;
  145. }
  146. void EQPacket::DumpRawHeader(uint16 seq, FILE* to) const
  147. {
  148. /*if (timestamp.tv_sec) {
  149. char temp[20];
  150. tm t;
  151. const time_t sec = timestamp.tv_sec;
  152. localtime_s(&t, &sec);
  153. strftime(temp, 20, "%F %T", &t);
  154. fprintf(to, "%s.%06lu ", temp, timestamp.tv_usec);
  155. }*/
  156. DumpRawHeaderNoTime(seq, to);
  157. }
  158. const char* EQPacket::GetOpcodeName(){
  159. int16 OpcodeVersion = GetOpcodeVersion(version);
  160. if(EQOpcodeManager.count(OpcodeVersion) > 0)
  161. return EQOpcodeManager[OpcodeVersion]->EQToName(opcode);
  162. else
  163. return NULL;
  164. }
  165. void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
  166. {
  167. if (src_ip) {
  168. string sIP,dIP;;
  169. sIP=long2ip(src_ip);
  170. dIP=long2ip(dst_ip);
  171. fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
  172. }
  173. if (seq != 0xffff)
  174. fprintf(to, "[Seq=%u] ",seq);
  175. string name;
  176. int16 OpcodeVersion = GetOpcodeVersion(version);
  177. if(EQOpcodeManager.count(OpcodeVersion) > 0)
  178. name = EQOpcodeManager[OpcodeVersion]->EQToName(opcode);
  179. fprintf(to, "[OpCode 0x%04x (%s) Size=%u]\n",opcode,name.c_str(),size);
  180. }
  181. void EQPacket::DumpRaw(FILE *to) const
  182. {
  183. DumpRawHeader();
  184. if (pBuffer && size)
  185. dump_message_column(pBuffer, size, " ", to);
  186. fprintf(to, "\n");
  187. }
  188. EQProtocolPacket::EQProtocolPacket(const unsigned char *buf, uint32 len, int in_opcode)
  189. {
  190. uint32 offset = 0;
  191. if(in_opcode>=0)
  192. opcode = in_opcode;
  193. else{
  194. offset=2;
  195. opcode=ntohs(*(const uint16 *)buf);
  196. }
  197. if (len-offset) {
  198. pBuffer= new unsigned char[len-offset];
  199. size=len-offset;
  200. if(buf)
  201. memcpy(pBuffer,buf+offset,len-offset);
  202. else
  203. memset(pBuffer,0,size);
  204. } else {
  205. pBuffer=NULL;
  206. size=0;
  207. }
  208. version = 0;
  209. eq2_compressed = false;
  210. packet_prepared = false;
  211. packet_encrypted = false;
  212. sent_time = 0;
  213. attempt_count = 0;
  214. sequence = 0;
  215. }
  216. bool EQ2Packet::AppCombine(EQ2Packet* rhs){
  217. bool result = false;
  218. uchar* tmpbuffer = 0;
  219. bool over_sized_packet = false;
  220. int32 new_size = 0;
  221. //bool whee = false;
  222. // DumpPacket(this);
  223. // DumpPacket(rhs);
  224. /*if(rhs->size >= 255){
  225. DumpPacket(this);
  226. DumpPacket(rhs);
  227. whee = true;
  228. }*/
  229. if (opcode==OP_AppCombined && ((size + rhs->size + 3) < 255)){
  230. int16 tmp_size = rhs->size - 2;
  231. if(tmp_size >= 255){
  232. new_size = size+tmp_size+3;
  233. over_sized_packet = true;
  234. }
  235. else
  236. new_size = size+tmp_size+1;
  237. tmpbuffer = new uchar[new_size];
  238. uchar* ptr = tmpbuffer;
  239. memcpy(ptr, pBuffer, size);
  240. ptr += size;
  241. if(over_sized_packet){
  242. memset(ptr, 255, sizeof(int8));
  243. ptr += sizeof(int8);
  244. tmp_size = htons(tmp_size);
  245. memcpy(ptr, &tmp_size, sizeof(int16));
  246. ptr += sizeof(int16);
  247. }
  248. else{
  249. memcpy(ptr, &tmp_size, sizeof(int8));
  250. ptr += sizeof(int8);
  251. }
  252. memcpy(ptr, rhs->pBuffer+2, rhs->size-2);
  253. delete[] pBuffer;
  254. size = new_size;
  255. pBuffer=tmpbuffer;
  256. safe_delete(rhs);
  257. result=true;
  258. }
  259. else if (rhs->size > 2 && size > 2 && (size + rhs->size + 6) < 255) {
  260. int32 tmp_size = size - 2;
  261. int32 tmp_size2 = rhs->size - 2;
  262. opcode=OP_AppCombined;
  263. bool over_sized_packet2 = false;
  264. new_size = size;
  265. if(tmp_size >= 255){
  266. new_size += 5;
  267. over_sized_packet = true;
  268. }
  269. else
  270. new_size += 3;
  271. if(tmp_size2 >= 255){
  272. new_size += tmp_size2+3;
  273. over_sized_packet2 = true;
  274. }
  275. else
  276. new_size += tmp_size2+1;
  277. tmpbuffer = new uchar[new_size];
  278. tmpbuffer[2]=0;
  279. tmpbuffer[3]=0x19;
  280. uchar* ptr = tmpbuffer+4;
  281. if(over_sized_packet){
  282. memset(ptr, 255, sizeof(int8));
  283. ptr += sizeof(int8);
  284. tmp_size = htons(tmp_size);
  285. memcpy(ptr, &tmp_size, sizeof(int16));
  286. ptr += sizeof(int16);
  287. }
  288. else{
  289. memcpy(ptr, &tmp_size, sizeof(int8));
  290. ptr += sizeof(int8);
  291. }
  292. memcpy(ptr, pBuffer+2, size-2);
  293. ptr += (size-2);
  294. if(over_sized_packet2){
  295. memset(ptr, 255, sizeof(int8));
  296. ptr += sizeof(int8);
  297. tmp_size2 = htons(tmp_size2);
  298. memcpy(ptr, &tmp_size2, sizeof(int16));
  299. ptr += sizeof(int16);
  300. }
  301. else{
  302. memcpy(ptr, &tmp_size2, sizeof(int8));
  303. ptr += sizeof(int8);
  304. }
  305. memcpy(ptr, rhs->pBuffer+2, rhs->size-2);
  306. size = new_size;
  307. delete[] pBuffer;
  308. pBuffer=tmpbuffer;
  309. safe_delete(rhs);
  310. result=true;
  311. }
  312. /*if(whee){
  313. DumpPacket(this);
  314. cout << "fsdfsdf";
  315. }*/
  316. //DumpPacket(this);
  317. return result;
  318. }
  319. bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
  320. {
  321. bool result=false;
  322. //if(dont_combine)
  323. // return false;
  324. //if (opcode==OP_Combined && size+rhs->size+5<256) {
  325. if (opcode == OP_Combined && size + rhs->size + 5 < 256) {
  326. auto tmpbuffer = new unsigned char[size + rhs->size + 3];
  327. memcpy(tmpbuffer, pBuffer, size);
  328. uint32 offset = size;
  329. tmpbuffer[offset++] = rhs->Size();
  330. offset += rhs->serialize(tmpbuffer + offset);
  331. size = offset;
  332. delete[] pBuffer;
  333. pBuffer = tmpbuffer;
  334. result = true;
  335. }
  336. else if (size + rhs->size + 7 < 256) {
  337. auto tmpbuffer = new unsigned char[size + rhs->size + 6];
  338. uint32 offset = 0;
  339. tmpbuffer[offset++] = Size();
  340. offset += serialize(tmpbuffer + offset);
  341. tmpbuffer[offset++] = rhs->Size();
  342. offset += rhs->serialize(tmpbuffer + offset);
  343. size = offset;
  344. delete[] pBuffer;
  345. pBuffer = tmpbuffer;
  346. opcode = OP_Combined;
  347. result = true;
  348. }
  349. return result;
  350. }
  351. EQApplicationPacket::EQApplicationPacket(const unsigned char *buf, uint32 len, uint8 opcode_size)
  352. {
  353. uint32 offset=0;
  354. app_opcode_size=(opcode_size==0) ? EQApplicationPacket::default_opcode_size : opcode_size;
  355. if (app_opcode_size==1) {
  356. opcode=*(const unsigned char *)buf;
  357. offset++;
  358. } else {
  359. opcode=*(const uint16 *)buf;
  360. offset+=2;
  361. }
  362. if ((len-offset)>0) {
  363. pBuffer=new unsigned char[len-offset];
  364. memcpy(pBuffer,buf+offset,len-offset);
  365. size=len-offset;
  366. } else {
  367. pBuffer=NULL;
  368. size=0;
  369. }
  370. emu_opcode = OP_Unknown;
  371. }
  372. bool EQApplicationPacket::combine(const EQApplicationPacket *rhs)
  373. {
  374. cout << "CALLED AP COMBINE!!!!\n";
  375. return false;
  376. }
  377. void EQApplicationPacket::SetOpcode(EmuOpcode emu_op) {
  378. if(emu_op == OP_Unknown) {
  379. opcode = 0;
  380. emu_opcode = OP_Unknown;
  381. return;
  382. }
  383. opcode = EQOpcodeManager[GetOpcodeVersion(version)]->EmuToEQ(emu_op);
  384. if(opcode == OP_Unknown) {
  385. LogWrite(PACKET__DEBUG, 0, "Packet", "Unable to convert Emu opcode %s (%d) into an EQ opcode.", OpcodeNames[emu_op], emu_op);
  386. }
  387. //save the emu opcode we just set.
  388. emu_opcode = emu_op;
  389. }
  390. const EmuOpcode EQApplicationPacket::GetOpcodeConst() const {
  391. if(emu_opcode != OP_Unknown) {
  392. return(emu_opcode);
  393. }
  394. if(opcode == 10000) {
  395. return(OP_Unknown);
  396. }
  397. EmuOpcode emu_op;
  398. emu_op = EQOpcodeManager[GetOpcodeVersion(version)]->EQToEmu(opcode);
  399. if(emu_op == OP_Unknown) {
  400. LogWrite(PACKET__DEBUG, 1, "Packet", "Unable to convert EQ opcode 0x%.4X (%i) to an emu opcode (%s)", opcode, opcode, __FUNCTION__);
  401. }
  402. return(emu_op);
  403. }
  404. EQApplicationPacket *EQProtocolPacket::MakeApplicationPacket(uint8 opcode_size) const {
  405. EQApplicationPacket *res = new EQApplicationPacket;
  406. res->app_opcode_size=(opcode_size==0) ? EQApplicationPacket::default_opcode_size : opcode_size;
  407. if (res->app_opcode_size==1) {
  408. res->pBuffer= new unsigned char[size+1];
  409. memcpy(res->pBuffer+1,pBuffer,size);
  410. *(res->pBuffer)=htons(opcode)&0xff;
  411. res->opcode=opcode&0xff;
  412. res->size=size+1;
  413. } else {
  414. res->pBuffer= new unsigned char[size];
  415. memcpy(res->pBuffer,pBuffer,size);
  416. res->opcode=opcode;
  417. res->size=size;
  418. }
  419. res->copyInfo(this);
  420. return(res);
  421. }
  422. bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint32 Key)
  423. {
  424. bool valid=false;
  425. // OP_SessionRequest, OP_SessionResponse, OP_OutOfSession are not CRC'd
  426. if (buffer[0]==0x00 && (buffer[1]==OP_SessionRequest || buffer[1]==OP_SessionResponse || buffer[1]==OP_OutOfSession)) {
  427. valid=true;
  428. } else if(buffer[2] == 0x00 && buffer[3] == 0x19){
  429. valid = true;
  430. }
  431. else {
  432. uint16 comp_crc=CRC16(buffer,length-2,Key);
  433. uint16 packet_crc=ntohs(*(const uint16 *)(buffer+length-2));
  434. #ifdef EQN_DEBUG
  435. if (packet_crc && comp_crc != packet_crc) {
  436. cout << "CRC mismatch: comp=" << hex << comp_crc << ", packet=" << packet_crc << dec << endl;
  437. }
  438. #endif
  439. valid = (!packet_crc || comp_crc == packet_crc);
  440. }
  441. return valid;
  442. }
  443. uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize)
  444. {
  445. uint32 newlen=0;
  446. uint32 flag_offset=0;
  447. newbuf[0]=buffer[0];
  448. if (buffer[0]==0x00) {
  449. flag_offset=2;
  450. newbuf[1]=buffer[1];
  451. } else
  452. flag_offset=1;
  453. if (length>2 && buffer[flag_offset]==0x5a) {
  454. LogWrite(PACKET__DEBUG, 0, "Packet", "In Decompress 1");
  455. newlen=Inflate(const_cast<unsigned char *>(buffer+flag_offset+1),length-(flag_offset+1)-2,newbuf+flag_offset,newbufsize-flag_offset)+2;
  456. // something went bad with zlib
  457. if (newlen == -1)
  458. {
  459. LogWrite(PACKET__ERROR, 0, "Packet", "Debug Bad Inflate!");
  460. DumpPacket(buffer, length);
  461. memcpy(newbuf, buffer, length);
  462. return length;
  463. }
  464. newbuf[newlen++]=buffer[length-2];
  465. newbuf[newlen++]=buffer[length-1];
  466. } else if (length>2 && buffer[flag_offset]==0xa5) {
  467. LogWrite(PACKET__DEBUG, 0, "Packet", "In Decompress 2");
  468. memcpy(newbuf+flag_offset,buffer+flag_offset+1,length-(flag_offset+1));
  469. newlen=length-1;
  470. } else {
  471. memcpy(newbuf,buffer,length);
  472. newlen=length;
  473. }
  474. return newlen;
  475. }
  476. uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) {
  477. uint32 flag_offset=1,newlength;
  478. //dump_message_column(buffer,length,"Before: ");
  479. newbuf[0]=buffer[0];
  480. if (buffer[0]==0) {
  481. flag_offset=2;
  482. newbuf[1]=buffer[1];
  483. }
  484. if (length>30) {
  485. newlength=Deflate(const_cast<unsigned char *>(buffer+flag_offset),length-flag_offset,newbuf+flag_offset+1,newbufsize);
  486. *(newbuf+flag_offset)=0x5a;
  487. newlength+=flag_offset+1;
  488. } else {
  489. memmove(newbuf+flag_offset+1,buffer+flag_offset,length-flag_offset);
  490. *(newbuf+flag_offset)=0xa5;
  491. newlength=length+1;
  492. }
  493. //dump_message_column(newbuf,length,"After: ");
  494. return newlength;
  495. }
  496. void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey)
  497. {
  498. if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
  499. int Key=DecodeKey;
  500. unsigned char *test=(unsigned char *)malloc(size);
  501. buffer+=2;
  502. size-=2;
  503. int i;
  504. for (i = 0 ; i+4 <= size ; i+=4)
  505. {
  506. int pt = (*(int*)&buffer[i])^(Key);
  507. Key = (*(int*)&buffer[i]);
  508. *(int*)&test[i]=pt;
  509. }
  510. unsigned char KC=Key&0xFF;
  511. for ( ; i < size ; i++)
  512. {
  513. test[i]=buffer[i]^KC;
  514. }
  515. memcpy(buffer,test,size);
  516. free(test);
  517. }
  518. }
  519. void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey)
  520. {
  521. if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
  522. int Key=EncodeKey;
  523. char *test=(char*)malloc(size);
  524. int i;
  525. buffer+=2;
  526. size-=2;
  527. for ( i = 0 ; i+4 <= size ; i+=4)
  528. {
  529. int pt = (*(int*)&buffer[i])^(Key);
  530. Key = pt;
  531. *(int*)&test[i]=pt;
  532. }
  533. unsigned char KC=Key&0xFF;
  534. for ( ; i < size ; i++)
  535. {
  536. test[i]=buffer[i]^KC;
  537. }
  538. memcpy(buffer,test,size);
  539. free(test);
  540. }
  541. }
  542. bool EQProtocolPacket::IsProtocolPacket(const unsigned char* in_buff, uint32_t len, bool bTrimCRC) {
  543. bool ret = false;
  544. uint16_t opcode = ntohs(*(uint16_t*)in_buff);
  545. uint32_t offset = 2;
  546. switch (opcode) {
  547. case OP_SessionRequest:
  548. case OP_SessionDisconnect:
  549. case OP_KeepAlive:
  550. case OP_SessionStatResponse:
  551. case OP_Packet:
  552. case OP_Combined:
  553. case OP_Fragment:
  554. case OP_Ack:
  555. case OP_OutOfOrderAck:
  556. case OP_OutOfSession:
  557. {
  558. ret = true;
  559. break;
  560. }
  561. }
  562. return ret;
  563. }
  564. void DumpPacketHex(const EQApplicationPacket* app)
  565. {
  566. DumpPacketHex(app->pBuffer, app->size);
  567. }
  568. void DumpPacketAscii(const EQApplicationPacket* app)
  569. {
  570. DumpPacketAscii(app->pBuffer, app->size);
  571. }
  572. void DumpPacket(const EQProtocolPacket* app) {
  573. DumpPacketHex(app->pBuffer, app->size);
  574. }
  575. void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
  576. if (iShowInfo) {
  577. cout << "Dumping Applayer: 0x" << hex << setfill('0') << setw(4) << app->GetOpcode() << dec;
  578. cout << " size:" << app->size << endl;
  579. }
  580. DumpPacketHex(app->pBuffer, app->size);
  581. // DumpPacketAscii(app->pBuffer, app->size);
  582. }
  583. void DumpPacketBin(const EQApplicationPacket* app) {
  584. DumpPacketBin(app->pBuffer, app->size);
  585. }