void UTPServer::Private::dataReceived(bt::Buffer::Ptr buffer, const net::Address& addr) { QMutexLocker lock(&mutex); //Out(SYS_UTP|LOG_NOTICE) << "UTP: received " << ba << " bytes packet from " << addr.toString() << endl; try { if (buffer->size() >= utp::Header::size()) // discard packets which are to small { p->handlePacket(buffer, addr); } } catch (utp::Connection::TransmissionError & err) { Out(SYS_UTP | LOG_NOTICE) << "UTP: " << err.location << endl; } }
virtual void dataReceived(bt::Buffer::Ptr ptr, const net::Address& addr) { try { // read and decode the packet BDecoder bdec(ptr->get(), ptr->size(), false); boost::scoped_ptr<BNode> n(bdec.decode()); if (!n || n->getType() != BNode::DICT) return; // try to make a RPCMsg of it RPCMsg::Ptr msg = factory.build((BDictNode*)n.get(), this); if (msg) { if (addr.ipVersion() == 6 && addr.isIPv4Mapped()) msg->setOrigin(addr.convertIPv4Mapped()); else msg->setOrigin(addr); msg->apply(dh_table); // erase an existing call if (msg->getType() == RSP_MSG && calls.contains(msg->getMTID())) { // delete the call, but first notify it off the response RPCCall* c = calls.find(msg->getMTID()); c->response(msg); calls.erase(msg->getMTID()); c->deleteLater(); doQueuedCalls(); } } } catch (bt::Error & err) { Out(SYS_DHT | LOG_DEBUG) << "Error happened during parsing : " << err.toString() << endl; } }