From 3f15752f73cca149e3fd8469ba61ce299374c6f0 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 7 Oct 2014 14:34:00 -0700 Subject: Add IPv4 address assignment to ffffffffffffffff test network. --- node/NetworkConfig.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'node/NetworkConfig.cpp') diff --git a/node/NetworkConfig.cpp b/node/NetworkConfig.cpp index f200ffc2..124171a7 100644 --- a/node/NetworkConfig.cpp +++ b/node/NetworkConfig.cpp @@ -25,6 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ +#include + #include "NetworkConfig.hpp" #include "Utils.hpp" @@ -51,6 +53,13 @@ SharedPtr NetworkConfig::createTestNetworkConfig(const Address &s nc->_name = "ZT_TEST_NETWORK"; nc->_description = "Built-in dummy test network"; + // Make up a V4 IP from 'self' in the 10.0.0.0/8 range -- no + // guarantee of uniqueness but collisions are unlikely. + uint32_t ip = (uint32_t)((self.toInt() & 0x00ffffff) | 0x0a000000); // 10.x.x.x + if ((ip & 0x000000ff) == 0x000000ff) ip ^= 0x00000001; // but not ending in .255 + if ((ip & 0x000000ff) == 0x00000000) ip ^= 0x00000001; // or .0 + nc->_staticIps.push_back(InetAddress(Utils::hton(ip),8)); + return nc; } -- cgit v1.2.3