44 using namespace dtn::core;
50 struct CompareNodeDestination:
51 public std::binary_function< dtn::core::Node, dtn::data::EID, bool > {
53 return node.
getEID() == destination;
57 ConnectionManager::ConnectionManager()
58 : _next_autoconnect(0)
96 _next_autoconnect = 0;
128 }
catch (
const std::bad_cast&) { }
139 }
catch (
const std::bad_cast&) { }
144 switch (connection.
state)
148 add(connection.
node);
154 remove(connection.
node);
162 }
catch (
const std::bad_cast&) { }
167 case GlobalEvent::GLOBAL_INTERNET_AVAILABLE:
171 case GlobalEvent::GLOBAL_INTERNET_UNAVAILABLE:
178 }
catch (
const std::bad_cast&) { };
184 pair<nodemap::iterator,bool> ret = _nodes.insert( pair<dtn::data::EID, dtn::core::Node>(n.
getEID(), n) );
194 if (old != db.
size()) {
221 if (old != db.
size()) {
247 for (std::set<ConvergenceLayer*>::const_iterator iter = _cl.begin(); iter != _cl.end(); ++iter)
255 entry.second = cl_stats;
257 stats.push_back(entry);
266 for (std::set<ConvergenceLayer*>::iterator iter = _cl.begin(); iter != _cl.end(); ++iter)
276 _dialups.insert(ext);
294 void ConnectionManager::check_available()
299 for (nodemap::iterator iter = _nodes.begin(); iter != _nodes.end(); ++iter)
313 void ConnectionManager::check_unavailable()
318 nodemap::iterator iter = _nodes.begin();
319 while ( iter != _nodes.end() )
342 _nodes.erase( iter++ );
351 void ConnectionManager::check_autoconnect()
353 std::queue<dtn::core::Node> _connect_nodes;
356 if (interval == 0)
return;
362 for (nodemap::const_iterator iter = _nodes.begin(); iter != _nodes.end(); ++iter)
364 const Node &n = (*iter).second;
365 std::list<Node::URI> ul = n.
get(Node::NODE_CONNECTED, Node::CONN_TCPIP);
369 _connect_nodes.push(n);
377 while (!_connect_nodes.empty())
380 open(_connect_nodes.front());
384 _connect_nodes.pop();
393 for (std::set<ConvergenceLayer*>::iterator iter = _cl.begin(); iter != _cl.end(); ++iter)
406 if (node.hasDialup())
423 std::list<Node::URI> uri_list = n.
get(Node::NODE_P2P_DIALUP);
426 for (std::list<Node::URI>::const_iterator it = uri_list.begin(); it != uri_list.end(); ++it)
431 for (std::set<P2PDialupExtension*>::iterator iter = _dialups.begin(); iter != _dialups.end(); ++iter)
448 std::list<Node::URI> uri_list = node.
getAll();
451 for (std::list<Node::URI>::const_iterator it = uri_list.begin(); it != uri_list.end(); ++it)
456 for (std::set<ConvergenceLayer*>::iterator iter = _cl.begin(); iter != _cl.end(); ++iter)
461 cl->
queue(node, job);
482 for (nodemap::const_iterator iter = _nodes.begin(); iter != _nodes.end(); ++iter)
510 std::set<dtn::core::Node> ret;
512 for (nodemap::const_iterator iter = _nodes.begin(); iter != _nodes.end(); ++iter)
514 const Node &n = (*iter).second;
524 const Node &n = getNode(eid);
548 return "ConnectionManager";
553 nodemap::iterator iter = _nodes.find(eid);
555 return (*iter).second;