本文整理匯總了C++中DumpPacket函數的典型用法代碼示例。如果您正苦於以下問題:C++ DumpPacket函數的具體用法?C++ DumpPacket怎麽用?C++ DumpPacket使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DumpPacket函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: world
void Client::Handle_SessionReady(const char* data, unsigned int size)
{
if(status != cs_not_sent_session_ready)
{
server_log->Log(log_network_error, "Session ready recieved again after already being recieved.");
return;
}
if(size < sizeof(unsigned int))
{
server_log->Log(log_network_error, "Session ready was too small.");
return;
}
unsigned int mode = *((unsigned int*)data);
if(mode == (unsigned int)lm_from_world)
{
server_log->Log(log_network, "Session ready indicated logged in from world(unsupported feature), disconnecting.");
connection->Close();
return;
}
status = cs_waiting_for_login;
/**
* The packets are mostly the same but slightly different between the two versions.
*/
if(version == cv_sod)
{
EQApplicationPacket *outapp = new EQApplicationPacket(OP_ChatMessage, 17);
outapp->pBuffer[0] = 0x02;
outapp->pBuffer[10] = 0x01;
outapp->pBuffer[11] = 0x65;
if(server.options.IsDumpOutPacketsOn())
{
DumpPacket(outapp);
}
connection->QueuePacket(outapp);
delete outapp;
}
else
{
const char *msg = "ChatMessage";
EQApplicationPacket *outapp = new EQApplicationPacket(OP_ChatMessage, 16 + strlen(msg));
outapp->pBuffer[0] = 0x02;
outapp->pBuffer[10] = 0x01;
outapp->pBuffer[11] = 0x65;
strcpy((char*)(outapp->pBuffer + 15), msg);
if(server.options.IsDumpOutPacketsOn())
{
DumpPacket(outapp);
}
connection->QueuePacket(outapp);
delete outapp;
}
}
示例2: lock
bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps)
{
if (RemoteID)
{
return false;
}
if (!Connected())
{
return false;
}
if (GetMode() != modePacket)
{
return false;
}
LockMutex lock(&MState);
eTCPMode tmp = GetMode();
if (tmp == modeTransition)
{
EmuTCPNetPacket_Struct* tnps2 = (EmuTCPNetPacket_Struct*) new uchar[tnps->size];
memcpy(tnps2, tnps, tnps->size);
InModeQueuePush(tnps2);
return true;
}
#if TCPN_LOG_PACKETS >= 1
if (tnps && tnps->opcode != 0)
{
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
std::cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << tnps->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
if (pOldFormat)
{
std::cout << " (OldFormat)";
}
std::cout << std::endl;
#if TCPN_LOG_PACKETS == 2
if (tnps->size >= 32)
{
DumpPacket((uchar*) tnps, 32);
}
else
{
DumpPacket((uchar*) tnps, tnps->size);
}
#endif
#if TCPN_LOG_PACKETS >= 3
DumpPacket((uchar*) tnps, tnps->size);
#endif
}
#endif
ServerSendQueuePushEnd((const uchar*) tnps, tnps->size);
return true;
}
示例3: RecvHook_WOD
DWORD __fastcall RecvHook_WOD(void* thisPTR, void* dummy, void* param1, void* param2, CDataStore* ds, void* param4)
{
DumpPacket(SMSG, 0, *(DWORD*)ds->buffer, 4, ds->size, ds->buffer);
CHECK(hookInfo.recvHookGood, "Recv hook is working.\n");
typedef DWORD(__thiscall *proto)(void*, void*, void*, void*, void*);
return reinterpret_cast<proto>(hookInfo.recvDetour)(thisPTR, param1, param2, ds, param4);
}
示例4: SendHook
DWORD __fastcall SendHook(void* thisPTR, void* dummy, CDataStore* ds, DWORD connectionId)
{
DumpPacket(CMSG, connectionId, *(DWORD*)ds->buffer, 4, ds->size, ds->buffer);
CHECK(hookInfo.sendHookGood, "Send hook is working.\n");
typedef DWORD(__thiscall *proto)(void*, void*, DWORD);
return reinterpret_cast<proto>(hookInfo.sendDetour)(thisPTR, ds, connectionId);
}
示例5: RecvHook
DWORD __fastcall RecvHook(void* thisPTR, void* /* dummy */, void* param1, CDataStore* dataStore, void* param3)
{
WORD opcodeSize = buildNumber <= WOW_MOP_16135 ? 2 : 4;
// packet dump
DumpPacket(SMSG, 0, opcodeSize, dataStore);
// unhooks the recv function
HookManager::UnHook(recvAddress, defaultMachineCodeRecv);
// calls client's function so it can processes the packet
DWORD returnValue = 0;
if (buildNumber <= WOW_TBC_8606) // different prototype
returnValue = RecvProto8606(recvAddress)(thisPTR, param1, dataStore);
else
returnValue = RecvProto(recvAddress)(thisPTR, param1, dataStore, param3);
// hooks again to catch the next incoming packets also
HookManager::ReHook(recvAddress, machineCodeHookRecv);
if (!recvHookGood)
{
printf("Recv hook is working.\n");
recvHookGood = true;
}
return returnValue;
}
示例6: while
void ServerManager::SendOldUserToWorldRequest(const char* server_id, unsigned int client_account_id)
{
list<WorldServer*>::iterator iter = world_servers.begin();
bool found = false;
while(iter != world_servers.end())
{
if((*iter)->GetRemoteIP() == server_id)
{
ServerPacket *outapp = new ServerPacket(ServerOP_UsertoWorldReq, sizeof(UsertoWorldRequest_Struct));
UsertoWorldRequest_Struct *utwr = (UsertoWorldRequest_Struct*)outapp->pBuffer;
utwr->worldid = (*iter)->GetServerListID();
utwr->lsaccountid = client_account_id;
(*iter)->GetConnection()->SendPacket(outapp);
found = true;
if(server.options.IsDumpInPacketsOn())
{
DumpPacket(outapp);
}
delete outapp;
}
++iter;
}
if(!found && server.options.IsTraceOn())
{
server_log->Log(log_client_error, "Client requested a user to world but supplied an invalid id of %s.", server_id);
}
}
示例7: handle_REQ_PERFORM_SUPPLEMENTARY_SERVICE
int handle_REQ_PERFORM_SUPPLEMENTARY_SERVICE( unsigned char * pkt, unsigned short len )
{
perform_supplementary_service_req * prq = ( perform_supplementary_service_req * ) pkt;
unsigned char * ssd = ( unsigned char * ) &prq[1];
unsigned short ssd_len = ( len - ( unsigned short ) sizeof( perform_supplementary_service_req ) );
printf( "Debugger request: REQ_PERFORM_SUPPLEMENTARY_SERVICE\n" );
printf( " ID: 0x%.08x", prq->id );
ServiceNameAndId *lookup;
for( lookup = services; lookup != NULL; lookup = lookup->next ) {
if( prq->id == lookup->service_id ) {
printf( " [%s]", lookup->service_name );
break;
}
}
last_service = lookup;
printf( "\n" );
if( ssd_len ) {
int rc = 0;
if( lookup && lookup->service_decode )
rc = lookup->service_decode( 1, ssd, ssd_len );
if( 0 != rc ) {
printf( " supplementary service data:\n" );
DumpPacket( ssd, ssd_len, 1 );
}
}
return 1;
}
示例8: clog
bool Client::HandleCharacterCreatePacket(const EQApplicationPacket *app) {
if (GetAccountID() == 0)
{
clog(WORLD__CLIENT_ERR,"Account ID not set; unable to create character.");
return false;
}
else if (app->size != sizeof(CharCreate_Struct))
{
clog(WORLD__CLIENT_ERR,"Wrong size on OP_CharacterCreate. Got: %d, Expected: %d",app->size,sizeof(CharCreate_Struct));
DumpPacket(app);
// the previous behavior was essentially returning true here
// but that seems a bit odd to me.
return true;
}
CharCreate_Struct *cc = (CharCreate_Struct*)app->pBuffer;
if(OPCharCreate(char_name, cc) == false)
{
database.DeleteCharacter(char_name);
EQApplicationPacket *outapp = new EQApplicationPacket(OP_ApproveName, 1);
outapp->pBuffer[0] = 0;
QueuePacket(outapp);
safe_delete(outapp);
}
else
{
SendCharInfo();
}
return true;
}
示例9: SDLNet_UDP_Send
int SDLNet_UDP_Send(UDPsocket sock, int channel, UDPpacket *packet)
{
DumpPacket(packet);
ssize_t sent = send(sock, packet->data, packet->len, 0);
printf("SDLNet_UDP_Send Sock Descriptor=%d, Data=%p, Len=%d, Sent=%ld\n"
, sock, packet->data, packet->len, sent);
return sent;
}
示例10: handle_REQ_READ_IO_REPLY
int handle_REQ_READ_IO_REPLY( unsigned char * pkt, unsigned short len )
{
printf( "Trap reply: REQ_READ_IO\n" );
printf( " Length: 0x%.04x\n", len );
if( len ){
printf( " Data:\n" );
DumpPacket( pkt, len, 1 );
}
return 1;
}
示例11: ProcessPacket
/*----------------------------------------------------------------------------*/
int
ProcessPacket(mtcp_manager_t mtcp, const int ifidx,
uint32_t cur_ts, unsigned char *pkt_data, int len)
{
struct ethhdr *ethh = (struct ethhdr *)pkt_data;
u_short ip_proto = ntohs(ethh->h_proto);
int ret;
#ifdef PKTDUMP
DumpPacket(mtcp, (char *)pkt_data, len, "IN", ifidx);
#endif
#ifdef NETSTAT
mtcp->nstat.rx_packets[ifidx]++;
mtcp->nstat.rx_bytes[ifidx] += len + 24;
#endif /* NETSTAT */
#if 0
/* ignore mac address which is not for current interface */
int i;
for (i = 0; i < 6; i ++) {
if (ethh->h_dest[i] != CONFIG.eths[ifidx].haddr[i]) {
return FALSE;
}
}
#endif
if (ip_proto == ETH_P_IP) {
/* process ipv4 packet */
ret = ProcessIPv4Packet(mtcp, cur_ts, ifidx, pkt_data, len);
} else if (ip_proto == ETH_P_ARP) {
ProcessARPPacket(mtcp, cur_ts, ifidx, pkt_data, len);
return TRUE;
} else {
//DumpPacket(mtcp, (char *)pkt_data, len, "??", ifidx);
struct ps_packet packet;
packet.ifindex = ifidx;
packet.len = len;
packet.buf = (char *)pkt_data;
ps_slowpath_packet(mtcp->ctx->handle, &packet);
return TRUE;
}
#ifdef NETSTAT
if (ret < 0) {
mtcp->nstat.rx_errors[ifidx]++;
}
#endif
return ret;
}
示例12: DumpPacket
void Client::SendServerListPacket()
{
EQApplicationPacket *outapp = server.SM->CreateServerListPacket(this);
if(server.options.IsDumpOutPacketsOn())
{
DumpPacket(outapp);
}
connection->QueuePacket(outapp);
delete outapp;
}
示例13: GetMode
bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
if (!Connected())
return false;
eTCPMode tmp = GetMode();
if (tmp != modePacket && tmp != modeTransition)
return false;
LockMutex lock(&MState);
if (RemoteID)
return RelayLink->SendPacket(pack, RemoteID);
else if (pOldFormat) {
#if TCPN_LOG_PACKETS >= 1
if (pack && pack->opcode != 0) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
std::cout << ": Logging outgoing TCP OldPacket. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
else
DumpPacket(pack);
#endif
#if TCPN_LOG_PACKETS >= 3
DumpPacket(pack);
#endif
}
#endif
SPackSendQueue* spsq = MakeOldPacket(pack);
ServerSendQueuePushEnd(spsq->buffer, spsq->size);
safe_delete_array(spsq);
}
else {
EmuTCPNetPacket_Struct* tnps = MakePacket(pack, iDestination);
if (tmp == modeTransition) {
InModeQueuePush(tnps);
}
else {
#if TCPN_LOG_PACKETS >= 1
if (pack && pack->opcode != 0) {
struct in_addr in;
in.s_addr = GetrIP();
CoutTimestamp(true);
std::cout << ": Logging outgoing TCP packet. OPCode: 0x" << hex << setw(4) << setfill('0') << pack->opcode << dec << ", size: " << setw(5) << setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
#if TCPN_LOG_PACKETS == 2
if (pack->size >= 32)
DumpPacket(pack->pBuffer, 32);
else
DumpPacket(pack);
#endif
#if TCPN_LOG_PACKETS >= 3
DumpPacket(pack);
#endif
}
#endif
ServerSendQueuePushEnd((uchar**) &tnps, tnps->size);
}
}
return true;
}
示例14: sizeof
void Mob::CreateHorseSpawnPacket(EQApplicationPacket* app, const char* ownername, uint16 ownerid, Mob* ForWho) {
app->SetOpcode(OP_NewSpawn);
app->pBuffer = new uchar[sizeof(NewSpawn_Struct)];
app->size = sizeof(NewSpawn_Struct);
memset(app->pBuffer, 0, sizeof(NewSpawn_Struct));
NewSpawn_Struct* ns = (NewSpawn_Struct*)app->pBuffer;
FillSpawnStruct(ns, ForWho);
#if (EQDEBUG >= 11)
printf("Horse Spawn Packet - Owner: %s\n", ownername);
DumpPacket(app);
#endif
}
示例15: handle_REQ_WRITE_IO
int handle_REQ_WRITE_IO( unsigned char * pkt, unsigned short len )
{
write_io_req * prq = ( write_io_req * ) pkt;
unsigned short to_write = ( len - ( unsigned short ) sizeof( write_io_req ) );
unsigned char * data = ( unsigned char * ) &prq[1];
printf( "Debugger request: REQ_WRITE_IO\n" );
printf( " Address: %.08x\n", prq->IO_offset );
printf( " Length: %.04x\n", to_write );
printf( " Data:\n" );
DumpPacket( data, to_write, 1 );
return 1;
}