36 #ifdef WITH_COMPRESSION
40 #ifdef WITH_BUNDLE_SECURITY
58 const std::string Registration::TAG =
"Registration";
60 std::set<std::string> Registration::_handles;
62 const std::string Registration::gen_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();
80 const std::string& Registration::alloc_handle(
const std::string &handle)
83 std::pair<std::set<std::string>::iterator,
bool> ret = _handles.insert(handle);
86 ret = _handles.insert(gen_handle());
92 const std::string& Registration::alloc_handle()
94 return alloc_handle(gen_handle());
97 void Registration::free_handle(
const std::string &handle)
100 _handles.erase(handle);
104 : _handle(alloc_handle(handle)),
105 _default_eid(core::
BundleCore::local), _no_more_bundles(false),
106 _persistent(false), _detached(false), _expiry(0), _filter_fragments(true)
112 : _handle(alloc_handle()),
113 _default_eid(core::
BundleCore::local), _no_more_bundles(false),
114 _persistent(false), _detached(false), _expiry(0), _filter_fragments(true)
121 free_handle(_handle);
129 _no_more_bundles =
false;
130 _wait_for_cond.
signal(
true);
134 _notify_queue.
push(call);
142 while (_no_more_bundles)
146 _wait_for_cond.
wait(timeout);
150 _wait_for_cond.
wait();
157 return _notify_queue.
getnpop(
true);
163 return (_endpoints.find(endpoint) != _endpoints.end());
192 return storage.
get(b);
238 BundleFilter(
const std::set<dtn::data::EID> endpoints,
const RegistrationQueue &queue,
bool loopback,
bool fragment_filter)
239 : _endpoints(endpoints), _queue(queue), _loopback(loopback), _fragment_filter(fragment_filter)
242 virtual ~BundleFilter() {};
254 if (_endpoints.find(meta.
destination) == _endpoints.end())
262 if (_endpoints.find(meta.
source) != _endpoints.end())
270 if (_queue.has(meta))
279 const std::string getWhere()
const throw ()
281 if (_endpoints.size() > 1)
283 std::string where =
"(";
285 for (
size_t i = _endpoints.size() - 1; i > 0; i--)
287 where +=
"destination = ? OR ";
290 return where +
"destination = ?)";
292 else if (_endpoints.size() == 1)
294 return "destination = ?";
298 return "destination = null";
302 int bind(sqlite3_stmt *st,
int offset)
const throw ()
306 for (std::set<dtn::data::EID>::const_iterator iter = _endpoints.begin(); iter != _endpoints.end(); ++iter)
308 const std::string data = (*iter).getString();
310 sqlite3_bind_text(st, o, data.c_str(),
static_cast<int>(data.size()), SQLITE_TRANSIENT);
319 const std::set<dtn::data::EID> _endpoints;
320 const RegistrationQueue &_queue;
321 const bool _loopback;
322 const bool _fragment_filter;
323 } filter(_endpoints, _queue,
false, fragment_conf && _filter_fragments);
331 _no_more_bundles =
true;
336 Registration::RegistrationQueue::RegistrationQueue()
340 Registration::RegistrationQueue::~RegistrationQueue()
350 _recv_bundles.add(bundle);
356 dtn::data::MetaBundle Registration::RegistrationQueue::pop() throw (const ibrcommon::QueueUnblockedException)
358 return _queue.getnpop(
false);
361 bool Registration::RegistrationQueue::has(
const dtn::data::BundleID &bundle)
const throw ()
364 return _recv_bundles.has(bundle);
370 _recv_bundles.expire(timestamp);
373 void Registration::RegistrationQueue::abort() throw ()
378 void Registration::RegistrationQueue::reset() throw ()
389 _endpoints.insert(endpoint);
399 _endpoints.erase(endpoint);
407 return (_handle == other);
415 return (_handle == other._handle);
423 return (_handle < other._handle);
429 _notify_queue.
abort();
432 _wait_for_cond.
abort();
478 _filter_fragments = val;
505 _notify_queue.
reset();
507 _wait_for_cond.
reset();
543 #ifdef WITH_COMPRESSION
555 #ifdef WITH_BUNDLE_SECURITY
593 std::list<dtn::data::Bundle> fragments;
598 for(std::list<dtn::data::Bundle>::iterator it = fragments.begin(); it != fragments.end(); ++it)