44 if (m_received == 0) {
45 m_fragCount = fragCount;
46 m_payloads.resize(fragCount);
49 if (m_fragCount != fragCount || fragIndex >= m_fragCount) {
53 if (!m_payloads[fragIndex].empty()) {
57 m_payloads[fragIndex] = payload;
66 return m_received == m_fragCount;
69 std::tuple<bool, Block>
76 for (
const Block& payload : m_payloads) {
77 buf = std::copy(payload.value_begin(), payload.value_end(), buf);
79 BOOST_ASSERT(buf == buffer->end());
84 std::tuple<bool, Block>
93 return std::make_tuple(
false,
Block());
98 : m_idleDuration(idleDuration)
105 bool isReassembled =
false;
114 this->scheduleCleanup(messageIdentifier, pm);
119 std::tie(isReassembled, reassembled) = pm.
reassemble();
120 m_partialMessages.erase(messageIdentifier);
127 if (!isReassembled) {
137 PartialMessageStore::scheduleCleanup(uint64_t messageIdentifier,
141 bind(&PartialMessageStore::cleanup,
this, messageIdentifier));
145 PartialMessageStore::cleanup(uint64_t messageIdentifier)
148 m_partialMessages.erase(messageIdentifier);
static std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to construct block from Buffer.
bool add(uint16_t fragIndex, uint16_t fragCount, const Block &payload)
shared_ptr< Buffer > BufferPtr
static std::tuple< bool, Block > reassembleSingle(const NdnlpData &fragment)
reassemble network layer packet from a single fragment
represents a NdnlpData packet
signal::Signal< PartialMessageStore, Block > onReceive
fires when network layer packet is received
Class representing a wire element of NDN-TLV packet format.
represents a partially received message
Table::const_iterator iterator
scheduler::ScopedEventId expiry
Block blockFromValue() const
Copyright (c) 2011-2015 Regents of the University of California.
EventId schedule(const time::nanoseconds &after, const std::function< void()> &event)
schedule an event
size_t value_size() const
std::tuple< bool, Block > reassemble()
reassemble network layer packet
PartialMessageStore(const time::nanoseconds &idleDuration=time::milliseconds(100))
#define NFD_LOG_INIT(name)
void receive(const NdnlpData &pkt)
receive a NdnlpData packet
#define NFD_LOG_TRACE(expression)
represents an error in TLV encoding or decoding