26 #ifndef NFD_CORE_SEGMENT_PUBLISHER_HPP 27 #define NFD_CORE_SEGMENT_PUBLISHER_HPP 31 #include <ndn-cxx/encoding/encoding-buffer.hpp> 32 #include <ndn-cxx/security/key-chain.hpp> 39 template <
class FaceBase>
45 ndn::KeyChain& keyChain,
49 , m_keyChain(keyChain)
50 , m_freshnessPeriod(freshnessPeriod)
63 return MAX_SEGMENT_SIZE;
66 static constexpr time::milliseconds
69 return time::milliseconds(1000);
78 const uint8_t* rawBuffer = buffer.buf();
79 const uint8_t* segmentBegin = rawBuffer;
80 const uint8_t* end = rawBuffer + buffer.size();
82 Name segmentPrefix(m_prefix);
85 uint64_t segmentNo = 0;
88 if (segmentEnd > end) {
92 Name segmentName(segmentPrefix);
95 shared_ptr<Data> data = make_shared<Data>(segmentName);
96 data->setContent(segmentBegin, segmentEnd - segmentBegin);
97 data->setFreshnessPeriod(m_freshnessPeriod);
99 segmentBegin = segmentEnd;
100 if (segmentBegin >= end) {
101 data->setFinalBlockId(segmentName[-1]);
104 publishSegment(data);
106 }
while (segmentBegin < end);
117 publishSegment(shared_ptr<Data>& data)
119 m_keyChain.sign(*data);
126 ndn::KeyChain& m_keyChain;
127 const time::milliseconds m_freshnessPeriod;
132 #endif // NFD_CORE_SEGMENT_PUBLISHER_HPP virtual size_t generate(ndn::EncodingBuffer &outBuffer)=0
In a derived class, write the octets into outBuffer.
provides a publisher of Status Dataset or other segmented octet stream
virtual ~SegmentPublisher()
static constexpr time::milliseconds getDefaultFreshness()
EncodingImpl< EncoderTag > EncodingBuffer
Copyright (c) 2011-2015 Regents of the University of California.
Name & appendSegment(uint64_t segmentNo)
Append segment number (sequential) using NDN naming conventions.
SegmentPublisher(FaceBase &face, const Name &prefix, ndn::KeyChain &keyChain, const time::milliseconds &freshnessPeriod=getDefaultFreshness())
Name abstraction to represent an absolute name.
static size_t getMaxSegmentSize()
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