Response::Response(const Name& zone, const name::Component& queryType) : m_zone(zone) , m_queryType(queryType) , m_contentType(NDNS_BLOB) , m_freshnessPeriod(DEFAULT_RR_FRESHNESS_PERIOD) , m_appContent(makeBinaryBlock(ndn::tlv::Content, reinterpret_cast<const uint8_t*>(0), 0)) { }
KeyLocator& KeyLocator::setKeyDigest(const ConstBufferPtr& keyDigest) { // WARNING: ConstBufferPtr is shared_ptr<const Buffer> // This function takes a constant reference of a shared pointer. // It MUST NOT change the reference count of that shared pointer. return this->setKeyDigest(makeBinaryBlock(tlv::KeyDigest, keyDigest->data(), keyDigest->size())); }
Data& Data::setContent(const uint8_t* content, size_t contentLength) { onChanged(); m_content = makeBinaryBlock(tlv::Content, content, contentLength); return *this; }
Interest& Interest::setApplicationParameters(const uint8_t* buffer, size_t bufferSize) { if (buffer == nullptr && bufferSize != 0) { NDN_THROW(std::invalid_argument("ApplicationParameters buffer cannot be nullptr")); } m_parameters = makeBinaryBlock(tlv::ApplicationParameters, buffer, bufferSize); m_wire.reset(); return *this; }
Interest& Interest::setNonce(uint32_t nonce) { if (m_wire.hasWire() && m_nonce.value_size() == sizeof(uint32_t)) { std::memcpy(const_cast<uint8_t*>(m_nonce.value()), &nonce, sizeof(nonce)); } else { m_nonce = makeBinaryBlock(tlv::Nonce, reinterpret_cast<const uint8_t*>(&nonce), sizeof(nonce)); m_wire.reset(); } return *this; }
Component::Component(const char* str) : Block(makeBinaryBlock(tlv::GenericNameComponent, str, std::char_traits<char>::length(str))) { }
Component::Component(uint32_t type, const uint8_t* value, size_t valueLen) : Block(makeBinaryBlock(type, value, valueLen)) { ensureValid(); }
inline Block dataBlock(uint32_t type, Iterator first, Iterator last) { return makeBinaryBlock(type, first, last); }
/** * @deprecated Use makeBinaryBlock instead */ inline Block dataBlock(uint32_t type, const char* data, size_t dataSize) { return makeBinaryBlock(type, data, dataSize); }
Response::Response() : m_contentType(NDNS_BLOB) , m_freshnessPeriod(DEFAULT_RR_FRESHNESS_PERIOD) , m_appContent(makeBinaryBlock(ndn::tlv::Content, reinterpret_cast<const uint8_t*>(0), 0)) { }
Response& Response::addRr(const std::string& rr) { return this->addRr(makeBinaryBlock(ndns::tlv::RrData, rr.c_str(), rr.size())); }