35 using namespace dtn::core;
41 DiscoveryAgent::DiscoveryAgent()
42 : _config(dtn::daemon::Configuration::getInstance().getDiscovery()),
43 _enabled(true), _sn(0), _adv_next(0), _last_announce_sent(0)
53 return "DiscoveryAgent";
62 if (_config.announce() && (_adv_next <= ts)) {
69 }
catch (
const std::bad_cast&) {
83 }
catch (
const std::bad_cast&) {
109 handler_list &list = _providers[iface];
110 list.push_back(handler);
116 handler_list &list = _providers[_any_iface];
117 list.push_back(handler);
125 for (handler_map::iterator it_p = _providers.begin(); it_p != _providers.end();)
127 handler_list &list = (*it_p).second;
129 for (handler_list::iterator it = list.begin(); it != list.end(); ++it) {
130 if ((*it) == handler) {
137 _providers.erase(it_p++);
146 if (_providers.find(iface) == _providers.end())
return;
148 handler_list &list = _providers[iface];
150 for (handler_list::iterator it = list.begin(); it != list.end(); ++it) {
151 if ((*it) == handler) {
153 if (list.empty()) _providers.erase(iface);
192 const std::list<DiscoveryService> &services = beacon.
getServices();
194 for (std::list<DiscoveryService>::const_iterator iter = services.begin(); iter != services.end(); ++iter)
209 to_value_mailcl = configTime;
232 if (_last_announce_sent != ts)
240 _last_announce_sent = ts;
245 void DiscoveryAgent::onAdvertise()
248 if (!_enabled)
return;
273 beacon.setSequencenumber(_sn);
278 const handler_list &any_list = _providers[_any_iface];
280 for (handler_map::const_iterator it_p = _providers.begin(); it_p != _providers.end(); ++it_p)
283 const handler_list &plist = (*it_p).second;
286 beacon.clearServices();
291 for (handler_list::const_iterator iter = plist.begin(); iter != plist.end(); ++iter)
304 if (iface != _any_iface)
306 for (handler_list::const_iterator iter = any_list.begin(); iter != any_list.end(); ++iter)
321 for (handler_list::const_iterator iter = plist.begin(); iter != plist.end(); ++iter)