dtn::ContactManager Class Reference

A contact manager class. More...

#include <ContactManager.h>

Inheritance diagram for dtn::ContactManager:

dtn::BundleEventHandler

List of all members.

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 LinkSetlinks ()
 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

LinkSetlinks_
 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


Detailed Description

A contact manager class.

Maintains topological information and connectivity state regarding available links and contacts.

Definition at line 39 of file ContactManager.h.


Member Typedef Documentation

Table storing link -> availability timer class.

Definition at line 190 of file ContactManager.h.


Constructor & Destructor Documentation

dtn::ContactManager::ContactManager (  ) 

Constructor / Destructor.

Definition at line 33 of file ContactManager.cc.

References links_.

dtn::ContactManager::~ContactManager (  )  [virtual]

Definition at line 41 of file ContactManager.cc.

References links_.


Member Function Documentation

bool dtn::ContactManager::add_new_link ( const LinkRef link  ) 

Add a link if the contact manager does not already have a link by the same name.

Definition at line 48 of file ContactManager.cc.

References ASSERT, has_link(), links_, lock_, and dtn::BundleDaemon::post().

Referenced by dtn::TcaRouter::create_link(), dtn::BundleDaemon::handle_link_create(), and new_opportunistic_link().

void dtn::ContactManager::del_link ( const LinkRef link,
bool  wait = false,
ContactEvent::reason_t  reason = ContactEvent::NO_INFO 
)

void dtn::ContactManager::dump ( oasys::StringBuffer *  buf  )  const

Dump a string representation of the info inside contact manager.

Definition at line 497 of file ContactManager.cc.

References links_, and lock_.

Referenced by dtn::BundleDaemon::get_routing_state().

LinkRef dtn::ContactManager::find_link ( const char *  name  ) 

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:.

Parameters:
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)
Returns:
The link if it matches or NULL if there's no match

Definition at line 394 of file ContactManager.cc.

References ASSERT, dtn::EndpointID::c_str(), dtn::Link::LINK_INVALID, dtn::Link::link_type_to_str(), links_, lock_, dtn::ConvergenceLayer::name(), and dtn::EndpointID::NULL_EID().

Referenced by dtn::CLConnection::find_contact(), and dtn::Discovery::handle_neighbor_discovered().

void dtn::ContactManager::handle_contact_up ( ContactUpEvent event  )  [virtual]

Event handler when a link is opened successfully.

Reimplemented from dtn::BundleEventHandler.

Definition at line 362 of file ContactManager.cc.

References dtn::Link::ALWAYSON, ASSERT, has_link(), lock_, and dtn::Link::ONDEMAND.

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::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 249 of file ContactManager.cc.

References ASSERT, availability_timers_, has_link(), and lock_.

void dtn::ContactManager::handle_link_created ( LinkCreatedEvent event  )  [virtual]

Event handler when a link has been created.

Reimplemented from dtn::BundleEventHandler.

Definition at line 223 of file ContactManager.cc.

References ASSERT, has_link(), and lock_.

void dtn::ContactManager::handle_link_unavailable ( LinkUnavailableEvent event  )  [virtual]

bool dtn::ContactManager::has_link ( const char *  name  ) 

Check if contact manager already has a link by the same name.

Definition at line 142 of file ContactManager.cc.

References ASSERT, links_, and lock_.

bool dtn::ContactManager::has_link ( const LinkRef link  ) 

Check if contact manager already has this link.

Definition at line 129 of file ContactManager.cc.

References ASSERT, links_, and lock_.

Referenced by add_new_link(), del_link(), handle_contact_up(), handle_link_available(), handle_link_created(), handle_link_unavailable(), and reopen_link().

const LinkSet * dtn::ContactManager::links (  ) 

oasys::Lock* dtn::ContactManager::lock (  )  [inline]

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.

Returns:
An idle link to represent the new contact

Definition at line 440 of file ContactManager.cc.

References add_new_link(), dtn::EndpointID::c_str(), dtn::Link::create_link(), find_link(), lock_, dtn::ConvergenceLayer::name(), dtn::Link::OPPORTUNISTIC, and opportunistic_cnt_.

Referenced by dtn::CLConnection::find_contact(), and dtn::Discovery::handle_neighbor_discovered().

void dtn::ContactManager::reopen_link ( const LinkRef link  )  [protected]


Friends And Related Function Documentation

friend class LinkAvailabilityTimer [friend]

Definition at line 185 of file ContactManager.h.

Referenced by handle_link_unavailable().


Member Data Documentation

Set of all links.

Definition at line 164 of file ContactManager.h.

Referenced by add_new_link(), ContactManager(), del_link(), dump(), find_link(), find_link_to(), has_link(), links(), and ~ContactManager().

oasys::SpinLock dtn::ContactManager::lock_ [mutable, protected]

Counter for opportunistic links.

Definition at line 165 of file ContactManager.h.

Referenced by new_opportunistic_link().


The documentation for this class was generated from the following files:

Generated on Fri Jan 30 09:27:03 2009 for DTN Reference Implementation by  doxygen 1.5.8