39 BOOST_THROW_EXCEPTION(std::invalid_argument(
"prefix does not start with Interest Name"));
42 if (m_state != State::INITIAL) {
43 BOOST_THROW_EXCEPTION(std::domain_error(
"state is not in INITIAL"));
48 if (!m_prefix[-1].isVersion()) {
55 const time::milliseconds&
71 if (m_state == State::FINALIZED) {
72 BOOST_THROW_EXCEPTION(std::domain_error(
"state is in FINALIZED"));
75 m_state = State::RESPONDED;
77 size_t nBytesLeft = block.
size();
78 while (nBytesLeft > 0) {
79 size_t nBytesAppend = std::min(nBytesLeft,
81 m_buffer->appendByteArray(block.
wire() + (block.
size() - nBytesLeft), nBytesAppend);
82 nBytesLeft -= nBytesAppend;
85 m_dataSender(
Name(m_prefix).appendSegment(m_segmentNo++),
89 m_buffer = std::make_shared<EncodingBuffer>();
97 if (m_state == State::FINALIZED) {
98 BOOST_THROW_EXCEPTION(std::domain_error(
"state is in FINALIZED"));
101 m_state = State::FINALIZED;
103 m_dataSender(
Name(m_prefix).appendSegment(m_segmentNo),
111 if (m_state != State::INITIAL) {
112 BOOST_THROW_EXCEPTION(std::domain_error(
"state is in REPONSED or FINALIZED"));
115 m_state = State::FINALIZED;
123 : m_interest(interest)
124 , m_dataSender(dataSender)
125 , m_nackSender(nackSender)
126 , m_expiry(DEFAULT_STATUS_DATASET_FRESHNESS_PERIOD)
129 , m_state(State::INITIAL)
std::function< void(const ControlResponse &resp)> NackSender
void reject(const ControlResponse &resp=ControlResponse().setCode(400))
declare the non-existence of a response
Copyright (c) 2011-2015 Regents of the University of California.
StatusDatasetContext & setExpiry(const time::milliseconds &expiry)
set expiration duration
const time::milliseconds DEFAULT_STATUS_DATASET_FRESHNESS_PERIOD
const uint8_t * wire() const
Class representing a wire element of NDN-TLV packet format.
represents an Interest packet
EncodingImpl< EncoderTag > EncodingBuffer
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block type type with value from a buffer value of size length.
void end()
end the response successfully after appending zero or more blocks
const time::milliseconds & getExpiry() const
Name abstraction to represent an absolute name.
bool isPrefixOf(const Name &name) const
Check if the N components of this name are the same as the first N components of the given name...
StatusDatasetContext(const Interest &interest, const DataSender &dataSender, const NackSender &nackSender)
const Name & getPrefix() const
StatusDatasetContext & setPrefix(const Name &prefix)
change prefix of Data packets
void append(const Block &block)
append a Block to the response
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const Block time::milliseconds bool isFinalBlock DataSender
provides a context for generating response to a StatusDataset request
Name & appendVersion(uint64_t version)
Append version using NDN naming conventions.
const size_t MAX_NDN_PACKET_SIZE
practical limit of network layer packet size
const Name & getName() const