1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 06:27:45 +00:00

add packet hex dump, moved gm1handler to use struct inpacket

This commit is contained in:
NotAdam 2018-07-06 21:53:35 +10:00
parent 4897481309
commit 3e4582560d
5 changed files with 26 additions and 12 deletions

View file

@ -137,10 +137,11 @@ struct FFXIVARR_PACKET_RAW
*/ */
enum FFXIVARR_SEGMENT_TYPE enum FFXIVARR_SEGMENT_TYPE
{ {
SEGMENTTYPE_SESSIONINIT = 1,
SEGMENTTYPE_IPC = 3, SEGMENTTYPE_IPC = 3,
SEGMENTTYPE_RESPONSE = 7, SEGMENTTYPE_KEEPALIVE = 7,
SEGMENTTYPE_KEEPALIVE = 8, //SEGMENTTYPE_RESPONSE = 8,
SEGMENTTYPE_ENCRYPTIONHANDSHAKE = 9, SEGMENTTYPE_ENCRYPTIONINIT = 9,
}; };
/** /**

View file

@ -14,6 +14,12 @@
#include "CommonNetwork.h" #include "CommonNetwork.h"
#include "PacketDef/Ipcs.h" #include "PacketDef/Ipcs.h"
#include <Framework.h>
#include <Logging/Logger.h>
#include <Util/Util.h>
extern Core::Framework g_fw;
namespace Core { namespace Core {
namespace Network { namespace Network {
namespace Packets { namespace Packets {
@ -186,6 +192,13 @@ public:
memcpy( &m_segHdr, &rawPacket.segHdr, sizeof( FFXIVARR_PACKET_SEGMENT_HEADER ) ); memcpy( &m_segHdr, &rawPacket.segHdr, sizeof( FFXIVARR_PACKET_SEGMENT_HEADER ) );
memcpy( &m_data, &rawPacket.data[0] + ipcHdrSize, copySize ); memcpy( &m_data, &rawPacket.data[0] + ipcHdrSize, copySize );
auto log = g_fw.get< Core::Logger >();
if( log )
{
log->debug( "rawpacket size" + std::to_string( rawPacket.segHdr.size ) + "\n" + Util::binaryToHexDump( const_cast< uint8_t* >( &rawPacket.data[0] ), rawPacket.segHdr.size ) );
log->debug( "T size " + std::to_string( sizeof( T ) ) + "\n" + Util::binaryToHexDump( reinterpret_cast< uint8_t* >( &m_data ), sizeof( T ) ) );
}
memset( &m_ipcHdr, 0, ipcHdrSize ); memset( &m_ipcHdr, 0, ipcHdrSize );
m_ipcHdr.type = static_cast< ServerZoneIpcType >( m_data._ServerIpcType ); m_ipcHdr.type = static_cast< ServerZoneIpcType >( m_data._ServerIpcType );
} }

View file

@ -14,8 +14,8 @@ struct FFXIVIpcGmCommand1 : FFXIVIpcBasePacket< GMCommand1 >
/* 0000 */ uint32_t commandId; /* 0000 */ uint32_t commandId;
/* 0004 */ uint32_t param1; /* 0004 */ uint32_t param1;
/* 0008 */ uint32_t param2; /* 0008 */ uint32_t param2;
/* 000C */ char unknown_C[28]; /* 000C */ uint8_t unknown_C[0xC];
/* 0028 */ uint32_t param3; /* 0018 */ uint32_t param3;
}; };
} }

View file

@ -483,7 +483,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
switch( inPacket.segHdr.type ) switch( inPacket.segHdr.type )
{ {
case 9: // Encryption init case SEGMENTTYPE_ENCRYPTIONINIT: // Encryption init
{ {
std::string key_phrase( reinterpret_cast< char* >( &inPacket.data[36] ) ); std::string key_phrase( reinterpret_cast< char* >( &inPacket.data[36] ) );
generateEncryptionKey( *reinterpret_cast< uint32_t* >( &inPacket.data[100] ), key_phrase ); generateEncryptionKey( *reinterpret_cast< uint32_t* >( &inPacket.data[100] ), key_phrase );
@ -501,13 +501,13 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
} }
case 3: // game packet case SEGMENTTYPE_IPC: // game packet
{ {
g_log.info( "GamePacket [" + std::to_string( inPacket.segHdr.type ) + "]" ); g_log.info( "GamePacket [" + std::to_string( inPacket.segHdr.type ) + "]" );
handleGamePacket( inPacket ); handleGamePacket( inPacket );
break; break;
} }
case 7: // keep alive case SEGMENTTYPE_KEEPALIVE: // keep alive
{ {
uint32_t id = *reinterpret_cast< uint32_t* >( &inPacket.data[0] ); uint32_t id = *reinterpret_cast< uint32_t* >( &inPacket.data[0] );
uint32_t timeStamp = *reinterpret_cast< uint32_t* >( &inPacket.data[4] ); uint32_t timeStamp = *reinterpret_cast< uint32_t* >( &inPacket.data[4] );

View file

@ -211,7 +211,7 @@ void Core::Network::GameConnection::handleZonePacket( Core::Network::Packets::FF
pLog->debug( sessionStr + " Undefined Zone IPC : Unknown ( " + pLog->debug( sessionStr + " Undefined Zone IPC : Unknown ( " +
boost::str( boost::format( "%|04X|" ) % boost::str( boost::format( "%|04X|" ) %
static_cast< uint32_t >( opcode ) ) + " )" ); static_cast< uint32_t >( opcode ) ) + " )" );
//pLog->debug( "\n" + pPacket.toString() ); pLog->debug( "Dump:\n" + Util::binaryToHexDump( const_cast< uint8_t* >( &pPacket.data[0] ), pPacket.segHdr.size ) );
} }
} }
@ -381,7 +381,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
{ {
switch( inPacket.segHdr.type ) switch( inPacket.segHdr.type )
{ {
case 1: case SEGMENTTYPE_SESSIONINIT:
{ {
char* id = ( char* ) &( inPacket.data[4] ); char* id = ( char* ) &( inPacket.data[4] );
uint32_t playerId = boost::lexical_cast< uint32_t >( id ); uint32_t playerId = boost::lexical_cast< uint32_t >( id );
@ -445,12 +445,12 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
break; break;
} }
case 3: // game packet case SEGMENTTYPE_IPC: // game packet
{ {
queueInPacket( inPacket ); queueInPacket( inPacket );
break; break;
} }
case 7: // keep alive case SEGMENTTYPE_KEEPALIVE: // keep alive
{ {
uint32_t id = *( uint32_t* ) &inPacket.data[0]; uint32_t id = *( uint32_t* ) &inPacket.data[0];
uint32_t timeStamp = *( uint32_t* ) &inPacket.data[4]; uint32_t timeStamp = *( uint32_t* ) &inPacket.data[4];