当前位置: 首页>>代码示例>>C++>>正文


C++ DumpPacket函数代码示例

本文整理汇总了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;
	}
}
开发者ID:Vaion,项目名称:Server,代码行数:60,代码来源:Client.cpp

示例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;
}
开发者ID:StationEmu,项目名称:LoginServer,代码行数:54,代码来源:emu_tcp_connection.cpp

示例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);
}
开发者ID:arkanoid1,项目名称:SzimatSzatyor,代码行数:7,代码来源:szimat.cpp

示例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);
}
开发者ID:arkanoid1,项目名称:SzimatSzatyor,代码行数:7,代码来源:szimat.cpp

示例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;
}
开发者ID:Nexflame,项目名称:SzimatSzatyor,代码行数:27,代码来源:szimat.cpp

示例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);
	}
}
开发者ID:bwilliams1,项目名称:Server,代码行数:29,代码来源:server_manager.cpp

示例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;
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:33,代码来源:trap2txt.cpp

示例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;
}
开发者ID:jdewitt,项目名称:Server,代码行数:31,代码来源:client.cpp

示例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;
}
开发者ID:Nekrofage,项目名称:Doom-Quake-1-Quake-2-for-Android,代码行数:10,代码来源:i_network.c

示例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;
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:11,代码来源:trap2txt.cpp

示例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;
}
开发者ID:jamesbjackson,项目名称:mtcp,代码行数:54,代码来源:eth_in.c

示例12: DumpPacket

void Client::SendServerListPacket()
{
	EQApplicationPacket *outapp = server.SM->CreateServerListPacket(this);
	
	if(server.options.IsDumpOutPacketsOn())
	{
		DumpPacket(outapp);
	}

	connection->QueuePacket(outapp);
	delete outapp;
}
开发者ID:Vaion,项目名称:Server,代码行数:12,代码来源:Client.cpp

示例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;
}
开发者ID:Derision,项目名称:Server,代码行数:59,代码来源:EmuTCPConnection.cpp

示例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
}
开发者ID:badcaptain,项目名称:Server,代码行数:13,代码来源:horse.cpp

示例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;
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:14,代码来源:trap2txt.cpp


注:本文中的DumpPacket函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。