本文整理汇总了C++中PacketPtr类的典型用法代码示例。如果您正苦于以下问题:C++ PacketPtr类的具体用法?C++ PacketPtr怎么用?C++ PacketPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PacketPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PRINTFN
void PHXSimWrap::writeData(uint id, uint64_t addr, uint64_t clockcycle)
{
PRINTFN("%s: id=%d addr=%#lx clock=%lu\n",__func__,id,addr,clockcycle);
std::multimap< uint64_t, PacketPtr >::iterator it =
m_wr_pktMap.find( addr );
assert( it != m_wr_pktMap.end() );
PacketPtr pkt = it->second;
m_wr_lat.sample( curTick() - pkt->dram_enter_time );
PRINTFN("%s() `%s` addr=%#lx size=%d\n", __func__, pkt->cmdString().c_str(),
(long)pkt->getAddr(), pkt->getSize());
PhysicalMemory::doAtomicAccess( pkt );
if ( pkt->needsResponse() ) {
m_readyQ.push_back(pkt);
} else {
delete pkt;
}
m_wr_pktMap.erase( addr );
}
示例2: Barrier
int FrontProtocol::Barrier()
{
int tag;
PacketPtr p;
unsigned int countACKs = 0;
#if defined(CONTROL_STREAM_BLOCKING)
cerr << "[FE] Entering barrier..." << endl;
MRN_STREAM_RECV(mrnApp->stControl, &tag, p, TAG_ACK);
p->unpack("%d", &countACKs);
cerr << "[FE] Barrier received " << countACKs << " ACK's..." << endl;
#else
for (int i=0; i<mrnApp->stControl->size(); i++)
{
int x = 0;
MRN_STREAM_RECV(mrnApp->stControl, &tag, p, TAG_ACK);
p->unpack("%d", &x);
countACKs += x;
}
#endif
cerr << "[FE] Barrier broadcasting " << countACKs << " ACK's..." << endl;
MRN_STREAM_SEND(mrnApp->stControl, TAG_ACK, "%d", countACKs);
if (countACKs != mrnApp->stControl->size())
{
cerr << "[FE] ERROR: FrontProtocol::Barrier: " << countACKs << " ACKs received, expected " << mrnApp->stControl->size() << endl;
return -1;
}
cerr << "[FE] Exiting barrier" << endl;
return 0;
}
示例3: DispatchZoneServer
bool CGameServer::DispatchZoneServer(const PacketPtr& PktPtr, KeyRef krSocket)
{
bool bRet = false;
switch (PktPtr->GetEvent()) {
case PAK_EVENT_LINK:
{
bRet = OnServerLink(static_cast<CPAKLink*>(PktPtr.Get()), krSocket);
}
break;
case PAK_EVENT_UPDATE:
{
bRet = OnServerUpdate(static_cast<CPAKUpdate*>(PktPtr.Get()), krSocket);
}
break;
case PAK_EVENT_UNLINK:
{
bRet = OnServerUnlink(PktPtr.Get(), krSocket);
}
break;
default:
{
LOGV_WARN(m_FileLog, TF("[游戏服务器]%p无法识别的地图服务器信令包数据[event=%d]"), krSocket, PktPtr->GetEvent());
}
}
return bRet;
}
示例4: I2P_LOG
void EstablishmentManager::processCreated(EstablishmentStatePtr const &state)
{
state->calculateDHSecret();
if(!state->verifyCreationSignature()) {
I2P_LOG(m_log, warning) << "creation signature verification failed";
state->setState(EstablishmentState::State::FAILURE);
return;
}
const ByteArray& dhSecret = state->getDHSecret();
SessionKey newKey(toSessionKey(dhSecret)), newMacKey;
state->setSessionKey(newKey);
copy(dhSecret.begin() + 32, dhSecret.begin() + 32 + 32, newMacKey.begin());
state->setMacKey(newMacKey);
Endpoint ep = state->getTheirEndpoint();
PeerState ps(ep, state->getTheirIdentity().getHash());
ps.setCurrentSessionKey(state->getSessionKey());
ps.setCurrentMacKey(state->getMacKey());
std::lock_guard<std::mutex> lock(m_context.peers.getMutex());
m_context.peers.addPeer(std::move(ps));
PacketPtr p = PacketBuilder::buildSessionConfirmed(state);
p->encrypt(state->getSessionKey(), state->getMacKey());
m_context.sendPacket(p);
state->setState(EstablishmentState::State::CONFIRMED_SENT);
post(state);
}
示例5: lock
void OutboundMessageFragments::timerCallback(const boost::system::error_code& e, PeerState ps, uint32_t const msgId)
{
if(!e) {
std::lock_guard<std::mutex> lock(m_mutex);
auto itr = m_states.find(msgId);
if(itr != m_states.end()) {
OutboundMessageState& oms = itr->second;
if(oms.getTries() > 5) {
m_states.erase(msgId);
return;
}
PacketBuilder::FragmentPtr frag = oms.getNextUnackdFragment();
if(frag) {
std::vector<PacketBuilder::FragmentPtr> fragList;
fragList.push_back(frag);
oms.markFragmentSent(fragList[0]->fragNum);
PacketPtr p = PacketBuilder::buildData(ps.getEndpoint(), false, CompleteAckList(), PartialAckList(), fragList);
p->encrypt(ps.getCurrentSessionKey(), ps.getCurrentMacKey());
m_context.sendPacket(p);
oms.incrementTries();
oms.getTimer().expires_at(oms.getTimer().expires_at() + boost::posix_time::time_duration(0, 0, 2));
oms.getTimer().async_wait(boost::bind(&OutboundMessageFragments::timerCallback, this, boost::asio::placeholders::error, ps, msgId));
}
}
}
}
示例6: _complete_packet
void RealmConnection::_complete_packet(PacketPtr packet_ptr)
{
UT_DEBUGMSG(("RealmConnection::_complete_packet()\n"));
int bytes_needed = packet_ptr->complete(m_buf.data(), m_buf.size());
switch (bytes_needed)
{
case -1:
UT_DEBUGMSG(("Error determining packet (type: 0x%x) completion state!\n", packet_ptr->type()));
return;
case 0:
{
UT_DEBUGMSG(("Read full packet\n"));
UT_return_if_fail(packet_ptr->parse(m_buf.data(), m_buf.size()) != -1);
m_packet_queue.push(packet_ptr);
_receive();
}
break;
default:
UT_DEBUGMSG(("Need more data (%d bytes) for this packet...\n", bytes_needed));
// read the needed number of bytes
char* ptr = m_buf.prepare(bytes_needed);
asio::async_read(m_socket, asio::buffer(ptr, bytes_needed),
boost::bind(&RealmConnection::_complete, shared_from_this(),
asio::placeholders::error, asio::placeholders::bytes_transferred, packet_ptr)
);
break;
}
}
示例7: DispatchGateServer
bool CGameServer::DispatchGateServer(const PacketPtr& PktPtr, KeyRef krSocket)
{
bool bRet = false;
switch (PktPtr->GetEvent()) {
case PAK_EVENT_LINK:
{
bRet = OnServerLink(static_cast<CPAKLink*>(PktPtr.Get()), krSocket);
}
break;
case PAK_EVENT_UPDATE:
{
bRet = OnServerUpdate(static_cast<CPAKUpdate*>(PktPtr.Get()), krSocket);
}
break;
case PAK_EVENT_UNLINK:
{
bRet = OnServerUnlink(PktPtr.Get(), krSocket);
}
break;
case PAK_EVENT_GAME_ID:
{
CPAKGameIdAck GameIdAck;
GameIdAck.SetId((Int)m_ServerInfo.usId);
GameIdAck.AdjustSize();
m_NetworkPtr->Send(krSocket, GameIdAck);
}
break;
default:
{
LOGV_WARN(m_FileLog, TF("[游戏服务器]%p无法识别的网关服务器信令包数据[event=%d]"), krSocket, PktPtr->GetEvent());
}
}
return bRet;
}
示例8: DispatchGameDBServer
bool CGameServer::DispatchGameDBServer(const PacketPtr& PktPtr, KeyRef krSocket)
{
switch (PktPtr->GetEvent()) {
case PAK_EVENT_LINKACK:
{
m_bGameDBLinked = true;
NET_ADDR NetAddr;
m_NetworkPtr->GetAddr(krSocket, NetAddr, false);
m_pUIHandler->OnHandle(PAK_EVENT_LINK, reinterpret_cast<uintptr_t>(&NetAddr), DATA_INDEX_GAMEDB);
LOG_INFO(m_FileLog, TF("[游戏服务器]收到游戏DB服务器注册回复包"));
}
break;
case PAK_EVENT_UPDATEACK:
{
DEV_INFO(TF("[游戏服务器]收到游戏DB服务器更新回复包"));
}
break;
case PAK_EVENT_UNLINKACK:
{
m_bGameDBLinked = false;
LOG_INFO(m_FileLog, TF("[游戏服务器]收到游戏DB服务器注销回复包"));
}
break;
case PAK_EVENT_LIVEACK:
{
}
break;
default:
{
LOGV_WARN(m_FileLog, TF("[游戏服务器]%p无法识别的游戏DB服务器信令包数据[event=%d]"), krSocket, PktPtr->GetEvent());
}
}
return true;
}
示例9: test_CountFilter
int test_CountFilter( Network * net, const char * so_file )
{
int retval, tag, recv_val=0;
PacketPtr buf;
std::string testname("test_Count");
test->start_SubTest(testname);
int filter_id = net->load_FilterFunc( so_file, "aggr_Count" );
if( filter_id == -1 ){
test->print("Stream::load_FilterFunc() failure\n", testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
Communicator * comm_BC = net->get_BroadcastCommunicator( );
Stream * stream = net->new_Stream(comm_BC, filter_id, SFILTER_WAITFORALL);
if( stream->send(PROT_COUNT, "") == -1 ){
test->print("stream::send() failure\n", testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
if( stream->flush( ) == -1 ){
test->print("stream::flush() failure\n", testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
retval = stream->recv(&tag, buf);
assert( retval != 0 ); //shouldn't be 0, either error or block till data
if( retval == -1){
//recv error
test->print("stream::recv() failure\n", testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
else{
//Got data
if( buf->unpack( "%d", &recv_val ) == -1 ){
test->print("stream::unpack() failure\n", testname);
return -1;
}
if( recv_val != (int)stream->size() ){
char tmp_buf[256];
sprintf(tmp_buf, "recv_val(%d) != NumEndPoints(%d). Failure.\n",
recv_val, stream->size( ) );
test->print(tmp_buf, testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
}
test->end_SubTest(testname, MRNTEST_SUCCESS);
return 0;
}
示例10: addSelectHeader
void RfidReaderMac::addSelectHeader(PacketPtr packet,
NodeId receiverId) const
{
RfidReaderMacDataPtr macData = RfidReaderMacData::create();
macData->setType(RfidReaderMacData::Types_Select);
macData->setSenderId(getNode()->getNodeId());
macData->setReceiverId(receiverId);
packet->setDoMaxTxPower(true);
packet->addData(Packet::DataTypes_Link, *macData);
}
示例11: sendRequest
void EstablishmentManager::sendRequest(EstablishmentStatePtr const &state)
{
PacketPtr p = PacketBuilder::buildSessionRequest(state);
p->encrypt(state->getSessionKey(), state->getMacKey());
m_context.sendPacket(p);
state->setState(EstablishmentState::State::REQUEST_SENT);
post(state);
}
示例12: test_CountOddsAndEvensFilter
int test_CountOddsAndEvensFilter( Network * net, const char * so_file )
{
int num_odds=0, num_evens=0, retval, tag=0;
PacketPtr buf;
std::string testname("test_CountOddsAndEvens");
test->start_SubTest(testname);
int filter_id = net->load_FilterFunc( so_file,
"aggr_CountOddsAndEvens" );
if( filter_id == -1 ){
test->print("Stream::load_FilterFunc() failure\n", testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
Communicator * comm_BC = net->get_BroadcastCommunicator( );
Stream * stream = net->new_Stream(comm_BC, filter_id, SFILTER_WAITFORALL);
if( stream->send(PROT_COUNTODDSANDEVENS, "") == -1 ){
test->print("stream::send() failure\n", testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
if( stream->flush( ) == -1 ){
test->print("stream::flush() failure\n", testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
retval = stream->recv(&tag, buf);
assert( retval != 0 ); //shouldn't be 0, either error or block till data
if( retval == -1){
//recv error
test->print("stream::recv() failure\n", testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
else{
//Got data
if( buf->unpack( "%d %d", &num_odds, &num_evens ) == -1 ){
test->print("stream::unpack() failure\n", testname);
test->end_SubTest(testname, MRNTEST_FAILURE);
return -1;
}
char tmp_buf[256];
sprintf(tmp_buf, "num_odds = %d; num_evens = %d\n",
num_odds, num_evens);
test->print(tmp_buf, testname);
}
test->end_SubTest(testname, MRNTEST_SUCCESS);
return 0;
}
示例13: sendData
bool SimulatorLink::sendData(PacketPtr data) {
// Create a copy, or we get the really wierd situation where updating the number of
// hops on one router will change all copies of the packet, even those in transit!
PacketPtr ptr = std::make_shared<Packet>(data->getData(), data->getDataLength());
sendQueue.push(ptr);
return true;
}
示例14: createAckPacket
PacketPtr RfidReaderMac::createAckPacket(NodeId destination) const
{
RfidReaderMacDataPtr macData = RfidReaderMacData::create();
macData->setType(RfidReaderMacData::Types_Ack);
macData->setSenderId(getNode()->getNodeId());
macData->setReceiverId(destination);
PacketPtr packet = Packet::create();
packet->setDoMaxTxPower(true);
packet->addData(Packet::DataTypes_Link, *macData);
return packet;
}
示例15: putPacket
bool Packetizer::putPacket(PacketPtr ptr) {
bool result = false;
//in case of stream is not mapped through stream_data element, discard packet
if (_streams.find(ptr->getStreamIndex()) == _streams.end()) {
return false;
}
if (_codec_overlap.find(_streams[ptr->getStreamIndex()].decoder->getCodecId()) == _codec_overlap.end()) {
_codec_overlap[_streams[ptr->getStreamIndex()].decoder->getCodecId()] = 0;
}
result = processPacket(ptr);
return result;
}