From ee1dc16e8ffc5c5cc8f3b5da97cf2d01c7604ab7 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Thu, 10 Aug 2017 00:59:15 -0700 Subject: Added getRoutes() for libzt --- service/OneService.cpp | 26 ++++++-------------------- service/OneService.hpp | 3 +-- 2 files changed, 7 insertions(+), 22 deletions(-) (limited to 'service') diff --git a/service/OneService.cpp b/service/OneService.cpp index 27f2ef3c..ab3b8d73 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -925,29 +925,15 @@ public: return _homePath; } - virtual EthernetTap * getTap(uint64_t nwid) + std::vector *getRoutes(uint64_t nwid) { Mutex::Lock _l(_nets_m); - std::map::const_iterator n(_nets.find(nwid)); - if (n == _nets.end()) - return NULL; - return n->second.tap; - } - - virtual EthernetTap *getTap(InetAddress &addr) - { - Mutex::Lock _l(_nets_m); - std::map::iterator it; - for(it = _nets.begin(); it != _nets.end(); it++) { - if(it->second.tap) { - for(int j=0; jsecond.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; - } - } - } + NetworkState &n = _nets[nwid]; + std::vector *routes = new std::vector(); + for(int i=0; ipush_back(n.config.routes[i]); } - return NULL; + return routes; } virtual Node *getNode() diff --git a/service/OneService.hpp b/service/OneService.hpp index eba10ca0..0d37ec63 100644 --- a/service/OneService.hpp +++ b/service/OneService.hpp @@ -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 *getRoutes(uint64_t nwid) = 0; #endif /** -- cgit v1.2.3