39 const std::string FragmentManager::TAG =
"FragmentManager";
42 std::set<FragmentManager::Transmission> FragmentManager::_offsets;
55 return "FragmentManager";
92 std::set<BundleMerger::Chunk> chunks;
93 for (std::list<dtn::data::MetaBundle>::const_iterator iter = list.begin(); iter != list.end(); ++iter)
109 for (std::list<dtn::data::MetaBundle>::const_iterator iter = list.begin(); iter != list.end(); ++iter)
139 for (std::list<dtn::data::MetaBundle>::const_iterator iter = list.begin(); iter != list.end(); ++iter)
166 }
catch (
const std::bad_cast&) {}
182 _incoming.
push(meta);
194 virtual ~BundleFilter() {};
204 if (meta.
source != _similar.source)
return false;
205 if (meta.
timestamp != _similar.timestamp)
return false;
216 BundleFilter filter(meta);
220 storage.
get(filter, list);
229 t.offset = get_payload_offset(b, abs_offset);
231 if (t.offset <= 0)
return;
249 for (std::set<Transmission>::const_iterator iter = _offsets.begin(); iter != _offsets.end(); ++iter)
251 const Transmission &t = (*iter);
252 if (t.peer != peer)
continue;
253 if (t.id !=
id)
continue;
280 if (abs_offset < header)
return 0;
281 return abs_offset - header;
282 }
catch (std::bad_cast&) { };
294 for (std::set<Transmission>::iterator iter = _offsets.begin(); iter != _offsets.end();)
296 const Transmission &t = (*iter);
297 if (t.expires >= timestamp)
return;
298 _offsets.erase(iter++);
315 if (payloadLength <= maxPayloadLength)
321 bool isFirstFragment =
true;
324 while (!(*stream).eof() && (payloadLength > offset))
349 if ((offset + maxPayloadLength) > payloadLength) {
358 offset += fragment_stream.
size();
364 addBlocksFromBundleToFragment(bundle, fragment, fragment_payloadBlock, isFirstFragment, payloadLength == offset);
370 fragments.push_back(fragment);
372 if (isFirstFragment) isFirstFragment =
false;
384 bool isAfterPayload =
false;
385 bool isReplicateInEveryBundle =
false;
395 const Block ¤t_block =
dynamic_cast<const Block&
>(**it);
397 block_type = current_block.
getType();
404 isAfterPayload =
true;
413 if (!isAfterPayload && (isFirstFragment || isReplicateInEveryBundle))
423 fragment_block = current_block;
433 fragment_block = current_block;
442 else if (isAfterPayload && (isLastFragment || isReplicateInEveryBundle))
452 fragment_block = current_block;
462 fragment_block = current_block;
472 FragmentManager::Transmission::Transmission()
473 : offset(0), expires(0)
477 FragmentManager::Transmission::~Transmission()
481 bool FragmentManager::Transmission::operator<(
const Transmission &other)
const
483 if (expires < other.expires)
return true;
484 if (expires != other.expires)
return false;
486 if (peer < other.peer)
return true;
487 if (peer != other.peer)
return false;
489 return (
id < other.id);
492 bool FragmentManager::Transmission::operator==(
const Transmission &other)
const
494 if (expires != other.expires)
return false;
495 if (peer != other.peer)
return false;
496 if (
id != other.id)
return false;