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;
119 StatusDatasetContext::StatusDatasetContext(
const Interest& interest,
120 const DataSender& dataSender,
121 const NackSender& nackSender)
122 : m_interest(interest)
123 , m_dataSender(dataSender)
124 , m_nackSender(nackSender)
125 , m_expiry(DEFAULT_STATUS_DATASET_FRESHNESS_PERIOD)
126 , m_buffer(make_shared<EncodingBuffer>())
128 , 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-2017 Regents of the University of California.
StatusDatasetContext & setExpiry(const time::milliseconds &expiry)
set expiration duration
const time::milliseconds DEFAULT_STATUS_DATASET_FRESHNESS_PERIOD
Name & appendVersion(uint64_t version)
Append a version component.
Represents a TLV element of NDN packet format.
represents an Interest packet
size_t size() const
Get size of encoded wire, including Type-Length-Value.
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block copying TLV-VALUE from raw buffer.
void end()
end the response successfully after appending zero or more blocks
Represents an absolute name.
bool isPrefixOf(const Name &other) const
Check if this name is a prefix of another name.
const uint8_t * wire() const
Get pointer to encoded wire.
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
const time::milliseconds & getExpiry() const
const size_t MAX_NDN_PACKET_SIZE
practical limit of network layer packet size