From c0639ccd37d9904ad0411a38f0a38f5d7d329f1e Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 16 Aug 2016 16:46:08 -0700 Subject: Just about ready to test. --- controller/SqliteNetworkController.hpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'controller/SqliteNetworkController.hpp') diff --git a/controller/SqliteNetworkController.hpp b/controller/SqliteNetworkController.hpp index 15e0968f..288ea23a 100644 --- a/controller/SqliteNetworkController.hpp +++ b/controller/SqliteNetworkController.hpp @@ -24,12 +24,14 @@ #include #include #include +#include #include "../node/Constants.hpp" #include "../node/NetworkController.hpp" #include "../node/Mutex.hpp" #include "../node/Utils.hpp" +#include "../node/InetAddress.hpp" #include "../osdep/OSUtils.hpp" @@ -76,14 +78,6 @@ public: std::string &responseContentType); private: - unsigned int _doCPGet( - const std::vector &path, - const std::map &urlArgs, - const std::map &headers, - const std::string &body, - std::string &responseBody, - std::string &responseContentType); - static void _circuitTestCallback(ZT_Node *node,ZT_CircuitTest *test,const ZT_CircuitTestReport *report); inline nlohmann::json _readJson(const std::string &path) @@ -134,6 +128,28 @@ private: return (_memberBP(nwid,member,create) + ZT_PATH_SEPARATOR + "config.json"); } + inline std::set _getAlreadyAllocatedIps(const uint64_t nwid) + { + std::set ips; + std::string bp(_networkBP(nwid,false) + ZT_PATH_SEPARATOR_S + "member"); + std::vector members(OSUtils::listSubdirectories(bp.c_str())); + for(std::vector::iterator m(members.begin());m!=members.end();++m) { + if (m->length() == ZT_ADDRESS_LENGTH_HEX) { + nlohmann::json mj = _readJson(bp + ZT_PATH_SEPARATOR_S + *m + ZT_PATH_SEPARATOR_S + "config.json"); + auto ipAssignments = mj["ipAssignments"]; + if (ipAssignments.is_array()) { + for(unsigned long i=0;i