36 #ifdef WITH_COMPRESSION
40 #ifdef WITH_BUNDLE_SECURITY
59 std::set<std::string> Registration::_handles;
61 const std::string Registration::alloc_handle()
65 std::string new_handle = rand.
gen_chars(16);
71 uint32_t *int_handle = (uint32_t*)new_handle.c_str();
74 new_handle = ss.str();
77 while (_handles.find(new_handle) != _handles.end())
85 uint32_t *int_handle = (uint32_t*)new_handle.c_str();
88 new_handle = ss.str();
92 Registration::_handles.insert(new_handle);
97 void Registration::free_handle(
const std::string &handle)
99 Registration::_handles.erase(handle);
103 : _handle(alloc_handle()),
104 _default_eid(core::
BundleCore::local.add( dtn::core::
BundleCore::local.getDelimiter() + _handle) ),
105 _persistent(false), _detached(false), _expiry(0), _filter_fragments(true)
111 free_handle(_handle);
119 _no_more_bundles =
false;
120 _wait_for_cond.
signal(
true);
124 _notify_queue.
push(call);
132 while (_no_more_bundles)
136 _wait_for_cond.
wait(timeout);
140 _wait_for_cond.
wait();
147 return _notify_queue.
getnpop(
true);
153 return (_endpoints.find(endpoint) != _endpoints.end());
182 return storage.
get(b);
228 BundleFilter(
const std::set<dtn::data::EID> endpoints,
const RegistrationQueue &queue,
bool loopback,
bool fragment_filter)
229 : _endpoints(endpoints), _queue(queue), _loopback(loopback), _fragment_filter(fragment_filter)
232 virtual ~BundleFilter() {};
239 if (meta.
fragment && _fragment_filter)
244 if (_endpoints.find(meta.
destination) == _endpoints.end())
252 if (_endpoints.find(meta.
source) != _endpoints.end())
260 if (_queue.has(meta))
269 const std::string getWhere()
const throw ()
271 if (_endpoints.size() > 1)
273 std::string where =
"(";
275 for (
size_t i = _endpoints.size() - 1; i > 0; i--)
277 where +=
"destination = ? OR ";
280 return where +
"destination = ?)";
282 else if (_endpoints.size() == 1)
284 return "destination = ?";
288 return "destination = null";
292 int bind(sqlite3_stmt *st,
int offset)
const throw ()
296 for (std::set<dtn::data::EID>::const_iterator iter = _endpoints.begin(); iter != _endpoints.end(); ++iter)
298 const std::string data = (*iter).getString();
300 sqlite3_bind_text(st, o, data.c_str(),
static_cast<int>(data.size()), SQLITE_TRANSIENT);
309 const std::set<dtn::data::EID> _endpoints;
310 const RegistrationQueue &_queue;
311 const bool _loopback;
312 const bool _fragment_filter;
313 } filter(_endpoints, _queue,
false, fragment_conf && _filter_fragments);
321 _no_more_bundles =
true;
326 Registration::RegistrationQueue::RegistrationQueue()
330 Registration::RegistrationQueue::~RegistrationQueue()
340 _recv_bundles.add(bundle);
346 dtn::data::MetaBundle Registration::RegistrationQueue::pop() throw (const ibrcommon::QueueUnblockedException)
348 return _queue.getnpop(
false);
351 bool Registration::RegistrationQueue::has(
const dtn::data::BundleID &bundle)
const throw ()
354 return _recv_bundles.has(bundle);
360 _recv_bundles.expire(timestamp);
363 void Registration::RegistrationQueue::abort() throw ()
368 void Registration::RegistrationQueue::reset() throw ()
379 _endpoints.insert(endpoint);
389 _endpoints.erase(endpoint);
397 return (_handle == other);
405 return (_handle == other._handle);
413 return (_handle < other._handle);
419 _notify_queue.
abort();
422 _wait_for_cond.
abort();
468 _filter_fragments = val;
495 _notify_queue.
reset();
497 _wait_for_cond.
reset();
530 #ifdef WITH_COMPRESSION
542 #ifdef WITH_BUNDLE_SECURITY
580 std::list<dtn::data::Bundle> fragments;
585 for(std::list<dtn::data::Bundle>::iterator it = fragments.begin(); it != fragments.end(); ++it)