/* */ #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; } 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