Added getRoutes() for libzt

This commit is contained in:
Joseph Henry 2017-08-10 00:59:15 -07:00
parent 1c04cc0485
commit ee1dc16e8f
2 changed files with 7 additions and 22 deletions

View File

@ -925,29 +925,15 @@ public:
return _homePath;
}
virtual EthernetTap * getTap(uint64_t nwid)
std::vector<ZT_VirtualNetworkRoute> *getRoutes(uint64_t nwid)
{
Mutex::Lock _l(_nets_m);
std::map<uint64_t,NetworkState>::const_iterator n(_nets.find(nwid));
if (n == _nets.end())
return NULL;
return n->second.tap;
NetworkState &n = _nets[nwid];
std::vector<ZT_VirtualNetworkRoute> *routes = new std::vector<ZT_VirtualNetworkRoute>();
for(int i=0; i<ZT_MAX_NETWORK_ROUTES; i++) {
routes->push_back(n.config.routes[i]);
}
virtual EthernetTap *getTap(InetAddress &addr)
{
Mutex::Lock _l(_nets_m);
std::map<uint64_t,NetworkState>::iterator it;
for(it = _nets.begin(); it != _nets.end(); it++) {
if(it->second.tap) {
for(int j=0; j<it->second.tap->_ips.size(); j++) {
if(it->second.tap->_ips[j].isEqualPrefix(addr) || it->second.tap->_ips[j].ipsEqual(addr) || it->second.tap->_ips[j].containsAddress(addr)) {
return it->second.tap;
}
}
}
}
return NULL;
return routes;
}
virtual Node *getNode()

View File

@ -150,10 +150,9 @@ public:
virtual void leave(const char *hp) = 0;
virtual void join(const char *hp) = 0;
virtual std::string givenHomePath() = 0;
virtual EthernetTap * getTap(uint64_t nwid) = 0;
virtual EthernetTap * getTap(InetAddress &addr) = 0;
virtual Node * getNode() = 0;
virtual void removeNets() = 0;
virtual std::vector<ZT_VirtualNetworkRoute> *getRoutes(uint64_t nwid) = 0;
#endif
/**