39 BOOST_THROW_EXCEPTION(std::invalid_argument(
"prefix does not start with Interest Name"));
43 BOOST_THROW_EXCEPTION(std::domain_error(
"state is not in INITIAL"));
48 if (!m_prefix[-1].isVersion()) {
55 const time::milliseconds&
72 BOOST_THROW_EXCEPTION(std::domain_error(
"state is in FINALIZED"));
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>();
98 BOOST_THROW_EXCEPTION(std::domain_error(
"state is in FINALIZED"));
103 m_dataSender(
Name(m_prefix).appendSegment(m_segmentNo),
112 BOOST_THROW_EXCEPTION(std::domain_error(
"state is in REPONSED or FINALIZED"));
120 StatusDatasetContext::StatusDatasetContext(
const Interest& interest,
121 const DataSender& dataSender,
122 const NackSender& nackSender)
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)
const Name & getPrefix() const
void reject(const ControlResponse &resp=ControlResponse().setCode(400))
declare the non-existence of a response
const Name & getName() const
Copyright (c) 2013-2016 Regents of the University of California.
StatusDatasetContext & setExpiry(const time::milliseconds &expiry)
set expiration duration
const time::milliseconds DEFAULT_STATUS_DATASET_FRESHNESS_PERIOD
.end or .reject has been invoked
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
Name abstraction to represent an absolute name.
const uint8_t * wire() const
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 & setPrefix(const Name &prefix)
change prefix of Data packets
void append(const Block &block)
append a Block to the response
provides a context for generating response to a StatusDataset request
none of .append, .end, .reject has been invoked
const time::milliseconds & getExpiry() const
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