#include <Discovery.h>
Inheritance diagram for dtn::Discovery:
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) |
Distribute 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[]) |
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 DiscoveryInfo objects | |
Private Member Functions | |
Discovery (const Discovery &) |
typedef std::list<Announce*> dtn::Discovery::List [protected] |
Definition at line 104 of file Discovery.h.
typedef std::list<Announce*>::iterator dtn::Discovery::iterator [protected] |
Definition at line 105 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 134 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[] | |||
) | [static] |
Factory method for instantiating objects from the appropriate derived class.
Definition at line 40 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 80 of file Discovery.cc.
References af_, oasys::StringBuffer::appendf(), 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::BluetoothDiscovery, and dtn::IPDiscovery.
Referenced by dtn::DiscoveryTable::del().
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 95 of file Discovery.cc.
References dtn::Announce::create_announce(), find(), dtn::ConvergenceLayer::find_clayer(), handle_announce(), list_, and log_err.
Referenced by dtn::DiscoveryCommand::exec(), find(), remove(), dtn::IPDiscovery::run(), and dtn::BluetoothDiscovery::run().
bool dtn::Discovery::remove | ( | const char * | name | ) |
Remove registration for named announce object.
Definition at line 133 of file Discovery.cc.
References announce(), find(), list_, and log_err.
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 | |||
) |
Distribute neighbor discovery out to registered DiscoveryInfo objects.
Definition at line 150 of file Discovery.cc.
References list_.
Referenced by dtn::IPDiscovery::run(), and dtn::BluetoothDiscovery::run().
virtual bool dtn::Discovery::configure | ( | int | argc, | |
const char * | argv[] | |||
) | [protected, pure virtual] |
Configure this Discovery instance.
Implemented in dtn::BluetoothDiscovery, and 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 121 of file Discovery.h.
Referenced by announce().
Find a registration by name.
Definition at line 164 of file Discovery.cc.
References announce(), and list_.
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 130 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 131 of file Discovery.h.
Referenced by dtn::IPDiscovery::configure(), dtn::BluetoothDiscovery::configure(), and local_addr().
List dtn::Discovery::list_ [protected] |
registered DiscoveryInfo objects
Definition at line 132 of file Discovery.h.
Referenced by announce(), dump(), find(), handle_neighbor_discovered(), remove(), dtn::IPDiscovery::run(), dtn::BluetoothDiscovery::run(), and ~Discovery().