49 :
DiscoveryAgent(dtn::daemon::Configuration::getInstance().getDiscovery()),
80 _destinations.insert(address);
91 if (_interfaces.find(net) != _interfaces.end())
return;
94 _interfaces.insert(net);
101 for (std::set<ibrcommon::vaddress>::const_iterator it_addr = _destinations.begin(); it_addr != _destinations.end(); ++it_addr)
104 msock.
leave(*it_addr, iface);
106 if (e.
error() != EADDRNOTAVAIL) {
121 for (std::set<ibrcommon::vaddress>::const_iterator it_addr = _destinations.begin(); it_addr != _destinations.end(); ++it_addr)
124 msock.
join(*it_addr, iface);
126 if (e.
error() != EADDRINUSE) {
138 stringstream ss; ss << a;
139 const std::string data = ss.str();
145 for (ibrcommon::socketset::const_iterator iter = fds.begin(); iter != fds.end(); ++iter)
154 sock.
sendto(data.c_str(), data.length(), 0, addr);
160 }
catch (
const std::bad_cast&) {
175 for (std::set<ibrcommon::vinterface>::const_iterator it_iface = _interfaces.begin(); it_iface != _interfaces.end(); ++it_iface)
185 for (std::list<DiscoveryServiceProvider*>::iterator iter = providers.begin(); iter != providers.end(); ++iter)
191 provider.
update(iface, announcement);
198 for (std::set<ibrcommon::vaddress>::iterator iter = _destinations.begin(); iter != _destinations.end(); ++iter) {
199 send(announcement, iface, (*iter));
207 std::list<ibrcommon::vaddress> addrs = iface.
getAddresses();
209 for (std::list<ibrcommon::vaddress>::iterator iter = addrs.begin(); iter != addrs.end(); ++iter) {
219 if (_send_socket_state) sock->
up();
220 _send_socket.add(sock, iface);
237 for (ibrcommon::socketset::iterator iter = socks.begin(); iter != socks.end(); ++iter) {
239 _send_socket.remove(sock);
263 if (_interfaces.find(dialup.
iface) != _interfaces.end())
break;
266 _interfaces.insert(dialup.
iface);
273 listen(dialup.
iface);
276 join_interface(dialup.
iface);
287 if (_interfaces.find(dialup.
iface) == _interfaces.end())
break;
290 _interfaces.erase(dialup.
iface);
297 leave_interface(dialup.
iface);
300 unlisten(dialup.
iface);
304 }
catch (std::bad_cast&) {
314 if (_interfaces.find(evt.
getInterface()) == _interfaces.end())
return;
336 for (ibrcommon::socketset::iterator iter = socks.begin(); iter != socks.end(); ++iter) {
340 if (socks.size() == 1) {
344 _send_socket.
remove(sock);
383 for (std::set<ibrcommon::vinterface>::const_iterator it_iface = _interfaces.begin(); it_iface != _interfaces.end(); ++it_iface)
394 join_interface(iface);
396 }
catch (std::bad_cast&) {
405 _send_socket_state =
true;
426 _send_socket_state =
false;
452 _recv_socket.
select(&fds, NULL, NULL, &tv);
455 for (ibrcommon::socketset::const_iterator iter = fds.begin(); iter != fds.end(); ++iter)
463 std::list<DiscoveryService> ret_services;
466 ssize_t len = sock.
recvfrom(data, 1500, 0, sender);
476 if (announce.isShort())
483 ret_source = announce.getEID();
487 const std::list<DiscoveryService> &services = announce.getServices();
489 if (services.empty() && announce.isShort())
495 for (std::list<DiscoveryService>::const_iterator iter = services.begin(); iter != services.end(); ++iter) {
499 if ( (service.
getParameters().find(
"port=") != std::string::npos) &&
500 (service.
getParameters().find(
"ip=") == std::string::npos) ) {
505 ret_services.push_back(ret_service);
510 ret_services.push_back(service);