68 #ifdef HAVE_SYS_INOTIFY_H
83 #ifdef HAVE_LOWPAN_SUPPORT
103 #ifdef WITH_BUNDLE_SECURITY
112 #ifdef WITH_DHT_NAMESERVICE
129 #define UNIT_MB * 1048576
146 : _runlevel(
RUNLEVEL_ZERO), _statecb(statecb), _eventcb(eventcb), _event_loop(NULL)
157 std::vector<std::string> ret;
168 void NativeDaemon::bindEvents()
170 if (_eventcb != NULL) {
183 void NativeDaemon::unbindEvents()
185 if (_eventcb != NULL) {
198 void NativeDaemon::addEventData(
const dtn::data::Bundle &b, std::vector<std::string> &data)
const
218 void NativeDaemon::addEventData(
const dtn::data::MetaBundle &b, std::vector<std::string> &data)
const
225 data.push_back(
"Procflags: " + b.
procflags.toString());
238 void NativeDaemon::addEventData(
const dtn::data::BundleID &b, std::vector<std::string> &data)
const
254 std::string
event = evt->getName();
256 std::vector<std::string> data;
265 action =
"available";
268 action =
"unavailable";
271 action =
"data_added";
274 action =
"data_removed";
282 }
catch (
const std::bad_cast&) { };
297 action =
"powersave";
309 action =
"internet available";
312 action =
"internet unavailable";
317 }
catch (
const std::bad_cast&) { };
326 data.push_back(
"Local: " + (received.
fromlocal ? std::string(
"true") : std::string(
"false")));
329 addEventData(received.
bundle, data);
330 }
catch (
const std::bad_cast&) { };
350 }
catch (
const std::bad_cast&) { };
362 }
catch (
const std::bad_cast&) { };
368 action =
"completed";
373 addEventData(completed.
getBundle(), data);
374 }
catch (
const std::bad_cast&) { };
380 switch (connection.
state)
400 }
catch (
const std::bad_cast&) { };
409 addEventData(queued.
bundle, data);
410 }
catch (
const std::bad_cast&) { };
413 _eventcb->eventRaised(event, action, data);
448 for (ConnectionManager::stats_list::const_iterator iter = list.begin(); iter != list.end(); ++iter) {
452 for (ConvergenceLayer::stats_map::const_iterator map_it = map.begin(); map_it != map.end(); ++map_it) {
454 ret.
addData(tag, (*map_it).second);
507 std::vector<std::string> ret;
511 for (std::set<dtn::core::Node>::const_iterator iter = nlist.begin(); iter != nlist.end(); ++iter)
527 if (protocol ==
"tcp")
529 std::string uri =
"ip=" + address +
";port=" + service +
";";
533 else if (protocol ==
"udp")
535 std::string uri =
"ip=" + address +
";port=" + service +
";";
539 else if (protocol ==
"file")
553 if (protocol ==
"tcp")
555 std::string uri =
"ip=" + address +
";port=" + service +
";";
559 else if (protocol ==
"udp")
561 std::string uri =
"ip=" + address +
";port=" + service +
";";
565 else if (protocol ==
"file")
628 #ifdef WITH_BUNDLE_SECURITY
678 if (_runlevel < rl) {
679 for (; _runlevel < rl; _runlevel =
DaemonRunLevel(_runlevel + 1)) {
681 _runlevel_cond.signal(
true);
683 }
else if (_runlevel > rl) {
684 for (; _runlevel >= rl; _runlevel =
DaemonRunLevel(_runlevel - 1)) {
685 init_down(_runlevel);
686 _runlevel_cond.signal(
true);
719 init_routing_extensions();
726 component_list &components = _components[rl];
727 for (component_list::iterator it = components.begin(); it != components.end(); ++it)
735 for (component_list::iterator it = components.begin(); it != components.end(); ++it)
740 if (_statecb != NULL) {
741 _statecb->levelChanged(rl);
747 void NativeDaemon::init_down(
DaemonRunLevel rl)
throw (NativeDaemonException)
752 component_list &components = _components[rl];
753 for (component_list::iterator it = components.begin(); it != components.end(); ++it)
784 shutdown_routing_extensions();
791 for (component_list::iterator it = components.begin(); it != components.end(); ++it)
797 if (_statecb != NULL) {
798 _statecb->levelChanged(rl);
808 while (_runlevel != rl) _runlevel_cond.wait();
828 if (_config_file.
exists()) {
857 _event_loop =
new NativeEventLoop(*
this);
860 _event_loop->
start();
871 #ifdef WITH_BUNDLE_SECURITY
880 void NativeDaemon::shutdown_core() throw (NativeDaemonException)
898 #ifdef WITH_BUNDLE_SECURITY
907 void NativeDaemon::init_storage() throw (NativeDaemonException)
935 throw NativeDaemonException(
"initialization of the bundle storage failed");
968 throw NativeDaemonException(
"bundle storage not available");
981 storage->
attach(bundle_index);
1000 if (!blob_path.
exists()) {
1018 void NativeDaemon::shutdown_storage()
const throw (NativeDaemonException)
1030 void NativeDaemon::init_routing() throw (NativeDaemonException)
1042 void NativeDaemon::shutdown_routing()
const throw (NativeDaemonException)
1048 void NativeDaemon::init_api() throw (NativeDaemonException)
1110 void NativeDaemon::shutdown_api() throw (NativeDaemonException)
1112 for (app_list::iterator it = _apps.begin(); it != _apps.end(); ++it)
1119 void NativeDaemon::init_network() throw (NativeDaemonException)
1128 std::map<dtn::daemon::Configuration::NetConfig::NetType, dtn::net::ConvergenceLayer*> _cl_map;
1134 #ifdef HAVE_SYS_INOTIFY_H
1139 for (std::list<dtn::daemon::Configuration::NetConfig>::const_iterator iter = nets.begin(); iter != nets.end(); ++iter)
1155 #ifdef HAVE_SYS_INOTIFY_H
1156 if (net.
url.size() > 0)
1193 std::map<dtn::daemon::Configuration::NetConfig::NetType, dtn::net::ConvergenceLayer*>::iterator it = _cl_map.find(net.
type);
1197 if (it == _cl_map.end()) {
1206 if (it == _cl_map.end()) {
1208 _cl_map[net.
type] = tcpcl;
1213 if (it == _cl_map.end()) {
1236 #ifdef HAVE_LOWPAN_SUPPORT
1277 }
catch (
const std::exception &ex) {
1286 #ifdef WITH_DHT_NAMESERVICE
1313 std::set<ibrcommon::vinterface> interfaces;
1316 for (std::list<dtn::daemon::Configuration::NetConfig>::const_iterator iter = nets.begin(); iter != nets.end(); ++iter)
1320 interfaces.insert(net.
iface);
1327 for (std::set<ibrcommon::vaddress>::const_iterator iter = addr.begin(); iter != addr.end(); ++iter) {
1336 for (std::set<ibrcommon::vinterface>::const_iterator iter = interfaces.begin(); iter != interfaces.end(); ++iter)
1347 for (app_list::iterator it = _apps.begin(); it != _apps.end(); ++it)
1354 }
catch (
const std::bad_cast&) { }
1361 for (component_list::iterator it = clist.begin(); it != clist.end(); ++it)
1368 }
catch (
const std::bad_cast&) { }
1382 for (component_list::iterator it = clist.begin(); it != clist.end(); ++it)
1389 }
catch (
const std::bad_cast&) { }
1395 for (list<Node>::const_iterator iter = static_nodes.begin(); iter != static_nodes.end(); ++iter)
1401 void NativeDaemon::shutdown_network() throw (NativeDaemonException)
1409 for (list<Node>::const_iterator iter = static_nodes.begin(); iter != static_nodes.end(); ++iter)
1418 for (component_list::iterator it = clist.begin(); it != clist.end(); ++it)
1425 }
catch (
const std::bad_cast&) { }
1429 void NativeDaemon::init_routing_extensions() throw (NativeDaemonException)
1465 if(strategy_name ==
"GRTR"){
1468 else if(strategy_name ==
"GTMX"){
1503 void NativeDaemon::shutdown_routing_extensions()
const throw (NativeDaemonException)