A contact manager class. More...
#include <ContactManager.h>
Classes | |
class | LinkAvailabilityTimer |
Timer class used to re-enable broken ondemand links. More... | |
Public Member Functions | |
ContactManager () | |
Constructor / Destructor. | |
virtual | ~ContactManager () |
void | dump (oasys::StringBuffer *buf) const |
Dump a string representation of the info inside contact manager. | |
bool | add_new_link (const LinkRef &link) |
Add a link if the contact manager does not already have a link by the same name. | |
void | del_link (const LinkRef &link, bool wait=false, ContactEvent::reason_t reason=ContactEvent::NO_INFO) |
Delete a link. | |
bool | has_link (const LinkRef &link) |
Check if contact manager already has this link. | |
bool | has_link (const char *name) |
Check if contact manager already has a link by the same name. | |
LinkRef | find_link (const char *name) |
Finds link corresponding to this name. | |
LinkRef | 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_created (LinkCreatedEvent *event) |
Event handler when a link has been created. | |
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. | |
LinkRef | new_opportunistic_link (ConvergenceLayer *cl, const std::string &nexthop, const EndpointID &remote_eid, const std::string *link_name=NULL) |
Notification from a convergence layer that a new opportunistic link has come knocking. | |
Protected Types | |
typedef std::map< LinkRef, LinkAvailabilityTimer * > | AvailabilityTimerMap |
Table storing link -> availability timer class. | |
Protected Member Functions | |
void | reopen_link (const LinkRef &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 |
A contact manager class.
Maintains topological information and connectivity state regarding available links and contacts.
Definition at line 39 of file ContactManager.h.
typedef std::map<LinkRef, LinkAvailabilityTimer*> dtn::ContactManager::AvailabilityTimerMap [protected] |
Table storing link -> availability timer class.
Definition at line 190 of file ContactManager.h.
dtn::ContactManager::ContactManager | ( | ) |
Constructor / Destructor.
Definition at line 27 of file ContactManager.cc.
dtn::ContactManager::~ContactManager | ( | ) | [virtual] |
Definition at line 35 of file ContactManager.cc.
Add a link if the contact manager does not already have a link by the same name.
Definition at line 42 of file ContactManager.cc.
References links_.
Referenced by dtn::TcaRouter::create_link().
void dtn::ContactManager::del_link | ( | const LinkRef & | link, | |
bool | wait = false , |
|||
ContactEvent::reason_t | reason = ContactEvent::NO_INFO | |||
) |
Delete a link.
Definition at line 65 of file ContactManager.cc.
void dtn::ContactManager::dump | ( | oasys::StringBuffer * | buf | ) | const |
Dump a string representation of the info inside contact manager.
Definition at line 491 of file ContactManager.cc.
LinkRef dtn::ContactManager::find_link | ( | const char * | name | ) |
Finds link corresponding to this name.
Definition at line 151 of file ContactManager.cc.
Referenced by dtn::TcaRouter::create_link(), and dtn::DTLSRRouter::recompute_routes().
LinkRef 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 388 of file ContactManager.cc.
void dtn::ContactManager::handle_contact_up | ( | ContactUpEvent * | event | ) | [virtual] |
Event handler when a link is opened successfully.
Reimplemented from dtn::BundleEventHandler.
Definition at line 356 of file ContactManager.cc.
void dtn::ContactManager::handle_event | ( | BundleEvent * | event | ) | [inline, virtual] |
Generic event handler.
Implements dtn::BundleEventHandler.
Definition at line 121 of file ContactManager.h.
References dtn::BundleEventHandler::dispatch_event().
Referenced by dtn::BundleDaemon::load_registrations().
void dtn::ContactManager::handle_link_available | ( | LinkAvailableEvent * | event | ) | [virtual] |
Event handler when a link becomes unavailable.
Reimplemented from dtn::BundleEventHandler.
Definition at line 243 of file ContactManager.cc.
void dtn::ContactManager::handle_link_created | ( | LinkCreatedEvent * | event | ) | [virtual] |
Event handler when a link has been created.
Reimplemented from dtn::BundleEventHandler.
Definition at line 217 of file ContactManager.cc.
void dtn::ContactManager::handle_link_unavailable | ( | LinkUnavailableEvent * | event | ) | [virtual] |
Event handler when a link becomes unavailable.
Reimplemented from dtn::BundleEventHandler.
Definition at line 284 of file ContactManager.cc.
bool dtn::ContactManager::has_link | ( | const char * | name | ) |
Check if contact manager already has a link by the same name.
Definition at line 136 of file ContactManager.cc.
Check if contact manager already has this link.
Definition at line 123 of file ContactManager.cc.
const LinkSet * dtn::ContactManager::links | ( | ) |
Return the list of links.
Asserts that the CM spin lock is held by the caller.
Definition at line 170 of file ContactManager.cc.
Referenced by dtn::TableBasedRouter::remove_from_deferred(), and dtnsim::SimConvergenceLayer::update_connectivity().
oasys::Lock* dtn::ContactManager::lock | ( | ) | [inline] |
Accessor for the ContactManager internal lock.
Definition at line 111 of file ContactManager.h.
References lock_.
Referenced by dtn::StreamConvergenceLayer::Connection::handle_poll_timeout(), dtn::TableBasedRouter::remove_from_deferred(), and dtnsim::SimConvergenceLayer::update_connectivity().
LinkRef dtn::ContactManager::new_opportunistic_link | ( | ConvergenceLayer * | cl, | |
const std::string & | nexthop, | |||
const EndpointID & | remote_eid, | |||
const std::string * | link_name = NULL | |||
) |
Notification from a convergence layer that a new opportunistic link has come knocking.
Definition at line 434 of file ContactManager.cc.
void dtn::ContactManager::reopen_link | ( | const LinkRef & | link | ) | [protected] |
Reopen a broken link.
Definition at line 188 of file ContactManager.cc.
friend class LinkAvailabilityTimer [friend] |
Definition at line 185 of file ContactManager.h.
Definition at line 191 of file ContactManager.h.
LinkSet* dtn::ContactManager::links_ [protected] |
oasys::SpinLock dtn::ContactManager::lock_ [mutable, protected] |
Lock to protect internal data structures.
Definition at line 196 of file ContactManager.h.
Referenced by lock().
int dtn::ContactManager::opportunistic_cnt_ [protected] |
Counter for opportunistic links.
Definition at line 165 of file ContactManager.h.