1#ifndef NDNPH_APP_SEGMENT_PRODUCER_HPP
2#define NDNPH_APP_SEGMENT_PRODUCER_HPP
4#include "../face/packet-handler.hpp"
5#include "../keychain/digest.hpp"
40 ,
m_opts(std::move(opts)) {}
72template<
typename SegmentConvention = convention::Segment,
size_t regionCap = 2048>
83 const Name& interestName = interest.getName();
85 if (interestName.
size() == dataNameSize) {
86 auto lastComp = interestName[-1];
90 return replySegment(lastComp.as<SegmentConvention>());
95 return replySegment(0);
100 bool replySegment(uint64_t segment) {
105 StaticRegion<regionCap> region;
106 Data data = region.template create<Data>();
108 data.setName(
m_prefix.
append(region, SegmentConvention(), segment));
Producer of segmented object.
Definition segment-producer.hpp:73
bool processInterest(Interest interest) final
Override to receive Interest packets.
Definition segment-producer.hpp:78
static const DigestKey & get()
Definition digest.hpp:16
Network layer face.
Definition face.hpp:12
Interest packet.
Definition interest.hpp:284
Name.
Definition name.hpp:14
size_t size() const
Get number of components.
Definition name.hpp:86
Name append(Region ®ion, const C &... comps) const
Append a sequence of components.
Definition name.hpp:183
bool isPrefixOf(const Name &other) const
Determine if this name is a prefix of other.
Definition name.hpp:239
Base class to receive packets from Face.
Definition packet-handler.hpp:10
bool reply(Arg &&... arg)
Synchronously transmit a packet in reply to current processing packet.
Definition packet-handler.hpp:119
Private key.
Definition private-key.hpp:9
Definition segment-producer.hpp:9
const uint8_t * m_content
Definition segment-producer.hpp:63
void setContent(Name prefix, const uint8_t *content, size_t size)
Set or change served content.
Definition segment-producer.hpp:52
SegmentProducerBase(Face &face)
Definition segment-producer.hpp:42
SegmentProducerBase(Face &face, Options opts)
Constructor.
Definition segment-producer.hpp:38
size_t m_size
Definition segment-producer.hpp:64
Options m_opts
Definition segment-producer.hpp:60
Name m_prefix
Definition segment-producer.hpp:61
uint64_t m_lastSegment
Definition segment-producer.hpp:62
#define NDNPH_ASSERT(x)
Definition common.hpp:30
std::enable_if< std::is_integral< I >::value, I >::type divCeil(const I &a, const I &b)
Compute ceil( a / b ).
Definition operators.hpp:25
Definition segment-producer.hpp:11
int discovery
Name discovery setting.
Definition segment-producer.hpp:30
size_t contentLen
Maximum Content TLV-VALUE in each segment.
Definition segment-producer.hpp:15
uint32_t freshnessPeriod
Definition segment-producer.hpp:17
const PrivateKey & signer
Definition segment-producer.hpp:12