#include <ContactManager.h>
Inheritance diagram for dtn::ContactManager:
Maintains topological information and connectivity state regarding available links and contacts.
Definition at line 39 of file ContactManager.h.
Public Member Functions | |
ContactManager () | |
Constructor / Destructor. | |
virtual | ~ContactManager () |
void | dump (oasys::StringBuffer *buf) const |
Dump a string representation of the info inside contact manager. | |
void | add_link (Link *link) |
Add a link. | |
void | del_link (Link *link) |
Delete a link. | |
bool | has_link (Link *link) |
Check if contact manager already has this link. | |
Link * | find_link (const char *name) |
Finds link corresponding to this name. | |
Link * | find_link_to (ConvergenceLayer *cl, const std::string &nexthop, const EndpointID &remote_eid=EndpointID::NULL_EID(), Link::link_type_t type=Link::LINK_INVALID, u_int states=0xffffffff) |
Helper routine to find a link based on criteria:. | |
const LinkSet * | links () |
Return the list of links. | |
oasys::Lock * | lock () |
Accessor for the ContactManager internal lock. | |
void | handle_event (BundleEvent *event) |
Generic event handler. | |
void | handle_link_available (LinkAvailableEvent *event) |
Event handler when a link becomes unavailable. | |
void | handle_link_unavailable (LinkUnavailableEvent *event) |
Event handler when a link becomes unavailable. | |
void | handle_contact_up (ContactUpEvent *event) |
Event handler when a link is opened successfully. | |
Link * | new_opportunistic_link (ConvergenceLayer *cl, const std::string &nexthop, const EndpointID &remote_eid) |
Notification from a convergence layer that a new opportunistic link has come knocking. | |
Protected Types | |
typedef std::map< Link *, LinkAvailabilityTimer * > | AvailabilityTimerMap |
Table storing link -> availability timer class. | |
Protected Member Functions | |
void | reopen_link (Link *link) |
Reopen a broken link. | |
Protected Attributes | |
LinkSet * | links_ |
Set of all links. | |
int | opportunistic_cnt_ |
Counter for opportunistic links. | |
AvailabilityTimerMap | availability_timers_ |
oasys::SpinLock | lock_ |
Lock to protect internal data structures. | |
Friends | |
class | LinkAvailabilityTimer |
Classes | |
class | LinkAvailabilityTimer |
Timer class used to re-enable broken ondemand links. More... |
typedef std::map<Link*, LinkAvailabilityTimer*> dtn::ContactManager::AvailabilityTimerMap [protected] |
dtn::ContactManager::ContactManager | ( | ) |
dtn::ContactManager::~ContactManager | ( | ) | [virtual] |
void dtn::ContactManager::dump | ( | oasys::StringBuffer * | buf | ) | const |
Dump a string representation of the info inside contact manager.
Definition at line 316 of file ContactManager.cc.
References oasys::StringBuffer::append(), oasys::StringBuffer::appendf(), ExamineDump::l, links_, and lock_.
Referenced by dtn::BundleDaemon::get_routing_state().
void dtn::ContactManager::add_link | ( | Link * | link | ) |
Add a link.
Definition at line 45 of file ContactManager.cc.
References ExamineDump::l, links_, lock_, log_debug, dtn::Link::name(), and dtn::BundleDaemon::post().
Referenced by new_opportunistic_link(), and dtnsim::Node::process().
void dtn::ContactManager::del_link | ( | Link * | link | ) |
Delete a link.
Definition at line 57 of file ContactManager.cc.
References has_link(), ExamineDump::l, links_, lock_, log_debug, log_err, dtn::Link::name(), and dtn::BundleDaemon::post().
Check if contact manager already has this link.
Definition at line 74 of file ContactManager.cc.
References ExamineDump::l, links_, and lock_.
Referenced by del_link().
Link * dtn::ContactManager::find_link | ( | const char * | name | ) |
Finds link corresponding to this name.
Definition at line 86 of file ContactManager.cc.
References ExamineDump::l, links_, lock_, and dtn::Link::name().
Referenced by dtn::TcaRouter::create_link(), dtn::BundleDaemon::handle_bundle_cancel(), dtn::BundleDaemon::handle_bundle_inject(), dtn::BundleDaemon::handle_bundle_send(), new_opportunistic_link(), dtnsim::Node::process(), and dtn::LinkStateChangeRequest::serialize().
Link * dtn::ContactManager::find_link_to | ( | ConvergenceLayer * | cl, | |
const std::string & | nexthop, | |||
const EndpointID & | remote_eid = EndpointID::NULL_EID() , |
|||
Link::link_type_t | type = Link::LINK_INVALID , |
|||
u_int | states = 0xffffffff | |||
) |
Helper routine to find a link based on criteria:.
cl | The convergence layer | |
nexthop | The next hop string | |
remote_eid | Remote endpoint id (NULL_EID for any) | |
type | Link type (LINK_INVALID for any) | |
states | Bit vector of legal link states, e.g. ~(OPEN | OPENING) |
Definition at line 240 of file ContactManager.cc.
References ASSERT, dtn::EndpointID::c_str(), dtn::Link::clayer(), ExamineDump::l, dtn::Link::LINK_INVALID, dtn::Link::link_type_to_str(), links_, lock_, log_debug, dtn::ConvergenceLayer::name(), dtn::Link::nexthop(), dtn::EndpointID::NULL_EID(), dtn::Link::remote_eid(), dtn::Link::state(), and dtn::Link::type().
Referenced by dtn::CLConnection::find_contact(), dtn::LinkStateRouter::handle_bundle_received(), dtn::IPAnnounce::handle_neighbor_discovered(), and dtn::BluetoothAnnounce::handle_neighbor_discovered().
const LinkSet * dtn::ContactManager::links | ( | ) |
Return the list of links.
Asserts that the CM spin lock is held by the caller.
Definition at line 103 of file ContactManager.cc.
References oasys::Lock::is_locked_by_me(), links_, and lock_.
Referenced by dtn::LinkCommand::exec(), dtn::LinkStateRouter::flood_announcement(), dtn::BundleDaemon::handle_shutdown_request(), dtn::BundleDaemon::reset_stats(), dtn::LinkReportEvent::serialize(), and dtn::ContactReportEvent::serialize().
oasys::Lock* dtn::ContactManager::lock | ( | ) | [inline] |
Accessor for the ContactManager internal lock.
Definition at line 103 of file ContactManager.h.
References lock_.
Referenced by dtn::LinkCommand::exec(), dtn::CLConnection::find_contact(), dtn::LinkStateRouter::flood_announcement(), dtn::BundleDaemon::handle_contact_up(), dtn::BundleDaemon::handle_link_state_change_request(), dtn::StreamConvergenceLayer::Connection::handle_poll_timeout(), dtn::BundleDaemon::handle_shutdown_request(), dtn::BundleDaemon::reset_stats(), dtn::LinkReportEvent::serialize(), and dtn::ContactReportEvent::serialize().
void dtn::ContactManager::handle_event | ( | BundleEvent * | event | ) | [inline, virtual] |
Generic event handler.
Implements dtn::BundleEventHandler.
Definition at line 113 of file ContactManager.h.
References dtn::BundleEventHandler::dispatch_event().
Referenced by dtn::BundleDaemon::handle_event().
void dtn::ContactManager::handle_link_available | ( | LinkAvailableEvent * | event | ) | [virtual] |
Event handler when a link becomes unavailable.
Reimplemented from dtn::BundleEventHandler.
Definition at line 142 of file ContactManager.cc.
References availability_timers_, oasys::Timer::cancel(), ExamineDump::l, dtn::LinkAvailableEvent::link_, lock_, and log_warn.
void dtn::ContactManager::handle_link_unavailable | ( | LinkUnavailableEvent * | event | ) | [virtual] |
Event handler when a link becomes unavailable.
Reimplemented from dtn::BundleEventHandler.
Definition at line 166 of file ContactManager.cc.
References dtn::Link::ALWAYSON, availability_timers_, dtn::ContactEvent::IDLE, ExamineDump::l, dtn::LinkUnavailableEvent::link_, LinkAvailabilityTimer, lock_, log_debug, log_err, dtn::Link::name(), dtn::Link::ONDEMAND, dtn::Link::params(), dtn::ContactEvent::reason_, dtn::ContactEvent::reason_to_str(), dtn::Link::retry_interval_, oasys::Timer::schedule_in(), dtn::Link::type(), dtn::Link::type_str(), and dtn::ContactEvent::USER.
void dtn::ContactManager::handle_contact_up | ( | ContactUpEvent * | event | ) | [virtual] |
Event handler when a link is opened successfully.
Reimplemented from dtn::BundleEventHandler.
Definition at line 224 of file ContactManager.cc.
References dtn::Link::ALWAYSON, dtn::ContactUpEvent::contact_, log_debug, dtn::Link::name(), dtn::Link::ONDEMAND, dtn::Link::params(), dtn::Link::retry_interval_, and dtn::Link::type().
Link * dtn::ContactManager::new_opportunistic_link | ( | ConvergenceLayer * | cl, | |
const std::string & | nexthop, | |||
const EndpointID & | remote_eid | |||
) |
Notification from a convergence layer that a new opportunistic link has come knocking.
Definition at line 286 of file ContactManager.cc.
References add_link(), dtn::EndpointID::c_str(), dtn::Link::create_link(), find_link(), ExamineDump::l, lock_, log_debug, dtn::ConvergenceLayer::name(), dtn::Link::OPPORTUNISTIC, opportunistic_cnt_, dtn::Link::set_remote_eid(), and snprintf().
Referenced by dtn::CLConnection::find_contact().
void dtn::ContactManager::reopen_link | ( | Link * | link | ) | [protected] |
Reopen a broken link.
Definition at line 121 of file ContactManager.cc.
References availability_timers_, ExamineDump::l, lock_, log_debug, log_err, dtn::Link::name(), dtn::Link::OPEN, dtn::BundleDaemon::post(), dtn::ContactEvent::RECONNECT, dtn::Link::state(), dtn::Link::state_to_str(), and dtn::Link::UNAVAILABLE.
Referenced by dtn::ContactManager::LinkAvailabilityTimer::timeout().
friend class LinkAvailabilityTimer [friend] |
LinkSet* dtn::ContactManager::links_ [protected] |
Set of all links.
Definition at line 150 of file ContactManager.h.
Referenced by add_link(), ContactManager(), del_link(), dump(), find_link(), find_link_to(), has_link(), links(), and ~ContactManager().
int dtn::ContactManager::opportunistic_cnt_ [protected] |
Counter for opportunistic links.
Definition at line 151 of file ContactManager.h.
Referenced by new_opportunistic_link().
Definition at line 177 of file ContactManager.h.
Referenced by handle_link_available(), handle_link_unavailable(), and reopen_link().
oasys::SpinLock dtn::ContactManager::lock_ [mutable, protected] |
Lock to protect internal data structures.
Definition at line 182 of file ContactManager.h.
Referenced by add_link(), del_link(), dump(), find_link(), find_link_to(), handle_link_available(), handle_link_unavailable(), has_link(), links(), lock(), new_opportunistic_link(), and reopen_link().