9
3

EQPacket.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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. int8 offset = 0;
  73. //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)
  74. int32 new_size = size + sizeof(int16) + sizeof(int8);
  75. bool oversized = false;
  76. if (login_opcode != 2) {
  77. new_size += sizeof(int8); //for opcode
  78. if (login_opcode >= 255) {
  79. new_size += sizeof(int16);
  80. oversized = true;
  81. }
  82. else
  83. login_opcode = ntohs(login_opcode);
  84. }
  85. uchar* new_buffer = new uchar[new_size];
  86. memset(new_buffer, 0, new_size);
  87. uchar* ptr = new_buffer + sizeof(int16); // sequence is first
  88. if (login_opcode != 2) {
  89. if (oversized) {
  90. ptr += sizeof(int8); //compressed flag
  91. int8 addon = 0xff;
  92. memcpy(ptr, &addon, sizeof(int8));
  93. ptr += sizeof(int8);
  94. }
  95. memcpy(ptr, &login_opcode, sizeof(int16));
  96. ptr += sizeof(int16);
  97. }
  98. else {
  99. memcpy(ptr, &login_opcode, sizeof(int8));
  100. ptr += sizeof(int8);
  101. }
  102. memcpy(ptr, pBuffer, size);
  103. safe_delete_array(pBuffer);
  104. pBuffer = new_buffer;
  105. offset = new_size - size - 1;
  106. size = new_size;
  107. return offset;
  108. }
  109. uint32 EQProtocolPacket::serialize(unsigned char *dest, int8 offset) const
  110. {
  111. if (opcode>0xff) {
  112. *(uint16 *)dest=opcode;
  113. } else {
  114. *(dest)=0;
  115. *(dest+1)=opcode;
  116. }
  117. memcpy(dest+2,pBuffer+offset,size-offset);
  118. return size+2;
  119. }
  120. uint32 EQApplicationPacket::serialize(unsigned char *dest) const
  121. {
  122. uint8 OpCodeBytes = app_opcode_size;
  123. if (app_opcode_size==1)
  124. *(unsigned char *)dest=opcode;
  125. else
  126. {
  127. // Application opcodes with a low order byte of 0x00 require an extra 0x00 byte inserting prior to the opcode.
  128. if ((opcode & 0x00ff) == 0)
  129. {
  130. *(uint8*)dest = 0;
  131. *(uint16*)(dest + 1) = opcode;
  132. ++OpCodeBytes;
  133. }
  134. else
  135. *(uint16*)dest = opcode;
  136. }
  137. memcpy(dest+app_opcode_size,pBuffer,size);
  138. return size+ OpCodeBytes;
  139. }
  140. EQPacket::~EQPacket()
  141. {
  142. safe_delete_array(pBuffer);
  143. pBuffer=NULL;
  144. }
  145. void EQPacket::DumpRawHeader(uint16 seq, FILE* to) const
  146. {
  147. /*if (timestamp.tv_sec) {
  148. char temp[20];
  149. tm t;
  150. const time_t sec = timestamp.tv_sec;
  151. localtime_s(&t, &sec);
  152. strftime(temp, 20, "%F %T", &t);
  153. fprintf(to, "%s.%06lu ", temp, timestamp.tv_usec);
  154. }*/
  155. DumpRawHeaderNoTime(seq, to);
  156. }
  157. const char* EQPacket::GetOpcodeName(){
  158. int16 OpcodeVersion = GetOpcodeVersion(version);
  159. if(EQOpcodeManager.count(OpcodeVersion) > 0)
  160. return EQOpcodeManager[OpcodeVersion]->EQToName(opcode);
  161. else
  162. return NULL;
  163. }
  164. void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
  165. {
  166. if (src_ip) {
  167. string sIP,dIP;;
  168. sIP=long2ip(src_ip);
  169. dIP=long2ip(dst_ip);
  170. fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
  171. }
  172. if (seq != 0xffff)
  173. fprintf(to, "[Seq=%u] ",seq);
  174. string name;
  175. int16 OpcodeVersion = GetOpcodeVersion(version);
  176. if(EQOpcodeManager.count(OpcodeVersion) > 0)
  177. name = EQOpcodeManager[OpcodeVersion]->EQToName(opcode);
  178. fprintf(to, "[OpCode 0x%04x (%s) Size=%u]\n",opcode,name.c_str(),size);
  179. }
  180. void EQPacket::DumpRaw(FILE *to) const
  181. {
  182. DumpRawHeader();
  183. if (pBuffer && size)
  184. dump_message_column(pBuffer, size, " ", to);
  185. fprintf(to, "\n");
  186. }
  187. EQProtocolPacket::EQProtocolPacket(const unsigned char *buf, uint32 len, int in_opcode)
  188. {
  189. uint32 offset = 0;
  190. if(in_opcode>=0)
  191. opcode = in_opcode;
  192. else{
  193. offset=2;
  194. opcode=ntohs(*(const uint16 *)buf);
  195. }
  196. if (len-offset) {
  197. pBuffer= new unsigned char[len-offset];
  198. size=len-offset;
  199. if(buf)
  200. memcpy(pBuffer,buf+offset,len-offset);
  201. else
  202. memset(pBuffer,0,size);
  203. } else {
  204. pBuffer=NULL;
  205. size=0;
  206. }
  207. version = 0;
  208. eq2_compressed = false;
  209. packet_prepared = false;
  210. packet_encrypted = false;
  211. sent_time = 0;
  212. attempt_count = 0;
  213. sequence = 0;
  214. }
  215. bool EQ2Packet::AppCombine(EQ2Packet* rhs){
  216. bool result = false;
  217. uchar* tmpbuffer = 0;
  218. bool over_sized_packet = false;
  219. int32 new_size = 0;
  220. //bool whee = false;
  221. // DumpPacket(this);
  222. // DumpPacket(rhs);
  223. /*if(rhs->size >= 255){
  224. DumpPacket(this);
  225. DumpPacket(rhs);
  226. whee = true;
  227. }*/
  228. if (opcode==OP_AppCombined && ((size + rhs->size + 3) < 255)){
  229. int16 tmp_size = rhs->size - 2;
  230. if(tmp_size >= 255){
  231. new_size = size+tmp_size+3;
  232. over_sized_packet = true;
  233. }
  234. else
  235. new_size = size+tmp_size+1;
  236. tmpbuffer = new uchar[new_size];
  237. uchar* ptr = tmpbuffer;
  238. memcpy(ptr, pBuffer, size);
  239. ptr += size;
  240. if(over_sized_packet){
  241. memset(ptr, 255, sizeof(int8));
  242. ptr += sizeof(int8);
  243. tmp_size = htons(tmp_size);
  244. memcpy(ptr, &tmp_size, sizeof(int16));
  245. ptr += sizeof(int16);
  246. }
  247. else{
  248. memcpy(ptr, &tmp_size, sizeof(int8));
  249. ptr += sizeof(int8);
  250. }
  251. memcpy(ptr, rhs->pBuffer+2, rhs->size-2);
  252. delete[] pBuffer;
  253. size = new_size;
  254. pBuffer=tmpbuffer;
  255. safe_delete(rhs);
  256. result=true;
  257. }
  258. else if (rhs->size > 2 && size > 2 && (size + rhs->size + 6) < 255) {
  259. int32 tmp_size = size - 2;
  260. int32 tmp_size2 = rhs->size - 2;
  261. opcode=OP_AppCombined;
  262. bool over_sized_packet2 = false;
  263. new_size = size;
  264. if(tmp_size >= 255){
  265. new_size += 5;
  266. over_sized_packet = true;
  267. }
  268. else
  269. new_size += 3;
  270. if(tmp_size2 >= 255){
  271. new_size += tmp_size2+3;
  272. over_sized_packet2 = true;
  273. }
  274. else
  275. new_size += tmp_size2+1;
  276. tmpbuffer = new uchar[new_size];
  277. tmpbuffer[2]=0;
  278. tmpbuffer[3]=0x19;
  279. uchar* ptr = tmpbuffer+4;
  280. if(over_sized_packet){
  281. memset(ptr, 255, sizeof(int8));
  282. ptr += sizeof(int8);
  283. tmp_size = htons(tmp_size);
  284. memcpy(ptr, &tmp_size, sizeof(int16));
  285. ptr += sizeof(int16);
  286. }
  287. else{
  288. memcpy(ptr, &tmp_size, sizeof(int8));
  289. ptr += sizeof(int8);
  290. }
  291. memcpy(ptr, pBuffer+2, size-2);
  292. ptr += (size-2);
  293. if(over_sized_packet2){
  294. memset(ptr, 255, sizeof(int8));
  295. ptr += sizeof(int8);
  296. tmp_size2 = htons(tmp_size2);
  297. memcpy(ptr, &tmp_size2, sizeof(int16));
  298. ptr += sizeof(int16);
  299. }
  300. else{
  301. memcpy(ptr, &tmp_size2, sizeof(int8));
  302. ptr += sizeof(int8);
  303. }
  304. memcpy(ptr, rhs->pBuffer+2, rhs->size-2);
  305. size = new_size;
  306. delete[] pBuffer;
  307. pBuffer=tmpbuffer;
  308. safe_delete(rhs);
  309. result=true;
  310. }
  311. /*if(whee){
  312. DumpPacket(this);
  313. cout << "fsdfsdf";
  314. }*/
  315. //DumpPacket(this);
  316. return result;
  317. }
  318. bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
  319. {
  320. bool result=false;
  321. //if(dont_combine)
  322. // return false;
  323. //if (opcode==OP_Combined && size+rhs->size+5<256) {
  324. if (opcode == OP_Combined && size + rhs->size + 5 < 256) {
  325. auto tmpbuffer = new unsigned char[size + rhs->size + 3];
  326. memcpy(tmpbuffer, pBuffer, size);
  327. uint32 offset = size;
  328. tmpbuffer[offset++] = rhs->Size();
  329. offset += rhs->serialize(tmpbuffer + offset);
  330. size = offset;
  331. delete[] pBuffer;
  332. pBuffer = tmpbuffer;
  333. result = true;
  334. }
  335. else if (size + rhs->size + 7 < 256) {
  336. auto tmpbuffer = new unsigned char[size + rhs->size + 6];
  337. uint32 offset = 0;
  338. tmpbuffer[offset++] = Size();
  339. offset += serialize(tmpbuffer + offset);
  340. tmpbuffer[offset++] = rhs->Size();
  341. offset += rhs->serialize(tmpbuffer + offset);
  342. size = offset;
  343. delete[] pBuffer;
  344. pBuffer = tmpbuffer;
  345. opcode = OP_Combined;
  346. result = true;
  347. }
  348. return result;
  349. }
  350. EQApplicationPacket::EQApplicationPacket(const unsigned char *buf, uint32 len, uint8 opcode_size)
  351. {
  352. uint32 offset=0;
  353. app_opcode_size=(opcode_size==0) ? EQApplicationPacket::default_opcode_size : opcode_size;
  354. if (app_opcode_size==1) {
  355. opcode=*(const unsigned char *)buf;
  356. offset++;
  357. } else {
  358. opcode=*(const uint16 *)buf;
  359. offset+=2;
  360. }
  361. if ((len-offset)>0) {
  362. pBuffer=new unsigned char[len-offset];
  363. memcpy(pBuffer,buf+offset,len-offset);
  364. size=len-offset;
  365. } else {
  366. pBuffer=NULL;
  367. size=0;
  368. }
  369. emu_opcode = OP_Unknown;
  370. }
  371. bool EQApplicationPacket::combine(const EQApplicationPacket *rhs)
  372. {
  373. cout << "CALLED AP COMBINE!!!!\n";
  374. return false;
  375. }
  376. void EQApplicationPacket::SetOpcode(EmuOpcode emu_op) {
  377. if(emu_op == OP_Unknown) {
  378. opcode = 0;
  379. emu_opcode = OP_Unknown;
  380. return;
  381. }
  382. opcode = EQOpcodeManager[GetOpcodeVersion(version)]->EmuToEQ(emu_op);
  383. if(opcode == OP_Unknown) {
  384. LogWrite(PACKET__DEBUG, 0, "Packet", "Unable to convert Emu opcode %s (%d) into an EQ opcode.", OpcodeNames[emu_op], emu_op);
  385. }
  386. //save the emu opcode we just set.
  387. emu_opcode = emu_op;
  388. }
  389. const EmuOpcode EQApplicationPacket::GetOpcodeConst() const {
  390. if(emu_opcode != OP_Unknown) {
  391. return(emu_opcode);
  392. }
  393. if(opcode == 10000) {
  394. return(OP_Unknown);
  395. }
  396. EmuOpcode emu_op;
  397. emu_op = EQOpcodeManager[GetOpcodeVersion(version)]->EQToEmu(opcode);
  398. if(emu_op == OP_Unknown) {
  399. LogWrite(PACKET__DEBUG, 1, "Packet", "Unable to convert EQ opcode 0x%.4X (%i) to an emu opcode (%s)", opcode, opcode, __FUNCTION__);
  400. }
  401. return(emu_op);
  402. }
  403. EQApplicationPacket *EQProtocolPacket::MakeApplicationPacket(uint8 opcode_size) const {
  404. EQApplicationPacket *res = new EQApplicationPacket;
  405. res->app_opcode_size=(opcode_size==0) ? EQApplicationPacket::default_opcode_size : opcode_size;
  406. if (res->app_opcode_size==1) {
  407. res->pBuffer= new unsigned char[size+1];
  408. memcpy(res->pBuffer+1,pBuffer,size);
  409. *(res->pBuffer)=htons(opcode)&0xff;
  410. res->opcode=opcode&0xff;
  411. res->size=size+1;
  412. } else {
  413. res->pBuffer= new unsigned char[size];
  414. memcpy(res->pBuffer,pBuffer,size);
  415. res->opcode=opcode;
  416. res->size=size;
  417. }
  418. res->copyInfo(this);
  419. return(res);
  420. }
  421. bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint32 Key)
  422. {
  423. bool valid=false;
  424. // OP_SessionRequest, OP_SessionResponse, OP_OutOfSession are not CRC'd
  425. if (buffer[0]==0x00 && (buffer[1]==OP_SessionRequest || buffer[1]==OP_SessionResponse || buffer[1]==OP_OutOfSession)) {
  426. valid=true;
  427. } else if(buffer[2] == 0x00 && buffer[3] == 0x19){
  428. valid = true;
  429. }
  430. else {
  431. uint16 comp_crc=CRC16(buffer,length-2,Key);
  432. uint16 packet_crc=ntohs(*(const uint16 *)(buffer+length-2));
  433. #ifdef EQN_DEBUG
  434. if (packet_crc && comp_crc != packet_crc) {
  435. cout << "CRC mismatch: comp=" << hex << comp_crc << ", packet=" << packet_crc << dec << endl;
  436. }
  437. #endif
  438. valid = (!packet_crc || comp_crc == packet_crc);
  439. }
  440. return valid;
  441. }
  442. uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize)
  443. {
  444. uint32 newlen=0;
  445. uint32 flag_offset=0;
  446. newbuf[0]=buffer[0];
  447. if (buffer[0]==0x00) {
  448. flag_offset=2;
  449. newbuf[1]=buffer[1];
  450. } else
  451. flag_offset=1;
  452. if (length>2 && buffer[flag_offset]==0x5a) {
  453. LogWrite(PACKET__DEBUG, 0, "Packet", "In Decompress 1");
  454. newlen=Inflate(const_cast<unsigned char *>(buffer+flag_offset+1),length-(flag_offset+1)-2,newbuf+flag_offset,newbufsize-flag_offset)+2;
  455. newbuf[newlen++]=buffer[length-2];
  456. newbuf[newlen++]=buffer[length-1];
  457. } else if (length>2 && buffer[flag_offset]==0xa5) {
  458. LogWrite(PACKET__DEBUG, 0, "Packet", "In Decompress 2");
  459. memcpy(newbuf+flag_offset,buffer+flag_offset+1,length-(flag_offset+1));
  460. newlen=length-1;
  461. } else {
  462. memcpy(newbuf,buffer,length);
  463. newlen=length;
  464. }
  465. return newlen;
  466. }
  467. uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) {
  468. uint32 flag_offset=1,newlength;
  469. //dump_message_column(buffer,length,"Before: ");
  470. newbuf[0]=buffer[0];
  471. if (buffer[0]==0) {
  472. flag_offset=2;
  473. newbuf[1]=buffer[1];
  474. }
  475. if (length>30) {
  476. newlength=Deflate(const_cast<unsigned char *>(buffer+flag_offset),length-flag_offset,newbuf+flag_offset+1,newbufsize);
  477. *(newbuf+flag_offset)=0x5a;
  478. newlength+=flag_offset+1;
  479. } else {
  480. memmove(newbuf+flag_offset+1,buffer+flag_offset,length-flag_offset);
  481. *(newbuf+flag_offset)=0xa5;
  482. newlength=length+1;
  483. }
  484. //dump_message_column(newbuf,length,"After: ");
  485. return newlength;
  486. }
  487. void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey)
  488. {
  489. if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
  490. int Key=DecodeKey;
  491. unsigned char *test=(unsigned char *)malloc(size);
  492. buffer+=2;
  493. size-=2;
  494. int i;
  495. for (i = 0 ; i+4 <= size ; i+=4)
  496. {
  497. int pt = (*(int*)&buffer[i])^(Key);
  498. Key = (*(int*)&buffer[i]);
  499. *(int*)&test[i]=pt;
  500. }
  501. unsigned char KC=Key&0xFF;
  502. for ( ; i < size ; i++)
  503. {
  504. test[i]=buffer[i]^KC;
  505. }
  506. memcpy(buffer,test,size);
  507. free(test);
  508. }
  509. }
  510. void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey)
  511. {
  512. if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
  513. int Key=EncodeKey;
  514. char *test=(char*)malloc(size);
  515. int i;
  516. buffer+=2;
  517. size-=2;
  518. for ( i = 0 ; i+4 <= size ; i+=4)
  519. {
  520. int pt = (*(int*)&buffer[i])^(Key);
  521. Key = pt;
  522. *(int*)&test[i]=pt;
  523. }
  524. unsigned char KC=Key&0xFF;
  525. for ( ; i < size ; i++)
  526. {
  527. test[i]=buffer[i]^KC;
  528. }
  529. memcpy(buffer,test,size);
  530. free(test);
  531. }
  532. }
  533. bool EQProtocolPacket::IsProtocolPacket(const unsigned char* in_buff, uint32_t len, bool bTrimCRC) {
  534. bool ret = false;
  535. uint16_t opcode = ntohs(*(uint16_t*)in_buff);
  536. uint32_t offset = 2;
  537. switch (opcode) {
  538. case OP_SessionRequest:
  539. case OP_SessionDisconnect:
  540. case OP_KeepAlive:
  541. case OP_SessionStatResponse:
  542. case OP_Packet:
  543. case OP_Combined:
  544. case OP_Fragment:
  545. case OP_Ack:
  546. case OP_OutOfOrderAck:
  547. case OP_OutOfSession:
  548. {
  549. ret = true;
  550. break;
  551. }
  552. }
  553. return ret;
  554. }
  555. void DumpPacketHex(const EQApplicationPacket* app)
  556. {
  557. DumpPacketHex(app->pBuffer, app->size);
  558. }
  559. void DumpPacketAscii(const EQApplicationPacket* app)
  560. {
  561. DumpPacketAscii(app->pBuffer, app->size);
  562. }
  563. void DumpPacket(const EQProtocolPacket* app) {
  564. DumpPacketHex(app->pBuffer, app->size);
  565. }
  566. void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
  567. if (iShowInfo) {
  568. cout << "Dumping Applayer: 0x" << hex << setfill('0') << setw(4) << app->GetOpcode() << dec;
  569. cout << " size:" << app->size << endl;
  570. }
  571. DumpPacketHex(app->pBuffer, app->size);
  572. // DumpPacketAscii(app->pBuffer, app->size);
  573. }
  574. void DumpPacketBin(const EQApplicationPacket* app) {
  575. DumpPacketBin(app->pBuffer, app->size);
  576. }