#include <Discovery.h>
Much like Interface, Discovery is generally created by the configuration file / console. Derived classes (such as IPDiscovery) typically bind to a UDP socket to listen for neighbor beacons. Bluetooth has built-in discovery mechanisms, so BluetoothDiscovery polls via Inquiry instead of listen()ing on a socket.
To advertise a local convergence layer, register its local address (and port) by calling "discovery add_cl". For each registered CL, Discovery will advertise (outbound) the CL's presence to neighbors, and distribute (inbound) each event of neighbor discovery to each CL.
Definition at line 43 of file Discovery.h.
Public Member Functions | |
const std::string & | name () const |
Name of this Discovery instance. | |
const std::string & | af () const |
Address family represented by this Discovery instance. | |
const std::string & | to_addr () const |
Outbound address of advertisements sent by this Discovery instance. | |
const std::string & | local_addr () const |
Local address on which to listen for advertisements. | |
void | dump (oasys::StringBuffer *buf) |
Append snapshot of object state to StringBuffer. | |
virtual void | shutdown ()=0 |
Close down listening socket and stop the thread. | |
bool | announce (const char *name, int argc, const char *argv[]) |
Register an Announce to advertise a local convergence layer and to respond to advertisements from neighbors. | |
bool | remove (const char *name) |
Remove registration for named announce object. | |
void | handle_neighbor_discovered (const std::string &cl_type, const std::string &cl_addr, const EndpointID &remote_eid) |
Handle neighbor discovery out to registered DiscoveryInfo objects. | |
virtual | ~Discovery () |
Static Public Member Functions | |
static Discovery * | create_discovery (const std::string &name, const std::string &afname, int argc, const char *argv[], const char **error) |
Factory method for instantiating objects from the appropriate derived class. | |
Protected Types | |
typedef std::list< Announce * > | List |
typedef std::list< Announce * > ::iterator | iterator |
Protected Member Functions | |
Discovery (const std::string &name, const std::string &af) | |
Constructor. | |
virtual bool | configure (int argc, const char *argv[])=0 |
Configure this Discovery instance. | |
virtual void | handle_announce () |
Optional handler for new Announce registration. | |
bool | find (const char *name, iterator *iter) |
Find a registration by name. | |
Protected Attributes | |
std::string | name_ |
name of discovery agent | |
std::string | af_ |
address family | |
std::string | to_addr_ |
outbound address of advertisements sent | |
std::string | local_ |
address of beacon listener | |
List | list_ |
registered Announce objects | |
Private Member Functions | |
Discovery (const Discovery &) |
typedef std::list<Announce*> dtn::Discovery::List [protected] |
Definition at line 105 of file Discovery.h.
typedef std::list<Announce*>::iterator dtn::Discovery::iterator [protected] |
Definition at line 106 of file Discovery.h.
dtn::Discovery::~Discovery | ( | ) | [virtual] |
dtn::Discovery::Discovery | ( | const std::string & | name, | |
const std::string & | af | |||
) | [protected] |
dtn::Discovery::Discovery | ( | const Discovery & | ) | [inline, private] |
Definition at line 135 of file Discovery.h.
const std::string& dtn::Discovery::name | ( | ) | const [inline] |
Name of this Discovery instance.
Definition at line 49 of file Discovery.h.
References name_.
Referenced by dtn::DiscoveryTable::find().
const std::string& dtn::Discovery::af | ( | ) | const [inline] |
Address family represented by this Discovery instance.
Definition at line 54 of file Discovery.h.
References af_.
const std::string& dtn::Discovery::to_addr | ( | ) | const [inline] |
Outbound address of advertisements sent by this Discovery instance.
Definition at line 59 of file Discovery.h.
References to_addr_.
const std::string& dtn::Discovery::local_addr | ( | ) | const [inline] |
Local address on which to listen for advertisements.
Definition at line 64 of file Discovery.h.
References local_.
Discovery * dtn::Discovery::create_discovery | ( | const std::string & | name, | |
const std::string & | afname, | |||
int | argc, | |||
const char * | argv[], | |||
const char ** | error | |||
) | [static] |
Factory method for instantiating objects from the appropriate derived class.
Definition at line 43 of file Discovery.cc.
References configure().
Referenced by dtn::DiscoveryTable::add().
void dtn::Discovery::dump | ( | oasys::StringBuffer * | buf | ) |
Append snapshot of object state to StringBuffer.
Definition at line 92 of file Discovery.cc.
References af_, list_, name_, and to_addr_.
Referenced by dtn::DiscoveryTable::dump().
virtual void dtn::Discovery::shutdown | ( | ) | [pure virtual] |
Close down listening socket and stop the thread.
Derived classes should NOT auto-delete.
Implemented in dtn::IPDiscovery.
Referenced by dtn::DiscoveryTable::del(), and dtn::DiscoveryTable::shutdown().
bool dtn::Discovery::announce | ( | const char * | name, | |
int | argc, | |||
const char * | argv[] | |||
) |
Register an Announce to advertise a local convergence layer and to respond to advertisements from neighbors.
Definition at line 108 of file Discovery.cc.
References dtn::Announce::create_announce(), find(), dtn::ConvergenceLayer::find_clayer(), handle_announce(), and list_.
Referenced by dtn::DiscoveryCommand::exec(), find(), remove(), and dtn::IPDiscovery::run().
bool dtn::Discovery::remove | ( | const char * | name | ) |
Remove registration for named announce object.
Definition at line 147 of file Discovery.cc.
References announce(), find(), and list_.
Referenced by dtn::DiscoveryCommand::exec().
void dtn::Discovery::handle_neighbor_discovered | ( | const std::string & | cl_type, | |
const std::string & | cl_addr, | |||
const EndpointID & | remote_eid | |||
) |
Handle neighbor discovery out to registered DiscoveryInfo objects.
Definition at line 181 of file Discovery.cc.
References ASSERT, dtn::Link::AVAILABLE, dtn::ContactEvent::DISCOVERY, dtn::ConvergenceLayer::find_clayer(), dtn::ContactManager::find_link_to(), dtn::ContactManager::new_opportunistic_link(), and dtn::BundleDaemon::post().
Referenced by dtn::IPDiscovery::run().
virtual bool dtn::Discovery::configure | ( | int | argc, | |
const char * | argv[] | |||
) | [protected, pure virtual] |
Configure this Discovery instance.
Implemented in dtn::IPDiscovery.
Referenced by create_discovery().
virtual void dtn::Discovery::handle_announce | ( | ) | [inline, protected, virtual] |
Optional handler for new Announce registration.
Reimplemented in dtn::IPDiscovery.
Definition at line 122 of file Discovery.h.
Referenced by announce().
bool dtn::Discovery::find | ( | const char * | name, | |
Discovery::iterator * | iter | |||
) | [protected] |
Find a registration by name.
Definition at line 165 of file Discovery.cc.
References announce(), list_, and dtn::Announce::name().
Referenced by announce(), and remove().
std::string dtn::Discovery::name_ [protected] |
std::string dtn::Discovery::af_ [protected] |
std::string dtn::Discovery::to_addr_ [protected] |
outbound address of advertisements sent
Definition at line 131 of file Discovery.h.
Referenced by dtn::IPDiscovery::configure(), dump(), and to_addr().
std::string dtn::Discovery::local_ [protected] |
address of beacon listener
Definition at line 132 of file Discovery.h.
Referenced by dtn::IPDiscovery::configure(), and local_addr().
List dtn::Discovery::list_ [protected] |
registered Announce objects
Definition at line 133 of file Discovery.h.
Referenced by announce(), dump(), find(), remove(), dtn::IPDiscovery::run(), and ~Discovery().