At point in which Client -> Server packet logging is working, will do more prechecking to declare that anything actually is subscribed to this category before outputting

This commit is contained in:
Akkadius
2015-01-31 02:23:58 -06:00
parent 0bdbc5f5c9
commit a6b95aeceb
9 changed files with 81 additions and 14 deletions
+10
View File
@@ -24,6 +24,7 @@
#include "platform.h"
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdio.h>
#ifndef STATIC_OPCODE
@@ -510,3 +511,12 @@ void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
// DumpPacketAscii(app->pBuffer, app->size);
}
std::string DumpPacketToString(const EQApplicationPacket* app, bool iShowInfo){
std::ostringstream out;
if (iShowInfo) {
out << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
out << " size:" << app->size << std::endl;
}
out << DumpPacketHexToString(app->pBuffer, app->size);
return out.str();
}
+2 -1
View File
@@ -20,6 +20,7 @@
#include "base_packet.h"
#include "platform.h"
#include <iostream>
#ifdef STATIC_OPCODE
typedef unsigned short EmuOpcode;
@@ -146,6 +147,6 @@ protected:
};
extern void DumpPacket(const EQApplicationPacket* app, bool iShowInfo = false);
extern std::string DumpPacketToString(const EQApplicationPacket* app, bool iShowInfo = false);
#endif
+4
View File
@@ -23,6 +23,7 @@
#include "op_codes.h"
#include "crc16.h"
#include "platform.h"
#include "string_util.h"
#include <string>
#include <iomanip>
@@ -558,6 +559,9 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
uint32 chunksize,used;
uint32 length;
// std::cout << "[Server -> Client] " << StringFormat("[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size()) << std::endl;
// DumpPacket(p);
// Convert the EQApplicationPacket to 1 or more EQProtocolPackets
if (p->size>(MaxLen-8)) { // proto-op(2), seq(2), app-op(2) ... data ... crc(2)
Log.Out(Logs::Detail, Logs::Netcode, _L "Making oversized packet, len %d" __L, p->size);
+1 -1
View File
@@ -88,7 +88,7 @@ namespace Logs{
"AI",
"Aggro",
"Attack",
"Client Server Packet",
"Packet: [Client -> Server]",
"Combat",
"Commands",
"Crash",
+46
View File
@@ -17,6 +17,7 @@
*/
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
@@ -89,6 +90,51 @@ void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
safe_delete_array(ascii);
}
std::string DumpPacketHexToString(const uchar* buf, uint32 size, uint32 cols, uint32 skip) {
std::ostringstream out;
if (size == 0 || size > 39565)
return "";
// Output as HEX
char output[4];
int j = 0;
char* ascii = new char[cols + 1];
memset(ascii, 0, cols + 1);
uint32 i;
for (i = skip; i < size; i++)
{
if ((i - skip) % cols == 0) {
if (i != skip)
out << " | " << ascii << std::endl;
out << std::setw(4) << std::setfill(' ') << i - skip << ": ";
memset(ascii, 0, cols + 1);
j = 0;
}
else if ((i - skip) % (cols / 2) == 0) {
out << "- ";
}
sprintf(output, "%02X ", (unsigned char)buf[i]);
out << output;
if (buf[i] >= 32 && buf[i] < 127) {
ascii[j++] = buf[i];
}
else {
ascii[j++] = '.';
}
// std::cout << std::setfill(0) << std::setw(2) << std::hex << (int)buf[i] << " "; // unknown intent [CODEBUG]
}
uint32 k = ((i - skip) - 1) % cols;
if (k < 8)
out << " ";
for (uint32 h = k + 1; h < cols; h++) {
out << " ";
}
out << " | " << ascii << std::endl;
safe_delete_array(ascii);
return out.str();
}
void DumpPacket(const uchar* buf, uint32 size)
{
DumpPacketHex(buf, size);
+1
View File
@@ -24,6 +24,7 @@ class ServerPacket;
void DumpPacketAscii(const uchar* buf, uint32 size, uint32 cols=16, uint32 skip=0);
void DumpPacketHex(const uchar* buf, uint32 size, uint32 cols=16, uint32 skip=0);
std::string DumpPacketHexToString(const uchar* buf, uint32 size, uint32 cols = 16, uint32 skip = 0);
void DumpPacketBin(const void* data, uint32 len);
void DumpPacket(const uchar* buf, uint32 size);
void DumpPacket(const ServerPacket* pack, bool iShowInfo = false);
+1 -1
View File
@@ -71,7 +71,6 @@ const std::string StringFormat(const char* format, ...)
return output;
}
// normal strncpy doesnt put a null term on copied strings, this one does
// ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecrt/htm/_wcecrt_strncpy_wcsncpy.asp
char* strn0cpy(char* dest, const char* source, uint32 size) {
@@ -408,3 +407,4 @@ bool isAlphaNumeric(const char *text)
return true;
}