/* */ #include "DHTUnknownMessage.h" #include #include #include "DHTNode.h" #include "util.h" #include "a2functional.h" namespace aria2 { const std::string DHTUnknownMessage::E("e"); const std::string DHTUnknownMessage::UNKNOWN("unknown"); DHTUnknownMessage::DHTUnknownMessage(const SharedHandle& localNode, const unsigned char* data, size_t length, const std::string& ipaddr, uint16_t port): DHTMessage(localNode, SharedHandle()), _length(length), _ipaddr(ipaddr), _port(port) { if(_length == 0) { _data = 0; } else { _data = new unsigned char[length]; memcpy(_data, data, length); } } DHTUnknownMessage::~DHTUnknownMessage() { delete [] _data; } void DHTUnknownMessage::doReceivedAction() {} bool DHTUnknownMessage::send() { return true; } bool DHTUnknownMessage::isReply() const { return false; } void DHTUnknownMessage::validate() const {} std::string DHTUnknownMessage::getMessageType() const { return UNKNOWN; } std::string DHTUnknownMessage::toString() const { size_t sampleLength = 8; if(_length < sampleLength) { sampleLength = _length; } std::string sample(&_data[0], &_data[sampleLength]); return strconcat("dht unknown Remote:", _ipaddr, ":", util::uitos(_port), " length=", util::uitos(_length), ", first 8 bytes(hex)=", util::toHex(sample)); } } // namespace aria2