69 #ifdef HAVE_SYS_INOTIFY_H
84 #ifdef HAVE_LOWPAN_SUPPORT
108 #ifdef WITH_BUNDLE_SECURITY
117 #ifdef WITH_DHT_NAMESERVICE
134 #define UNIT_MB * 1048576
148 const std::string NativeDaemon::TAG =
"NativeDaemon";
151 : _runlevel(
RUNLEVEL_ZERO), _statecb(statecb), _eventcb(eventcb), _event_loop(NULL)
162 std::vector<std::string> ret;
183 void NativeDaemon::bindEvents()
185 if (_eventcb != NULL) {
198 void NativeDaemon::unbindEvents()
200 if (_eventcb != NULL) {
213 void NativeDaemon::addEventData(
const dtn::data::Bundle &b, std::vector<std::string> &data)
const
233 void NativeDaemon::addEventData(
const dtn::data::MetaBundle &b, std::vector<std::string> &data)
const
240 data.push_back(
"Procflags: " + b.
procflags.toString());
253 void NativeDaemon::addEventData(
const dtn::data::BundleID &b, std::vector<std::string> &data)
const
270 const std::string
event = evt->getName();
272 std::vector<std::string> data;
281 action =
"available";
284 action =
"unavailable";
287 action =
"data_added";
290 action =
"data_removed";
298 }
catch (
const std::bad_cast&) { };
325 action =
"internet available";
328 action =
"internet unavailable";
331 action =
"discovery start";
334 action =
"discovery stop";
339 }
catch (
const std::bad_cast&) { };
348 data.push_back(
"Local: " + (received.
fromlocal ? std::string(
"true") : std::string(
"false")));
351 addEventData(received.
bundle, data);
352 }
catch (
const std::bad_cast&) { };
372 }
catch (
const std::bad_cast&) { };
384 }
catch (
const std::bad_cast&) { };
390 action =
"completed";
395 addEventData(completed.
getBundle(), data);
396 }
catch (
const std::bad_cast&) { };
422 }
catch (
const std::bad_cast&) { };
431 addEventData(queued.
bundle, data);
432 }
catch (
const std::bad_cast&) { };
435 _eventcb->eventRaised(event, action, data);
471 for (dtn::net::ConvergenceLayer::stats_data::const_iterator iter = data.begin(); iter != data.end(); ++iter) {
473 ret.
addData(pair.first, pair.second);
525 std::vector<std::string> ret;
529 for (std::set<dtn::core::Node>::const_iterator iter = nlist.begin(); iter != nlist.end(); ++iter)
545 if (protocol ==
"tcp")
547 std::string uri =
"ip=" + address +
";port=" + service +
";";
551 else if (protocol ==
"udp")
553 std::string uri =
"ip=" + address +
";port=" + service +
";";
557 else if (protocol ==
"file")
571 if (protocol ==
"tcp")
573 std::string uri =
"ip=" + address +
";port=" + service +
";";
577 else if (protocol ==
"udp")
579 std::string uri =
"ip=" + address +
";port=" + service +
";";
583 else if (protocol ==
"file")
646 #ifdef WITH_BUNDLE_SECURITY
696 if (_runlevel < rl) {
697 for (; _runlevel < rl; _runlevel =
DaemonRunLevel(_runlevel + 1)) {
699 _runlevel_cond.signal(
true);
701 }
else if (_runlevel > rl) {
702 for (; _runlevel > rl; _runlevel =
DaemonRunLevel(_runlevel - 1)) {
703 init_down(_runlevel);
704 _runlevel_cond.signal(
true);
737 init_routing_extensions();
744 component_list &components = _components[rl];
745 for (component_list::iterator it = components.begin(); it != components.end(); ++it)
753 for (component_list::iterator it = components.begin(); it != components.end(); ++it)
758 if (_statecb != NULL) {
759 _statecb->levelChanged(rl);
765 void NativeDaemon::init_down(
DaemonRunLevel rl)
throw (NativeDaemonException)
770 component_list &components = _components[rl];
771 for (component_list::iterator it = components.begin(); it != components.end(); ++it)
802 shutdown_routing_extensions();
809 for (component_list::iterator it = components.begin(); it != components.end(); ++it)
815 if (_statecb != NULL) {
826 while (_runlevel != rl) _runlevel_cond.wait();
846 if (_config_file.
exists()) {
879 _event_loop =
new NativeEventLoop(*
this);
882 _event_loop->
start();
893 #ifdef WITH_BUNDLE_SECURITY
902 void NativeDaemon::shutdown_core() throw (NativeDaemonException)
920 #ifdef WITH_BUNDLE_SECURITY
929 void NativeDaemon::init_storage() throw (NativeDaemonException)
967 throw NativeDaemonException(
"initialization of the bundle storage failed");
1002 if (storage == NULL)
1005 throw NativeDaemonException(
"bundle storage not available");
1018 storage->
attach(bundle_index);
1037 if (!blob_path.
exists()) {
1055 void NativeDaemon::shutdown_storage()
const throw (NativeDaemonException)
1067 void NativeDaemon::init_routing() throw (NativeDaemonException)
1076 void NativeDaemon::shutdown_routing()
const throw (NativeDaemonException)
1080 void NativeDaemon::init_api() throw (NativeDaemonException)
1142 void NativeDaemon::shutdown_api() throw (NativeDaemonException)
1144 for (app_list::iterator it = _apps.begin(); it != _apps.end(); ++it)
1151 void NativeDaemon::init_network() throw (NativeDaemonException)
1160 std::map<dtn::daemon::Configuration::NetConfig::NetType, dtn::net::ConvergenceLayer*> _cl_map;
1166 #ifdef HAVE_SYS_INOTIFY_H
1171 for (std::list<dtn::daemon::Configuration::NetConfig>::const_iterator iter = nets.begin(); iter != nets.end(); ++iter)
1187 #ifdef HAVE_SYS_INOTIFY_H
1188 if (net.
url.size() > 0)
1225 std::map<dtn::daemon::Configuration::NetConfig::NetType, dtn::net::ConvergenceLayer*>::iterator it = _cl_map.find(net.
type);
1229 if (it == _cl_map.end()) {
1238 if (it == _cl_map.end()) {
1240 _cl_map[net.
type] = tcpcl;
1245 if (it == _cl_map.end()) {
1268 #ifdef HAVE_LOWPAN_SUPPORT
1322 }
catch (
const std::exception &ex) {
1331 #ifdef WITH_DHT_NAMESERVICE
1362 for (std::set<ibrcommon::vaddress>::const_iterator iter = addr.begin(); iter != addr.end(); ++iter) {
1372 for (std::list<dtn::daemon::Configuration::NetConfig>::const_iterator iter = nets.begin(); iter != nets.end(); ++iter)
1390 for (component_list::iterator it = clist.begin(); it != clist.end(); ++it)
1397 }
catch (
const std::bad_cast&) { }
1403 for (list<Node>::const_iterator iter = static_nodes.begin(); iter != static_nodes.end(); ++iter)
1409 void NativeDaemon::shutdown_network() throw (NativeDaemonException)
1417 for (list<Node>::const_iterator iter = static_nodes.begin(); iter != static_nodes.end(); ++iter)
1426 for (component_list::iterator it = clist.begin(); it != clist.end(); ++it)
1433 }
catch (
const std::bad_cast&) { }
1437 void NativeDaemon::init_routing_extensions() throw (NativeDaemonException)
1473 if(strategy_name ==
"GRTR"){
1476 else if(strategy_name ==
"GTMX"){
1511 void NativeDaemon::shutdown_routing_extensions()
const throw (NativeDaemonException)