summaryrefslogtreecommitdiff
path: root/node/NetworkConfig.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-07 14:34:00 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-07 14:34:00 -0700
commit3f15752f73cca149e3fd8469ba61ce299374c6f0 (patch)
treeba43bd70c6ce6dc80952da0432a0cec86abdec90 /node/NetworkConfig.cpp
parentcb6fd3afb3cb894f506989e3fe013d1adff54f5a (diff)
downloadinfinitytier-3f15752f73cca149e3fd8469ba61ce299374c6f0.tar.gz
infinitytier-3f15752f73cca149e3fd8469ba61ce299374c6f0.zip
Add IPv4 address assignment to ffffffffffffffff test network.
Diffstat (limited to 'node/NetworkConfig.cpp')
-rw-r--r--node/NetworkConfig.cpp9
1 files changed, 9 insertions, 0 deletions
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 <stdint.h>
+
#include "NetworkConfig.hpp"
#include "Utils.hpp"
@@ -51,6 +53,13 @@ SharedPtr<NetworkConfig> 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;
}