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


C++ PacketBuffer类代码示例

本文整理汇总了C++中PacketBuffer的典型用法代码示例。如果您正苦于以下问题:C++ PacketBuffer类的具体用法?C++ PacketBuffer怎么用?C++ PacketBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PacketBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: valid

/**
   Creates and posts a PacketBuffer::pcClosed message to the server message
   que. The message contains the socket handle, and the ip address in dotted
   decimal format. The socket you pass in is the socket that you are
   removing. The socket should still be valid (not yet deleted) when this method
   is called.

   \param s Pointer to the socket that is being removed.
**/
void
SimpleServer::queClosedMessage(ServerSocket* s)
{
  PacketBuffer* pktRemove = new PacketBuffer(PacketBuffer::pcClosed);
  *pktRemove << (signed32)   s->getSocket();
  *pktRemove << s->getAddr().dottedDecimal();
  pktRemove->rewind();
  PacketMessage* pmsg = new PacketMessage(s,pktRemove);         //socket is no longer valid
  m_que.add(pmsg);
}
开发者ID:NorthernForce,项目名称:ssobjects,代码行数:19,代码来源:simpleserver.cpp

示例2: read

void PacketEncryptionResponse::read(PacketBuffer &buffer) {
    varint_t secretLength;
    buffer.getVarInt(secretLength);
    sharedSecret = ubytes_t(secretLength);
    buffer.getUBytes(sharedSecret);
    varint_t tokenLength;
    buffer.getVarInt(tokenLength);
    verifyToken = ubytes_t(tokenLength);
    buffer.getUBytes(verifyToken);
}
开发者ID:NeatMonster,项目名称:Proxy,代码行数:10,代码来源:PacketEncryptionResponse.cpp

示例3: sendProcessClosedEvent

/**
 * Sends a process closed debug event to BinNavi.
 *
 * @param dbg The debug event to be sent.
 *
 * @return A NaviError code that describes whether the operation was successful
 * or not.
 **/
NaviError BaseConnection::sendProcessClosedEvent(const DBGEVT *) const {
  const unsigned int NUMBER_OF_ARGUMENTS = 0;
  PacketBuffer buffer;
  buffer.add(createPacketHeader(resp_process_closed, 0, NUMBER_OF_ARGUMENTS));
  NaviError sendResult = send(buffer.data(), buffer.size());
  if (sendResult) {
    msglog->log(LOG_VERBOSE, "Error: Couldn't send debug event");
    return sendResult;
  }
  return NaviErrors::SUCCESS;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:19,代码来源:BaseConnection.cpp

示例4: sendSimpleReply

/**
 * Sends a simple reply to BinNavi.
 *
 * @param command The type of the reply.
 *
 * @return A NaviError code that describes whether the operation was successful
 * or not.
 **/
NaviError BaseConnection::sendSimpleReply(const commandtype_t command,
                                          unsigned int id) const {
  const unsigned int NUMBER_OF_ARGUMENTS = 0;
  PacketBuffer buffer;
  buffer.add(createPacketHeader(command, id, NUMBER_OF_ARGUMENTS));
  NaviError sendResult = send(buffer.data(), buffer.size());
  if (sendResult) {
    msglog->log(LOG_VERBOSE, "Error: Couldn't send simple reply message");
    return sendResult;
  }
  return NaviErrors::SUCCESS;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:20,代码来源:BaseConnection.cpp

示例5: sendRegistersReply

/**
 * Sends a reply to a register values request to BinNavi.
 *
 * @param id The message ID of the reply.
 * @param regString The register data string.
 *
 * @return A NaviError code that describes whether the operation was
 * successful or not.
 **/
NaviError BaseConnection::sendRegistersReply(commandtype_t type,
                                             unsigned int id,
                                             const std::string &str) const {
  const unsigned int NUMBER_OF_ARGUMENTS = 1;
  PacketBuffer buffer;
  buffer.add(createPacketHeader(type, id, NUMBER_OF_ARGUMENTS));
  addStringArgument(buffer, str);
  NaviError sendResult = send(buffer.data(), buffer.size());
  if (sendResult) {
    msglog->log(LOG_VERBOSE, "Error: Couldn't send registers reply message");
    return sendResult;
  }
  return NaviErrors::SUCCESS;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:23,代码来源:BaseConnection.cpp

示例6: write

void DataWatcher::write(PacketBuffer &buffer) {
    for (byte_t index = 0; index < 23; ++index) {
        if (type[index] == NONE)
            continue;
        buffer.putByte(type[index] << 5 | (index & 0x1f));
        switch (type[index]) {
            case BYTE:
                buffer.putByte(getByte(index));
                break;
            case SHORT:
                buffer.putShort(getShort(index));
                break;
            case INT:
                buffer.putInt(getInt(index));
                break;
            case FLOAT:
                buffer.putFloat(getFloat(index));
                break;
            case STRING:
                buffer.putString(getString(index));
                break;
            case ITEMSTACK:
                buffer.putItemStack(getItemStack(index));
                break;
        }
    }
    buffer.putByte(0x7f);
}
开发者ID:NeatMonster,项目名称:Serveur,代码行数:28,代码来源:DataWatcher.cpp

示例7: addAddressArgument

/**
 * Sends a reply to a memory data request to BinNavi.
 *
 * @param id The message ID of the reply.
 * @param address The address from the original memory request.
 * @param memrange The memory data.
 *
 * @return A NaviError code that describes whether the operation was
 * successful or not.
 **/
NaviError
BaseConnection::sendMemoryReply(unsigned int id, CPUADDRESS address,
                                const MemoryContainer &memrange) const {
  const unsigned int NUMBER_OF_ARGUMENTS = 2;
  PacketBuffer buffer;
  buffer.add(createPacketHeader(resp_read_memory, id, NUMBER_OF_ARGUMENTS));
  addAddressArgument(buffer, address);
  addStringArgument(buffer, memrange);
  NaviError sendResult = send(buffer.data(), buffer.size());
  if (sendResult) {
    msglog->log(LOG_VERBOSE, "Error: Couldn't send memory reply message");
    return sendResult;
  }
  return NaviErrors::SUCCESS;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:25,代码来源:BaseConnection.cpp

示例8: inject

void Injector::inject(const PacketBuffer &pb ) const
{
	if( handle_ == NULL )
	{
		std::cerr << "ERROR: Problems injecting packet" << std::endl;
		std::cerr << "NO DEVICE SET" << std::endl;
		exit(2);
	}
	int err = pcap_sendpacket(handle_, pb.buffer(), pb.size());
	if( err )
	{ //clean up
		std::cerr << "ERROR: Problems injecting packet " << std::endl;
		std::cerr << pcap_geterr( handle_ ) << std::endl;
		exit( 2 );
	}
}
开发者ID:MuminSalimov,项目名称:packet-manipulation-library,代码行数:16,代码来源:injector.cpp

示例9: sendIntegersReply

/**
 * Sends a debug reply with a variable number of integer arguments and the
 * given command and packet ID to BinNavi.
 *
 * @param command The type of the reply.
 * @param id The message ID of the reply.
 * @param values The integer arguments to send to BinNavi.
 * @param nrvalues The number of integer arguments to send to BinNavi.
 *
 * @return A NaviError code that describes whether the operation was
 * successful or not.
 **/
NaviError BaseConnection::sendIntegersReply(const commandtype_t command,
                                            unsigned int id,
                                            unsigned int *values,
                                            unsigned int nrvalues) const {
  PacketBuffer buffer;
  buffer.add(createPacketHeader(command, id, nrvalues));
  for (unsigned int i = 0; i < nrvalues; i++) {
    addIntegerArgument(buffer, values[i]);
  }
  NaviError sendResult = send(buffer.data(), buffer.size());
  if (sendResult) {
    msglog->log(LOG_VERBOSE, "Error: Couldn't send integer reply message");
    return sendResult;
  }
  return NaviErrors::SUCCESS;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:28,代码来源:BaseConnection.cpp

示例10: sendAddressesReply

/**
 * Sends a debug reply with a variable number of address arguments and the
 * given command and packet ID to BinNavi.
 *
 * @param command The type of the reply.
 * @param id The message ID of the reply.
 * @param addresses The address arguments to send to BinNavi.
 * @param nraddresses The number of address arguments to send to BinNavi.
 *
 * @return A NaviError code that describes whether the operation was
 * successful or not.
 **/
NaviError BaseConnection::sendAddressesReply(const commandtype_t command,
                                             unsigned int id,
                                             const CPUADDRESS *addresses,
                                             unsigned int nraddresses) const {
  PacketBuffer buffer;
  buffer.add(createPacketHeader(command, id, nraddresses));
  for (unsigned int i = 0; i < nraddresses; ++i) {
    addAddressArgument(buffer, addresses[i]);
  }
  msglog->log(LOG_ALL, "%d", nraddresses);
  NaviError sendResult = send(buffer.data(), buffer.size());
  if (sendResult) {
    msglog->log(LOG_VERBOSE, "Error: Couldn't send address reply message");
    return sendResult;
  }
  return NaviErrors::SUCCESS;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:29,代码来源:BaseConnection.cpp

示例11: sendIntegerIntegerAddressReply

/**
 * Sends a debug reply with two integer arguments and one address argument and
 * the given command and packet ID
 * to BinNavi.
 *
 * @param command The type of the reply.
 * @param id The message ID of the reply.
 * @param value1 The first integer value to send.
 * @param value2 The second integer value to send.
 * @param address The address value to send.
 *
 * @return A NaviError code that describes whether the operation was
 * successful or not.
 **/
NaviError BaseConnection::sendIntegerIntegerAddressReply(
    const commandtype_t command, unsigned int id, unsigned int value1,
    unsigned int value2, CPUADDRESS address) const {
  const unsigned int NUMBER_OF_ARGUMENTS = 3;
  PacketBuffer buffer;
  buffer.add(createPacketHeader(command, id, NUMBER_OF_ARGUMENTS));
  addIntegerArgument(buffer, value1);
  addIntegerArgument(buffer, value2);
  addAddressArgument(buffer, address);
  NaviError sendResult = send(buffer.data(), buffer.size());
  if (sendResult) {
    msglog->log(LOG_VERBOSE,
                "Error: Couldn't send integer integer address reply message");
    return sendResult;
  }
  return NaviErrors::SUCCESS;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:31,代码来源:BaseConnection.cpp

示例12: cookie

/**
    Reads data and returns a pointer to a new PacketBuffer object. You are responsible for
    deleting the returned packet when you are finished with it.

    You are gerented to receive a full PacketBuffer object.

    When data is read in, some verification is done to ensure that the packet header is
    valid. There is no way to validate the buffer portion of the packet. A test is done
    on the header to see if the cookie (just a constant value passed all the time) and
    to see the the command looks like it might be valid. There is no way to tell other then
    if the command is zero (PacketBuffer::pcInvalid). Note that a common problem with getting
    PacketBuffer::pcInvalid as a command is not setting the command in a packet before sending
    it.

    If a packet is sent with a size greater then 3000 bytes, the read operation will
    reset the internal buffer, and throw an exception. This is done to prevent bogus packets
    overflowing the buffer.

    \throw SocketInstanceException  If there is a read error, or a connection was closed.
    \throw BufferedSocketException          If a bad packet was read.
**/
PacketBuffer* BufferedSocket::recvPacket()
{
    PacketBuffer* pPacket = readFullPacket();

    if(pPacket->cookie()!=PacketBuffer::pkCookie || pPacket->getCmd()==PacketBuffer::pcInvalid)
    {
#ifdef DEBUG
        logs::dump(pPacket,PacketBuffer::getHeaderSize());
        logs::dump(pPacket->m_Buffer,pPacket->getBufferSize());
#endif
        resetBuffer();
        CStr msg;
        msg.format("bad packet received %s",
                   pPacket->getCmd() ? "(invalid command)":"(invalid cookie)");
        throwBufferedSocketException(msg);
    }

    return pPacket;
}
开发者ID:patterson7019,项目名称:ssobjects,代码行数:40,代码来源:bufferedsocket.cpp

示例13: sendBreakpointsReply

/**
 * Sends a debug reply that indicates what breakpoints were correctly set and
 * which ones were not.
 *
 * @param command The type of the reply.
 * @param id The message ID of the reply.
 * @param result Vector that contains the error codes for the individual
 * breakpoints. 0 = breakpoint was set.
 *
 * @return A NaviError code that describes whether the operation was
 * successful or not.
 **/
NaviError BaseConnection::sendBreakpointsReply(
    const commandtype_t command, unsigned int id,
    const std::vector<std::pair<CPUADDRESS, unsigned int>> &results) const {
  const unsigned int NUMBER_OF_ARGUMENTS = 1 + 2 * results.size();
  PacketBuffer buffer;
  buffer.add(createPacketHeader(command, id, NUMBER_OF_ARGUMENTS));
  addIntegerArgument(buffer, results.size());
  for (const auto &breakpoint : results) {
    addAddressArgument(buffer, breakpoint.first);
    addIntegerArgument(buffer, breakpoint.second);
  }
  NaviError sendResult = send(buffer.data(), buffer.size());
  if (sendResult) {
    msglog->log(LOG_VERBOSE,
                "Error: Couldn't send integer address reply message");
    return sendResult;
  }
  return NaviErrors::SUCCESS;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:31,代码来源:BaseConnection.cpp

示例14: NetClientThread

int NetClientThread( void *client )
{
	NetClient *net_client = (NetClient *) client;
	char data[ PACKET_BUFFER_SIZE ] = "";
	PacketBuffer Buffer;
	
	while( net_client->Connected )
	{
		// Check for packets.
		int size = 0;
		if( ( size = SDLNet_TCP_Recv( net_client->Socket, data, PACKET_BUFFER_SIZE ) ) > 0 )
		{
			if( ! net_client->Connected )
				break;
			
			net_client->BytesReceived += size;
			Buffer.AddData( data, size );
			
			while( Packet *packet = Buffer.Pop() )
			{
				SDL_mutexP( net_client->Lock );
				net_client->InBuffer.push( packet );
				SDL_mutexV( net_client->Lock );
			}
		}
		else
		{
			// If 0 (disconnect) or -1 (error), stop listening.
			if( size < 0 )
				net_client->DisconnectMessage = std::string("SDLNet_TCP_Recv: ") + std::string(SDLNet_GetError());
			net_client->Disconnect();
			break;
		}
		
		// Let the thread rest a bit.
		SDL_Delay( 1 );
	}
	
	// Set the thread pointer to NULL when we disconnect.
	net_client->Thread = NULL;
	
	return 0;
}
开发者ID:Raptor007,项目名称:RaptorEngine,代码行数:43,代码来源:NetClient.cpp

示例15: addIntegerArgument

/**
 * Sends a reply to an event that suspended the process to BinNavi.
 *
 * @param command The type of the reply.
 * @param id The message ID of the reply.
 * @param info Object that provides information about the event.
 *
 * @return A NaviError code that describes whether the operation was successful
 * or not.
 **/
NaviError
BaseConnection::sendSuspendedReply(const commandtype_t command, unsigned int id,
                                   const InformationProvider &info) const {
  if (info.getRegisterString().size() == 0) {
    return NaviErrors::SUCCESS;
  }
  const unsigned int NUMBER_OF_ARGUMENTS = 3;
  PacketBuffer buffer;
  buffer.add(createPacketHeader(command, id, NUMBER_OF_ARGUMENTS));
  addIntegerArgument(buffer, info.getTid());
  addAddressArgument(buffer, info.getAddress(0));
  addStringArgument(buffer, info.getRegisterString());
  NaviError sendResult = send(buffer.data(), buffer.size());
  if (sendResult) {
    msglog->log(LOG_VERBOSE, "Error: Couldn't send suspended reply message");
    return sendResult;
  }
  return NaviErrors::SUCCESS;
}
开发者ID:0x90erator,项目名称:binnavi,代码行数:29,代码来源:BaseConnection.cpp


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