39 NDN_THROW(std::invalid_argument(
"prefix does not start with Interest Name"));
42 if (m_state != State::INITIAL) {
43 NDN_THROW(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 NDN_THROW(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 = make_shared<EncodingBuffer>();
97 if (m_state == State::FINALIZED) {
98 NDN_THROW(std::domain_error(
"state is in FINALIZED"));
101 m_state = State::FINALIZED;
102 m_dataSender(
Name(m_prefix).appendSegment(m_segmentNo),
110 if (m_state != State::INITIAL) {
111 NDN_THROW(std::domain_error(
"state is in RESPONDED or FINALIZED"));
114 m_state = State::FINALIZED;
118 StatusDatasetContext::StatusDatasetContext(
const Interest& interest,
119 const DataSender& dataSender,
120 const NackSender& nackSender)
121 : m_interest(interest)
122 , m_dataSender(dataSender)
123 , m_nackSender(nackSender)
124 , m_expiry(DEFAULT_STATUS_DATASET_FRESHNESS_PERIOD)
125 , m_buffer(make_shared<EncodingBuffer>())
127 , m_state(State::INITIAL)
void reject(const ControlResponse &resp=ControlResponse().setCode(400))
declare the non-existence of a response
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.
const uint8_t * wire() const
Return a raw pointer to the beginning of the encoded wire.
Represents a TLV element of NDN packet format.
Represents an Interest packet.
Name & appendVersion(optional< uint64_t > version=nullopt)
Append a version component.
size_t size() const
Return the size of the encoded wire, i.e.
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.
const Name & getPrefix() const
const Name & getName() const noexcept
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 size_t MAX_NDN_PACKET_SIZE
practical limit of network layer packet size