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;
120 const DataSender& dataSender,
122 : m_interest(interest)
123 , m_dataSender(dataSender)
124 , m_nackSender(nackSender)
128 , 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
bool isPrefixOf(const Name &other) const
Check if this name is a prefix of another name.
Name & appendVersion(uint64_t version)
Append a version component.
const uint8_t * wire() const
Get pointer to encoded wire.
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
const time::milliseconds & getExpiry() const
Represents an absolute 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
provides a context for generating response to a StatusDataset request
EncodingImpl< EncoderTag > EncodingBuffer
const size_t MAX_NDN_PACKET_SIZE
practical limit of network layer packet size
const Name & getName() const