IBR-DTNSuite
0.10
|
#include <NativeDaemon.h>
Public Member Functions | |
NativeDaemon (NativeDaemonCallback *statecb=NULL, NativeEventCallback *eventcb=NULL) | |
virtual | ~NativeDaemon () |
DaemonRunLevel | getRunLevel () const throw () |
void | init (DaemonRunLevel rl) throw (NativeDaemonException) |
void | wait (DaemonRunLevel rl) throw () |
void | reload () throw () |
void | setDebug (int level) throw () |
void | setLogging (const std::string &defaultTag, int logLevel) const throw () |
void | setLogFile (const std::string &path, int logLevel) const throw () |
void | setConfigFile (const std::string &config_file) |
std::string | getLocalUri () const throw () |
std::vector< std::string > | getNeighbors () const throw () |
NativeNode | getInfo (const std::string &neighbor_eid) const throw (NativeDaemonException) |
NativeStats | getStats () throw () |
void | addConnection (std::string eid, std::string protocol, std::string address, std::string service, bool local=false) const throw () |
void | removeConnection (std::string eid, std::string protocol, std::string address, std::string service, bool local=false) const throw () |
void | initiateConnection (std::string eid) |
virtual void | raiseEvent (const Event *evt) throw () |
std::vector< std::string > | getVersion () const throw () |
void | clearStorage () const throw () |
Public Member Functions inherited from dtn::core::EventReceiver | |
virtual | ~EventReceiver ()=0 |
Static Public Attributes | |
static const std::string | TAG = "NativeDaemon" |
Definition at line 142 of file NativeDaemon.h.
dtn::daemon::NativeDaemon::NativeDaemon | ( | NativeDaemonCallback * | statecb = NULL , |
NativeEventCallback * | eventcb = NULL |
||
) |
Constructor
Definition at line 145 of file NativeDaemon.cpp.
|
virtual |
Destructor
Definition at line 151 of file NativeDaemon.cpp.
void dtn::daemon::NativeDaemon::addConnection | ( | std::string | eid, |
std::string | protocol, | ||
std::string | address, | ||
std::string | service, | ||
bool | local = false |
||
) | const throw () |
Add a static connection to the neighbor with the given EID
Definition at line 520 of file NativeDaemon.cpp.
References dtn::net::ConnectionManager::add(), dtn::core::Node::add(), dtn::core::Node::CONN_FILE, dtn::core::Node::CONN_TCPIP, dtn::core::Node::CONN_UDPIP, dtn::core::BundleCore::getConnectionManager(), dtn::core::BundleCore::getInstance(), dtn::core::Node::NODE_STATIC_GLOBAL, and dtn::core::Node::NODE_STATIC_LOCAL.
void dtn::daemon::NativeDaemon::clearStorage | ( | ) | const throw () |
Delete all bundles in the storage
Definition at line 163 of file NativeDaemon.cpp.
References dtn::storage::BundleStorage::clear(), dtn::core::BundleCore::getInstance(), and dtn::core::BundleCore::getStorage().
NativeNode dtn::daemon::NativeDaemon::getInfo | ( | const std::string & | neighbor_eid | ) | const throw (NativeDaemonException) |
Get neighbor info
Definition at line 461 of file NativeDaemon.cpp.
References dtn::core::Node::getAll(), dtn::core::BundleCore::getConnectionManager(), dtn::core::BundleCore::getInstance(), dtn::net::ConnectionManager::getNeighbor(), dtn::daemon::NativeNode::NODE_CONNECTED, dtn::core::Node::NODE_CONNECTED, dtn::core::Node::NODE_DHT_DISCOVERED, dtn::daemon::NativeNode::NODE_DISCOVERED, dtn::core::Node::NODE_DISCOVERED, dtn::daemon::NativeNode::NODE_INTERNET, dtn::daemon::NativeNode::NODE_P2P, dtn::core::Node::NODE_P2P_DIALUP, dtn::daemon::NativeNode::NODE_STATIC, dtn::core::Node::NODE_STATIC_GLOBAL, dtn::core::Node::NODE_STATIC_LOCAL, dtn::core::Node::NODE_UNAVAILABLE, dtn::daemon::NativeNode::type, dtn::core::Node::URI::type, and ibrcommon::Exception::what().
std::string dtn::daemon::NativeDaemon::getLocalUri | ( | ) | const throw () |
NATIVE DAEMON METHODS Get the local EID of this node
Definition at line 416 of file NativeDaemon.cpp.
References dtn::data::EID::getString(), and dtn::core::BundleCore::local.
std::vector< std::string > dtn::daemon::NativeDaemon::getNeighbors | ( | ) | const throw () |
Get the neighbors
Definition at line 505 of file NativeDaemon.cpp.
References dtn::core::BundleCore::getConnectionManager(), dtn::core::Node::getEID(), dtn::core::BundleCore::getInstance(), dtn::net::ConnectionManager::getNeighbors(), and dtn::data::EID::getString().
DaemonRunLevel dtn::daemon::NativeDaemon::getRunLevel | ( | ) | const throw () |
Get the current runlevel
Definition at line 670 of file NativeDaemon.cpp.
NativeStats dtn::daemon::NativeDaemon::getStats | ( | ) | throw () |
Get statistical data
Definition at line 421 of file NativeDaemon.cpp.
References dtn::daemon::NativeStats::addData(), dtn::daemon::NativeStats::bundles_aborted, dtn::daemon::NativeStats::bundles_expired, dtn::daemon::NativeStats::bundles_generated, dtn::daemon::NativeStats::bundles_queued, dtn::daemon::NativeStats::bundles_received, dtn::daemon::NativeStats::bundles_requeued, dtn::daemon::NativeStats::bundles_stored, dtn::daemon::NativeStats::bundles_transmitted, dtn::storage::BundleStorage::count(), dtn::data::SDNV< E >::get(), dtn::core::BundleCore::getConnectionManager(), dtn::core::EventDispatcher< E >::getCounter(), dtn::core::BundleCore::getInstance(), dtn::net::ConnectionManager::getNeighbors(), dtn::utils::Clock::getOffset(), dtn::utils::Clock::getRating(), dtn::net::ConnectionManager::getStats(), dtn::core::BundleCore::getStorage(), dtn::utils::Clock::getTime(), dtn::utils::Clock::getUptime(), dtn::daemon::NativeStats::neighbors, dtn::storage::BundleStorage::size(), dtn::daemon::NativeStats::storage_size, dtn::daemon::NativeStats::time_adjustments, dtn::daemon::NativeStats::time_offset, dtn::daemon::NativeStats::time_rating, dtn::daemon::NativeStats::timestamp, dtn::utils::Clock::toDouble(), dtn::core::Node::toString(), and dtn::daemon::NativeStats::uptime.
std::vector< std::string > dtn::daemon::NativeDaemon::getVersion | ( | ) | const throw () |
Returns version information about the native daemon
Definition at line 155 of file NativeDaemon.cpp.
References BUILD_NUMBER, and VERSION.
void dtn::daemon::NativeDaemon::init | ( | DaemonRunLevel | rl | ) | throw (NativeDaemonException) |
Switch the runlevel of the daemon
Definition at line 675 of file NativeDaemon.cpp.
Referenced by __daemon_run().
void dtn::daemon::NativeDaemon::initiateConnection | ( | std::string | eid | ) |
initiate a connection to a given neighbor
Definition at line 572 of file NativeDaemon.cpp.
References dtn::core::BundleCore::getConnectionManager(), dtn::core::BundleCore::getInstance(), dtn::net::ConnectionManager::getNeighbor(), and dtn::net::ConnectionManager::open().
|
virtual |
Implements dtn::core::EventReceiver.
Definition at line 252 of file NativeDaemon.cpp.
References dtn::routing::QueueBundleEvent::bundle, dtn::net::BundleReceivedEvent::bundle, dtn::net::ConnectionEvent::CONNECTION_DOWN, dtn::net::ConnectionEvent::CONNECTION_SETUP, dtn::net::ConnectionEvent::CONNECTION_TIMEOUT, dtn::net::ConnectionEvent::CONNECTION_UP, dtn::core::CUSTODY_ACCEPT, dtn::core::CUSTODY_REJECT, dtn::net::BundleReceivedEvent::fromlocal, dtn::core::CustodyEvent::getAction(), dtn::core::NodeEvent::getAction(), dtn::core::GlobalEvent::getAction(), dtn::core::CustodyEvent::getBundle(), dtn::net::TransferCompletedEvent::getBundle(), dtn::net::TransferAbortedEvent::getBundleID(), dtn::core::Node::getEID(), dtn::core::NodeEvent::getNode(), dtn::net::TransferCompletedEvent::getPeer(), dtn::net::TransferAbortedEvent::getPeer(), dtn::data::EID::getString(), dtn::core::GlobalEvent::GLOBAL_BUSY, dtn::core::GlobalEvent::GLOBAL_IDLE, dtn::core::GlobalEvent::GLOBAL_INTERNET_AVAILABLE, dtn::core::GlobalEvent::GLOBAL_INTERNET_UNAVAILABLE, dtn::core::GlobalEvent::GLOBAL_POWERSAVE, dtn::core::GlobalEvent::GLOBAL_RELOAD, dtn::core::GlobalEvent::GLOBAL_SHUTDOWN, dtn::core::GlobalEvent::GLOBAL_SUSPEND, dtn::core::NODE_AVAILABLE, dtn::core::NODE_DATA_ADDED, dtn::core::NODE_DATA_REMOVED, dtn::core::NODE_UNAVAILABLE, dtn::net::BundleReceivedEvent::peer, dtn::net::ConnectionEvent::peer, and dtn::net::ConnectionEvent::state.
void dtn::daemon::NativeDaemon::reload | ( | ) | throw () |
Generate a reload signal
Definition at line 1517 of file NativeDaemon.cpp.
References dtn::core::GlobalEvent::GLOBAL_RELOAD, dtn::core::GlobalEvent::raise(), and ibrcommon::Logger::reload().
Referenced by sighandler().
void dtn::daemon::NativeDaemon::removeConnection | ( | std::string | eid, |
std::string | protocol, | ||
std::string | address, | ||
std::string | service, | ||
bool | local = false |
||
) | const throw () |
Remove a static connection of the neighbor with the given EID
Definition at line 546 of file NativeDaemon.cpp.
References dtn::core::Node::add(), dtn::core::Node::CONN_FILE, dtn::core::Node::CONN_TCPIP, dtn::core::Node::CONN_UDPIP, dtn::core::BundleCore::getConnectionManager(), dtn::core::BundleCore::getInstance(), dtn::core::Node::NODE_STATIC_GLOBAL, dtn::core::Node::NODE_STATIC_LOCAL, and dtn::net::ConnectionManager::remove().
void dtn::daemon::NativeDaemon::setConfigFile | ( | const std::string & | config_file | ) |
Set the daemon configuration
Definition at line 617 of file NativeDaemon.cpp.
References dtn::security::SecurityKeyManager::getInstance(), dtn::core::BundleCore::getInstance(), dtn::daemon::Configuration::getInstance(), ibrcommon::File::getPath(), dtn::daemon::Configuration::load(), dtn::security::SecurityKeyManager::onConfigurationChanged(), and dtn::core::BundleCore::onConfigurationChanged().
void dtn::daemon::NativeDaemon::setDebug | ( | int | level | ) | throw () |
Enable / disable debugging at runtime
Definition at line 1529 of file NativeDaemon.cpp.
References IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::LogLevel::info, ibrcommon::Logger::setVerbosity(), and TAG.
Referenced by sighandler().
void dtn::daemon::NativeDaemon::setLogFile | ( | const std::string & | path, |
int | logLevel | ||
) | const throw () |
Set the path to the log file
Definition at line 637 of file NativeDaemon.cpp.
References ibrcommon::Logger::LOG_DATETIME, ibrcommon::Logger::LOG_LEVEL, ibrcommon::Logger::LOG_TAG, ibrcommon::Logger::LOGGER_ALERT, ibrcommon::Logger::LOGGER_CRIT, ibrcommon::Logger::LOGGER_DEBUG, ibrcommon::Logger::LOGGER_EMERG, ibrcommon::Logger::LOGGER_ERR, ibrcommon::Logger::LOGGER_INFO, ibrcommon::Logger::LOGGER_NOTICE, ibrcommon::Logger::LOGGER_WARNING, logopts, logsys, and ibrcommon::Logger::setLogfile().
void dtn::daemon::NativeDaemon::setLogging | ( | const std::string & | defaultTag, |
int | logLevel | ||
) | const throw () |
Set the config file and enable default logging capabilities
setup logging capabilities
Definition at line 585 of file NativeDaemon.cpp.
References ibrcommon::Logger::enableSyslog(), ibrcommon::Logger::LOGGER_ALERT, ibrcommon::Logger::LOGGER_CRIT, ibrcommon::Logger::LOGGER_DEBUG, ibrcommon::Logger::LOGGER_EMERG, ibrcommon::Logger::LOGGER_ERR, ibrcommon::Logger::LOGGER_INFO, ibrcommon::Logger::LOGGER_NOTICE, ibrcommon::Logger::LOGGER_WARNING, logsys, and ibrcommon::Logger::setDefaultTag().
void dtn::daemon::NativeDaemon::wait | ( | DaemonRunLevel | rl | ) | throw () |
Wait until the runlevel is reached
Definition at line 804 of file NativeDaemon.cpp.
|
static |
Definition at line 144 of file NativeDaemon.h.
Referenced by setDebug().