38 const std::string FragmentManager::TAG =
"FragmentManager";
41 std::set<FragmentManager::Transmission> FragmentManager::_offsets;
54 return "FragmentManager";
88 if (storage.
contains(origin))
continue;
99 std::set<BundleMerger::Chunk> chunks;
100 for (std::list<dtn::data::MetaBundle>::const_iterator iter = list.begin(); iter != list.end(); ++iter)
106 chunks.insert(chunk);
116 for (std::list<dtn::data::MetaBundle>::const_iterator iter = list.begin(); iter != list.end(); ++iter)
148 for (std::list<dtn::data::MetaBundle>::const_iterator iter = list.begin(); iter != list.end(); ++iter)
173 }
catch (
const std::bad_cast&) {}
189 _incoming.
push(meta);
201 virtual ~BundleFilter() {};
211 if (meta.
source != _similar.source)
return false;
212 if (meta.
timestamp != _similar.timestamp)
return false;
223 BundleFilter filter(meta);
227 storage.
get(filter, list);
236 t.offset = get_payload_offset(b, abs_offset, frag_offset);
238 if (t.offset <= 0)
return;
244 IBRCOMMON_LOGGER_DEBUG_TAG(FragmentManager::TAG, 4) <<
"Store offset of partial transmitted bundle " <<
id.toString() <<
" to " << peer.getString() <<
256 for (std::set<Transmission>::const_iterator iter = _offsets.begin(); iter != _offsets.end(); ++iter)
258 const Transmission &t = (*iter);
259 if (t.peer != peer)
continue;
260 if (t.id !=
id)
continue;
275 if (frag_offset > 0) {
297 if (abs_offset < header)
return 0;
298 return frag_offset + (abs_offset - header);
299 }
catch (std::bad_cast&) { };
311 for (std::set<Transmission>::iterator iter = _offsets.begin(); iter != _offsets.end();)
313 const Transmission &t = (*iter);
314 if (t.expires >= timestamp)
return;
315 _offsets.erase(iter++);
332 if (payloadLength <= maxPayloadLength)
350 bool isFirstFragment =
true;
353 while (!(*stream).eof() && (payloadLength > offset))
369 if ((offset + maxPayloadLength) > payloadLength) {
378 offset += fragment_stream.
size();
384 addBlocksFromBundleToFragment(bundle, fragment, fragment_payloadBlock, isFirstFragment, payloadLength == offset);
390 fragments.push_back(fragment);
392 if (isFirstFragment) isFirstFragment =
false;
404 bool isAfterPayload =
false;
405 bool isReplicateInEveryBundle =
false;
415 const Block ¤t_block =
dynamic_cast<const Block&
>(**it);
417 block_type = current_block.
getType();
424 isAfterPayload =
true;
433 if (!isAfterPayload && (isFirstFragment || isReplicateInEveryBundle))
443 fragment_block = current_block;
453 fragment_block = current_block;
462 else if (isAfterPayload && (isLastFragment || isReplicateInEveryBundle))
472 fragment_block = current_block;
482 fragment_block = current_block;
492 FragmentManager::Transmission::Transmission()
493 : offset(0), expires(0)
497 FragmentManager::Transmission::~Transmission()
501 bool FragmentManager::Transmission::operator<(
const Transmission &other)
const
503 if (expires < other.expires)
return true;
504 if (expires != other.expires)
return false;
506 if (peer < other.peer)
return true;
507 if (peer != other.peer)
return false;
509 return (
id < other.id);
512 bool FragmentManager::Transmission::operator==(
const Transmission &other)
const
514 if (expires != other.expires)
return false;
515 if (peer != other.peer)
return false;
516 if (
id != other.id)
return false;