summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-03-18 16:10:48 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-03-18 16:10:48 -0700
commita8a92c5b89b51f6786d6e5cb41a588197b6afabb (patch)
tree9004ad82f5660f889635e5ccf5ede58be0f4922d /node
parentcea3f2815589f956f699ad589a66c9d09f406ee9 (diff)
downloadinfinitytier-a8a92c5b89b51f6786d6e5cb41a588197b6afabb.tar.gz
infinitytier-a8a92c5b89b51f6786d6e5cb41a588197b6afabb.zip
A whole lot of Sqlite netconf master work, and some fixes elsewhere in the code.
Diffstat (limited to 'node')
-rw-r--r--node/Identity.cpp3
-rw-r--r--node/MulticastGroup.hpp2
-rw-r--r--node/NetworkConfig.cpp2
-rw-r--r--node/NetworkConfig.hpp3
-rw-r--r--node/NetworkConfigMaster.hpp6
5 files changed, 12 insertions, 4 deletions
diff --git a/node/Identity.cpp b/node/Identity.cpp
index 6c843cc2..8765da51 100644
--- a/node/Identity.cpp
+++ b/node/Identity.cpp
@@ -155,6 +155,9 @@ std::string Identity::toString(bool includePrivate) const
bool Identity::fromString(const char *str)
{
+ if (!str)
+ return false;
+
char *saveptr = (char *)0;
char tmp[4096];
if (!Utils::scopy(tmp,sizeof(tmp),str))
diff --git a/node/MulticastGroup.hpp b/node/MulticastGroup.hpp
index bef17a44..85855438 100644
--- a/node/MulticastGroup.hpp
+++ b/node/MulticastGroup.hpp
@@ -111,7 +111,7 @@ public:
inline std::string toString() const
{
char buf[64];
- Utils::snprintf(buf,sizeof(buf),"%.2x%.2x%.2x%.2x%.2x%.2x/%lx",(unsigned int)_mac[0],(unsigned int)_mac[1],(unsigned int)_mac[2],(unsigned int)_mac[3],(unsigned int)_mac[4],(unsigned int)_mac[5],(unsigned long)_adi);
+ Utils::snprintf(buf,sizeof(buf),"%.2x%.2x%.2x%.2x%.2x%.2x/%.4x",(unsigned int)_mac[0],(unsigned int)_mac[1],(unsigned int)_mac[2],(unsigned int)_mac[3],(unsigned int)_mac[4],(unsigned int)_mac[5],(unsigned int)_adi);
return std::string(buf);
}
diff --git a/node/NetworkConfig.cpp b/node/NetworkConfig.cpp
index 98e1b0d8..e42b0299 100644
--- a/node/NetworkConfig.cpp
+++ b/node/NetworkConfig.cpp
@@ -44,6 +44,7 @@ SharedPtr<NetworkConfig> NetworkConfig::createTestNetworkConfig(const Address &s
nc->_etWhitelist[0] |= 1; // allow all
nc->_nwid = ZT_TEST_NETWORK_ID;
nc->_timestamp = Utils::now();
+ nc->_revision = 1;
nc->_issuedTo = self;
nc->_multicastLimit = ZT_MULTICAST_DEFAULT_LIMIT;
nc->_allowPassiveBridging = false;
@@ -108,6 +109,7 @@ void NetworkConfig::_fromDictionary(const Dictionary &d)
throw std::invalid_argument("configuration contains zero network ID");
_timestamp = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP).c_str());
+ _revision = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_REVISION,"1").c_str()); // older netconf masters don't send this, so default to 1
memset(_etWhitelist,0,sizeof(_etWhitelist));
std::vector<std::string> ets(Utils::split(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOWED_ETHERNET_TYPES).c_str(),",","",""));
diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp
index 4b998ea1..0aa7a70d 100644
--- a/node/NetworkConfig.hpp
+++ b/node/NetworkConfig.hpp
@@ -52,6 +52,7 @@ namespace ZeroTier {
#define ZT_NETWORKCONFIG_DICT_KEY_ALLOWED_ETHERNET_TYPES "et"
#define ZT_NETWORKCONFIG_DICT_KEY_NETWORK_ID "nwid"
#define ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP "ts"
+#define ZT_NETWORKCONFIG_DICT_KEY_REVISION "r"
#define ZT_NETWORKCONFIG_DICT_KEY_ISSUED_TO "id"
#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_LIMIT "ml"
#define ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_RATES "mr"
@@ -134,6 +135,7 @@ public:
inline uint64_t networkId() const throw() { return _nwid; }
inline uint64_t timestamp() const throw() { return _timestamp; }
+ inline uint64_t revision() const throw() { return _revision; }
inline const Address &issuedTo() const throw() { return _issuedTo; }
inline unsigned int multicastLimit() const throw() { return _multicastLimit; }
inline const std::map<MulticastGroup,MulticastRate> &multicastRates() const throw() { return _multicastRates; }
@@ -174,6 +176,7 @@ private:
uint64_t _nwid;
uint64_t _timestamp;
+ uint64_t _revision;
unsigned char _etWhitelist[65536 / 8];
Address _issuedTo;
unsigned int _multicastLimit;
diff --git a/node/NetworkConfigMaster.hpp b/node/NetworkConfigMaster.hpp
index 12a926fa..06a4e56c 100644
--- a/node/NetworkConfigMaster.hpp
+++ b/node/NetworkConfigMaster.hpp
@@ -75,17 +75,17 @@ public:
* @param member Originating peer ZeroTier identity
* @param nwid 64-bit network ID
* @param metaData Meta-data bundled with request (empty if none)
- * @param haveTimestamp Timestamp sent by requesting peer or 0 if none
+ * @param haveRevision Network revision ID sent by requesting peer or 0 if none
* @param result Dictionary to receive resulting signed netconf on success
* @return Returns NETCONF_QUERY_OK if result dictionary is valid, or an error code on error
*/
virtual NetworkConfigMaster::ResultCode doNetworkConfigRequest(
const InetAddress &fromAddr,
uint64_t packetId,
- const Identity &member,
+ const Identity &identity,
uint64_t nwid,
const Dictionary &metaData,
- uint64_t haveTimestamp,
+ uint64_t haveRevision,
Dictionary &result) = 0;
};